@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,159 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var errors$1 = require('../lib/errors.cjs.js');
5
+
6
+ function registerPackageCommand(program) {
7
+ const command = program.command("package [command]").description("Various tools for working with specific packages.");
8
+ const schemaCommand = command.command("schema [command]").description(
9
+ "Various tools for working with specific packages' API schema"
10
+ );
11
+ const openApiCommand = schemaCommand.command("openapi [command]").description("Tooling for OpenAPI schema");
12
+ openApiCommand.command("init").description(
13
+ "Initialize any required files to use the OpenAPI tooling for this package."
14
+ ).action(
15
+ lazy(
16
+ () => Promise.resolve().then(function () { return require('./package/schema/openapi/init.cjs.js'); }).then((m) => m.singleCommand)
17
+ )
18
+ );
19
+ openApiCommand.command("generate").option(
20
+ "--client-package [package]",
21
+ "Top-level path to where the client should be generated, ie packages/catalog-client."
22
+ ).option("--server").description(
23
+ "Command to generate a client and/or a server stub from an OpenAPI spec."
24
+ ).option("--client-additional-properties [properties]").description(
25
+ "Additional properties that can be passed to @openapitools/openapi-generator-cli"
26
+ ).action(
27
+ lazy(
28
+ () => Promise.resolve().then(function () { return require('./package/schema/openapi/generate/index.cjs.js'); }).then((m) => m.command)
29
+ )
30
+ );
31
+ openApiCommand.command("fuzz").description(
32
+ "Fuzz an OpenAPI schema by generating random data and sending it to the server."
33
+ ).option("--limit <limit>", "Maximum number of requests to send.").option("--workers <workers>", "Number of workers to use", "2").option(
34
+ "--debug",
35
+ `Enable debug mode, which will save cassettes to '.cassettes/{pluginId}.yml'`
36
+ ).option(
37
+ "--exclude-checks <excludeChecks>",
38
+ "Exclude checks from schemathesis run"
39
+ ).action(
40
+ lazy(() => Promise.resolve().then(function () { return require('./package/schema/openapi/fuzz.cjs.js'); }).then((m) => m.command))
41
+ );
42
+ 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(
43
+ lazy(() => Promise.resolve().then(function () { return require('./package/schema/openapi/diff.cjs.js'); }).then((m) => m.command))
44
+ );
45
+ }
46
+ function registerRepoCommand(program) {
47
+ const command = program.command("repo [command]").description("Tools for working across your entire repository.");
48
+ const schemaCommand = command.command("schema [command]").description("Various tools for working with API schema");
49
+ const openApiCommand = schemaCommand.command("openapi [command]").description("Tooling for OpenApi schema");
50
+ openApiCommand.command("verify [paths...]").description(
51
+ "Verify that all OpenAPI schemas are valid and set up correctly."
52
+ ).action(
53
+ lazy(
54
+ () => Promise.resolve().then(function () { return require('./repo/schema/openapi/verify.cjs.js'); }).then((m) => m.bulkCommand)
55
+ )
56
+ );
57
+ openApiCommand.command("lint [paths...]").description("Lint OpenAPI schemas.").option(
58
+ "--strict",
59
+ "Fail on any linting severity messages, not just errors."
60
+ ).action(
61
+ lazy(() => Promise.resolve().then(function () { return require('./repo/schema/openapi/lint.cjs.js'); }).then((m) => m.bulkCommand))
62
+ );
63
+ openApiCommand.command("test [paths...]").description("Test OpenAPI schemas against written tests").option("--update", "Update the spec on failure.").action(
64
+ lazy(() => Promise.resolve().then(function () { return require('./repo/schema/openapi/test.cjs.js'); }).then((m) => m.bulkCommand))
65
+ );
66
+ openApiCommand.command("fuzz").description("Fuzz all packages").option(
67
+ "--since <ref>",
68
+ "Only fuzz packages that have changed since the given ref"
69
+ ).action(
70
+ lazy(() => Promise.resolve().then(function () { return require('./repo/schema/openapi/fuzz.cjs.js'); }).then((m) => m.command))
71
+ );
72
+ openApiCommand.command("diff").description(
73
+ "Diff the repository against a specific ref, will run all package `diff` scripts."
74
+ ).option(
75
+ "--since <ref>",
76
+ "Diff the API against a specific ref",
77
+ "origin/master"
78
+ ).action(
79
+ lazy(() => Promise.resolve().then(function () { return require('./repo/schema/openapi/diff.cjs.js'); }).then((m) => m.command))
80
+ );
81
+ }
82
+ function registerLintCommand(program) {
83
+ const lintCommand = program.command("lint [command]").description("Tools for linting repository.");
84
+ lintCommand.command("legacy-backend-exports [paths...]").description(
85
+ "Lint backend plugin packages for legacy exports and make sure it conforms to the new export pattern"
86
+ ).action(
87
+ lazy(
88
+ () => Promise.resolve().then(function () { return require('./lint-legacy-backend-exports/lint-legacy-backend-exports.cjs.js'); }).then((m) => m.lint)
89
+ )
90
+ );
91
+ }
92
+ function registerCommands(program) {
93
+ 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(
94
+ "--include <pattern>",
95
+ "Only include packages matching the provided patterns",
96
+ (opt, opts = []) => [...opts, ...opt.split(",")]
97
+ ).option(
98
+ "--exclude <pattern>",
99
+ "Exclude package matching the provided patterns",
100
+ (opt, opts = []) => [...opts, ...opt.split(",")]
101
+ ).option(
102
+ "-a, --allow-warnings <allowWarningsPaths>",
103
+ "continue processing packages after getting errors on selected packages Allows glob patterns and comma separated values (i.e. packages/core,plugins/core-*)"
104
+ ).option(
105
+ "--allow-all-warnings",
106
+ "continue processing packages after getting errors on all packages",
107
+ false
108
+ ).option(
109
+ "-o, --omit-messages <messageCodes>",
110
+ "select some message code to be omited on the API Extractor (comma separated values i.e ae-cyclic-inherit-doc,ae-missing-getter )"
111
+ ).option(
112
+ "--validate-release-tags",
113
+ "Turn on release tag validation for the public, beta, and alpha APIs"
114
+ ).description("Generate an API report for selected packages").action(
115
+ lazy(
116
+ () => Promise.resolve().then(function () { return require('./api-reports/api-reports.cjs.js'); }).then((m) => m.buildApiReports)
117
+ )
118
+ );
119
+ program.command("type-deps").description("Find inconsistencies in types of all packages and plugins").action(lazy(() => Promise.resolve().then(function () { return require('./type-deps/type-deps.cjs.js'); }).then((m) => m.default)));
120
+ program.command("peer-deps").description(
121
+ "Ensure your packages are using the correct peer dependency format."
122
+ ).option("--fix", "Fix the issues found").action(lazy(() => Promise.resolve().then(function () { return require('./peer-deps/peer-deps.cjs.js'); }).then((m) => m.default)));
123
+ program.command("generate-catalog-info").option(
124
+ "--dry-run",
125
+ "Shows what would happen without actually writing any yaml."
126
+ ).option(
127
+ "--ci",
128
+ "CI run checks that there are no changes to catalog-info.yaml files"
129
+ ).description("Create or fix info yaml files for all backstage packages").action(
130
+ lazy(
131
+ () => Promise.resolve().then(function () { return require('./generate-catalog-info/generate-catalog-info.cjs.js'); }).then(
132
+ (m) => m.default
133
+ )
134
+ )
135
+ );
136
+ 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(
137
+ lazy(
138
+ () => Promise.resolve().then(function () { return require('./knip-reports/knip-reports.cjs.js'); }).then((m) => m.buildKnipReports)
139
+ )
140
+ );
141
+ registerPackageCommand(program);
142
+ registerRepoCommand(program);
143
+ registerLintCommand(program);
144
+ }
145
+ function lazy(getActionFunc) {
146
+ return async (...args) => {
147
+ try {
148
+ const actionFunc = await getActionFunc();
149
+ await actionFunc(...args);
150
+ process.exit(0);
151
+ } catch (error) {
152
+ errors.assertError(error);
153
+ errors$1.exitWithError(error);
154
+ }
155
+ };
156
+ }
157
+
158
+ exports.registerCommands = registerCommands;
159
+ //# sourceMappingURL=index.cjs.js.map
@@ -1,15 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var paths = require('./paths-BvbxdT_S.cjs.js');
3
+ var paths = require('../../lib/paths.cjs.js');
4
4
  var pLimit = require('p-limit');
5
5
  var os = require('os');
6
6
  var path = require('path');
7
7
  var fs = require('fs-extra');
8
- var util = require('./util-BhlP_S3V.cjs.js');
9
- require('@backstage/cli-common');
10
- require('@backstage/cli-node');
11
- require('minimatch');
12
- require('child_process');
8
+ var util = require('../util.cjs.js');
13
9
 
14
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
11
 
@@ -154,37 +150,5 @@ async function runKnipReports({
154
150
  }
155
151
  }
156
152
 
157
- const buildKnipReports = async (paths$1 = [], opts) => {
158
- const isCiBuild = opts.ci;
159
- const isAllPackages = !paths$1?.length;
160
- const selectedPackageDirs = await paths.resolvePackagePaths({
161
- paths: paths$1,
162
- include: opts.include,
163
- exclude: opts.exclude
164
- });
165
- if (isAllPackages && !isCiBuild) {
166
- console.log("");
167
- console.log(
168
- "TIP: You can generate knip-reports for select packages by passing package paths:"
169
- );
170
- console.log("");
171
- console.log(
172
- " yarn build:knip-reports packages/config packages/core-plugin-api plugins/*"
173
- );
174
- console.log("");
175
- }
176
- if (selectedPackageDirs.length > 0) {
177
- console.log("# Generating package knip reports");
178
- try {
179
- await runKnipReports({
180
- packageDirs: selectedPackageDirs,
181
- isLocalBuild: !isCiBuild
182
- });
183
- } catch (e) {
184
- process.exit(1);
185
- }
186
- }
187
- };
188
-
189
- exports.buildKnipReports = buildKnipReports;
190
- //# sourceMappingURL=knip-reports-028OuOct.cjs.js.map
153
+ exports.runKnipReports = runKnipReports;
154
+ //# sourceMappingURL=knip-extractor.cjs.js.map
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ var knipExtractor = require('./knip-extractor.cjs.js');
4
+ var paths = require('../../lib/paths.cjs.js');
5
+
6
+ const buildKnipReports = async (paths$1 = [], opts) => {
7
+ const isCiBuild = opts.ci;
8
+ const isAllPackages = !paths$1?.length;
9
+ const selectedPackageDirs = await paths.resolvePackagePaths({
10
+ paths: paths$1,
11
+ include: opts.include,
12
+ exclude: opts.exclude
13
+ });
14
+ if (isAllPackages && !isCiBuild) {
15
+ console.log("");
16
+ console.log(
17
+ "TIP: You can generate knip-reports for select packages by passing package paths:"
18
+ );
19
+ console.log("");
20
+ console.log(
21
+ " yarn build:knip-reports packages/config packages/core-plugin-api plugins/*"
22
+ );
23
+ console.log("");
24
+ }
25
+ if (selectedPackageDirs.length > 0) {
26
+ console.log("# Generating package knip reports");
27
+ try {
28
+ await knipExtractor.runKnipReports({
29
+ packageDirs: selectedPackageDirs,
30
+ isLocalBuild: !isCiBuild
31
+ });
32
+ } catch (e) {
33
+ process.exit(1);
34
+ }
35
+ }
36
+ };
37
+
38
+ exports.buildKnipReports = buildKnipReports;
39
+ //# sourceMappingURL=knip-reports.cjs.js.map
@@ -3,10 +3,8 @@
3
3
  var tsMorph = require('ts-morph');
4
4
  var cliNode = require('@backstage/cli-node');
5
5
  var fs = require('fs-extra');
6
- var paths = require('./paths-BvbxdT_S.cjs.js');
6
+ var paths = require('../../lib/paths.cjs.js');
7
7
  var path = require('path');
8
- require('@backstage/cli-common');
9
- require('minimatch');
10
8
 
11
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
12
10
 
@@ -69,4 +67,4 @@ function verifyIndex(pkg, packageJson) {
69
67
  }
70
68
 
71
69
  exports.lint = lint;
72
- //# sourceMappingURL=lint-legacy-backend-exports-CDxZ51l5.cjs.js.map
70
+ //# sourceMappingURL=lint-legacy-backend-exports.cjs.js.map
@@ -1,19 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var exec = require('./exec-C0kCNRgF.cjs.js');
5
- var helpers = require('./helpers-ja_ryoK_.cjs.js');
6
- var paths = require('./paths-BvbxdT_S.cjs.js');
4
+ var exec = require('../../../../lib/exec.cjs.js');
5
+ var helpers = require('../../../../lib/openapi/helpers.cjs.js');
6
+ var paths = require('../../../../lib/paths.cjs.js');
7
7
  var process$1 = require('process');
8
8
  var promises = require('fs/promises');
9
9
  var path = require('path');
10
- require('util');
11
- require('child_process');
12
- require('fs-extra');
13
- require('./constants-Dwa51b6l.cjs.js');
14
- require('@backstage/cli-common');
15
- require('@backstage/cli-node');
16
- require('minimatch');
17
10
 
18
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
19
12
 
@@ -79,4 +72,4 @@ async function command(opts) {
79
72
  }
80
73
 
81
74
  exports.command = command;
82
- //# sourceMappingURL=diff-zt06VUKR.cjs.js.map
75
+ //# sourceMappingURL=diff.cjs.js.map
@@ -1,20 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var fs = require('fs-extra');
4
- var paths = require('./paths-BvbxdT_S.cjs.js');
4
+ var paths = require('../../../../lib/paths.cjs.js');
5
5
  var chalk = require('chalk');
6
- var exec = require('./exec-C0kCNRgF.cjs.js');
7
- var helpers = require('./helpers-ja_ryoK_.cjs.js');
6
+ var exec = require('../../../../lib/exec.cjs.js');
7
+ var helpers = require('../../../../lib/openapi/helpers.cjs.js');
8
8
  var configLoader = require('@backstage/config-loader');
9
9
  var YAML = require('js-yaml');
10
10
  var path = require('path');
11
11
  var commandExists = require('command-exists');
12
- require('@backstage/cli-common');
13
- require('@backstage/cli-node');
14
- require('minimatch');
15
- require('util');
16
- require('child_process');
17
- require('./constants-Dwa51b6l.cjs.js');
18
12
 
19
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
20
14
 
@@ -85,4 +79,4 @@ async function command(opts) {
85
79
  }
86
80
 
87
81
  exports.command = command;
88
- //# sourceMappingURL=fuzz-BGbvHwkB.cjs.js.map
82
+ //# sourceMappingURL=fuzz.cjs.js.map
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var path = require('path');
5
+ var constants = require('../../../../../lib/openapi/constants.cjs.js');
6
+ var paths = require('../../../../../lib/paths.cjs.js');
7
+ var fs = require('fs-extra');
8
+ var exec = require('../../../../../lib/exec.cjs.js');
9
+ var backendPluginApi = require('@backstage/backend-plugin-api');
10
+ var helpers = require('../../../../../lib/openapi/helpers.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
+ async function generate(outputDirectory, clientAdditionalProperties) {
18
+ const resolvedOpenapiPath = await helpers.getPathToCurrentOpenApiSpec();
19
+ const resolvedOutputDirectory = paths.paths.resolveTargetRoot(
20
+ outputDirectory,
21
+ constants.OUTPUT_PATH
22
+ );
23
+ const additionalProperties = clientAdditionalProperties ? `--additional-properties=${clientAdditionalProperties}` : "";
24
+ fs.mkdirpSync(resolvedOutputDirectory);
25
+ await fs__default.default.mkdirp(resolvedOutputDirectory);
26
+ await fs__default.default.writeFile(
27
+ path.resolve(resolvedOutputDirectory, ".openapi-generator-ignore"),
28
+ constants.OPENAPI_IGNORE_FILES.join("\n")
29
+ );
30
+ await exec.exec(
31
+ "node",
32
+ [
33
+ backendPluginApi.resolvePackagePath("@openapitools/openapi-generator-cli", "main.js"),
34
+ "generate",
35
+ "-i",
36
+ resolvedOpenapiPath,
37
+ "-o",
38
+ resolvedOutputDirectory,
39
+ "-g",
40
+ "typescript",
41
+ "-c",
42
+ backendPluginApi.resolvePackagePath(
43
+ "@backstage/repo-tools",
44
+ "templates/typescript-backstage.yaml"
45
+ ),
46
+ "--generator-key",
47
+ "v3.0",
48
+ additionalProperties
49
+ ],
50
+ {
51
+ maxBuffer: Number.MAX_VALUE,
52
+ cwd: backendPluginApi.resolvePackagePath("@backstage/repo-tools"),
53
+ env: {
54
+ ...process.env
55
+ }
56
+ }
57
+ );
58
+ await exec.exec(
59
+ `yarn backstage-cli package lint --fix ${resolvedOutputDirectory}`
60
+ );
61
+ const prettier = paths.paths.resolveTargetRoot("node_modules/.bin/prettier");
62
+ if (prettier) {
63
+ await exec.exec(`${prettier} --write ${resolvedOutputDirectory}`);
64
+ }
65
+ fs__default.default.removeSync(path.resolve(resolvedOutputDirectory, ".openapi-generator-ignore"));
66
+ fs__default.default.rmSync(path.resolve(resolvedOutputDirectory, ".openapi-generator"), {
67
+ recursive: true,
68
+ force: true
69
+ });
70
+ }
71
+ async function command(outputPackage, clientAdditionalProperties) {
72
+ try {
73
+ await generate(outputPackage, clientAdditionalProperties);
74
+ console.log(
75
+ chalk__default.default.green(`Generated client in ${outputPackage}/${constants.OUTPUT_PATH}`)
76
+ );
77
+ } catch (err) {
78
+ console.log();
79
+ console.log(chalk__default.default.red(`Client generation failed:`));
80
+ console.log(err);
81
+ process.exit(1);
82
+ }
83
+ }
84
+
85
+ exports.command = command;
86
+ //# sourceMappingURL=client.cjs.js.map
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var client = require('./client.cjs.js');
5
+ var server = require('./server.cjs.js');
6
+
7
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
+
9
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
10
+
11
+ async function command(opts) {
12
+ if (!opts.clientPackage && !opts.server) {
13
+ console.log(
14
+ chalk__default.default.red("Either --client-package or --server must be defined.")
15
+ );
16
+ process.exit(1);
17
+ }
18
+ if (opts.clientPackage) {
19
+ await client.command(opts.clientPackage, opts.clientAdditionalProperties);
20
+ }
21
+ if (opts.server) {
22
+ await server.command();
23
+ }
24
+ }
25
+
26
+ exports.command = command;
27
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var YAML = require('js-yaml');
5
+ var chalk = require('chalk');
6
+ var paths = require('../../../../../lib/paths.cjs.js');
7
+ var constants = require('../../../../../lib/openapi/constants.cjs.js');
8
+ var util = require('util');
9
+ var child_process = require('child_process');
10
+ var helpers = require('../../../../../lib/openapi/helpers.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
15
+ var YAML__default = /*#__PURE__*/_interopDefaultCompat(YAML);
16
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
17
+
18
+ const exec = util.promisify(child_process.exec);
19
+ async function generate() {
20
+ const openapiPath = await helpers.getPathToCurrentOpenApiSpec();
21
+ const yaml = YAML__default.default.load(await fs__default.default.readFile(openapiPath, "utf8"));
22
+ const tsPath = paths.paths.resolveTarget(constants.TS_SCHEMA_PATH);
23
+ await fs__default.default.writeFile(
24
+ tsPath,
25
+ `//
26
+
27
+ // ******************************************************************
28
+ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
29
+ // ******************************************************************
30
+ import {createValidatedOpenApiRouter} from '@backstage/backend-openapi-utils';
31
+ export const spec = ${JSON.stringify(yaml, null, 2)} as const;
32
+ export const createOpenApiRouter = async (
33
+ options?: Parameters<typeof createValidatedOpenApiRouter>['1'],
34
+ ) => createValidatedOpenApiRouter<typeof spec>(spec, options);
35
+ `
36
+ );
37
+ await exec(`yarn backstage-cli package lint --fix ${tsPath}`);
38
+ if (await paths.paths.resolveTargetRoot("node_modules/.bin/prettier")) {
39
+ await exec(`yarn prettier --write ${tsPath}`, {
40
+ cwd: paths.paths.targetRoot
41
+ });
42
+ }
43
+ }
44
+ async function command() {
45
+ try {
46
+ await generate();
47
+ console.log(chalk__default.default.green("Generated all files."));
48
+ } catch (err) {
49
+ console.log(chalk__default.default.red(`OpenAPI server stub generation failed.`));
50
+ console.log(err.message);
51
+ process.exit(1);
52
+ }
53
+ }
54
+
55
+ exports.command = command;
56
+ //# sourceMappingURL=server.cjs.js.map
@@ -1,17 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var fs = require('fs-extra');
4
- var constants = require('./constants-Dwa51b6l.cjs.js');
5
- var paths = require('./paths-BvbxdT_S.cjs.js');
4
+ var constants = require('../../../../lib/openapi/constants.cjs.js');
5
+ var paths = require('../../../../lib/paths.cjs.js');
6
6
  var chalk = require('chalk');
7
- var exec = require('./exec-C0kCNRgF.cjs.js');
8
- var helpers = require('./helpers-ja_ryoK_.cjs.js');
9
- require('@backstage/cli-common');
10
- require('@backstage/cli-node');
11
- require('minimatch');
12
- require('path');
13
- require('util');
14
- require('child_process');
7
+ var exec = require('../../../../lib/exec.cjs.js');
8
+ var helpers = require('../../../../lib/openapi/helpers.cjs.js');
15
9
 
16
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
17
11
 
@@ -71,4 +65,4 @@ async function singleCommand() {
71
65
  }
72
66
 
73
67
  exports.singleCommand = singleCommand;
74
- //# sourceMappingURL=init-wsIZc-Ys.cjs.js.map
68
+ //# sourceMappingURL=init.cjs.js.map