@backstage/plugin-scaffolder-backend 1.16.2 → 1.16.3-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.
package/CHANGELOG.md CHANGED
@@ -1,33 +1,31 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
- ## 1.16.2
3
+ ## 1.16.3-next.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - a4989552d828: Add examples for `publish:github` and `publish:gitlab` scaffolder actions.
8
+ - 5f1a92b9f19f: Use `DefaultAzureDevOpsCredentialsProvider` to retrieve credentials for Azure DevOps.
9
+ - fb57a4694fc6: Fixed the plugin and module ID of the alpha `catalogModuleTemplateKind` export.
10
+ - cfc3ca6ce060: Changes needed to support MySQL
7
11
  - Updated dependencies
8
- - @backstage/integration@1.6.1
9
- - @backstage/plugin-catalog-backend@1.12.1
10
- - @backstage/backend-common@0.19.3
11
- - @backstage/plugin-scaffolder-node@0.2.1
12
- - @backstage/backend-tasks@0.5.6
13
- - @backstage/plugin-auth-node@0.2.18
14
- - @backstage/plugin-catalog-node@1.4.2
15
- - @backstage/plugin-permission-node@0.7.12
16
- - @backstage/backend-plugin-api@0.6.1
12
+ - @backstage/plugin-catalog-backend@1.12.2-next.0
13
+ - @backstage/plugin-auth-node@0.3.0-next.0
14
+ - @backstage/backend-common@0.19.4-next.0
15
+ - @backstage/integration@1.7.0-next.0
16
+ - @backstage/backend-tasks@0.5.7-next.0
17
+ - @backstage/backend-plugin-api@0.6.2-next.0
17
18
  - @backstage/catalog-client@1.4.3
18
19
  - @backstage/catalog-model@1.4.1
19
20
  - @backstage/config@1.0.8
20
21
  - @backstage/errors@1.2.1
21
22
  - @backstage/types@1.1.0
22
23
  - @backstage/plugin-catalog-common@1.0.15
24
+ - @backstage/plugin-catalog-node@1.4.3-next.0
23
25
  - @backstage/plugin-permission-common@0.7.7
26
+ - @backstage/plugin-permission-node@0.7.13-next.0
24
27
  - @backstage/plugin-scaffolder-common@1.4.0
25
-
26
- ## 1.16.1
27
-
28
- ### Patch Changes
29
-
30
- - 2ba07bcdb046: Fixed the plugin and module ID of the alpha `catalogModuleTemplateKind` export.
28
+ - @backstage/plugin-scaffolder-node@0.2.2-next.0
31
29
 
32
30
  ## 1.16.0
33
31
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.16.2",
3
+ "version": "1.16.3-next.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-4b7489dd.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-a60339ce.cjs.js');
8
8
  var alpha$1 = require('@backstage/plugin-scaffolder-common/alpha');
9
9
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
10
10
  var backendCommon = require('@backstage/backend-common');
@@ -81,7 +81,7 @@ var winston__namespace = /*#__PURE__*/_interopNamespace(winston);
81
81
  var nunjucks__default = /*#__PURE__*/_interopDefaultLegacy(nunjucks);
82
82
  var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
83
83
 
84
- const examples$b = [
84
+ const examples$d = [
85
85
  {
86
86
  description: "Register with the catalog",
87
87
  example: yaml__default["default"].stringify({
@@ -105,7 +105,7 @@ function createCatalogRegisterAction(options) {
105
105
  return pluginScaffolderNode.createTemplateAction({
106
106
  id: id$4,
107
107
  description: "Registers entities from a catalog descriptor file in the workspace into the software catalog.",
108
- examples: examples$b,
108
+ examples: examples$d,
109
109
  schema: {
110
110
  input: {
111
111
  oneOf: [
@@ -229,7 +229,7 @@ function createCatalogRegisterAction(options) {
229
229
  });
230
230
  }
231
231
 
232
- const examples$a = [
232
+ const examples$c = [
233
233
  {
234
234
  description: "Write a catalog yaml file",
235
235
  example: yaml__namespace.stringify({
@@ -273,7 +273,7 @@ function createCatalogWriteAction() {
273
273
  )
274
274
  })
275
275
  },
276
- examples: examples$a,
276
+ examples: examples$c,
277
277
  supportsDryRun: true,
278
278
  async handler(ctx) {
279
279
  ctx.logStream.write(`Writing catalog-info.yaml`);
@@ -287,7 +287,7 @@ function createCatalogWriteAction() {
287
287
  });
288
288
  }
289
289
 
290
- const examples$9 = [
290
+ const examples$b = [
291
291
  {
292
292
  description: "Fetch entity by reference",
293
293
  example: yaml__default["default"].stringify({
@@ -326,7 +326,7 @@ function createFetchCatalogEntityAction(options) {
326
326
  return pluginScaffolderNode.createTemplateAction({
327
327
  id: id$2,
328
328
  description: "Returns entity or entities from the catalog by entity reference(s)",
329
- examples: examples$9,
329
+ examples: examples$b,
330
330
  supportsDryRun: true,
331
331
  schema: {
332
332
  input: zod.z.object({
@@ -401,7 +401,7 @@ function createFetchCatalogEntityAction(options) {
401
401
  });
402
402
  }
403
403
 
404
- const examples$8 = [
404
+ const examples$a = [
405
405
  {
406
406
  description: "Write a debug message",
407
407
  example: yaml__default["default"].stringify({
@@ -439,7 +439,7 @@ function createDebugLogAction() {
439
439
  return pluginScaffolderNode.createTemplateAction({
440
440
  id: id$1,
441
441
  description: "Writes a message into the log or lists all files in the workspace.",
442
- examples: examples$8,
442
+ examples: examples$a,
443
443
  schema: {
444
444
  input: {
445
445
  type: "object",
@@ -486,7 +486,7 @@ async function recursiveReadDir(dir) {
486
486
  return files.reduce((a, f) => a.concat(f), []);
487
487
  }
488
488
 
489
- const examples$7 = [
489
+ const examples$9 = [
490
490
  {
491
491
  description: "Waiting for 50 milliseconds",
492
492
  example: yaml__default["default"].stringify({
@@ -549,7 +549,7 @@ function createWaitAction(options) {
549
549
  return pluginScaffolderNode.createTemplateAction({
550
550
  id,
551
551
  description: "Waits for a certain period of time.",
552
- examples: examples$7,
552
+ examples: examples$9,
553
553
  schema: {
554
554
  input: {
555
555
  type: "object",
@@ -594,7 +594,7 @@ function createWaitAction(options) {
594
594
  });
595
595
  }
596
596
 
597
- const examples$6 = [
597
+ const examples$8 = [
598
598
  {
599
599
  description: "Downloads content and places it in the workspace.",
600
600
  example: yaml__default["default"].stringify({
@@ -633,7 +633,7 @@ function createFetchPlainAction(options) {
633
633
  const { reader, integrations } = options;
634
634
  return pluginScaffolderNode.createTemplateAction({
635
635
  id: ACTION_ID,
636
- examples: examples$6,
636
+ examples: examples$8,
637
637
  description: "Downloads content and places it in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
638
638
  schema: {
639
639
  input: {
@@ -670,7 +670,7 @@ function createFetchPlainAction(options) {
670
670
  });
671
671
  }
672
672
 
673
- const examples$5 = [
673
+ const examples$7 = [
674
674
  {
675
675
  description: "Downloads a file and places it in the workspace.",
676
676
  example: yaml__default["default"].stringify({
@@ -694,7 +694,7 @@ function createFetchPlainFileAction(options) {
694
694
  return pluginScaffolderNode.createTemplateAction({
695
695
  id: "fetch:plain:file",
696
696
  description: "Downloads single file and places it in the workspace.",
697
- examples: examples$5,
697
+ examples: examples$7,
698
698
  schema: {
699
699
  input: {
700
700
  type: "object",
@@ -962,7 +962,7 @@ const createDefaultFilters = ({
962
962
  };
963
963
  };
964
964
 
965
- const examples$4 = [
965
+ const examples$6 = [
966
966
  {
967
967
  description: "Downloads a skelaton directory that lives alongside the template file and fill it out with values.",
968
968
  example: yaml__default["default"].stringify({
@@ -998,7 +998,7 @@ function createFetchTemplateAction(options) {
998
998
  return pluginScaffolderNode.createTemplateAction({
999
999
  id: "fetch:template",
1000
1000
  description: "Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
1001
- examples: examples$4,
1001
+ examples: examples$6,
1002
1002
  schema: {
1003
1003
  input: {
1004
1004
  type: "object",
@@ -1203,7 +1203,7 @@ function containsSkippedContent(localOutputPath) {
1203
1203
  return localOutputPath === "" || localOutputPath.startsWith("/") || localOutputPath.includes("//");
1204
1204
  }
1205
1205
 
1206
- const examples$3 = [
1206
+ const examples$5 = [
1207
1207
  {
1208
1208
  description: "Delete specified files",
1209
1209
  example: yaml__namespace.stringify({
@@ -1225,7 +1225,7 @@ const createFilesystemDeleteAction = () => {
1225
1225
  return pluginScaffolderNode.createTemplateAction({
1226
1226
  id: "fs:delete",
1227
1227
  description: "Deletes files and directories from the workspace",
1228
- examples: examples$3,
1228
+ examples: examples$5,
1229
1229
  schema: {
1230
1230
  input: {
1231
1231
  required: ["files"],
@@ -1262,7 +1262,7 @@ const createFilesystemDeleteAction = () => {
1262
1262
  });
1263
1263
  };
1264
1264
 
1265
- const examples$2 = [
1265
+ const examples$4 = [
1266
1266
  {
1267
1267
  description: "Rename specified files ",
1268
1268
  example: yaml__namespace.stringify({
@@ -1288,7 +1288,7 @@ const createFilesystemRenameAction = () => {
1288
1288
  return pluginScaffolderNode.createTemplateAction({
1289
1289
  id: "fs:rename",
1290
1290
  description: "Renames files and directories within the workspace",
1291
- examples: examples$2,
1291
+ examples: examples$4,
1292
1292
  schema: {
1293
1293
  input: {
1294
1294
  required: ["files"],
@@ -2170,7 +2170,7 @@ const commitHash = {
2170
2170
  type: "string"
2171
2171
  };
2172
2172
 
2173
- const examples$1 = [
2173
+ const examples$3 = [
2174
2174
  {
2175
2175
  description: "Creates a GitHub repository with default configuration.",
2176
2176
  example: yaml__default["default"].stringify({
@@ -2223,7 +2223,7 @@ function createGithubRepoCreateAction(options) {
2223
2223
  return pluginScaffolderNode.createTemplateAction({
2224
2224
  id: "github:repo:create",
2225
2225
  description: "Creates a GitHub repository.",
2226
- examples: examples$1,
2226
+ examples: examples$3,
2227
2227
  schema: {
2228
2228
  input: {
2229
2229
  type: "object",
@@ -2330,7 +2330,7 @@ function createGithubRepoCreateAction(options) {
2330
2330
  });
2331
2331
  }
2332
2332
 
2333
- const examples = [
2333
+ const examples$2 = [
2334
2334
  {
2335
2335
  description: "Setup repo with no modifications to branch protection rules",
2336
2336
  example: yaml__default["default"].stringify({
@@ -2382,7 +2382,7 @@ function createGithubRepoPushAction(options) {
2382
2382
  return pluginScaffolderNode.createTemplateAction({
2383
2383
  id: "github:repo:push",
2384
2384
  description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
2385
- examples,
2385
+ examples: examples$2,
2386
2386
  schema: {
2387
2387
  input: {
2388
2388
  type: "object",
@@ -2929,7 +2929,7 @@ function createPublishAzureAction(options) {
2929
2929
  }
2930
2930
  },
2931
2931
  async handler(ctx) {
2932
- var _a;
2932
+ var _a, _b;
2933
2933
  const {
2934
2934
  repoUrl,
2935
2935
  defaultBranch = "master",
@@ -2946,18 +2946,16 @@ function createPublishAzureAction(options) {
2946
2946
  `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`
2947
2947
  );
2948
2948
  }
2949
- const integrationConfig = integrations.azure.byHost(host);
2950
- if (!integrationConfig) {
2949
+ const url = `https://${host}/${organization}`;
2950
+ const credentialProvider = integration.DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);
2951
+ const credentials = await credentialProvider.getCredentials({ url });
2952
+ if (credentials === void 0 && ctx.input.token === void 0) {
2951
2953
  throw new errors.InputError(
2952
- `No matching integration configuration for host ${host}, please check your integrations config`
2954
+ `No credentials provided ${url}, please check your integrations config`
2953
2955
  );
2954
2956
  }
2955
- if (!integrationConfig.config.token && !ctx.input.token) {
2956
- throw new errors.InputError(`No token provided for Azure Integration ${host}`);
2957
- }
2958
- const token = (_a = ctx.input.token) != null ? _a : integrationConfig.config.token;
2959
- const authHandler = azureDevopsNodeApi.getPersonalAccessTokenHandler(token);
2960
- const webApi = new azureDevopsNodeApi.WebApi(`https://${host}/${organization}`, authHandler);
2957
+ const authHandler = ctx.input.token || (credentials == null ? void 0 : credentials.type) === "pat" ? azureDevopsNodeApi.getPersonalAccessTokenHandler((_a = ctx.input.token) != null ? _a : credentials.token) : azureDevopsNodeApi.getBearerHandler(credentials.token);
2958
+ const webApi = new azureDevopsNodeApi.WebApi(url, authHandler);
2961
2959
  const client = await webApi.getGitApi();
2962
2960
  const createOptions = { name: repo };
2963
2961
  const returnedRepo = await client.createRepository(createOptions, owner);
@@ -2982,14 +2980,15 @@ function createPublishAzureAction(options) {
2982
2980
  name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
2983
2981
  email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
2984
2982
  };
2983
+ const auth = ctx.input.token || (credentials == null ? void 0 : credentials.type) === "pat" ? {
2984
+ username: "notempty",
2985
+ password: (_b = ctx.input.token) != null ? _b : credentials.token
2986
+ } : { token: credentials.token };
2985
2987
  const commitResult = await initRepoAndPush({
2986
2988
  dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
2987
2989
  remoteUrl,
2988
2990
  defaultBranch,
2989
- auth: {
2990
- username: "notempty",
2991
- password: token
2992
- },
2991
+ auth,
2993
2992
  logger: ctx.logger,
2994
2993
  commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
2995
2994
  gitAuthorInfo
@@ -4166,11 +4165,63 @@ Change-Id: ${changeId}`;
4166
4165
  });
4167
4166
  }
4168
4167
 
4168
+ const examples$1 = [
4169
+ {
4170
+ description: "Initializes a git repository of contents in workspace and publish it to GitHub with default configuration.",
4171
+ example: yaml__default["default"].stringify({
4172
+ steps: [
4173
+ {
4174
+ id: "publish",
4175
+ action: "publish:github",
4176
+ name: "Publish to GitHub",
4177
+ input: {
4178
+ repoUrl: "github.com?repo=repo&owner=owner"
4179
+ }
4180
+ }
4181
+ ]
4182
+ })
4183
+ },
4184
+ {
4185
+ description: "Add a description.",
4186
+ example: yaml__default["default"].stringify({
4187
+ steps: [
4188
+ {
4189
+ id: "publish",
4190
+ action: "publish:github",
4191
+ name: "Publish to GitHub",
4192
+ input: {
4193
+ repoUrl: "github.com?repo=repo&owner=owner",
4194
+ description: "Initialize a git repository"
4195
+ }
4196
+ }
4197
+ ]
4198
+ })
4199
+ },
4200
+ {
4201
+ description: "Change visibility of the repository.",
4202
+ example: yaml__default["default"].stringify({
4203
+ steps: [
4204
+ {
4205
+ id: "publish",
4206
+ action: "publish:github",
4207
+ name: "Publish to GitHub",
4208
+ input: {
4209
+ repoUrl: "github.com?repo=repo&owner=owner",
4210
+ description: "Initialize a git repository",
4211
+ repoVisibility: "public"
4212
+ }
4213
+ }
4214
+ ]
4215
+ })
4216
+ }
4217
+ ];
4218
+
4169
4219
  function createPublishGithubAction(options) {
4170
4220
  const { integrations, config, githubCredentialsProvider } = options;
4171
4221
  return pluginScaffolderNode.createTemplateAction({
4172
4222
  id: "publish:github",
4173
4223
  description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
4224
+ examples: examples$1,
4174
4225
  schema: {
4175
4226
  input: {
4176
4227
  type: "object",
@@ -4648,11 +4699,63 @@ const createPublishGithubPullRequestAction = (options) => {
4648
4699
  }
4649
4700
  };
4650
4701
 
4702
+ const examples = [
4703
+ {
4704
+ description: "Initializes a git repository of the content in the workspace, and publishes it to GitLab.",
4705
+ example: yaml__default["default"].stringify({
4706
+ steps: [
4707
+ {
4708
+ id: "publish",
4709
+ action: "publish:gitlab",
4710
+ name: "Publish to GitLab",
4711
+ input: {
4712
+ repoUrl: "gitlab.com?repo=project_name&owner=group_name"
4713
+ }
4714
+ }
4715
+ ]
4716
+ })
4717
+ },
4718
+ {
4719
+ description: "Add a description.",
4720
+ example: yaml__default["default"].stringify({
4721
+ steps: [
4722
+ {
4723
+ id: "publish",
4724
+ action: "publish:gitlab",
4725
+ name: "Publish to GitLab",
4726
+ input: {
4727
+ repoUrl: "gitlab.com?repo=project_name&owner=group_name",
4728
+ description: "Initialize a git repository"
4729
+ }
4730
+ }
4731
+ ]
4732
+ })
4733
+ },
4734
+ {
4735
+ description: "Sets the commit message on the repository. The default value is `initial commit`.",
4736
+ example: yaml__default["default"].stringify({
4737
+ steps: [
4738
+ {
4739
+ id: "publish",
4740
+ action: "publish:gitlab",
4741
+ name: "Publish to GitLab",
4742
+ input: {
4743
+ repoUrl: "gitlab.com?repo=project_name&owner=group_name",
4744
+ description: "Initialize a git repository",
4745
+ gitCommitMessage: "Started a project."
4746
+ }
4747
+ }
4748
+ ]
4749
+ })
4750
+ }
4751
+ ];
4752
+
4651
4753
  function createPublishGitlabAction(options) {
4652
4754
  const { integrations, config } = options;
4653
4755
  return pluginScaffolderNode.createTemplateAction({
4654
4756
  id: "publish:gitlab",
4655
4757
  description: "Initializes a git repository of the content in the workspace, and publishes it to GitLab.",
4758
+ examples,
4656
4759
  schema: {
4657
4760
  input: {
4658
4761
  type: "object",
@@ -5306,13 +5409,19 @@ class DatabaseTaskStore {
5306
5409
  }
5307
5410
  async listStaleTasks(options) {
5308
5411
  const { timeoutS } = options;
5309
- const rawRows = await this.db("tasks").where("status", "processing").andWhere(
5310
- "last_heartbeat_at",
5311
- "<=",
5312
- this.db.client.config.client.includes("sqlite3") ? this.db.raw(`datetime('now', ?)`, [`-${timeoutS} seconds`]) : this.db.raw(`? - interval '${timeoutS} seconds'`, [
5313
- this.db.fn.now()
5314
- ])
5315
- );
5412
+ let heartbeatInterval = this.db.raw(`? - interval '${timeoutS} seconds'`, [
5413
+ this.db.fn.now()
5414
+ ]);
5415
+ if (this.db.client.config.client.includes("mysql")) {
5416
+ heartbeatInterval = this.db.raw(
5417
+ `date_sub(now(), interval ${timeoutS} second)`
5418
+ );
5419
+ } else if (this.db.client.config.client.includes("sqlite3")) {
5420
+ heartbeatInterval = this.db.raw(`datetime('now', ?)`, [
5421
+ `-${timeoutS} seconds`
5422
+ ]);
5423
+ }
5424
+ const rawRows = await this.db("tasks").where("status", "processing").andWhere("last_heartbeat_at", "<=", heartbeatInterval);
5316
5425
  const tasks = rawRows.map((row) => ({
5317
5426
  taskId: row.id
5318
5427
  }));
@@ -6995,4 +7104,4 @@ exports.createRouter = createRouter;
6995
7104
  exports.createWaitAction = createWaitAction;
6996
7105
  exports.scaffolderActionRules = scaffolderActionRules;
6997
7106
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
6998
- //# sourceMappingURL=ScaffolderEntitiesProcessor-4b7489dd.cjs.js.map
7107
+ //# sourceMappingURL=ScaffolderEntitiesProcessor-a60339ce.cjs.js.map