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