@backstage/repo-tools 0.2.0-next.2 → 0.2.0
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 +17 -0
- package/dist/cjs/{api-reports-6ef2363c.cjs.js → api-reports-c4f9a18d.cjs.js} +8 -6
- package/dist/cjs/{constants-a9b2f484.cjs.js → constants-d6934676.cjs.js} +3 -3
- package/dist/cjs/{generate-d9406b4d.cjs.js → generate-9b41d8d7.cjs.js} +5 -5
- package/dist/cjs/paths-9ab9b8a8.cjs.js +49 -0
- package/dist/cjs/{verify-47d1fef6.cjs.js → verify-be04e091.cjs.js} +5 -6
- package/dist/index.cjs.js +14 -4
- package/package.json +3 -2
- package/dist/cjs/paths-5e048aab.cjs.js +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @backstage/repo-tools
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a876e69b20e: Adding two new commands to support OpenAPI spec writing, `schema:openapi:generate` to generate the Typescript file that `@backstage/backend-openapi-utils` needs for typing and `schema:openapi:verify` to verify that this file exists and matches your `src/schema/openapi.yaml` file.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f59041a3c07: Package paths provided to `api-reports` and OpenAPI commands will now match any path within the target package.
|
|
12
|
+
- f59041a3c07: Added `--include <patterns>` and `--exclude <patterns>` options for `api-reports` command that work based on package names.
|
|
13
|
+
- 9129ca8cabb: Log API report instructions when api-report is missing.
|
|
14
|
+
- e0c6e8b9c3c: Update peer dependencies
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/cli-node@0.1.0
|
|
17
|
+
- @backstage/cli-common@0.1.12
|
|
18
|
+
- @backstage/errors@1.1.5
|
|
19
|
+
|
|
3
20
|
## 0.2.0-next.2
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -12,13 +12,11 @@ var DocTable = require('@microsoft/api-documenter/lib/nodes/DocTable');
|
|
|
12
12
|
var DocTableRow = require('@microsoft/api-documenter/lib/nodes/DocTableRow');
|
|
13
13
|
var DocHeading = require('@microsoft/api-documenter/lib/nodes/DocHeading');
|
|
14
14
|
var CustomMarkdownEmitter = require('@microsoft/api-documenter/lib/markdown/CustomMarkdownEmitter');
|
|
15
|
-
var paths = require('./paths-
|
|
15
|
+
var paths = require('./paths-9ab9b8a8.cjs.js');
|
|
16
16
|
var minimatch = require('minimatch');
|
|
17
17
|
var entryPoints = require('./entryPoints-c9b88245.cjs.js');
|
|
18
18
|
require('@backstage/cli-common');
|
|
19
|
-
require('
|
|
20
|
-
require('is-glob');
|
|
21
|
-
require('util');
|
|
19
|
+
require('@backstage/cli-node');
|
|
22
20
|
|
|
23
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
22
|
|
|
@@ -1092,7 +1090,11 @@ const buildApiReports = async (paths$1 = [], opts) => {
|
|
|
1092
1090
|
const allowAllWarnings = opts.allowAllWarnings;
|
|
1093
1091
|
const omitMessages = parseArrayOption(opts.omitMessages);
|
|
1094
1092
|
const isAllPackages = !(paths$1 == null ? void 0 : paths$1.length);
|
|
1095
|
-
const selectedPackageDirs = await paths.
|
|
1093
|
+
const selectedPackageDirs = await paths.resolvePackagePaths({
|
|
1094
|
+
paths: paths$1,
|
|
1095
|
+
include: opts.include,
|
|
1096
|
+
exclude: opts.exclude
|
|
1097
|
+
});
|
|
1096
1098
|
if (isAllPackages && !isCiBuild && !isDocsBuild) {
|
|
1097
1099
|
console.log("");
|
|
1098
1100
|
console.log(
|
|
@@ -1148,4 +1150,4 @@ function parseArrayOption(value) {
|
|
|
1148
1150
|
}
|
|
1149
1151
|
|
|
1150
1152
|
exports.buildApiReports = buildApiReports;
|
|
1151
|
-
//# sourceMappingURL=api-reports-
|
|
1153
|
+
//# sourceMappingURL=api-reports-c4f9a18d.cjs.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var paths = require('./paths-
|
|
3
|
+
var paths = require('./paths-9ab9b8a8.cjs.js');
|
|
4
4
|
var pLimit = require('p-limit');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var pLimit__default = /*#__PURE__*/_interopDefaultLegacy(pLimit);
|
|
10
10
|
|
|
11
11
|
async function runner(paths$1, command) {
|
|
12
|
-
const packages = await paths.
|
|
12
|
+
const packages = await paths.resolvePackagePaths({ paths: paths$1 });
|
|
13
13
|
const limit = pLimit__default["default"](5);
|
|
14
14
|
const resultsList = await Promise.all(
|
|
15
15
|
packages.map(
|
|
@@ -39,4 +39,4 @@ exports.TS_MODULE = TS_MODULE;
|
|
|
39
39
|
exports.TS_SCHEMA_PATH = TS_SCHEMA_PATH;
|
|
40
40
|
exports.YAML_SCHEMA_PATH = YAML_SCHEMA_PATH;
|
|
41
41
|
exports.runner = runner;
|
|
42
|
-
//# sourceMappingURL=constants-
|
|
42
|
+
//# sourceMappingURL=constants-d6934676.cjs.js.map
|
|
@@ -4,13 +4,13 @@ var fs = require('fs-extra');
|
|
|
4
4
|
var YAML = require('js-yaml');
|
|
5
5
|
var chalk = require('chalk');
|
|
6
6
|
var path = require('path');
|
|
7
|
-
var constants = require('./constants-
|
|
7
|
+
var constants = require('./constants-d6934676.cjs.js');
|
|
8
8
|
var util = require('util');
|
|
9
9
|
var child_process = require('child_process');
|
|
10
|
-
require('./paths-
|
|
10
|
+
require('./paths-9ab9b8a8.cjs.js');
|
|
11
11
|
require('@backstage/cli-common');
|
|
12
|
-
require('
|
|
13
|
-
require('
|
|
12
|
+
require('@backstage/cli-node');
|
|
13
|
+
require('minimatch');
|
|
14
14
|
require('p-limit');
|
|
15
15
|
|
|
16
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -63,4 +63,4 @@ async function bulkCommand(paths = []) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
exports.bulkCommand = bulkCommand;
|
|
66
|
-
//# sourceMappingURL=generate-
|
|
66
|
+
//# sourceMappingURL=generate-9b41d8d7.cjs.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cliCommon = require('@backstage/cli-common');
|
|
4
|
+
var cliNode = require('@backstage/cli-node');
|
|
5
|
+
var minimatch = require('minimatch');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
|
|
8
|
+
const paths = cliCommon.findPaths(__dirname);
|
|
9
|
+
async function resolvePackagePaths(options = {}) {
|
|
10
|
+
const { paths: providedPaths, include, exclude } = options;
|
|
11
|
+
let packages = await cliNode.PackageGraph.listTargetPackages();
|
|
12
|
+
if (providedPaths && providedPaths.length > 0) {
|
|
13
|
+
packages = packages.filter(
|
|
14
|
+
({ dir }) => providedPaths.some(
|
|
15
|
+
(path$1) => new minimatch.Minimatch(path$1).match(path.relative(paths.targetRoot, dir)) || isChildPath(dir, path$1)
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (include) {
|
|
20
|
+
packages = packages.filter(
|
|
21
|
+
(pkg) => include.some(
|
|
22
|
+
(pattern) => new minimatch.Minimatch(pattern).match(path.relative(paths.targetRoot, pkg.dir))
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
if (exclude) {
|
|
27
|
+
packages = packages.filter(
|
|
28
|
+
(pkg) => exclude.some(
|
|
29
|
+
(pattern) => !new minimatch.Minimatch(pattern).match(
|
|
30
|
+
path.relative(paths.targetRoot, pkg.dir)
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return packages.map((pkg) => path.relative(paths.targetRoot, pkg.dir));
|
|
36
|
+
}
|
|
37
|
+
function isChildPath(base, path$1) {
|
|
38
|
+
const relative = path.relative(base, path$1);
|
|
39
|
+
if (relative === "") {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const outsideBase = relative.startsWith("..");
|
|
43
|
+
const differentDrive = path.isAbsolute(relative);
|
|
44
|
+
return !outsideBase && !differentDrive;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.paths = paths;
|
|
48
|
+
exports.resolvePackagePaths = resolvePackagePaths;
|
|
49
|
+
//# sourceMappingURL=paths-9ab9b8a8.cjs.js.map
|
|
@@ -6,13 +6,12 @@ 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 constants = require('./constants-
|
|
10
|
-
var paths = require('./paths-
|
|
9
|
+
var constants = require('./constants-d6934676.cjs.js');
|
|
10
|
+
var paths = require('./paths-9ab9b8a8.cjs.js');
|
|
11
11
|
require('p-limit');
|
|
12
12
|
require('@backstage/cli-common');
|
|
13
|
-
require('
|
|
14
|
-
require('
|
|
15
|
-
require('util');
|
|
13
|
+
require('@backstage/cli-node');
|
|
14
|
+
require('minimatch');
|
|
16
15
|
|
|
17
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
17
|
|
|
@@ -80,4 +79,4 @@ async function bulkCommand(paths = []) {
|
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
exports.bulkCommand = bulkCommand;
|
|
83
|
-
//# sourceMappingURL=verify-
|
|
82
|
+
//# sourceMappingURL=verify-be04e091.cjs.js.map
|
package/dist/index.cjs.js
CHANGED
|
@@ -39,6 +39,14 @@ ${chalk__default["default"].red(`${error}`)}
|
|
|
39
39
|
|
|
40
40
|
function registerCommands(program) {
|
|
41
41
|
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(
|
|
42
|
+
"--include <pattern>",
|
|
43
|
+
"Only include packages matching the provided patterns",
|
|
44
|
+
(opt, opts = []) => [...opts, ...opt.split(",")]
|
|
45
|
+
).option(
|
|
46
|
+
"--exclude <pattern>",
|
|
47
|
+
"Exclude package matching the provided patterns",
|
|
48
|
+
(opt, opts = []) => [...opts, ...opt.split(",")]
|
|
49
|
+
).option(
|
|
42
50
|
"-a, --allow-warnings <allowWarningsPaths>",
|
|
43
51
|
"continue processing packages after getting errors on selected packages Allows glob patterns and comma separated values (i.e. packages/core,plugins/core-*)"
|
|
44
52
|
).option(
|
|
@@ -53,16 +61,16 @@ function registerCommands(program) {
|
|
|
53
61
|
"Turn on release tag validation for the public, beta, and alpha APIs"
|
|
54
62
|
).description("Generate an API report for selected packages").action(
|
|
55
63
|
lazy(
|
|
56
|
-
() => Promise.resolve().then(function () { return require('./cjs/api-reports-
|
|
64
|
+
() => Promise.resolve().then(function () { return require('./cjs/api-reports-c4f9a18d.cjs.js'); }).then((m) => m.buildApiReports)
|
|
57
65
|
)
|
|
58
66
|
);
|
|
59
67
|
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-5eacd931.cjs.js'); }).then((m) => m.default)));
|
|
60
68
|
program.command("schema:openapi:verify [paths...]").description(
|
|
61
69
|
"Verify that all OpenAPI schemas are valid and have a matching `schemas/openapi.ts` file."
|
|
62
|
-
).action(lazy(() => Promise.resolve().then(function () { return require('./cjs/verify-
|
|
70
|
+
).action(lazy(() => Promise.resolve().then(function () { return require('./cjs/verify-be04e091.cjs.js'); }).then((m) => m.bulkCommand)));
|
|
63
71
|
program.command("schema:openapi:generate [paths...]").description(
|
|
64
72
|
"Generates a Typescript file from an OpenAPI yaml spec. For use with the `@backstage/backend-openapi-utils` ApiRouter type."
|
|
65
|
-
).action(lazy(() => Promise.resolve().then(function () { return require('./cjs/generate-
|
|
73
|
+
).action(lazy(() => Promise.resolve().then(function () { return require('./cjs/generate-9b41d8d7.cjs.js'); }).then((m) => m.bulkCommand)));
|
|
66
74
|
}
|
|
67
75
|
function lazy(getActionFunc) {
|
|
68
76
|
return async (...args) => {
|
|
@@ -77,8 +85,10 @@ function lazy(getActionFunc) {
|
|
|
77
85
|
};
|
|
78
86
|
}
|
|
79
87
|
|
|
88
|
+
var version = "0.2.0";
|
|
89
|
+
|
|
80
90
|
const main = (argv) => {
|
|
81
|
-
commander.program.name("backstage-repo-tools").version(
|
|
91
|
+
commander.program.name("backstage-repo-tools").version(version);
|
|
82
92
|
registerCommands(commander.program);
|
|
83
93
|
commander.program.on("command:*", () => {
|
|
84
94
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/repo-tools",
|
|
3
3
|
"description": "CLI for Backstage repo tooling ",
|
|
4
|
-
"version": "0.2.0
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
34
34
|
"@backstage/cli-common": "^0.1.12",
|
|
35
|
+
"@backstage/cli-node": "^0.1.0",
|
|
35
36
|
"@backstage/errors": "^1.1.5",
|
|
36
37
|
"@manypkg/get-packages": "^1.1.3",
|
|
37
38
|
"@microsoft/api-documenter": "^7.19.27",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"ts-node": "^10.0.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@backstage/cli": "^0.22.6
|
|
52
|
+
"@backstage/cli": "^0.22.6",
|
|
52
53
|
"@backstage/types": "^1.0.2",
|
|
53
54
|
"@types/is-glob": "^4.0.2",
|
|
54
55
|
"@types/mock-fs": "^4.13.0",
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var cliCommon = require('@backstage/cli-common');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var fs = require('fs-extra');
|
|
6
|
-
var g = require('glob');
|
|
7
|
-
var isGlob = require('is-glob');
|
|
8
|
-
var util = require('util');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
13
|
-
var g__default = /*#__PURE__*/_interopDefaultLegacy(g);
|
|
14
|
-
var isGlob__default = /*#__PURE__*/_interopDefaultLegacy(isGlob);
|
|
15
|
-
|
|
16
|
-
const glob = util.promisify(g__default["default"]);
|
|
17
|
-
const paths = cliCommon.findPaths(__dirname);
|
|
18
|
-
async function resolvePackagePath(packagePath) {
|
|
19
|
-
const fullPackageDir = paths.resolveTargetRoot(packagePath);
|
|
20
|
-
try {
|
|
21
|
-
const stat = await fs__default["default"].stat(fullPackageDir);
|
|
22
|
-
if (!stat.isDirectory()) {
|
|
23
|
-
return void 0;
|
|
24
|
-
}
|
|
25
|
-
const packageJsonPath = path.join(fullPackageDir, "package.json");
|
|
26
|
-
await fs__default["default"].access(packageJsonPath);
|
|
27
|
-
} catch (e) {
|
|
28
|
-
console.log(`folder omitted: ${fullPackageDir}, cause: ${e}`);
|
|
29
|
-
return void 0;
|
|
30
|
-
}
|
|
31
|
-
return path.relative(paths.targetRoot, fullPackageDir);
|
|
32
|
-
}
|
|
33
|
-
async function findPackageDirs(selectedPaths = []) {
|
|
34
|
-
const packageDirs = new Array();
|
|
35
|
-
for (const packageRoot of selectedPaths) {
|
|
36
|
-
const dirs = isGlob__default["default"](packageRoot) ? await glob(packageRoot, { cwd: paths.targetRoot }) : [packageRoot];
|
|
37
|
-
for (const dir of dirs) {
|
|
38
|
-
const packageDir = await resolvePackagePath(dir);
|
|
39
|
-
if (!packageDir) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
packageDirs.push(packageDir);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return packageDirs;
|
|
46
|
-
}
|
|
47
|
-
async function getWorkspacePackagePathPatterns() {
|
|
48
|
-
var _a;
|
|
49
|
-
const pkgJson = await fs__default["default"].readJson(paths.resolveTargetRoot("package.json")).catch((error) => {
|
|
50
|
-
if (error.code === "ENOENT") {
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
throw error;
|
|
54
|
-
});
|
|
55
|
-
const workspaces = (_a = pkgJson == null ? void 0 : pkgJson.workspaces) == null ? void 0 : _a.packages;
|
|
56
|
-
return workspaces;
|
|
57
|
-
}
|
|
58
|
-
async function getMatchingWorkspacePaths(cliPaths) {
|
|
59
|
-
const isAllPackages = !(cliPaths == null ? void 0 : cliPaths.length);
|
|
60
|
-
const selectedPaths = isAllPackages ? await getWorkspacePackagePathPatterns() : cliPaths;
|
|
61
|
-
return await findPackageDirs(selectedPaths);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exports.getMatchingWorkspacePaths = getMatchingWorkspacePaths;
|
|
65
|
-
exports.paths = paths;
|
|
66
|
-
//# sourceMappingURL=paths-5e048aab.cjs.js.map
|