@backstage/cli 0.36.0-next.1 → 0.36.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 +110 -0
- package/config/eslint-factory.js +1 -0
- package/config/getJestEnvironment.js +7 -29
- package/config/jest-environment-jsdom/index.js +9 -43
- package/config/jest.js +7 -401
- package/config/jestCacheResultProcessor.cjs +10 -6
- package/config/jestCachingModuleLoader.js +11 -19
- package/config/jestFileTransform.js +11 -28
- package/config/jestRejectNetworkRequests.js +10 -53
- package/config/jestSucraseTransform.js +10 -70
- package/config/jestSwcTransform.js +10 -27
- package/config/jestYamlTransform.js +11 -24
- package/config/nodeTransform.cjs +10 -70
- package/config/nodeTransformHooks.mjs +4 -278
- package/config/webpack-public-path.js +10 -14
- package/dist/cli-internal/src/InternalCliModule.cjs.js +11 -0
- package/dist/cli-internal/src/InternalCommandNode.cjs.js +25 -0
- package/dist/cli-internal/src/knownPluginPackages.cjs.js +40 -0
- package/dist/index.cjs.js +21 -10
- package/dist/wiring/CliInitializer.cjs.js +61 -20
- package/dist/wiring/CommandGraph.cjs.js +81 -23
- package/dist/wiring/discoverCliModules.cjs.js +44 -0
- package/package.json +27 -154
- package/dist/modules/build/commands/buildWorkspace.cjs.js +0 -24
- package/dist/modules/build/commands/package/build/command.cjs.js +0 -89
- package/dist/modules/build/commands/package/build/index.cjs.js +0 -8
- package/dist/modules/build/commands/package/clean.cjs.js +0 -21
- package/dist/modules/build/commands/package/postpack.cjs.js +0 -15
- package/dist/modules/build/commands/package/prepack.cjs.js +0 -29
- package/dist/modules/build/commands/package/start/command.cjs.js +0 -23
- package/dist/modules/build/commands/package/start/index.cjs.js +0 -8
- package/dist/modules/build/commands/package/start/resolveLinkedWorkspace.cjs.js +0 -34
- package/dist/modules/build/commands/package/start/startBackend.cjs.js +0 -46
- package/dist/modules/build/commands/package/start/startFrontend.cjs.js +0 -50
- package/dist/modules/build/commands/package/start/startPackage.cjs.js +0 -53
- package/dist/modules/build/commands/repo/build.cjs.js +0 -114
- package/dist/modules/build/commands/repo/clean.cjs.js +0 -41
- package/dist/modules/build/commands/repo/start.cjs.js +0 -150
- package/dist/modules/build/index.cjs.js +0 -192
- package/dist/modules/build/lib/buildBackend.cjs.js +0 -81
- package/dist/modules/build/lib/buildFrontend.cjs.js +0 -50
- package/dist/modules/build/lib/builder/config.cjs.js +0 -257
- package/dist/modules/build/lib/builder/packager.cjs.js +0 -131
- package/dist/modules/build/lib/builder/plugins.cjs.js +0 -125
- package/dist/modules/build/lib/builder/types.cjs.js +0 -10
- package/dist/modules/build/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js +0 -43
- package/dist/modules/build/lib/bundler/bundle.cjs.js +0 -189
- package/dist/modules/build/lib/bundler/config.cjs.js +0 -308
- package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +0 -17
- package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +0 -34
- package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +0 -135
- package/dist/modules/build/lib/bundler/optimization.cjs.js +0 -68
- package/dist/modules/build/lib/bundler/packageDetection.cjs.js +0 -124
- package/dist/modules/build/lib/bundler/paths.cjs.js +0 -62
- package/dist/modules/build/lib/bundler/server.cjs.js +0 -231
- package/dist/modules/build/lib/bundler/transforms.cjs.js +0 -145
- package/dist/modules/build/lib/config.cjs.js +0 -94
- package/dist/modules/build/lib/entryPoints.cjs.js +0 -49
- package/dist/modules/build/lib/ipc/IpcServer.cjs.js +0 -60
- package/dist/modules/build/lib/ipc/ServerDataStore.cjs.js +0 -36
- package/dist/modules/build/lib/optionsParser.cjs.js +0 -37
- package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +0 -235
- package/dist/modules/build/lib/packager/productionPack.cjs.js +0 -160
- package/dist/modules/build/lib/publishing.cjs.js +0 -40
- package/dist/modules/build/lib/role.cjs.js +0 -24
- package/dist/modules/build/lib/runner/runBackend.cjs.js +0 -136
- package/dist/modules/build/lib/typeDistProject.cjs.js +0 -89
- package/dist/modules/build/lib/urls.cjs.js +0 -13
- package/dist/modules/config/commands/docs.cjs.js +0 -62
- package/dist/modules/config/commands/print.cjs.js +0 -80
- package/dist/modules/config/commands/schema.cjs.js +0 -55
- package/dist/modules/config/commands/validate.cjs.js +0 -49
- package/dist/modules/config/index.cjs.js +0 -51
- package/dist/modules/config/lib/config.cjs.js +0 -94
- package/dist/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.cjs.js +0 -127
- package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +0 -115
- package/dist/modules/create-github-app/index.cjs.js +0 -27
- package/dist/modules/info/commands/info.cjs.js +0 -181
- package/dist/modules/info/index.cjs.js +0 -19
- package/dist/modules/lint/commands/package/lint.cjs.js +0 -46
- package/dist/modules/lint/commands/repo/lint.cjs.js +0 -212
- package/dist/modules/lint/index.cjs.js +0 -82
- package/dist/modules/lint/lib/optionsParser.cjs.js +0 -37
- package/dist/modules/maintenance/commands/repo/fix.cjs.js +0 -400
- package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +0 -74
- package/dist/modules/maintenance/index.cjs.js +0 -42
- package/dist/modules/migrate/commands/packageExports.cjs.js +0 -15
- package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +0 -77
- package/dist/modules/migrate/commands/packageRole.cjs.js +0 -57
- package/dist/modules/migrate/commands/packageScripts.cjs.js +0 -87
- package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +0 -51
- package/dist/modules/migrate/commands/versions/bump.cjs.js +0 -373
- package/dist/modules/migrate/commands/versions/migrate.cjs.js +0 -112
- package/dist/modules/migrate/index.cjs.js +0 -82
- package/dist/modules/migrate/lib/utils.cjs.js +0 -44
- package/dist/modules/migrate/lib/versioning/packages.cjs.js +0 -71
- package/dist/modules/migrate/lib/versioning/yarn.cjs.js +0 -28
- package/dist/modules/new/commands/new.cjs.js +0 -60
- package/dist/modules/new/index.cjs.js +0 -68
- package/dist/modules/new/lib/codeowners/codeowners.cjs.js +0 -92
- package/dist/modules/new/lib/createNewPackage.cjs.js +0 -32
- package/dist/modules/new/lib/defaultTemplates.cjs.js +0 -17
- package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +0 -89
- package/dist/modules/new/lib/execution/executePortableTemplate.cjs.js +0 -66
- package/dist/modules/new/lib/execution/installNewPackage.cjs.js +0 -127
- package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +0 -116
- package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +0 -157
- package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +0 -81
- package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +0 -132
- package/dist/modules/new/lib/preparation/resolvePackageParams.cjs.js +0 -40
- package/dist/modules/new/lib/preparation/selectTemplateInteractively.cjs.js +0 -38
- package/dist/modules/new/lib/tasks.cjs.js +0 -51
- package/dist/modules/new/lib/types.cjs.js +0 -19
- package/dist/modules/new/lib/version.cjs.js +0 -91
- package/dist/modules/test/commands/package/test.cjs.js +0 -65
- package/dist/modules/test/commands/repo/test.cjs.js +0 -288
- package/dist/modules/test/index.cjs.js +0 -54
- package/dist/modules/translations/commands/export.cjs.js +0 -127
- package/dist/modules/translations/commands/import.cjs.js +0 -164
- package/dist/modules/translations/index.cjs.js +0 -24
- package/dist/modules/translations/lib/discoverPackages.cjs.js +0 -121
- package/dist/modules/translations/lib/extractTranslations.cjs.js +0 -71
- package/dist/modules/translations/lib/messageFilePath.cjs.js +0 -43
- package/dist/packages/backend-defaults/package.json.cjs.js +0 -6
- package/dist/packages/backend-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/backend-test-utils/package.json.cjs.js +0 -6
- package/dist/packages/catalog-client/package.json.cjs.js +0 -6
- package/dist/packages/cli/package.json.cjs.js +0 -156
- package/dist/packages/config/package.json.cjs.js +0 -6
- package/dist/packages/core-app-api/package.json.cjs.js +0 -6
- package/dist/packages/core-components/package.json.cjs.js +0 -6
- package/dist/packages/core-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/dev-utils/package.json.cjs.js +0 -6
- package/dist/packages/errors/package.json.cjs.js +0 -6
- package/dist/packages/frontend-defaults/package.json.cjs.js +0 -6
- package/dist/packages/frontend-plugin-api/package.json.cjs.js +0 -6
- package/dist/packages/frontend-plugin-api/src/routing/describeParentCallSite.cjs.js +0 -26
- package/dist/packages/frontend-test-utils/package.json.cjs.js +0 -6
- package/dist/packages/test-utils/package.json.cjs.js +0 -6
- package/dist/packages/theme/package.json.cjs.js +0 -6
- package/dist/packages/types/package.json.cjs.js +0 -6
- package/dist/plugins/auth-backend/package.json.cjs.js +0 -6
- package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +0 -6
- package/dist/plugins/catalog-node/package.json.cjs.js +0 -6
- package/dist/plugins/scaffolder-node/package.json.cjs.js +0 -6
- package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +0 -6
- package/dist/wiring/CommandRegistry.cjs.js +0 -14
- package/dist/wiring/factory.cjs.js +0 -15
- package/dist/wiring/lazy.cjs.js +0 -22
- package/dist/wiring/types.cjs.js +0 -11
- package/templates/backend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/backend-plugin/README.md.hbs +0 -28
- package/templates/backend-plugin/dev/index.ts.hbs +0 -60
- package/templates/backend-plugin/package.json.hbs +0 -44
- package/templates/backend-plugin/portable-template.yaml +0 -5
- package/templates/backend-plugin/src/index.ts.hbs +0 -1
- package/templates/backend-plugin/src/plugin.test.ts.hbs +0 -129
- package/templates/backend-plugin/src/plugin.ts.hbs +0 -32
- package/templates/backend-plugin/src/router.test.ts +0 -67
- package/templates/backend-plugin/src/router.ts +0 -51
- package/templates/backend-plugin/src/services/TodoListService.ts +0 -155
- package/templates/backend-plugin/src/setupTests.ts +0 -1
- package/templates/backend-plugin-module/.eslintrc.js.hbs +0 -1
- package/templates/backend-plugin-module/README.md.hbs +0 -5
- package/templates/backend-plugin-module/package.json.hbs +0 -34
- package/templates/backend-plugin-module/portable-template.yaml +0 -5
- package/templates/backend-plugin-module/src/index.ts.hbs +0 -8
- package/templates/backend-plugin-module/src/module.ts.hbs +0 -17
- package/templates/catalog-provider-module/.eslintrc.js.hbs +0 -1
- package/templates/catalog-provider-module/README.md.hbs +0 -5
- package/templates/catalog-provider-module/config.d.ts.hbs +0 -34
- package/templates/catalog-provider-module/package.json.hbs +0 -36
- package/templates/catalog-provider-module/portable-template.yaml +0 -9
- package/templates/catalog-provider-module/src/index.ts.hbs +0 -8
- package/templates/catalog-provider-module/src/module.ts.hbs +0 -29
- package/templates/catalog-provider-module/src/provider/readProviderConfigs.ts.hbs +0 -78
- package/templates/catalog-provider-module/src/provider/{{providerClass}}.test.ts.hbs +0 -18
- package/templates/catalog-provider-module/src/provider/{{providerClass}}.ts.hbs +0 -109
- package/templates/frontend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/frontend-plugin/README.md.hbs +0 -13
- package/templates/frontend-plugin/dev/index.tsx.hbs +0 -11
- package/templates/frontend-plugin/package.json.hbs +0 -54
- package/templates/frontend-plugin/portable-template.yaml +0 -6
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
- package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
- package/templates/frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
- package/templates/frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
- package/templates/frontend-plugin/src/index.ts.hbs +0 -1
- package/templates/frontend-plugin/src/plugin.test.ts.hbs +0 -7
- package/templates/frontend-plugin/src/plugin.ts.hbs +0 -22
- package/templates/frontend-plugin/src/routes.ts.hbs +0 -5
- package/templates/frontend-plugin/src/setupTests.ts +0 -1
- package/templates/new-frontend-plugin/.eslintrc.js.hbs +0 -1
- package/templates/new-frontend-plugin/README.md.hbs +0 -20
- package/templates/new-frontend-plugin/dev/index.tsx +0 -10
- package/templates/new-frontend-plugin/package.json.hbs +0 -49
- package/templates/new-frontend-plugin/portable-template.yaml +0 -5
- package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
- package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
- package/templates/new-frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
- package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
- package/templates/new-frontend-plugin/src/index.ts.hbs +0 -1
- package/templates/new-frontend-plugin/src/plugin.test.ts.hbs +0 -7
- package/templates/new-frontend-plugin/src/plugin.tsx.hbs +0 -25
- package/templates/new-frontend-plugin/src/routes.ts +0 -3
- package/templates/new-frontend-plugin/src/setupTests.ts +0 -1
- package/templates/new-frontend-plugin-module/.eslintrc.js.hbs +0 -1
- package/templates/new-frontend-plugin-module/README.md.hbs +0 -5
- package/templates/new-frontend-plugin-module/package.json.hbs +0 -35
- package/templates/new-frontend-plugin-module/portable-template.yaml +0 -5
- package/templates/new-frontend-plugin-module/src/index.ts.hbs +0 -1
- package/templates/new-frontend-plugin-module/src/module.tsx.hbs +0 -8
- package/templates/new-frontend-plugin-module/src/setupTests.ts +0 -1
- package/templates/node-library/.eslintrc.js.hbs +0 -1
- package/templates/node-library/README.md.hbs +0 -12
- package/templates/node-library/package.json.hbs +0 -29
- package/templates/node-library/portable-template.yaml +0 -3
- package/templates/node-library/src/index.ts.hbs +0 -1
- package/templates/node-library/src/setupTests.ts +0 -1
- package/templates/plugin-common-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-common-library/README.md.hbs +0 -5
- package/templates/plugin-common-library/package.json.hbs +0 -31
- package/templates/plugin-common-library/portable-template.yaml +0 -3
- package/templates/plugin-common-library/src/index.ts.hbs +0 -19
- package/templates/plugin-common-library/src/setupTests.ts +0 -1
- package/templates/plugin-node-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-node-library/README.md.hbs +0 -5
- package/templates/plugin-node-library/package.json.hbs +0 -30
- package/templates/plugin-node-library/portable-template.yaml +0 -3
- package/templates/plugin-node-library/src/index.ts.hbs +0 -18
- package/templates/plugin-node-library/src/setupTests.ts +0 -1
- package/templates/plugin-web-library/.eslintrc.js.hbs +0 -1
- package/templates/plugin-web-library/README.md.hbs +0 -5
- package/templates/plugin-web-library/package.json.hbs +0 -42
- package/templates/plugin-web-library/portable-template.yaml +0 -3
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx +0 -17
- package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx +0 -28
- package/templates/plugin-web-library/src/components/ExampleComponent/index.ts +0 -2
- package/templates/plugin-web-library/src/components/index.ts +0 -5
- package/templates/plugin-web-library/src/hooks/index.ts +0 -5
- package/templates/plugin-web-library/src/hooks/useExample/index.ts +0 -1
- package/templates/plugin-web-library/src/hooks/useExample/useExample.ts +0 -15
- package/templates/plugin-web-library/src/index.ts.hbs +0 -12
- package/templates/plugin-web-library/src/setupTests.ts +0 -1
- package/templates/scaffolder-backend-module/.eslintrc.js.hbs +0 -1
- package/templates/scaffolder-backend-module/README.md.hbs +0 -5
- package/templates/scaffolder-backend-module/package.json.hbs +0 -36
- package/templates/scaffolder-backend-module/portable-template.yaml +0 -6
- package/templates/scaffolder-backend-module/src/actions/example.test.ts +0 -24
- package/templates/scaffolder-backend-module/src/actions/example.ts +0 -39
- package/templates/scaffolder-backend-module/src/index.ts.hbs +0 -8
- package/templates/scaffolder-backend-module/src/module.ts +0 -21
- package/templates/web-library/.eslintrc.js.hbs +0 -1
- package/templates/web-library/README.md.hbs +0 -12
- package/templates/web-library/package.json.hbs +0 -30
- package/templates/web-library/portable-template.yaml +0 -3
- package/templates/web-library/src/index.ts.hbs +0 -1
- package/templates/web-library/src/setupTests.ts +0 -1
- /package/dist/{packages/opaque-internal → opaque-internal}/src/OpaqueType.cjs.js +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var upperFirst = require('lodash/upperFirst');
|
|
5
|
-
var camelCase = require('lodash/camelCase');
|
|
6
|
-
var cliCommon = require('@backstage/cli-common');
|
|
7
|
-
var tasks = require('../tasks.cjs.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
-
|
|
11
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
12
|
-
var upperFirst__default = /*#__PURE__*/_interopDefaultCompat(upperFirst);
|
|
13
|
-
var camelCase__default = /*#__PURE__*/_interopDefaultCompat(camelCase);
|
|
14
|
-
|
|
15
|
-
async function installNewPackage(input) {
|
|
16
|
-
switch (input.roleParams.role) {
|
|
17
|
-
case "web-library":
|
|
18
|
-
case "node-library":
|
|
19
|
-
case "common-library":
|
|
20
|
-
case "plugin-web-library":
|
|
21
|
-
case "plugin-node-library":
|
|
22
|
-
case "plugin-common-library":
|
|
23
|
-
return;
|
|
24
|
-
// No installation action needed for library packages
|
|
25
|
-
case "frontend-plugin":
|
|
26
|
-
await addDependency(input, "packages/app/package.json");
|
|
27
|
-
await tryAddFrontendLegacy(input);
|
|
28
|
-
return;
|
|
29
|
-
case "frontend-plugin-module":
|
|
30
|
-
await addDependency(input, "packages/app/package.json");
|
|
31
|
-
return;
|
|
32
|
-
case "backend-plugin":
|
|
33
|
-
await addDependency(input, "packages/backend/package.json");
|
|
34
|
-
await tryAddBackend(input);
|
|
35
|
-
return;
|
|
36
|
-
case "backend-plugin-module":
|
|
37
|
-
await addDependency(input, "packages/backend/package.json");
|
|
38
|
-
await tryAddBackend(input);
|
|
39
|
-
return;
|
|
40
|
-
default:
|
|
41
|
-
throw new Error(
|
|
42
|
-
`Unsupported role ${input.roleParams.role}`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async function addDependency(input, path) {
|
|
47
|
-
const pkgJsonPath = cliCommon.targetPaths.resolveRoot(path);
|
|
48
|
-
const pkgJson = await fs__default.default.readJson(pkgJsonPath).catch((error) => {
|
|
49
|
-
if (error.code === "ENOENT") {
|
|
50
|
-
return void 0;
|
|
51
|
-
}
|
|
52
|
-
throw error;
|
|
53
|
-
});
|
|
54
|
-
if (!pkgJson) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
pkgJson.dependencies = {
|
|
59
|
-
...pkgJson.dependencies,
|
|
60
|
-
[input.packageName]: `workspace:^`
|
|
61
|
-
};
|
|
62
|
-
await fs__default.default.writeJson(path, pkgJson, { spaces: 2 });
|
|
63
|
-
} catch (error) {
|
|
64
|
-
throw new Error(`Failed to add package dependencies, ${error}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async function tryAddFrontendLegacy(input) {
|
|
68
|
-
const { roleParams } = input;
|
|
69
|
-
if (roleParams.role !== "frontend-plugin") {
|
|
70
|
-
throw new Error(
|
|
71
|
-
"add-frontend-legacy can only be used for frontend plugins"
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
const appDefinitionPath = cliCommon.targetPaths.resolveRoot("packages/app/src/App.tsx");
|
|
75
|
-
if (!await fs__default.default.pathExists(appDefinitionPath)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
await tasks.Task.forItem("app", "adding import", async () => {
|
|
79
|
-
const content = await fs__default.default.readFile(appDefinitionPath, "utf8");
|
|
80
|
-
const revLines = content.split("\n").reverse();
|
|
81
|
-
const lastImportIndex = revLines.findIndex(
|
|
82
|
-
(line) => line.match(/ from ("|').*("|')/)
|
|
83
|
-
);
|
|
84
|
-
const lastRouteIndex = revLines.findIndex(
|
|
85
|
-
(line) => line.match(/<\/FlatRoutes/)
|
|
86
|
-
);
|
|
87
|
-
if (lastImportIndex !== -1 && lastRouteIndex !== -1) {
|
|
88
|
-
const extensionName = upperFirst__default.default(`${camelCase__default.default(roleParams.pluginId)}Page`);
|
|
89
|
-
const importLine = `import { ${extensionName} } from '${input.packageName}';`;
|
|
90
|
-
if (!content.includes(importLine)) {
|
|
91
|
-
revLines.splice(lastImportIndex, 0, importLine);
|
|
92
|
-
}
|
|
93
|
-
const componentLine = `<Route path="/${roleParams.pluginId}" element={<${extensionName} />} />`;
|
|
94
|
-
if (!content.includes(componentLine)) {
|
|
95
|
-
const [indentation] = revLines[lastRouteIndex + 1].match(/^\s*/) ?? [];
|
|
96
|
-
revLines.splice(lastRouteIndex + 1, 0, indentation + componentLine);
|
|
97
|
-
}
|
|
98
|
-
const newContent = revLines.reverse().join("\n");
|
|
99
|
-
await fs__default.default.writeFile(appDefinitionPath, newContent, "utf8");
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async function tryAddBackend(input) {
|
|
104
|
-
const backendIndexPath = cliCommon.targetPaths.resolveRoot(
|
|
105
|
-
"packages/backend/src/index.ts"
|
|
106
|
-
);
|
|
107
|
-
if (!await fs__default.default.pathExists(backendIndexPath)) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
await tasks.Task.forItem("backend", `adding ${input.packageName}`, async () => {
|
|
111
|
-
const content = await fs__default.default.readFile(backendIndexPath, "utf8");
|
|
112
|
-
const lines = content.split("\n");
|
|
113
|
-
const backendAddLine = `backend.add(import('${input.packageName}'));`;
|
|
114
|
-
const backendStartIndex = lines.findIndex(
|
|
115
|
-
(line) => line.match(/backend.start/)
|
|
116
|
-
);
|
|
117
|
-
if (backendStartIndex !== -1) {
|
|
118
|
-
const [indentation] = lines[backendStartIndex].match(/^\s*/);
|
|
119
|
-
lines.splice(backendStartIndex, 0, `${indentation}${backendAddLine}`);
|
|
120
|
-
const newContent = lines.join("\n");
|
|
121
|
-
await fs__default.default.writeFile(backendIndexPath, newContent, "utf8");
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
exports.installNewPackage = installNewPackage;
|
|
127
|
-
//# sourceMappingURL=installNewPackage.cjs.js.map
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var path = require('node:path');
|
|
5
|
-
var errors = require('@backstage/errors');
|
|
6
|
-
var cliNode = require('@backstage/cli-node');
|
|
7
|
-
var PortableTemplater = require('./PortableTemplater.cjs.js');
|
|
8
|
-
var cliCommon = require('@backstage/cli-common');
|
|
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 writeTemplateContents(template, input) {
|
|
15
|
-
const targetDir = cliCommon.targetPaths.resolveRoot(input.packagePath);
|
|
16
|
-
if (await fs__default.default.pathExists(targetDir)) {
|
|
17
|
-
throw new errors.InputError(`Package '${input.packagePath}' already exists`);
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const isMonoRepo = await cliNode.isMonoRepo();
|
|
21
|
-
const { role, ...roleValues } = input.roleParams;
|
|
22
|
-
const templater = await PortableTemplater.PortableTemplater.create({
|
|
23
|
-
values: {
|
|
24
|
-
...roleValues,
|
|
25
|
-
packageName: input.packageName
|
|
26
|
-
},
|
|
27
|
-
templatedValues: template.values
|
|
28
|
-
});
|
|
29
|
-
if (!isMonoRepo) {
|
|
30
|
-
await fs__default.default.writeJson(
|
|
31
|
-
path.resolve(targetDir, "tsconfig.json"),
|
|
32
|
-
{
|
|
33
|
-
extends: "@backstage/cli/config/tsconfig.json",
|
|
34
|
-
include: ["src", "dev", "migrations"],
|
|
35
|
-
exclude: ["node_modules"],
|
|
36
|
-
compilerOptions: {
|
|
37
|
-
outDir: "dist-types",
|
|
38
|
-
rootDir: "."
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{ spaces: 2 }
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
for (const file of template.files) {
|
|
45
|
-
const destPath = path.resolve(targetDir, templater.template(file.path));
|
|
46
|
-
if (!cliCommon.isChildPath(targetDir, destPath)) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Path ${destPath} is outside of target directory ${targetDir}`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
await fs__default.default.ensureDir(path.dirname(destPath));
|
|
52
|
-
let content = file.syntax === "handlebars" ? templater.template(file.content) : file.content;
|
|
53
|
-
if (file.path === "package.json") {
|
|
54
|
-
try {
|
|
55
|
-
content = injectPackageJsonInput(input, content);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
throw new errors.ForwardedError(
|
|
58
|
-
"Failed to transform templated package.json",
|
|
59
|
-
error
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
await fs__default.default.writeFile(destPath, content).catch((error) => {
|
|
64
|
-
throw new errors.ForwardedError(`Failed to copy file to ${destPath}`, error);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return { targetDir };
|
|
68
|
-
} catch (error) {
|
|
69
|
-
await fs__default.default.rm(targetDir, { recursive: true, force: true, maxRetries: 10 });
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function injectPackageJsonInput(input, content) {
|
|
74
|
-
const pkgJson = JSON.parse(content);
|
|
75
|
-
const toAdd = new Array();
|
|
76
|
-
if (pkgJson.version) {
|
|
77
|
-
pkgJson.version = input.version;
|
|
78
|
-
} else {
|
|
79
|
-
toAdd.push(["version", input.version]);
|
|
80
|
-
}
|
|
81
|
-
if (pkgJson.license) {
|
|
82
|
-
pkgJson.license = input.license;
|
|
83
|
-
} else {
|
|
84
|
-
toAdd.push(["license", input.license]);
|
|
85
|
-
}
|
|
86
|
-
if (input.private) {
|
|
87
|
-
if (pkgJson.private === false) {
|
|
88
|
-
pkgJson.private = true;
|
|
89
|
-
} else if (!pkgJson.private) {
|
|
90
|
-
toAdd.push(["private", true]);
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
delete pkgJson.private;
|
|
94
|
-
}
|
|
95
|
-
if (input.publishRegistry) {
|
|
96
|
-
if (pkgJson.publishConfig) {
|
|
97
|
-
pkgJson.publishConfig = {
|
|
98
|
-
...pkgJson.publishConfig,
|
|
99
|
-
registry: input.publishRegistry
|
|
100
|
-
};
|
|
101
|
-
} else {
|
|
102
|
-
toAdd.push(["publishConfig", { registry: input.publishRegistry }]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const entries = Object.entries(pkgJson);
|
|
106
|
-
const nameIndex = entries.findIndex(([name]) => name === "name");
|
|
107
|
-
if (nameIndex === -1) {
|
|
108
|
-
throw new Error("templated package.json does not contain a name field");
|
|
109
|
-
}
|
|
110
|
-
entries.splice(nameIndex + 1, 0, ...toAdd);
|
|
111
|
-
return JSON.stringify(Object.fromEntries(entries), null, 2);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
exports.injectPackageJsonInput = injectPackageJsonInput;
|
|
115
|
-
exports.writeTemplateContents = writeTemplateContents;
|
|
116
|
-
//# sourceMappingURL=writeTemplateContents.cjs.js.map
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var inquirer = require('inquirer');
|
|
4
|
-
var codeowners = require('../codeowners/codeowners.cjs.js');
|
|
5
|
-
var cliCommon = require('@backstage/cli-common');
|
|
6
|
-
var resolvePackageParams = require('./resolvePackageParams.cjs.js');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
var inquirer__default = /*#__PURE__*/_interopDefaultCompat(inquirer);
|
|
11
|
-
|
|
12
|
-
async function collectPortableTemplateInput(options) {
|
|
13
|
-
const { config, template, prefilledParams } = options;
|
|
14
|
-
const codeOwnersFilePath = await codeowners.getCodeownersFilePath(cliCommon.targetPaths.rootDir);
|
|
15
|
-
const prompts = getPromptsForRole(template.role);
|
|
16
|
-
if (codeOwnersFilePath) {
|
|
17
|
-
prompts.push(ownerPrompt());
|
|
18
|
-
}
|
|
19
|
-
const deprecatedParams = {};
|
|
20
|
-
if (config.isUsingDefaultTemplates && prefilledParams.id) {
|
|
21
|
-
console.warn(
|
|
22
|
-
`DEPRECATION WARNING: The 'id' parameter is deprecated, use 'pluginId' instead`
|
|
23
|
-
);
|
|
24
|
-
deprecatedParams.pluginId = prefilledParams.id;
|
|
25
|
-
}
|
|
26
|
-
const parameters = {
|
|
27
|
-
...template.values,
|
|
28
|
-
...prefilledParams,
|
|
29
|
-
...deprecatedParams
|
|
30
|
-
};
|
|
31
|
-
const needsAnswer = [];
|
|
32
|
-
const prefilledAnswers = {};
|
|
33
|
-
for (const prompt of prompts) {
|
|
34
|
-
if (prompt.name && parameters[prompt.name] !== void 0) {
|
|
35
|
-
prefilledAnswers[prompt.name] = parameters[prompt.name];
|
|
36
|
-
} else {
|
|
37
|
-
needsAnswer.push(prompt);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const promptAnswers = await inquirer__default.default.prompt(
|
|
41
|
-
needsAnswer
|
|
42
|
-
);
|
|
43
|
-
const answers = {
|
|
44
|
-
...prefilledAnswers,
|
|
45
|
-
...promptAnswers
|
|
46
|
-
};
|
|
47
|
-
const roleParams = {
|
|
48
|
-
role: template.role,
|
|
49
|
-
name: answers.name,
|
|
50
|
-
pluginId: answers.pluginId,
|
|
51
|
-
moduleId: answers.moduleId
|
|
52
|
-
};
|
|
53
|
-
const packageParams = resolvePackageParams.resolvePackageParams({
|
|
54
|
-
roleParams,
|
|
55
|
-
packagePrefix: config.packageNamePrefix,
|
|
56
|
-
pluginInfix: config.packageNamePluginInfix
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
roleParams,
|
|
60
|
-
owner: answers.owner,
|
|
61
|
-
license: config.license,
|
|
62
|
-
version: config.version,
|
|
63
|
-
private: config.private,
|
|
64
|
-
publishRegistry: config.publishRegistry,
|
|
65
|
-
packageName: packageParams.packageName,
|
|
66
|
-
packagePath: packageParams.packagePath
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function namePrompt() {
|
|
70
|
-
return {
|
|
71
|
-
type: "input",
|
|
72
|
-
name: "name",
|
|
73
|
-
message: "Enter the name of the package, without scope [required]",
|
|
74
|
-
validate: (value) => {
|
|
75
|
-
if (!value) {
|
|
76
|
-
return "Please enter the name of the package";
|
|
77
|
-
} else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {
|
|
78
|
-
return "Package names must be lowercase and contain only letters, digits, and dashes.";
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function pluginIdPrompt() {
|
|
85
|
-
return {
|
|
86
|
-
type: "input",
|
|
87
|
-
name: "pluginId",
|
|
88
|
-
message: "Enter the ID of the plugin [required]",
|
|
89
|
-
validate: (value) => {
|
|
90
|
-
if (!value) {
|
|
91
|
-
return "Please enter the ID of the plugin";
|
|
92
|
-
} else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {
|
|
93
|
-
return "Plugin IDs must be lowercase and contain only letters, digits, and dashes.";
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function moduleIdIdPrompt() {
|
|
100
|
-
return {
|
|
101
|
-
type: "input",
|
|
102
|
-
name: "moduleId",
|
|
103
|
-
message: "Enter the ID of the module [required]",
|
|
104
|
-
validate: (value) => {
|
|
105
|
-
if (!value) {
|
|
106
|
-
return "Please enter the ID of the module";
|
|
107
|
-
} else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {
|
|
108
|
-
return "Module IDs must be lowercase and contain only letters, digits, and dashes.";
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function getPromptsForRole(role) {
|
|
115
|
-
switch (role) {
|
|
116
|
-
case "web-library":
|
|
117
|
-
case "node-library":
|
|
118
|
-
case "common-library":
|
|
119
|
-
return [namePrompt()];
|
|
120
|
-
case "plugin-web-library":
|
|
121
|
-
case "plugin-node-library":
|
|
122
|
-
case "plugin-common-library":
|
|
123
|
-
case "frontend-plugin":
|
|
124
|
-
case "backend-plugin":
|
|
125
|
-
return [pluginIdPrompt()];
|
|
126
|
-
case "frontend-plugin-module":
|
|
127
|
-
case "backend-plugin-module":
|
|
128
|
-
return [pluginIdPrompt(), moduleIdIdPrompt()];
|
|
129
|
-
default:
|
|
130
|
-
return [];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function ownerPrompt() {
|
|
134
|
-
return {
|
|
135
|
-
type: "input",
|
|
136
|
-
name: "owner",
|
|
137
|
-
message: "Enter an owner to add to CODEOWNERS [optional]",
|
|
138
|
-
validate: (value) => {
|
|
139
|
-
if (!value) {
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
const ownerIds = codeowners.parseOwnerIds(value);
|
|
143
|
-
if (!ownerIds) {
|
|
144
|
-
return "The owner must be a space separated list of team names (e.g. @org/team-name), usernames (e.g. @username), or the email addresses (e.g. user@example.com).";
|
|
145
|
-
}
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
exports.collectPortableTemplateInput = collectPortableTemplateInput;
|
|
152
|
-
exports.getPromptsForRole = getPromptsForRole;
|
|
153
|
-
exports.moduleIdIdPrompt = moduleIdIdPrompt;
|
|
154
|
-
exports.namePrompt = namePrompt;
|
|
155
|
-
exports.ownerPrompt = ownerPrompt;
|
|
156
|
-
exports.pluginIdPrompt = pluginIdPrompt;
|
|
157
|
-
//# sourceMappingURL=collectPortableTemplateInput.cjs.js.map
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var zod = require('zod');
|
|
4
|
-
var fs = require('fs-extra');
|
|
5
|
-
var recursiveReaddir = require('recursive-readdir');
|
|
6
|
-
var path = require('node:path');
|
|
7
|
-
var yaml = require('yaml');
|
|
8
|
-
var cliCommon = require('@backstage/cli-common');
|
|
9
|
-
var types = require('../types.cjs.js');
|
|
10
|
-
var errors = require('@backstage/errors');
|
|
11
|
-
var v3 = require('zod-validation-error/v3');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
|
-
|
|
15
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
16
|
-
var recursiveReaddir__default = /*#__PURE__*/_interopDefaultCompat(recursiveReaddir);
|
|
17
|
-
|
|
18
|
-
const templateDefinitionSchema = zod.z.object({
|
|
19
|
-
name: zod.z.string(),
|
|
20
|
-
role: zod.z.enum(types.TEMPLATE_ROLES),
|
|
21
|
-
description: zod.z.string().optional(),
|
|
22
|
-
values: zod.z.record(zod.z.string()).optional()
|
|
23
|
-
}).strict();
|
|
24
|
-
async function loadPortableTemplate(pointer) {
|
|
25
|
-
if (pointer.target.match(/https?:\/\//)) {
|
|
26
|
-
throw new Error("Remote templates are not supported yet");
|
|
27
|
-
}
|
|
28
|
-
const templateContent = await fs__default.default.readFile(cliCommon.targetPaths.resolveRoot(pointer.target), "utf-8").catch((error) => {
|
|
29
|
-
throw new errors.ForwardedError(
|
|
30
|
-
`Failed to load template definition from '${pointer.target}'`,
|
|
31
|
-
error
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
const rawTemplate = yaml.parse(templateContent);
|
|
35
|
-
const parsed = templateDefinitionSchema.safeParse(rawTemplate);
|
|
36
|
-
if (!parsed.success) {
|
|
37
|
-
throw new errors.ForwardedError(
|
|
38
|
-
`Invalid template definition at '${pointer.target}'`,
|
|
39
|
-
v3.fromZodError(parsed.error)
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
const { role, values = {} } = parsed.data;
|
|
43
|
-
const templatePath = path.resolve(path.dirname(pointer.target));
|
|
44
|
-
const filePaths = await recursiveReaddir__default.default(templatePath).catch((error) => {
|
|
45
|
-
throw new errors.ForwardedError(
|
|
46
|
-
`Failed to load template contents from '${templatePath}'`,
|
|
47
|
-
error
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
const loadedFiles = new Array();
|
|
51
|
-
for (const filePath of filePaths) {
|
|
52
|
-
const path$1 = path.relative(templatePath, filePath);
|
|
53
|
-
if (filePath === pointer.target) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const content = await fs__default.default.readFile(filePath, "utf-8").catch((error) => {
|
|
57
|
-
throw new errors.ForwardedError(
|
|
58
|
-
`Failed to load file contents from '${path$1}'`,
|
|
59
|
-
error
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
if (path$1.endsWith(".hbs")) {
|
|
63
|
-
loadedFiles.push({
|
|
64
|
-
path: path$1.slice(0, -4),
|
|
65
|
-
content,
|
|
66
|
-
syntax: "handlebars"
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
loadedFiles.push({ path: path$1, content });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
name: pointer.name,
|
|
74
|
-
role,
|
|
75
|
-
files: loadedFiles,
|
|
76
|
-
values
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
exports.loadPortableTemplate = loadPortableTemplate;
|
|
81
|
-
//# sourceMappingURL=loadPortableTemplate.cjs.js.map
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs-extra');
|
|
4
|
-
var path = require('node:path');
|
|
5
|
-
var cliCommon = require('@backstage/cli-common');
|
|
6
|
-
var defaultTemplates = require('../defaultTemplates.cjs.js');
|
|
7
|
-
var types = require('../types.cjs.js');
|
|
8
|
-
var yaml = require('yaml');
|
|
9
|
-
var zod = require('zod');
|
|
10
|
-
var v3 = require('zod-validation-error/v3');
|
|
11
|
-
var errors = require('@backstage/errors');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
|
-
|
|
15
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
16
|
-
|
|
17
|
-
const defaults = {
|
|
18
|
-
license: "Apache-2.0",
|
|
19
|
-
version: "0.1.0",
|
|
20
|
-
private: true,
|
|
21
|
-
publishRegistry: void 0,
|
|
22
|
-
packageNamePrefix: "@internal/",
|
|
23
|
-
packageNamePluginInfix: "plugin-"
|
|
24
|
-
};
|
|
25
|
-
const newConfigSchema = zod.z.object({
|
|
26
|
-
templates: zod.z.array(zod.z.string()).optional(),
|
|
27
|
-
globals: zod.z.object({
|
|
28
|
-
license: zod.z.string().optional(),
|
|
29
|
-
version: zod.z.string().optional(),
|
|
30
|
-
private: zod.z.boolean().optional(),
|
|
31
|
-
publishRegistry: zod.z.string().optional(),
|
|
32
|
-
namePrefix: zod.z.string().optional(),
|
|
33
|
-
namePluginInfix: zod.z.string().optional()
|
|
34
|
-
}).optional()
|
|
35
|
-
}).strict();
|
|
36
|
-
const pkgJsonWithNewConfigSchema = zod.z.object({
|
|
37
|
-
backstage: zod.z.object({
|
|
38
|
-
cli: zod.z.object({
|
|
39
|
-
new: newConfigSchema.optional()
|
|
40
|
-
}).optional()
|
|
41
|
-
}).optional()
|
|
42
|
-
});
|
|
43
|
-
function computePackageNamePluginInfix(packageNamePrefix, namePluginInfix) {
|
|
44
|
-
const packageNamePluginInfix = namePluginInfix ?? (packageNamePrefix.includes("backstage") ? defaults.packageNamePluginInfix : "backstage-plugin-");
|
|
45
|
-
return {
|
|
46
|
-
packageNamePluginInfix
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
async function loadPortableTemplateConfig(options = {}) {
|
|
50
|
-
const { overrides = {} } = options;
|
|
51
|
-
const pkgPath = options.packagePath ?? cliCommon.targetPaths.resolveRoot("package.json");
|
|
52
|
-
const pkgJson = await fs__default.default.readJson(pkgPath);
|
|
53
|
-
const parsed = pkgJsonWithNewConfigSchema.safeParse(pkgJson);
|
|
54
|
-
if (!parsed.success) {
|
|
55
|
-
throw new errors.ForwardedError(
|
|
56
|
-
`Failed to load templating configuration from '${pkgPath}'`,
|
|
57
|
-
v3.fromZodError(parsed.error)
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
const config = parsed.data.backstage?.cli?.new;
|
|
61
|
-
const basePath = path.dirname(pkgPath);
|
|
62
|
-
const templatePointerEntries = await Promise.all(
|
|
63
|
-
(config?.templates ?? defaultTemplates.defaultTemplates).map(async (rawPointer) => {
|
|
64
|
-
try {
|
|
65
|
-
const templatePath = resolveLocalTemplatePath(rawPointer, basePath);
|
|
66
|
-
const pointer = await peekLocalTemplateDefinition(templatePath);
|
|
67
|
-
return { pointer, rawPointer };
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw new errors.ForwardedError(
|
|
70
|
-
`Failed to load template definition '${rawPointer}'`,
|
|
71
|
-
error
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
const templateNameConflicts = /* @__PURE__ */ new Map();
|
|
77
|
-
for (const { pointer, rawPointer } of templatePointerEntries) {
|
|
78
|
-
const conflict = templateNameConflicts.get(pointer.name);
|
|
79
|
-
if (conflict) {
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Invalid template configuration, received conflicting template name '${pointer.name}' from '${conflict}' and '${rawPointer}'`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
templateNameConflicts.set(pointer.name, rawPointer);
|
|
85
|
-
}
|
|
86
|
-
const packageNamePrefix = overrides.packageNamePrefix ?? config?.globals?.namePrefix ?? defaults.packageNamePrefix;
|
|
87
|
-
const { packageNamePluginInfix } = computePackageNamePluginInfix(
|
|
88
|
-
packageNamePrefix,
|
|
89
|
-
overrides.packageNamePluginInfix ?? config?.globals?.namePluginInfix
|
|
90
|
-
);
|
|
91
|
-
return {
|
|
92
|
-
isUsingDefaultTemplates: !config?.templates,
|
|
93
|
-
templatePointers: templatePointerEntries.map(({ pointer }) => pointer),
|
|
94
|
-
license: overrides.license ?? config?.globals?.license ?? defaults.license,
|
|
95
|
-
version: overrides.version ?? config?.globals?.version ?? defaults.version,
|
|
96
|
-
private: overrides.private ?? config?.globals?.private ?? defaults.private,
|
|
97
|
-
publishRegistry: overrides.publishRegistry ?? config?.globals?.publishRegistry ?? defaults.publishRegistry,
|
|
98
|
-
packageNamePrefix,
|
|
99
|
-
packageNamePluginInfix
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function resolveLocalTemplatePath(pointer, basePath) {
|
|
103
|
-
if (path.isAbsolute(pointer)) {
|
|
104
|
-
throw new Error(`Template target may not be an absolute path`);
|
|
105
|
-
}
|
|
106
|
-
if (pointer.startsWith(".")) {
|
|
107
|
-
return path.resolve(basePath, pointer, types.TEMPLATE_FILE_NAME);
|
|
108
|
-
}
|
|
109
|
-
return require.resolve(`${pointer}/${types.TEMPLATE_FILE_NAME}`, {
|
|
110
|
-
paths: [basePath]
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
const partialTemplateDefinitionSchema = zod.z.object({
|
|
114
|
-
name: zod.z.string(),
|
|
115
|
-
description: zod.z.string().optional()
|
|
116
|
-
});
|
|
117
|
-
async function peekLocalTemplateDefinition(target) {
|
|
118
|
-
const content = await fs__default.default.readFile(target, "utf8");
|
|
119
|
-
const rawTemplate = yaml.parse(content);
|
|
120
|
-
const parsed = partialTemplateDefinitionSchema.safeParse(rawTemplate);
|
|
121
|
-
if (!parsed.success) {
|
|
122
|
-
throw v3.fromZodError(parsed.error);
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
name: parsed.data.name,
|
|
126
|
-
description: parsed.data.description,
|
|
127
|
-
target
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
exports.loadPortableTemplateConfig = loadPortableTemplateConfig;
|
|
132
|
-
//# sourceMappingURL=loadPortableTemplateConfig.cjs.js.map
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
|
|
5
|
-
function resolvePackageParams(options) {
|
|
6
|
-
const baseName = getBaseNameForRole(options.roleParams);
|
|
7
|
-
const isPlugin = options.roleParams.role.includes("plugin");
|
|
8
|
-
const pluginInfix = isPlugin ? options.pluginInfix : "";
|
|
9
|
-
return {
|
|
10
|
-
packageName: `${options.packagePrefix}${pluginInfix}${baseName}`,
|
|
11
|
-
packagePath: path.join(isPlugin ? "plugins" : "packages", baseName)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function getBaseNameForRole(roleParams) {
|
|
15
|
-
switch (roleParams.role) {
|
|
16
|
-
case "web-library":
|
|
17
|
-
case "node-library":
|
|
18
|
-
case "common-library":
|
|
19
|
-
return roleParams.name;
|
|
20
|
-
case "plugin-web-library":
|
|
21
|
-
return `${roleParams.pluginId}-react`;
|
|
22
|
-
case "plugin-node-library":
|
|
23
|
-
return `${roleParams.pluginId}-node`;
|
|
24
|
-
case "plugin-common-library":
|
|
25
|
-
return `${roleParams.pluginId}-common`;
|
|
26
|
-
case "frontend-plugin":
|
|
27
|
-
return `${roleParams.pluginId}`;
|
|
28
|
-
case "frontend-plugin-module":
|
|
29
|
-
return `${roleParams.pluginId}-module-${roleParams.moduleId}`;
|
|
30
|
-
case "backend-plugin":
|
|
31
|
-
return `${roleParams.pluginId}-backend`;
|
|
32
|
-
case "backend-plugin-module":
|
|
33
|
-
return `${roleParams.pluginId}-backend-module-${roleParams.moduleId}`;
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Unknown role ${roleParams.role}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.resolvePackageParams = resolvePackageParams;
|
|
40
|
-
//# sourceMappingURL=resolvePackageParams.cjs.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var inquirer = require('inquirer');
|
|
4
|
-
|
|
5
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
|
-
|
|
7
|
-
var inquirer__default = /*#__PURE__*/_interopDefaultCompat(inquirer);
|
|
8
|
-
|
|
9
|
-
async function selectTemplateInteractively(config, preselectedTemplateName) {
|
|
10
|
-
let selectedName = preselectedTemplateName;
|
|
11
|
-
if (config.isUsingDefaultTemplates && selectedName === "plugin") {
|
|
12
|
-
console.warn(
|
|
13
|
-
`DEPRECATION WARNING: The 'plugin' template is deprecated, use 'frontend-plugin' instead`
|
|
14
|
-
);
|
|
15
|
-
selectedName = "frontend-plugin";
|
|
16
|
-
}
|
|
17
|
-
if (!selectedName) {
|
|
18
|
-
const answers = await inquirer__default.default.prompt([
|
|
19
|
-
{
|
|
20
|
-
type: "list",
|
|
21
|
-
name: "name",
|
|
22
|
-
message: "What do you want to create?",
|
|
23
|
-
choices: config.templatePointers.map(
|
|
24
|
-
(t) => t.description ? { name: `${t.name} - ${t.description}`, value: t.name } : t.name
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
]);
|
|
28
|
-
selectedName = answers.name;
|
|
29
|
-
}
|
|
30
|
-
const template = config.templatePointers.find((t) => t.name === selectedName);
|
|
31
|
-
if (!template) {
|
|
32
|
-
throw new Error(`Template '${selectedName}' not found`);
|
|
33
|
-
}
|
|
34
|
-
return template;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.selectTemplateInteractively = selectTemplateInteractively;
|
|
38
|
-
//# sourceMappingURL=selectTemplateInteractively.cjs.js.map
|