@backstage/cli 0.27.1 → 0.28.0-next.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 (45) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/{build-D9YZ-dyI.cjs.js → build-gNEKjjhr.cjs.js} +9 -8
  3. package/dist/cjs/{buildBackend-CmtimF8a.cjs.js → buildBackend-DXvz7jvh.cjs.js} +6 -6
  4. package/dist/cjs/{buildWorkspace-C4wCq5WM.cjs.js → buildWorkspace-DLfI3EjD.cjs.js} +6 -5
  5. package/dist/cjs/{bump-BQ6YRL6D.cjs.js → bump-d9dS56p9.cjs.js} +73 -9
  6. package/dist/cjs/{clean-BllZTky1.cjs.js → clean-Dpgqc3P2.cjs.js} +2 -2
  7. package/dist/cjs/{clean-CVl--Ec9.cjs.js → clean-bdpRw-oZ.cjs.js} +2 -2
  8. package/dist/cjs/{config-BMsjTUVf.cjs.js → config-nCB2LQK-.cjs.js} +2 -2
  9. package/dist/cjs/{createDistWorkspace-DxOWPD6z.cjs.js → createDistWorkspace-DKzy-L-f.cjs.js} +7 -5
  10. package/dist/cjs/{docs-DPzCP6Jp.cjs.js → docs-CDE82fWG.cjs.js} +3 -3
  11. package/dist/cjs/{fix-BM8I_DZ2.cjs.js → fix-BTjof5XT.cjs.js} +2 -2
  12. package/dist/cjs/{index-CXG8-26G.cjs.js → index-7LxfekFu.cjs.js} +14 -11
  13. package/dist/cjs/{index-BgEQ8aeF.cjs.js → index-DVDDx3pk.cjs.js} +2 -2
  14. package/dist/cjs/{index-Cw0lUK20.cjs.js → index-DsP5wbju.cjs.js} +10 -9
  15. package/dist/cjs/{index-DmUbBCFk.cjs.js → index-v57xnvgT.cjs.js} +61 -79
  16. package/dist/cjs/{info-FKrzx-9W.cjs.js → info-CB7ln5K_.cjs.js} +5 -6
  17. package/dist/cjs/{lint-6vrbdjyg.cjs.js → lint-6_0f9f26.cjs.js} +2 -2
  18. package/dist/cjs/{lint-Cm_9pg85.cjs.js → lint-DYO_SeK3.cjs.js} +2 -2
  19. package/dist/cjs/{list-deprecations-C6R3rEyS.cjs.js → list-deprecations-DFgQENam.cjs.js} +2 -2
  20. package/dist/cjs/{moduleFederation-8XXecxLD.cjs.js → moduleFederation-Dq0n1quT.cjs.js} +3 -3
  21. package/dist/cjs/{new-DJUBFwiF.cjs.js → new-C0D_k25O.cjs.js} +336 -97
  22. package/dist/cjs/{pack-BqFGqZb5.cjs.js → pack-D8AK7Uem.cjs.js} +4 -3
  23. package/dist/cjs/{packageExports-DvjdOWjC.cjs.js → packageExports-bg4mFuFZ.cjs.js} +3 -3
  24. package/dist/cjs/{packageLintConfigs-DGkvTpBd.cjs.js → packageLintConfigs-BBvQehRd.cjs.js} +3 -3
  25. package/dist/cjs/{packageRole-CHz7zkIQ.cjs.js → packageRole-CkpKfhJA.cjs.js} +2 -2
  26. package/dist/cjs/{print-CQU7JzAh.cjs.js → print-BX8-7Nzg.cjs.js} +3 -3
  27. package/dist/cjs/{productionPack-BWU8WkGs.cjs.js → productionPack-Dfl28j3c.cjs.js} +105 -4
  28. package/dist/cjs/{role-8b0z7P0n.cjs.js → role-e0emQj8q.cjs.js} +2 -2
  29. package/dist/cjs/{run-CSt1n0F1.cjs.js → run-HW3lfDbM.cjs.js} +2 -2
  30. package/dist/cjs/{schema-B4250t0W.cjs.js → schema-Cabm6I6c.cjs.js} +3 -3
  31. package/dist/cjs/{test-DVUsmgyZ.cjs.js → test-5bQM0VRL.cjs.js} +3 -3
  32. package/dist/cjs/{test-Diil1uTk.cjs.js → test-YJMOGqXG.cjs.js} +3 -3
  33. package/dist/cjs/{validate-DDIGkK2r.cjs.js → validate-DKBlShmI.cjs.js} +3 -3
  34. package/dist/cjs/{Lockfile-B4mqBkH6.cjs.js → yarn-6FNAgNBK.cjs.js} +31 -1
  35. package/dist/index.cjs.js +1 -1
  36. package/package.json +9 -8
  37. package/dist/cjs/codeowners-FKKtpciN.cjs.js +0 -91
  38. package/dist/cjs/createPlugin-Dj7O_us6.cjs.js +0 -280
  39. package/dist/cjs/diff-Drt115Zb.cjs.js +0 -436
  40. package/dist/cjs/index-DRp-18FB.cjs.js +0 -1027
  41. package/dist/cjs/install-BMA3RshT.cjs.js +0 -268
  42. package/dist/cjs/lint-Dkx_fBkS.cjs.js +0 -10
  43. package/dist/cjs/packages-Cuogjl7j.cjs.js +0 -75
  44. package/dist/cjs/tasks-DtAiMv5G.cjs.js +0 -188
  45. package/dist/cjs/yarn-Ukl9MOS0.cjs.js +0 -34
@@ -7,25 +7,22 @@ var chalk = require('chalk');
7
7
  var inquirer = require('inquirer');
8
8
  var camelCase = require('lodash/camelCase');
9
9
  var upperFirst = require('lodash/upperFirst');
10
- var index = require('./index-DmUbBCFk.cjs.js');
11
- var codeowners = require('./codeowners-FKKtpciN.cjs.js');
12
- var tasks = require('./tasks-DtAiMv5G.cjs.js');
13
- var Lockfile = require('./Lockfile-B4mqBkH6.cjs.js');
10
+ var index = require('./index-v57xnvgT.cjs.js');
11
+ var handlebars = require('handlebars');
12
+ var ora = require('ora');
13
+ var util = require('util');
14
+ var recursive = require('recursive-readdir');
15
+ var child_process = require('child_process');
16
+ var errors = require('@backstage/errors');
17
+ var yarn = require('./yarn-6FNAgNBK.cjs.js');
14
18
  require('minimatch');
15
19
  require('@manypkg/get-packages');
16
- require('./yarn-Ukl9MOS0.cjs.js');
17
- require('./run-CSt1n0F1.cjs.js');
20
+ require('./run-HW3lfDbM.cjs.js');
18
21
  var partition = require('lodash/partition');
19
22
  var cliNode = require('@backstage/cli-node');
20
- var errors = require('@backstage/errors');
21
23
  require('commander');
22
24
  require('semver');
23
25
  require('@backstage/cli-common');
24
- require('handlebars');
25
- require('ora');
26
- require('util');
27
- require('recursive-readdir');
28
- require('child_process');
29
26
  require('@yarnpkg/parsers');
30
27
  require('@yarnpkg/lockfile');
31
28
 
@@ -33,16 +30,258 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
33
30
 
34
31
  var os__default = /*#__PURE__*/_interopDefaultCompat(os);
35
32
  var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
33
+ var path__default = /*#__PURE__*/_interopDefaultCompat(path);
36
34
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
37
35
  var inquirer__default = /*#__PURE__*/_interopDefaultCompat(inquirer);
38
36
  var camelCase__default = /*#__PURE__*/_interopDefaultCompat(camelCase);
39
37
  var upperFirst__default = /*#__PURE__*/_interopDefaultCompat(upperFirst);
38
+ var handlebars__default = /*#__PURE__*/_interopDefaultCompat(handlebars);
39
+ var ora__default = /*#__PURE__*/_interopDefaultCompat(ora);
40
+ var recursive__default = /*#__PURE__*/_interopDefaultCompat(recursive);
40
41
  var partition__default = /*#__PURE__*/_interopDefaultCompat(partition);
41
42
 
43
+ const TEAM_ID_RE = /^@[-\w]+\/[-\w]+$/;
44
+ const USER_ID_RE = /^@[-\w]+$/;
45
+ const EMAIL_RE = /^[^@]+@[-.\w]+\.[-\w]+$/i;
46
+ const DEFAULT_OWNER = "@backstage/maintainers";
47
+ async function getCodeownersFilePath(rootDir) {
48
+ const possiblePaths = [
49
+ path__default.default.join(rootDir, ".github", "CODEOWNERS"),
50
+ path__default.default.join(rootDir, ".gitlab", "CODEOWNERS"),
51
+ path__default.default.join(rootDir, "docs", "CODEOWNERS"),
52
+ path__default.default.join(rootDir, "CODEOWNERS")
53
+ ];
54
+ for (const p of possiblePaths) {
55
+ if (await fs__default.default.pathExists(p)) {
56
+ return p;
57
+ }
58
+ }
59
+ return void 0;
60
+ }
61
+ function isValidSingleOwnerId(id) {
62
+ if (!id || typeof id !== "string") {
63
+ return false;
64
+ }
65
+ return TEAM_ID_RE.test(id) || USER_ID_RE.test(id) || EMAIL_RE.test(id);
66
+ }
67
+ function parseOwnerIds(spaceSeparatedOwnerIds) {
68
+ if (!spaceSeparatedOwnerIds || typeof spaceSeparatedOwnerIds !== "string") {
69
+ return void 0;
70
+ }
71
+ const ids = spaceSeparatedOwnerIds.split(" ").filter(Boolean);
72
+ if (!ids.every(isValidSingleOwnerId)) {
73
+ return void 0;
74
+ }
75
+ return ids;
76
+ }
77
+ async function addCodeownersEntry(ownedPath, ownerStr, codeownersFilePath) {
78
+ const ownerIds = parseOwnerIds(ownerStr);
79
+ if (!ownerIds || ownerIds.length === 0) {
80
+ return false;
81
+ }
82
+ let filePath = codeownersFilePath;
83
+ if (!filePath) {
84
+ filePath = await getCodeownersFilePath(index.paths.targetRoot);
85
+ if (!filePath) {
86
+ return false;
87
+ }
88
+ }
89
+ const allLines = (await fs__default.default.readFile(filePath, "utf8")).split("\n");
90
+ const commentLines = [];
91
+ for (const line of allLines) {
92
+ if (line[0] !== "#") {
93
+ break;
94
+ }
95
+ commentLines.push(line);
96
+ }
97
+ const oldDeclarationEntries = allLines.filter((line) => line[0] !== "#").map((line) => line.split(/\s+/).filter(Boolean)).filter((tokens) => tokens.length >= 2).map((tokens) => ({
98
+ ownedPath: tokens[0],
99
+ ownerIds: tokens.slice(1)
100
+ }));
101
+ const newDeclarationEntries = oldDeclarationEntries.filter((entry) => entry.ownedPath !== "*").concat([{ ownedPath, ownerIds }]).sort((l1, l2) => l1.ownedPath.localeCompare(l2.ownedPath));
102
+ newDeclarationEntries.unshift({
103
+ ownedPath: "*",
104
+ ownerIds: [DEFAULT_OWNER]
105
+ });
106
+ const longestOwnedPath = newDeclarationEntries.reduce(
107
+ (length, entry) => Math.max(length, entry.ownedPath.length),
108
+ 0
109
+ );
110
+ const newDeclarationLines = newDeclarationEntries.map((entry) => {
111
+ const entryPath = entry.ownedPath + " ".repeat(longestOwnedPath - entry.ownedPath.length);
112
+ return [entryPath, ...entry.ownerIds].join(" ");
113
+ });
114
+ const newLines = [...commentLines, "", ...newDeclarationLines, ""];
115
+ await fs__default.default.writeFile(filePath, newLines.join("\n"), "utf8");
116
+ return true;
117
+ }
118
+
42
119
  function createFactory(config) {
43
120
  return config;
44
121
  }
45
122
 
123
+ const exec = util.promisify(child_process.exec);
124
+ const TASK_NAME_MAX_LENGTH = 14;
125
+ class Task {
126
+ static log(name = "") {
127
+ process.stderr.write(`${chalk__default.default.green(name)}
128
+ `);
129
+ }
130
+ static error(message = "") {
131
+ process.stderr.write(`
132
+ ${chalk__default.default.red(message)}
133
+
134
+ `);
135
+ }
136
+ static section(name) {
137
+ const title = chalk__default.default.green(`${name}:`);
138
+ process.stderr.write(`
139
+ ${title}
140
+ `);
141
+ }
142
+ static exit(code = 0) {
143
+ process.exit(code);
144
+ }
145
+ static async forItem(task, item, taskFunc) {
146
+ const paddedTask = chalk__default.default.green(task.padEnd(TASK_NAME_MAX_LENGTH));
147
+ const spinner = ora__default.default({
148
+ prefixText: chalk__default.default.green(` ${paddedTask}${chalk__default.default.cyan(item)}`),
149
+ spinner: "arc",
150
+ color: "green"
151
+ }).start();
152
+ try {
153
+ const result = await taskFunc();
154
+ spinner.succeed();
155
+ return result;
156
+ } catch (error) {
157
+ spinner.fail();
158
+ throw error;
159
+ }
160
+ }
161
+ static async forCommand(command, options) {
162
+ try {
163
+ await Task.forItem("executing", command, async () => {
164
+ await exec(command, { cwd: options?.cwd });
165
+ });
166
+ } catch (error) {
167
+ errors.assertError(error);
168
+ if (error.stderr) {
169
+ process.stderr.write(error.stderr);
170
+ }
171
+ if (error.stdout) {
172
+ process.stdout.write(error.stdout);
173
+ }
174
+ if (options?.optional) {
175
+ Task.error(`Warning: Failed to execute command ${chalk__default.default.cyan(command)}`);
176
+ } else {
177
+ throw new Error(
178
+ `Failed to execute command '${chalk__default.default.cyan(command)}', ${error}`
179
+ );
180
+ }
181
+ }
182
+ }
183
+ }
184
+ async function templatingTask(templateDir, destinationDir, context, versionProvider, isMonoRepo) {
185
+ const files = await recursive__default.default(templateDir).catch((error) => {
186
+ throw new Error(`Failed to read template directory: ${error.message}`);
187
+ });
188
+ for (const file of files) {
189
+ const destinationFile = file.replace(templateDir, destinationDir);
190
+ await fs__default.default.ensureDir(path.dirname(destinationFile));
191
+ if (file.endsWith(".hbs")) {
192
+ await Task.forItem("templating", path.basename(file), async () => {
193
+ const destination = destinationFile.replace(/\.hbs$/, "");
194
+ const template = await fs__default.default.readFile(file);
195
+ const compiled = handlebars__default.default.compile(template.toString(), {
196
+ strict: true
197
+ });
198
+ const contents = compiled(
199
+ { name: path.basename(destination), ...context },
200
+ {
201
+ helpers: {
202
+ versionQuery(name, versionHint) {
203
+ return versionProvider(
204
+ name,
205
+ typeof versionHint === "string" ? versionHint : void 0
206
+ );
207
+ }
208
+ }
209
+ }
210
+ );
211
+ await fs__default.default.writeFile(destination, contents).catch((error) => {
212
+ throw new Error(
213
+ `Failed to create file: ${destination}: ${error.message}`
214
+ );
215
+ });
216
+ });
217
+ } else {
218
+ if (isMonoRepo && file.match("tsconfig.json")) {
219
+ continue;
220
+ }
221
+ await Task.forItem("copying", path.basename(file), async () => {
222
+ await fs__default.default.copyFile(file, destinationFile).catch((error) => {
223
+ const destination = destinationFile;
224
+ throw new Error(
225
+ `Failed to copy file to ${destination} : ${error.message}`
226
+ );
227
+ });
228
+ });
229
+ }
230
+ }
231
+ }
232
+ async function addPackageDependency(path, options) {
233
+ try {
234
+ const pkgJson = await fs__default.default.readJson(path);
235
+ const normalize = (obj) => {
236
+ if (Object.keys(obj).length === 0) {
237
+ return void 0;
238
+ }
239
+ return Object.fromEntries(
240
+ Object.keys(obj).sort().map((key) => [key, obj[key]])
241
+ );
242
+ };
243
+ pkgJson.dependencies = normalize({
244
+ ...pkgJson.dependencies,
245
+ ...options.dependencies
246
+ });
247
+ pkgJson.devDependencies = normalize({
248
+ ...pkgJson.devDependencies,
249
+ ...options.devDependencies
250
+ });
251
+ pkgJson.peerDependencies = normalize({
252
+ ...pkgJson.peerDependencies,
253
+ ...options.peerDependencies
254
+ });
255
+ await fs__default.default.writeJson(path, pkgJson, { spaces: 2 });
256
+ } catch (error) {
257
+ throw new Error(`Failed to add package dependencies, ${error}`);
258
+ }
259
+ }
260
+ async function addToBackend(name, options) {
261
+ if (await fs__default.default.pathExists(index.paths.resolveTargetRoot("packages/backend"))) {
262
+ await Task.forItem("backend", `adding ${options.type}`, async () => {
263
+ const backendFilePath = index.paths.resolveTargetRoot(
264
+ "packages/backend/src/index.ts"
265
+ );
266
+ if (!await fs__default.default.pathExists(backendFilePath)) {
267
+ return;
268
+ }
269
+ const content = await fs__default.default.readFile(backendFilePath, "utf8");
270
+ const lines = content.split("\n");
271
+ const backendAddLine = `backend.add(import('${name}'));`;
272
+ const backendStartIndex = lines.findIndex(
273
+ (line) => line.match(/backend.start/)
274
+ );
275
+ if (backendStartIndex !== -1) {
276
+ const [indentation] = lines[backendStartIndex].match(/^\s*/);
277
+ lines.splice(backendStartIndex, 0, `${indentation}${backendAddLine}`);
278
+ const newContent = lines.join("\n");
279
+ await fs__default.default.writeFile(backendFilePath, newContent, "utf8");
280
+ }
281
+ });
282
+ }
283
+ }
284
+
46
285
  function pluginIdPrompt() {
47
286
  return {
48
287
  type: "input",
@@ -83,7 +322,7 @@ function ownerPrompt() {
83
322
  if (!value) {
84
323
  return true;
85
324
  }
86
- const ownerIds = codeowners.parseOwnerIds(value);
325
+ const ownerIds = parseOwnerIds(value);
87
326
  if (!ownerIds) {
88
327
  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).";
89
328
  }
@@ -96,12 +335,12 @@ async function executePluginPackageTemplate(ctx, options) {
96
335
  const { targetDir } = options;
97
336
  let lockfile;
98
337
  try {
99
- lockfile = await Lockfile.Lockfile.load(index.paths.resolveTargetRoot("yarn.lock"));
338
+ lockfile = await yarn.Lockfile.load(index.paths.resolveTargetRoot("yarn.lock"));
100
339
  } catch {
101
340
  }
102
- tasks.Task.section("Checking Prerequisites");
341
+ Task.section("Checking Prerequisites");
103
342
  const shortPluginDir = path.relative(index.paths.targetRoot, targetDir);
104
- await tasks.Task.forItem("availability", shortPluginDir, async () => {
343
+ await Task.forItem("availability", shortPluginDir, async () => {
105
344
  if (await fs__default.default.pathExists(targetDir)) {
106
345
  throw new Error(
107
346
  `A package with the same plugin ID already exists at ${chalk__default.default.cyan(
@@ -110,11 +349,11 @@ async function executePluginPackageTemplate(ctx, options) {
110
349
  );
111
350
  }
112
351
  });
113
- const tempDir = await tasks.Task.forItem("creating", "temp dir", async () => {
352
+ const tempDir = await Task.forItem("creating", "temp dir", async () => {
114
353
  return await ctx.createTemporaryDirectory("backstage-create");
115
354
  });
116
- tasks.Task.section("Executing Template");
117
- await tasks.templatingTask(
355
+ Task.section("Executing Template");
356
+ await templatingTask(
118
357
  index.paths.resolveOwn("templates", options.templateName),
119
358
  tempDir,
120
359
  options.values,
@@ -126,8 +365,8 @@ async function executePluginPackageTemplate(ctx, options) {
126
365
  const pkgJson = await fs__default.default.readJson(pkgJsonPath);
127
366
  await fs__default.default.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
128
367
  }
129
- tasks.Task.section("Installing");
130
- await tasks.Task.forItem("moving", shortPluginDir, async () => {
368
+ Task.section("Installing");
369
+ await Task.forItem("moving", shortPluginDir, async () => {
131
370
  await fs__default.default.move(tempDir, targetDir).catch((error) => {
132
371
  throw new Error(
133
372
  `Failed to move package from ${tempDir} to ${targetDir}, ${error.message}`
@@ -153,7 +392,7 @@ const frontendPlugin = createFactory({
153
392
  name: "plugin",
154
393
  description: "A new frontend plugin",
155
394
  optionsDiscovery: async () => ({
156
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
395
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
157
396
  }),
158
397
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
159
398
  async create(options, ctx) {
@@ -164,8 +403,8 @@ const frontendPlugin = createFactory({
164
403
  plugin: true
165
404
  });
166
405
  const extensionName = `${upperFirst__default.default(camelCase__default.default(id))}Page`;
167
- tasks.Task.log();
168
- tasks.Task.log(`Creating frontend plugin ${chalk__default.default.cyan(name)}`);
406
+ Task.log();
407
+ Task.log(`Creating frontend plugin ${chalk__default.default.cyan(name)}`);
169
408
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", id) : index.paths.resolveTargetRoot(`backstage-plugin-${id}`);
170
409
  await executePluginPackageTemplate(ctx, {
171
410
  targetDir,
@@ -182,8 +421,8 @@ const frontendPlugin = createFactory({
182
421
  }
183
422
  });
184
423
  if (await fs__default.default.pathExists(index.paths.resolveTargetRoot("packages/app"))) {
185
- await tasks.Task.forItem("app", "adding dependency", async () => {
186
- await tasks.addPackageDependency(
424
+ await Task.forItem("app", "adding dependency", async () => {
425
+ await addPackageDependency(
187
426
  index.paths.resolveTargetRoot("packages/app/package.json"),
188
427
  {
189
428
  dependencies: {
@@ -192,7 +431,7 @@ const frontendPlugin = createFactory({
192
431
  }
193
432
  );
194
433
  });
195
- await tasks.Task.forItem("app", "adding import", async () => {
434
+ await Task.forItem("app", "adding import", async () => {
196
435
  const pluginsFilePath = index.paths.resolveTargetRoot(
197
436
  "packages/app/src/App.tsx"
198
437
  );
@@ -223,10 +462,10 @@ const frontendPlugin = createFactory({
223
462
  });
224
463
  }
225
464
  if (options.owner) {
226
- await codeowners.addCodeownersEntry(`/plugins/${id}`, options.owner);
465
+ await addCodeownersEntry(`/plugins/${id}`, options.owner);
227
466
  }
228
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
229
- await tasks.Task.forCommand("yarn lint --fix", {
467
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
468
+ await Task.forCommand("yarn lint --fix", {
230
469
  cwd: targetDir,
231
470
  optional: true
232
471
  });
@@ -237,7 +476,7 @@ const backendPlugin = createFactory({
237
476
  name: "backend-plugin",
238
477
  description: "A new backend plugin",
239
478
  optionsDiscovery: async () => ({
240
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
479
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
241
480
  }),
242
481
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
243
482
  async create(options, ctx) {
@@ -248,8 +487,8 @@ const backendPlugin = createFactory({
248
487
  scope: ctx.scope,
249
488
  plugin: true
250
489
  });
251
- tasks.Task.log();
252
- tasks.Task.log(`Creating backend plugin ${chalk__default.default.cyan(name)}`);
490
+ Task.log();
491
+ Task.log(`Creating backend plugin ${chalk__default.default.cyan(name)}`);
253
492
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", pluginId) : index.paths.resolveTargetRoot(`backstage-plugin-${pluginId}`);
254
493
  await executePluginPackageTemplate(ctx, {
255
494
  targetDir,
@@ -265,8 +504,8 @@ const backendPlugin = createFactory({
265
504
  }
266
505
  });
267
506
  if (await fs__default.default.pathExists(index.paths.resolveTargetRoot("packages/backend"))) {
268
- await tasks.Task.forItem("backend", "adding dependency", async () => {
269
- await tasks.addPackageDependency(
507
+ await Task.forItem("backend", "adding dependency", async () => {
508
+ await addPackageDependency(
270
509
  index.paths.resolveTargetRoot("packages/backend/package.json"),
271
510
  {
272
511
  dependencies: {
@@ -276,14 +515,14 @@ const backendPlugin = createFactory({
276
515
  );
277
516
  });
278
517
  }
279
- await tasks.addToBackend(name, {
518
+ await addToBackend(name, {
280
519
  type: "plugin"
281
520
  });
282
521
  if (options.owner) {
283
- await codeowners.addCodeownersEntry(`/plugins/${id}`, options.owner);
522
+ await addCodeownersEntry(`/plugins/${id}`, options.owner);
284
523
  }
285
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
286
- await tasks.Task.forCommand("yarn lint --fix", {
524
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
525
+ await Task.forCommand("yarn lint --fix", {
287
526
  cwd: targetDir,
288
527
  optional: true
289
528
  });
@@ -294,7 +533,7 @@ const backendModule = createFactory({
294
533
  name: "backend-module",
295
534
  description: "A new backend module that extends an existing backend plugin with additional features",
296
535
  optionsDiscovery: async () => ({
297
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
536
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
298
537
  }),
299
538
  optionsPrompts: [pluginIdPrompt(), moduleIdIdPrompt(), ownerPrompt()],
300
539
  async create(options, ctx) {
@@ -305,8 +544,8 @@ const backendModule = createFactory({
305
544
  scope: ctx.scope,
306
545
  plugin: true
307
546
  });
308
- tasks.Task.log();
309
- tasks.Task.log(`Creating backend module ${chalk__default.default.cyan(name)}`);
547
+ Task.log();
548
+ Task.log(`Creating backend module ${chalk__default.default.cyan(name)}`);
310
549
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", dirName) : index.paths.resolveTargetRoot(`backstage-plugin-${dirName}`);
311
550
  const moduleCamelCase = camelCase__default.default(moduleId);
312
551
  const modulePascalCase = moduleCamelCase[0].toUpperCase() + moduleCamelCase.slice(1);
@@ -326,8 +565,8 @@ const backendModule = createFactory({
326
565
  }
327
566
  });
328
567
  if (await fs__default.default.pathExists(index.paths.resolveTargetRoot("packages/backend"))) {
329
- await tasks.Task.forItem("backend", "adding dependency", async () => {
330
- await tasks.addPackageDependency(
568
+ await Task.forItem("backend", "adding dependency", async () => {
569
+ await addPackageDependency(
331
570
  index.paths.resolveTargetRoot("packages/backend/package.json"),
332
571
  {
333
572
  dependencies: {
@@ -337,14 +576,14 @@ const backendModule = createFactory({
337
576
  );
338
577
  });
339
578
  }
340
- await tasks.addToBackend(name, {
579
+ await addToBackend(name, {
341
580
  type: "module"
342
581
  });
343
582
  if (options.owner) {
344
- await codeowners.addCodeownersEntry(`/plugins/${dirName}`, options.owner);
583
+ await addCodeownersEntry(`/plugins/${dirName}`, options.owner);
345
584
  }
346
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
347
- await tasks.Task.forCommand("yarn lint --fix", {
585
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
586
+ await Task.forCommand("yarn lint --fix", {
348
587
  cwd: targetDir,
349
588
  optional: true
350
589
  });
@@ -355,7 +594,7 @@ const nodeLibraryPackage = createFactory({
355
594
  name: "node-library",
356
595
  description: "A new node-library package, exporting shared functionality for backend plugins and modules",
357
596
  optionsDiscovery: async () => ({
358
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
597
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
359
598
  }),
360
599
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
361
600
  async create(options, ctx) {
@@ -365,8 +604,8 @@ const nodeLibraryPackage = createFactory({
365
604
  scope: ctx.scope,
366
605
  plugin: false
367
606
  });
368
- tasks.Task.log();
369
- tasks.Task.log(`Creating node-library package ${chalk__default.default.cyan(name)}`);
607
+ Task.log();
608
+ Task.log(`Creating node-library package ${chalk__default.default.cyan(name)}`);
370
609
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("packages", id) : index.paths.resolveTargetRoot(`${id}`);
371
610
  await executePluginPackageTemplate(ctx, {
372
611
  targetDir,
@@ -381,10 +620,10 @@ const nodeLibraryPackage = createFactory({
381
620
  }
382
621
  });
383
622
  if (options.owner) {
384
- await codeowners.addCodeownersEntry(`/packages/${id}`, options.owner);
623
+ await addCodeownersEntry(`/packages/${id}`, options.owner);
385
624
  }
386
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
387
- await tasks.Task.forCommand("yarn lint --fix", {
625
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
626
+ await Task.forCommand("yarn lint --fix", {
388
627
  cwd: targetDir,
389
628
  optional: true
390
629
  });
@@ -395,7 +634,7 @@ const webLibraryPackage = createFactory({
395
634
  name: "web-library",
396
635
  description: "A new web-library package, exporting shared functionality for frontend plugins",
397
636
  optionsDiscovery: async () => ({
398
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
637
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
399
638
  }),
400
639
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
401
640
  async create(options, ctx) {
@@ -405,8 +644,8 @@ const webLibraryPackage = createFactory({
405
644
  scope: ctx.scope,
406
645
  plugin: false
407
646
  });
408
- tasks.Task.log();
409
- tasks.Task.log(`Creating web-library package ${chalk__default.default.cyan(name)}`);
647
+ Task.log();
648
+ Task.log(`Creating web-library package ${chalk__default.default.cyan(name)}`);
410
649
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("packages", id) : index.paths.resolveTargetRoot(`${id}`);
411
650
  await executePluginPackageTemplate(ctx, {
412
651
  targetDir,
@@ -421,10 +660,10 @@ const webLibraryPackage = createFactory({
421
660
  }
422
661
  });
423
662
  if (options.owner) {
424
- await codeowners.addCodeownersEntry(`/packages/${id}`, options.owner);
663
+ await addCodeownersEntry(`/packages/${id}`, options.owner);
425
664
  }
426
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
427
- await tasks.Task.forCommand("yarn lint --fix", {
665
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
666
+ await Task.forCommand("yarn lint --fix", {
428
667
  cwd: targetDir,
429
668
  optional: true
430
669
  });
@@ -435,7 +674,7 @@ const pluginCommon = createFactory({
435
674
  name: "plugin-common",
436
675
  description: "A new isomorphic common plugin package",
437
676
  optionsDiscovery: async () => ({
438
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
677
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
439
678
  }),
440
679
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
441
680
  async create(options, ctx) {
@@ -446,8 +685,8 @@ const pluginCommon = createFactory({
446
685
  scope: ctx.scope,
447
686
  plugin: true
448
687
  });
449
- tasks.Task.log();
450
- tasks.Task.log(`Creating common plugin package ${chalk__default.default.cyan(name)}`);
688
+ Task.log();
689
+ Task.log(`Creating common plugin package ${chalk__default.default.cyan(name)}`);
451
690
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", suffix) : index.paths.resolveTargetRoot(`backstage-plugin-${suffix}`);
452
691
  await executePluginPackageTemplate(ctx, {
453
692
  targetDir,
@@ -462,10 +701,10 @@ const pluginCommon = createFactory({
462
701
  }
463
702
  });
464
703
  if (options.owner) {
465
- await codeowners.addCodeownersEntry(`/plugins/${suffix}`, options.owner);
704
+ await addCodeownersEntry(`/plugins/${suffix}`, options.owner);
466
705
  }
467
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
468
- await tasks.Task.forCommand("yarn lint --fix", {
706
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
707
+ await Task.forCommand("yarn lint --fix", {
469
708
  cwd: targetDir,
470
709
  optional: true
471
710
  });
@@ -476,7 +715,7 @@ const pluginNode = createFactory({
476
715
  name: "plugin-node",
477
716
  description: "A new Node.js library plugin package",
478
717
  optionsDiscovery: async () => ({
479
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
718
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
480
719
  }),
481
720
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
482
721
  async create(options, ctx) {
@@ -487,8 +726,8 @@ const pluginNode = createFactory({
487
726
  scope: ctx.scope,
488
727
  plugin: true
489
728
  });
490
- tasks.Task.log();
491
- tasks.Task.log(`Creating Node.js plugin library ${chalk__default.default.cyan(name)}`);
729
+ Task.log();
730
+ Task.log(`Creating Node.js plugin library ${chalk__default.default.cyan(name)}`);
492
731
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", suffix) : index.paths.resolveTargetRoot(`backstage-plugin-${suffix}`);
493
732
  await executePluginPackageTemplate(ctx, {
494
733
  targetDir,
@@ -503,10 +742,10 @@ const pluginNode = createFactory({
503
742
  }
504
743
  });
505
744
  if (options.owner) {
506
- await codeowners.addCodeownersEntry(`/plugins/${suffix}`, options.owner);
745
+ await addCodeownersEntry(`/plugins/${suffix}`, options.owner);
507
746
  }
508
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
509
- await tasks.Task.forCommand("yarn lint --fix", {
747
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
748
+ await Task.forCommand("yarn lint --fix", {
510
749
  cwd: targetDir,
511
750
  optional: true
512
751
  });
@@ -517,7 +756,7 @@ const pluginWeb = createFactory({
517
756
  name: "plugin-react",
518
757
  description: "A new web library plugin package",
519
758
  optionsDiscovery: async () => ({
520
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
759
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
521
760
  }),
522
761
  optionsPrompts: [pluginIdPrompt(), ownerPrompt()],
523
762
  async create(options, ctx) {
@@ -528,8 +767,8 @@ const pluginWeb = createFactory({
528
767
  scope: ctx.scope,
529
768
  plugin: true
530
769
  });
531
- tasks.Task.log();
532
- tasks.Task.log(`Creating web plugin library ${chalk__default.default.cyan(name)}`);
770
+ Task.log();
771
+ Task.log(`Creating web plugin library ${chalk__default.default.cyan(name)}`);
533
772
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", suffix) : index.paths.resolveTargetRoot(`backstage-plugin-${suffix}`);
534
773
  await executePluginPackageTemplate(ctx, {
535
774
  targetDir,
@@ -544,10 +783,10 @@ const pluginWeb = createFactory({
544
783
  }
545
784
  });
546
785
  if (options.owner) {
547
- await codeowners.addCodeownersEntry(`/plugins/${suffix}`, options.owner);
786
+ await addCodeownersEntry(`/plugins/${suffix}`, options.owner);
548
787
  }
549
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
550
- await tasks.Task.forCommand("yarn lint --fix", {
788
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
789
+ await Task.forCommand("yarn lint --fix", {
551
790
  cwd: targetDir,
552
791
  optional: true
553
792
  });
@@ -558,7 +797,7 @@ const scaffolderModule = createFactory({
558
797
  name: "scaffolder-module",
559
798
  description: "An module exporting custom actions for @backstage/plugin-scaffolder-backend",
560
799
  optionsDiscovery: async () => ({
561
- codeOwnersPath: await codeowners.getCodeownersFilePath(index.paths.targetRoot)
800
+ codeOwnersPath: await getCodeownersFilePath(index.paths.targetRoot)
562
801
  }),
563
802
  optionsPrompts: [
564
803
  {
@@ -584,8 +823,8 @@ const scaffolderModule = createFactory({
584
823
  scope: ctx.scope,
585
824
  plugin: true
586
825
  });
587
- tasks.Task.log();
588
- tasks.Task.log(`Creating module ${chalk__default.default.cyan(name)}`);
826
+ Task.log();
827
+ Task.log(`Creating module ${chalk__default.default.cyan(name)}`);
589
828
  const targetDir = ctx.isMonoRepo ? index.paths.resolveTargetRoot("plugins", slug) : index.paths.resolveTargetRoot(`backstage-plugin-${slug}`);
590
829
  await executePluginPackageTemplate(ctx, {
591
830
  targetDir,
@@ -600,8 +839,8 @@ const scaffolderModule = createFactory({
600
839
  }
601
840
  });
602
841
  if (await fs__default.default.pathExists(index.paths.resolveTargetRoot("packages/backend"))) {
603
- await tasks.Task.forItem("backend", "adding dependency", async () => {
604
- await tasks.addPackageDependency(
842
+ await Task.forItem("backend", "adding dependency", async () => {
843
+ await addPackageDependency(
605
844
  index.paths.resolveTargetRoot("packages/backend/package.json"),
606
845
  {
607
846
  dependencies: {
@@ -611,14 +850,14 @@ const scaffolderModule = createFactory({
611
850
  );
612
851
  });
613
852
  }
614
- await tasks.addToBackend(name, {
853
+ await addToBackend(name, {
615
854
  type: "module"
616
855
  });
617
856
  if (options.owner) {
618
- await codeowners.addCodeownersEntry(`/plugins/${slug}`, options.owner);
857
+ await addCodeownersEntry(`/plugins/${slug}`, options.owner);
619
858
  }
620
- await tasks.Task.forCommand("yarn install", { cwd: targetDir, optional: true });
621
- await tasks.Task.forCommand("yarn lint --fix", {
859
+ await Task.forCommand("yarn install", { cwd: targetDir, optional: true });
860
+ await Task.forCommand("yarn lint --fix", {
622
861
  cwd: targetDir,
623
862
  optional: true
624
863
  });
@@ -770,22 +1009,22 @@ var _new = async (opts) => {
770
1009
  modified = true;
771
1010
  }
772
1011
  });
773
- tasks.Task.log();
774
- tasks.Task.log(`\u{1F389} Successfully created ${factory.name}`);
775
- tasks.Task.log();
1012
+ Task.log();
1013
+ Task.log(`\u{1F389} Successfully created ${factory.name}`);
1014
+ Task.log();
776
1015
  } catch (error) {
777
1016
  errors.assertError(error);
778
- tasks.Task.error(error.message);
1017
+ Task.error(error.message);
779
1018
  if (modified) {
780
- tasks.Task.log("It seems that something went wrong in the creation process \u{1F914}");
781
- tasks.Task.log();
782
- tasks.Task.log(
1019
+ Task.log("It seems that something went wrong in the creation process \u{1F914}");
1020
+ Task.log();
1021
+ Task.log(
783
1022
  "We have left the changes that were made intact in case you want to"
784
1023
  );
785
- tasks.Task.log(
1024
+ Task.log(
786
1025
  "continue manually, but you can also revert the changes and try again."
787
1026
  );
788
- tasks.Task.error(`\u{1F525} Failed to create ${factory.name}!`);
1027
+ Task.error(`\u{1F525} Failed to create ${factory.name}!`);
789
1028
  }
790
1029
  } finally {
791
1030
  for (const dir of tempDirs) {
@@ -801,4 +1040,4 @@ var _new = async (opts) => {
801
1040
  };
802
1041
 
803
1042
  exports.default = _new;
804
- //# sourceMappingURL=new-DJUBFwiF.cjs.js.map
1043
+ //# sourceMappingURL=new-C0D_k25O.cjs.js.map