@backstage/cli 0.32.0-next.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +117 -0
- package/bin/backstage-cli-alpha +0 -0
- package/config/eslint-factory.js +20 -1
- package/dist/commands/index.cjs.js +23 -57
- package/dist/lib/errors.cjs.js +1 -1
- package/dist/lib/removed.cjs.js +13 -0
- 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/{commands → modules/create-github-app/commands}/create-github-app/index.cjs.js +1 -1
- package/dist/modules/create-github-app/index.cjs.js +15 -0
- package/dist/{commands/new → modules/new/commands}/new.cjs.js +1 -1
- package/dist/modules/new/index.cjs.js +35 -0
- package/dist/{lib/new → modules/new/lib}/execution/PortableTemplater.cjs.js +5 -5
- package/dist/{lib/new → modules/new/lib}/execution/executePortableTemplate.cjs.js +2 -2
- package/dist/{lib/new → modules/new/lib}/execution/installNewPackage.cjs.js +2 -2
- package/dist/{lib/new → modules/new/lib}/execution/writeTemplateContents.cjs.js +1 -1
- package/dist/{lib/new → modules/new/lib}/preparation/collectPortableTemplateInput.cjs.js +2 -2
- package/dist/{lib/new → modules/new/lib}/preparation/loadPortableTemplate.cjs.js +1 -1
- package/dist/{lib/new → modules/new/lib}/preparation/loadPortableTemplateConfig.cjs.js +1 -1
- 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-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 +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/auth-backend-module-guest-provider/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 +29 -28
- 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/create-github-app/commands}/create-github-app/GithubCreateAppServer.cjs.js +0 -0
- /package/dist/{lib/new → modules/new/lib}/createNewPackage.cjs.js +0 -0
- /package/dist/{lib/new → modules/new/lib}/defaultTemplates.cjs.js +0 -0
- /package/dist/{lib/new → modules/new/lib}/preparation/resolvePackageParams.cjs.js +0 -0
- /package/dist/{lib/new → modules/new/lib}/preparation/selectTemplateInteractively.cjs.js +0 -0
- /package/dist/{lib/new → modules/new/lib}/types.cjs.js +0 -0
- /package/dist/{commands → modules/start/commands/package}/start/index.cjs.js +0 -0
|
@@ -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
|
|
3
|
+
"version": "0.32.0",
|
|
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",
|
|
@@ -47,16 +48,16 @@
|
|
|
47
48
|
]
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@backstage/catalog-model": "1.7.3",
|
|
51
|
-
"@backstage/cli-common": "0.1.15",
|
|
52
|
-
"@backstage/cli-node": "0.2.13",
|
|
53
|
-
"@backstage/config": "1.3.2",
|
|
54
|
-
"@backstage/config-loader": "1.10.0",
|
|
55
|
-
"@backstage/errors": "1.2.7",
|
|
56
|
-
"@backstage/eslint-plugin": "0.1.10",
|
|
57
|
-
"@backstage/integration": "1.16.3
|
|
58
|
-
"@backstage/release-manifests": "0.0.12",
|
|
59
|
-
"@backstage/types": "1.2.1",
|
|
51
|
+
"@backstage/catalog-model": "^1.7.3",
|
|
52
|
+
"@backstage/cli-common": "^0.1.15",
|
|
53
|
+
"@backstage/cli-node": "^0.2.13",
|
|
54
|
+
"@backstage/config": "^1.3.2",
|
|
55
|
+
"@backstage/config-loader": "^1.10.0",
|
|
56
|
+
"@backstage/errors": "^1.2.7",
|
|
57
|
+
"@backstage/eslint-plugin": "^0.1.10",
|
|
58
|
+
"@backstage/integration": "^1.16.3",
|
|
59
|
+
"@backstage/release-manifests": "^0.0.12",
|
|
60
|
+
"@backstage/types": "^1.2.1",
|
|
60
61
|
"@manypkg/get-packages": "^1.1.3",
|
|
61
62
|
"@module-federation/enhanced": "^0.9.0",
|
|
62
63
|
"@octokit/graphql": "^5.0.0",
|
|
@@ -163,22 +164,22 @@
|
|
|
163
164
|
"zod-validation-error": "^3.4.0"
|
|
164
165
|
},
|
|
165
166
|
"devDependencies": {
|
|
166
|
-
"@backstage/backend-plugin-api": "1.
|
|
167
|
-
"@backstage/backend-test-utils": "1.
|
|
168
|
-
"@backstage/catalog-client": "1.9.1",
|
|
169
|
-
"@backstage/config": "1.3.2",
|
|
170
|
-
"@backstage/core-app-api": "1.16.
|
|
171
|
-
"@backstage/core-components": "0.17.1
|
|
172
|
-
"@backstage/core-plugin-api": "1.10.
|
|
173
|
-
"@backstage/dev-utils": "1.1.9
|
|
174
|
-
"@backstage/errors": "1.2.7",
|
|
175
|
-
"@backstage/plugin-auth-backend": "0.24.5
|
|
176
|
-
"@backstage/plugin-auth-backend-module-guest-provider": "0.2.
|
|
177
|
-
"@backstage/plugin-catalog-node": "1.16.
|
|
178
|
-
"@backstage/plugin-scaffolder-node": "0.8.1
|
|
179
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.2.1
|
|
180
|
-
"@backstage/test-utils": "1.7.
|
|
181
|
-
"@backstage/theme": "0.6.
|
|
167
|
+
"@backstage/backend-plugin-api": "^1.3.0",
|
|
168
|
+
"@backstage/backend-test-utils": "^1.4.0",
|
|
169
|
+
"@backstage/catalog-client": "^1.9.1",
|
|
170
|
+
"@backstage/config": "^1.3.2",
|
|
171
|
+
"@backstage/core-app-api": "^1.16.1",
|
|
172
|
+
"@backstage/core-components": "^0.17.1",
|
|
173
|
+
"@backstage/core-plugin-api": "^1.10.6",
|
|
174
|
+
"@backstage/dev-utils": "^1.1.9",
|
|
175
|
+
"@backstage/errors": "^1.2.7",
|
|
176
|
+
"@backstage/plugin-auth-backend": "^0.24.5",
|
|
177
|
+
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.7",
|
|
178
|
+
"@backstage/plugin-catalog-node": "^1.16.3",
|
|
179
|
+
"@backstage/plugin-scaffolder-node": "^0.8.1",
|
|
180
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.2.1",
|
|
181
|
+
"@backstage/test-utils": "^1.7.7",
|
|
182
|
+
"@backstage/theme": "^0.6.5",
|
|
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
|
+
});
|