@backstage/cli 0.28.0-next.1 → 0.28.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.
Files changed (157) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/config/jest.js +9 -1
  3. package/config/jestCacheResultProcessor.cjs +23 -0
  4. package/config/jestSwcTransform.js +4 -1
  5. package/dist/commands/build/buildBackend.cjs.js +65 -0
  6. package/dist/commands/build/buildFrontend.cjs.js +57 -0
  7. package/dist/commands/build/command.cjs.js +75 -0
  8. package/dist/commands/build/index.cjs.js +8 -0
  9. package/dist/commands/buildWorkspace.cjs.js +24 -0
  10. package/dist/commands/clean/clean.cjs.js +19 -0
  11. package/dist/{cjs/docs-BGyA6jwW.cjs.js → commands/config/docs.cjs.js} +4 -12
  12. package/dist/{cjs/print-Dd6aChXU.cjs.js → commands/config/print.cjs.js} +4 -12
  13. package/dist/{cjs/schema-D93FRhBL.cjs.js → commands/config/schema.cjs.js} +4 -12
  14. package/dist/commands/config/validate.cjs.js +19 -0
  15. package/dist/{cjs/index-j193pV_Y.cjs.js → commands/create-github-app/GithubCreateAppServer.cjs.js} +2 -110
  16. package/dist/commands/create-github-app/index.cjs.js +117 -0
  17. package/dist/commands/index.cjs.js +231 -0
  18. package/dist/{cjs/info-DuAv1Tsx.cjs.js → commands/info.cjs.js} +13 -17
  19. package/dist/{cjs/lint-BwiDJkjE.cjs.js → commands/lint.cjs.js} +10 -10
  20. package/dist/commands/migrate/packageExports.cjs.js +17 -0
  21. package/dist/{cjs/packageLintConfigs-DeUGBP17.cjs.js → commands/migrate/packageLintConfigs.cjs.js} +2 -10
  22. package/dist/{cjs/packageRole-Iuv9NRii.cjs.js → commands/migrate/packageRole.cjs.js} +5 -8
  23. package/dist/{cjs/packageScripts-DX6dilK6.cjs.js → commands/migrate/packageScripts.cjs.js} +1 -1
  24. package/dist/{cjs/reactRouterDeps-CR-hjviw.cjs.js → commands/migrate/reactRouterDeps.cjs.js} +1 -1
  25. package/dist/commands/new/new.cjs.js +101 -0
  26. package/dist/commands/pack.cjs.js +29 -0
  27. package/dist/commands/repo/build.cjs.js +113 -0
  28. package/dist/{cjs/clean-a6Q4k9Vm.cjs.js → commands/repo/clean.cjs.js} +5 -10
  29. package/dist/{cjs/fix-COitqgqm.cjs.js → commands/repo/fix.cjs.js} +8 -13
  30. package/dist/commands/repo/lint.cjs.js +205 -0
  31. package/dist/{cjs/list-deprecations-CtUaQgaP.cjs.js → commands/repo/list-deprecations.cjs.js} +7 -12
  32. package/dist/commands/repo/optionsParser.cjs.js +37 -0
  33. package/dist/commands/repo/test.cjs.js +277 -0
  34. package/dist/commands/start/command.cjs.js +48 -0
  35. package/dist/commands/start/index.cjs.js +8 -0
  36. package/dist/commands/start/startBackend.cjs.js +112 -0
  37. package/dist/commands/start/startFrontend.cjs.js +47 -0
  38. package/dist/{cjs/test-COxIko8N.cjs.js → commands/test.cjs.js} +6 -12
  39. package/dist/{cjs/bump-BHEh5ytx.cjs.js → commands/versions/bump.cjs.js} +21 -190
  40. package/dist/commands/versions/migrate.cjs.js +112 -0
  41. package/dist/index.cjs.js +29 -7
  42. package/dist/lib/builder/config.cjs.js +199 -0
  43. package/dist/lib/builder/packager.cjs.js +131 -0
  44. package/dist/lib/builder/plugins.cjs.js +71 -0
  45. package/dist/lib/builder/types.cjs.js +11 -0
  46. package/dist/lib/bundler/LinkedPackageResolvePlugin.cjs.js +47 -0
  47. package/dist/lib/bundler/backend.cjs.js +36 -0
  48. package/dist/{cjs/buildBackend-CkhZWCz1.cjs.js → lib/bundler/bundle.cjs.js} +31 -117
  49. package/dist/lib/bundler/config.cjs.js +491 -0
  50. package/dist/lib/bundler/hasReactDomClient.cjs.js +17 -0
  51. package/dist/lib/bundler/moduleFederation.cjs.js +28 -0
  52. package/dist/lib/bundler/optimization.cjs.js +67 -0
  53. package/dist/lib/bundler/packageDetection.cjs.js +117 -0
  54. package/dist/lib/bundler/paths.cjs.js +60 -0
  55. package/dist/lib/bundler/server.cjs.js +286 -0
  56. package/dist/lib/bundler/transforms.cjs.js +172 -0
  57. package/dist/lib/codeowners/codeowners.cjs.js +92 -0
  58. package/dist/{cjs/config-DBpmZirN.cjs.js → lib/config.cjs.js} +6 -6
  59. package/dist/{cjs/entryPoints-coip0t-x.cjs.js → lib/entryPoints.cjs.js} +1 -1
  60. package/dist/lib/errors.cjs.js +45 -0
  61. package/dist/lib/experimental/IpcServer.cjs.js +60 -0
  62. package/dist/lib/experimental/ServerDataStore.cjs.js +36 -0
  63. package/dist/lib/experimental/startBackendExperimental.cjs.js +128 -0
  64. package/dist/lib/new/FactoryRegistry.cjs.js +96 -0
  65. package/dist/lib/new/factories/backendModule.cjs.js +82 -0
  66. package/dist/lib/new/factories/backendPlugin.cjs.js +78 -0
  67. package/dist/lib/new/factories/common/prompts.cjs.js +57 -0
  68. package/dist/lib/new/factories/common/tasks.cjs.js +66 -0
  69. package/dist/lib/new/factories/common/util.cjs.js +16 -0
  70. package/dist/lib/new/factories/frontendPlugin.cjs.js +107 -0
  71. package/dist/lib/new/factories/index.cjs.js +24 -0
  72. package/dist/lib/new/factories/nodeLibraryPackage.cjs.js +57 -0
  73. package/dist/lib/new/factories/pluginCommon.cjs.js +58 -0
  74. package/dist/lib/new/factories/pluginNode.cjs.js +58 -0
  75. package/dist/lib/new/factories/pluginWeb.cjs.js +58 -0
  76. package/dist/lib/new/factories/scaffolderModule.cjs.js +90 -0
  77. package/dist/lib/new/factories/webLibraryPackage.cjs.js +57 -0
  78. package/dist/lib/new/types.cjs.js +8 -0
  79. package/dist/lib/packager/createDistWorkspace.cjs.js +219 -0
  80. package/dist/{cjs/productionPack-BxoMbBkH.cjs.js → lib/packager/productionPack.cjs.js} +8 -96
  81. package/dist/{cjs/parallel-BszNaKyc.cjs.js → lib/parallel.cjs.js} +2 -1
  82. package/dist/lib/paths.cjs.js +8 -0
  83. package/dist/{cjs/publishing-DQtsKTbc.cjs.js → lib/publishing.cjs.js} +1 -1
  84. package/dist/{cjs/role-BjiBExhi.cjs.js → lib/role.cjs.js} +3 -3
  85. package/dist/{cjs/run-CpZGNJQr.cjs.js → lib/run.cjs.js} +6 -5
  86. package/dist/{cjs/svgrTemplate-BTjBQ3by.cjs.js → lib/svgrTemplate.cjs.js} +1 -1
  87. package/dist/lib/tasks.cjs.js +188 -0
  88. package/dist/lib/typeDistProject.cjs.js +94 -0
  89. package/dist/lib/urls.cjs.js +13 -0
  90. package/dist/lib/version.cjs.js +94 -0
  91. package/dist/{cjs/yarn-6FNAgNBK.cjs.js → lib/versioning/Lockfile.cjs.js} +1 -31
  92. package/dist/lib/versioning/packages.cjs.js +75 -0
  93. package/dist/lib/yarn.cjs.js +34 -0
  94. package/dist/packages/backend-defaults/package.json.cjs.js +6 -0
  95. package/dist/packages/backend-plugin-api/package.json.cjs.js +6 -0
  96. package/dist/packages/backend-test-utils/package.json.cjs.js +6 -0
  97. package/dist/packages/catalog-client/package.json.cjs.js +6 -0
  98. package/dist/packages/cli/package.json.cjs.js +171 -0
  99. package/dist/packages/config/package.json.cjs.js +6 -0
  100. package/dist/packages/core-app-api/package.json.cjs.js +6 -0
  101. package/dist/packages/core-components/package.json.cjs.js +6 -0
  102. package/dist/packages/core-plugin-api/package.json.cjs.js +6 -0
  103. package/dist/packages/dev-utils/package.json.cjs.js +6 -0
  104. package/dist/packages/errors/package.json.cjs.js +6 -0
  105. package/dist/packages/test-utils/package.json.cjs.js +6 -0
  106. package/dist/packages/theme/package.json.cjs.js +6 -0
  107. package/dist/plugins/auth-backend/package.json.cjs.js +6 -0
  108. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +6 -0
  109. package/dist/plugins/catalog-node/package.json.cjs.js +6 -0
  110. package/dist/plugins/scaffolder-node/package.json.cjs.js +6 -0
  111. package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +6 -0
  112. package/package.json +55 -25
  113. package/templates/default-backend-plugin/README.md.hbs +22 -8
  114. package/templates/default-backend-plugin/dev/index.ts.hbs +60 -0
  115. package/templates/default-backend-plugin/package.json.hbs +5 -5
  116. package/templates/default-backend-plugin/src/index.ts.hbs +0 -1
  117. package/templates/default-backend-plugin/src/plugin.test.ts.hbs +85 -0
  118. package/templates/default-backend-plugin/src/plugin.ts.hbs +16 -14
  119. package/templates/default-backend-plugin/src/router.test.ts +67 -0
  120. package/templates/default-backend-plugin/src/router.ts +51 -0
  121. package/templates/default-backend-plugin/src/services/TodoListService/createTodoListService.ts +100 -0
  122. package/templates/default-backend-plugin/src/services/TodoListService/index.ts +1 -0
  123. package/templates/default-backend-plugin/src/services/TodoListService/types.ts +27 -0
  124. package/templates/scaffolder-module/package.json.hbs +3 -1
  125. package/templates/scaffolder-module/src/actions/example.test.ts +24 -0
  126. package/templates/scaffolder-module/src/actions/{example/example.ts → example.ts} +7 -3
  127. package/templates/scaffolder-module/src/index.ts.hbs +1 -1
  128. package/templates/scaffolder-module/src/{actions/example/module.ts → module.ts} +3 -3
  129. package/dist/cjs/build-CQdcGuBr.cjs.js +0 -194
  130. package/dist/cjs/buildWorkspace-CZPp9oRm.cjs.js +0 -53
  131. package/dist/cjs/clean-W6nxsHeK.cjs.js +0 -22
  132. package/dist/cjs/createDistWorkspace-DdHPGSMS.cjs.js +0 -576
  133. package/dist/cjs/index-BXv4Xa2e.cjs.js +0 -625
  134. package/dist/cjs/index-CGuAP7nv.cjs.js +0 -131
  135. package/dist/cjs/index-b1ouG3q6.cjs.js +0 -518
  136. package/dist/cjs/lint-Dsiocf9K.cjs.js +0 -91
  137. package/dist/cjs/moduleFederation-DmStnvEg.cjs.js +0 -910
  138. package/dist/cjs/new-CEnFhTT-.cjs.js +0 -1043
  139. package/dist/cjs/pack-XLRcGJqH.cjs.js +0 -34
  140. package/dist/cjs/packageExports-BJBwdvUH.cjs.js +0 -27
  141. package/dist/cjs/test-JcLI2pPM.cjs.js +0 -126
  142. package/dist/cjs/validate-CELljsEX.cjs.js +0 -28
  143. package/templates/default-backend-plugin/dev/index.ts +0 -9
  144. package/templates/default-backend-plugin/src/service/router.test.ts +0 -30
  145. package/templates/default-backend-plugin/src/service/router.ts +0 -28
  146. package/templates/scaffolder-module/src/actions/example/example.test.ts +0 -32
  147. package/templates/scaffolder-module/src/actions/example/index.ts +0 -7
  148. package/templates/scaffolder-module/src/actions/index.ts +0 -1
  149. /package/templates/default-backend-module/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  150. /package/templates/default-backend-plugin/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  151. /package/templates/default-common-plugin-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  152. /package/templates/default-node-plugin-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  153. /package/templates/default-plugin/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  154. /package/templates/default-react-plugin-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  155. /package/templates/node-library-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  156. /package/templates/scaffolder-module/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
  157. /package/templates/web-library-package/{.eslintrc.js → .eslintrc.js.hbs} +0 -0
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var codeowners = require('../../../codeowners/codeowners.cjs.js');
4
+
5
+ function pluginIdPrompt() {
6
+ return {
7
+ type: "input",
8
+ name: "id",
9
+ message: "Enter the ID of the plugin [required]",
10
+ validate: (value) => {
11
+ if (!value) {
12
+ return "Please enter the ID of the plugin";
13
+ } else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {
14
+ return "Plugin IDs must be lowercase and contain only letters, digits, and dashes.";
15
+ }
16
+ return true;
17
+ }
18
+ };
19
+ }
20
+ function moduleIdIdPrompt() {
21
+ return {
22
+ type: "input",
23
+ name: "moduleId",
24
+ message: "Enter the ID of the module [required]",
25
+ validate: (value) => {
26
+ if (!value) {
27
+ return "Please enter the ID of the module";
28
+ } else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {
29
+ return "Module IDs must be lowercase and contain only letters, digits, and dashes.";
30
+ }
31
+ return true;
32
+ }
33
+ };
34
+ }
35
+ function ownerPrompt() {
36
+ return {
37
+ type: "input",
38
+ name: "owner",
39
+ message: "Enter an owner to add to CODEOWNERS [optional]",
40
+ when: (opts) => Boolean(opts.codeOwnersPath),
41
+ validate: (value) => {
42
+ if (!value) {
43
+ return true;
44
+ }
45
+ const ownerIds = codeowners.parseOwnerIds(value);
46
+ if (!ownerIds) {
47
+ 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).";
48
+ }
49
+ return true;
50
+ }
51
+ };
52
+ }
53
+
54
+ exports.moduleIdIdPrompt = moduleIdIdPrompt;
55
+ exports.ownerPrompt = ownerPrompt;
56
+ exports.pluginIdPrompt = pluginIdPrompt;
57
+ //# sourceMappingURL=prompts.cjs.js.map
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var chalk = require('chalk');
5
+ var path = require('path');
6
+ var paths = require('../../../paths.cjs.js');
7
+ var tasks = require('../../../tasks.cjs.js');
8
+ var Lockfile = require('../../../versioning/Lockfile.cjs.js');
9
+ require('minimatch');
10
+ require('@manypkg/get-packages');
11
+ require('../../../yarn.cjs.js');
12
+ require('../../../run.cjs.js');
13
+ var version = require('../../../version.cjs.js');
14
+
15
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
16
+
17
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
18
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
19
+
20
+ async function executePluginPackageTemplate(ctx, options) {
21
+ const { targetDir } = options;
22
+ let lockfile;
23
+ try {
24
+ lockfile = await Lockfile.Lockfile.load(paths.paths.resolveTargetRoot("yarn.lock"));
25
+ } catch {
26
+ }
27
+ tasks.Task.section("Checking Prerequisites");
28
+ const shortPluginDir = path.relative(paths.paths.targetRoot, targetDir);
29
+ await tasks.Task.forItem("availability", shortPluginDir, async () => {
30
+ if (await fs__default.default.pathExists(targetDir)) {
31
+ throw new Error(
32
+ `A package with the same plugin ID already exists at ${chalk__default.default.cyan(
33
+ shortPluginDir
34
+ )}. Please try again with a different ID.`
35
+ );
36
+ }
37
+ });
38
+ const tempDir = await tasks.Task.forItem("creating", "temp dir", async () => {
39
+ return await ctx.createTemporaryDirectory("backstage-create");
40
+ });
41
+ tasks.Task.section("Executing Template");
42
+ await tasks.templatingTask(
43
+ paths.paths.resolveOwn("templates", options.templateName),
44
+ tempDir,
45
+ options.values,
46
+ version.createPackageVersionProvider(lockfile),
47
+ ctx.isMonoRepo
48
+ );
49
+ const pkgJsonPath = path.resolve(tempDir, "package.json");
50
+ if (await fs__default.default.pathExists(pkgJsonPath)) {
51
+ const pkgJson = await fs__default.default.readJson(pkgJsonPath);
52
+ await fs__default.default.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
53
+ }
54
+ tasks.Task.section("Installing");
55
+ await tasks.Task.forItem("moving", shortPluginDir, async () => {
56
+ await fs__default.default.move(tempDir, targetDir).catch((error) => {
57
+ throw new Error(
58
+ `Failed to move package from ${tempDir} to ${targetDir}, ${error.message}`
59
+ );
60
+ });
61
+ });
62
+ ctx.markAsModified();
63
+ }
64
+
65
+ exports.executePluginPackageTemplate = executePluginPackageTemplate;
66
+ //# sourceMappingURL=tasks.cjs.js.map
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const resolvePackageName = (options) => {
4
+ const { baseName, scope, plugin } = options;
5
+ if (scope) {
6
+ if (plugin) {
7
+ const pluginName = scope.startsWith("backstage") ? "plugin" : "backstage-plugin";
8
+ return scope.includes("/") ? `@${scope}${pluginName}-${baseName}` : `@${scope}/${pluginName}-${baseName}`;
9
+ }
10
+ return scope.includes("/") ? `@${scope}${baseName}` : `@${scope}/${baseName}`;
11
+ }
12
+ return plugin ? `backstage-plugin-${baseName}` : baseName;
13
+ };
14
+
15
+ exports.resolvePackageName = resolvePackageName;
16
+ //# sourceMappingURL=util.cjs.js.map
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var chalk = require('chalk');
5
+ var camelCase = require('lodash/camelCase');
6
+ var upperFirst = require('lodash/upperFirst');
7
+ var paths = require('../../paths.cjs.js');
8
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
9
+ var types = require('../types.cjs.js');
10
+ var tasks = require('../../tasks.cjs.js');
11
+ var prompts = require('./common/prompts.cjs.js');
12
+ var tasks$1 = require('./common/tasks.cjs.js');
13
+ var util = require('./common/util.cjs.js');
14
+
15
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
16
+
17
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
18
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
19
+ var camelCase__default = /*#__PURE__*/_interopDefaultCompat(camelCase);
20
+ var upperFirst__default = /*#__PURE__*/_interopDefaultCompat(upperFirst);
21
+
22
+ const frontendPlugin = types.createFactory({
23
+ name: "plugin",
24
+ description: "A new frontend plugin",
25
+ optionsDiscovery: async () => ({
26
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
27
+ }),
28
+ optionsPrompts: [prompts.pluginIdPrompt(), prompts.ownerPrompt()],
29
+ async create(options, ctx) {
30
+ const { id } = options;
31
+ const name = util.resolvePackageName({
32
+ baseName: id,
33
+ scope: ctx.scope,
34
+ plugin: true
35
+ });
36
+ const extensionName = `${upperFirst__default.default(camelCase__default.default(id))}Page`;
37
+ tasks.Task.log();
38
+ tasks.Task.log(`Creating frontend plugin ${chalk__default.default.cyan(name)}`);
39
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("plugins", id) : paths.paths.resolveTargetRoot(`backstage-plugin-${id}`);
40
+ await tasks$1.executePluginPackageTemplate(ctx, {
41
+ targetDir,
42
+ templateName: "default-plugin",
43
+ values: {
44
+ id,
45
+ name,
46
+ extensionName,
47
+ pluginVar: `${camelCase__default.default(id)}Plugin`,
48
+ pluginVersion: ctx.defaultVersion,
49
+ privatePackage: ctx.private,
50
+ npmRegistry: ctx.npmRegistry,
51
+ license: ctx.license
52
+ }
53
+ });
54
+ if (await fs__default.default.pathExists(paths.paths.resolveTargetRoot("packages/app"))) {
55
+ await tasks.Task.forItem("app", "adding dependency", async () => {
56
+ await tasks.addPackageDependency(
57
+ paths.paths.resolveTargetRoot("packages/app/package.json"),
58
+ {
59
+ dependencies: {
60
+ [name]: `^${ctx.defaultVersion}`
61
+ }
62
+ }
63
+ );
64
+ });
65
+ await tasks.Task.forItem("app", "adding import", async () => {
66
+ const pluginsFilePath = paths.paths.resolveTargetRoot(
67
+ "packages/app/src/App.tsx"
68
+ );
69
+ if (!await fs__default.default.pathExists(pluginsFilePath)) {
70
+ return;
71
+ }
72
+ const content = await fs__default.default.readFile(pluginsFilePath, "utf8");
73
+ const revLines = content.split("\n").reverse();
74
+ const lastImportIndex = revLines.findIndex(
75
+ (line) => line.match(/ from ("|').*("|')/)
76
+ );
77
+ const lastRouteIndex = revLines.findIndex(
78
+ (line) => line.match(/<\/FlatRoutes/)
79
+ );
80
+ if (lastImportIndex !== -1 && lastRouteIndex !== -1) {
81
+ const importLine = `import { ${extensionName} } from '${name}';`;
82
+ if (!content.includes(importLine)) {
83
+ revLines.splice(lastImportIndex, 0, importLine);
84
+ }
85
+ const componentLine = `<Route path="/${id}" element={<${extensionName} />} />`;
86
+ if (!content.includes(componentLine)) {
87
+ const [indentation] = revLines[lastRouteIndex + 1].match(/^\s*/) ?? [];
88
+ revLines.splice(lastRouteIndex + 1, 0, indentation + componentLine);
89
+ }
90
+ const newContent = revLines.reverse().join("\n");
91
+ await fs__default.default.writeFile(pluginsFilePath, newContent, "utf8");
92
+ }
93
+ });
94
+ }
95
+ if (options.owner) {
96
+ await codeowners.addCodeownersEntry(`/plugins/${id}`, options.owner);
97
+ }
98
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
99
+ await tasks.Task.forCommand("yarn lint --fix", {
100
+ cwd: targetDir,
101
+ optional: true
102
+ });
103
+ }
104
+ });
105
+
106
+ exports.frontendPlugin = frontendPlugin;
107
+ //# sourceMappingURL=frontendPlugin.cjs.js.map
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var frontendPlugin = require('./frontendPlugin.cjs.js');
4
+ var backendPlugin = require('./backendPlugin.cjs.js');
5
+ var backendModule = require('./backendModule.cjs.js');
6
+ var nodeLibraryPackage = require('./nodeLibraryPackage.cjs.js');
7
+ var webLibraryPackage = require('./webLibraryPackage.cjs.js');
8
+ var pluginCommon = require('./pluginCommon.cjs.js');
9
+ var pluginNode = require('./pluginNode.cjs.js');
10
+ var pluginWeb = require('./pluginWeb.cjs.js');
11
+ var scaffolderModule = require('./scaffolderModule.cjs.js');
12
+
13
+
14
+
15
+ exports.frontendPlugin = frontendPlugin.frontendPlugin;
16
+ exports.backendPlugin = backendPlugin.backendPlugin;
17
+ exports.backendModule = backendModule.backendModule;
18
+ exports.nodeLibraryPackage = nodeLibraryPackage.nodeLibraryPackage;
19
+ exports.webLibraryPackage = webLibraryPackage.webLibraryPackage;
20
+ exports.pluginCommon = pluginCommon.pluginCommon;
21
+ exports.pluginNode = pluginNode.pluginNode;
22
+ exports.pluginWeb = pluginWeb.pluginWeb;
23
+ exports.scaffolderModule = scaffolderModule.scaffolderModule;
24
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var paths = require('../../paths.cjs.js');
5
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
6
+ var types = require('../types.cjs.js');
7
+ var tasks = require('../../tasks.cjs.js');
8
+ var prompts = require('./common/prompts.cjs.js');
9
+ var tasks$1 = require('./common/tasks.cjs.js');
10
+ var util = require('./common/util.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
15
+
16
+ const nodeLibraryPackage = types.createFactory({
17
+ name: "node-library",
18
+ description: "A new node-library package, exporting shared functionality for backend plugins and modules",
19
+ optionsDiscovery: async () => ({
20
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
21
+ }),
22
+ optionsPrompts: [prompts.pluginIdPrompt(), prompts.ownerPrompt()],
23
+ async create(options, ctx) {
24
+ const { id } = options;
25
+ const name = util.resolvePackageName({
26
+ baseName: id,
27
+ scope: ctx.scope,
28
+ plugin: false
29
+ });
30
+ tasks.Task.log();
31
+ tasks.Task.log(`Creating node-library package ${chalk__default.default.cyan(name)}`);
32
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("packages", id) : paths.paths.resolveTargetRoot(`${id}`);
33
+ await tasks$1.executePluginPackageTemplate(ctx, {
34
+ targetDir,
35
+ templateName: "node-library-package",
36
+ values: {
37
+ id,
38
+ name,
39
+ pluginVersion: ctx.defaultVersion,
40
+ privatePackage: ctx.private,
41
+ npmRegistry: ctx.npmRegistry,
42
+ license: ctx.license
43
+ }
44
+ });
45
+ if (options.owner) {
46
+ await codeowners.addCodeownersEntry(`/packages/${id}`, options.owner);
47
+ }
48
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
49
+ await tasks.Task.forCommand("yarn lint --fix", {
50
+ cwd: targetDir,
51
+ optional: true
52
+ });
53
+ }
54
+ });
55
+
56
+ exports.nodeLibraryPackage = nodeLibraryPackage;
57
+ //# sourceMappingURL=nodeLibraryPackage.cjs.js.map
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var paths = require('../../paths.cjs.js');
5
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
6
+ var types = require('../types.cjs.js');
7
+ var tasks = require('../../tasks.cjs.js');
8
+ var prompts = require('./common/prompts.cjs.js');
9
+ var tasks$1 = require('./common/tasks.cjs.js');
10
+ var util = require('./common/util.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
15
+
16
+ const pluginCommon = types.createFactory({
17
+ name: "plugin-common",
18
+ description: "A new isomorphic common plugin package",
19
+ optionsDiscovery: async () => ({
20
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
21
+ }),
22
+ optionsPrompts: [prompts.pluginIdPrompt(), prompts.ownerPrompt()],
23
+ async create(options, ctx) {
24
+ const { id } = options;
25
+ const suffix = `${id}-common`;
26
+ const name = util.resolvePackageName({
27
+ baseName: suffix,
28
+ scope: ctx.scope,
29
+ plugin: true
30
+ });
31
+ tasks.Task.log();
32
+ tasks.Task.log(`Creating common plugin package ${chalk__default.default.cyan(name)}`);
33
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("plugins", suffix) : paths.paths.resolveTargetRoot(`backstage-plugin-${suffix}`);
34
+ await tasks$1.executePluginPackageTemplate(ctx, {
35
+ targetDir,
36
+ templateName: "default-common-plugin-package",
37
+ values: {
38
+ id,
39
+ name,
40
+ privatePackage: ctx.private,
41
+ npmRegistry: ctx.npmRegistry,
42
+ pluginVersion: ctx.defaultVersion,
43
+ license: ctx.license
44
+ }
45
+ });
46
+ if (options.owner) {
47
+ await codeowners.addCodeownersEntry(`/plugins/${suffix}`, options.owner);
48
+ }
49
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
50
+ await tasks.Task.forCommand("yarn lint --fix", {
51
+ cwd: targetDir,
52
+ optional: true
53
+ });
54
+ }
55
+ });
56
+
57
+ exports.pluginCommon = pluginCommon;
58
+ //# sourceMappingURL=pluginCommon.cjs.js.map
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var paths = require('../../paths.cjs.js');
5
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
6
+ var types = require('../types.cjs.js');
7
+ var tasks = require('../../tasks.cjs.js');
8
+ var prompts = require('./common/prompts.cjs.js');
9
+ var tasks$1 = require('./common/tasks.cjs.js');
10
+ var util = require('./common/util.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
15
+
16
+ const pluginNode = types.createFactory({
17
+ name: "plugin-node",
18
+ description: "A new Node.js library plugin package",
19
+ optionsDiscovery: async () => ({
20
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
21
+ }),
22
+ optionsPrompts: [prompts.pluginIdPrompt(), prompts.ownerPrompt()],
23
+ async create(options, ctx) {
24
+ const { id } = options;
25
+ const suffix = `${id}-node`;
26
+ const name = util.resolvePackageName({
27
+ baseName: suffix,
28
+ scope: ctx.scope,
29
+ plugin: true
30
+ });
31
+ tasks.Task.log();
32
+ tasks.Task.log(`Creating Node.js plugin library ${chalk__default.default.cyan(name)}`);
33
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("plugins", suffix) : paths.paths.resolveTargetRoot(`backstage-plugin-${suffix}`);
34
+ await tasks$1.executePluginPackageTemplate(ctx, {
35
+ targetDir,
36
+ templateName: "default-node-plugin-package",
37
+ values: {
38
+ id,
39
+ name,
40
+ privatePackage: ctx.private,
41
+ npmRegistry: ctx.npmRegistry,
42
+ pluginVersion: ctx.defaultVersion,
43
+ license: ctx.license
44
+ }
45
+ });
46
+ if (options.owner) {
47
+ await codeowners.addCodeownersEntry(`/plugins/${suffix}`, options.owner);
48
+ }
49
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
50
+ await tasks.Task.forCommand("yarn lint --fix", {
51
+ cwd: targetDir,
52
+ optional: true
53
+ });
54
+ }
55
+ });
56
+
57
+ exports.pluginNode = pluginNode;
58
+ //# sourceMappingURL=pluginNode.cjs.js.map
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var paths = require('../../paths.cjs.js');
5
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
6
+ var types = require('../types.cjs.js');
7
+ var tasks = require('../../tasks.cjs.js');
8
+ var prompts = require('./common/prompts.cjs.js');
9
+ var tasks$1 = require('./common/tasks.cjs.js');
10
+ var util = require('./common/util.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
15
+
16
+ const pluginWeb = types.createFactory({
17
+ name: "plugin-react",
18
+ description: "A new web library plugin package",
19
+ optionsDiscovery: async () => ({
20
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
21
+ }),
22
+ optionsPrompts: [prompts.pluginIdPrompt(), prompts.ownerPrompt()],
23
+ async create(options, ctx) {
24
+ const { id } = options;
25
+ const suffix = `${id}-react`;
26
+ const name = util.resolvePackageName({
27
+ baseName: suffix,
28
+ scope: ctx.scope,
29
+ plugin: true
30
+ });
31
+ tasks.Task.log();
32
+ tasks.Task.log(`Creating web plugin library ${chalk__default.default.cyan(name)}`);
33
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("plugins", suffix) : paths.paths.resolveTargetRoot(`backstage-plugin-${suffix}`);
34
+ await tasks$1.executePluginPackageTemplate(ctx, {
35
+ targetDir,
36
+ templateName: "default-react-plugin-package",
37
+ values: {
38
+ id,
39
+ name,
40
+ privatePackage: ctx.private,
41
+ npmRegistry: ctx.npmRegistry,
42
+ pluginVersion: ctx.defaultVersion,
43
+ license: ctx.license
44
+ }
45
+ });
46
+ if (options.owner) {
47
+ await codeowners.addCodeownersEntry(`/plugins/${suffix}`, options.owner);
48
+ }
49
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
50
+ await tasks.Task.forCommand("yarn lint --fix", {
51
+ cwd: targetDir,
52
+ optional: true
53
+ });
54
+ }
55
+ });
56
+
57
+ exports.pluginWeb = pluginWeb;
58
+ //# sourceMappingURL=pluginWeb.cjs.js.map
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var chalk = require('chalk');
5
+ var paths = require('../../paths.cjs.js');
6
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
7
+ var types = require('../types.cjs.js');
8
+ var tasks = require('../../tasks.cjs.js');
9
+ var prompts = require('./common/prompts.cjs.js');
10
+ var tasks$1 = require('./common/tasks.cjs.js');
11
+ var util = require('./common/util.cjs.js');
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 chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
17
+
18
+ const scaffolderModule = types.createFactory({
19
+ name: "scaffolder-module",
20
+ description: "An module exporting custom actions for @backstage/plugin-scaffolder-backend",
21
+ optionsDiscovery: async () => ({
22
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
23
+ }),
24
+ optionsPrompts: [
25
+ {
26
+ type: "input",
27
+ name: "id",
28
+ message: "Enter the name of the module [required]",
29
+ validate: (value) => {
30
+ if (!value) {
31
+ return "Please enter the name of the module";
32
+ } else if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)) {
33
+ return "Module names must be lowercase and contain only letters, digits, and dashes.";
34
+ }
35
+ return true;
36
+ }
37
+ },
38
+ prompts.ownerPrompt()
39
+ ],
40
+ async create(options, ctx) {
41
+ const { id } = options;
42
+ const slug = `scaffolder-backend-module-${id}`;
43
+ const name = util.resolvePackageName({
44
+ baseName: slug,
45
+ scope: ctx.scope,
46
+ plugin: true
47
+ });
48
+ tasks.Task.log();
49
+ tasks.Task.log(`Creating module ${chalk__default.default.cyan(name)}`);
50
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("plugins", slug) : paths.paths.resolveTargetRoot(`backstage-plugin-${slug}`);
51
+ await tasks$1.executePluginPackageTemplate(ctx, {
52
+ targetDir,
53
+ templateName: "scaffolder-module",
54
+ values: {
55
+ id,
56
+ name,
57
+ privatePackage: ctx.private,
58
+ npmRegistry: ctx.npmRegistry,
59
+ pluginVersion: ctx.defaultVersion,
60
+ license: ctx.license
61
+ }
62
+ });
63
+ if (await fs__default.default.pathExists(paths.paths.resolveTargetRoot("packages/backend"))) {
64
+ await tasks.Task.forItem("backend", "adding dependency", async () => {
65
+ await tasks.addPackageDependency(
66
+ paths.paths.resolveTargetRoot("packages/backend/package.json"),
67
+ {
68
+ dependencies: {
69
+ [name]: `^${ctx.defaultVersion}`
70
+ }
71
+ }
72
+ );
73
+ });
74
+ }
75
+ await tasks.addToBackend(name, {
76
+ type: "module"
77
+ });
78
+ if (options.owner) {
79
+ await codeowners.addCodeownersEntry(`/plugins/${slug}`, options.owner);
80
+ }
81
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
82
+ await tasks.Task.forCommand("yarn lint --fix", {
83
+ cwd: targetDir,
84
+ optional: true
85
+ });
86
+ }
87
+ });
88
+
89
+ exports.scaffolderModule = scaffolderModule;
90
+ //# sourceMappingURL=scaffolderModule.cjs.js.map
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var paths = require('../../paths.cjs.js');
5
+ var codeowners = require('../../codeowners/codeowners.cjs.js');
6
+ var types = require('../types.cjs.js');
7
+ var tasks = require('../../tasks.cjs.js');
8
+ var prompts = require('./common/prompts.cjs.js');
9
+ var tasks$1 = require('./common/tasks.cjs.js');
10
+ var util = require('./common/util.cjs.js');
11
+
12
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
+
14
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
15
+
16
+ const webLibraryPackage = types.createFactory({
17
+ name: "web-library",
18
+ description: "A new web-library package, exporting shared functionality for frontend plugins",
19
+ optionsDiscovery: async () => ({
20
+ codeOwnersPath: await codeowners.getCodeownersFilePath(paths.paths.targetRoot)
21
+ }),
22
+ optionsPrompts: [prompts.pluginIdPrompt(), prompts.ownerPrompt()],
23
+ async create(options, ctx) {
24
+ const { id } = options;
25
+ const name = util.resolvePackageName({
26
+ baseName: id,
27
+ scope: ctx.scope,
28
+ plugin: false
29
+ });
30
+ tasks.Task.log();
31
+ tasks.Task.log(`Creating web-library package ${chalk__default.default.cyan(name)}`);
32
+ const targetDir = ctx.isMonoRepo ? paths.paths.resolveTargetRoot("packages", id) : paths.paths.resolveTargetRoot(`${id}`);
33
+ await tasks$1.executePluginPackageTemplate(ctx, {
34
+ targetDir,
35
+ templateName: "web-library-package",
36
+ values: {
37
+ id,
38
+ name,
39
+ pluginVersion: ctx.defaultVersion,
40
+ privatePackage: ctx.private,
41
+ npmRegistry: ctx.npmRegistry,
42
+ license: ctx.license
43
+ }
44
+ });
45
+ if (options.owner) {
46
+ await codeowners.addCodeownersEntry(`/packages/${id}`, options.owner);
47
+ }
48
+ await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
49
+ await tasks.Task.forCommand("yarn lint --fix", {
50
+ cwd: targetDir,
51
+ optional: true
52
+ });
53
+ }
54
+ });
55
+
56
+ exports.webLibraryPackage = webLibraryPackage;
57
+ //# sourceMappingURL=webLibraryPackage.cjs.js.map
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ function createFactory(config) {
4
+ return config;
5
+ }
6
+
7
+ exports.createFactory = createFactory;
8
+ //# sourceMappingURL=types.cjs.js.map