@backstage/cli 0.7.14 → 0.8.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 (48) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/config/eslint.backend.js +11 -6
  3. package/config/jest.js +105 -23
  4. package/config/jestEsmTransform.js +4 -21
  5. package/config/jestSucraseTransform.js +66 -0
  6. package/dist/cjs/{build-71c737ac.cjs.js → build-036a2109.cjs.js} +4 -3
  7. package/dist/cjs/{build-b73c8aec.cjs.js → build-3192edeb.cjs.js} +6 -5
  8. package/dist/cjs/{build-61ca5bd1.cjs.js → build-32289a53.cjs.js} +4 -3
  9. package/dist/cjs/{build-b61079aa.cjs.js → build-7357e33b.cjs.js} +4 -3
  10. package/dist/cjs/{buildImage-66df0236.cjs.js → buildImage-62344040.cjs.js} +5 -4
  11. package/dist/cjs/{buildWorkspace-a669db03.cjs.js → buildWorkspace-794159d5.cjs.js} +5 -4
  12. package/dist/cjs/{bump-2c638ffb.cjs.js → bump-ab142f88.cjs.js} +10 -50
  13. package/dist/cjs/{bundle-11249412.cjs.js → bundle-faf5ad1e.cjs.js} +6 -5
  14. package/dist/cjs/{clean-d2c13478.cjs.js → clean-e96f4b94.cjs.js} +3 -2
  15. package/dist/cjs/{config-f0ca8800.cjs.js → config-dab34362.cjs.js} +2 -2
  16. package/dist/cjs/{createPlugin-3e4b2655.cjs.js → createPlugin-3c802c14.cjs.js} +8 -5
  17. package/dist/cjs/{dev-42d0b115.cjs.js → dev-5750e5cb.cjs.js} +7 -5
  18. package/dist/cjs/{diff-b3b15773.cjs.js → diff-86e1188b.cjs.js} +3 -2
  19. package/dist/cjs/{docs-75bdaacf.cjs.js → docs-34d3c7fe.cjs.js} +4 -3
  20. package/dist/cjs/{index-b0d38feb.cjs.js → index-1db5f8d6.cjs.js} +38 -35
  21. package/dist/cjs/{index-639c9015.cjs.js → index-69ec4ee3.cjs.js} +3 -3
  22. package/dist/cjs/{index-a8bb12f8.cjs.js → index-dc92c8f4.cjs.js} +3 -2
  23. package/dist/cjs/{info-35e4ffe5.cjs.js → info-f1a293c8.cjs.js} +4 -3
  24. package/dist/cjs/install-40b1f07e.cjs.js +214 -0
  25. package/dist/cjs/{lint-bda30147.cjs.js → lint-73e3cf0a.cjs.js} +4 -3
  26. package/dist/cjs/{lint-a5758aab.cjs.js → lint-95a1066a.cjs.js} +4 -3
  27. package/dist/cjs/{pack-08aaeb74.cjs.js → pack-a254b380.cjs.js} +3 -2
  28. package/dist/cjs/{packager-a538a0d7.cjs.js → packager-679f1af5.cjs.js} +2 -2
  29. package/dist/cjs/packages-4fe3897c.cjs.js +50 -0
  30. package/dist/cjs/{paths-38b204ca.cjs.js → paths-9f678df9.cjs.js} +15 -6
  31. package/dist/cjs/{print-38e80be2.cjs.js → print-b972c130.cjs.js} +4 -3
  32. package/dist/cjs/{removePlugin-eb1ad78f.cjs.js → removePlugin-dc596b42.cjs.js} +11 -3
  33. package/dist/cjs/{run-e50c9fbb.cjs.js → run-a312f9a6.cjs.js} +9 -4
  34. package/dist/cjs/{schema-c9b6362b.cjs.js → schema-463ba3bd.cjs.js} +4 -3
  35. package/dist/cjs/{serve-7edb404b.cjs.js → serve-3d293027.cjs.js} +8 -7
  36. package/dist/cjs/{serve-956c01c6.cjs.js → serve-7b531df5.cjs.js} +7 -6
  37. package/dist/cjs/{server-7a3f6d5a.cjs.js → server-5582cec8.cjs.js} +2 -2
  38. package/dist/cjs/{tasks-cfde6de5.cjs.js → tasks-d6b72c3c.cjs.js} +2 -2
  39. package/dist/cjs/{testCommand-635a6e22.cjs.js → testCommand-42b484a8.cjs.js} +4 -3
  40. package/dist/cjs/{validate-08241b93.cjs.js → validate-4b57eb89.cjs.js} +4 -3
  41. package/dist/index.cjs.js +2 -1
  42. package/package.json +20 -20
  43. package/templates/default-backend-plugin/package.json.hbs +1 -1
  44. package/templates/default-plugin/package.json.hbs +1 -1
  45. package/templates/default-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +5 -2
  46. package/templates/default-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +2 -2
  47. package/templates/default-plugin/src/plugin.ts.hbs +1 -0
  48. package/templates/default-plugin/src/setupTests.ts +1 -1
@@ -4,13 +4,14 @@ var os = require('os');
4
4
  var fs = require('fs-extra');
5
5
  var path = require('path');
6
6
  var tar = require('tar');
7
- var index$1 = require('./index-639c9015.cjs.js');
8
- var index = require('./index-b0d38feb.cjs.js');
7
+ var index$1 = require('./index-69ec4ee3.cjs.js');
8
+ var index = require('./index-1db5f8d6.cjs.js');
9
9
  var parallel = require('./parallel-a4714c72.cjs.js');
10
- var packager = require('./packager-a538a0d7.cjs.js');
11
- require('./run-e50c9fbb.cjs.js');
10
+ var packager = require('./packager-679f1af5.cjs.js');
11
+ require('./run-a312f9a6.cjs.js');
12
12
  require('child_process');
13
13
  require('util');
14
+ require('@backstage/errors');
14
15
  require('commander');
15
16
  require('chalk');
16
17
  require('semver');
@@ -66,4 +67,4 @@ var bundle = async (cmd) => {
66
67
  };
67
68
 
68
69
  exports.default = bundle;
69
- //# sourceMappingURL=bundle-11249412.cjs.js.map
70
+ //# sourceMappingURL=bundle-faf5ad1e.cjs.js.map
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var fs = require('fs-extra');
4
- var index = require('./index-b0d38feb.cjs.js');
4
+ var index = require('./index-1db5f8d6.cjs.js');
5
5
  require('commander');
6
6
  require('chalk');
7
7
  require('semver');
8
8
  require('@backstage/cli-common');
9
9
  require('@backstage/config/package.json');
10
+ require('@backstage/errors');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
13
 
@@ -19,4 +20,4 @@ async function clean() {
19
20
  }
20
21
 
21
22
  exports.default = clean;
22
- //# sourceMappingURL=clean-d2c13478.cjs.js.map
23
+ //# sourceMappingURL=clean-e96f4b94.cjs.js.map
@@ -2,7 +2,7 @@
2
2
 
3
3
  var configLoader = require('@backstage/config-loader');
4
4
  var config = require('@backstage/config');
5
- var index = require('./index-b0d38feb.cjs.js');
5
+ var index = require('./index-1db5f8d6.cjs.js');
6
6
 
7
7
  async function loadCliConfig(options) {
8
8
  const configPaths = options.args.map((arg) => index.paths.resolveTarget(arg));
@@ -67,4 +67,4 @@ function findPackages(packages, fromPackage) {
67
67
  }
68
68
 
69
69
  exports.loadCliConfig = loadCliConfig;
70
- //# sourceMappingURL=config-f0ca8800.cjs.js.map
70
+ //# sourceMappingURL=config-dab34362.cjs.js.map
@@ -9,10 +9,11 @@ var path = require('path');
9
9
  var camelCase = require('lodash/camelCase');
10
10
  var upperFirst = require('lodash/upperFirst');
11
11
  var os = require('os');
12
- var tasks = require('./tasks-cfde6de5.cjs.js');
13
- var index = require('./index-b0d38feb.cjs.js');
12
+ var errors = require('@backstage/errors');
13
+ var tasks = require('./tasks-d6b72c3c.cjs.js');
14
+ var index = require('./index-1db5f8d6.cjs.js');
14
15
  var Lockfile = require('./Lockfile-80f0eec4.cjs.js');
15
- require('./run-e50c9fbb.cjs.js');
16
+ require('./run-a312f9a6.cjs.js');
16
17
  require('handlebars');
17
18
  require('ora');
18
19
  require('recursive-readdir');
@@ -114,6 +115,7 @@ async function buildPlugin(pluginFolder) {
114
115
  throw new Error(`Warning: Could not execute command ${chalk__default['default'].cyan(command)}`);
115
116
  });
116
117
  } catch (error) {
118
+ errors.assertError(error);
117
119
  tasks.Task.error(error.message);
118
120
  break;
119
121
  }
@@ -161,7 +163,7 @@ var createPlugin = async (cmd) => {
161
163
  });
162
164
  }
163
165
  const answers = await inquirer__default['default'].prompt(questions);
164
- const pluginId = cmd.backend ? `${answers.id}-backend` : answers.id;
166
+ const pluginId = cmd.backend && !answers.id.endsWith("-backend") ? `${answers.id}-backend` : answers.id;
165
167
  const name = cmd.scope ? `@${cmd.scope.replace(/^@/, "")}/plugin-${pluginId}` : `plugin-${pluginId}`;
166
168
  const pluginVar = `${camelCase__default['default'](answers.id)}Plugin`;
167
169
  const extensionName = `${upperFirst__default['default'](camelCase__default['default'](answers.id))}Page`;
@@ -214,6 +216,7 @@ var createPlugin = async (cmd) => {
214
216
  tasks.Task.log();
215
217
  tasks.Task.exit();
216
218
  } catch (error) {
219
+ errors.assertError(error);
217
220
  tasks.Task.error(error.message);
218
221
  tasks.Task.log("It seems that something went wrong when creating the plugin \u{1F914}");
219
222
  tasks.Task.log("We are going to clean up, and then you can try again.");
@@ -230,4 +233,4 @@ exports.addPluginExtensionToApp = addPluginExtensionToApp;
230
233
  exports.capitalize = capitalize;
231
234
  exports.default = createPlugin;
232
235
  exports.movePlugin = movePlugin;
233
- //# sourceMappingURL=createPlugin-3e4b2655.cjs.js.map
236
+ //# sourceMappingURL=createPlugin-3c802c14.cjs.js.map
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var fs = require('fs-extra');
4
- var index = require('./index-b0d38feb.cjs.js');
4
+ var index = require('./index-1db5f8d6.cjs.js');
5
5
  var webpack = require('webpack');
6
- var paths = require('./paths-38b204ca.cjs.js');
6
+ var paths = require('./paths-9f678df9.cjs.js');
7
7
  require('commander');
8
8
  require('chalk');
9
9
  require('semver');
10
10
  require('@backstage/cli-common');
11
11
  require('@backstage/config/package.json');
12
+ require('@backstage/errors');
12
13
  require('path');
13
14
  require('fork-ts-checker-webpack-plugin');
14
15
  require('html-webpack-plugin');
@@ -19,7 +20,7 @@ require('terser-webpack-plugin');
19
20
  require('./parallel-a4714c72.cjs.js');
20
21
  require('mini-css-extract-plugin');
21
22
  require('./svgrTemplate-2d0d15cf.cjs.js');
22
- require('./run-e50c9fbb.cjs.js');
23
+ require('./run-a312f9a6.cjs.js');
23
24
  require('child_process');
24
25
  require('util');
25
26
  require('lodash/pickBy');
@@ -59,10 +60,11 @@ var dev = async (cmd) => {
59
60
  const waitForExit = await serveBackend({
60
61
  entry: "src/index",
61
62
  checksEnabled: cmd.check,
62
- inspectEnabled: cmd.inspect
63
+ inspectEnabled: cmd.inspect,
64
+ inspectBrkEnabled: cmd.inspectBrk
63
65
  });
64
66
  await waitForExit();
65
67
  };
66
68
 
67
69
  exports.default = dev;
68
- //# sourceMappingURL=dev-42d0b115.cjs.js.map
70
+ //# sourceMappingURL=dev-5750e5cb.cjs.js.map
@@ -7,11 +7,12 @@ var path = require('path');
7
7
  var inquirer = require('inquirer');
8
8
  var handlebars = require('handlebars');
9
9
  var recursive = require('recursive-readdir');
10
- var index = require('./index-b0d38feb.cjs.js');
10
+ var index = require('./index-1db5f8d6.cjs.js');
11
11
  require('commander');
12
12
  require('semver');
13
13
  require('@backstage/cli-common');
14
14
  require('@backstage/config/package.json');
15
+ require('@backstage/errors');
15
16
 
16
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
18
 
@@ -373,4 +374,4 @@ async function readPluginData() {
373
374
  }
374
375
 
375
376
  exports.default = diff;
376
- //# sourceMappingURL=diff-b3b15773.cjs.js.map
377
+ //# sourceMappingURL=diff-86e1188b.cjs.js.map
@@ -2,15 +2,16 @@
2
2
 
3
3
  var configLoader = require('@backstage/config-loader');
4
4
  var openBrowser = require('react-dev-utils/openBrowser');
5
- var config = require('./config-f0ca8800.cjs.js');
5
+ var config = require('./config-dab34362.cjs.js');
6
6
  require('@backstage/config');
7
- require('./index-b0d38feb.cjs.js');
7
+ require('./index-1db5f8d6.cjs.js');
8
8
  require('commander');
9
9
  require('chalk');
10
10
  require('fs-extra');
11
11
  require('semver');
12
12
  require('@backstage/cli-common');
13
13
  require('@backstage/config/package.json');
14
+ require('@backstage/errors');
14
15
 
15
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
17
 
@@ -28,4 +29,4 @@ var docs = async (cmd) => {
28
29
  };
29
30
 
30
31
  exports.default = docs;
31
- //# sourceMappingURL=docs-75bdaacf.cjs.js.map
32
+ //# sourceMappingURL=docs-34d3c7fe.cjs.js.map
@@ -6,6 +6,7 @@ var fs = require('fs-extra');
6
6
  var semver = require('semver');
7
7
  var cliCommon = require('@backstage/cli-common');
8
8
  var package_json = require('@backstage/config/package.json');
9
+ var errors = require('@backstage/errors');
9
10
 
10
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
12
 
@@ -49,21 +50,21 @@ class NotFoundError extends CustomError {
49
50
 
50
51
  const paths = cliCommon.findPaths(__dirname);
51
52
 
52
- var version$8 = "0.9.5";
53
+ var version$8 = "0.9.8";
53
54
 
54
- var version$7 = "0.7.14";
55
+ var version$7 = "0.8.1";
55
56
 
56
- var version$6 = "0.1.15";
57
+ var version$6 = "0.1.19";
57
58
 
58
- var version$5 = "0.6.0";
59
+ var version$5 = "0.7.2";
59
60
 
60
- var version$4 = "0.1.9";
61
+ var version$4 = "0.1.12";
61
62
 
62
- var version$3 = "0.2.11";
63
+ var version$3 = "0.2.12";
63
64
 
64
- var version$2 = "0.1.17";
65
+ var version$2 = "0.1.20";
65
66
 
66
- var version$1 = "0.2.10";
67
+ var version$1 = "0.2.12";
67
68
 
68
69
  const packageVersions = {
69
70
  "@backstage/backend-common": version$8,
@@ -116,32 +117,33 @@ function registerCommands(program) {
116
117
  (opt, opts) => [...opts, opt],
117
118
  Array()
118
119
  ];
119
- program.command("app:build").description("Build an app for a production release").option("--stats", "Write bundle stats to output directory").option("--lax", "Do not require environment variables to be set").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./build-b73c8aec.cjs.js'); }).then((m) => m.default)));
120
- program.command("app:serve").description("Serve an app for local development").option("--check", "Enable type checking and linting").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./serve-7edb404b.cjs.js'); }).then((m) => m.default)));
121
- program.command("backend:build").description("Build a backend plugin").action(lazy(() => Promise.resolve().then(function () { return require('./build-b61079aa.cjs.js'); }).then((m) => m.default)));
122
- program.command("backend:bundle").description("Bundle the backend into a deployment archive").option("--build-dependencies", "Build all local package dependencies before bundling the backend").action(lazy(() => Promise.resolve().then(function () { return require('./bundle-11249412.cjs.js'); }).then((m) => m.default)));
123
- program.command("backend:build-image").allowUnknownOption(true).helpOption(", --backstage-cli-help").option("--build", "Build packages before packing them into the image").description("Bundles the package into a docker image. This command is deprecated and will be removed.").action(lazy(() => Promise.resolve().then(function () { return require('./buildImage-66df0236.cjs.js'); }).then((m) => m.default)));
124
- program.command("backend:dev").description("Start local development server with HMR for the backend").option("--check", "Enable type checking and linting").option("--inspect", "Enable debugger").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./dev-42d0b115.cjs.js'); }).then((m) => m.default)));
125
- program.command("create-plugin").option("--backend", "Create plugin with the backend dependencies as default").description("Creates a new plugin in the current repository").option("--scope <scope>", "npm scope").option("--npm-registry <URL>", "npm registry URL").option("--no-private", "Public npm package").action(lazy(() => Promise.resolve().then(function () { return require('./createPlugin-3e4b2655.cjs.js'); }).then((m) => m.default)));
126
- program.command("remove-plugin").description("Removes plugin in the current repository").action(lazy(() => Promise.resolve().then(function () { return require('./removePlugin-eb1ad78f.cjs.js'); }).then((m) => m.default)));
127
- program.command("plugin:build").description("Build a plugin").action(lazy(() => Promise.resolve().then(function () { return require('./build-71c737ac.cjs.js'); }).then((m) => m.default)));
128
- program.command("plugin:serve").description("Serves the dev/ folder of a plugin").option("--check", "Enable type checking and linting").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./serve-956c01c6.cjs.js'); }).then((m) => m.default)));
129
- program.command("plugin:diff").option("--check", "Fail if changes are required").option("--yes", "Apply all changes").description("Diff an existing plugin with the creation template").action(lazy(() => Promise.resolve().then(function () { return require('./diff-b3b15773.cjs.js'); }).then((m) => m.default)));
130
- program.command("build").description("Build a package for publishing").option("--outputs <formats>", "List of formats to output [types,cjs,esm]").action(lazy(() => Promise.resolve().then(function () { return require('./build-61ca5bd1.cjs.js'); }).then((m) => m.default)));
131
- program.command("lint").option("--format <format>", "Lint report output format", "eslint-formatter-friendly").option("--fix", "Attempt to automatically fix violations").description("Lint a package").action(lazy(() => Promise.resolve().then(function () { return require('./lint-bda30147.cjs.js'); }).then((m) => m.default)));
132
- program.command("test").allowUnknownOption(true).helpOption(", --backstage-cli-help").description("Run tests, forwarding args to Jest, defaulting to watch mode").action(lazy(() => Promise.resolve().then(function () { return require('./testCommand-635a6e22.cjs.js'); }).then((m) => m.default)));
133
- program.command("config:docs").option("--package <name>", "Only include the schema that applies to the given package").description("Browse the configuration reference documentation").action(lazy(() => Promise.resolve().then(function () { return require('./docs-75bdaacf.cjs.js'); }).then((m) => m.default)));
134
- program.command("config:print").option("--package <name>", "Only load config schema that applies to the given package").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("--format <format>", "Format to print the configuration in, either json or yaml [yaml]").option(...configOption).description("Print the app configuration for the current package").action(lazy(() => Promise.resolve().then(function () { return require('./print-38e80be2.cjs.js'); }).then((m) => m.default)));
135
- program.command("config:check").option("--package <name>", "Only load config schema that applies to the given package").option("--lax", "Do not require environment variables to be set").option(...configOption).description("Validate that the given configuration loads and matches schema").action(lazy(() => Promise.resolve().then(function () { return require('./validate-08241b93.cjs.js'); }).then((m) => m.default)));
136
- program.command("config:schema").option("--package <name>", "Only output config schema that applies to the given package").option("--format <format>", "Format to print the schema in, either json or yaml [yaml]").description("Print configuration schema").action(lazy(() => Promise.resolve().then(function () { return require('./schema-c9b6362b.cjs.js'); }).then((m) => m.default)));
137
- program.command("versions:bump").description("Bump Backstage packages to the latest versions").action(lazy(() => Promise.resolve().then(function () { return require('./bump-2c638ffb.cjs.js'); }).then((m) => m.default)));
138
- program.command("versions:check").option("--fix", "Fix any auto-fixable versioning problems").description("Check Backstage package versioning").action(lazy(() => Promise.resolve().then(function () { return require('./lint-a5758aab.cjs.js'); }).then((m) => m.default)));
139
- program.command("prepack").description("Prepares a package for packaging before publishing").action(lazy(() => Promise.resolve().then(function () { return require('./pack-08aaeb74.cjs.js'); }).then((m) => m.pre)));
140
- program.command("postpack").description("Restores the changes made by the prepack command").action(lazy(() => Promise.resolve().then(function () { return require('./pack-08aaeb74.cjs.js'); }).then((m) => m.post)));
141
- program.command("clean").description("Delete cache directories").action(lazy(() => Promise.resolve().then(function () { return require('./clean-d2c13478.cjs.js'); }).then((m) => m.default)));
142
- program.command("build-workspace <workspace-dir> ...<packages>").description("Builds a temporary dist workspace from the provided packages").action(lazy(() => Promise.resolve().then(function () { return require('./buildWorkspace-a669db03.cjs.js'); }).then((m) => m.default)));
143
- program.command("create-github-app <github-org>").description("Create new GitHub App in your organization.").action(lazy(() => Promise.resolve().then(function () { return require('./index-a8bb12f8.cjs.js'); }).then((m) => m.default)));
144
- program.command("info").description("Show helpful information for debugging and reporting bugs").action(lazy(() => Promise.resolve().then(function () { return require('./info-35e4ffe5.cjs.js'); }).then((m) => m.default)));
120
+ program.command("app:build").description("Build an app for a production release").option("--stats", "Write bundle stats to output directory").option("--lax", "Do not require environment variables to be set").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./build-3192edeb.cjs.js'); }).then((m) => m.default)));
121
+ program.command("app:serve").description("Serve an app for local development").option("--check", "Enable type checking and linting").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./serve-3d293027.cjs.js'); }).then((m) => m.default)));
122
+ program.command("backend:build").description("Build a backend plugin").action(lazy(() => Promise.resolve().then(function () { return require('./build-7357e33b.cjs.js'); }).then((m) => m.default)));
123
+ program.command("backend:bundle").description("Bundle the backend into a deployment archive").option("--build-dependencies", "Build all local package dependencies before bundling the backend").action(lazy(() => Promise.resolve().then(function () { return require('./bundle-faf5ad1e.cjs.js'); }).then((m) => m.default)));
124
+ program.command("backend:build-image").allowUnknownOption(true).helpOption(", --backstage-cli-help").option("--build", "Build packages before packing them into the image").description("Bundles the package into a docker image. This command is deprecated and will be removed.").action(lazy(() => Promise.resolve().then(function () { return require('./buildImage-62344040.cjs.js'); }).then((m) => m.default)));
125
+ program.command("backend:dev").description("Start local development server with HMR for the backend").option("--check", "Enable type checking and linting").option("--inspect", "Enable debugger").option("--inspect-brk", "Enable debugger with await to attach debugger").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./dev-5750e5cb.cjs.js'); }).then((m) => m.default)));
126
+ program.command("create-plugin").option("--backend", "Create plugin with the backend dependencies as default").description("Creates a new plugin in the current repository").option("--scope <scope>", "npm scope").option("--npm-registry <URL>", "npm registry URL").option("--no-private", "Public npm package").action(lazy(() => Promise.resolve().then(function () { return require('./createPlugin-3c802c14.cjs.js'); }).then((m) => m.default)));
127
+ program.command("remove-plugin").description("Removes plugin in the current repository").action(lazy(() => Promise.resolve().then(function () { return require('./removePlugin-dc596b42.cjs.js'); }).then((m) => m.default)));
128
+ program.command("plugin:build").description("Build a plugin").action(lazy(() => Promise.resolve().then(function () { return require('./build-036a2109.cjs.js'); }).then((m) => m.default)));
129
+ program.command("plugin:serve").description("Serves the dev/ folder of a plugin").option("--check", "Enable type checking and linting").option(...configOption).action(lazy(() => Promise.resolve().then(function () { return require('./serve-7b531df5.cjs.js'); }).then((m) => m.default)));
130
+ program.command("plugin:diff").option("--check", "Fail if changes are required").option("--yes", "Apply all changes").description("Diff an existing plugin with the creation template").action(lazy(() => Promise.resolve().then(function () { return require('./diff-86e1188b.cjs.js'); }).then((m) => m.default)));
131
+ program.command("build").description("Build a package for publishing").option("--outputs <formats>", "List of formats to output [types,cjs,esm]").action(lazy(() => Promise.resolve().then(function () { return require('./build-32289a53.cjs.js'); }).then((m) => m.default)));
132
+ program.command("lint").option("--format <format>", "Lint report output format", "eslint-formatter-friendly").option("--fix", "Attempt to automatically fix violations").description("Lint a package").action(lazy(() => Promise.resolve().then(function () { return require('./lint-73e3cf0a.cjs.js'); }).then((m) => m.default)));
133
+ program.command("test").allowUnknownOption(true).helpOption(", --backstage-cli-help").description("Run tests, forwarding args to Jest, defaulting to watch mode").action(lazy(() => Promise.resolve().then(function () { return require('./testCommand-42b484a8.cjs.js'); }).then((m) => m.default)));
134
+ program.command("config:docs").option("--package <name>", "Only include the schema that applies to the given package").description("Browse the configuration reference documentation").action(lazy(() => Promise.resolve().then(function () { return require('./docs-34d3c7fe.cjs.js'); }).then((m) => m.default)));
135
+ program.command("config:print").option("--package <name>", "Only load config schema that applies to the given package").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("--format <format>", "Format to print the configuration in, either json or yaml [yaml]").option(...configOption).description("Print the app configuration for the current package").action(lazy(() => Promise.resolve().then(function () { return require('./print-b972c130.cjs.js'); }).then((m) => m.default)));
136
+ program.command("config:check").option("--package <name>", "Only load config schema that applies to the given package").option("--lax", "Do not require environment variables to be set").option(...configOption).description("Validate that the given configuration loads and matches schema").action(lazy(() => Promise.resolve().then(function () { return require('./validate-4b57eb89.cjs.js'); }).then((m) => m.default)));
137
+ program.command("config:schema").option("--package <name>", "Only output config schema that applies to the given package").option("--format <format>", "Format to print the schema in, either json or yaml [yaml]").description("Print configuration schema").action(lazy(() => Promise.resolve().then(function () { return require('./schema-463ba3bd.cjs.js'); }).then((m) => m.default)));
138
+ program.command("versions:bump").description("Bump Backstage packages to the latest versions").action(lazy(() => Promise.resolve().then(function () { return require('./bump-ab142f88.cjs.js'); }).then((m) => m.default)));
139
+ program.command("versions:check").option("--fix", "Fix any auto-fixable versioning problems").description("Check Backstage package versioning").action(lazy(() => Promise.resolve().then(function () { return require('./lint-95a1066a.cjs.js'); }).then((m) => m.default)));
140
+ program.command("prepack").description("Prepares a package for packaging before publishing").action(lazy(() => Promise.resolve().then(function () { return require('./pack-a254b380.cjs.js'); }).then((m) => m.pre)));
141
+ program.command("postpack").description("Restores the changes made by the prepack command").action(lazy(() => Promise.resolve().then(function () { return require('./pack-a254b380.cjs.js'); }).then((m) => m.post)));
142
+ program.command("clean").description("Delete cache directories").action(lazy(() => Promise.resolve().then(function () { return require('./clean-e96f4b94.cjs.js'); }).then((m) => m.default)));
143
+ program.command("build-workspace <workspace-dir> ...<packages>").description("Builds a temporary dist workspace from the provided packages").action(lazy(() => Promise.resolve().then(function () { return require('./buildWorkspace-794159d5.cjs.js'); }).then((m) => m.default)));
144
+ program.command("create-github-app <github-org>").description("Create new GitHub App in your organization.").action(lazy(() => Promise.resolve().then(function () { return require('./index-dc92c8f4.cjs.js'); }).then((m) => m.default)));
145
+ program.command("info").description("Show helpful information for debugging and reporting bugs").action(lazy(() => Promise.resolve().then(function () { return require('./info-f1a293c8.cjs.js'); }).then((m) => m.default)));
146
+ program.command("install [plugin-id]", {hidden: true}).option("--from <packageJsonFilePath>", "Install from a local package.json containing the installation recipe").description("Install a Backstage plugin [EXPERIMENTAL]").action(lazy(() => Promise.resolve().then(function () { return require('./install-40b1f07e.cjs.js'); }).then((m) => m.default)));
145
147
  }
146
148
  function lazy(getActionFunc) {
147
149
  return async (...args) => {
@@ -150,6 +152,7 @@ function lazy(getActionFunc) {
150
152
  await actionFunc(...args);
151
153
  process.exit(0);
152
154
  } catch (error) {
155
+ errors.assertError(error);
153
156
  exitWithError(error);
154
157
  }
155
158
  };
@@ -183,4 +186,4 @@ exports.packageVersions = packageVersions;
183
186
  exports.paths = paths;
184
187
  exports.version = version;
185
188
  exports.version$1 = version$7;
186
- //# sourceMappingURL=index-b0d38feb.cjs.js.map
189
+ //# sourceMappingURL=index-1db5f8d6.cjs.js.map
@@ -4,8 +4,8 @@ var fs = require('fs-extra');
4
4
  var path = require('path');
5
5
  var os = require('os');
6
6
  var tar = require('tar');
7
- var index = require('./index-b0d38feb.cjs.js');
8
- var run = require('./run-e50c9fbb.cjs.js');
7
+ var index = require('./index-1db5f8d6.cjs.js');
8
+ var run = require('./run-a312f9a6.cjs.js');
9
9
 
10
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
11
 
@@ -118,4 +118,4 @@ async function findTargetPackages(pkgNames) {
118
118
  }
119
119
 
120
120
  exports.createDistWorkspace = createDistWorkspace;
121
- //# sourceMappingURL=index-639c9015.cjs.js.map
121
+ //# sourceMappingURL=index-69ec4ee3.cjs.js.map
@@ -3,7 +3,7 @@
3
3
  var fs = require('fs-extra');
4
4
  var chalk = require('chalk');
5
5
  var yaml = require('yaml');
6
- var index$1 = require('./index-b0d38feb.cjs.js');
6
+ var index$1 = require('./index-1db5f8d6.cjs.js');
7
7
  var crypto = require('crypto');
8
8
  var openBrowser = require('react-dev-utils/openBrowser');
9
9
  var request = require('@octokit/request');
@@ -12,6 +12,7 @@ require('commander');
12
12
  require('semver');
13
13
  require('@backstage/cli-common');
14
14
  require('@backstage/config/package.json');
15
+ require('@backstage/errors');
15
16
 
16
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
18
 
@@ -127,4 +128,4 @@ ${yaml.stringify(config)}`;
127
128
  };
128
129
 
129
130
  exports.default = index;
130
- //# sourceMappingURL=index-a8bb12f8.cjs.js.map
131
+ //# sourceMappingURL=index-dc92c8f4.cjs.js.map
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-b0d38feb.cjs.js');
3
+ var index = require('./index-1db5f8d6.cjs.js');
4
4
  var os = require('os');
5
- var run = require('./run-e50c9fbb.cjs.js');
5
+ var run = require('./run-a312f9a6.cjs.js');
6
6
  var Lockfile = require('./Lockfile-80f0eec4.cjs.js');
7
7
  require('chalk');
8
8
  require('commander');
@@ -10,6 +10,7 @@ require('fs-extra');
10
10
  require('semver');
11
11
  require('@backstage/cli-common');
12
12
  require('@backstage/config/package.json');
13
+ require('@backstage/errors');
13
14
  require('child_process');
14
15
  require('util');
15
16
  require('@yarnpkg/lockfile');
@@ -40,4 +41,4 @@ var info = async () => {
40
41
  };
41
42
 
42
43
  exports.default = info;
43
- //# sourceMappingURL=info-35e4ffe5.cjs.js.map
44
+ //# sourceMappingURL=info-f1a293c8.cjs.js.map
@@ -0,0 +1,214 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ require('semver');
5
+ require('@yarnpkg/lockfile');
6
+ var packages = require('./packages-4fe3897c.cjs.js');
7
+ var index = require('./index-1db5f8d6.cjs.js');
8
+ var chalk = require('chalk');
9
+ var sortBy = require('lodash/sortBy');
10
+ var groupBy = require('lodash/groupBy');
11
+ var run = require('./run-a312f9a6.cjs.js');
12
+ require('commander');
13
+ require('@backstage/cli-common');
14
+ require('@backstage/config/package.json');
15
+ require('@backstage/errors');
16
+ require('child_process');
17
+ require('util');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
22
+ var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
23
+ var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
24
+ var groupBy__default = /*#__PURE__*/_interopDefaultLegacy(groupBy);
25
+
26
+ function createStepDefinition(config) {
27
+ return config;
28
+ }
29
+
30
+ class AppRouteStep {
31
+ constructor(data) {
32
+ this.data = data;
33
+ }
34
+ async run() {
35
+ var _a;
36
+ const {path, element, packageName} = this.data;
37
+ const appTsxPath = index.paths.resolveTargetRoot("packages/app/src/App.tsx");
38
+ const contents = await fs__default['default'].readFile(appTsxPath, "utf-8");
39
+ let failed = false;
40
+ const contentsWithRoute = contents.replace(/(\s*)<\/FlatRoutes>/, `$1 <Route path="${path}" element={${element}} />$1</FlatRoutes>`);
41
+ if (contentsWithRoute === contents) {
42
+ failed = true;
43
+ }
44
+ const componentName = (_a = element.match(/[A-Za-z0-9]+/)) == null ? void 0 : _a[0];
45
+ if (!componentName) {
46
+ throw new Error(`Could not find component name in ${element}`);
47
+ }
48
+ const contentsWithImport = contentsWithRoute.replace(/^import /m, `import { ${componentName} } from '${packageName}';
49
+ import `);
50
+ if (contentsWithImport === contentsWithRoute) {
51
+ failed = true;
52
+ }
53
+ if (failed) {
54
+ console.log("Failed to automatically add a route to package/app/src/App.tsx");
55
+ console.log(`Action needed, add the following:`);
56
+ console.log(`1. import { ${componentName} } from '${packageName}';`);
57
+ console.log(`2. <Route path="${path}" element={${element}} />`);
58
+ } else {
59
+ await fs__default['default'].writeFile(appTsxPath, contentsWithImport);
60
+ }
61
+ }
62
+ }
63
+ const appRoute = createStepDefinition({
64
+ type: "app-route",
65
+ deserialize(obj, pkg) {
66
+ const {path, element} = obj;
67
+ if (!path || typeof path !== "string") {
68
+ throw new Error("Invalid install step, 'path' must be a string");
69
+ }
70
+ if (!element || typeof element !== "string") {
71
+ throw new Error("Invalid install step, 'element' must be a string");
72
+ }
73
+ return new AppRouteStep({path, element, packageName: pkg.name});
74
+ },
75
+ create(data) {
76
+ return new AppRouteStep(data);
77
+ }
78
+ });
79
+
80
+ class DependenciesStep {
81
+ constructor(data) {
82
+ this.data = data;
83
+ }
84
+ async run() {
85
+ const {dependencies: dependencies2} = this.data;
86
+ const byTarget = groupBy__default['default'](dependencies2, "target");
87
+ for (const [target, deps] of Object.entries(byTarget)) {
88
+ const pkgPath = index.paths.resolveTargetRoot(target, "package.json");
89
+ const pkgJson = await fs__default['default'].readJson(pkgPath);
90
+ const depTypes = new Set();
91
+ for (const dep of deps) {
92
+ depTypes.add(dep.type);
93
+ pkgJson[dep.type][dep.name] = dep.query;
94
+ }
95
+ for (const depType of depTypes) {
96
+ pkgJson[depType] = Object.fromEntries(sortBy__default['default'](Object.entries(pkgJson[depType]), ([key]) => key));
97
+ }
98
+ await fs__default['default'].writeJson(pkgPath, pkgJson, {spaces: 2});
99
+ }
100
+ console.log();
101
+ console.log(`Running ${chalk__default['default'].blue("yarn install")} to install new versions`);
102
+ console.log();
103
+ await run.run("yarn", ["install"]);
104
+ }
105
+ }
106
+ const dependencies = createStepDefinition({
107
+ type: "dependencies",
108
+ deserialize() {
109
+ throw new Error("The dependency step may not be defined in JSON");
110
+ },
111
+ create(data) {
112
+ return new DependenciesStep(data);
113
+ }
114
+ });
115
+
116
+ class MessageStep {
117
+ constructor(data) {
118
+ this.data = data;
119
+ }
120
+ async run() {
121
+ console.log(this.data.message);
122
+ }
123
+ }
124
+ const message = createStepDefinition({
125
+ type: "message",
126
+ deserialize(obj) {
127
+ const {message: msg} = obj;
128
+ if (!msg || typeof msg !== "string" && !Array.isArray(msg)) {
129
+ throw new Error("Invalid install step, 'message' must be a string or array");
130
+ }
131
+ return new MessageStep({message: [msg].flat().join("")});
132
+ },
133
+ create(data) {
134
+ return new MessageStep(data);
135
+ }
136
+ });
137
+
138
+ var stepDefinitionMap = /*#__PURE__*/Object.freeze({
139
+ __proto__: null,
140
+ appRoute: appRoute,
141
+ dependencies: dependencies,
142
+ message: message
143
+ });
144
+
145
+ const stepDefinitions = Object.values(stepDefinitionMap);
146
+ async function fetchPluginPackage(id) {
147
+ const searchNames = [`@backstage/plugin-${id}`, `backstage-plugin-${id}`, id];
148
+ for (const name of searchNames) {
149
+ try {
150
+ const packageInfo = await packages.fetchPackageInfo(name);
151
+ return packageInfo;
152
+ } catch (error) {
153
+ if (error.name !== "NotFoundError") {
154
+ throw error;
155
+ }
156
+ }
157
+ }
158
+ throw new index.NotFoundError(`No matching package found for '${id}', tried ${searchNames.join(", ")}`);
159
+ }
160
+ class PluginInstaller {
161
+ constructor(steps) {
162
+ this.steps = steps;
163
+ }
164
+ static async resolveSteps(pkg) {
165
+ var _a, _b;
166
+ const steps = [];
167
+ const dependencies$1 = [];
168
+ dependencies$1.push({
169
+ target: "packages/app",
170
+ type: "dependencies",
171
+ name: pkg.name,
172
+ query: `^${pkg.version}`
173
+ });
174
+ steps.push({
175
+ type: "dependencies",
176
+ step: dependencies.create({dependencies: dependencies$1})
177
+ });
178
+ for (const step of (_b = (_a = pkg.experimentalInstallationRecipe) == null ? void 0 : _a.steps) != null ? _b : []) {
179
+ const {type} = step;
180
+ const definition = stepDefinitions.find((d) => d.type === type);
181
+ if (definition) {
182
+ steps.push({
183
+ type,
184
+ step: definition.deserialize(step, pkg)
185
+ });
186
+ } else {
187
+ throw new Error(`Unsupported step type: ${type}`);
188
+ }
189
+ }
190
+ return steps;
191
+ }
192
+ async run() {
193
+ for (const {type, step} of this.steps) {
194
+ console.log(`Running step ${type}`);
195
+ await step.run();
196
+ }
197
+ }
198
+ }
199
+ var install = async (pluginId, cmd) => {
200
+ let pkg;
201
+ if (pluginId) {
202
+ pkg = await fetchPluginPackage(pluginId);
203
+ } else if (cmd == null ? void 0 : cmd.from) {
204
+ pkg = await fs__default['default'].readJson(cmd.from);
205
+ } else {
206
+ throw new Error("Missing both <plugin-id> or a package.json file path in the --from flag.");
207
+ }
208
+ const steps = await PluginInstaller.resolveSteps(pkg);
209
+ const installer = new PluginInstaller(steps);
210
+ await installer.run();
211
+ };
212
+
213
+ exports.default = install;
214
+ //# sourceMappingURL=install-40b1f07e.cjs.js.map
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var run = require('./run-e50c9fbb.cjs.js');
4
- var index = require('./index-b0d38feb.cjs.js');
3
+ var run = require('./run-a312f9a6.cjs.js');
4
+ var index = require('./index-1db5f8d6.cjs.js');
5
5
  require('child_process');
6
6
  require('util');
7
+ require('@backstage/errors');
7
8
  require('commander');
8
9
  require('chalk');
9
10
  require('fs-extra');
@@ -25,4 +26,4 @@ var lint = async (cmd, cmdArgs) => {
25
26
  };
26
27
 
27
28
  exports.default = lint;
28
- //# sourceMappingURL=lint-bda30147.cjs.js.map
29
+ //# sourceMappingURL=lint-73e3cf0a.cjs.js.map