@backstage/plugin-scaffolder-backend 1.6.0-next.3 → 1.6.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 CHANGED
@@ -1,5 +1,56 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ea2eee9e6a: Add the option for a homepage when using the `github:publish` action
8
+ - 8872cc735d: Fixed a bug in plugin-scaffolder-backend where it ignores the skip migration database options.
9
+
10
+ To use this new implementation you need to create the instance of `DatabaseTaskStore` using the `PluginDatabaseManager` instead of `Knex`;
11
+
12
+ ```
13
+ import { DatabaseManager, getRootLogger, loadBackendConfig } from '@backstage/backend-common';
14
+ import { DatabaseTaskStore } from '@backstage/plugin-scaffolder-backend';
15
+
16
+ const config = await loadBackendConfig({ argv: process.argv, logger: getRootLogger() });
17
+ const databaseManager = DatabaseManager.fromConfig(config, { migrations: { skip: true } });
18
+ const databaseTaskStore = await DatabaseTaskStore.create(databaseManager);
19
+ ```
20
+
21
+ - 7db9613671: Added `projectId` for gitlab projects to be displayed in the `gitlab:publish` output
22
+ - d1f7ba58e3: Added `repositoryId` output when create a repository in Azure
23
+ - 1ff817b3f0: add entity metadata to the template info type
24
+
25
+ ### Patch Changes
26
+
27
+ - eadf56bbbf: Bump `git-url-parse` version to `^13.0.0`
28
+ - de8ee4afe3: Provide information about the user into scaffolder template action's context
29
+ - 096631e571: Added support for handling broken symlinks within the scaffolder backend. This is intended for templates that may hold a symlink that is invalid at build time but valid within the destination repo.
30
+ - 0d8d650e32: Applied the fix from version 1.5.1 of this package, which is part of the v1.5.1 release of Backstage.
31
+ - 667d917488: Updated dependency `msw` to `^0.47.0`.
32
+ - 87ec2ba4d6: Updated dependency `msw` to `^0.46.0`.
33
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
34
+ - 2df9955f4a: Removed the depreacated `publish:file` action, use the template editor to test templates instead.
35
+ - 0ecc9a6784: Properly set `ctx.isDryRun` when running actions in dry run mode. Also always log action inputs for debugging purposes when running in dry run mode.
36
+ - 6b9f6c0a4d: Added alpha `scaffolderPlugin` to be used with experimental backend system.
37
+ - 83c037cd46: Disable octokit throttling in publish:github:pull-request
38
+ - 2cbd533426: Uptake the `IdentityApi` change to use `getIdentity` instead of `authenticate` for retrieving the logged in users identity.
39
+ - ef9ab322de: Minor API signatures cleanup
40
+ - 50467bc15b: The number of task workers used to execute templates now default to 3, rather than 1.
41
+ - Updated dependencies
42
+ - @backstage/backend-plugin-api@0.1.2
43
+ - @backstage/backend-common@0.15.1
44
+ - @backstage/plugin-auth-node@0.2.5
45
+ - @backstage/plugin-catalog-node@1.1.0
46
+ - @backstage/integration@1.3.1
47
+ - @backstage/plugin-catalog-backend@1.4.0
48
+ - @backstage/catalog-client@1.1.0
49
+ - @backstage/catalog-model@1.1.1
50
+ - @backstage/config@1.0.2
51
+ - @backstage/errors@1.1.1
52
+ - @backstage/plugin-scaffolder-common@1.2.0
53
+
3
54
  ## 1.6.0-next.3
4
55
 
5
56
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.6.0-next.3",
3
+ "version": "1.6.0",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -32,6 +32,7 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
32
32
  import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common';
33
33
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
34
34
  import { UrlReader } from '@backstage/backend-common';
35
+ import { UserEntity } from '@backstage/catalog-model';
35
36
  import { Writable } from 'stream';
36
37
 
37
38
  /**
@@ -55,6 +56,19 @@ export declare type ActionContext<Input extends JsonObject> = {
55
56
  * This will only ever be true if the actions as marked as supporting dry-runs.
56
57
  */
57
58
  isDryRun?: boolean;
59
+ /**
60
+ * The user which triggered the action.
61
+ */
62
+ user?: {
63
+ /**
64
+ * The decorated entity from the Catalog
65
+ */
66
+ entity?: UserEntity;
67
+ /**
68
+ * An entity ref for the author of the task
69
+ */
70
+ ref?: string;
71
+ };
58
72
  };
59
73
 
60
74
  /**
@@ -32,6 +32,7 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
32
32
  import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common';
33
33
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
34
34
  import { UrlReader } from '@backstage/backend-common';
35
+ import { UserEntity } from '@backstage/catalog-model';
35
36
  import { Writable } from 'stream';
36
37
 
37
38
  /**
@@ -55,6 +56,19 @@ export declare type ActionContext<Input extends JsonObject> = {
55
56
  * This will only ever be true if the actions as marked as supporting dry-runs.
56
57
  */
57
58
  isDryRun?: boolean;
59
+ /**
60
+ * The user which triggered the action.
61
+ */
62
+ user?: {
63
+ /**
64
+ * The decorated entity from the Catalog
65
+ */
66
+ entity?: UserEntity;
67
+ /**
68
+ * An entity ref for the author of the task
69
+ */
70
+ ref?: string;
71
+ };
58
72
  };
59
73
 
60
74
  /**
package/dist/index.cjs.js CHANGED
@@ -4166,7 +4166,7 @@ class NunjucksWorkflowRunner {
4166
4166
  });
4167
4167
  }
4168
4168
  async execute(task) {
4169
- var _a, _b, _c, _d, _e;
4169
+ var _a, _b, _c, _d, _e, _f, _g;
4170
4170
  if (!isValidTaskSpec(task.spec)) {
4171
4171
  throw new errors.InputError(
4172
4172
  "Wrong template version executed with the workflow engine"
@@ -4215,30 +4215,53 @@ class NunjucksWorkflowRunner {
4215
4215
  });
4216
4216
  const action = this.options.actionRegistry.get(step.action);
4217
4217
  const { taskLogger, streamLogger } = createStepLogger({ task, step });
4218
- if (task.isDryRun && !action.supportsDryRun) {
4219
- task.emitLog(
4220
- `Skipping because ${action.id} does not support dry-run`,
4218
+ if (task.isDryRun) {
4219
+ const redactedSecrets = Object.fromEntries(
4220
+ Object.entries((_a = task.secrets) != null ? _a : {}).map((secret) => [
4221
+ secret[0],
4222
+ "[REDACTED]"
4223
+ ])
4224
+ );
4225
+ const debugInput = (_b = step.input && this.render(
4226
+ step.input,
4221
4227
  {
4222
- stepId: step.id,
4223
- status: "skipped"
4224
- }
4228
+ ...context,
4229
+ secrets: redactedSecrets
4230
+ },
4231
+ renderTemplate
4232
+ )) != null ? _b : {};
4233
+ taskLogger.info(
4234
+ `Running ${action.id} in dry-run mode with inputs (secrets redacted): ${JSON.stringify(
4235
+ debugInput,
4236
+ void 0,
4237
+ 2
4238
+ )}`
4225
4239
  );
4226
- const outputSchema = (_a = action.schema) == null ? void 0 : _a.output;
4227
- if (outputSchema) {
4228
- context.steps[step.id] = {
4229
- output: generateExampleOutput(outputSchema)
4230
- };
4231
- } else {
4232
- context.steps[step.id] = { output: {} };
4240
+ if (!action.supportsDryRun) {
4241
+ task.emitLog(
4242
+ `Skipping because ${action.id} does not support dry-run`,
4243
+ {
4244
+ stepId: step.id,
4245
+ status: "skipped"
4246
+ }
4247
+ );
4248
+ const outputSchema = (_c = action.schema) == null ? void 0 : _c.output;
4249
+ if (outputSchema) {
4250
+ context.steps[step.id] = {
4251
+ output: generateExampleOutput(outputSchema)
4252
+ };
4253
+ } else {
4254
+ context.steps[step.id] = { output: {} };
4255
+ }
4256
+ continue;
4233
4257
  }
4234
- continue;
4235
4258
  }
4236
- const input = (_c = step.input && this.render(
4259
+ const input = (_e = step.input && this.render(
4237
4260
  step.input,
4238
- { ...context, secrets: (_b = task.secrets) != null ? _b : {} },
4261
+ { ...context, secrets: (_d = task.secrets) != null ? _d : {} },
4239
4262
  renderTemplate
4240
- )) != null ? _c : {};
4241
- if ((_d = action.schema) == null ? void 0 : _d.input) {
4263
+ )) != null ? _e : {};
4264
+ if ((_f = action.schema) == null ? void 0 : _f.input) {
4242
4265
  const validateResult = jsonschema.validate(
4243
4266
  input,
4244
4267
  action.schema.input
@@ -4254,7 +4277,7 @@ class NunjucksWorkflowRunner {
4254
4277
  const stepOutput = {};
4255
4278
  await action.handler({
4256
4279
  input,
4257
- secrets: (_e = task.secrets) != null ? _e : {},
4280
+ secrets: (_g = task.secrets) != null ? _g : {},
4258
4281
  logger: taskLogger,
4259
4282
  logStream: streamLogger,
4260
4283
  workspacePath,
@@ -4268,7 +4291,9 @@ class NunjucksWorkflowRunner {
4268
4291
  output(name, value) {
4269
4292
  stepOutput[name] = value;
4270
4293
  },
4271
- templateInfo: task.spec.templateInfo
4294
+ templateInfo: task.spec.templateInfo,
4295
+ user: task.spec.user,
4296
+ isDryRun: task.isDryRun
4272
4297
  });
4273
4298
  for (const tmpDir of tmpDirs) {
4274
4299
  await fs__default["default"].remove(tmpDir);