github-action-readme-generator 1.8.10 → 1.9.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.
@@ -24,6 +24,11 @@ export default class ReadmeEditor {
24
24
  * @param {string} filePath - The path to the README file.
25
25
  */
26
26
  constructor(filePath: string);
27
+ /**
28
+ * Gets the current README content.
29
+ * @returns {string} - The README file content.
30
+ */
31
+ getReadmeContent(): string;
27
32
  /**
28
33
  * Gets the indexes of the start and end tokens for a given section.
29
34
  * @param {string} token - The section token.
@@ -42,6 +42,13 @@ export default class ReadmeEditor {
42
42
  throw error;
43
43
  }
44
44
  }
45
+ /**
46
+ * Gets the current README content.
47
+ * @returns {string} - The README file content.
48
+ */
49
+ getReadmeContent() {
50
+ return this.fileContent;
51
+ }
45
52
  /**
46
53
  * Gets the indexes of the start and end tokens for a given section.
47
54
  * @param {string} token - The section token.
@@ -1 +1 @@
1
- {"version":3,"file":"readme-editor.js","sourceRoot":"","sources":["../../src/readme-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAEzE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAErE,MAAM,CAAC,OAAO,OAAO,YAAY;IACvB,GAAG,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IAE1C;;OAEG;IACc,QAAQ,CAAS;IAE1B,WAAW,CAAS;IAE5B;;;O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IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports the necessary modules and defines a class named `ReadmeEditor`.\n * The class represents an editor for modifying a README file.\n * It has methods to update specific sections within the file and dump the modified content back to the file.\n */\n\nimport * as fs from 'node:fs';\nimport { EOL } from 'node:os';\n\nimport * as core from '@actions/core';\n\nimport { indexOfRegex, lastIndexOfRegex } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport { formatMarkdown } from './prettier.js';\n\n/**\n * The format for the start token of a section.\n */\n\nexport const startTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+start\\\\s+%s\\\\s+-->';\n\n/**\n * The format for the end token of a section.\n */\nexport const endTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+end\\\\s+%s\\\\s+-->';\n\nexport default class ReadmeEditor {\n private log = new LogTask('ReadmeEditor');\n\n /**\n * The path to the README file.\n */\n private readonly filePath: string;\n\n private fileContent: string;\n\n /**\n * Creates a new instance of `ReadmeEditor`.\n * @param {string} filePath - The path to the README file.\n */\n constructor(filePath: string) {\n this.filePath = filePath;\n try {\n fs.accessSync(filePath);\n this.fileContent = fs.readFileSync(filePath, 'utf8');\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_before', this.fileContent);\n }\n } catch (error) {\n this.log.fail(`Readme at '${filePath}' does not exist.`);\n throw error;\n }\n }\n\n /**\n * Gets the indexes of the start and end tokens for a given section.\n * @param {string} token - The section token.\n * @returns {number[]} - The indexes of the start and end tokens.\n */\n getTokenIndexes(token: string, logTask?: LogTask): number[] {\n const log = logTask ?? new LogTask('getTokenIndexes');\n const startRegExp = new RegExp(startTokenFormat.replace('%s', token));\n const stopRegExp = new RegExp(endTokenFormat.replace('%s', token));\n const startIndex = lastIndexOfRegex(this.fileContent, startRegExp);\n if (startIndex === -1) {\n log.debug(`No start token found for section '${token}'. Skipping`);\n return [];\n }\n\n const stopIndex = indexOfRegex(this.fileContent, stopRegExp);\n if (stopIndex === -1) {\n log.debug(`No start or end token found for section '${token}'. Skipping`);\n return [];\n }\n\n return [startIndex, stopIndex];\n }\n\n /**\n * Updates a specific section in the README file with the provided content.\n * @param {string} name - The name of the section.\n * @param {string | string[]} providedContent - The content to update the section with.\n * @param {boolean} addNewlines - Whether to add newlines before and after the content.\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, log);\n if (startIndex && stopIndex) {\n const beforeContent = this.fileContent.slice(0, startIndex);\n const afterContent = this.fileContent.slice(stopIndex);\n\n this.fileContent = addNewlines\n ? `${beforeContent}\\n\\n${content}\\n${afterContent}`\n : `${beforeContent}${content}${afterContent}`;\n }\n }\n\n /**\n * Dumps the modified content back to the README file.\n * @returns {Promise<void>}\n */\n async dumpToFile(): Promise<void> {\n const content = await formatMarkdown(this.fileContent);\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_after', content);\n }\n return fs.promises.writeFile(this.filePath, content, 'utf8');\n }\n}\n"]}
1
+ {"version":3,"file":"readme-editor.js","sourceRoot":"","sources":["../../src/readme-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,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CAAC,SAAS,CAAC,CAAC;YAEvD,IAAI,CAAC,WAAW,GAAG,WAAW;gBAC5B,CAAC,CAAC,GAAG,aAAa,OAAO,OAAO,KAAK,YAAY,EAAE;gBACnD,CAAC,CAAC,GAAG,aAAa,GAAG,OAAO,GAAG,YAAY,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports the necessary modules and defines a class named `ReadmeEditor`.\n * The class represents an editor for modifying a README file.\n * It has methods to update specific sections within the file and dump the modified content back to the file.\n */\n\nimport * as fs from 'node:fs';\nimport { EOL } from 'node:os';\n\nimport * as core from '@actions/core';\n\nimport { indexOfRegex, lastIndexOfRegex } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport { formatMarkdown } from './prettier.js';\n\n/**\n * The format for the start token of a section.\n */\n\nexport const startTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+start\\\\s+%s\\\\s+-->';\n\n/**\n * The format for the end token of a section.\n */\nexport const endTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+end\\\\s+%s\\\\s+-->';\n\nexport default class ReadmeEditor {\n private log = new LogTask('ReadmeEditor');\n\n /**\n * The path to the README file.\n */\n private readonly filePath: string;\n\n private fileContent: string;\n\n /**\n * Creates a new instance of `ReadmeEditor`.\n * @param {string} filePath - The path to the README file.\n */\n constructor(filePath: string) {\n this.filePath = filePath;\n try {\n fs.accessSync(filePath);\n this.fileContent = fs.readFileSync(filePath, 'utf8');\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_before', this.fileContent);\n }\n } catch (error) {\n this.log.fail(`Readme at '${filePath}' does not exist.`);\n throw error;\n }\n }\n\n /**\n * Gets the current README content.\n * @returns {string} - The README file content.\n */\n getReadmeContent(): string {\n return this.fileContent;\n }\n\n /**\n * Gets the indexes of the start and end tokens for a given section.\n * @param {string} token - The section token.\n * @returns {number[]} - The indexes of the start and end tokens.\n */\n getTokenIndexes(token: string, logTask?: LogTask): number[] {\n const log = logTask ?? new LogTask('getTokenIndexes');\n const startRegExp = new RegExp(startTokenFormat.replace('%s', token));\n const stopRegExp = new RegExp(endTokenFormat.replace('%s', token));\n const startIndex = lastIndexOfRegex(this.fileContent, startRegExp);\n if (startIndex === -1) {\n log.debug(`No start token found for section '${token}'. Skipping`);\n return [];\n }\n\n const stopIndex = indexOfRegex(this.fileContent, stopRegExp);\n if (stopIndex === -1) {\n log.debug(`No start or end token found for section '${token}'. Skipping`);\n return [];\n }\n\n return [startIndex, stopIndex];\n }\n\n /**\n * Updates a specific section in the README file with the provided content.\n * @param {string} name - The name of the section.\n * @param {string | string[]} providedContent - The content to update the section with.\n * @param {boolean} addNewlines - Whether to add newlines before and after the content.\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, log);\n if (startIndex && stopIndex) {\n const beforeContent = this.fileContent.slice(0, startIndex);\n const afterContent = this.fileContent.slice(stopIndex);\n\n this.fileContent = addNewlines\n ? `${beforeContent}\\n\\n${content}\\n${afterContent}`\n : `${beforeContent}${content}${afterContent}`;\n }\n }\n\n /**\n * Dumps the modified content back to the README file.\n * @returns {Promise<void>}\n */\n async dumpToFile(): Promise<void> {\n const content = await formatMarkdown(this.fileContent);\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_after', content);\n }\n return fs.promises.writeFile(this.filePath, content, 'utf8');\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import LogTask from '../logtask/index.js';
2
2
  import updateBadges from './update-badges.js';
3
3
  import updateBranding from './update-branding.js';
4
+ import updateContents from './update-contents.js';
4
5
  import updateDescription from './update-description.js';
5
6
  import updateInputs from './update-inputs.js';
6
7
  import updateOutputs from './update-outputs.js';
@@ -37,6 +38,9 @@ export default async function updateSection(section, inputs) {
37
38
  case 'outputs': {
38
39
  return updateOutputs(section, inputs);
39
40
  }
41
+ case 'contents': {
42
+ return updateContents(section, inputs);
43
+ }
40
44
  default: {
41
45
  log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);
42
46
  return {};
@@ -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,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,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 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 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,MAAM,mBAAmB,CAAC;AAC5C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;AAEzC,MAAM,CAAC,OAAO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AAC,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"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This TypeScript code exports a function named 'updateContents' which generates
3
+ * a table of contents from the README.md headers.
4
+ * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
5
+ * @param {Inputs} inputs - The Inputs class instance.
6
+ */
7
+ import { ReadmeSection } from '../constants.js';
8
+ import type Inputs from '../inputs.js';
9
+ export default function updateContents(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
@@ -0,0 +1,87 @@
1
+ import LogTask from '../logtask/index.js';
2
+ /**
3
+ * Converts a header text to a GitHub-compatible anchor link.
4
+ * @param {string} text - The header text to convert.
5
+ * @returns {string} The anchor link.
6
+ */
7
+ function headerToAnchor(text) {
8
+ return text
9
+ .toLowerCase()
10
+ .replaceAll(/[^\w\s-]/g, '') // Remove special characters except hyphens
11
+ .replaceAll(/\s+/g, '-') // Replace spaces with hyphens
12
+ .replaceAll(/-+/g, '-') // Collapse multiple hyphens
13
+ .replaceAll(/^-|-$/g, ''); // Remove leading/trailing hyphens
14
+ }
15
+ /**
16
+ * Extracts headers from markdown content, excluding those in code blocks.
17
+ * @param {string} content - The markdown content.
18
+ * @returns {Array<{level: number, text: string}>} Array of header objects.
19
+ */
20
+ function extractHeaders(content) {
21
+ const headers = [];
22
+ const lines = content.split('\n');
23
+ let inCodeBlock = false;
24
+ for (const line of lines) {
25
+ // Track code block state
26
+ if (line.trim().startsWith('```')) {
27
+ inCodeBlock = !inCodeBlock;
28
+ continue;
29
+ }
30
+ // Skip if inside code block
31
+ if (inCodeBlock) {
32
+ continue;
33
+ }
34
+ // Match markdown headers (## Header)
35
+ const headerMatch = /^(#{2,6})\s+(.+)$/.exec(line);
36
+ if (headerMatch) {
37
+ const level = headerMatch[1].length;
38
+ let text = headerMatch[2].trim();
39
+ // Remove inline images and other markdown formatting from header text
40
+ text = text.replaceAll(/<img[^>]*>/g, '').trim();
41
+ // Remove markdown links but keep the text
42
+ text = text.replaceAll(/\[([^\]]+)]\([^)]+\)/g, '$1');
43
+ if (text) {
44
+ headers.push({ level, text });
45
+ }
46
+ }
47
+ }
48
+ return headers;
49
+ }
50
+ export default function updateContents(sectionToken, inputs) {
51
+ const log = new LogTask(sectionToken);
52
+ log.start();
53
+ const content = [];
54
+ const readmeContent = inputs.readmeEditor.getReadmeContent();
55
+ // Extract headers from README
56
+ const headers = extractHeaders(readmeContent);
57
+ // Filter out the title (h1) and contents section itself
58
+ const tocHeaders = headers.filter((h) => h.level >= 2 && !h.text.toLowerCase().includes('contents'));
59
+ if (tocHeaders.length === 0) {
60
+ log.info('No headers found for table of contents');
61
+ }
62
+ else {
63
+ log.info(`Generating table of contents with ${tocHeaders.length} entries`);
64
+ // Find minimum header level for proper indentation
65
+ const minLevel = Math.min(...tocHeaders.map((h) => h.level));
66
+ // Track anchor occurrences to disambiguate duplicates like GitHub does
67
+ const anchorCounts = new Map();
68
+ // Generate TOC entries
69
+ content.push('## Table of Contents', '');
70
+ for (const header of tocHeaders) {
71
+ const indent = ' '.repeat(header.level - minLevel);
72
+ const baseAnchor = headerToAnchor(header.text);
73
+ // Track occurrences and compute unique anchor
74
+ const count = anchorCounts.get(baseAnchor) ?? 0;
75
+ anchorCounts.set(baseAnchor, count + 1);
76
+ // First occurrence uses base anchor, subsequent ones get -1, -2, etc.
77
+ const anchor = count === 0 ? baseAnchor : `${baseAnchor}-${count}`;
78
+ content.push(`${indent}- [${header.text}](#${anchor})`);
79
+ }
80
+ }
81
+ inputs.readmeEditor.updateSection(sectionToken, content);
82
+ log.success();
83
+ const ret = {};
84
+ ret[sectionToken] = content.join('\n');
85
+ return ret;
86
+ }
87
+ //# sourceMappingURL=update-contents.js.map
@@ -0,0 +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,8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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 { 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"]}
@@ -412,6 +412,11 @@ declare module "src/readme-editor" {
412
412
  * @param {string} filePath - The path to the README file.
413
413
  */
414
414
  constructor(filePath: string);
415
+ /**
416
+ * Gets the current README content.
417
+ * @returns {string} - The README file content.
418
+ */
419
+ getReadmeContent(): string;
415
420
  /**
416
421
  * Gets the indexes of the start and end tokens for a given section.
417
422
  * @param {string} token - The section token.
@@ -881,6 +886,17 @@ declare module "src/sections/update-branding" {
881
886
  */
882
887
  export default function updateBranding(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
883
888
  }
889
+ declare module "src/sections/update-contents" {
890
+ /**
891
+ * This TypeScript code exports a function named 'updateContents' which generates
892
+ * a table of contents from the README.md headers.
893
+ * @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
894
+ * @param {Inputs} inputs - The Inputs class instance.
895
+ */
896
+ import { ReadmeSection } from "src/constants";
897
+ import type Inputs from "src/inputs";
898
+ export default function updateContents(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
899
+ }
884
900
  declare module "src/sections/update-description" {
885
901
  /**
886
902
  * This TypeScript code exports a function named 'updateDescription' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
@@ -1004,6 +1020,7 @@ declare module "__tests__/readme-generator.test" {
1004
1020
  export const __filename: string;
1005
1021
  export const __dirname: string;
1006
1022
  }
1023
+ declare module "__tests__/update-contents.test" { }
1007
1024
  declare module "__tests__/logtask/index.test" { }
1008
1025
  declare module "src/config" {
1009
1026
  import type Inputs from "src/inputs";
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "github-action-readme-generator",
3
3
  "displayName": "bitflight-devops/github-action-readme-generator",
4
- "version": "1.8.10",
5
- "description": "This is a CLI tool and GitHub Action that reads in the details from a \nGitHub Action's `action.yml` file and updates the `README.md` file\nwith the `name`, `description`, `usage`, `inputs`, `outputs`, and\nexamples of the action.\nConfiguration can be provided via a `.ghadocs.json` file stored in the\nroot directory of the Action's repository, via the command line when\nusing the cli, or via the `with:` section of this Action.\n\n\nThis tool uses markdown comments as delimiting tokens within the `README.md`\nfile to determine where to place the generated content.\n\n[`README.example.md`](README.example.md) example with all fields filled in, and no other free-form content.",
4
+ "version": "1.9.1",
5
+ "description": "The docs generator for GitHub Actions. Auto-syncs action.yml to README.md with 8 sections: inputs, outputs, usage, badges, branding & more. Works as CLI or GitHub Action.",
6
6
  "keywords": [
7
+ "github-actions",
7
8
  "actions",
8
- "github",
9
- "node20",
10
9
  "documentation",
11
- "github-actions",
12
- "generator",
13
10
  "readme-generator",
14
- "action-metadata",
15
- "markdown-generator"
11
+ "action-yml",
12
+ "markdown-generator",
13
+ "github-action-docs",
14
+ "auto-docs",
15
+ "devops",
16
+ "cli",
17
+ "inputs-outputs",
18
+ "usage-generator"
16
19
  ],
17
20
  "homepage": "https://github.com/bitflight-devops/github-action-readme-generator#readme",
18
21
  "bugs": {
@@ -141,14 +144,14 @@
141
144
  },
142
145
  "dependencies": {
143
146
  "@actions/core": "^2.0.1",
144
- "@actions/github": "^6.0.1",
147
+ "@actions/github": "^7.0.0",
145
148
  "@svgdotjs/svg.js": "^3.2.5",
146
149
  "@types/feather-icons": "^4.29.4",
147
150
  "@types/svgdom": "^0.1.2",
148
151
  "chalk": "^5.6.2",
149
152
  "feather-icons": "^4.29.2",
150
153
  "nconf": "^0.13.0",
151
- "prettier": "^3.7.4",
154
+ "prettier": "^3.8.1",
152
155
  "svgdom": "^0.1.22",
153
156
  "yaml": "^2.8.2"
154
157
  },
@@ -158,7 +161,7 @@
158
161
  "@babel/plugin-proposal-decorators": "^7.28.0",
159
162
  "@babel/preset-env": "^7.26.0",
160
163
  "@commitlint/cli": "^20.3.1",
161
- "@commitlint/config-conventional": "^20.0.0",
164
+ "@commitlint/config-conventional": "^20.3.1",
162
165
  "@commitlint/prompt": "^20.3.1",
163
166
  "@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
164
167
  "@semantic-release/changelog": "^6.0.3",
@@ -170,7 +173,7 @@
170
173
  "@types/nconf": "^0.10.5",
171
174
  "@types/node": "^25.0.9",
172
175
  "@types/node-emoji": "^2.1.0",
173
- "@typescript-eslint/eslint-plugin": "^8.53.0",
176
+ "@typescript-eslint/eslint-plugin": "^8.53.1",
174
177
  "@typescript-eslint/parser": "^8.53.0",
175
178
  "@vitest/coverage-v8": "^4.0.6",
176
179
  "commitizen": "^4.3.1",