@backstage/plugin-scaffolder-backend 0.15.11 → 0.15.12
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 +50 -0
- package/dist/index.cjs.js +175 -123
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +294 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { Config } from '@backstage/config';
|
|
|
11
11
|
import { createPullRequest } from 'octokit-plugin-create-pull-request';
|
|
12
12
|
import { Octokit } from '@octokit/rest';
|
|
13
13
|
export { createFetchCookiecutterAction } from '@backstage/plugin-scaffolder-backend-module-cookiecutter';
|
|
14
|
+
import { Knex } from 'knex';
|
|
14
15
|
import express from 'express';
|
|
15
16
|
import { TemplateEntityV1beta2, Entity, LocationSpec } from '@backstage/catalog-model';
|
|
16
17
|
import { CatalogProcessor, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
@@ -190,6 +191,297 @@ declare const createTemplateAction: <Input extends Partial<{
|
|
|
190
191
|
[name: string]: _backstage_types.JsonValue | Partial<_backstage_types.JsonObject> | undefined;
|
|
191
192
|
}>>(templateAction: TemplateAction<Input>) => TemplateAction<any>;
|
|
192
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Status
|
|
196
|
+
*
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
declare type Status = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
|
|
200
|
+
/**
|
|
201
|
+
* CompletedTaskState
|
|
202
|
+
*
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
declare type CompletedTaskState = 'failed' | 'completed';
|
|
206
|
+
/**
|
|
207
|
+
* SerializedTask
|
|
208
|
+
*
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
declare type SerializedTask = {
|
|
212
|
+
id: string;
|
|
213
|
+
spec: TaskSpec;
|
|
214
|
+
status: Status;
|
|
215
|
+
createdAt: string;
|
|
216
|
+
lastHeartbeatAt?: string;
|
|
217
|
+
secrets?: TaskSecrets;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* TaskEventType
|
|
221
|
+
*
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
declare type TaskEventType = 'completion' | 'log';
|
|
225
|
+
/**
|
|
226
|
+
* SerializedTaskEvent
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
declare type SerializedTaskEvent = {
|
|
231
|
+
id: number;
|
|
232
|
+
taskId: string;
|
|
233
|
+
body: JsonObject;
|
|
234
|
+
type: TaskEventType;
|
|
235
|
+
createdAt: string;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* TaskSpecV1beta2
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
interface TaskSpecV1beta2 {
|
|
243
|
+
apiVersion: 'backstage.io/v1beta2';
|
|
244
|
+
baseUrl?: string;
|
|
245
|
+
values: JsonObject;
|
|
246
|
+
steps: Array<{
|
|
247
|
+
id: string;
|
|
248
|
+
name: string;
|
|
249
|
+
action: string;
|
|
250
|
+
input?: JsonObject;
|
|
251
|
+
if?: string | boolean;
|
|
252
|
+
}>;
|
|
253
|
+
output: {
|
|
254
|
+
[name: string]: string;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
interface TaskStep {
|
|
258
|
+
id: string;
|
|
259
|
+
name: string;
|
|
260
|
+
action: string;
|
|
261
|
+
input?: JsonObject;
|
|
262
|
+
if?: string | boolean;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* TaskSpecV1beta3
|
|
266
|
+
*
|
|
267
|
+
* @public
|
|
268
|
+
*/
|
|
269
|
+
interface TaskSpecV1beta3 {
|
|
270
|
+
apiVersion: 'scaffolder.backstage.io/v1beta3';
|
|
271
|
+
baseUrl?: string;
|
|
272
|
+
parameters: JsonObject;
|
|
273
|
+
steps: TaskStep[];
|
|
274
|
+
output: {
|
|
275
|
+
[name: string]: JsonValue;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* TaskSpec
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
declare type TaskSpec = TaskSpecV1beta2 | TaskSpecV1beta3;
|
|
284
|
+
/**
|
|
285
|
+
* TaskSecrets
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
declare type TaskSecrets = {
|
|
290
|
+
token: string | undefined;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* DispatchResult
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
declare type DispatchResult = {
|
|
298
|
+
taskId: string;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Task
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
305
|
+
interface TaskContext {
|
|
306
|
+
spec: TaskSpec;
|
|
307
|
+
secrets?: TaskSecrets;
|
|
308
|
+
done: boolean;
|
|
309
|
+
emitLog(message: string, metadata?: JsonValue): Promise<void>;
|
|
310
|
+
complete(result: CompletedTaskState, metadata?: JsonValue): Promise<void>;
|
|
311
|
+
getWorkspaceName(): Promise<string>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* TaskBroker
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
interface TaskBroker {
|
|
319
|
+
claim(): Promise<TaskContext>;
|
|
320
|
+
dispatch(spec: TaskSpec, secrets?: TaskSecrets): Promise<DispatchResult>;
|
|
321
|
+
vacuumTasks(timeoutS: {
|
|
322
|
+
timeoutS: number;
|
|
323
|
+
}): Promise<void>;
|
|
324
|
+
observe(options: {
|
|
325
|
+
taskId: string;
|
|
326
|
+
after: number | undefined;
|
|
327
|
+
}, callback: (error: Error | undefined, result: {
|
|
328
|
+
events: SerializedTaskEvent[];
|
|
329
|
+
}) => void): {
|
|
330
|
+
unsubscribe: () => void;
|
|
331
|
+
};
|
|
332
|
+
get(taskId: string): Promise<SerializedTask>;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* TaskStoreEmitOptions
|
|
336
|
+
*
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
declare type TaskStoreEmitOptions = {
|
|
340
|
+
taskId: string;
|
|
341
|
+
body: JsonObject;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* TaskStoreListEventsOptions
|
|
345
|
+
*
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
declare type TaskStoreListEventsOptions = {
|
|
349
|
+
taskId: string;
|
|
350
|
+
after?: number | undefined;
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* TaskStore
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
interface TaskStore {
|
|
358
|
+
createTask(task: TaskSpec, secrets?: TaskSecrets): Promise<{
|
|
359
|
+
taskId: string;
|
|
360
|
+
}>;
|
|
361
|
+
getTask(taskId: string): Promise<SerializedTask>;
|
|
362
|
+
claimTask(): Promise<SerializedTask | undefined>;
|
|
363
|
+
completeTask(options: {
|
|
364
|
+
taskId: string;
|
|
365
|
+
status: Status;
|
|
366
|
+
eventBody: JsonObject;
|
|
367
|
+
}): Promise<void>;
|
|
368
|
+
heartbeatTask(taskId: string): Promise<void>;
|
|
369
|
+
listStaleTasks(options: {
|
|
370
|
+
timeoutS: number;
|
|
371
|
+
}): Promise<{
|
|
372
|
+
tasks: {
|
|
373
|
+
taskId: string;
|
|
374
|
+
}[];
|
|
375
|
+
}>;
|
|
376
|
+
emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
|
|
377
|
+
listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
|
|
378
|
+
events: SerializedTaskEvent[];
|
|
379
|
+
}>;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* DatabaseTaskStore
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
declare type DatabaseTaskStoreOptions = {
|
|
388
|
+
database: Knex;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* DatabaseTaskStore
|
|
392
|
+
*
|
|
393
|
+
* @public
|
|
394
|
+
*/
|
|
395
|
+
declare class DatabaseTaskStore implements TaskStore {
|
|
396
|
+
private readonly db;
|
|
397
|
+
static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
|
|
398
|
+
constructor(options: DatabaseTaskStoreOptions);
|
|
399
|
+
getTask(taskId: string): Promise<SerializedTask>;
|
|
400
|
+
createTask(spec: TaskSpec, secrets?: TaskSecrets): Promise<{
|
|
401
|
+
taskId: string;
|
|
402
|
+
}>;
|
|
403
|
+
claimTask(): Promise<SerializedTask | undefined>;
|
|
404
|
+
heartbeatTask(taskId: string): Promise<void>;
|
|
405
|
+
listStaleTasks({ timeoutS }: {
|
|
406
|
+
timeoutS: number;
|
|
407
|
+
}): Promise<{
|
|
408
|
+
tasks: {
|
|
409
|
+
taskId: string;
|
|
410
|
+
}[];
|
|
411
|
+
}>;
|
|
412
|
+
completeTask({ taskId, status, eventBody, }: {
|
|
413
|
+
taskId: string;
|
|
414
|
+
status: Status;
|
|
415
|
+
eventBody: JsonObject;
|
|
416
|
+
}): Promise<void>;
|
|
417
|
+
emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
|
|
418
|
+
listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
|
|
419
|
+
events: SerializedTaskEvent[];
|
|
420
|
+
}>;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* TaskManager
|
|
425
|
+
*
|
|
426
|
+
* @public
|
|
427
|
+
*/
|
|
428
|
+
declare class TaskManager implements TaskContext {
|
|
429
|
+
private readonly state;
|
|
430
|
+
private readonly storage;
|
|
431
|
+
private readonly logger;
|
|
432
|
+
private isDone;
|
|
433
|
+
private heartbeatTimeoutId?;
|
|
434
|
+
static create(state: TaskState, storage: TaskStore, logger: Logger): TaskManager;
|
|
435
|
+
private constructor();
|
|
436
|
+
get spec(): TaskSpec;
|
|
437
|
+
get secrets(): TaskSecrets | undefined;
|
|
438
|
+
getWorkspaceName(): Promise<string>;
|
|
439
|
+
get done(): boolean;
|
|
440
|
+
emitLog(message: string, metadata?: JsonObject): Promise<void>;
|
|
441
|
+
complete(result: CompletedTaskState, metadata?: JsonObject): Promise<void>;
|
|
442
|
+
private startTimeout;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* TaskState
|
|
446
|
+
*
|
|
447
|
+
* @public
|
|
448
|
+
*/
|
|
449
|
+
interface TaskState {
|
|
450
|
+
spec: TaskSpec;
|
|
451
|
+
taskId: string;
|
|
452
|
+
secrets?: TaskSecrets;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* CreateWorkerOptions
|
|
457
|
+
*
|
|
458
|
+
* @public
|
|
459
|
+
*/
|
|
460
|
+
declare type CreateWorkerOptions = {
|
|
461
|
+
taskBroker: TaskBroker;
|
|
462
|
+
actionRegistry: TemplateActionRegistry;
|
|
463
|
+
integrations: ScmIntegrations;
|
|
464
|
+
workingDirectory: string;
|
|
465
|
+
logger: Logger;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* TaskWorker
|
|
469
|
+
*
|
|
470
|
+
* @public
|
|
471
|
+
*/
|
|
472
|
+
declare class TaskWorker {
|
|
473
|
+
private readonly options;
|
|
474
|
+
private constructor();
|
|
475
|
+
static create(options: CreateWorkerOptions): Promise<TaskWorker>;
|
|
476
|
+
start(): void;
|
|
477
|
+
runOneTask(task: TaskContext): Promise<void>;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* RouterOptions
|
|
482
|
+
*
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
193
485
|
interface RouterOptions {
|
|
194
486
|
logger: Logger;
|
|
195
487
|
config: Config;
|
|
@@ -199,6 +491,7 @@ interface RouterOptions {
|
|
|
199
491
|
actions?: TemplateAction<any>[];
|
|
200
492
|
taskWorkers?: number;
|
|
201
493
|
containerRunner: ContainerRunner;
|
|
494
|
+
taskBroker?: TaskBroker;
|
|
202
495
|
}
|
|
203
496
|
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
204
497
|
|
|
@@ -225,4 +518,4 @@ declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
|
|
225
518
|
postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
226
519
|
}
|
|
227
520
|
|
|
228
|
-
export { ActionContext, CatalogEntityClient, OctokitProvider, RouterOptions, ScaffolderEntitiesProcessor, TemplateAction, TemplateActionRegistry, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishFileAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createRouter, createTemplateAction, fetchContents, runCommand };
|
|
521
|
+
export { ActionContext, CatalogEntityClient, CompletedTaskState, CreateWorkerOptions, DatabaseTaskStore, DispatchResult, OctokitProvider, RouterOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, Status, TaskBroker, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskSpec, TaskSpecV1beta2, TaskSpecV1beta3, TaskState, TaskStore, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskWorker, TemplateAction, TemplateActionRegistry, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishFileAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createRouter, createTemplateAction, fetchContents, runCommand };
|
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.
|
|
4
|
+
"version": "0.15.12",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"clean": "backstage-cli clean"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@backstage/backend-common": "^0.9.
|
|
34
|
-
"@backstage/catalog-client": "^0.5.
|
|
33
|
+
"@backstage/backend-common": "^0.9.9",
|
|
34
|
+
"@backstage/catalog-client": "^0.5.1",
|
|
35
35
|
"@backstage/catalog-model": "^0.9.6",
|
|
36
36
|
"@backstage/config": "^0.1.11",
|
|
37
37
|
"@backstage/errors": "^0.1.4",
|
|
38
38
|
"@backstage/integration": "^0.6.9",
|
|
39
|
-
"@backstage/plugin-catalog-backend": "^0.17.
|
|
40
|
-
"@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.1.
|
|
39
|
+
"@backstage/plugin-catalog-backend": "^0.17.3",
|
|
40
|
+
"@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.1.4",
|
|
41
41
|
"@backstage/plugin-scaffolder-common": "^0.1.1",
|
|
42
42
|
"@backstage/types": "^0.1.1",
|
|
43
43
|
"@gitbeaker/core": "^30.2.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"yaml": "^1.10.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@backstage/cli": "^0.8.
|
|
75
|
-
"@backstage/test-utils": "^0.1.
|
|
74
|
+
"@backstage/cli": "^0.8.2",
|
|
75
|
+
"@backstage/test-utils": "^0.1.21",
|
|
76
76
|
"@types/command-exists": "^1.2.0",
|
|
77
77
|
"@types/fs-extra": "^9.0.1",
|
|
78
78
|
"@types/git-url-parse": "^9.0.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"config.d.ts"
|
|
92
92
|
],
|
|
93
93
|
"configSchema": "config.d.ts",
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "5bdaccc40b4a814cf0b45d429f15a3afacc2f60b"
|
|
95
95
|
}
|