@backstage/plugin-scaffolder-backend 0.15.23-next.1 → 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.23-next.1",
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.6-next.0",
35
- "@backstage/catalog-client": "^0.5.5",
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.2-next.1",
41
- "@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.1.10-next.1",
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,26 +58,25 @@
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",
62
- "knex": "^0.95.1",
64
+ "knex": "^1.0.2",
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",
70
72
  "uuid": "^8.2.0",
71
- "vm2": "^3.9.5",
73
+ "vm2": "^3.9.6",
72
74
  "winston": "^3.2.1",
73
75
  "yaml": "^1.10.0"
74
76
  },
75
77
  "devDependencies": {
76
- "@backstage/cli": "^0.13.1-next.1",
77
- "@backstage/test-utils": "^0.2.4-next.0",
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": "d6da97a1edeb21fcefc682d91916987ba9f3d89a"
100
+ "gitHead": "4805c3d13ce9bfc369e53c271b1b95e722b3b4dc"
99
101
  }
package/dist/index.d.ts DELETED
@@ -1,505 +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
- };
125
- interface CreateGithubPullRequestActionOptions {
126
- integrations: ScmIntegrationRegistry;
127
- githubCredentialsProvider?: GithubCredentialsProvider;
128
- clientFactory?: (input: ClientFactoryInput) => Promise<PullRequestCreator>;
129
- }
130
- declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<any>;
131
-
132
- declare function createPublishGitlabAction(options: {
133
- integrations: ScmIntegrationRegistry;
134
- config: Config;
135
- }): TemplateAction<any>;
136
-
137
- declare const createPublishGitlabMergeRequestAction: (options: {
138
- integrations: ScmIntegrationRegistry;
139
- }) => TemplateAction<any>;
140
-
141
- declare function createGithubActionsDispatchAction(options: {
142
- integrations: ScmIntegrations;
143
- githubCredentialsProvider?: GithubCredentialsProvider;
144
- }): TemplateAction<any>;
145
-
146
- declare function createGithubWebhookAction(options: {
147
- integrations: ScmIntegrationRegistry;
148
- defaultWebhookSecret?: string;
149
- githubCredentialsProvider?: GithubCredentialsProvider;
150
- }): TemplateAction<any>;
151
-
152
- declare type OctokitIntegration = {
153
- client: Octokit;
154
- token: string;
155
- owner: string;
156
- repo: string;
157
- };
158
- /**
159
- * OctokitProvider provides Octokit client based on ScmIntegrationsRegistry configuration.
160
- * OctokitProvider supports GitHub credentials caching out of the box.
161
- */
162
- declare class OctokitProvider {
163
- private readonly integrations;
164
- private readonly githubCredentialsProvider;
165
- constructor(integrations: ScmIntegrationRegistry, githubCredentialsProvider?: GithubCredentialsProvider);
166
- /**
167
- * gets standard Octokit client based on repository URL.
168
- *
169
- * @param repoUrl - Repository URL
170
- */
171
- getOctokit(repoUrl: string): Promise<OctokitIntegration>;
172
- }
173
-
174
- declare type RunCommandOptions = {
175
- /** command to run */
176
- command: string;
177
- /** arguments to pass the command */
178
- args: string[];
179
- /** options to pass to spawn */
180
- options?: SpawnOptionsWithoutStdio;
181
- /** stream to capture stdout and stderr output */
182
- logStream?: Writable;
183
- };
184
- /**
185
- * Run a command in a sub-process, normally a shell command.
186
- */
187
- declare const runCommand: ({ command, args, logStream, options, }: RunCommandOptions) => Promise<void>;
188
-
189
- /**
190
- * Status
191
- *
192
- * @public
193
- */
194
- declare type Status = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
195
- /**
196
- * CompletedTaskState
197
- *
198
- * @public
199
- */
200
- declare type CompletedTaskState = 'failed' | 'completed';
201
- /**
202
- * SerializedTask
203
- *
204
- * @public
205
- */
206
- declare type SerializedTask = {
207
- id: string;
208
- spec: TaskSpec;
209
- status: Status;
210
- createdAt: string;
211
- lastHeartbeatAt?: string;
212
- secrets?: TaskSecrets;
213
- };
214
- /**
215
- * TaskEventType
216
- *
217
- * @public
218
- */
219
- declare type TaskEventType = 'completion' | 'log';
220
- /**
221
- * SerializedTaskEvent
222
- *
223
- * @public
224
- */
225
- declare type SerializedTaskEvent = {
226
- id: number;
227
- taskId: string;
228
- body: JsonObject;
229
- type: TaskEventType;
230
- createdAt: string;
231
- };
232
- /**
233
- * TaskSecrets
234
- *
235
- * @public
236
- */
237
- declare type TaskSecrets = Record<string, string> & {
238
- /** @deprecated Use `backstageToken` instead */
239
- token?: string;
240
- backstageToken?: string;
241
- };
242
- /**
243
- * DispatchResult
244
- *
245
- * @public
246
- */
247
- declare type DispatchResult = {
248
- taskId: string;
249
- };
250
- /**
251
- * Task
252
- *
253
- * @public
254
- */
255
- interface TaskContext {
256
- spec: TaskSpec;
257
- secrets?: TaskSecrets;
258
- done: boolean;
259
- emitLog(message: string, metadata?: JsonValue): Promise<void>;
260
- complete(result: CompletedTaskState, metadata?: JsonValue): Promise<void>;
261
- getWorkspaceName(): Promise<string>;
262
- }
263
- /**
264
- * TaskBroker
265
- *
266
- * @public
267
- */
268
- interface TaskBroker {
269
- claim(): Promise<TaskContext>;
270
- dispatch(spec: TaskSpec, secrets?: TaskSecrets): Promise<DispatchResult>;
271
- vacuumTasks(timeoutS: {
272
- timeoutS: number;
273
- }): Promise<void>;
274
- observe(options: {
275
- taskId: string;
276
- after: number | undefined;
277
- }, callback: (error: Error | undefined, result: {
278
- events: SerializedTaskEvent[];
279
- }) => void): {
280
- unsubscribe: () => void;
281
- };
282
- get(taskId: string): Promise<SerializedTask>;
283
- }
284
- /**
285
- * TaskStoreEmitOptions
286
- *
287
- * @public
288
- */
289
- declare type TaskStoreEmitOptions = {
290
- taskId: string;
291
- body: JsonObject;
292
- };
293
- /**
294
- * TaskStoreListEventsOptions
295
- *
296
- * @public
297
- */
298
- declare type TaskStoreListEventsOptions = {
299
- taskId: string;
300
- after?: number | undefined;
301
- };
302
- /**
303
- * TaskStore
304
- *
305
- * @public
306
- */
307
- interface TaskStore {
308
- createTask(task: TaskSpec, secrets?: TaskSecrets): Promise<{
309
- taskId: string;
310
- }>;
311
- getTask(taskId: string): Promise<SerializedTask>;
312
- claimTask(): Promise<SerializedTask | undefined>;
313
- completeTask(options: {
314
- taskId: string;
315
- status: Status;
316
- eventBody: JsonObject;
317
- }): Promise<void>;
318
- heartbeatTask(taskId: string): Promise<void>;
319
- listStaleTasks(options: {
320
- timeoutS: number;
321
- }): Promise<{
322
- tasks: {
323
- taskId: string;
324
- }[];
325
- }>;
326
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
327
- listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
328
- events: SerializedTaskEvent[];
329
- }>;
330
- }
331
-
332
- declare type PartialJsonObject = Partial<JsonObject>;
333
- declare type PartialJsonValue = PartialJsonObject | JsonValue | undefined;
334
- declare type InputBase = Partial<{
335
- [name: string]: PartialJsonValue;
336
- }>;
337
- declare type ActionContext<Input extends InputBase> = {
338
- /**
339
- * Base URL for the location of the task spec, typically the url of the source entity file.
340
- */
341
- baseUrl?: string;
342
- logger: Logger;
343
- logStream: Writable;
344
- /**
345
- * User token forwarded from initial request, for use in subsequent api requests
346
- * @deprecated use `secrets.backstageToken` instead
347
- */
348
- token?: string | undefined;
349
- secrets?: TaskSecrets;
350
- workspacePath: string;
351
- input: Input;
352
- output(name: string, value: JsonValue): void;
353
- /**
354
- * Creates a temporary directory for use by the action, which is then cleaned up automatically.
355
- */
356
- createTemporaryDirectory(): Promise<string>;
357
- metadata?: TemplateMetadata;
358
- };
359
- declare type TemplateAction<Input extends InputBase> = {
360
- id: string;
361
- description?: string;
362
- schema?: {
363
- input?: Schema;
364
- output?: Schema;
365
- };
366
- handler: (ctx: ActionContext<Input>) => Promise<void>;
367
- };
368
-
369
- declare class TemplateActionRegistry {
370
- private readonly actions;
371
- register<Parameters extends InputBase>(action: TemplateAction<Parameters>): void;
372
- get(actionId: string): TemplateAction<any>;
373
- list(): TemplateAction<any>[];
374
- }
375
-
376
- declare const createTemplateAction: <Input extends Partial<{
377
- [name: string]: _backstage_types.JsonValue | Partial<_backstage_types.JsonObject> | undefined;
378
- }>>(templateAction: TemplateAction<Input>) => TemplateAction<any>;
379
-
380
- /**
381
- * DatabaseTaskStore
382
- *
383
- * @public
384
- */
385
- declare type DatabaseTaskStoreOptions = {
386
- database: Knex;
387
- };
388
- /**
389
- * DatabaseTaskStore
390
- *
391
- * @public
392
- */
393
- declare class DatabaseTaskStore implements TaskStore {
394
- private readonly db;
395
- static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
396
- constructor(options: DatabaseTaskStoreOptions);
397
- getTask(taskId: string): Promise<SerializedTask>;
398
- createTask(spec: TaskSpec, secrets?: TaskSecrets): Promise<{
399
- taskId: string;
400
- }>;
401
- claimTask(): Promise<SerializedTask | undefined>;
402
- heartbeatTask(taskId: string): Promise<void>;
403
- listStaleTasks({ timeoutS }: {
404
- timeoutS: number;
405
- }): Promise<{
406
- tasks: {
407
- taskId: string;
408
- }[];
409
- }>;
410
- completeTask({ taskId, status, eventBody, }: {
411
- taskId: string;
412
- status: Status;
413
- eventBody: JsonObject;
414
- }): Promise<void>;
415
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
416
- listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
417
- events: SerializedTaskEvent[];
418
- }>;
419
- }
420
-
421
- /**
422
- * TaskManager
423
- *
424
- * @public
425
- */
426
- declare class TaskManager implements TaskContext {
427
- private readonly state;
428
- private readonly storage;
429
- private readonly logger;
430
- private isDone;
431
- private heartbeatTimeoutId?;
432
- static create(state: TaskState, storage: TaskStore, logger: Logger): TaskManager;
433
- private constructor();
434
- get spec(): TaskSpec;
435
- get secrets(): TaskSecrets | undefined;
436
- getWorkspaceName(): Promise<string>;
437
- get done(): boolean;
438
- emitLog(message: string, metadata?: JsonObject): Promise<void>;
439
- complete(result: CompletedTaskState, metadata?: JsonObject): Promise<void>;
440
- private startTimeout;
441
- }
442
- /**
443
- * TaskState
444
- *
445
- * @public
446
- */
447
- interface TaskState {
448
- spec: TaskSpec;
449
- taskId: string;
450
- secrets?: TaskSecrets;
451
- }
452
-
453
- /**
454
- * CreateWorkerOptions
455
- *
456
- * @public
457
- */
458
- declare type CreateWorkerOptions = {
459
- taskBroker: TaskBroker;
460
- actionRegistry: TemplateActionRegistry;
461
- integrations: ScmIntegrations;
462
- workingDirectory: string;
463
- logger: Logger;
464
- additionalTemplateFilters?: Record<string, TemplateFilter>;
465
- };
466
- /**
467
- * TaskWorker
468
- *
469
- * @public
470
- */
471
- declare class TaskWorker {
472
- private readonly options;
473
- private constructor();
474
- static create(options: CreateWorkerOptions): Promise<TaskWorker>;
475
- start(): void;
476
- runOneTask(task: TaskContext): Promise<void>;
477
- }
478
-
479
- /**
480
- * RouterOptions
481
- *
482
- * @public
483
- */
484
- interface RouterOptions {
485
- logger: Logger;
486
- config: Config;
487
- reader: UrlReader;
488
- database: PluginDatabaseManager;
489
- catalogClient: CatalogApi;
490
- actions?: TemplateAction<any>[];
491
- taskWorkers?: number;
492
- containerRunner?: ContainerRunner;
493
- taskBroker?: TaskBroker;
494
- additionalTemplateFilters?: Record<string, TemplateFilter>;
495
- }
496
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
497
-
498
- /** @public */
499
- declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
500
- private readonly validators;
501
- validateEntityKind(entity: Entity): Promise<boolean>;
502
- postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
503
- }
504
-
505
- 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 };