@backstage/plugin-scaffolder-backend 0.0.0-nightly-20220305022735 → 0.0.0-nightly-20220308022132
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 +23 -6
- package/dist/index.cjs.js +38 -237
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +686 -0
- package/package.json +8 -9
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,686 @@
|
|
|
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 { JsonValue, JsonObject, Observable } from '@backstage/types';
|
|
7
|
+
import { Schema } from 'jsonschema';
|
|
8
|
+
import * as _backstage_plugin_scaffolder_common from '@backstage/plugin-scaffolder-common';
|
|
9
|
+
import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common';
|
|
10
|
+
import { Entity } from '@backstage/catalog-model';
|
|
11
|
+
import { UrlReader, PluginDatabaseManager } from '@backstage/backend-common';
|
|
12
|
+
import { Config } from '@backstage/config';
|
|
13
|
+
import { createPullRequest } from 'octokit-plugin-create-pull-request';
|
|
14
|
+
import { SpawnOptionsWithoutStdio } from 'child_process';
|
|
15
|
+
import { Knex } from 'knex';
|
|
16
|
+
import express from 'express';
|
|
17
|
+
import { CatalogProcessor, LocationSpec, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Registers entities from a catalog descriptor file in the workspace into the software catalog.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
declare function createCatalogRegisterAction(options: {
|
|
24
|
+
catalogClient: CatalogApi;
|
|
25
|
+
integrations: ScmIntegrations;
|
|
26
|
+
}): TemplateAction<{
|
|
27
|
+
catalogInfoUrl: string;
|
|
28
|
+
optional?: boolean | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
repoContentsUrl: string;
|
|
31
|
+
catalogInfoPath?: string | undefined;
|
|
32
|
+
optional?: boolean | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Writes a catalog descriptor file containing the provided entity to a path in the workspace.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
declare function createCatalogWriteAction(): TemplateAction<{
|
|
40
|
+
filePath?: string | undefined;
|
|
41
|
+
entity: Entity;
|
|
42
|
+
}>;
|
|
43
|
+
|
|
44
|
+
/** @public */
|
|
45
|
+
declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The status of each step of the Task
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
|
|
53
|
+
/**
|
|
54
|
+
* The state of a completed task.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
declare type TaskCompletionState = 'failed' | 'completed';
|
|
59
|
+
/**
|
|
60
|
+
* SerializedTask
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
declare type SerializedTask = {
|
|
65
|
+
id: string;
|
|
66
|
+
spec: TaskSpec;
|
|
67
|
+
status: TaskStatus;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
lastHeartbeatAt?: string;
|
|
70
|
+
secrets?: TaskSecrets;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* TaskEventType
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
declare type TaskEventType = 'completion' | 'log';
|
|
78
|
+
/**
|
|
79
|
+
* SerializedTaskEvent
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
declare type SerializedTaskEvent = {
|
|
84
|
+
id: number;
|
|
85
|
+
taskId: string;
|
|
86
|
+
body: JsonObject;
|
|
87
|
+
type: TaskEventType;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* TaskSecrets
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
declare type TaskSecrets = Record<string, string> & {
|
|
96
|
+
backstageToken?: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The result of {@link TaskBroker.dispatch}
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
declare type TaskBrokerDispatchResult = {
|
|
104
|
+
taskId: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The options passed to {@link TaskBroker.dispatch}
|
|
108
|
+
* Currently a spec and optional secrets
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
declare type TaskBrokerDispatchOptions = {
|
|
113
|
+
spec: TaskSpec;
|
|
114
|
+
secrets?: TaskSecrets;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Task
|
|
118
|
+
*
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
interface TaskContext {
|
|
122
|
+
spec: TaskSpec;
|
|
123
|
+
secrets?: TaskSecrets;
|
|
124
|
+
done: boolean;
|
|
125
|
+
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
|
|
126
|
+
complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
|
|
127
|
+
getWorkspaceName(): Promise<string>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* TaskBroker
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
interface TaskBroker {
|
|
135
|
+
claim(): Promise<TaskContext>;
|
|
136
|
+
dispatch(options: TaskBrokerDispatchOptions): Promise<TaskBrokerDispatchResult>;
|
|
137
|
+
vacuumTasks(options: {
|
|
138
|
+
timeoutS: number;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
event$(options: {
|
|
141
|
+
taskId: string;
|
|
142
|
+
after: number | undefined;
|
|
143
|
+
}): Observable<{
|
|
144
|
+
events: SerializedTaskEvent[];
|
|
145
|
+
}>;
|
|
146
|
+
get(taskId: string): Promise<SerializedTask>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* TaskStoreEmitOptions
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
declare type TaskStoreEmitOptions<TBody = JsonObject> = {
|
|
154
|
+
taskId: string;
|
|
155
|
+
body: TBody;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* TaskStoreListEventsOptions
|
|
159
|
+
*
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
declare type TaskStoreListEventsOptions = {
|
|
163
|
+
taskId: string;
|
|
164
|
+
after?: number | undefined;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* The options passed to {@link TaskStore.createTask}
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
declare type TaskStoreCreateTaskOptions = {
|
|
171
|
+
spec: TaskSpec;
|
|
172
|
+
secrets?: TaskSecrets;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The response from {@link TaskStore.createTask}
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
declare type TaskStoreCreateTaskResult = {
|
|
179
|
+
taskId: string;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* TaskStore
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
interface TaskStore {
|
|
187
|
+
createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
|
|
188
|
+
getTask(taskId: string): Promise<SerializedTask>;
|
|
189
|
+
claimTask(): Promise<SerializedTask | undefined>;
|
|
190
|
+
completeTask(options: {
|
|
191
|
+
taskId: string;
|
|
192
|
+
status: TaskStatus;
|
|
193
|
+
eventBody: JsonObject;
|
|
194
|
+
}): Promise<void>;
|
|
195
|
+
heartbeatTask(taskId: string): Promise<void>;
|
|
196
|
+
listStaleTasks(options: {
|
|
197
|
+
timeoutS: number;
|
|
198
|
+
}): Promise<{
|
|
199
|
+
tasks: {
|
|
200
|
+
taskId: string;
|
|
201
|
+
}[];
|
|
202
|
+
}>;
|
|
203
|
+
emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
|
|
204
|
+
listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
|
|
205
|
+
events: SerializedTaskEvent[];
|
|
206
|
+
}>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* ActionContext is passed into scaffolder actions.
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
declare type ActionContext<Input extends JsonObject> = {
|
|
214
|
+
logger: Logger;
|
|
215
|
+
logStream: Writable;
|
|
216
|
+
secrets?: TaskSecrets;
|
|
217
|
+
workspacePath: string;
|
|
218
|
+
input: Input;
|
|
219
|
+
output(name: string, value: JsonValue): void;
|
|
220
|
+
/**
|
|
221
|
+
* Creates a temporary directory for use by the action, which is then cleaned up automatically.
|
|
222
|
+
*/
|
|
223
|
+
createTemporaryDirectory(): Promise<string>;
|
|
224
|
+
templateInfo?: TemplateInfo;
|
|
225
|
+
};
|
|
226
|
+
/** @public */
|
|
227
|
+
declare type TemplateAction<Input extends JsonObject> = {
|
|
228
|
+
id: string;
|
|
229
|
+
description?: string;
|
|
230
|
+
schema?: {
|
|
231
|
+
input?: Schema;
|
|
232
|
+
output?: Schema;
|
|
233
|
+
};
|
|
234
|
+
handler: (ctx: ActionContext<Input>) => Promise<void>;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The options passed to {@link createBuiltinActions}
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
interface CreateBuiltInActionsOptions {
|
|
242
|
+
reader: UrlReader;
|
|
243
|
+
integrations: ScmIntegrations;
|
|
244
|
+
catalogClient: CatalogApi;
|
|
245
|
+
config: Config;
|
|
246
|
+
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A function to generate create a list of default actions that the scaffolder provides.
|
|
250
|
+
* Is called internally in the default setup, but can be used when adding your own actions or overriding the default ones
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
* @returns A list of actions that can be used in the scaffolder
|
|
254
|
+
*/
|
|
255
|
+
declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => TemplateAction<JsonObject>[];
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Writes a message into the log or lists all files in the workspace
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
*
|
|
262
|
+
* This task is useful for local development and testing of both the scaffolder
|
|
263
|
+
* and scaffolder templates.
|
|
264
|
+
*
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
declare function createDebugLogAction(): TemplateAction<{
|
|
268
|
+
message?: string | undefined;
|
|
269
|
+
listWorkspace?: boolean | undefined;
|
|
270
|
+
}>;
|
|
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
|
+
*/
|
|
277
|
+
declare function createFetchPlainAction(options: {
|
|
278
|
+
reader: UrlReader;
|
|
279
|
+
integrations: ScmIntegrations;
|
|
280
|
+
}): TemplateAction<{
|
|
281
|
+
url: string;
|
|
282
|
+
targetPath?: string | undefined;
|
|
283
|
+
}>;
|
|
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
|
+
*/
|
|
292
|
+
declare function createFetchTemplateAction(options: {
|
|
293
|
+
reader: UrlReader;
|
|
294
|
+
integrations: ScmIntegrations;
|
|
295
|
+
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
296
|
+
}): TemplateAction<{
|
|
297
|
+
url: string;
|
|
298
|
+
targetPath?: string | undefined;
|
|
299
|
+
values: any;
|
|
300
|
+
templateFileExtension?: string | boolean | undefined;
|
|
301
|
+
copyWithoutRender?: string[] | undefined;
|
|
302
|
+
cookiecutterCompat?: boolean | undefined;
|
|
303
|
+
}>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* A helper function that reads the contents of a directory from the given URL.
|
|
307
|
+
* Can be used in your own actions, and also used behind fetch:template and fetch:plain
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
|
|
312
|
+
reader: UrlReader;
|
|
313
|
+
integrations: ScmIntegrations;
|
|
314
|
+
baseUrl?: string;
|
|
315
|
+
fetchUrl?: string;
|
|
316
|
+
outputPath: string;
|
|
317
|
+
}): Promise<void>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Creates new action that enables deletion of files and directories in the workspace.
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
323
|
+
declare const createFilesystemDeleteAction: () => TemplateAction<{
|
|
324
|
+
files: string[];
|
|
325
|
+
}>;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Creates a new action that allows renames of files and directories in the workspace.
|
|
329
|
+
* @public
|
|
330
|
+
*/
|
|
331
|
+
declare const createFilesystemRenameAction: () => TemplateAction<{
|
|
332
|
+
files: Array<{
|
|
333
|
+
from: string;
|
|
334
|
+
to: string;
|
|
335
|
+
overwrite?: boolean;
|
|
336
|
+
}>;
|
|
337
|
+
}>;
|
|
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
|
+
*/
|
|
344
|
+
declare function createPublishAzureAction(options: {
|
|
345
|
+
integrations: ScmIntegrationRegistry;
|
|
346
|
+
config: Config;
|
|
347
|
+
}): TemplateAction<{
|
|
348
|
+
repoUrl: string;
|
|
349
|
+
description?: string | undefined;
|
|
350
|
+
defaultBranch?: string | undefined;
|
|
351
|
+
sourcePath?: string | undefined;
|
|
352
|
+
token?: string | undefined;
|
|
353
|
+
}>;
|
|
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
|
+
*/
|
|
360
|
+
declare function createPublishBitbucketAction(options: {
|
|
361
|
+
integrations: ScmIntegrationRegistry;
|
|
362
|
+
config: Config;
|
|
363
|
+
}): TemplateAction<{
|
|
364
|
+
repoUrl: string;
|
|
365
|
+
description?: string | undefined;
|
|
366
|
+
defaultBranch?: string | undefined;
|
|
367
|
+
repoVisibility?: "private" | "public" | undefined;
|
|
368
|
+
sourcePath?: string | undefined;
|
|
369
|
+
enableLFS?: boolean | undefined;
|
|
370
|
+
token?: string | undefined;
|
|
371
|
+
}>;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* This task is useful for local development and testing of both the scaffolder
|
|
375
|
+
* and scaffolder templates.
|
|
376
|
+
*
|
|
377
|
+
* @remarks
|
|
378
|
+
*
|
|
379
|
+
* This action is not installed by default and should not be installed in
|
|
380
|
+
* production, as it writes the files to the local filesystem of the scaffolder.
|
|
381
|
+
*
|
|
382
|
+
* @public
|
|
383
|
+
*/
|
|
384
|
+
declare function createPublishFileAction(): TemplateAction<{
|
|
385
|
+
path: string;
|
|
386
|
+
}>;
|
|
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
|
+
*/
|
|
394
|
+
declare function createPublishGithubAction(options: {
|
|
395
|
+
integrations: ScmIntegrationRegistry;
|
|
396
|
+
config: Config;
|
|
397
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
398
|
+
}): TemplateAction<{
|
|
399
|
+
repoUrl: string;
|
|
400
|
+
description?: string | undefined;
|
|
401
|
+
access?: string | undefined;
|
|
402
|
+
defaultBranch?: string | undefined;
|
|
403
|
+
deleteBranchOnMerge?: boolean | undefined;
|
|
404
|
+
allowRebaseMerge?: boolean | undefined;
|
|
405
|
+
allowSquashMerge?: boolean | undefined;
|
|
406
|
+
allowMergeCommit?: boolean | undefined;
|
|
407
|
+
sourcePath?: string | undefined;
|
|
408
|
+
requireCodeOwnerReviews?: boolean | undefined;
|
|
409
|
+
repoVisibility?: "private" | "public" | "internal" | undefined;
|
|
410
|
+
collaborators?: {
|
|
411
|
+
username: string;
|
|
412
|
+
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
|
|
413
|
+
}[] | undefined;
|
|
414
|
+
token?: string | undefined;
|
|
415
|
+
topics?: string[] | undefined;
|
|
416
|
+
}>;
|
|
417
|
+
|
|
418
|
+
/** @public */
|
|
419
|
+
interface OctokitWithPullRequestPluginClient {
|
|
420
|
+
createPullRequest(options: createPullRequest.Options): Promise<{
|
|
421
|
+
data: {
|
|
422
|
+
html_url: string;
|
|
423
|
+
};
|
|
424
|
+
} | null>;
|
|
425
|
+
}
|
|
426
|
+
/** @public */
|
|
427
|
+
declare type CreateGithubPullRequestClientFactoryInput = {
|
|
428
|
+
integrations: ScmIntegrationRegistry;
|
|
429
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
430
|
+
host: string;
|
|
431
|
+
owner: string;
|
|
432
|
+
repo: string;
|
|
433
|
+
token?: string;
|
|
434
|
+
};
|
|
435
|
+
/** @public */
|
|
436
|
+
interface CreateGithubPullRequestActionOptions {
|
|
437
|
+
integrations: ScmIntegrationRegistry;
|
|
438
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
439
|
+
clientFactory?: (input: CreateGithubPullRequestClientFactoryInput) => Promise<OctokitWithPullRequestPluginClient>;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates a Github Pull Request action.
|
|
443
|
+
* @public
|
|
444
|
+
*/
|
|
445
|
+
declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<{
|
|
446
|
+
title: string;
|
|
447
|
+
branchName: string;
|
|
448
|
+
description: string;
|
|
449
|
+
repoUrl: string;
|
|
450
|
+
targetPath?: string | undefined;
|
|
451
|
+
sourcePath?: string | undefined;
|
|
452
|
+
token?: string | undefined;
|
|
453
|
+
}>;
|
|
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
|
+
*/
|
|
461
|
+
declare function createPublishGitlabAction(options: {
|
|
462
|
+
integrations: ScmIntegrationRegistry;
|
|
463
|
+
config: Config;
|
|
464
|
+
}): TemplateAction<{
|
|
465
|
+
repoUrl: string;
|
|
466
|
+
defaultBranch?: string | undefined;
|
|
467
|
+
repoVisibility?: "private" | "public" | "internal" | undefined;
|
|
468
|
+
sourcePath?: string | undefined;
|
|
469
|
+
token?: string | undefined;
|
|
470
|
+
}>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Create a new action that creates a gitlab merge request.
|
|
474
|
+
*
|
|
475
|
+
* @public
|
|
476
|
+
*/
|
|
477
|
+
declare const createPublishGitlabMergeRequestAction: (options: {
|
|
478
|
+
integrations: ScmIntegrationRegistry;
|
|
479
|
+
}) => TemplateAction<{
|
|
480
|
+
projectid: string;
|
|
481
|
+
repoUrl: string;
|
|
482
|
+
title: string;
|
|
483
|
+
description: string;
|
|
484
|
+
branchName: string;
|
|
485
|
+
targetPath: string;
|
|
486
|
+
token?: string | undefined;
|
|
487
|
+
}>;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.
|
|
491
|
+
* @public
|
|
492
|
+
*/
|
|
493
|
+
declare function createGithubActionsDispatchAction(options: {
|
|
494
|
+
integrations: ScmIntegrations;
|
|
495
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
496
|
+
}): TemplateAction<{
|
|
497
|
+
repoUrl: string;
|
|
498
|
+
workflowId: string;
|
|
499
|
+
branchOrTagName: string;
|
|
500
|
+
workflowInputs?: {
|
|
501
|
+
[key: string]: string;
|
|
502
|
+
} | undefined;
|
|
503
|
+
token?: string | undefined;
|
|
504
|
+
}>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Creates new action that creates a webhook for a repository on GitHub.
|
|
508
|
+
* @public
|
|
509
|
+
*/
|
|
510
|
+
declare function createGithubWebhookAction(options: {
|
|
511
|
+
integrations: ScmIntegrationRegistry;
|
|
512
|
+
defaultWebhookSecret?: string;
|
|
513
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
514
|
+
}): TemplateAction<{
|
|
515
|
+
repoUrl: string;
|
|
516
|
+
webhookUrl: string;
|
|
517
|
+
webhookSecret?: string | undefined;
|
|
518
|
+
events?: string[] | undefined;
|
|
519
|
+
active?: boolean | undefined;
|
|
520
|
+
contentType?: "form" | "json" | undefined;
|
|
521
|
+
insecureSsl?: boolean | undefined;
|
|
522
|
+
token?: string | undefined;
|
|
523
|
+
}>;
|
|
524
|
+
|
|
525
|
+
/** @public */
|
|
526
|
+
declare type RunCommandOptions = {
|
|
527
|
+
/** command to run */
|
|
528
|
+
command: string;
|
|
529
|
+
/** arguments to pass the command */
|
|
530
|
+
args: string[];
|
|
531
|
+
/** options to pass to spawn */
|
|
532
|
+
options?: SpawnOptionsWithoutStdio;
|
|
533
|
+
/** stream to capture stdout and stderr output */
|
|
534
|
+
logStream?: Writable;
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Run a command in a sub-process, normally a shell command.
|
|
538
|
+
*
|
|
539
|
+
* @public
|
|
540
|
+
*/
|
|
541
|
+
declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Registry of all registered template actions.
|
|
545
|
+
* @public
|
|
546
|
+
*/
|
|
547
|
+
declare class TemplateActionRegistry {
|
|
548
|
+
private readonly actions;
|
|
549
|
+
register<TInput extends JsonObject>(action: TemplateAction<TInput>): void;
|
|
550
|
+
get(actionId: string): TemplateAction<JsonObject>;
|
|
551
|
+
list(): TemplateAction<JsonObject>[];
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* This function is used to create new template actions to get type safety.
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* DatabaseTaskStore
|
|
562
|
+
*
|
|
563
|
+
* @public
|
|
564
|
+
*/
|
|
565
|
+
declare type DatabaseTaskStoreOptions = {
|
|
566
|
+
database: Knex;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* DatabaseTaskStore
|
|
570
|
+
*
|
|
571
|
+
* @public
|
|
572
|
+
*/
|
|
573
|
+
declare class DatabaseTaskStore implements TaskStore {
|
|
574
|
+
private readonly db;
|
|
575
|
+
static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
|
|
576
|
+
private constructor();
|
|
577
|
+
getTask(taskId: string): Promise<SerializedTask>;
|
|
578
|
+
createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
|
|
579
|
+
claimTask(): Promise<SerializedTask | undefined>;
|
|
580
|
+
heartbeatTask(taskId: string): Promise<void>;
|
|
581
|
+
listStaleTasks({ timeoutS }: {
|
|
582
|
+
timeoutS: number;
|
|
583
|
+
}): Promise<{
|
|
584
|
+
tasks: {
|
|
585
|
+
taskId: string;
|
|
586
|
+
}[];
|
|
587
|
+
}>;
|
|
588
|
+
completeTask({ taskId, status, eventBody, }: {
|
|
589
|
+
taskId: string;
|
|
590
|
+
status: TaskStatus;
|
|
591
|
+
eventBody: JsonObject;
|
|
592
|
+
}): Promise<void>;
|
|
593
|
+
emitLogEvent(options: TaskStoreEmitOptions<{
|
|
594
|
+
message: string;
|
|
595
|
+
} & JsonObject>): Promise<void>;
|
|
596
|
+
listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
|
|
597
|
+
events: SerializedTaskEvent[];
|
|
598
|
+
}>;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* TaskManager
|
|
603
|
+
*
|
|
604
|
+
* @public
|
|
605
|
+
*/
|
|
606
|
+
declare class TaskManager implements TaskContext {
|
|
607
|
+
private readonly task;
|
|
608
|
+
private readonly storage;
|
|
609
|
+
private readonly logger;
|
|
610
|
+
private isDone;
|
|
611
|
+
private heartbeatTimeoutId?;
|
|
612
|
+
static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
|
|
613
|
+
private constructor();
|
|
614
|
+
get spec(): _backstage_plugin_scaffolder_common.TaskSpecV1beta3;
|
|
615
|
+
get secrets(): TaskSecrets | undefined;
|
|
616
|
+
getWorkspaceName(): Promise<string>;
|
|
617
|
+
get done(): boolean;
|
|
618
|
+
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
|
|
619
|
+
complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
|
|
620
|
+
private startTimeout;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Stores the state of the current claimed task passed to the TaskContext
|
|
624
|
+
*
|
|
625
|
+
* @public
|
|
626
|
+
*/
|
|
627
|
+
interface CurrentClaimedTask {
|
|
628
|
+
spec: TaskSpec;
|
|
629
|
+
taskId: string;
|
|
630
|
+
secrets?: TaskSecrets;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* CreateWorkerOptions
|
|
635
|
+
*
|
|
636
|
+
* @public
|
|
637
|
+
*/
|
|
638
|
+
declare type CreateWorkerOptions = {
|
|
639
|
+
taskBroker: TaskBroker;
|
|
640
|
+
actionRegistry: TemplateActionRegistry;
|
|
641
|
+
integrations: ScmIntegrations;
|
|
642
|
+
workingDirectory: string;
|
|
643
|
+
logger: Logger;
|
|
644
|
+
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* TaskWorker
|
|
648
|
+
*
|
|
649
|
+
* @public
|
|
650
|
+
*/
|
|
651
|
+
declare class TaskWorker {
|
|
652
|
+
private readonly options;
|
|
653
|
+
private constructor();
|
|
654
|
+
static create(options: CreateWorkerOptions): Promise<TaskWorker>;
|
|
655
|
+
start(): void;
|
|
656
|
+
runOneTask(task: TaskContext): Promise<void>;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* RouterOptions
|
|
661
|
+
*
|
|
662
|
+
* @public
|
|
663
|
+
*/
|
|
664
|
+
interface RouterOptions {
|
|
665
|
+
logger: Logger;
|
|
666
|
+
config: Config;
|
|
667
|
+
reader: UrlReader;
|
|
668
|
+
database: PluginDatabaseManager;
|
|
669
|
+
catalogClient: CatalogApi;
|
|
670
|
+
actions?: TemplateAction<any>[];
|
|
671
|
+
taskWorkers?: number;
|
|
672
|
+
taskBroker?: TaskBroker;
|
|
673
|
+
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
|
674
|
+
}
|
|
675
|
+
/** @public */
|
|
676
|
+
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
677
|
+
|
|
678
|
+
/** @public */
|
|
679
|
+
declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
|
680
|
+
getProcessorName(): string;
|
|
681
|
+
private readonly validators;
|
|
682
|
+
validateEntityKind(entity: Entity): Promise<boolean>;
|
|
683
|
+
postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
684
|
+
}
|
|
685
|
+
|
|
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 };
|