@backstage/plugin-scaffolder-backend 0.17.3 → 1.0.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 +105 -0
- package/dist/index.cjs.js +145 -294
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +69 -83
- package/migrations/20210120143715_init.js +1 -1
- package/package.json +14 -16
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,12 @@ 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
|
|
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,
|
|
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';
|
|
@@ -51,26 +50,12 @@ declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
|
|
|
51
50
|
* @public
|
|
52
51
|
*/
|
|
53
52
|
declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
|
|
54
|
-
/**
|
|
55
|
-
* The status of each step of the Task
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
* @deprecated use TaskStatus instead
|
|
59
|
-
*/
|
|
60
|
-
declare type Status = TaskStatus;
|
|
61
53
|
/**
|
|
62
54
|
* The state of a completed task.
|
|
63
55
|
*
|
|
64
56
|
* @public
|
|
65
57
|
*/
|
|
66
58
|
declare type TaskCompletionState = 'failed' | 'completed';
|
|
67
|
-
/**
|
|
68
|
-
* The state of a completed task.
|
|
69
|
-
*
|
|
70
|
-
* @public
|
|
71
|
-
* @deprecated use TaskCompletionState instead
|
|
72
|
-
*/
|
|
73
|
-
declare type CompletedTaskState = TaskCompletionState;
|
|
74
59
|
/**
|
|
75
60
|
* SerializedTask
|
|
76
61
|
*
|
|
@@ -128,13 +113,6 @@ declare type TaskBrokerDispatchOptions = {
|
|
|
128
113
|
spec: TaskSpec;
|
|
129
114
|
secrets?: TaskSecrets;
|
|
130
115
|
};
|
|
131
|
-
/**
|
|
132
|
-
* DispatchResult
|
|
133
|
-
*
|
|
134
|
-
* @public
|
|
135
|
-
* @deprecated use TaskBrokerDispatchResult instead
|
|
136
|
-
*/
|
|
137
|
-
declare type DispatchResult = TaskBrokerDispatchResult;
|
|
138
116
|
/**
|
|
139
117
|
* Task
|
|
140
118
|
*
|
|
@@ -230,13 +208,9 @@ interface TaskStore {
|
|
|
230
208
|
|
|
231
209
|
/**
|
|
232
210
|
* ActionContext is passed into scaffolder actions.
|
|
233
|
-
* @public
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
234
213
|
declare type ActionContext<Input extends JsonObject> = {
|
|
235
|
-
/**
|
|
236
|
-
* Base URL for the location of the task spec, typically the url of the source entity file.
|
|
237
|
-
* @deprecated please use templateInfo.baseUrl instead
|
|
238
|
-
*/
|
|
239
|
-
baseUrl?: string;
|
|
240
214
|
logger: Logger;
|
|
241
215
|
logStream: Writable;
|
|
242
216
|
secrets?: TaskSecrets;
|
|
@@ -247,10 +221,6 @@ declare type ActionContext<Input extends JsonObject> = {
|
|
|
247
221
|
* Creates a temporary directory for use by the action, which is then cleaned up automatically.
|
|
248
222
|
*/
|
|
249
223
|
createTemporaryDirectory(): Promise<string>;
|
|
250
|
-
/**
|
|
251
|
-
* @deprecated please use templateInfo instead
|
|
252
|
-
*/
|
|
253
|
-
metadata?: TemplateMetadata;
|
|
254
224
|
templateInfo?: TemplateInfo;
|
|
255
225
|
};
|
|
256
226
|
/** @public */
|
|
@@ -269,12 +239,26 @@ declare type TemplateAction<Input extends JsonObject> = {
|
|
|
269
239
|
* @public
|
|
270
240
|
*/
|
|
271
241
|
interface CreateBuiltInActionsOptions {
|
|
242
|
+
/**
|
|
243
|
+
* The {@link @backstage/backend-common#UrlReader} interface that will be used in the default actions.
|
|
244
|
+
*/
|
|
272
245
|
reader: UrlReader;
|
|
246
|
+
/**
|
|
247
|
+
* The {@link @backstage/integrations#ScmIntegrations} that will be used in the default actions.
|
|
248
|
+
*/
|
|
273
249
|
integrations: ScmIntegrations;
|
|
250
|
+
/**
|
|
251
|
+
* The {@link @backstage/catalog-client#CatalogApi} that will be used in the default actions.
|
|
252
|
+
*/
|
|
274
253
|
catalogClient: CatalogApi;
|
|
275
|
-
/**
|
|
276
|
-
|
|
254
|
+
/**
|
|
255
|
+
* The {@link @backstage/config#Config} that will be used in the default actions.
|
|
256
|
+
*/
|
|
277
257
|
config: Config;
|
|
258
|
+
/**
|
|
259
|
+
* Additional custom filters that will be passed to the nunjucks template engine for use in
|
|
260
|
+
* Template Manifests and also template skeleton files when using `fetch:template`.
|
|
261
|
+
*/
|
|
278
262
|
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
279
263
|
}
|
|
280
264
|
/**
|
|
@@ -432,6 +416,10 @@ declare function createPublishGithubAction(options: {
|
|
|
432
416
|
description?: string | undefined;
|
|
433
417
|
access?: string | undefined;
|
|
434
418
|
defaultBranch?: string | undefined;
|
|
419
|
+
deleteBranchOnMerge?: boolean | undefined;
|
|
420
|
+
allowRebaseMerge?: boolean | undefined;
|
|
421
|
+
allowSquashMerge?: boolean | undefined;
|
|
422
|
+
allowMergeCommit?: boolean | undefined;
|
|
435
423
|
sourcePath?: string | undefined;
|
|
436
424
|
requireCodeOwnerReviews?: boolean | undefined;
|
|
437
425
|
repoVisibility?: "internal" | "private" | "public" | undefined;
|
|
@@ -448,10 +436,14 @@ interface OctokitWithPullRequestPluginClient {
|
|
|
448
436
|
createPullRequest(options: createPullRequest.Options): Promise<{
|
|
449
437
|
data: {
|
|
450
438
|
html_url: string;
|
|
439
|
+
number: number;
|
|
451
440
|
};
|
|
452
441
|
} | null>;
|
|
453
442
|
}
|
|
454
|
-
/**
|
|
443
|
+
/**
|
|
444
|
+
* The options passed to the client factory function.
|
|
445
|
+
* @public
|
|
446
|
+
*/
|
|
455
447
|
declare type CreateGithubPullRequestClientFactoryInput = {
|
|
456
448
|
integrations: ScmIntegrationRegistry;
|
|
457
449
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
@@ -460,10 +452,22 @@ declare type CreateGithubPullRequestClientFactoryInput = {
|
|
|
460
452
|
repo: string;
|
|
461
453
|
token?: string;
|
|
462
454
|
};
|
|
463
|
-
/**
|
|
455
|
+
/**
|
|
456
|
+
* The options passed to {@link createPublishGithubPullRequestAction} method
|
|
457
|
+
* @public
|
|
458
|
+
*/
|
|
464
459
|
interface CreateGithubPullRequestActionOptions {
|
|
460
|
+
/**
|
|
461
|
+
* An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.
|
|
462
|
+
*/
|
|
465
463
|
integrations: ScmIntegrationRegistry;
|
|
464
|
+
/**
|
|
465
|
+
* An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.
|
|
466
|
+
*/
|
|
466
467
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
468
|
+
/**
|
|
469
|
+
* A method to return the Octokit client with the Pull Request Plugin.
|
|
470
|
+
*/
|
|
467
471
|
clientFactory?: (input: CreateGithubPullRequestClientFactoryInput) => Promise<OctokitWithPullRequestPluginClient>;
|
|
468
472
|
}
|
|
469
473
|
/**
|
|
@@ -550,35 +554,19 @@ declare function createGithubWebhookAction(options: {
|
|
|
550
554
|
token?: string | undefined;
|
|
551
555
|
}>;
|
|
552
556
|
|
|
553
|
-
declare type OctokitIntegration = {
|
|
554
|
-
client: Octokit;
|
|
555
|
-
token: string;
|
|
556
|
-
owner: string;
|
|
557
|
-
repo: string;
|
|
558
|
-
};
|
|
559
557
|
/**
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* @deprecated we are no longer providing a way from the scaffolder to generate octokit instances.
|
|
564
|
-
* Implement your own if you're using this method from an external package, or use the internal `getOctokitOptions` function instead
|
|
558
|
+
* Adds labels to a pull request or issue on GitHub
|
|
559
|
+
* @public
|
|
565
560
|
*/
|
|
566
|
-
declare
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
* @deprecated we are no longer providing a way from the scaffolder to generate octokit instances.
|
|
576
|
-
* Implement your own if you're using this method from an external package, or use the internal `getOctokitOptions` function instead
|
|
577
|
-
*/
|
|
578
|
-
getOctokit(repoUrl: string, options?: {
|
|
579
|
-
token?: string;
|
|
580
|
-
}): Promise<OctokitIntegration>;
|
|
581
|
-
}
|
|
561
|
+
declare function createGithubIssuesLabelAction(options: {
|
|
562
|
+
integrations: ScmIntegrationRegistry;
|
|
563
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
564
|
+
}): TemplateAction<{
|
|
565
|
+
repoUrl: string;
|
|
566
|
+
number: number;
|
|
567
|
+
labels: string[];
|
|
568
|
+
token?: string | undefined;
|
|
569
|
+
}>;
|
|
582
570
|
|
|
583
571
|
/** @public */
|
|
584
572
|
declare type RunCommandOptions = {
|
|
@@ -597,12 +585,6 @@ declare type RunCommandOptions = {
|
|
|
597
585
|
* @public
|
|
598
586
|
*/
|
|
599
587
|
declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
|
|
600
|
-
/**
|
|
601
|
-
* Run a command in a sub-process, normally a shell command.
|
|
602
|
-
* @public
|
|
603
|
-
* @deprecated use {@link executeShellCommand} instead
|
|
604
|
-
*/
|
|
605
|
-
declare const runCommand: (options: RunCommandOptions) => Promise<void>;
|
|
606
588
|
|
|
607
589
|
/**
|
|
608
590
|
* Registry of all registered template actions.
|
|
@@ -675,7 +657,7 @@ declare class TaskManager implements TaskContext {
|
|
|
675
657
|
private heartbeatTimeoutId?;
|
|
676
658
|
static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
|
|
677
659
|
private constructor();
|
|
678
|
-
get spec():
|
|
660
|
+
get spec(): _backstage_plugin_scaffolder_common.TaskSpecV1beta3;
|
|
679
661
|
get secrets(): TaskSecrets | undefined;
|
|
680
662
|
getWorkspaceName(): Promise<string>;
|
|
681
663
|
get done(): boolean;
|
|
@@ -689,17 +671,19 @@ declare class TaskManager implements TaskContext {
|
|
|
689
671
|
* @public
|
|
690
672
|
*/
|
|
691
673
|
interface CurrentClaimedTask {
|
|
674
|
+
/**
|
|
675
|
+
* The TaskSpec of the current claimed task.
|
|
676
|
+
*/
|
|
692
677
|
spec: TaskSpec;
|
|
678
|
+
/**
|
|
679
|
+
* The uuid of the current claimed task.
|
|
680
|
+
*/
|
|
693
681
|
taskId: string;
|
|
682
|
+
/**
|
|
683
|
+
* The secrets that are stored with the task.
|
|
684
|
+
*/
|
|
694
685
|
secrets?: TaskSecrets;
|
|
695
686
|
}
|
|
696
|
-
/**
|
|
697
|
-
* TaskState
|
|
698
|
-
*
|
|
699
|
-
* @public
|
|
700
|
-
* @deprecated use CurrentClaimedTask instead
|
|
701
|
-
*/
|
|
702
|
-
declare type TaskState = CurrentClaimedTask;
|
|
703
687
|
|
|
704
688
|
/**
|
|
705
689
|
* CreateWorkerOptions
|
|
@@ -740,11 +724,13 @@ interface RouterOptions {
|
|
|
740
724
|
catalogClient: CatalogApi;
|
|
741
725
|
actions?: TemplateAction<any>[];
|
|
742
726
|
taskWorkers?: number;
|
|
743
|
-
containerRunner?: ContainerRunner;
|
|
744
727
|
taskBroker?: TaskBroker;
|
|
745
728
|
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
746
729
|
}
|
|
747
|
-
/**
|
|
730
|
+
/**
|
|
731
|
+
* A method to create a router for the scaffolder backend plugin.
|
|
732
|
+
* @public
|
|
733
|
+
*/
|
|
748
734
|
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
749
735
|
|
|
750
736
|
/** @public */
|
|
@@ -755,4 +741,4 @@ declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
|
|
755
741
|
postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
756
742
|
}
|
|
757
743
|
|
|
758
|
-
export { ActionContext,
|
|
744
|
+
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, createGithubIssuesLabelAction, 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
|
|
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.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -34,16 +34,15 @@
|
|
|
34
34
|
"build:assets": "node scripts/build-nunjucks.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@backstage/backend-common": "^0.
|
|
38
|
-
"@backstage/catalog-client": "^0.
|
|
39
|
-
"@backstage/catalog-model": "^0.
|
|
40
|
-
"@backstage/config": "^0.
|
|
41
|
-
"@backstage/errors": "^0.
|
|
42
|
-
"@backstage/integration": "^0.
|
|
43
|
-
"@backstage/plugin-catalog-backend": "^0.
|
|
44
|
-
"@backstage/plugin-scaffolder-
|
|
45
|
-
"@backstage/
|
|
46
|
-
"@backstage/types": "^0.1.3",
|
|
37
|
+
"@backstage/backend-common": "^0.13.1",
|
|
38
|
+
"@backstage/catalog-client": "^1.0.0",
|
|
39
|
+
"@backstage/catalog-model": "^1.0.0",
|
|
40
|
+
"@backstage/config": "^1.0.0",
|
|
41
|
+
"@backstage/errors": "^1.0.0",
|
|
42
|
+
"@backstage/integration": "^1.0.0",
|
|
43
|
+
"@backstage/plugin-catalog-backend": "^1.0.0",
|
|
44
|
+
"@backstage/plugin-scaffolder-common": "^1.0.0",
|
|
45
|
+
"@backstage/types": "^1.0.0",
|
|
47
46
|
"@gitbeaker/core": "^34.6.0",
|
|
48
47
|
"@gitbeaker/node": "^35.1.0",
|
|
49
48
|
"@octokit/webhooks": "^9.14.1",
|
|
@@ -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.
|
|
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/
|
|
80
|
-
"@backstage/
|
|
77
|
+
"@backstage/backend-test-utils": "^0.1.22",
|
|
78
|
+
"@backstage/cli": "^0.16.0",
|
|
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": "
|
|
100
|
+
"gitHead": "e9496f746b31600dbfac7fa76987479e66426257"
|
|
103
101
|
}
|