@roadiehq/scaffolder-backend-module-utils 1.16.0 → 1.17.1

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/README.md CHANGED
@@ -12,6 +12,7 @@ This contains a collection of actions to use in scaffolder templates:
12
12
  - [Serialise to JSON or YAML](#serialise)
13
13
  - [Parse and Transform JSON or YAML](#parse-and-transform-json-or-yaml)
14
14
  - [Merge new data into an existing JSON file](#merge-json)
15
+ - [Merge](#merge)
15
16
  - [Append content to a file](#append)
16
17
  - [Write content to a file](#write-to-file)
17
18
  - [Replace in files](#replace-in-files)
@@ -198,7 +199,7 @@ spec:
198
199
  name: sleep
199
200
  action: roadiehq:utils:sleep
200
201
  input:
201
- path: ${{ parameters.amount }}
202
+ amount: ${{ parameters.amount }}
202
203
  ```
203
204
 
204
205
  ### Deserialise
@@ -247,7 +248,7 @@ spec:
247
248
  path: ${{ parameters.path }}
248
249
  parser: ${{ parameters.parser }}
249
250
  output:
250
- content: ${{ steps.serialize.output.content }}
251
+ content: ${{ steps.parsefile.output.content }}
251
252
  ```
252
253
 
253
254
  ### Serialise to JSON or YAML
@@ -569,6 +570,32 @@ spec:
569
570
  message: 'RemoteURL: ${{ steps["publish-pr"].output.remoteUrl }}'
570
571
  ```
571
572
 
573
+ ### Merge
574
+
575
+ **Action name**: `roadiehq:utils:merge`
576
+
577
+ **Required params:**
578
+
579
+ - path: The file path for the file you want to edit.
580
+ - content: The content you want to merge in, as a string or a YAML object.
581
+
582
+ **Optional params:**
583
+
584
+ - mergeArrays: If `true` then where a value is an array the merge function will concatenate the provided array value with the target array.
585
+ - preserveYamlComments: If `true`, it will preserve standalone and inline comments in YAML files.
586
+ - options: YAML stringify options to customize the output format.
587
+ - indent: (default: 2) - indentation width to use (in spaces).
588
+ - noArrayIndent: (default: false) - when true, will not add an indentation level to array elements.
589
+ - skipInvalid: (default: false) - do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types.
590
+ - flowLevel: (default: -1) - specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everywhere.
591
+ - sortKeys: (default: false) - if true, sort keys when dumping YAML. If a function, use the function to sort the keys.
592
+ - lineWidth: (default: 80) - set max line width. Set -1 for unlimited width.
593
+ - noRefs: (default: false) - if true, don't convert duplicate objects into references.
594
+ - noCompatMode: (default: false) - if true, don't try to be compatible with older YAML versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1.
595
+ - condenseFlow: (default: false) - if true, flow sequences will be condensed, omitting the space between a, b. Eg. '[a,b]', and omitting the space between key: value and quoting the key. Eg. '{"a":b}' Can be useful when using YAML for pretty URL query params as spaces are %-encoded.
596
+ - quotingType: (' or ", default: ') - strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters.
597
+ - forceQuotes: (default: false) - if true, all non-key strings will be quoted even if they normally don't need to.
598
+
572
599
  ### Append
573
600
 
574
601
  **Action name**: `roadiehq:utils:fs:append`
@@ -9,6 +9,7 @@ var YAML = require('yaml');
9
9
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
10
10
  var path = require('path');
11
11
  var lodash = require('lodash');
12
+ var YAWN = require('yawn-yaml');
12
13
  var detectIndent = require('detect-indent');
13
14
  var jsonata = require('jsonata');
14
15
 
@@ -17,6 +18,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
17
18
  var AdmZip__default = /*#__PURE__*/_interopDefaultCompat(AdmZip);
18
19
  var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
19
20
  var YAML__default = /*#__PURE__*/_interopDefaultCompat(YAML);
21
+ var YAWN__default = /*#__PURE__*/_interopDefaultCompat(YAWN);
20
22
  var detectIndent__default = /*#__PURE__*/_interopDefaultCompat(detectIndent);
21
23
  var jsonata__default = /*#__PURE__*/_interopDefaultCompat(jsonata);
22
24
 
@@ -477,6 +479,12 @@ function createMergeAction() {
477
479
  title: "Merge Arrays?",
478
480
  description: "Where a value is an array the merge function should concatenate the provided array value with the target array"
479
481
  },
482
+ preserveYamlComments: {
483
+ type: "boolean",
484
+ default: false,
485
+ title: "Preserve Comments?",
486
+ description: "Will preserve standalone and inline comments in YAML files"
487
+ },
480
488
  options: {
481
489
  ...yamlOptionsSchema,
482
490
  description: `${yamlOptionsSchema.description} (for YAML output only)`
@@ -521,14 +529,29 @@ function createMergeAction() {
521
529
  case ".yml":
522
530
  case ".yaml": {
523
531
  const newContent = typeof ctx.input.content === "string" ? YAML__default.default.parse(ctx.input.content) : ctx.input.content;
524
- mergedContent = YAML__default.default.stringify(
525
- lodash.mergeWith(
526
- YAML__default.default.parse(originalContent),
532
+ if (ctx.input.preserveYamlComments) {
533
+ const yawn = new YAWN__default.default(originalContent);
534
+ const parsedOriginal = yawn.json;
535
+ const mergedJsonContent = lodash.mergeWith(
536
+ parsedOriginal,
527
537
  newContent,
528
538
  ctx.input.mergeArrays ? mergeArrayCustomiser : void 0
529
- ),
530
- ctx.input.options
531
- );
539
+ );
540
+ yawn.json = mergedJsonContent;
541
+ mergedContent = YAML__default.default.stringify(
542
+ YAML__default.default.parseDocument(yawn.yaml),
543
+ ctx.input.options
544
+ );
545
+ } else {
546
+ mergedContent = YAML__default.default.stringify(
547
+ lodash.mergeWith(
548
+ YAML__default.default.parse(originalContent),
549
+ newContent,
550
+ ctx.input.mergeArrays ? mergeArrayCustomiser : void 0
551
+ ),
552
+ ctx.input.options
553
+ );
554
+ }
532
555
  break;
533
556
  }
534
557
  }
@@ -878,4 +901,4 @@ exports.createSleepAction = createSleepAction;
878
901
  exports.createWriteFileAction = createWriteFileAction;
879
902
  exports.createYamlJSONataTransformAction = createYamlJSONataTransformAction;
880
903
  exports.createZipAction = createZipAction;
881
- //# sourceMappingURL=yaml-8suklH_U.cjs.js.map
904
+ //# sourceMappingURL=yaml-CSkuC5qH.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-CSkuC5qH.cjs.js","sources":["../../src/actions/zip.ts","../../src/actions/fs/writeFile.ts","../../src/actions/fs/appendFile.ts","../../src/actions/fs/parseFile.ts","../../src/actions/fs/replaceInFile.ts","../../src/types.ts","../../src/actions/merge/merge.ts","../../src/actions/sleep.ts","../../src/actions/jsonata/jsonata.ts","../../src/actions/jsonata/yaml.ts","../../src/actions/jsonata/json.ts","../../src/actions/serialize/json.ts","../../src/actions/serialize/yaml.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-common';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-backend';\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","/*\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-backend';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-common';\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","/*\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 indent: {\n description: '(default: 2) - indentation width to use (in spaces)',\n type: 'number',\n },\n noArrayIndent: {\n description:\n '(default: false) - when true, will not add an indentation level to array elements',\n type: 'boolean',\n },\n skipInvalid: {\n description:\n '(default: false) - do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types',\n type: 'boolean',\n },\n flowLevel: {\n description:\n '(default: -1) - specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere',\n type: 'number',\n },\n sortKeys: {\n description:\n '(default: false) - if true, sort keys when dumping YAML. If a function, use the function to sort the keys',\n type: 'boolean',\n },\n lineWidth: {\n description:\n '(default: 80) - set max line width. Set -1 for unlimited width',\n type: 'number',\n },\n noRefs: {\n description:\n \"(default: false) - if true, don't convert duplicate objects into references\",\n type: 'boolean',\n },\n noCompatMode: {\n description:\n '(default: false) - if true don\\'t try to be compatible with older yaml versions. Currently: don\\'t quote \"yes\", \"no\" and so on, as required for YAML 1.1',\n type: 'boolean',\n },\n condenseFlow: {\n description:\n \"(default: false) - if true flow sequences will be condensed, omitting the space between a, b. Eg. '[a,b]', and omitting the space between key: value and quoting the key. Eg. '{\\\"a\\\":b}' Can be useful when using yaml for pretty URL query params as spaces are %-encoded.\",\n type: 'boolean',\n },\n quotingType: {\n description:\n \"(' or \\\", default: ') - strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters.\",\n type: 'string',\n },\n forceQuotes: {\n description:\n \"(default: false) - if true, all non-key strings will be quoted even if they normally don't need to.\",\n type: 'boolean',\n },\n },\n};\n","/*\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","/*\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-backend';\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","/*\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-backend';\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","/*\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-backend';\nimport jsonata from 'jsonata';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\nimport jsonata from 'jsonata';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\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","/*\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","AdmZip","resolveSafeChildPath","fs","InputError","YAML","content","isArray","isNull","detectIndent","mergeWith","extname","YAWN","jsonata"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBO,SAAS,eAAkB,GAAA;AAChC,EAAA,OAAOA,4CAA2D,CAAA;AAAA,IA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ml-CSkuC5qH.cjs.js');
4
4
  require('@backstage/backend-common');
5
5
  require('@backstage/plugin-scaffolder-backend');
6
6
  require('@backstage/errors');
@@ -10,6 +10,7 @@ require('yaml');
10
10
  require('@backstage/plugin-scaffolder-node');
11
11
  require('path');
12
12
  require('lodash');
13
+ require('yawn-yaml');
13
14
  require('detect-indent');
14
15
  require('jsonata');
15
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -46,6 +46,7 @@ declare function createMergeAction(): _backstage_plugin_scaffolder_node.Template
46
46
  path: string;
47
47
  content: any;
48
48
  mergeArrays?: boolean | undefined;
49
+ preserveYamlComments?: boolean | undefined;
49
50
  options?: stringifyOptions | undefined;
50
51
  }, _backstage_types.JsonObject>;
51
52
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-scaffolder-node/alpha');
7
- var yaml = require('./cjs/yaml-8suklH_U.cjs.js');
7
+ var yaml = require('./cjs/yaml-CSkuC5qH.cjs.js');
8
8
  require('@backstage/backend-common');
9
9
  require('@backstage/plugin-scaffolder-backend');
10
10
  require('@backstage/errors');
@@ -14,6 +14,7 @@ require('yaml');
14
14
  require('@backstage/plugin-scaffolder-node');
15
15
  require('path');
16
16
  require('lodash');
17
+ require('yawn-yaml');
17
18
  require('detect-indent');
18
19
  require('jsonata');
19
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"new-backend.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,qCAAA;AAAA,OACd;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAc,EAAA;AACzB,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,2BAA0C,EAAA;AAAA,UAC1CC,wBAAuC,EAAA;AAAA,UACvCC,qCAAoD,EAAA;AAAA,UACpDC,sBAAqC,EAAA;AAAA,UACrCC,0BAAyC,CAAA,EAAE,CAAA;AAAA,UAC3CC,0BAAyC,EAAA;AAAA,UACzCC,8BAA6C,EAAA;AAAA,UAC7CC,8BAA6C,EAAA;AAAA,UAC7CC,8BAA6C,EAAA;AAAA,UAC7CC,sBAAqC,EAAA;AAAA,UACrCC,0BAAyC,EAAA;AAAA,UACzCC,qCAAoD,EAAA;AAAA,UACpDC,oBAAmC,EAAA;AAAA,SACrC,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"new-backend.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,qCAAA;AAAA,OACd;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAc,EAAA;AACzB,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,2BAA0C,EAAA;AAAA,UAC1CC,wBAAuC,EAAA;AAAA,UACvCC,qCAAoD,EAAA;AAAA,UACpDC,sBAAqC,EAAA;AAAA,UACrCC,0BAAyC,CAAA,EAAE,CAAA;AAAA,UAC3CC,0BAAyC,EAAA;AAAA,UACzCC,8BAA6C,EAAA;AAAA,UAC7CC,8BAA6C,EAAA;AAAA,UAC7CC,8BAA6C,EAAA;AAAA,UAC7CC,sBAAqC,EAAA;AAAA,UACrCC,0BAAyC,EAAA;AAAA,UACzCC,qCAAoD,EAAA;AAAA,UACpDC,oBAAmC,EAAA;AAAA,SACrC,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roadiehq/scaffolder-backend-module-utils",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "main": "../dist/new-backend.cjs.js",
5
5
  "types": "../dist/new-backend.d.ts"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roadiehq/scaffolder-backend-module-utils",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -55,7 +55,8 @@
55
55
  "jsonata": "^2.0.4",
56
56
  "lodash": "^4.17.21",
57
57
  "winston": "^3.2.1",
58
- "yaml": "^2.3.4"
58
+ "yaml": "^2.3.4",
59
+ "yawn-yaml": "^2.2.0"
59
60
  },
60
61
  "devDependencies": {
61
62
  "@backstage/backend-test-utils": "^0.3.7",
@@ -71,5 +72,5 @@
71
72
  "dist",
72
73
  "new-backend"
73
74
  ],
74
- "gitHead": "8c55326f8b38d46356dc39cb86aa15990c0475e1"
75
+ "gitHead": "e5ba6784fb7bfb34e9ed520f3ce5bfb9fbab1c2c"
75
76
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"yaml-8suklH_U.cjs.js","sources":["../../src/actions/zip.ts","../../src/actions/fs/writeFile.ts","../../src/actions/fs/appendFile.ts","../../src/actions/fs/parseFile.ts","../../src/actions/fs/replaceInFile.ts","../../src/types.ts","../../src/actions/merge/merge.ts","../../src/actions/sleep.ts","../../src/actions/jsonata/jsonata.ts","../../src/actions/jsonata/yaml.ts","../../src/actions/jsonata/json.ts","../../src/actions/serialize/json.ts","../../src/actions/serialize/yaml.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-common';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-backend';\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","/*\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-backend';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-common';\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","/*\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 indent: {\n description: '(default: 2) - indentation width to use (in spaces)',\n type: 'number',\n },\n noArrayIndent: {\n description:\n '(default: false) - when true, will not add an indentation level to array elements',\n type: 'boolean',\n },\n skipInvalid: {\n description:\n '(default: false) - do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types',\n type: 'boolean',\n },\n flowLevel: {\n description:\n '(default: -1) - specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere',\n type: 'number',\n },\n sortKeys: {\n description:\n '(default: false) - if true, sort keys when dumping YAML. If a function, use the function to sort the keys',\n type: 'boolean',\n },\n lineWidth: {\n description:\n '(default: 80) - set max line width. Set -1 for unlimited width',\n type: 'number',\n },\n noRefs: {\n description:\n \"(default: false) - if true, don't convert duplicate objects into references\",\n type: 'boolean',\n },\n noCompatMode: {\n description:\n '(default: false) - if true don\\'t try to be compatible with older yaml versions. Currently: don\\'t quote \"yes\", \"no\" and so on, as required for YAML 1.1',\n type: 'boolean',\n },\n condenseFlow: {\n description:\n \"(default: false) - if true flow sequences will be condensed, omitting the space between a, b. Eg. '[a,b]', and omitting the space between key: value and quoting the key. Eg. '{\\\"a\\\":b}' Can be useful when using yaml for pretty URL query params as spaces are %-encoded.\",\n type: 'boolean',\n },\n quotingType: {\n description:\n \"(' or \\\", default: ') - strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters.\",\n type: 'string',\n },\n forceQuotes: {\n description:\n \"(default: false) - if true, all non-key strings will be quoted even if they normally don't need to.\",\n type: 'boolean',\n },\n },\n};\n","/*\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 { 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 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 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 mergedContent = YAML.stringify(\n mergeWith(\n YAML.parse(originalContent),\n newContent,\n ctx.input.mergeArrays ? mergeArrayCustomiser : undefined,\n ),\n ctx.input.options,\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","/*\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-backend';\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","/*\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-backend';\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","/*\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-backend';\nimport jsonata from 'jsonata';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\nimport jsonata from 'jsonata';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\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","/*\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-backend';\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","/*\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","AdmZip","resolveSafeChildPath","fs","InputError","YAML","content","isArray","isNull","detectIndent","mergeWith","extname","jsonata"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBO,SAAS,eAAkB,GAAA;AAChC,EAAA,OAAOA,4CAA2D,CAAA;AAAA,IAChE,EAAI,EAAA,oBAAA;AAAA,IACJ,WAAa,EAAA,8BAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAA,EAAU,CAAC,MAAM,CAAA;AAAA,QACjB,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,MAAA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