@backstage/cli 0.36.0-next.1 → 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 (80) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/index.cjs.js +1 -0
  3. package/dist/modules/auth/commands/list.cjs.js +23 -0
  4. package/dist/modules/auth/commands/login.cjs.js +316 -0
  5. package/dist/modules/auth/commands/logout.cjs.js +55 -0
  6. package/dist/modules/auth/commands/printToken.cjs.js +41 -0
  7. package/dist/modules/auth/commands/select.cjs.js +32 -0
  8. package/dist/modules/auth/commands/show.cjs.js +59 -0
  9. package/dist/modules/auth/index.cjs.js +44 -0
  10. package/dist/modules/auth/lib/auth.cjs.js +60 -0
  11. package/dist/modules/auth/lib/http.cjs.js +26 -0
  12. package/dist/modules/auth/lib/localServer.cjs.js +80 -0
  13. package/dist/modules/auth/lib/pkce.cjs.js +23 -0
  14. package/dist/modules/auth/lib/prompt.cjs.js +44 -0
  15. package/dist/modules/auth/lib/secretStore.cjs.js +81 -0
  16. package/dist/modules/auth/lib/storage.cjs.js +152 -0
  17. package/dist/modules/build/commands/buildWorkspace.cjs.js +31 -2
  18. package/dist/modules/build/commands/package/build/command.cjs.js +62 -15
  19. package/dist/modules/build/commands/package/build/index.cjs.js +3 -1
  20. package/dist/modules/build/commands/package/clean.cjs.js +1 -1
  21. package/dist/modules/build/commands/package/postpack.cjs.js +1 -1
  22. package/dist/modules/build/commands/package/prepack.cjs.js +1 -1
  23. package/dist/modules/build/commands/package/start/command.cjs.js +68 -11
  24. package/dist/modules/build/commands/package/start/index.cjs.js +3 -1
  25. package/dist/modules/build/commands/repo/build.cjs.js +45 -10
  26. package/dist/modules/build/commands/repo/clean.cjs.js +1 -1
  27. package/dist/modules/build/commands/repo/start.cjs.js +54 -5
  28. package/dist/modules/build/index.cjs.js +5 -129
  29. package/dist/modules/build/lib/optionsParser.cjs.js +9 -24
  30. package/dist/modules/build/lib/role.cjs.js +1 -1
  31. package/dist/modules/config/commands/docs.cjs.js +1 -0
  32. package/dist/modules/config/commands/print.cjs.js +3 -2
  33. package/dist/modules/config/commands/schema.cjs.js +3 -2
  34. package/dist/modules/config/commands/validate.cjs.js +1 -0
  35. package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +14 -3
  36. package/dist/modules/create-github-app/index.cjs.js +1 -9
  37. package/dist/modules/info/commands/info.cjs.js +1 -0
  38. package/dist/modules/lint/commands/package/lint.cjs.js +42 -10
  39. package/dist/modules/lint/commands/repo/lint.cjs.js +95 -25
  40. package/dist/modules/lint/index.cjs.js +2 -60
  41. package/dist/modules/lint/lib/optionsParser.cjs.js +9 -24
  42. package/dist/modules/maintenance/commands/repo/fix.cjs.js +31 -5
  43. package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +20 -4
  44. package/dist/modules/maintenance/index.cjs.js +2 -20
  45. package/dist/modules/migrate/commands/packageExports.cjs.js +1 -1
  46. package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +1 -1
  47. package/dist/modules/migrate/commands/packageRole.cjs.js +1 -1
  48. package/dist/modules/migrate/commands/packageScripts.cjs.js +1 -1
  49. package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +1 -1
  50. package/dist/modules/migrate/commands/versions/bump.cjs.js +41 -11
  51. package/dist/modules/migrate/commands/versions/migrate.cjs.js +24 -3
  52. package/dist/modules/migrate/index.cjs.js +2 -25
  53. package/dist/modules/new/commands/new.cjs.js +70 -15
  54. package/dist/modules/new/index.cjs.js +1 -29
  55. package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +2 -2
  56. package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +2 -2
  57. package/dist/modules/test/commands/package/test.cjs.js +1 -7
  58. package/dist/modules/test/commands/repo/test.cjs.js +45 -34
  59. package/dist/modules/test/index.cjs.js +2 -32
  60. package/dist/modules/translations/commands/export.cjs.js +1 -0
  61. package/dist/modules/translations/commands/import.cjs.js +1 -0
  62. package/dist/packages/backend-defaults/package.json.cjs.js +1 -1
  63. package/dist/packages/backend-plugin-api/package.json.cjs.js +1 -1
  64. package/dist/packages/backend-test-utils/package.json.cjs.js +1 -1
  65. package/dist/packages/catalog-client/package.json.cjs.js +1 -1
  66. package/dist/packages/cli/package.json.cjs.js +7 -4
  67. package/dist/packages/core-app-api/package.json.cjs.js +1 -1
  68. package/dist/packages/core-components/package.json.cjs.js +1 -1
  69. package/dist/packages/core-plugin-api/package.json.cjs.js +1 -1
  70. package/dist/packages/frontend-defaults/package.json.cjs.js +1 -1
  71. package/dist/packages/frontend-plugin-api/package.json.cjs.js +1 -1
  72. package/dist/packages/frontend-test-utils/package.json.cjs.js +1 -1
  73. package/dist/plugins/auth-backend/package.json.cjs.js +1 -1
  74. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +1 -1
  75. package/dist/plugins/catalog-node/package.json.cjs.js +1 -1
  76. package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
  77. package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +1 -1
  78. package/dist/wiring/CliInitializer.cjs.js +12 -2
  79. package/package.json +23 -17
  80. package/dist/wiring/lazy.cjs.js +0 -22
@@ -8,6 +8,7 @@ var fs = require('fs-extra');
8
8
  var chalk = require('chalk');
9
9
  var minimatch = require('minimatch');
10
10
  var semver = require('semver');
11
+ var cleye = require('cleye');
11
12
  var errors = require('@backstage/errors');
12
13
  var path = require('node:path');
13
14
  var cliNode = require('@backstage/cli-node');
@@ -36,11 +37,40 @@ function extendsDefaultPattern(pattern) {
36
37
  }
37
38
  return minimatch.minimatch("@backstage/", pattern.slice(0, -1));
38
39
  }
39
- var bump = async (opts) => {
40
+ var bump = async ({ args, info }) => {
41
+ const {
42
+ flags: { pattern: patternFlag, release, skipInstall, skipMigrate }
43
+ } = cleye.cli(
44
+ {
45
+ help: info,
46
+ booleanFlagNegation: true,
47
+ flags: {
48
+ pattern: {
49
+ type: String,
50
+ description: "Override glob for matching packages to upgrade"
51
+ },
52
+ release: {
53
+ type: String,
54
+ description: "Bump to a specific Backstage release line or version",
55
+ default: "main"
56
+ },
57
+ skipInstall: {
58
+ type: Boolean,
59
+ description: "Skips yarn install step"
60
+ },
61
+ skipMigrate: {
62
+ type: Boolean,
63
+ description: "Skips migration of any moved packages"
64
+ }
65
+ }
66
+ },
67
+ void 0,
68
+ args
69
+ );
40
70
  const lockfilePath = cliCommon.targetPaths.resolveRoot("yarn.lock");
41
71
  const lockfile = await cliNode.Lockfile.load(lockfilePath);
42
72
  const yarnPluginEnabled = await cliNode.hasBackstageYarnPlugin();
43
- let pattern = opts.pattern;
73
+ let pattern = patternFlag;
44
74
  if (!pattern) {
45
75
  console.log(`Using default pattern glob ${DEFAULT_PATTERN_GLOB}`);
46
76
  pattern = DEFAULT_PATTERN_GLOB;
@@ -56,13 +86,13 @@ var bump = async (opts) => {
56
86
  findTargetVersion = createStrictVersionFinder({
57
87
  releaseManifest
58
88
  });
59
- } else if (semver__default.default.valid(opts.release)) {
60
- releaseManifest = await releaseManifests.getManifestByVersion({ version: opts.release });
89
+ } else if (semver__default.default.valid(release)) {
90
+ releaseManifest = await releaseManifests.getManifestByVersion({ version: release });
61
91
  findTargetVersion = createStrictVersionFinder({
62
92
  releaseManifest
63
93
  });
64
94
  } else {
65
- if (opts.release === "next") {
95
+ if (release === "next") {
66
96
  const next = await releaseManifests.getManifestByReleaseLine({
67
97
  releaseLine: "next",
68
98
  versionsBaseUrl: node_process.env.BACKSTAGE_VERSIONS_BASE_URL
@@ -74,12 +104,12 @@ var bump = async (opts) => {
74
104
  releaseManifest = semver__default.default.gt(next.releaseVersion, main.releaseVersion) ? next : main;
75
105
  } else {
76
106
  releaseManifest = await releaseManifests.getManifestByReleaseLine({
77
- releaseLine: opts.release,
107
+ releaseLine: release,
78
108
  versionsBaseUrl: node_process.env.BACKSTAGE_VERSIONS_BASE_URL
79
109
  });
80
110
  }
81
111
  findTargetVersion = createVersionFinder({
82
- releaseLine: opts.releaseLine,
112
+ releaseLine: release,
83
113
  releaseManifest
84
114
  });
85
115
  }
@@ -181,18 +211,18 @@ var bump = async (opts) => {
181
211
  )
182
212
  );
183
213
  }
184
- if (!opts.skipInstall) {
214
+ if (!skipInstall) {
185
215
  await utils.runYarnInstall();
186
216
  } else {
187
217
  console.log();
188
218
  console.log(chalk__default.default.yellow(`Skipping yarn install`));
189
219
  }
190
- if (!opts.skipMigrate) {
220
+ if (!skipMigrate) {
191
221
  console.log();
192
222
  const changed = await migrate.migrateMovedPackages({
193
- pattern: opts.pattern
223
+ pattern: patternFlag
194
224
  });
195
- if (changed && !opts.skipInstall) {
225
+ if (changed && !skipInstall) {
196
226
  await utils.runYarnInstall();
197
227
  }
198
228
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var cliNode = require('@backstage/cli-node');
6
6
  var chalk = require('chalk');
7
7
  var path = require('node:path');
8
+ var cleye = require('cleye');
8
9
  var fs = require('fs-extra');
9
10
  var minimatch = require('minimatch');
10
11
  var utils = require('../../lib/utils.cjs.js');
@@ -15,10 +16,30 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
15
16
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
16
17
  var replace__default = /*#__PURE__*/_interopDefaultCompat(replace);
17
18
 
18
- var migrate = async (options) => {
19
+ var migrate = async ({ args, info }) => {
20
+ const {
21
+ flags: { pattern, skipCodeChanges }
22
+ } = cleye.cli(
23
+ {
24
+ help: info,
25
+ booleanFlagNegation: true,
26
+ flags: {
27
+ pattern: {
28
+ type: String,
29
+ description: "Override glob for matching packages to upgrade"
30
+ },
31
+ skipCodeChanges: {
32
+ type: Boolean,
33
+ description: "Skip code changes and only update package.json files"
34
+ }
35
+ }
36
+ },
37
+ void 0,
38
+ args
39
+ );
19
40
  const changed = await migrateMovedPackages({
20
- pattern: options.pattern,
21
- skipCodeChanges: options.skipCodeChanges
41
+ pattern,
42
+ skipCodeChanges
22
43
  });
23
44
  if (changed) {
24
45
  await utils.runYarnInstall();
@@ -3,8 +3,6 @@
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('../../wiring/lazy.cjs.js');
8
6
 
9
7
  var index = factory.createCliPlugin({
10
8
  pluginId: "migrate",
@@ -12,33 +10,12 @@ var index = factory.createCliPlugin({
12
10
  reg.addCommand({
13
11
  path: ["versions:migrate"],
14
12
  description: "Migrate any plugins that have been moved to the @backstage-community namespace automatically",
15
- execute: async ({ args }) => {
16
- const command = new commander.Command();
17
- const defaultCommand = command.option(
18
- "--pattern <glob>",
19
- "Override glob for matching packages to upgrade"
20
- ).option(
21
- "--skip-code-changes",
22
- "Skip code changes and only update package.json files"
23
- ).action(lazy.lazy(() => import('./commands/versions/migrate.cjs.js'), "default"));
24
- await defaultCommand.parseAsync(args, { from: "user" });
25
- }
13
+ execute: { loader: () => import('./commands/versions/migrate.cjs.js') }
26
14
  });
27
15
  reg.addCommand({
28
16
  path: ["versions:bump"],
29
17
  description: "Bump Backstage packages to the latest versions",
30
- execute: async ({ args }) => {
31
- const command = new commander.Command();
32
- const defaultCommand = command.option(
33
- "--pattern <glob>",
34
- "Override glob for matching packages to upgrade"
35
- ).option(
36
- "--release <version|next|main>",
37
- "Bump to a specific Backstage release line or version",
38
- "main"
39
- ).option("--skip-install", "Skips yarn install step").option("--skip-migrate", "Skips migration of any moved packages").action(lazy.lazy(() => import('./commands/versions/bump.cjs.js'), "default"));
40
- await defaultCommand.parseAsync(args, { from: "user" });
41
- }
18
+ execute: { loader: () => import('./commands/versions/bump.cjs.js') }
42
19
  });
43
20
  reg.addCommand({
44
21
  path: ["migrate", "package-roles"],
@@ -2,17 +2,73 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var cleye = require('cleye');
5
6
  var createNewPackage = require('../lib/createNewPackage.cjs.js');
6
7
 
7
- var _new = async (opts) => {
8
+ var _new = async ({ args, info }) => {
9
+ for (const flag of ["skipInstall", "npmRegistry", "baseVersion"]) {
10
+ if (args.some((a) => a === `--${flag}` || a.startsWith(`--${flag}=`))) {
11
+ process.stderr.write(
12
+ `DEPRECATION WARNING: --${flag} is deprecated, use the kebab-case form instead
13
+ `
14
+ );
15
+ }
16
+ }
8
17
  const {
9
- option: rawArgOptions,
10
- select: preselectedTemplateId,
11
- skipInstall,
12
- scope,
13
- private: isPrivate,
14
- ...otherGlobals
15
- } = opts;
18
+ flags: {
19
+ select,
20
+ option: rawArgOptions,
21
+ skipInstall,
22
+ scope,
23
+ npmRegistry,
24
+ baseVersion,
25
+ license,
26
+ private: isPrivate
27
+ }
28
+ } = cleye.cli(
29
+ {
30
+ help: info,
31
+ booleanFlagNegation: true,
32
+ flags: {
33
+ select: {
34
+ type: String,
35
+ description: "Select the thing you want to be creating upfront"
36
+ },
37
+ option: {
38
+ type: [String],
39
+ description: "Pre-fill options for the creation process",
40
+ default: []
41
+ },
42
+ skipInstall: {
43
+ type: Boolean,
44
+ description: `Skips running 'yarn install' and 'yarn lint --fix'`
45
+ },
46
+ scope: {
47
+ type: String,
48
+ description: "The scope to use for new packages"
49
+ },
50
+ npmRegistry: {
51
+ type: String,
52
+ description: "The package registry to use for new packages"
53
+ },
54
+ baseVersion: {
55
+ type: String,
56
+ description: "The version to use for any new packages (default: 0.1.0)"
57
+ },
58
+ license: {
59
+ type: String,
60
+ description: "The license to use for any new packages (default: Apache-2.0)"
61
+ },
62
+ private: {
63
+ type: Boolean,
64
+ description: "Mark new packages as private",
65
+ default: true
66
+ }
67
+ }
68
+ },
69
+ void 0,
70
+ args
71
+ );
16
72
  const prefilledParams = parseParams(rawArgOptions);
17
73
  let pluginInfix = void 0;
18
74
  let packagePrefix = void 0;
@@ -21,24 +77,23 @@ var _new = async (opts) => {
21
77
  packagePrefix = normalizedScope.includes("/") ? normalizedScope : `${normalizedScope}/`;
22
78
  pluginInfix = scope.includes("backstage") ? "plugin-" : "backstage-plugin-";
23
79
  }
24
- if (isPrivate === false || // set to false with --no-private flag
25
- Object.values(otherGlobals).filter(Boolean).length !== 0) {
80
+ if (isPrivate === false || [npmRegistry, baseVersion, license].filter(Boolean).length !== 0) {
26
81
  console.warn(
27
82
  `Global template configuration via CLI flags is deprecated, see https://backstage.io/docs/cli/new for information on how to configure package templating`
28
83
  );
29
84
  }
30
85
  await createNewPackage.createNewPackage({
31
86
  prefilledParams,
32
- preselectedTemplateId,
87
+ preselectedTemplateId: select,
33
88
  configOverrides: {
34
- license: otherGlobals.license,
35
- version: otherGlobals.baseVersion,
89
+ license,
90
+ version: baseVersion,
36
91
  private: isPrivate,
37
- publishRegistry: otherGlobals.npmRegistry,
92
+ publishRegistry: npmRegistry,
38
93
  packageNamePrefix: packagePrefix,
39
94
  packageNamePluginInfix: pluginInfix
40
95
  },
41
- skipInstall
96
+ skipInstall: Boolean(skipInstall)
42
97
  });
43
98
  };
44
99
  function parseParams(optionStrings) {
@@ -3,8 +3,6 @@
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('../../wiring/lazy.cjs.js');
8
6
  var errors = require('@backstage/errors');
9
7
 
10
8
  var index = factory.createCliPlugin({
@@ -13,33 +11,7 @@ var index = factory.createCliPlugin({
13
11
  reg.addCommand({
14
12
  path: ["new"],
15
13
  description: "Open up an interactive guide to creating new things in your app",
16
- execute: async ({ args }) => {
17
- const command = new commander.Command();
18
- const defaultCommand = command.storeOptionsAsProperties(false).description(
19
- "Open up an interactive guide to creating new things in your app"
20
- ).option(
21
- "--select <name>",
22
- "Select the thing you want to be creating upfront"
23
- ).option(
24
- "--option <name>=<value>",
25
- "Pre-fill options for the creation process",
26
- (opt, arr) => [...arr, opt],
27
- []
28
- ).option(
29
- "--skip-install",
30
- `Skips running 'yarn install' and 'yarn lint --fix'`
31
- ).option("--scope <scope>", "The scope to use for new packages").option(
32
- "--npm-registry <URL>",
33
- "The package registry to use for new packages"
34
- ).option(
35
- "--baseVersion <version>",
36
- "The version to use for any new packages (default: 0.1.0)"
37
- ).option(
38
- "--license <license>",
39
- "The license to use for any new packages (default: Apache-2.0)"
40
- ).option("--no-private", "Do not mark new packages as private").action(lazy.lazy(() => import('./commands/new.cjs.js'), "default"));
41
- await defaultCommand.parseAsync(args, { from: "user" });
42
- }
14
+ execute: { loader: () => import('./commands/new.cjs.js') }
43
15
  });
44
16
  reg.addCommand({
45
17
  path: ["create"],
@@ -4,7 +4,7 @@ var zod = require('zod');
4
4
  var fs = require('fs-extra');
5
5
  var recursiveReaddir = require('recursive-readdir');
6
6
  var path = require('node:path');
7
- var yaml = require('yaml');
7
+ var YAML = require('yaml');
8
8
  var cliCommon = require('@backstage/cli-common');
9
9
  var types = require('../types.cjs.js');
10
10
  var errors = require('@backstage/errors');
@@ -31,7 +31,7 @@ async function loadPortableTemplate(pointer) {
31
31
  error
32
32
  );
33
33
  });
34
- const rawTemplate = yaml.parse(templateContent);
34
+ const rawTemplate = YAML.parse(templateContent);
35
35
  const parsed = templateDefinitionSchema.safeParse(rawTemplate);
36
36
  if (!parsed.success) {
37
37
  throw new errors.ForwardedError(
@@ -5,7 +5,7 @@ var path = require('node:path');
5
5
  var cliCommon = require('@backstage/cli-common');
6
6
  var defaultTemplates = require('../defaultTemplates.cjs.js');
7
7
  var types = require('../types.cjs.js');
8
- var yaml = require('yaml');
8
+ var YAML = require('yaml');
9
9
  var zod = require('zod');
10
10
  var v3 = require('zod-validation-error/v3');
11
11
  var errors = require('@backstage/errors');
@@ -116,7 +116,7 @@ const partialTemplateDefinitionSchema = zod.z.object({
116
116
  });
117
117
  async function peekLocalTemplateDefinition(target) {
118
118
  const content = await fs__default.default.readFile(target, "utf8");
119
- const rawTemplate = yaml.parse(content);
119
+ const rawTemplate = YAML.parse(content);
120
120
  const parsed = partialTemplateDefinitionSchema.safeParse(rawTemplate);
121
121
  if (!parsed.success) {
122
122
  throw v3.fromZodError(parsed.error);
@@ -12,13 +12,7 @@ function includesAnyOf(hayStack, ...needles) {
12
12
  }
13
13
  return false;
14
14
  }
15
- var test = async (_opts, cmd) => {
16
- let parent = cmd;
17
- while (parent.parent) {
18
- parent = parent.parent;
19
- }
20
- const allArgs = parent.args;
21
- const args = allArgs.slice(allArgs.indexOf("test") + 1);
15
+ var test = async ({ args }) => {
22
16
  if (!includesAnyOf(args, "-c", "--config")) {
23
17
  args.push("--config", cliCommon.findOwnPaths(__dirname).resolve("config/jest.js"));
24
18
  }
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var os = require('node:os');
4
6
  var crypto = require('node:crypto');
7
+ var cleye = require('cleye');
5
8
  var yargs = require('yargs');
6
9
  var jestCli = require('jest-cli');
7
10
  var path = require('node:path');
@@ -71,31 +74,45 @@ function createFlagFinder(args) {
71
74
  return false;
72
75
  };
73
76
  }
74
- function removeOptionArg(args, option, size = 2) {
75
- let changed = false;
76
- do {
77
- changed = false;
78
- const index = args.indexOf(option);
79
- if (index >= 0) {
80
- changed = true;
81
- args.splice(index, size);
82
- }
83
- const indexEq = args.findIndex((arg) => arg.startsWith(`${option}=`));
84
- if (indexEq >= 0) {
85
- changed = true;
86
- args.splice(indexEq, 1);
87
- }
88
- } while (changed);
89
- }
90
- async function command(opts, cmd) {
77
+ var test = async ({ args, info }) => {
91
78
  const testGlobal = global;
92
- let parent = cmd;
93
- while (parent.parent) {
94
- parent = parent.parent;
79
+ for (const flag of ["successCache", "successCacheDir", "jestHelp"]) {
80
+ if (args.some((a) => a === `--${flag}` || a.startsWith(`--${flag}=`))) {
81
+ process.stderr.write(
82
+ `DEPRECATION WARNING: --${flag} is deprecated, use the kebab-case form instead
83
+ `
84
+ );
85
+ }
95
86
  }
96
- const allArgs = parent.args;
97
- const args = allArgs.slice(allArgs.indexOf("test") + 1);
87
+ const { flags: opts } = cleye.cli(
88
+ {
89
+ help: info,
90
+ booleanFlagNegation: true,
91
+ flags: {
92
+ since: {
93
+ type: String,
94
+ description: "Only include test packages changed since the specified ref"
95
+ },
96
+ successCache: {
97
+ type: Boolean,
98
+ description: "Cache and skip tests for unchanged packages"
99
+ },
100
+ successCacheDir: {
101
+ type: String,
102
+ description: "Directory for the success cache"
103
+ },
104
+ jestHelp: {
105
+ type: Boolean,
106
+ description: "Show Jest's own help output"
107
+ }
108
+ },
109
+ ignoreArgv: (type) => type === "unknown-flag" || type === "argument"
110
+ },
111
+ void 0,
112
+ args
113
+ );
98
114
  const hasFlags = createFlagFinder(args);
115
+ const sinceRef = opts.since || void 0;
99
116
  const { _: parsedArgs } = await yargs__default.default(args).options(jestCli.yargsOptions).argv;
100
117
  if (!hasFlags("-c", "--config")) {
101
118
  args.push("--config", cliCommon.findOwnPaths(__dirname).resolve("config/jest.js"));
@@ -104,7 +121,7 @@ async function command(opts, cmd) {
104
121
  args.push("--passWithNoTests");
105
122
  }
106
123
  let isSingleWatchMode = args.includes("--watch");
107
- if (!opts.since && !process.env.CI && !hasFlags("--coverage", "--watch", "--watchAll")) {
124
+ if (!sinceRef && !process.env.CI && !hasFlags("--coverage", "--watch", "--watchAll")) {
108
125
  const isGitRepo = () => cliCommon.runCheck(["git", "rev-parse", "--is-inside-work-tree"]);
109
126
  const isMercurialRepo = () => cliCommon.runCheck(["hg", "--cwd", ".", "root"]);
110
127
  if (await isGitRepo() || await isMercurialRepo()) {
@@ -140,9 +157,6 @@ async function command(opts, cmd) {
140
157
  if (os__default.default.cpus().length <= 3 && !hasFlags("-i", "--runInBand", "-w", "--maxWorkers")) {
141
158
  args.push("--maxWorkers=2");
142
159
  }
143
- if (opts.since) {
144
- removeOptionArg(args, "--since");
145
- }
146
160
  let packageGraph;
147
161
  async function getPackageGraph() {
148
162
  if (packageGraph) {
@@ -153,10 +167,10 @@ async function command(opts, cmd) {
153
167
  return packageGraph;
154
168
  }
155
169
  let selectedProjects = void 0;
156
- if (opts.since && !hasFlags("--selectProjects")) {
170
+ if (sinceRef && !hasFlags("--selectProjects")) {
157
171
  const graph = await getPackageGraph();
158
172
  const changedPackages = await graph.listChangedPackages({
159
- ref: opts.since,
173
+ ref: sinceRef,
160
174
  analyzeLockfile: true
161
175
  });
162
176
  selectedProjects = Array.from(
@@ -180,13 +194,10 @@ async function command(opts, cmd) {
180
194
  if (!process.env.NODE_OPTIONS?.includes("--node-snapshot")) {
181
195
  process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ` : ""}--no-node-snapshot`;
182
196
  }
183
- if (args.includes("--jest-help")) {
184
- removeOptionArg(args, "--jest-help");
197
+ if (opts.jestHelp) {
185
198
  args.push("--help");
186
199
  }
187
200
  if (opts.successCache) {
188
- removeOptionArg(args, "--successCache", 1);
189
- removeOptionArg(args, "--successCacheDir");
190
201
  if (parsedArgs.length > 0) {
191
202
  throw new Error(
192
203
  `The --successCache flag can not be combined with the following arguments: ${parsedArgs.join(
@@ -281,8 +292,8 @@ async function command(opts, cmd) {
281
292
  };
282
293
  }
283
294
  await jestCli.run(args);
284
- }
295
+ };
285
296
 
286
- exports.command = command;
287
297
  exports.createFlagFinder = createFlagFinder;
298
+ exports.default = test;
288
299
  //# sourceMappingURL=test.cjs.js.map
@@ -3,8 +3,6 @@
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('../../wiring/lazy.cjs.js');
8
6
 
9
7
  var index = factory.createCliPlugin({
10
8
  pluginId: "test",
@@ -12,40 +10,12 @@ var index = factory.createCliPlugin({
12
10
  reg.addCommand({
13
11
  path: ["repo", "test"],
14
12
  description: "Run tests, forwarding args to Jest, defaulting to watch mode",
15
- execute: async ({ args }) => {
16
- const command = new commander.Command();
17
- command.allowUnknownOption(true);
18
- command.allowExcessArguments(true);
19
- command.option(
20
- "--since <ref>",
21
- "Only test packages that changed since the specified ref"
22
- );
23
- command.option("--successCache", "Enable success caching");
24
- command.option(
25
- "--successCacheDir <path>",
26
- "Set the success cache location, (default: node_modules/.cache/backstage-cli)"
27
- );
28
- command.option(
29
- "--jest-help",
30
- "Show help for Jest CLI options, which are passed through"
31
- );
32
- command.action(lazy.lazy(() => import('./commands/repo/test.cjs.js'), "command"));
33
- await command.parseAsync(args, { from: "user" });
34
- }
13
+ execute: { loader: () => import('./commands/repo/test.cjs.js') }
35
14
  });
36
15
  reg.addCommand({
37
16
  path: ["package", "test"],
38
17
  description: "Run tests, forwarding args to Jest, defaulting to watch mode",
39
- execute: async ({ args }) => {
40
- const command = new commander.Command();
41
- command.allowUnknownOption(true);
42
- command.allowExcessArguments(true);
43
- command.helpOption("--backstage-cli-help");
44
- command.action(
45
- lazy.lazy(() => import('./commands/package/test.cjs.js'), "default")
46
- );
47
- await command.parseAsync(args, { from: "user" });
48
- }
18
+ execute: { loader: () => import('./commands/package/test.cjs.js') }
49
19
  });
50
20
  }
51
21
  });
@@ -20,6 +20,7 @@ var _export = async ({ args, info }) => {
20
20
  } = cleye.cli(
21
21
  {
22
22
  help: info,
23
+ booleanFlagNegation: true,
23
24
  flags: {
24
25
  output: {
25
26
  type: String,
@@ -19,6 +19,7 @@ var _import = async ({ args, info }) => {
19
19
  } = cleye.cli(
20
20
  {
21
21
  help: info,
22
+ booleanFlagNegation: true,
22
23
  flags: {
23
24
  input: {
24
25
  type: String,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.16.0-next.1";
3
+ var version = "0.16.0-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.7.1-next.0";
3
+ var version = "1.8.0-next.1";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.11.1-next.1";
3
+ var version = "1.11.1-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.14.0-next.1";
3
+ var version = "1.14.0-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map