@backstage/plugin-scaffolder-backend 1.30.0-next.1 → 1.30.0-next.3
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 +79 -0
- package/config.d.ts +5 -0
- package/dist/ScaffolderPlugin.cjs.js +16 -2
- package/dist/ScaffolderPlugin.cjs.js.map +1 -1
- package/dist/index.d.ts +32 -29
- package/dist/lib/templating/SecureTemplater.cjs.js +2 -1
- package/dist/lib/templating/SecureTemplater.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/createBuiltinActions.cjs.js +29 -29
- package/dist/scaffolder/actions/builtin/createBuiltinActions.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/delete.cjs.js +15 -7
- package/dist/scaffolder/actions/builtin/filesystem/delete.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/delete.examples.cjs.js +15 -0
- package/dist/scaffolder/actions/builtin/filesystem/delete.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/deprecated.cjs.js +25 -51
- package/dist/scaffolder/actions/deprecated.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/TaskWorker.cjs.js +12 -4
- package/dist/scaffolder/tasks/TaskWorker.cjs.js.map +1 -1
- package/dist/service/router.cjs.js +26 -11
- package/dist/service/router.cjs.js.map +1 -1
- package/package.json +27 -23
|
@@ -4,11 +4,13 @@ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
|
4
4
|
var errors = require('@backstage/errors');
|
|
5
5
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
6
|
var fs = require('fs-extra');
|
|
7
|
+
var globby = require('globby');
|
|
7
8
|
var delete_examples = require('./delete.examples.cjs.js');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
11
|
|
|
11
12
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
13
|
+
var globby__default = /*#__PURE__*/_interopDefaultCompat(globby);
|
|
12
14
|
|
|
13
15
|
const createFilesystemDeleteAction = () => {
|
|
14
16
|
return pluginScaffolderNode.createTemplateAction({
|
|
@@ -37,13 +39,19 @@ const createFilesystemDeleteAction = () => {
|
|
|
37
39
|
throw new errors.InputError("files must be an Array");
|
|
38
40
|
}
|
|
39
41
|
for (const file of ctx.input.files) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const safeFilepath = backendPluginApi.resolveSafeChildPath(ctx.workspacePath, file);
|
|
43
|
+
const resolvedPaths = await globby__default.default(safeFilepath, {
|
|
44
|
+
cwd: ctx.workspacePath,
|
|
45
|
+
absolute: true
|
|
46
|
+
});
|
|
47
|
+
for (const filepath of resolvedPaths) {
|
|
48
|
+
try {
|
|
49
|
+
await fs__default.default.remove(filepath);
|
|
50
|
+
ctx.logger.info(`File ${filepath} deleted successfully`);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
ctx.logger.error(`Failed to delete file ${filepath}:`, err);
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/filesystem/delete.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport { examples } from './delete.examples';\n\n/**\n * Creates new action that enables deletion of files and directories in the workspace.\n * @public\n */\nexport const createFilesystemDeleteAction = () => {\n return createTemplateAction<{ files: string[] }>({\n id: 'fs:delete',\n description: 'Deletes files and directories from the workspace',\n examples,\n schema: {\n input: {\n required: ['files'],\n type: 'object',\n properties: {\n files: {\n title: 'Files',\n description: 'A list of files and directories that will be deleted',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n if (!Array.isArray(ctx.input?.files)) {\n throw new InputError('files must be an Array');\n }\n\n for (const file of ctx.input.files) {\n const
|
|
1
|
+
{"version":3,"file":"delete.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/filesystem/delete.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { examples } from './delete.examples';\n\n/**\n * Creates new action that enables deletion of files and directories in the workspace.\n * @public\n */\nexport const createFilesystemDeleteAction = () => {\n return createTemplateAction<{ files: string[] }>({\n id: 'fs:delete',\n description: 'Deletes files and directories from the workspace',\n examples,\n schema: {\n input: {\n required: ['files'],\n type: 'object',\n properties: {\n files: {\n title: 'Files',\n description: 'A list of files and directories that will be deleted',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n if (!Array.isArray(ctx.input?.files)) {\n throw new InputError('files must be an Array');\n }\n\n for (const file of ctx.input.files) {\n const safeFilepath = resolveSafeChildPath(ctx.workspacePath, file);\n const resolvedPaths = await globby(safeFilepath, {\n cwd: ctx.workspacePath,\n absolute: true,\n });\n\n for (const filepath of resolvedPaths) {\n try {\n await fs.remove(filepath);\n ctx.logger.info(`File ${filepath} deleted successfully`);\n } catch (err) {\n ctx.logger.error(`Failed to delete file ${filepath}:`, err);\n throw err;\n }\n }\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","InputError","resolveSafeChildPath","globby","fs"],"mappings":";;;;;;;;;;;;;;AA2BO,MAAM,+BAA+B,MAAM;AAChD,EAAA,OAAOA,yCAA0C,CAAA;AAAA,IAC/C,EAAI,EAAA,WAAA;AAAA,IACJ,WAAa,EAAA,kDAAA;AAAA,cACbC,wBAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAA,EAAU,CAAC,OAAO,CAAA;AAAA,QAClB,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,OAAA;AAAA,YACP,WAAa,EAAA,sDAAA;AAAA,YACb,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL,IAAM,EAAA;AAAA;AACR;AACF;AACF;AACF,KACF;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,GAAI,CAAA,KAAA,EAAO,KAAK,CAAG,EAAA;AACpC,QAAM,MAAA,IAAIC,kBAAW,wBAAwB,CAAA;AAAA;AAG/C,MAAW,KAAA,MAAA,IAAA,IAAQ,GAAI,CAAA,KAAA,CAAM,KAAO,EAAA;AAClC,QAAA,MAAM,YAAe,GAAAC,qCAAA,CAAqB,GAAI,CAAA,aAAA,EAAe,IAAI,CAAA;AACjE,QAAM,MAAA,aAAA,GAAgB,MAAMC,uBAAA,CAAO,YAAc,EAAA;AAAA,UAC/C,KAAK,GAAI,CAAA,aAAA;AAAA,UACT,QAAU,EAAA;AAAA,SACX,CAAA;AAED,QAAA,KAAA,MAAW,YAAY,aAAe,EAAA;AACpC,UAAI,IAAA;AACF,YAAM,MAAAC,mBAAA,CAAG,OAAO,QAAQ,CAAA;AACxB,YAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAQ,KAAA,EAAA,QAAQ,CAAuB,qBAAA,CAAA,CAAA;AAAA,mBAChD,GAAK,EAAA;AACZ,YAAA,GAAA,CAAI,MAAO,CAAA,KAAA,CAAM,CAAyB,sBAAA,EAAA,QAAQ,KAAK,GAAG,CAAA;AAC1D,YAAM,MAAA,GAAA;AAAA;AACR;AACF;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -37,6 +37,21 @@ const examples = [
|
|
|
37
37
|
}
|
|
38
38
|
]
|
|
39
39
|
})
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: "Delete files with wildcard",
|
|
43
|
+
example: yaml__namespace.stringify({
|
|
44
|
+
steps: [
|
|
45
|
+
{
|
|
46
|
+
action: "fs:delete",
|
|
47
|
+
id: "deleteFiles",
|
|
48
|
+
name: "Delete files",
|
|
49
|
+
input: {
|
|
50
|
+
files: ["*.txt"]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
})
|
|
40
55
|
}
|
|
41
56
|
];
|
|
42
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/filesystem/delete.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport * as yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Delete specified files',\n example: yaml.stringify({\n steps: [\n {\n action: 'fs:delete',\n id: 'deleteFiles',\n name: 'Delete files',\n input: {\n files: ['file1.txt', 'file2.txt'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wBAAA;AAAA,IACb,OAAA,EAASA,gBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,WAAA;AAAA,UACR,EAAI,EAAA,aAAA;AAAA,UACJ,IAAM,EAAA,cAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,KAAA,EAAO,CAAC,WAAA,EAAa,WAAW;AAAA;AAClC;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"delete.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/filesystem/delete.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport * as yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Delete specified files',\n example: yaml.stringify({\n steps: [\n {\n action: 'fs:delete',\n id: 'deleteFiles',\n name: 'Delete files',\n input: {\n files: ['file1.txt', 'file2.txt'],\n },\n },\n ],\n }),\n },\n {\n description: 'Delete files with wildcard',\n example: yaml.stringify({\n steps: [\n {\n action: 'fs:delete',\n id: 'deleteFiles',\n name: 'Delete files',\n input: {\n files: ['*.txt'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wBAAA;AAAA,IACb,OAAA,EAASA,gBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,WAAA;AAAA,UACR,EAAI,EAAA,aAAA;AAAA,UACJ,IAAM,EAAA,cAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,KAAA,EAAO,CAAC,WAAA,EAAa,WAAW;AAAA;AAClC;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,4BAAA;AAAA,IACb,OAAA,EAASA,gBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,WAAA;AAAA,UACR,EAAI,EAAA,aAAA;AAAA,UACJ,IAAM,EAAA,cAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,KAAA,EAAO,CAAC,OAAO;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1,57 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
3
|
+
var pluginScaffolderBackendModuleGithub = require('@backstage/plugin-scaffolder-backend-module-github');
|
|
4
|
+
var pluginScaffolderBackendModuleGitlab = require('@backstage/plugin-scaffolder-backend-module-gitlab');
|
|
5
|
+
var pluginScaffolderBackendModuleAzure = require('@backstage/plugin-scaffolder-backend-module-azure');
|
|
6
|
+
var pluginScaffolderBackendModuleBitbucket = require('@backstage/plugin-scaffolder-backend-module-bitbucket');
|
|
7
|
+
var pluginScaffolderBackendModuleBitbucketCloud = require('@backstage/plugin-scaffolder-backend-module-bitbucket-cloud');
|
|
8
|
+
var pluginScaffolderBackendModuleBitbucketServer = require('@backstage/plugin-scaffolder-backend-module-bitbucket-server');
|
|
9
|
+
var pluginScaffolderBackendModuleGerrit = require('@backstage/plugin-scaffolder-backend-module-gerrit');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var github__namespace = /*#__PURE__*/_interopNamespaceCompat(github);
|
|
30
|
-
var gitlab__namespace = /*#__PURE__*/_interopNamespaceCompat(gitlab);
|
|
31
|
-
var azure__namespace = /*#__PURE__*/_interopNamespaceCompat(azure);
|
|
32
|
-
var bitbucket__namespace = /*#__PURE__*/_interopNamespaceCompat(bitbucket);
|
|
33
|
-
var bitbucketCloud__namespace = /*#__PURE__*/_interopNamespaceCompat(bitbucketCloud);
|
|
34
|
-
var bitbucketServer__namespace = /*#__PURE__*/_interopNamespaceCompat(bitbucketServer);
|
|
35
|
-
var gerrit__namespace = /*#__PURE__*/_interopNamespaceCompat(gerrit);
|
|
36
|
-
|
|
37
|
-
const createGithubActionsDispatchAction = github__namespace.createGithubActionsDispatchAction;
|
|
38
|
-
const createGithubDeployKeyAction = github__namespace.createGithubDeployKeyAction;
|
|
39
|
-
const createGithubEnvironmentAction = github__namespace.createGithubEnvironmentAction;
|
|
40
|
-
const createGithubIssuesLabelAction = github__namespace.createGithubIssuesLabelAction;
|
|
41
|
-
const createGithubRepoCreateAction = github__namespace.createGithubRepoCreateAction;
|
|
42
|
-
const createGithubRepoPushAction = github__namespace.createGithubRepoPushAction;
|
|
43
|
-
const createGithubWebhookAction = github__namespace.createGithubWebhookAction;
|
|
44
|
-
const createPublishGithubAction = github__namespace.createPublishGithubAction;
|
|
45
|
-
const createPublishGithubPullRequestAction = github__namespace.createPublishGithubPullRequestAction;
|
|
46
|
-
const createPublishBitbucketAction = bitbucket__namespace.createPublishBitbucketAction;
|
|
47
|
-
const createPublishBitbucketCloudAction = bitbucketCloud__namespace.createPublishBitbucketCloudAction;
|
|
48
|
-
const createPublishBitbucketServerAction = bitbucketServer__namespace.createPublishBitbucketServerAction;
|
|
49
|
-
const createPublishBitbucketServerPullRequestAction = bitbucketServer__namespace.createPublishBitbucketServerPullRequestAction;
|
|
50
|
-
const createPublishAzureAction = azure__namespace.createPublishAzureAction;
|
|
51
|
-
const createPublishGerritAction = gerrit__namespace.createPublishGerritAction;
|
|
52
|
-
const createPublishGerritReviewAction = gerrit__namespace.createPublishGerritReviewAction;
|
|
53
|
-
const createPublishGitlabAction = gitlab__namespace.createPublishGitlabAction;
|
|
54
|
-
const createPublishGitlabMergeRequestAction = gitlab__namespace.createPublishGitlabMergeRequestAction;
|
|
11
|
+
const createGithubActionsDispatchAction = pluginScaffolderBackendModuleGithub.createGithubActionsDispatchAction;
|
|
12
|
+
const createGithubDeployKeyAction = pluginScaffolderBackendModuleGithub.createGithubDeployKeyAction;
|
|
13
|
+
const createGithubEnvironmentAction = pluginScaffolderBackendModuleGithub.createGithubEnvironmentAction;
|
|
14
|
+
const createGithubIssuesLabelAction = pluginScaffolderBackendModuleGithub.createGithubIssuesLabelAction;
|
|
15
|
+
const createGithubRepoCreateAction = pluginScaffolderBackendModuleGithub.createGithubRepoCreateAction;
|
|
16
|
+
const createGithubRepoPushAction = pluginScaffolderBackendModuleGithub.createGithubRepoPushAction;
|
|
17
|
+
const createGithubWebhookAction = pluginScaffolderBackendModuleGithub.createGithubWebhookAction;
|
|
18
|
+
const createPublishGithubAction = pluginScaffolderBackendModuleGithub.createPublishGithubAction;
|
|
19
|
+
const createPublishGithubPullRequestAction = pluginScaffolderBackendModuleGithub.createPublishGithubPullRequestAction;
|
|
20
|
+
const createPublishBitbucketAction = pluginScaffolderBackendModuleBitbucket.createPublishBitbucketAction;
|
|
21
|
+
const createPublishBitbucketCloudAction = pluginScaffolderBackendModuleBitbucketCloud.createPublishBitbucketCloudAction;
|
|
22
|
+
const createPublishBitbucketServerAction = pluginScaffolderBackendModuleBitbucketServer.createPublishBitbucketServerAction;
|
|
23
|
+
const createPublishBitbucketServerPullRequestAction = pluginScaffolderBackendModuleBitbucketServer.createPublishBitbucketServerPullRequestAction;
|
|
24
|
+
const createPublishAzureAction = pluginScaffolderBackendModuleAzure.createPublishAzureAction;
|
|
25
|
+
const createPublishGerritAction = pluginScaffolderBackendModuleGerrit.createPublishGerritAction;
|
|
26
|
+
const createPublishGerritReviewAction = pluginScaffolderBackendModuleGerrit.createPublishGerritReviewAction;
|
|
27
|
+
const createPublishGitlabAction = pluginScaffolderBackendModuleGitlab.createPublishGitlabAction;
|
|
28
|
+
const createPublishGitlabMergeRequestAction = pluginScaffolderBackendModuleGitlab.createPublishGitlabMergeRequestAction;
|
|
55
29
|
|
|
56
30
|
exports.createGithubActionsDispatchAction = createGithubActionsDispatchAction;
|
|
57
31
|
exports.createGithubDeployKeyAction = createGithubDeployKeyAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated.cjs.js","sources":["../../../src/scaffolder/actions/deprecated.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
|
1
|
+
{"version":3,"file":"deprecated.cjs.js","sources":["../../../src/scaffolder/actions/deprecated.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createGithubActionsDispatchAction as githubActionsDispatch,\n createGithubDeployKeyAction as githubDeployKey,\n createGithubEnvironmentAction as githubEnvironment,\n createGithubIssuesLabelAction as githubIssuesLabel,\n CreateGithubPullRequestActionOptions as GithubPullRequestActionOptions,\n createGithubRepoCreateAction as githubRepoCreate,\n createGithubRepoPushAction as githubRepoPush,\n createGithubWebhookAction as githubWebhook,\n createPublishGithubAction as publishGithub,\n createPublishGithubPullRequestAction as publishGithubPullRequest,\n} from '@backstage/plugin-scaffolder-backend-module-github';\n\nimport {\n createPublishGitlabAction as publishGitlab,\n createPublishGitlabMergeRequestAction as publishGitlabMergeRequest,\n} from '@backstage/plugin-scaffolder-backend-module-gitlab';\n\nimport { createPublishAzureAction as publishAzure } from '@backstage/plugin-scaffolder-backend-module-azure';\n\nimport { createPublishBitbucketAction as publishBitbucket } from '@backstage/plugin-scaffolder-backend-module-bitbucket';\n\nimport { createPublishBitbucketCloudAction as publishBitbucketCloud } from '@backstage/plugin-scaffolder-backend-module-bitbucket-cloud';\n\nimport {\n createPublishBitbucketServerAction as publishBitbucketServer,\n createPublishBitbucketServerPullRequestAction as publishBitbucketServerPullRequest,\n} from '@backstage/plugin-scaffolder-backend-module-bitbucket-server';\n\nimport {\n createPublishGerritAction as publishGerrit,\n createPublishGerritReviewAction as publishGerritReview,\n} from '@backstage/plugin-scaffolder-backend-module-gerrit';\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubActionsDispatchAction = githubActionsDispatch;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubDeployKeyAction = githubDeployKey;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubEnvironmentAction = githubEnvironment;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubIssuesLabelAction = githubIssuesLabel;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport type CreateGithubPullRequestActionOptions =\n GithubPullRequestActionOptions;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubRepoCreateAction = githubRepoCreate;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubRepoPushAction = githubRepoPush;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createGithubWebhookAction = githubWebhook;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createPublishGithubAction = publishGithub;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-github` instead\n */\nexport const createPublishGithubPullRequestAction = publishGithubPullRequest;\n\n/**\n * @public @deprecated use \"createPublishBitbucketCloudAction\" from \\@backstage/plugin-scaffolder-backend-module-bitbucket-cloud or \"createPublishBitbucketServerAction\" from \\@backstage/plugin-scaffolder-backend-module-bitbucket-server instead\n */\nexport const createPublishBitbucketAction = publishBitbucket;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-bitbucket-cloud` instead\n */\nexport const createPublishBitbucketCloudAction = publishBitbucketCloud;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-bitbucket-server` instead\n */\nexport const createPublishBitbucketServerAction = publishBitbucketServer;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-bitbucket-server` instead\n */\nexport const createPublishBitbucketServerPullRequestAction =\n publishBitbucketServerPullRequest;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-azure` instead\n */\nexport const createPublishAzureAction = publishAzure;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-gerrit` instead\n */\nexport const createPublishGerritAction = publishGerrit;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-gerrit` instead\n */\nexport const createPublishGerritReviewAction = publishGerritReview;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-gitlab` instead\n */\nexport const createPublishGitlabAction = publishGitlab;\n\n/**\n * @public\n * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-gitlab` instead\n */\nexport const createPublishGitlabMergeRequestAction = publishGitlabMergeRequest;\n"],"names":["githubActionsDispatch","githubDeployKey","githubEnvironment","githubIssuesLabel","githubRepoCreate","githubRepoPush","githubWebhook","publishGithub","publishGithubPullRequest","publishBitbucket","publishBitbucketCloud","publishBitbucketServer","publishBitbucketServerPullRequest","publishAzure","publishGerrit","publishGerritReview","publishGitlab","publishGitlabMergeRequest"],"mappings":";;;;;;;;;;AAqDO,MAAM,iCAAoC,GAAAA;AAM1C,MAAM,2BAA8B,GAAAC;AAMpC,MAAM,6BAAgC,GAAAC;AAMtC,MAAM,6BAAgC,GAAAC;AAatC,MAAM,4BAA+B,GAAAC;AAMrC,MAAM,0BAA6B,GAAAC;AAMnC,MAAM,yBAA4B,GAAAC;AAMlC,MAAM,yBAA4B,GAAAC;AAMlC,MAAM,oCAAuC,GAAAC;AAK7C,MAAM,4BAA+B,GAAAC;AAMrC,MAAM,iCAAoC,GAAAC;AAM1C,MAAM,kCAAqC,GAAAC;AAM3C,MAAM,6CACX,GAAAC;AAMK,MAAM,wBAA2B,GAAAC;AAMjC,MAAM,yBAA4B,GAAAC;AAMlC,MAAM,+BAAkC,GAAAC;AAMxC,MAAM,yBAA4B,GAAAC;AAMlC,MAAM,qCAAwC,GAAAC;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var errors = require('@backstage/errors');
|
|
4
4
|
var PQueue = require('p-queue');
|
|
5
5
|
var NunjucksWorkflowRunner = require('./NunjucksWorkflowRunner.cjs.js');
|
|
6
|
+
var promises = require('timers/promises');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -34,7 +35,8 @@ class TaskWorker {
|
|
|
34
35
|
concurrentTasksLimit = 10,
|
|
35
36
|
// from 1 to Infinity
|
|
36
37
|
additionalTemplateGlobals,
|
|
37
|
-
permissions
|
|
38
|
+
permissions,
|
|
39
|
+
gracefulShutdown
|
|
38
40
|
} = options;
|
|
39
41
|
const workflowRunner = new NunjucksWorkflowRunner.NunjucksWorkflowRunner({
|
|
40
42
|
actionRegistry,
|
|
@@ -51,7 +53,8 @@ class TaskWorker {
|
|
|
51
53
|
runners: { workflowRunner },
|
|
52
54
|
concurrentTasksLimit,
|
|
53
55
|
permissions,
|
|
54
|
-
auditor
|
|
56
|
+
auditor,
|
|
57
|
+
gracefulShutdown
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
async recoverTasks() {
|
|
@@ -64,7 +67,7 @@ class TaskWorker {
|
|
|
64
67
|
start() {
|
|
65
68
|
(async () => {
|
|
66
69
|
while (!this.stopWorkers) {
|
|
67
|
-
await
|
|
70
|
+
await promises.setTimeout(1e4);
|
|
68
71
|
await this.recoverTasks();
|
|
69
72
|
}
|
|
70
73
|
})();
|
|
@@ -78,8 +81,13 @@ class TaskWorker {
|
|
|
78
81
|
}
|
|
79
82
|
})();
|
|
80
83
|
}
|
|
81
|
-
stop() {
|
|
84
|
+
async stop() {
|
|
82
85
|
this.stopWorkers = true;
|
|
86
|
+
if (this.options?.gracefulShutdown) {
|
|
87
|
+
while (this.taskQueue.size > 0) {
|
|
88
|
+
await promises.setTimeout(1e3);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
83
91
|
}
|
|
84
92
|
onReadyToClaimTask() {
|
|
85
93
|
if (this.taskQueue.pending < this.options.concurrentTasksLimit) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskWorker.cjs.js","sources":["../../../src/scaffolder/tasks/TaskWorker.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AuditorService } from '@backstage/backend-plugin-api';\nimport { assertError, stringifyError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { PermissionEvaluator } from '@backstage/plugin-permission-common';\nimport {\n TaskBroker,\n TaskContext,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport PQueue from 'p-queue';\nimport { Logger } from 'winston';\nimport { TemplateActionRegistry } from '../actions';\nimport { NunjucksWorkflowRunner } from './NunjucksWorkflowRunner';\nimport { WorkflowRunner } from './types';\n\n/**\n * TaskWorkerOptions\n *\n * @public\n */\nexport type TaskWorkerOptions = {\n taskBroker: TaskBroker;\n runners: {\n workflowRunner: WorkflowRunner;\n };\n concurrentTasksLimit: number;\n permissions?: PermissionEvaluator;\n logger?: Logger;\n auditor?: AuditorService;\n};\n\n/**\n * CreateWorkerOptions\n *\n * @public\n */\nexport type CreateWorkerOptions = {\n taskBroker: TaskBroker;\n actionRegistry: TemplateActionRegistry;\n integrations: ScmIntegrations;\n workingDirectory: string;\n logger: Logger;\n auditor?: AuditorService;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n /**\n * The number of tasks that can be executed at the same time by the worker\n * @defaultValue 10\n * @example\n * ```\n * {\n * concurrentTasksLimit: 1,\n * // OR\n * concurrentTasksLimit: Infinity\n * }\n * ```\n */\n concurrentTasksLimit?: number;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n permissions?: PermissionEvaluator;\n};\n\n/**\n * TaskWorker\n *\n * @public\n */\nexport class TaskWorker {\n private taskQueue: PQueue;\n private logger: Logger | undefined;\n private auditor: AuditorService | undefined;\n private stopWorkers: boolean;\n\n private constructor(private readonly options: TaskWorkerOptions) {\n this.stopWorkers = false;\n this.logger = options.logger;\n this.auditor = options.auditor;\n this.taskQueue = new PQueue({\n concurrency: options.concurrentTasksLimit,\n });\n }\n\n static async create(options: CreateWorkerOptions): Promise<TaskWorker> {\n const {\n taskBroker,\n logger,\n auditor,\n actionRegistry,\n integrations,\n workingDirectory,\n additionalTemplateFilters,\n concurrentTasksLimit = 10, // from 1 to Infinity\n additionalTemplateGlobals,\n permissions,\n } = options;\n\n const workflowRunner = new NunjucksWorkflowRunner({\n actionRegistry,\n integrations,\n logger,\n auditor,\n workingDirectory,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n\n return new TaskWorker({\n taskBroker: taskBroker,\n runners: { workflowRunner },\n concurrentTasksLimit,\n permissions,\n auditor,\n });\n }\n\n async recoverTasks() {\n try {\n await this.options.taskBroker.recoverTasks?.();\n } catch (err) {\n this.logger?.error(stringifyError(err));\n }\n }\n\n start() {\n (async () => {\n while (!this.stopWorkers) {\n await
|
|
1
|
+
{"version":3,"file":"TaskWorker.cjs.js","sources":["../../../src/scaffolder/tasks/TaskWorker.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AuditorService } from '@backstage/backend-plugin-api';\nimport { assertError, stringifyError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { PermissionEvaluator } from '@backstage/plugin-permission-common';\nimport {\n TaskBroker,\n TaskContext,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport PQueue from 'p-queue';\nimport { Logger } from 'winston';\nimport { TemplateActionRegistry } from '../actions';\nimport { NunjucksWorkflowRunner } from './NunjucksWorkflowRunner';\nimport { WorkflowRunner } from './types';\nimport { setTimeout } from 'timers/promises';\n\n/**\n * TaskWorkerOptions\n *\n * @public\n */\nexport type TaskWorkerOptions = {\n taskBroker: TaskBroker;\n runners: {\n workflowRunner: WorkflowRunner;\n };\n concurrentTasksLimit: number;\n permissions?: PermissionEvaluator;\n logger?: Logger;\n auditor?: AuditorService;\n gracefulShutdown?: boolean;\n};\n\n/**\n * CreateWorkerOptions\n *\n * @public\n */\nexport type CreateWorkerOptions = {\n taskBroker: TaskBroker;\n actionRegistry: TemplateActionRegistry;\n integrations: ScmIntegrations;\n workingDirectory: string;\n logger: Logger;\n auditor?: AuditorService;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n /**\n * The number of tasks that can be executed at the same time by the worker\n * @defaultValue 10\n * @example\n * ```\n * {\n * concurrentTasksLimit: 1,\n * // OR\n * concurrentTasksLimit: Infinity\n * }\n * ```\n */\n concurrentTasksLimit?: number;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n permissions?: PermissionEvaluator;\n gracefulShutdown?: boolean;\n};\n\n/**\n * TaskWorker\n *\n * @public\n */\nexport class TaskWorker {\n private taskQueue: PQueue;\n private logger: Logger | undefined;\n private auditor: AuditorService | undefined;\n private stopWorkers: boolean;\n\n private constructor(private readonly options: TaskWorkerOptions) {\n this.stopWorkers = false;\n this.logger = options.logger;\n this.auditor = options.auditor;\n this.taskQueue = new PQueue({\n concurrency: options.concurrentTasksLimit,\n });\n }\n\n static async create(options: CreateWorkerOptions): Promise<TaskWorker> {\n const {\n taskBroker,\n logger,\n auditor,\n actionRegistry,\n integrations,\n workingDirectory,\n additionalTemplateFilters,\n concurrentTasksLimit = 10, // from 1 to Infinity\n additionalTemplateGlobals,\n permissions,\n gracefulShutdown,\n } = options;\n\n const workflowRunner = new NunjucksWorkflowRunner({\n actionRegistry,\n integrations,\n logger,\n auditor,\n workingDirectory,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n\n return new TaskWorker({\n taskBroker: taskBroker,\n runners: { workflowRunner },\n concurrentTasksLimit,\n permissions,\n auditor,\n gracefulShutdown,\n });\n }\n\n async recoverTasks() {\n try {\n await this.options.taskBroker.recoverTasks?.();\n } catch (err) {\n this.logger?.error(stringifyError(err));\n }\n }\n\n start() {\n (async () => {\n while (!this.stopWorkers) {\n await setTimeout(10000);\n await this.recoverTasks();\n }\n })();\n (async () => {\n while (!this.stopWorkers) {\n await this.onReadyToClaimTask();\n if (!this.stopWorkers) {\n const task = await this.options.taskBroker.claim();\n void this.taskQueue.add(() => this.runOneTask(task));\n }\n }\n })();\n }\n\n async stop() {\n this.stopWorkers = true;\n if (this.options?.gracefulShutdown) {\n while (this.taskQueue.size > 0) {\n await setTimeout(1000);\n }\n }\n }\n\n protected onReadyToClaimTask(): Promise<void> {\n if (this.taskQueue.pending < this.options.concurrentTasksLimit) {\n return Promise.resolve();\n }\n return new Promise(resolve => {\n // \"next\" event emits when a task completes\n // https://github.com/sindresorhus/p-queue#next\n this.taskQueue.once('next', () => {\n resolve();\n });\n });\n }\n\n async runOneTask(task: TaskContext) {\n const auditorEvent = await this.auditor?.createEvent({\n eventId: 'task',\n severityLevel: 'medium',\n meta: {\n actionType: 'execution',\n taskId: task.taskId,\n taskParameters: task.spec.parameters,\n templateRef: task.spec.templateInfo?.entityRef,\n },\n });\n\n try {\n if (task.spec.apiVersion !== 'scaffolder.backstage.io/v1beta3') {\n throw new Error(\n `Unsupported Template apiVersion ${task.spec.apiVersion}`,\n );\n }\n\n const { output } = await this.options.runners.workflowRunner.execute(\n task,\n );\n\n await task.complete('completed', { output });\n await auditorEvent?.success();\n } catch (error) {\n assertError(error);\n await auditorEvent?.fail({\n error,\n });\n await task.complete('failed', {\n error: { name: error.name, message: error.message },\n });\n }\n }\n}\n"],"names":["PQueue","NunjucksWorkflowRunner","stringifyError","setTimeout","assertError"],"mappings":"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"}
|
|
@@ -193,8 +193,25 @@ async function createRouter(options) {
|
|
|
193
193
|
taskBroker = options.taskBroker;
|
|
194
194
|
}
|
|
195
195
|
const actionRegistry = new TemplateActionRegistry.TemplateActionRegistry();
|
|
196
|
+
const templateExtensions = {
|
|
197
|
+
additionalTemplateFilters: Array.isArray(additionalTemplateFilters) ? Object.fromEntries(
|
|
198
|
+
additionalTemplateFilters.map((f) => [
|
|
199
|
+
f.id,
|
|
200
|
+
f.filter
|
|
201
|
+
])
|
|
202
|
+
) : additionalTemplateFilters,
|
|
203
|
+
additionalTemplateGlobals: Array.isArray(additionalTemplateGlobals) ? Object.fromEntries(
|
|
204
|
+
additionalTemplateGlobals.map((g) => [
|
|
205
|
+
g.id,
|
|
206
|
+
"value" in g ? g.value : g.fn
|
|
207
|
+
])
|
|
208
|
+
) : additionalTemplateGlobals
|
|
209
|
+
};
|
|
196
210
|
const workers = [];
|
|
197
211
|
if (concurrentTasksLimit !== 0) {
|
|
212
|
+
const gracefulShutdown = config.getOptionalBoolean(
|
|
213
|
+
"scaffolder.EXPERIMENTAL_gracefulShutdown"
|
|
214
|
+
);
|
|
198
215
|
for (let i = 0; i < (taskWorkers || 1); i++) {
|
|
199
216
|
const worker = await TaskWorker.TaskWorker.create({
|
|
200
217
|
taskBroker,
|
|
@@ -203,10 +220,10 @@ async function createRouter(options) {
|
|
|
203
220
|
logger,
|
|
204
221
|
auditor,
|
|
205
222
|
workingDirectory,
|
|
206
|
-
additionalTemplateFilters,
|
|
207
|
-
additionalTemplateGlobals,
|
|
208
223
|
concurrentTasksLimit,
|
|
209
|
-
permissions
|
|
224
|
+
permissions,
|
|
225
|
+
gracefulShutdown,
|
|
226
|
+
...templateExtensions
|
|
210
227
|
});
|
|
211
228
|
workers.push(worker);
|
|
212
229
|
}
|
|
@@ -216,14 +233,13 @@ async function createRouter(options) {
|
|
|
216
233
|
catalogClient,
|
|
217
234
|
reader,
|
|
218
235
|
config,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
auth
|
|
236
|
+
auth,
|
|
237
|
+
...templateExtensions
|
|
222
238
|
});
|
|
223
239
|
actionsToRegister.forEach((action) => actionRegistry.register(action));
|
|
224
240
|
const launchWorkers = () => workers.forEach((worker) => worker.start());
|
|
225
|
-
const shutdownWorkers = () => {
|
|
226
|
-
workers.
|
|
241
|
+
const shutdownWorkers = async () => {
|
|
242
|
+
await Promise.allSettled(workers.map((worker) => worker.stop()));
|
|
227
243
|
};
|
|
228
244
|
if (options.lifecycle) {
|
|
229
245
|
options.lifecycle.addStartupHook(launchWorkers);
|
|
@@ -237,9 +253,8 @@ async function createRouter(options) {
|
|
|
237
253
|
logger,
|
|
238
254
|
auditor,
|
|
239
255
|
workingDirectory,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
permissions
|
|
256
|
+
permissions,
|
|
257
|
+
...templateExtensions
|
|
243
258
|
});
|
|
244
259
|
const templateRules = Object.values(
|
|
245
260
|
rules.scaffolderTemplateRules
|