@backstage/cli 0.0.0-nightly-20241008023419 → 0.0.0-nightly-20241009023248
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 +34 -6
- package/config/jest.js +9 -1
- package/config/jestCacheResultProcessor.cjs +23 -0
- package/config/jestSwcTransform.js +4 -1
- package/dist/commands/buildWorkspace.cjs.js +2 -1
- package/dist/commands/index.cjs.js +6 -0
- package/dist/commands/pack.cjs.js +5 -1
- package/dist/commands/repo/test.cjs.js +161 -5
- package/dist/lib/packager/createDistWorkspace.cjs.js +5 -4
- package/dist/lib/packager/productionPack.cjs.js +4 -5
- 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/cli/package.json.cjs.js +4 -2
- 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/test-utils/package.json.cjs.js +1 -1
- package/dist/packages/theme/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/scaffolder-node/package.json.cjs.js +1 -1
- package/package.json +15 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @backstage/cli
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20241009023248
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -23,17 +23,45 @@
|
|
|
23
23
|
- 03810d2: Remove unknown dependency `diff`
|
|
24
24
|
- cebee4f: Added support for a new experimental `EXPERIMENTAL_TRIM_NEXT_ENTRY` flag which removes any `./next` entry points present in packages when building and publishing.
|
|
25
25
|
- 094eaa3: Remove references to in-repo backend-common
|
|
26
|
+
- 7955f9b: Tweaked the new package feature detection to not be active when building backend packages.
|
|
27
|
+
- 720a2f9: Updated dependency `git-url-parse` to `^15.0.0`.
|
|
26
28
|
- 2c5ecf5: Support `--max-warnings` flag for package linting
|
|
27
|
-
- 8fe740d: Added a new `--successCache` option to the `backstage-cli repo lint`
|
|
29
|
+
- 8fe740d: Added a new `--successCache` option to the `backstage-cli repo test` and `backstage-cli repo lint` commands. The cache keeps track of successful runs and avoids re-running for individual packages if they haven't changed. This option is intended only to be used in CI.
|
|
28
30
|
|
|
29
|
-
In addition a `--successCacheDir
|
|
31
|
+
In addition a `--successCacheDir <path>` option has also been added to be able to override the default cache directory.
|
|
30
32
|
|
|
31
33
|
- 55b8b84: The Jest configuration will now search for a `src/setupTests.*` file with any valid script extension, not only `.ts`.
|
|
32
34
|
- 79ba5a8: The `LEGACY_BACKEND_START` flag is now deprecated.
|
|
35
|
+
- f0514c7: Disabled parsing of input source maps in the SWC transform for Jest.
|
|
33
36
|
- Updated dependencies
|
|
34
|
-
- @backstage/cli-node@0.0.0-nightly-
|
|
35
|
-
- @backstage/eslint-plugin@0.0.0-nightly-
|
|
36
|
-
- @backstage/integration@0.0.0-nightly-
|
|
37
|
+
- @backstage/cli-node@0.0.0-nightly-20241009023248
|
|
38
|
+
- @backstage/eslint-plugin@0.0.0-nightly-20241009023248
|
|
39
|
+
- @backstage/integration@0.0.0-nightly-20241009023248
|
|
40
|
+
- @backstage/catalog-model@1.7.0
|
|
41
|
+
- @backstage/cli-common@0.1.14
|
|
42
|
+
- @backstage/config@1.2.0
|
|
43
|
+
- @backstage/config-loader@1.9.1
|
|
44
|
+
- @backstage/errors@1.2.4
|
|
45
|
+
- @backstage/release-manifests@0.0.11
|
|
46
|
+
- @backstage/types@1.1.1
|
|
47
|
+
|
|
48
|
+
## 0.28.0-next.2
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- ea16633: Preserve directory structure for CommonJS build output, just like ESM. This makes the build output more stable and easier to browse, and allows for more effective tree shaking and lazy imports.
|
|
53
|
+
- 7955f9b: Tweaked the new package feature detection to not be active when building backend packages.
|
|
54
|
+
- 720a2f9: Updated dependency `git-url-parse` to `^15.0.0`.
|
|
55
|
+
- 2c5ecf5: Support `--max-warnings` flag for package linting
|
|
56
|
+
- 8fe740d: Added a new `--successCache` option to the `backstage-cli repo test` and `backstage-cli repo lint` commands. The cache keeps track of successful runs and avoids re-running for individual packages if they haven't changed. This option is intended only to be used in CI.
|
|
57
|
+
|
|
58
|
+
In addition a `--successCacheDir <path>` option has also been added to be able to override the default cache directory.
|
|
59
|
+
|
|
60
|
+
- f0514c7: Disabled parsing of input source maps in the SWC transform for Jest.
|
|
61
|
+
- Updated dependencies
|
|
62
|
+
- @backstage/cli-node@0.2.9-next.0
|
|
63
|
+
- @backstage/eslint-plugin@0.1.10-next.1
|
|
64
|
+
- @backstage/integration@1.15.1-next.1
|
|
37
65
|
- @backstage/catalog-model@1.7.0
|
|
38
66
|
- @backstage/cli-common@0.1.14
|
|
39
67
|
- @backstage/config@1.2.0
|
package/config/jest.js
CHANGED
|
@@ -306,7 +306,7 @@ async function getRootConfig() {
|
|
|
306
306
|
),
|
|
307
307
|
).then(_ => _.flat());
|
|
308
308
|
|
|
309
|
-
|
|
309
|
+
let configs = await Promise.all(
|
|
310
310
|
projectPaths.flat().map(async projectPath => {
|
|
311
311
|
const packagePath = path.resolve(projectPath, 'package.json');
|
|
312
312
|
if (!(await fs.pathExists(packagePath))) {
|
|
@@ -331,9 +331,17 @@ async function getRootConfig() {
|
|
|
331
331
|
}),
|
|
332
332
|
).then(cs => cs.filter(Boolean));
|
|
333
333
|
|
|
334
|
+
const cache = global.__backstageCli_jestSuccessCache;
|
|
335
|
+
if (cache) {
|
|
336
|
+
configs = await cache.filterConfigs(configs, globalRootConfig);
|
|
337
|
+
}
|
|
338
|
+
|
|
334
339
|
return {
|
|
335
340
|
rootDir: paths.targetRoot,
|
|
336
341
|
projects: configs,
|
|
342
|
+
testResultsProcessor: cache
|
|
343
|
+
? require.resolve('./jestCacheResultProcessor.cjs')
|
|
344
|
+
: undefined,
|
|
337
345
|
...globalRootConfig,
|
|
338
346
|
};
|
|
339
347
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
module.exports = async results => {
|
|
18
|
+
const cache = global.__backstageCli_jestSuccessCache;
|
|
19
|
+
if (cache) {
|
|
20
|
+
await cache.reportResults(results);
|
|
21
|
+
}
|
|
22
|
+
return results;
|
|
23
|
+
};
|
|
@@ -18,7 +18,10 @@ const { createTransformer: createSwcTransformer } = require('@swc/jest');
|
|
|
18
18
|
const ESM_REGEX = /\b(?:import|export)\b/;
|
|
19
19
|
|
|
20
20
|
function createTransformer(config) {
|
|
21
|
-
const swcTransformer = createSwcTransformer(
|
|
21
|
+
const swcTransformer = createSwcTransformer({
|
|
22
|
+
inputSourceMap: false,
|
|
23
|
+
...config,
|
|
24
|
+
});
|
|
22
25
|
const process = (source, filePath, jestOptions) => {
|
|
23
26
|
if (filePath.endsWith('.js') && !ESM_REGEX.test(source)) {
|
|
24
27
|
return { code: source };
|
|
@@ -15,7 +15,8 @@ var buildWorkspace = async (dir, packages, options) => {
|
|
|
15
15
|
}
|
|
16
16
|
await createDistWorkspace.createDistWorkspace(packages, {
|
|
17
17
|
targetDir: dir,
|
|
18
|
-
alwaysYarnPack: options.alwaysYarnPack
|
|
18
|
+
alwaysYarnPack: options.alwaysYarnPack,
|
|
19
|
+
enableFeatureDetection: true
|
|
19
20
|
});
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -51,6 +51,12 @@ function registerRepoCommand(program) {
|
|
|
51
51
|
command.command("test").allowUnknownOption(true).option(
|
|
52
52
|
"--since <ref>",
|
|
53
53
|
"Only test packages that changed since the specified ref"
|
|
54
|
+
).option(
|
|
55
|
+
"--successCache",
|
|
56
|
+
"Enable success caching, which skips running tests for unchanged packages that were successful in the previous run"
|
|
57
|
+
).option(
|
|
58
|
+
"--successCacheDir <path>",
|
|
59
|
+
"Set the success cache location, (default: node_modules/.cache/backstage-cli)"
|
|
54
60
|
).option(
|
|
55
61
|
"--jest-help",
|
|
56
62
|
"Show help for Jest CLI options, which are passed through"
|
|
@@ -4,6 +4,7 @@ var productionPack = require('../lib/packager/productionPack.cjs.js');
|
|
|
4
4
|
var paths = require('../lib/paths.cjs.js');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
var publishing = require('../lib/publishing.cjs.js');
|
|
7
|
+
var typeDistProject = require('../lib/typeDistProject.cjs.js');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
10
|
|
|
@@ -14,7 +15,10 @@ const pre = async () => {
|
|
|
14
15
|
dir: paths.paths.targetDir,
|
|
15
16
|
packageJson: await fs__default.default.readJson(paths.paths.resolveTarget("package.json"))
|
|
16
17
|
});
|
|
17
|
-
await productionPack.productionPack({
|
|
18
|
+
await productionPack.productionPack({
|
|
19
|
+
packageDir: paths.paths.targetDir,
|
|
20
|
+
featureDetectionProject: await typeDistProject.createTypeDistProject()
|
|
21
|
+
});
|
|
18
22
|
};
|
|
19
23
|
const post = async () => {
|
|
20
24
|
await productionPack.revertProductionPack(paths.paths.targetDir);
|
|
@@ -1,14 +1,68 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var os = require('os');
|
|
4
|
+
var crypto = require('node:crypto');
|
|
5
|
+
var fs = require('fs-extra');
|
|
6
|
+
var yargs = require('yargs');
|
|
7
|
+
var path = require('path');
|
|
4
8
|
var cliNode = require('@backstage/cli-node');
|
|
5
9
|
var paths = require('../../lib/paths.cjs.js');
|
|
6
10
|
var run = require('../../lib/run.cjs.js');
|
|
11
|
+
var cliCommon = require('@backstage/cli-common');
|
|
7
12
|
|
|
8
13
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
14
|
|
|
10
15
|
var os__default = /*#__PURE__*/_interopDefaultCompat(os);
|
|
16
|
+
var crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
17
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
18
|
+
var yargs__default = /*#__PURE__*/_interopDefaultCompat(yargs);
|
|
11
19
|
|
|
20
|
+
const CACHE_FILE_NAME = "test-cache.json";
|
|
21
|
+
async function readCache(dir) {
|
|
22
|
+
try {
|
|
23
|
+
const data = await fs__default.default.readJson(path.resolve(dir, CACHE_FILE_NAME));
|
|
24
|
+
if (!Array.isArray(data)) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
if (data.some((x) => typeof x !== "string")) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
return data;
|
|
31
|
+
} catch {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function writeCache(dir, cache) {
|
|
36
|
+
fs__default.default.mkdirpSync(dir);
|
|
37
|
+
fs__default.default.writeJsonSync(path.resolve(dir, CACHE_FILE_NAME), cache, { spaces: 2 });
|
|
38
|
+
}
|
|
39
|
+
async function readPackageTreeHashes(graph) {
|
|
40
|
+
const pkgs = Array.from(graph.values());
|
|
41
|
+
const output = await run.runPlain(
|
|
42
|
+
"git",
|
|
43
|
+
"ls-tree",
|
|
44
|
+
"--object-only",
|
|
45
|
+
"HEAD",
|
|
46
|
+
"--",
|
|
47
|
+
...pkgs.map((pkg) => path.relative(paths.paths.targetRoot, pkg.dir))
|
|
48
|
+
);
|
|
49
|
+
const treeShaList = output.trim().split(/\r?\n/);
|
|
50
|
+
if (treeShaList.length !== pkgs.length) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Error listing project git tree hashes, output length does not equal input length`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
const map = new Map(
|
|
56
|
+
pkgs.map((pkg, i) => [pkg.packageJson.name, treeShaList[i]])
|
|
57
|
+
);
|
|
58
|
+
return (pkgName) => {
|
|
59
|
+
const sha = map.get(pkgName);
|
|
60
|
+
if (!sha) {
|
|
61
|
+
throw new Error(`Tree sha not found for ${pkgName}`);
|
|
62
|
+
}
|
|
63
|
+
return sha;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
12
66
|
function createFlagFinder(args) {
|
|
13
67
|
const flags = /* @__PURE__ */ new Set();
|
|
14
68
|
for (const arg of args) {
|
|
@@ -32,14 +86,14 @@ function createFlagFinder(args) {
|
|
|
32
86
|
return false;
|
|
33
87
|
};
|
|
34
88
|
}
|
|
35
|
-
function removeOptionArg(args, option) {
|
|
89
|
+
function removeOptionArg(args, option, size = 2) {
|
|
36
90
|
let changed = false;
|
|
37
91
|
do {
|
|
38
92
|
changed = false;
|
|
39
93
|
const index = args.indexOf(option);
|
|
40
94
|
if (index >= 0) {
|
|
41
95
|
changed = true;
|
|
42
|
-
args.splice(index,
|
|
96
|
+
args.splice(index, size);
|
|
43
97
|
}
|
|
44
98
|
const indexEq = args.findIndex((arg) => arg.startsWith(`${option}=`));
|
|
45
99
|
if (indexEq >= 0) {
|
|
@@ -80,9 +134,17 @@ async function command(opts, cmd) {
|
|
|
80
134
|
if (opts.since) {
|
|
81
135
|
removeOptionArg(args, "--since");
|
|
82
136
|
}
|
|
83
|
-
|
|
137
|
+
let packageGraph;
|
|
138
|
+
async function getPackageGraph() {
|
|
139
|
+
if (packageGraph) {
|
|
140
|
+
return packageGraph;
|
|
141
|
+
}
|
|
84
142
|
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
85
|
-
|
|
143
|
+
packageGraph = cliNode.PackageGraph.fromPackages(packages);
|
|
144
|
+
return packageGraph;
|
|
145
|
+
}
|
|
146
|
+
if (opts.since && !hasFlags("--selectProjects")) {
|
|
147
|
+
const graph = await getPackageGraph();
|
|
86
148
|
const changedPackages = await graph.listChangedPackages({
|
|
87
149
|
ref: opts.since,
|
|
88
150
|
analyzeLockfile: true
|
|
@@ -110,7 +172,101 @@ async function command(opts, cmd) {
|
|
|
110
172
|
args.push("--help");
|
|
111
173
|
process.stdout._handle.setBlocking(true);
|
|
112
174
|
}
|
|
113
|
-
|
|
175
|
+
const jestCli = require("jest-cli");
|
|
176
|
+
if (opts.successCache) {
|
|
177
|
+
removeOptionArg(args, "--successCache", 1);
|
|
178
|
+
removeOptionArg(args, "--successCacheDir");
|
|
179
|
+
const cacheDir = path.resolve(
|
|
180
|
+
opts.successCacheDir ?? "node_modules/.cache/backstage-cli"
|
|
181
|
+
);
|
|
182
|
+
const { _: parsedArgs } = await yargs__default.default(args).options(jestCli.yargsOptions).argv;
|
|
183
|
+
if (parsedArgs.length > 0) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`The --successCache flag can not be combined with the following arguments: ${parsedArgs.join(
|
|
186
|
+
", "
|
|
187
|
+
)}`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
if (args.includes("--shard")) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
`The --successCache flag can not be combined with the --shard flag`
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
const graph = await getPackageGraph();
|
|
196
|
+
const projectHashes = /* @__PURE__ */ new Map();
|
|
197
|
+
const outputSuccessCache = new Array();
|
|
198
|
+
const globalWithCache = global;
|
|
199
|
+
globalWithCache.__backstageCli_jestSuccessCache = {
|
|
200
|
+
// This is called by `config/jest.js` after the project configs have been gathered
|
|
201
|
+
async filterConfigs(projectConfigs, globalRootConfig) {
|
|
202
|
+
const cache = await readCache(cacheDir);
|
|
203
|
+
const lockfile = await cliNode.Lockfile.load(
|
|
204
|
+
paths.paths.resolveTargetRoot("yarn.lock")
|
|
205
|
+
);
|
|
206
|
+
const getPackageTreeHash = await readPackageTreeHashes(graph);
|
|
207
|
+
const baseHash = crypto__default.default.createHash("sha1");
|
|
208
|
+
baseHash.update("v1");
|
|
209
|
+
baseHash.update("\0");
|
|
210
|
+
baseHash.update(process.version);
|
|
211
|
+
baseHash.update("\0");
|
|
212
|
+
baseHash.update(JSON.stringify(globalRootConfig));
|
|
213
|
+
const baseSha = baseHash.digest("hex");
|
|
214
|
+
return projectConfigs.filter((project) => {
|
|
215
|
+
const packageName = project.displayName;
|
|
216
|
+
const pkg = graph.get(packageName);
|
|
217
|
+
if (!pkg) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Package ${packageName} not found in package graph`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
const hash = crypto__default.default.createHash("sha1");
|
|
223
|
+
hash.update(baseSha);
|
|
224
|
+
const packageTreeSha = getPackageTreeHash(packageName);
|
|
225
|
+
hash.update(packageTreeSha);
|
|
226
|
+
for (const [depName, depPkg] of pkg.allLocalDependencies) {
|
|
227
|
+
const depHash = getPackageTreeHash(depPkg.name);
|
|
228
|
+
hash.update(`${depName}:${depHash}`);
|
|
229
|
+
}
|
|
230
|
+
hash.update(JSON.stringify(project));
|
|
231
|
+
hash.update(lockfile.getDependencyTreeHash(packageName));
|
|
232
|
+
const sha = hash.digest("hex");
|
|
233
|
+
projectHashes.set(packageName, sha);
|
|
234
|
+
if (cache?.includes(sha)) {
|
|
235
|
+
console.log(`Skipped ${packageName} due to cache hit`);
|
|
236
|
+
outputSuccessCache.push(sha);
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
return project;
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
// This is called by `config/jestCacheResultProcess.cjs` after all tests have run
|
|
243
|
+
async reportResults(results) {
|
|
244
|
+
const successful = /* @__PURE__ */ new Set();
|
|
245
|
+
const failed = /* @__PURE__ */ new Set();
|
|
246
|
+
for (const testResult of results.testResults) {
|
|
247
|
+
for (const [pkgName, pkg] of graph) {
|
|
248
|
+
if (cliCommon.isChildPath(pkg.dir, testResult.testFilePath)) {
|
|
249
|
+
if (testResult.testExecError || testResult.failureMessage || testResult.numFailingTests > 0) {
|
|
250
|
+
failed.add(pkgName);
|
|
251
|
+
successful.delete(pkgName);
|
|
252
|
+
} else if (!failed.has(pkgName)) {
|
|
253
|
+
successful.add(pkgName);
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const pkgName of successful) {
|
|
260
|
+
const sha = projectHashes.get(pkgName);
|
|
261
|
+
if (sha) {
|
|
262
|
+
outputSuccessCache.push(sha);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
await writeCache(cacheDir, outputSuccessCache);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
await jestCli.run(args);
|
|
114
270
|
}
|
|
115
271
|
|
|
116
272
|
exports.command = command;
|
|
@@ -118,7 +118,8 @@ async function createDistWorkspace(packageNames, options = {}) {
|
|
|
118
118
|
await moveToDistWorkspace(
|
|
119
119
|
targetDir,
|
|
120
120
|
targets,
|
|
121
|
-
Boolean(options.alwaysYarnPack)
|
|
121
|
+
Boolean(options.alwaysYarnPack),
|
|
122
|
+
Boolean(options.enableFeatureDetection)
|
|
122
123
|
);
|
|
123
124
|
const files = options.files ?? ["yarn.lock", "package.json"];
|
|
124
125
|
for (const file of files) {
|
|
@@ -149,12 +150,12 @@ const FAST_PACK_SCRIPTS = [
|
|
|
149
150
|
"backstage-cli prepack",
|
|
150
151
|
"backstage-cli package prepack"
|
|
151
152
|
];
|
|
152
|
-
async function moveToDistWorkspace(workspaceDir, localPackages, alwaysYarnPack) {
|
|
153
|
+
async function moveToDistWorkspace(workspaceDir, localPackages, alwaysYarnPack, enableFeatureDetection) {
|
|
153
154
|
const [fastPackPackages, slowPackPackages] = partition__default.default(
|
|
154
155
|
localPackages,
|
|
155
156
|
(pkg) => !alwaysYarnPack && FAST_PACK_SCRIPTS.includes(pkg.packageJson.scripts?.prepack)
|
|
156
157
|
);
|
|
157
|
-
const
|
|
158
|
+
const featureDetectionProject = fastPackPackages.length > 0 && enableFeatureDetection ? await typeDistProject.createTypeDistProject() : void 0;
|
|
158
159
|
await Promise.all(
|
|
159
160
|
fastPackPackages.map(async (target) => {
|
|
160
161
|
console.log(`Moving ${target.name} into dist workspace`);
|
|
@@ -163,7 +164,7 @@ async function moveToDistWorkspace(workspaceDir, localPackages, alwaysYarnPack)
|
|
|
163
164
|
await productionPack.productionPack({
|
|
164
165
|
packageDir: target.dir,
|
|
165
166
|
targetDir: absoluteOutputPath,
|
|
166
|
-
|
|
167
|
+
featureDetectionProject
|
|
167
168
|
});
|
|
168
169
|
})
|
|
169
170
|
);
|
|
@@ -26,7 +26,7 @@ async function productionPack(options) {
|
|
|
26
26
|
const writeCompatibilityEntryPoints = await prepareExportsEntryPoints(
|
|
27
27
|
pkg,
|
|
28
28
|
packageDir,
|
|
29
|
-
options.
|
|
29
|
+
options.featureDetectionProject
|
|
30
30
|
);
|
|
31
31
|
const publishConfig = pkg.publishConfig ?? {};
|
|
32
32
|
for (const key of Object.keys(publishConfig)) {
|
|
@@ -87,7 +87,7 @@ const EXPORT_MAP = {
|
|
|
87
87
|
require: ".cjs.js",
|
|
88
88
|
types: ".d.ts"
|
|
89
89
|
};
|
|
90
|
-
async function prepareExportsEntryPoints(pkg, packageDir,
|
|
90
|
+
async function prepareExportsEntryPoints(pkg, packageDir, featureDetectionProject) {
|
|
91
91
|
const distPath = path.resolve(packageDir, "dist");
|
|
92
92
|
if (!await fs__default.default.pathExists(distPath)) {
|
|
93
93
|
return void 0;
|
|
@@ -96,7 +96,6 @@ async function prepareExportsEntryPoints(pkg, packageDir, commonProject) {
|
|
|
96
96
|
const outputExports = {};
|
|
97
97
|
const compatibilityWriters = new Array();
|
|
98
98
|
const entryPoints$1 = entryPoints.readEntryPoints(pkg);
|
|
99
|
-
const project = commonProject || await typeDistProject.createTypeDistProject();
|
|
100
99
|
for (const entryPoint of entryPoints$1) {
|
|
101
100
|
if (!SCRIPT_EXTS.includes(entryPoint.ext)) {
|
|
102
101
|
outputExports[entryPoint.mount] = entryPoint.path;
|
|
@@ -110,11 +109,11 @@ async function prepareExportsEntryPoints(pkg, packageDir, commonProject) {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
exp.default = exp.require ?? exp.import;
|
|
113
|
-
if (exp.types) {
|
|
112
|
+
if (exp.types && featureDetectionProject) {
|
|
114
113
|
const defaultFeatureType = pkg.backstage?.role && typeDistProject.getEntryPointDefaultFeatureType(
|
|
115
114
|
pkg.backstage?.role,
|
|
116
115
|
packageDir,
|
|
117
|
-
|
|
116
|
+
featureDetectionProject,
|
|
118
117
|
exp.types
|
|
119
118
|
);
|
|
120
119
|
if (defaultFeatureType) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = "0.0.0-nightly-
|
|
3
|
+
var version = "0.0.0-nightly-20241009023248";
|
|
4
4
|
var dependencies = {
|
|
5
5
|
"@backstage/catalog-model": "workspace:*",
|
|
6
6
|
"@backstage/cli-common": "workspace:*",
|
|
@@ -66,13 +66,14 @@ var dependencies = {
|
|
|
66
66
|
express: "^4.17.1",
|
|
67
67
|
"fork-ts-checker-webpack-plugin": "^9.0.0",
|
|
68
68
|
"fs-extra": "^11.2.0",
|
|
69
|
-
"git-url-parse": "^
|
|
69
|
+
"git-url-parse": "^15.0.0",
|
|
70
70
|
glob: "^7.1.7",
|
|
71
71
|
"global-agent": "^3.0.0",
|
|
72
72
|
handlebars: "^4.7.3",
|
|
73
73
|
"html-webpack-plugin": "^5.3.1",
|
|
74
74
|
inquirer: "^8.2.0",
|
|
75
75
|
jest: "^29.7.0",
|
|
76
|
+
"jest-cli": "^29.7.0",
|
|
76
77
|
"jest-css-modules": "^2.1.0",
|
|
77
78
|
"jest-environment-jsdom": "^29.0.2",
|
|
78
79
|
"jest-runtime": "^29.0.2",
|
|
@@ -112,6 +113,7 @@ var dependencies = {
|
|
|
112
113
|
"webpack-dev-server": "^5.0.0",
|
|
113
114
|
"webpack-node-externals": "^3.0.0",
|
|
114
115
|
yaml: "^2.0.0",
|
|
116
|
+
yargs: "^16.2.0",
|
|
115
117
|
"yml-loader": "^2.1.0",
|
|
116
118
|
yn: "^4.0.0",
|
|
117
119
|
zod: "^3.22.4"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/cli",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20241009023248",
|
|
4
4
|
"description": "CLI for developing Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "cli"
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@backstage/catalog-model": "1.7.0",
|
|
46
46
|
"@backstage/cli-common": "0.1.14",
|
|
47
|
-
"@backstage/cli-node": "0.0.0-nightly-
|
|
47
|
+
"@backstage/cli-node": "0.0.0-nightly-20241009023248",
|
|
48
48
|
"@backstage/config": "1.2.0",
|
|
49
49
|
"@backstage/config-loader": "1.9.1",
|
|
50
50
|
"@backstage/errors": "1.2.4",
|
|
51
|
-
"@backstage/eslint-plugin": "0.0.0-nightly-
|
|
52
|
-
"@backstage/integration": "0.0.0-nightly-
|
|
51
|
+
"@backstage/eslint-plugin": "0.0.0-nightly-20241009023248",
|
|
52
|
+
"@backstage/integration": "0.0.0-nightly-20241009023248",
|
|
53
53
|
"@backstage/release-manifests": "0.0.11",
|
|
54
54
|
"@backstage/types": "1.1.1",
|
|
55
55
|
"@manypkg/get-packages": "^1.1.3",
|
|
@@ -106,13 +106,14 @@
|
|
|
106
106
|
"express": "^4.17.1",
|
|
107
107
|
"fork-ts-checker-webpack-plugin": "^9.0.0",
|
|
108
108
|
"fs-extra": "^11.2.0",
|
|
109
|
-
"git-url-parse": "^
|
|
109
|
+
"git-url-parse": "^15.0.0",
|
|
110
110
|
"glob": "^7.1.7",
|
|
111
111
|
"global-agent": "^3.0.0",
|
|
112
112
|
"handlebars": "^4.7.3",
|
|
113
113
|
"html-webpack-plugin": "^5.3.1",
|
|
114
114
|
"inquirer": "^8.2.0",
|
|
115
115
|
"jest": "^29.7.0",
|
|
116
|
+
"jest-cli": "^29.7.0",
|
|
116
117
|
"jest-css-modules": "^2.1.0",
|
|
117
118
|
"jest-environment-jsdom": "^29.0.2",
|
|
118
119
|
"jest-runtime": "^29.0.2",
|
|
@@ -152,21 +153,22 @@
|
|
|
152
153
|
"webpack-dev-server": "^5.0.0",
|
|
153
154
|
"webpack-node-externals": "^3.0.0",
|
|
154
155
|
"yaml": "^2.0.0",
|
|
156
|
+
"yargs": "^16.2.0",
|
|
155
157
|
"yml-loader": "^2.1.0",
|
|
156
158
|
"yn": "^4.0.0",
|
|
157
159
|
"zod": "^3.22.4"
|
|
158
160
|
},
|
|
159
161
|
"devDependencies": {
|
|
160
162
|
"@backstage/backend-common": "^0.25.0",
|
|
161
|
-
"@backstage/backend-plugin-api": "0.0.0-nightly-
|
|
162
|
-
"@backstage/backend-test-utils": "0.0.0-nightly-
|
|
163
|
+
"@backstage/backend-plugin-api": "0.0.0-nightly-20241009023248",
|
|
164
|
+
"@backstage/backend-test-utils": "0.0.0-nightly-20241009023248",
|
|
163
165
|
"@backstage/config": "1.2.0",
|
|
164
|
-
"@backstage/core-app-api": "0.0.0-nightly-
|
|
165
|
-
"@backstage/core-components": "0.0.0-nightly-
|
|
166
|
-
"@backstage/core-plugin-api": "0.0.0-nightly-
|
|
167
|
-
"@backstage/dev-utils": "0.0.0-nightly-
|
|
168
|
-
"@backstage/test-utils": "0.0.0-nightly-
|
|
169
|
-
"@backstage/theme": "0.0.0-nightly-
|
|
166
|
+
"@backstage/core-app-api": "0.0.0-nightly-20241009023248",
|
|
167
|
+
"@backstage/core-components": "0.0.0-nightly-20241009023248",
|
|
168
|
+
"@backstage/core-plugin-api": "0.0.0-nightly-20241009023248",
|
|
169
|
+
"@backstage/dev-utils": "0.0.0-nightly-20241009023248",
|
|
170
|
+
"@backstage/test-utils": "0.0.0-nightly-20241009023248",
|
|
171
|
+
"@backstage/theme": "0.0.0-nightly-20241009023248",
|
|
170
172
|
"@types/cross-spawn": "^6.0.2",
|
|
171
173
|
"@types/ejs": "^3.1.3",
|
|
172
174
|
"@types/express": "^4.17.6",
|