@roadiehq/scaffolder-backend-module-utils 3.0.0 → 3.1.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/dist/actions/fs/appendFile.cjs.js +4 -4
- package/dist/actions/fs/appendFile.cjs.js.map +1 -1
- package/dist/actions/fs/parseFile.cjs.js +4 -4
- package/dist/actions/fs/parseFile.cjs.js.map +1 -1
- package/dist/actions/fs/replaceInFile.cjs.js +2 -2
- package/dist/actions/fs/replaceInFile.cjs.js.map +1 -1
- package/dist/actions/fs/writeFile.cjs.js +4 -4
- package/dist/actions/fs/writeFile.cjs.js.map +1 -1
- package/dist/actions/jsonata/json.cjs.js +4 -4
- package/dist/actions/jsonata/json.cjs.js.map +1 -1
- package/dist/actions/jsonata/jsonata.cjs.js +2 -2
- package/dist/actions/jsonata/jsonata.cjs.js.map +1 -1
- package/dist/actions/jsonata/yaml.cjs.js +4 -4
- package/dist/actions/jsonata/yaml.cjs.js.map +1 -1
- package/dist/actions/merge/merge.cjs.js +3 -3
- package/dist/actions/merge/merge.cjs.js.map +1 -1
- package/dist/actions/serialize/json.cjs.js +2 -2
- package/dist/actions/serialize/json.cjs.js.map +1 -1
- package/dist/actions/serialize/yaml.cjs.js.map +1 -1
- package/dist/actions/sleep.cjs.js +2 -2
- package/dist/actions/sleep.cjs.js.map +1 -1
- package/dist/actions/zip.cjs.js +5 -5
- package/dist/actions/zip.cjs.js.map +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/module.cjs.js.map +1 -1
- package/dist/types.cjs.js.map +1 -1
- package/package.json +20 -12
- package/new-backend/package.json +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -9,7 +9,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
10
10
|
|
|
11
11
|
function createAppendFileAction() {
|
|
12
|
-
return
|
|
12
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
13
13
|
id: "roadiehq:utils:fs:append",
|
|
14
14
|
description: "Append content to the end of the given file, it will create the file if it does not exist.",
|
|
15
15
|
supportsDryRun: true,
|
|
@@ -41,7 +41,7 @@ function createAppendFileAction() {
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
async handler(ctx) {
|
|
44
|
-
const sourceFilepath =
|
|
44
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
45
45
|
ctx.workspacePath,
|
|
46
46
|
ctx.input.path
|
|
47
47
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendFile.cjs.js","sources":["../../../src/actions/fs/appendFile.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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-
|
|
1
|
+
{"version":3,"file":"appendFile.cjs.js","sources":["../../../src/actions/fs/appendFile.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\n\nexport function createAppendFileAction() {\n return createTemplateAction<{ path: string; content: string }>({\n id: 'roadiehq:utils:fs:append',\n description:\n 'Append content to the end of the given file, it will create the file if it does not exist.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['content', 'path'],\n properties: {\n path: {\n title: 'Path',\n description: 'Path to existing file to append.',\n type: 'string',\n },\n content: {\n title: 'Content',\n description: 'This will be appended to the file',\n type: 'string',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n\n fs.appendFileSync(sourceFilepath, ctx.input.content);\n ctx.output('path', sourceFilepath);\n },\n });\n}\n"],"names":["createTemplateAction","resolveSafeChildPath","fs"],"mappings":";;;;;;;;;;AAoBO,SAAS,sBAAyB,GAAA;AACvC,EAAA,OAAOA,yCAAwD,CAAA;AAAA,IAC7D,EAAI,EAAA,0BAAA;AAAA,IACJ,WACE,EAAA,4FAAA;AAAA,IACF,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,MAAM,CAAA;AAAA,QAC5B,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,kCAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,SAAA;AAAA,YACP,WAAa,EAAA,mCAAA;AAAA,YACb,IAAM,EAAA;AAAA;AACR;AACF,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,cAAiB,GAAAC,qCAAA;AAAA,QACrB,GAAI,CAAA,aAAA;AAAA,QACJ,IAAI,KAAM,CAAA;AAAA,OACZ;AAEA,MAAAC,mBAAA,CAAG,cAAe,CAAA,cAAA,EAAgB,GAAI,CAAA,KAAA,CAAM,OAAO,CAAA;AACnD,MAAI,GAAA,CAAA,MAAA,CAAO,QAAQ,cAAc,CAAA;AAAA;AACnC,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
var YAML = require('yaml');
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ const parsers = {
|
|
|
16
16
|
multiyaml: (cnt) => YAML__default.default.parseAllDocuments(cnt).map((doc) => doc.toJSON())
|
|
17
17
|
};
|
|
18
18
|
function createParseFileAction() {
|
|
19
|
-
return
|
|
19
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
20
20
|
id: "roadiehq:utils:fs:parse",
|
|
21
21
|
description: "Reads a file from the workspace and optionally parses it",
|
|
22
22
|
supportsDryRun: true,
|
|
@@ -49,7 +49,7 @@ function createParseFileAction() {
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
async handler(ctx) {
|
|
52
|
-
const sourceFilepath =
|
|
52
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
53
53
|
ctx.workspacePath,
|
|
54
54
|
ctx.input.path
|
|
55
55
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFile.cjs.js","sources":["../../../src/actions/fs/parseFile.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-
|
|
1
|
+
{"version":3,"file":"parseFile.cjs.js","sources":["../../../src/actions/fs/parseFile.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport YAML from 'yaml';\n\nconst parsers: Record<'yaml' | 'json' | 'multiyaml', (cnt: string) => any> = {\n yaml: (cnt: string) => YAML.parse(cnt),\n json: (cnt: string) => JSON.parse(cnt),\n multiyaml: (cnt: string) =>\n YAML.parseAllDocuments(cnt).map(doc => doc.toJSON()),\n};\n\nexport function createParseFileAction() {\n return createTemplateAction<{\n path: string;\n parser?: 'yaml' | 'json' | 'multiyaml';\n }>({\n id: 'roadiehq:utils:fs:parse',\n description: 'Reads a file from the workspace and optionally parses it',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['path'],\n properties: {\n path: {\n title: 'Path',\n description: 'Path to the file to read.',\n type: 'string',\n },\n parser: {\n title: 'Parse',\n description: 'Optionally parse the content to an object.',\n type: 'string',\n enum: ['yaml', 'json', 'multiyaml'],\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n content: {\n title: 'Content of the file',\n type: ['string', 'object'],\n },\n },\n },\n },\n async handler(ctx) {\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n const parserName = ctx.input.parser;\n let parser = (content: string) => content;\n\n if (parserName) {\n parser = parsers[parserName];\n }\n\n const content: string | object = parser(\n fs.readFileSync(sourceFilepath).toString(),\n );\n\n ctx.output('content', content);\n },\n });\n}\n"],"names":["YAML","createTemplateAction","resolveSafeChildPath","content","fs"],"mappings":";;;;;;;;;;;;AAoBA,MAAM,OAAuE,GAAA;AAAA,EAC3E,IAAM,EAAA,CAAC,GAAgB,KAAAA,qBAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACrC,IAAM,EAAA,CAAC,GAAgB,KAAA,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACrC,SAAA,EAAW,CAAC,GAAA,KACVA,qBAAK,CAAA,iBAAA,CAAkB,GAAG,CAAA,CAAE,GAAI,CAAA,CAAA,GAAA,KAAO,GAAI,CAAA,MAAA,EAAQ;AACvD,CAAA;AAEO,SAAS,qBAAwB,GAAA;AACtC,EAAA,OAAOC,yCAGJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,0DAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAA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= require('@backstage/errors');
|
|
6
|
-
var
|
|
6
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
7
7
|
|
|
8
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
9
|
|
|
@@ -62,7 +62,7 @@ function createReplaceInFileAction() {
|
|
|
62
62
|
"each file must have a find and replaceWith property"
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
const sourceFilepath =
|
|
65
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
66
66
|
ctx.workspacePath,
|
|
67
67
|
file.file
|
|
68
68
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceInFile.cjs.js","sources":["../../../src/actions/fs/replaceInFile.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 fs from 'fs-extra';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-
|
|
1
|
+
{"version":3,"file":"replaceInFile.cjs.js","sources":["../../../src/actions/fs/replaceInFile.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 fs from 'fs-extra';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\n\nexport function createReplaceInFileAction() {\n return createTemplateAction<{\n files: Array<{\n file: string;\n find: string;\n matchRegex: boolean;\n replaceWith: string;\n }>;\n }>({\n id: 'roadiehq:utils:fs:replace',\n description: 'Replaces content of a file with given values.',\n supportsDryRun: true,\n schema: {\n input: {\n required: ['files'],\n type: 'object',\n properties: {\n files: {\n title: 'Files',\n description: 'A list of files and replacements to be done',\n type: 'array',\n items: {\n type: 'object',\n required: [],\n properties: {\n file: {\n type: 'string',\n title:\n 'The source location of the file to be used to run replace against',\n },\n find: {\n type: 'string',\n title: 'A string to be replaced',\n },\n matchRegex: {\n type: 'bool',\n title: 'Use regex to match the find string',\n },\n replaceWith: {\n type: 'string',\n title: 'Text to be used to replace the found lines with',\n },\n },\n },\n },\n },\n },\n },\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 if (!file.file) {\n throw new InputError('Path to file needs to be defined');\n }\n if (!file.find || !file.replaceWith) {\n throw new InputError(\n 'each file must have a find and replaceWith property',\n );\n }\n\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n file.file,\n );\n const content: string = fs.readFileSync(sourceFilepath).toString();\n\n let find: string | RegExp = file.find;\n if (file.matchRegex) {\n find = new RegExp(file.find, 'g');\n }\n\n const replacedContent = content.replaceAll(find, file.replaceWith);\n\n fs.writeFileSync(sourceFilepath, replacedContent);\n }\n },\n });\n}\n"],"names":["createTemplateAction","InputError","resolveSafeChildPath","fs"],"mappings":";;;;;;;;;;;AAqBO,SAAS,yBAA4B,GAAA;AAC1C,EAAA,OAAOA,yCAOJ,CAAA;AAAA,IACD,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,+CAA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AA,YACR;AAAA,WACF;AAAA;AAGF,QAAA,MAAM,cAAiB,GAAAC,qCAAA;AAAA,UACrB,GAAI,CAAA,aAAA;AAAA,UACJ,IAAK,CAAA;AAAA,SACP;AACA,QAAA,MAAM,OAAkB,GAAAC,mBAAA,CAAG,YAAa,CAAA,cAAc,EAAE,QAAS,EAAA;AAEjE,QAAA,IAAI,OAAwB,IAAK,CAAA,IAAA;AACjC,QAAA,IAAI,KAAK,UAAY,EAAA;AACnB,UAAA,IAAA,GAAO,IAAI,MAAA,CAAO,IAAK,CAAA,IAAA,EAAM,GAAG,CAAA;AAAA;AAGlC,QAAA,MAAM,eAAkB,GAAA,OAAA,CAAQ,UAAW,CAAA,IAAA,EAAM,KAAK,WAAW,CAAA;AAEjE,QAAGA,mBAAA,CAAA,aAAA,CAAc,gBAAgB,eAAe,CAAA;AAAA;AAClD;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -9,7 +9,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
10
10
|
|
|
11
11
|
function createWriteFileAction() {
|
|
12
|
-
return
|
|
12
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
13
13
|
id: "roadiehq:utils:fs:write",
|
|
14
14
|
description: "Creates a file with the content on the given path",
|
|
15
15
|
supportsDryRun: true,
|
|
@@ -47,7 +47,7 @@ function createWriteFileAction() {
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
async handler(ctx) {
|
|
50
|
-
const destFilepath =
|
|
50
|
+
const destFilepath = backendPluginApi.resolveSafeChildPath(
|
|
51
51
|
ctx.workspacePath,
|
|
52
52
|
ctx.input.path
|
|
53
53
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFile.cjs.js","sources":["../../../src/actions/fs/writeFile.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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-
|
|
1
|
+
{"version":3,"file":"writeFile.cjs.js","sources":["../../../src/actions/fs/writeFile.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\n\nexport function createWriteFileAction() {\n return createTemplateAction<{\n path: string;\n content: string;\n preserveFormatting?: boolean;\n }>({\n id: 'roadiehq:utils:fs:write',\n description: 'Creates a file with the content on the given path',\n supportsDryRun: true,\n schema: {\n input: {\n required: ['path', 'content'],\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n description: 'Relative path',\n type: 'string',\n },\n content: {\n title: 'Content',\n description: 'This will be the content of the file',\n type: 'string',\n },\n preserveFormatting: {\n title: 'Preserve Formatting',\n description:\n 'Specify whether to preserve formatting for JSON content',\n type: 'boolean',\n default: false,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const destFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n let formattedContent = ctx.input.content;\n if (ctx.input.preserveFormatting) {\n try {\n const parsedContent = JSON.parse(ctx.input.content);\n formattedContent = JSON.stringify(parsedContent, null, 2);\n } catch (error) {\n // Content is not JSON, no need to format\n }\n }\n\n fs.outputFileSync(destFilepath, formattedContent);\n\n ctx.output('path', destFilepath);\n },\n });\n}\n"],"names":["createTemplateAction","resolveSafeChildPath","fs"],"mappings":";;;;;;;;;;AAoBO,SAAS,qBAAwB,GAAA;AACtC,EAAA,OAAOA,yCAIJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,mDAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAA,EAAU,CAAC,MAAA,EAAQ,SAAS,CAAA;AAAA,QAC5B,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,eAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,SAAA;AAAA,YACP,WAAa,EAAA,sCAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,kBAAoB,EAAA;AAAA,YAClB,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,yDAAA;AAAA,YACF,IAAM,EAAA,SAAA;AAAA,YACN,OAAS,EAAA;AAAA;AACX;AACF,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,YAAe,GAAAC,qCAAA;AAAA,QACnB,GAAI,CAAA,aAAA;AAAA,QACJ,IAAI,KAAM,CAAA;AAAA,OACZ;AACA,MAAI,IAAA,gBAAA,GAAmB,IAAI,KAAM,CAAA,OAAA;AACjC,MAAI,IAAA,GAAA,CAAI,MAAM,kBAAoB,EAAA;AAChC,QAAI,IAAA;AACF,UAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,KAAM,CAAA,GAAA,CAAI,MAAM,OAAO,CAAA;AAClD,UAAA,gBAAA,GAAmB,IAAK,CAAA,SAAA,CAAU,aAAe,EAAA,IAAA,EAAM,CAAC,CAAA;AAAA,iBACjD,KAAO,EAAA;AAAA;AAEhB;AAGF,MAAGC,mBAAA,CAAA,cAAA,CAAe,cAAc,gBAAgB,CAAA;AAEhD,MAAI,GAAA,CAAA,MAAA,CAAO,QAAQ,YAAY,CAAA;AAAA;AACjC,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
4
|
var jsonata = require('jsonata');
|
|
5
|
-
var
|
|
5
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
6
|
var fs = require('fs-extra');
|
|
7
7
|
|
|
8
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -11,7 +11,7 @@ var jsonata__default = /*#__PURE__*/_interopDefaultCompat(jsonata);
|
|
|
11
11
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
12
12
|
|
|
13
13
|
function createJsonJSONataTransformAction() {
|
|
14
|
-
return
|
|
14
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
15
15
|
id: "roadiehq:utils:jsonata:json:transform",
|
|
16
16
|
description: "Allows performing JSONata operations and transformations on a JSON file in the workspace. The result can be read from the `result` step output.",
|
|
17
17
|
supportsDryRun: true,
|
|
@@ -68,7 +68,7 @@ function createJsonJSONataTransformAction() {
|
|
|
68
68
|
} else {
|
|
69
69
|
resultHandler = (rz) => JSON.stringify(rz, ctx.input.replacer, ctx.input.space);
|
|
70
70
|
}
|
|
71
|
-
const sourceFilepath =
|
|
71
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
72
72
|
ctx.workspacePath,
|
|
73
73
|
ctx.input.path
|
|
74
74
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.cjs.js","sources":["../../../src/actions/jsonata/json.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-
|
|
1
|
+
{"version":3,"file":"json.cjs.js","sources":["../../../src/actions/jsonata/json.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport jsonata from 'jsonata';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\n\nexport function createJsonJSONataTransformAction() {\n return createTemplateAction<{\n path: string;\n expression: string;\n replacer?: string[];\n space?: string;\n as?: 'string' | 'object';\n }>({\n id: 'roadiehq:utils:jsonata:json:transform',\n description:\n 'Allows performing JSONata operations and transformations on a JSON file in the workspace. The result can be read from the `result` step output.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['path', 'expression'],\n properties: {\n path: {\n title: 'Path',\n description: 'Input path to read json file',\n type: 'string',\n },\n expression: {\n title: 'Expression',\n description: 'JSONata expression to perform on the input',\n type: 'string',\n },\n as: {\n title: 'Desired Result Type',\n description:\n 'Permitted values are: \"string\" (default) and \"object\"',\n type: 'string',\n enum: ['string', 'object'],\n },\n replacer: {\n title: 'Replacer',\n description: 'Replacer array',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n space: {\n title: 'Space',\n description: 'Space character',\n type: 'string',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n result: {\n title: 'Output result from JSONata',\n type: 'object | string',\n },\n },\n },\n },\n async handler(ctx) {\n let resultHandler: (rz: any) => any;\n\n if (ctx.input.as === 'object') {\n resultHandler = rz => rz;\n } else {\n resultHandler = rz =>\n JSON.stringify(rz, ctx.input.replacer, ctx.input.space);\n }\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n\n const data = JSON.parse(fs.readFileSync(sourceFilepath).toString());\n const expression = jsonata(ctx.input.expression);\n const result = await expression.evaluate(data);\n\n ctx.output('result', resultHandler(result));\n },\n });\n}\n"],"names":["createTemplateAction","resolveSafeChildPath","fs","jsonata"],"mappings":";;;;;;;;;;;;AAoBO,SAAS,gCAAmC,GAAA;AACjD,EAAA,OAAOA,yC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AM,CAAA,EAAA,KAAO,QAAU,EAAA;AAC7B,QAAA,aAAA,GAAgB,CAAM,EAAA,KAAA,EAAA;AAAA,OACjB,MAAA;AACL,QAAgB,aAAA,GAAA,CAAA,EAAA,KACd,KAAK,SAAU,CAAA,EAAA,EAAI,IAAI,KAAM,CAAA,QAAA,EAAU,GAAI,CAAA,KAAA,CAAM,KAAK,CAAA;AAAA;AAE1D,MAAA,MAAM,cAAiB,GAAAC,qCAAA;AAAA,QACrB,GAAI,CAAA,aAAA;AAAA,QACJ,IAAI,KAAM,CAAA;AAAA,OACZ;AAEA,MAAM,MAAA,IAAA,GAAO,KAAK,KAAM,CAAAC,mBAAA,CAAG,aAAa,cAAc,CAAA,CAAE,UAAU,CAAA;AAClE,MAAA,MAAM,UAAa,GAAAC,wBAAA,CAAQ,GAAI,CAAA,KAAA,CAAM,UAAU,CAAA;AAC/C,MAAA,MAAM,MAAS,GAAA,MAAM,UAAW,CAAA,QAAA,CAAS,IAAI,CAAA;AAE7C,MAAA,GAAA,CAAI,MAAO,CAAA,QAAA,EAAU,aAAc,CAAA,MAAM,CAAC,CAAA;AAAA;AAC5C,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
4
|
var jsonata = require('jsonata');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -8,7 +8,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
var jsonata__default = /*#__PURE__*/_interopDefaultCompat(jsonata);
|
|
9
9
|
|
|
10
10
|
function createJSONataAction() {
|
|
11
|
-
return
|
|
11
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
12
12
|
id: "roadiehq:utils:jsonata",
|
|
13
13
|
description: "Allows performing JSONata operations and transformations on input objects and produces the output result as a step output.",
|
|
14
14
|
supportsDryRun: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonata.cjs.js","sources":["../../../src/actions/jsonata/jsonata.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-
|
|
1
|
+
{"version":3,"file":"jsonata.cjs.js","sources":["../../../src/actions/jsonata/jsonata.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport jsonata from 'jsonata';\n\nexport function createJSONataAction() {\n return createTemplateAction<{\n data: any;\n expression: string;\n }>({\n id: 'roadiehq:utils:jsonata',\n description:\n 'Allows performing JSONata operations and transformations on input objects and produces the output result as a step output.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['data', 'expression'],\n properties: {\n data: {\n title: 'Data',\n description: 'Input data to be transformed',\n type: [\n 'object',\n 'array',\n 'string',\n 'number',\n 'integer',\n 'boolean',\n 'null',\n ],\n },\n expression: {\n title: 'Expression',\n description: 'JSONata expression to perform on the input',\n type: 'string',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n result: {\n title: 'Output result from JSONata',\n type: 'object',\n },\n },\n },\n },\n async handler(ctx) {\n try {\n const expression = jsonata(ctx.input.expression);\n const result = await expression.evaluate(ctx.input.data);\n\n ctx.output('result', result);\n } catch (e: any) {\n const message = e.hasOwnProperty('message')\n ? e.message\n : 'unknown JSONata evaluation error';\n throw new Error(\n `JSONata failed to evaluate the expression: ${message}`,\n );\n }\n },\n });\n}\n"],"names":["createTemplateAction","jsonata"],"mappings":";;;;;;;;;AAkBO,SAAS,mBAAsB,GAAA;AACpC,EAAA,OAAOA,yCAGJ,CAAA;AAAA,IACD,EAAI,EAAA,wBAAA;AAAA,IACJ,WACE,EAAA,4HAAA;AAAA,IACF,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,QAC/B,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,8BAAA;AAAA,YACb,IAAM,EAAA;AAAA,cACJ,QAAA;AAAA,cACA,OAAA;AAAA,cACA,QAAA;AAAA,cACA,QAAA;AAAA,cACA,SAAA;AAAA,cACA,SAAA;AAAA,cACA;AAAA;AACF,WACF;AAAA,UACA,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,YAAA;AAAA,YACP,WAAa,EAAA,4CAAA;AAAA,YACb,IAAM,EAAA;AAAA;AACR;AACF,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,4BAAA;AAAA,YACP,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAI,IAAA;AACF,QAAA,MAAM,UAAa,GAAAC,wBAAA,CAAQ,GAAI,CAAA,KAAA,CAAM,UAAU,CAAA;AAC/C,QAAA,MAAM,SAAS,MAAM,UAAA,CAAW,QAAS,CAAA,GAAA,CAAI,MAAM,IAAI,CAAA;AAEvD,QAAI,GAAA,CAAA,MAAA,CAAO,UAAU,MAAM,CAAA;AAAA,eACpB,CAAQ,EAAA;AACf,QAAA,MAAM,UAAU,CAAE,CAAA,cAAA,CAAe,SAAS,CAAA,GACtC,EAAE,OACF,GAAA,kCAAA;AACJ,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,8CAA8C,OAAO,CAAA;AAAA,SACvD;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
4
|
var jsonata = require('jsonata');
|
|
5
|
-
var
|
|
5
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
6
|
var fs = require('fs-extra');
|
|
7
7
|
var YAML = require('yaml');
|
|
8
8
|
var types = require('../../types.cjs.js');
|
|
@@ -14,7 +14,7 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
|
14
14
|
var YAML__default = /*#__PURE__*/_interopDefaultCompat(YAML);
|
|
15
15
|
|
|
16
16
|
function createYamlJSONataTransformAction() {
|
|
17
|
-
return
|
|
17
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
18
18
|
id: "roadiehq:utils:jsonata:yaml:transform",
|
|
19
19
|
description: "Allows performing JSONata operations and transformations on a YAML file in the workspace. The result can be read from the `result` step output.",
|
|
20
20
|
supportsDryRun: true,
|
|
@@ -64,7 +64,7 @@ function createYamlJSONataTransformAction() {
|
|
|
64
64
|
} else {
|
|
65
65
|
resultHandler = (rz) => YAML__default.default.stringify(rz, ctx.input.options);
|
|
66
66
|
}
|
|
67
|
-
const sourceFilepath =
|
|
67
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
68
68
|
ctx.workspacePath,
|
|
69
69
|
ctx.input.path
|
|
70
70
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.cjs.js","sources":["../../../src/actions/jsonata/yaml.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-
|
|
1
|
+
{"version":3,"file":"yaml.cjs.js","sources":["../../../src/actions/jsonata/yaml.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport jsonata from 'jsonata';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport YAML from 'yaml';\nimport { stringifyOptions, yamlOptionsSchema } from '../../types';\n\nexport function createYamlJSONataTransformAction() {\n return createTemplateAction<{\n path: string;\n expression: string;\n options?: stringifyOptions;\n loadAll?: boolean;\n as?: 'string' | 'object';\n }>({\n id: 'roadiehq:utils:jsonata:yaml:transform',\n description:\n 'Allows performing JSONata operations and transformations on a YAML file in the workspace. The result can be read from the `result` step output.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['path', 'expression'],\n properties: {\n path: {\n title: 'Path',\n description: 'Input path to read yaml file',\n type: 'string',\n },\n expression: {\n title: 'Expression',\n description: 'JSONata expression to perform on the input',\n type: 'string',\n },\n loadAll: {\n title: 'Load All',\n description:\n 'Use this if the yaml source file contains multiple yaml objects',\n type: 'boolean',\n },\n as: {\n title: 'Desired Result Type',\n description:\n 'Permitted values are: \"string\" (default) and \"object\"',\n type: 'string',\n enum: ['string', 'object'],\n },\n options: yamlOptionsSchema,\n },\n },\n output: {\n type: 'object',\n properties: {\n result: {\n title: 'Output result from JSONata',\n type: 'object | string',\n },\n },\n },\n },\n async handler(ctx) {\n let resultHandler: (rz: any) => any;\n\n if (ctx.input.as === 'object') {\n resultHandler = rz => rz;\n } else {\n resultHandler = rz => YAML.stringify(rz, ctx.input.options);\n }\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n let data;\n if (ctx.input.loadAll) {\n data = YAML.parseAllDocuments(\n fs.readFileSync(sourceFilepath).toString(),\n ).map(doc => doc.toJSON());\n } else {\n data = YAML.parse(fs.readFileSync(sourceFilepath).toString());\n }\n const expression = jsonata(ctx.input.expression);\n const result = await expression.evaluate(data);\n\n ctx.output('result', resultHandler(result));\n },\n });\n}\n"],"names":["createTemplateAction","yamlOptionsSchema","YAML","resolveSafeChildPath","fs","jsonata"],"mappings":";;;;;;;;;;;;;;;AAsBO,SAAS,gCAAmC,GAAA;AACjD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,uCAAA;AAAA,IACJ,WACE,EAAA,iJAAA;AAAA,IACF,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;A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,OAAS,EAAA;AACrB,QAAA,IAAA,GAAOD,qBAAK,CAAA,iBAAA;AAAA,UACVE,mBAAG,CAAA,YAAA,CAAa,cAAc,CAAA,CAAE,QAAS;AAAA,SACzC,CAAA,GAAA,CAAI,CAAO,GAAA,KAAA,GAAA,CAAI,QAAQ,CAAA;AAAA,OACpB,MAAA;AACL,QAAA,IAAA,GAAOF,sBAAK,KAAM,CAAAE,mBAAA,CAAG,aAAa,cAAc,CAAA,CAAE,UAAU,CAAA;AAAA;AAE9D,MAAA,MAAM,UAAa,GAAAC,wBAAA,CAAQ,GAAI,CAAA,KAAA,CAAM,UAAU,CAAA;AAC/C,MAAA,MAAM,MAAS,GAAA,MAAM,UAAW,CAAA,QAAA,CAAS,IAAI,CAAA;AAE7C,MAAA,GAAA,CAAI,MAAO,CAAA,QAAA,EAAU,aAAc,CAAA,MAAM,CAAC,CAAA;AAAA;AAC5C,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
|
-
var
|
|
4
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var lodash = require('lodash');
|
|
@@ -68,7 +68,7 @@ function createMergeJSONAction({ actionId }) {
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
async handler(ctx) {
|
|
71
|
-
const sourceFilepath =
|
|
71
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
72
72
|
ctx.workspacePath,
|
|
73
73
|
ctx.input.path
|
|
74
74
|
);
|
|
@@ -161,7 +161,7 @@ function createMergeAction() {
|
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
async handler(ctx) {
|
|
164
|
-
const sourceFilepath =
|
|
164
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
165
165
|
ctx.workspacePath,
|
|
166
166
|
ctx.input.path
|
|
167
167
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.cjs.js","sources":["../../../src/actions/merge/merge.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 { resolveSafeChildPath } from '@backstage/backend-common';\nimport fs from 'fs-extra';\nimport { extname } from 'path';\nimport { isArray, isNull, mergeWith } from 'lodash';\nimport YAML from 'yaml';\nimport YAWN from 'yawn-yaml';\nimport { stringifyOptions, yamlOptionsSchema } from '../../types';\nimport detectIndent from 'detect-indent';\n\nfunction mergeArrayCustomiser(objValue: string | any[], srcValue: any) {\n if (isArray(objValue) && !isNull(objValue)) {\n return Array.from(new Set(objValue.concat(srcValue)));\n }\n return undefined;\n}\n\nexport function createMergeJSONAction({ actionId }: { actionId?: string }) {\n return createTemplateAction<{\n path: string;\n content: any;\n mergeArrays?: boolean;\n matchFileIndent?: boolean;\n }>({\n id: actionId || 'roadiehq:utils:json:merge',\n description: 'Merge new data into an existing JSON file.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['content', 'path'],\n properties: {\n path: {\n title: 'Path',\n description: 'Path to existing file to append.',\n type: 'string',\n },\n content: {\n description:\n 'This will be merged into to the file. Can be either an object or a string.',\n title: 'Content',\n type: ['string', 'object'],\n },\n mergeArrays: {\n type: 'boolean',\n default: false,\n title: 'Merge Arrays?',\n description:\n 'Where a value is an array the merge function should concatenate the provided array value with the target array',\n },\n matchFileIndent: {\n type: 'boolean',\n default: false,\n title: 'Match file indent?',\n description:\n 'Make the output file indentation match that of the specified input file.',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n\n let existingContent;\n\n if (fs.existsSync(sourceFilepath)) {\n existingContent = JSON.parse(\n fs.readFileSync(sourceFilepath).toString(),\n );\n } else {\n ctx.logger.info(\n `The file ${sourceFilepath} does not exist, creating it.`,\n );\n existingContent = {};\n }\n const content =\n typeof ctx.input.content === 'string'\n ? JSON.parse(ctx.input.content)\n : ctx.input.content;\n\n let fileIndent = 2;\n if (ctx.input.matchFileIndent) {\n fileIndent = detectIndent(\n fs.readFileSync(sourceFilepath, 'utf8'),\n ).amount;\n if (!fileIndent) {\n fileIndent = 2;\n ctx.logger.info(\n `Failed to detect source file indentation, using default value of 2.`,\n );\n }\n }\n fs.writeFileSync(\n sourceFilepath,\n JSON.stringify(\n mergeWith(\n existingContent,\n content,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n null,\n fileIndent,\n ),\n );\n ctx.output('path', sourceFilepath);\n },\n });\n}\n\nexport function createMergeAction() {\n return createTemplateAction<{\n path: string;\n content: any;\n mergeArrays?: boolean;\n preserveYamlComments?: boolean;\n options?: stringifyOptions;\n }>({\n id: 'roadiehq:utils:merge',\n description: 'Merges data into an existing structured file.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['content', 'path'],\n properties: {\n path: {\n title: 'Path',\n description: 'Path to existing file to append.',\n type: 'string',\n },\n content: {\n description:\n 'This will be merged into to the file. Can be either an object or a string.',\n title: 'Content',\n type: ['string', 'object'],\n },\n mergeArrays: {\n type: 'boolean',\n default: false,\n title: 'Merge Arrays?',\n description:\n 'Where a value is an array the merge function should concatenate the provided array value with the target array',\n },\n preserveYamlComments: {\n type: 'boolean',\n default: false,\n title: 'Preserve Comments?',\n description:\n 'Will preserve standalone and inline comments in YAML files',\n },\n options: {\n ...yamlOptionsSchema,\n description: `${yamlOptionsSchema.description} (for YAML output only)`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n\n if (!fs.existsSync(sourceFilepath)) {\n ctx.logger.error(`The file ${sourceFilepath} does not exist.`);\n throw new Error(`The file ${sourceFilepath} does not exist.`);\n }\n const originalContent = fs.readFileSync(sourceFilepath).toString();\n let mergedContent;\n\n switch (extname(sourceFilepath)) {\n case '.json': {\n const newContent =\n typeof ctx.input.content === 'string'\n ? JSON.parse(ctx.input.content)\n : ctx.input.content; // This supports the case where dynamic keys are required\n mergedContent = JSON.stringify(\n mergeWith(\n YAML.parse(originalContent),\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n null,\n 2,\n );\n break;\n }\n case '.yml':\n case '.yaml': {\n const newContent =\n typeof ctx.input.content === 'string'\n ? YAML.parse(ctx.input.content)\n : ctx.input.content; // This supports the case where dynamic keys are required\n if (ctx.input.preserveYamlComments) {\n const yawn = new YAWN(originalContent);\n const parsedOriginal = yawn.json;\n const mergedJsonContent = mergeWith(\n parsedOriginal,\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n );\n yawn.json = mergedJsonContent;\n mergedContent = YAML.stringify(\n YAML.parseDocument(yawn.yaml),\n ctx.input.options,\n );\n } else {\n mergedContent = YAML.stringify(\n mergeWith(\n YAML.parse(originalContent),\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n ctx.input.options,\n );\n }\n break;\n }\n default:\n break;\n }\n if (!mergedContent) {\n return;\n }\n fs.writeFileSync(sourceFilepath, mergedContent);\n ctx.output('path', sourceFilepath);\n },\n });\n}\n"],"names":["isArray","isNull","createTemplateAction","res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,aACZ,CAAA;AAAA,WACK,MAAA;AACL,YAAA,aAAA,GAAgBA,qBAAK,CAAA,SAAA;AAAA,cACnBH,gBAAA;AAAA,gBACEG,qBAAA,CAAK,MAAM,eAAe,CAAA;AAAA,gBAC1B,UAAA;AAAA,gBACA,GAAA,CAAI,KAAM,CAAA,WAAA,GAAc,oBAAuB,GAAA,KAAA,CAAA;AAAA,eACjD;AAAA,cACA,IAAI,KAAM,CAAA,OAAA;AAAA,aACZ,CAAA;AAAA,WACF;AACA,UAAA,MAAA;AAAA,SACF;AAEE,OACJ;AACA,MAAA,IAAI,CAAC,aAAe,EAAA;AAClB,QAAA,OAAA;AAAA,OACF;AACA,MAAGL,mBAAA,CAAA,aAAA,CAAc,gBAAgB,aAAa,CAAA,CAAA;AAC9C,MAAI,GAAA,CAAA,MAAA,CAAO,QAAQ,cAAc,CAAA,CAAA;AAAA,KACnC;AAAA,GACD,CAAA,CAAA;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"merge.cjs.js","sources":["../../../src/actions/merge/merge.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport { extname } from 'path';\nimport { isArray, isNull, mergeWith } from 'lodash';\nimport YAML from 'yaml';\nimport YAWN from 'yawn-yaml';\nimport { stringifyOptions, yamlOptionsSchema } from '../../types';\nimport detectIndent from 'detect-indent';\n\nfunction mergeArrayCustomiser(objValue: string | any[], srcValue: any) {\n if (isArray(objValue) && !isNull(objValue)) {\n return Array.from(new Set(objValue.concat(srcValue)));\n }\n return undefined;\n}\n\nexport function createMergeJSONAction({ actionId }: { actionId?: string }) {\n return createTemplateAction<{\n path: string;\n content: any;\n mergeArrays?: boolean;\n matchFileIndent?: boolean;\n }>({\n id: actionId || 'roadiehq:utils:json:merge',\n description: 'Merge new data into an existing JSON file.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['content', 'path'],\n properties: {\n path: {\n title: 'Path',\n description: 'Path to existing file to append.',\n type: 'string',\n },\n content: {\n description:\n 'This will be merged into to the file. Can be either an object or a string.',\n title: 'Content',\n type: ['string', 'object'],\n },\n mergeArrays: {\n type: 'boolean',\n default: false,\n title: 'Merge Arrays?',\n description:\n 'Where a value is an array the merge function should concatenate the provided array value with the target array',\n },\n matchFileIndent: {\n type: 'boolean',\n default: false,\n title: 'Match file indent?',\n description:\n 'Make the output file indentation match that of the specified input file.',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n\n let existingContent;\n\n if (fs.existsSync(sourceFilepath)) {\n existingContent = JSON.parse(\n fs.readFileSync(sourceFilepath).toString(),\n );\n } else {\n ctx.logger.info(\n `The file ${sourceFilepath} does not exist, creating it.`,\n );\n existingContent = {};\n }\n const content =\n typeof ctx.input.content === 'string'\n ? JSON.parse(ctx.input.content)\n : ctx.input.content;\n\n let fileIndent = 2;\n if (ctx.input.matchFileIndent) {\n fileIndent = detectIndent(\n fs.readFileSync(sourceFilepath, 'utf8'),\n ).amount;\n if (!fileIndent) {\n fileIndent = 2;\n ctx.logger.info(\n `Failed to detect source file indentation, using default value of 2.`,\n );\n }\n }\n fs.writeFileSync(\n sourceFilepath,\n JSON.stringify(\n mergeWith(\n existingContent,\n content,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n null,\n fileIndent,\n ),\n );\n ctx.output('path', sourceFilepath);\n },\n });\n}\n\nexport function createMergeAction() {\n return createTemplateAction<{\n path: string;\n content: any;\n mergeArrays?: boolean;\n preserveYamlComments?: boolean;\n options?: stringifyOptions;\n }>({\n id: 'roadiehq:utils:merge',\n description: 'Merges data into an existing structured file.',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['content', 'path'],\n properties: {\n path: {\n title: 'Path',\n description: 'Path to existing file to append.',\n type: 'string',\n },\n content: {\n description:\n 'This will be merged into to the file. Can be either an object or a string.',\n title: 'Content',\n type: ['string', 'object'],\n },\n mergeArrays: {\n type: 'boolean',\n default: false,\n title: 'Merge Arrays?',\n description:\n 'Where a value is an array the merge function should concatenate the provided array value with the target array',\n },\n preserveYamlComments: {\n type: 'boolean',\n default: false,\n title: 'Preserve Comments?',\n description:\n 'Will preserve standalone and inline comments in YAML files',\n },\n options: {\n ...yamlOptionsSchema,\n description: `${yamlOptionsSchema.description} (for YAML output only)`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n\n if (!fs.existsSync(sourceFilepath)) {\n ctx.logger.error(`The file ${sourceFilepath} does not exist.`);\n throw new Error(`The file ${sourceFilepath} does not exist.`);\n }\n const originalContent = fs.readFileSync(sourceFilepath).toString();\n let mergedContent;\n\n switch (extname(sourceFilepath)) {\n case '.json': {\n const newContent =\n typeof ctx.input.content === 'string'\n ? JSON.parse(ctx.input.content)\n : ctx.input.content; // This supports the case where dynamic keys are required\n mergedContent = JSON.stringify(\n mergeWith(\n YAML.parse(originalContent),\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n null,\n 2,\n );\n break;\n }\n case '.yml':\n case '.yaml': {\n const newContent =\n typeof ctx.input.content === 'string'\n ? YAML.parse(ctx.input.content)\n : ctx.input.content; // This supports the case where dynamic keys are required\n if (ctx.input.preserveYamlComments) {\n const yawn = new YAWN(originalContent);\n const parsedOriginal = yawn.json;\n const mergedJsonContent = mergeWith(\n parsedOriginal,\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n );\n yawn.json = mergedJsonContent;\n mergedContent = YAML.stringify(\n YAML.parseDocument(yawn.yaml),\n ctx.input.options,\n );\n } else {\n mergedContent = YAML.stringify(\n mergeWith(\n YAML.parse(originalContent),\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n ctx.input.options,\n );\n }\n break;\n }\n default:\n break;\n }\n if (!mergedContent) {\n return;\n }\n fs.writeFileSync(sourceFilepath, mergedContent);\n ctx.output('path', sourceFilepath);\n },\n });\n}\n"],"names":["isArray","isNull","createTemplateAction","resolveSafeChildPath","fs","detectIndent","mergeWith","yamlOptionsSchema","extname","YAML","YAWN"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,SAAS,oBAAA,CAAqB,UAA0B,QAAe,EAAA;AACrE,EAAA,IAAIA,eAAQ,QAAQ,CAAA,IAAK,CAACC,aAAA,CAAO,QAAQ,CAAG,EAAA;AAC1C,IAAO,OAAA,KAAA,CAAM,KAAK,IAAI,GAAA,CAAI,SAAS,MAAO,CAAA,QAAQ,CAAC,CAAC,CAAA;AAAA;AAEtD,EAAO,OAAA,KAAA,CAAA;AACT;AAEgB,SAAA,qBAAA,CAAsB,EAAE,QAAA,EAAmC,EAAA;AACzE,EAAA,OAAOC,yCAKJ,CAAA;AAAA,IACD,IAAI,QAAY,IAAA,2BAAA;AAAA,IAChB,WAAa,EAAA,4CAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,MAAM,CAAA;AAAA,QAC5B,UAAY,EAAA;AAAA,UACV,IAA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BA,qBAAA,CAAK,aAAc,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,cAC5B,IAAI,KAAM,CAAA;AAAA,aACZ;AAAA,WACK,MAAA;AACL,YAAA,aAAA,GAAgBA,qBAAK,CAAA,SAAA;AAAA,cACnBH,gBAAA;AAAA,gBACEG,qBAAA,CAAK,MAAM,eAAe,CAAA;AAAA,gBAC1B,UAAA;AAAA,gBACA,GAAA,CAAI,KAAM,CAAA,WAAA,GAAc,oBAAuB,GAAA,KAAA;AAAA,eACjD;AAAA,cACA,IAAI,KAAM,CAAA;AAAA,aACZ;AAAA;AAEF,UAAA;AAAA;AAGA;AAEJ,MAAA,IAAI,CAAC,aAAe,EAAA;AAClB,QAAA;AAAA;AAEF,MAAGL,mBAAA,CAAA,aAAA,CAAc,gBAAgB,aAAa,CAAA;AAC9C,MAAI,GAAA,CAAA,MAAA,CAAO,QAAQ,cAAc,CAAA;AAAA;AACnC,GACD,CAAA;AACH;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
4
|
|
|
5
5
|
function createSerializeJsonAction() {
|
|
6
|
-
return
|
|
6
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
7
7
|
id: "roadiehq:utils:serialize:json",
|
|
8
8
|
description: "Allows performing serialization on an object",
|
|
9
9
|
supportsDryRun: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.cjs.js","sources":["../../../src/actions/serialize/json.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-
|
|
1
|
+
{"version":3,"file":"json.cjs.js","sources":["../../../src/actions/serialize/json.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\n\nexport function createSerializeJsonAction() {\n return createTemplateAction<{\n data: any;\n replacer?: string[];\n space?: string;\n }>({\n id: 'roadiehq:utils:serialize:json',\n description: 'Allows performing serialization on an object',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['data'],\n properties: {\n data: {\n title: 'Data',\n description: 'Input data to perform seriazation on.',\n type: 'object',\n },\n replacer: {\n title: 'Replacer',\n description: 'Replacer array',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n space: {\n title: 'Space',\n description: 'Space character',\n type: 'string',\n },\n },\n },\n output: {\n type: 'string',\n properties: {\n serialized: {\n title: 'Output result from serialization',\n type: 'string',\n },\n },\n },\n },\n\n async handler(ctx) {\n ctx.output(\n 'serialized',\n JSON.stringify(ctx.input.data, ctx.input.replacer, ctx.input.space),\n );\n },\n });\n}\n"],"names":["createTemplateAction"],"mappings":";;;;AAiBO,SAAS,yBAA4B,GAAA;AAC1C,EAAA,OAAOA,yCAIJ,CAAA;AAAA,IACD,EAAI,EAAA,+BAAA;AAAA,IACJ,WAAa,EAAA,8CAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,MAAM,CAAA;AAAA,QACjB,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,uCAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,QAAU,EAAA;AAAA,YACR,KAAO,EAAA,UAAA;AAAA,YACP,WAAa,EAAA,gBAAA;AAAA,YACb,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL,IAAM,EAAA;AAAA;AACR,WACF;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,OAAA;AAAA,YACP,WAAa,EAAA,iBAAA;AAAA,YACb,IAAM,EAAA;AAAA;AACR;AACF,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,kCAAA;AAAA,YACP,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IAEA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAI,GAAA,CAAA,MAAA;AAAA,QACF,YAAA;AAAA,QACA,IAAA,CAAK,SAAU,CAAA,GAAA,CAAI,KAAM,CAAA,IAAA,EAAM,IAAI,KAAM,CAAA,QAAA,EAAU,GAAI,CAAA,KAAA,CAAM,KAAK;AAAA,OACpE;AAAA;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.cjs.js","sources":["../../../src/actions/serialize/yaml.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport YAML from 'yaml';\nimport { stringifyOptions, yamlOptionsSchema } from '../../types';\n\nexport function createSerializeYamlAction() {\n return createTemplateAction<{\n data: any;\n options?: stringifyOptions;\n }>({\n id: 'roadiehq:utils:serialize:yaml',\n description: 'Allows performing serialization on an object',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['data'],\n properties: {\n data: {\n title: 'Data',\n description: 'Input data to perform seriazation on.',\n type: 'object',\n },\n replacer: {\n title: 'Replacer',\n description: 'Replacer array',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n options: yamlOptionsSchema,\n },\n },\n output: {\n type: 'string',\n properties: {\n serialized: {\n title: 'Output result from serialization',\n type: 'string',\n },\n },\n },\n },\n\n async handler(ctx) {\n ctx.output(\n 'serialized',\n YAML.stringify(ctx.input.data, ctx.input.options),\n );\n },\n });\n}\n"],"names":["createTemplateAction","yamlOptionsSchema","YAML"],"mappings":";;;;;;;;;;AAmBO,SAAS,yBAA4B,GAAA;AAC1C,EAAA,OAAOA,yCAGJ,CAAA;AAAA,IACD,EAAI,EAAA,+BAAA;AAAA,IACJ,WAAa,EAAA,8CAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,MAAM,CAAA;AAAA,QACjB,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,uCAAA;AAAA,YACb,IAAM,EAAA
|
|
1
|
+
{"version":3,"file":"yaml.cjs.js","sources":["../../../src/actions/serialize/yaml.ts"],"sourcesContent":["/*\n * Copyright 2022 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport YAML from 'yaml';\nimport { stringifyOptions, yamlOptionsSchema } from '../../types';\n\nexport function createSerializeYamlAction() {\n return createTemplateAction<{\n data: any;\n options?: stringifyOptions;\n }>({\n id: 'roadiehq:utils:serialize:yaml',\n description: 'Allows performing serialization on an object',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['data'],\n properties: {\n data: {\n title: 'Data',\n description: 'Input data to perform seriazation on.',\n type: 'object',\n },\n replacer: {\n title: 'Replacer',\n description: 'Replacer array',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n options: yamlOptionsSchema,\n },\n },\n output: {\n type: 'string',\n properties: {\n serialized: {\n title: 'Output result from serialization',\n type: 'string',\n },\n },\n },\n },\n\n async handler(ctx) {\n ctx.output(\n 'serialized',\n YAML.stringify(ctx.input.data, ctx.input.options),\n );\n },\n });\n}\n"],"names":["createTemplateAction","yamlOptionsSchema","YAML"],"mappings":";;;;;;;;;;AAmBO,SAAS,yBAA4B,GAAA;AAC1C,EAAA,OAAOA,yCAGJ,CAAA;AAAA,IACD,EAAI,EAAA,+BAAA;AAAA,IACJ,WAAa,EAAA,8CAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,MAAM,CAAA;AAAA,QACjB,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA;AAAA,YACP,WAAa,EAAA,uCAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,QAAU,EAAA;AAAA,YACR,KAAO,EAAA,UAAA;AAAA,YACP,WAAa,EAAA,gBAAA;AAAA,YACb,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL,IAAM,EAAA;AAAA;AACR,WACF;AAAA,UACA,OAAS,EAAAC;AAAA;AACX,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,kCAAA;AAAA,YACP,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IAEA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAI,GAAA,CAAA,MAAA;AAAA,QACF,YAAA;AAAA,QACAC,sBAAK,SAAU,CAAA,GAAA,CAAI,MAAM,IAAM,EAAA,GAAA,CAAI,MAAM,OAAO;AAAA,OAClD;AAAA;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
4
4
|
var errors = require('@backstage/errors');
|
|
5
5
|
|
|
6
6
|
function createSleepAction(options) {
|
|
7
|
-
return
|
|
7
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
8
8
|
id: "roadiehq:utils:sleep",
|
|
9
9
|
description: "Halts the scaffolding for the given amount of seconds",
|
|
10
10
|
supportsDryRun: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.cjs.js","sources":["../../src/actions/sleep.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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-
|
|
1
|
+
{"version":3,"file":"sleep.cjs.js","sources":["../../src/actions/sleep.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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';\n\nexport function createSleepAction(options?: { maxSleep?: number }) {\n return createTemplateAction<{ amount: number }>({\n id: 'roadiehq:utils:sleep',\n description: 'Halts the scaffolding for the given amount of seconds',\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['amount'],\n properties: {\n amount: {\n title: 'Sleep Amount',\n description: 'How much seconds should this step take.',\n type: 'number',\n },\n },\n },\n },\n async handler(ctx) {\n if (isNaN(ctx.input?.amount)) {\n throw new InputError('amount must be a number');\n } else if (options?.maxSleep && ctx.input.amount > options.maxSleep) {\n throw new InputError(\n `sleep amount can not be greater than maxSleep. amount: ${ctx.input.amount}, maxSleep: ${options.maxSleep}`,\n );\n }\n ctx.logger.info(`Waiting ${ctx.input.amount} seconds`);\n\n await new Promise(resolve => {\n setTimeout(resolve, ctx.input.amount * 1000);\n });\n },\n });\n}\n"],"names":["createTemplateAction","InputError"],"mappings":";;;;;AAmBO,SAAS,kBAAkB,OAAiC,EAAA;AACjE,EAAA,OAAOA,yCAAyC,CAAA;AAAA,IAC9C,EAAI,EAAA,sBAAA;AAAA,IACJ,WAAa,EAAA,uDAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,QAAQ,CAAA;AAAA,QACnB,UAAY,EAAA;AAAA,UACV,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,cAAA;AAAA,YACP,WAAa,EAAA,yCAAA;AAAA,YACb,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,IAAI,KAAM,CAAA,GAAA,CAAI,KAAO,EAAA,MAAM,CAAG,EAAA;AAC5B,QAAM,MAAA,IAAIC,kBAAW,yBAAyB,CAAA;AAAA,iBACrC,OAAS,EAAA,QAAA,IAAY,IAAI,KAAM,CAAA,MAAA,GAAS,QAAQ,QAAU,EAAA;AACnE,QAAA,MAAM,IAAIA,iBAAA;AAAA,UACR,0DAA0D,GAAI,CAAA,KAAA,CAAM,MAAM,CAAA,YAAA,EAAe,QAAQ,QAAQ,CAAA;AAAA,SAC3G;AAAA;AAEF,MAAA,GAAA,CAAI,OAAO,IAAK,CAAA,CAAA,QAAA,EAAW,GAAI,CAAA,KAAA,CAAM,MAAM,CAAU,QAAA,CAAA,CAAA;AAErD,MAAM,MAAA,IAAI,QAAQ,CAAW,OAAA,KAAA;AAC3B,QAAA,UAAA,CAAW,OAAS,EAAA,GAAA,CAAI,KAAM,CAAA,MAAA,GAAS,GAAI,CAAA;AAAA,OAC5C,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
|
package/dist/actions/zip.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
5
5
|
var errors = require('@backstage/errors');
|
|
6
6
|
var AdmZip = require('adm-zip');
|
|
7
7
|
var fs = require('fs-extra');
|
|
@@ -12,7 +12,7 @@ var AdmZip__default = /*#__PURE__*/_interopDefaultCompat(AdmZip);
|
|
|
12
12
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
13
13
|
|
|
14
14
|
function createZipAction() {
|
|
15
|
-
return
|
|
15
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
16
16
|
id: "roadiehq:utils:zip",
|
|
17
17
|
description: "Zips the content of the path",
|
|
18
18
|
supportsDryRun: true,
|
|
@@ -45,11 +45,11 @@ function createZipAction() {
|
|
|
45
45
|
},
|
|
46
46
|
async handler(ctx) {
|
|
47
47
|
const zip = new AdmZip__default.default();
|
|
48
|
-
const sourceFilepath =
|
|
48
|
+
const sourceFilepath = backendPluginApi.resolveSafeChildPath(
|
|
49
49
|
ctx.workspacePath,
|
|
50
50
|
ctx.input.path
|
|
51
51
|
);
|
|
52
|
-
const destFilepath =
|
|
52
|
+
const destFilepath = backendPluginApi.resolveSafeChildPath(
|
|
53
53
|
ctx.workspacePath,
|
|
54
54
|
ctx.input.outputPath
|
|
55
55
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip.cjs.js","sources":["../../src/actions/zip.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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-
|
|
1
|
+
{"version":3,"file":"zip.cjs.js","sources":["../../src/actions/zip.ts"],"sourcesContent":["/*\n * Copyright 2021 Larder Software Limited\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport AdmZip from 'adm-zip';\nimport fs from 'fs-extra';\n\nexport function createZipAction() {\n return createTemplateAction<{ path: string; outputPath: string }>({\n id: 'roadiehq:utils:zip',\n description: 'Zips the content of the path',\n supportsDryRun: true,\n schema: {\n input: {\n required: ['path'],\n type: 'object',\n properties: {\n path: {\n title: 'Path',\n description: 'Relative path you would like to zip',\n type: 'string',\n },\n\n outputPath: {\n title: 'Output Path',\n description: 'The name of the result of the zip command',\n type: 'string',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n outputPath: {\n title: 'Zip Path',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const zip = new AdmZip();\n const sourceFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.path,\n );\n const destFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.outputPath,\n );\n\n if (!fs.existsSync(sourceFilepath)) {\n throw new InputError(\n `File ${ctx.input.path} does not exist. Can't zip it.`,\n );\n }\n if (fs.lstatSync(sourceFilepath).isDirectory()) {\n zip.addLocalFolder(sourceFilepath);\n } else if (fs.lstatSync(sourceFilepath).isFile()) {\n zip.addLocalFile(sourceFilepath);\n }\n zip.writeZip(destFilepath);\n ctx.output('outputPath', ctx.input.outputPath);\n },\n });\n}\n"],"names":["createTemplateAction","AdmZip","resolveSafeChildPath","fs","InputError"],"mappings":";;;;;;;;;;;;;AA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AG,CAAA,SAAA,CAAU,cAAc,CAAA,CAAE,aAAe,EAAA;AAC9C,QAAA,GAAA,CAAI,eAAe,cAAc,CAAA;AAAA,iBACxBA,mBAAG,CAAA,SAAA,CAAU,cAAc,CAAA,CAAE,QAAU,EAAA;AAChD,QAAA,GAAA,CAAI,aAAa,cAAc,CAAA;AAAA;AAEjC,MAAA,GAAA,CAAI,SAAS,YAAY,CAAA;AACzB,MAAA,GAAA,CAAI,MAAO,CAAA,YAAA,EAAc,GAAI,CAAA,KAAA,CAAM,UAAU,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
|
|
2
|
-
import * as
|
|
2
|
+
import * as _backstage_types_index from '@backstage/types/index';
|
|
3
3
|
import { ToStringOptions } from 'yaml';
|
|
4
4
|
export { default } from './new-backend.js';
|
|
5
5
|
import '@backstage/backend-plugin-api';
|
|
@@ -7,23 +7,23 @@ import '@backstage/backend-plugin-api';
|
|
|
7
7
|
declare function createZipAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
8
8
|
path: string;
|
|
9
9
|
outputPath: string;
|
|
10
|
-
},
|
|
10
|
+
}, _backstage_types_index.JsonObject>;
|
|
11
11
|
|
|
12
12
|
declare function createWriteFileAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
13
13
|
path: string;
|
|
14
14
|
content: string;
|
|
15
15
|
preserveFormatting?: boolean;
|
|
16
|
-
},
|
|
16
|
+
}, _backstage_types_index.JsonObject>;
|
|
17
17
|
|
|
18
18
|
declare function createAppendFileAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
19
19
|
path: string;
|
|
20
20
|
content: string;
|
|
21
|
-
},
|
|
21
|
+
}, _backstage_types_index.JsonObject>;
|
|
22
22
|
|
|
23
23
|
declare function createParseFileAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
24
24
|
path: string;
|
|
25
25
|
parser?: "yaml" | "json" | "multiyaml";
|
|
26
|
-
},
|
|
26
|
+
}, _backstage_types_index.JsonObject>;
|
|
27
27
|
|
|
28
28
|
declare function createReplaceInFileAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
29
29
|
files: Array<{
|
|
@@ -32,7 +32,7 @@ declare function createReplaceInFileAction(): _backstage_plugin_scaffolder_node.
|
|
|
32
32
|
matchRegex: boolean;
|
|
33
33
|
replaceWith: string;
|
|
34
34
|
}>;
|
|
35
|
-
},
|
|
35
|
+
}, _backstage_types_index.JsonObject>;
|
|
36
36
|
|
|
37
37
|
type stringifyOptions = Omit<ToStringOptions, 'commentString'>;
|
|
38
38
|
|
|
@@ -43,25 +43,25 @@ declare function createMergeJSONAction({ actionId }: {
|
|
|
43
43
|
content: any;
|
|
44
44
|
mergeArrays?: boolean;
|
|
45
45
|
matchFileIndent?: boolean;
|
|
46
|
-
},
|
|
46
|
+
}, _backstage_types_index.JsonObject>;
|
|
47
47
|
declare function createMergeAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
48
48
|
path: string;
|
|
49
49
|
content: any;
|
|
50
50
|
mergeArrays?: boolean;
|
|
51
51
|
preserveYamlComments?: boolean;
|
|
52
52
|
options?: stringifyOptions;
|
|
53
|
-
},
|
|
53
|
+
}, _backstage_types_index.JsonObject>;
|
|
54
54
|
|
|
55
55
|
declare function createSleepAction(options?: {
|
|
56
56
|
maxSleep?: number;
|
|
57
57
|
}): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
58
58
|
amount: number;
|
|
59
|
-
},
|
|
59
|
+
}, _backstage_types_index.JsonObject>;
|
|
60
60
|
|
|
61
61
|
declare function createJSONataAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
62
62
|
data: any;
|
|
63
63
|
expression: string;
|
|
64
|
-
},
|
|
64
|
+
}, _backstage_types_index.JsonObject>;
|
|
65
65
|
|
|
66
66
|
declare function createYamlJSONataTransformAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
67
67
|
path: string;
|
|
@@ -69,7 +69,7 @@ declare function createYamlJSONataTransformAction(): _backstage_plugin_scaffolde
|
|
|
69
69
|
options?: stringifyOptions;
|
|
70
70
|
loadAll?: boolean;
|
|
71
71
|
as?: "string" | "object";
|
|
72
|
-
},
|
|
72
|
+
}, _backstage_types_index.JsonObject>;
|
|
73
73
|
|
|
74
74
|
declare function createJsonJSONataTransformAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
75
75
|
path: string;
|
|
@@ -77,17 +77,17 @@ declare function createJsonJSONataTransformAction(): _backstage_plugin_scaffolde
|
|
|
77
77
|
replacer?: string[];
|
|
78
78
|
space?: string;
|
|
79
79
|
as?: "string" | "object";
|
|
80
|
-
},
|
|
80
|
+
}, _backstage_types_index.JsonObject>;
|
|
81
81
|
|
|
82
82
|
declare function createSerializeJsonAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
83
83
|
data: any;
|
|
84
84
|
replacer?: string[];
|
|
85
85
|
space?: string;
|
|
86
|
-
},
|
|
86
|
+
}, _backstage_types_index.JsonObject>;
|
|
87
87
|
|
|
88
88
|
declare function createSerializeYamlAction(): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
89
89
|
data: any;
|
|
90
90
|
options?: stringifyOptions;
|
|
91
|
-
},
|
|
91
|
+
}, _backstage_types_index.JsonObject>;
|
|
92
92
|
|
|
93
93
|
export { createAppendFileAction, createJSONataAction, createJsonJSONataTransformAction, createMergeAction, createMergeJSONAction, createParseFileAction, createReplaceInFileAction, createSerializeJsonAction, createSerializeYamlAction, createSleepAction, createWriteFileAction, createYamlJSONataTransformAction, createZipAction };
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 Larder Software Limited\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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport * as backendModuleUtils from './actions';\n\n/**\n * @public\n * The Roadie Module for the Scaffolder Backend\n */\nexport const scaffolderBackendModuleUtils = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'scaffolder-backend-module-utils',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n },\n async init({ scaffolder }) {\n scaffolder.addActions(\n backendModuleUtils.createAppendFileAction(),\n backendModuleUtils.createJSONataAction(),\n backendModuleUtils.createJsonJSONataTransformAction(),\n backendModuleUtils.createMergeAction(),\n backendModuleUtils.createMergeJSONAction({}),\n backendModuleUtils.createParseFileAction(),\n backendModuleUtils.createReplaceInFileAction(),\n backendModuleUtils.createSerializeJsonAction(),\n backendModuleUtils.createSerializeYamlAction(),\n backendModuleUtils.createSleepAction(),\n backendModuleUtils.createWriteFileAction(),\n backendModuleUtils.createYamlJSONataTransformAction(),\n backendModuleUtils.createZipAction(),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","backendModuleUtils.createAppendFileAction","backendModuleUtils.createJSONataAction","backendModuleUtils.createJsonJSONataTransformAction","backendModuleUtils.createMergeAction","backendModuleUtils.createMergeJSONAction","backendModuleUtils.createParseFileAction","backendModuleUtils.createReplaceInFileAction","backendModuleUtils.createSerializeJsonAction","backendModuleUtils.createSerializeYamlAction","backendModuleUtils.createSleepAction","backendModuleUtils.createWriteFileAction","backendModuleUtils.createYamlJSONataTransformAction","backendModuleUtils.createZipAction"],"mappings":";;;;;;;;;;;;;;;;;AAuBO,MAAM,+BAA+BA,oCAAoB,CAAA;AAAA,EAC9D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,iCAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 Larder Software Limited\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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport * as backendModuleUtils from './actions';\n\n/**\n * @public\n * The Roadie Module for the Scaffolder Backend\n */\nexport const scaffolderBackendModuleUtils = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'scaffolder-backend-module-utils',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n },\n async init({ scaffolder }) {\n scaffolder.addActions(\n backendModuleUtils.createAppendFileAction(),\n backendModuleUtils.createJSONataAction(),\n backendModuleUtils.createJsonJSONataTransformAction(),\n backendModuleUtils.createMergeAction(),\n backendModuleUtils.createMergeJSONAction({}),\n backendModuleUtils.createParseFileAction(),\n backendModuleUtils.createReplaceInFileAction(),\n backendModuleUtils.createSerializeJsonAction(),\n backendModuleUtils.createSerializeYamlAction(),\n backendModuleUtils.createSleepAction(),\n backendModuleUtils.createWriteFileAction(),\n backendModuleUtils.createYamlJSONataTransformAction(),\n backendModuleUtils.createZipAction(),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","backendModuleUtils.createAppendFileAction","backendModuleUtils.createJSONataAction","backendModuleUtils.createJsonJSONataTransformAction","backendModuleUtils.createMergeAction","backendModuleUtils.createMergeJSONAction","backendModuleUtils.createParseFileAction","backendModuleUtils.createReplaceInFileAction","backendModuleUtils.createSerializeJsonAction","backendModuleUtils.createSerializeYamlAction","backendModuleUtils.createSleepAction","backendModuleUtils.createWriteFileAction","backendModuleUtils.createYamlJSONataTransformAction","backendModuleUtils.createZipAction"],"mappings":";;;;;;;;;;;;;;;;;AAuBO,MAAM,+BAA+BA,oCAAoB,CAAA;AAAA,EAC9D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,iCAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC;AAAA,OACd;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAc,EAAA;AACzB,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,iCAA0C,EAAA;AAAA,UAC1CC,2BAAuC,EAAA;AAAA,UACvCC,qCAAoD,EAAA;AAAA,UACpDC,uBAAqC,EAAA;AAAA,UACrCC,2BAAyC,CAAA,EAAE,CAAA;AAAA,UAC3CC,+BAAyC,EAAA;AAAA,UACzCC,uCAA6C,EAAA;AAAA,UAC7CC,gCAA6C,EAAA;AAAA,UAC7CC,8BAA6C,EAAA;AAAA,UAC7CC,uBAAqC,EAAA;AAAA,UACrCC,+BAAyC,EAAA;AAAA,UACzCC,uCAAoD,EAAA;AAAA,UACpDC,mBAAmC;AAAA,SACrC;AAAA;AACF,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
package/dist/types.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright 2023 Larder Software Limited\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 { ToStringOptions } from 'yaml';\n\nexport type stringifyOptions = Omit<ToStringOptions, 'commentString'>;\n\nexport const yamlOptionsSchema = {\n title: 'Options',\n description: 'YAML stringify options',\n type: 'object',\n properties: {\n blockQuote: {\n description:\n '(default: true) - use block quote styles for scalar values where applicable',\n type: \"boolean | 'folded' | 'literal'\",\n },\n collectionStyle: {\n description:\n \"(default: 'any') - enforce 'block' or 'flow' style on maps and sequences. By default, allows each collection to set its own flow: boolean property\",\n type: \"'any' | 'block' | 'flow'\",\n },\n defaultKeyType: {\n description:\n '(default: null) - if not null, overrides defaultStringType for implicit key values',\n type: \"'BLOCK_FOLDED' ⎮ 'BLOCK_LITERAL' ⎮ 'QUOTE_DOUBLE' ⎮ 'QUOTE_SINGLE' ⎮ 'PLAIN' ⎮ null\",\n },\n defaultStringType: {\n description:\n \"(default: 'PLAIN') - the default type of string literal used to stringify values\",\n type: \"'BLOCK_FOLDED' ⎮ 'BLOCK_LITERAL' ⎮ 'QUOTE_DOUBLE' ⎮ 'QUOTE_SINGLE' ⎮ 'PLAIN'\",\n },\n directives: {\n description:\n '(default: null) - include directives in the output. If true, at least the document-start marker --- is always included. If false, no directives or marker is ever included. If null, directives and marker may be included if required',\n type: 'boolean | null',\n },\n doubleQuotedAsJSON: {\n description:\n '(default: false) - if true, restrict double-quoted strings to use JSON-compatible syntax',\n type: 'boolean',\n },\n doubleQuotedMinMultiLineLength: {\n description:\n '(default: 40) - minimum length for double-quoted strings to use multiple lines to represent the value instead of escaping newlines',\n type: 'number',\n },\n falseStr: {\n description:\n \"(default: 'false') - string representation for false boolean values\",\n type: 'string',\n },\n flowCollectionPadding: {\n description:\n '(default: true) - if true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections',\n type: 'boolean',\n },\n indent: {\n description:\n '(default: 2) - the number of spaces to use when indenting code. Should be a strictly positive integer',\n type: 'number',\n },\n indentSeq: {\n description:\n '(default: true) - if true, block sequences should be indented',\n type: 'boolean',\n },\n lineWidth: {\n description:\n '(default: 80) -maximum line width (set to 0 to disable folding). This is a soft limit, as only double-quoted semantics allow for inserting a line break in the middle of a word ',\n type: 'number',\n },\n minContentWidth: {\n description:\n '(default: 20) - minimum line width for highly-indented content (set to 0 to disable)',\n type: 'number',\n },\n nullStr: {\n description: \"(default: 'null') - string representation for null values\",\n type: 'number',\n },\n simpleKeys: {\n description:\n '(default: false) - if true, require keys to be scalars and always use implicit rather than explicit notation',\n type: 'boolean',\n },\n singleQuote: {\n description:\n '(default: null) - Use single quote rather than double quote where applicable. Set to false to disable single quotes completely',\n type: 'boolean | null',\n },\n trueStr: {\n description:\n \"(default: 'true') - string representation for true boolean values\",\n type: 'string',\n },\n },\n};\n"],"names":[],"mappings":";;AAoBO,MAAM,iBAAoB,GAAA;AAAA,EAC/B,KAAO,EAAA,SAAA;AAAA,EACP,WAAa,EAAA,wBAAA;AAAA,EACb,IAAM,EAAA,QAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,MACV,WACE,EAAA,6EAAA;AAAA,MACF,IAAM,EAAA
|
|
1
|
+
{"version":3,"file":"types.cjs.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright 2023 Larder Software Limited\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 { ToStringOptions } from 'yaml';\n\nexport type stringifyOptions = Omit<ToStringOptions, 'commentString'>;\n\nexport const yamlOptionsSchema = {\n title: 'Options',\n description: 'YAML stringify options',\n type: 'object',\n properties: {\n blockQuote: {\n description:\n '(default: true) - use block quote styles for scalar values where applicable',\n type: \"boolean | 'folded' | 'literal'\",\n },\n collectionStyle: {\n description:\n \"(default: 'any') - enforce 'block' or 'flow' style on maps and sequences. By default, allows each collection to set its own flow: boolean property\",\n type: \"'any' | 'block' | 'flow'\",\n },\n defaultKeyType: {\n description:\n '(default: null) - if not null, overrides defaultStringType for implicit key values',\n type: \"'BLOCK_FOLDED' ⎮ 'BLOCK_LITERAL' ⎮ 'QUOTE_DOUBLE' ⎮ 'QUOTE_SINGLE' ⎮ 'PLAIN' ⎮ null\",\n },\n defaultStringType: {\n description:\n \"(default: 'PLAIN') - the default type of string literal used to stringify values\",\n type: \"'BLOCK_FOLDED' ⎮ 'BLOCK_LITERAL' ⎮ 'QUOTE_DOUBLE' ⎮ 'QUOTE_SINGLE' ⎮ 'PLAIN'\",\n },\n directives: {\n description:\n '(default: null) - include directives in the output. If true, at least the document-start marker --- is always included. If false, no directives or marker is ever included. If null, directives and marker may be included if required',\n type: 'boolean | null',\n },\n doubleQuotedAsJSON: {\n description:\n '(default: false) - if true, restrict double-quoted strings to use JSON-compatible syntax',\n type: 'boolean',\n },\n doubleQuotedMinMultiLineLength: {\n description:\n '(default: 40) - minimum length for double-quoted strings to use multiple lines to represent the value instead of escaping newlines',\n type: 'number',\n },\n falseStr: {\n description:\n \"(default: 'false') - string representation for false boolean values\",\n type: 'string',\n },\n flowCollectionPadding: {\n description:\n '(default: true) - if true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections',\n type: 'boolean',\n },\n indent: {\n description:\n '(default: 2) - the number of spaces to use when indenting code. Should be a strictly positive integer',\n type: 'number',\n },\n indentSeq: {\n description:\n '(default: true) - if true, block sequences should be indented',\n type: 'boolean',\n },\n lineWidth: {\n description:\n '(default: 80) -maximum line width (set to 0 to disable folding). This is a soft limit, as only double-quoted semantics allow for inserting a line break in the middle of a word ',\n type: 'number',\n },\n minContentWidth: {\n description:\n '(default: 20) - minimum line width for highly-indented content (set to 0 to disable)',\n type: 'number',\n },\n nullStr: {\n description: \"(default: 'null') - string representation for null values\",\n type: 'number',\n },\n simpleKeys: {\n description:\n '(default: false) - if true, require keys to be scalars and always use implicit rather than explicit notation',\n type: 'boolean',\n },\n singleQuote: {\n description:\n '(default: null) - Use single quote rather than double quote where applicable. Set to false to disable single quotes completely',\n type: 'boolean | null',\n },\n trueStr: {\n description:\n \"(default: 'true') - string representation for true boolean values\",\n type: 'string',\n },\n },\n};\n"],"names":[],"mappings":";;AAoBO,MAAM,iBAAoB,GAAA;AAAA,EAC/B,KAAO,EAAA,SAAA;AAAA,EACP,WAAa,EAAA,wBAAA;AAAA,EACb,IAAM,EAAA,QAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,MACV,WACE,EAAA,6EAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,eAAiB,EAAA;AAAA,MACf,WACE,EAAA,oJAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,cAAgB,EAAA;AAAA,MACd,WACE,EAAA,oFAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,iBAAmB,EAAA;AAAA,MACjB,WACE,EAAA,kFAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,UAAY,EAAA;AAAA,MACV,WACE,EAAA,wOAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,kBAAoB,EAAA;AAAA,MAClB,WACE,EAAA,0FAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,8BAAgC,EAAA;AAAA,MAC9B,WACE,EAAA,oIAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,QAAU,EAAA;AAAA,MACR,WACE,EAAA,qEAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,qBAAuB,EAAA;AAAA,MACrB,WACE,EAAA,oIAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,WACE,EAAA,uGAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,SAAW,EAAA;AAAA,MACT,WACE,EAAA,+DAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,SAAW,EAAA;AAAA,MACT,WACE,EAAA,kLAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,eAAiB,EAAA;AAAA,MACf,WACE,EAAA,sFAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,OAAS,EAAA;AAAA,MACP,WAAa,EAAA,2DAAA;AAAA,MACb,IAAM,EAAA;AAAA,KACR;AAAA,IACA,UAAY,EAAA;AAAA,MACV,WACE,EAAA,8GAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,WAAa,EAAA;AAAA,MACX,WACE,EAAA,gIAAA;AAAA,MACF,IAAM,EAAA;AAAA,KACR;AAAA,IACA,OAAS,EAAA;AAAA,MACP,WACE,EAAA,mEAAA;AAAA,MACF,IAAM,EAAA;AAAA;AACR;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roadiehq/scaffolder-backend-module-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,6 +27,16 @@
|
|
|
27
27
|
"default": "./dist/new-backend.cjs.js"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
+
"typesVersions": {
|
|
31
|
+
"*": {
|
|
32
|
+
"index": [
|
|
33
|
+
"dist/index.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"new-backend": [
|
|
36
|
+
"dist/new-backend.d.ts"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
30
40
|
"repository": {
|
|
31
41
|
"type": "git",
|
|
32
42
|
"url": "github:RoadieHQ/roadie-backstage-plugins",
|
|
@@ -46,12 +56,10 @@
|
|
|
46
56
|
"clean": "backstage-cli clean"
|
|
47
57
|
},
|
|
48
58
|
"dependencies": {
|
|
49
|
-
"@backstage/backend-
|
|
50
|
-
"@backstage/
|
|
51
|
-
"@backstage/
|
|
52
|
-
"@backstage/
|
|
53
|
-
"@backstage/plugin-scaffolder-backend": "^1.26.1",
|
|
54
|
-
"@backstage/plugin-scaffolder-node": "^0.5.0",
|
|
59
|
+
"@backstage/backend-plugin-api": "^1.0.2",
|
|
60
|
+
"@backstage/config": "^1.3.0",
|
|
61
|
+
"@backstage/errors": "^1.2.5",
|
|
62
|
+
"@backstage/plugin-scaffolder-node": "^0.6.0",
|
|
55
63
|
"adm-zip": "^0.5.9",
|
|
56
64
|
"cross-fetch": "^3.1.4",
|
|
57
65
|
"detect-indent": "^6.1.0",
|
|
@@ -63,8 +71,9 @@
|
|
|
63
71
|
"yawn-yaml": "^2.2.0"
|
|
64
72
|
},
|
|
65
73
|
"devDependencies": {
|
|
66
|
-
"@backstage/backend-
|
|
67
|
-
"@backstage/
|
|
74
|
+
"@backstage/backend-common": "^0.25.0",
|
|
75
|
+
"@backstage/backend-test-utils": "^1.1.0",
|
|
76
|
+
"@backstage/cli": "^0.29.2",
|
|
68
77
|
"@testing-library/jest-dom": "^6.4.2",
|
|
69
78
|
"@types/adm-zip": "^0.4.34",
|
|
70
79
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -73,8 +82,7 @@
|
|
|
73
82
|
"mock-fs": "^5.1.2"
|
|
74
83
|
},
|
|
75
84
|
"files": [
|
|
76
|
-
"dist"
|
|
77
|
-
"new-backend"
|
|
85
|
+
"dist"
|
|
78
86
|
],
|
|
79
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "e27d32c1346b21394aa19e0f975087e41be67835"
|
|
80
88
|
}
|