github-action-readme-generator 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.example.md +2 -0
  3. package/README.md +55 -47
  4. package/dist/bin/index.js +321306 -0
  5. package/dist/mjs/Action.d.ts +33 -0
  6. package/dist/mjs/Action.js +51 -0
  7. package/dist/mjs/Action.js.map +1 -0
  8. package/dist/mjs/config.d.ts +30 -0
  9. package/dist/mjs/config.js +56 -0
  10. package/dist/mjs/config.js.map +1 -0
  11. package/dist/mjs/generate-docs.d.ts +3 -0
  12. package/dist/mjs/generate-docs.js +21 -0
  13. package/dist/mjs/generate-docs.js.map +1 -0
  14. package/dist/mjs/helpers.d.ts +17 -0
  15. package/dist/mjs/helpers.js +187 -0
  16. package/dist/mjs/helpers.js.map +1 -0
  17. package/dist/mjs/index.d.ts +2 -0
  18. package/dist/mjs/index.js +4 -0
  19. package/dist/mjs/index.js.map +1 -0
  20. package/dist/mjs/inputs.d.ts +18 -0
  21. package/dist/mjs/inputs.js +252 -0
  22. package/dist/mjs/inputs.js.map +1 -0
  23. package/dist/mjs/inputs.test.d.ts +2 -0
  24. package/dist/mjs/inputs.test.js +8 -0
  25. package/dist/mjs/inputs.test.js.map +1 -0
  26. package/dist/mjs/logtask/index.d.ts +20 -0
  27. package/dist/mjs/logtask/index.js +181 -0
  28. package/dist/mjs/logtask/index.js.map +1 -0
  29. package/dist/mjs/markdowner/index.d.ts +17 -0
  30. package/dist/mjs/markdowner/index.js +104 -0
  31. package/dist/mjs/markdowner/index.js.map +1 -0
  32. package/dist/mjs/package.json +3 -0
  33. package/dist/mjs/prettier.d.ts +3 -0
  34. package/dist/mjs/prettier.js +32 -0
  35. package/dist/mjs/prettier.js.map +1 -0
  36. package/dist/mjs/readme-editor.d.ts +10 -0
  37. package/dist/mjs/readme-editor.js +42 -0
  38. package/dist/mjs/readme-editor.js.map +1 -0
  39. package/dist/mjs/save.d.ts +2 -0
  40. package/dist/mjs/save.js +10 -0
  41. package/dist/mjs/save.js.map +1 -0
  42. package/dist/mjs/sections/index.d.ts +2 -0
  43. package/dist/mjs/sections/index.js +48 -0
  44. package/dist/mjs/sections/index.js.map +1 -0
  45. package/dist/mjs/sections/update-badges.d.ts +7 -0
  46. package/dist/mjs/sections/update-badges.js +71 -0
  47. package/dist/mjs/sections/update-badges.js.map +1 -0
  48. package/dist/mjs/sections/update-branding.d.ts +7 -0
  49. package/dist/mjs/sections/update-branding.js +46 -0
  50. package/dist/mjs/sections/update-branding.js.map +1 -0
  51. package/dist/mjs/sections/update-description.d.ts +2 -0
  52. package/dist/mjs/sections/update-description.js +21 -0
  53. package/dist/mjs/sections/update-description.js.map +1 -0
  54. package/dist/mjs/sections/update-inputs.d.ts +2 -0
  55. package/dist/mjs/sections/update-inputs.js +47 -0
  56. package/dist/mjs/sections/update-inputs.js.map +1 -0
  57. package/dist/mjs/sections/update-outputs.d.ts +2 -0
  58. package/dist/mjs/sections/update-outputs.js +42 -0
  59. package/dist/mjs/sections/update-outputs.js.map +1 -0
  60. package/dist/mjs/sections/update-title.d.ts +2 -0
  61. package/dist/mjs/sections/update-title.js +19 -0
  62. package/dist/mjs/sections/update-title.js.map +1 -0
  63. package/dist/mjs/sections/update-usage.d.ts +2 -0
  64. package/dist/mjs/sections/update-usage.js +49 -0
  65. package/dist/mjs/sections/update-usage.js.map +1 -0
  66. package/dist/mjs/svg-editor.d.mts +22 -0
  67. package/dist/mjs/svg-editor.mjs +138 -0
  68. package/dist/mjs/svg-editor.mjs.map +1 -0
  69. package/dist/mjs/working-directory.d.ts +2 -0
  70. package/dist/mjs/working-directory.js +5 -0
  71. package/dist/mjs/working-directory.js.map +1 -0
  72. package/dist/{index.d.ts → types/index.d.ts} +44 -10
  73. package/package.json +117 -135
  74. package/dist/index.js +0 -16
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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AE,CAAC,CAAC;AAChC,CAAC;AAED,eAAe,4BAA4B,CAAC","sourcesContent":["export type MarkdownArrayRowType = string[][];\nexport type MarkdownArrayItemType = string;\n/**\n * Fills the width of the cell.\n * @param text\n * @param width\n * @param paddingStart\n */\nexport function fillWidth(text: string, width: number, paddingStart: number): string {\n return (\n ' '.repeat(paddingStart) + text + ' '.repeat(Math.max(1, width - text.length - paddingStart))\n );\n}\n/**\n * Escape a text so it can be used in a markdown table\n * @param text\n */\nexport function markdownEscapeTableCell(text: string): string {\n return text.replaceAll('\\n', '<br />').replaceAll('|', '\\\\|');\n}\n\nexport function markdownEscapeInlineCode(content: string): string {\n // replace grave accents with <code> HTML element to resolve unicode character in markdown\n // let isClosingTag = false;\n if (content.includes('|')) {\n return content.replaceAll(/([\\s*_]|^)`([^`]+)`([\\s*_]|$)/g, '$1<code>$2</code>$3');\n }\n return content;\n\n // ?.forEach((match) => {\n // if (!isClosingTag) {\n // content = content.replace(match, '<code>');\n // } else {\n // content = content.replace(match, '</code>');\n // }\n // isClosingTag = !isClosingTag;\n // });\n // return content\n}\n\nexport function ArrayOfArraysToMarkdownTable(providedTableContent: MarkdownArrayRowType): string {\n const tableContent: MarkdownArrayRowType = [];\n const outputStrings: string[] = [];\n // Clone the arrays so we don't modify the original\n for (const rowA of providedTableContent) {\n tableContent.push([...rowA] as string[]);\n }\n const maxRows = tableContent.length;\n let maxCols = 0;\n let minCols = 0;\n // Find the max and min columns so we can pad the rows\n // for (const [i, e] of tableContent.entries()) {\n let tblIdx = 0;\n for (const e of tableContent) {\n if (tableContent[tblIdx] !== undefined) {\n const numCols = e.length;\n if (numCols > maxCols) {\n maxCols = numCols;\n }\n if (numCols < minCols || minCols === 0) {\n minCols = numCols;\n }\n }\n tblIdx += 1;\n }\n if (maxCols !== minCols) {\n let cntIdx = 0;\n for (const e of tableContent) {\n if (tableContent[cntIdx] === undefined) {\n tableContent[cntIdx] = Array.from({ length: maxCols }).fill('') as string[];\n } else if (e.length < maxCols) {\n tableContent[cntIdx] = [\n ...e,\n ...Array.from({ length: maxCols - e.length }).fill('undefined'),\n ] as string[];\n }\n cntIdx += 1;\n }\n }\n const markdownArrayRowsLength = maxRows + 1;\n const markdownArrayEntriesLength = maxCols * 2 + 1;\n const markdownArrays: MarkdownArrayRowType = Array.from({ length: markdownArrayRowsLength }).fill(\n Array.from({ length: markdownArrayEntriesLength }).fill('|' as string) as string[],\n ) as MarkdownArrayRowType;\n let i = 0;\n for (const row of markdownArrays) {\n let col = 0;\n\n const idx = i > 1 ? i - 1 : 0;\n const dataRow = tableContent[idx];\n for (let j = 0; j < row.length; j++) {\n let content = markdownEscapeTableCell(dataRow[col] ?? '');\n\n content = markdownEscapeInlineCode(content);\n\n if (j % 2 === 1) {\n if (i === 0) {\n markdownArrays[i][j] = ` **${content.trim()}** `;\n } else if (i === 1) {\n markdownArrays[i][j] = '---';\n } else {\n markdownArrays[i][j] = ` ${content.trim()} `;\n }\n col += 1;\n }\n }\n outputStrings.push(`${markdownArrays[i].join('')}\\n`);\n i += 1;\n }\n\n return outputStrings.join('');\n}\n\nexport default ArrayOfArraysToMarkdownTable;\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare function formatYaml(value: string, filepath?: string): Promise<string>;
2
+ export declare function formatMarkdown(value: string, filepath?: string): Promise<string>;
3
+ export declare function wrapDescription(value: string | undefined, content: string[], prefix: string): Promise<string[]>;
@@ -0,0 +1,32 @@
1
+ import { format } from 'prettier';
2
+ export async function formatYaml(value, filepath) {
3
+ const fp = filepath ? { filepath } : {};
4
+ return format(value, {
5
+ semi: false,
6
+ parser: 'yaml',
7
+ embeddedLanguageFormatting: 'auto',
8
+ ...fp,
9
+ });
10
+ }
11
+ export async function formatMarkdown(value, filepath) {
12
+ const fp = filepath ? { filepath } : {};
13
+ return format(value, {
14
+ semi: false,
15
+ parser: 'markdown',
16
+ embeddedLanguageFormatting: 'auto',
17
+ ...fp,
18
+ });
19
+ }
20
+ export async function wrapDescription(value, content, prefix) {
21
+ if (!value)
22
+ return content ?? [];
23
+ const valueWithoutPrefix = prefix ? value.replace(prefix, '') : value;
24
+ const formattedString = await format(`${prefix ?? ''}${valueWithoutPrefix}`, {
25
+ semi: false,
26
+ parser: 'yaml',
27
+ proseWrap: 'always',
28
+ });
29
+ content.push(...formattedString.split('\n'));
30
+ return content;
31
+ }
32
+ //# sourceMappingURL=prettier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../src/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAa,EAAE,QAAiB;IAC/D,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC,KAAK,EAAE;QACnB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,MAAM;QACd,0BAA0B,EAAE,MAAM;QAClC,GAAG,EAAE;KACN,CAAC,CAAC;AACL,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAa,EAAE,QAAiB;IACnE,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC,KAAK,EAAE;QACnB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,UAAU;QAClB,0BAA0B,EAAE,MAAM;QAClC,GAAG,EAAE;KACN,CAAC,CAAC;AACL,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAyB,EACzB,OAAiB,EACjB,MAAc;IAEd,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,IAAI,EAAE,CAAC;IACjC,MAAM,kBAAkB,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACtE,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,GAAG,MAAM,IAAI,EAAE,GAAG,kBAAkB,EAAE,EAAE;QAC3E,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,QAAQ;KACpB,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { format } from 'prettier';\n\nexport async function formatYaml(value: string, filepath?: string): Promise<string> {\n const fp = filepath ? { filepath } : {};\n return format(value, {\n semi: false,\n parser: 'yaml',\n embeddedLanguageFormatting: 'auto',\n ...fp,\n });\n}\nexport async function formatMarkdown(value: string, filepath?: string): Promise<string> {\n const fp = filepath ? { filepath } : {};\n return format(value, {\n semi: false,\n parser: 'markdown',\n embeddedLanguageFormatting: 'auto',\n ...fp,\n });\n}\nexport async function wrapDescription(\n value: string | undefined,\n content: string[],\n prefix: string,\n): Promise<string[]> {\n if (!value) return content ?? [];\n const valueWithoutPrefix = prefix ? value.replace(prefix, '') : value;\n const formattedString = await format(`${prefix ?? ''}${valueWithoutPrefix}`, {\n semi: false,\n parser: 'yaml',\n proseWrap: 'always',\n });\n content.push(...formattedString.split('\\n'));\n return content;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ export declare const startTokenFormat = "<!-- start %s -->";
2
+ export declare const endTokenFormat = "<!-- end %s -->";
3
+ export default class ReadmeEditor {
4
+ private readonly filePath;
5
+ private fileContent;
6
+ constructor(filePath: string);
7
+ getTokenIndexes(token: string): number[];
8
+ updateSection(name: string, providedContent: string | string[], addNewlines?: boolean): void;
9
+ dumpToFile(): Promise<void>;
10
+ }
@@ -0,0 +1,42 @@
1
+ import * as fs from 'node:fs';
2
+ import { EOL } from 'node:os';
3
+ import LogTask from './logtask/index.js';
4
+ import { formatMarkdown } from './prettier.js';
5
+ export const startTokenFormat = '<!-- start %s -->';
6
+ export const endTokenFormat = '<!-- end %s -->';
7
+ export default class ReadmeEditor {
8
+ filePath;
9
+ fileContent;
10
+ constructor(filePath) {
11
+ this.filePath = filePath;
12
+ this.fileContent = fs.readFileSync(filePath, 'utf8');
13
+ }
14
+ getTokenIndexes(token) {
15
+ const startToken = startTokenFormat.replace('%s', token);
16
+ const stopToken = endTokenFormat.replace('%s', token);
17
+ const startIndex = Math.max(0, this.fileContent.indexOf(startToken) + startToken.length);
18
+ const stopIndex = this.fileContent.indexOf(stopToken);
19
+ return [startIndex, stopIndex];
20
+ }
21
+ updateSection(name, providedContent, addNewlines = true) {
22
+ const log = new LogTask(name);
23
+ const content = (Array.isArray(providedContent) ? providedContent.join(EOL) : providedContent ?? '').trim();
24
+ log.info(`Looking for the ${name} token in ${this.filePath}`);
25
+ const [startIndex, stopIndex] = this.getTokenIndexes(name);
26
+ if (startIndex !== -1 && stopIndex !== -1) {
27
+ const beforeContent = this.fileContent.slice(0, startIndex);
28
+ const afterContent = this.fileContent.slice(stopIndex);
29
+ this.fileContent = addNewlines
30
+ ? `${beforeContent}\n${content}\n${afterContent}`
31
+ : `${beforeContent}${content}${afterContent}`;
32
+ }
33
+ else if (stopIndex < startIndex) {
34
+ throw new Error(`Start token for section '${name}' must appear before end token`);
35
+ }
36
+ }
37
+ async dumpToFile() {
38
+ const content = await formatMarkdown(this.fileContent);
39
+ return fs.writeFileSync(this.filePath, content, 'utf8');
40
+ }
41
+ }
42
+ //# sourceMappingURL=readme-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readme-editor.js","sourceRoot":"","sources":["../../src/readme-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,O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AAC,CAAC;QAE9D,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAE3D,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;YACzC,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;YAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAEvD,IAAI,CAAC,WAAW,GAAG,WAAW;gBAC5B,CAAC,CAAC,GAAG,aAAa,KAAK,OAAO,KAAK,YAAY,EAAE;gBACjD,CAAC,CAAC,GAAG,aAAa,GAAG,OAAO,GAAG,YAAY,EAAE,CAAC;SACjD;aAAM,IAAI,SAAS,GAAG,UAAU,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,gCAAgC,CAAC,CAAC;SACnF;IACH,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvD,OAAO,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import * as fs from 'node:fs';\nimport { EOL } from 'node:os';\n\nimport LogTask from './logtask/index.js';\nimport { formatMarkdown } from './prettier.js';\n\nexport const startTokenFormat = '<!-- start %s -->';\nexport const endTokenFormat = '<!-- end %s -->';\n\nexport default class ReadmeEditor {\n private readonly filePath: string;\n\n private fileContent: string;\n\n constructor(filePath: string) {\n this.filePath = filePath;\n this.fileContent = fs.readFileSync(filePath, 'utf8');\n }\n\n getTokenIndexes(token: string): number[] {\n const startToken = startTokenFormat.replace('%s', token);\n const stopToken = endTokenFormat.replace('%s', token);\n const startIndex = Math.max(0, this.fileContent.indexOf(startToken) + startToken.length);\n const stopIndex = this.fileContent.indexOf(stopToken);\n return [startIndex, stopIndex];\n }\n\n updateSection(name: string, providedContent: string | string[], addNewlines = true): void {\n const log = new LogTask(name);\n const content = (\n Array.isArray(providedContent) ? providedContent.join(EOL) : providedContent ?? ''\n ).trim();\n log.info(`Looking for the ${name} token in ${this.filePath}`);\n\n const [startIndex, stopIndex] = this.getTokenIndexes(name);\n\n if (startIndex !== -1 && stopIndex !== -1) {\n const beforeContent = this.fileContent.slice(0, startIndex);\n const afterContent = this.fileContent.slice(stopIndex);\n\n this.fileContent = addNewlines\n ? `${beforeContent}\\n${content}\\n${afterContent}`\n : `${beforeContent}${content}${afterContent}`;\n } else if (stopIndex < startIndex) {\n throw new Error(`Start token for section '${name}' must appear before end token`);\n }\n }\n\n async dumpToFile(): Promise<void> {\n const content = await formatMarkdown(this.fileContent);\n return fs.writeFileSync(this.filePath, content, 'utf8');\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import Inputs from './inputs.js';
2
+ export default function save(inputs: Inputs): void;
@@ -0,0 +1,10 @@
1
+ import { GHActionDocsConfig } from './config.js';
2
+ // This script rebuilds the usage section in the README.md to be consistent with the action.yml
3
+ export default function save(inputs) {
4
+ const docsConfig = new GHActionDocsConfig();
5
+ docsConfig.loadInputs(inputs);
6
+ if (inputs.config.get('save')) {
7
+ docsConfig.save(inputs.configPath);
8
+ }
9
+ }
10
+ //# sourceMappingURL=save.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,+FAA+F;AAC/F,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc;IACzC,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC7B,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KACpC;AACH,CAAC","sourcesContent":["import { GHActionDocsConfig } from './config.js';\nimport Inputs from './inputs.js';\n\n// This script rebuilds the usage section in the README.md to be consistent with the action.yml\nexport default function save(inputs: Inputs): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get('save')) {\n docsConfig.save(inputs.configPath);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type Inputs from '../inputs.js';
2
+ export default function updateSection(section: string, inputs: Inputs): void;
@@ -0,0 +1,48 @@
1
+ import LogTask from '../logtask/index.js';
2
+ import updateBadges from './update-badges.js';
3
+ import updateBranding from './update-branding.js';
4
+ import updateDescription from './update-description.js';
5
+ import updateInputs from './update-inputs.js';
6
+ import updateOutputs from './update-outputs.js';
7
+ import updateTitle from './update-title.js';
8
+ import updateUsage from './update-usage.js';
9
+ const log = new LogTask('updateSection');
10
+ export default function updateSection(section, inputs) {
11
+ const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);
12
+ if (startToken === -1 || stopToken === -1)
13
+ return;
14
+ switch (section) {
15
+ case 'branding': {
16
+ updateBranding(section, inputs);
17
+ break;
18
+ }
19
+ case 'badges': {
20
+ updateBadges(section, inputs);
21
+ break;
22
+ }
23
+ case 'usage': {
24
+ updateUsage(section, inputs);
25
+ break;
26
+ }
27
+ case 'title': {
28
+ updateTitle(section, inputs);
29
+ break;
30
+ }
31
+ case 'description': {
32
+ updateDescription(section, inputs);
33
+ break;
34
+ }
35
+ case 'inputs': {
36
+ updateInputs(section, inputs);
37
+ break;
38
+ }
39
+ case 'outputs': {
40
+ updateOutputs(section, inputs);
41
+ break;
42
+ }
43
+ default: {
44
+ log.debug(`unknown section ${section}`);
45
+ }
46
+ }
47
+ }
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot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YAC9B,MAAM;SACP;QACD,KAAK,SAAS,CAAC,CAAC;YACd,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC/B,MAAM;SACP;QACD,OAAO,CAAC,CAAC;YACP,GAAG,CAAC,KAAK,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;SACzC;KACF;AACH,CAAC","sourcesContent":["import type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport updateBadges from './update-badges.js';\nimport updateBranding from './update-branding.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');\nexport default function updateSection(section: string, inputs: Inputs): void {\n const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);\n if (startToken === -1 || stopToken === -1) return;\n switch (section) {\n case 'branding': {\n updateBranding(section, inputs);\n break;\n }\n case 'badges': {\n updateBadges(section, inputs);\n break;\n }\n case 'usage': {\n updateUsage(section, inputs);\n break;\n }\n case 'title': {\n updateTitle(section, inputs);\n break;\n }\n case 'description': {\n updateDescription(section, inputs);\n break;\n }\n case 'inputs': {\n updateInputs(section, inputs);\n break;\n }\n case 'outputs': {\n updateOutputs(section, inputs);\n break;\n }\n default: {\n log.debug(`unknown section ${section}`);\n }\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type Inputs from '../inputs.js';
2
+ export interface IBadge {
3
+ alt: string;
4
+ img: string;
5
+ url?: string;
6
+ }
7
+ export default function updateBadges(token: string, inputs: Inputs): void;
@@ -0,0 +1,71 @@
1
+ import LogTask from '../logtask/index.js';
2
+ export default function updateBadges(token, inputs) {
3
+ const log = new LogTask(token);
4
+ const enableVersioning = inputs.config.get('versioning:badges');
5
+ const badges = [];
6
+ const repos = {
7
+ owner: inputs.config.get('owner'),
8
+ repo: inputs.config.get('repo'),
9
+ };
10
+ /**
11
+ * Generate github badges.
12
+ * @param githubId
13
+ */
14
+ function githubBadges() {
15
+ const repoUrl = `https://github.com/${repos.owner}/${repos.repo}`;
16
+ return [
17
+ {
18
+ img: `https://img.shields.io/github/v/release/${repos.owner}/${repos.repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,
19
+ alt: 'Release',
20
+ url: `${repoUrl}/releases/latest`,
21
+ },
22
+ {
23
+ img: `https://img.shields.io/github/release-date/${repos.owner}/${repos.repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,
24
+ alt: 'Release',
25
+ url: `${repoUrl}/releases/latest`,
26
+ },
27
+ {
28
+ img: `https://img.shields.io/github/last-commit/${repos.owner}/${repos.repo}?logo=github&style=flat-square`,
29
+ alt: 'Commit',
30
+ },
31
+ {
32
+ img: `https://img.shields.io/github/issues/${repos.owner}/${repos.repo}?logo=github&style=flat-square`,
33
+ alt: 'Open Issues',
34
+ url: `${repoUrl}/issues`,
35
+ },
36
+ {
37
+ img: `https://img.shields.io/github/downloads/${repos.owner}/${repos.repo}/total?logo=github&style=flat-square`,
38
+ alt: 'Downloads',
39
+ },
40
+ ];
41
+ }
42
+ /**
43
+ * Generates a badge.
44
+ */
45
+ function generateBadge(item) {
46
+ const badgeTemplate = `<img src="${item.img}" alt="${item.alt || ''}" />`;
47
+ if (item.url) {
48
+ return `<a href="${item.url}">${badgeTemplate}</a>`;
49
+ }
50
+ return badgeTemplate;
51
+ }
52
+ /**
53
+ * Generates all badges.
54
+ */
55
+ function generateBadges() {
56
+ const badgeArray = [];
57
+ for (const b of badges) {
58
+ badgeArray.push(generateBadge(b));
59
+ }
60
+ return [badgeArray.join('')];
61
+ }
62
+ log.start();
63
+ // Add Github badges
64
+ if (enableVersioning) {
65
+ badges.push(...githubBadges());
66
+ }
67
+ const content = generateBadges();
68
+ inputs.readmeEditor.updateSection(token, content);
69
+ log.success();
70
+ }
71
+ //# sourceMappingURL=update-badges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-badges.js","sourceRoot":"","sources":["../../../src/sections/update-badges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C,IAAI,sCAAsC;gBAC/G,GAAG,EAAE,WAAW;aACjB;SACF,CAAC;IACJ,CAAC;IACD;;OAEG;IACH,SAAS,aAAa,CAAC,IAAY;QACjC,MAAM,aAAa,GAAG,aAAa,IAAI,CAAC,GAAG,UAAU,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC;QAC1E,IAAI,IAAI,CAAC,GAAG,EAAE;YACZ,OAAO,YAAY,IAAI,CAAC,GAAG,KAAK,aAAa,MAAM,CAAC;SACrD;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD;;OAEG;IACH,SAAS,cAAc;QACrB,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE;YACtB,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;SACnC;QACD,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,KAAK,EAAE,CAAC;IAEZ,oBAAoB;IACpB,IAAI,gBAAgB,EAAE;QACpB,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,EAAE,CAAC,CAAC;KAChC;IACD,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElD,GAAG,CAAC,OAAO,EAAE,CAAC;AAChB,CAAC","sourcesContent":["import type { Repo } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\nexport interface IBadge {\n alt: string;\n img: string;\n url?: string;\n}\nexport default function updateBadges(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\n const enableVersioning = inputs.config.get('versioning:badges');\n const badges: IBadge[] = [];\n const repos: Repo = {\n owner: inputs.config.get('owner'),\n repo: inputs.config.get('repo'),\n };\n\n /**\n * Generate github badges.\n * @param githubId\n */\n function githubBadges(): IBadge[] {\n const repoUrl = `https://github.com/${repos.owner}/${repos.repo}`;\n return [\n {\n img: `https://img.shields.io/github/v/release/${repos.owner}/${repos.repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/release-date/${repos.owner}/${repos.repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/last-commit/${repos.owner}/${repos.repo}?logo=github&style=flat-square`,\n alt: 'Commit',\n },\n {\n img: `https://img.shields.io/github/issues/${repos.owner}/${repos.repo}?logo=github&style=flat-square`,\n alt: 'Open Issues',\n url: `${repoUrl}/issues`,\n },\n {\n img: `https://img.shields.io/github/downloads/${repos.owner}/${repos.repo}/total?logo=github&style=flat-square`,\n alt: 'Downloads',\n },\n ];\n }\n /**\n * Generates a badge.\n */\n function generateBadge(item: IBadge): string {\n const badgeTemplate = `<img src=\"${item.img}\" alt=\"${item.alt || ''}\" />`;\n if (item.url) {\n return `<a href=\"${item.url}\">${badgeTemplate}</a>`;\n }\n return badgeTemplate;\n }\n /**\n * Generates all badges.\n */\n function generateBadges(): string[] {\n const badgeArray = [];\n for (const b of badges) {\n badgeArray.push(generateBadge(b));\n }\n return [badgeArray.join('')];\n }\n\n log.start();\n\n // Add Github badges\n if (enableVersioning) {\n badges.push(...githubBadges());\n }\n const content = generateBadges();\n inputs.readmeEditor.updateSection(token, content);\n\n log.success();\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type Inputs from '../inputs.js';
2
+ export interface IBranding {
3
+ alt: string;
4
+ img: string;
5
+ url?: string;
6
+ }
7
+ export default function updateBranding(token: string, inputs: Inputs): void;
@@ -0,0 +1,46 @@
1
+ import LogTask from '../logtask/index.js';
2
+ import SVGEditor, { GITHUB_ACTIONS_BRANDING_ICONS } from '../svg-editor.mjs';
3
+ function featherType(iconName) {
4
+ return iconName;
5
+ }
6
+ /**
7
+ * Generates a svg branding image.
8
+ */
9
+ function generateSvgImage(svgPath, icon, bgcolor) {
10
+ const svgEditor = new SVGEditor();
11
+ svgEditor.generateSvgImage(svgPath, icon, bgcolor);
12
+ // const svgOut = [
13
+ // '<?xml version="1.0" encoding="UTF-8" standalone="no"?>',
14
+ // draw.svg(),
15
+ // '\n',
16
+ // ].join('\n');
17
+ // log.info(`SVG data to write: ${svgOut}`);
18
+ // fs.mkdirSync(path.dirname(svgPath), { recursive: true });
19
+ // fs.writeFileSync(svgPath, svgOut, { encoding: 'utf8' });
20
+ // } catch (error) {
21
+ // log.error(`Error generating svg image: ${svgPath}. Error: ${error}`);
22
+ // }
23
+ }
24
+ function generateImgMarkup(svgPath, brand) {
25
+ return `<img src="${svgPath}" alt="${brand.icon ?? ''}" />`;
26
+ }
27
+ export default function updateBranding(token, inputs) {
28
+ const log = new LogTask(token);
29
+ const svgPath = inputs.config.get('branding_svg_path');
30
+ log.info(`Brand details: ${JSON.stringify(inputs.action.branding)}`);
31
+ const brand = inputs.action.branding;
32
+ log.start();
33
+ if (typeof brand.icon === 'string' && GITHUB_ACTIONS_BRANDING_ICONS.has(brand.icon)) {
34
+ const iconName = featherType(brand.icon);
35
+ log.info(`Generating action.yml branding image for ${iconName}`);
36
+ generateSvgImage(svgPath, iconName, brand.color);
37
+ const content = generateImgMarkup(svgPath, brand);
38
+ inputs.readmeEditor.updateSection(token, content);
39
+ }
40
+ else {
41
+ log.warn('No icon specified for branding in action.yml. Leaving section blank');
42
+ inputs.readmeEditor.updateSection(token, '');
43
+ }
44
+ log.success();
45
+ }
46
+ //# sourceMappingURL=update-branding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-branding.js","sourceRoot":"","sources":["../../../src/sections/update-branding.ts"],"names":[],"mappings":"AAKA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,SAAS,EAAE,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAU7E,SAAS,WAAW,CAA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QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACnD;SAAM;QACL,GAAG,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;QAChF,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KAC9C;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport * as feather from 'feather-icons';\n\nimport type { Branding } from '../Action.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport SVGEditor, { GITHUB_ACTIONS_BRANDING_ICONS } 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 */\ntype conforms<T, V> = T extends V ? T : V;\ntype FeatherIconKeysArray = keyof typeof feather.icons;\ntype FeatherIconKeys<T extends string, R = FeatherIconKeysArray> = conforms<T, R>;\nfunction featherType<T extends FeatherIconKeysArray | string>(iconName: T): FeatherIconKeys<T> {\n return iconName as FeatherIconKeys<T>;\n}\nexport interface IBranding {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generates a svg branding image.\n */\nfunction generateSvgImage(\n svgPath: string,\n icon: FeatherIconKeys<keyof typeof feather.icons>,\n bgcolor: string,\n): void {\n const svgEditor = new SVGEditor();\n svgEditor.generateSvgImage(svgPath, icon, bgcolor);\n // const svgOut = [\n // '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>',\n // draw.svg(),\n // '\\n',\n // ].join('\\n');\n // log.info(`SVG data to write: ${svgOut}`);\n // fs.mkdirSync(path.dirname(svgPath), { recursive: true });\n // fs.writeFileSync(svgPath, svgOut, { encoding: 'utf8' });\n // } catch (error) {\n // log.error(`Error generating svg image: ${svgPath}. Error: ${error}`);\n // }\n}\nfunction generateImgMarkup(svgPath: string, brand: Branding): string {\n return `<img src=\"${svgPath}\" alt=\"${brand.icon ?? ''}\" />`;\n}\nexport default function updateBranding(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\n const svgPath = inputs.config.get('branding_svg_path') as string;\n\n log.info(`Brand details: ${JSON.stringify(inputs.action.branding)}`);\n\n const brand: Branding = inputs.action.branding;\n\n log.start();\n if (typeof brand.icon === 'string' && GITHUB_ACTIONS_BRANDING_ICONS.has(brand.icon)) {\n const iconName = featherType(brand.icon);\n log.info(`Generating action.yml branding image for ${iconName}`);\n\n generateSvgImage(svgPath, iconName, brand.color);\n const content = generateImgMarkup(svgPath, brand);\n inputs.readmeEditor.updateSection(token, content);\n } else {\n log.warn('No icon specified for branding in action.yml. Leaving section blank');\n inputs.readmeEditor.updateSection(token, '');\n }\n log.success();\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type Inputs from '../inputs.js';
2
+ export default function updateDescription(token: string, inputs: Inputs): void;
@@ -0,0 +1,21 @@
1
+ import LogTask from '../logtask/index.js';
2
+ export default function updateDescription(token, inputs) {
3
+ const log = new LogTask(token);
4
+ // Build the new README
5
+ const content = [];
6
+ // Build the new description section
7
+ if (inputs?.action?.description) {
8
+ log.start();
9
+ const desc = inputs.action.description
10
+ .trim()
11
+ .replaceAll('\r\n', '\n') // Convert CR to LF
12
+ .replaceAll(/ +/g, ' ') // Squash consecutive spaces
13
+ .replaceAll(' \n', '\n') // Squash space followed by newline
14
+ .replaceAll('\n\n', '<br />'); // convert double return to a break
15
+ log.info(`Writing ${desc.length} characters to the description section`);
16
+ content.push(desc);
17
+ inputs.readmeEditor.updateSection(token, content);
18
+ log.success();
19
+ }
20
+ }
21
+ //# sourceMappingURL=update-description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-description.js","sourceRoot":"","sources":["../../../src/sections/update-description.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAa,EAAE,MAAc;IACrE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,oCAAoC;IACpC,IAAI,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE;QAC/B,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,+BAA+B;aACtD,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,oCAAoC;aAC5D,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,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,EAAE,CAAC;KACf;AACH,CAAC","sourcesContent":["import type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\nexport default function updateDescription(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\n // Build the new README\n const content: string[] = [];\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(token, content);\n log.success();\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type Inputs from '../inputs.js';
2
+ export default function updateInputs(token: string, inputs: Inputs): void;
@@ -0,0 +1,47 @@
1
+ import { columnHeader, rowHeader } from '../helpers.js';
2
+ import LogTask from '../logtask/index.js';
3
+ import markdowner from '../markdowner/index.js';
4
+ export default function updateInputs(token, inputs) {
5
+ const log = new LogTask(token);
6
+ // Build the new README
7
+ const content = [];
8
+ const markdownArray = [];
9
+ const titleArray = ['Input', 'Description', 'Default', 'Required'];
10
+ const titles = [];
11
+ for (const t of titleArray) {
12
+ titles.push(columnHeader(t));
13
+ }
14
+ markdownArray.push(titles);
15
+ const vars = inputs.action.inputs;
16
+ const tI = vars ? Object.keys(vars).length : 0;
17
+ if (tI > 0) {
18
+ log.start();
19
+ for (const key of Object.keys(vars)) {
20
+ const values = vars[key];
21
+ let description = values?.description ?? '';
22
+ // Check if only first line should be added (only subject without body)
23
+ // eslint-disable-next-line no-useless-escape
24
+ const matches = description.match('(.*?)\n\n([Ss]*)');
25
+ if (matches && matches.length >= 2) {
26
+ description = matches[1] || description;
27
+ }
28
+ description = description.trim().replace('\n', '<br />');
29
+ const row = [
30
+ rowHeader(key),
31
+ description,
32
+ values?.default ? `\`${values.default}\`` : '',
33
+ values?.required ? '**true**' : '__false__',
34
+ ];
35
+ log.debug(JSON.stringify(row));
36
+ markdownArray.push(row);
37
+ }
38
+ content.push(markdowner(markdownArray));
39
+ log.info(`Action has ${tI} total ${token}`);
40
+ inputs.readmeEditor.updateSection(token, content);
41
+ log.success();
42
+ }
43
+ else {
44
+ log.debug(`Action has no ${token}`);
45
+ }
46
+ }
47
+ //# sourceMappingURL=update-inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-inputs.js","sourceRoot":"","sources":["../../../src/sections/update-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MA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C,CAAC,IAAI,WAAW,CAAC;aACzC;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,KAAK,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE;gBAC9C,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;SACzB;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;QAC5C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,EAAE,CAAC;KACf;SAAM;QACL,GAAG,CAAC,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;KACrC;AACH,CAAC","sourcesContent":["import { 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(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\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 for (const t of titleArray) {\n titles.push(columnHeader(t));\n }\n markdownArray.push(titles);\n const vars = inputs.action.inputs;\n const tI = vars ? Object.keys(vars).length : 0;\n if (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 // eslint-disable-next-line no-useless-escape\n const matches = description.match('(.*?)\\n\\n([Ss]*)');\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 ? `\\`${values.default}\\`` : '',\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 ${token}`);\n inputs.readmeEditor.updateSection(token, content);\n log.success();\n } else {\n log.debug(`Action has no ${token}`);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type Inputs from '../inputs.js';
2
+ export default function updateOutputs(token: string, inputs: Inputs): void;
@@ -0,0 +1,42 @@
1
+ import { columnHeader, rowHeader } from '../helpers.js';
2
+ import LogTask from '../logtask/index.js';
3
+ import markdowner from '../markdowner/index.js';
4
+ export default function updateOutputs(token, inputs) {
5
+ const log = new LogTask(token);
6
+ // Build the new README
7
+ const content = [];
8
+ const markdownArray = [];
9
+ const titleArray = ['Output', 'Description'];
10
+ const titles = [];
11
+ for (const t of titleArray) {
12
+ titles.push(columnHeader(t));
13
+ }
14
+ markdownArray.push(titles);
15
+ const vars = inputs.action.outputs;
16
+ const tI = vars ? Object.keys(vars).length : 0;
17
+ if (tI > 0) {
18
+ log.start();
19
+ for (const key of Object.keys(vars)) {
20
+ const values = vars[key];
21
+ let description = values?.description ?? '';
22
+ // Check if only first line should be added (only subject without body)
23
+ // eslint-disable-next-line no-useless-escape
24
+ const matches = /(.*?)\n\n([Ss]*)/.exec(description);
25
+ if (matches && matches.length >= 2) {
26
+ description = matches[1] || description;
27
+ }
28
+ description = description.trim().replace('\n', '<br />');
29
+ const row = [rowHeader(key), description];
30
+ log.debug(JSON.stringify(row));
31
+ markdownArray.push(row);
32
+ }
33
+ content.push(markdowner(markdownArray));
34
+ log.info(`Action has ${tI} total ${token}`);
35
+ inputs.readmeEditor.updateSection(token, content);
36
+ log.success();
37
+ }
38
+ else {
39
+ log.debug(`Action has no ${token}`);
40
+ }
41
+ }
42
+ //# sourceMappingURL=update-outputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-outputs.js","sourceRoot":"","sources":["../../../src/sections/update-outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;IACjE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAE/B,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,aAAa,GAAe,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KAC9B;IACD,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACnC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,IAAI,EAAE,GAAG,CAAC,EAAE;QACV,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YAEzB,IAAI,WAAW,GAAG,MAAM,EAAE,WAAW,IAAI,EAAE,CAAC;YAE5C,uEAAuE;YACvE,6CAA6C;YAC7C,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACrD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;gBAClC,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;aACzC;YAED,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzD,MAAM,GAAG,GAAa,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC;YAEpD,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzB;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;QAC5C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,EAAE,CAAC;KACf;SAAM;QACL,GAAG,CAAC,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;KACrC;AACH,CAAC","sourcesContent":["import { 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(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\n\n // Build the new README\n const content: string[] = [];\n\n const markdownArray: string[][] = [];\n const titleArray = ['Output', 'Description'];\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 (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 // eslint-disable-next-line no-useless-escape\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 row: string[] = [rowHeader(key), description];\n\n log.debug(JSON.stringify(row));\n markdownArray.push(row);\n }\n content.push(markdowner(markdownArray));\n log.info(`Action has ${tI} total ${token}`);\n inputs.readmeEditor.updateSection(token, content);\n log.success();\n } else {\n log.debug(`Action has no ${token}`);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type Inputs from '../inputs.js';
2
+ export default function updateTitle(token: string, inputs: Inputs): void;
@@ -0,0 +1,19 @@
1
+ import LogTask from '../logtask/index.js';
2
+ export default function updateTitle(token, inputs) {
3
+ const log = new LogTask(token);
4
+ // Build the new README
5
+ const content = [];
6
+ let name = '';
7
+ if (inputs.action.name) {
8
+ log.start();
9
+ name = inputs.action.name;
10
+ log.info(`Writing ${name.length} characters to the title`);
11
+ const title = `# ${inputs.config.get('title_prefix')}${inputs.action.name}`;
12
+ log.info(`Title: ${title}`);
13
+ // Build the new usage section
14
+ content.push(title);
15
+ inputs.readmeEditor.updateSection(token, content);
16
+ log.success();
17
+ }
18
+ }
19
+ //# sourceMappingURL=update-title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-title.js","sourceRoot":"","sources":["../../../src/sections/update-title.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAa,EAAE,MAAc;IAC/D,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,uBAAuB;IACvB,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QACtB,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QAE1B,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,0BAA0B,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACtF,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC;QAC5B,8BAA8B;QAC9B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEpB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,EAAE,CAAC;KACf;AACH,CAAC","sourcesContent":["import type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\nexport default function updateTitle(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\n // Build the new README\n const content: string[] = [];\n let name = '';\n if (inputs.action.name) {\n log.start();\n name = inputs.action.name;\n\n log.info(`Writing ${name.length} characters to the title`);\n const title = `# ${inputs.config.get('title_prefix') as string}${inputs.action.name}`;\n log.info(`Title: ${title}`);\n // Build the new usage section\n content.push(title);\n\n inputs.readmeEditor.updateSection(token, content);\n log.success();\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type Inputs from '../inputs.js';
2
+ export default function updateUsage(token: string, inputs: Inputs): void;
@@ -0,0 +1,49 @@
1
+ import { getCurrentVersionString } from '../helpers.js';
2
+ import LogTask from '../logtask/index.js';
3
+ import { wrapDescription } from '../prettier.js';
4
+ export default function updateUsage(token, inputs) {
5
+ const log = new LogTask(token);
6
+ log.start();
7
+ const actionName = `${inputs.config.get('owner')}/${inputs.config.get('repo')}`;
8
+ log.info(`Action name: ${actionName}`);
9
+ const versionString = getCurrentVersionString(inputs);
10
+ log.info(`Version string: ${versionString}`);
11
+ const actionReference = `${actionName}@${versionString}`;
12
+ if (!actionReference) {
13
+ throw new Error('Parameter actionReference must not be empty');
14
+ }
15
+ // Build the new README
16
+ const content = [];
17
+ // Build the new usage section
18
+ content.push('```yaml', `- uses: ${actionReference}`, ' with:');
19
+ const inp = inputs.action.inputs;
20
+ let firstInput = true;
21
+ if (inp) {
22
+ for (const key of Object.keys(inp)) {
23
+ const input = inp[key];
24
+ if (input !== undefined) {
25
+ // Line break between inputs
26
+ if (!firstInput) {
27
+ content.push('');
28
+ }
29
+ // Constrain the width of the description, and append it
30
+ wrapDescription(input.description, content, ' # ');
31
+ if (input.default !== undefined) {
32
+ // Append blank line if description had paragraphs
33
+ if (input.description?.trimEnd().match(/\n *\r?\n/)) {
34
+ content.push(' #');
35
+ }
36
+ // Default
37
+ content.push(` # Default: ${input.default}`);
38
+ }
39
+ // Input name
40
+ content.push(` ${key}: ''`);
41
+ firstInput = false;
42
+ }
43
+ }
44
+ }
45
+ content.push('```\n');
46
+ inputs.readmeEditor.updateSection(token, content);
47
+ log.success();
48
+ }
49
+ //# sourceMappingURL=update-usage.js.map