@backstage/cli 0.34.4-next.1 → 0.34.4-next.3

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 CHANGED
@@ -1,5 +1,38 @@
1
1
  # @backstage/cli
2
2
 
3
+ ## 0.34.4-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - f2cf564: Removed the script transform cache from the default Jest configuration. The script cache provided a moderate performance boost, but it is incompatible with Jest 30.
8
+ - 024645e: Remove unused @octokit modules from cli package
9
+
10
+ - @octokit/graphql
11
+ - @octokit/graphql-schema
12
+ - @octokit/oauth-app
13
+
14
+ - d14ef24: Added automatic detection and support for the Backstage Yarn plugin when generating new packages with `yarn new`. When the plugin is installed, new packages will automatically use `backstage:^` ranges for `@backstage/*` dependencies.
15
+
16
+ ## 0.34.4-next.2
17
+
18
+ ### Patch Changes
19
+
20
+ - ab96bb7: Added a new `--entrypoint` option to the `package start` command, which allows you to specify a custom entry directory/file for development applications. This is particularly useful when maintaining separate dev apps for different versions of your plugin (e.g., stable and alpha).
21
+
22
+ **Example usage:**
23
+
24
+ Consider the following plugin dev folder structure:
25
+
26
+ ```
27
+ dev/
28
+ index.tsx
29
+ alpha/
30
+ index.ts
31
+ ```
32
+
33
+ - The default `yarn package start` command uses the `dev/` folder as the entry point and executes `dev/index.tsx` file;
34
+ - Running `yarn package start --entrypoint dev/alpha` will instead use `dev/alpha/` as the entry point and execute `dev/alpha/index.ts` file.
35
+
3
36
  ## 0.34.4-next.1
4
37
 
5
38
  ### Patch Changes
@@ -16,29 +16,12 @@
16
16
 
17
17
  const { default: JestRuntime } = require('jest-runtime');
18
18
 
19
- const scriptTransformCache = new Map();
20
-
21
19
  module.exports = class CachingJestRuntime extends JestRuntime {
22
20
  constructor(config, ...restArgs) {
23
21
  super(config, ...restArgs);
24
22
  this.allowLoadAsEsm = config.extensionsToTreatAsEsm.includes('.mts');
25
23
  }
26
24
 
27
- // This may or may not be a good idea. Theoretically I don't know why this would impact
28
- // test correctness and flakiness, but it seems like it may introduce flakiness and strange failures.
29
- // It does seem to speed up test execution by a fair amount though.
30
- createScriptFromCode(scriptSource, filename) {
31
- let script = scriptTransformCache.get(scriptSource);
32
- if (!script) {
33
- script = super.createScriptFromCode(scriptSource, filename);
34
- // Tried to store the script object in a WeakRef here. It starts out at
35
- // about 90% hit rate, but eventually drops all the way to 20%, and overall
36
- // it seemed to increase memory usage by 20% or so.
37
- scriptTransformCache.set(scriptSource, script);
38
- }
39
- return script;
40
- }
41
-
42
25
  // Unfortunately we need to use this unstable API to make sure that .js files
43
26
  // are only loaded as modules where ESM is supported, i.e. Node.js packages.
44
27
  unstable_shouldLoadAsEsm(path, ...restArgs) {
@@ -61,20 +61,23 @@ function findVersion() {
61
61
  }
62
62
  const version = findVersion();
63
63
  fs__default.default.pathExistsSync(paths.paths.resolveOwn("src"));
64
- function createPackageVersionProvider(lockfile) {
64
+ function createPackageVersionProvider(lockfile, options) {
65
65
  return (name, versionHint) => {
66
66
  const packageVersion = packageVersions[name];
67
+ const lockfileEntries = lockfile?.get(name);
68
+ const lockfileEntry = lockfileEntries?.find(
69
+ (entry) => entry.range.startsWith("workspace:")
70
+ );
71
+ if (lockfileEntry) {
72
+ return "workspace:^";
73
+ }
74
+ if (options?.preferBackstageProtocol && name.startsWith("@backstage/")) {
75
+ return "backstage:^";
76
+ }
67
77
  const targetVersion = versionHint || packageVersion;
68
78
  if (!targetVersion) {
69
79
  throw new Error(`No version available for package ${name}`);
70
80
  }
71
- const lockfileEntries = lockfile?.get(name);
72
- for (const specifier of ["^", "~", "*"]) {
73
- const range = `workspace:${specifier}`;
74
- if (lockfileEntries?.some((entry) => entry.range === range)) {
75
- return range;
76
- }
77
- }
78
81
  const validRanges = lockfileEntries?.filter(
79
82
  (entry) => semver__default.default.satisfies(targetVersion, entry.range)
80
83
  );
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var yaml = require('yaml');
5
+ var z = require('zod');
6
+ var paths = require('./paths.cjs.js');
7
+
8
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
9
+
10
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
11
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
12
+ var z__default = /*#__PURE__*/_interopDefaultCompat(z);
13
+
14
+ const yarnRcSchema = z__default.default.object({
15
+ plugins: z__default.default.array(
16
+ z__default.default.object({
17
+ path: z__default.default.string()
18
+ })
19
+ ).optional()
20
+ });
21
+ async function getHasYarnPlugin() {
22
+ const yarnRcPath = paths.paths.resolveTargetRoot(".yarnrc.yml");
23
+ const yarnRcContent = await fs__default.default.readFile(yarnRcPath, "utf-8").catch((e) => {
24
+ if (e.code === "ENOENT") {
25
+ return "";
26
+ }
27
+ throw e;
28
+ });
29
+ if (!yarnRcContent) {
30
+ return false;
31
+ }
32
+ const parseResult = yarnRcSchema.safeParse(yaml__default.default.parse(yarnRcContent));
33
+ if (!parseResult.success) {
34
+ throw new Error(
35
+ `Unexpected content in .yarnrc.yml: ${parseResult.error.toString()}`
36
+ );
37
+ }
38
+ const yarnRc = parseResult.data;
39
+ const backstagePlugin = yarnRc.plugins?.some(
40
+ (plugin) => plugin.path === ".yarn/plugins/@yarnpkg/plugin-backstage.cjs"
41
+ );
42
+ return Boolean(backstagePlugin);
43
+ }
44
+
45
+ exports.getHasYarnPlugin = getHasYarnPlugin;
46
+ //# sourceMappingURL=yarnPlugin.cjs.js.map
@@ -8,6 +8,7 @@ var paths = require('../../../../../lib/paths.cjs.js');
8
8
  async function command(opts) {
9
9
  await startPackage.startPackage({
10
10
  role: await role.findRoleFromCommand(opts),
11
+ entrypoint: opts.entrypoint,
11
12
  targetDir: paths.paths.targetDir,
12
13
  configPaths: opts.config,
13
14
  checksEnabled: Boolean(opts.check),
@@ -2,7 +2,17 @@
2
2
 
3
3
  var startBackend = require('./startBackend.cjs.js');
4
4
  var startFrontend = require('./startFrontend.cjs.js');
5
+ var path = require('path');
6
+ var glob = require('glob');
5
7
 
8
+ function resolveEntryPath(entrypoint = "dev", targetDir) {
9
+ const { dir: entryDir, name: entryName } = path.parse(entrypoint);
10
+ const [entryFile] = glob.glob.sync(`${path.resolve(targetDir, entryDir, entryName)}.*`);
11
+ if (entryFile) {
12
+ return path.join(entryDir, entryName);
13
+ }
14
+ return path.join(entryDir, entryName, "index");
15
+ }
6
16
  async function startPackage(options) {
7
17
  switch (options.role) {
8
18
  case "backend":
@@ -21,8 +31,8 @@ async function startPackage(options) {
21
31
  case "frontend-plugin":
22
32
  case "frontend-plugin-module":
23
33
  return startFrontend.startFrontend({
24
- entry: "dev/index",
25
- ...options
34
+ ...options,
35
+ entry: resolveEntryPath(options.entrypoint, options.targetDir)
26
36
  });
27
37
  case "frontend-dynamic-container":
28
38
  return startFrontend.startFrontend({
@@ -38,5 +48,6 @@ async function startPackage(options) {
38
48
  }
39
49
  }
40
50
 
51
+ exports.resolveEntryPath = resolveEntryPath;
41
52
  exports.startPackage = startPackage;
42
53
  //# sourceMappingURL=startPackage.cjs.js.map
@@ -89,6 +89,9 @@ const buildPlugin = factory.createCliPlugin({
89
89
  ).option(
90
90
  "--link <path>",
91
91
  "Link an external workspace for module resolution"
92
+ ).option(
93
+ "--entrypoint <path>",
94
+ 'The entrypoint to start from, relative to the package root. Can point to either a file (without extension) or a directory (in which case the index file in that directory is used). Defaults to "dev"'
92
95
  ).action(lazy.lazy(() => import('./commands/package/start/index.cjs.js'), "command"));
93
96
  await defaultCommand.parseAsync(args, { from: "user" });
94
97
  }
@@ -6,11 +6,10 @@ var fs = require('fs-extra');
6
6
  var chalk = require('chalk');
7
7
  var minimatch = require('minimatch');
8
8
  var semver = require('semver');
9
- var yaml = require('yaml');
10
- var z = require('zod');
11
9
  var errors = require('@backstage/errors');
12
10
  var path = require('path');
13
11
  var paths = require('../../../../lib/paths.cjs.js');
12
+ var yarnPlugin = require('../../../../lib/yarnPlugin.cjs.js');
14
13
  var Lockfile = require('../../../../lib/versioning/Lockfile.cjs.js');
15
14
  var packages = require('../../../../lib/versioning/packages.cjs.js');
16
15
  var cliCommon = require('@backstage/cli-common');
@@ -25,8 +24,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
25
24
  var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
26
25
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
27
26
  var semver__default = /*#__PURE__*/_interopDefaultCompat(semver);
28
- var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
29
- var z__default = /*#__PURE__*/_interopDefaultCompat(z);
30
27
 
31
28
  maybeBootstrapProxy();
32
29
  function maybeBootstrapProxy() {
@@ -56,7 +53,7 @@ function extendsDefaultPattern(pattern) {
56
53
  var bump = async (opts) => {
57
54
  const lockfilePath = paths.paths.resolveTargetRoot("yarn.lock");
58
55
  const lockfile = await Lockfile.Lockfile.load(lockfilePath);
59
- const hasYarnPlugin = await getHasYarnPlugin();
56
+ const hasYarnPlugin = await yarnPlugin.getHasYarnPlugin();
60
57
  let pattern = opts.pattern;
61
58
  if (!pattern) {
62
59
  console.log(`Using default pattern glob ${DEFAULT_PATTERN_GLOB}`);
@@ -377,35 +374,6 @@ async function asLockfileVersion(version) {
377
374
  }
378
375
  return version;
379
376
  }
380
- const yarnRcSchema = z__default.default.object({
381
- plugins: z__default.default.array(
382
- z__default.default.object({
383
- path: z__default.default.string()
384
- })
385
- ).optional()
386
- });
387
- async function getHasYarnPlugin() {
388
- const yarnRcPath = paths.paths.resolveTargetRoot(".yarnrc.yml");
389
- const yarnRcContent = await fs__default.default.readFile(yarnRcPath, "utf-8").catch((e) => {
390
- if (e.code === "ENOENT") {
391
- return "";
392
- }
393
- throw e;
394
- });
395
- if (!yarnRcContent) {
396
- return false;
397
- }
398
- const parseResult = yarnRcSchema.safeParse(yaml__default.default.parse(yarnRcContent));
399
- if (!parseResult.success) {
400
- throw new Error(
401
- `Unexpected content in .yarnrc.yml: ${parseResult.error.toString()}`
402
- );
403
- }
404
- const yarnRc = parseResult.data;
405
- return yarnRc.plugins?.some(
406
- (plugin) => plugin.path === ".yarn/plugins/@yarnpkg/plugin-backstage.cjs"
407
- );
408
- }
409
377
 
410
378
  exports.bumpBackstageJsonVersion = bumpBackstageJsonVersion;
411
379
  exports.createStrictVersionFinder = createStrictVersionFinder;
@@ -17,6 +17,7 @@ require('../../../../lib/run.cjs.js');
17
17
  require('@backstage/errors');
18
18
  var paths = require('../../../../lib/paths.cjs.js');
19
19
  var version = require('../../../../lib/version.cjs.js');
20
+ var yarnPlugin = require('../../../../lib/yarnPlugin.cjs.js');
20
21
 
21
22
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
22
23
 
@@ -47,7 +48,10 @@ class PortableTemplater {
47
48
  lockfile = await Lockfile.Lockfile.load(paths.paths.resolveTargetRoot("yarn.lock"));
48
49
  } catch {
49
50
  }
50
- const versionProvider = version.createPackageVersionProvider(lockfile);
51
+ const hasYarnPlugin = await yarnPlugin.getHasYarnPlugin();
52
+ const versionProvider = version.createPackageVersionProvider(lockfile, {
53
+ preferBackstageProtocol: hasYarnPlugin
54
+ });
51
55
  const templater = new PortableTemplater(
52
56
  {
53
57
  versionQuery(name, versionHint) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.13.0-next.1";
3
+ var version = "0.13.0-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.34.4-next.1";
3
+ var version = "0.34.4-next.3";
4
4
  var dependencies = {
5
5
  "@backstage/catalog-model": "workspace:^",
6
6
  "@backstage/cli-common": "workspace:^",
@@ -14,9 +14,6 @@ var dependencies = {
14
14
  "@backstage/types": "workspace:^",
15
15
  "@manypkg/get-packages": "^1.1.3",
16
16
  "@module-federation/enhanced": "^0.9.0",
17
- "@octokit/graphql": "^5.0.0",
18
- "@octokit/graphql-schema": "^13.7.0",
19
- "@octokit/oauth-app": "^4.2.0",
20
17
  "@octokit/request": "^8.0.0",
21
18
  "@rollup/plugin-commonjs": "^26.0.0",
22
19
  "@rollup/plugin-json": "^6.0.0",
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.3.4-next.0";
3
+ var version = "1.3.5-next.0";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.18.2-next.1";
3
+ var version = "0.18.2-next.3";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.1.15-next.1";
3
+ var version = "1.1.15-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.12.1-next.1";
3
+ var version = "0.12.1-next.2";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.7.12-next.0";
3
+ var version = "1.7.12-next.1";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.6.8";
3
+ var version = "0.6.9-next.0";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/cli",
3
- "version": "0.34.4-next.1",
3
+ "version": "0.34.4-next.3",
4
4
  "description": "CLI for developing Backstage plugins and apps",
5
5
  "backstage": {
6
6
  "role": "cli"
@@ -50,8 +50,8 @@
50
50
  "@backstage/catalog-model": "1.7.5",
51
51
  "@backstage/cli-common": "0.1.15",
52
52
  "@backstage/cli-node": "0.2.14",
53
- "@backstage/config": "1.3.4-next.0",
54
- "@backstage/config-loader": "1.10.4-next.0",
53
+ "@backstage/config": "1.3.5-next.0",
54
+ "@backstage/config-loader": "1.10.5-next.0",
55
55
  "@backstage/errors": "1.2.7",
56
56
  "@backstage/eslint-plugin": "0.1.11",
57
57
  "@backstage/integration": "1.18.1-next.1",
@@ -59,9 +59,6 @@
59
59
  "@backstage/types": "1.2.2",
60
60
  "@manypkg/get-packages": "^1.1.3",
61
61
  "@module-federation/enhanced": "^0.9.0",
62
- "@octokit/graphql": "^5.0.0",
63
- "@octokit/graphql-schema": "^13.7.0",
64
- "@octokit/oauth-app": "^4.2.0",
65
62
  "@octokit/request": "^8.0.0",
66
63
  "@rollup/plugin-commonjs": "^26.0.0",
67
64
  "@rollup/plugin-json": "^6.0.0",
@@ -157,19 +154,19 @@
157
154
  "@backstage/backend-plugin-api": "1.4.4-next.0",
158
155
  "@backstage/backend-test-utils": "1.9.1-next.1",
159
156
  "@backstage/catalog-client": "1.12.0",
160
- "@backstage/config": "1.3.4-next.0",
157
+ "@backstage/config": "1.3.5-next.0",
161
158
  "@backstage/core-app-api": "1.19.1-next.0",
162
- "@backstage/core-components": "0.18.2-next.1",
159
+ "@backstage/core-components": "0.18.2-next.3",
163
160
  "@backstage/core-plugin-api": "1.11.1-next.0",
164
- "@backstage/dev-utils": "1.1.15-next.1",
161
+ "@backstage/dev-utils": "1.1.15-next.2",
165
162
  "@backstage/errors": "1.2.7",
166
163
  "@backstage/plugin-auth-backend": "0.25.5-next.0",
167
164
  "@backstage/plugin-auth-backend-module-guest-provider": "0.2.13-next.0",
168
165
  "@backstage/plugin-catalog-node": "1.19.1-next.0",
169
166
  "@backstage/plugin-scaffolder-node": "0.12.0-next.1",
170
167
  "@backstage/plugin-scaffolder-node-test-utils": "0.3.4-next.1",
171
- "@backstage/test-utils": "1.7.12-next.0",
172
- "@backstage/theme": "0.6.8",
168
+ "@backstage/test-utils": "1.7.12-next.1",
169
+ "@backstage/theme": "0.6.9-next.0",
173
170
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
174
171
  "@types/cross-spawn": "^6.0.2",
175
172
  "@types/ejs": "^3.1.3",