@backstage/cli 0.32.0-next.0 → 0.32.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/bin/backstage-cli-alpha +0 -0
- package/config/eslint-factory.js +20 -1
- package/dist/commands/index.cjs.js +9 -13
- package/dist/lib/errors.cjs.js +1 -1
- package/dist/lib/runner/runBackend.cjs.js +1 -0
- package/dist/modules/build/lib/bundler/server.cjs.js +9 -3
- package/dist/modules/build/lib/packager/productionPack.cjs.js +6 -6
- package/dist/modules/config/lib/config.cjs.js +4 -2
- package/dist/modules/start/commands/package/start/command.cjs.js +22 -0
- package/dist/modules/start/commands/package/start/resolveLinkedWorkspace.cjs.js +34 -0
- package/dist/{commands → modules/start/commands/package}/start/startBackend.cjs.js +6 -3
- package/dist/{commands → modules/start/commands/package}/start/startFrontend.cjs.js +9 -8
- package/dist/modules/start/commands/package/start/startPackage.cjs.js +42 -0
- package/dist/modules/start/commands/repo/start.cjs.js +150 -0
- package/dist/modules/start/index.cjs.js +38 -0
- package/dist/packages/backend-defaults/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 +1 -1
- 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/catalog-node/package.json.cjs.js +1 -1
- package/dist/plugins/scaffolder-node/package.json.cjs.js +1 -1
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +1 -1
- package/package.json +15 -14
- package/templates/backend-plugin/README.md.hbs +1 -1
- package/templates/backend-plugin/src/plugin.ts.hbs +2 -4
- package/templates/backend-plugin/src/services/TodoListService/createTodoListService.ts +3 -11
- package/templates/frontend-plugin/dev/index.tsx.hbs +0 -1
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -1
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -1
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -1
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -1
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx +17 -18
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx +28 -29
- package/dist/commands/start/command.cjs.js +0 -75
- /package/dist/{commands → modules/start/commands/package}/start/index.cjs.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# @backstage/cli
|
|
2
2
|
|
|
3
|
+
## 0.32.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a47fd39: Removes default React imports from template files, aligning with the requirements for the upcoming React 19 migration. Introduces a new ESLint rule to disallow `import React from 'react'` and `import * as React from 'react'`.
|
|
8
|
+
|
|
9
|
+
<https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 6969f79: Avoid trailing `/*` when automatically adding imports for package with multiple entry points.
|
|
14
|
+
- 98b7131: Update the `to do` plugin template to stop using the deprecated catalog alpha service reference.
|
|
15
|
+
If you start seeing the `should create TODO item with catalog information` test failing, you have two options to fix this:
|
|
16
|
+
Update the test to mock the legacy alpha catalog service, or migrate the `TODO` plugin backend to use the new catalog service reference.
|
|
17
|
+
We recommend the second option, see [this](https://github.com/backstage/backstage/pull/29450/files/267115d0436009443ca68ac84e7dcc646c9c938d#diff-47e01aeb12dd55fab9e697f810be21a8d08d39c37df1b078f6d0894f9bad5a1b) pull request for an example of how to do the migration.
|
|
18
|
+
- d5c4fed: make certificate strings optional for Dev environments
|
|
19
|
+
- d2091c6: Added a new `repo start` command to replace the existing pattern of using `yarn dev` scripts. The `repo start` command runs the app and/or backend package in the repo by default, but will also fall back to running other individual frontend or backend packages or even plugin dev entry points if the can be uniquely selected.
|
|
20
|
+
|
|
21
|
+
The goal of this change is to reduce the number of different necessary scripts and align on `yarn start` being the only command needed for local development, similar to how `repo test` handles testing in the repo. It also opens up for more powerful options, like the `--plugin <pluginId>` flag that runs the dev entry point of the selected plugin.
|
|
22
|
+
|
|
23
|
+
The new script is installed as follows, replacing the existing `yarn start` script:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"scripts": {
|
|
28
|
+
"start": "backstage-cli repo start"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
In order to help users migrate in existing projects, it is recommended to add the following scripts to the root `package.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "echo \"Use 'yarn start' instead\"",
|
|
39
|
+
"start-backend": "echo \"Use 'yarn start backend' instead\""
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For more information, run `yarn start --help` once the new command is installed.
|
|
45
|
+
|
|
46
|
+
- Updated dependencies
|
|
47
|
+
- @backstage/catalog-model@1.7.3
|
|
48
|
+
- @backstage/cli-common@0.1.15
|
|
49
|
+
- @backstage/cli-node@0.2.13
|
|
50
|
+
- @backstage/config@1.3.2
|
|
51
|
+
- @backstage/config-loader@1.10.0
|
|
52
|
+
- @backstage/errors@1.2.7
|
|
53
|
+
- @backstage/eslint-plugin@0.1.10
|
|
54
|
+
- @backstage/integration@1.16.3-next.0
|
|
55
|
+
- @backstage/release-manifests@0.0.12
|
|
56
|
+
- @backstage/types@1.2.1
|
|
57
|
+
|
|
58
|
+
## 0.32.0-next.1
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Updated dependencies
|
|
63
|
+
- @backstage/integration@1.16.3-next.0
|
|
64
|
+
- @backstage/catalog-model@1.7.3
|
|
65
|
+
- @backstage/cli-common@0.1.15
|
|
66
|
+
- @backstage/cli-node@0.2.13
|
|
67
|
+
- @backstage/config@1.3.2
|
|
68
|
+
- @backstage/config-loader@1.10.0
|
|
69
|
+
- @backstage/errors@1.2.7
|
|
70
|
+
- @backstage/eslint-plugin@0.1.10
|
|
71
|
+
- @backstage/release-manifests@0.0.12
|
|
72
|
+
- @backstage/types@1.2.1
|
|
73
|
+
|
|
3
74
|
## 0.32.0-next.0
|
|
4
75
|
|
|
5
76
|
### Minor Changes
|
package/bin/backstage-cli-alpha
CHANGED
|
File without changes
|
package/config/eslint-factory.js
CHANGED
|
@@ -243,8 +243,27 @@ function createConfigForRole(dir, role, extraConfig = {}) {
|
|
|
243
243
|
'@mui/*/*/*',
|
|
244
244
|
...(extraConfig.restrictedImportPatterns ?? []),
|
|
245
245
|
],
|
|
246
|
+
rules: {
|
|
247
|
+
'react/react-in-jsx-scope': 'off',
|
|
248
|
+
'no-restricted-syntax': [
|
|
249
|
+
'warn',
|
|
250
|
+
{
|
|
251
|
+
message:
|
|
252
|
+
'React default imports are deprecated. Follow the x migration guide for details.',
|
|
253
|
+
selector:
|
|
254
|
+
"ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
message:
|
|
258
|
+
'React default imports are deprecated. Follow the x migration guide for details. If you need a global type that collides with a React named export (such as `MouseEvent`), try using `globalThis.MouseHandler`.',
|
|
259
|
+
selector:
|
|
260
|
+
"ImportDeclaration[source.value='react'] :matches(ImportDefaultSpecifier, ImportNamespaceSpecifier)",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
...extraConfig.rules,
|
|
264
|
+
},
|
|
246
265
|
tsRules: {
|
|
247
|
-
'react/prop-types':
|
|
266
|
+
'react/prop-types': 'off',
|
|
248
267
|
...extraConfig.tsRules,
|
|
249
268
|
},
|
|
250
269
|
});
|
|
@@ -3,32 +3,28 @@
|
|
|
3
3
|
var lazy = require('../lib/lazy.cjs.js');
|
|
4
4
|
var index = require('../modules/config/index.cjs.js');
|
|
5
5
|
var index$2 = require('../modules/build/index.cjs.js');
|
|
6
|
+
var index$4 = require('../modules/start/index.cjs.js');
|
|
6
7
|
var index$3 = require('../modules/info/index.cjs.js');
|
|
7
8
|
var index$1 = require('../modules/migrate/index.cjs.js');
|
|
8
|
-
var index$
|
|
9
|
-
var index$
|
|
10
|
-
var index$
|
|
9
|
+
var index$5 = require('../modules/test/index.cjs.js');
|
|
10
|
+
var index$6 = require('../modules/lint/index.cjs.js');
|
|
11
|
+
var index$7 = require('../modules/maintenance/index.cjs.js');
|
|
11
12
|
|
|
12
13
|
function registerRepoCommand(program) {
|
|
13
14
|
const command = program.command("repo [command]").description("Command that run across an entire Backstage project");
|
|
14
|
-
index$2.registerRepoCommands(command);
|
|
15
15
|
index$4.registerRepoCommands(command);
|
|
16
|
+
index$2.registerRepoCommands(command);
|
|
16
17
|
index$5.registerRepoCommands(command);
|
|
17
18
|
index$6.registerRepoCommands(command);
|
|
19
|
+
index$7.registerRepoCommands(command);
|
|
18
20
|
}
|
|
19
21
|
function registerScriptCommand(program) {
|
|
20
22
|
const command = program.command("package [command]").description("Lifecycle scripts for individual packages");
|
|
21
|
-
command.command("start").description("Start a package for local development").option(...index.configOption).option("--role <name>", "Run the command with an explicit package role").option("--check", "Enable type checking and linting if available").option("--inspect [host]", "Enable debugger in Node.js environments").option(
|
|
22
|
-
"--inspect-brk [host]",
|
|
23
|
-
"Enable debugger in Node.js environments, breaking before code starts"
|
|
24
|
-
).option(
|
|
25
|
-
"--require <path...>",
|
|
26
|
-
"Add a --require argument to the node process"
|
|
27
|
-
).option("--link <path>", "Link an external workspace for module resolution").action(lazy.lazy(() => import('./start/index.cjs.js'), "command"));
|
|
28
|
-
index$2.registerPackageCommands(command);
|
|
29
23
|
index$4.registerPackageCommands(command);
|
|
30
|
-
index$
|
|
24
|
+
index$2.registerPackageCommands(command);
|
|
31
25
|
index$5.registerPackageCommands(command);
|
|
26
|
+
index$7.registerPackageCommands(command);
|
|
27
|
+
index$6.registerPackageCommands(command);
|
|
32
28
|
}
|
|
33
29
|
function registerCommands(program) {
|
|
34
30
|
program.command("new").storeOptionsAsProperties(false).description(
|
package/dist/lib/errors.cjs.js
CHANGED
|
@@ -78,6 +78,7 @@ async function runBackend(options) {
|
|
|
78
78
|
[...loaderArgs, ...optionArgs, options.entry, ...userArgs],
|
|
79
79
|
{
|
|
80
80
|
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
81
|
+
cwd: options.targetDir,
|
|
81
82
|
env: {
|
|
82
83
|
...process.env,
|
|
83
84
|
BACKSTAGE_CLI_LINKED_WORKSPACE: options.linkedWorkspace,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var fs = require('fs-extra');
|
|
5
|
+
var path = require('path');
|
|
5
6
|
var openBrowser = require('react-dev-utils/openBrowser');
|
|
6
7
|
var webpack = require('webpack');
|
|
7
8
|
var WebpackDevServer = require('webpack-dev-server');
|
|
@@ -34,7 +35,9 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
checkReactVersion();
|
|
37
|
-
const { name } = await fs__default.default.readJson(
|
|
38
|
+
const { name } = await fs__default.default.readJson(
|
|
39
|
+
path.resolve(options.targetDir ?? paths$1.paths.targetDir, "package.json")
|
|
40
|
+
);
|
|
38
41
|
let webpackServer = void 0;
|
|
39
42
|
let latestFrontendAppConfigs = [];
|
|
40
43
|
const triggerReload = () => {
|
|
@@ -50,6 +53,7 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
50
53
|
};
|
|
51
54
|
const cliConfig = await config.loadCliConfig({
|
|
52
55
|
args: options.configPaths,
|
|
56
|
+
targetDir: options.targetDir,
|
|
53
57
|
fromPackage: name,
|
|
54
58
|
withFilteredKeys: true,
|
|
55
59
|
watch(appConfigs) {
|
|
@@ -145,8 +149,10 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
145
149
|
server: url.protocol === "https:" ? {
|
|
146
150
|
type: "https",
|
|
147
151
|
options: {
|
|
148
|
-
cert: fullConfig.
|
|
149
|
-
|
|
152
|
+
cert: fullConfig.getOptionalString(
|
|
153
|
+
"app.https.certificate.cert"
|
|
154
|
+
),
|
|
155
|
+
key: fullConfig.getOptionalString("app.https.certificate.key")
|
|
150
156
|
}
|
|
151
157
|
} : {},
|
|
152
158
|
host,
|
|
@@ -106,8 +106,11 @@ async function rewriteEntryPoints(pkg, packageDir, featureDetectionProject) {
|
|
|
106
106
|
if (!pkg.typesVersions) {
|
|
107
107
|
pkg.typesVersions = { "*": {} };
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
if (entryPoint.name !== "index") {
|
|
110
|
+
pkg.typesVersions["*"][entryPoint.name] = [
|
|
111
|
+
`dist/${entryPoint.name}.d.ts`
|
|
112
|
+
];
|
|
113
|
+
}
|
|
111
114
|
}
|
|
112
115
|
exp.default = exp.require ?? exp.import;
|
|
113
116
|
if (exp.types && featureDetectionProject) {
|
|
@@ -140,10 +143,7 @@ async function rewriteEntryPoints(pkg, packageDir, featureDetectionProject) {
|
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
if (pkg.typesVersions?.["*"]) {
|
|
143
|
-
|
|
144
|
-
if (keys.length === 1 && keys[0] === "*") {
|
|
145
|
-
delete pkg.typesVersions;
|
|
146
|
-
}
|
|
146
|
+
pkg.typesVersions["*"]["package.json"] = ["package.json"];
|
|
147
147
|
}
|
|
148
148
|
if (pkg.exports) {
|
|
149
149
|
pkg.exports = outputExports;
|
|
@@ -5,9 +5,11 @@ var config = require('@backstage/config');
|
|
|
5
5
|
var paths = require('../../../lib/paths.cjs.js');
|
|
6
6
|
var getPackages = require('@manypkg/get-packages');
|
|
7
7
|
var cliNode = require('@backstage/cli-node');
|
|
8
|
+
var path = require('path');
|
|
8
9
|
|
|
9
10
|
async function loadCliConfig(options) {
|
|
10
|
-
const
|
|
11
|
+
const targetDir = options.targetDir ?? paths.paths.targetDir;
|
|
12
|
+
const { packages } = await getPackages.getPackages(targetDir);
|
|
11
13
|
let localPackageNames;
|
|
12
14
|
if (options.fromPackage) {
|
|
13
15
|
if (packages.length) {
|
|
@@ -37,7 +39,7 @@ async function loadCliConfig(options) {
|
|
|
37
39
|
substitutionFunc: options.mockEnv ? async (name) => process.env[name] || "x" : void 0,
|
|
38
40
|
watch: Boolean(options.watch),
|
|
39
41
|
rootDir: paths.paths.targetRoot,
|
|
40
|
-
argv: options.args.flatMap((t) => ["--config",
|
|
42
|
+
argv: options.args.flatMap((t) => ["--config", path.resolve(targetDir, t)])
|
|
41
43
|
});
|
|
42
44
|
const appConfigs = await new Promise((resolve, reject) => {
|
|
43
45
|
async function loadConfigReaderLoop() {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var startPackage = require('./startPackage.cjs.js');
|
|
4
|
+
var resolveLinkedWorkspace = require('./resolveLinkedWorkspace.cjs.js');
|
|
5
|
+
var role = require('../../../../../lib/role.cjs.js');
|
|
6
|
+
var paths = require('../../../../../lib/paths.cjs.js');
|
|
7
|
+
|
|
8
|
+
async function command(opts) {
|
|
9
|
+
await startPackage.startPackage({
|
|
10
|
+
role: await role.findRoleFromCommand(opts),
|
|
11
|
+
targetDir: paths.paths.targetDir,
|
|
12
|
+
configPaths: opts.config,
|
|
13
|
+
checksEnabled: Boolean(opts.check),
|
|
14
|
+
linkedWorkspace: await resolveLinkedWorkspace.resolveLinkedWorkspace(opts.link),
|
|
15
|
+
inspectEnabled: opts.inspect,
|
|
16
|
+
inspectBrkEnabled: opts.inspectBrk,
|
|
17
|
+
require: opts.require
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.command = command;
|
|
22
|
+
//# sourceMappingURL=command.cjs.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var errors = require('@backstage/errors');
|
|
4
|
+
var fs = require('fs-extra');
|
|
5
|
+
var posix = require('path/posix');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
10
|
+
|
|
11
|
+
async function resolveLinkedWorkspace(linkPath) {
|
|
12
|
+
if (!linkPath) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
const dir = posix.resolve(linkPath);
|
|
16
|
+
if (!fs__default.default.pathExistsSync(dir)) {
|
|
17
|
+
throw new Error(`Invalid workspace link, directory does not exist: ${dir}`);
|
|
18
|
+
}
|
|
19
|
+
const pkgJson = await fs__default.default.readJson(posix.resolve(dir, "package.json")).catch((error) => {
|
|
20
|
+
throw new errors.ForwardedError(
|
|
21
|
+
"Failed to read package.json in linked workspace",
|
|
22
|
+
error
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
if (!pkgJson.workspaces) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Invalid workspace link, directory is not a workspace: ${dir}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return dir;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.resolveLinkedWorkspace = resolveLinkedWorkspace;
|
|
34
|
+
//# sourceMappingURL=resolveLinkedWorkspace.cjs.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('fs-extra');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var paths = require('../../../../../lib/paths.cjs.js');
|
|
6
|
+
var runBackend = require('../../../../../lib/runner/runBackend.cjs.js');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -10,6 +11,7 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
|
10
11
|
|
|
11
12
|
async function startBackend(options) {
|
|
12
13
|
const waitForExit = await runBackend.runBackend({
|
|
14
|
+
targetDir: options.targetDir,
|
|
13
15
|
entry: "src/index",
|
|
14
16
|
inspectEnabled: options.inspectEnabled,
|
|
15
17
|
inspectBrkEnabled: options.inspectBrkEnabled,
|
|
@@ -20,7 +22,7 @@ async function startBackend(options) {
|
|
|
20
22
|
}
|
|
21
23
|
async function startBackendPlugin(options) {
|
|
22
24
|
const hasDevIndexEntry = await fs__default.default.pathExists(
|
|
23
|
-
paths.paths.
|
|
25
|
+
path.resolve(options.targetDir ?? paths.paths.targetDir, "dev/index.ts")
|
|
24
26
|
);
|
|
25
27
|
if (!hasDevIndexEntry) {
|
|
26
28
|
console.warn(
|
|
@@ -29,6 +31,7 @@ async function startBackendPlugin(options) {
|
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
33
|
const waitForExit = await runBackend.runBackend({
|
|
34
|
+
targetDir: options.targetDir,
|
|
32
35
|
entry: "dev/index",
|
|
33
36
|
inspectEnabled: options.inspectEnabled,
|
|
34
37
|
inspectBrkEnabled: options.inspectBrkEnabled,
|
|
@@ -13,23 +13,24 @@ require('html-webpack-plugin');
|
|
|
13
13
|
require('@module-federation/enhanced/webpack');
|
|
14
14
|
require('react-dev-utils/ModuleScopePlugin');
|
|
15
15
|
require('@pmmmwh/react-refresh-webpack-plugin');
|
|
16
|
-
var paths = require('
|
|
17
|
-
require('
|
|
16
|
+
var paths = require('../../../../../lib/paths.cjs.js');
|
|
17
|
+
require('../../../../build/lib/bundler/optimization.cjs.js');
|
|
18
18
|
require('lodash/pickBy');
|
|
19
|
-
require('
|
|
19
|
+
require('../../../../../lib/run.cjs.js');
|
|
20
20
|
require('mini-css-extract-plugin');
|
|
21
|
-
require('
|
|
21
|
+
require('../../../../../lib/version.cjs.js');
|
|
22
22
|
require('@manypkg/get-packages');
|
|
23
|
-
require('
|
|
24
|
-
var moduleFederation = require('
|
|
25
|
-
var server = require('
|
|
23
|
+
require('../../../../build/lib/bundler/packageDetection.cjs.js');
|
|
24
|
+
var moduleFederation = require('../../../../build/lib/bundler/moduleFederation.cjs.js');
|
|
25
|
+
var server = require('../../../../build/lib/bundler/server.cjs.js');
|
|
26
26
|
|
|
27
27
|
async function startFrontend(options) {
|
|
28
28
|
const packageJson = await fs.readJson(
|
|
29
|
-
paths.paths.
|
|
29
|
+
path.resolve(options.targetDir ?? paths.paths.targetDir, "package.json")
|
|
30
30
|
);
|
|
31
31
|
const waitForExit = await server.serveBundle({
|
|
32
32
|
entry: options.entry,
|
|
33
|
+
targetDir: options.targetDir,
|
|
33
34
|
checksEnabled: options.checksEnabled,
|
|
34
35
|
configPaths: options.configPaths,
|
|
35
36
|
verifyVersions: options.verifyVersions,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var startBackend = require('./startBackend.cjs.js');
|
|
4
|
+
var startFrontend = require('./startFrontend.cjs.js');
|
|
5
|
+
|
|
6
|
+
async function startPackage(options) {
|
|
7
|
+
switch (options.role) {
|
|
8
|
+
case "backend":
|
|
9
|
+
return startBackend.startBackend(options);
|
|
10
|
+
case "backend-plugin":
|
|
11
|
+
case "backend-plugin-module":
|
|
12
|
+
case "node-library":
|
|
13
|
+
return startBackend.startBackendPlugin(options);
|
|
14
|
+
case "frontend":
|
|
15
|
+
return startFrontend.startFrontend({
|
|
16
|
+
...options,
|
|
17
|
+
entry: "src/index",
|
|
18
|
+
verifyVersions: true
|
|
19
|
+
});
|
|
20
|
+
case "web-library":
|
|
21
|
+
case "frontend-plugin":
|
|
22
|
+
case "frontend-plugin-module":
|
|
23
|
+
return startFrontend.startFrontend({
|
|
24
|
+
entry: "dev/index",
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
case "frontend-dynamic-container":
|
|
28
|
+
return startFrontend.startFrontend({
|
|
29
|
+
entry: "src/index",
|
|
30
|
+
...options,
|
|
31
|
+
skipOpenBrowser: true,
|
|
32
|
+
isModuleFederationRemote: true
|
|
33
|
+
});
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Start command is not supported for package role '${options.role}'`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.startPackage = startPackage;
|
|
42
|
+
//# sourceMappingURL=startPackage.cjs.js.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cliNode = require('@backstage/cli-node');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var paths = require('../../../../lib/paths.cjs.js');
|
|
6
|
+
var resolveLinkedWorkspace = require('../package/start/resolveLinkedWorkspace.cjs.js');
|
|
7
|
+
var startPackage = require('../package/start/startPackage.cjs.js');
|
|
8
|
+
var util = require('util');
|
|
9
|
+
|
|
10
|
+
const ACCEPTED_PACKAGE_ROLES = [
|
|
11
|
+
"frontend",
|
|
12
|
+
"backend",
|
|
13
|
+
"frontend-plugin",
|
|
14
|
+
"backend-plugin"
|
|
15
|
+
];
|
|
16
|
+
async function command(namesOrPaths, options) {
|
|
17
|
+
const targetPackages = await findTargetPackages(namesOrPaths, options.plugin);
|
|
18
|
+
const packageOptions = await resolvePackageOptions(targetPackages, options);
|
|
19
|
+
if (packageOptions.length === 0) {
|
|
20
|
+
console.log("No packages found to start");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(
|
|
24
|
+
`Starting ${packageOptions.map(({ pkg }) => pkg.packageJson.name).join(", ")}`
|
|
25
|
+
);
|
|
26
|
+
await Promise.all(packageOptions.map((entry) => startPackage.startPackage(entry.options)));
|
|
27
|
+
}
|
|
28
|
+
async function findTargetPackages(namesOrPaths, pluginIds) {
|
|
29
|
+
const targetPackages = new Array();
|
|
30
|
+
const packages = await cliNode.PackageGraph.listTargetPackages();
|
|
31
|
+
for (const pluginId of pluginIds) {
|
|
32
|
+
const matchingPackages = packages.filter((pkg) => {
|
|
33
|
+
return pluginId === pkg.packageJson.backstage?.pluginId && ACCEPTED_PACKAGE_ROLES.includes(pkg.packageJson.backstage.role);
|
|
34
|
+
});
|
|
35
|
+
if (matchingPackages.length === 0) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Unable to find any plugin packages with plugin ID '${pluginId}'. Make sure backstage.pluginId is set in your package.json files by running 'yarn fix --publish'.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
targetPackages.push(...matchingPackages);
|
|
41
|
+
}
|
|
42
|
+
if (targetPackages.length > 0) {
|
|
43
|
+
return targetPackages;
|
|
44
|
+
}
|
|
45
|
+
for (const nameOrPath of namesOrPaths) {
|
|
46
|
+
let matchingPackage = packages.find(
|
|
47
|
+
(pkg) => nameOrPath === pkg.packageJson.name
|
|
48
|
+
);
|
|
49
|
+
if (!matchingPackage) {
|
|
50
|
+
const absPath = paths.paths.resolveTargetRoot(nameOrPath);
|
|
51
|
+
matchingPackage = packages.find(
|
|
52
|
+
(pkg) => path.relative(pkg.dir, absPath) === ""
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (!matchingPackage) {
|
|
56
|
+
throw new Error(`Unable to find package by name '${nameOrPath}'`);
|
|
57
|
+
}
|
|
58
|
+
targetPackages.push(matchingPackage);
|
|
59
|
+
}
|
|
60
|
+
if (targetPackages.length > 0) {
|
|
61
|
+
return targetPackages;
|
|
62
|
+
}
|
|
63
|
+
for (const role of ["frontend", "backend"]) {
|
|
64
|
+
const matchingPackages = packages.filter(
|
|
65
|
+
(pkg) => pkg.packageJson.backstage?.role === role
|
|
66
|
+
);
|
|
67
|
+
if (matchingPackages.length > 1) {
|
|
68
|
+
const expectedPath = paths.paths.resolveTargetRoot(
|
|
69
|
+
role === "frontend" ? "packages/app" : "packages/backend"
|
|
70
|
+
);
|
|
71
|
+
const matchByPath = matchingPackages.find(
|
|
72
|
+
(pkg) => path.relative(expectedPath, pkg.dir) === ""
|
|
73
|
+
);
|
|
74
|
+
if (matchByPath) {
|
|
75
|
+
targetPackages.push(matchByPath);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Found multiple packages with role '${role}' but none of the use the default path '${expectedPath}',choose which packages you want to run by passing the package names explicitly as arguments, for example 'yarn backstage-cli repo start my-app my-backend'.`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
targetPackages.push(...matchingPackages);
|
|
83
|
+
}
|
|
84
|
+
if (targetPackages.length > 0) {
|
|
85
|
+
return targetPackages;
|
|
86
|
+
}
|
|
87
|
+
for (const role of ["frontend-plugin", "backend-plugin"]) {
|
|
88
|
+
const matchingPackages = packages.filter(
|
|
89
|
+
(pkg) => pkg.packageJson.backstage?.role === role
|
|
90
|
+
);
|
|
91
|
+
if (matchingPackages.length > 1) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Found multiple packages with role '${role}', please choose which packages you want to run by passing the package names explicitly as arguments, for example 'yarn backstage-cli repo start my-plugin my-plugin-backend'.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
targetPackages.push(...matchingPackages);
|
|
97
|
+
}
|
|
98
|
+
if (targetPackages.length > 0) {
|
|
99
|
+
return targetPackages;
|
|
100
|
+
}
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Unable to find any packages with role 'frontend', 'backend', 'frontend-plugin', or 'backend-plugin'.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
async function resolvePackageOptions(targetPackages, options) {
|
|
106
|
+
const linkedWorkspace = await resolveLinkedWorkspace.resolveLinkedWorkspace(options.link);
|
|
107
|
+
return targetPackages.flatMap((pkg) => {
|
|
108
|
+
const startScript = pkg.packageJson.scripts?.start;
|
|
109
|
+
if (!startScript) {
|
|
110
|
+
console.log(
|
|
111
|
+
`No start script found for package ${pkg.packageJson.name}, skipping...`
|
|
112
|
+
);
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const { values: parsedOpts } = util.parseArgs({
|
|
116
|
+
args: startScript.split(" "),
|
|
117
|
+
strict: false,
|
|
118
|
+
options: {
|
|
119
|
+
config: {
|
|
120
|
+
type: "string",
|
|
121
|
+
multiple: true
|
|
122
|
+
},
|
|
123
|
+
require: {
|
|
124
|
+
type: "string"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const parsedRequire = typeof parsedOpts.require === "string" ? parsedOpts.require : void 0;
|
|
129
|
+
const parsedConfig = parsedOpts.config?.filter((c) => typeof c === "string") ?? [];
|
|
130
|
+
return [
|
|
131
|
+
{
|
|
132
|
+
pkg,
|
|
133
|
+
options: {
|
|
134
|
+
role: pkg.packageJson.backstage?.role,
|
|
135
|
+
targetDir: pkg.dir,
|
|
136
|
+
configPaths: options.config.length > 0 ? options.config : parsedConfig,
|
|
137
|
+
checksEnabled: false,
|
|
138
|
+
linkedWorkspace,
|
|
139
|
+
inspectEnabled: options.inspect,
|
|
140
|
+
inspectBrkEnabled: options.inspectBrk,
|
|
141
|
+
require: options.require ?? parsedRequire
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
exports.command = command;
|
|
149
|
+
exports.findTargetPackages = findTargetPackages;
|
|
150
|
+
//# sourceMappingURL=start.cjs.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lazy = require('../../lib/lazy.cjs.js');
|
|
4
|
+
var index = require('../config/index.cjs.js');
|
|
5
|
+
|
|
6
|
+
function registerRepoCommands(command) {
|
|
7
|
+
command.command("start").description("Starts packages in the repo for local development").argument(
|
|
8
|
+
"[packageNameOrPath...]",
|
|
9
|
+
"Run the specified package instead of the defaults."
|
|
10
|
+
).option(
|
|
11
|
+
"--plugin <pluginId>",
|
|
12
|
+
"Start the dev entry-point for any matching plugin package in the repo",
|
|
13
|
+
(opt, opts) => opts ? [...opts, opt] : [opt],
|
|
14
|
+
Array()
|
|
15
|
+
).option(...index.configOption).option(
|
|
16
|
+
"--inspect [host]",
|
|
17
|
+
"Enable debugger in Node.js environments. Applies to backend package only"
|
|
18
|
+
).option(
|
|
19
|
+
"--inspect-brk [host]",
|
|
20
|
+
"Enable debugger in Node.js environments, breaking before code starts. Applies to backend package only"
|
|
21
|
+
).option(
|
|
22
|
+
"--require <path...>",
|
|
23
|
+
"Add a --require argument to the node process. Applies to backend package only"
|
|
24
|
+
).option("--link <path>", "Link an external workspace for module resolution").action(lazy.lazy(() => import('./commands/repo/start.cjs.js'), "command"));
|
|
25
|
+
}
|
|
26
|
+
function registerPackageCommands(command) {
|
|
27
|
+
command.command("start").description("Start a package for local development").option(...index.configOption).option("--role <name>", "Run the command with an explicit package role").option("--check", "Enable type checking and linting if available").option("--inspect [host]", "Enable debugger in Node.js environments").option(
|
|
28
|
+
"--inspect-brk [host]",
|
|
29
|
+
"Enable debugger in Node.js environments, breaking before code starts"
|
|
30
|
+
).option(
|
|
31
|
+
"--require <path...>",
|
|
32
|
+
"Add a --require argument to the node process"
|
|
33
|
+
).option("--link <path>", "Link an external workspace for module resolution").action(lazy.lazy(() => import('./commands/package/start/index.cjs.js'), "command"));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.registerPackageCommands = registerPackageCommands;
|
|
37
|
+
exports.registerRepoCommands = registerRepoCommands;
|
|
38
|
+
//# sourceMappingURL=index.cjs.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/cli",
|
|
3
|
-
"version": "0.32.0-next.
|
|
3
|
+
"version": "0.32.0-next.2",
|
|
4
4
|
"description": "CLI for developing Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "cli"
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"main": "dist/index.cjs.js",
|
|
22
22
|
"bin": {
|
|
23
|
-
"backstage-cli": "bin/backstage-cli"
|
|
23
|
+
"backstage-cli": "bin/backstage-cli",
|
|
24
|
+
"backstage-cli-alpha": "bin/backstage-cli-alpha"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"asset-types",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"@backstage/config-loader": "1.10.0",
|
|
55
56
|
"@backstage/errors": "1.2.7",
|
|
56
57
|
"@backstage/eslint-plugin": "0.1.10",
|
|
57
|
-
"@backstage/integration": "1.16.
|
|
58
|
+
"@backstage/integration": "1.16.3-next.0",
|
|
58
59
|
"@backstage/release-manifests": "0.0.12",
|
|
59
60
|
"@backstage/types": "1.2.1",
|
|
60
61
|
"@manypkg/get-packages": "^1.1.3",
|
|
@@ -164,21 +165,21 @@
|
|
|
164
165
|
},
|
|
165
166
|
"devDependencies": {
|
|
166
167
|
"@backstage/backend-plugin-api": "1.2.1",
|
|
167
|
-
"@backstage/backend-test-utils": "1.3.2-next.
|
|
168
|
+
"@backstage/backend-test-utils": "1.3.2-next.2",
|
|
168
169
|
"@backstage/catalog-client": "1.9.1",
|
|
169
170
|
"@backstage/config": "1.3.2",
|
|
170
|
-
"@backstage/core-app-api": "1.16.0",
|
|
171
|
-
"@backstage/core-components": "0.17.
|
|
172
|
-
"@backstage/core-plugin-api": "1.10.
|
|
173
|
-
"@backstage/dev-utils": "1.1.9-next.
|
|
171
|
+
"@backstage/core-app-api": "1.16.1-next.0",
|
|
172
|
+
"@backstage/core-components": "0.17.1-next.1",
|
|
173
|
+
"@backstage/core-plugin-api": "1.10.6-next.0",
|
|
174
|
+
"@backstage/dev-utils": "1.1.9-next.2",
|
|
174
175
|
"@backstage/errors": "1.2.7",
|
|
175
|
-
"@backstage/plugin-auth-backend": "0.24.5-next.
|
|
176
|
+
"@backstage/plugin-auth-backend": "0.24.5-next.2",
|
|
176
177
|
"@backstage/plugin-auth-backend-module-guest-provider": "0.2.6",
|
|
177
|
-
"@backstage/plugin-catalog-node": "1.16.
|
|
178
|
-
"@backstage/plugin-scaffolder-node": "0.8.1-next.
|
|
179
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.2.1-next.
|
|
180
|
-
"@backstage/test-utils": "1.7.
|
|
181
|
-
"@backstage/theme": "0.6.
|
|
178
|
+
"@backstage/plugin-catalog-node": "1.16.3-next.0",
|
|
179
|
+
"@backstage/plugin-scaffolder-node": "0.8.1-next.1",
|
|
180
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.2.1-next.2",
|
|
181
|
+
"@backstage/test-utils": "1.7.7-next.0",
|
|
182
|
+
"@backstage/theme": "0.6.5-next.0",
|
|
182
183
|
"@rspack/core": "^1.0.10",
|
|
183
184
|
"@rspack/dev-server": "^1.0.9",
|
|
184
185
|
"@rspack/plugin-react-refresh": "^1.0.0",
|
|
@@ -25,4 +25,4 @@ This plugin backend can be started in a standalone mode from directly in this
|
|
|
25
25
|
package with `yarn start`. It is a limited setup that is most convenient when
|
|
26
26
|
developing the plugin backend itself.
|
|
27
27
|
|
|
28
|
-
If you want to run the entire project, including the frontend, run `yarn
|
|
28
|
+
If you want to run the entire project, including the frontend, run `yarn start` from the root directory.
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createBackendPlugin,
|
|
4
4
|
} from '@backstage/backend-plugin-api';
|
|
5
5
|
import { createRouter } from './router';
|
|
6
|
-
import { catalogServiceRef } from '@backstage/plugin-catalog-node
|
|
6
|
+
import { catalogServiceRef } from '@backstage/plugin-catalog-node';
|
|
7
7
|
import { createTodoListService } from './services/TodoListService';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -17,15 +17,13 @@ export const {{pluginVar}} = createBackendPlugin({
|
|
|
17
17
|
env.registerInit({
|
|
18
18
|
deps: {
|
|
19
19
|
logger: coreServices.logger,
|
|
20
|
-
auth: coreServices.auth,
|
|
21
20
|
httpAuth: coreServices.httpAuth,
|
|
22
21
|
httpRouter: coreServices.httpRouter,
|
|
23
22
|
catalog: catalogServiceRef,
|
|
24
23
|
},
|
|
25
|
-
async init({ logger,
|
|
24
|
+
async init({ logger, httpAuth, httpRouter, catalog }) {
|
|
26
25
|
const todoListService = await createTodoListService({
|
|
27
26
|
logger,
|
|
28
|
-
auth,
|
|
29
27
|
catalog,
|
|
30
28
|
});
|
|
31
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LoggerService } from '@backstage/backend-plugin-api';
|
|
2
2
|
import { NotFoundError } from '@backstage/errors';
|
|
3
|
-
import { catalogServiceRef } from '@backstage/plugin-catalog-node
|
|
3
|
+
import { catalogServiceRef } from '@backstage/plugin-catalog-node';
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
5
|
import { TodoItem, TodoListService } from './types';
|
|
6
6
|
|
|
@@ -10,11 +10,9 @@ import { TodoItem, TodoListService } from './types';
|
|
|
10
10
|
// documentation for more information on how to do this:
|
|
11
11
|
// https://backstage.io/docs/backend-system/core-services/database
|
|
12
12
|
export async function createTodoListService({
|
|
13
|
-
auth,
|
|
14
13
|
logger,
|
|
15
14
|
catalog,
|
|
16
15
|
}: {
|
|
17
|
-
auth: AuthService;
|
|
18
16
|
logger: LoggerService;
|
|
19
17
|
catalog: typeof catalogServiceRef.T;
|
|
20
18
|
}): Promise<TodoListService> {
|
|
@@ -40,13 +38,7 @@ export async function createTodoListService({
|
|
|
40
38
|
// If you want to make a request using the plugin backend's own identity,
|
|
41
39
|
// you can access it via the `auth.getOwnServiceCredentials()` method.
|
|
42
40
|
// Beware that this bypasses any user permission checks.
|
|
43
|
-
const
|
|
44
|
-
onBehalfOf: options.credentials,
|
|
45
|
-
targetPluginId: 'catalog',
|
|
46
|
-
});
|
|
47
|
-
const entity = await catalog.getEntityByRef(input.entityRef, {
|
|
48
|
-
token,
|
|
49
|
-
});
|
|
41
|
+
const entity = await catalog.getEntityByRef(input.entityRef, options);
|
|
50
42
|
if (!entity) {
|
|
51
43
|
throw new NotFoundError(
|
|
52
44
|
`No entity found for ref '${input.entityRef}'`,
|
package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
2
|
+
import { renderInTestApp } from '@backstage/test-utils';
|
|
3
|
+
import { ExampleComponent } from './ExampleComponent';
|
|
4
|
+
|
|
5
|
+
describe('ExampleComponent', () => {
|
|
6
|
+
it('should render', async () => {
|
|
7
|
+
await renderInTestApp(<ExampleComponent />);
|
|
8
|
+
|
|
9
|
+
expect(screen.getByText('Hello World')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should display a custom message', async () => {
|
|
13
|
+
await renderInTestApp(<ExampleComponent message="Hello Example" />);
|
|
14
|
+
|
|
15
|
+
expect(screen.getByText('Hello Example')).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
1
|
+
import { Typography } from '@material-ui/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for {@link ExampleComponent}.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface ExampleComponentProps {
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Displays an example.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
*
|
|
17
|
+
* Longer descriptions should be put after the `@remarks` tag. That way the initial summary
|
|
18
|
+
* will show up in the API docs overview section, while the longer description will only be
|
|
19
|
+
* displayed on the page for the specific API.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export function ExampleComponent(props: ExampleComponentProps) {
|
|
24
|
+
// By destructuring props here rather than in the signature the API docs will look nicer
|
|
25
|
+
const { message = 'Hello World' } = props;
|
|
26
|
+
|
|
27
|
+
return <Typography variant="h1">{message}</Typography>;
|
|
28
|
+
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var node_path = require('node:path');
|
|
5
|
-
var role = require('../../lib/role.cjs.js');
|
|
6
|
-
var startBackend = require('./startBackend.cjs.js');
|
|
7
|
-
var startFrontend = require('./startFrontend.cjs.js');
|
|
8
|
-
var errors = require('@backstage/errors');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
13
|
-
|
|
14
|
-
async function command(opts) {
|
|
15
|
-
const role$1 = await role.findRoleFromCommand(opts);
|
|
16
|
-
if (opts.link) {
|
|
17
|
-
const dir = node_path.resolve(opts.link);
|
|
18
|
-
if (!fs__default.default.pathExistsSync(dir)) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`Invalid workspace link, directory does not exist: ${dir}`
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
const pkgJson = await fs__default.default.readJson(node_path.resolve(dir, "package.json")).catch((error) => {
|
|
24
|
-
throw new errors.ForwardedError(
|
|
25
|
-
"Failed to read package.json in linked workspace",
|
|
26
|
-
error
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
if (!pkgJson.workspaces) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
`Invalid workspace link, directory is not a workspace: ${dir}`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const options = {
|
|
36
|
-
configPaths: opts.config,
|
|
37
|
-
checksEnabled: Boolean(opts.check),
|
|
38
|
-
linkedWorkspace: opts.link,
|
|
39
|
-
inspectEnabled: opts.inspect,
|
|
40
|
-
inspectBrkEnabled: opts.inspectBrk,
|
|
41
|
-
require: opts.require
|
|
42
|
-
};
|
|
43
|
-
switch (role$1) {
|
|
44
|
-
case "backend":
|
|
45
|
-
return startBackend.startBackend(options);
|
|
46
|
-
case "backend-plugin":
|
|
47
|
-
case "backend-plugin-module":
|
|
48
|
-
case "node-library":
|
|
49
|
-
return startBackend.startBackendPlugin(options);
|
|
50
|
-
case "frontend":
|
|
51
|
-
return startFrontend.startFrontend({
|
|
52
|
-
...options,
|
|
53
|
-
entry: "src/index",
|
|
54
|
-
verifyVersions: true
|
|
55
|
-
});
|
|
56
|
-
case "web-library":
|
|
57
|
-
case "frontend-plugin":
|
|
58
|
-
case "frontend-plugin-module":
|
|
59
|
-
return startFrontend.startFrontend({ entry: "dev/index", ...options });
|
|
60
|
-
case "frontend-dynamic-container":
|
|
61
|
-
return startFrontend.startFrontend({
|
|
62
|
-
entry: "src/index",
|
|
63
|
-
...options,
|
|
64
|
-
skipOpenBrowser: true,
|
|
65
|
-
isModuleFederationRemote: true
|
|
66
|
-
});
|
|
67
|
-
default:
|
|
68
|
-
throw new Error(
|
|
69
|
-
`Start command is not supported for package role '${role$1}'`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exports.command = command;
|
|
75
|
-
//# sourceMappingURL=command.cjs.js.map
|
|
File without changes
|