@backstage/plugin-scaffolder-backend 0.15.19 → 0.15.20
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 +18 -0
- package/dist/index.cjs.js +39 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +11 -6
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 0.15.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9fbd3b90ae: fix: Register plugin to prioritise Component kind for entityRef
|
|
8
|
+
- 451ef0aa07: Fix token pass-through for software templates using beta 3 version
|
|
9
|
+
- 5333451def: Cleaned up API exports
|
|
10
|
+
- 3b4d8caff6: Allow a GitHubCredentialsProvider to be passed to the GitHub scaffolder tasks actions.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/config@0.1.12
|
|
13
|
+
- @backstage/integration@0.7.1
|
|
14
|
+
- @backstage/backend-common@0.10.3
|
|
15
|
+
- @backstage/plugin-catalog-backend@0.20.0
|
|
16
|
+
- @backstage/errors@0.2.0
|
|
17
|
+
- @backstage/catalog-client@0.5.4
|
|
18
|
+
- @backstage/catalog-model@0.9.9
|
|
19
|
+
- @backstage/plugin-scaffolder-backend-module-cookiecutter@0.1.8
|
|
20
|
+
|
|
3
21
|
## 0.15.19
|
|
4
22
|
|
|
5
23
|
### 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) {
|
|
@@ -1150,12 +1156,9 @@ function createPublishFileAction() {
|
|
|
1150
1156
|
}
|
|
1151
1157
|
|
|
1152
1158
|
class OctokitProvider {
|
|
1153
|
-
constructor(integrations) {
|
|
1159
|
+
constructor(integrations, githubCredentialsProvider) {
|
|
1154
1160
|
this.integrations = integrations;
|
|
1155
|
-
this.
|
|
1156
|
-
const provider = integration.SingleInstanceGithubCredentialsProvider.create(integration$1.config);
|
|
1157
|
-
return [integration$1.config.host, provider];
|
|
1158
|
-
}));
|
|
1161
|
+
this.githubCredentialsProvider = githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
|
|
1159
1162
|
}
|
|
1160
1163
|
async getOctokit(repoUrl) {
|
|
1161
1164
|
var _a;
|
|
@@ -1167,11 +1170,7 @@ class OctokitProvider {
|
|
|
1167
1170
|
if (!integrationConfig) {
|
|
1168
1171
|
throw new errors.InputError(`No integration for host ${host}`);
|
|
1169
1172
|
}
|
|
1170
|
-
const
|
|
1171
|
-
if (!credentialsProvider) {
|
|
1172
|
-
throw new errors.InputError(`No matching credentials for host ${host}, please check your integrations config`);
|
|
1173
|
-
}
|
|
1174
|
-
const { token } = await credentialsProvider.getCredentials({
|
|
1173
|
+
const { token } = await this.githubCredentialsProvider.getCredentials({
|
|
1175
1174
|
url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
|
|
1176
1175
|
});
|
|
1177
1176
|
if (!token) {
|
|
@@ -1187,8 +1186,8 @@ class OctokitProvider {
|
|
|
1187
1186
|
}
|
|
1188
1187
|
|
|
1189
1188
|
function createPublishGithubAction(options) {
|
|
1190
|
-
const { integrations, config } = options;
|
|
1191
|
-
const octokitProvider = new OctokitProvider(integrations);
|
|
1189
|
+
const { integrations, config, githubCredentialsProvider } = options;
|
|
1190
|
+
const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
|
|
1192
1191
|
return createTemplateAction({
|
|
1193
1192
|
id: "publish:github",
|
|
1194
1193
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
@@ -1388,6 +1387,7 @@ class GithubResponseError extends errors.CustomErrorBase {
|
|
|
1388
1387
|
}
|
|
1389
1388
|
const defaultClientFactory = async ({
|
|
1390
1389
|
integrations,
|
|
1390
|
+
githubCredentialsProvider,
|
|
1391
1391
|
owner,
|
|
1392
1392
|
repo,
|
|
1393
1393
|
host = "github.com"
|
|
@@ -1397,10 +1397,7 @@ const defaultClientFactory = async ({
|
|
|
1397
1397
|
if (!integrationConfig) {
|
|
1398
1398
|
throw new errors.InputError(`No integration for host ${host}`);
|
|
1399
1399
|
}
|
|
1400
|
-
const credentialsProvider = integration.SingleInstanceGithubCredentialsProvider.create(integrationConfig);
|
|
1401
|
-
if (!credentialsProvider) {
|
|
1402
|
-
throw new errors.InputError(`No matching credentials for host ${host}, please check your integrations config`);
|
|
1403
|
-
}
|
|
1400
|
+
const credentialsProvider = githubCredentialsProvider || integration.SingleInstanceGithubCredentialsProvider.create(integrationConfig);
|
|
1404
1401
|
const { token } = await credentialsProvider.getCredentials({
|
|
1405
1402
|
url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
|
|
1406
1403
|
});
|
|
@@ -1415,6 +1412,7 @@ const defaultClientFactory = async ({
|
|
|
1415
1412
|
};
|
|
1416
1413
|
const createPublishGithubPullRequestAction = ({
|
|
1417
1414
|
integrations,
|
|
1415
|
+
githubCredentialsProvider,
|
|
1418
1416
|
clientFactory = defaultClientFactory
|
|
1419
1417
|
}) => {
|
|
1420
1418
|
return createTemplateAction({
|
|
@@ -1481,7 +1479,13 @@ const createPublishGithubPullRequestAction = ({
|
|
|
1481
1479
|
if (!owner) {
|
|
1482
1480
|
throw new errors.InputError(`No owner provided for host: ${host}, and repo ${repo}`);
|
|
1483
1481
|
}
|
|
1484
|
-
const client = await clientFactory({
|
|
1482
|
+
const client = await clientFactory({
|
|
1483
|
+
integrations,
|
|
1484
|
+
githubCredentialsProvider,
|
|
1485
|
+
host,
|
|
1486
|
+
owner,
|
|
1487
|
+
repo
|
|
1488
|
+
});
|
|
1485
1489
|
const fileRoot = sourcePath ? backendCommon.resolveSafeChildPath(ctx.workspacePath, sourcePath) : ctx.workspacePath;
|
|
1486
1490
|
const localFilePaths = await globby__default["default"](["./**", "./**/.*", "!.git"], {
|
|
1487
1491
|
cwd: fileRoot,
|
|
@@ -1743,8 +1747,8 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
1743
1747
|
};
|
|
1744
1748
|
|
|
1745
1749
|
function createGithubActionsDispatchAction(options) {
|
|
1746
|
-
const { integrations } = options;
|
|
1747
|
-
const octokitProvider = new OctokitProvider(integrations);
|
|
1750
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
1751
|
+
const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
|
|
1748
1752
|
return createTemplateAction({
|
|
1749
1753
|
id: "github:actions:dispatch",
|
|
1750
1754
|
description: "Dispatches a GitHub Action workflow for a given branch or tag",
|
|
@@ -1787,8 +1791,8 @@ function createGithubActionsDispatchAction(options) {
|
|
|
1787
1791
|
}
|
|
1788
1792
|
|
|
1789
1793
|
function createGithubWebhookAction(options) {
|
|
1790
|
-
const { integrations, defaultWebhookSecret } = options;
|
|
1791
|
-
const octokitProvider = new OctokitProvider(integrations);
|
|
1794
|
+
const { integrations, defaultWebhookSecret, githubCredentialsProvider } = options;
|
|
1795
|
+
const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider != null ? githubCredentialsProvider : integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
|
|
1792
1796
|
const eventNames = webhooks.emitterEventNames.filter((event) => !event.includes("."));
|
|
1793
1797
|
return createTemplateAction({
|
|
1794
1798
|
id: "github:webhook",
|
|
@@ -1888,6 +1892,7 @@ function createGithubWebhookAction(options) {
|
|
|
1888
1892
|
|
|
1889
1893
|
const createBuiltinActions = (options) => {
|
|
1890
1894
|
const { reader, integrations, containerRunner, catalogClient, config } = options;
|
|
1895
|
+
const githubCredentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
|
|
1891
1896
|
const actions = [
|
|
1892
1897
|
createFetchPlainAction({
|
|
1893
1898
|
reader,
|
|
@@ -1899,10 +1904,12 @@ const createBuiltinActions = (options) => {
|
|
|
1899
1904
|
}),
|
|
1900
1905
|
createPublishGithubAction({
|
|
1901
1906
|
integrations,
|
|
1902
|
-
config
|
|
1907
|
+
config,
|
|
1908
|
+
githubCredentialsProvider
|
|
1903
1909
|
}),
|
|
1904
1910
|
createPublishGithubPullRequestAction({
|
|
1905
|
-
integrations
|
|
1911
|
+
integrations,
|
|
1912
|
+
githubCredentialsProvider
|
|
1906
1913
|
}),
|
|
1907
1914
|
createPublishGitlabAction({
|
|
1908
1915
|
integrations,
|
|
@@ -1925,10 +1932,12 @@ const createBuiltinActions = (options) => {
|
|
|
1925
1932
|
createFilesystemDeleteAction(),
|
|
1926
1933
|
createFilesystemRenameAction(),
|
|
1927
1934
|
createGithubActionsDispatchAction({
|
|
1928
|
-
integrations
|
|
1935
|
+
integrations,
|
|
1936
|
+
githubCredentialsProvider
|
|
1929
1937
|
}),
|
|
1930
1938
|
createGithubWebhookAction({
|
|
1931
|
-
integrations
|
|
1939
|
+
integrations,
|
|
1940
|
+
githubCredentialsProvider
|
|
1932
1941
|
})
|
|
1933
1942
|
];
|
|
1934
1943
|
if (containerRunner) {
|
|
@@ -2521,7 +2530,7 @@ class NunjucksWorkflowRunner {
|
|
|
2521
2530
|
});
|
|
2522
2531
|
}
|
|
2523
2532
|
async execute(task) {
|
|
2524
|
-
var _a, _b;
|
|
2533
|
+
var _a, _b, _c;
|
|
2525
2534
|
if (!isValidTaskSpec(task.spec)) {
|
|
2526
2535
|
throw new errors.InputError("Wrong template version executed with the workflow engine");
|
|
2527
2536
|
}
|
|
@@ -2570,6 +2579,7 @@ class NunjucksWorkflowRunner {
|
|
|
2570
2579
|
await action.handler({
|
|
2571
2580
|
baseUrl: task.spec.baseUrl,
|
|
2572
2581
|
input,
|
|
2582
|
+
token: (_c = task.secrets) == null ? void 0 : _c.token,
|
|
2573
2583
|
logger: taskLogger,
|
|
2574
2584
|
logStream: streamLogger,
|
|
2575
2585
|
workspacePath,
|