@backstage/cli 0.35.5-next.0 → 0.36.0-next.2

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 (106) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/config/jest.js +2 -2
  3. package/dist/index.cjs.js +1 -0
  4. package/dist/modules/auth/commands/list.cjs.js +23 -0
  5. package/dist/modules/auth/commands/login.cjs.js +316 -0
  6. package/dist/modules/auth/commands/logout.cjs.js +55 -0
  7. package/dist/modules/auth/commands/printToken.cjs.js +41 -0
  8. package/dist/modules/auth/commands/select.cjs.js +32 -0
  9. package/dist/modules/auth/commands/show.cjs.js +59 -0
  10. package/dist/modules/auth/index.cjs.js +44 -0
  11. package/dist/modules/auth/lib/auth.cjs.js +60 -0
  12. package/dist/modules/auth/lib/http.cjs.js +26 -0
  13. package/dist/modules/auth/lib/localServer.cjs.js +80 -0
  14. package/dist/modules/auth/lib/pkce.cjs.js +23 -0
  15. package/dist/modules/auth/lib/prompt.cjs.js +44 -0
  16. package/dist/modules/auth/lib/secretStore.cjs.js +81 -0
  17. package/dist/modules/auth/lib/storage.cjs.js +152 -0
  18. package/dist/modules/build/commands/buildWorkspace.cjs.js +31 -2
  19. package/dist/modules/build/commands/package/build/command.cjs.js +62 -15
  20. package/dist/modules/build/commands/package/build/index.cjs.js +3 -1
  21. package/dist/modules/{maintenance → build}/commands/package/clean.cjs.js +4 -2
  22. package/dist/modules/build/commands/package/postpack.cjs.js +15 -0
  23. package/dist/modules/{maintenance/commands/package/pack.cjs.js → build/commands/package/prepack.cjs.js} +10 -10
  24. package/dist/modules/build/commands/package/start/command.cjs.js +68 -11
  25. package/dist/modules/build/commands/package/start/index.cjs.js +3 -1
  26. package/dist/modules/build/commands/package/start/startFrontend.cjs.js +1 -1
  27. package/dist/modules/build/commands/repo/build.cjs.js +46 -11
  28. package/dist/modules/{maintenance → build}/commands/repo/clean.cjs.js +7 -3
  29. package/dist/modules/build/commands/repo/start.cjs.js +54 -5
  30. package/dist/modules/build/index.cjs.js +32 -123
  31. package/dist/modules/build/lib/buildFrontend.cjs.js +2 -2
  32. package/dist/modules/build/lib/bundler/config.cjs.js +1 -1
  33. package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +1 -1
  34. package/dist/modules/build/lib/bundler/server.cjs.js +1 -1
  35. package/dist/modules/build/lib/config.cjs.js +94 -0
  36. package/dist/modules/build/lib/optionsParser.cjs.js +22 -0
  37. package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +1 -1
  38. package/dist/modules/build/lib/packager/productionPack.cjs.js +1 -1
  39. package/dist/modules/build/lib/role.cjs.js +1 -1
  40. package/dist/modules/config/commands/docs.cjs.js +19 -2
  41. package/dist/modules/config/commands/print.cjs.js +41 -13
  42. package/dist/modules/config/commands/schema.cjs.js +25 -6
  43. package/dist/modules/config/commands/validate.cjs.js +38 -7
  44. package/dist/modules/config/index.cjs.js +6 -65
  45. package/dist/modules/config/lib/config.cjs.js +6 -22
  46. package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +14 -3
  47. package/dist/modules/create-github-app/index.cjs.js +1 -9
  48. package/dist/modules/info/commands/info.cjs.js +26 -6
  49. package/dist/modules/info/index.cjs.js +1 -23
  50. package/dist/modules/lint/commands/package/lint.cjs.js +42 -10
  51. package/dist/modules/lint/commands/repo/lint.cjs.js +99 -27
  52. package/dist/modules/lint/index.cjs.js +2 -60
  53. package/dist/modules/lint/lib/optionsParser.cjs.js +22 -0
  54. package/dist/modules/maintenance/commands/repo/fix.cjs.js +32 -9
  55. package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +20 -4
  56. package/dist/modules/maintenance/index.cjs.js +2 -64
  57. package/dist/modules/migrate/commands/packageExports.cjs.js +9 -11
  58. package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +7 -3
  59. package/dist/modules/migrate/commands/packageRole.cjs.js +3 -1
  60. package/dist/modules/migrate/commands/packageScripts.cjs.js +11 -7
  61. package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +7 -3
  62. package/dist/modules/migrate/commands/versions/bump.cjs.js +48 -20
  63. package/dist/modules/migrate/commands/versions/migrate.cjs.js +24 -3
  64. package/dist/modules/migrate/index.cjs.js +12 -55
  65. package/dist/modules/new/commands/new.cjs.js +70 -15
  66. package/dist/modules/new/index.cjs.js +1 -29
  67. package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +5 -9
  68. package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +8 -8
  69. package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +18 -18
  70. package/dist/{lib → modules/new/lib}/version.cjs.js +22 -34
  71. package/dist/modules/test/commands/package/test.cjs.js +1 -10
  72. package/dist/modules/test/commands/repo/test.cjs.js +51 -39
  73. package/dist/modules/test/index.cjs.js +2 -32
  74. package/dist/modules/translations/commands/export.cjs.js +25 -1
  75. package/dist/modules/translations/commands/import.cjs.js +25 -1
  76. package/dist/modules/translations/index.cjs.js +2 -37
  77. package/dist/packages/backend-defaults/package.json.cjs.js +1 -1
  78. package/dist/packages/backend-plugin-api/package.json.cjs.js +1 -1
  79. package/dist/packages/backend-test-utils/package.json.cjs.js +1 -1
  80. package/dist/packages/catalog-client/package.json.cjs.js +1 -1
  81. package/dist/packages/cli/package.json.cjs.js +7 -6
  82. package/dist/packages/core-app-api/package.json.cjs.js +1 -1
  83. package/dist/packages/core-components/package.json.cjs.js +1 -1
  84. package/dist/packages/core-plugin-api/package.json.cjs.js +1 -1
  85. package/dist/packages/dev-utils/package.json.cjs.js +1 -1
  86. package/dist/packages/frontend-defaults/package.json.cjs.js +1 -1
  87. package/dist/packages/frontend-plugin-api/package.json.cjs.js +1 -1
  88. package/dist/packages/frontend-test-utils/package.json.cjs.js +1 -1
  89. package/dist/plugins/auth-backend/package.json.cjs.js +1 -1
  90. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +1 -1
  91. package/dist/plugins/catalog-node/package.json.cjs.js +1 -1
  92. package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
  93. package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +1 -1
  94. package/dist/wiring/CliInitializer.cjs.js +24 -7
  95. package/dist/wiring/version.cjs.js +20 -0
  96. package/package.json +26 -22
  97. package/dist/lib/cache/SuccessCache.cjs.js +0 -79
  98. package/dist/lib/lazy.cjs.js +0 -22
  99. package/dist/lib/optionsParser.cjs.js +0 -37
  100. package/dist/lib/versioning/Lockfile.cjs.js +0 -89
  101. package/dist/lib/yarnPlugin.cjs.js +0 -46
  102. /package/dist/modules/{maintenance → build}/lib/publishing.cjs.js +0 -0
  103. /package/dist/{lib → modules/build/lib}/typeDistProject.cjs.js +0 -0
  104. /package/dist/{lib → modules/migrate/lib}/versioning/packages.cjs.js +0 -0
  105. /package/dist/{lib → modules/migrate/lib}/versioning/yarn.cjs.js +0 -0
  106. /package/dist/{lib → wiring}/errors.cjs.js +0 -0
@@ -2,13 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var yargs = require('yargs');
6
5
  var factory = require('../../wiring/factory.cjs.js');
7
- var lazy = require('../../lib/lazy.cjs.js');
8
-
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
-
11
- var yargs__default = /*#__PURE__*/_interopDefaultCompat(yargs);
12
6
 
13
7
  var index = factory.createCliPlugin({
14
8
  pluginId: "info",
@@ -16,23 +10,7 @@ var index = factory.createCliPlugin({
16
10
  reg.addCommand({
17
11
  path: ["info"],
18
12
  description: "Show helpful information for debugging and reporting bugs",
19
- execute: async ({ args }) => {
20
- const argv = await yargs__default.default().options({
21
- include: {
22
- type: "string",
23
- array: true,
24
- default: [],
25
- description: "Glob patterns for additional packages to include (e.g., @spotify/backstage*)"
26
- },
27
- format: {
28
- type: "string",
29
- choices: ["text", "json"],
30
- default: "text",
31
- description: "Output format (text or json)"
32
- }
33
- }).help().parse(args);
34
- await lazy.lazy(() => import('./commands/info.cjs.js'), "default")(argv);
35
- }
13
+ execute: { loader: () => import('./commands/info.cjs.js') }
36
14
  });
37
15
  }
38
16
  });
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var fs = require('fs-extra');
6
+ var cleye = require('cleye');
6
7
  var cliCommon = require('@backstage/cli-common');
7
8
  var eslint = require('eslint');
8
9
 
@@ -10,29 +11,60 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
10
11
 
11
12
  var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
12
13
 
13
- var lint = async (directories, opts) => {
14
+ var lint = async ({ args, info }) => {
15
+ const {
16
+ flags: { fix, format, outputFile, maxWarnings },
17
+ _: directories
18
+ } = cleye.cli(
19
+ {
20
+ help: { ...info, usage: `${info.usage} [directories...]` },
21
+ booleanFlagNegation: true,
22
+ parameters: ["[directories...]"],
23
+ flags: {
24
+ fix: {
25
+ type: Boolean,
26
+ description: "Attempt to automatically fix violations"
27
+ },
28
+ format: {
29
+ type: String,
30
+ description: "Lint report output format",
31
+ default: "eslint-formatter-friendly"
32
+ },
33
+ outputFile: {
34
+ type: String,
35
+ description: "Write the lint report to a file instead of stdout"
36
+ },
37
+ maxWarnings: {
38
+ type: String,
39
+ description: "Fail if more than this number of warnings. -1 allows warnings. (default: -1)"
40
+ }
41
+ }
42
+ },
43
+ void 0,
44
+ args
45
+ );
14
46
  const eslint$1 = new eslint.ESLint({
15
47
  cwd: cliCommon.targetPaths.dir,
16
- fix: opts.fix,
48
+ fix,
17
49
  extensions: ["js", "jsx", "ts", "tsx", "mjs", "cjs"]
18
50
  });
19
51
  const results = await eslint$1.lintFiles(
20
52
  directories.length ? directories : ["."]
21
53
  );
22
- const maxWarnings = opts.maxWarnings ?? -1;
23
- const ignoreWarnings = +maxWarnings === -1;
24
- const failed = results.some((r) => r.errorCount > 0) || !ignoreWarnings && results.reduce((current, next) => current + next.warningCount, 0) > maxWarnings;
25
- if (opts.fix) {
54
+ const maxWarningsNum = maxWarnings ? +maxWarnings : -1;
55
+ const ignoreWarnings = maxWarningsNum === -1;
56
+ const failed = results.some((r) => r.errorCount > 0) || !ignoreWarnings && results.reduce((current, next) => current + next.warningCount, 0) > maxWarningsNum;
57
+ if (fix) {
26
58
  await eslint.ESLint.outputFixes(results);
27
59
  }
28
- const formatter = await eslint$1.loadFormatter(opts.format);
29
- if (opts.format === "eslint-formatter-friendly") {
60
+ const formatter = await eslint$1.loadFormatter(format);
61
+ if (format === "eslint-formatter-friendly") {
30
62
  process.chdir(cliCommon.targetPaths.rootDir);
31
63
  }
32
64
  const resultText = await formatter.format(results);
33
65
  if (resultText) {
34
- if (opts.outputFile) {
35
- await fs__default.default.writeFile(cliCommon.targetPaths.resolve(opts.outputFile), resultText);
66
+ if (outputFile) {
67
+ await fs__default.default.writeFile(cliCommon.targetPaths.resolve(outputFile), resultText);
36
68
  } else {
37
69
  console.log(resultText);
38
70
  }
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var chalk = require('chalk');
4
6
  var fs = require('fs-extra');
7
+ var cleye = require('cleye');
5
8
  var crypto = require('node:crypto');
6
9
  var path = require('node:path');
7
10
  var cliNode = require('@backstage/cli-node');
8
11
  var cliCommon = require('@backstage/cli-common');
9
- var optionsParser = require('../../../../lib/optionsParser.cjs.js');
10
- var SuccessCache = require('../../../../lib/cache/SuccessCache.cjs.js');
12
+ var optionsParser = require('../../lib/optionsParser.cjs.js');
11
13
 
12
14
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
15
 
@@ -19,28 +21,98 @@ function depCount(pkg) {
19
21
  const devDeps = pkg.devDependencies ? Object.keys(pkg.devDependencies).length : 0;
20
22
  return deps + devDeps;
21
23
  }
22
- async function command(opts, cmd) {
24
+ var lint = async ({ args, info }) => {
25
+ for (const flag of [
26
+ "outputFile",
27
+ "successCache",
28
+ "successCacheDir",
29
+ "maxWarnings"
30
+ ]) {
31
+ if (args.some((a) => a === `--${flag}` || a.startsWith(`--${flag}=`))) {
32
+ process.stderr.write(
33
+ `DEPRECATION WARNING: --${flag} is deprecated, use the kebab-case form instead
34
+ `
35
+ );
36
+ }
37
+ }
38
+ const {
39
+ flags: {
40
+ fix,
41
+ format,
42
+ outputFile,
43
+ successCache: useSuccessCache,
44
+ successCacheDir,
45
+ since,
46
+ maxWarnings
47
+ }
48
+ } = cleye.cli(
49
+ {
50
+ help: info,
51
+ booleanFlagNegation: true,
52
+ flags: {
53
+ fix: {
54
+ type: Boolean,
55
+ description: "Attempt to automatically fix violations"
56
+ },
57
+ format: {
58
+ type: String,
59
+ description: "Lint report output format",
60
+ default: "eslint-formatter-friendly"
61
+ },
62
+ outputFile: {
63
+ type: String,
64
+ description: "Write the lint report to a file instead of stdout"
65
+ },
66
+ successCache: {
67
+ type: Boolean,
68
+ description: "Enable success caching, which skips running tests for unchanged packages that were successful in the previous run"
69
+ },
70
+ successCacheDir: {
71
+ type: String,
72
+ description: "Set the success cache location, (default: node_modules/.cache/backstage-cli)"
73
+ },
74
+ since: {
75
+ type: String,
76
+ description: "Only lint packages that changed since the specified ref"
77
+ },
78
+ maxWarnings: {
79
+ type: String,
80
+ description: "Fail if more than this number of warnings. -1 allows warnings. (default: -1)"
81
+ }
82
+ }
83
+ },
84
+ void 0,
85
+ args
86
+ );
23
87
  let packages = await cliNode.PackageGraph.listTargetPackages();
24
- const cache = new SuccessCache.SuccessCache("lint", opts.successCacheDir);
25
- const cacheContext = opts.successCache ? {
88
+ const cache = cliNode.SuccessCache.create({
89
+ name: "lint",
90
+ basePath: successCacheDir
91
+ });
92
+ const cacheContext = useSuccessCache ? {
26
93
  entries: await cache.read(),
27
94
  lockfile: await cliNode.Lockfile.load(cliCommon.targetPaths.resolveRoot("yarn.lock"))
28
95
  } : void 0;
29
- if (opts.since) {
96
+ if (since) {
30
97
  const graph = cliNode.PackageGraph.fromPackages(packages);
31
98
  packages = await graph.listChangedPackages({
32
- ref: opts.since,
99
+ ref: since,
33
100
  analyzeLockfile: true
34
101
  });
35
102
  }
36
103
  packages.sort((a, b) => depCount(b.packageJson) - depCount(a.packageJson));
37
- if (opts.format === "eslint-formatter-friendly") {
104
+ if (format === "eslint-formatter-friendly") {
38
105
  process.chdir(cliCommon.targetPaths.rootDir);
39
106
  }
40
107
  if (!process.env.FORCE_COLOR) {
41
108
  process.env.FORCE_COLOR = "1";
42
109
  }
43
- const parseLintScript = optionsParser.createScriptOptionsParser(cmd, ["package", "lint"]);
110
+ const parseLintScript = optionsParser.createScriptOptionsParser(["package", "lint"], {
111
+ fix: { type: "boolean" },
112
+ format: { type: "string" },
113
+ "output-file": { type: "string" },
114
+ "max-warnings": { type: "string" }
115
+ });
44
116
  const items = await Promise.all(
45
117
  packages.map(async (pkg) => {
46
118
  const lintOptions = parseLintScript(pkg.packageJson.scripts?.lint);
@@ -73,20 +145,20 @@ async function command(opts, cmd) {
73
145
  items: items.filter((item) => item.lintOptions),
74
146
  // Filter out packages without lint script
75
147
  context: {
76
- fix: Boolean(opts.fix),
77
- format: opts.format,
148
+ fix: Boolean(fix),
149
+ format,
78
150
  shouldCache: Boolean(cacheContext),
79
- maxWarnings: opts.maxWarnings ?? -1,
151
+ maxWarnings: maxWarnings ?? "-1",
80
152
  successCache: cacheContext?.entries,
81
153
  rootDir: cliCommon.targetPaths.rootDir
82
154
  },
83
155
  workerFactory: async ({
84
- fix,
85
- format,
156
+ fix: workerFix,
157
+ format: workerFormat,
86
158
  shouldCache,
87
159
  successCache,
88
160
  rootDir,
89
- maxWarnings
161
+ maxWarnings: workerMaxWarnings
90
162
  }) => {
91
163
  const { ESLint } = require("eslint");
92
164
  const crypto = require("node:crypto");
@@ -102,7 +174,7 @@ async function command(opts, cmd) {
102
174
  const start = Date.now();
103
175
  const eslint = new ESLint({
104
176
  cwd: fullDir,
105
- fix,
177
+ fix: workerFix,
106
178
  extensions: ["js", "jsx", "ts", "tsx", "mjs", "cjs"]
107
179
  });
108
180
  let sha = void 0;
@@ -138,17 +210,17 @@ async function command(opts, cmd) {
138
210
  return { relativeDir, sha, failed: false };
139
211
  }
140
212
  }
141
- const formatter = await eslint.loadFormatter(format);
213
+ const formatter = await eslint.loadFormatter(workerFormat);
142
214
  const results = await eslint.lintFiles(["."]);
143
215
  const count = String(results.length).padStart(3);
144
216
  const time = ((Date.now() - start) / 1e3).toFixed(2);
145
217
  console.log(`Checked ${count} files in ${relativeDir} ${time}s`);
146
- if (fix) {
218
+ if (workerFix) {
147
219
  await ESLint.outputFixes(results);
148
220
  }
149
- const ignoreWarnings = +maxWarnings === -1;
221
+ const ignoreWarnings = +workerMaxWarnings === -1;
150
222
  const resultText = formatter.format(results);
151
- const failed2 = results.some((r) => r.errorCount > 0) || !ignoreWarnings && results.reduce((current, next) => current + next.warningCount, 0) > maxWarnings;
223
+ const failed2 = results.some((r) => r.errorCount > 0) || !ignoreWarnings && results.reduce((current, next) => current + next.warningCount, 0) > +workerMaxWarnings;
152
224
  return {
153
225
  relativeDir,
154
226
  resultText,
@@ -172,8 +244,8 @@ async function command(opts, cmd) {
172
244
  console.log(chalk__default.default.red(`Lint failed in ${relativeDir}`));
173
245
  failed = true;
174
246
  if (resultText) {
175
- if (opts.outputFile) {
176
- if (opts.format === "json") {
247
+ if (outputFile) {
248
+ if (format === "json") {
177
249
  jsonResults.push(resultText);
178
250
  } else {
179
251
  errorOutput += `${resultText}
@@ -188,15 +260,15 @@ async function command(opts, cmd) {
188
260
  outputSuccessCache.push(sha);
189
261
  }
190
262
  }
191
- if (opts.format === "json") {
263
+ if (format === "json") {
192
264
  let mergedJsonResults = [];
193
265
  for (const jsonResult of jsonResults) {
194
266
  mergedJsonResults = mergedJsonResults.concat(JSON.parse(jsonResult));
195
267
  }
196
268
  errorOutput = JSON.stringify(mergedJsonResults, null, 2);
197
269
  }
198
- if (opts.outputFile && errorOutput) {
199
- await fs__default.default.writeFile(cliCommon.targetPaths.resolveRoot(opts.outputFile), errorOutput);
270
+ if (outputFile && errorOutput) {
271
+ await fs__default.default.writeFile(cliCommon.targetPaths.resolveRoot(outputFile), errorOutput);
200
272
  }
201
273
  if (cacheContext) {
202
274
  await cache.write(outputSuccessCache);
@@ -204,7 +276,7 @@ async function command(opts, cmd) {
204
276
  if (failed) {
205
277
  process.exit(1);
206
278
  }
207
- }
279
+ };
208
280
 
209
- exports.command = command;
281
+ exports.default = lint;
210
282
  //# sourceMappingURL=lint.cjs.js.map
@@ -3,80 +3,22 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var factory = require('../../wiring/factory.cjs.js');
6
- var commander = require('commander');
7
- var lazy = require('../../lib/lazy.cjs.js');
8
6
 
9
- function registerPackageLintCommand(command) {
10
- command.arguments("[directories...]");
11
- command.option("--fix", "Attempt to automatically fix violations");
12
- command.option(
13
- "--format <format>",
14
- "Lint report output format",
15
- "eslint-formatter-friendly"
16
- );
17
- command.option(
18
- "--output-file <path>",
19
- "Write the lint report to a file instead of stdout"
20
- );
21
- command.option(
22
- "--max-warnings <number>",
23
- "Fail if more than this number of warnings. -1 allows warnings. (default: -1)"
24
- );
25
- command.description("Lint a package");
26
- command.action(lazy.lazy(() => import('./commands/package/lint.cjs.js'), "default"));
27
- }
28
7
  var index = factory.createCliPlugin({
29
8
  pluginId: "lint",
30
9
  init: async (reg) => {
31
10
  reg.addCommand({
32
11
  path: ["package", "lint"],
33
12
  description: "Lint a package",
34
- execute: async ({ args }) => {
35
- const command = new commander.Command();
36
- registerPackageLintCommand(command);
37
- await command.parseAsync(args, { from: "user" });
38
- }
13
+ execute: { loader: () => import('./commands/package/lint.cjs.js') }
39
14
  });
40
15
  reg.addCommand({
41
16
  path: ["repo", "lint"],
42
17
  description: "Lint a repository",
43
- execute: async ({ args }) => {
44
- const command = new commander.Command();
45
- registerPackageLintCommand(command.command("package").command("lint"));
46
- command.option("--fix", "Attempt to automatically fix violations");
47
- command.option(
48
- "--format <format>",
49
- "Lint report output format",
50
- "eslint-formatter-friendly"
51
- );
52
- command.option(
53
- "--output-file <path>",
54
- "Write the lint report to a file instead of stdout"
55
- );
56
- command.option(
57
- "--successCache",
58
- "Enable success caching, which skips running tests for unchanged packages that were successful in the previous run"
59
- );
60
- command.option(
61
- "--successCacheDir <path>",
62
- "Set the success cache location, (default: node_modules/.cache/backstage-cli)"
63
- );
64
- command.option(
65
- "--since <ref>",
66
- "Only lint packages that changed since the specified ref"
67
- );
68
- command.option(
69
- "--max-warnings <number>",
70
- "Fail if more than this number of warnings. -1 allows warnings. (default: -1)"
71
- );
72
- command.description("Lint a repository");
73
- command.action(lazy.lazy(() => import('./commands/repo/lint.cjs.js'), "command"));
74
- await command.parseAsync(args, { from: "user" });
75
- }
18
+ execute: { loader: () => import('./commands/repo/lint.cjs.js') }
76
19
  });
77
20
  }
78
21
  });
79
22
 
80
23
  exports.default = index;
81
- exports.registerPackageLintCommand = registerPackageLintCommand;
82
24
  //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var node_util = require('node:util');
4
+ var shellQuote = require('shell-quote');
5
+
6
+ function createScriptOptionsParser(commandPath, options) {
7
+ const expectedScript = `backstage-cli ${commandPath.join(" ")}`;
8
+ return (scriptStr) => {
9
+ if (!scriptStr || !scriptStr.startsWith(expectedScript)) {
10
+ return void 0;
11
+ }
12
+ const argsStr = scriptStr.slice(expectedScript.length).trim();
13
+ const args = argsStr ? shellQuote.parse(argsStr).filter(
14
+ (e) => typeof e === "string"
15
+ ) : [];
16
+ const { values } = node_util.parseArgs({ args, strict: false, options });
17
+ return values;
18
+ };
19
+ }
20
+
21
+ exports.createScriptOptionsParser = createScriptOptionsParser;
22
+ //# sourceMappingURL=optionsParser.cjs.js.map
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var cliNode = require('@backstage/cli-node');
6
+ var cleye = require('cleye');
4
7
  var fs = require('fs-extra');
5
8
  var path = require('node:path');
6
9
  var cliCommon = require('@backstage/cli-common');
7
- var publishing = require('../../lib/publishing.cjs.js');
8
10
 
9
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
12
 
@@ -362,18 +364,39 @@ function fixPeerModules(pkg) {
362
364
  }
363
365
  }
364
366
  }
365
- async function command(opts) {
367
+ var fix = async ({
368
+ args,
369
+ info
370
+ }) => {
371
+ const {
372
+ flags: { publish, check }
373
+ } = cleye.cli(
374
+ {
375
+ help: info,
376
+ booleanFlagNegation: true,
377
+ flags: {
378
+ publish: {
379
+ type: Boolean,
380
+ description: "Enable additional fixes that only apply when publishing packages"
381
+ },
382
+ check: {
383
+ type: Boolean,
384
+ description: "Fail if any packages would have been changed by the command"
385
+ }
386
+ }
387
+ },
388
+ void 0,
389
+ args
390
+ );
366
391
  const packages = await readFixablePackages();
367
392
  const fixRepositoryField = createRepositoryFieldFixer();
368
393
  const fixers = [fixPackageExports, fixSideEffects];
369
- if (opts.publish) {
394
+ if (publish) {
370
395
  fixers.push(
371
396
  fixRepositoryField,
372
397
  fixPluginId,
373
398
  fixPluginPackages,
374
- fixPeerModules,
375
- // Run the publish preflight check too, to make sure we don't uncover errors during publishing
376
- publishing.publishPreflightCheck
399
+ fixPeerModules
377
400
  );
378
401
  }
379
402
  for (const fixer of fixers) {
@@ -381,17 +404,17 @@ async function command(opts) {
381
404
  fixer(pkg, packages);
382
405
  }
383
406
  }
384
- if (opts.check) {
407
+ if (check) {
385
408
  if (printPackageFixHint(packages)) {
386
409
  process.exit(1);
387
410
  }
388
411
  } else {
389
412
  await writeFixedPackages(packages);
390
413
  }
391
- }
414
+ };
392
415
 
393
- exports.command = command;
394
416
  exports.createRepositoryFieldFixer = createRepositoryFieldFixer;
417
+ exports.default = fix;
395
418
  exports.fixPackageExports = fixPackageExports;
396
419
  exports.fixPeerModules = fixPeerModules;
397
420
  exports.fixPluginId = fixPluginId;
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var chalk = require('chalk');
4
6
  var eslint = require('eslint');
7
+ var cleye = require('cleye');
5
8
  var path = require('node:path');
6
9
  var cliNode = require('@backstage/cli-node');
7
10
  var cliCommon = require('@backstage/cli-common');
@@ -10,7 +13,20 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
10
13
 
11
14
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
12
15
 
13
- async function command(opts) {
16
+ var listDeprecations = async ({ args, info }) => {
17
+ const {
18
+ flags: { json }
19
+ } = cleye.cli(
20
+ {
21
+ help: info,
22
+ booleanFlagNegation: true,
23
+ flags: {
24
+ json: { type: Boolean, description: "Output as JSON" }
25
+ }
26
+ },
27
+ void 0,
28
+ args
29
+ );
14
30
  const packages = await cliNode.PackageGraph.listTargetPackages();
15
31
  const eslint$1 = new eslint.ESLint({
16
32
  cwd: cliCommon.targetPaths.dir,
@@ -56,7 +72,7 @@ async function command(opts) {
56
72
  stderr.clearLine(0);
57
73
  stderr.cursorTo(0);
58
74
  }
59
- if (opts.json) {
75
+ if (json) {
60
76
  console.log(JSON.stringify(deprecations, null, 2));
61
77
  } else {
62
78
  for (const d of deprecations) {
@@ -68,7 +84,7 @@ async function command(opts) {
68
84
  if (deprecations.length > 0) {
69
85
  process.exit(1);
70
86
  }
71
- }
87
+ };
72
88
 
73
- exports.command = command;
89
+ exports.default = listDeprecations;
74
90
  //# sourceMappingURL=list-deprecations.cjs.js.map
@@ -2,82 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var commander = require('commander');
6
5
  var factory = require('../../wiring/factory.cjs.js');
7
- var lazy = require('../../lib/lazy.cjs.js');
8
6
 
9
7
  var index = factory.createCliPlugin({
10
8
  pluginId: "maintenance",
11
9
  init: async (reg) => {
12
- reg.addCommand({
13
- path: ["package", "clean"],
14
- description: "Delete cache directories",
15
- execute: async ({ args }) => {
16
- const command = new commander.Command();
17
- const defaultCommand = command.action(
18
- lazy.lazy(() => import('./commands/package/clean.cjs.js'), "default")
19
- );
20
- await defaultCommand.parseAsync(args, { from: "user" });
21
- }
22
- });
23
- reg.addCommand({
24
- path: ["package", "prepack"],
25
- description: "Prepares a package for packaging before publishing",
26
- execute: async ({ args }) => {
27
- const command = new commander.Command();
28
- const defaultCommand = command.action(
29
- lazy.lazy(() => import('./commands/package/pack.cjs.js'), "pre")
30
- );
31
- await defaultCommand.parseAsync(args, { from: "user" });
32
- }
33
- });
34
- reg.addCommand({
35
- path: ["package", "postpack"],
36
- description: "Restores the changes made by the prepack command",
37
- execute: async ({ args }) => {
38
- const command = new commander.Command();
39
- const defaultCommand = command.action(
40
- lazy.lazy(() => import('./commands/package/pack.cjs.js'), "post")
41
- );
42
- await defaultCommand.parseAsync(args, { from: "user" });
43
- }
44
- });
45
10
  reg.addCommand({
46
11
  path: ["repo", "fix"],
47
12
  description: "Automatically fix packages in the project",
48
- execute: async ({ args }) => {
49
- const command = new commander.Command();
50
- const defaultCommand = command.option(
51
- "--publish",
52
- "Enable additional fixes that only apply when publishing packages"
53
- ).option(
54
- "--check",
55
- "Fail if any packages would have been changed by the command"
56
- ).action(lazy.lazy(() => import('./commands/repo/fix.cjs.js'), "command"));
57
- await defaultCommand.parseAsync(args, { from: "user" });
58
- }
59
- });
60
- reg.addCommand({
61
- path: ["repo", "clean"],
62
- description: "Delete cache and output directories",
63
- execute: async ({ args }) => {
64
- const command = new commander.Command();
65
- const defaultCommand = command.action(
66
- lazy.lazy(() => import('./commands/repo/clean.cjs.js'), "command")
67
- );
68
- await defaultCommand.parseAsync(args, { from: "user" });
69
- }
13
+ execute: { loader: () => import('./commands/repo/fix.cjs.js') }
70
14
  });
71
15
  reg.addCommand({
72
16
  path: ["repo", "list-deprecations"],
73
17
  description: "List deprecations",
74
- execute: async ({ args }) => {
75
- const command = new commander.Command();
76
- const defaultCommand = command.option("--json", "Output as JSON").action(
77
- lazy.lazy(() => import('./commands/repo/list-deprecations.cjs.js'), "command")
78
- );
79
- await defaultCommand.parseAsync(args, { from: "user" });
80
- }
18
+ execute: { loader: () => import('./commands/repo/list-deprecations.cjs.js') }
81
19
  });
82
20
  }
83
21
  });