@backstage/cli 0.7.14 → 0.8.1
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 +63 -0
- package/config/eslint.backend.js +11 -6
- package/config/jest.js +105 -23
- package/config/jestEsmTransform.js +4 -21
- package/config/jestSucraseTransform.js +66 -0
- package/dist/cjs/{build-71c737ac.cjs.js → build-036a2109.cjs.js} +4 -3
- package/dist/cjs/{build-b73c8aec.cjs.js → build-3192edeb.cjs.js} +6 -5
- package/dist/cjs/{build-61ca5bd1.cjs.js → build-32289a53.cjs.js} +4 -3
- package/dist/cjs/{build-b61079aa.cjs.js → build-7357e33b.cjs.js} +4 -3
- package/dist/cjs/{buildImage-66df0236.cjs.js → buildImage-62344040.cjs.js} +5 -4
- package/dist/cjs/{buildWorkspace-a669db03.cjs.js → buildWorkspace-794159d5.cjs.js} +5 -4
- package/dist/cjs/{bump-2c638ffb.cjs.js → bump-ab142f88.cjs.js} +10 -50
- package/dist/cjs/{bundle-11249412.cjs.js → bundle-faf5ad1e.cjs.js} +6 -5
- package/dist/cjs/{clean-d2c13478.cjs.js → clean-e96f4b94.cjs.js} +3 -2
- package/dist/cjs/{config-f0ca8800.cjs.js → config-dab34362.cjs.js} +2 -2
- package/dist/cjs/{createPlugin-3e4b2655.cjs.js → createPlugin-3c802c14.cjs.js} +8 -5
- package/dist/cjs/{dev-42d0b115.cjs.js → dev-5750e5cb.cjs.js} +7 -5
- package/dist/cjs/{diff-b3b15773.cjs.js → diff-86e1188b.cjs.js} +3 -2
- package/dist/cjs/{docs-75bdaacf.cjs.js → docs-34d3c7fe.cjs.js} +4 -3
- package/dist/cjs/{index-b0d38feb.cjs.js → index-1db5f8d6.cjs.js} +38 -35
- package/dist/cjs/{index-639c9015.cjs.js → index-69ec4ee3.cjs.js} +3 -3
- package/dist/cjs/{index-a8bb12f8.cjs.js → index-dc92c8f4.cjs.js} +3 -2
- package/dist/cjs/{info-35e4ffe5.cjs.js → info-f1a293c8.cjs.js} +4 -3
- package/dist/cjs/install-40b1f07e.cjs.js +214 -0
- package/dist/cjs/{lint-bda30147.cjs.js → lint-73e3cf0a.cjs.js} +4 -3
- package/dist/cjs/{lint-a5758aab.cjs.js → lint-95a1066a.cjs.js} +4 -3
- package/dist/cjs/{pack-08aaeb74.cjs.js → pack-a254b380.cjs.js} +3 -2
- package/dist/cjs/{packager-a538a0d7.cjs.js → packager-679f1af5.cjs.js} +2 -2
- package/dist/cjs/packages-4fe3897c.cjs.js +50 -0
- package/dist/cjs/{paths-38b204ca.cjs.js → paths-9f678df9.cjs.js} +15 -6
- package/dist/cjs/{print-38e80be2.cjs.js → print-b972c130.cjs.js} +4 -3
- package/dist/cjs/{removePlugin-eb1ad78f.cjs.js → removePlugin-dc596b42.cjs.js} +11 -3
- package/dist/cjs/{run-e50c9fbb.cjs.js → run-a312f9a6.cjs.js} +9 -4
- package/dist/cjs/{schema-c9b6362b.cjs.js → schema-463ba3bd.cjs.js} +4 -3
- package/dist/cjs/{serve-7edb404b.cjs.js → serve-3d293027.cjs.js} +8 -7
- package/dist/cjs/{serve-956c01c6.cjs.js → serve-7b531df5.cjs.js} +7 -6
- package/dist/cjs/{server-7a3f6d5a.cjs.js → server-5582cec8.cjs.js} +2 -2
- package/dist/cjs/{tasks-cfde6de5.cjs.js → tasks-d6b72c3c.cjs.js} +2 -2
- package/dist/cjs/{testCommand-635a6e22.cjs.js → testCommand-42b484a8.cjs.js} +4 -3
- package/dist/cjs/{validate-08241b93.cjs.js → validate-4b57eb89.cjs.js} +4 -3
- package/dist/index.cjs.js +2 -1
- package/package.json +20 -20
- package/templates/default-backend-plugin/package.json.hbs +1 -1
- package/templates/default-plugin/package.json.hbs +1 -1
- package/templates/default-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +5 -2
- package/templates/default-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +2 -2
- package/templates/default-plugin/src/plugin.ts.hbs +1 -0
- package/templates/default-plugin/src/setupTests.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# @backstage/cli
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f1e96dc5b1: Update usage of msw in default plugin template
|
|
8
|
+
- b0dc1fd241: bump `@spotify/eslint-config-base` from 9.0.2 to 12.0.0
|
|
9
|
+
- c5bb1df55d: Bump `msw` to `v0.35.0` to resolve [CVE-2021-32796](https://github.com/advisories/GHSA-5fg8-2547-mr8q).
|
|
10
|
+
- 10615525f3: Switch to use the json and observable types from `@backstage/types`
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/config@0.1.11
|
|
13
|
+
- @backstage/cli-common@0.1.5
|
|
14
|
+
- @backstage/errors@0.1.4
|
|
15
|
+
- @backstage/config-loader@0.7.1
|
|
16
|
+
|
|
17
|
+
## 0.8.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- b486adb8c6: The Jest configuration that's included with the Backstage CLI has received several changes.
|
|
22
|
+
|
|
23
|
+
As a part of migrating to more widespread usage of ESM modules, the default configuration now transforms all source files everywhere, including those within `node_modules`. Due to this change the existing `transformModules` option has been removed and will be ignored. There is also a list of known packages that do not require transforms in the CLI, which will evolve over time. If needed there will also be an option to add packages to this list in the future, but it is not included yet to avoid clutter.
|
|
24
|
+
|
|
25
|
+
To counteract the slowdown of the additional transforms that have been introduced, the default configuration has also been reworked to enable caching across different packages. Previously each package in a Backstage monorepo would have its own isolated Jest cache, but it is now shared between packages that have a similar enough Jest configuration.
|
|
26
|
+
|
|
27
|
+
Another change that will speed up test execution is that the transformer for `.esm.js` files has been switched. It used to be an ESM transformer based on Babel, but it is also done by sucrase now since it is significantly faster.
|
|
28
|
+
|
|
29
|
+
The changes above are not strictly breaking as all tests should still work. It may however cause excessive slowdowns in projects that have configured custom transforms in the `jest` field within `package.json` files. In this case it is either best to consider removing the custom transforms, or overriding the `transformIgnorePatterns` to instead use Jest's default `'/node_modules/'` pattern.
|
|
30
|
+
|
|
31
|
+
This change also removes the `@backstage/cli/config/jestEsmTransform.js` transform, which can be replaced by using the `@backstage/cli/config/sucraseEsmTransform.js` transform instead.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 36e67d2f24: Internal updates to apply more strict checks to throw errors.
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
- @backstage/config-loader@0.7.0
|
|
38
|
+
- @backstage/errors@0.1.3
|
|
39
|
+
|
|
40
|
+
## 0.7.16
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- 53bdc66623: add a --from <location> option to the plugin install command
|
|
45
|
+
- 84e24fcdaf: Bump sucrase to version 3.20.2
|
|
46
|
+
- 6583c6ac40: Add semicolon in template to make prettier happy
|
|
47
|
+
- c6f927d819: Bump mini-css-extract-plugin to v2
|
|
48
|
+
- 16f044cb6b: Update default backend ESLint configuration to allow usage of `__dirname` in tests.
|
|
49
|
+
- 1ef9e64901: Add an experimental `install <plugin>` command.
|
|
50
|
+
|
|
51
|
+
Given a `pluginId`, the command looks for NPM packages matching `@backstage/plugin-{pluginId}` or `backstage-plugin-{pluginId}` or `{pluginId}`. It looks for the `experimentalInstallationRecipe` in their `package.json` for the steps of installation. Detailed documentation and API Spec to follow (and to be decided as well).
|
|
52
|
+
|
|
53
|
+
## 0.7.15
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- ae4680b88d: The `create-plugin` command now passes the extension name via the `name` key
|
|
58
|
+
in `createRoutableExtension()` calls in newly created plugins.
|
|
59
|
+
- df1242ffe4: Adding `--inspect-brk` as an option when debugging backend for development
|
|
60
|
+
- c7f2a2307d: When creating a backend plugin with `--backend` flag, don't add `-backend` if it's already suffixed
|
|
61
|
+
- 185fec5c0c: The default jest configuration used by the `test` command now supports yarn workspaces. By running `backstage-cli test` in the root of a monorepo, all packages will now automatically be included in the test suite and it will run just like it does within a package. Each package in the monorepo will still use its own local jest configuration, and only packages that have `backstage-cli test` in the `test` script within `package.json` will be included.
|
|
62
|
+
- Updated dependencies
|
|
63
|
+
- @backstage/config-loader@0.6.10
|
|
64
|
+
- @backstage/cli-common@0.1.4
|
|
65
|
+
|
|
3
66
|
## 0.7.14
|
|
4
67
|
|
|
5
68
|
### Patch Changes
|
package/config/eslint.backend.js
CHANGED
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
const globalRestrictedSyntax = [
|
|
18
|
+
{
|
|
19
|
+
message:
|
|
20
|
+
'Default import from winston is not allowed, import `* as winston` instead.',
|
|
21
|
+
selector:
|
|
22
|
+
'ImportDeclaration[source.value="winston"] ImportDefaultSpecifier',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
17
26
|
module.exports = {
|
|
18
27
|
extends: [
|
|
19
28
|
'@spotify/eslint-config-base',
|
|
@@ -69,17 +78,12 @@ module.exports = {
|
|
|
69
78
|
// Avoid default import from winston as it breaks at runtime
|
|
70
79
|
'no-restricted-syntax': [
|
|
71
80
|
'error',
|
|
72
|
-
{
|
|
73
|
-
message:
|
|
74
|
-
'Default import from winston is not allowed, import `* as winston` instead.',
|
|
75
|
-
selector:
|
|
76
|
-
'ImportDeclaration[source.value="winston"] ImportDefaultSpecifier',
|
|
77
|
-
},
|
|
78
81
|
{
|
|
79
82
|
message:
|
|
80
83
|
"`__dirname` doesn't refer to the same dir in production builds, try `resolvePackagePath()` from `@backstage/backend-common` instead.",
|
|
81
84
|
selector: 'Identifier[name="__dirname"]',
|
|
82
85
|
},
|
|
86
|
+
...globalRestrictedSyntax,
|
|
83
87
|
],
|
|
84
88
|
},
|
|
85
89
|
overrides: [
|
|
@@ -103,6 +107,7 @@ module.exports = {
|
|
|
103
107
|
bundledDependencies: true,
|
|
104
108
|
},
|
|
105
109
|
],
|
|
110
|
+
'no-restricted-syntax': ['error', ...globalRestrictedSyntax],
|
|
106
111
|
},
|
|
107
112
|
},
|
|
108
113
|
],
|
package/config/jest.js
CHANGED
|
@@ -16,20 +16,41 @@
|
|
|
16
16
|
|
|
17
17
|
const fs = require('fs-extra');
|
|
18
18
|
const path = require('path');
|
|
19
|
+
const crypto = require('crypto');
|
|
20
|
+
const glob = require('util').promisify(require('glob'));
|
|
21
|
+
const { version } = require('../package.json');
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
const transformIgnorePattern = [
|
|
24
|
+
'@material-ui',
|
|
25
|
+
'@rjsf',
|
|
26
|
+
'ajv',
|
|
27
|
+
'core-js',
|
|
28
|
+
'jest-.*',
|
|
29
|
+
'jsdom',
|
|
30
|
+
'knex',
|
|
31
|
+
'react',
|
|
32
|
+
'react-dom',
|
|
33
|
+
'highlight\\.js',
|
|
34
|
+
'prismjs',
|
|
35
|
+
'react-use',
|
|
36
|
+
'typescript',
|
|
37
|
+
].join('|');
|
|
38
|
+
|
|
39
|
+
async function getProjectConfig(targetPath, displayName) {
|
|
40
|
+
const configJsPath = path.resolve(targetPath, 'jest.config.js');
|
|
41
|
+
const configTsPath = path.resolve(targetPath, 'jest.config.ts');
|
|
21
42
|
// If the package has it's own jest config, we use that instead.
|
|
22
|
-
if (await fs.pathExists(
|
|
23
|
-
return require(
|
|
24
|
-
} else if (await fs.pathExists(
|
|
25
|
-
return require(
|
|
43
|
+
if (await fs.pathExists(configJsPath)) {
|
|
44
|
+
return require(configJsPath);
|
|
45
|
+
} else if (await fs.pathExists(configTsPath)) {
|
|
46
|
+
return require(configTsPath);
|
|
26
47
|
}
|
|
27
48
|
|
|
28
49
|
// We read all "jest" config fields in package.json files all the way to the filesystem root.
|
|
29
50
|
// All configs are merged together to create the final config, with longer paths taking precedence.
|
|
30
51
|
// The merging of the configs is shallow, meaning e.g. all transforms are replaced if new ones are defined.
|
|
31
52
|
const pkgJsonConfigs = [];
|
|
32
|
-
let currentPath =
|
|
53
|
+
let currentPath = targetPath;
|
|
33
54
|
|
|
34
55
|
// Some sanity check to avoid infinite loop
|
|
35
56
|
for (let i = 0; i < 100; i++) {
|
|
@@ -55,10 +76,7 @@ async function getConfig() {
|
|
|
55
76
|
currentPath = newPath;
|
|
56
77
|
}
|
|
57
78
|
|
|
58
|
-
//
|
|
59
|
-
// called `transformModules`. It's a list of modules that we want to apply
|
|
60
|
-
// our configured jest transformations for.
|
|
61
|
-
// This is useful when packages are published in untranspiled ESM or TS form.
|
|
79
|
+
// This is an old deprecated option that is no longer used.
|
|
62
80
|
const transformModules = pkgJsonConfigs
|
|
63
81
|
.flatMap(conf => {
|
|
64
82
|
const modules = conf.transformModules || [];
|
|
@@ -67,19 +85,23 @@ async function getConfig() {
|
|
|
67
85
|
})
|
|
68
86
|
.map(name => `${name}/`)
|
|
69
87
|
.join('|');
|
|
70
|
-
|
|
88
|
+
if (transformModules.length > 0) {
|
|
89
|
+
console.warn(
|
|
90
|
+
'The Backstage CLI jest transformModules option is no longer used and will be ignored. All modules are now always transformed.',
|
|
91
|
+
);
|
|
92
|
+
}
|
|
71
93
|
|
|
72
94
|
const options = {
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
...(displayName && { displayName }),
|
|
96
|
+
rootDir: path.resolve(targetPath, 'src'),
|
|
97
|
+
coverageDirectory: path.resolve(targetPath, 'coverage'),
|
|
75
98
|
collectCoverageFrom: ['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts'],
|
|
76
99
|
moduleNameMapper: {
|
|
77
100
|
'\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'),
|
|
78
101
|
},
|
|
79
102
|
|
|
80
103
|
transform: {
|
|
81
|
-
'\\.
|
|
82
|
-
'\\.(js|jsx|ts|tsx)$': require.resolve('@sucrase/jest-plugin'),
|
|
104
|
+
'\\.(js|jsx|ts|tsx)$': require.resolve('./jestSucraseTransform.js'),
|
|
83
105
|
'\\.(bmp|gif|jpg|jpeg|png|frag|xml|svg|eot|woff|woff2|ttf)$':
|
|
84
106
|
require.resolve('./jestFileTransform.js'),
|
|
85
107
|
'\\.(yaml)$': require.resolve('jest-transform-yaml'),
|
|
@@ -88,19 +110,79 @@ async function getConfig() {
|
|
|
88
110
|
// A bit more opinionated
|
|
89
111
|
testMatch: ['**/?(*.)test.{js,jsx,mjs,ts,tsx}'],
|
|
90
112
|
|
|
91
|
-
|
|
92
|
-
// to apply the esm-transformer to .esm.js files, since that's what we use in backstage packages.
|
|
93
|
-
transformIgnorePatterns: [
|
|
94
|
-
`/node_modules/${transformModulePattern}.*\\.(?:(?<!esm\\.)js|json)$`,
|
|
95
|
-
],
|
|
113
|
+
transformIgnorePatterns: [`/node_modules/(?:${transformIgnorePattern})/`],
|
|
96
114
|
};
|
|
97
115
|
|
|
98
116
|
// Use src/setupTests.ts as the default location for configuring test env
|
|
99
|
-
if (fs.existsSync('src/setupTests.ts')) {
|
|
117
|
+
if (fs.existsSync(path.resolve(targetPath, 'src/setupTests.ts'))) {
|
|
100
118
|
options.setupFilesAfterEnv = ['<rootDir>/setupTests.ts'];
|
|
101
119
|
}
|
|
102
120
|
|
|
103
|
-
|
|
121
|
+
const config = Object.assign(options, ...pkgJsonConfigs);
|
|
122
|
+
|
|
123
|
+
// The config name is a cache key that lets us share the jest cache across projects.
|
|
124
|
+
// If no explicit name was configured, generated one based on the configuration.
|
|
125
|
+
if (!config.name) {
|
|
126
|
+
const configHash = crypto
|
|
127
|
+
.createHash('md5')
|
|
128
|
+
.update(version)
|
|
129
|
+
.update(Buffer.alloc(1))
|
|
130
|
+
.update(JSON.stringify(config.transform))
|
|
131
|
+
.digest('hex');
|
|
132
|
+
config.name = `backstage_cli_${configHash}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return config;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// This loads the root jest config, which in turn will either refer to a single
|
|
139
|
+
// configuration for the current package, or a collection of configurations for
|
|
140
|
+
// the target workspace packages
|
|
141
|
+
async function getRootConfig() {
|
|
142
|
+
const targetPath = process.cwd();
|
|
143
|
+
const targetPackagePath = path.resolve(targetPath, 'package.json');
|
|
144
|
+
const exists = await fs.pathExists(targetPackagePath);
|
|
145
|
+
|
|
146
|
+
if (!exists) {
|
|
147
|
+
return getProjectConfig(targetPath);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Check whether the current package is a workspace root or not
|
|
151
|
+
const data = await fs.readJson(targetPackagePath);
|
|
152
|
+
const workspacePatterns = data.workspaces && data.workspaces.packages;
|
|
153
|
+
if (!workspacePatterns) {
|
|
154
|
+
return getProjectConfig(targetPath);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// If the target package is a workspace root, we find all packages in the
|
|
158
|
+
// workspace and load those in as separate jest projects instead.
|
|
159
|
+
const projectPaths = await Promise.all(
|
|
160
|
+
workspacePatterns.map(pattern => glob(path.join(targetPath, pattern))),
|
|
161
|
+
).then(_ => _.flat());
|
|
162
|
+
|
|
163
|
+
const configs = await Promise.all(
|
|
164
|
+
projectPaths.flat().map(async projectPath => {
|
|
165
|
+
const packagePath = path.resolve(projectPath, 'package.json');
|
|
166
|
+
if (!(await fs.pathExists(packagePath))) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// We check for the presence of "backstage-cli test" in the package test
|
|
171
|
+
// script to determine whether a given package should be tested
|
|
172
|
+
const packageData = await fs.readJson(packagePath);
|
|
173
|
+
const testScript = packageData.scripts && packageData.scripts.test;
|
|
174
|
+
if (testScript && testScript.includes('backstage-cli test')) {
|
|
175
|
+
return await getProjectConfig(projectPath, packageData.name);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return undefined;
|
|
179
|
+
}),
|
|
180
|
+
).then(cs => cs.filter(Boolean));
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
rootDir: targetPath,
|
|
184
|
+
projects: configs,
|
|
185
|
+
};
|
|
104
186
|
}
|
|
105
187
|
|
|
106
|
-
module.exports =
|
|
188
|
+
module.exports = getRootConfig();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2021 The Backstage Authors
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,23 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// TODO: jest is working on module support, it's possible that we can remove this in the future
|
|
21
|
-
module.exports = {
|
|
22
|
-
process(src) {
|
|
23
|
-
const result = babel.transform(src, {
|
|
24
|
-
babelrc: false,
|
|
25
|
-
compact: false,
|
|
26
|
-
plugins: [
|
|
27
|
-
// This transforms the regular ESM syntax, import and export statements
|
|
28
|
-
require.resolve('@babel/plugin-transform-modules-commonjs'),
|
|
29
|
-
// This transforms dynamic `import()`, which is not supported yet in the Node.js VM API
|
|
30
|
-
require.resolve('babel-plugin-dynamic-import-node'),
|
|
31
|
-
],
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return result.code;
|
|
35
|
-
},
|
|
36
|
-
};
|
|
17
|
+
throw new Error(
|
|
18
|
+
'The ./jestEsmTransform.js transform has been removed, switch to using ./jestSucraseTransform.js instead',
|
|
19
|
+
);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 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
|
+
const { createHash } = require('crypto');
|
|
18
|
+
const { transform } = require('sucrase');
|
|
19
|
+
const sucrasePkg = require('sucrase/package.json');
|
|
20
|
+
const sucrasePluginPkg = require('@sucrase/jest-plugin/package.json');
|
|
21
|
+
|
|
22
|
+
const ESM_REGEX = /\b(?:import|export)\b/;
|
|
23
|
+
|
|
24
|
+
function process(source, filePath) {
|
|
25
|
+
let transforms;
|
|
26
|
+
|
|
27
|
+
if (filePath.endsWith('.esm.js')) {
|
|
28
|
+
transforms = ['imports'];
|
|
29
|
+
} else if (filePath.endsWith('.js')) {
|
|
30
|
+
// This is a very rough filter to avoid transforming things that we quickly
|
|
31
|
+
// can be sure are definitely not ESM modules.
|
|
32
|
+
if (ESM_REGEX.test(source)) {
|
|
33
|
+
transforms = ['imports', 'jsx']; // JSX within .js is currently allowed
|
|
34
|
+
}
|
|
35
|
+
} else if (filePath.endsWith('.jsx')) {
|
|
36
|
+
transforms = ['jsx', 'imports'];
|
|
37
|
+
} else if (filePath.endsWith('.ts')) {
|
|
38
|
+
transforms = ['typescript', 'imports'];
|
|
39
|
+
} else if (filePath.endsWith('.tsx')) {
|
|
40
|
+
transforms = ['typescript', 'jsx', 'imports'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Only apply the jest transform to the test files themselves
|
|
44
|
+
if (transforms && filePath.includes('.test.')) {
|
|
45
|
+
transforms.push('jest');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (transforms) {
|
|
49
|
+
return transform(source, { transforms, filePath }).code;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return source;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// TODO: contribute something like this to @sucrase/jest-plugin
|
|
56
|
+
function getCacheKey(sourceText) {
|
|
57
|
+
return createHash('md5')
|
|
58
|
+
.update(sourceText)
|
|
59
|
+
.update(Buffer.alloc(1))
|
|
60
|
+
.update(sucrasePkg.version)
|
|
61
|
+
.update(Buffer.alloc(1))
|
|
62
|
+
.update(sucrasePluginPkg.version)
|
|
63
|
+
.digest('hex');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { process, getCacheKey };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var packager = require('./packager-
|
|
3
|
+
var packager = require('./packager-679f1af5.cjs.js');
|
|
4
4
|
require('fs-extra');
|
|
5
5
|
require('rollup');
|
|
6
6
|
require('chalk');
|
|
7
7
|
require('path');
|
|
8
|
-
require('./index-
|
|
8
|
+
require('./index-1db5f8d6.cjs.js');
|
|
9
9
|
require('commander');
|
|
10
10
|
require('semver');
|
|
11
11
|
require('@backstage/cli-common');
|
|
12
12
|
require('@backstage/config/package.json');
|
|
13
|
+
require('@backstage/errors');
|
|
13
14
|
require('rollup-plugin-peer-deps-external');
|
|
14
15
|
require('@rollup/plugin-commonjs');
|
|
15
16
|
require('@rollup/plugin-node-resolve');
|
|
@@ -29,4 +30,4 @@ var build = async () => {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
exports.default = build;
|
|
32
|
-
//# sourceMappingURL=build-
|
|
33
|
+
//# sourceMappingURL=build-036a2109.cjs.js.map
|
|
@@ -12,20 +12,21 @@ require('@backstage/cli-common');
|
|
|
12
12
|
require('terser-webpack-plugin');
|
|
13
13
|
var parallel = require('./parallel-a4714c72.cjs.js');
|
|
14
14
|
require('mini-css-extract-plugin');
|
|
15
|
-
var index = require('./index-
|
|
16
|
-
require('./run-
|
|
15
|
+
var index = require('./index-1db5f8d6.cjs.js');
|
|
16
|
+
require('./run-a312f9a6.cjs.js');
|
|
17
17
|
require('lodash/pickBy');
|
|
18
18
|
var yn = require('yn');
|
|
19
19
|
var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
20
20
|
var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
21
|
-
var paths = require('./paths-
|
|
21
|
+
var paths = require('./paths-9f678df9.cjs.js');
|
|
22
22
|
var chalk = require('chalk');
|
|
23
23
|
require('webpack-dev-server');
|
|
24
24
|
require('react-dev-utils/openBrowser');
|
|
25
|
-
var config = require('./config-
|
|
25
|
+
var config = require('./config-dab34362.cjs.js');
|
|
26
26
|
require('commander');
|
|
27
27
|
require('semver');
|
|
28
28
|
require('@backstage/config/package.json');
|
|
29
|
+
require('@backstage/errors');
|
|
29
30
|
require('child_process');
|
|
30
31
|
require('util');
|
|
31
32
|
require('./svgrTemplate-2d0d15cf.cjs.js');
|
|
@@ -135,4 +136,4 @@ var build = async (cmd) => {
|
|
|
135
136
|
};
|
|
136
137
|
|
|
137
138
|
exports.default = build;
|
|
138
|
-
//# sourceMappingURL=build-
|
|
139
|
+
//# sourceMappingURL=build-3192edeb.cjs.js.map
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var packager = require('./packager-
|
|
3
|
+
var packager = require('./packager-679f1af5.cjs.js');
|
|
4
4
|
require('fs-extra');
|
|
5
5
|
require('rollup');
|
|
6
6
|
require('chalk');
|
|
7
7
|
require('path');
|
|
8
|
-
require('./index-
|
|
8
|
+
require('./index-1db5f8d6.cjs.js');
|
|
9
9
|
require('commander');
|
|
10
10
|
require('semver');
|
|
11
11
|
require('@backstage/cli-common');
|
|
12
12
|
require('@backstage/config/package.json');
|
|
13
|
+
require('@backstage/errors');
|
|
13
14
|
require('rollup-plugin-peer-deps-external');
|
|
14
15
|
require('@rollup/plugin-commonjs');
|
|
15
16
|
require('@rollup/plugin-node-resolve');
|
|
@@ -40,4 +41,4 @@ var build = async (cmd) => {
|
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
exports.default = build;
|
|
43
|
-
//# sourceMappingURL=build-
|
|
44
|
+
//# sourceMappingURL=build-32289a53.cjs.js.map
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var packager = require('./packager-
|
|
3
|
+
var packager = require('./packager-679f1af5.cjs.js');
|
|
4
4
|
require('fs-extra');
|
|
5
5
|
require('rollup');
|
|
6
6
|
require('chalk');
|
|
7
7
|
require('path');
|
|
8
|
-
require('./index-
|
|
8
|
+
require('./index-1db5f8d6.cjs.js');
|
|
9
9
|
require('commander');
|
|
10
10
|
require('semver');
|
|
11
11
|
require('@backstage/cli-common');
|
|
12
12
|
require('@backstage/config/package.json');
|
|
13
|
+
require('@backstage/errors');
|
|
13
14
|
require('rollup-plugin-peer-deps-external');
|
|
14
15
|
require('@rollup/plugin-commonjs');
|
|
15
16
|
require('@rollup/plugin-node-resolve');
|
|
@@ -29,4 +30,4 @@ var build = async () => {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
exports.default = build;
|
|
32
|
-
//# sourceMappingURL=build-
|
|
33
|
+
//# sourceMappingURL=build-7357e33b.cjs.js.map
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var fs = require('fs-extra');
|
|
5
5
|
var path = require('path');
|
|
6
|
-
var index$1 = require('./index-
|
|
7
|
-
var index = require('./index-
|
|
8
|
-
var run = require('./run-
|
|
6
|
+
var index$1 = require('./index-69ec4ee3.cjs.js');
|
|
7
|
+
var index = require('./index-1db5f8d6.cjs.js');
|
|
8
|
+
var run = require('./run-a312f9a6.cjs.js');
|
|
9
9
|
var parallel = require('./parallel-a4714c72.cjs.js');
|
|
10
10
|
require('os');
|
|
11
11
|
require('tar');
|
|
@@ -13,6 +13,7 @@ require('commander');
|
|
|
13
13
|
require('semver');
|
|
14
14
|
require('@backstage/cli-common');
|
|
15
15
|
require('@backstage/config/package.json');
|
|
16
|
+
require('@backstage/errors');
|
|
16
17
|
require('child_process');
|
|
17
18
|
require('util');
|
|
18
19
|
|
|
@@ -73,4 +74,4 @@ async function findAppConfigs() {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
exports.default = buildImage;
|
|
76
|
-
//# sourceMappingURL=buildImage-
|
|
77
|
+
//# sourceMappingURL=buildImage-62344040.cjs.js.map
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('fs-extra');
|
|
4
|
-
var index = require('./index-
|
|
4
|
+
var index = require('./index-69ec4ee3.cjs.js');
|
|
5
5
|
require('path');
|
|
6
6
|
require('os');
|
|
7
7
|
require('tar');
|
|
8
|
-
require('./index-
|
|
8
|
+
require('./index-1db5f8d6.cjs.js');
|
|
9
9
|
require('commander');
|
|
10
10
|
require('chalk');
|
|
11
11
|
require('semver');
|
|
12
12
|
require('@backstage/cli-common');
|
|
13
13
|
require('@backstage/config/package.json');
|
|
14
|
-
require('
|
|
14
|
+
require('@backstage/errors');
|
|
15
|
+
require('./run-a312f9a6.cjs.js');
|
|
15
16
|
require('child_process');
|
|
16
17
|
require('util');
|
|
17
18
|
|
|
@@ -29,4 +30,4 @@ var buildWorkspace = async (dir, _cmd, packages) => {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
exports.default = buildWorkspace;
|
|
32
|
-
//# sourceMappingURL=buildWorkspace-
|
|
33
|
+
//# sourceMappingURL=buildWorkspace-794159d5.cjs.js.map
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
var fs = require('fs-extra');
|
|
4
4
|
var chalk = require('chalk');
|
|
5
5
|
var semver = require('semver');
|
|
6
|
+
var errors = require('@backstage/errors');
|
|
6
7
|
var path = require('path');
|
|
7
|
-
var run = require('./run-
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var run = require('./run-a312f9a6.cjs.js');
|
|
9
|
+
var index = require('./index-1db5f8d6.cjs.js');
|
|
9
10
|
var Lockfile = require('./Lockfile-80f0eec4.cjs.js');
|
|
10
|
-
var
|
|
11
|
+
var packages = require('./packages-4fe3897c.cjs.js');
|
|
12
|
+
var lint = require('./lint-95a1066a.cjs.js');
|
|
11
13
|
require('child_process');
|
|
12
14
|
require('util');
|
|
13
15
|
require('commander');
|
|
@@ -22,48 +24,6 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
|
22
24
|
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
23
25
|
var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
|
|
24
26
|
|
|
25
|
-
const PREFIX = "@backstage";
|
|
26
|
-
const DEP_TYPES$1 = [
|
|
27
|
-
"dependencies",
|
|
28
|
-
"devDependencies",
|
|
29
|
-
"peerDependencies",
|
|
30
|
-
"optionalDependencies"
|
|
31
|
-
];
|
|
32
|
-
async function fetchPackageInfo(name) {
|
|
33
|
-
const output = await run.runPlain("yarn", "info", "--json", name);
|
|
34
|
-
if (!output) {
|
|
35
|
-
throw new index.NotFoundError(`No package information found for package ${name}`);
|
|
36
|
-
}
|
|
37
|
-
const info = JSON.parse(output);
|
|
38
|
-
if (info.type !== "inspect") {
|
|
39
|
-
throw new Error(`Received unknown yarn info for ${name}, ${output}`);
|
|
40
|
-
}
|
|
41
|
-
return info.data;
|
|
42
|
-
}
|
|
43
|
-
async function mapDependencies(targetDir) {
|
|
44
|
-
var _a;
|
|
45
|
-
const {Project} = require("@lerna/project");
|
|
46
|
-
const project = new Project(targetDir);
|
|
47
|
-
const packages = await project.getPackages();
|
|
48
|
-
const dependencyMap = new Map();
|
|
49
|
-
for (const pkg of packages) {
|
|
50
|
-
const deps = DEP_TYPES$1.flatMap((t) => {
|
|
51
|
-
var _a2;
|
|
52
|
-
return Object.entries((_a2 = pkg.get(t)) != null ? _a2 : {});
|
|
53
|
-
});
|
|
54
|
-
for (const [name, range] of deps) {
|
|
55
|
-
if (name.startsWith(PREFIX)) {
|
|
56
|
-
dependencyMap.set(name, ((_a = dependencyMap.get(name)) != null ? _a : []).concat({
|
|
57
|
-
range,
|
|
58
|
-
name: pkg.name,
|
|
59
|
-
location: pkg.location
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return dependencyMap;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
27
|
const DEP_TYPES = [
|
|
68
28
|
"dependencies",
|
|
69
29
|
"devDependencies",
|
|
@@ -75,7 +35,7 @@ var bump = async () => {
|
|
|
75
35
|
const lockfilePath = index.paths.resolveTargetRoot("yarn.lock");
|
|
76
36
|
const lockfile = await Lockfile.Lockfile.load(lockfilePath);
|
|
77
37
|
const findTargetVersion = createVersionFinder();
|
|
78
|
-
const dependencyMap = await mapDependencies(index.paths.targetDir);
|
|
38
|
+
const dependencyMap = await packages.mapDependencies(index.paths.targetDir);
|
|
79
39
|
const versionBumps = new Map();
|
|
80
40
|
const unlocked = Array();
|
|
81
41
|
await workerThreads(16, dependencyMap.entries(), async ([name, pkgs]) => {
|
|
@@ -84,7 +44,7 @@ var bump = async () => {
|
|
|
84
44
|
try {
|
|
85
45
|
target = await findTargetVersion(name);
|
|
86
46
|
} catch (error) {
|
|
87
|
-
if (error.name === "NotFoundError") {
|
|
47
|
+
if (errors.isError(error) && error.name === "NotFoundError") {
|
|
88
48
|
console.log(`Package info not found, ignoring package ${name}`);
|
|
89
49
|
return;
|
|
90
50
|
}
|
|
@@ -114,7 +74,7 @@ var bump = async () => {
|
|
|
114
74
|
try {
|
|
115
75
|
target = await findTargetVersion(name);
|
|
116
76
|
} catch (error) {
|
|
117
|
-
if (error.name === "NotFoundError") {
|
|
77
|
+
if (errors.isError(error) && error.name === "NotFoundError") {
|
|
118
78
|
console.log(`Package info not found, ignoring package ${name}`);
|
|
119
79
|
return;
|
|
120
80
|
}
|
|
@@ -220,7 +180,7 @@ function createVersionFinder() {
|
|
|
220
180
|
return existing;
|
|
221
181
|
}
|
|
222
182
|
console.log(`Checking for updates of ${name}`);
|
|
223
|
-
const info = await fetchPackageInfo(name);
|
|
183
|
+
const info = await packages.fetchPackageInfo(name);
|
|
224
184
|
const latest = info["dist-tags"].latest;
|
|
225
185
|
if (!latest) {
|
|
226
186
|
throw new Error(`No latest version found for ${name}`);
|
|
@@ -243,4 +203,4 @@ async function workerThreads(count, items, fn) {
|
|
|
243
203
|
}
|
|
244
204
|
|
|
245
205
|
exports.default = bump;
|
|
246
|
-
//# sourceMappingURL=bump-
|
|
206
|
+
//# sourceMappingURL=bump-ab142f88.cjs.js.map
|