@backstage/cli 0.32.1 → 0.33.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/bin/backstage-cli-alpha +0 -0
  3. package/config/jest.js +5 -4
  4. package/dist/index.cjs.js +14 -29
  5. package/dist/lib/removed.cjs.js +1 -1
  6. package/dist/lib/run.cjs.js +7 -7
  7. package/dist/modules/{start → build}/commands/package/start/startFrontend.cjs.js +6 -6
  8. package/dist/modules/build/index.cjs.js +125 -27
  9. package/dist/modules/build/lib/bundler/config.cjs.js +2 -39
  10. package/dist/modules/config/commands/docs.cjs.js +18 -1
  11. package/dist/modules/config/index.cjs.js +101 -30
  12. package/dist/modules/create-github-app/index.cjs.js +21 -9
  13. package/dist/modules/info/index.cjs.js +23 -5
  14. package/dist/modules/lint/commands/repo/lint.cjs.js +13 -1
  15. package/dist/modules/lint/index.cjs.js +68 -29
  16. package/dist/modules/maintenance/index.cjs.js +80 -18
  17. package/dist/modules/migrate/index.cjs.js +96 -30
  18. package/dist/modules/new/index.cjs.js +57 -28
  19. package/dist/modules/test/index.cjs.js +46 -20
  20. package/dist/packages/backend-defaults/package.json.cjs.js +1 -1
  21. package/dist/packages/backend-plugin-api/package.json.cjs.js +1 -1
  22. package/dist/packages/backend-test-utils/package.json.cjs.js +1 -1
  23. package/dist/packages/catalog-client/package.json.cjs.js +1 -1
  24. package/dist/packages/cli/package.json.cjs.js +1 -1
  25. package/dist/packages/core-components/package.json.cjs.js +1 -1
  26. package/dist/packages/dev-utils/package.json.cjs.js +1 -1
  27. package/dist/packages/frontend-plugin-api/src/routing/describeParentCallSite.cjs.js +26 -0
  28. package/dist/packages/opaque-internal/src/OpaqueType.cjs.js +105 -0
  29. package/dist/plugins/auth-backend/package.json.cjs.js +1 -1
  30. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +1 -1
  31. package/dist/plugins/catalog-node/package.json.cjs.js +1 -1
  32. package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
  33. package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +1 -1
  34. package/dist/wiring/CliInitializer.cjs.js +124 -0
  35. package/dist/wiring/CommandGraph.cjs.js +71 -0
  36. package/dist/wiring/CommandRegistry.cjs.js +14 -0
  37. package/dist/wiring/factory.cjs.js +15 -0
  38. package/dist/wiring/types.cjs.js +11 -0
  39. package/package.json +28 -29
  40. package/templates/backend-plugin/package.json.hbs +2 -1
  41. package/templates/backend-plugin-module/package.json.hbs +2 -1
  42. package/templates/frontend-plugin/package.json.hbs +2 -1
  43. package/templates/plugin-common-library/package.json.hbs +2 -1
  44. package/templates/plugin-node-library/package.json.hbs +2 -1
  45. package/templates/plugin-web-library/package.json.hbs +2 -1
  46. package/templates/scaffolder-backend-module/package.json.hbs +2 -1
  47. package/templates/scaffolder-backend-module/src/actions/example.ts +6 -12
  48. package/dist/commands/index.cjs.js +0 -55
  49. package/dist/modules/config/commands/print.cjs.js +0 -53
  50. package/dist/modules/config/commands/validate.cjs.js +0 -19
  51. package/dist/modules/info/commands/info.cjs.js +0 -55
  52. package/dist/modules/start/index.cjs.js +0 -38
  53. /package/dist/modules/{start → build}/commands/package/start/command.cjs.js +0 -0
  54. /package/dist/modules/{start → build}/commands/package/start/index.cjs.js +0 -0
  55. /package/dist/modules/{start → build}/commands/package/start/resolveLinkedWorkspace.cjs.js +0 -0
  56. /package/dist/modules/{start → build}/commands/package/start/startBackend.cjs.js +0 -0
  57. /package/dist/modules/{start → build}/commands/package/start/startPackage.cjs.js +0 -0
  58. /package/dist/modules/{start → build}/commands/repo/start.cjs.js +0 -0
  59. /package/dist/modules/{start → build}/lib/ipc/IpcServer.cjs.js +0 -0
  60. /package/dist/modules/{start → build}/lib/ipc/ServerDataStore.cjs.js +0 -0
  61. /package/dist/modules/{start → build}/lib/runner/runBackend.cjs.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @backstage/cli
2
2
 
3
+ ## 0.33.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - eef0e83: Internal update to promote the modular CLI entrypoint to stable.
8
+
9
+ ### Patch Changes
10
+
11
+ - d07fe35: Added user feedback when opening config docs in browser. The command now clearly indicates what it's doing and provides fallback instructions if the browser fails to open.
12
+ - d6d63c7: Updating the scaffolder action boilerplate to use new `zod` schema
13
+ - e36e855: Added `backstage.pluginId` field in `package.json` to all default plugin package templates for the `new` command.
14
+ - Updated dependencies
15
+ - @backstage/catalog-model@1.7.4
16
+ - @backstage/cli-common@0.1.15
17
+ - @backstage/cli-node@0.2.13
18
+ - @backstage/config@1.3.2
19
+ - @backstage/config-loader@1.10.1
20
+ - @backstage/errors@1.2.7
21
+ - @backstage/eslint-plugin@0.1.10
22
+ - @backstage/integration@1.17.0
23
+ - @backstage/release-manifests@0.0.13
24
+ - @backstage/types@1.2.1
25
+
26
+ ## 0.32.2-next.0
27
+
28
+ ### Patch Changes
29
+
30
+ - ce70439: The `BACKSTAGE_CLI_EXPERIMENTAL_BUILD_CACHE` flag has been removed. Existing users are encouraged to switch to `EXPERIMENTAL_RSPACK` instead.
31
+ - 1d8f00b: Switched to using the `ModuleFederationPlugin` from `@module-federation/enhanced/rspack` for Rspack, rather than the built-in one.
32
+ - 2b9633f: The experimental `FORCE_REACT_DEVELOPMENT` flag has been removed.
33
+ - d8c4a54: Only use the caching Jest module loader for frontend packages in order to avoid breaking real ESM module imports.
34
+ - 1bab255: Internal refactor to combine alpha `build` and `start` modules.
35
+ - 713e957: fix: merge eslint reports when using json format
36
+ - Updated dependencies
37
+ - @backstage/catalog-model@1.7.4
38
+ - @backstage/cli-common@0.1.15
39
+ - @backstage/cli-node@0.2.13
40
+ - @backstage/config@1.3.2
41
+ - @backstage/config-loader@1.10.1
42
+ - @backstage/errors@1.2.7
43
+ - @backstage/eslint-plugin@0.1.10
44
+ - @backstage/integration@1.17.0
45
+ - @backstage/release-manifests@0.0.13
46
+ - @backstage/types@1.2.1
47
+
3
48
  ## 0.32.1
4
49
 
5
50
  ### Patch Changes
File without changes
package/config/jest.js CHANGED
@@ -212,6 +212,11 @@ function getRoleConfig(role, pkgJson) {
212
212
  if (FRONTEND_ROLES.includes(role)) {
213
213
  return {
214
214
  testEnvironment: require.resolve('jest-environment-jsdom'),
215
+ // The caching module loader is only used to speed up frontend tests,
216
+ // as it breaks real dynamic imports of ESM modules.
217
+ runtime: envOptions.oldTests
218
+ ? undefined
219
+ : require.resolve('./jestCachingModuleLoader'),
215
220
  transform,
216
221
  };
217
222
  }
@@ -257,10 +262,6 @@ async function getProjectConfig(targetPath, extraConfig, extraOptions) {
257
262
  // A bit more opinionated
258
263
  testMatch: [`**/*.test.{${SRC_EXTS.join(',')}}`],
259
264
 
260
- runtime: envOptions.oldTests
261
- ? undefined
262
- : require.resolve('./jestCachingModuleLoader'),
263
-
264
265
  transformIgnorePatterns: [`/node_modules/(?:${transformIgnorePattern})/`],
265
266
  ...getRoleConfig(pkgJson.backstage?.role, pkgJson),
266
267
  };
package/dist/index.cjs.js CHANGED
@@ -1,33 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var commander = require('commander');
4
- var chalk = require('chalk');
5
- var errors = require('./lib/errors.cjs.js');
6
- var version = require('./lib/version.cjs.js');
7
- var index = require('./commands/index.cjs.js');
3
+ var CliInitializer = require('./wiring/CliInitializer.cjs.js');
8
4
 
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
-
11
- var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
12
-
13
- const main = (argv) => {
14
- commander.program.name("backstage-cli").version(version.version);
15
- index.registerCommands(commander.program);
16
- commander.program.on("command:*", () => {
17
- console.log();
18
- console.log(chalk__default.default.red(`Invalid command: ${commander.program.args.join(" ")}`));
19
- console.log();
20
- commander.program.outputHelp();
21
- process.exit(1);
22
- });
23
- commander.program.parse(argv);
24
- };
25
- process.on("unhandledRejection", (rejection) => {
26
- if (rejection instanceof Error) {
27
- errors.exitWithError(rejection);
28
- } else {
29
- errors.exitWithError(new Error(`Unknown rejection: '${rejection}'`));
30
- }
31
- });
32
- main(process.argv);
5
+ (async () => {
6
+ const initializer = new CliInitializer.CliInitializer();
7
+ initializer.add(import('./modules/build/index.cjs.js'));
8
+ initializer.add(import('./modules/config/index.cjs.js'));
9
+ initializer.add(import('./modules/create-github-app/index.cjs.js'));
10
+ initializer.add(import('./modules/info/index.cjs.js'));
11
+ initializer.add(import('./modules/lint/index.cjs.js'));
12
+ initializer.add(import('./modules/maintenance/index.cjs.js'));
13
+ initializer.add(import('./modules/migrate/index.cjs.js'));
14
+ initializer.add(import('./modules/new/index.cjs.js'));
15
+ initializer.add(import('./modules/test/index.cjs.js'));
16
+ await initializer.run();
17
+ })();
33
18
  //# sourceMappingURL=index.cjs.js.map
@@ -3,7 +3,7 @@
3
3
  function removed(message) {
4
4
  return () => {
5
5
  console.error(
6
- message ? `This command has been removed, ${message}` : "This command has been removed"
6
+ `This command has been removed, ${message}`
7
7
  );
8
8
  process.exit(1);
9
9
  };
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var child_process = require('child_process');
4
- var errors$1 = require('./errors.cjs.js');
4
+ var errors = require('./errors.cjs.js');
5
5
  var util = require('util');
6
- var errors = require('@backstage/errors');
6
+ var errors$1 = require('@backstage/errors');
7
7
 
8
8
  const execFile = util.promisify(child_process.execFile);
9
9
  async function run(name, args = [], options = {}) {
@@ -37,14 +37,14 @@ async function runPlain(cmd, ...args) {
37
37
  const { stdout } = await execFile(cmd, args, { shell: true });
38
38
  return stdout.trim();
39
39
  } catch (error) {
40
- errors.assertError(error);
40
+ errors$1.assertError(error);
41
41
  if ("stderr" in error) {
42
42
  process.stderr.write(error.stderr);
43
43
  }
44
44
  if (typeof error.code === "number") {
45
- throw new errors$1.ExitCodeError(error.code, [cmd, ...args].join(" "));
45
+ throw new errors.ExitCodeError(error.code, [cmd, ...args].join(" "));
46
46
  }
47
- throw new errors.ForwardedError("Unknown execution error", error);
47
+ throw new errors$1.ForwardedError("Unknown execution error", error);
48
48
  }
49
49
  }
50
50
  async function runCheck(cmd, ...args) {
@@ -58,7 +58,7 @@ async function runCheck(cmd, ...args) {
58
58
  async function waitForExit(child, name) {
59
59
  if (typeof child.exitCode === "number") {
60
60
  if (child.exitCode) {
61
- throw new errors$1.ExitCodeError(child.exitCode, name);
61
+ throw new errors.ExitCodeError(child.exitCode, name);
62
62
  }
63
63
  return;
64
64
  }
@@ -66,7 +66,7 @@ async function waitForExit(child, name) {
66
66
  child.once("error", (error) => reject(error));
67
67
  child.once("exit", (code) => {
68
68
  if (code) {
69
- reject(new errors$1.ExitCodeError(code, name));
69
+ reject(new errors.ExitCodeError(code, name));
70
70
  } else {
71
71
  resolve();
72
72
  }
@@ -6,7 +6,6 @@ require('yn');
6
6
  require('webpack');
7
7
  require('react-dev-utils/FileSizeReporter');
8
8
  require('react-dev-utils/formatWebpackMessages');
9
- require('chalk');
10
9
  require('eslint-webpack-plugin');
11
10
  require('fork-ts-checker-webpack-plugin');
12
11
  require('html-webpack-plugin');
@@ -14,16 +13,17 @@ require('@module-federation/enhanced/webpack');
14
13
  require('react-dev-utils/ModuleScopePlugin');
15
14
  require('@pmmmwh/react-refresh-webpack-plugin');
16
15
  var paths = require('../../../../../lib/paths.cjs.js');
17
- require('../../../../build/lib/bundler/optimization.cjs.js');
16
+ require('../../../lib/bundler/optimization.cjs.js');
18
17
  require('lodash/pickBy');
19
18
  require('../../../../../lib/run.cjs.js');
20
19
  require('mini-css-extract-plugin');
21
20
  require('../../../../../lib/version.cjs.js');
22
- var hasReactDomClient = require('../../../../build/lib/bundler/hasReactDomClient.cjs.js');
21
+ var hasReactDomClient = require('../../../lib/bundler/hasReactDomClient.cjs.js');
23
22
  require('@manypkg/get-packages');
24
- require('../../../../build/lib/bundler/packageDetection.cjs.js');
25
- var moduleFederation = require('../../../../build/lib/bundler/moduleFederation.cjs.js');
26
- var server = require('../../../../build/lib/bundler/server.cjs.js');
23
+ require('chalk');
24
+ require('../../../lib/bundler/packageDetection.cjs.js');
25
+ var moduleFederation = require('../../../lib/bundler/moduleFederation.cjs.js');
26
+ var server = require('../../../lib/bundler/server.cjs.js');
27
27
 
28
28
  async function startFrontend(options) {
29
29
  const packageJson = await fs.readJson(
@@ -1,22 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var commander = require('commander');
6
+ var factory = require('../../wiring/factory.cjs.js');
4
7
  var lazy = require('../../lib/lazy.cjs.js');
8
+ var index = require('../config/index.cjs.js');
5
9
 
6
- function registerRepoCommands(command) {
7
- command.command("build").description(
8
- "Build packages in the project, excluding bundled app and backend packages."
9
- ).option(
10
- "--all",
11
- "Build all packages, including bundled app and backend packages."
12
- ).option(
13
- "--since <ref>",
14
- "Only build packages and their dev dependents that changed since the specified ref"
15
- ).option(
16
- "--minify",
17
- "Minify the generated code. Does not apply to app package (app is minified by default)."
18
- ).action(lazy.lazy(() => import('./commands/repo/build.cjs.js'), "command"));
19
- }
20
10
  function registerPackageCommands(command) {
21
11
  command.command("build").description("Build a package for production deployment or publishing").option("--role <name>", "Run the command with an explicit package role").option(
22
12
  "--minify",
@@ -34,19 +24,127 @@ function registerPackageCommands(command) {
34
24
  Array()
35
25
  ).action(lazy.lazy(() => import('./commands/package/build/index.cjs.js'), "command"));
36
26
  }
37
- function registerCommands(program) {
38
- program.command("build-workspace <workspace-dir> [packages...]").addOption(
39
- new commander.Option(
40
- "--alwaysYarnPack",
41
- "Alias for --alwaysPack for backwards compatibility."
42
- ).implies({ alwaysPack: true }).hideHelp(true)
43
- ).option(
44
- "--alwaysPack",
45
- "Force workspace output to be a result of running `yarn pack` on each package (warning: very slow)"
46
- ).description("Builds a temporary dist workspace from the provided packages").action(lazy.lazy(() => import('./commands/buildWorkspace.cjs.js'), "default"));
47
- }
27
+ const buildPlugin = factory.createCliPlugin({
28
+ pluginId: "build",
29
+ init: async (reg) => {
30
+ reg.addCommand({
31
+ path: ["package", "build"],
32
+ description: "Build a package for production deployment or publishing",
33
+ execute: async ({ args }) => {
34
+ const command = new commander.Command();
35
+ const defaultCommand = command.option(
36
+ "--role <name>",
37
+ "Run the command with an explicit package role"
38
+ ).option(
39
+ "--minify",
40
+ "Minify the generated code. Does not apply to app package (app is minified by default)."
41
+ ).option(
42
+ "--skip-build-dependencies",
43
+ "Skip the automatic building of local dependencies. Applies to backend packages only."
44
+ ).option(
45
+ "--stats",
46
+ "If bundle stats are available, write them to the output directory. Applies to app packages only."
47
+ ).option(
48
+ "--config <path>",
49
+ "Config files to load instead of app-config.yaml. Applies to app packages only.",
50
+ (opt, opts) => opts ? [...opts, opt] : [opt],
51
+ Array()
52
+ ).action(lazy.lazy(() => import('./commands/package/build/index.cjs.js'), "command"));
53
+ await defaultCommand.parseAsync(args, { from: "user" });
54
+ }
55
+ });
56
+ reg.addCommand({
57
+ path: ["repo", "build"],
58
+ description: "Build packages in the project, excluding bundled app and backend packages.",
59
+ execute: async ({ args }) => {
60
+ const command = new commander.Command();
61
+ registerPackageCommands(command.command("package"));
62
+ const defaultCommand = command.option(
63
+ "--all",
64
+ "Build all packages, including bundled app and backend packages."
65
+ ).option(
66
+ "--since <ref>",
67
+ "Only build packages and their dev dependents that changed since the specified ref"
68
+ ).option(
69
+ "--minify",
70
+ "Minify the generated code. Does not apply to app package (app is minified by default)."
71
+ ).action(lazy.lazy(() => import('./commands/repo/build.cjs.js'), "command"));
72
+ await defaultCommand.parseAsync(args, { from: "user" });
73
+ }
74
+ });
75
+ reg.addCommand({
76
+ path: ["package", "start"],
77
+ description: "Start a package for local development",
78
+ execute: async ({ args }) => {
79
+ const command = new commander.Command();
80
+ const defaultCommand = command.option(...index.configOption).option(
81
+ "--role <name>",
82
+ "Run the command with an explicit package role"
83
+ ).option("--check", "Enable type checking and linting if available").option("--inspect [host]", "Enable debugger in Node.js environments").option(
84
+ "--inspect-brk [host]",
85
+ "Enable debugger in Node.js environments, breaking before code starts"
86
+ ).option(
87
+ "--require <path...>",
88
+ "Add a --require argument to the node process"
89
+ ).option(
90
+ "--link <path>",
91
+ "Link an external workspace for module resolution"
92
+ ).action(lazy.lazy(() => import('./commands/package/start/index.cjs.js'), "command"));
93
+ await defaultCommand.parseAsync(args, { from: "user" });
94
+ }
95
+ });
96
+ reg.addCommand({
97
+ path: ["repo", "start"],
98
+ description: "Starts packages in the repo for local development",
99
+ execute: async ({ args }) => {
100
+ const command = new commander.Command();
101
+ const defaultCommand = command.argument(
102
+ "[packageNameOrPath...]",
103
+ "Run the specified package instead of the defaults."
104
+ ).option(
105
+ "--plugin <pluginId>",
106
+ "Start the dev entry-point for any matching plugin package in the repo",
107
+ (opt, opts) => opts ? [...opts, opt] : [opt],
108
+ Array()
109
+ ).option(...index.configOption).option(
110
+ "--inspect [host]",
111
+ "Enable debugger in Node.js environments. Applies to backend package only"
112
+ ).option(
113
+ "--inspect-brk [host]",
114
+ "Enable debugger in Node.js environments, breaking before code starts. Applies to backend package only"
115
+ ).option(
116
+ "--require <path...>",
117
+ "Add a --require argument to the node process. Applies to backend package only"
118
+ ).option(
119
+ "--link <path>",
120
+ "Link an external workspace for module resolution"
121
+ ).action(
122
+ lazy.lazy(() => import('./commands/repo/start.cjs.js'), "command")
123
+ );
124
+ await defaultCommand.parseAsync(args, { from: "user" });
125
+ }
126
+ });
127
+ reg.addCommand({
128
+ path: ["build-workspace"],
129
+ description: "Builds a temporary dist workspace from the provided packages",
130
+ execute: async ({ args }) => {
131
+ const command = new commander.Command();
132
+ const defaultCommand = command.arguments("<workspace-dir> [packages...]").addOption(
133
+ new commander.Option(
134
+ "--alwaysYarnPack",
135
+ "Alias for --alwaysPack for backwards compatibility."
136
+ ).implies({ alwaysPack: true }).hideHelp(true)
137
+ ).option(
138
+ "--alwaysPack",
139
+ "Force workspace output to be a result of running `yarn pack` on each package (warning: very slow)"
140
+ ).action(lazy.lazy(() => import('./commands/buildWorkspace.cjs.js'), "default"));
141
+ await defaultCommand.parseAsync(args, { from: "user" });
142
+ }
143
+ });
144
+ }
145
+ });
48
146
 
49
- exports.registerCommands = registerCommands;
147
+ exports.buildPlugin = buildPlugin;
148
+ exports.default = buildPlugin;
50
149
  exports.registerPackageCommands = registerPackageCommands;
51
- exports.registerRepoCommands = registerRepoCommands;
52
150
  //# sourceMappingURL=index.cjs.js.map
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var path = require('path');
4
- var chalk = require('chalk');
5
4
  var webpack$1 = require('webpack');
6
5
  var ESLintPlugin = require('eslint-webpack-plugin');
7
6
  var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
@@ -23,7 +22,6 @@ var ConfigInjectingHtmlWebpackPlugin = require('./ConfigInjectingHtmlWebpackPlug
23
22
 
24
23
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
25
24
 
26
- var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
27
25
  var webpack__default = /*#__PURE__*/_interopDefaultCompat(webpack$1);
28
26
  var ESLintPlugin__default = /*#__PURE__*/_interopDefaultCompat(ESLintPlugin);
29
27
  var ForkTsCheckerWebpackPlugin__default = /*#__PURE__*/_interopDefaultCompat(ForkTsCheckerWebpackPlugin);
@@ -34,7 +32,6 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
34
32
  var pickBy__default = /*#__PURE__*/_interopDefaultCompat(pickBy);
35
33
  var yn__default = /*#__PURE__*/_interopDefaultCompat(yn);
36
34
 
37
- const BUILD_CACHE_ENV_VAR = "BACKSTAGE_CLI_EXPERIMENTAL_BUILD_CACHE";
38
35
  function resolveBaseUrl(config, moduleFederation) {
39
36
  const baseUrl = config.getOptionalString("app.baseUrl");
40
37
  const defaultBaseUrl = moduleFederation?.mode === "remote" ? `http://localhost:${process.env.PORT ?? "3000"}` : "http://localhost:3000";
@@ -168,7 +165,7 @@ async function createConfig(paths, options) {
168
165
  }
169
166
  if (options.moduleFederation) {
170
167
  const isRemote = options.moduleFederation?.mode === "remote";
171
- const AdaptedModuleFederationPlugin = rspack ? rspack.container.ModuleFederationPlugin : webpack.ModuleFederationPlugin;
168
+ const AdaptedModuleFederationPlugin = rspack ? require("@module-federation/enhanced/rspack").ModuleFederationPlugin : webpack.ModuleFederationPlugin;
172
169
  const exposes = options.moduleFederation?.exposes ? Object.fromEntries(
173
170
  Object.entries(options.moduleFederation?.exposes).map(([k, v]) => [
174
171
  k,
@@ -266,32 +263,6 @@ async function createConfig(paths, options) {
266
263
  ];
267
264
  const mode = isDev ? "development" : "production";
268
265
  const optimization$1 = optimization.optimization(options);
269
- if (mode === "production" && process.env.EXPERIMENTAL_MODULE_FEDERATION && process.env.FORCE_REACT_DEVELOPMENT) {
270
- console.log(
271
- chalk__default.default.yellow(
272
- `\u26A0\uFE0F WARNING: Forcing react and react-dom into development mode. This build should not be used in production.`
273
- )
274
- );
275
- const reactPackageDirs = [
276
- `${path.dirname(require.resolve("react/package.json"))}/`,
277
- `${path.dirname(require.resolve("react-dom/package.json"))}/`
278
- ];
279
- optimization$1.nodeEnv = false;
280
- plugins.push(
281
- new bundler.DefinePlugin({
282
- "process.env.NODE_ENV": rspack ? (
283
- // FIXME: see also https://github.com/web-infra-dev/rspack/issues/5606
284
- JSON.stringify(mode)
285
- ) : webpack__default.default.DefinePlugin.runtimeValue(({ module }) => {
286
- if (reactPackageDirs.some((val) => module.resource.startsWith(val))) {
287
- return '"development"';
288
- }
289
- return `"${mode}"`;
290
- })
291
- })
292
- );
293
- }
294
- const withCache = yn__default.default(process.env[BUILD_CACHE_ENV_VAR], { default: false });
295
266
  return {
296
267
  mode,
297
268
  profile: false,
@@ -365,15 +336,7 @@ async function createConfig(paths, options) {
365
336
  css: false
366
337
  }
367
338
  },
368
- plugins,
369
- ...withCache && {
370
- cache: {
371
- type: "filesystem",
372
- buildDependencies: {
373
- config: [__filename]
374
- }
375
- }
376
- }
339
+ plugins
377
340
  };
378
341
  }
379
342
 
@@ -4,11 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var configLoader = require('@backstage/config-loader');
6
6
  var openBrowser = require('react-dev-utils/openBrowser');
7
+ var chalk = require('chalk');
7
8
  var config = require('../lib/config.cjs.js');
8
9
 
9
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
11
 
11
12
  var openBrowser__default = /*#__PURE__*/_interopDefaultCompat(openBrowser);
13
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
12
14
 
13
15
  const DOCS_URL = "https://config.backstage.io";
14
16
  var docs = async (opts) => {
@@ -22,7 +24,22 @@ var docs = async (opts) => {
22
24
  (_) => _.value
23
25
  )
24
26
  );
25
- openBrowser__default.default(`${DOCS_URL}#schema=${JSON.stringify(schema)}`);
27
+ const url = `${DOCS_URL}#schema=${JSON.stringify(schema)}`;
28
+ console.log();
29
+ console.log(
30
+ chalk__default.default.cyan(
31
+ "Opening configuration reference documentation in your browser..."
32
+ )
33
+ );
34
+ console.log(` ${chalk__default.default.cyan(url)}`);
35
+ console.log();
36
+ const opened = openBrowser__default.default(url);
37
+ if (!opened) {
38
+ console.log(
39
+ chalk__default.default.yellow("\u26A0\uFE0F WARNING: Unable to open browser automatically.")
40
+ );
41
+ console.log(chalk__default.default.yellow("Please open the URL manually in your browser."));
42
+ }
26
43
  };
27
44
 
28
45
  exports.default = docs;
@@ -1,43 +1,114 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var factory = require('../../wiring/factory.cjs.js');
6
+ var yargs = require('yargs');
7
+ var commander = require('commander');
3
8
  var lazy = require('../../lib/lazy.cjs.js');
4
9
 
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
+
12
+ var yargs__default = /*#__PURE__*/_interopDefaultCompat(yargs);
13
+
5
14
  const configOption = [
6
15
  "--config <path>",
7
16
  "Config files to load instead of app-config.yaml",
8
17
  (opt, opts) => opts ? [...opts, opt] : [opt],
9
18
  Array()
10
19
  ];
11
- function registerCommands(program) {
12
- program.command("config:docs").option(
13
- "--package <name>",
14
- "Only include the schema that applies to the given package"
15
- ).description("Browse the configuration reference documentation").action(lazy.lazy(() => import('./commands/docs.cjs.js'), "default"));
16
- program.command("config:print").option(
17
- "--package <name>",
18
- "Only load config schema that applies to the given package"
19
- ).option("--lax", "Do not require environment variables to be set").option("--frontend", "Print only the frontend configuration").option("--with-secrets", "Include secrets in the printed configuration").option(
20
- "--format <format>",
21
- "Format to print the configuration in, either json or yaml [yaml]"
22
- ).option(...configOption).description("Print the app configuration for the current package").action(lazy.lazy(() => import('./commands/print.cjs.js'), "default"));
23
- program.command("config:check").option(
24
- "--package <name>",
25
- "Only load config schema that applies to the given package"
26
- ).option("--lax", "Do not require environment variables to be set").option("--frontend", "Only validate the frontend configuration").option("--deprecated", "Output deprecated configuration settings").option(
27
- "--strict",
28
- "Enable strict config validation, forbidding errors and unknown keys"
29
- ).option(...configOption).description(
30
- "Validate that the given configuration loads and matches schema"
31
- ).action(lazy.lazy(() => import('./commands/validate.cjs.js'), "default"));
32
- program.command("config:schema").option(
33
- "--package <name>",
34
- "Only output config schema that applies to the given package"
35
- ).option(
36
- "--format <format>",
37
- "Format to print the schema in, either json or yaml [yaml]"
38
- ).option("--merge", "Print the config schemas merged", true).option("--no-merge", "Print the config schemas not merged").description("Print configuration schema").action(lazy.lazy(() => import('./commands/schema.cjs.js'), "default"));
39
- }
20
+ var index = factory.createCliPlugin({
21
+ pluginId: "config",
22
+ init: async (reg) => {
23
+ reg.addCommand({
24
+ path: ["config:docs"],
25
+ description: "Browse the configuration reference documentation",
26
+ execute: async ({ args }) => {
27
+ const command = new commander.Command();
28
+ const defaultCommand = command.option(
29
+ "--package <name>",
30
+ "Only include the schema that applies to the given package"
31
+ ).description("Browse the configuration reference documentation").action(lazy.lazy(() => import('./commands/docs.cjs.js'), "default"));
32
+ await defaultCommand.parseAsync(args, { from: "user" });
33
+ }
34
+ });
35
+ reg.addCommand({
36
+ path: ["config", "docs"],
37
+ description: "Browse the configuration reference documentation",
38
+ execute: async ({ args, info }) => {
39
+ await new commander.Command(info.usage).option(
40
+ "--package <name>",
41
+ "Only include the schema that applies to the given package"
42
+ ).description(info.description).action(lazy.lazy(() => import('./commands/docs.cjs.js'), "default")).parseAsync(args, { from: "user" });
43
+ }
44
+ });
45
+ reg.addCommand({
46
+ path: ["config:print"],
47
+ description: "Print the app configuration for the current package",
48
+ execute: async ({ args, info }) => {
49
+ const argv = await yargs__default.default.options({
50
+ package: { type: "string" },
51
+ lax: { type: "boolean" },
52
+ frontend: { type: "boolean" },
53
+ "with-secrets": { type: "boolean" },
54
+ format: { type: "string" },
55
+ config: { type: "string", array: true, default: [] }
56
+ }).usage("$0", info.description).help().parse(args);
57
+ const m = await require("./commands/print");
58
+ await m.default(argv);
59
+ }
60
+ });
61
+ reg.addCommand({
62
+ path: ["config:check"],
63
+ description: "Validate that the given configuration loads and matches schema",
64
+ execute: async ({ args }) => {
65
+ const argv = await yargs__default.default.options({
66
+ package: { type: "string" },
67
+ lax: { type: "boolean" },
68
+ frontend: { type: "boolean" },
69
+ deprecated: { type: "boolean" },
70
+ strict: { type: "boolean" },
71
+ config: {
72
+ type: "string",
73
+ array: true,
74
+ default: []
75
+ }
76
+ }).help().parse(args);
77
+ const m = await require("./commands/validate");
78
+ await m.default(argv);
79
+ }
80
+ });
81
+ reg.addCommand({
82
+ path: ["config:schema"],
83
+ description: "Print the JSON schema for the given configuration",
84
+ execute: async ({ args }) => {
85
+ const argv = await yargs__default.default.options({
86
+ package: { type: "string" },
87
+ format: { type: "string" },
88
+ merge: { type: "boolean" },
89
+ "no-merge": { type: "boolean" }
90
+ }).help().parse(args);
91
+ const m = await import('./commands/schema.cjs.js');
92
+ await m.default(argv);
93
+ }
94
+ });
95
+ reg.addCommand({
96
+ path: ["config", "schema"],
97
+ description: "Print the JSON schema for the given configuration",
98
+ execute: async ({ args }) => {
99
+ const argv = await yargs__default.default.options({
100
+ package: { type: "string" },
101
+ format: { type: "string" },
102
+ merge: { type: "boolean" },
103
+ "no-merge": { type: "boolean" }
104
+ }).help().parse(args);
105
+ const m = await import('./commands/schema.cjs.js');
106
+ await m.default(argv);
107
+ }
108
+ });
109
+ }
110
+ });
40
111
 
41
112
  exports.configOption = configOption;
42
- exports.registerCommands = registerCommands;
113
+ exports.default = index;
43
114
  //# sourceMappingURL=index.cjs.js.map