@backstage/cli 0.35.4 → 0.36.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/config/jest.js +2 -2
- package/dist/index.cjs.js +1 -0
- package/dist/modules/build/commands/package/build/command.cjs.js +7 -7
- package/dist/modules/build/commands/package/clean.cjs.js +21 -0
- package/dist/modules/build/commands/package/postpack.cjs.js +15 -0
- package/dist/modules/build/commands/package/prepack.cjs.js +29 -0
- package/dist/modules/build/commands/package/start/command.cjs.js +3 -3
- package/dist/modules/build/commands/package/start/startBackend.cjs.js +2 -2
- package/dist/modules/build/commands/package/start/startFrontend.cjs.js +4 -5
- package/dist/modules/build/commands/repo/build.cjs.js +7 -8
- package/dist/modules/{maintenance → build}/commands/repo/clean.cjs.js +10 -7
- package/dist/modules/build/commands/repo/start.cjs.js +3 -3
- package/dist/modules/build/index.cjs.js +37 -4
- package/dist/modules/build/lib/buildBackend.cjs.js +0 -2
- package/dist/modules/build/lib/buildFrontend.cjs.js +3 -6
- package/dist/modules/build/lib/builder/config.cjs.js +5 -5
- package/dist/modules/build/lib/builder/packager.cjs.js +7 -8
- package/dist/modules/build/lib/bundler/config.cjs.js +2 -3
- package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +2 -2
- package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +2 -2
- package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +3 -3
- package/dist/modules/build/lib/bundler/packageDetection.cjs.js +2 -2
- package/dist/modules/build/lib/bundler/paths.cjs.js +8 -6
- package/dist/modules/build/lib/bundler/server.cjs.js +11 -11
- package/dist/modules/build/lib/config.cjs.js +94 -0
- package/dist/{lib → modules/build/lib}/optionsParser.cjs.js +2 -2
- package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +10 -10
- package/dist/modules/build/lib/packager/productionPack.cjs.js +2 -2
- package/dist/{lib → modules/build/lib}/role.cjs.js +2 -2
- package/dist/modules/build/lib/runner/runBackend.cjs.js +2 -2
- package/dist/{lib → modules/build/lib}/typeDistProject.cjs.js +2 -2
- package/dist/modules/config/commands/docs.cjs.js +18 -2
- package/dist/modules/config/commands/print.cjs.js +38 -11
- package/dist/modules/config/commands/schema.cjs.js +22 -4
- package/dist/modules/config/commands/validate.cjs.js +37 -7
- package/dist/modules/config/index.cjs.js +6 -65
- package/dist/modules/config/lib/config.cjs.js +10 -26
- package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +2 -2
- package/dist/modules/create-github-app/index.cjs.js +1 -1
- package/dist/modules/info/commands/info.cjs.js +29 -11
- package/dist/modules/info/index.cjs.js +1 -23
- package/dist/modules/lint/commands/package/lint.cjs.js +4 -4
- package/dist/modules/lint/commands/repo/lint.cjs.js +13 -12
- package/dist/modules/lint/index.cjs.js +1 -1
- package/dist/modules/lint/lib/optionsParser.cjs.js +37 -0
- package/dist/modules/maintenance/commands/repo/fix.cjs.js +8 -11
- package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +4 -4
- package/dist/modules/maintenance/index.cjs.js +1 -45
- package/dist/modules/migrate/commands/packageExports.cjs.js +9 -11
- package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +7 -3
- package/dist/modules/migrate/commands/packageRole.cjs.js +5 -3
- package/dist/modules/migrate/commands/packageScripts.cjs.js +11 -7
- package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +7 -3
- package/dist/modules/migrate/commands/versions/bump.cjs.js +15 -18
- package/dist/modules/migrate/index.cjs.js +11 -31
- package/dist/modules/new/index.cjs.js +1 -1
- package/dist/modules/new/lib/codeowners/codeowners.cjs.js +2 -2
- package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +6 -11
- package/dist/modules/new/lib/execution/installNewPackage.cjs.js +4 -4
- package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +1 -2
- package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +2 -2
- package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +8 -8
- package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +18 -18
- package/dist/{lib → modules/new/lib}/version.cjs.js +22 -33
- package/dist/modules/test/commands/package/test.cjs.js +1 -5
- package/dist/modules/test/commands/repo/test.cjs.js +9 -9
- package/dist/modules/test/index.cjs.js +4 -2
- package/dist/modules/translations/commands/export.cjs.js +127 -0
- package/dist/modules/translations/commands/import.cjs.js +164 -0
- package/dist/modules/translations/index.cjs.js +24 -0
- package/dist/modules/translations/lib/discoverPackages.cjs.js +121 -0
- package/dist/modules/translations/lib/extractTranslations.cjs.js +71 -0
- package/dist/modules/translations/lib/messageFilePath.cjs.js +43 -0
- package/dist/packages/backend-defaults/package.json.cjs.js +1 -1
- package/dist/packages/backend-plugin-api/package.json.cjs.js +1 -1
- package/dist/packages/backend-test-utils/package.json.cjs.js +1 -1
- package/dist/packages/catalog-client/package.json.cjs.js +1 -1
- package/dist/packages/cli/package.json.cjs.js +6 -8
- package/dist/packages/core-app-api/package.json.cjs.js +1 -1
- package/dist/packages/core-components/package.json.cjs.js +1 -1
- package/dist/packages/core-plugin-api/package.json.cjs.js +1 -1
- package/dist/packages/dev-utils/package.json.cjs.js +1 -1
- package/dist/packages/frontend-defaults/package.json.cjs.js +1 -1
- package/dist/packages/frontend-plugin-api/package.json.cjs.js +1 -1
- package/dist/packages/frontend-test-utils/package.json.cjs.js +1 -1
- package/dist/packages/test-utils/package.json.cjs.js +1 -1
- package/dist/plugins/auth-backend/package.json.cjs.js +1 -1
- package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +1 -1
- package/dist/plugins/catalog-node/package.json.cjs.js +1 -1
- package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +1 -1
- package/dist/wiring/CliInitializer.cjs.js +12 -5
- package/dist/wiring/version.cjs.js +20 -0
- package/package.json +34 -36
- package/dist/lib/cache/SuccessCache.cjs.js +0 -79
- package/dist/lib/parallel.cjs.js +0 -141
- package/dist/lib/paths.cjs.js +0 -8
- package/dist/lib/versioning/Lockfile.cjs.js +0 -89
- package/dist/lib/yarnPlugin.cjs.js +0 -46
- package/dist/modules/maintenance/commands/package/clean.cjs.js +0 -19
- package/dist/modules/maintenance/commands/package/pack.cjs.js +0 -29
- /package/dist/{lib → modules/build/lib}/entryPoints.cjs.js +0 -0
- /package/dist/modules/{maintenance → build}/lib/publishing.cjs.js +0 -0
- /package/dist/{lib → modules/migrate/lib}/versioning/packages.cjs.js +0 -0
- /package/dist/{lib → modules/migrate/lib}/versioning/yarn.cjs.js +0 -0
- /package/dist/{lib → wiring}/errors.cjs.js +0 -0
- /package/dist/{lib → wiring}/lazy.cjs.js +0 -0
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var factory = require('../../wiring/factory.cjs.js');
|
|
6
|
-
var yargs = require('yargs');
|
|
7
|
-
var commander = require('commander');
|
|
8
|
-
var lazy = require('../../lib/lazy.cjs.js');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var yargs__default = /*#__PURE__*/_interopDefaultCompat(yargs);
|
|
13
6
|
|
|
14
7
|
const configOption = [
|
|
15
8
|
"--config <path>",
|
|
@@ -23,84 +16,32 @@ var index = factory.createCliPlugin({
|
|
|
23
16
|
reg.addCommand({
|
|
24
17
|
path: ["config:docs"],
|
|
25
18
|
description: "Browse the configuration reference documentation",
|
|
26
|
-
execute:
|
|
27
|
-
const command = new commander.Command();
|
|
28
|
-
const defaultCommand = command.option(
|
|
29
|
-
"--package <name>",
|
|
30
|
-
"Only include the schema that applies to the given package"
|
|
31
|
-
).description("Browse the configuration reference documentation").action(lazy.lazy(() => import('./commands/docs.cjs.js'), "default"));
|
|
32
|
-
await defaultCommand.parseAsync(args, { from: "user" });
|
|
33
|
-
}
|
|
19
|
+
execute: { loader: () => import('./commands/docs.cjs.js') }
|
|
34
20
|
});
|
|
35
21
|
reg.addCommand({
|
|
36
22
|
path: ["config", "docs"],
|
|
37
23
|
description: "Browse the configuration reference documentation",
|
|
38
|
-
execute:
|
|
39
|
-
await new commander.Command(info.usage).option(
|
|
40
|
-
"--package <name>",
|
|
41
|
-
"Only include the schema that applies to the given package"
|
|
42
|
-
).description(info.description).action(lazy.lazy(() => import('./commands/docs.cjs.js'), "default")).parseAsync(args, { from: "user" });
|
|
43
|
-
}
|
|
24
|
+
execute: { loader: () => import('./commands/docs.cjs.js') }
|
|
44
25
|
});
|
|
45
26
|
reg.addCommand({
|
|
46
27
|
path: ["config:print"],
|
|
47
28
|
description: "Print the app configuration for the current package",
|
|
48
|
-
execute:
|
|
49
|
-
const argv = await yargs__default.default().options({
|
|
50
|
-
package: { type: "string" },
|
|
51
|
-
lax: { type: "boolean" },
|
|
52
|
-
frontend: { type: "boolean" },
|
|
53
|
-
"with-secrets": { type: "boolean" },
|
|
54
|
-
format: { type: "string" },
|
|
55
|
-
config: { type: "string", array: true, default: [] }
|
|
56
|
-
}).usage("$0", info.description).help().parse(args);
|
|
57
|
-
await lazy.lazy(() => import('./commands/print.cjs.js'), "default")(argv);
|
|
58
|
-
}
|
|
29
|
+
execute: { loader: () => import('./commands/print.cjs.js') }
|
|
59
30
|
});
|
|
60
31
|
reg.addCommand({
|
|
61
32
|
path: ["config:check"],
|
|
62
33
|
description: "Validate that the given configuration loads and matches schema",
|
|
63
|
-
execute:
|
|
64
|
-
const argv = await yargs__default.default().options({
|
|
65
|
-
package: { type: "string" },
|
|
66
|
-
lax: { type: "boolean" },
|
|
67
|
-
frontend: { type: "boolean" },
|
|
68
|
-
deprecated: { type: "boolean" },
|
|
69
|
-
strict: { type: "boolean" },
|
|
70
|
-
config: {
|
|
71
|
-
type: "string",
|
|
72
|
-
array: true,
|
|
73
|
-
default: []
|
|
74
|
-
}
|
|
75
|
-
}).help().parse(args);
|
|
76
|
-
await lazy.lazy(() => import('./commands/validate.cjs.js'), "default")(argv);
|
|
77
|
-
}
|
|
34
|
+
execute: { loader: () => import('./commands/validate.cjs.js') }
|
|
78
35
|
});
|
|
79
36
|
reg.addCommand({
|
|
80
37
|
path: ["config:schema"],
|
|
81
38
|
description: "Print the JSON schema for the given configuration",
|
|
82
|
-
execute:
|
|
83
|
-
const argv = await yargs__default.default().options({
|
|
84
|
-
package: { type: "string" },
|
|
85
|
-
format: { type: "string" },
|
|
86
|
-
merge: { type: "boolean" },
|
|
87
|
-
"no-merge": { type: "boolean" }
|
|
88
|
-
}).help().parse(args);
|
|
89
|
-
await lazy.lazy(() => import('./commands/schema.cjs.js'), "default")(argv);
|
|
90
|
-
}
|
|
39
|
+
execute: { loader: () => import('./commands/schema.cjs.js') }
|
|
91
40
|
});
|
|
92
41
|
reg.addCommand({
|
|
93
42
|
path: ["config", "schema"],
|
|
94
43
|
description: "Print the JSON schema for the given configuration",
|
|
95
|
-
execute:
|
|
96
|
-
const argv = await yargs__default.default().options({
|
|
97
|
-
package: { type: "string" },
|
|
98
|
-
format: { type: "string" },
|
|
99
|
-
merge: { type: "boolean" },
|
|
100
|
-
"no-merge": { type: "boolean" }
|
|
101
|
-
}).help().parse(args);
|
|
102
|
-
await lazy.lazy(() => import('./commands/schema.cjs.js'), "default")(argv);
|
|
103
|
-
}
|
|
44
|
+
execute: { loader: () => import('./commands/schema.cjs.js') }
|
|
104
45
|
});
|
|
105
46
|
}
|
|
106
47
|
});
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var configLoader = require('@backstage/config-loader');
|
|
4
4
|
var config = require('@backstage/config');
|
|
5
|
-
var
|
|
5
|
+
var cliCommon = require('@backstage/cli-common');
|
|
6
6
|
var getPackages = require('@manypkg/get-packages');
|
|
7
7
|
var cliNode = require('@backstage/cli-node');
|
|
8
8
|
var path = require('node:path');
|
|
9
9
|
|
|
10
10
|
async function loadCliConfig(options) {
|
|
11
|
-
const targetDir = options.targetDir ??
|
|
11
|
+
const targetDir = options.targetDir ?? cliCommon.targetPaths.dir;
|
|
12
12
|
const { packages } = await getPackages.getPackages(targetDir);
|
|
13
13
|
let localPackageNames;
|
|
14
14
|
if (options.fromPackage) {
|
|
@@ -31,49 +31,34 @@ async function loadCliConfig(options) {
|
|
|
31
31
|
const schema = await configLoader.loadConfigSchema({
|
|
32
32
|
dependencies: localPackageNames,
|
|
33
33
|
// Include the package.json in the project root if it exists
|
|
34
|
-
packagePaths: [
|
|
34
|
+
packagePaths: [cliCommon.targetPaths.resolveRoot("package.json")],
|
|
35
35
|
noUndeclaredProperties: options.strict
|
|
36
36
|
});
|
|
37
37
|
const source = configLoader.ConfigSources.default({
|
|
38
38
|
allowMissingDefaultConfig: true,
|
|
39
39
|
substitutionFunc: options.mockEnv ? async (name) => process.env[name] || "x" : void 0,
|
|
40
|
-
|
|
41
|
-
rootDir: paths.paths.targetRoot,
|
|
40
|
+
rootDir: cliCommon.targetPaths.rootDir,
|
|
42
41
|
argv: options.args.flatMap((t) => ["--config", path.resolve(targetDir, t)])
|
|
43
42
|
});
|
|
44
43
|
const appConfigs = await new Promise((resolve, reject) => {
|
|
45
|
-
async function
|
|
44
|
+
async function readConfig() {
|
|
46
45
|
let loaded = false;
|
|
47
46
|
try {
|
|
48
47
|
const abortController = new AbortController();
|
|
49
48
|
for await (const { configs } of source.readConfigData({
|
|
50
49
|
signal: abortController.signal
|
|
51
50
|
})) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
withFilteredKeys: options.withFilteredKeys,
|
|
56
|
-
withDeprecatedKeys: options.withDeprecatedKeys,
|
|
57
|
-
ignoreSchemaErrors: !options.strict
|
|
58
|
-
});
|
|
59
|
-
options.watch?.(newFrontendAppConfigs);
|
|
60
|
-
} else {
|
|
61
|
-
resolve(configs);
|
|
62
|
-
loaded = true;
|
|
63
|
-
if (!options.watch) {
|
|
64
|
-
abortController.abort();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
51
|
+
resolve(configs);
|
|
52
|
+
loaded = true;
|
|
53
|
+
abortController.abort();
|
|
67
54
|
}
|
|
68
55
|
} catch (error) {
|
|
69
|
-
if (loaded) {
|
|
70
|
-
console.error(`Failed to reload configuration, ${error}`);
|
|
71
|
-
} else {
|
|
56
|
+
if (!loaded) {
|
|
72
57
|
reject(error);
|
|
73
58
|
}
|
|
74
59
|
}
|
|
75
60
|
}
|
|
76
|
-
|
|
61
|
+
readConfig();
|
|
77
62
|
});
|
|
78
63
|
const configurationLoadedMessage = appConfigs.length ? `Loaded config from ${appConfigs.map((c) => c.context).join(", ")}` : `No configuration files found, running without config`;
|
|
79
64
|
process.stderr.write(`${configurationLoadedMessage}
|
|
@@ -81,7 +66,6 @@ async function loadCliConfig(options) {
|
|
|
81
66
|
try {
|
|
82
67
|
const frontendAppConfigs = schema.process(appConfigs, {
|
|
83
68
|
visibility: options.fullVisibility ? ["frontend", "backend", "secret"] : ["frontend"],
|
|
84
|
-
withFilteredKeys: options.withFilteredKeys,
|
|
85
69
|
withDeprecatedKeys: options.withDeprecatedKeys,
|
|
86
70
|
ignoreSchemaErrors: !options.strict
|
|
87
71
|
});
|
|
@@ -6,7 +6,7 @@ var fs = require('fs-extra');
|
|
|
6
6
|
var chalk = require('chalk');
|
|
7
7
|
var yaml = require('yaml');
|
|
8
8
|
var inquirer = require('inquirer');
|
|
9
|
-
var
|
|
9
|
+
var cliCommon = require('@backstage/cli-common');
|
|
10
10
|
var GithubCreateAppServer = require('./GithubCreateAppServer.cjs.js');
|
|
11
11
|
var openBrowser = require('react-dev-utils/openBrowser');
|
|
12
12
|
|
|
@@ -51,7 +51,7 @@ var index = async (org) => {
|
|
|
51
51
|
const fileName = `github-app-${slug}-credentials.yaml`;
|
|
52
52
|
const content = `# Name: ${name}
|
|
53
53
|
${yaml.stringify(config)}`;
|
|
54
|
-
await fs__default.default.writeFile(
|
|
54
|
+
await fs__default.default.writeFile(cliCommon.targetPaths.resolveRoot(fileName), content);
|
|
55
55
|
console.log(`GitHub App configuration written to ${chalk__default.default.cyan(fileName)}`);
|
|
56
56
|
console.log(
|
|
57
57
|
chalk__default.default.yellow(
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var factory = require('../../wiring/factory.cjs.js');
|
|
6
6
|
var commander = require('commander');
|
|
7
|
-
var lazy = require('../../
|
|
7
|
+
var lazy = require('../../wiring/lazy.cjs.js');
|
|
8
8
|
|
|
9
9
|
var index = factory.createCliPlugin({
|
|
10
10
|
pluginId: "new",
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var cleye = require('cleye');
|
|
5
6
|
var _package = require('../../../packages/cli/package.json.cjs.js');
|
|
6
7
|
var os = require('node:os');
|
|
7
8
|
var cliCommon = require('@backstage/cli-common');
|
|
8
|
-
var paths = require('../../../lib/paths.cjs.js');
|
|
9
|
-
var Lockfile = require('../../../lib/versioning/Lockfile.cjs.js');
|
|
10
|
-
var minimatch = require('minimatch');
|
|
11
|
-
require('@manypkg/get-packages');
|
|
12
|
-
require('@backstage/errors');
|
|
13
9
|
var cliNode = require('@backstage/cli-node');
|
|
10
|
+
var minimatch = require('minimatch');
|
|
14
11
|
var fs = require('fs-extra');
|
|
15
12
|
|
|
16
13
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -31,11 +28,32 @@ function hasBackstageField(packageName, targetPath) {
|
|
|
31
28
|
const pkg = tryReadPackageJson(packageName, targetPath);
|
|
32
29
|
return pkg?.backstage !== void 0;
|
|
33
30
|
}
|
|
34
|
-
var info = async (
|
|
31
|
+
var info = async ({ args, info }) => {
|
|
32
|
+
const {
|
|
33
|
+
flags: { include, format }
|
|
34
|
+
} = cleye.cli(
|
|
35
|
+
{
|
|
36
|
+
help: info,
|
|
37
|
+
flags: {
|
|
38
|
+
include: {
|
|
39
|
+
type: [String],
|
|
40
|
+
description: "Glob patterns for additional packages to include (e.g., @spotify/backstage*)"
|
|
41
|
+
},
|
|
42
|
+
format: {
|
|
43
|
+
type: String,
|
|
44
|
+
description: "Output format (text or json)",
|
|
45
|
+
default: "text"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
void 0,
|
|
50
|
+
args
|
|
51
|
+
);
|
|
52
|
+
const options = { include, format };
|
|
35
53
|
await new Promise(async () => {
|
|
36
54
|
const yarnVersion = await cliCommon.runOutput(["yarn", "--version"]);
|
|
37
|
-
const isLocal = fs__default.default.existsSync(
|
|
38
|
-
const backstageFile =
|
|
55
|
+
const isLocal = fs__default.default.existsSync(cliCommon.findOwnPaths(__dirname).resolve("./src"));
|
|
56
|
+
const backstageFile = cliCommon.targetPaths.resolveRoot("backstage.json");
|
|
39
57
|
let backstageVersion = "N/A";
|
|
40
58
|
if (fs__default.default.existsSync(backstageFile)) {
|
|
41
59
|
try {
|
|
@@ -57,9 +75,9 @@ var info = async (options) => {
|
|
|
57
75
|
cli: { version: _package.version, local: isLocal },
|
|
58
76
|
backstage: backstageVersion
|
|
59
77
|
};
|
|
60
|
-
const lockfilePath =
|
|
61
|
-
const lockfile = await
|
|
62
|
-
const targetPath =
|
|
78
|
+
const lockfilePath = cliCommon.targetPaths.resolveRoot("yarn.lock");
|
|
79
|
+
const lockfile = await cliNode.Lockfile.load(lockfilePath);
|
|
80
|
+
const targetPath = cliCommon.targetPaths.rootDir;
|
|
63
81
|
const workspacePackages = /* @__PURE__ */ new Map();
|
|
64
82
|
try {
|
|
65
83
|
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
@@ -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:
|
|
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,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
|
-
var
|
|
6
|
+
var cliCommon = require('@backstage/cli-common');
|
|
7
7
|
var eslint = require('eslint');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -12,7 +12,7 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
|
12
12
|
|
|
13
13
|
var lint = async (directories, opts) => {
|
|
14
14
|
const eslint$1 = new eslint.ESLint({
|
|
15
|
-
cwd:
|
|
15
|
+
cwd: cliCommon.targetPaths.dir,
|
|
16
16
|
fix: opts.fix,
|
|
17
17
|
extensions: ["js", "jsx", "ts", "tsx", "mjs", "cjs"]
|
|
18
18
|
});
|
|
@@ -27,12 +27,12 @@ var lint = async (directories, opts) => {
|
|
|
27
27
|
}
|
|
28
28
|
const formatter = await eslint$1.loadFormatter(opts.format);
|
|
29
29
|
if (opts.format === "eslint-formatter-friendly") {
|
|
30
|
-
process.chdir(
|
|
30
|
+
process.chdir(cliCommon.targetPaths.rootDir);
|
|
31
31
|
}
|
|
32
32
|
const resultText = await formatter.format(results);
|
|
33
33
|
if (resultText) {
|
|
34
34
|
if (opts.outputFile) {
|
|
35
|
-
await fs__default.default.writeFile(
|
|
35
|
+
await fs__default.default.writeFile(cliCommon.targetPaths.resolve(opts.outputFile), resultText);
|
|
36
36
|
} else {
|
|
37
37
|
console.log(resultText);
|
|
38
38
|
}
|
|
@@ -5,10 +5,8 @@ var fs = require('fs-extra');
|
|
|
5
5
|
var crypto = require('node:crypto');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var cliNode = require('@backstage/cli-node');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var optionsParser = require('../../../../lib/optionsParser.cjs.js');
|
|
11
|
-
var SuccessCache = require('../../../../lib/cache/SuccessCache.cjs.js');
|
|
8
|
+
var cliCommon = require('@backstage/cli-common');
|
|
9
|
+
var optionsParser = require('../../lib/optionsParser.cjs.js');
|
|
12
10
|
|
|
13
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
12
|
|
|
@@ -22,10 +20,13 @@ function depCount(pkg) {
|
|
|
22
20
|
}
|
|
23
21
|
async function command(opts, cmd) {
|
|
24
22
|
let packages = await cliNode.PackageGraph.listTargetPackages();
|
|
25
|
-
const cache =
|
|
23
|
+
const cache = cliNode.SuccessCache.create({
|
|
24
|
+
name: "lint",
|
|
25
|
+
basePath: opts.successCacheDir
|
|
26
|
+
});
|
|
26
27
|
const cacheContext = opts.successCache ? {
|
|
27
28
|
entries: await cache.read(),
|
|
28
|
-
lockfile: await cliNode.Lockfile.load(
|
|
29
|
+
lockfile: await cliNode.Lockfile.load(cliCommon.targetPaths.resolveRoot("yarn.lock"))
|
|
29
30
|
} : void 0;
|
|
30
31
|
if (opts.since) {
|
|
31
32
|
const graph = cliNode.PackageGraph.fromPackages(packages);
|
|
@@ -36,7 +37,7 @@ async function command(opts, cmd) {
|
|
|
36
37
|
}
|
|
37
38
|
packages.sort((a, b) => depCount(b.packageJson) - depCount(a.packageJson));
|
|
38
39
|
if (opts.format === "eslint-formatter-friendly") {
|
|
39
|
-
process.chdir(
|
|
40
|
+
process.chdir(cliCommon.targetPaths.rootDir);
|
|
40
41
|
}
|
|
41
42
|
if (!process.env.FORCE_COLOR) {
|
|
42
43
|
process.env.FORCE_COLOR = "1";
|
|
@@ -47,7 +48,7 @@ async function command(opts, cmd) {
|
|
|
47
48
|
const lintOptions = parseLintScript(pkg.packageJson.scripts?.lint);
|
|
48
49
|
const base = {
|
|
49
50
|
fullDir: pkg.dir,
|
|
50
|
-
relativeDir: path.relative(
|
|
51
|
+
relativeDir: path.relative(cliCommon.targetPaths.rootDir, pkg.dir),
|
|
51
52
|
lintOptions,
|
|
52
53
|
parentHash: void 0
|
|
53
54
|
};
|
|
@@ -70,16 +71,16 @@ async function command(opts, cmd) {
|
|
|
70
71
|
};
|
|
71
72
|
})
|
|
72
73
|
);
|
|
73
|
-
const resultsList = await
|
|
74
|
+
const { results: resultsList } = await cliNode.runWorkerQueueThreads({
|
|
74
75
|
items: items.filter((item) => item.lintOptions),
|
|
75
76
|
// Filter out packages without lint script
|
|
76
|
-
|
|
77
|
+
context: {
|
|
77
78
|
fix: Boolean(opts.fix),
|
|
78
79
|
format: opts.format,
|
|
79
80
|
shouldCache: Boolean(cacheContext),
|
|
80
81
|
maxWarnings: opts.maxWarnings ?? -1,
|
|
81
82
|
successCache: cacheContext?.entries,
|
|
82
|
-
rootDir:
|
|
83
|
+
rootDir: cliCommon.targetPaths.rootDir
|
|
83
84
|
},
|
|
84
85
|
workerFactory: async ({
|
|
85
86
|
fix,
|
|
@@ -197,7 +198,7 @@ async function command(opts, cmd) {
|
|
|
197
198
|
errorOutput = JSON.stringify(mergedJsonResults, null, 2);
|
|
198
199
|
}
|
|
199
200
|
if (opts.outputFile && errorOutput) {
|
|
200
|
-
await fs__default.default.writeFile(
|
|
201
|
+
await fs__default.default.writeFile(cliCommon.targetPaths.resolveRoot(opts.outputFile), errorOutput);
|
|
201
202
|
}
|
|
202
203
|
if (cacheContext) {
|
|
203
204
|
await cache.write(outputSuccessCache);
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var factory = require('../../wiring/factory.cjs.js');
|
|
6
6
|
var commander = require('commander');
|
|
7
|
-
var lazy = require('../../
|
|
7
|
+
var lazy = require('../../wiring/lazy.cjs.js');
|
|
8
8
|
|
|
9
9
|
function registerPackageLintCommand(command) {
|
|
10
10
|
command.arguments("[directories...]");
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function createScriptOptionsParser(anyCmd, commandPath) {
|
|
4
|
+
let rootCmd = anyCmd;
|
|
5
|
+
while (rootCmd.parent) {
|
|
6
|
+
rootCmd = rootCmd.parent;
|
|
7
|
+
}
|
|
8
|
+
let targetCmd = rootCmd;
|
|
9
|
+
for (const name of commandPath) {
|
|
10
|
+
targetCmd = targetCmd?.commands.find((c) => c.name() === name);
|
|
11
|
+
}
|
|
12
|
+
if (!targetCmd) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`Could not find package command '${commandPath.join(" ")}'`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
const cmd = targetCmd;
|
|
18
|
+
const expectedScript = `backstage-cli ${commandPath.join(" ")}`;
|
|
19
|
+
return (scriptStr) => {
|
|
20
|
+
if (!scriptStr || !scriptStr.startsWith(expectedScript)) {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
const argsStr = scriptStr.slice(expectedScript.length).trim();
|
|
24
|
+
const currentOpts = cmd._optionValues;
|
|
25
|
+
const currentStore = cmd._storeOptionsAsProperties;
|
|
26
|
+
const result = {};
|
|
27
|
+
cmd._storeOptionsAsProperties = false;
|
|
28
|
+
cmd._optionValues = result;
|
|
29
|
+
cmd.parseOptions(argsStr.split(" "));
|
|
30
|
+
cmd._optionValues = currentOpts;
|
|
31
|
+
cmd._storeOptionsAsProperties = currentStore;
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.createScriptOptionsParser = createScriptOptionsParser;
|
|
37
|
+
//# sourceMappingURL=optionsParser.cjs.js.map
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
var cliNode = require('@backstage/cli-node');
|
|
4
4
|
var fs = require('fs-extra');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var
|
|
7
|
-
var publishing = require('../../lib/publishing.cjs.js');
|
|
6
|
+
var cliCommon = require('@backstage/cli-common');
|
|
8
7
|
|
|
9
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
9
|
|
|
@@ -18,7 +17,7 @@ async function readFixablePackages() {
|
|
|
18
17
|
function printPackageFixHint(packages) {
|
|
19
18
|
const changed = packages.filter((pkg) => pkg.changed);
|
|
20
19
|
if (changed.length > 0) {
|
|
21
|
-
const rootPkg = require(
|
|
20
|
+
const rootPkg = require(cliCommon.targetPaths.resolveRoot("package.json"));
|
|
22
21
|
const fixCmd = rootPkg.scripts?.fix === "backstage-cli repo fix" ? "fix" : "backstage-cli repo fix";
|
|
23
22
|
console.log(
|
|
24
23
|
`The following packages are out of sync, run 'yarn ${fixCmd}' to fix them:`
|
|
@@ -148,7 +147,7 @@ function fixSideEffects(pkg) {
|
|
|
148
147
|
pkg.changed = true;
|
|
149
148
|
}
|
|
150
149
|
function createRepositoryFieldFixer() {
|
|
151
|
-
const rootPkg = require(
|
|
150
|
+
const rootPkg = require(cliCommon.targetPaths.resolveRoot("package.json"));
|
|
152
151
|
const rootRepoField = rootPkg.repository;
|
|
153
152
|
if (!rootRepoField) {
|
|
154
153
|
return () => {
|
|
@@ -160,7 +159,7 @@ function createRepositoryFieldFixer() {
|
|
|
160
159
|
return (pkg) => {
|
|
161
160
|
const expectedPath = path.posix.join(
|
|
162
161
|
rootDir,
|
|
163
|
-
path.relative(
|
|
162
|
+
path.relative(cliCommon.targetPaths.rootDir, pkg.dir)
|
|
164
163
|
);
|
|
165
164
|
const repoField = pkg.packageJson.repository;
|
|
166
165
|
if (!repoField || typeof repoField === "string") {
|
|
@@ -234,7 +233,7 @@ function fixPluginId(pkg) {
|
|
|
234
233
|
const guessedPluginId = guessPluginId(role, pkg.packageJson.name);
|
|
235
234
|
if (!guessedPluginId && (role === "frontend-plugin" || role === "frontend-plugin-module" || role === "backend-plugin" || role === "backend-plugin-module")) {
|
|
236
235
|
const path$1 = path.relative(
|
|
237
|
-
|
|
236
|
+
cliCommon.targetPaths.rootDir,
|
|
238
237
|
path.resolve(pkg.dir, "package.json")
|
|
239
238
|
);
|
|
240
239
|
const msg = `Failed to guess plugin ID for "${pkg.packageJson.name}", please set the 'backstage.pluginId' field manually in "${path$1}"`;
|
|
@@ -305,7 +304,7 @@ function fixPluginPackages(pkg, repoPackages) {
|
|
|
305
304
|
return;
|
|
306
305
|
}
|
|
307
306
|
const path$1 = path.relative(
|
|
308
|
-
|
|
307
|
+
cliCommon.targetPaths.rootDir,
|
|
309
308
|
path.resolve(pkg.dir, "package.json")
|
|
310
309
|
);
|
|
311
310
|
const suggestedRole = role === "frontend-plugin-module" ? "web-library" : "node-library";
|
|
@@ -341,7 +340,7 @@ function fixPeerModules(pkg) {
|
|
|
341
340
|
return;
|
|
342
341
|
}
|
|
343
342
|
const packagePath = path.relative(
|
|
344
|
-
|
|
343
|
+
cliCommon.targetPaths.rootDir,
|
|
345
344
|
path.resolve(pkg.dir, "package.json")
|
|
346
345
|
);
|
|
347
346
|
if (role !== "backend-plugin" && role !== "frontend-plugin") {
|
|
@@ -371,9 +370,7 @@ async function command(opts) {
|
|
|
371
370
|
fixRepositoryField,
|
|
372
371
|
fixPluginId,
|
|
373
372
|
fixPluginPackages,
|
|
374
|
-
fixPeerModules
|
|
375
|
-
// Run the publish preflight check too, to make sure we don't uncover errors during publishing
|
|
376
|
-
publishing.publishPreflightCheck
|
|
373
|
+
fixPeerModules
|
|
377
374
|
);
|
|
378
375
|
}
|
|
379
376
|
for (const fixer of fixers) {
|
|
@@ -4,7 +4,7 @@ var chalk = require('chalk');
|
|
|
4
4
|
var eslint = require('eslint');
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var cliNode = require('@backstage/cli-node');
|
|
7
|
-
var
|
|
7
|
+
var cliCommon = require('@backstage/cli-common');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
10
|
|
|
@@ -13,14 +13,14 @@ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
|
13
13
|
async function command(opts) {
|
|
14
14
|
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
15
15
|
const eslint$1 = new eslint.ESLint({
|
|
16
|
-
cwd:
|
|
16
|
+
cwd: cliCommon.targetPaths.dir,
|
|
17
17
|
overrideConfig: {
|
|
18
18
|
plugins: ["deprecation"],
|
|
19
19
|
rules: {
|
|
20
20
|
"deprecation/deprecation": "error"
|
|
21
21
|
},
|
|
22
22
|
parserOptions: {
|
|
23
|
-
project: [
|
|
23
|
+
project: [cliCommon.targetPaths.resolveRoot("tsconfig.json")]
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
extensions: ["jsx", "ts", "tsx", "mjs", "cjs"]
|
|
@@ -37,7 +37,7 @@ async function command(opts) {
|
|
|
37
37
|
if (message.ruleId !== "deprecation/deprecation") {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
const path$1 = path.relative(
|
|
40
|
+
const path$1 = path.relative(cliCommon.targetPaths.rootDir, result.filePath);
|
|
41
41
|
deprecations.push({
|
|
42
42
|
path: path$1,
|
|
43
43
|
message: message.message,
|
|
@@ -4,44 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var commander = require('commander');
|
|
6
6
|
var factory = require('../../wiring/factory.cjs.js');
|
|
7
|
-
var lazy = require('../../
|
|
7
|
+
var lazy = require('../../wiring/lazy.cjs.js');
|
|
8
8
|
|
|
9
9
|
var index = factory.createCliPlugin({
|
|
10
10
|
pluginId: "maintenance",
|
|
11
11
|
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
12
|
reg.addCommand({
|
|
46
13
|
path: ["repo", "fix"],
|
|
47
14
|
description: "Automatically fix packages in the project",
|
|
@@ -57,17 +24,6 @@ var index = factory.createCliPlugin({
|
|
|
57
24
|
await defaultCommand.parseAsync(args, { from: "user" });
|
|
58
25
|
}
|
|
59
26
|
});
|
|
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
|
-
}
|
|
70
|
-
});
|
|
71
27
|
reg.addCommand({
|
|
72
28
|
path: ["repo", "list-deprecations"],
|
|
73
29
|
description: "List deprecations",
|