@backstage/plugin-scaffolder-backend 2.2.1 → 2.2.2
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 +9 -0
- package/dist/scaffolder/actions/builtin/debug/log.cjs.js +11 -2
- package/dist/scaffolder/actions/builtin/debug/log.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/delete.cjs.js +4 -3
- package/dist/scaffolder/actions/builtin/filesystem/delete.cjs.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
3
4
|
var fs$1 = require('fs-extra');
|
|
4
5
|
var path = require('path');
|
|
5
6
|
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
@@ -37,10 +38,18 @@ function createDebugLogAction() {
|
|
|
37
38
|
${files.map((f) => {
|
|
38
39
|
const relativePath = path.relative(ctx.workspacePath, f);
|
|
39
40
|
if (ctx.input?.listWorkspace === "with-contents") {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
const safePath = backendPluginApi.resolveSafeChildPath(
|
|
43
|
+
ctx.workspacePath,
|
|
44
|
+
relativePath
|
|
45
|
+
);
|
|
46
|
+
const content = fs__default.default.readFileSync(safePath, "utf-8");
|
|
47
|
+
return ` - ${relativePath}:
|
|
42
48
|
|
|
43
49
|
${content}`;
|
|
50
|
+
} catch {
|
|
51
|
+
return ` - ${relativePath}: [skipped]`;
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
return ` - ${relativePath}`;
|
|
46
55
|
}).join("\n")}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/log.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 { readdir, stat } from 'fs-extra';\nimport { join, relative } from 'path';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './log.examples';\nimport fs from 'fs';\n\nconst id = 'debug:log';\n\n/**\n * Writes a message into the log or lists all files in the workspace\n *\n * @remarks\n *\n * This task is useful for local development and testing of both the scaffolder\n * and scaffolder templates.\n *\n * @public\n */\nexport function createDebugLogAction() {\n return createTemplateAction({\n id,\n description:\n 'Writes a message into the log and/or lists all files in the workspace.',\n examples,\n schema: {\n input: {\n message: z =>\n z.string({ description: 'Message to output.' }).optional(),\n listWorkspace: z =>\n z\n .union([z.boolean(), z.enum(['with-filenames', 'with-contents'])], {\n description:\n 'List all files in the workspace. If used with \"with-contents\", also the file contents are listed.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info(JSON.stringify(ctx.input, null, 2));\n\n if (ctx.input?.message) {\n ctx.logger.info(ctx.input.message);\n }\n\n if (ctx.input?.listWorkspace) {\n const files = await recursiveReadDir(ctx.workspacePath);\n ctx.logger.info(\n `Workspace:\\n${files\n .map(f => {\n const relativePath = relative(ctx.workspacePath, f);\n if (ctx.input?.listWorkspace === 'with-contents') {\n const content = fs.readFileSync(
|
|
1
|
+
{"version":3,"file":"log.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/log.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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { readdir, stat } from 'fs-extra';\nimport { join, relative } from 'path';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './log.examples';\nimport fs from 'fs';\n\nconst id = 'debug:log';\n\n/**\n * Writes a message into the log or lists all files in the workspace\n *\n * @remarks\n *\n * This task is useful for local development and testing of both the scaffolder\n * and scaffolder templates.\n *\n * @public\n */\nexport function createDebugLogAction() {\n return createTemplateAction({\n id,\n description:\n 'Writes a message into the log and/or lists all files in the workspace.',\n examples,\n schema: {\n input: {\n message: z =>\n z.string({ description: 'Message to output.' }).optional(),\n listWorkspace: z =>\n z\n .union([z.boolean(), z.enum(['with-filenames', 'with-contents'])], {\n description:\n 'List all files in the workspace. If used with \"with-contents\", also the file contents are listed.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info(JSON.stringify(ctx.input, null, 2));\n\n if (ctx.input?.message) {\n ctx.logger.info(ctx.input.message);\n }\n\n if (ctx.input?.listWorkspace) {\n const files = await recursiveReadDir(ctx.workspacePath);\n ctx.logger.info(\n `Workspace:\\n${files\n .map(f => {\n const relativePath = relative(ctx.workspacePath, f);\n if (ctx.input?.listWorkspace === 'with-contents') {\n try {\n const safePath = resolveSafeChildPath(\n ctx.workspacePath,\n relativePath,\n );\n const content = fs.readFileSync(safePath, 'utf-8');\n return ` - ${relativePath}:\\n\\n ${content}`;\n } catch {\n return ` - ${relativePath}: [skipped]`;\n }\n }\n return ` - ${relativePath}`;\n })\n .join('\\n')}`,\n );\n }\n },\n });\n}\n\nexport async function recursiveReadDir(dir: string): Promise<string[]> {\n const subdirs = await readdir(dir);\n const files = await Promise.all(\n subdirs.map(async subdir => {\n const res = join(dir, subdir);\n return (await stat(res)).isDirectory() ? recursiveReadDir(res) : [res];\n }),\n );\n return files.reduce((a, f) => a.concat(f), []);\n}\n"],"names":["createTemplateAction","examples","relative","resolveSafeChildPath","fs","readdir","join","stat"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,EAAA,GAAK,WAAA;AAYJ,SAAS,oBAAA,GAAuB;AACrC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EACE,wEAAA;AAAA,cACFC,qBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,OACP,CAAA,CAAE,MAAA,CAAO,EAAE,WAAA,EAAa,oBAAA,EAAsB,CAAA,CAAE,QAAA,EAAS;AAAA,QAC3D,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CACG,KAAA,CAAM,CAAC,CAAA,CAAE,OAAA,EAAQ,EAAG,CAAA,CAAE,KAAK,CAAC,gBAAA,EAAkB,eAAe,CAAC,CAAC,CAAA,EAAG;AAAA,UACjE,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,IAAA,CAAK,SAAA,CAAU,IAAI,KAAA,EAAO,IAAA,EAAM,CAAC,CAAC,CAAA;AAElD,MAAA,IAAI,GAAA,CAAI,OAAO,OAAA,EAAS;AACtB,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,OAAO,CAAA;AAAA,MACnC;AAEA,MAAA,IAAI,GAAA,CAAI,OAAO,aAAA,EAAe;AAC5B,QAAA,MAAM,KAAA,GAAQ,MAAM,gBAAA,CAAiB,GAAA,CAAI,aAAa,CAAA;AACtD,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,C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,EAAE,MAAA,CAAO,CAAC,CAAA,EAAG,EAAE,CAAA;AAC/C;;;;;"}
|
|
@@ -41,10 +41,11 @@ const createFilesystemDeleteAction = () => {
|
|
|
41
41
|
});
|
|
42
42
|
for (const filepath of resolvedPaths) {
|
|
43
43
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const safePath = backendPluginApi.resolveSafeChildPath(ctx.workspacePath, filepath);
|
|
45
|
+
await fs__default.default.remove(safePath);
|
|
46
|
+
ctx.logger.info(`File ${safePath} deleted successfully`);
|
|
46
47
|
} catch (err) {
|
|
47
|
-
ctx.logger.error(`Failed to delete file
|
|
48
|
+
ctx.logger.error(`Failed to delete file`, err);
|
|
48
49
|
throw err;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -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 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({\n id: 'fs:delete',\n description: 'Deletes files and directories from the workspace',\n examples,\n schema: {\n input: {\n files: z =>\n z.array(z.string(), {\n description: 'A list of files and directories that will be deleted',\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 // globby cannot handle backslash file separators\n const safeFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n file,\n ).replace(/\\\\/g, '/');\n const resolvedPaths = await globby(safeFilepath, {\n cwd: ctx.workspacePath,\n absolute: true,\n dot: true,\n });\n\n for (const filepath of resolvedPaths) {\n try {\n await fs.remove(
|
|
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({\n id: 'fs:delete',\n description: 'Deletes files and directories from the workspace',\n examples,\n schema: {\n input: {\n files: z =>\n z.array(z.string(), {\n description: 'A list of files and directories that will be deleted',\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 // globby cannot handle backslash file separators\n const safeFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n file,\n ).replace(/\\\\/g, '/');\n const resolvedPaths = await globby(safeFilepath, {\n cwd: ctx.workspacePath,\n absolute: true,\n dot: true,\n });\n\n for (const filepath of resolvedPaths) {\n try {\n const safePath = resolveSafeChildPath(ctx.workspacePath, filepath);\n await fs.remove(safePath);\n ctx.logger.info(`File ${safePath} deleted successfully`);\n } catch (err) {\n ctx.logger.error(`Failed to delete file`, 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,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,WAAA;AAAA,IACJ,WAAA,EAAa,kDAAA;AAAA,cACbC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAO,CAAA,CAAA,KACL,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd;AAAA;AACL,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,KAAK,CAAA,EAAG;AACpC,QAAA,MAAM,IAAIC,kBAAW,wBAAwB,CAAA;AAAA,MAC/C;AAEA,MAAA,KAAA,MAAW,IAAA,IAAQ,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO;AAElC,QAAA,MAAM,YAAA,GAAeC,qCAAA;AAAA,UACnB,GAAA,CAAI,aAAA;AAAA,UACJ;AAAA,SACF,CAAE,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AACpB,QAAA,MAAM,aAAA,GAAgB,MAAMC,uBAAA,CAAO,YAAA,EAAc;AAAA,UAC/C,KAAK,GAAA,CAAI,aAAA;AAAA,UACT,QAAA,EAAU,IAAA;AAAA,UACV,GAAA,EAAK;AAAA,SACN,CAAA;AAED,QAAA,KAAA,MAAW,YAAY,aAAA,EAAe;AACpC,UAAA,IAAI;AACF,YAAA,MAAM,QAAA,GAAWD,qCAAA,CAAqB,GAAA,CAAI,aAAA,EAAe,QAAQ,CAAA;AACjE,YAAA,MAAME,mBAAA,CAAG,OAAO,QAAQ,CAAA;AACxB,YAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,KAAA,EAAQ,QAAQ,CAAA,qBAAA,CAAuB,CAAA;AAAA,UACzD,SAAS,GAAA,EAAK;AACZ,YAAA,GAAA,CAAI,MAAA,CAAO,KAAA,CAAM,CAAA,qBAAA,CAAA,EAAyB,GAAG,CAAA;AAC7C,YAAA,MAAM,GAAA;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "The Backstage backend plugin that helps you create new things",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
"test": "backstage-cli package test"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@backstage/backend-defaults": "^0.12.
|
|
77
|
+
"@backstage/backend-defaults": "^0.12.2",
|
|
78
78
|
"@backstage/backend-openapi-utils": "^0.6.1",
|
|
79
79
|
"@backstage/backend-plugin-api": "^1.4.3",
|
|
80
80
|
"@backstage/catalog-model": "^1.7.5",
|
|
81
|
-
"@backstage/config": "^1.3.
|
|
81
|
+
"@backstage/config": "^1.3.4",
|
|
82
82
|
"@backstage/errors": "^1.2.7",
|
|
83
83
|
"@backstage/integration": "^1.18.0",
|
|
84
84
|
"@backstage/plugin-auth-node": "^0.6.7",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"@backstage/plugin-scaffolder-backend-module-github": "^0.9.0",
|
|
98
98
|
"@backstage/plugin-scaffolder-backend-module-gitlab": "^0.9.5",
|
|
99
99
|
"@backstage/plugin-scaffolder-common": "^1.7.1",
|
|
100
|
-
"@backstage/plugin-scaffolder-node": "^0.11.
|
|
100
|
+
"@backstage/plugin-scaffolder-node": "^0.11.2",
|
|
101
101
|
"@backstage/types": "^1.2.2",
|
|
102
102
|
"@opentelemetry/api": "^1.9.0",
|
|
103
103
|
"@types/luxon": "^3.0.0",
|
|
@@ -128,9 +128,9 @@
|
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@backstage/backend-app-api": "^1.2.7",
|
|
131
|
-
"@backstage/backend-defaults": "^0.12.
|
|
131
|
+
"@backstage/backend-defaults": "^0.12.2",
|
|
132
132
|
"@backstage/backend-test-utils": "^1.9.0",
|
|
133
|
-
"@backstage/cli": "^0.34.
|
|
133
|
+
"@backstage/cli": "^0.34.3",
|
|
134
134
|
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.3",
|
|
135
135
|
"@backstage/repo-tools": "^0.15.2",
|
|
136
136
|
"@types/express": "^4.17.6",
|