@backstage/plugin-scaffolder-backend 0.15.24 → 0.16.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/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.15.24",
4
+ "version": "0.16.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -11,6 +11,9 @@
11
11
  "main": "dist/index.cjs.js",
12
12
  "types": "dist/index.d.ts"
13
13
  },
14
+ "backstage": {
15
+ "role": "backend-plugin"
16
+ },
14
17
  "homepage": "https://backstage.io",
15
18
  "repository": {
16
19
  "type": "git",
@@ -21,26 +24,26 @@
21
24
  "backstage"
22
25
  ],
23
26
  "scripts": {
24
- "start": "backstage-cli backend:dev",
25
- "build": "backstage-cli backend:build",
26
- "lint": "backstage-cli lint",
27
- "test": "backstage-cli test",
28
- "prepack": "backstage-cli prepack",
29
- "postpack": "backstage-cli postpack",
30
- "clean": "backstage-cli clean",
27
+ "start": "backstage-cli package start",
28
+ "build": "backstage-cli package build",
29
+ "lint": "backstage-cli package lint",
30
+ "test": "backstage-cli package test",
31
+ "prepack": "backstage-cli package prepack",
32
+ "postpack": "backstage-cli package postpack",
33
+ "clean": "backstage-cli package clean",
31
34
  "build:assets": "node scripts/build-nunjucks.js"
32
35
  },
33
36
  "dependencies": {
34
- "@backstage/backend-common": "^0.10.7",
35
- "@backstage/catalog-client": "^0.6.0",
36
- "@backstage/catalog-model": "^0.9.10",
37
- "@backstage/config": "^0.1.13",
38
- "@backstage/errors": "^0.2.0",
39
- "@backstage/integration": "^0.7.2",
40
- "@backstage/plugin-catalog-backend": "^0.21.3",
41
- "@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.1.11",
42
- "@backstage/plugin-scaffolder-common": "^0.1.3",
43
- "@backstage/types": "^0.1.1",
37
+ "@backstage/backend-common": "^0.10.8",
38
+ "@backstage/catalog-client": "^0.7.0",
39
+ "@backstage/catalog-model": "^0.10.0",
40
+ "@backstage/config": "^0.1.14",
41
+ "@backstage/errors": "^0.2.1",
42
+ "@backstage/integration": "^0.7.3",
43
+ "@backstage/plugin-catalog-backend": "^0.21.4",
44
+ "@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.2.0",
45
+ "@backstage/plugin-scaffolder-common": "^0.2.0",
46
+ "@backstage/types": "^0.1.2",
44
47
  "@gitbeaker/core": "^34.6.0",
45
48
  "@gitbeaker/node": "^35.1.0",
46
49
  "@octokit/webhooks": "^9.14.1",
@@ -55,7 +58,6 @@
55
58
  "git-url-parse": "^11.6.0",
56
59
  "globby": "^11.0.0",
57
60
  "handlebars": "^4.7.6",
58
- "helmet": "^4.0.0",
59
61
  "isbinaryfile": "^4.0.8",
60
62
  "isomorphic-git": "^1.8.0",
61
63
  "jsonschema": "^1.2.6",
@@ -63,7 +65,7 @@
63
65
  "lodash": "^4.17.21",
64
66
  "luxon": "^2.0.2",
65
67
  "morgan": "^1.10.0",
66
- "node-fetch": "^2.6.1",
68
+ "node-fetch": "^2.6.7",
67
69
  "nunjucks": "^3.2.3",
68
70
  "octokit": "^1.7.1",
69
71
  "octokit-plugin-create-pull-request": "^3.10.0",
@@ -73,8 +75,8 @@
73
75
  "yaml": "^1.10.0"
74
76
  },
75
77
  "devDependencies": {
76
- "@backstage/cli": "^0.13.2",
77
- "@backstage/test-utils": "^0.2.4",
78
+ "@backstage/cli": "^0.14.0",
79
+ "@backstage/test-utils": "^0.2.5",
78
80
  "@types/command-exists": "^1.2.0",
79
81
  "@types/fs-extra": "^9.0.1",
80
82
  "@types/git-url-parse": "^9.0.0",
@@ -95,5 +97,5 @@
95
97
  "assets"
96
98
  ],
97
99
  "configSchema": "config.d.ts",
98
- "gitHead": "4f4bc77a4152d372b10a4e8d97d92f00e23f3b56"
100
+ "gitHead": "4805c3d13ce9bfc369e53c271b1b95e722b3b4dc"
99
101
  }
package/dist/index.d.ts DELETED
@@ -1,508 +0,0 @@
1
- /// <reference types="node" />
2
- import { ScmIntegrations, ScmIntegrationRegistry, GithubCredentialsProvider } from '@backstage/integration';
3
- import { CatalogApi } from '@backstage/catalog-client';
4
- import { Logger } from 'winston';
5
- import { Writable } from 'stream';
6
- import * as _backstage_types from '@backstage/types';
7
- import { JsonValue, JsonObject } from '@backstage/types';
8
- import { Schema } from 'jsonschema';
9
- import { TaskSpec, TemplateMetadata } from '@backstage/plugin-scaffolder-common';
10
- export { TaskSpec, TaskSpecV1beta2, TaskSpecV1beta3, TemplateMetadata } from '@backstage/plugin-scaffolder-common';
11
- import { UrlReader, ContainerRunner, PluginDatabaseManager } from '@backstage/backend-common';
12
- import { Config } from '@backstage/config';
13
- import { createPullRequest } from 'octokit-plugin-create-pull-request';
14
- import { Octokit } from 'octokit';
15
- export { createFetchCookiecutterAction } from '@backstage/plugin-scaffolder-backend-module-cookiecutter';
16
- import { SpawnOptionsWithoutStdio } from 'child_process';
17
- import { Knex } from 'knex';
18
- import express from 'express';
19
- import { TemplateEntityV1beta2, Entity, LocationSpec } from '@backstage/catalog-model';
20
- import { CatalogProcessor, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
21
-
22
- declare function createCatalogRegisterAction(options: {
23
- catalogClient: CatalogApi;
24
- integrations: ScmIntegrations;
25
- }): TemplateAction<any>;
26
-
27
- declare function createCatalogWriteAction(): TemplateAction<any>;
28
-
29
- /**
30
- * A catalog client tailored for reading out entity data from the catalog.
31
- */
32
- declare class CatalogEntityClient {
33
- private readonly catalogClient;
34
- constructor(catalogClient: CatalogApi);
35
- /**
36
- * Looks up a single template using a template name.
37
- *
38
- * Throws a NotFoundError or ConflictError if 0 or multiple templates are found.
39
- */
40
- findTemplate(templateName: string, options?: {
41
- token?: string;
42
- }): Promise<TemplateEntityV1beta2>;
43
- }
44
-
45
- declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
46
-
47
- declare const createBuiltinActions: (options: {
48
- reader: UrlReader;
49
- integrations: ScmIntegrations;
50
- catalogClient: CatalogApi;
51
- containerRunner?: ContainerRunner;
52
- config: Config;
53
- additionalTemplateFilters?: Record<string, TemplateFilter>;
54
- }) => TemplateAction<any>[];
55
-
56
- /**
57
- * This task is useful for local development and testing of both the scaffolder
58
- * and scaffolder templates.
59
- */
60
- declare function createDebugLogAction(): TemplateAction<any>;
61
-
62
- declare function createFetchPlainAction(options: {
63
- reader: UrlReader;
64
- integrations: ScmIntegrations;
65
- }): TemplateAction<any>;
66
-
67
- declare function createFetchTemplateAction(options: {
68
- reader: UrlReader;
69
- integrations: ScmIntegrations;
70
- additionalTemplateFilters?: Record<string, TemplateFilter>;
71
- }): TemplateAction<any>;
72
-
73
- declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
74
- reader: UrlReader;
75
- integrations: ScmIntegrations;
76
- baseUrl?: string;
77
- fetchUrl?: JsonValue;
78
- outputPath: string;
79
- }): Promise<void>;
80
-
81
- declare const createFilesystemDeleteAction: () => TemplateAction<any>;
82
-
83
- declare const createFilesystemRenameAction: () => TemplateAction<any>;
84
-
85
- declare function createPublishAzureAction(options: {
86
- integrations: ScmIntegrationRegistry;
87
- config: Config;
88
- }): TemplateAction<any>;
89
-
90
- declare function createPublishBitbucketAction(options: {
91
- integrations: ScmIntegrationRegistry;
92
- config: Config;
93
- }): TemplateAction<any>;
94
-
95
- /**
96
- * This task is useful for local development and testing of both the scaffolder
97
- * and scaffolder templates.
98
- *
99
- * This action is not installed by default and should not be installed in
100
- * production, as it writes the files to the local filesystem of the scaffolder.
101
- */
102
- declare function createPublishFileAction(): TemplateAction<any>;
103
-
104
- declare function createPublishGithubAction(options: {
105
- integrations: ScmIntegrationRegistry;
106
- config: Config;
107
- githubCredentialsProvider?: GithubCredentialsProvider;
108
- }): TemplateAction<any>;
109
-
110
- declare type CreatePullRequestResponse = {
111
- data: {
112
- html_url: string;
113
- };
114
- };
115
- interface PullRequestCreator {
116
- createPullRequest(options: createPullRequest.Options): Promise<CreatePullRequestResponse | null>;
117
- }
118
- declare type ClientFactoryInput = {
119
- integrations: ScmIntegrationRegistry;
120
- githubCredentialsProvider?: GithubCredentialsProvider;
121
- host: string;
122
- owner: string;
123
- repo: string;
124
- token?: string;
125
- };
126
- interface CreateGithubPullRequestActionOptions {
127
- integrations: ScmIntegrationRegistry;
128
- githubCredentialsProvider?: GithubCredentialsProvider;
129
- clientFactory?: (input: ClientFactoryInput) => Promise<PullRequestCreator>;
130
- }
131
- declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<any>;
132
-
133
- declare function createPublishGitlabAction(options: {
134
- integrations: ScmIntegrationRegistry;
135
- config: Config;
136
- }): TemplateAction<any>;
137
-
138
- declare const createPublishGitlabMergeRequestAction: (options: {
139
- integrations: ScmIntegrationRegistry;
140
- }) => TemplateAction<any>;
141
-
142
- declare function createGithubActionsDispatchAction(options: {
143
- integrations: ScmIntegrations;
144
- githubCredentialsProvider?: GithubCredentialsProvider;
145
- }): TemplateAction<any>;
146
-
147
- declare function createGithubWebhookAction(options: {
148
- integrations: ScmIntegrationRegistry;
149
- defaultWebhookSecret?: string;
150
- githubCredentialsProvider?: GithubCredentialsProvider;
151
- }): TemplateAction<any>;
152
-
153
- declare type OctokitIntegration = {
154
- client: Octokit;
155
- token: string;
156
- owner: string;
157
- repo: string;
158
- };
159
- /**
160
- * OctokitProvider provides Octokit client based on ScmIntegrationsRegistry configuration.
161
- * OctokitProvider supports GitHub credentials caching out of the box.
162
- */
163
- declare class OctokitProvider {
164
- private readonly integrations;
165
- private readonly githubCredentialsProvider;
166
- constructor(integrations: ScmIntegrationRegistry, githubCredentialsProvider?: GithubCredentialsProvider);
167
- /**
168
- * gets standard Octokit client based on repository URL.
169
- *
170
- * @param repoUrl - Repository URL
171
- */
172
- getOctokit(repoUrl: string, options?: {
173
- token?: string;
174
- }): Promise<OctokitIntegration>;
175
- }
176
-
177
- declare type RunCommandOptions = {
178
- /** command to run */
179
- command: string;
180
- /** arguments to pass the command */
181
- args: string[];
182
- /** options to pass to spawn */
183
- options?: SpawnOptionsWithoutStdio;
184
- /** stream to capture stdout and stderr output */
185
- logStream?: Writable;
186
- };
187
- /**
188
- * Run a command in a sub-process, normally a shell command.
189
- */
190
- declare const runCommand: ({ command, args, logStream, options, }: RunCommandOptions) => Promise<void>;
191
-
192
- /**
193
- * Status
194
- *
195
- * @public
196
- */
197
- declare type Status = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
198
- /**
199
- * CompletedTaskState
200
- *
201
- * @public
202
- */
203
- declare type CompletedTaskState = 'failed' | 'completed';
204
- /**
205
- * SerializedTask
206
- *
207
- * @public
208
- */
209
- declare type SerializedTask = {
210
- id: string;
211
- spec: TaskSpec;
212
- status: Status;
213
- createdAt: string;
214
- lastHeartbeatAt?: string;
215
- secrets?: TaskSecrets;
216
- };
217
- /**
218
- * TaskEventType
219
- *
220
- * @public
221
- */
222
- declare type TaskEventType = 'completion' | 'log';
223
- /**
224
- * SerializedTaskEvent
225
- *
226
- * @public
227
- */
228
- declare type SerializedTaskEvent = {
229
- id: number;
230
- taskId: string;
231
- body: JsonObject;
232
- type: TaskEventType;
233
- createdAt: string;
234
- };
235
- /**
236
- * TaskSecrets
237
- *
238
- * @public
239
- */
240
- declare type TaskSecrets = Record<string, string> & {
241
- /** @deprecated Use `backstageToken` instead */
242
- token?: string;
243
- backstageToken?: string;
244
- };
245
- /**
246
- * DispatchResult
247
- *
248
- * @public
249
- */
250
- declare type DispatchResult = {
251
- taskId: string;
252
- };
253
- /**
254
- * Task
255
- *
256
- * @public
257
- */
258
- interface TaskContext {
259
- spec: TaskSpec;
260
- secrets?: TaskSecrets;
261
- done: boolean;
262
- emitLog(message: string, metadata?: JsonValue): Promise<void>;
263
- complete(result: CompletedTaskState, metadata?: JsonValue): Promise<void>;
264
- getWorkspaceName(): Promise<string>;
265
- }
266
- /**
267
- * TaskBroker
268
- *
269
- * @public
270
- */
271
- interface TaskBroker {
272
- claim(): Promise<TaskContext>;
273
- dispatch(spec: TaskSpec, secrets?: TaskSecrets): Promise<DispatchResult>;
274
- vacuumTasks(timeoutS: {
275
- timeoutS: number;
276
- }): Promise<void>;
277
- observe(options: {
278
- taskId: string;
279
- after: number | undefined;
280
- }, callback: (error: Error | undefined, result: {
281
- events: SerializedTaskEvent[];
282
- }) => void): {
283
- unsubscribe: () => void;
284
- };
285
- get(taskId: string): Promise<SerializedTask>;
286
- }
287
- /**
288
- * TaskStoreEmitOptions
289
- *
290
- * @public
291
- */
292
- declare type TaskStoreEmitOptions = {
293
- taskId: string;
294
- body: JsonObject;
295
- };
296
- /**
297
- * TaskStoreListEventsOptions
298
- *
299
- * @public
300
- */
301
- declare type TaskStoreListEventsOptions = {
302
- taskId: string;
303
- after?: number | undefined;
304
- };
305
- /**
306
- * TaskStore
307
- *
308
- * @public
309
- */
310
- interface TaskStore {
311
- createTask(task: TaskSpec, secrets?: TaskSecrets): Promise<{
312
- taskId: string;
313
- }>;
314
- getTask(taskId: string): Promise<SerializedTask>;
315
- claimTask(): Promise<SerializedTask | undefined>;
316
- completeTask(options: {
317
- taskId: string;
318
- status: Status;
319
- eventBody: JsonObject;
320
- }): Promise<void>;
321
- heartbeatTask(taskId: string): Promise<void>;
322
- listStaleTasks(options: {
323
- timeoutS: number;
324
- }): Promise<{
325
- tasks: {
326
- taskId: string;
327
- }[];
328
- }>;
329
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
330
- listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
331
- events: SerializedTaskEvent[];
332
- }>;
333
- }
334
-
335
- declare type PartialJsonObject = Partial<JsonObject>;
336
- declare type PartialJsonValue = PartialJsonObject | JsonValue | undefined;
337
- declare type InputBase = Partial<{
338
- [name: string]: PartialJsonValue;
339
- }>;
340
- declare type ActionContext<Input extends InputBase> = {
341
- /**
342
- * Base URL for the location of the task spec, typically the url of the source entity file.
343
- */
344
- baseUrl?: string;
345
- logger: Logger;
346
- logStream: Writable;
347
- /**
348
- * User token forwarded from initial request, for use in subsequent api requests
349
- * @deprecated use `secrets.backstageToken` instead
350
- */
351
- token?: string | undefined;
352
- secrets?: TaskSecrets;
353
- workspacePath: string;
354
- input: Input;
355
- output(name: string, value: JsonValue): void;
356
- /**
357
- * Creates a temporary directory for use by the action, which is then cleaned up automatically.
358
- */
359
- createTemporaryDirectory(): Promise<string>;
360
- metadata?: TemplateMetadata;
361
- };
362
- declare type TemplateAction<Input extends InputBase> = {
363
- id: string;
364
- description?: string;
365
- schema?: {
366
- input?: Schema;
367
- output?: Schema;
368
- };
369
- handler: (ctx: ActionContext<Input>) => Promise<void>;
370
- };
371
-
372
- declare class TemplateActionRegistry {
373
- private readonly actions;
374
- register<Parameters extends InputBase>(action: TemplateAction<Parameters>): void;
375
- get(actionId: string): TemplateAction<any>;
376
- list(): TemplateAction<any>[];
377
- }
378
-
379
- declare const createTemplateAction: <Input extends Partial<{
380
- [name: string]: _backstage_types.JsonValue | Partial<_backstage_types.JsonObject> | undefined;
381
- }>>(templateAction: TemplateAction<Input>) => TemplateAction<any>;
382
-
383
- /**
384
- * DatabaseTaskStore
385
- *
386
- * @public
387
- */
388
- declare type DatabaseTaskStoreOptions = {
389
- database: Knex;
390
- };
391
- /**
392
- * DatabaseTaskStore
393
- *
394
- * @public
395
- */
396
- declare class DatabaseTaskStore implements TaskStore {
397
- private readonly db;
398
- static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
399
- constructor(options: DatabaseTaskStoreOptions);
400
- getTask(taskId: string): Promise<SerializedTask>;
401
- createTask(spec: TaskSpec, secrets?: TaskSecrets): Promise<{
402
- taskId: string;
403
- }>;
404
- claimTask(): Promise<SerializedTask | undefined>;
405
- heartbeatTask(taskId: string): Promise<void>;
406
- listStaleTasks({ timeoutS }: {
407
- timeoutS: number;
408
- }): Promise<{
409
- tasks: {
410
- taskId: string;
411
- }[];
412
- }>;
413
- completeTask({ taskId, status, eventBody, }: {
414
- taskId: string;
415
- status: Status;
416
- eventBody: JsonObject;
417
- }): Promise<void>;
418
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
419
- listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
420
- events: SerializedTaskEvent[];
421
- }>;
422
- }
423
-
424
- /**
425
- * TaskManager
426
- *
427
- * @public
428
- */
429
- declare class TaskManager implements TaskContext {
430
- private readonly state;
431
- private readonly storage;
432
- private readonly logger;
433
- private isDone;
434
- private heartbeatTimeoutId?;
435
- static create(state: TaskState, storage: TaskStore, logger: Logger): TaskManager;
436
- private constructor();
437
- get spec(): TaskSpec;
438
- get secrets(): TaskSecrets | undefined;
439
- getWorkspaceName(): Promise<string>;
440
- get done(): boolean;
441
- emitLog(message: string, metadata?: JsonObject): Promise<void>;
442
- complete(result: CompletedTaskState, metadata?: JsonObject): Promise<void>;
443
- private startTimeout;
444
- }
445
- /**
446
- * TaskState
447
- *
448
- * @public
449
- */
450
- interface TaskState {
451
- spec: TaskSpec;
452
- taskId: string;
453
- secrets?: TaskSecrets;
454
- }
455
-
456
- /**
457
- * CreateWorkerOptions
458
- *
459
- * @public
460
- */
461
- declare type CreateWorkerOptions = {
462
- taskBroker: TaskBroker;
463
- actionRegistry: TemplateActionRegistry;
464
- integrations: ScmIntegrations;
465
- workingDirectory: string;
466
- logger: Logger;
467
- additionalTemplateFilters?: Record<string, TemplateFilter>;
468
- };
469
- /**
470
- * TaskWorker
471
- *
472
- * @public
473
- */
474
- declare class TaskWorker {
475
- private readonly options;
476
- private constructor();
477
- static create(options: CreateWorkerOptions): Promise<TaskWorker>;
478
- start(): void;
479
- runOneTask(task: TaskContext): Promise<void>;
480
- }
481
-
482
- /**
483
- * RouterOptions
484
- *
485
- * @public
486
- */
487
- interface RouterOptions {
488
- logger: Logger;
489
- config: Config;
490
- reader: UrlReader;
491
- database: PluginDatabaseManager;
492
- catalogClient: CatalogApi;
493
- actions?: TemplateAction<any>[];
494
- taskWorkers?: number;
495
- containerRunner?: ContainerRunner;
496
- taskBroker?: TaskBroker;
497
- additionalTemplateFilters?: Record<string, TemplateFilter>;
498
- }
499
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
500
-
501
- /** @public */
502
- declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
503
- private readonly validators;
504
- validateEntityKind(entity: Entity): Promise<boolean>;
505
- postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
506
- }
507
-
508
- export { ActionContext, CatalogEntityClient, CompletedTaskState, CreateWorkerOptions, DatabaseTaskStore, DispatchResult, OctokitProvider, RouterOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, Status, TaskBroker, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskState, TaskStore, 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, fetchContents, runCommand };