This is an automated email from the ASF dual-hosted git repository. andytaylor pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-artemis-console.git
commit 4dd762cd585b041688bd38132836c17a5a935dce Author: Grzegorz Grzybek <[email protected]> AuthorDate: Wed Apr 23 13:15:43 2025 +0200 ARTEMIS-5447 - Align dependencies with hawtio and tweak config files (tsup and webpack) --- .gitignore | 2 + .../.yarn/releases/LICENSE-yarn.txt | 143 --------------------- .../artemis-extension/.yarnrc.yml | 2 +- artemis-console-extension/artemis-extension/DEV.md | 80 ++++++++++++ .../artemis-extension/app/package.json | 46 ++----- .../artemis-extension/app/src/bootstrap.tsx | 3 +- .../artemis-extension/app/tsconfig.json | 64 +++++---- .../artemis-extension/app/webpack.config.cjs | 87 +++++++++++-- .../artemis-extension/package.json | 17 ++- .../packages/artemis-console-plugin/package.json | 78 ++++------- .../src/addresses/AddressesTable.tsx | 2 +- .../src/addresses/DeleteAddress.tsx | 2 +- .../artemis-console-plugin/src/artemis-service.ts | 2 +- .../src/messages/MessagesTable.tsx | 4 +- .../src/table/ArtemisTable.tsx | 2 +- .../packages/artemis-console-plugin/src/types.d.ts | 1 + .../packages/artemis-console-plugin/tsconfig.json | 63 +++++---- .../packages/artemis-console-plugin/tsup.config.ts | 31 +++++ .../plugins/investigation-webpack-plugin/plugin.js | 44 +++++++ 19 files changed, 371 insertions(+), 302 deletions(-) diff --git a/.gitignore b/.gitignore index 50a04ee..99419e6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ .idea/ .vscode/ ratReport.txt +dist/ +build/ # generated by shade **/dependency-reduced-pom.xml diff --git a/artemis-console-extension/artemis-extension/.yarn/releases/LICENSE-yarn.txt b/artemis-console-extension/artemis-extension/.yarn/releases/LICENSE-yarn.txt deleted file mode 100644 index c45862e..0000000 --- a/artemis-console-extension/artemis-extension/.yarn/releases/LICENSE-yarn.txt +++ /dev/null @@ -1,143 +0,0 @@ -* - * Copyright (c) 2014-present, Jon Schlinkert. - * Licensed under the MIT License. - */ -/*! - * is-extglob <https://github.com/jonschlinkert/is-extglob> - * - * Copyright (c) 2014-2016, Jon Schlinkert. - * Licensed under the MIT License. - */ -/*! - * is-glob <https://github.com/jonschlinkert/is-glob> - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ -/*! - * is-number <https://github.com/jonschlinkert/is-number> - * - * Copyright (c) 2014-present, Jon Schlinkert. - * Released under the MIT License. - */ -/*! - * is-windows <https://github.com/jonschlinkert/is-windows> - * - * Copyright © 2015-2018, Jon Schlinkert. - * Released under the MIT License. - */ -/*! - * to-regex-range <https://github.com/micromatch/to-regex-range> - * - * Copyright (c) 2015-present, Jon Schlinkert. - * Released under the MIT License. - */ -/** - @license - Copyright (c) 2015, Rebecca Turner - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - */ -/** - @license - Copyright Joyent, Inc. and other Node contributors. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to permit - persons to whom the Software is furnished to do so, subject to the - following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -/** - @license - Copyright Node.js contributors. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. -*/ -/** - @license - The MIT License (MIT) - - Copyright (c) 2014 Blake Embrey ([email protected]) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ -/** @license React v0.18.0 - * scheduler.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/** @license React v0.24.0 - * react-reconciler.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/** @license React v16.13.1 - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ diff --git a/artemis-console-extension/artemis-extension/.yarnrc.yml b/artemis-console-extension/artemis-extension/.yarnrc.yml index f7cd521..55529e2 100644 --- a/artemis-console-extension/artemis-extension/.yarnrc.yml +++ b/artemis-console-extension/artemis-extension/.yarnrc.yml @@ -21,4 +21,4 @@ plugins: path: .yarn/plugins/@yarnpkg/plugin-licenses.cjs spec: "https://raw.githubusercontent.com/mhassan1/yarn-plugin-licenses/v0.15.0/bundles/@yarnpkg/plugin-licenses.js" -yarnPath: .yarn/releases/yarn-4.9.0.cjs +yarnPath: .yarn/releases/yarn-4.9.1.cjs diff --git a/artemis-console-extension/artemis-extension/DEV.md b/artemis-console-extension/artemis-extension/DEV.md new file mode 100644 index 0000000..f145bfe --- /dev/null +++ b/artemis-console-extension/artemis-extension/DEV.md @@ -0,0 +1,80 @@ +# Developer notes + +Artemis Console Extension is a Java Maven module that uses [Frontend Maven Plugin][1] which packages Javascript application as Maven module used later by [Apache Artemis][2]. + +Everything besides the `pom.xml` is a [Javascript monorepository][3] containing the following: + +* An Artemis Console itself - a Javascript application bundled using [Webpack][4] +* An Artemis Console plugin used by this console, but also published independently to [NPM][5], which can be consumed by other applications. This plugin is bundled using [tsup][6] which uses [esbuild][7] as actual bundler of TypeScript code and [Rollup][8] for TypeScript types generation. + +## Dependencies + +Artemis Console plugin (and application) depends on Hawtio because it is effectively a [Hawtio plugin][9]. That's why the most important dependency is: + + "@hawtio/react": "^1.9.0" + +To keep compatibility with Hawtio, versions of [Patternfly][10] and [React][11] packages should be aligned. + +To make it easier to maintain consistent dependencies between Hawtio (which can be treated as host for the plugins) and Artemis plugin (a plugin itself), the dependencies like Patternfly or React should be specified as peer dependencies here. + +## Javascript tooling + +It's worth following some guidelines in the fascinating world of JavaScript build tools. Personally I find this distinction very important: + +* _libraries_ - packages published to NPM registry and consumable by other packages/applications +* _applications_ - final deployables that use other packages which are not consumed further + +This separation determines the _bundlers_ that should be used to change original code into distributed code. + +When using _bundlers_ for libraries, we have to be careful, because the libraries package will be consumed by projects using own configurations and own bundlers. That's why we use [tsup][6] = [esbuild][7] + [Rollup][8] for this task. + +When using _bundlers_ for applications, we need to ensure that all dependencies are included (bundled) in most optimal way (chunking, tersing, ...). That's why we use [Webpack][4] for this task (which may be replaced by [Rspack][12] at some point). + +## Project structure + +We use [Javascript monorepository][3] for better separation of library and application code. + +Top level `package.json` declares `workspaces` field and _child_ `package.json` contain specific dependencies and scripts. Common dependencies are declared in parent `package.json`. + +## Yarn package manager management + +In the early days, developers were using `npm install -g` to install common JS tools available as NPM packages _globally_. This was the case with tools like Grunt, Gulp or Bower. + +Ideally though, we should avoid global dependencies, because these make projects location dependent and developers may struggle from environment differences. Here's a quick guide into clean JS development from the perspective of tools. + +1. The only global dependency should be (from the perspective of this project) `corepack`: +```console +$ npm list -g +/usr/local/lib +└── [email protected] +``` +2. `corepack` is documented [at Yarn page][13] and [at Node.js page][14] and is (as of April 2025) the recommended way to deal with Node package managers as Yarn. +3. Main purpose of `corepack` is to find nearest `package.json` file and its `packageManager` field and delegate the package management to project-specific package manager. +4. `corepack use yarn@latest` is the way to add `packageManager` field to your `package.json` and later, `yarn set version x.y.z` can be used to update this version +5. I found it really handy, clear and transparent to use this additional option: +```console +$ yarn set version 4.9.1 --yarn-path +➤ YN0000: Downloading https://repo.yarnpkg.com/4.9.1/packages/yarnpkg-cli/bin/yarn.js +➤ YN0000: Saving the new release in .yarn/releases/yarn-4.9.1.cjs +➤ YN0000: Done in 0s 448ms +``` + +With `yarn set version 4.9.1 --yarn-path`: +* `packageManager` field is updated with selected version +* `yarnPath` field in `.yarnrc.yml` is updated to point to _downloaded_ version of Yarn which should be stored in SCM - by default it's `.yarn/releases/yarn-4.9.1.cjs` (for version 4.9.1) + +---- +[1]: https://github.com/eirslett/frontend-maven-plugin +[2]: https://activemq.apache.org/components/artemis +[3]: https://yarnpkg.com/features/workspaces +[4]: https://webpack.js.org/ +[5]: https://www.npmjs.com/ +[6]: https://tsup.egoist.dev/ +[7]: https://github.com/evanw/esbuild +[8]: https://rollupjs.org/ +[9]: https://hawt.io/docs/plugins.html +[10]: https://v5-archive.patternfly.org/ +[11]: https://react.dev/ +[12]: https://rspack.dev/ +[13]: https://yarnpkg.com/corepack +[14]: https://github.com/nodejs/corepack diff --git a/artemis-console-extension/artemis-extension/app/package.json b/artemis-console-extension/artemis-extension/app/package.json index 51c418b..2935141 100644 --- a/artemis-console-extension/artemis-extension/app/package.json +++ b/artemis-console-extension/artemis-extension/app/package.json @@ -1,29 +1,28 @@ { - "name": "artemis-console", + "name": "artemis-console-app", "version": "1.1.0", "description": "Artemis Console", - "main": "./src/main/webapp/app/artemis-console.js", "license": "Apache-2.0", "private": true, "scripts": { "start": "webpack serve --mode development", "build": "webpack --mode production && yarn replace-version", - "test": "craco test", - "replace-version": "replace __PACKAGE_VERSION_PLACEHOLDER__ $npm_package_version ./build/static/js -r --include=\"*.js\"", - "license": "yarn licenses generate-disclaimer -R > ../../artemis-console-distribution/src/main/resources/licenses/licenses/NPMLicenses.txt" + "replace-version": "replace __PACKAGE_VERSION_PLACEHOLDER__ $npm_package_version ./build/static/js -r --include=\"*.js\"" }, "dependencies": { - "@hawtio/react": "1.9.0", + "@hawtio/react": "1.9.2", "@patternfly/react-charts": "~7.4.9", "@patternfly/react-core": "~5.4.14", - "@patternfly/react-icons": "~5.3.2", + "@patternfly/react-icons": "~5.4.2", + "@patternfly/react-styles": "~5.4.1", "@patternfly/react-table": "~5.4.16", - "@patternfly/react-topology": "~5.4.1", + "@patternfly/react-tokens": "~5.4.1", + "@patternfly/react-topology": "~5.3.0", + "artemis-console-plugin": "1.1.0", "d3": "^7.8.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-router-dom": "^6.27.0", - "react-scripts": "^5.0.1" + "react-router-dom": "^6.30.0" }, "devDependencies": { "@craco/craco": "^7.1.0", @@ -44,31 +43,9 @@ "terser-webpack-plugin": "^5.3.10", "webpack": "^5.95.0", "webpack-cli": "^5.1.4", + "webpack-dev-server": "4.13.1", "webpack-manifest-plugin": "^5.0.0" }, - "resolutions": { - "axios": "1.8.2", - "@typescript-eslint/eslint-plugin": "6.9.0", - "@typescript-eslint/parser": "6.9.0", - "d3-color": "3.1.0", - "nth-check": "2.0.1", - "tough-cookie": "4.1.3", - "semver": "7.5.2", - "word-wrap": "1.2.4", - "postcss": "8.4.31", - "ws": "8.18.0", - "braces": "3.0.3", - "express": "4.21.0", - "webpack": "5.95.0", - "cookie": "0.7.0", - "micromatch": "4.0.8", - "rollup": "2.79.2", - "http-proxy-middleware": "2.0.7", - "cross-spawn": "7.0.5", - "nanoid": "3.3.8", - "path-to-regexp": "0.1.12", - "serialize-javascript": "6.0.2" - }, "eslintConfig": { "extends": [ "react-app", @@ -86,6 +63,5 @@ "last 1 firefox version", "last 1 safari version" ] - }, - "packageManager": "[email protected]" + } } diff --git a/artemis-console-extension/artemis-extension/app/src/bootstrap.tsx b/artemis-console-extension/artemis-extension/app/src/bootstrap.tsx index f18d0ab..81d62ab 100644 --- a/artemis-console-extension/artemis-extension/app/src/bootstrap.tsx +++ b/artemis-console-extension/artemis-extension/app/src/bootstrap.tsx @@ -17,7 +17,8 @@ import { hawtio, Hawtio, connect, jmx, keycloak, oidc, rbac, runtime, configManager } from '@hawtio/react' import React from 'react' import ReactDOM from 'react-dom/client' -import { artemis } from './artemis-extension/artemis'; +import { artemis } from 'artemis-console-plugin'; +import 'artemis-console-plugin/styles'; // Register builtin plugins diff --git a/artemis-console-extension/artemis-extension/app/tsconfig.json b/artemis-console-extension/artemis-extension/app/tsconfig.json index 2e72ec9..1a1b081 100644 --- a/artemis-console-extension/artemis-extension/app/tsconfig.json +++ b/artemis-console-extension/artemis-extension/app/tsconfig.json @@ -1,30 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "baseUrl": ".", - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "strictFunctionTypes": false, + /* Language and Environment */ + "target": "esnext", + "lib": [ "dom", "es2023" ], + "jsx": "react-jsx", + + /* Modules */ + "module": "esnext", + "moduleResolution": "bundler", + + /* JavaScript Support */ "allowJs": true, - "skipLibCheck": true, + + /* Emit */ + "declaration": true, + "declarationDir": "dist/dts", + "emitDeclarationOnly": true, + "noEmit": true, + + /* Interop Constraints */ + "isolatedModules": true, "esModuleInterop": true, - "allowSyntheticDefaultImports": true, + + /* Type Checking */ "strict": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" }, - "include": [ - "src" - ] + "include": [ "src" ] } diff --git a/artemis-console-extension/artemis-extension/app/webpack.config.cjs b/artemis-console-extension/artemis-extension/app/webpack.config.cjs index c20d265..d86cdbc 100644 --- a/artemis-console-extension/artemis-extension/app/webpack.config.cjs +++ b/artemis-console-extension/artemis-extension/app/webpack.config.cjs @@ -28,6 +28,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin') const outputPath = path.resolve(__dirname, 'build') +const InvestigationPlugin = require("../plugins/investigation-webpack-plugin/plugin") + module.exports = (webpackEnv, args) => { const isEnvDevelopment = args.mode === 'development'; const isEnvProduction = args.mode === 'production'; @@ -109,9 +111,9 @@ module.exports = (webpackEnv, args) => { name: 'artemisPlugin', filename: 'remoteEntry.js', // The key in exposes corresponds to 'remote' passed to HawtioPlugin - exposes: { - './plugin': './src/artemis-extension', - }, + // exposes: { + // './plugin': 'artemis-console-plugin', + // }, shared: { ...dependencies, 'react': { @@ -130,21 +132,22 @@ module.exports = (webpackEnv, args) => { singleton: true, requiredVersion: dependencies['@hawtio/react'], }, - }, - }) + } + }), + new InvestigationPlugin({}) ], entry: "./src/index.ts", output: { // Required for Module Federation publicPath: 'auto', path: outputPath, - // Add /* filename */ comments to generated require()s in the output. + // Add /* filename */ comments to generated require()s in the output. Use "verbose" for origin information. pathinfo: isEnvDevelopment, // There will be one main bundle, and one file per asynchronous chunk. // In development, it does not produce real files. filename: isEnvProduction ? 'static/js/[name].[contenthash:8].js' - : isEnvDevelopment && 'static/js/bundle.js', + : isEnvDevelopment && 'static/js/[name].bundle.js', // There are also additional JS chunk files if you use code splitting. chunkFilename: isEnvProduction ? 'static/js/[name].[contenthash:8].chunk.js' @@ -217,10 +220,10 @@ module.exports = (webpackEnv, args) => { extensions: ['.ts', '.tsx', '.js', '.cjs', '.jsx'], // To resolve errors for @module-federation/utilities 2.x // https://github.com/module-federation/universe/issues/827 - fallback: { - path: require.resolve('path-browserify'), - os: require.resolve('os-browserify'), - }, + // fallback: { + // path: require.resolve('path-browserify'), + // os: require.resolve('os-browserify'), + // }, }, optimization: { minimize: isEnvProduction, @@ -265,6 +268,64 @@ module.exports = (webpackEnv, args) => { // This is only used in production mode new CssMinimizerPlugin(), ], + splitChunks: { + chunks: 'all', + automaticNameDelimiter: '-', + cacheGroups: { + react: { + test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/, + name: 'react', + priority: 40, + enforce: true, + }, + patternfly: { + test: /[\\/]node_modules[\\/]@patternfly[\\/]/, + // name: 'patternfly', + name(module, chunks, cacheGroupKey) { + const allModules = module + .identifier() + .split('/') + .filter(Boolean); + + // Try to extract package name from node_modules + const nodeModulesIndex = allModules.indexOf('node_modules'); + if (nodeModulesIndex !== -1) { + const packageName = allModules[nodeModulesIndex + 1]; + if (packageName && packageName.startsWith('@')) { + // Scoped package (e.g., @patternfly/react-core) + return `${cacheGroupKey}-${packageName.replace('@', '').replace(/\//g, '-')}`; + } + return `${cacheGroupKey}-${packageName}`; + } + + // Default to the cache group key (e.g., react, patternfly, monaco) + return cacheGroupKey; + }, + priority: 30, + enforce: true, + }, + monaco: { + test: /[\\/]node_modules[\\/](monaco-editor)[\\/]/, + name: 'monaco', + priority: 25, + enforce: true, + }, + hawtio: { + test: /[\\/]node_modules[\\/]@hawtio[\\/]/, + name: 'hawtio', + priority: 20, + enforce: true, + }, + vendors: { + test: /[\\/]node_modules[\\/]/, + name: 'other', + priority: 10, + enforce: true, + reuseExistingChunk: true, + }, + }, + }, + runtimeChunk: 'single', }, devServer: { static: [ @@ -313,6 +374,10 @@ module.exports = (webpackEnv, args) => { login = false res.redirect('/console/login') }) + devServer.app.get('/console/auth/config/session-timeout', (_, res) => { + res.type('application/json') + res.send('{}') + }) devServer.app.get('/console/proxy/enabled', (_, res) => res.send(String(proxyEnabled))) devServer.app.get('/console/plugin', (_, res) => res.send(JSON.stringify(plugin))) diff --git a/artemis-console-extension/artemis-extension/package.json b/artemis-console-extension/artemis-extension/package.json index 90ce144..39a3010 100644 --- a/artemis-console-extension/artemis-extension/package.json +++ b/artemis-console-extension/artemis-extension/package.json @@ -1,15 +1,14 @@ { - "name": "artemis-console", - "version": "1.1.0", - "description": "Artemis Console", - "main": "./src/main/webapp/app/artemis-console.js", + "name": "artemis-console-monorepo", + "version": "0", + "description": "Artemis Console Monorepo", "license": "Apache-2.0", "private": true, + "workspaces": [ + "packages/*", + "app" + ], "scripts": { - "start": "webpack serve --mode development", - "build": "webpack --mode production && yarn replace-version", - "test": "craco test", - "replace-version": "replace __PACKAGE_VERSION_PLACEHOLDER__ $npm_package_version ./build/static/js -r --include=\"*.js\"", "license": "yarn licenses generate-disclaimer -R > ../../artemis-console-distribution/src/main/resources/licenses/licenses/NPMLicenses.txt" }, "dependencies": { @@ -92,5 +91,5 @@ "last 1 safari version" ] }, - "packageManager": "[email protected]" + "packageManager": "[email protected]" } diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/package.json b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/package.json index 51c418b..cfa752e 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/package.json +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/package.json @@ -1,29 +1,40 @@ { - "name": "artemis-console", + "name": "artemis-console-plugin", "version": "1.1.0", - "description": "Artemis Console", - "main": "./src/main/webapp/app/artemis-console.js", + "description": "Artemis Console Plugin for Hawtio", "license": "Apache-2.0", - "private": true, + "files": [ + "dist" + ], + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + }, + "./styles": "./dist/index.css", + "./dist/index.css": "./dist/index.css" + }, "scripts": { - "start": "webpack serve --mode development", - "build": "webpack --mode production && yarn replace-version", - "test": "craco test", - "replace-version": "replace __PACKAGE_VERSION_PLACEHOLDER__ $npm_package_version ./build/static/js -r --include=\"*.js\"", - "license": "yarn licenses generate-disclaimer -R > ../../artemis-console-distribution/src/main/resources/licenses/licenses/NPMLicenses.txt" + "build": "tsup --clean" }, "dependencies": { - "@hawtio/react": "1.9.0", + "@hawtio/react": "1.9.2", "@patternfly/react-charts": "~7.4.9", + "@patternfly/react-code-editor": "~5.4.18", "@patternfly/react-core": "~5.4.14", - "@patternfly/react-icons": "~5.3.2", + "@patternfly/react-icons": "~5.4.2", + "@patternfly/react-styles": "~5.4.1", "@patternfly/react-table": "~5.4.16", - "@patternfly/react-topology": "~5.4.1", + "@patternfly/react-tokens": "~5.4.1", + "@patternfly/react-topology": "~5.3.0", "d3": "^7.8.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-router-dom": "^6.27.0", - "react-scripts": "^5.0.1" + "react-router-dom": "^6.30.0", + "react-split": "~2.0.14", + "xml-formatter": "3.6.5" }, "devDependencies": { "@craco/craco": "^7.1.0", @@ -42,50 +53,15 @@ "style-loader": "^4.0.0", "swc-loader": "^0.2.6", "terser-webpack-plugin": "^5.3.10", + "tsup": "^8.4.0", "webpack": "^5.95.0", "webpack-cli": "^5.1.4", "webpack-manifest-plugin": "^5.0.0" }, - "resolutions": { - "axios": "1.8.2", - "@typescript-eslint/eslint-plugin": "6.9.0", - "@typescript-eslint/parser": "6.9.0", - "d3-color": "3.1.0", - "nth-check": "2.0.1", - "tough-cookie": "4.1.3", - "semver": "7.5.2", - "word-wrap": "1.2.4", - "postcss": "8.4.31", - "ws": "8.18.0", - "braces": "3.0.3", - "express": "4.21.0", - "webpack": "5.95.0", - "cookie": "0.7.0", - "micromatch": "4.0.8", - "rollup": "2.79.2", - "http-proxy-middleware": "2.0.7", - "cross-spawn": "7.0.5", - "nanoid": "3.3.8", - "path-to-regexp": "0.1.12", - "serialize-javascript": "6.0.2" - }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - }, - "packageManager": "[email protected]" + } } diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/AddressesTable.tsx b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/AddressesTable.tsx index 1e513ae..f0f3463 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/AddressesTable.tsx +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/AddressesTable.tsx @@ -19,7 +19,7 @@ import { ActiveSort, ArtemisTable, Column, Filter, ToolbarAction } from '../tabl import { Navigate } from '../views/ArtemisTabView.js'; import { artemisService } from '../artemis-service'; import { IAction } from '@patternfly/react-table'; -import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; +import { ExclamationCircleIcon } from '@patternfly/react-icons'; import { Button, Icon, Modal, ModalVariant, TextContent, Text } from '@patternfly/react-core'; import { CreateQueue } from '../queues/CreateQueue'; import { Attributes, eventService, Operations, workspace } from '@hawtio/react'; diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/DeleteAddress.tsx b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/DeleteAddress.tsx index de5a419..98354e7 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/DeleteAddress.tsx +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/addresses/DeleteAddress.tsx @@ -16,7 +16,7 @@ */ import { ActionGroup, Text, Button, Form, Icon, Modal, ModalVariant, TextContent, Title, Popover } from '@patternfly/react-core'; import React, { useState } from 'react' -import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; +import { ExclamationCircleIcon } from '@patternfly/react-icons'; import { eventService, workspace } from '@hawtio/react'; import { artemisService } from '../artemis-service'; import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons'; diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts index d49dc93..fa1a6b2 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts @@ -154,7 +154,7 @@ class ArtemisService { private async initBrokerObjectName(): Promise<string> { const config = await configManager.getArtemisconfig(); var search = await jolokiaService.search(config.jmx.domain + ":broker=*"); - return search[0] ? search[0] : ""; + return search && search[0] ? search[0] : ""; } diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/messages/MessagesTable.tsx b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/messages/MessagesTable.tsx index bf472d8..0e88c64 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/messages/MessagesTable.tsx +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/messages/MessagesTable.tsx @@ -18,8 +18,8 @@ import React, { useContext, useEffect, useState } from 'react' import { Column } from '../table/ArtemisTable'; import { artemisService } from '../artemis-service'; import { Toolbar, ToolbarContent, ToolbarItem, Text, SearchInput, Button, PaginationVariant, Pagination, DataList, DataListCell, DataListCheck, DataListItem, DataListItemCells, DataListItemRow, Modal, TextContent, Icon, ModalVariant } from '@patternfly/react-core'; -import { Thead, Tr, Th, Tbody, Td, ActionsColumn, IAction, Table, InnerScrollContainer } from '@patternfly/react-table'; -import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; +import { Thead, Tr, Th, Tbody, Td, ActionsColumn, IAction, Table } from '@patternfly/react-table'; +import { ExclamationCircleIcon } from '@patternfly/react-icons'; import { createQueueObjectName } from '../util/jmx'; import { Link } from 'react-router-dom'; import { eventService } from '@hawtio/react'; diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/table/ArtemisTable.tsx b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/table/ArtemisTable.tsx index 0784183..c775540 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/table/ArtemisTable.tsx +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/table/ArtemisTable.tsx @@ -39,7 +39,7 @@ import { MenuToggle, SelectList } from '@patternfly/react-core'; -import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon'; +import { SortAmountDownIcon } from '@patternfly/react-icons'; import { Thead, Tr, Th, Tbody, Td, IAction, ActionsColumn, Table, InnerScrollContainer } from '@patternfly/react-table'; import { artemisPreferencesService } from '../artemis-preferences-service'; import { diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/types.d.ts b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/types.d.ts new file mode 100644 index 0000000..5df5b15 --- /dev/null +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/types.d.ts @@ -0,0 +1 @@ +declare module "*.md" diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsconfig.json b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsconfig.json index 2e72ec9..6098df4 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsconfig.json +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsconfig.json @@ -1,30 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "baseUrl": ".", - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "strictFunctionTypes": false, + /* Language and Environment */ + "target": "esnext", + "lib": [ "dom", "es2023" ], + "jsx": "react-jsx", + + /* Modules */ + "module": "esnext", + "moduleResolution": "bundler", + + /* JavaScript Support */ "allowJs": true, - "skipLibCheck": true, + + /* Emit */ + "declaration": true, + "declarationDir": "dist/dts", + "emitDeclarationOnly": true, +// "noEmit": true, + + /* Interop Constraints */ + "isolatedModules": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, + + /* Type Checking */ "strict": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" }, - "include": [ - "src" - ] + "include": [ "src" ] } diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsup.config.ts b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsup.config.ts new file mode 100644 index 0000000..ed4a547 --- /dev/null +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/tsup.config.ts @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { defineConfig } from 'tsup' + +export default defineConfig({ + entry: ["src/index.ts"], + format: "cjs", + target: "esnext", + sourcemap: true, + dts: true, + loader: { + ".md": "text" + } +}) diff --git a/artemis-console-extension/artemis-extension/plugins/investigation-webpack-plugin/plugin.js b/artemis-console-extension/artemis-extension/plugins/investigation-webpack-plugin/plugin.js new file mode 100644 index 0000000..6c69d42 --- /dev/null +++ b/artemis-console-extension/artemis-extension/plugins/investigation-webpack-plugin/plugin.js @@ -0,0 +1,44 @@ +// noinspection JSUnusedGlobalSymbols + +const pluginName = "InvestigationPlugin" + +class InvestigationPlugin { + constructor(properties = {}) { + } + apply(compiler) { + // single compiler hooks just to install compilation hooks + // see https://webpack.js.org/api/compiler-hooks/#thiscompilation + compiler.hooks.thisCompilation.tap(pluginName, (compilation, params) => { + // various compilation hooks + // see https://webpack.js.org/api/compilation-hooks/ + compilation.hooks.moduleIds.tap(pluginName, (modules) => { + console.info("modules count:", modules.size) + }) + compilation.hooks.afterChunks.tap(pluginName, (chunks) => { + // The afterChunks hook is invoked following the creation of the chunks and module graph, and prior to their + // optimization. This hook provides an opportunity to examine, analyze, and modify the chunk graph if necessary. + for (const c of chunks) { + if (c && c.name) { + console.info("[afterChunks] original chunk:", c.name) + } + } + }) + compilation.hooks.afterOptimizeChunks.tap(pluginName, (chunks) => { + // Fired after chunk optimization has completed. + for (const c of chunks) { + if (c && c.name) { + console.info("[afterOptimizeChunks] optimized chunk:", c.name) + } + } + }) + compilation.hooks.afterOptimizeModules.tap(pluginName, (modules) => { + // Called after modules optimization has completed. + // for (const m of modules) { + // console.info("[afterOptimizeModules] module:", m.identifier()) + // } + }) + }) + } +} + +module.exports = InvestigationPlugin --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
