@backstage/cli 0.28.0-next.0 → 0.28.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 (131) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/config/jest.js +123 -69
  3. package/config/jestCacheResultProcessor.cjs +23 -0
  4. package/config/jestSwcTransform.js +4 -1
  5. package/dist/commands/build/buildBackend.cjs.js +65 -0
  6. package/dist/commands/build/buildFrontend.cjs.js +56 -0
  7. package/dist/commands/build/command.cjs.js +72 -0
  8. package/dist/commands/build/index.cjs.js +8 -0
  9. package/dist/commands/buildWorkspace.cjs.js +24 -0
  10. package/dist/commands/clean/clean.cjs.js +19 -0
  11. package/dist/{cjs/docs-CDE82fWG.cjs.js → commands/config/docs.cjs.js} +4 -12
  12. package/dist/{cjs/print-BX8-7Nzg.cjs.js → commands/config/print.cjs.js} +4 -12
  13. package/dist/{cjs/schema-Cabm6I6c.cjs.js → commands/config/schema.cjs.js} +4 -12
  14. package/dist/commands/config/validate.cjs.js +19 -0
  15. package/dist/{cjs/index-DVDDx3pk.cjs.js → commands/create-github-app/GithubCreateAppServer.cjs.js} +2 -110
  16. package/dist/commands/create-github-app/index.cjs.js +117 -0
  17. package/dist/commands/index.cjs.js +231 -0
  18. package/dist/{cjs/info-CB7ln5K_.cjs.js → commands/info.cjs.js} +13 -17
  19. package/dist/{cjs/lint-6_0f9f26.cjs.js → commands/lint.cjs.js} +10 -10
  20. package/dist/commands/migrate/packageExports.cjs.js +17 -0
  21. package/dist/{cjs/packageLintConfigs-BBvQehRd.cjs.js → commands/migrate/packageLintConfigs.cjs.js} +2 -10
  22. package/dist/{cjs/packageRole-CkpKfhJA.cjs.js → commands/migrate/packageRole.cjs.js} +5 -8
  23. package/dist/{cjs/packageScripts-DX6dilK6.cjs.js → commands/migrate/packageScripts.cjs.js} +1 -1
  24. package/dist/{cjs/reactRouterDeps-CR-hjviw.cjs.js → commands/migrate/reactRouterDeps.cjs.js} +1 -1
  25. package/dist/commands/new/new.cjs.js +101 -0
  26. package/dist/commands/pack.cjs.js +29 -0
  27. package/dist/commands/repo/build.cjs.js +113 -0
  28. package/dist/{cjs/clean-bdpRw-oZ.cjs.js → commands/repo/clean.cjs.js} +5 -10
  29. package/dist/{cjs/fix-BTjof5XT.cjs.js → commands/repo/fix.cjs.js} +8 -13
  30. package/dist/commands/repo/lint.cjs.js +193 -0
  31. package/dist/{cjs/list-deprecations-DFgQENam.cjs.js → commands/repo/list-deprecations.cjs.js} +7 -12
  32. package/dist/commands/repo/optionsParser.cjs.js +37 -0
  33. package/dist/commands/repo/test.cjs.js +274 -0
  34. package/dist/commands/start/command.cjs.js +48 -0
  35. package/dist/commands/start/index.cjs.js +8 -0
  36. package/dist/commands/start/startBackend.cjs.js +112 -0
  37. package/dist/commands/start/startFrontend.cjs.js +47 -0
  38. package/dist/{cjs/test-YJMOGqXG.cjs.js → commands/test.cjs.js} +6 -12
  39. package/dist/{cjs/bump-d9dS56p9.cjs.js → commands/versions/bump.cjs.js} +21 -190
  40. package/dist/commands/versions/migrate.cjs.js +112 -0
  41. package/dist/index.cjs.js +29 -7
  42. package/dist/lib/builder/config.cjs.js +199 -0
  43. package/dist/lib/builder/packager.cjs.js +131 -0
  44. package/dist/lib/builder/plugins.cjs.js +71 -0
  45. package/dist/lib/builder/types.cjs.js +11 -0
  46. package/dist/lib/bundler/LinkedPackageResolvePlugin.cjs.js +47 -0
  47. package/dist/lib/bundler/backend.cjs.js +36 -0
  48. package/dist/{cjs/buildBackend-DXvz7jvh.cjs.js → lib/bundler/bundle.cjs.js} +26 -113
  49. package/dist/lib/bundler/config.cjs.js +469 -0
  50. package/dist/lib/bundler/hasReactDomClient.cjs.js +13 -0
  51. package/dist/lib/bundler/moduleFederation.cjs.js +28 -0
  52. package/dist/lib/bundler/optimization.cjs.js +63 -0
  53. package/dist/lib/bundler/packageDetection.cjs.js +117 -0
  54. package/dist/lib/bundler/paths.cjs.js +60 -0
  55. package/dist/lib/bundler/server.cjs.js +246 -0
  56. package/dist/lib/bundler/transforms.cjs.js +171 -0
  57. package/dist/lib/codeowners/codeowners.cjs.js +92 -0
  58. package/dist/{cjs/config-nCB2LQK-.cjs.js → lib/config.cjs.js} +6 -6
  59. package/dist/{cjs/entryPoints-CoHH4lBA.cjs.js → lib/entryPoints.cjs.js} +4 -1
  60. package/dist/lib/errors.cjs.js +45 -0
  61. package/dist/lib/experimental/IpcServer.cjs.js +60 -0
  62. package/dist/lib/experimental/ServerDataStore.cjs.js +36 -0
  63. package/dist/lib/experimental/startBackendExperimental.cjs.js +128 -0
  64. package/dist/lib/new/FactoryRegistry.cjs.js +96 -0
  65. package/dist/lib/new/factories/backendModule.cjs.js +82 -0
  66. package/dist/lib/new/factories/backendPlugin.cjs.js +78 -0
  67. package/dist/lib/new/factories/common/prompts.cjs.js +57 -0
  68. package/dist/lib/new/factories/common/tasks.cjs.js +66 -0
  69. package/dist/lib/new/factories/common/util.cjs.js +16 -0
  70. package/dist/lib/new/factories/frontendPlugin.cjs.js +107 -0
  71. package/dist/lib/new/factories/index.cjs.js +24 -0
  72. package/dist/lib/new/factories/nodeLibraryPackage.cjs.js +57 -0
  73. package/dist/lib/new/factories/pluginCommon.cjs.js +58 -0
  74. package/dist/lib/new/factories/pluginNode.cjs.js +58 -0
  75. package/dist/lib/new/factories/pluginWeb.cjs.js +58 -0
  76. package/dist/lib/new/factories/scaffolderModule.cjs.js +90 -0
  77. package/dist/lib/new/factories/webLibraryPackage.cjs.js +57 -0
  78. package/dist/lib/new/types.cjs.js +8 -0
  79. package/dist/lib/packager/createDistWorkspace.cjs.js +219 -0
  80. package/dist/{cjs/productionPack-Dfl28j3c.cjs.js → lib/packager/productionPack.cjs.js} +8 -96
  81. package/dist/{cjs/parallel-BszNaKyc.cjs.js → lib/parallel.cjs.js} +2 -1
  82. package/dist/lib/paths.cjs.js +8 -0
  83. package/dist/{cjs/publishing-DQtsKTbc.cjs.js → lib/publishing.cjs.js} +1 -1
  84. package/dist/{cjs/role-e0emQj8q.cjs.js → lib/role.cjs.js} +3 -3
  85. package/dist/{cjs/run-HW3lfDbM.cjs.js → lib/run.cjs.js} +6 -5
  86. package/dist/{cjs/svgrTemplate-BTjBQ3by.cjs.js → lib/svgrTemplate.cjs.js} +1 -1
  87. package/dist/lib/tasks.cjs.js +188 -0
  88. package/dist/lib/typeDistProject.cjs.js +94 -0
  89. package/dist/lib/urls.cjs.js +13 -0
  90. package/dist/lib/version.cjs.js +86 -0
  91. package/dist/{cjs/yarn-6FNAgNBK.cjs.js → lib/versioning/Lockfile.cjs.js} +1 -31
  92. package/dist/lib/versioning/packages.cjs.js +75 -0
  93. package/dist/lib/yarn.cjs.js +34 -0
  94. package/dist/packages/backend-defaults/package.json.cjs.js +6 -0
  95. package/dist/packages/backend-plugin-api/package.json.cjs.js +6 -0
  96. package/dist/packages/backend-test-utils/package.json.cjs.js +6 -0
  97. package/dist/packages/cli/package.json.cjs.js +159 -0
  98. package/dist/packages/config/package.json.cjs.js +6 -0
  99. package/dist/packages/core-app-api/package.json.cjs.js +6 -0
  100. package/dist/packages/core-components/package.json.cjs.js +6 -0
  101. package/dist/packages/core-plugin-api/package.json.cjs.js +6 -0
  102. package/dist/packages/dev-utils/package.json.cjs.js +6 -0
  103. package/dist/packages/test-utils/package.json.cjs.js +6 -0
  104. package/dist/packages/theme/package.json.cjs.js +6 -0
  105. package/dist/plugins/auth-backend/package.json.cjs.js +6 -0
  106. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +6 -0
  107. package/dist/plugins/scaffolder-node/package.json.cjs.js +6 -0
  108. package/package.json +23 -23
  109. package/dist/cjs/build-gNEKjjhr.cjs.js +0 -194
  110. package/dist/cjs/buildWorkspace-DLfI3EjD.cjs.js +0 -53
  111. package/dist/cjs/clean-Dpgqc3P2.cjs.js +0 -22
  112. package/dist/cjs/createDistWorkspace-DKzy-L-f.cjs.js +0 -576
  113. package/dist/cjs/index-7LxfekFu.cjs.js +0 -625
  114. package/dist/cjs/index-DsP5wbju.cjs.js +0 -131
  115. package/dist/cjs/index-v57xnvgT.cjs.js +0 -520
  116. package/dist/cjs/lint-DYO_SeK3.cjs.js +0 -91
  117. package/dist/cjs/moduleFederation-Dq0n1quT.cjs.js +0 -910
  118. package/dist/cjs/new-C0D_k25O.cjs.js +0 -1043
  119. package/dist/cjs/pack-D8AK7Uem.cjs.js +0 -34
  120. package/dist/cjs/packageExports-bg4mFuFZ.cjs.js +0 -27
  121. package/dist/cjs/test-5bQM0VRL.cjs.js +0 -126
  122. package/dist/cjs/validate-DKBlShmI.cjs.js +0 -28
  123. /package/templates/default-backend-module/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  124. /package/templates/default-backend-plugin/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  125. /package/templates/default-common-plugin-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  126. /package/templates/default-node-plugin-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  127. /package/templates/default-plugin/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  128. /package/templates/default-react-plugin-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  129. /package/templates/node-library-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  130. /package/templates/scaffolder-module/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  131. /package/templates/web-library-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
@@ -3,15 +3,7 @@
3
3
  var fs = require('fs-extra');
4
4
  var path = require('path');
5
5
  var cliNode = require('@backstage/cli-node');
6
- var run = require('./run-HW3lfDbM.cjs.js');
7
- require('child_process');
8
- require('./index-v57xnvgT.cjs.js');
9
- require('commander');
10
- require('chalk');
11
- require('semver');
12
- require('@backstage/cli-common');
13
- require('@backstage/errors');
14
- require('util');
6
+ var run = require('../../lib/run.cjs.js');
15
7
 
16
8
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
17
9
 
@@ -78,4 +70,4 @@ async function command() {
78
70
  }
79
71
 
80
72
  exports.command = command;
81
- //# sourceMappingURL=packageLintConfigs-BBvQehRd.cjs.js.map
73
+ //# sourceMappingURL=packageLintConfigs.cjs.js.map
@@ -1,22 +1,19 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var fs = require('fs-extra');
4
6
  var path = require('path');
5
7
  var getPackages = require('@manypkg/get-packages');
6
8
  var cliNode = require('@backstage/cli-node');
7
- var index = require('./index-v57xnvgT.cjs.js');
8
- require('commander');
9
- require('chalk');
10
- require('semver');
11
- require('@backstage/cli-common');
12
- require('@backstage/errors');
9
+ var paths = require('../../lib/paths.cjs.js');
13
10
 
14
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
12
 
16
13
  var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
17
14
 
18
15
  var packageRole = async () => {
19
- const { packages } = await getPackages.getPackages(index.paths.targetDir);
16
+ const { packages } = await getPackages.getPackages(paths.paths.targetDir);
20
17
  await Promise.all(
21
18
  packages.map(async ({ dir, packageJson: pkg }) => {
22
19
  const { name } = pkg;
@@ -55,4 +52,4 @@ var packageRole = async () => {
55
52
  };
56
53
 
57
54
  exports.default = packageRole;
58
- //# sourceMappingURL=packageRole-CkpKfhJA.cjs.js.map
55
+ //# sourceMappingURL=packageRole.cjs.js.map
@@ -80,4 +80,4 @@ async function command() {
80
80
  }
81
81
 
82
82
  exports.command = command;
83
- //# sourceMappingURL=packageScripts-DX6dilK6.cjs.js.map
83
+ //# sourceMappingURL=packageScripts.cjs.js.map
@@ -44,4 +44,4 @@ async function command() {
44
44
  }
45
45
 
46
46
  exports.command = command;
47
- //# sourceMappingURL=reactRouterDeps-CR-hjviw.cjs.js.map
47
+ //# sourceMappingURL=reactRouterDeps.cjs.js.map
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var os = require('os');
6
+ var fs = require('fs-extra');
7
+ var path = require('path');
8
+ var FactoryRegistry = require('../../lib/new/FactoryRegistry.cjs.js');
9
+ var cliNode = require('@backstage/cli-node');
10
+ var paths = require('../../lib/paths.cjs.js');
11
+ var errors = require('@backstage/errors');
12
+ var tasks = require('../../lib/tasks.cjs.js');
13
+
14
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
+
16
+ var os__default = /*#__PURE__*/_interopDefaultCompat(os);
17
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
18
+
19
+ function parseOptions(optionStrings) {
20
+ const options = {};
21
+ for (const str of optionStrings) {
22
+ const [key] = str.split("=", 1);
23
+ const value = str.slice(key.length + 1);
24
+ if (!key || str[key.length] !== "=") {
25
+ throw new Error(
26
+ `Invalid option '${str}', must be of the format <key>=<value>`
27
+ );
28
+ }
29
+ options[key] = value;
30
+ }
31
+ return options;
32
+ }
33
+ var _new = async (opts) => {
34
+ const factory = await FactoryRegistry.FactoryRegistry.interactiveSelect(opts.select);
35
+ const providedOptions = parseOptions(opts.option);
36
+ const options = await FactoryRegistry.FactoryRegistry.populateOptions(
37
+ factory,
38
+ providedOptions
39
+ );
40
+ let defaultVersion = "0.1.0";
41
+ if (opts.baseVersion) {
42
+ defaultVersion = opts.baseVersion;
43
+ } else {
44
+ const lernaVersion = await fs__default.default.readJson(paths.paths.resolveTargetRoot("lerna.json")).then((pkg) => pkg.version).catch(() => void 0);
45
+ if (lernaVersion) {
46
+ defaultVersion = lernaVersion;
47
+ }
48
+ }
49
+ const tempDirs = new Array();
50
+ async function createTemporaryDirectory(name) {
51
+ const dir = await fs__default.default.mkdtemp(path.join(os__default.default.tmpdir(), name));
52
+ tempDirs.push(dir);
53
+ return dir;
54
+ }
55
+ const license = opts.license ?? "Apache-2.0";
56
+ let modified = false;
57
+ try {
58
+ await factory.create(options, {
59
+ isMonoRepo: await cliNode.isMonoRepo(),
60
+ defaultVersion,
61
+ license,
62
+ scope: opts.scope?.replace(/^@/, ""),
63
+ npmRegistry: opts.npmRegistry,
64
+ private: Boolean(opts.private),
65
+ createTemporaryDirectory,
66
+ markAsModified() {
67
+ modified = true;
68
+ }
69
+ });
70
+ tasks.Task.log();
71
+ tasks.Task.log(`\u{1F389} Successfully created ${factory.name}`);
72
+ tasks.Task.log();
73
+ } catch (error) {
74
+ errors.assertError(error);
75
+ tasks.Task.error(error.message);
76
+ if (modified) {
77
+ tasks.Task.log("It seems that something went wrong in the creation process \u{1F914}");
78
+ tasks.Task.log();
79
+ tasks.Task.log(
80
+ "We have left the changes that were made intact in case you want to"
81
+ );
82
+ tasks.Task.log(
83
+ "continue manually, but you can also revert the changes and try again."
84
+ );
85
+ tasks.Task.error(`\u{1F525} Failed to create ${factory.name}!`);
86
+ }
87
+ } finally {
88
+ for (const dir of tempDirs) {
89
+ try {
90
+ await fs__default.default.remove(dir);
91
+ } catch (error) {
92
+ console.error(
93
+ `Failed to remove temporary directory '${dir}', ${error}`
94
+ );
95
+ }
96
+ }
97
+ }
98
+ };
99
+
100
+ exports.default = _new;
101
+ //# sourceMappingURL=new.cjs.js.map
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var productionPack = require('../lib/packager/productionPack.cjs.js');
4
+ var paths = require('../lib/paths.cjs.js');
5
+ var fs = require('fs-extra');
6
+ var publishing = require('../lib/publishing.cjs.js');
7
+ var typeDistProject = require('../lib/typeDistProject.cjs.js');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
+
11
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
12
+
13
+ const pre = async () => {
14
+ publishing.publishPreflightCheck({
15
+ dir: paths.paths.targetDir,
16
+ packageJson: await fs__default.default.readJson(paths.paths.resolveTarget("package.json"))
17
+ });
18
+ await productionPack.productionPack({
19
+ packageDir: paths.paths.targetDir,
20
+ featureDetectionProject: await typeDistProject.createTypeDistProject()
21
+ });
22
+ };
23
+ const post = async () => {
24
+ await productionPack.revertProductionPack(paths.paths.targetDir);
25
+ };
26
+
27
+ exports.post = post;
28
+ exports.pre = pre;
29
+ //# sourceMappingURL=pack.cjs.js.map
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var path = require('path');
5
+ var packager = require('../../lib/builder/packager.cjs.js');
6
+ var paths = require('../../lib/paths.cjs.js');
7
+ var cliNode = require('@backstage/cli-node');
8
+ var parallel = require('../../lib/parallel.cjs.js');
9
+ var buildFrontend = require('../build/buildFrontend.cjs.js');
10
+ var buildBackend = require('../build/buildBackend.cjs.js');
11
+ var optionsParser = require('./optionsParser.cjs.js');
12
+
13
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
14
+
15
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
16
+
17
+ async function command(opts, cmd) {
18
+ let packages = await cliNode.PackageGraph.listTargetPackages();
19
+ if (opts.since) {
20
+ const graph = cliNode.PackageGraph.fromPackages(packages);
21
+ const changedPackages = await graph.listChangedPackages({
22
+ ref: opts.since,
23
+ analyzeLockfile: true
24
+ });
25
+ const withDevDependents = graph.collectPackageNames(
26
+ changedPackages.map((pkg) => pkg.name),
27
+ (pkg) => pkg.localDevDependents.keys()
28
+ );
29
+ packages = Array.from(withDevDependents).map((name) => graph.get(name));
30
+ }
31
+ const apps = new Array();
32
+ const backends = new Array();
33
+ const parseBuildScript = optionsParser.createScriptOptionsParser(cmd, ["package", "build"]);
34
+ const options = packages.flatMap((pkg) => {
35
+ const role = pkg.packageJson.backstage?.role ?? cliNode.PackageRoles.detectRoleFromPackage(pkg.packageJson);
36
+ if (!role) {
37
+ console.warn(`Ignored ${pkg.packageJson.name} because it has no role`);
38
+ return [];
39
+ }
40
+ if (role === "frontend") {
41
+ apps.push(pkg);
42
+ return [];
43
+ } else if (role === "backend") {
44
+ backends.push(pkg);
45
+ return [];
46
+ }
47
+ const outputs = packager.getOutputsForRole(role);
48
+ if (outputs.size === 0) {
49
+ console.warn(`Ignored ${pkg.packageJson.name} because it has no output`);
50
+ return [];
51
+ }
52
+ const buildOptions = parseBuildScript(pkg.packageJson.scripts?.build);
53
+ if (!buildOptions) {
54
+ console.warn(
55
+ `Ignored ${pkg.packageJson.name} because it does not have a matching build script`
56
+ );
57
+ return [];
58
+ }
59
+ return {
60
+ targetDir: pkg.dir,
61
+ packageJson: pkg.packageJson,
62
+ outputs,
63
+ logPrefix: `${chalk__default.default.cyan(path.relative(paths.paths.targetRoot, pkg.dir))}: `,
64
+ workspacePackages: packages,
65
+ minify: opts.minify ?? buildOptions.minify
66
+ };
67
+ });
68
+ console.log("Building packages");
69
+ await packager.buildPackages(options);
70
+ if (opts.all) {
71
+ console.log("Building apps");
72
+ await parallel.runParallelWorkers({
73
+ items: apps,
74
+ parallelismFactor: 1 / 2,
75
+ worker: async (pkg) => {
76
+ const buildOptions = parseBuildScript(pkg.packageJson.scripts?.build);
77
+ if (!buildOptions) {
78
+ console.warn(
79
+ `Ignored ${pkg.packageJson.name} because it does not have a matching build script`
80
+ );
81
+ return;
82
+ }
83
+ await buildFrontend.buildFrontend({
84
+ targetDir: pkg.dir,
85
+ configPaths: buildOptions.config ?? [],
86
+ writeStats: Boolean(buildOptions.stats)
87
+ });
88
+ }
89
+ });
90
+ console.log("Building backends");
91
+ await parallel.runParallelWorkers({
92
+ items: backends,
93
+ parallelismFactor: 1 / 2,
94
+ worker: async (pkg) => {
95
+ const buildOptions = parseBuildScript(pkg.packageJson.scripts?.build);
96
+ if (!buildOptions) {
97
+ console.warn(
98
+ `Ignored ${pkg.packageJson.name} because it does not have a matching build script`
99
+ );
100
+ return;
101
+ }
102
+ await buildBackend.buildBackend({
103
+ targetDir: pkg.dir,
104
+ skipBuildDependencies: true,
105
+ minify: opts.minify ?? buildOptions.minify
106
+ });
107
+ }
108
+ });
109
+ }
110
+ }
111
+
112
+ exports.command = command;
113
+ //# sourceMappingURL=build.cjs.js.map
@@ -5,12 +5,7 @@ var fs = require('fs-extra');
5
5
  var path = require('path');
6
6
  var util = require('util');
7
7
  var cliNode = require('@backstage/cli-node');
8
- var index = require('./index-v57xnvgT.cjs.js');
9
- require('commander');
10
- require('chalk');
11
- require('semver');
12
- require('@backstage/cli-common');
13
- require('@backstage/errors');
8
+ var paths = require('../../lib/paths.cjs.js');
14
9
 
15
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
16
11
 
@@ -19,9 +14,9 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
19
14
  const execFile = util.promisify(child_process.execFile);
20
15
  async function command() {
21
16
  const packages = await cliNode.PackageGraph.listTargetPackages();
22
- await fs__default.default.remove(index.paths.resolveTargetRoot("dist"));
23
- await fs__default.default.remove(index.paths.resolveTargetRoot("dist-types"));
24
- await fs__default.default.remove(index.paths.resolveTargetRoot("coverage"));
17
+ await fs__default.default.remove(paths.paths.resolveTargetRoot("dist"));
18
+ await fs__default.default.remove(paths.paths.resolveTargetRoot("dist-types"));
19
+ await fs__default.default.remove(paths.paths.resolveTargetRoot("coverage"));
25
20
  await Promise.all(
26
21
  Array.from(Array(10), async () => {
27
22
  while (packages.length > 0) {
@@ -45,4 +40,4 @@ async function command() {
45
40
  }
46
41
 
47
42
  exports.command = command;
48
- //# sourceMappingURL=clean-bdpRw-oZ.cjs.js.map
43
+ //# sourceMappingURL=clean.cjs.js.map
@@ -3,13 +3,8 @@
3
3
  var cliNode = require('@backstage/cli-node');
4
4
  var fs = require('fs-extra');
5
5
  var path = require('path');
6
- var index = require('./index-v57xnvgT.cjs.js');
7
- var publishing = require('./publishing-DQtsKTbc.cjs.js');
8
- require('commander');
9
- require('chalk');
10
- require('semver');
11
- require('@backstage/cli-common');
12
- require('@backstage/errors');
6
+ var paths = require('../../lib/paths.cjs.js');
7
+ var publishing = require('../../lib/publishing.cjs.js');
13
8
 
14
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
10
 
@@ -22,7 +17,7 @@ async function readFixablePackages() {
22
17
  function printPackageFixHint(packages) {
23
18
  const changed = packages.filter((pkg) => pkg.changed);
24
19
  if (changed.length > 0) {
25
- const rootPkg = require(index.paths.resolveTargetRoot("package.json"));
20
+ const rootPkg = require(paths.paths.resolveTargetRoot("package.json"));
26
21
  const fixCmd = rootPkg.scripts?.fix === "backstage-cli repo fix" ? "fix" : "backstage-cli repo fix";
27
22
  console.log(
28
23
  `The following packages are out of sync, run 'yarn ${fixCmd}' to fix them:`
@@ -141,7 +136,7 @@ function fixSideEffects(pkg) {
141
136
  pkg.changed = true;
142
137
  }
143
138
  function createRepositoryFieldFixer() {
144
- const rootPkg = require(index.paths.resolveTargetRoot("package.json"));
139
+ const rootPkg = require(paths.paths.resolveTargetRoot("package.json"));
145
140
  const rootRepoField = rootPkg.repository;
146
141
  if (!rootRepoField) {
147
142
  return () => {
@@ -153,7 +148,7 @@ function createRepositoryFieldFixer() {
153
148
  return (pkg) => {
154
149
  const expectedPath = path.posix.join(
155
150
  rootDir,
156
- path.relative(index.paths.targetRoot, pkg.dir)
151
+ path.relative(paths.paths.targetRoot, pkg.dir)
157
152
  );
158
153
  const repoField = pkg.packageJson.repository;
159
154
  if (!repoField || typeof repoField === "string") {
@@ -227,7 +222,7 @@ function fixPluginId(pkg) {
227
222
  const guessedPluginId = guessPluginId(role, pkg.packageJson.name);
228
223
  if (!guessedPluginId && (role === "frontend-plugin" || role === "frontend-plugin-module" || role === "backend-plugin" || role === "backend-plugin-module")) {
229
224
  const path$1 = path.relative(
230
- index.paths.targetRoot,
225
+ paths.paths.targetRoot,
231
226
  path.resolve(pkg.dir, "package.json")
232
227
  );
233
228
  const msg = `Failed to guess plugin ID for "${pkg.packageJson.name}", please set the 'backstage.pluginId' field manually in "${path$1}"`;
@@ -298,7 +293,7 @@ function fixPluginPackages(pkg, repoPackages) {
298
293
  return;
299
294
  }
300
295
  const path$1 = path.relative(
301
- index.paths.targetRoot,
296
+ paths.paths.targetRoot,
302
297
  path.resolve(pkg.dir, "package.json")
303
298
  );
304
299
  const suggestedRole = role === "frontend-plugin-module" ? "web-library" : "node-library";
@@ -359,4 +354,4 @@ exports.fixSideEffects = fixSideEffects;
359
354
  exports.printPackageFixHint = printPackageFixHint;
360
355
  exports.readFixablePackages = readFixablePackages;
361
356
  exports.writeFixedPackages = writeFixedPackages;
362
- //# sourceMappingURL=fix-BTjof5XT.cjs.js.map
357
+ //# sourceMappingURL=fix.cjs.js.map
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var fs = require('fs-extra');
5
+ var crypto = require('crypto');
6
+ var path = require('path');
7
+ var cliNode = require('@backstage/cli-node');
8
+ var paths = require('../../lib/paths.cjs.js');
9
+ var parallel = require('../../lib/parallel.cjs.js');
10
+ var optionsParser = require('./optionsParser.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
15
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
16
+
17
+ function depCount(pkg) {
18
+ const deps = pkg.dependencies ? Object.keys(pkg.dependencies).length : 0;
19
+ const devDeps = pkg.devDependencies ? Object.keys(pkg.devDependencies).length : 0;
20
+ return deps + devDeps;
21
+ }
22
+ const CACHE_FILE_NAME = "lint-cache.json";
23
+ async function readCache(dir) {
24
+ try {
25
+ const data = await fs__default.default.readJson(path.resolve(dir, CACHE_FILE_NAME));
26
+ if (!Array.isArray(data)) {
27
+ return void 0;
28
+ }
29
+ if (data.some((x) => typeof x !== "string")) {
30
+ return void 0;
31
+ }
32
+ return data;
33
+ } catch {
34
+ return void 0;
35
+ }
36
+ }
37
+ async function writeCache(dir, cache) {
38
+ await fs__default.default.mkdirp(dir);
39
+ await fs__default.default.writeJson(path.resolve(dir, CACHE_FILE_NAME), cache, { spaces: 2 });
40
+ }
41
+ async function command(opts, cmd) {
42
+ let packages = await cliNode.PackageGraph.listTargetPackages();
43
+ const cacheDir = path.resolve(
44
+ opts.successCacheDir ?? "node_modules/.cache/backstage-cli"
45
+ );
46
+ const cacheContext = opts.successCache ? {
47
+ cache: await readCache(cacheDir),
48
+ lockfile: await cliNode.Lockfile.load(paths.paths.resolveTargetRoot("yarn.lock"))
49
+ } : void 0;
50
+ if (opts.since) {
51
+ const graph = cliNode.PackageGraph.fromPackages(packages);
52
+ packages = await graph.listChangedPackages({
53
+ ref: opts.since,
54
+ analyzeLockfile: true
55
+ });
56
+ }
57
+ packages.sort((a, b) => depCount(b.packageJson) - depCount(a.packageJson));
58
+ if (opts.format === "eslint-formatter-friendly") {
59
+ process.chdir(paths.paths.targetRoot);
60
+ }
61
+ if (!process.env.FORCE_COLOR) {
62
+ process.env.FORCE_COLOR = "1";
63
+ }
64
+ const parseLintScript = optionsParser.createScriptOptionsParser(cmd, ["package", "lint"]);
65
+ const items = await Promise.all(
66
+ packages.map(async (pkg) => {
67
+ const lintOptions = parseLintScript(pkg.packageJson.scripts?.lint);
68
+ const base = {
69
+ fullDir: pkg.dir,
70
+ relativeDir: path.relative(paths.paths.targetRoot, pkg.dir),
71
+ lintOptions,
72
+ parentHash: void 0
73
+ };
74
+ if (!cacheContext) {
75
+ return base;
76
+ }
77
+ const hash = crypto.createHash("sha1");
78
+ hash.update(
79
+ cacheContext.lockfile.getDependencyTreeHash(pkg.packageJson.name)
80
+ );
81
+ hash.update("\0");
82
+ hash.update(JSON.stringify(lintOptions));
83
+ hash.update("\0");
84
+ hash.update(process.version);
85
+ hash.update("\0");
86
+ hash.update("v1");
87
+ return {
88
+ ...base,
89
+ parentHash: hash.digest("hex")
90
+ };
91
+ })
92
+ );
93
+ const resultsList = await parallel.runWorkerQueueThreads({
94
+ items,
95
+ workerData: {
96
+ fix: Boolean(opts.fix),
97
+ format: opts.format,
98
+ shouldCache: Boolean(cacheContext),
99
+ successCache: cacheContext?.cache
100
+ },
101
+ workerFactory: async ({ fix, format, shouldCache, successCache }) => {
102
+ const { ESLint } = require("eslint");
103
+ const crypto = require("crypto");
104
+ const recursiveReadDir = require("recursive-readdir");
105
+ const { readFile } = require("fs/promises");
106
+ const { relative: workerRelativePath } = require("path");
107
+ return async ({
108
+ fullDir,
109
+ relativeDir,
110
+ lintOptions,
111
+ parentHash
112
+ }) => {
113
+ process.cwd = () => fullDir;
114
+ const start = Date.now();
115
+ const eslint = new ESLint({
116
+ cwd: fullDir,
117
+ fix,
118
+ extensions: ["js", "jsx", "ts", "tsx", "mjs", "cjs"]
119
+ });
120
+ let sha = void 0;
121
+ if (shouldCache) {
122
+ const result = await recursiveReadDir(fullDir);
123
+ const hash = crypto.createHash("sha1");
124
+ hash.update(parentHash);
125
+ hash.update("\0");
126
+ for (const path of result.sort()) {
127
+ if (await eslint.isPathIgnored(path)) {
128
+ continue;
129
+ }
130
+ hash.update(workerRelativePath(fullDir, path));
131
+ hash.update("\0");
132
+ hash.update(await readFile(path));
133
+ hash.update("\0");
134
+ hash.update(
135
+ JSON.stringify(await eslint.calculateConfigForFile(path))
136
+ );
137
+ hash.update("\0");
138
+ }
139
+ sha = await hash.digest("hex");
140
+ if (successCache?.includes(sha)) {
141
+ console.log(`Skipped ${relativeDir} due to cache hit`);
142
+ return { relativeDir, sha, failed: false };
143
+ }
144
+ }
145
+ const formatter = await eslint.loadFormatter(format);
146
+ const results = await eslint.lintFiles(["."]);
147
+ const count = String(results.length).padStart(3);
148
+ const time = ((Date.now() - start) / 1e3).toFixed(2);
149
+ console.log(`Checked ${count} files in ${relativeDir} ${time}s`);
150
+ if (fix) {
151
+ await ESLint.outputFixes(results);
152
+ }
153
+ const maxWarnings = lintOptions?.maxWarnings ?? 0;
154
+ const resultText = formatter.format(results);
155
+ const failed2 = results.some((r) => r.errorCount > 0) || results.reduce((current, next) => current + next.warningCount, 0) > maxWarnings;
156
+ return {
157
+ relativeDir,
158
+ resultText,
159
+ failed: failed2,
160
+ sha
161
+ };
162
+ };
163
+ }
164
+ });
165
+ const outputSuccessCache = [];
166
+ let failed = false;
167
+ for (const {
168
+ relativeDir,
169
+ resultText,
170
+ failed: runFailed,
171
+ sha
172
+ } of resultsList) {
173
+ if (runFailed) {
174
+ console.log(chalk__default.default.red(`Lint failed in ${relativeDir}`));
175
+ failed = true;
176
+ if (resultText) {
177
+ console.log();
178
+ console.log(resultText.trimStart());
179
+ }
180
+ } else if (sha) {
181
+ outputSuccessCache.push(sha);
182
+ }
183
+ }
184
+ if (cacheContext) {
185
+ await writeCache(cacheDir, outputSuccessCache);
186
+ }
187
+ if (failed) {
188
+ process.exit(1);
189
+ }
190
+ }
191
+
192
+ exports.command = command;
193
+ //# sourceMappingURL=lint.cjs.js.map
@@ -4,12 +4,7 @@ var chalk = require('chalk');
4
4
  var eslint = require('eslint');
5
5
  var path = require('path');
6
6
  var cliNode = require('@backstage/cli-node');
7
- var index = require('./index-v57xnvgT.cjs.js');
8
- require('commander');
9
- require('fs-extra');
10
- require('semver');
11
- require('@backstage/cli-common');
12
- require('@backstage/errors');
7
+ var paths = require('../../lib/paths.cjs.js');
13
8
 
14
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
10
 
@@ -18,14 +13,14 @@ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
18
13
  async function command(opts) {
19
14
  const packages = await cliNode.PackageGraph.listTargetPackages();
20
15
  const eslint$1 = new eslint.ESLint({
21
- cwd: index.paths.targetDir,
16
+ cwd: paths.paths.targetDir,
22
17
  overrideConfig: {
23
18
  plugins: ["deprecation"],
24
19
  rules: {
25
20
  "deprecation/deprecation": "error"
26
21
  },
27
22
  parserOptions: {
28
- project: [index.paths.resolveTargetRoot("tsconfig.json")]
23
+ project: [paths.paths.resolveTargetRoot("tsconfig.json")]
29
24
  }
30
25
  },
31
26
  extensions: ["jsx", "ts", "tsx", "mjs", "cjs"]
@@ -35,14 +30,14 @@ async function command(opts) {
35
30
  stderr.write("Initializing TypeScript...");
36
31
  }
37
32
  const deprecations = [];
38
- for (const [index$1, pkg] of packages.entries()) {
33
+ for (const [index, pkg] of packages.entries()) {
39
34
  const results = await eslint$1.lintFiles(pkg.dir);
40
35
  for (const result of results) {
41
36
  for (const message of result.messages) {
42
37
  if (message.ruleId !== "deprecation/deprecation") {
43
38
  continue;
44
39
  }
45
- const path$1 = path.relative(index.paths.targetRoot, result.filePath);
40
+ const path$1 = path.relative(paths.paths.targetRoot, result.filePath);
46
41
  deprecations.push({
47
42
  path: path$1,
48
43
  message: message.message,
@@ -54,7 +49,7 @@ async function command(opts) {
54
49
  if (stderr.isTTY) {
55
50
  stderr.clearLine(0);
56
51
  stderr.cursorTo(0);
57
- stderr.write(`Scanning packages ${index$1 + 1}/${packages.length}`);
52
+ stderr.write(`Scanning packages ${index + 1}/${packages.length}`);
58
53
  }
59
54
  }
60
55
  if (stderr.isTTY) {
@@ -76,4 +71,4 @@ async function command(opts) {
76
71
  }
77
72
 
78
73
  exports.command = command;
79
- //# sourceMappingURL=list-deprecations-DFgQENam.cjs.js.map
74
+ //# sourceMappingURL=list-deprecations.cjs.js.map