@backstage/repo-tools 0.10.0-next.0 → 0.10.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 (37) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{cjs/api-reports-B3Gt_Fej.cjs.js → commands/api-reports/api-extractor.cjs.js} +13 -103
  3. package/dist/commands/api-reports/api-reports.cjs.js +78 -0
  4. package/dist/commands/api-reports/generateTypeDeclarations.cjs.js +33 -0
  5. package/dist/commands/generate-catalog-info/codeowners.cjs.js +42 -0
  6. package/dist/{cjs/generate-catalog-info-DxKb-9Wh.cjs.js → commands/generate-catalog-info/generate-catalog-info.cjs.js} +22 -68
  7. package/dist/commands/generate-catalog-info/utils.cjs.js +30 -0
  8. package/dist/commands/index.cjs.js +159 -0
  9. package/dist/{cjs/knip-reports-028OuOct.cjs.js → commands/knip-reports/knip-extractor.cjs.js} +4 -40
  10. package/dist/commands/knip-reports/knip-reports.cjs.js +39 -0
  11. package/dist/{cjs/lint-legacy-backend-exports-CDxZ51l5.cjs.js → commands/lint-legacy-backend-exports/lint-legacy-backend-exports.cjs.js} +2 -4
  12. package/dist/{cjs/diff-zt06VUKR.cjs.js → commands/package/schema/openapi/diff.cjs.js} +4 -11
  13. package/dist/{cjs/fuzz-BGbvHwkB.cjs.js → commands/package/schema/openapi/fuzz.cjs.js} +4 -10
  14. package/dist/commands/package/schema/openapi/generate/client.cjs.js +86 -0
  15. package/dist/commands/package/schema/openapi/generate/index.cjs.js +27 -0
  16. package/dist/commands/package/schema/openapi/generate/server.cjs.js +56 -0
  17. package/dist/{cjs/init-wsIZc-Ys.cjs.js → commands/package/schema/openapi/init.cjs.js} +5 -11
  18. package/dist/commands/peer-deps/peer-deps.cjs.js +175 -0
  19. package/dist/commands/repo/schema/openapi/diff.cjs.js +81 -0
  20. package/dist/{cjs/fuzz-CRe0ewrD.cjs.js → commands/repo/schema/openapi/fuzz.cjs.js} +2 -4
  21. package/dist/{cjs/lint-DqMp4VN_.cjs.js → commands/repo/schema/openapi/lint.cjs.js} +3 -11
  22. package/dist/{cjs/test-5XE2uhir.cjs.js → commands/repo/schema/openapi/test.cjs.js} +6 -13
  23. package/dist/{cjs/verify-ARmbHOf8.cjs.js → commands/repo/schema/openapi/verify.cjs.js} +5 -10
  24. package/dist/{cjs/type-deps-DgJcEpV_.cjs.js → commands/type-deps/type-deps.cjs.js} +7 -2
  25. package/dist/{cjs/util-BhlP_S3V.cjs.js → commands/util.cjs.js} +1 -1
  26. package/dist/index.cjs.js +7 -186
  27. package/dist/lib/errors.cjs.js +42 -0
  28. package/dist/{cjs/exec-C0kCNRgF.cjs.js → lib/exec.cjs.js} +1 -1
  29. package/dist/{cjs/getPackageExportDetails-FkT40JIH.cjs.js → lib/getPackageExportDetails.cjs.js} +1 -1
  30. package/dist/{cjs/constants-Dwa51b6l.cjs.js → lib/openapi/constants.cjs.js} +1 -1
  31. package/dist/{cjs/helpers-ja_ryoK_.cjs.js → lib/openapi/helpers.cjs.js} +5 -3
  32. package/dist/{cjs/diff-DDkHPBWC.cjs.js → lib/openapi/optic/helpers.cjs.js} +2 -82
  33. package/dist/{cjs/paths-BvbxdT_S.cjs.js → lib/paths.cjs.js} +2 -1
  34. package/dist/{cjs/runner-DMC006Gs.cjs.js → lib/runner.cjs.js} +2 -2
  35. package/dist/package.json.cjs.js +6 -0
  36. package/package.json +10 -10
  37. package/dist/cjs/index-zZtTyIMm.cjs.js +0 -145
@@ -0,0 +1,175 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var path = require('path');
6
+ var getPackages = require('@manypkg/get-packages');
7
+ var fs = require('fs');
8
+
9
+ const desiredLocalVersionsOfDependencies = {
10
+ "@types/react": "^18.0.0",
11
+ react: "^18.0.2",
12
+ "react-dom": "^18.0.2",
13
+ "react-router-dom": "^6.3.0"
14
+ };
15
+ const peerDependencies = {
16
+ "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
17
+ react: "^16.13.1 || ^17.0.0 || ^18.0.0",
18
+ "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
19
+ "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
20
+ };
21
+ const groupsOfPeerDependencies = [["@types/react", "react", "react-dom"]];
22
+ const optionalPeerDependencies = /* @__PURE__ */ new Set(["@types/react"]);
23
+ const isOptional = (dep) => {
24
+ return optionalPeerDependencies.has(dep);
25
+ };
26
+ const isMarkedAsOptional = (dep, packageJson) => {
27
+ return packageJson.peerDependenciesMeta?.[dep]?.optional;
28
+ };
29
+ const isDevDependency = (dep, packageJson) => {
30
+ return !!packageJson.devDependencies?.[dep];
31
+ };
32
+ const isProdDependency = (dep, packageJson) => {
33
+ return !!packageJson.dependencies?.[dep];
34
+ };
35
+ const isPeerDependency = (dep, packageJson) => {
36
+ return !!packageJson.peerDependencies?.[dep];
37
+ };
38
+ const isStandaloneApplication = (packageJson) => {
39
+ return ["cli", "frontend", "backend"].includes(
40
+ packageJson.backstage?.role || ""
41
+ );
42
+ };
43
+ const matchesDependency = (dep, packageJson) => {
44
+ return packageJson.devDependencies && packageJson.devDependencies[dep] === desiredLocalVersionsOfDependencies[dep];
45
+ };
46
+ const matchesPeerDependency = (dep, packageJson) => {
47
+ return packageJson.peerDependencies && packageJson.peerDependencies[dep] === peerDependencies[dep];
48
+ };
49
+ var peerDeps = async ({ fix }) => {
50
+ let failed = false;
51
+ const attemptToApplyFix = (fn) => {
52
+ if (fix) {
53
+ fn();
54
+ } else {
55
+ failed = true;
56
+ }
57
+ };
58
+ const { packages } = await getPackages.getPackages(path.resolve("."));
59
+ const packagesWithRelevantDependencies = [];
60
+ for (const pkg of packages) {
61
+ if (isStandaloneApplication(pkg.packageJson)) {
62
+ continue;
63
+ }
64
+ const dependencies = {
65
+ ...pkg.packageJson.dependencies,
66
+ ...pkg.packageJson.devDependencies,
67
+ ...pkg.packageJson.peerDependencies
68
+ };
69
+ for (const dep in peerDependencies) {
70
+ if (dependencies?.[dep]) {
71
+ packagesWithRelevantDependencies.push(pkg);
72
+ break;
73
+ }
74
+ }
75
+ }
76
+ for (const pkg of packagesWithRelevantDependencies) {
77
+ const packageJson = pkg.packageJson;
78
+ for (const dep of Object.keys(peerDependencies)) {
79
+ if (isPeerDependency(dep, packageJson)) {
80
+ if (isOptional(dep) && !isMarkedAsOptional(dep, packageJson)) {
81
+ console.error(
82
+ `Optional peer dependency ${dep} in ${pkg.packageJson.name} is not marked as optional`
83
+ );
84
+ attemptToApplyFix(() => {
85
+ packageJson.peerDependenciesMeta = packageJson.peerDependenciesMeta || {};
86
+ packageJson.peerDependenciesMeta[dep] = { optional: true };
87
+ });
88
+ } else if (!isOptional(dep) && isMarkedAsOptional(dep, packageJson)) {
89
+ console.error(
90
+ `Peer dependency ${dep} in ${pkg.packageJson.name} is marked as optional but should not be`
91
+ );
92
+ attemptToApplyFix(() => {
93
+ packageJson.peerDependenciesMeta = packageJson.peerDependenciesMeta || {};
94
+ delete packageJson.peerDependenciesMeta[dep];
95
+ });
96
+ }
97
+ if (!isDevDependency(dep, packageJson)) {
98
+ console.error(
99
+ `Peer dependency ${dep} in ${pkg.packageJson.name} is not listed as a devDependency`
100
+ );
101
+ attemptToApplyFix(() => {
102
+ delete packageJson.dependencies?.[dep];
103
+ packageJson.devDependencies = packageJson.devDependencies || {};
104
+ packageJson.devDependencies[dep] = desiredLocalVersionsOfDependencies[dep];
105
+ });
106
+ } else if (isProdDependency(dep, packageJson)) {
107
+ console.error(
108
+ `Peer dependency ${dep} in ${pkg.packageJson.name} is listed as a dependency`
109
+ );
110
+ attemptToApplyFix(() => {
111
+ delete packageJson.dependencies?.[dep];
112
+ });
113
+ }
114
+ const groups = groupsOfPeerDependencies.filter(
115
+ (group) => group.includes(dep)
116
+ );
117
+ if (groups.length) {
118
+ for (const group of groups) {
119
+ for (const groupDep of group) {
120
+ if (!isPeerDependency(groupDep, packageJson)) {
121
+ console.error(
122
+ `Peer dependency ${groupDep} in ${pkg.packageJson.name} is missing`
123
+ );
124
+ attemptToApplyFix(() => {
125
+ packageJson.peerDependencies = packageJson.peerDependencies || {};
126
+ packageJson.peerDependencies[groupDep] = peerDependencies[groupDep];
127
+ });
128
+ }
129
+ }
130
+ }
131
+ }
132
+ if (!matchesDependency(dep, packageJson)) {
133
+ console.error(
134
+ `Incorrect dependency ${dep} in ${pkg.packageJson.name}`
135
+ );
136
+ attemptToApplyFix(() => {
137
+ packageJson.devDependencies = packageJson.devDependencies || {};
138
+ packageJson.devDependencies[dep] = desiredLocalVersionsOfDependencies[dep];
139
+ });
140
+ }
141
+ if (!matchesPeerDependency(dep, packageJson)) {
142
+ console.error(
143
+ `Incorrect peer dependency ${dep} in ${pkg.packageJson.name}`
144
+ );
145
+ attemptToApplyFix(() => {
146
+ packageJson.peerDependencies = packageJson.peerDependencies || {};
147
+ packageJson.peerDependencies[dep] = peerDependencies[dep];
148
+ });
149
+ }
150
+ } else {
151
+ console.error(
152
+ `Missing peer dependency ${dep} in ${pkg.packageJson.name}`
153
+ );
154
+ attemptToApplyFix(() => {
155
+ packageJson.peerDependencies = packageJson.peerDependencies || {};
156
+ packageJson.peerDependencies[dep] = peerDependencies[dep];
157
+ });
158
+ }
159
+ }
160
+ if (fix) {
161
+ fs.writeFileSync(
162
+ path.resolve(pkg.dir, "package.json"),
163
+ `${JSON.stringify(packageJson, null, 2)}
164
+ `
165
+ );
166
+ }
167
+ }
168
+ if (failed) {
169
+ console.error("Some packages have incorrect peer dependencies");
170
+ process.exit(1);
171
+ }
172
+ };
173
+
174
+ exports.default = peerDeps;
175
+ //# sourceMappingURL=peer-deps.cjs.js.map
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var cliNode = require('@backstage/cli-node');
4
+ var exec = require('../../../../lib/exec.cjs.js');
5
+ var helpers = require('../../../../lib/openapi/optic/helpers.cjs.js');
6
+ var paths = require('../../../../lib/paths.cjs.js');
7
+ var constants = require('../../../../lib/openapi/constants.cjs.js');
8
+
9
+ function cleanUpApiName(e) {
10
+ e.apiName = e.apiName.replace(paths.paths.targetDir, "").replace(constants.YAML_SCHEMA_PATH, "");
11
+ }
12
+ async function command(opts) {
13
+ let packages = await cliNode.PackageGraph.listTargetPackages();
14
+ let since = "";
15
+ if (opts.since) {
16
+ const { stdout: sinceRaw } = await exec.exec("git", ["rev-parse", opts.since]);
17
+ since = sinceRaw.toString().trim();
18
+ const { stdout: changedFilesRaw } = await exec.exec("git", [
19
+ "diff",
20
+ "--name-only",
21
+ since
22
+ ]);
23
+ const changedFiles = changedFilesRaw.toString().trim();
24
+ const changedOpenApiSpecs = changedFiles.split("\n").filter((e) => e.endsWith(constants.YAML_SCHEMA_PATH)).map((e) => paths.paths.resolveTarget(e));
25
+ packages = packages.filter(
26
+ (pkg) => changedOpenApiSpecs.some((e) => e.startsWith(`${pkg.dir}/`))
27
+ );
28
+ }
29
+ const checkablePackages = packages.filter((e) => e.packageJson.scripts?.diff);
30
+ try {
31
+ const outputs = {
32
+ completed: [],
33
+ failed: [],
34
+ noop: [],
35
+ warning: [],
36
+ severity: 0
37
+ };
38
+ for (const pkg of checkablePackages) {
39
+ const sinceCommands = since ? ["--since", since] : [];
40
+ const { stdout } = await exec.exec(
41
+ "yarn",
42
+ ["diff", "--ignore", "--json", ...sinceCommands],
43
+ {
44
+ cwd: pkg.dir
45
+ }
46
+ );
47
+ const result = JSON.parse(stdout.toString());
48
+ outputs.completed.push(...result.completed ?? []);
49
+ outputs.failed.push(...result.failed ?? []);
50
+ outputs.noop.push(...result.noop ?? []);
51
+ }
52
+ for (const pkg of packages.filter((e) => !e.packageJson.scripts?.diff)) {
53
+ outputs.warning?.push({
54
+ apiName: `${pkg.dir}/`,
55
+ warning: "No diff script found in package.json"
56
+ });
57
+ }
58
+ outputs.completed.forEach(cleanUpApiName);
59
+ outputs.failed.forEach(cleanUpApiName);
60
+ outputs.noop.forEach(cleanUpApiName);
61
+ outputs.warning?.forEach(cleanUpApiName);
62
+ const { stdout: currentSha } = await exec.exec("git", ["rev-parse", "HEAD"]);
63
+ console.log(
64
+ helpers.generateCompareSummaryMarkdown(
65
+ { sha: currentSha.toString().trim() },
66
+ outputs,
67
+ { verbose: true }
68
+ )
69
+ );
70
+ const failed = outputs.failed.length > 0;
71
+ if (failed) {
72
+ throw new Error("Some checks failed");
73
+ }
74
+ } catch (err) {
75
+ console.error(err);
76
+ process.exit(1);
77
+ }
78
+ }
79
+
80
+ exports.command = command;
81
+ //# sourceMappingURL=diff.cjs.js.map
@@ -1,10 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var cliNode = require('@backstage/cli-node');
4
- var exec = require('./exec-C0kCNRgF.cjs.js');
4
+ var exec = require('../../../../lib/exec.cjs.js');
5
5
  var chalk = require('chalk');
6
- require('util');
7
- require('child_process');
8
6
 
9
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
8
 
@@ -39,4 +37,4 @@ async function command(opts) {
39
37
  }
40
38
 
41
39
  exports.command = command;
42
- //# sourceMappingURL=fuzz-CRe0ewrD.cjs.js.map
40
+ //# sourceMappingURL=fuzz.cjs.js.map
@@ -5,20 +5,12 @@ var spectralParsers = require('@stoplight/spectral-parsers');
5
5
  var ruleset = require('@apisyouwonthate/style-guide');
6
6
  var fs = require('fs-extra');
7
7
  var chalk = require('chalk');
8
- var runner = require('./runner-DMC006Gs.cjs.js');
8
+ var runner = require('../../../../lib/runner.cjs.js');
9
9
  var spectralRulesets = require('@stoplight/spectral-rulesets');
10
10
  var spectralFunctions = require('@stoplight/spectral-functions');
11
11
  var types = require('@stoplight/types');
12
12
  var spectralFormatters = require('@stoplight/spectral-formatters');
13
- var helpers = require('./helpers-ja_ryoK_.cjs.js');
14
- require('./paths-BvbxdT_S.cjs.js');
15
- require('@backstage/cli-common');
16
- require('@backstage/cli-node');
17
- require('minimatch');
18
- require('path');
19
- require('p-limit');
20
- require('portfinder');
21
- require('./constants-Dwa51b6l.cjs.js');
13
+ var helpers = require('../../../../lib/openapi/helpers.cjs.js');
22
14
 
23
15
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
24
16
 
@@ -104,4 +96,4 @@ async function bulkCommand(paths = [], options) {
104
96
  }
105
97
 
106
98
  exports.bulkCommand = bulkCommand;
107
- //# sourceMappingURL=lint-DqMp4VN_.cjs.js.map
99
+ //# sourceMappingURL=lint.cjs.js.map
@@ -3,18 +3,11 @@
3
3
  var fs = require('fs-extra');
4
4
  var path = require('path');
5
5
  var chalk = require('chalk');
6
- var runner = require('./runner-DMC006Gs.cjs.js');
7
- var constants = require('./constants-Dwa51b6l.cjs.js');
8
- var paths = require('./paths-BvbxdT_S.cjs.js');
9
- var exec = require('./exec-C0kCNRgF.cjs.js');
10
- var helpers = require('./helpers-ja_ryoK_.cjs.js');
11
- require('p-limit');
12
- require('portfinder');
13
- require('@backstage/cli-common');
14
- require('@backstage/cli-node');
15
- require('minimatch');
16
- require('util');
17
- require('child_process');
6
+ var runner = require('../../../../lib/runner.cjs.js');
7
+ var constants = require('../../../../lib/openapi/constants.cjs.js');
8
+ var paths = require('../../../../lib/paths.cjs.js');
9
+ var exec = require('../../../../lib/exec.cjs.js');
10
+ var helpers = require('../../../../lib/openapi/helpers.cjs.js');
18
11
 
19
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
20
13
 
@@ -96,4 +89,4 @@ async function bulkCommand(paths = [], options) {
96
89
  }
97
90
 
98
91
  exports.bulkCommand = bulkCommand;
99
- //# sourceMappingURL=test-5XE2uhir.cjs.js.map
92
+ //# sourceMappingURL=test.cjs.js.map
@@ -6,15 +6,10 @@ var lodash = require('lodash');
6
6
  var path = require('path');
7
7
  var chalk = require('chalk');
8
8
  var Parser = require('@apidevtools/swagger-parser');
9
- var runner = require('./runner-DMC006Gs.cjs.js');
10
- var paths = require('./paths-BvbxdT_S.cjs.js');
11
- var constants = require('./constants-Dwa51b6l.cjs.js');
12
- var helpers = require('./helpers-ja_ryoK_.cjs.js');
13
- require('p-limit');
14
- require('portfinder');
15
- require('@backstage/cli-common');
16
- require('@backstage/cli-node');
17
- require('minimatch');
9
+ var runner = require('../../../../lib/runner.cjs.js');
10
+ var paths = require('../../../../lib/paths.cjs.js');
11
+ var constants = require('../../../../lib/openapi/constants.cjs.js');
12
+ var helpers = require('../../../../lib/openapi/helpers.cjs.js');
18
13
 
19
14
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
20
15
 
@@ -66,4 +61,4 @@ async function bulkCommand(paths = []) {
66
61
  }
67
62
 
68
63
  exports.bulkCommand = bulkCommand;
69
- //# sourceMappingURL=verify-ARmbHOf8.cjs.js.map
64
+ //# sourceMappingURL=verify.cjs.js.map
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var fs = require('fs');
4
6
  var path = require('path');
5
7
  var chalk = require('chalk');
6
8
  var getPackages = require('@manypkg/get-packages');
7
- var getPackageExportDetails = require('./getPackageExportDetails-FkT40JIH.cjs.js');
9
+ var getPackageExportDetails = require('../../lib/getPackageExportDetails.cjs.js');
8
10
 
9
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
12
 
@@ -144,6 +146,9 @@ function findTypeDepErrors(typeDeps, pkg) {
144
146
  }
145
147
  }
146
148
  for (const dep of deps) {
149
+ if (["@types/react"].includes(dep)) {
150
+ continue;
151
+ }
147
152
  errors.push(
148
153
  mkErr("WrongDepError", `Should be dev dep ${dep}`, {
149
154
  dep,
@@ -166,4 +171,4 @@ function mkErr(name, msg, extra) {
166
171
  }
167
172
 
168
173
  exports.default = typeDeps;
169
- //# sourceMappingURL=type-deps-DgJcEpV_.cjs.js.map
174
+ //# sourceMappingURL=type-deps.cjs.js.map
@@ -38,4 +38,4 @@ ${stderr}`));
38
38
  }
39
39
 
40
40
  exports.createBinRunner = createBinRunner;
41
- //# sourceMappingURL=util-BhlP_S3V.cjs.js.map
41
+ //# sourceMappingURL=util.cjs.js.map
package/dist/index.cjs.js CHANGED
@@ -2,196 +2,17 @@
2
2
 
3
3
  var commander = require('commander');
4
4
  var chalk = require('chalk');
5
- var errors = require('@backstage/errors');
5
+ var errors = require('./lib/errors.cjs.js');
6
+ var index = require('./commands/index.cjs.js');
7
+ var _package = require('./package.json.cjs.js');
6
8
 
7
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
10
 
9
11
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
10
12
 
11
- class CustomError extends Error {
12
- get name() {
13
- return this.constructor.name;
14
- }
15
- }
16
- class ExitCodeError extends CustomError {
17
- code;
18
- constructor(code, command) {
19
- super(
20
- command ? `Command '${command}' exited with code ${code}` : `Child exited with code ${code}`
21
- );
22
- this.code = code;
23
- }
24
- }
25
- function exitWithError(error) {
26
- if (error instanceof ExitCodeError) {
27
- process.stderr.write(`
28
- ${chalk__default.default.red(error.message)}
29
-
30
- `);
31
- process.exit(error.code);
32
- } else {
33
- process.stderr.write(`
34
- ${chalk__default.default.red(`${error}`)}
35
-
36
- `);
37
- process.exit(1);
38
- }
39
- }
40
-
41
- function registerPackageCommand(program) {
42
- const command = program.command("package [command]").description("Various tools for working with specific packages.");
43
- const schemaCommand = command.command("schema [command]").description(
44
- "Various tools for working with specific packages' API schema"
45
- );
46
- const openApiCommand = schemaCommand.command("openapi [command]").description("Tooling for OpenAPI schema");
47
- openApiCommand.command("init").description(
48
- "Initialize any required files to use the OpenAPI tooling for this package."
49
- ).action(
50
- lazy(
51
- () => Promise.resolve().then(function () { return require('./cjs/init-wsIZc-Ys.cjs.js'); }).then((m) => m.singleCommand)
52
- )
53
- );
54
- openApiCommand.command("generate").option(
55
- "--client-package [package]",
56
- "Top-level path to where the client should be generated, ie packages/catalog-client."
57
- ).option("--server").description(
58
- "Command to generate a client and/or a server stub from an OpenAPI spec."
59
- ).option("--client-additional-properties [properties]").description(
60
- "Additional properties that can be passed to @openapitools/openapi-generator-cli"
61
- ).action(
62
- lazy(
63
- () => Promise.resolve().then(function () { return require('./cjs/index-zZtTyIMm.cjs.js'); }).then((m) => m.command)
64
- )
65
- );
66
- openApiCommand.command("fuzz").description(
67
- "Fuzz an OpenAPI schema by generating random data and sending it to the server."
68
- ).option("--limit <limit>", "Maximum number of requests to send.").option("--workers <workers>", "Number of workers to use", "2").option(
69
- "--debug",
70
- `Enable debug mode, which will save cassettes to '.cassettes/{pluginId}.yml'`
71
- ).option(
72
- "--exclude-checks <excludeChecks>",
73
- "Exclude checks from schemathesis run"
74
- ).action(
75
- lazy(() => Promise.resolve().then(function () { return require('./cjs/fuzz-BGbvHwkB.cjs.js'); }).then((m) => m.command))
76
- );
77
- openApiCommand.command("diff").option("--ignore", "Ignore linting failures and only log the results.").option("--json", "Output the results as JSON").option("--since <ref>", "Diff the API against a specific ref").action(
78
- lazy(() => Promise.resolve().then(function () { return require('./cjs/diff-zt06VUKR.cjs.js'); }).then((m) => m.command))
79
- );
80
- }
81
- function registerRepoCommand(program) {
82
- const command = program.command("repo [command]").description("Tools for working across your entire repository.");
83
- const schemaCommand = command.command("schema [command]").description("Various tools for working with API schema");
84
- const openApiCommand = schemaCommand.command("openapi [command]").description("Tooling for OpenApi schema");
85
- openApiCommand.command("verify [paths...]").description(
86
- "Verify that all OpenAPI schemas are valid and set up correctly."
87
- ).action(
88
- lazy(
89
- () => Promise.resolve().then(function () { return require('./cjs/verify-ARmbHOf8.cjs.js'); }).then((m) => m.bulkCommand)
90
- )
91
- );
92
- openApiCommand.command("lint [paths...]").description("Lint OpenAPI schemas.").option(
93
- "--strict",
94
- "Fail on any linting severity messages, not just errors."
95
- ).action(
96
- lazy(() => Promise.resolve().then(function () { return require('./cjs/lint-DqMp4VN_.cjs.js'); }).then((m) => m.bulkCommand))
97
- );
98
- openApiCommand.command("test [paths...]").description("Test OpenAPI schemas against written tests").option("--update", "Update the spec on failure.").action(
99
- lazy(() => Promise.resolve().then(function () { return require('./cjs/test-5XE2uhir.cjs.js'); }).then((m) => m.bulkCommand))
100
- );
101
- openApiCommand.command("fuzz").description("Fuzz all packages").option(
102
- "--since <ref>",
103
- "Only fuzz packages that have changed since the given ref"
104
- ).action(
105
- lazy(() => Promise.resolve().then(function () { return require('./cjs/fuzz-CRe0ewrD.cjs.js'); }).then((m) => m.command))
106
- );
107
- openApiCommand.command("diff").description(
108
- "Diff the repository against a specific ref, will run all package `diff` scripts."
109
- ).option(
110
- "--since <ref>",
111
- "Diff the API against a specific ref",
112
- "origin/master"
113
- ).action(
114
- lazy(() => Promise.resolve().then(function () { return require('./cjs/diff-DDkHPBWC.cjs.js'); }).then((m) => m.command))
115
- );
116
- }
117
- function registerLintCommand(program) {
118
- const lintCommand = program.command("lint [command]").description("Tools for linting repository.");
119
- lintCommand.command("legacy-backend-exports [paths...]").description(
120
- "Lint backend plugin packages for legacy exports and make sure it conforms to the new export pattern"
121
- ).action(
122
- lazy(
123
- () => Promise.resolve().then(function () { return require('./cjs/lint-legacy-backend-exports-CDxZ51l5.cjs.js'); }).then((m) => m.lint)
124
- )
125
- );
126
- }
127
- function registerCommands(program) {
128
- program.command("api-reports [paths...]").option("--ci", "CI run checks that there is no changes on API reports").option("--tsc", "executes the tsc compilation before extracting the APIs").option("--docs", "generates the api documentation").option(
129
- "--include <pattern>",
130
- "Only include packages matching the provided patterns",
131
- (opt, opts = []) => [...opts, ...opt.split(",")]
132
- ).option(
133
- "--exclude <pattern>",
134
- "Exclude package matching the provided patterns",
135
- (opt, opts = []) => [...opts, ...opt.split(",")]
136
- ).option(
137
- "-a, --allow-warnings <allowWarningsPaths>",
138
- "continue processing packages after getting errors on selected packages Allows glob patterns and comma separated values (i.e. packages/core,plugins/core-*)"
139
- ).option(
140
- "--allow-all-warnings",
141
- "continue processing packages after getting errors on all packages",
142
- false
143
- ).option(
144
- "-o, --omit-messages <messageCodes>",
145
- "select some message code to be omited on the API Extractor (comma separated values i.e ae-cyclic-inherit-doc,ae-missing-getter )"
146
- ).option(
147
- "--validate-release-tags",
148
- "Turn on release tag validation for the public, beta, and alpha APIs"
149
- ).description("Generate an API report for selected packages").action(
150
- lazy(
151
- () => Promise.resolve().then(function () { return require('./cjs/api-reports-B3Gt_Fej.cjs.js'); }).then((m) => m.buildApiReports)
152
- )
153
- );
154
- program.command("type-deps").description("Find inconsistencies in types of all packages and plugins").action(lazy(() => Promise.resolve().then(function () { return require('./cjs/type-deps-DgJcEpV_.cjs.js'); }).then((m) => m.default)));
155
- program.command("generate-catalog-info").option(
156
- "--dry-run",
157
- "Shows what would happen without actually writing any yaml."
158
- ).option(
159
- "--ci",
160
- "CI run checks that there are no changes to catalog-info.yaml files"
161
- ).description("Create or fix info yaml files for all backstage packages").action(
162
- lazy(
163
- () => Promise.resolve().then(function () { return require('./cjs/generate-catalog-info-DxKb-9Wh.cjs.js'); }).then(
164
- (m) => m.default
165
- )
166
- )
167
- );
168
- program.command("knip-reports [paths...]").option("--ci", "CI run checks that there is no changes on knip reports").description("Generate a knip report for selected packages").action(
169
- lazy(
170
- () => Promise.resolve().then(function () { return require('./cjs/knip-reports-028OuOct.cjs.js'); }).then((m) => m.buildKnipReports)
171
- )
172
- );
173
- registerPackageCommand(program);
174
- registerRepoCommand(program);
175
- registerLintCommand(program);
176
- }
177
- function lazy(getActionFunc) {
178
- return async (...args) => {
179
- try {
180
- const actionFunc = await getActionFunc();
181
- await actionFunc(...args);
182
- process.exit(0);
183
- } catch (error) {
184
- errors.assertError(error);
185
- exitWithError(error);
186
- }
187
- };
188
- }
189
-
190
- var version = "0.10.0-next.0";
191
-
192
13
  const main = (argv) => {
193
- commander.program.name("backstage-repo-tools").version(version);
194
- registerCommands(commander.program);
14
+ commander.program.name("backstage-repo-tools").version(_package.version);
15
+ index.registerCommands(commander.program);
195
16
  commander.program.on("command:*", () => {
196
17
  console.log();
197
18
  console.log(chalk__default.default.red(`Invalid command: ${commander.program.args.join(" ")}`));
@@ -203,9 +24,9 @@ const main = (argv) => {
203
24
  };
204
25
  process.on("unhandledRejection", (rejection) => {
205
26
  if (rejection instanceof Error) {
206
- exitWithError(rejection);
27
+ errors.exitWithError(rejection);
207
28
  } else {
208
- exitWithError(new Error(`Unknown rejection: '${rejection}'`));
29
+ errors.exitWithError(new Error(`Unknown rejection: '${rejection}'`));
209
30
  }
210
31
  });
211
32
  main(process.argv);
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
8
+
9
+ class CustomError extends Error {
10
+ get name() {
11
+ return this.constructor.name;
12
+ }
13
+ }
14
+ class ExitCodeError extends CustomError {
15
+ code;
16
+ constructor(code, command) {
17
+ super(
18
+ command ? `Command '${command}' exited with code ${code}` : `Child exited with code ${code}`
19
+ );
20
+ this.code = code;
21
+ }
22
+ }
23
+ function exitWithError(error) {
24
+ if (error instanceof ExitCodeError) {
25
+ process.stderr.write(`
26
+ ${chalk__default.default.red(error.message)}
27
+
28
+ `);
29
+ process.exit(error.code);
30
+ } else {
31
+ process.stderr.write(`
32
+ ${chalk__default.default.red(`${error}`)}
33
+
34
+ `);
35
+ process.exit(1);
36
+ }
37
+ }
38
+
39
+ exports.CustomError = CustomError;
40
+ exports.ExitCodeError = ExitCodeError;
41
+ exports.exitWithError = exitWithError;
42
+ //# sourceMappingURL=errors.cjs.js.map
@@ -33,4 +33,4 @@ const spawn = (command, args, options) => {
33
33
 
34
34
  exports.exec = exec;
35
35
  exports.spawn = spawn;
36
- //# sourceMappingURL=exec-C0kCNRgF.cjs.js.map
36
+ //# sourceMappingURL=exec.cjs.js.map
@@ -39,4 +39,4 @@ function getPackageExportDetails(pkg) {
39
39
  }
40
40
 
41
41
  exports.getPackageExportDetails = getPackageExportDetails;
42
- //# sourceMappingURL=getPackageExportDetails-FkT40JIH.cjs.js.map
42
+ //# sourceMappingURL=getPackageExportDetails.cjs.js.map
@@ -41,4 +41,4 @@ exports.OUTPUT_PATH = OUTPUT_PATH;
41
41
  exports.TS_MODULE = TS_MODULE;
42
42
  exports.TS_SCHEMA_PATH = TS_SCHEMA_PATH;
43
43
  exports.YAML_SCHEMA_PATH = YAML_SCHEMA_PATH;
44
- //# sourceMappingURL=constants-Dwa51b6l.cjs.js.map
44
+ //# sourceMappingURL=constants.cjs.js.map