@backstage/plugin-scaffolder-backend 0.15.17 → 0.15.21-next.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 +56 -0
- package/dist/index.cjs.js +47 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +14 -64
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 0.15.21-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-catalog-backend@0.21.0-next.0
|
|
9
|
+
- @backstage/backend-common@0.10.4-next.0
|
|
10
|
+
- @backstage/config@0.1.13-next.0
|
|
11
|
+
- @backstage/catalog-model@0.9.10-next.0
|
|
12
|
+
- @backstage/catalog-client@0.5.5-next.0
|
|
13
|
+
- @backstage/integration@0.7.2-next.0
|
|
14
|
+
- @backstage/plugin-scaffolder-backend-module-cookiecutter@0.1.9-next.0
|
|
15
|
+
- @backstage/plugin-scaffolder-common@0.1.3-next.0
|
|
16
|
+
|
|
17
|
+
## 0.15.20
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 9fbd3b90ae: fix: Register plugin to prioritise Component kind for entityRef
|
|
22
|
+
- 451ef0aa07: Fix token pass-through for software templates using beta 3 version
|
|
23
|
+
- 5333451def: Cleaned up API exports
|
|
24
|
+
- 3b4d8caff6: Allow a GitHubCredentialsProvider to be passed to the GitHub scaffolder tasks actions.
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/config@0.1.12
|
|
27
|
+
- @backstage/integration@0.7.1
|
|
28
|
+
- @backstage/backend-common@0.10.3
|
|
29
|
+
- @backstage/plugin-catalog-backend@0.20.0
|
|
30
|
+
- @backstage/errors@0.2.0
|
|
31
|
+
- @backstage/catalog-client@0.5.4
|
|
32
|
+
- @backstage/catalog-model@0.9.9
|
|
33
|
+
- @backstage/plugin-scaffolder-backend-module-cookiecutter@0.1.8
|
|
34
|
+
|
|
35
|
+
## 0.15.19
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 7d4b4e937c: Uptake changes to the GitHub Credentials Provider interface.
|
|
40
|
+
- d078377f67: Support navigating back to pre-filled templates to update inputs of scaffolder tasks for resubmission
|
|
41
|
+
- 5f8ceba1b1: Support custom file name for `catalog:write` action
|
|
42
|
+
- Updated dependencies
|
|
43
|
+
- @backstage/backend-common@0.10.1
|
|
44
|
+
- @backstage/plugin-catalog-backend@0.19.4
|
|
45
|
+
- @backstage/plugin-scaffolder-common@0.1.2
|
|
46
|
+
- @backstage/integration@0.7.0
|
|
47
|
+
- @backstage/plugin-scaffolder-backend-module-cookiecutter@0.1.7
|
|
48
|
+
|
|
49
|
+
## 0.15.18
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies
|
|
54
|
+
- @backstage/backend-common@0.10.0
|
|
55
|
+
- @backstage/catalog-client@0.5.3
|
|
56
|
+
- @backstage/plugin-catalog-backend@0.19.3
|
|
57
|
+
- @backstage/plugin-scaffolder-backend-module-cookiecutter@0.1.6
|
|
58
|
+
|
|
3
59
|
## 0.15.17
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -7,6 +7,7 @@ var catalogModel = require('@backstage/catalog-model');
|
|
|
7
7
|
var fs = require('fs-extra');
|
|
8
8
|
var yaml = require('yaml');
|
|
9
9
|
var backendCommon = require('@backstage/backend-common');
|
|
10
|
+
var integration = require('@backstage/integration');
|
|
10
11
|
var path = require('path');
|
|
11
12
|
var globby = require('globby');
|
|
12
13
|
var isbinaryfile = require('isbinaryfile');
|
|
@@ -16,7 +17,6 @@ var child_process = require('child_process');
|
|
|
16
17
|
var stream = require('stream');
|
|
17
18
|
var azureDevopsNodeApi = require('azure-devops-node-api');
|
|
18
19
|
var fetch = require('node-fetch');
|
|
19
|
-
var integration = require('@backstage/integration');
|
|
20
20
|
var rest = require('@octokit/rest');
|
|
21
21
|
var lodash = require('lodash');
|
|
22
22
|
var octokitPluginCreatePullRequest = require('octokit-plugin-create-pull-request');
|
|
@@ -119,7 +119,6 @@ function createCatalogRegisterAction(options) {
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
async handler(ctx) {
|
|
122
|
-
var _a;
|
|
123
122
|
const { input } = ctx;
|
|
124
123
|
let catalogInfoUrl;
|
|
125
124
|
if ("catalogInfoUrl" in input) {
|
|
@@ -148,7 +147,14 @@ function createCatalogRegisterAction(options) {
|
|
|
148
147
|
}, ctx.token ? { token: ctx.token } : {});
|
|
149
148
|
if (result.entities.length > 0) {
|
|
150
149
|
const { entities } = result;
|
|
151
|
-
|
|
150
|
+
let entity;
|
|
151
|
+
entity = entities.find((e) => !e.metadata.name.startsWith("generated-") && e.kind === "Component");
|
|
152
|
+
if (!entity) {
|
|
153
|
+
entity = entities.find((e) => !e.metadata.name.startsWith("generated-"));
|
|
154
|
+
}
|
|
155
|
+
if (!entity) {
|
|
156
|
+
entity = entities[0];
|
|
157
|
+
}
|
|
152
158
|
ctx.output("entityRef", catalogModel.stringifyEntityRef(entity));
|
|
153
159
|
}
|
|
154
160
|
} catch (e) {
|
|
@@ -169,6 +175,11 @@ function createCatalogWriteAction() {
|
|
|
169
175
|
input: {
|
|
170
176
|
type: "object",
|
|
171
177
|
properties: {
|
|
178
|
+
filePath: {
|
|
179
|
+
title: "Catalog file path",
|
|
180
|
+
description: "Defaults to catalog-info.yaml",
|
|
181
|
+
type: "string"
|
|
182
|
+
},
|
|
172
183
|
entity: {
|
|
173
184
|
title: "Entity info to write catalog-info.yaml",
|
|
174
185
|
description: "You can provide the same values used in the Entity schema.",
|
|
@@ -179,8 +190,9 @@ function createCatalogWriteAction() {
|
|
|
179
190
|
},
|
|
180
191
|
async handler(ctx) {
|
|
181
192
|
ctx.logStream.write(`Writing catalog-info.yaml`);
|
|
182
|
-
const { entity } = ctx.input;
|
|
183
|
-
|
|
193
|
+
const { filePath, entity } = ctx.input;
|
|
194
|
+
const path = filePath != null ? filePath : "catalog-info.yaml";
|
|
195
|
+
await fs__default["default"].writeFile(backendCommon.resolveSafeChildPath(ctx.workspacePath, path), yaml__namespace.stringify(entity));
|
|
184
196
|
}
|
|
185
197
|
});
|
|
186
198
|
}
|
|
@@ -1144,12 +1156,9 @@ function createPublishFileAction() {
|
|
|
1144
1156
|
}
|
|
1145
1157
|
|
|
1146
1158
|
class OctokitProvider {
|
|
1147
|
-
constructor(integrations) {
|
|
1159
|
+
constructor(integrations, githubCredentialsProvider) {
|
|
1148
1160
|
this.integrations = integrations;
|
|
1149
|
-
this.
|
|
1150
|
-
const provider = integration.GithubCredentialsProvider.create(integration$1.config);
|
|
1151
|
-
return [integration$1.config.host, provider];
|
|
1152
|
-
}));
|
|
1161
|
+
this.githubCredentialsProvider = githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
|
|
1153
1162
|
}
|
|
1154
1163
|
async getOctokit(repoUrl) {
|
|
1155
1164
|
var _a;
|
|
@@ -1161,11 +1170,7 @@ class OctokitProvider {
|
|
|
1161
1170
|
if (!integrationConfig) {
|
|
1162
1171
|
throw new errors.InputError(`No integration for host ${host}`);
|
|
1163
1172
|
}
|
|
1164
|
-
const
|
|
1165
|
-
if (!credentialsProvider) {
|
|
1166
|
-
throw new errors.InputError(`No matching credentials for host ${host}, please check your integrations config`);
|
|
1167
|
-
}
|
|
1168
|
-
const { token } = await credentialsProvider.getCredentials({
|
|
1173
|
+
const { token } = await this.githubCredentialsProvider.getCredentials({
|
|
1169
1174
|
url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
|
|
1170
1175
|
});
|
|
1171
1176
|
if (!token) {
|
|
@@ -1181,8 +1186,8 @@ class OctokitProvider {
|
|
|
1181
1186
|
}
|
|
1182
1187
|
|
|
1183
1188
|
function createPublishGithubAction(options) {
|
|
1184
|
-
const { integrations, config } = options;
|
|
1185
|
-
const octokitProvider = new OctokitProvider(integrations);
|
|
1189
|
+
const { integrations, config, githubCredentialsProvider } = options;
|
|
1190
|
+
const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
|
|
1186
1191
|
return createTemplateAction({
|
|
1187
1192
|
id: "publish:github",
|
|
1188
1193
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
@@ -1382,6 +1387,7 @@ class GithubResponseError extends errors.CustomErrorBase {
|
|
|
1382
1387
|
}
|
|
1383
1388
|
const defaultClientFactory = async ({
|
|
1384
1389
|
integrations,
|
|
1390
|
+
githubCredentialsProvider,
|
|
1385
1391
|
owner,
|
|
1386
1392
|
repo,
|
|
1387
1393
|
host = "github.com"
|
|
@@ -1391,10 +1397,7 @@ const defaultClientFactory = async ({
|
|
|
1391
1397
|
if (!integrationConfig) {
|
|
1392
1398
|
throw new errors.InputError(`No integration for host ${host}`);
|
|
1393
1399
|
}
|
|
1394
|
-
const credentialsProvider = integration.
|
|
1395
|
-
if (!credentialsProvider) {
|
|
1396
|
-
throw new errors.InputError(`No matching credentials for host ${host}, please check your integrations config`);
|
|
1397
|
-
}
|
|
1400
|
+
const credentialsProvider = githubCredentialsProvider || integration.SingleInstanceGithubCredentialsProvider.create(integrationConfig);
|
|
1398
1401
|
const { token } = await credentialsProvider.getCredentials({
|
|
1399
1402
|
url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
|
|
1400
1403
|
});
|
|
@@ -1409,6 +1412,7 @@ const defaultClientFactory = async ({
|
|
|
1409
1412
|
};
|
|
1410
1413
|
const createPublishGithubPullRequestAction = ({
|
|
1411
1414
|
integrations,
|
|
1415
|
+
githubCredentialsProvider,
|
|
1412
1416
|
clientFactory = defaultClientFactory
|
|
1413
1417
|
}) => {
|
|
1414
1418
|
return createTemplateAction({
|
|
@@ -1475,7 +1479,13 @@ const createPublishGithubPullRequestAction = ({
|
|
|
1475
1479
|
if (!owner) {
|
|
1476
1480
|
throw new errors.InputError(`No owner provided for host: ${host}, and repo ${repo}`);
|
|
1477
1481
|
}
|
|
1478
|
-
const client = await clientFactory({
|
|
1482
|
+
const client = await clientFactory({
|
|
1483
|
+
integrations,
|
|
1484
|
+
githubCredentialsProvider,
|
|
1485
|
+
host,
|
|
1486
|
+
owner,
|
|
1487
|
+
repo
|
|
1488
|
+
});
|
|
1479
1489
|
const fileRoot = sourcePath ? backendCommon.resolveSafeChildPath(ctx.workspacePath, sourcePath) : ctx.workspacePath;
|
|
1480
1490
|
const localFilePaths = await globby__default["default"](["./**", "./**/.*", "!.git"], {
|
|
1481
1491
|
cwd: fileRoot,
|
|
@@ -1737,8 +1747,8 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
1737
1747
|
};
|
|
1738
1748
|
|
|
1739
1749
|
function createGithubActionsDispatchAction(options) {
|
|
1740
|
-
const { integrations } = options;
|
|
1741
|
-
const octokitProvider = new OctokitProvider(integrations);
|
|
1750
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
1751
|
+
const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
|
|
1742
1752
|
return createTemplateAction({
|
|
1743
1753
|
id: "github:actions:dispatch",
|
|
1744
1754
|
description: "Dispatches a GitHub Action workflow for a given branch or tag",
|
|
@@ -1781,8 +1791,8 @@ function createGithubActionsDispatchAction(options) {
|
|
|
1781
1791
|
}
|
|
1782
1792
|
|
|
1783
1793
|
function createGithubWebhookAction(options) {
|
|
1784
|
-
const { integrations, defaultWebhookSecret } = options;
|
|
1785
|
-
const octokitProvider = new OctokitProvider(integrations);
|
|
1794
|
+
const { integrations, defaultWebhookSecret, githubCredentialsProvider } = options;
|
|
1795
|
+
const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider != null ? githubCredentialsProvider : integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
|
|
1786
1796
|
const eventNames = webhooks.emitterEventNames.filter((event) => !event.includes("."));
|
|
1787
1797
|
return createTemplateAction({
|
|
1788
1798
|
id: "github:webhook",
|
|
@@ -1882,6 +1892,7 @@ function createGithubWebhookAction(options) {
|
|
|
1882
1892
|
|
|
1883
1893
|
const createBuiltinActions = (options) => {
|
|
1884
1894
|
const { reader, integrations, containerRunner, catalogClient, config } = options;
|
|
1895
|
+
const githubCredentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
|
|
1885
1896
|
const actions = [
|
|
1886
1897
|
createFetchPlainAction({
|
|
1887
1898
|
reader,
|
|
@@ -1893,10 +1904,12 @@ const createBuiltinActions = (options) => {
|
|
|
1893
1904
|
}),
|
|
1894
1905
|
createPublishGithubAction({
|
|
1895
1906
|
integrations,
|
|
1896
|
-
config
|
|
1907
|
+
config,
|
|
1908
|
+
githubCredentialsProvider
|
|
1897
1909
|
}),
|
|
1898
1910
|
createPublishGithubPullRequestAction({
|
|
1899
|
-
integrations
|
|
1911
|
+
integrations,
|
|
1912
|
+
githubCredentialsProvider
|
|
1900
1913
|
}),
|
|
1901
1914
|
createPublishGitlabAction({
|
|
1902
1915
|
integrations,
|
|
@@ -1919,10 +1932,12 @@ const createBuiltinActions = (options) => {
|
|
|
1919
1932
|
createFilesystemDeleteAction(),
|
|
1920
1933
|
createFilesystemRenameAction(),
|
|
1921
1934
|
createGithubActionsDispatchAction({
|
|
1922
|
-
integrations
|
|
1935
|
+
integrations,
|
|
1936
|
+
githubCredentialsProvider
|
|
1923
1937
|
}),
|
|
1924
1938
|
createGithubWebhookAction({
|
|
1925
|
-
integrations
|
|
1939
|
+
integrations,
|
|
1940
|
+
githubCredentialsProvider
|
|
1926
1941
|
})
|
|
1927
1942
|
];
|
|
1928
1943
|
if (containerRunner) {
|
|
@@ -2515,7 +2530,7 @@ class NunjucksWorkflowRunner {
|
|
|
2515
2530
|
});
|
|
2516
2531
|
}
|
|
2517
2532
|
async execute(task) {
|
|
2518
|
-
var _a, _b;
|
|
2533
|
+
var _a, _b, _c;
|
|
2519
2534
|
if (!isValidTaskSpec(task.spec)) {
|
|
2520
2535
|
throw new errors.InputError("Wrong template version executed with the workflow engine");
|
|
2521
2536
|
}
|
|
@@ -2564,6 +2579,7 @@ class NunjucksWorkflowRunner {
|
|
|
2564
2579
|
await action.handler({
|
|
2565
2580
|
baseUrl: task.spec.baseUrl,
|
|
2566
2581
|
input,
|
|
2582
|
+
token: (_c = task.secrets) == null ? void 0 : _c.token,
|
|
2567
2583
|
logger: taskLogger,
|
|
2568
2584
|
logStream: streamLogger,
|
|
2569
2585
|
workspacePath,
|