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":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMzC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAY,MAAM,WAAW,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAClD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACxD,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,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aAAa,CAAC,MAAM;QAChC,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,GAAG,CAAC,CAAC;IAChE,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,IAAI,KAAK,GAA2B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,OAAO,KAAK,EAAE,CAAC;QACb,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACpB,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,aAAqB;IACjE,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM;QAChC,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,GAAG,CAAC,CAAC;IAChE,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,IAAI,KAAK,GAA2B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,OAAO,KAAK,EAAE,CAAC;QACb,KAAK,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAU;IACjC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC","sourcesContent":["import { execSync } from 'node:child_process';\nimport { accessSync, readFileSync } from 'node:fs';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { Context } from '@actions/github/lib/context.js';\nimport type { PackageJson } from 'types-package-json';\n\nimport type Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\nimport { unicodeWordMatch } from './unicode-word-match.js';\nimport { notEmpty, Nullable } from './util.js';\n\nexport const __filename = fileURLToPath(import.meta.url);\nexport const __dirname = path.dirname(__filename);\n/**\n * Returns the input value if it is not empty, otherwise returns undefined.\n * @param value - The input value to check.\n * @returns The input value if it is not empty, otherwise undefined.\n */\nexport function undefinedOnEmpty(value: string | undefined): string | undefined {\n if (!value || value === '') {\n return undefined;\n }\n return value;\n}\n\n/**\n * Returns the basename of the given path.\n * @param pathStr - The path to extract the basename from.\n * @returns The basename of the path.\n */\nexport function basename(pathStr: string): string | undefined {\n if (!pathStr) return undefined;\n const log = new LogTask('basename');\n const result = path.basename(pathStr);\n log.debug(`Basename passed ${pathStr} and returns ${result}`);\n return result;\n}\n/**\n * Removes the \"refs/heads/\" or \"refs/tags/\" prefix from the given path.\n *\n * @param pathStr - The path to remove the prefix from\n * @returns The path without the prefix, or null if path is empty\n */\nexport function stripRefs(pathStr: string): string | null {\n if (!pathStr) return null;\n const log = new LogTask('stripRefs');\n const result = pathStr.replace('refs/heads/', '').replace('refs/tags/', '');\n log.debug(`stripRefs passed ${pathStr} and returns ${result}`);\n return result;\n}\n\n/**\n * Converts the given text to title case.\n * @param text - The text to convert.\n * @returns The text converted to title case.\n * @throws {TypeError} If the input is not a string.\n */\nexport function titlecase(text: string): string | undefined {\n if (!text) return undefined;\n if (typeof text !== 'string') {\n throw new TypeError(`Invalid argument type provided to titlecase(): ${typeof text}`);\n }\n return text.replaceAll(unicodeWordMatch, (txt) =>\n txt[0] ? txt[0].toUpperCase() + txt.slice(1).toLowerCase() : txt,\n );\n}\n\n/**\n * Parses the given text and converts it to title case, replacing underscores and dashes with spaces.\n * @param text - The text to parse and convert.\n * @returns The parsed text converted to title case.\n */\nexport function prefixParser(text: string | undefined): string | undefined {\n if (!text) return undefined;\n if (typeof text !== 'string') {\n throw new TypeError(`Invalid argument type provided to prefixParser(): ${typeof text}`);\n }\n return titlecase(text.replace(/[_-]+/, ' '));\n}\n\n/**\n * Wraps the given text into multiple lines with a maximum width of 80 characters.\n * @param text - The text to wrap.\n * @param content - The array to store the wrapped lines.\n * @param prepend - The string to prepend to each wrapped line.\n * @returns The array of wrapped lines.\n */\nexport function wrapText(text: string | undefined, content: string[], prepend = ''): string[] {\n // Constrain the width of the description\n if (!text) return content;\n const width = 80;\n\n let description = text\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\n while (description) {\n // Longer than width? Find a space to break apart\n let segment: string;\n if (description.length > width) {\n segment = description.slice(0, Math.max(0, width + 1));\n while (!segment.endsWith(' ') && !segment.endsWith('\\n') && segment) {\n segment = segment.slice(0, Math.max(0, segment.length - 1));\n }\n\n // Trimmed too much?\n if (segment.length < width * 0.67) {\n segment = description;\n }\n } else {\n segment = description;\n }\n\n // Check for newline\n const newlineIndex = segment.indexOf('\\n');\n if (newlineIndex >= 0) {\n segment = segment.slice(0, Math.max(0, newlineIndex + 1));\n }\n content.push(`${prepend}${segment}`.trimEnd());\n // Remaining\n description = description.slice(segment.length);\n }\n return content;\n}\n\n/**\n * Represents a repository with owner and repo properties.\n */\nexport interface Repo {\n owner: string;\n repo: string;\n}\n\nexport function readFile(filename: string): string {\n try {\n return readFileSync(filename, 'utf8');\n } catch (error) {\n throw new Error(`Cannot read file ${filename}: ${error}`);\n }\n}\n\nexport function repoObjFromRepoName(\n repository: Nullable<string>,\n log: LogTask,\n from?: string,\n): Nullable<Repo> {\n if (notEmpty(repository)) {\n const [owner, repo] = repository.split('/');\n if (owner && repo) {\n log.debug(`repoObjFromRepoName using ${from} and returns ${JSON.stringify({ owner, repo })}`);\n return { owner, repo };\n }\n }\n return undefined;\n}\nexport const remoteGitUrlPattern = /url( )?=( )?.*github\\.com[/:](?<owner>.*)\\/(?<repo>.*)\\.git/;\n/**\n * Finds the repository information from the input, context, environment variables, or git configuration.\n * @param inputRepo - The input repository string.\n * @param context - The GitHub context object.\n * @returns The repository information (owner and repo) or null if not found.\n */\nexport function repositoryFinder(\n inputRepo: Nullable<string>,\n context: Nullable<Context>,\n): Repo | null {\n const log = new LogTask('repositoryFinder');\n /**\n * Attempt to get git user and repo from input\n */\n const repoObj = repoObjFromRepoName(inputRepo, log, 'inputRepo');\n\n if (repoObj) {\n return repoObj;\n }\n\n /**\n * Attempt to get git user and repo from GitHub context,\n * which includes checking for GITHUB_REPOSITORY environment variable\n */\n if (context) {\n try {\n const result = { ...context.repo };\n log.debug(`repositoryFinder using GitHub context and returns ${JSON.stringify(result)}`);\n return result;\n } catch (error) {\n log.debug(`repositoryFinder using GitHub context gives error ${JSON.stringify(error)}`);\n }\n }\n\n /**\n * Attempt to get git user and repo from .git/config\n */\n try {\n const fileContent = readFile('.git/config');\n log.debug(`loading .git/config:\\n***\\n${fileContent}\\n***`);\n const results = remoteGitUrlPattern.exec(fileContent);\n if (results?.groups?.owner && results?.groups?.repo) {\n log.debug(\n `repositoryFinder using '.git/config' and returns ${JSON.stringify(results.groups)}`,\n );\n return {\n owner: results.groups.owner,\n repo: results.groups.repo,\n };\n }\n } catch (error) {\n // can't find it\n log.error(`Couldn't retrieve owner or repo in .git/config file: ${error}`);\n }\n throw new Error('No owner or repo found');\n}\n\n/**\n * Returns the default branch of the git repository.\n * @returns The default branch.\n */\n/**\n * Gets the default branch for the Git repository.\n *\n * @returns The name of the default branch.\n */\nexport function getDefaultGitBranch(): string {\n let result: Buffer | undefined;\n try {\n // Run git command to get default branch\n result = execSync('git symbolic-ref HEAD | sed s@^refs/heads/@@');\n } catch (error) {\n // If command fails, try alternative for MacOS\n if (error) {\n try {\n result = execSync(\n \"git remote set-head origin -a;git remote show origin | head 50 sed -n 's/^.*default branch \\\\(.*\\\\)/\\\\1/p'\",\n );\n } catch {\n result = execSync(\n \"git remote set-head origin -a;git remote show origin | sed -n 's/^s*HEAD branch: \\\\(.*\\\\)/\\\\1/p'\",\n );\n }\n }\n }\n return result?.toString().trim() ?? '';\n}\n\n/**\n * Formats the given value as a column header.\n * @param value - The value to format.\n * @returns The formatted column header.\n */\nexport function columnHeader(value: string): string {\n if (!value) {\n return '';\n }\n let text: string = value.replaceAll(/\\*\\*(.*?)\\*\\*/g, '$1');\n\n // Remove italic formatting: *italic*\n text = text.replaceAll(/\\*(.*?)\\*/g, '$1');\n\n // Remove strikethrough formatting: ~~strikethrough~~\n text = text.replaceAll(/~~(.*?)~~/g, '$1');\n\n const normalisedHeader = titlecase(text.trim());\n if (normalisedHeader) {\n return `${normalisedHeader}`;\n }\n return '';\n}\n/**\n * Formats the given value as a row header in HTML.\n *\n * Removes formatting from the string and converts it to code style.\n *\n * @param value - The string to format as a header\n * @returns The formatted row header string\n */\nexport function rowHeader(value: string): string {\n if (!value) {\n return '';\n }\n\n let text = value;\n\n // Remove bold formatting\n text = text.replaceAll(/\\*\\*(.*?)\\*\\*/g, '$1');\n\n // Remove italic formatting: *italic*\n text = text.replaceAll(/\\*(.*?)\\*/g, '$1');\n\n // Remove strikethrough formatting: ~~strikethrough~~\n text = text.replaceAll(/~~(.*?)~~/g, '$1');\n\n // Normalize spacing\n text = text.trim();\n\n // Add code formatting\n return `<code>${text}</code>`;\n}\n\nexport function getCurrentVersionString(inputs: Inputs): string {\n let versionString = '';\n const log = new LogTask('getCurrentVersionString');\n if (inputs.config.get('versioning:enabled')) {\n log.debug('version string in generated example is enabled');\n const oRide = inputs.config.get('versioning:override') as string;\n let packageVersion = process.env.npm_package_version;\n log.debug(`version string in env:npm_package_version is ${packageVersion ?? 'not found'}`);\n if (!packageVersion) {\n log.debug('version string in env:npm_package_version is not found, trying to use git');\n try {\n accessSync('package.json');\n const packageData: Partial<PackageJson> = JSON.parse(readFileSync('package.json', 'utf8'));\n packageVersion = packageData.version;\n } catch (error) {\n log.debug(`package.json not found. ${error}`);\n }\n log.debug(`version string in package.json:version is ${packageVersion ?? 'not found'}`);\n }\n\n versionString = oRide && oRide.length > 0 ? oRide : (packageVersion ?? '0.0.0');\n\n if (\n versionString &&\n !versionString.startsWith(inputs.config.get('versioning:prefix') as string)\n ) {\n versionString = `${inputs.config.get('versioning:prefix') as string}${versionString}`;\n }\n } else {\n versionString = inputs.config.get('versioning:branch') as string;\n }\n log.debug(`version to use in generated example is ${versionString}`);\n return versionString;\n}\n\nexport function indexOfRegex(str: string, providedRegex: RegExp): number {\n const regex = providedRegex.global\n ? providedRegex\n : new RegExp(providedRegex.source, `${providedRegex.flags}g`);\n let index = -1;\n let match: RegExpExecArray | null = regex.exec(str);\n while (match) {\n index = match.index;\n match = regex.exec(str);\n }\n return index;\n}\n\nexport function lastIndexOfRegex(str: string, providedRegex: RegExp): number {\n const regex = providedRegex.global\n ? providedRegex\n : new RegExp(providedRegex.source, `${providedRegex.flags}g`);\n let index = -1;\n let match: RegExpExecArray | null = regex.exec(str);\n while (match) {\n index = match.index + match[0].length;\n match = regex.exec(str);\n }\n return index;\n}\n\nexport function isObject(value: any): value is object {\n const type = typeof value;\n return type === 'object' && !!value;\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAMlC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAiB,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACxD,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC3B,OAAO,SAAS,C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AC;AACf,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC","sourcesContent":["import { execSync } from 'node:child_process';\nimport { accessSync, readFileSync } from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { Context } from '@actions/github/lib/context.js';\nimport type { PackageJson } from 'types-package-json';\n\nimport type Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\nimport { unicodeWordMatch } from './unicode-word-match.js';\nimport { type Nullable, notEmpty } from './util.js';\n/**\n * Returns the input value if it is not empty, otherwise returns undefined.\n * @param value - The input value to check.\n * @returns The input value if it is not empty, otherwise undefined.\n */\nexport function undefinedOnEmpty(value: string | undefined): string | undefined {\n if (!value || value === '') {\n return undefined;\n }\n return value;\n}\n\n/**\n * Returns the basename of the given path.\n * @param pathStr - The path to extract the basename from.\n * @returns The basename of the path.\n */\nexport function basename(pathStr: string): string | undefined {\n if (!pathStr) {\n return undefined;\n }\n const log = new LogTask('basename');\n const result = path.basename(pathStr);\n log.debug(`Basename passed ${pathStr} and returns ${result}`);\n return result;\n}\n/**\n * Removes the \"refs/heads/\" or \"refs/tags/\" prefix from the given path.\n *\n * @param pathStr - The path to remove the prefix from\n * @returns The path without the prefix, or null if path is empty\n */\nexport function stripRefs(pathStr: string): string | null {\n if (!pathStr) {\n return null;\n }\n const log = new LogTask('stripRefs');\n const result = pathStr.replace('refs/heads/', '').replace('refs/tags/', '');\n log.debug(`stripRefs passed ${pathStr} and returns ${result}`);\n return result;\n}\n\n/**\n * Converts the given text to title case.\n * @param text - The text to convert.\n * @returns The text converted to title case.\n * @throws {TypeError} If the input is not a string.\n */\nexport function titlecase(text: string): string | undefined {\n if (!text) {\n return undefined;\n }\n if (typeof text !== 'string') {\n throw new TypeError(`Invalid argument type provided to titlecase(): ${typeof text}`);\n }\n return text.replaceAll(unicodeWordMatch, (txt) =>\n txt[0] ? txt[0].toUpperCase() + txt.slice(1).toLowerCase() : txt,\n );\n}\n\n/**\n * Parses the given text and converts it to title case, replacing underscores and dashes with spaces.\n * @param text - The text to parse and convert.\n * @returns The parsed text converted to title case.\n */\nexport function prefixParser(text: string | undefined): string | undefined {\n if (!text) {\n return undefined;\n }\n if (typeof text !== 'string') {\n throw new TypeError(`Invalid argument type provided to prefixParser(): ${typeof text}`);\n }\n return titlecase(text.replace(/[_-]+/, ' '));\n}\n\n/**\n * Wraps the given text into multiple lines with a maximum width of 80 characters.\n * @param text - The text to wrap.\n * @param content - The array to store the wrapped lines.\n * @param prepend - The string to prepend to each wrapped line.\n * @returns The array of wrapped lines.\n */\nexport function wrapText(\n text: string | undefined,\n content: string[],\n prepend: string = '',\n): string[] {\n // Constrain the width of the description\n if (!text) {\n return content;\n }\n const width = 80;\n\n let description = text\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\n while (description) {\n // Longer than width? Find a space to break apart\n let segment: string;\n if (description.length > width) {\n segment = description.slice(0, Math.max(0, width + 1));\n while (!segment.endsWith(' ') && !segment.endsWith('\\n') && segment) {\n segment = segment.slice(0, Math.max(0, segment.length - 1));\n }\n\n // Trimmed too much?\n if (segment.length < width * 0.67) {\n segment = description;\n }\n } else {\n segment = description;\n }\n\n // Check for newline\n const newlineIndex = segment.indexOf('\\n');\n if (newlineIndex >= 0) {\n segment = segment.slice(0, Math.max(0, newlineIndex + 1));\n }\n content.push(`${prepend}${segment}`.trimEnd());\n // Remaining\n description = description.slice(segment.length);\n }\n return content;\n}\n\n/**\n * Represents a repository with owner and repo properties.\n */\nexport interface Repo {\n owner: string;\n repo: string;\n}\n\nexport function readFile(filename: string): string {\n try {\n return readFileSync(filename, 'utf8');\n } catch (error) {\n throw new Error(`Cannot read file ${filename}: ${error}`);\n }\n}\n\nexport function repoObjFromRepoName(\n repository: Nullable<string>,\n log: LogTask,\n from?: string,\n): Nullable<Repo> {\n if (notEmpty(repository)) {\n const [owner, repo] = repository.split('/');\n if (owner && repo) {\n log.debug(`repoObjFromRepoName using ${from} and returns ${JSON.stringify({ owner, repo })}`);\n return { owner, repo };\n }\n }\n return undefined;\n}\n// Pattern to match GitHub remote URLs in .git/config\n// Handles both HTTPS (github.com/) and SSH (github.com:) formats\n// Captures the repo name with or without .git suffix - suffix is stripped in code\nexport const remoteGitUrlPattern = /url\\s*=\\s*.*github\\.com[/:](?<owner>[^/\\s]+)\\/(?<repo>[^\\s]+)/;\n/**\n * Finds the repository information from the input, context, environment variables, or git configuration.\n * @param inputRepo - The input repository string.\n * @param context - The GitHub context object.\n * @param baseDir - Optional base directory to look for .git/config (defaults to CWD).\n * @returns The repository information (owner and repo) or null if not found.\n */\nexport function repositoryFinder(\n inputRepo: Nullable<string>,\n context: Nullable<Context>,\n baseDir?: string,\n): Repo | null {\n const log = new LogTask('repositoryFinder');\n /**\n * Attempt to get git user and repo from input\n */\n const repoObj = repoObjFromRepoName(inputRepo, log, 'inputRepo');\n\n if (repoObj) {\n return repoObj;\n }\n\n /**\n * When baseDir is provided, prioritize .git/config from that directory\n * This is critical for external repos where GITHUB_REPOSITORY points to\n * the workflow repo, not the target repo being documented\n */\n if (baseDir) {\n try {\n const gitConfigPath = path.join(baseDir, '.git', 'config');\n const fileContent = readFile(gitConfigPath);\n log.debug(`Reading git config from: ${gitConfigPath}`);\n const results = remoteGitUrlPattern.exec(fileContent);\n if (results?.groups?.owner && results?.groups?.repo) {\n // Strip .git suffix if present (actions/checkout may or may not include it)\n const repo = results.groups.repo.replace(/\\.git$/, '');\n log.debug(\n `repositoryFinder using '${gitConfigPath}' and returns ${JSON.stringify({ owner: results.groups.owner, repo })}`,\n );\n return {\n owner: results.groups.owner,\n repo,\n };\n } else {\n log.debug(`No remote URL found in ${gitConfigPath}`);\n }\n } catch (error) {\n log.debug(`Couldn't read .git/config from baseDir ${baseDir}: ${error}`);\n // Fall through to other methods\n }\n }\n\n /**\n * Attempt to get git user and repo from GitHub context,\n * which includes checking for GITHUB_REPOSITORY environment variable\n */\n if (context) {\n try {\n const result = { ...context.repo };\n if (result.owner && result.repo) {\n log.debug(`repositoryFinder using GitHub context and returns ${JSON.stringify(result)}`);\n return result;\n }\n } catch (error) {\n log.debug(`repositoryFinder using GitHub context gives error ${JSON.stringify(error)}`);\n }\n }\n\n /**\n * Fallback: Try to parse GITHUB_REPOSITORY environment variable directly\n * This handles cases where the Context class doesn't pick up the value\n */\n const githubRepo = process.env.GITHUB_REPOSITORY;\n if (githubRepo) {\n const repoFromEnv = repoObjFromRepoName(githubRepo, log, 'GITHUB_REPOSITORY env');\n if (repoFromEnv) {\n return repoFromEnv;\n }\n }\n\n /**\n * Last resort: Attempt to get git user and repo from .git/config in CWD\n */\n try {\n const fileContent = readFile('.git/config');\n log.debug('Reading git config from: .git/config');\n const results = remoteGitUrlPattern.exec(fileContent);\n if (results?.groups?.owner && results?.groups?.repo) {\n // Strip .git suffix if present\n const repo = results.groups.repo.replace(/\\.git$/, '');\n log.debug(\n `repositoryFinder using '.git/config' and returns ${JSON.stringify({ owner: results.groups.owner, repo })}`,\n );\n return {\n owner: results.groups.owner,\n repo,\n };\n } else {\n log.debug('No remote URL found in .git/config');\n }\n } catch (error) {\n // can't find it\n log.error(`Couldn't retrieve owner or repo in .git/config file: ${error}`);\n }\n throw new Error('No owner or repo found');\n}\n\n/**\n * Returns the default branch of the git repository.\n * @returns The default branch.\n */\n/**\n * Gets the default branch for the Git repository.\n *\n * @returns The name of the default branch.\n */\nexport function getDefaultGitBranch(): string {\n let result: Buffer | undefined;\n try {\n // Run git command to get default branch\n result = execSync('git symbolic-ref HEAD | sed s@^refs/heads/@@');\n } catch (error) {\n // If command fails, try alternative for MacOS\n if (error) {\n try {\n result = execSync(\n \"git remote set-head origin -a;git remote show origin | head 50 sed -n 's/^.*default branch \\\\(.*\\\\)/\\\\1/p'\",\n );\n } catch {\n result = execSync(\n \"git remote set-head origin -a;git remote show origin | sed -n 's/^s*HEAD branch: \\\\(.*\\\\)/\\\\1/p'\",\n );\n }\n }\n }\n return result?.toString().trim() ?? '';\n}\n\n/**\n * Formats the given value as a column header.\n * @param value - The value to format.\n * @returns The formatted column header.\n */\nexport function columnHeader(value: string): string {\n if (!value) {\n return '';\n }\n let text: string = value.replaceAll(/\\*\\*(.*?)\\*\\*/g, '$1');\n\n // Remove italic formatting: *italic*\n text = text.replaceAll(/\\*(.*?)\\*/g, '$1');\n\n // Remove strikethrough formatting: ~~strikethrough~~\n text = text.replaceAll(/~~(.*?)~~/g, '$1');\n\n const normalisedHeader = titlecase(text.trim());\n if (normalisedHeader) {\n return `${normalisedHeader}`;\n }\n return '';\n}\n/**\n * Formats the given value as a row header in HTML.\n *\n * Removes formatting from the string and converts it to code style.\n *\n * @param value - The string to format as a header\n * @returns The formatted row header string\n */\nexport function rowHeader(value: string): string {\n if (!value) {\n return '';\n }\n\n let text = value;\n\n // Remove bold formatting\n text = text.replaceAll(/\\*\\*(.*?)\\*\\*/g, '$1');\n\n // Remove italic formatting: *italic*\n text = text.replaceAll(/\\*(.*?)\\*/g, '$1');\n\n // Remove strikethrough formatting: ~~strikethrough~~\n text = text.replaceAll(/~~(.*?)~~/g, '$1');\n\n // Normalize spacing\n text = text.trim();\n\n // Add code formatting\n return `<code>${text}</code>`;\n}\n\n/**\n * Gets the version from git tags.\n */\nfunction getVersionFromGitTag(actionDir: string, log: LogTask): string | undefined {\n try {\n const gitVersion = execSync(\n 'git describe --tags --abbrev=0 2>/dev/null || git tag -l \"v*\" --sort=-v:refname | head -1',\n {\n cwd: actionDir,\n encoding: 'utf8',\n },\n ).trim();\n if (gitVersion) {\n // Remove 'v' prefix if present for consistency, we'll add it back with the configured prefix\n const version = gitVersion.replace(/^v/, '');\n log.debug(`version from git tags: ${version}`);\n return version;\n }\n } catch {\n log.debug(`Could not get version from git tags in ${actionDir}`);\n }\n return undefined;\n}\n\n/**\n * Gets the current git branch name.\n */\nfunction getVersionFromGitBranch(actionDir: string, log: LogTask): string | undefined {\n try {\n const branch = execSync('git rev-parse --abbrev-ref HEAD', {\n cwd: actionDir,\n encoding: 'utf8',\n }).trim();\n if (branch && branch !== 'HEAD') {\n log.debug(`version from git branch: ${branch}`);\n return branch;\n }\n } catch {\n log.debug(`Could not get branch name in ${actionDir}`);\n }\n return undefined;\n}\n\n/**\n * Gets the current git commit SHA (short form).\n */\nfunction getVersionFromGitSha(actionDir: string, log: LogTask): string | undefined {\n try {\n const sha = execSync('git rev-parse --short HEAD', {\n cwd: actionDir,\n encoding: 'utf8',\n }).trim();\n if (sha) {\n log.debug(`version from git sha: ${sha}`);\n return sha;\n }\n } catch {\n log.debug(`Could not get commit SHA in ${actionDir}`);\n }\n return undefined;\n}\n\n/**\n * Gets the version from package.json.\n */\nfunction getVersionFromPackageJson(actionDir: string, log: LogTask): string | undefined {\n const packageJsonPath = path.join(actionDir, 'package.json');\n log.debug(`Looking for package.json at: ${packageJsonPath}`);\n try {\n accessSync(packageJsonPath);\n const packageData: Partial<PackageJson> = JSON.parse(readFileSync(packageJsonPath, 'utf8'));\n const version = packageData.version;\n log.debug(`version from package.json: ${version ?? 'not found'}`);\n return version;\n } catch {\n log.debug(`package.json not found at ${packageJsonPath}`);\n }\n return undefined;\n}\n\nexport function getCurrentVersionString(inputs: Inputs): string {\n let versionString = '';\n const log = new LogTask('getCurrentVersionString');\n // Default to enabled if not explicitly set (matches action.yml default of \"true\")\n const versioningEnabled = inputs.config.get('versioning:enabled');\n const isVersioningEnabled =\n versioningEnabled === undefined || versioningEnabled === true || versioningEnabled === 'true';\n\n if (isVersioningEnabled) {\n log.debug('version string in generated example is enabled');\n const override = inputs.config.get('versioning:override') as string;\n const versionSource = (inputs.config.get('versioning:source') as string) ?? 'git-tag';\n const actionDir = path.dirname(inputs.action.path);\n\n log.debug(`version source: ${versionSource}`);\n\n let detectedVersion: string | undefined;\n\n // If override is set and we're in explicit mode, use it directly\n if (versionSource === 'explicit') {\n if (override && override.length > 0) {\n detectedVersion = override;\n log.debug(`using explicit version override: ${detectedVersion}`);\n } else {\n log.debug('explicit mode but no version_override set, falling back to 0.0.0');\n detectedVersion = '0.0.0';\n }\n } else {\n // Get version based on selected source\n switch (versionSource) {\n case 'git-branch':\n detectedVersion = getVersionFromGitBranch(actionDir, log);\n break;\n case 'git-sha':\n detectedVersion = getVersionFromGitSha(actionDir, log);\n break;\n case 'package-json':\n detectedVersion = getVersionFromPackageJson(actionDir, log);\n break;\n case 'git-tag':\n default:\n // For git-tag (default), use the legacy fallback behavior\n detectedVersion = getVersionFromGitTag(actionDir, log);\n if (!detectedVersion) {\n detectedVersion = getVersionFromPackageJson(actionDir, log);\n }\n if (!detectedVersion) {\n detectedVersion = process.env.npm_package_version;\n log.debug(`Falling back to env:npm_package_version: ${detectedVersion ?? 'not found'}`);\n }\n break;\n }\n\n // Override takes precedence if set (except for explicit mode which is handled above)\n if (override && override.length > 0) {\n detectedVersion = override;\n log.debug(`using version override: ${detectedVersion}`);\n }\n }\n\n versionString = detectedVersion ?? '0.0.0';\n\n // Get prefix, defaulting to 'v' if not set\n // For git-branch and git-sha, we typically don't want a prefix\n const prefix = (inputs.config.get('versioning:prefix') as string) ?? 'v';\n const shouldApplyPrefix = versionSource !== 'git-branch' && versionSource !== 'git-sha';\n\n if (shouldApplyPrefix && versionString && !versionString.startsWith(prefix)) {\n versionString = `${prefix}${versionString}`;\n }\n } else {\n versionString = inputs.config.get('versioning:branch') as string;\n }\n log.debug(`version to use in generated example is ${versionString}`);\n return versionString;\n}\n\nexport function indexOfRegex(str: string, providedRegex: RegExp): number {\n const regex = providedRegex.global\n ? providedRegex\n : new RegExp(providedRegex.source, `${providedRegex.flags}g`);\n let index = -1;\n let match: RegExpExecArray | null = regex.exec(str);\n while (match) {\n index = match.index;\n match = regex.exec(str);\n }\n return index;\n}\n\nexport function lastIndexOfRegex(str: string, providedRegex: RegExp): number {\n const regex = providedRegex.global\n ? providedRegex\n : new RegExp(providedRegex.source, `${providedRegex.flags}g`);\n let index = -1;\n let match: RegExpExecArray | null = regex.exec(str);\n while (match) {\n index = match.index + match[0].length;\n match = regex.exec(str);\n }\n return index;\n}\n\nexport function isObject(value: unknown): value is object {\n const type = typeof value;\n return type === 'object' && !!value;\n}\n"]}
@@ -1,19 +1,11 @@
1
1
  import { Context } from '@actions/github/lib/context.js';
2
2
  import nconf from 'nconf';
3
- import Action, { Input } from './Action.js';
4
- import { ReadmeSection } from './constants.js';
3
+ import Action, { type Input } from './Action.js';
4
+ import { type ReadmeSection } from './constants.js';
5
5
  import LogTask from './logtask/index.js';
6
6
  import ReadmeEditor from './readme-editor.js';
7
7
  declare const Provider: typeof nconf.Provider;
8
8
  type IOptions = nconf.IOptions;
9
- /**
10
- * Get the filename from the import.meta.url
11
- */
12
- export declare const __filename: string;
13
- /**
14
- * Get the directory name from the filename
15
- */
16
- export declare const __dirname: string;
17
9
  /**
18
10
  * Change working directory to output of workingDirectory()
19
11
  */
@@ -37,7 +29,7 @@ type KVPairType = {
37
29
  * Type alias for Provider instance
38
30
  */
39
31
  type ProviderInstance = InstanceType<typeof Provider>;
40
- export declare function transformGitHubInputsToArgv(log: LogTask, config: ProviderInstance, obj: KVPairType): undefined | KVPairType;
32
+ export declare function transformGitHubInputsToArgv(log: LogTask, _config: ProviderInstance, obj: KVPairType): undefined | KVPairType;
41
33
  /**
42
34
  * Sets config value from action file default
43
35
  *
@@ -6,25 +6,16 @@
6
6
  */
7
7
  import * as fs from 'node:fs';
8
8
  import * as path from 'node:path';
9
- import { fileURLToPath } from 'node:url';
10
9
  import * as core from '@actions/core';
11
10
  import { Context } from '@actions/github/lib/context.js';
12
11
  import nconf from 'nconf';
13
12
  import YAML from 'yaml';
14
13
  import Action from './Action.js';
15
- import { configFileName, ConfigKeys, README_SECTIONS } from './constants.js';
14
+ import { ConfigKeys, configFileName, README_SECTIONS } from './constants.js';
16
15
  import { repositoryFinder } from './helpers.js';
17
16
  import LogTask from './logtask/index.js';
18
17
  import ReadmeEditor from './readme-editor.js';
19
18
  const { Provider } = nconf;
20
- /**
21
- * Get the filename from the import.meta.url
22
- */
23
- export const __filename = fileURLToPath(import.meta.url);
24
- /**
25
- * Get the directory name from the filename
26
- */
27
- export const __dirname = path.dirname(__filename);
28
19
  /**
29
20
  * Change working directory to output of workingDirectory()
30
21
  */
@@ -174,6 +165,19 @@ argvOptions[ConfigKeys.VersioningBranch] = {
174
165
  describe: 'If versioning is disabled show this branch instead',
175
166
  parseValues: true,
176
167
  };
168
+ /**
169
+ * Versioning source option configuration.
170
+ * @property {string | string[]} alias - Alias(es) for the version_source option.
171
+ * @property {string} describe - Description for the version_source option.
172
+ * @property {boolean} parseValues - Specifies whether to parse values for the version_source option.
173
+ * @property {string} type - Type of the version_source option.
174
+ */
175
+ argvOptions[ConfigKeys.VersioningSource] = {
176
+ alias: ['version-source', 'version_source', 'versioning_source'],
177
+ describe: 'How to detect the action version (git-tag, git-branch, git-sha, package-json, explicit)',
178
+ parseValues: true,
179
+ type: 'string',
180
+ };
177
181
  /**
178
182
  * Include GitHub version badge option configuration.
179
183
  * @property {string | string[]} alias - Alias(es) for the include_github_version_badge option.
@@ -237,18 +241,24 @@ const ConfigKeysInputsMap = {
237
241
  version_prefix: ConfigKeys.VersioningPrefix,
238
242
  versioning_default_branch: ConfigKeys.VersioningBranch,
239
243
  version_override: ConfigKeys.VersioningOverride,
244
+ version_source: ConfigKeys.VersioningSource,
240
245
  include_github_version_badge: ConfigKeys.IncludeGithubVersionBadge,
241
246
  owner: ConfigKeys.Owner,
242
247
  repo: ConfigKeys.Repo,
243
248
  title_prefix: ConfigKeys.TitlePrefix,
244
249
  pretty: ConfigKeys.Prettier,
245
250
  };
246
- export function transformGitHubInputsToArgv(log, config, obj) {
251
+ export function transformGitHubInputsToArgv(log, _config, obj) {
247
252
  /** The obj.key is always in lowercase, but it checks for it without case sensitivity */
248
253
  if (/^(INPUT|input)_[A-Z_a-z]\w*$/.test(obj.key)) {
249
254
  log.debug(`Parsing input: ${obj.key} with ith value: ${obj.value}`);
250
255
  const keyParsed = obj.key.replace(/^(INPUT|input)_/, '').toLocaleLowerCase();
251
256
  const key = ConfigKeysInputsMap[keyParsed] || keyParsed;
257
+ // Skip empty values for owner/repo to allow fallback detection from .git/config or GITHUB_REPOSITORY
258
+ if ((key === 'owner' || key === 'repo') && (!obj.value || obj.value === '')) {
259
+ log.debug(`Ignoring empty ${key} input to allow auto-detection`);
260
+ return undefined;
261
+ }
252
262
  log.debug(`New input is ${key} with the value ${obj.value}`);
253
263
  return { key, value: obj.value };
254
264
  }
@@ -281,8 +291,8 @@ export function collectAllDefaultValuesFromAction(log, providedMetaActionPath, p
281
291
  log.debug('Collecting default values from action.yml');
282
292
  // This loads the defaults from THIS action's own action.yml file (github-action-readme-generator's action.yml)
283
293
  // NOT the user's action.yml file (which is loaded separately via the 'action' input parameter)
284
- // Therefore, we use __dirname to find this package's action.yml regardless of where it's installed
285
- const thisActionPath = path.join(__dirname, providedMetaActionPath ?? metaActionPath);
294
+ // Therefore, we use import.meta.dirname to find this package's action.yml regardless of where it's installed
295
+ const thisActionPath = path.join(import.meta.dirname, providedMetaActionPath ?? metaActionPath);
286
296
  try {
287
297
  const defaultValues = {};
288
298
  const thisAction = new Action(thisActionPath);
@@ -352,7 +362,11 @@ export function loadDefaultConfig(log, config, providedContext) {
352
362
  const repoFromConfig = config.get('repo');
353
363
  const ownerInput = ownerFromConfig ?? process.env.INPUT_OWNER ?? '';
354
364
  const repoInput = repoFromConfig ?? process.env.INPUT_REPO ?? '';
355
- const repositoryDetail = repositoryFinder(`${ownerInput}/${repoInput}`, context);
365
+ // Get the action path to derive the target repo directory for .git/config lookup
366
+ const actionPath = config.get(ConfigKeys.pathsAction);
367
+ const actionDir = actionPath ? path.dirname(path.resolve(actionPath)) : undefined;
368
+ log.debug(`Action directory for repository detection: ${actionDir ?? 'not specified'}`);
369
+ const repositoryDetail = repositoryFinder(`${ownerInput}/${repoInput}`, context, actionDir);
356
370
  log.debug(`repositoryDetail: ${repositoryDetail}`);
357
371
  // Apply the default values from the action.yml file
358
372
  return config.defaults({
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.js","sourceRoot":"","sources":["../../src/inputs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAiB,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAiB,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AAG3B;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAElD;;GAEG;AACH,qCAAqC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAUjD;;GAEG;AACH,MAAM,WAAW,GAAyB,EAAE,CAAC;AAE7C;;;;;;GAMG;AACH,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG;IAC7B,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,uBAAuB,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,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAW,CAAC,CAAC;QAC7F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF;;WAEG;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD;;WAEG;QACH,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE5D;;WAEG;QACH,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS;QACP,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;gBAC3B,WAAW;YACb,CAAC;QACH,CAAC;QACD,kEAAkE;QAClE,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * This class handles input configuration and manipulation.\n * It imports various modules and packages for file operations, configuration parsing, and logging.\n * The class has methods for initializing the input configuration, setting default values, and converting the configuration to a string.\n * It also has properties for storing the configuration values, sections, readme path, action instance, and readme editor instance.\n */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport * as core from '@actions/core';\nimport { Context } from '@actions/github/lib/context.js';\nimport nconf from 'nconf';\nimport YAML from 'yaml';\n\nimport Action, { Input } from './Action.js';\nimport { configFileName, ConfigKeys, README_SECTIONS, ReadmeSection } from './constants.js';\nimport { repositoryFinder } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport ReadmeEditor from './readme-editor.js';\n\nconst { Provider } = nconf;\ntype IOptions = nconf.IOptions;\n\n/**\n * Get the filename from the import.meta.url\n */\nexport const __filename = fileURLToPath(import.meta.url);\n\n/**\n * Get the directory name from the filename\n */\nexport const __dirname = path.dirname(__filename);\n\n/**\n * Change working directory to output of workingDirectory()\n */\n// process.chdir(workingDirectory());\nexport const metaActionPath = '../../action.yml';\n\nexport type ArgvOptionProperties = {\n [key: string]: {\n alias: string | string[];\n describe: string;\n parseValues?: boolean;\n type?: string;\n };\n};\n/**\n * Represents the command line argument options for the application.\n */\nconst argvOptions: ArgvOptionProperties = {};\n\n/**\n * Save option configuration.\n * @property {string} alias - Alias for the save option.\n * @property {string} describe - Description for the save option.\n * @property {boolean} parseValues - Specifies whether to parse values for the save option.\n * @property {string} type - Type of the save option.\n */\nargvOptions[ConfigKeys.Save] = {\n alias: 'save',\n describe: `Save this config to ${configFileName}`,\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Paths action option configuration.\n * @property {string | string[]} alias - Alias(es) for the pathsAction option.\n * @property {string} type - Type of the pathsAction option.\n * @property {string} describe - Description for the pathsAction option.\n */\nargvOptions[ConfigKeys.pathsAction] = {\n alias: ['pathsAction', 'action'],\n type: 'string',\n describe: 'Path to the action.yml',\n};\n\n/**\n * Paths readme option configuration.\n * @property {string | string[]} alias - Alias(es) for the pathsReadme option.\n * @property {string} type - Type of the pathsReadme option.\n * @property {string} describe - Description for the pathsReadme option.\n */\nargvOptions[ConfigKeys.pathsReadme] = {\n alias: ['pathsReadme', 'readme'],\n type: 'string',\n describe: 'Path to the README file',\n};\n\n/**\n * Branding SVG path option configuration.\n * @property {string} alias - Alias for the svg option.\n * @property {string} type - Type of the svg option.\n * @property {string} describe - Description for the svg option.\n */\nargvOptions[ConfigKeys.BrandingSvgPath] = {\n alias: 'svg',\n type: 'string',\n describe: 'Save and load the branding svg image in the README from this path',\n};\n\n/**\n * Branding as title prefix option configuration.\n * @property {string} alias - Alias for the branding_prefix option.\n * @property {string} type - Type of the branding_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the branding_prefix option.\n * @property {string} describe - Description for the branding_prefix option.\n */\nargvOptions[ConfigKeys.BrandingAsTitlePrefix] = {\n alias: 'branding_prefix',\n type: 'boolean',\n parseValues: true,\n describe: 'Use the branding svg as a prefix for the README title',\n};\n\n/**\n * Owner option configuration.\n * @property {string} alias - Alias for the owner option.\n * @property {string} type - Type of the owner option.\n * @property {string} describe - Description for the owner option.\n */\nargvOptions[ConfigKeys.Owner] = {\n alias: 'owner',\n type: 'string',\n describe: 'The GitHub Action repository owner. i.e: `bitflight-devops`',\n};\n\n/**\n * Repo option configuration.\n * @property {string} alias - Alias for the repo option.\n * @property {string} type - Type of the repo option.\n * @property {string} describe - Description for the repo option.\n */\nargvOptions[ConfigKeys.Repo] = {\n alias: 'repo',\n type: 'string',\n describe: 'The GitHub Action repository name. i.e: `github-action-readme-generator`',\n};\n\n/**\n * Prettier option configuration.\n * @property {string | string[]} alias - Alias(es) for the prettier option.\n * @property {string} type - Type of the prettier option.\n * @property {boolean} parseValues - Specifies whether to parse values for the prettier option.\n * @property {string} describe - Description for the prettier option.\n */\nargvOptions[ConfigKeys.Prettier] = {\n alias: ['pretty', 'prettier'],\n type: 'boolean',\n parseValues: true,\n describe: 'Format the markdown using prettier formatter',\n};\n\n/**\n * Versioning enabled option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_enabled option.\n * @property {string} describe - Description for the versioning_enabled option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_enabled option.\n * @property {string} type - Type of the versioning_enabled option.\n */\nargvOptions[ConfigKeys.VersioningEnabled] = {\n alias: ['versioning', 'versioning_enabled'],\n describe:\n 'Enable the update of the usage version to match the latest version in the package.json file',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Versioning override option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_override option.\n * @property {string} describe - Description for the versioning_override option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_override option.\n */\nargvOptions[ConfigKeys.VersioningOverride] = {\n alias: ['setversion', 'versioning_override', 'version_override'],\n describe: 'Set a specific version to display in the README.md',\n parseValues: true,\n};\n\n/**\n * Versioning prefix option configuration.\n * @property {string | string[]} alias - Alias(es) for the version_prefix option.\n * @property {string} describe - Description for the version_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the version_prefix option.\n */\nargvOptions[ConfigKeys.VersioningPrefix] = {\n alias: ['vp', 'version_prefix'],\n describe: \"Prefix the version with this value (if it isn't already prefixed)\",\n parseValues: true,\n};\n\n/**\n * Versioning branch option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_default_branch option.\n * @property {string} describe - Description for the versioning_default_branch option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_default_branch option.\n */\nargvOptions[ConfigKeys.VersioningBranch] = {\n alias: ['branch', 'versioning_default_branch'],\n describe: 'If versioning is disabled show this branch instead',\n parseValues: true,\n};\n\n/**\n * Include GitHub version badge option configuration.\n * @property {string | string[]} alias - Alias(es) for the include_github_version_badge option.\n * @property {string} describe - Description for the include_github_version_badge option.\n * @property {boolean} parseValues - Specifies whether to parse values for the include_github_version_badge option.\n * @property {string} type - Type of the include_github_version_badge option.\n */\nargvOptions[ConfigKeys.IncludeGithubVersionBadge] = {\n alias: ['version-badge', 'versioning_badge', 'include_github_version_badge'],\n describe: 'Display the current version as a badge',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Title prefix option configuration.\n * @property {string | string[]} alias - Alias(es) for the title_prefix option.\n * @property {string} describe - Description for the title_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the title_prefix option.\n */\nargvOptions[ConfigKeys.TitlePrefix] = {\n alias: ['prefix', 'title_prefix'],\n describe: 'Add a prefix to the README title',\n parseValues: true,\n};\n\n/**\n * Debug Nconf option configuration.\n * @property {string} describe - Description for the debugNconf option.\n * @property {boolean} parseValues - Specifies whether to parse values for the debugNconf option.\n * @property {string} type - Type of the debugNconf option.\n */\nargvOptions[ConfigKeys.DebugNconf] = {\n alias: ['debug_nconf'],\n describe: 'Print out the resolved nconf object with all values',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Debug Config option configuration.\n * @property {string} describe - Description for the debugConfig option.\n * @property {boolean} parseValues - Specifies whether to parse values for the debugConfig option.\n * @property {string} type - Type of the debugConfig option.\n */\nargvOptions[ConfigKeys.DebugConfig] = {\n alias: ['debug_config'],\n describe: 'Print out the resolved nconf object with all values',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Configuration inputs from the github action don't\n * all match the input names when running on cli.\n * This maps the action inputs to the cli.\n */\nconst ConfigKeysInputsMap: Record<string, string> = {\n save: ConfigKeys.Save,\n action: ConfigKeys.pathsAction,\n readme: ConfigKeys.pathsReadme,\n branding_svg_path: ConfigKeys.BrandingSvgPath,\n branding_as_title_prefix: ConfigKeys.BrandingAsTitlePrefix,\n versioning_enabled: ConfigKeys.VersioningEnabled,\n version_prefix: ConfigKeys.VersioningPrefix,\n versioning_default_branch: ConfigKeys.VersioningBranch,\n version_override: ConfigKeys.VersioningOverride,\n include_github_version_badge: ConfigKeys.IncludeGithubVersionBadge,\n owner: ConfigKeys.Owner,\n repo: ConfigKeys.Repo,\n title_prefix: ConfigKeys.TitlePrefix,\n pretty: ConfigKeys.Prettier,\n};\n\n/**\n * Interface for key/value pair object\n */\ntype KVPairType = {\n key: string;\n value: string | undefined;\n};\n\n/**\n * Type alias for Provider instance\n */\ntype ProviderInstance = InstanceType<typeof Provider>;\n\nexport function transformGitHubInputsToArgv(\n log: LogTask,\n config: ProviderInstance,\n obj: KVPairType,\n): undefined | KVPairType {\n /** The obj.key is always in lowercase, but it checks for it without case sensitivity */\n if (/^(INPUT|input)_[A-Z_a-z]\\w*$/.test(obj.key)) {\n log.debug(`Parsing input: ${obj.key} with ith value: ${obj.value}`);\n const keyParsed = obj.key.replace(/^(INPUT|input)_/, '').toLocaleLowerCase();\n const key = ConfigKeysInputsMap[keyParsed] || keyParsed;\n\n log.debug(`New input is ${key} with the value ${obj.value}`);\n return { key, value: obj.value };\n }\n log.debug(`Ignoring input: ${obj.key} with ith value: ${obj.value}`);\n return undefined;\n}\n\n/**\n * Sets config value from action file default\n *\n * @param {Action} actionInstance - The action instance\n * @param {string} inputName - The input name\n * @returns {string | boolean | undefined} The default value\n */\nexport function setConfigValueFromActionFileDefault(\n log: LogTask,\n actionInstance: Action,\n inputName: string,\n): string | boolean | undefined {\n if (ConfigKeysInputsMap[inputName] === undefined) {\n log.error(\n `${inputName} from ${\n actionInstance.path\n } does not match a known input. Known inputs are: ${Object.keys(ConfigKeysInputsMap)}`,\n );\n return;\n }\n\n const configName = ConfigKeysInputsMap[inputName];\n const defaultValue = actionInstance.inputDefault(inputName);\n\n log.debug(`Default Value for action.yml: ${inputName} CLI: ${configName} = ${defaultValue}`);\n\n return defaultValue;\n}\n\n/**\n * Collects all default values from action file\n *\n * @returns {IOptions} The default values object\n */\nexport function collectAllDefaultValuesFromAction(\n log: LogTask,\n providedMetaActionPath?: string,\n providedDefaults: {\n [key: string]: Input;\n } = {},\n): IOptions {\n log.debug('Collecting default values from action.yml');\n // This loads the defaults from THIS action's own action.yml file (github-action-readme-generator's action.yml)\n // NOT the user's action.yml file (which is loaded separately via the 'action' input parameter)\n // Therefore, we use __dirname to find this package's action.yml regardless of where it's installed\n const thisActionPath = path.join(__dirname, providedMetaActionPath ?? metaActionPath);\n try {\n const defaultValues = {} as IOptions;\n const thisAction = new Action(thisActionPath);\n const defaults: {\n [key: string]: Input;\n } = { ...thisAction.inputs, ...providedDefaults };\n // Collect all of the default values from the action.yml file\n if (defaults) {\n for (const key of Object.keys(defaults)) {\n const mappedKey = ConfigKeysInputsMap[key] ?? key;\n defaultValues[mappedKey] = setConfigValueFromActionFileDefault(log, thisAction, key);\n }\n }\n log.debug(JSON.stringify(defaultValues, null, 2));\n return defaultValues;\n } catch (error) {\n // When running as a CLI tool (e.g., via npx or yarn dlx), the tool's own action.yml\n // may not be present in the node_modules. This is expected behavior, as the tool\n // should still work to generate documentation for other actions.\n log.debug(`Could not load defaults from this tool's action.yml at ${thisActionPath}: ${error}`);\n log.debug('Continuing without default values from action.yml');\n return {} as IOptions;\n }\n}\n\n/**\n * Loads the configuration\n *\n * @returns {ProviderInstance} The configuration instance\n */\nexport function loadConfig(\n log: LogTask,\n providedConfig?: ProviderInstance,\n configFilePath?: string,\n): ProviderInstance {\n log.debug('Loading config from env and argv');\n const config = providedConfig ?? new Provider();\n if (process.env.GITHUB_ACTION === 'true') {\n log.info('Running in GitHub action');\n }\n if (configFilePath) {\n if (fs.existsSync(configFilePath)) {\n log.info(`Config file found: ${configFilePath}`);\n config.file(configFilePath);\n } else {\n log.debug(`Config file not found: ${configFilePath}`);\n }\n }\n\n config\n .env({\n lowerCase: true,\n parseValues: true,\n transform: (obj: KVPairType): undefined | KVPairType => {\n return transformGitHubInputsToArgv(log, config, obj);\n },\n })\n .argv(argvOptions);\n\n return config;\n}\n\n/**\n * Loads the default configuration\n *\n * @param {ProviderInstance} config - The config instance\n * @returns {ProviderInstance} The updated config instance\n */\nexport function loadDefaultConfig(\n log: LogTask,\n config: ProviderInstance,\n providedContext?: Context,\n): ProviderInstance {\n log.debug('Loading default config');\n const defaultValues = collectAllDefaultValuesFromAction(log);\n const context = providedContext ?? new Context();\n\n // Get owner/repo from config (which includes CLI args), falling back to env vars for GitHub Actions\n const ownerFromConfig = config.get('owner') as string | undefined;\n const repoFromConfig = config.get('repo') as string | undefined;\n const ownerInput = ownerFromConfig ?? process.env.INPUT_OWNER ?? '';\n const repoInput = repoFromConfig ?? process.env.INPUT_REPO ?? '';\n\n const repositoryDetail = repositoryFinder(`${ownerInput}/${repoInput}`, context);\n log.debug(`repositoryDetail: ${repositoryDetail}`);\n // Apply the default values from the action.yml file\n return config.defaults({\n ...defaultValues,\n owner: repositoryDetail?.owner,\n repo: repositoryDetail?.repo,\n sections: [...README_SECTIONS] as ReadmeSection[],\n });\n}\n\n/**\n * Represents the required inputs for the action.\n */\nconst RequiredInputs = [\n ConfigKeys.pathsAction,\n ConfigKeys.pathsReadme,\n ConfigKeys.Owner,\n ConfigKeys.Repo,\n] as const;\n\n/**\n * Loads the required configuration\n *\n * @param {ProviderInstance} config - The config instance\n * @returns {ProviderInstance} The updated config instance\n */\nexport function loadRequiredConfig(\n log: LogTask,\n config: ProviderInstance,\n requiredInputs: readonly string[] = RequiredInputs,\n): ProviderInstance {\n log.debug('Loading required config');\n\n return config.required([...requiredInputs]);\n}\n\n/**\n *\n */\nexport function loadAction(log: LogTask, actionPath: string): Action {\n log.debug(`Loading action from: ${actionPath}`);\n if (actionPath) {\n return new Action(path.resolve(actionPath));\n }\n throw new Error(`Action path not found: ${actionPath}`);\n}\n\nexport type InputContext = {\n /**\n * The configuration instance\n */\n config?: ProviderInstance;\n\n /**\n * The readme sections\n */\n sections?: ReadmeSection[];\n\n /**\n * The readme file path\n */\n readmePath?: string;\n\n /**\n * The config file path\n */\n configPath?: string;\n\n /**\n * The action instance\n */\n action?: Action;\n\n /**\n * The readme editor instance\n */\n readmeEditor?: ReadmeEditor;\n\n /**\n * The repository owner\n */\n owner?: string;\n\n /**\n * The repository name\n */\n repo?: string;\n};\n/**\n * Main Inputs class that handles configuration\n */\nexport default class Inputs {\n /**\n * The configuration instance\n */\n config: ProviderInstance;\n\n /**\n * The readme sections\n */\n sections: ReadmeSection[];\n\n /**\n * The readme file path\n */\n readmePath: string;\n\n /**\n * The config file path\n */\n configPath: string;\n\n /**\n * The action instance\n */\n action: Action;\n\n /**\n * The readme editor instance\n */\n readmeEditor: ReadmeEditor;\n\n /**\n * The repository owner\n */\n owner: string;\n\n /**\n * The repository name\n */\n repo: string;\n\n /** The logger for this instance */\n log: LogTask;\n\n /**\n * Initializes a new instance of the Inputs class.\n */\n constructor(providedInputContext: InputContext = {}, log: LogTask = new LogTask('inputs')) {\n this.log = log ?? new LogTask('inputs');\n this.log.debug('Initializing Inputs');\n const inputContext = providedInputContext ?? {};\n this.configPath = inputContext.configPath ?? path.resolve(configFileName);\n this.config = inputContext.config ?? new Provider();\n loadConfig(log, this.config, this.configPath);\n loadDefaultConfig(log, this.config);\n loadRequiredConfig(log, this.config);\n\n this.action = inputContext.action ?? loadAction(log, this.config.get(ConfigKeys.pathsAction));\n this.config.set(\n 'sections',\n inputContext.sections ?? (this.config.get('sections') as ReadmeSection[]),\n );\n this.sections = this.config.get('sections') as ReadmeSection[];\n this.readmePath =\n inputContext.readmePath ?? path.resolve(this.config.get(ConfigKeys.pathsReadme) as string);\n this.readmeEditor = inputContext.readmeEditor ?? new ReadmeEditor(this.readmePath);\n /**\n * Output the readme path that is being parsed\n */\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme', this.readmePath);\n }\n /**\n * owner is required, and if it doesn't exist it is handled by nconf which throws an error\n */\n this.owner = inputContext.owner ?? this.config.get('owner');\n\n /**\n * repo is required, and if it doesn't exist it is handled by nconf which throws an error\n */\n this.repo = inputContext.repo ?? this.config.get('repo');\n }\n\n stringify(): string {\n if (this?.config) {\n try {\n return YAML.stringify(this.config.get());\n } catch (error) {\n this.log.error(`${error}`);\n // continue\n }\n }\n // this is just for debug, no need to stop the process if it fails\n return '';\n }\n}\n"]}
1
+ {"version":3,"file":"inputs.js","sourceRoot":"","sources":["../../src/inputs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CA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M,CAAC,GAAG,CAAC,UAAU,CAAqB,CAC1E,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAoB,CAAC;QAC/D,IAAI,CAAC,UAAU;YACb,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAW,CAAC,CAAC;QAC7F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF;;WAEG;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD;;WAEG;QACH,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE5D;;WAEG;QACH,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS;QACP,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;gBAC3B,WAAW;YACb,CAAC;QACH,CAAC;QACD,kEAAkE;QAClE,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * This class handles input configuration and manipulation.\n * It imports various modules and packages for file operations, configuration parsing, and logging.\n * The class has methods for initializing the input configuration, setting default values, and converting the configuration to a string.\n * It also has properties for storing the configuration values, sections, readme path, action instance, and readme editor instance.\n */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport * as core from '@actions/core';\nimport { Context } from '@actions/github/lib/context.js';\nimport nconf from 'nconf';\nimport YAML from 'yaml';\n\nimport Action, { type Input } from './Action.js';\nimport { ConfigKeys, configFileName, README_SECTIONS, type ReadmeSection } from './constants.js';\nimport { repositoryFinder } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport ReadmeEditor from './readme-editor.js';\n\nconst { Provider }: typeof nconf = nconf;\ntype IOptions = nconf.IOptions;\n\n/**\n * Change working directory to output of workingDirectory()\n */\n// process.chdir(workingDirectory());\nexport const metaActionPath = '../../action.yml';\n\nexport type ArgvOptionProperties = {\n [key: string]: {\n alias: string | string[];\n describe: string;\n parseValues?: boolean;\n type?: string;\n };\n};\n/**\n * Represents the command line argument options for the application.\n */\nconst argvOptions: ArgvOptionProperties = {};\n\n/**\n * Save option configuration.\n * @property {string} alias - Alias for the save option.\n * @property {string} describe - Description for the save option.\n * @property {boolean} parseValues - Specifies whether to parse values for the save option.\n * @property {string} type - Type of the save option.\n */\nargvOptions[ConfigKeys.Save] = {\n alias: 'save',\n describe: `Save this config to ${configFileName}`,\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Paths action option configuration.\n * @property {string | string[]} alias - Alias(es) for the pathsAction option.\n * @property {string} type - Type of the pathsAction option.\n * @property {string} describe - Description for the pathsAction option.\n */\nargvOptions[ConfigKeys.pathsAction] = {\n alias: ['pathsAction', 'action'],\n type: 'string',\n describe: 'Path to the action.yml',\n};\n\n/**\n * Paths readme option configuration.\n * @property {string | string[]} alias - Alias(es) for the pathsReadme option.\n * @property {string} type - Type of the pathsReadme option.\n * @property {string} describe - Description for the pathsReadme option.\n */\nargvOptions[ConfigKeys.pathsReadme] = {\n alias: ['pathsReadme', 'readme'],\n type: 'string',\n describe: 'Path to the README file',\n};\n\n/**\n * Branding SVG path option configuration.\n * @property {string} alias - Alias for the svg option.\n * @property {string} type - Type of the svg option.\n * @property {string} describe - Description for the svg option.\n */\nargvOptions[ConfigKeys.BrandingSvgPath] = {\n alias: 'svg',\n type: 'string',\n describe: 'Save and load the branding svg image in the README from this path',\n};\n\n/**\n * Branding as title prefix option configuration.\n * @property {string} alias - Alias for the branding_prefix option.\n * @property {string} type - Type of the branding_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the branding_prefix option.\n * @property {string} describe - Description for the branding_prefix option.\n */\nargvOptions[ConfigKeys.BrandingAsTitlePrefix] = {\n alias: 'branding_prefix',\n type: 'boolean',\n parseValues: true,\n describe: 'Use the branding svg as a prefix for the README title',\n};\n\n/**\n * Owner option configuration.\n * @property {string} alias - Alias for the owner option.\n * @property {string} type - Type of the owner option.\n * @property {string} describe - Description for the owner option.\n */\nargvOptions[ConfigKeys.Owner] = {\n alias: 'owner',\n type: 'string',\n describe: 'The GitHub Action repository owner. i.e: `bitflight-devops`',\n};\n\n/**\n * Repo option configuration.\n * @property {string} alias - Alias for the repo option.\n * @property {string} type - Type of the repo option.\n * @property {string} describe - Description for the repo option.\n */\nargvOptions[ConfigKeys.Repo] = {\n alias: 'repo',\n type: 'string',\n describe: 'The GitHub Action repository name. i.e: `github-action-readme-generator`',\n};\n\n/**\n * Prettier option configuration.\n * @property {string | string[]} alias - Alias(es) for the prettier option.\n * @property {string} type - Type of the prettier option.\n * @property {boolean} parseValues - Specifies whether to parse values for the prettier option.\n * @property {string} describe - Description for the prettier option.\n */\nargvOptions[ConfigKeys.Prettier] = {\n alias: ['pretty', 'prettier'],\n type: 'boolean',\n parseValues: true,\n describe: 'Format the markdown using prettier formatter',\n};\n\n/**\n * Versioning enabled option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_enabled option.\n * @property {string} describe - Description for the versioning_enabled option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_enabled option.\n * @property {string} type - Type of the versioning_enabled option.\n */\nargvOptions[ConfigKeys.VersioningEnabled] = {\n alias: ['versioning', 'versioning_enabled'],\n describe:\n 'Enable the update of the usage version to match the latest version in the package.json file',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Versioning override option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_override option.\n * @property {string} describe - Description for the versioning_override option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_override option.\n */\nargvOptions[ConfigKeys.VersioningOverride] = {\n alias: ['setversion', 'versioning_override', 'version_override'],\n describe: 'Set a specific version to display in the README.md',\n parseValues: true,\n};\n\n/**\n * Versioning prefix option configuration.\n * @property {string | string[]} alias - Alias(es) for the version_prefix option.\n * @property {string} describe - Description for the version_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the version_prefix option.\n */\nargvOptions[ConfigKeys.VersioningPrefix] = {\n alias: ['vp', 'version_prefix'],\n describe: \"Prefix the version with this value (if it isn't already prefixed)\",\n parseValues: true,\n};\n\n/**\n * Versioning branch option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_default_branch option.\n * @property {string} describe - Description for the versioning_default_branch option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_default_branch option.\n */\nargvOptions[ConfigKeys.VersioningBranch] = {\n alias: ['branch', 'versioning_default_branch'],\n describe: 'If versioning is disabled show this branch instead',\n parseValues: true,\n};\n\n/**\n * Versioning source option configuration.\n * @property {string | string[]} alias - Alias(es) for the version_source option.\n * @property {string} describe - Description for the version_source option.\n * @property {boolean} parseValues - Specifies whether to parse values for the version_source option.\n * @property {string} type - Type of the version_source option.\n */\nargvOptions[ConfigKeys.VersioningSource] = {\n alias: ['version-source', 'version_source', 'versioning_source'],\n describe:\n 'How to detect the action version (git-tag, git-branch, git-sha, package-json, explicit)',\n parseValues: true,\n type: 'string',\n};\n\n/**\n * Include GitHub version badge option configuration.\n * @property {string | string[]} alias - Alias(es) for the include_github_version_badge option.\n * @property {string} describe - Description for the include_github_version_badge option.\n * @property {boolean} parseValues - Specifies whether to parse values for the include_github_version_badge option.\n * @property {string} type - Type of the include_github_version_badge option.\n */\nargvOptions[ConfigKeys.IncludeGithubVersionBadge] = {\n alias: ['version-badge', 'versioning_badge', 'include_github_version_badge'],\n describe: 'Display the current version as a badge',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Title prefix option configuration.\n * @property {string | string[]} alias - Alias(es) for the title_prefix option.\n * @property {string} describe - Description for the title_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the title_prefix option.\n */\nargvOptions[ConfigKeys.TitlePrefix] = {\n alias: ['prefix', 'title_prefix'],\n describe: 'Add a prefix to the README title',\n parseValues: true,\n};\n\n/**\n * Debug Nconf option configuration.\n * @property {string} describe - Description for the debugNconf option.\n * @property {boolean} parseValues - Specifies whether to parse values for the debugNconf option.\n * @property {string} type - Type of the debugNconf option.\n */\nargvOptions[ConfigKeys.DebugNconf] = {\n alias: ['debug_nconf'],\n describe: 'Print out the resolved nconf object with all values',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Debug Config option configuration.\n * @property {string} describe - Description for the debugConfig option.\n * @property {boolean} parseValues - Specifies whether to parse values for the debugConfig option.\n * @property {string} type - Type of the debugConfig option.\n */\nargvOptions[ConfigKeys.DebugConfig] = {\n alias: ['debug_config'],\n describe: 'Print out the resolved nconf object with all values',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Configuration inputs from the github action don't\n * all match the input names when running on cli.\n * This maps the action inputs to the cli.\n */\nconst ConfigKeysInputsMap: Record<string, string> = {\n save: ConfigKeys.Save,\n action: ConfigKeys.pathsAction,\n readme: ConfigKeys.pathsReadme,\n branding_svg_path: ConfigKeys.BrandingSvgPath,\n branding_as_title_prefix: ConfigKeys.BrandingAsTitlePrefix,\n versioning_enabled: ConfigKeys.VersioningEnabled,\n version_prefix: ConfigKeys.VersioningPrefix,\n versioning_default_branch: ConfigKeys.VersioningBranch,\n version_override: ConfigKeys.VersioningOverride,\n version_source: ConfigKeys.VersioningSource,\n include_github_version_badge: ConfigKeys.IncludeGithubVersionBadge,\n owner: ConfigKeys.Owner,\n repo: ConfigKeys.Repo,\n title_prefix: ConfigKeys.TitlePrefix,\n pretty: ConfigKeys.Prettier,\n};\n\n/**\n * Interface for key/value pair object\n */\ntype KVPairType = {\n key: string;\n value: string | undefined;\n};\n\n/**\n * Type alias for Provider instance\n */\ntype ProviderInstance = InstanceType<typeof Provider>;\n\nexport function transformGitHubInputsToArgv(\n log: LogTask,\n _config: ProviderInstance,\n obj: KVPairType,\n): undefined | KVPairType {\n /** The obj.key is always in lowercase, but it checks for it without case sensitivity */\n if (/^(INPUT|input)_[A-Z_a-z]\\w*$/.test(obj.key)) {\n log.debug(`Parsing input: ${obj.key} with ith value: ${obj.value}`);\n const keyParsed = obj.key.replace(/^(INPUT|input)_/, '').toLocaleLowerCase();\n const key = ConfigKeysInputsMap[keyParsed] || keyParsed;\n\n // Skip empty values for owner/repo to allow fallback detection from .git/config or GITHUB_REPOSITORY\n if ((key === 'owner' || key === 'repo') && (!obj.value || obj.value === '')) {\n log.debug(`Ignoring empty ${key} input to allow auto-detection`);\n return undefined;\n }\n\n log.debug(`New input is ${key} with the value ${obj.value}`);\n return { key, value: obj.value };\n }\n log.debug(`Ignoring input: ${obj.key} with ith value: ${obj.value}`);\n return undefined;\n}\n\n/**\n * Sets config value from action file default\n *\n * @param {Action} actionInstance - The action instance\n * @param {string} inputName - The input name\n * @returns {string | boolean | undefined} The default value\n */\nexport function setConfigValueFromActionFileDefault(\n log: LogTask,\n actionInstance: Action,\n inputName: string,\n): string | boolean | undefined {\n if (ConfigKeysInputsMap[inputName] === undefined) {\n log.error(\n `${inputName} from ${\n actionInstance.path\n } does not match a known input. Known inputs are: ${Object.keys(ConfigKeysInputsMap)}`,\n );\n return;\n }\n\n const configName = ConfigKeysInputsMap[inputName];\n const defaultValue = actionInstance.inputDefault(inputName);\n\n log.debug(`Default Value for action.yml: ${inputName} CLI: ${configName} = ${defaultValue}`);\n\n return defaultValue;\n}\n\n/**\n * Collects all default values from action file\n *\n * @returns {IOptions} The default values object\n */\nexport function collectAllDefaultValuesFromAction(\n log: LogTask,\n providedMetaActionPath?: string,\n providedDefaults: {\n [key: string]: Input;\n } = {},\n): IOptions {\n log.debug('Collecting default values from action.yml');\n // This loads the defaults from THIS action's own action.yml file (github-action-readme-generator's action.yml)\n // NOT the user's action.yml file (which is loaded separately via the 'action' input parameter)\n // Therefore, we use import.meta.dirname to find this package's action.yml regardless of where it's installed\n const thisActionPath = path.join(import.meta.dirname, providedMetaActionPath ?? metaActionPath);\n try {\n const defaultValues = {} as IOptions;\n const thisAction = new Action(thisActionPath);\n const defaults: {\n [key: string]: Input;\n } = { ...thisAction.inputs, ...providedDefaults };\n // Collect all of the default values from the action.yml file\n if (defaults) {\n for (const key of Object.keys(defaults)) {\n const mappedKey = ConfigKeysInputsMap[key] ?? key;\n defaultValues[mappedKey] = setConfigValueFromActionFileDefault(log, thisAction, key);\n }\n }\n log.debug(JSON.stringify(defaultValues, null, 2));\n return defaultValues;\n } catch (error) {\n // When running as a CLI tool (e.g., via npx or yarn dlx), the tool's own action.yml\n // may not be present in the node_modules. This is expected behavior, as the tool\n // should still work to generate documentation for other actions.\n log.debug(`Could not load defaults from this tool's action.yml at ${thisActionPath}: ${error}`);\n log.debug('Continuing without default values from action.yml');\n return {} as IOptions;\n }\n}\n\n/**\n * Loads the configuration\n *\n * @returns {ProviderInstance} The configuration instance\n */\nexport function loadConfig(\n log: LogTask,\n providedConfig?: ProviderInstance,\n configFilePath?: string,\n): ProviderInstance {\n log.debug('Loading config from env and argv');\n const config = providedConfig ?? new Provider();\n if (process.env.GITHUB_ACTION === 'true') {\n log.info('Running in GitHub action');\n }\n if (configFilePath) {\n if (fs.existsSync(configFilePath)) {\n log.info(`Config file found: ${configFilePath}`);\n config.file(configFilePath);\n } else {\n log.debug(`Config file not found: ${configFilePath}`);\n }\n }\n\n config\n .env({\n lowerCase: true,\n parseValues: true,\n transform: (obj: KVPairType): undefined | KVPairType => {\n return transformGitHubInputsToArgv(log, config, obj);\n },\n })\n .argv(argvOptions);\n\n return config;\n}\n\n/**\n * Loads the default configuration\n *\n * @param {ProviderInstance} config - The config instance\n * @returns {ProviderInstance} The updated config instance\n */\nexport function loadDefaultConfig(\n log: LogTask,\n config: ProviderInstance,\n providedContext?: Context,\n): ProviderInstance {\n log.debug('Loading default config');\n const defaultValues = collectAllDefaultValuesFromAction(log);\n const context = providedContext ?? new Context();\n\n // Get owner/repo from config (which includes CLI args), falling back to env vars for GitHub Actions\n const ownerFromConfig = config.get('owner') as string | undefined;\n const repoFromConfig = config.get('repo') as string | undefined;\n const ownerInput = ownerFromConfig ?? process.env.INPUT_OWNER ?? '';\n const repoInput = repoFromConfig ?? process.env.INPUT_REPO ?? '';\n\n // Get the action path to derive the target repo directory for .git/config lookup\n const actionPath = config.get(ConfigKeys.pathsAction) as string | undefined;\n const actionDir = actionPath ? path.dirname(path.resolve(actionPath)) : undefined;\n log.debug(`Action directory for repository detection: ${actionDir ?? 'not specified'}`);\n\n const repositoryDetail = repositoryFinder(`${ownerInput}/${repoInput}`, context, actionDir);\n log.debug(`repositoryDetail: ${repositoryDetail}`);\n // Apply the default values from the action.yml file\n return config.defaults({\n ...defaultValues,\n owner: repositoryDetail?.owner,\n repo: repositoryDetail?.repo,\n sections: [...README_SECTIONS] as ReadmeSection[],\n });\n}\n\n/**\n * Represents the required inputs for the action.\n */\nconst RequiredInputs = [\n ConfigKeys.pathsAction,\n ConfigKeys.pathsReadme,\n ConfigKeys.Owner,\n ConfigKeys.Repo,\n] as const;\n\n/**\n * Loads the required configuration\n *\n * @param {ProviderInstance} config - The config instance\n * @returns {ProviderInstance} The updated config instance\n */\nexport function loadRequiredConfig(\n log: LogTask,\n config: ProviderInstance,\n requiredInputs: readonly string[] = RequiredInputs,\n): ProviderInstance {\n log.debug('Loading required config');\n\n return config.required([...requiredInputs]);\n}\n\n/**\n *\n */\nexport function loadAction(log: LogTask, actionPath: string): Action {\n log.debug(`Loading action from: ${actionPath}`);\n if (actionPath) {\n return new Action(path.resolve(actionPath));\n }\n throw new Error(`Action path not found: ${actionPath}`);\n}\n\nexport type InputContext = {\n /**\n * The configuration instance\n */\n config?: ProviderInstance;\n\n /**\n * The readme sections\n */\n sections?: ReadmeSection[];\n\n /**\n * The readme file path\n */\n readmePath?: string;\n\n /**\n * The config file path\n */\n configPath?: string;\n\n /**\n * The action instance\n */\n action?: Action;\n\n /**\n * The readme editor instance\n */\n readmeEditor?: ReadmeEditor;\n\n /**\n * The repository owner\n */\n owner?: string;\n\n /**\n * The repository name\n */\n repo?: string;\n};\n/**\n * Main Inputs class that handles configuration\n */\nexport default class Inputs {\n /**\n * The configuration instance\n */\n config: ProviderInstance;\n\n /**\n * The readme sections\n */\n sections: ReadmeSection[];\n\n /**\n * The readme file path\n */\n readmePath: string;\n\n /**\n * The config file path\n */\n configPath: string;\n\n /**\n * The action instance\n */\n action: Action;\n\n /**\n * The readme editor instance\n */\n readmeEditor: ReadmeEditor;\n\n /**\n * The repository owner\n */\n owner: string;\n\n /**\n * The repository name\n */\n repo: string;\n\n /** The logger for this instance */\n log: LogTask;\n\n /**\n * Initializes a new instance of the Inputs class.\n */\n constructor(providedInputContext: InputContext = {}, log: LogTask = new LogTask('inputs')) {\n this.log = log ?? new LogTask('inputs');\n this.log.debug('Initializing Inputs');\n const inputContext = providedInputContext ?? {};\n this.configPath = inputContext.configPath ?? path.resolve(configFileName);\n this.config = inputContext.config ?? new Provider();\n loadConfig(log, this.config, this.configPath);\n loadDefaultConfig(log, this.config);\n loadRequiredConfig(log, this.config);\n\n this.action = inputContext.action ?? loadAction(log, this.config.get(ConfigKeys.pathsAction));\n this.config.set(\n 'sections',\n inputContext.sections ?? (this.config.get('sections') as ReadmeSection[]),\n );\n this.sections = this.config.get('sections') as ReadmeSection[];\n this.readmePath =\n inputContext.readmePath ?? path.resolve(this.config.get(ConfigKeys.pathsReadme) as string);\n this.readmeEditor = inputContext.readmeEditor ?? new ReadmeEditor(this.readmePath);\n /**\n * Output the readme path that is being parsed\n */\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme', this.readmePath);\n }\n /**\n * owner is required, and if it doesn't exist it is handled by nconf which throws an error\n */\n this.owner = inputContext.owner ?? this.config.get('owner');\n\n /**\n * repo is required, and if it doesn't exist it is handled by nconf which throws an error\n */\n this.repo = inputContext.repo ?? this.config.get('repo');\n }\n\n stringify(): string {\n if (this?.config) {\n try {\n return YAML.stringify(this.config.get());\n } catch (error) {\n this.log.error(`${error}`);\n // continue\n }\n }\n // this is just for debug, no need to stop the process if it fails\n return '';\n }\n}\n"]}
@@ -2,7 +2,7 @@ import * as core from '@actions/core';
2
2
  import chalkPkg from 'chalk';
3
3
  import { notEmpty } from '../util.js';
4
4
  // Chalk color styles
5
- const { bgRedBright, cyan, green, greenBright, whiteBright, yellow, yellowBright } = chalkPkg;
5
+ const { bgRedBright, cyan, green, greenBright, whiteBright, yellow, yellowBright, } = chalkPkg;
6
6
  // Constants for different log step types
7
7
  var LogGroup;
8
8
  (function (LogGroup) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logtask/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;AAE9F,yCAAyC;AAEzC,IAAK,QAOJ;AAPD,WAAK,QAAQ;IACX,+CAAY,CAAA;IACZ,qDAAW,CAAA;IACX,iDAAS,CAAA;IACT,+CAAQ,CAAA;IACR,iDAAS,CAAA;IACT,+CAAQ,CAAA;AACV,CAAC,EAPI,QAAQ,KAAR,QAAQ,QAOZ;AAED,SAAS,eAAe;IACtB,OAAO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;;;OAIG;IACH,IAAI,CAAC,OAAO,GAAG,EAAE,EAAE,OAAO,GAAG,IAAI;QAC/B,iCAAiC;QACjC,MAAM,IAAI,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;QAC/D,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;gBAC/B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpF,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,GAAG,EAAE;QAChB,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,GAAG,EAAE;QAChB,+BAA+B;QAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC","sourcesContent":["import * as core from '@actions/core';\nimport chalkPkg from 'chalk';\n\nimport { notEmpty } from '../util.js';\n\n// Chalk color styles\nconst { bgRedBright, cyan, green, greenBright, whiteBright, yellow, yellowBright } = chalkPkg;\n\n// Constants for different log step types\n\nenum LogGroup {\n NO_GROUP = 0,\n START_GROUP,\n END_GROUP,\n IS_ERROR,\n IS_FAILED,\n IS_TITLE,\n}\n\nfunction inGitHubActions(): boolean {\n return notEmpty(process.env.GITHUB_ACTIONS) && process.env.GITHUB_ACTIONS === 'true';\n}\n\nfunction highlightMessage(step: string, message: string): { desc: any; failed: any } {\n let failed = false;\n const ci = inGitHubActions();\n let desc: string;\n switch (step) {\n case 'START': {\n desc = `${message}`;\n break;\n }\n case 'INFO': {\n desc = green(`${message}`);\n break;\n }\n case 'WARN': {\n desc = yellow(`${message}`);\n break;\n }\n case 'SUCCESS': {\n desc = greenBright(`${message}`);\n break;\n }\n case 'FAILURE': {\n desc = ci ? message : yellow.bold(`${message}`);\n failed = true;\n break;\n }\n case 'ERROR': {\n desc = ci ? message : yellow(`${message}`);\n break;\n }\n case '#####': {\n desc = cyan(`${message}`);\n break;\n }\n default: {\n desc = message;\n break;\n }\n }\n return { desc, failed };\n}\nfunction highlightStep(step: string, message: string): string {\n let msg: string;\n const ci = inGitHubActions();\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n switch (step) {\n case 'START': {\n msg = yellowBright(message);\n break;\n }\n case 'SUCCESS': {\n msg = whiteBright(message);\n break;\n }\n case 'FAILURE':\n case 'ERROR': {\n msg = ci ? message : bgRedBright(message);\n break;\n }\n default: {\n msg = message;\n break;\n }\n }\n return msg;\n}\n\nfunction handleOutput(startGroup: LogGroup, msg: string, originalString?: string): void {\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n const ci = inGitHubActions();\n\n switch (startGroup) {\n case LogGroup.START_GROUP: {\n if (ci && originalString) {\n core.startGroup(originalString);\n } else {\n core.info(msg);\n }\n\n break;\n }\n case LogGroup.END_GROUP: {\n if (ci) {\n core.endGroup();\n }\n break;\n }\n // Logic to handle erroring or failed steps\n case LogGroup.IS_ERROR: {\n core.error(msg);\n break;\n }\n case LogGroup.IS_FAILED: {\n core.setFailed(msg);\n break;\n }\n default: {\n core.info(msg);\n }\n }\n}\n/**\n * Represents a logging task with various log step methods.\n */\nexport default class LogTask {\n /**\n * Map of ingroup settings per task name.\n */\n private static ingroupSettings = new Map<string, boolean>();\n\n /**\n * The width of the indentation for log messages.\n */\n private static indentWidth = 5;\n\n /**\n * Checks if debug mode is enabled.\n * @returns A boolean indicating if debug mode is enabled.\n */\n static isDebug(): boolean {\n return core.isDebug() || (notEmpty(process.env.DEBUG) && process.env.DEBUG === 'true');\n }\n\n /**\n * The name of the task.\n */\n private name: string;\n\n /**\n * Creates a new instance of the LogTask class.\n * @param name - The name of the task.\n */\n constructor(name: string) {\n this.name = name?.trim();\n }\n\n /**\n * Gets the ingroup setting for the task.\n */\n get ingroup(): boolean {\n return LogTask.ingroupSettings.get(this.name) ?? false;\n }\n\n /**\n * Sets the ingroup setting for this task.\n */\n set ingroup(value: boolean) {\n LogTask.ingroupSettings.set(this.name, value);\n }\n\n getMessageString(step: string, desc: string, emojiStr: string): string {\n let msg: string;\n if (this.ingroup) {\n const indentStr = ' '.repeat(LogTask.indentWidth);\n msg = `${indentStr} ${emojiStr}: ${this.name} > ${desc}`;\n } else {\n const stepStr = step.padEnd(LogTask.indentWidth, ' ');\n msg = `[${stepStr}][${this.name.padEnd(11, ' ')}] ${emojiStr}: ${desc}`;\n }\n return highlightStep(step, msg);\n }\n\n /**\n * Logs a step with the given emoji, type, message and group.\n * @param emojiStr - The emoji string to display.\n * @param step - The step type.\n * @param message - The message of the step.\n * @param startGroup - The start group type.\n */\n logStep(emojiStr: string, step: string, message: string, startGroup = LogGroup.NO_GROUP): void {\n // Logic to determine the log message color and format based on the step type\n if (step.length > LogTask.indentWidth) {\n LogTask.indentWidth = step.length;\n }\n const { desc } = highlightMessage(step, message);\n const msg = this.getMessageString(step, desc, emojiStr);\n\n handleOutput(startGroup, msg, message);\n }\n\n /**\n * Logs a debug message.\n * @param message - The message of the debug message.\n */\n debug(message = ''): void {\n // Logic to log a debug message\n if (LogTask.isDebug() && message !== '') {\n this.logStep('🐞', 'DEBUG', message);\n }\n }\n\n /**\n * Logs a start message.\n * @param message - The message of the start message.\n */\n start(message = ''): void {\n // Logic to log a start message\n const desc = message === '' ? `Starting ${this.name}...` : message;\n\n this.logStep('🚀', 'START', desc, LogGroup.START_GROUP);\n }\n\n /**\n * Logs an info message.\n * @param message - The message of the info message.\n */\n info(message = ''): void {\n // Logic to log an info message\n this.logStep('✨', 'INFO', message);\n }\n\n /**\n * Logs a warning message.\n * @param message - The message of the warning message.\n */\n warn(message = ''): void {\n // Logic to log a warning message\n this.logStep('⚠️', 'WARN', message);\n }\n\n /**\n * Logs a success message.\n * @param message - The message of the success message.\n * @param ingroup - Indicates whether the success message is in a group.\n */\n success(message = '', ingroup = true): void {\n // Logic to log a success message\n const desc = message === '' ? `Completed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n this.logStep('✅', 'SUCCESS', desc);\n }\n\n /**\n * Logs a failure message.\n * @param message - The message of the failure message.\n * @param ingroup - Indicates whether the failure message is in a group.\n */\n fail(message = '', ingroup = true): void {\n // Logic to log a failure message\n const desc = message === '' ? `Failed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n const msgtype = process.env.GITHUB_ACTIONS ? LogGroup.IS_FAILED : LogGroup.IS_ERROR;\n this.logStep('❌', 'FAILURE', desc, msgtype);\n }\n\n /**\n * Logs an error message.\n * @param message - The message of the error message.\n */\n error(message = ''): void {\n // Logic to log an error message\n this.logStep('🔴', 'ERROR', message, LogGroup.IS_ERROR);\n }\n\n /**\n * Logs a title message.\n * @param message - The message of the title message.\n */\n title(message = ''): void {\n // Logic to log a title message\n this.logStep('📓', '#####', message, LogGroup.IS_TITLE);\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logtask/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,C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,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC","sourcesContent":["import * as core from '@actions/core';\nimport chalkPkg from 'chalk';\n\nimport { notEmpty } from '../util.js';\n\n// Chalk color styles\nconst {\n bgRedBright,\n cyan,\n green,\n greenBright,\n whiteBright,\n yellow,\n yellowBright,\n}: typeof chalkPkg = chalkPkg;\n\n// Constants for different log step types\n\nenum LogGroup {\n NO_GROUP = 0,\n START_GROUP = 1,\n END_GROUP = 2,\n IS_ERROR = 3,\n IS_FAILED = 4,\n IS_TITLE = 5,\n}\n\nfunction inGitHubActions(): boolean {\n return notEmpty(process.env.GITHUB_ACTIONS) && process.env.GITHUB_ACTIONS === 'true';\n}\n\nfunction highlightMessage(step: string, message: string): { desc: string; failed: boolean } {\n let failed = false;\n const ci = inGitHubActions();\n let desc: string;\n switch (step) {\n case 'START': {\n desc = `${message}`;\n break;\n }\n case 'INFO': {\n desc = green(`${message}`);\n break;\n }\n case 'WARN': {\n desc = yellow(`${message}`);\n break;\n }\n case 'SUCCESS': {\n desc = greenBright(`${message}`);\n break;\n }\n case 'FAILURE': {\n desc = ci ? message : yellow.bold(`${message}`);\n failed = true;\n break;\n }\n case 'ERROR': {\n desc = ci ? message : yellow(`${message}`);\n break;\n }\n case '#####': {\n desc = cyan(`${message}`);\n break;\n }\n default: {\n desc = message;\n break;\n }\n }\n return { desc, failed };\n}\nfunction highlightStep(step: string, message: string): string {\n let msg: string;\n const ci = inGitHubActions();\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n switch (step) {\n case 'START': {\n msg = yellowBright(message);\n break;\n }\n case 'SUCCESS': {\n msg = whiteBright(message);\n break;\n }\n case 'FAILURE':\n case 'ERROR': {\n msg = ci ? message : bgRedBright(message);\n break;\n }\n default: {\n msg = message;\n break;\n }\n }\n return msg;\n}\n\nfunction handleOutput(startGroup: LogGroup, msg: string, originalString?: string): void {\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n const ci = inGitHubActions();\n\n switch (startGroup) {\n case LogGroup.START_GROUP: {\n if (ci && originalString) {\n core.startGroup(originalString);\n } else {\n core.info(msg);\n }\n\n break;\n }\n case LogGroup.END_GROUP: {\n if (ci) {\n core.endGroup();\n }\n break;\n }\n // Logic to handle erroring or failed steps\n case LogGroup.IS_ERROR: {\n core.error(msg);\n break;\n }\n case LogGroup.IS_FAILED: {\n core.setFailed(msg);\n break;\n }\n default: {\n core.info(msg);\n }\n }\n}\n/**\n * Represents a logging task with various log step methods.\n */\nexport default class LogTask {\n /**\n * Map of ingroup settings per task name.\n */\n private static ingroupSettings = new Map<string, boolean>();\n\n /**\n * The width of the indentation for log messages.\n */\n private static indentWidth = 5;\n\n /**\n * Checks if debug mode is enabled.\n * @returns A boolean indicating if debug mode is enabled.\n */\n static isDebug(): boolean {\n return core.isDebug() || (notEmpty(process.env.DEBUG) && process.env.DEBUG === 'true');\n }\n\n /**\n * The name of the task.\n */\n private name: string;\n\n /**\n * Creates a new instance of the LogTask class.\n * @param name - The name of the task.\n */\n constructor(name: string) {\n this.name = name?.trim();\n }\n\n /**\n * Gets the ingroup setting for the task.\n */\n get ingroup(): boolean {\n return LogTask.ingroupSettings.get(this.name) ?? false;\n }\n\n /**\n * Sets the ingroup setting for this task.\n */\n set ingroup(value: boolean) {\n LogTask.ingroupSettings.set(this.name, value);\n }\n\n getMessageString(step: string, desc: string, emojiStr: string): string {\n let msg: string;\n if (this.ingroup) {\n const indentStr = ' '.repeat(LogTask.indentWidth);\n msg = `${indentStr} ${emojiStr}: ${this.name} > ${desc}`;\n } else {\n const stepStr = step.padEnd(LogTask.indentWidth, ' ');\n msg = `[${stepStr}][${this.name.padEnd(11, ' ')}] ${emojiStr}: ${desc}`;\n }\n return highlightStep(step, msg);\n }\n\n /**\n * Logs a step with the given emoji, type, message and group.\n * @param emojiStr - The emoji string to display.\n * @param step - The step type.\n * @param message - The message of the step.\n * @param startGroup - The start group type.\n */\n logStep(\n emojiStr: string,\n step: string,\n message: string,\n startGroup: LogGroup = LogGroup.NO_GROUP,\n ): void {\n // Logic to determine the log message color and format based on the step type\n if (step.length > LogTask.indentWidth) {\n LogTask.indentWidth = step.length;\n }\n const { desc } = highlightMessage(step, message);\n const msg = this.getMessageString(step, desc, emojiStr);\n\n handleOutput(startGroup, msg, message);\n }\n\n /**\n * Logs a debug message.\n * @param message - The message of the debug message.\n */\n debug(message: string = ''): void {\n // Logic to log a debug message\n if (LogTask.isDebug() && message !== '') {\n this.logStep('🐞', 'DEBUG', message);\n }\n }\n\n /**\n * Logs a start message.\n * @param message - The message of the start message.\n */\n start(message: string = ''): void {\n // Logic to log a start message\n const desc = message === '' ? `Starting ${this.name}...` : message;\n\n this.logStep('🚀', 'START', desc, LogGroup.START_GROUP);\n }\n\n /**\n * Logs an info message.\n * @param message - The message of the info message.\n */\n info(message: string = ''): void {\n // Logic to log an info message\n this.logStep('✨', 'INFO', message);\n }\n\n /**\n * Logs a warning message.\n * @param message - The message of the warning message.\n */\n warn(message: string = ''): void {\n // Logic to log a warning message\n this.logStep('⚠️', 'WARN', message);\n }\n\n /**\n * Logs a success message.\n * @param message - The message of the success message.\n * @param ingroup - Indicates whether the success message is in a group.\n */\n success(message: string = '', ingroup: boolean = true): void {\n // Logic to log a success message\n const desc = message === '' ? `Completed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n this.logStep('✅', 'SUCCESS', desc);\n }\n\n /**\n * Logs a failure message.\n * @param message - The message of the failure message.\n * @param ingroup - Indicates whether the failure message is in a group.\n */\n fail(message: string = '', ingroup: boolean = true): void {\n // Logic to log a failure message\n const desc = message === '' ? `Failed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n const msgtype = process.env.GITHUB_ACTIONS ? LogGroup.IS_FAILED : LogGroup.IS_ERROR;\n this.logStep('❌', 'FAILURE', desc, msgtype);\n }\n\n /**\n * Logs an error message.\n * @param message - The message of the error message.\n */\n error(message: string = ''): void {\n // Logic to log an error message\n this.logStep('🔴', 'ERROR', message, LogGroup.IS_ERROR);\n }\n\n /**\n * Logs a title message.\n * @param message - The message of the title message.\n */\n title(message: string = ''): void {\n // Logic to log a title message\n this.logStep('📓', '#####', message, LogGroup.IS_TITLE);\n }\n}\n"]}
@@ -18,7 +18,7 @@ const log = new LogTask('prettier');
18
18
  */
19
19
  export async function formatYaml(value, filepath) {
20
20
  const fp = filepath ? { filepath } : {};
21
- return format(value, {
21
+ return await format(value, {
22
22
  semi: false,
23
23
  parser: 'yaml',
24
24
  embeddedLanguageFormatting: 'auto',
@@ -33,7 +33,7 @@ export async function formatYaml(value, filepath) {
33
33
  */
34
34
  export async function formatMarkdown(value, filepath) {
35
35
  const fp = filepath ? { filepath } : {};
36
- return format(value, {
36
+ return await format(value, {
37
37
  semi: false,
38
38
  parser: 'markdown',
39
39
  embeddedLanguageFormatting: 'auto',
@@ -48,8 +48,9 @@ export async function formatMarkdown(value, filepath) {
48
48
  * @returns {Promise<string[]>} A promise that resolves with the updated content array.
49
49
  */
50
50
  export async function wrapDescription(value, content, prefix = ' # ') {
51
- if (!value)
51
+ if (!value) {
52
52
  return content ?? [];
53
+ }
53
54
  // const valueWithoutPrefix = prefix && prefix.length > 0 ? value.replace(prefix, '') : value;
54
55
  let formattedString = '';
55
56
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../src/prettier.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAa,EAAE,QAAiB;IAC/D,MAAM,EAAE,GAAG,QAAQ,CAAC,C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OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * This TypeScript code exports three functions: `formatYaml`, `formatMarkdown`, and `wrapDescription`.\n *\n * - `formatYaml` takes a YAML string and an optional filepath as parameters and uses the `prettier` library to format the YAML code. It returns the formatted YAML string.\n * - `formatMarkdown` takes a Markdown string and an optional filepath as parameters and uses the `prettier` library to format the Markdown code. It returns the formatted Markdown string.\n * - `wrapDescription` takes a string value, an array of content, and an optional prefix as parameters. It wraps the description text with the specified prefix and formats it using `prettier`. It returns the updated content array with the formatted description lines.\n *\n * The code utilizes the `prettier` library for code formatting and the `LogTask` class for logging purposes.\n */\n\nimport { format } from 'prettier';\n\nimport LogTask from './logtask/index.js';\n\nconst log = new LogTask('prettier');\n\n/**\n * Formats a YAML string using `prettier`.\n * @param {string} value - The YAML string to format.\n * @param {string} [filepath] - The optional filepath.\n * @returns {Promise<string>} A promise that resolves with the formatted YAML string.\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}\n\n/**\n * Formats a Markdown string using `prettier`.\n * @param {string} value - The Markdown string to format.\n * @param {string} [filepath] - The optional filepath.\n * @returns {Promise<string>} A promise that resolves with the formatted Markdown string.\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}\n\n/**\n * Wraps a description text with a prefix and formats it using `prettier`.\n * @param {string | undefined} value - The description text to wrap and format.\n * @param {string[]} content - The array of content to update.\n * @param {string} [prefix=' # '] - The optional prefix to wrap the description lines.\n * @returns {Promise<string[]>} A promise that resolves with the updated content array.\n */\nexport async function wrapDescription(\n value: string | undefined,\n content: string[],\n prefix = ' # ',\n): Promise<string[]> {\n if (!value) return content ?? [];\n // const valueWithoutPrefix = prefix && prefix.length > 0 ? value.replace(prefix, '') : value;\n let formattedString = '';\n try {\n formattedString = await format(value, {\n semi: false,\n parser: 'markdown',\n proseWrap: 'always',\n });\n } catch (error) {\n log.error(`${error}`);\n }\n\n content.push(...formattedString.split('\\n').map((line) => prefix + line.replace(prefix, '')));\n return content;\n}\n"]}
1
+ {"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../src/prettier.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,MAAM,GAAG,GAAY,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,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,MAAM,CAAC,KAAK,EAAE;QACzB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,MAAM;QACd,0BAA0B,EAAE,MAAM;QAClC,GAAG,EAAE;KACN,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,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,MAAM,CAAC,KAAK,EAAE;QACzB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,UAAU;QAClB,0BAA0B,EAAE,MAAM;QAClC,GAAG,EAAE;KACN,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAyB,EACzB,OAAiB,EACjB,SAAiB,QAAQ;IAEzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,OAAO,IAAI,EAAE,CAAC;IACvB,CAAC;IACD,8FAA8F;IAC9F,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,eAAe,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE;YACpC,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,QAAQ;SACpB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9F,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * This TypeScript code exports three functions: `formatYaml`, `formatMarkdown`, and `wrapDescription`.\n *\n * - `formatYaml` takes a YAML string and an optional filepath as parameters and uses the `prettier` library to format the YAML code. It returns the formatted YAML string.\n * - `formatMarkdown` takes a Markdown string and an optional filepath as parameters and uses the `prettier` library to format the Markdown code. It returns the formatted Markdown string.\n * - `wrapDescription` takes a string value, an array of content, and an optional prefix as parameters. It wraps the description text with the specified prefix and formats it using `prettier`. It returns the updated content array with the formatted description lines.\n *\n * The code utilizes the `prettier` library for code formatting and the `LogTask` class for logging purposes.\n */\n\nimport { format } from 'prettier';\n\nimport LogTask from './logtask/index.js';\n\nconst log: LogTask = new LogTask('prettier');\n\n/**\n * Formats a YAML string using `prettier`.\n * @param {string} value - The YAML string to format.\n * @param {string} [filepath] - The optional filepath.\n * @returns {Promise<string>} A promise that resolves with the formatted YAML string.\n */\nexport async function formatYaml(value: string, filepath?: string): Promise<string> {\n const fp = filepath ? { filepath } : {};\n return await format(value, {\n semi: false,\n parser: 'yaml',\n embeddedLanguageFormatting: 'auto',\n ...fp,\n });\n}\n\n/**\n * Formats a Markdown string using `prettier`.\n * @param {string} value - The Markdown string to format.\n * @param {string} [filepath] - The optional filepath.\n * @returns {Promise<string>} A promise that resolves with the formatted Markdown string.\n */\nexport async function formatMarkdown(value: string, filepath?: string): Promise<string> {\n const fp = filepath ? { filepath } : {};\n return await format(value, {\n semi: false,\n parser: 'markdown',\n embeddedLanguageFormatting: 'auto',\n ...fp,\n });\n}\n\n/**\n * Wraps a description text with a prefix and formats it using `prettier`.\n * @param {string | undefined} value - The description text to wrap and format.\n * @param {string[]} content - The array of content to update.\n * @param {string} [prefix=' # '] - The optional prefix to wrap the description lines.\n * @returns {Promise<string[]>} A promise that resolves with the updated content array.\n */\nexport async function wrapDescription(\n value: string | undefined,\n content: string[],\n prefix: string = ' # ',\n): Promise<string[]> {\n if (!value) {\n return content ?? [];\n }\n // const valueWithoutPrefix = prefix && prefix.length > 0 ? value.replace(prefix, '') : value;\n let formattedString = '';\n try {\n formattedString = await format(value, {\n semi: false,\n parser: 'markdown',\n proseWrap: 'always',\n });\n } catch (error) {\n log.error(`${error}`);\n }\n\n content.push(...formattedString.split('\\n').map((line) => prefix + line.replace(prefix, '')));\n return content;\n}\n"]}
@@ -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,wCA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,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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G,CAAC,IAAI,CAAC,mBAAmB,IAAI,aAAa,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE9D,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChE,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;YAC5B,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,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(\n name: string,\n providedContent: string | string[],\n addNewlines: boolean = true,\n ): 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"]}
@@ -5,9 +5,9 @@
5
5
  * If an error occurs during the update of a section, it logs the error message and stops the process.
6
6
  * Finally, it saves the updated README.md file and calls the 'save' function.
7
7
  */
8
- import { ReadmeSection } from './constants.js';
9
- import Inputs from './inputs.js';
10
- import LogTask from './logtask/index.js';
8
+ import type { ReadmeSection } from './constants.js';
9
+ import type Inputs from './inputs.js';
10
+ import type LogTask from './logtask/index.js';
11
11
  export type SectionKV = Record<string, string>;
12
12
  /**
13
13
  * Class for managing README generation.