github-action-readme-generator 1.9.2 → 1.10.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +13 -1
  3. package/action.yml +17 -0
  4. package/dist/bin/index.js +212 -59
  5. package/dist/mjs/Action.d.ts +15 -15
  6. package/dist/mjs/Action.js +11 -4
  7. package/dist/mjs/Action.js.map +1 -1
  8. package/dist/mjs/constants.d.ts +13 -0
  9. package/dist/mjs/constants.js +17 -0
  10. package/dist/mjs/constants.js.map +1 -1
  11. package/dist/mjs/helpers.d.ts +4 -5
  12. package/dist/mjs/helpers.js +201 -33
  13. package/dist/mjs/helpers.js.map +1 -1
  14. package/dist/mjs/inputs.d.ts +3 -11
  15. package/dist/mjs/inputs.js +28 -14
  16. package/dist/mjs/inputs.js.map +1 -1
  17. package/dist/mjs/logtask/index.js +1 -1
  18. package/dist/mjs/logtask/index.js.map +1 -1
  19. package/dist/mjs/prettier.js +4 -3
  20. package/dist/mjs/prettier.js.map +1 -1
  21. package/dist/mjs/readme-editor.js.map +1 -1
  22. package/dist/mjs/readme-generator.d.ts +3 -3
  23. package/dist/mjs/readme-generator.js.map +1 -1
  24. package/dist/mjs/save.d.ts +2 -2
  25. package/dist/mjs/save.js.map +1 -1
  26. package/dist/mjs/sections/index.d.ts +1 -1
  27. package/dist/mjs/sections/index.js +8 -8
  28. package/dist/mjs/sections/index.js.map +1 -1
  29. package/dist/mjs/sections/update-badges.d.ts +1 -1
  30. package/dist/mjs/sections/update-badges.js.map +1 -1
  31. package/dist/mjs/sections/update-branding.d.ts +1 -1
  32. package/dist/mjs/sections/update-branding.js.map +1 -1
  33. package/dist/mjs/sections/update-contents.d.ts +1 -1
  34. package/dist/mjs/sections/update-contents.js.map +1 -1
  35. package/dist/mjs/sections/update-description.d.ts +1 -1
  36. package/dist/mjs/sections/update-description.js.map +1 -1
  37. package/dist/mjs/sections/update-inputs.d.ts +1 -1
  38. package/dist/mjs/sections/update-inputs.js.map +1 -1
  39. package/dist/mjs/sections/update-outputs.d.ts +1 -1
  40. package/dist/mjs/sections/update-outputs.js.map +1 -1
  41. package/dist/mjs/sections/update-title.d.ts +1 -1
  42. package/dist/mjs/sections/update-title.js.map +1 -1
  43. package/dist/mjs/sections/update-usage.d.ts +1 -1
  44. package/dist/mjs/sections/update-usage.js.map +1 -1
  45. package/dist/mjs/svg-editor.d.mts +2 -2
  46. package/dist/mjs/svg-editor.mjs +3 -3
  47. package/dist/mjs/svg-editor.mjs.map +1 -1
  48. package/dist/types/index.d.ts +122 -129
  49. package/package.json +16 -36
@@ -1 +1 @@
1
- {"version":3,"file":"readme-generator.js","sourceRoot":"","sources":["../../src/readme-generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAKtC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACK,MAAM,CAAS;IAEvB;;OAEG;IACK,GAAG,CAAU;IAErB;;;;;OAKG;IACH,YAAY,MAAc,EAAE,GAAY;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,QAAyB;QACtC,MAAM,QAAQ,GAAyB,EAAE,CAAC;QAE1C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAAC,QAA8B;QACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,QAAmB;QAChC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACtC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,mBAAoC,IAAI,CAAC,MAAM,CAAC,QAAQ;QACrE,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAE5D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports various modules and defines a function named 'generateDocs'.\n * The function is responsible for generating documentation for the README.md file based on the provided inputs.\n * It iterates through each section defined in the 'inputs.sections' array and calls the 'updateSection' function to update the corresponding section in the README.md file.\n * If an error occurs during the update of a section, it logs the error message and stops the process.\n * Finally, it saves the updated README.md file and calls the 'save' function.\n */\n\nimport * as core from '@actions/core';\n\nimport { ReadmeSection } from './constants.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\nimport updateSection from './sections/index.js';\n\nexport type SectionKV = Record<string, string>;\n/**\n * Class for managing README generation.\n */\nexport class ReadmeGenerator {\n /**\n * The Inputs instance.\n */\n private inputs: Inputs;\n\n /**\n * The Logger instance.\n */\n private log: LogTask;\n\n /**\n * Initializes the ReadmeGenerator.\n *\n * @param inputs - The Inputs instance\n * @param log - The Logger instance\n */\n constructor(inputs: Inputs, log: LogTask) {\n this.inputs = inputs;\n this.log = log;\n }\n\n /**\n * Updates the README sections.\n *\n * @param sections - The sections array\n * @returns Promise array of section KV objects\n */\n updateSections(sections: ReadmeSection[]): Promise<SectionKV>[] {\n const promises: Promise<SectionKV>[] = [];\n\n for (const section of sections) {\n promises.push(updateSection(section, this.inputs));\n }\n\n return promises;\n }\n\n /**\n * Resolves the section update promises.\n *\n * @param promises - The promise array\n * @returns Promise resolving to combined sections KV\n */\n async resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV> {\n this.log.debug('Resolving updates');\n const results = await Promise.all(promises);\n const sections: SectionKV = {};\n\n for (const result of results) {\n Object.assign(sections, result);\n }\n\n return sections;\n }\n\n /**\n * Outputs the sections KV to GitHub output.\n *\n * @param sections - The sections KV\n */\n outputSections(sections: SectionKV): void {\n if (process.env.GITHUB_ACTIONS) {\n this.log.debug('Outputting sections');\n core.setOutput('sections', JSON.stringify(sections, null, 2));\n } else {\n this.log.debug('Not outputting sections');\n }\n }\n\n /**\n * Generates the README documentation.\n *\n * @returns Promise resolving when done\n */\n async generate(providedSections: ReadmeSection[] = this.inputs.sections): Promise<void> {\n const sectionPromises = this.updateSections(providedSections);\n const sections = await this.resolveUpdates(sectionPromises);\n\n this.outputSections(sections);\n\n return this.inputs.readmeEditor.dumpToFile();\n }\n}\n"]}
1
+ {"version":3,"file":"readme-generator.js","sourceRoot":"","sources":["../../src/readme-generator.ts"],"names":[],"mappings":"AAAA;;;;;;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,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,mBAAoC,IAAI,CAAC,MAAM,CAAC,QAAQ;QACrE,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAE5D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports various modules and defines a function named 'generateDocs'.\n * The function is responsible for generating documentation for the README.md file based on the provided inputs.\n * It iterates through each section defined in the 'inputs.sections' array and calls the 'updateSection' function to update the corresponding section in the README.md file.\n * If an error occurs during the update of a section, it logs the error message and stops the process.\n * Finally, it saves the updated README.md file and calls the 'save' function.\n */\n\nimport * as core from '@actions/core';\n\nimport type { ReadmeSection } from './constants.js';\nimport type Inputs from './inputs.js';\nimport type LogTask from './logtask/index.js';\nimport updateSection from './sections/index.js';\n\nexport type SectionKV = Record<string, string>;\n/**\n * Class for managing README generation.\n */\nexport class ReadmeGenerator {\n /**\n * The Inputs instance.\n */\n private inputs: Inputs;\n\n /**\n * The Logger instance.\n */\n private log: LogTask;\n\n /**\n * Initializes the ReadmeGenerator.\n *\n * @param inputs - The Inputs instance\n * @param log - The Logger instance\n */\n constructor(inputs: Inputs, log: LogTask) {\n this.inputs = inputs;\n this.log = log;\n }\n\n /**\n * Updates the README sections.\n *\n * @param sections - The sections array\n * @returns Promise array of section KV objects\n */\n updateSections(sections: ReadmeSection[]): Promise<SectionKV>[] {\n const promises: Promise<SectionKV>[] = [];\n\n for (const section of sections) {\n promises.push(updateSection(section, this.inputs));\n }\n\n return promises;\n }\n\n /**\n * Resolves the section update promises.\n *\n * @param promises - The promise array\n * @returns Promise resolving to combined sections KV\n */\n async resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV> {\n this.log.debug('Resolving updates');\n const results = await Promise.all(promises);\n const sections: SectionKV = {};\n\n for (const result of results) {\n Object.assign(sections, result);\n }\n\n return sections;\n }\n\n /**\n * Outputs the sections KV to GitHub output.\n *\n * @param sections - The sections KV\n */\n outputSections(sections: SectionKV): void {\n if (process.env.GITHUB_ACTIONS) {\n this.log.debug('Outputting sections');\n core.setOutput('sections', JSON.stringify(sections, null, 2));\n } else {\n this.log.debug('Not outputting sections');\n }\n }\n\n /**\n * Generates the README documentation.\n *\n * @returns Promise resolving when done\n */\n async generate(providedSections: ReadmeSection[] = this.inputs.sections): Promise<void> {\n const sectionPromises = this.updateSections(providedSections);\n const sections = await this.resolveUpdates(sectionPromises);\n\n this.outputSections(sections);\n\n return this.inputs.readmeEditor.dumpToFile();\n }\n}\n"]}
@@ -4,8 +4,8 @@
4
4
  * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.
5
5
  * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.
6
6
  */
7
- import Inputs from './inputs.js';
8
- import LogTask from './logtask/index.js';
7
+ import type Inputs from './inputs.js';
8
+ import type LogTask from './logtask/index.js';
9
9
  /**
10
10
  * This script rebuilds the usage section in the README.md to be consistent with the action.yml
11
11
  * @param {Inputs} inputs - the inputs class
@@ -1 +1 @@
1
- {"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc,EAAE,GAAY;IACvD,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.\n * The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.\n * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.\n * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.\n */\n\nimport { GHActionDocsConfig } from './config.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * This script rebuilds the usage section in the README.md to be consistent with the action.yml\n * @param {Inputs} inputs - the inputs class\n */\nexport default function save(inputs: Inputs, log: LogTask): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get().save === true) {\n try {\n docsConfig.save(inputs.configPath);\n } catch (error) {\n log.error(`${error}`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc,EAAE,GAAY;IACvD,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.\n * The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.\n * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.\n * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.\n */\n\nimport { GHActionDocsConfig } from './config.js';\nimport type Inputs from './inputs.js';\nimport type LogTask from './logtask/index.js';\n\n/**\n * This script rebuilds the usage section in the README.md to be consistent with the action.yml\n * @param {Inputs} inputs - the inputs class\n */\nexport default function save(inputs: Inputs, log: LogTask): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get().save === true) {\n try {\n docsConfig.save(inputs.configPath);\n } catch (error) {\n log.error(`${error}`);\n }\n }\n}\n"]}
@@ -6,6 +6,6 @@
6
6
  * @param {Inputs} inputs - The Inputs class instance.
7
7
  * @returns {Promise<void>} A promise that resolves once the section is updated.
8
8
  */
9
- import { ReadmeSection } from '../constants.js';
9
+ import type { ReadmeSection } from '../constants.js';
10
10
  import type Inputs from '../inputs.js';
11
11
  export default function updateSection(section: ReadmeSection, inputs: Inputs): Promise<Record<string, string>>;
@@ -18,28 +18,28 @@ export default async function updateSection(section, inputs) {
18
18
  }
19
19
  switch (section) {
20
20
  case 'branding': {
21
- return updateBranding(section, inputs);
21
+ return await updateBranding(section, inputs);
22
22
  }
23
23
  case 'badges': {
24
- return updateBadges(section, inputs);
24
+ return await updateBadges(section, inputs);
25
25
  }
26
26
  case 'usage': {
27
- return updateUsage(section, inputs);
27
+ return await updateUsage(section, inputs);
28
28
  }
29
29
  case 'title': {
30
- return updateTitle(section, inputs);
30
+ return await updateTitle(section, inputs);
31
31
  }
32
32
  case 'description': {
33
- return updateDescription(section, inputs);
33
+ return await updateDescription(section, inputs);
34
34
  }
35
35
  case 'inputs': {
36
- return updateInputs(section, inputs);
36
+ return await updateInputs(section, inputs);
37
37
  }
38
38
  case 'outputs': {
39
- return updateOutputs(section, inputs);
39
+ return await updateOutputs(section, inputs);
40
40
  }
41
41
  case 'contents': {
42
- return updateContents(section, inputs);
42
+ return await updateContents(section, inputs);
43
43
  }
44
44
  default: {
45
45
  log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;AAEzC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,OAAsB,EACtB,MAAc;IAEd,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC7E,KAAK;IACL,6CAA6C;IAC7C,yDAAyD;IACzD,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,OAAO,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,GAAG,CAAC,KAAK,CAAC,oCAAoC,OAAO,6BAA6B,CAAC,CAAC;YACpF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating different sections of the README.md file based on the provided section input.\n * It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.\n * @param {ReadmeSection} section - The section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n * @returns {Promise<void>} A promise that resolves once the section is updated.\n */\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport updateBadges from './update-badges.js';\nimport updateBranding from './update-branding.js';\nimport updateContents from './update-contents.js';\nimport updateDescription from './update-description.js';\nimport updateInputs from './update-inputs.js';\nimport updateOutputs from './update-outputs.js';\nimport updateTitle from './update-title.js';\nimport updateUsage from './update-usage.js';\n\nconst log = new LogTask('updateSection');\n\nexport default async function updateSection(\n section: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);\n // &&\n // ['branding', 'title'].includes(section) &&\n // inputs.config.get('branding_as_title_prefix') !== true\n if (startToken === -1 || stopToken === -1) {\n return {};\n }\n switch (section) {\n case 'branding': {\n return updateBranding(section, inputs);\n }\n case 'badges': {\n return updateBadges(section, inputs);\n }\n case 'usage': {\n return updateUsage(section, inputs);\n }\n case 'title': {\n return updateTitle(section, inputs);\n }\n case 'description': {\n return updateDescription(section, inputs);\n }\n case 'inputs': {\n return updateInputs(section, inputs);\n }\n case 'outputs': {\n return updateOutputs(section, inputs);\n }\n case 'contents': {\n return updateContents(section, inputs);\n }\n default: {\n log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);\n return {};\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,WAAW,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9C,CAAC;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,GAAG,CAAC,KAAK,CAAC,oCAAoC,OAAO,6BAA6B,CAAC,CAAC;YACpF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating different sections of the README.md file based on the provided section input.\n * It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.\n * @param {ReadmeSection} section - The section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n * @returns {Promise<void>} A promise that resolves once the section is updated.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport updateBadges from './update-badges.js';\nimport updateBranding from './update-branding.js';\nimport updateContents from './update-contents.js';\nimport updateDescription from './update-description.js';\nimport updateInputs from './update-inputs.js';\nimport updateOutputs from './update-outputs.js';\nimport updateTitle from './update-title.js';\nimport updateUsage from './update-usage.js';\n\nconst log: LogTask = new LogTask('updateSection');\n\nexport default async function updateSection(\n section: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);\n // &&\n // ['branding', 'title'].includes(section) &&\n // inputs.config.get('branding_as_title_prefix') !== true\n if (startToken === -1 || stopToken === -1) {\n return {};\n }\n switch (section) {\n case 'branding': {\n return await updateBranding(section, inputs);\n }\n case 'badges': {\n return await updateBadges(section, inputs);\n }\n case 'usage': {\n return await updateUsage(section, inputs);\n }\n case 'title': {\n return await updateTitle(section, inputs);\n }\n case 'description': {\n return await updateDescription(section, inputs);\n }\n case 'inputs': {\n return await updateInputs(section, inputs);\n }\n case 'outputs': {\n return await updateOutputs(section, inputs);\n }\n case 'contents': {\n return await updateContents(section, inputs);\n }\n default: {\n log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);\n return {};\n }\n }\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * The function is responsible for updating the badges section in the README.md file based on the provided inputs.
4
4
  * It utilizes the 'LogTask' class for logging purposes.
5
5
  */
6
- import { ReadmeSection } from '../constants.js';
6
+ import type { ReadmeSection } from '../constants.js';
7
7
  import type Inputs from '../inputs.js';
8
8
  /**
9
9
  * Interface for a badge.
@@ -1 +1 @@
1
- {"version":3,"file":"update-badges.js","sourceRoot":"","sources":["../../../src/sections/update-badges.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAW1C;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAa,EAAE,IAAY;IAC/C,MAAM,OAAO,GAAG,sBAAsB,KAAK,IAAI,IAAI,EAAE,CAAC;IACtD,OAAO;QACL;YACE,GAAG,EAAE,2CAA2C,KAAK,IAAI,IAAI,6DAA6D;YAC1H,GAAG,EAAE,gBAAgB;YACrB,GAAG,EAAE,GAAG,OAAO,kBAAkB;SAClC;QACD;YACE,GAAG,EAAE,8CAA8C,KAAK,IAAI,IAAI,6DAA6D;YAC7H,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,GAAG,OAAO,kBAAkB;SAClC;QACD;YACE,GAAG,EAAE,6CAA6C,KAAK,IAAI,IAAI,gCAAgC;YAC/F,GAAG,EAAE,QAAQ;SACd;QACD;YACE,GAAG,EAAE,wCAAwC,KAAK,IAAI,IAAI,gCAAgC;YAC1F,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,GAAG,OAAO,SAAS;SACzB;QACD;YACE,GAAG,EAAE,2CAA2C,KAAK,IAAI,IAAI,sCAAsC;YACnG,GAAG,EAAE,WAAW;SACjB;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAY,EAAE,GAAY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CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACjE,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code imports necessary modules and defines a function named 'updateBadges' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the badges section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes.\n */\n\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\n/**\n * Interface for a badge.\n */\nexport interface IBadge {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generate GitHub badges.\n * @returns {IBadge[]} - The array of GitHub badges.\n */\nfunction githubBadges(owner: string, repo: string): IBadge[] {\n const repoUrl = `https://github.com/${owner}/${repo}`;\n return [\n {\n img: `https://img.shields.io/github/v/release/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by tag',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/release-date/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by date',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/last-commit/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Commit',\n },\n {\n img: `https://img.shields.io/github/issues/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Open Issues',\n url: `${repoUrl}/issues`,\n },\n {\n img: `https://img.shields.io/github/downloads/${owner}/${repo}/total?logo=github&style=flat-square`,\n alt: 'Downloads',\n },\n ];\n}\n\n/**\n * Generates a badge HTML markup.\n * @param {IBadge} item - The badge object.\n * @returns {string} - The HTML markup for the badge.\n */\nfunction generateBadge(item: IBadge, log: LogTask): string {\n const badgeTemplate = `<img src=\"${item.img}\" alt=\"${encodeURIComponent(item.alt) || ''}\" />`;\n log.info(`Generating badge ${item.alt}`);\n if (item.url) {\n return `<a href=\"${encodeURIComponent(item.url)}\">${badgeTemplate}</a>`;\n }\n return badgeTemplate;\n}\n\n/**\n * Generates all badges HTML markup.\n * @param {IBadge} badges - The array of badge objects\n * @param log - A LogTask instance\n * @returns {string[]} - The array of HTML markup for all badges.\n */\nfunction generateBadges(badges: IBadge[], log: LogTask): string[] {\n const badgeArray: string[] = [];\n for (const b of badges) {\n badgeArray.push(generateBadge(b, log));\n }\n log.debug(`Total badges: ${badgeArray.length}`);\n return badgeArray;\n}\nexport default function updateBadges(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n const config = inputs.config.get();\n\n const enableVersioning = config ? config.versioning?.badge : false;\n log.info(`Versioning badge: ${enableVersioning}`);\n\n log.start();\n let content = '';\n // Add GitHub badges\n if (enableVersioning) {\n const badges: IBadge[] = githubBadges(inputs.owner, inputs.repo);\n content = generateBadges(badges, log).join('');\n inputs.readmeEditor.updateSection(sectionToken, content);\n }\n log.success();\n const ret: Record<string, string> = {};\n ret[sectionToken] = content;\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-badges.js","sourceRoot":"","sources":["../../../src/sections/update-badges.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAW1C;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAa,EAAE,IAAY;IAC/C,MAAM,OAAO,GAAG,sBAAsB,KAAK,IAAI,IAAI,EAAE,CAAC;IACtD,OAAO;QACL;YACE,GAAG,EAAE,2CAA2C,K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iB,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC;AACpB,CAAC;AACD,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IAEnC,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,GAAG,CAAC,IAAI,CAAC,qBAAqB,gBAAgB,EAAE,CAAC,CAAC;IAElD,GAAG,CAAC,KAAK,EAAE,CAAC;IACZ,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,oBAAoB;IACpB,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,MAAM,GAAa,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACjE,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code imports necessary modules and defines a function named 'updateBadges' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the badges section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes.\n */\n\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\n/**\n * Interface for a badge.\n */\nexport interface IBadge {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generate GitHub badges.\n * @returns {IBadge[]} - The array of GitHub badges.\n */\nfunction githubBadges(owner: string, repo: string): IBadge[] {\n const repoUrl = `https://github.com/${owner}/${repo}`;\n return [\n {\n img: `https://img.shields.io/github/v/release/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by tag',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/release-date/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by date',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/last-commit/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Commit',\n },\n {\n img: `https://img.shields.io/github/issues/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Open Issues',\n url: `${repoUrl}/issues`,\n },\n {\n img: `https://img.shields.io/github/downloads/${owner}/${repo}/total?logo=github&style=flat-square`,\n alt: 'Downloads',\n },\n ];\n}\n\n/**\n * Generates a badge HTML markup.\n * @param {IBadge} item - The badge object.\n * @returns {string} - The HTML markup for the badge.\n */\nfunction generateBadge(item: IBadge, log: LogTask): string {\n const badgeTemplate = `<img src=\"${item.img}\" alt=\"${encodeURIComponent(item.alt) || ''}\" />`;\n log.info(`Generating badge ${item.alt}`);\n if (item.url) {\n return `<a href=\"${encodeURIComponent(item.url)}\">${badgeTemplate}</a>`;\n }\n return badgeTemplate;\n}\n\n/**\n * Generates all badges HTML markup.\n * @param {IBadge} badges - The array of badge objects\n * @param log - A LogTask instance\n * @returns {string[]} - The array of HTML markup for all badges.\n */\nfunction generateBadges(badges: IBadge[], log: LogTask): string[] {\n const badgeArray: string[] = [];\n for (const b of badges) {\n badgeArray.push(generateBadge(b, log));\n }\n log.debug(`Total badges: ${badgeArray.length}`);\n return badgeArray;\n}\nexport default function updateBadges(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n const config = inputs.config.get();\n\n const enableVersioning = config ? config.versioning?.badge : false;\n log.info(`Versioning badge: ${enableVersioning}`);\n\n log.start();\n let content = '';\n // Add GitHub badges\n if (enableVersioning) {\n const badges: IBadge[] = githubBadges(inputs.owner, inputs.repo);\n content = generateBadges(badges, log).join('');\n inputs.readmeEditor.updateSection(sectionToken, content);\n }\n log.success();\n const ret: Record<string, string> = {};\n ret[sectionToken] = content;\n return ret;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { FeatherIconNames } from 'feather-icons';
2
2
  import type { BrandColors } from '../constants.js';
3
- import { ReadmeSection } from '../constants.js';
3
+ import { type ReadmeSection } from '../constants.js';
4
4
  import type Inputs from '../inputs.js';
5
5
  export interface IBranding {
6
6
  alt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"update-branding.js","sourceRoot":"","sources":["../../../src/sections/update-branding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,WAAW,EAAiB,MAAM,iBAAiB,CAAC;AAE3F,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAe1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,IAA+B,EAC/B,OAA6B;IAE7B,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAgC;IAC/D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,4BAA4B,CAAC,GAAG,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CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,GAAG,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACzF,OAAO,wCAAwC,MAAM,MAAM,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtC,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAErE,GAAG,CAAC,KAAK,EAAE,CAAC;IACZ,wDAAwD;IACxD,MAAM,UAAU,GAAG,KAAK,CAAC;IACzB,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,OAAO,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC9B,GAAG,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { FeatherIconNames } from 'feather-icons';\n\nimport type { BrandColors } from '../constants.js';\nimport { GITHUB_ACTIONS_OMITTED_ICONS, isValidIcon, ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport SVGEditor from '../svg-editor.mjs';\n/**\n * Wiith thanks to\n * https://github.com/haya14busa/github-action-brandings/blob/master/main.js\n * for the urls to the branding images.\n */\n\ntype Maybe<T> = T | undefined;\n\nexport interface IBranding {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generates a svg branding image.\n * example:\n * ```ts\n * generateSvgImage('/path/to/file.svg', 'home', 'red')\n * ```\n *\n * @param svgPath - The path to where the svg file will be saved\n * @param icon - The icon name from the feather-icons list\n * @param bgcolor - The background color of the circle behind the icon\n */\nexport function generateSvgImage(\n svgPath: string,\n icon: Partial<FeatherIconNames>,\n bgcolor: Partial<BrandColors>,\n): void {\n const svgEditor = new SVGEditor();\n svgEditor.generateSvgImage(svgPath, icon, bgcolor);\n}\n\n/**\n * This function returns a valid icon name based on the provided branding.\n * If the branding is undefined or not a valid icon name, an error is thrown.\n * It checks if the branding icon is present in the GITHUB_ACTIONS_BRANDING_ICONS set,\n * and if so, returns the corresponding feather icon key array.\n * If the branding icon is present in the GITHUB_ACTIONS_OMITTED_ICONS set,\n * an error is thrown specifying that the icon is part of the omitted icons list.\n * If the branding icon is not a valid icon from the feather-icons list, an error is thrown.\n * @param brand - The branding object\n * @returns The corresponding feather icon key array\n * @throws Error if the branding icon is undefined, not a valid icon name, or part of the omitted icons list\n */\nexport function getValidIconName(icon?: Partial<FeatherIconNames>): FeatherIconNames {\n if (!icon) {\n throw new Error(`No valid branding icon name found: action.yml branding is undefined`);\n }\n\n if (isValidIcon(icon)) {\n return icon;\n }\n\n if (GITHUB_ACTIONS_OMITTED_ICONS.has(icon)) {\n throw new Error(\n `No valid branding icon name found: ${icon} is part of the list of omitted icons. `,\n );\n }\n\n throw new Error(\n `No valid branding icon name found: ${icon} is not a valid icon from the feather-icons list`,\n );\n}\n\n/**\n * This function generates an HTML image markup with branding information.\n * It takes inputs and an optional width parameter.\n * If the branding_svg_path is provided, it generates an action.yml branding image for the specified icon and color.\n * Otherwise, it returns an error message.\n *\n * @param inputs - The inputs instance with data for the function.\n * @param width - The width of the image (default is '15%').\n * @returns The HTML image markup with branding information or an error message.\n */\nexport function generateImgMarkup(inputs: Inputs, width = '15%'): string {\n // Create a log task for debugging\n const log = new LogTask('generateImgMarkup');\n if (!inputs.action.branding) {\n log.info('No branding section');\n return '';\n }\n // Get the branding information from the inputs\n const { icon, color } = inputs.action.branding;\n const iconName = getValidIconName(icon);\n const svgPath = inputs.config.get('branding_svg_path') as Maybe<string>;\n const result = `<img src=\"${svgPath}\" width=\"${width}\" align=\"center\" alt=\"branding<icon:${iconName} color:${color}>\" />`;\n\n if (svgPath) {\n log.info(`Generating action.yml branding image for ${iconName}`);\n const svg = inputs.config.get('image_generated') as Maybe<string>;\n const hash = `${iconName}${color}`;\n if (svg && hash.localeCompare(svg) !== 0) {\n generateSvgImage(svgPath, iconName, color);\n inputs.config.set('image_generated', hash);\n }\n return result;\n }\n log.error(`No branding_svg_path provided or it is empty string, can't create the file!`);\n return `<!-- ERROR: no branding path found = ${result} -->`;\n}\n\n/**\n * This is a TypeScript function named \"updateBranding\" that takes in a sectionToken string and an object of inputs.\n * It exports the function as the default export.\n * The function logs the brand details from the inputs, starts a log task, generates image markup,\n * updates a section in the readme editor using the sectionToken and content, and logs success or failure messages.\n *\n * @param sectionToken - The sectionToken string that is used to identify the section in the readme editor.\n * @param inputs - The inputs object that contains data for the function.\n */\nexport default function updateBranding(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n log.info(`Brand details: ${JSON.stringify(inputs.action.branding)}`);\n\n log.start();\n /** create <img /> markup with an image width of 15% */\n const imageWidth = '15%';\n const content = generateImgMarkup(inputs, imageWidth);\n inputs.readmeEditor.updateSection(sectionToken, content);\n if (content && content !== '') {\n log.success('branding svg successfully created');\n } else {\n log.fail('branding svg failed to be created');\n }\n\n const ret: Record<string, string> = {};\n ret[sectionToken] = content;\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-branding.js","sourceRoot":"","sources":["../../../src/sections/update-branding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4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tD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,OAAO,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC9B,GAAG,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { FeatherIconNames } from 'feather-icons';\n\nimport type { BrandColors } from '../constants.js';\nimport { GITHUB_ACTIONS_OMITTED_ICONS, isValidIcon, type ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport SVGEditor from '../svg-editor.mjs';\n\n/**\n * Wiith thanks to\n * https://github.com/haya14busa/github-action-brandings/blob/master/main.js\n * for the urls to the branding images.\n */\n\ntype Maybe<T> = T | undefined;\n\nexport interface IBranding {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generates a svg branding image.\n * example:\n * ```ts\n * generateSvgImage('/path/to/file.svg', 'home', 'red')\n * ```\n *\n * @param svgPath - The path to where the svg file will be saved\n * @param icon - The icon name from the feather-icons list\n * @param bgcolor - The background color of the circle behind the icon\n */\nexport function generateSvgImage(\n svgPath: string,\n icon: Partial<FeatherIconNames>,\n bgcolor: Partial<BrandColors>,\n): void {\n const svgEditor = new SVGEditor();\n svgEditor.generateSvgImage(svgPath, icon, bgcolor);\n}\n\n/**\n * This function returns a valid icon name based on the provided branding.\n * If the branding is undefined or not a valid icon name, an error is thrown.\n * It checks if the branding icon is present in the GITHUB_ACTIONS_BRANDING_ICONS set,\n * and if so, returns the corresponding feather icon key array.\n * If the branding icon is present in the GITHUB_ACTIONS_OMITTED_ICONS set,\n * an error is thrown specifying that the icon is part of the omitted icons list.\n * If the branding icon is not a valid icon from the feather-icons list, an error is thrown.\n * @param brand - The branding object\n * @returns The corresponding feather icon key array\n * @throws Error if the branding icon is undefined, not a valid icon name, or part of the omitted icons list\n */\nexport function getValidIconName(icon?: Partial<FeatherIconNames>): FeatherIconNames {\n if (!icon) {\n throw new Error(`No valid branding icon name found: action.yml branding is undefined`);\n }\n\n if (isValidIcon(icon)) {\n return icon;\n }\n\n if (GITHUB_ACTIONS_OMITTED_ICONS.has(icon)) {\n throw new Error(\n `No valid branding icon name found: ${icon} is part of the list of omitted icons. `,\n );\n }\n\n throw new Error(\n `No valid branding icon name found: ${icon} is not a valid icon from the feather-icons list`,\n );\n}\n\n/**\n * This function generates an HTML image markup with branding information.\n * It takes inputs and an optional width parameter.\n * If the branding_svg_path is provided, it generates an action.yml branding image for the specified icon and color.\n * Otherwise, it returns an error message.\n *\n * @param inputs - The inputs instance with data for the function.\n * @param width - The width of the image (default is '15%').\n * @returns The HTML image markup with branding information or an error message.\n */\nexport function generateImgMarkup(inputs: Inputs, width: string = '15%'): string {\n // Create a log task for debugging\n const log = new LogTask('generateImgMarkup');\n if (!inputs.action.branding) {\n log.info('No branding section');\n return '';\n }\n // Get the branding information from the inputs\n const { icon, color } = inputs.action.branding;\n const iconName = getValidIconName(icon);\n const svgPath = inputs.config.get('branding_svg_path') as Maybe<string>;\n const result = `<img src=\"${svgPath}\" width=\"${width}\" align=\"center\" alt=\"branding<icon:${iconName} color:${color}>\" />`;\n\n if (svgPath) {\n log.info(`Generating action.yml branding image for ${iconName}`);\n const svg = inputs.config.get('image_generated') as Maybe<string>;\n const hash = `${iconName}${color}`;\n if (svg && hash.localeCompare(svg) !== 0) {\n generateSvgImage(svgPath, iconName, color);\n inputs.config.set('image_generated', hash);\n }\n return result;\n }\n log.error(`No branding_svg_path provided or it is empty string, can't create the file!`);\n return `<!-- ERROR: no branding path found = ${result} -->`;\n}\n\n/**\n * This is a TypeScript function named \"updateBranding\" that takes in a sectionToken string and an object of inputs.\n * It exports the function as the default export.\n * The function logs the brand details from the inputs, starts a log task, generates image markup,\n * updates a section in the readme editor using the sectionToken and content, and logs success or failure messages.\n *\n * @param sectionToken - The sectionToken string that is used to identify the section in the readme editor.\n * @param inputs - The inputs object that contains data for the function.\n */\nexport default function updateBranding(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n log.info(`Brand details: ${JSON.stringify(inputs.action.branding)}`);\n\n log.start();\n /** create <img /> markup with an image width of 15% */\n const imageWidth = '15%';\n const content = generateImgMarkup(inputs, imageWidth);\n inputs.readmeEditor.updateSection(sectionToken, content);\n if (content && content !== '') {\n log.success('branding svg successfully created');\n } else {\n log.fail('branding svg failed to be created');\n }\n\n const ret: Record<string, string> = {};\n ret[sectionToken] = content;\n return ret;\n}\n"]}
@@ -4,6 +4,6 @@
4
4
  * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
5
5
  * @param {Inputs} inputs - The Inputs class instance.
6
6
  */
7
- import { ReadmeSection } from '../constants.js';
7
+ import type { ReadmeSection } from '../constants.js';
8
8
  import type Inputs from '../inputs.js';
9
9
  export default function updateContents(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"update-contents.js","sourceRoot":"","sources":["../../../src/sections/update-contents.ts"],"names":[],"mappings":"AAQA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI;SACR,WAAW,EAAE;SACb,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,2CAA2C;SACvE,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,8BAA8B;SACtD,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,4BAA4B;SACnD,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,kCAAkC;AACjE,CAAC;AAED;;;;GAIG;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,GAAG,CAAC,CAAC,CAAC;YAExC,sEAAsE;YACtE,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,KAAK,EAAE,CAAC;YAEnE,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,MAAM,MAAM,CAAC,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAEd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateContents' which generates\n * a table of contents from the README.md headers.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\n/**\n * Converts a header text to a GitHub-compatible anchor link.\n * @param {string} text - The header text to convert.\n * @returns {string} The anchor link.\n */\nfunction headerToAnchor(text: string): string {\n return text\n .toLowerCase()\n .replaceAll(/[^\\w\\s-]/g, '') // Remove special characters except hyphens\n .replaceAll(/\\s+/g, '-') // Replace spaces with hyphens\n .replaceAll(/-+/g, '-') // Collapse multiple hyphens\n .replaceAll(/^-|-$/g, ''); // Remove leading/trailing hyphens\n}\n\n/**\n * Extracts headers from markdown content, excluding those in code blocks.\n * @param {string} content - The markdown content.\n * @returns {Array<{level: number, text: string}>} Array of header objects.\n */\nfunction extractHeaders(content: string): { level: number; text: string }[] {\n const headers: { level: number; text: string }[] = [];\n const lines = content.split('\\n');\n let inCodeBlock = false;\n\n for (const line of lines) {\n // Track code block state\n if (line.trim().startsWith('```')) {\n inCodeBlock = !inCodeBlock;\n continue;\n }\n\n // Skip if inside code block\n if (inCodeBlock) {\n continue;\n }\n\n // Match markdown headers (## Header)\n const headerMatch = /^(#{2,6})\\s+(.+)$/.exec(line);\n if (headerMatch) {\n const level = headerMatch[1].length;\n let text = headerMatch[2].trim();\n\n // Remove inline images and other markdown formatting from header text\n text = text.replaceAll(/<img[^>]*>/g, '').trim();\n // Remove markdown links but keep the text\n text = text.replaceAll(/\\[([^\\]]+)]\\([^)]+\\)/g, '$1');\n\n if (text) {\n headers.push({ level, text });\n }\n }\n }\n\n return headers;\n}\n\nexport default function updateContents(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n log.start();\n\n const content: string[] = [];\n const readmeContent = inputs.readmeEditor.getReadmeContent();\n\n // Extract headers from README\n const headers = extractHeaders(readmeContent);\n\n // Filter out the title (h1) and contents section itself\n const tocHeaders = headers.filter(\n (h) => h.level >= 2 && !h.text.toLowerCase().includes('contents'),\n );\n\n if (tocHeaders.length === 0) {\n log.info('No headers found for table of contents');\n } else {\n log.info(`Generating table of contents with ${tocHeaders.length} entries`);\n\n // Find minimum header level for proper indentation\n const minLevel = Math.min(...tocHeaders.map((h) => h.level));\n\n // Track anchor occurrences to disambiguate duplicates like GitHub does\n const anchorCounts = new Map<string, number>();\n\n // Generate TOC entries\n content.push('## Table of Contents', '');\n\n for (const header of tocHeaders) {\n const indent = ' '.repeat(header.level - minLevel);\n const baseAnchor = headerToAnchor(header.text);\n\n // Track occurrences and compute unique anchor\n const count = anchorCounts.get(baseAnchor) ?? 0;\n anchorCounts.set(baseAnchor, count + 1);\n\n // First occurrence uses base anchor, subsequent ones get -1, -2, etc.\n const anchor = count === 0 ? baseAnchor : `${baseAnchor}-${count}`;\n\n content.push(`${indent}- [${header.text}](#${anchor})`);\n }\n }\n\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-contents.js","sourceRoot":"","sources":["../../../src/sections/update-contents.ts"],"names":[],"mappings":"AAQA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI;SACR,WAAW,EAAE;SACb,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,2CAA2C;SACvE,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,8BAA8B;SACtD,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,4BAA4B;SACnD,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,kCAAkC;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,MAAM,OAAO,GAAsC,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,yBAAyB;QACzB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,WAAW,GAAG,CAAC,WAAW,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,4BAA4B;QAC5B,IAAI,WAAW,EAAE,CAAC;YAChB,SAAS;QACX,CAAC;QAED,qCAAqC;QACrC,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACpC,IAAI,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEjC,sEAAsE;YACtE,IAAI,GAAG,IAAI,CAAC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C,CAAC;QAE7D,uEAAuE;QACvE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE/C,uBAAuB;QACvB,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;QAEzC,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAE/C,8CAA8C;YAC9C,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAChD,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAExC,sEAAsE;YACtE,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,KAAK,EAAE,CAAC;YAEnE,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,MAAM,MAAM,CAAC,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAEd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateContents' which generates\n * a table of contents from the README.md headers.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\n/**\n * Converts a header text to a GitHub-compatible anchor link.\n * @param {string} text - The header text to convert.\n * @returns {string} The anchor link.\n */\nfunction headerToAnchor(text: string): string {\n return text\n .toLowerCase()\n .replaceAll(/[^\\w\\s-]/g, '') // Remove special characters except hyphens\n .replaceAll(/\\s+/g, '-') // Replace spaces with hyphens\n .replaceAll(/-+/g, '-') // Collapse multiple hyphens\n .replaceAll(/^-|-$/g, ''); // Remove leading/trailing hyphens\n}\n\n/**\n * Extracts headers from markdown content, excluding those in code blocks.\n * @param {string} content - The markdown content.\n * @returns {Array<{level: number, text: string}>} Array of header objects.\n */\nfunction extractHeaders(content: string): { level: number; text: string }[] {\n const headers: { level: number; text: string }[] = [];\n const lines = content.split('\\n');\n let inCodeBlock = false;\n\n for (const line of lines) {\n // Track code block state\n if (line.trim().startsWith('```')) {\n inCodeBlock = !inCodeBlock;\n continue;\n }\n\n // Skip if inside code block\n if (inCodeBlock) {\n continue;\n }\n\n // Match markdown headers (## Header)\n const headerMatch = /^(#{2,6})\\s+(.+)$/.exec(line);\n if (headerMatch) {\n const level = headerMatch[1].length;\n let text = headerMatch[2].trim();\n\n // Remove inline images and other markdown formatting from header text\n text = text.replaceAll(/<img[^>]*>/g, '').trim();\n // Remove markdown links but keep the text\n text = text.replaceAll(/\\[([^\\]]+)]\\([^)]+\\)/g, '$1');\n\n if (text) {\n headers.push({ level, text });\n }\n }\n }\n\n return headers;\n}\n\nexport default function updateContents(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n log.start();\n\n const content: string[] = [];\n const readmeContent = inputs.readmeEditor.getReadmeContent();\n\n // Extract headers from README\n const headers = extractHeaders(readmeContent);\n\n // Filter out the title (h1) and contents section itself\n const tocHeaders = headers.filter(\n (h) => h.level >= 2 && !h.text.toLowerCase().includes('contents'),\n );\n\n if (tocHeaders.length === 0) {\n log.info('No headers found for table of contents');\n } else {\n log.info(`Generating table of contents with ${tocHeaders.length} entries`);\n\n // Find minimum header level for proper indentation\n const minLevel = Math.min(...tocHeaders.map((h) => h.level));\n\n // Track anchor occurrences to disambiguate duplicates like GitHub does\n const anchorCounts = new Map<string, number>();\n\n // Generate TOC entries\n content.push('## Table of Contents', '');\n\n for (const header of tocHeaders) {\n const indent = ' '.repeat(header.level - minLevel);\n const baseAnchor = headerToAnchor(header.text);\n\n // Track occurrences and compute unique anchor\n const count = anchorCounts.get(baseAnchor) ?? 0;\n anchorCounts.set(baseAnchor, count + 1);\n\n // First occurrence uses base anchor, subsequent ones get -1, -2, etc.\n const anchor = count === 0 ? baseAnchor : `${baseAnchor}-${count}`;\n\n content.push(`${indent}- [${header.text}](#${anchor})`);\n }\n }\n\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
@@ -5,6 +5,6 @@
5
5
  * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
6
6
  * @param {Inputs} inputs - The Inputs class instance.
7
7
  */
8
- import { ReadmeSection } from '../constants.js';
8
+ import type { ReadmeSection } from '../constants.js';
9
9
  import type Inputs from '../inputs.js';
10
10
  export default function updateDescription(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"update-description.js","sourceRoot":"","sources":["../../../src/sections/update-description.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtC,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,oCAAoC;IACpC,IAAI,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QAChC,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,MAAM,IAAI,GAAW,MAAM,CAAC,MAAM,CAAC,WAAW;aAC3C,IAAI,EAAE;aACN,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,mBAAmB;aAC5C,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,4BAA4B;aACnD,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,mCAAmC;aAC3D,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,mCAAmC;QAEpE,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,wCAAwC,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateDescription' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the description section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\nexport default function updateDescription(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n\n // Build the new description section\n if (inputs?.action?.description) {\n log.start();\n const desc: string = inputs.action.description\n .trim()\n .replaceAll('\\r\\n', '\\n') // Convert CR to LF\n .replaceAll(/ +/g, ' ') // Squash consecutive spaces\n .replaceAll(' \\n', '\\n') // Squash space followed by newline\n .replaceAll('\\n\\n', '<br />'); // Convert double return to a break\n\n log.info(`Writing ${desc.length} characters to the description section`);\n content.push(desc);\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-description.js","sourceRoot":"","sources":["../../../src/sections/update-description.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtC,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,oCAAoC;IACpC,IAAI,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QAChC,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,MAAM,IAAI,GAAW,MAAM,CAAC,MAAM,CAAC,WAAW;aAC3C,IAAI,EAAE;aACN,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,mBAAmB;aAC5C,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,4BAA4B;aACnD,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,mCAAmC;aAC3D,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,mCAAmC;QAEpE,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,wCAAwC,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateDescription' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the description section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\nexport default function updateDescription(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n\n // Build the new description section\n if (inputs?.action?.description) {\n log.start();\n const desc: string = inputs.action.description\n .trim()\n .replaceAll('\\r\\n', '\\n') // Convert CR to LF\n .replaceAll(/ +/g, ' ') // Squash consecutive spaces\n .replaceAll(' \\n', '\\n') // Squash space followed by newline\n .replaceAll('\\n\\n', '<br />'); // Convert double return to a break\n\n log.info(`Writing ${desc.length} characters to the description section`);\n content.push(desc);\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
@@ -5,6 +5,6 @@
5
5
  * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
6
6
  * @param {Inputs} inputs - The Inputs class instance.
7
7
  */
8
- import { ReadmeSection } from '../constants.js';
8
+ import type { ReadmeSection } from '../constants.js';
9
9
  import type Inputs from '../inputs.js';
10
10
  export default function updateInputs(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"update-inputs.js","sourceRoot":"","sources":["../../../src/sections/update-inputs.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,OA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AC,CAAC,IAAI,WAAW,CAAC;YAC1C,CAAC;YAED,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAEzD,MAAM,GAAG,GAAa;gBACpB,SAAS,CAAC,GAAG,CAAC;gBACd,WAAW;gBACX,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE;gBACvD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW;aAC5C,CAAC;YACF,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,YAAY,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateInputs' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the inputs section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes, 'columnHeader' and 'rowHeader' functions from '../helpers.js' for formatting table headers, and 'markdowner' function from '../markdowner/index.js' for generating markdown content.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport { ReadmeSection } from '../constants.js';\nimport { columnHeader, rowHeader } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport markdowner from '../markdowner/index.js';\n\nexport default function updateInputs(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n const markdownArray: string[][] = [];\n const titleArray = ['Input', 'Description', 'Default', 'Required'];\n const titles: string[] = [];\n\n for (const t of titleArray) {\n titles.push(columnHeader(t));\n }\n\n markdownArray.push(titles);\n\n const vars = inputs.action.inputs;\n const tI = vars ? Object.keys(vars).length : 0;\n\n if (vars && tI > 0) {\n log.start();\n\n for (const key of Object.keys(vars)) {\n const values = vars[key];\n let description = values?.description ?? '';\n\n // Check if only the first line should be added (only subject without body)\n const matches = /(.*?)\\n\\n([Ss]*)/.exec(description);\n\n if (matches && matches.length >= 2) {\n description = matches[1] || description;\n }\n\n description = description.trim().replace('\\n', '<br />');\n\n const row: string[] = [\n rowHeader(key),\n description,\n values?.default ? `<code>${values.default}</code>` : '',\n values?.required ? '**true**' : '__false__',\n ];\n log.debug(JSON.stringify(row));\n markdownArray.push(row);\n }\n content.push(markdowner(markdownArray));\n log.info(`Action has ${tI} total ${sectionToken}`);\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n } else {\n log.debug(`Action has no ${sectionToken}`);\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-inputs.js","sourceRoot":"","sources":["../../../src/sections/update-inputs.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,UAAU,MAAM,wB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GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAEzD,MAAM,GAAG,GAAa;gBACpB,SAAS,CAAC,GAAG,CAAC;gBACd,WAAW;gBACX,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE;gBACvD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW;aAC5C,CAAC;YACF,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,YAAY,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateInputs' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the inputs section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes, 'columnHeader' and 'rowHeader' functions from '../helpers.js' for formatting table headers, and 'markdowner' function from '../markdowner/index.js' for generating markdown content.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport { columnHeader, rowHeader } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport markdowner from '../markdowner/index.js';\n\nexport default function updateInputs(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n const markdownArray: string[][] = [];\n const titleArray = ['Input', 'Description', 'Default', 'Required'];\n const titles: string[] = [];\n\n for (const t of titleArray) {\n titles.push(columnHeader(t));\n }\n\n markdownArray.push(titles);\n\n const vars = inputs.action.inputs;\n const tI = vars ? Object.keys(vars).length : 0;\n\n if (vars && tI > 0) {\n log.start();\n\n for (const key of Object.keys(vars)) {\n const values = vars[key];\n let description = values?.description ?? '';\n\n // Check if only the first line should be added (only subject without body)\n const matches = /(.*?)\\n\\n([Ss]*)/.exec(description);\n\n if (matches && matches.length >= 2) {\n description = matches[1] || description;\n }\n\n description = description.trim().replace('\\n', '<br />');\n\n const row: string[] = [\n rowHeader(key),\n description,\n values?.default ? `<code>${values.default}</code>` : '',\n values?.required ? '**true**' : '__false__',\n ];\n log.debug(JSON.stringify(row));\n markdownArray.push(row);\n }\n content.push(markdowner(markdownArray));\n log.info(`Action has ${tI} total ${sectionToken}`);\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n } else {\n log.debug(`Action has no ${sectionToken}`);\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
@@ -6,6 +6,6 @@
6
6
  * @param {ReadmeSection} sectionToken - The sectionToken used for identifying the section.
7
7
  * @param {Inputs} inputs - The Inputs class instance.
8
8
  */
9
- import { ReadmeSection } from '../constants.js';
9
+ import type { ReadmeSection } from '../constants.js';
10
10
  import type Inputs from '../inputs.js';
11
11
  export default function updateOutputs(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
@@ -1 +1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BAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACrD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACnC,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;YAC1C,CAAC;YAED,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzD,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,MAAM,GAAG,GAAa,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;YAE3D,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,YAAY,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateOutputs' which takes a sectionToken (string) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the outputs section in the README.md file based on the provided inputs.\n * It generates a table with three columns: Output name, Description, and Value (for composite actions).\n * It utilizes the 'LogTask' class for logging purposes, 'columnHeader' and 'rowHeader' functions from '../helpers.js' for formatting table headers, and 'markdowner' function from '../markdowner/index.js' for generating markdown content.\n * @param {ReadmeSection} sectionToken - The sectionToken used for identifying the section.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport { ReadmeSection } from '../constants.js';\nimport { columnHeader, rowHeader } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport markdowner from '../markdowner/index.js';\n\nexport default function updateOutputs(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n\n const markdownArray: string[][] = [];\n const titleArray = ['Output', 'Description', 'Value'];\n const titles: string[] = [];\n for (const t of titleArray) {\n titles.push(columnHeader(t));\n }\n markdownArray.push(titles);\n const vars = inputs.action.outputs;\n const tI = vars ? Object.keys(vars).length : 0;\n if (vars && tI > 0) {\n log.start();\n for (const key of Object.keys(vars)) {\n const values = vars[key];\n\n let description = values?.description ?? '';\n\n // Check if only first line should be added (only subject without body)\n\n const matches = /(.*?)\\n\\n([Ss]*)/.exec(description);\n if (matches && matches.length >= 2) {\n description = matches[1] || description;\n }\n\n description = description.trim().replace('\\n', '<br />');\n const value = values?.value ? `\\`${values.value}\\`` : '';\n const row: string[] = [rowHeader(key), description, value];\n\n log.debug(JSON.stringify(row));\n markdownArray.push(row);\n }\n content.push(markdowner(markdownArray));\n log.info(`Action has ${tI} total ${sectionToken}`);\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n } else {\n log.debug(`Action has no ${sectionToken}`);\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-outputs.js","sourceRoot":"","sources":["../../../src/sections/update-outputs.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,SAAS,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,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;YAC1C,CAAC;YAED,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzD,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,MAAM,GAAG,GAAa,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;YAE3D,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,YAAY,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateOutputs' which takes a sectionToken (string) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the outputs section in the README.md file based on the provided inputs.\n * It generates a table with three columns: Output name, Description, and Value (for composite actions).\n * It utilizes the 'LogTask' class for logging purposes, 'columnHeader' and 'rowHeader' functions from '../helpers.js' for formatting table headers, and 'markdowner' function from '../markdowner/index.js' for generating markdown content.\n * @param {ReadmeSection} sectionToken - The sectionToken used for identifying the section.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport { columnHeader, rowHeader } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport markdowner from '../markdowner/index.js';\n\nexport default function updateOutputs(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n\n const markdownArray: string[][] = [];\n const titleArray = ['Output', 'Description', 'Value'];\n const titles: string[] = [];\n for (const t of titleArray) {\n titles.push(columnHeader(t));\n }\n markdownArray.push(titles);\n const vars = inputs.action.outputs;\n const tI = vars ? Object.keys(vars).length : 0;\n if (vars && tI > 0) {\n log.start();\n for (const key of Object.keys(vars)) {\n const values = vars[key];\n\n let description = values?.description ?? '';\n\n // Check if only first line should be added (only subject without body)\n\n const matches = /(.*?)\\n\\n([Ss]*)/.exec(description);\n if (matches && matches.length >= 2) {\n description = matches[1] || description;\n }\n\n description = description.trim().replace('\\n', '<br />');\n const value = values?.value ? `\\`${values.value}\\`` : '';\n const row: string[] = [rowHeader(key), description, value];\n\n log.debug(JSON.stringify(row));\n markdownArray.push(row);\n }\n content.push(markdowner(markdownArray));\n log.info(`Action has ${tI} total ${sectionToken}`);\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n } else {\n log.debug(`Action has no ${sectionToken}`);\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
@@ -5,6 +5,6 @@
5
5
  * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
6
6
  * @param {Inputs} inputs - The Inputs class instance.
7
7
  */
8
- import { ReadmeSection } from '../constants.js';
8
+ import type { ReadmeSection } from '../constants.js';
9
9
  import type Inputs from '../inputs.js';
10
10
  export default function updateTitle(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"update-title.js","sourceRoot":"","sources":["../../../src/sections/update-title.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtC,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QAC1B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAY,EAAE,CAAC;YAC7D,SAAS,GAAG,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;QACtD,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,0BAA0B,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAW,GACxE,MAAM,CAAC,MAAM,CAAC,IAChB,EAAE,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC;QAC5B,8BAA8B;QAC9B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAE/D,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateTitle' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the title section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes, the 'generateImgMarkup' function from './update-branding.js' for generating image markup.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport { generateImgMarkup } from './update-branding.js';\n\nexport default function updateTitle(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n let name = '';\n let svgInline = '';\n\n if (inputs.action.name) {\n log.start();\n name = inputs.action.name;\n if (inputs.config.get('branding_as_title_prefix') as boolean) {\n svgInline = `${generateImgMarkup(inputs, '60px')} `;\n }\n log.info(`Writing ${name.length} characters to the title`);\n const title = `# ${svgInline}${inputs.config.get('title_prefix') as string}${\n inputs.action.name\n }`;\n log.info(`Title: ${title}`);\n // Build the new usage section\n content.push(title);\n inputs.readmeEditor.updateSection(sectionToken, content, true);\n\n log.success();\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-title.js","sourceRoot":"","sources":["../../../src/sections/update-title.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEtC,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QAC1B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAY,EAAE,CAAC;YAC7D,SAAS,GAAG,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;QACtD,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,0BAA0B,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAW,GACxE,MAAM,CAAC,MAAM,CAAC,IAChB,EAAE,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC;QAC5B,8BAA8B;QAC9B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAE/D,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateTitle' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the title section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes, the 'generateImgMarkup' function from './update-branding.js' for generating image markup.\n * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport { generateImgMarkup } from './update-branding.js';\n\nexport default function updateTitle(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n\n // Build the new README\n const content: string[] = [];\n let name = '';\n let svgInline = '';\n\n if (inputs.action.name) {\n log.start();\n name = inputs.action.name;\n if (inputs.config.get('branding_as_title_prefix') as boolean) {\n svgInline = `${generateImgMarkup(inputs, '60px')} `;\n }\n log.info(`Writing ${name.length} characters to the title`);\n const title = `# ${svgInline}${inputs.config.get('title_prefix') as string}${\n inputs.action.name\n }`;\n log.info(`Title: ${title}`);\n // Build the new usage section\n content.push(title);\n inputs.readmeEditor.updateSection(sectionToken, content, true);\n\n log.success();\n }\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
@@ -1,3 +1,3 @@
1
- import { ReadmeSection } from '../constants.js';
1
+ import type { ReadmeSection } from '../constants.js';
2
2
  import type Inputs from '../inputs.js';
3
3
  export default function updateUsage(sectionToken: ReadmeSection, inputs: Inputs): Promise<Record<string, string>>;
@@ -1 +1 @@
1
- {"version":3,"file":"update-usage.js","sourceRoot":"","sources":["../../../src/sections/update-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CACvC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,GAAG,CAAC,KAA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AAG,CAAC,OAAO,EAAE,CAAC;IACd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { ReadmeSection } from '../constants.js';\nimport { getCurrentVersionString } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport { wrapDescription } from '../prettier.js';\n\ntype DescriptionType = Record<string, string[]>;\nexport default async function updateUsage(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const log = new LogTask(sectionToken);\n log.start();\n\n const actionName = `${inputs.owner}/${inputs.repo}`;\n log.info(`Action name: ${actionName}`);\n const versionString: string = getCurrentVersionString(inputs);\n\n log.info(`Version string: ${versionString}`);\n\n const actionReference = `${actionName}@${versionString}`;\n\n const indent = ' # ';\n // Build the new README\n const content: string[] = [];\n // Build the new usage section\n content.push('```yaml', `- uses: ${actionReference}`, ' with:');\n\n const inp = inputs.action.inputs;\n let firstInput = true;\n const descriptionPromises: Record<string, Promise<string[]>> = {};\n if (inp) {\n for (const key of Object.keys(inp)) {\n const input = inp[key];\n if (input !== undefined) {\n descriptionPromises[key] = wrapDescription(`Description: ${input.description}`, [], indent);\n }\n }\n\n const descriptions: DescriptionType = {};\n const kvArray = await Promise.all(\n Object.keys(descriptionPromises).map(async (key) => {\n return { key, value: await descriptionPromises[key] };\n }),\n );\n for (const e of kvArray) {\n descriptions[e.key] = e.value;\n log.debug(`${e.key}: ${descriptions[e.key].join('\\n')}`);\n }\n\n for (const key of Object.keys(inp)) {\n const input = inp[key];\n if (input !== undefined) {\n // Line break between inputs\n if (!firstInput) {\n content.push('');\n }\n\n // Constrain the width of the description, and append it\n content.push(...descriptions[key]);\n\n if (input.default !== undefined) {\n // Append blank line if description had paragraphs\n // if (input.description?.trimEnd().match(/\\n *\\r?\\n/)) {\n // content.push(' #');\n // }\n\n // Default\n content.push(`${indent}Default: ${input.default}`);\n }\n\n // Input name\n content.push(` ${key}: ''`);\n\n firstInput = false;\n }\n }\n }\n\n content.push('```\\n');\n\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
1
+ {"version":3,"file":"update-usage.js","sourceRoot":"","sources":["../../../src/sections/update-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CACvC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,GAAG,CAAC,KAAK,EAAE,CAAC;IAEZ,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;IACpD,GAAG,CAAC,IAAI,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;IACvC,MAAM,aAAa,GAAW,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAE9D,GAAG,CAAC,IAAI,CAAC,mBAAmB,aAAa,EAAE,CAAC,CAAC;IAE7C,MAAM,eAAe,GAAG,GAAG,UAAU,IAAI,aAAa,EAAE,CAAC;IAEzD,MAAM,MAAM,GAAG,QAAQ,CAAC;IACxB,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,8BAA8B;IAC9B,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,eAAe,EAAE,EAAE,SAAS,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IACjC,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,MAAM,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AAC;gBAED,wDAAwD;gBACxD,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;gBAEnC,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;oBAChC,kDAAkD;oBAClD,yDAAyD;oBACzD,2BAA2B;oBAC3B,IAAI;oBAEJ,UAAU;oBACV,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBACrD,CAAC;gBAED,aAAa;gBACb,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;gBAE/B,UAAU,GAAG,KAAK,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEtB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACzD,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { ReadmeSection } from '../constants.js';\nimport { getCurrentVersionString } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport { wrapDescription } from '../prettier.js';\n\ntype DescriptionType = Record<string, string[]>;\nexport default async function updateUsage(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const log = new LogTask(sectionToken);\n log.start();\n\n const actionName = `${inputs.owner}/${inputs.repo}`;\n log.info(`Action name: ${actionName}`);\n const versionString: string = getCurrentVersionString(inputs);\n\n log.info(`Version string: ${versionString}`);\n\n const actionReference = `${actionName}@${versionString}`;\n\n const indent = ' # ';\n // Build the new README\n const content: string[] = [];\n // Build the new usage section\n content.push('```yaml', `- uses: ${actionReference}`, ' with:');\n\n const inp = inputs.action.inputs;\n let firstInput = true;\n const descriptionPromises: Record<string, Promise<string[]>> = {};\n if (inp) {\n for (const key of Object.keys(inp)) {\n const input = inp[key];\n if (input !== undefined) {\n descriptionPromises[key] = wrapDescription(`Description: ${input.description}`, [], indent);\n }\n }\n\n const descriptions: DescriptionType = {};\n const kvArray = await Promise.all(\n Object.keys(descriptionPromises).map(async (key) => {\n return { key, value: await descriptionPromises[key] };\n }),\n );\n for (const e of kvArray) {\n descriptions[e.key] = e.value;\n log.debug(`${e.key}: ${descriptions[e.key].join('\\n')}`);\n }\n\n for (const key of Object.keys(inp)) {\n const input = inp[key];\n if (input !== undefined) {\n // Line break between inputs\n if (!firstInput) {\n content.push('');\n }\n\n // Constrain the width of the description, and append it\n content.push(...descriptions[key]);\n\n if (input.default !== undefined) {\n // Append blank line if description had paragraphs\n // if (input.description?.trimEnd().match(/\\n *\\r?\\n/)) {\n // content.push(' #');\n // }\n\n // Default\n content.push(`${indent}Default: ${input.default}`);\n }\n\n // Input name\n content.push(` ${key}: ''`);\n\n firstInput = false;\n }\n }\n }\n\n content.push('```\\n');\n\n inputs.readmeEditor.updateSection(sectionToken, content);\n log.success();\n const ret: Record<string, string> = {};\n ret[sectionToken] = content.join('\\n');\n return ret;\n}\n"]}
@@ -21,7 +21,7 @@ export default class SVGEditor {
21
21
  /**
22
22
  * Initializes the SVG window, document, and canvas if not already set up.
23
23
  */
24
- initSVG(): Promise<void>;
24
+ initSVG(): void;
25
25
  /**
26
26
  * Generates a branded SVG image.
27
27
  * @param {string | undefined} svgPath - Path to write the generated SVG file to.
@@ -29,7 +29,7 @@ export default class SVGEditor {
29
29
  * @param {Partial<BrandColors>} bgcolor - Background color for the image.
30
30
  * @returns {Promise<void>} A promise that resolves when the image is generated.
31
31
  */
32
- generateSvgImage(svgPath: string | undefined, icon?: Partial<FeatherIconNames>, bgcolor?: Partial<BrandColors>): Promise<void>;
32
+ generateSvgImage(svgPath: string | undefined, icon?: Partial<FeatherIconNames>, bgcolor?: Partial<BrandColors>): void;
33
33
  /**
34
34
  * Writes the SVG xml to disk.
35
35
  * @param {string} svgPath - File path to save the SVG to.
@@ -28,7 +28,7 @@ export default class SVGEditor {
28
28
  /**
29
29
  * Initializes the SVG window, document, and canvas if not already set up.
30
30
  */
31
- async initSVG() {
31
+ initSVG() {
32
32
  if (!this.window) {
33
33
  this.window = createSVGWindow();
34
34
  const { document } = this.window;
@@ -45,7 +45,7 @@ export default class SVGEditor {
45
45
  * @param {Partial<BrandColors>} bgcolor - Background color for the image.
46
46
  * @returns {Promise<void>} A promise that resolves when the image is generated.
47
47
  */
48
- async generateSvgImage(svgPath, icon = DEFAULT_BRAND_ICON, bgcolor = DEFAULT_BRAND_COLOR) {
48
+ generateSvgImage(svgPath, icon = DEFAULT_BRAND_ICON, bgcolor = DEFAULT_BRAND_COLOR) {
49
49
  if (!svgPath || svgPath.length === 0) {
50
50
  this.log.debug('No svgPath provided');
51
51
  return;
@@ -62,7 +62,7 @@ export default class SVGEditor {
62
62
  }
63
63
  this.log.info(`SVG to generate ${icon} at ${svgPath} with color ${bgcolor}.`);
64
64
  // Initialize SVG
65
- await this.initSVG();
65
+ this.initSVG();
66
66
  // Generate SVG content
67
67
  const svgContent = this.generateSVGContent(icon, bgcolor);
68
68
  // Write SVG file
@@ -1 +1 @@
1
- {"version":3,"file":"svg-editor.mjs","sourceRoot":"","sources":["../../src/svg-editor.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAA0B,MAAM,QAAQ,CAAC,CAAC,oBAAoB;AAGtF,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,kBA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O,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,6DAA6D;QAC7D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAE9D,2BAA2B;QAC3B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAEpC,qEAAqE;QACrE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAEhC,6DAA6D;QAC7D,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAErC,8BAA8B;QAC9B,OAAO,CAAC,wDAAwD,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CACxF,IAAI,CACL,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports necessary modules and defines a class named 'SVGEditor' for generating SVG images.\n * The class has methods for initializing the SVG window, generating SVG content, and writing SVG files.\n * It utilizes various packages such as 'fs', 'path', '@svgdotjs/svg.js', 'feather-icons', and 'svgdom' for SVG manipulation and file operations.\n * The class also defines interfaces for badges and brand colors.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { Container } from '@svgdotjs/svg.js';\nimport { registerWindow, SVG } from '@svgdotjs/svg.js';\nimport type { FeatherIconNames } from 'feather-icons';\nimport * as feather from 'feather-icons';\nimport { createSVGWindow, SVGDocument, SVGWindow } from 'svgdom'; /// main-module.js';\n\nimport type { BrandColors } from './constants.js';\nimport {\n brandingSquareEdgeLengthInPixels,\n DEFAULT_BRAND_COLOR,\n DEFAULT_BRAND_ICON,\n GITHUB_ACTIONS_BRANDING_COLORS,\n GITHUB_ACTIONS_BRANDING_ICONS,\n isValidColor,\n isValidIcon,\n} from './constants.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * Utility class for generating SVG images.\n */\n\nexport default class SVGEditor {\n private log: LogTask;\n\n private window?: SVGWindow;\n\n private canvas?: Container;\n\n private document?: SVGDocument;\n\n /**\n * Initializes a new SVGEditor instance.\n */\n constructor() {\n this.log = new LogTask('SVGEditor');\n }\n\n /**\n * Initializes the SVG window, document, and canvas if not already set up.\n */\n async initSVG(): Promise<void> {\n if (!this.window) {\n this.window = createSVGWindow();\n const { document } = this.window;\n registerWindow(this.window, document);\n if (!this.canvas) {\n this.canvas = SVG(document.documentElement) as Container;\n }\n }\n }\n\n /**\n * Generates a branded SVG image.\n * @param {string | undefined} svgPath - Path to write the generated SVG file to.\n * @param {Partial<FeatherIconNames>} icon - Name of the icon to use.\n * @param {Partial<BrandColors>} bgcolor - Background color for the image.\n * @returns {Promise<void>} A promise that resolves when the image is generated.\n */\n async generateSvgImage(\n svgPath: string | undefined,\n icon: Partial<FeatherIconNames> = DEFAULT_BRAND_ICON,\n bgcolor: Partial<BrandColors> = DEFAULT_BRAND_COLOR\n ): Promise<void> {\n if (!svgPath || svgPath.length === 0) {\n this.log.debug('No svgPath provided');\n return;\n }\n\n if (!isValidIcon(icon)) {\n this.log.error(`Valid Branding Icon Names: ${GITHUB_ACTIONS_BRANDING_ICONS}`);\n this.log.fail(`Invalid icon name: ${icon}`);\n return;\n }\n if (!isValidColor(bgcolor)) {\n this.log.error(`Valid Branding Colors: ${GITHUB_ACTIONS_BRANDING_COLORS}`);\n this.log.fail('Invalid branding color');\n return;\n }\n this.log.info(`SVG to generate ${icon} at ${svgPath} with color ${bgcolor}.`);\n // Initialize SVG\n await this.initSVG();\n // Generate SVG content\n const svgContent = this.generateSVGContent(icon, bgcolor);\n\n // Write SVG file\n this.writeSVGFile(svgPath, svgContent);\n\n this.log.debug('SVG image generated successfully');\n }\n\n /**\n * Writes the SVG xml to disk.\n * @param {string} svgPath - File path to save the SVG to.\n * @param {string} svgContent - The XML for the SVG file.\n */\n writeSVGFile(svgPath: string, svgContent: string): void {\n fs.mkdirSync(path.dirname(svgPath), { recursive: true });\n this.log.debug(`Writing SVG file to ${svgPath}`);\n fs.writeFile(svgPath, svgContent, 'utf8', () => {\n return this.log.debug(`SVG image generated: ${svgPath}`);\n });\n }\n\n /**\n * Generates the SVG content for the branding image.\n * @param {FeatherIconNames} icon - Name of the icon to use.\n * @param {BrandColors} color - Background color for the image.\n * @param {number} outerViewBox - Size of the canvas for the image.\n * @returns {string} The generated SVG content.\n */\n generateSVGContent(icon: FeatherIconNames, color: BrandColors, outerViewBox = 100): string {\n const { canvas, log } = this;\n // Validate canvas\n if (!canvas) {\n log.fail('Canvas not initialized');\n return '';\n }\n\n const svgData = feather.icons[icon];\n log.debug(`SVG data to ingest: ${svgData.toSvg()}`);\n\n canvas.clear();\n\n // Create a canvas that is `outerViewBox` x `outerViewBox`\n canvas\n .size(brandingSquareEdgeLengthInPixels, brandingSquareEdgeLengthInPixels)\n .viewbox(`0 0 ${outerViewBox} ${outerViewBox}`)\n .fill('none');\n\n // Create a 'color' circle that touches the edges of the canvas\n const circleSize = outerViewBox / 2;\n canvas\n .circle('50%')\n .fill(color)\n .radius(circleSize)\n .cx(circleSize)\n .cy(circleSize)\n .stroke({ width: 0 });\n\n // Create an svg box that is half the size of the parent\n const iconsvgOuter = canvas.nested();\n iconsvgOuter.attr('overflow', 'visible').height('50%').width('50%').x('25%').y('25%');\n\n // create a nested svg and add the feather-icon paths to the svg\n const iconsvg = iconsvgOuter.nested();\n iconsvg.id('icon').svg(svgData.contents);\n\n // Append all of the attributes from the fether-icon\n for (const attr of Object.keys(svgData.attrs)) {\n iconsvg.attr(attr, svgData.attrs[attr]);\n }\n\n // invert the stroke color if it matches the background color\n iconsvg.stroke(color.startsWith('white') ? 'white' : 'black');\n\n // remove the edge clipping\n iconsvg.attr('overflow', 'visible');\n\n // Make the viewbox of the svg match the exact dimensions of the icon\n iconsvg.viewbox(iconsvg.bbox());\n\n // Make the svg icon center itself vertically and horozonally\n iconsvg.height('auto').width('auto');\n\n // return the xml file content\n return ['<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>', canvas.svg(), '\\n'].join(\n '\\n'\n );\n }\n}\n"]}
1
+ {"version":3,"file":"svg-editor.mjs","sourceRoot":"","sources":["../../src/svg-editor.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAoC,MAAM,QAAQ,CAAC,CAAC,oBAAoB;AAGhG,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,8BAA8B,EAC9B,6BAA6B,EAC7B,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,SAAS;IACpB,GAAG,CAAU;IAEb,MAAM,CAAa;IAEnB,MAAM,CAAa;IAEnB,QAAQ,CAAe;IAE/B;;OAEG;IACH;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;YAChC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;YACjC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACtC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,IAA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**\n * This TypeScript code imports necessary modules and defines a class named 'SVGEditor' for generating SVG images.\n * The class has methods for initializing the SVG window, generating SVG content, and writing SVG files.\n * It utilizes various packages such as 'fs', 'path', '@svgdotjs/svg.js', 'feather-icons', and 'svgdom' for SVG manipulation and file operations.\n * The class also defines interfaces for badges and brand colors.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { Container } from '@svgdotjs/svg.js';\nimport { registerWindow, SVG } from '@svgdotjs/svg.js';\nimport type { FeatherIconNames } from 'feather-icons';\nimport * as feather from 'feather-icons';\nimport { createSVGWindow, type SVGDocument, type SVGWindow } from 'svgdom'; /// main-module.js';\n\nimport type { BrandColors } from './constants.js';\nimport {\n brandingSquareEdgeLengthInPixels,\n DEFAULT_BRAND_COLOR,\n DEFAULT_BRAND_ICON,\n GITHUB_ACTIONS_BRANDING_COLORS,\n GITHUB_ACTIONS_BRANDING_ICONS,\n isValidColor,\n isValidIcon,\n} from './constants.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * Utility class for generating SVG images.\n */\n\nexport default class SVGEditor {\n private log: LogTask;\n\n private window?: SVGWindow;\n\n private canvas?: Container;\n\n private document?: SVGDocument;\n\n /**\n * Initializes a new SVGEditor instance.\n */\n constructor() {\n this.log = new LogTask('SVGEditor');\n }\n\n /**\n * Initializes the SVG window, document, and canvas if not already set up.\n */\n initSVG(): void {\n if (!this.window) {\n this.window = createSVGWindow();\n const { document } = this.window;\n registerWindow(this.window, document);\n if (!this.canvas) {\n this.canvas = SVG(document.documentElement) as Container;\n }\n }\n }\n\n /**\n * Generates a branded SVG image.\n * @param {string | undefined} svgPath - Path to write the generated SVG file to.\n * @param {Partial<FeatherIconNames>} icon - Name of the icon to use.\n * @param {Partial<BrandColors>} bgcolor - Background color for the image.\n * @returns {Promise<void>} A promise that resolves when the image is generated.\n */\n generateSvgImage(\n svgPath: string | undefined,\n icon: Partial<FeatherIconNames> = DEFAULT_BRAND_ICON,\n bgcolor: Partial<BrandColors> = DEFAULT_BRAND_COLOR\n ): void {\n if (!svgPath || svgPath.length === 0) {\n this.log.debug('No svgPath provided');\n return;\n }\n\n if (!isValidIcon(icon)) {\n this.log.error(`Valid Branding Icon Names: ${GITHUB_ACTIONS_BRANDING_ICONS}`);\n this.log.fail(`Invalid icon name: ${icon}`);\n return;\n }\n if (!isValidColor(bgcolor)) {\n this.log.error(`Valid Branding Colors: ${GITHUB_ACTIONS_BRANDING_COLORS}`);\n this.log.fail('Invalid branding color');\n return;\n }\n this.log.info(`SVG to generate ${icon} at ${svgPath} with color ${bgcolor}.`);\n // Initialize SVG\n this.initSVG();\n // Generate SVG content\n const svgContent = this.generateSVGContent(icon, bgcolor);\n\n // Write SVG file\n this.writeSVGFile(svgPath, svgContent);\n\n this.log.debug('SVG image generated successfully');\n }\n\n /**\n * Writes the SVG xml to disk.\n * @param {string} svgPath - File path to save the SVG to.\n * @param {string} svgContent - The XML for the SVG file.\n */\n writeSVGFile(svgPath: string, svgContent: string): void {\n fs.mkdirSync(path.dirname(svgPath), { recursive: true });\n this.log.debug(`Writing SVG file to ${svgPath}`);\n fs.writeFile(svgPath, svgContent, 'utf8', () => {\n return this.log.debug(`SVG image generated: ${svgPath}`);\n });\n }\n\n /**\n * Generates the SVG content for the branding image.\n * @param {FeatherIconNames} icon - Name of the icon to use.\n * @param {BrandColors} color - Background color for the image.\n * @param {number} outerViewBox - Size of the canvas for the image.\n * @returns {string} The generated SVG content.\n */\n generateSVGContent(\n icon: FeatherIconNames,\n color: BrandColors,\n outerViewBox: number = 100\n ): string {\n const { canvas, log } = this;\n // Validate canvas\n if (!canvas) {\n log.fail('Canvas not initialized');\n return '';\n }\n\n const svgData = feather.icons[icon];\n log.debug(`SVG data to ingest: ${svgData.toSvg()}`);\n\n canvas.clear();\n\n // Create a canvas that is `outerViewBox` x `outerViewBox`\n canvas\n .size(brandingSquareEdgeLengthInPixels, brandingSquareEdgeLengthInPixels)\n .viewbox(`0 0 ${outerViewBox} ${outerViewBox}`)\n .fill('none');\n\n // Create a 'color' circle that touches the edges of the canvas\n const circleSize = outerViewBox / 2;\n canvas\n .circle('50%')\n .fill(color)\n .radius(circleSize)\n .cx(circleSize)\n .cy(circleSize)\n .stroke({ width: 0 });\n\n // Create an svg box that is half the size of the parent\n const iconsvgOuter = canvas.nested();\n iconsvgOuter.attr('overflow', 'visible').height('50%').width('50%').x('25%').y('25%');\n\n // create a nested svg and add the feather-icon paths to the svg\n const iconsvg = iconsvgOuter.nested();\n iconsvg.id('icon').svg(svgData.contents);\n\n // Append all of the attributes from the fether-icon\n for (const attr of Object.keys(svgData.attrs)) {\n iconsvg.attr(attr, svgData.attrs[attr]);\n }\n\n // invert the stroke color if it matches the background color\n iconsvg.stroke(color.startsWith('white') ? 'white' : 'black');\n\n // remove the edge clipping\n iconsvg.attr('overflow', 'visible');\n\n // Make the viewbox of the svg match the exact dimensions of the icon\n iconsvg.viewbox(iconsvg.bbox());\n\n // Make the svg icon center itself vertically and horozonally\n iconsvg.height('auto').width('auto');\n\n // return the xml file content\n return ['<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>', canvas.svg(), '\\n'].join(\n '\\n'\n );\n }\n}\n"]}