@backstage/plugin-scaffolder-backend 0.17.2 → 0.18.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/dist/index.d.ts CHANGED
@@ -5,18 +5,21 @@ import { Logger } from 'winston';
5
5
  import { Writable } from 'stream';
6
6
  import { JsonValue, JsonObject, Observable } from '@backstage/types';
7
7
  import { Schema } from 'jsonschema';
8
- import { TaskSpec, TemplateMetadata, TemplateInfo } from '@backstage/plugin-scaffolder-common';
8
+ import * as _backstage_plugin_scaffolder_common from '@backstage/plugin-scaffolder-common';
9
+ import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common';
9
10
  import { Entity } from '@backstage/catalog-model';
10
- import { UrlReader, ContainerRunner, PluginDatabaseManager } from '@backstage/backend-common';
11
+ import { UrlReader, PluginDatabaseManager } from '@backstage/backend-common';
11
12
  import { Config } from '@backstage/config';
12
13
  import { createPullRequest } from 'octokit-plugin-create-pull-request';
13
- import { Octokit } from 'octokit';
14
- export { createFetchCookiecutterAction } from '@backstage/plugin-scaffolder-backend-module-cookiecutter';
15
14
  import { SpawnOptionsWithoutStdio } from 'child_process';
16
15
  import { Knex } from 'knex';
17
16
  import express from 'express';
18
17
  import { CatalogProcessor, LocationSpec, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
19
18
 
19
+ /**
20
+ * Registers entities from a catalog descriptor file in the workspace into the software catalog.
21
+ * @public
22
+ */
20
23
  declare function createCatalogRegisterAction(options: {
21
24
  catalogClient: CatalogApi;
22
25
  integrations: ScmIntegrations;
@@ -29,11 +32,16 @@ declare function createCatalogRegisterAction(options: {
29
32
  optional?: boolean | undefined;
30
33
  }>;
31
34
 
35
+ /**
36
+ * Writes a catalog descriptor file containing the provided entity to a path in the workspace.
37
+ * @public
38
+ */
32
39
  declare function createCatalogWriteAction(): TemplateAction<{
33
40
  filePath?: string | undefined;
34
41
  entity: Entity;
35
42
  }>;
36
43
 
44
+ /** @public */
37
45
  declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
38
46
 
39
47
  /**
@@ -42,26 +50,12 @@ declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
42
50
  * @public
43
51
  */
44
52
  declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
45
- /**
46
- * The status of each step of the Task
47
- *
48
- * @public
49
- * @deprecated use TaskStatus instead
50
- */
51
- declare type Status = TaskStatus;
52
53
  /**
53
54
  * The state of a completed task.
54
55
  *
55
56
  * @public
56
57
  */
57
58
  declare type TaskCompletionState = 'failed' | 'completed';
58
- /**
59
- * The state of a completed task.
60
- *
61
- * @public
62
- * @deprecated use TaskCompletionState instead
63
- */
64
- declare type CompletedTaskState = TaskCompletionState;
65
59
  /**
66
60
  * SerializedTask
67
61
  *
@@ -119,13 +113,6 @@ declare type TaskBrokerDispatchOptions = {
119
113
  spec: TaskSpec;
120
114
  secrets?: TaskSecrets;
121
115
  };
122
- /**
123
- * DispatchResult
124
- *
125
- * @public
126
- * @deprecated use TaskBrokerDispatchResult instead
127
- */
128
- declare type DispatchResult = TaskBrokerDispatchResult;
129
116
  /**
130
117
  * Task
131
118
  *
@@ -219,12 +206,11 @@ interface TaskStore {
219
206
  }>;
220
207
  }
221
208
 
209
+ /**
210
+ * ActionContext is passed into scaffolder actions.
211
+ * @public
212
+ */
222
213
  declare type ActionContext<Input extends JsonObject> = {
223
- /**
224
- * Base URL for the location of the task spec, typically the url of the source entity file.
225
- * @deprecated please use templateInfo.baseUrl instead
226
- */
227
- baseUrl?: string;
228
214
  logger: Logger;
229
215
  logStream: Writable;
230
216
  secrets?: TaskSecrets;
@@ -235,12 +221,9 @@ declare type ActionContext<Input extends JsonObject> = {
235
221
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
236
222
  */
237
223
  createTemporaryDirectory(): Promise<string>;
238
- /**
239
- * @deprecated please use templateInfo instead
240
- */
241
- metadata?: TemplateMetadata;
242
224
  templateInfo?: TemplateInfo;
243
225
  };
226
+ /** @public */
244
227
  declare type TemplateAction<Input extends JsonObject> = {
245
228
  id: string;
246
229
  description?: string;
@@ -259,8 +242,6 @@ interface CreateBuiltInActionsOptions {
259
242
  reader: UrlReader;
260
243
  integrations: ScmIntegrations;
261
244
  catalogClient: CatalogApi;
262
- /** @deprecated when the cookiecutter action is removed this won't be necessary */
263
- containerRunner?: ContainerRunner;
264
245
  config: Config;
265
246
  additionalTemplateFilters?: Record<string, TemplateFilter>;
266
247
  }
@@ -274,14 +255,25 @@ interface CreateBuiltInActionsOptions {
274
255
  declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => TemplateAction<JsonObject>[];
275
256
 
276
257
  /**
258
+ * Writes a message into the log or lists all files in the workspace
259
+ *
260
+ * @remarks
261
+ *
277
262
  * This task is useful for local development and testing of both the scaffolder
278
263
  * and scaffolder templates.
264
+ *
265
+ * @public
279
266
  */
280
267
  declare function createDebugLogAction(): TemplateAction<{
281
268
  message?: string | undefined;
282
269
  listWorkspace?: boolean | undefined;
283
270
  }>;
284
271
 
272
+ /**
273
+ * Downloads content and places it in the workspace, or optionally
274
+ * in a subdirectory specified by the 'targetPath' input option.
275
+ * @public
276
+ */
285
277
  declare function createFetchPlainAction(options: {
286
278
  reader: UrlReader;
287
279
  integrations: ScmIntegrations;
@@ -290,6 +282,13 @@ declare function createFetchPlainAction(options: {
290
282
  targetPath?: string | undefined;
291
283
  }>;
292
284
 
285
+ /**
286
+ * Downloads a skeleton, templates variables into file and directory names and content.
287
+ * Then places the result in the workspace, or optionally in a subdirectory
288
+ * specified by the 'targetPath' input option.
289
+ *
290
+ * @public
291
+ */
293
292
  declare function createFetchTemplateAction(options: {
294
293
  reader: UrlReader;
295
294
  integrations: ScmIntegrations;
@@ -317,10 +316,18 @@ declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, output
317
316
  outputPath: string;
318
317
  }): Promise<void>;
319
318
 
319
+ /**
320
+ * Creates new action that enables deletion of files and directories in the workspace.
321
+ * @public
322
+ */
320
323
  declare const createFilesystemDeleteAction: () => TemplateAction<{
321
324
  files: string[];
322
325
  }>;
323
326
 
327
+ /**
328
+ * Creates a new action that allows renames of files and directories in the workspace.
329
+ * @public
330
+ */
324
331
  declare const createFilesystemRenameAction: () => TemplateAction<{
325
332
  files: Array<{
326
333
  from: string;
@@ -329,6 +336,11 @@ declare const createFilesystemRenameAction: () => TemplateAction<{
329
336
  }>;
330
337
  }>;
331
338
 
339
+ /**
340
+ * Creates a new action that initializes a git repository of the content in the workspace
341
+ * and publishes it to Azure.
342
+ * @public
343
+ */
332
344
  declare function createPublishAzureAction(options: {
333
345
  integrations: ScmIntegrationRegistry;
334
346
  config: Config;
@@ -340,6 +352,11 @@ declare function createPublishAzureAction(options: {
340
352
  token?: string | undefined;
341
353
  }>;
342
354
 
355
+ /**
356
+ * Creates a new action that initializes a git repository of the content in the workspace
357
+ * and publishes it to Bitbucket.
358
+ * @public
359
+ */
343
360
  declare function createPublishBitbucketAction(options: {
344
361
  integrations: ScmIntegrationRegistry;
345
362
  config: Config;
@@ -357,13 +374,23 @@ declare function createPublishBitbucketAction(options: {
357
374
  * This task is useful for local development and testing of both the scaffolder
358
375
  * and scaffolder templates.
359
376
  *
377
+ * @remarks
378
+ *
360
379
  * This action is not installed by default and should not be installed in
361
380
  * production, as it writes the files to the local filesystem of the scaffolder.
381
+ *
382
+ * @public
362
383
  */
363
384
  declare function createPublishFileAction(): TemplateAction<{
364
385
  path: string;
365
386
  }>;
366
387
 
388
+ /**
389
+ * Creates a new action that initializes a git repository of the content in the workspace
390
+ * and publishes it to GitHub.
391
+ *
392
+ * @public
393
+ */
367
394
  declare function createPublishGithubAction(options: {
368
395
  integrations: ScmIntegrationRegistry;
369
396
  config: Config;
@@ -373,6 +400,10 @@ declare function createPublishGithubAction(options: {
373
400
  description?: string | undefined;
374
401
  access?: string | undefined;
375
402
  defaultBranch?: string | undefined;
403
+ deleteBranchOnMerge?: boolean | undefined;
404
+ allowRebaseMerge?: boolean | undefined;
405
+ allowSquashMerge?: boolean | undefined;
406
+ allowMergeCommit?: boolean | undefined;
376
407
  sourcePath?: string | undefined;
377
408
  requireCodeOwnerReviews?: boolean | undefined;
378
409
  repoVisibility?: "internal" | "private" | "public" | undefined;
@@ -384,15 +415,16 @@ declare function createPublishGithubAction(options: {
384
415
  topics?: string[] | undefined;
385
416
  }>;
386
417
 
387
- declare type CreatePullRequestResponse = {
388
- data: {
389
- html_url: string;
390
- };
391
- };
392
- interface PullRequestCreator {
393
- createPullRequest(options: createPullRequest.Options): Promise<CreatePullRequestResponse | null>;
418
+ /** @public */
419
+ interface OctokitWithPullRequestPluginClient {
420
+ createPullRequest(options: createPullRequest.Options): Promise<{
421
+ data: {
422
+ html_url: string;
423
+ };
424
+ } | null>;
394
425
  }
395
- declare type ClientFactoryInput = {
426
+ /** @public */
427
+ declare type CreateGithubPullRequestClientFactoryInput = {
396
428
  integrations: ScmIntegrationRegistry;
397
429
  githubCredentialsProvider?: GithubCredentialsProvider;
398
430
  host: string;
@@ -400,11 +432,16 @@ declare type ClientFactoryInput = {
400
432
  repo: string;
401
433
  token?: string;
402
434
  };
435
+ /** @public */
403
436
  interface CreateGithubPullRequestActionOptions {
404
437
  integrations: ScmIntegrationRegistry;
405
438
  githubCredentialsProvider?: GithubCredentialsProvider;
406
- clientFactory?: (input: ClientFactoryInput) => Promise<PullRequestCreator>;
439
+ clientFactory?: (input: CreateGithubPullRequestClientFactoryInput) => Promise<OctokitWithPullRequestPluginClient>;
407
440
  }
441
+ /**
442
+ * Creates a Github Pull Request action.
443
+ * @public
444
+ */
408
445
  declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<{
409
446
  title: string;
410
447
  branchName: string;
@@ -415,6 +452,12 @@ declare const createPublishGithubPullRequestAction: ({ integrations, githubCrede
415
452
  token?: string | undefined;
416
453
  }>;
417
454
 
455
+ /**
456
+ * Creates a new action that initializes a git repository of the content in the workspace
457
+ * and publishes it to GitLab.
458
+ *
459
+ * @public
460
+ */
418
461
  declare function createPublishGitlabAction(options: {
419
462
  integrations: ScmIntegrationRegistry;
420
463
  config: Config;
@@ -426,6 +469,11 @@ declare function createPublishGitlabAction(options: {
426
469
  token?: string | undefined;
427
470
  }>;
428
471
 
472
+ /**
473
+ * Create a new action that creates a gitlab merge request.
474
+ *
475
+ * @public
476
+ */
429
477
  declare const createPublishGitlabMergeRequestAction: (options: {
430
478
  integrations: ScmIntegrationRegistry;
431
479
  }) => TemplateAction<{
@@ -438,6 +486,10 @@ declare const createPublishGitlabMergeRequestAction: (options: {
438
486
  token?: string | undefined;
439
487
  }>;
440
488
 
489
+ /**
490
+ * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.
491
+ * @public
492
+ */
441
493
  declare function createGithubActionsDispatchAction(options: {
442
494
  integrations: ScmIntegrations;
443
495
  githubCredentialsProvider?: GithubCredentialsProvider;
@@ -451,6 +503,10 @@ declare function createGithubActionsDispatchAction(options: {
451
503
  token?: string | undefined;
452
504
  }>;
453
505
 
506
+ /**
507
+ * Creates new action that creates a webhook for a repository on GitHub.
508
+ * @public
509
+ */
454
510
  declare function createGithubWebhookAction(options: {
455
511
  integrations: ScmIntegrationRegistry;
456
512
  defaultWebhookSecret?: string;
@@ -466,36 +522,7 @@ declare function createGithubWebhookAction(options: {
466
522
  token?: string | undefined;
467
523
  }>;
468
524
 
469
- declare type OctokitIntegration = {
470
- client: Octokit;
471
- token: string;
472
- owner: string;
473
- repo: string;
474
- };
475
- /**
476
- * OctokitProvider provides Octokit client based on ScmIntegrationsRegistry configuration.
477
- * OctokitProvider supports GitHub credentials caching out of the box.
478
- *
479
- * @deprecated we are no longer providing a way from the scaffolder to generate octokit instances.
480
- * Implement your own if you're using this method from an external package, or use the internal `getOctokitOptions` function instead
481
- */
482
- declare class OctokitProvider {
483
- private readonly integrations;
484
- private readonly githubCredentialsProvider;
485
- constructor(integrations: ScmIntegrationRegistry, githubCredentialsProvider?: GithubCredentialsProvider);
486
- /**
487
- * gets standard Octokit client based on repository URL.
488
- *
489
- * @param repoUrl - Repository URL
490
- *
491
- * @deprecated we are no longer providing a way from the scaffolder to generate octokit instances.
492
- * Implement your own if you're using this method from an external package, or use the internal `getOctokitOptions` function instead
493
- */
494
- getOctokit(repoUrl: string, options?: {
495
- token?: string;
496
- }): Promise<OctokitIntegration>;
497
- }
498
-
525
+ /** @public */
499
526
  declare type RunCommandOptions = {
500
527
  /** command to run */
501
528
  command: string;
@@ -512,13 +539,11 @@ declare type RunCommandOptions = {
512
539
  * @public
513
540
  */
514
541
  declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
542
+
515
543
  /**
516
- * Run a command in a sub-process, normally a shell command.
544
+ * Registry of all registered template actions.
517
545
  * @public
518
- * @deprecated use {@link executeShellCommand} instead
519
546
  */
520
- declare const runCommand: (options: RunCommandOptions) => Promise<void>;
521
-
522
547
  declare class TemplateActionRegistry {
523
548
  private readonly actions;
524
549
  register<TInput extends JsonObject>(action: TemplateAction<TInput>): void;
@@ -526,6 +551,10 @@ declare class TemplateActionRegistry {
526
551
  list(): TemplateAction<JsonObject>[];
527
552
  }
528
553
 
554
+ /**
555
+ * This function is used to create new template actions to get type safety.
556
+ * @public
557
+ */
529
558
  declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
530
559
 
531
560
  /**
@@ -582,7 +611,7 @@ declare class TaskManager implements TaskContext {
582
611
  private heartbeatTimeoutId?;
583
612
  static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
584
613
  private constructor();
585
- get spec(): TaskSpec;
614
+ get spec(): _backstage_plugin_scaffolder_common.TaskSpecV1beta3;
586
615
  get secrets(): TaskSecrets | undefined;
587
616
  getWorkspaceName(): Promise<string>;
588
617
  get done(): boolean;
@@ -600,13 +629,6 @@ interface CurrentClaimedTask {
600
629
  taskId: string;
601
630
  secrets?: TaskSecrets;
602
631
  }
603
- /**
604
- * TaskState
605
- *
606
- * @public
607
- * @deprecated use CurrentClaimedTask instead
608
- */
609
- declare type TaskState = CurrentClaimedTask;
610
632
 
611
633
  /**
612
634
  * CreateWorkerOptions
@@ -647,10 +669,10 @@ interface RouterOptions {
647
669
  catalogClient: CatalogApi;
648
670
  actions?: TemplateAction<any>[];
649
671
  taskWorkers?: number;
650
- containerRunner?: ContainerRunner;
651
672
  taskBroker?: TaskBroker;
652
673
  additionalTemplateFilters?: Record<string, TemplateFilter>;
653
674
  }
675
+ /** @public */
654
676
  declare function createRouter(options: RouterOptions): Promise<express.Router>;
655
677
 
656
678
  /** @public */
@@ -661,4 +683,4 @@ declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
661
683
  postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
662
684
  }
663
685
 
664
- export { ActionContext, CompletedTaskState, CreateBuiltInActionsOptions, CreateWorkerOptions, CurrentClaimedTask, DatabaseTaskStore, DispatchResult, OctokitProvider, RouterOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, Status, TaskBroker, TaskBrokerDispatchOptions, TaskBrokerDispatchResult, TaskCompletionState, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskState, TaskStatus, TaskStore, TaskStoreCreateTaskOptions, TaskStoreCreateTaskResult, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskWorker, TemplateAction, TemplateActionRegistry, TemplateFilter, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishFileAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createRouter, createTemplateAction, executeShellCommand, fetchContents, runCommand };
686
+ export { ActionContext, CreateBuiltInActionsOptions, CreateGithubPullRequestActionOptions, CreateGithubPullRequestClientFactoryInput, CreateWorkerOptions, CurrentClaimedTask, DatabaseTaskStore, DatabaseTaskStoreOptions, OctokitWithPullRequestPluginClient, RouterOptions, RunCommandOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, TaskBroker, TaskBrokerDispatchOptions, TaskBrokerDispatchResult, TaskCompletionState, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskStatus, TaskStore, TaskStoreCreateTaskOptions, TaskStoreCreateTaskResult, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskWorker, TemplateAction, TemplateActionRegistry, TemplateFilter, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishFileAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createRouter, createTemplateAction, executeShellCommand, fetchContents };
@@ -75,7 +75,7 @@ exports.up = async function up(knex) {
75
75
  * @param {import('knex').Knex} knex
76
76
  */
77
77
  exports.down = async function down(knex) {
78
- if (knex.client.config.client !== 'sqlite3') {
78
+ if (!knex.client.config.client.includes('sqlite3')) {
79
79
  await knex.schema.alterTable('task_events', table => {
80
80
  table.dropIndex([], 'task_events_task_id_idx');
81
81
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
3
  "description": "The Backstage backend plugin that helps you create new things",
4
- "version": "0.17.2",
4
+ "version": "0.18.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -34,15 +34,14 @@
34
34
  "build:assets": "node scripts/build-nunjucks.js"
35
35
  },
36
36
  "dependencies": {
37
- "@backstage/backend-common": "^0.11.0",
38
- "@backstage/catalog-client": "^0.7.2",
39
- "@backstage/catalog-model": "^0.11.0",
37
+ "@backstage/backend-common": "^0.13.0",
38
+ "@backstage/catalog-client": "^0.9.0",
39
+ "@backstage/catalog-model": "^0.13.0",
40
40
  "@backstage/config": "^0.1.15",
41
41
  "@backstage/errors": "^0.2.2",
42
- "@backstage/integration": "^0.7.5",
43
- "@backstage/plugin-catalog-backend": "^0.22.0",
44
- "@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.2.2",
45
- "@backstage/plugin-scaffolder-common": "^0.2.2",
42
+ "@backstage/integration": "^0.8.0",
43
+ "@backstage/plugin-catalog-backend": "^0.24.0",
44
+ "@backstage/plugin-scaffolder-common": "^0.3.0",
46
45
  "@backstage/types": "^0.1.3",
47
46
  "@gitbeaker/core": "^34.6.0",
48
47
  "@gitbeaker/node": "^35.1.0",
@@ -54,10 +53,9 @@
54
53
  "cors": "^2.8.5",
55
54
  "express": "^4.17.1",
56
55
  "express-promise-router": "^4.1.0",
57
- "fs-extra": "10.0.0",
56
+ "fs-extra": "10.0.1",
58
57
  "git-url-parse": "^11.6.0",
59
58
  "globby": "^11.0.0",
60
- "handlebars": "^4.7.6",
61
59
  "isbinaryfile": "^4.0.8",
62
60
  "isomorphic-git": "^1.8.0",
63
61
  "jsonschema": "^1.2.6",
@@ -76,8 +74,8 @@
76
74
  "zen-observable": "^0.8.15"
77
75
  },
78
76
  "devDependencies": {
79
- "@backstage/cli": "^0.14.1",
80
- "@backstage/test-utils": "^0.2.6",
77
+ "@backstage/backend-test-utils": "^0.1.21",
78
+ "@backstage/cli": "^0.15.2",
81
79
  "@types/command-exists": "^1.2.0",
82
80
  "@types/fs-extra": "^9.0.1",
83
81
  "@types/git-url-parse": "^9.0.0",
@@ -99,5 +97,5 @@
99
97
  "assets"
100
98
  ],
101
99
  "configSchema": "config.d.ts",
102
- "gitHead": "ec2472ce819b110dc9515f66275b77be83f77219"
100
+ "gitHead": "60c4e39d1fcaeb10d6488ada1d907f34dc2a105a"
103
101
  }