github-action-readme-generator 1.8.6 → 1.8.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../src/Action.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAiB,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,OAAO,MAAM,oBAAoB,CAAC;AA6GzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,MAAM,CAAC,QAAQ,CAAC,GAAQ;QACtB,IAAI,MAAM,IAAI,GAAG,IAAI,aAAa,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE;YACjF,OAAO,CACL,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;gBAC5B,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ;gBACnC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CACnC,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAU;IAEb,yBAAyB;IACzB,IAAI,CAAS;IAEb,MAAM,CAAU;IAEhB,gCAAgC;IAChC,WAAW,CAAS;IAEpB,2BAA2B;IAC3B,QAAQ,CAAY;IAEpB,wBAAwB;IACxB,MAAM,CAA4B;IAElC,yBAAyB;IACzB,OAAO,CAA6B;IAEpC,4BAA4B;IAC5B,IAAI,CAAa;IAEjB,yBAAyB;IACzB,IAAI,CAAS;IAEb,gCAAgC;IAChC,aAAa,GAAG,EAAE,CAAC;IAEnB;;;;OAIG;IACH,YAAY,UAAkB,EAAE,GAAa;QAC3C,4BAA4B;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It provides properties and methods for accessing and manipulating the metadata.\n * [Further reading on the metadata can be found here](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs)\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport YAML from 'yaml';\n\nimport { type Branding, DEFAULT_BRAND_COLOR, DEFAULT_BRAND_ICON } from './constants.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * Represents an input for the action.\n */\nexport type Input = {\n /** Description of the input */\n description: string;\n\n /** Whether the input is required */\n required?: boolean;\n\n /** Default value for the input */\n default?: string;\n /** Optional If the input parameter is used, this string is this.logged as a warning message. You can use this warning to notify users that the input is deprecated and mention any alternatives. */\n deprecationMessage?: string;\n};\n\n/**\n * Represents an output for the action.\n */\nexport interface Output {\n /** Description of the output */\n description?: string;\n value?: string;\n}\ntype CompositeAction = 'composite';\ntype ContainerAction = 'docker';\ntype JavascriptAction = `Node${string}` | `node${string}`;\n\n/**\n * Defines the runs property for container actions.\n */\ntype RunsContainer = {\n 'using': ContainerAction;\n 'image': string;\n 'args'?: string[];\n 'pre-entrypoint'?: string;\n 'post-entrypoint'?: string;\n 'entrypoint'?: string;\n};\n\n/**\n * Defines the runs property for JavaScript actions.\n */\ntype RunsJavascript = {\n /** The runner used to execute the action */\n 'using': JavascriptAction;\n\n /** The entrypoint file for the action */\n 'main': string;\n\n 'pre'?: string;\n 'pre-if'?: string;\n\n 'post-if'?: string;\n\n 'post'?: string;\n};\n\n/**\n * Defines the steps property for composite actions.\n */\ntype Steps = {\n 'shell'?: string;\n 'if'?: string;\n 'run'?: string;\n 'name'?: string;\n 'id'?: string;\n 'working-directory'?: string;\n 'env': { [key: string]: string };\n};\n\n/**\n * Defines the runs property for composite actions.\n */\ntype RunsComposite = {\n /** The runner used to execute the action */\n using: CompositeAction;\n steps: Steps;\n};\n\nexport type ActionType = RunsContainer | RunsJavascript | RunsComposite;\n/**\n * Defines how the action is run.\n */\nexport type ActionYaml = {\n name: string;\n\n author?: string;\n\n /** Description of the action */\n description: string;\n\n /** Branding information */\n branding?: Branding;\n\n /** Input definitions */\n inputs?: { [key: string]: Input };\n\n /** Output definitions */\n outputs?: { [key: string]: Output };\n\n /** How the action is run */\n runs: ActionType;\n\n /** Path to the action */\n path: string;\n};\n/**\n * Parses and represents metadata from action.yml.\n */\nexport default class Action implements ActionYaml {\n static validate(obj: any): obj is ActionType {\n if ('name' in obj && 'description' in obj && 'runs' in obj && 'using' in obj.runs) {\n return (\n typeof obj.name === 'string' &&\n typeof obj.description === 'string' &&\n typeof obj.runs.using === 'string'\n );\n }\n return false;\n }\n\n log: LogTask;\n\n /** Name of the action */\n name: string;\n\n author?: string;\n\n /** Description of the action */\n description: string;\n\n /** Branding information */\n branding?: Branding;\n\n /** Input definitions */\n inputs?: { [key: string]: Input };\n\n /** Output definitions */\n outputs?: { [key: string]: Output };\n\n /** How the action is run */\n runs: ActionType;\n\n /** Path to the action */\n path: string;\n\n /** the original file content */\n rawYamlString = '';\n\n /**\n * Creates a new instance of the Action class by loading and parsing action.yml.\n *\n * @param actionPath The path to the action.yml file.\n */\n constructor(actionPath: string, log?: LogTask) {\n // Load and parse action.yml\n this.log = log ?? new LogTask(actionPath);\n this.path = actionPath;\n let actionYaml: ActionYaml;\n this.log.debug(`Constucting ${actionPath}`);\n try {\n actionYaml = this.loadActionFrom(actionPath);\n } catch (error) {\n throw new Error(`Failed to load ${actionPath}. ${error}`);\n }\n this.log.debug(`Action YAML: ${JSON.stringify(actionYaml)}`);\n\n this.name = actionYaml.name;\n this.author = actionYaml.author;\n this.description = actionYaml.description;\n\n this.branding = {\n color: actionYaml.branding?.color ?? DEFAULT_BRAND_COLOR,\n icon: actionYaml.branding?.icon ?? DEFAULT_BRAND_ICON,\n };\n this.inputs = actionYaml.inputs;\n this.outputs = actionYaml.outputs;\n this.runs = actionYaml.runs;\n }\n\n loadActionFrom(actionPath: string): ActionYaml {\n const actionDir = path.dirname(path.resolve(actionPath));\n this.log.debug(`Load ${actionPath} from ${actionDir}`);\n // Check if the action file exists\n if (!fs.existsSync(actionPath)) {\n throw new Error(`${actionPath} does not exist in ${actionDir}`);\n }\n // Ensure the path is a file and not a directory\n if (!fs.statSync(actionPath).isFile()) {\n throw new Error(`${actionPath} is not a file type at ${actionDir}`);\n }\n\n this.rawYamlString = fs.readFileSync(actionPath, 'utf8');\n\n this.log.debug(`Parse ${actionPath} from ${actionDir}`);\n const actionObj = YAML.parse(this.rawYamlString) as ActionYaml;\n if (Action.validate(actionObj)) {\n return actionObj;\n }\n throw new Error(`Invalid action metadata syntax in ${actionPath}.`);\n }\n\n /**\n * Gets the value of an input.\n }\n\n /**\n * Gets the default value for an input.\n *\n * @param inputName The name of the input.\n * @returns The default value if defined,or undefined\n */\n inputDefault(inputName: string): string | boolean | undefined {\n if (this.inputs) {\n return this.inputs[inputName]?.default ?? undefined;\n }\n return undefined;\n }\n\n /**\n * Stringifies the action back to YAML.\n *\n * @returns The YAML string for debugging.\n */\n stringify(): string {\n try {\n return YAML.stringify(this);\n } catch (error) {\n this.log.error(`Failed to stringify Action. ${error}`);\n // this is just for debugging, continue on error\n return '';\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../src/Action.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAiB,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,OAAO,MAAM,oBAAoB,CAAC;AA6GzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,MAAM,CAAC,QAAQ,CAAC,GAAQ;QACtB,IAAI,MAAM,IAAI,GAAG,IAAI,aAAa,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YAClF,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,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,GAAG,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;OASG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,IAAI,SAAS,CAAC;QACtD,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;YACvD,gDAAgD;YAChD,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * This class represents the metadata of a GitHub action defined in the action.yml file.\n * It provides properties and methods for accessing and manipulating the metadata.\n * [Further reading on the metadata can be found here](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs)\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport YAML from 'yaml';\n\nimport { type Branding, DEFAULT_BRAND_COLOR, DEFAULT_BRAND_ICON } from './constants.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * Represents an input for the action.\n */\nexport type Input = {\n /** Description of the input */\n description: string;\n\n /** Whether the input is required */\n required?: boolean;\n\n /** Default value for the input */\n default?: string;\n /** Optional If the input parameter is used, this string is this.logged as a warning message. You can use this warning to notify users that the input is deprecated and mention any alternatives. */\n deprecationMessage?: string;\n};\n\n/**\n * Represents an output for the action.\n */\nexport interface Output {\n /** Description of the output */\n description?: string;\n value?: string;\n}\ntype CompositeAction = 'composite';\ntype ContainerAction = 'docker';\ntype JavascriptAction = `Node${string}` | `node${string}`;\n\n/**\n * Defines the runs property for container actions.\n */\ntype RunsContainer = {\n 'using': ContainerAction;\n 'image': string;\n 'args'?: string[];\n 'pre-entrypoint'?: string;\n 'post-entrypoint'?: string;\n 'entrypoint'?: string;\n};\n\n/**\n * Defines the runs property for JavaScript actions.\n */\ntype RunsJavascript = {\n /** The runner used to execute the action */\n 'using': JavascriptAction;\n\n /** The entrypoint file for the action */\n 'main': string;\n\n 'pre'?: string;\n 'pre-if'?: string;\n\n 'post-if'?: string;\n\n 'post'?: string;\n};\n\n/**\n * Defines the steps property for composite actions.\n */\ntype Steps = {\n 'shell'?: string;\n 'if'?: string;\n 'run'?: string;\n 'name'?: string;\n 'id'?: string;\n 'working-directory'?: string;\n 'env': { [key: string]: string };\n};\n\n/**\n * Defines the runs property for composite actions.\n */\ntype RunsComposite = {\n /** The runner used to execute the action */\n using: CompositeAction;\n steps: Steps;\n};\n\nexport type ActionType = RunsContainer | RunsJavascript | RunsComposite;\n/**\n * Defines how the action is run.\n */\nexport type ActionYaml = {\n name: string;\n\n author?: string;\n\n /** Description of the action */\n description: string;\n\n /** Branding information */\n branding?: Branding;\n\n /** Input definitions */\n inputs?: { [key: string]: Input };\n\n /** Output definitions */\n outputs?: { [key: string]: Output };\n\n /** How the action is run */\n runs: ActionType;\n\n /** Path to the action */\n path: string;\n};\n/**\n * Parses and represents metadata from action.yml.\n */\nexport default class Action implements ActionYaml {\n static validate(obj: any): obj is ActionType {\n if ('name' in obj && 'description' in obj && 'runs' in obj && 'using' in obj.runs) {\n return (\n typeof obj.name === 'string' &&\n typeof obj.description === 'string' &&\n typeof obj.runs.using === 'string'\n );\n }\n return false;\n }\n\n log: LogTask;\n\n /** Name of the action */\n name: string;\n\n author?: string;\n\n /** Description of the action */\n description: string;\n\n /** Branding information */\n branding?: Branding;\n\n /** Input definitions */\n inputs?: { [key: string]: Input };\n\n /** Output definitions */\n outputs?: { [key: string]: Output };\n\n /** How the action is run */\n runs: ActionType;\n\n /** Path to the action */\n path: string;\n\n /** the original file content */\n rawYamlString = '';\n\n /**\n * Creates a new instance of the Action class by loading and parsing action.yml.\n *\n * @param actionPath The path to the action.yml file.\n */\n constructor(actionPath: string, log?: LogTask) {\n // Load and parse action.yml\n this.log = log ?? new LogTask(actionPath);\n this.path = actionPath;\n let actionYaml: ActionYaml;\n this.log.debug(`Constucting ${actionPath}`);\n try {\n actionYaml = this.loadActionFrom(actionPath);\n } catch (error) {\n throw new Error(`Failed to load ${actionPath}. ${error}`);\n }\n this.log.debug(`Action YAML: ${JSON.stringify(actionYaml)}`);\n\n this.name = actionYaml.name;\n this.author = actionYaml.author;\n this.description = actionYaml.description;\n\n this.branding = {\n color: actionYaml.branding?.color ?? DEFAULT_BRAND_COLOR,\n icon: actionYaml.branding?.icon ?? DEFAULT_BRAND_ICON,\n };\n this.inputs = actionYaml.inputs;\n this.outputs = actionYaml.outputs;\n this.runs = actionYaml.runs;\n }\n\n loadActionFrom(actionPath: string): ActionYaml {\n const actionDir = path.dirname(path.resolve(actionPath));\n this.log.debug(`Load ${actionPath} from ${actionDir}`);\n // Check if the action file exists\n if (!fs.existsSync(actionPath)) {\n throw new Error(`${actionPath} does not exist in ${actionDir}`);\n }\n // Ensure the path is a file and not a directory\n if (!fs.statSync(actionPath).isFile()) {\n throw new Error(`${actionPath} is not a file type at ${actionDir}`);\n }\n\n this.rawYamlString = fs.readFileSync(actionPath, 'utf8');\n\n this.log.debug(`Parse ${actionPath} from ${actionDir}`);\n const actionObj = YAML.parse(this.rawYamlString) as ActionYaml;\n if (Action.validate(actionObj)) {\n return actionObj;\n }\n throw new Error(`Invalid action metadata syntax in ${actionPath}.`);\n }\n\n /**\n * Gets the value of an input.\n }\n\n /**\n * Gets the default value for an input.\n *\n * @param inputName The name of the input.\n * @returns The default value if defined,or undefined\n */\n inputDefault(inputName: string): string | boolean | undefined {\n if (this.inputs) {\n return this.inputs[inputName]?.default ?? undefined;\n }\n return undefined;\n }\n\n /**\n * Stringifies the action back to YAML.\n *\n * @returns The YAML string for debugging.\n */\n stringify(): string {\n try {\n return YAML.stringify(this);\n } catch (error) {\n this.log.error(`Failed to stringify Action. ${error}`);\n // this is just for debugging, continue on error\n return '';\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAqBzC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC7B,KAAK,CAAU;IAEf,IAAI,CAAU;IAEd,YAAY,CAAU;IAEtB,KAAK,CAAU;IAEf,KAAK,CAAS;IAEd,iBAAiB,CAAU;IAE3B,UAAU,CAAc;IAExB,QAAQ,CAAW;IAEnB;;;OAGG;IACH,UAAU,CAAC,MAAc;QACvB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,UAAkB;QAC3B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3C,IAAI;YACF,MAAM,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;SACxD;QAAC,OAAO,KAAK,EAAE;YACd,GAAG,CAAC,KAAK,CAAC,6BAA6B,SAAS,GAAG,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC;SACb;QAED,IAAI;YACF,MAAM,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACtE,GAAG,CAAC,IAAI,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;SACnD;QAAC,OAAO,KAAK,EAAE;YACd,GAAG,CAAC,KAAK,CAAC,8BAA8B,UAAU,GAAG,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports the necessary modules and defines two interfaces: `Versioning` and `Paths`.\n * It also defines a class named `GHActionDocsConfig` that represents the configuration for generating GitHub Actions documentation.\n * The class has properties that correspond to the configuration options and a method `loadInputs` to load the configuration from the provided `Inputs` object.\n * The class also has a method `save` to save the configuration to a file.\n */\n\nimport { promises as fsPromises } from 'node:fs';\nimport path from 'node:path';\n\nimport type Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * Represents the versioning configuration for GitHub Actions documentation.\n */\nexport interface Versioning {\n enabled?: boolean;\n prefix?: string;\n override?: string;\n branch?: string;\n badge?: string;\n}\n\n/**\n * Represents the paths configuration for GitHub Actions documentation.\n */\nexport interface Paths {\n action: string;\n readme: string;\n}\n\n/**\n * Represents the configuration for generating GitHub Actions documentation.\n */\nexport class GHActionDocsConfig {\n owner?: string;\n\n repo?: string;\n\n title_prefix?: string;\n\n title?: string;\n\n paths?: Paths;\n\n branding_svg_path?: string;\n\n versioning?: Versioning;\n\n prettier?: boolean;\n\n /**\n * Loads the configuration from the provided `Inputs` object.\n * @param {Inputs} inputs - The `Inputs` object containing the configuration values.\n */\n loadInputs(inputs: Inputs): void {\n const config = inputs.config.get();\n this.owner = config.owner;\n this.repo = config.repo;\n this.title_prefix = config.title_prefix;\n this.title = config.title;\n this.paths = config.paths;\n this.branding_svg_path = config.branding_svg_path;\n this.versioning = config.versioning;\n this.prettier = config.prettier;\n }\n\n /**\n * Saves the configuration to a file. If the file exists, it will be overwritten.\n * @param {string} configPath - The path to the configuration file.\n */\n async save(configPath: string): Promise<void> {\n const log = new LogTask('config:save');\n const directory = path.dirname(configPath);\n\n try {\n await fsPromises.mkdir(directory, { recursive: true });\n } catch (error) {\n log.error(`Error creating directory: ${directory}.`);\n throw error;\n }\n\n try {\n await fsPromises.writeFile(configPath, JSON.stringify(this, null, 2));\n log.info(`Config file written to: ${configPath}`);\n } catch (error) {\n log.error(`Error writing config file: ${configPath}.`);\n throw error;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAqBzC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC7B,KAAK,CAAU;IAEf,IAAI,CAAU;IAEd,YAAY,CAAU;IAEtB,KAAK,CAAU;IAEf,KAAK,CAAS;IAEd,iBAAiB,CAAU;IAE3B,UAAU,CAAc;IAExB,QAAQ,CAAW;IAEnB;;;OAGG;IACH,UAAU,CAAC,MAAc;QACvB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,UAAkB;QAC3B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,6BAA6B,SAAS,GAAG,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACtE,GAAG,CAAC,IAAI,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,8BAA8B,UAAU,GAAG,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports the necessary modules and defines two interfaces: `Versioning` and `Paths`.\n * It also defines a class named `GHActionDocsConfig` that represents the configuration for generating GitHub Actions documentation.\n * The class has properties that correspond to the configuration options and a method `loadInputs` to load the configuration from the provided `Inputs` object.\n * The class also has a method `save` to save the configuration to a file.\n */\n\nimport { promises as fsPromises } from 'node:fs';\nimport path from 'node:path';\n\nimport type Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * Represents the versioning configuration for GitHub Actions documentation.\n */\nexport interface Versioning {\n enabled?: boolean;\n prefix?: string;\n override?: string;\n branch?: string;\n badge?: string;\n}\n\n/**\n * Represents the paths configuration for GitHub Actions documentation.\n */\nexport interface Paths {\n action: string;\n readme: string;\n}\n\n/**\n * Represents the configuration for generating GitHub Actions documentation.\n */\nexport class GHActionDocsConfig {\n owner?: string;\n\n repo?: string;\n\n title_prefix?: string;\n\n title?: string;\n\n paths?: Paths;\n\n branding_svg_path?: string;\n\n versioning?: Versioning;\n\n prettier?: boolean;\n\n /**\n * Loads the configuration from the provided `Inputs` object.\n * @param {Inputs} inputs - The `Inputs` object containing the configuration values.\n */\n loadInputs(inputs: Inputs): void {\n const config = inputs.config.get();\n this.owner = config.owner;\n this.repo = config.repo;\n this.title_prefix = config.title_prefix;\n this.title = config.title;\n this.paths = config.paths;\n this.branding_svg_path = config.branding_svg_path;\n this.versioning = config.versioning;\n this.prettier = config.prettier;\n }\n\n /**\n * Saves the configuration to a file. If the file exists, it will be overwritten.\n * @param {string} configPath - The path to the configuration file.\n */\n async save(configPath: string): Promise<void> {\n const log = new LogTask('config:save');\n const directory = path.dirname(configPath);\n\n try {\n await fsPromises.mkdir(directory, { recursive: true });\n } catch (error) {\n log.error(`Error creating directory: ${directory}.`);\n throw error;\n }\n\n try {\n await fsPromises.writeFile(configPath, JSON.stringify(this, null, 2));\n log.info(`Config file written to: ${configPath}`);\n } catch (error) {\n log.error(`Error writing config file: ${configPath}.`);\n throw error;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts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C,GAAG,CAAC,CAAC;KACzB;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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,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 +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;I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AAY,GAAG,YAAY,CAAC,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF;;WAEG;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;YAC9B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SAC3C;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;YAChB,IAAI;gBACF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;aAC1C;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;gBAC3B,WAAW;aACZ;SACF;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;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,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AED,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 +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,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,CAAC;AACvF,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,OAAe;IACrD,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IAC7B,IAAI,IAAY,CAAC;IACjB,QAAQ,IAAI,EAAE;QACZ,KAAK,OAAO,CAAC,CAAC;YACZ,IAAI,GAAG,GAA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,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,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,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,CAAC;AACvF,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,OAAe;IACrD,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IAC7B,IAAI,IAAY,CAAC;IACjB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO,CAAC,CAAC,CAAC;Y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;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 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/markdowner/index.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,YAAoB;IACzE,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACtD,OAAO,OAAO,CAAC,UA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,CAAC;iBAClD;qBAAM,IAAI,CAAC,KAAK,CAAC,EAAE;oBAClB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;iBAC9B;qBAAM;oBACL,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;iBAC9C;gBACD,GAAG,IAAI,CAAC,CAAC;aACV;SACF;QACD,aAAa,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC,IAAI,CAAC,CAAC;KACR;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,eAAe,4BAA4B,CAAC","sourcesContent":["/**\n * Types representing a 2D array of strings for a Markdown table.\n */\nexport type MarkdownArrayRowType = string[][];\nexport type MarkdownArrayItemType = string;\n\n/**\n * Fills a string to a desired width by padding with spaces.\n *\n * @param text - The text to pad.\n * @param width - The desired total width.\n * @param paddingStart - Number of spaces to pad at the start.\n * @returns The padded string.\n */\nexport function padString(text: string, width: number, paddingStart: number): string {\n return ' '.repeat(paddingStart) + text.padEnd(width);\n}\n\n/**\n * Escapes special Markdown characters in a string.\n *\n * @param text - The text to escape.\n * @returns The escaped text.\n */\nexport function markdownEscapeTableCell(text: string): string {\n return text.replaceAll('\\n', '<br />').replaceAll('|', '\\\\|');\n}\n\n/**\n * Escapes inline code blocks in a Markdown string.\n *\n * @param content - Markdown string.\n * @returns String with escaped inline code blocks.\n */\nexport function markdownEscapeInlineCode(content: string): string {\n return content.replaceAll(/`([^`]*)`/g, '<code>$1</code>').replaceAll('><!--', '>\\\\<!--');\n}\n/**\n * Clones a 2D array.\n *\n * @param arr - Array to clone.\n * @returns Cloned array.\n */\nexport function cloneArray(arr: MarkdownArrayRowType): MarkdownArrayRowType {\n return arr.map((innerArr) => [...innerArr]);\n}\n\n/**\n * Gets max and min column counts from 2D array.\n *\n * @param data - 2D string array.\n * @returns Object with max and min cols.\n */\nexport function getColumnCounts(data: MarkdownArrayRowType): {\n maxCols: number;\n minCols: number;\n} {\n let maxCols = 0;\n let minCols = 0;\n\n for (const e of data) {\n const numCols = e.length;\n maxCols = Math.max(maxCols, numCols);\n minCols = minCols === 0 ? numCols : Math.min(minCols, numCols);\n }\n\n return { maxCols, minCols };\n}\n\n/**\n * Pads 2D array rows to equal length.\n *\n * @param data - 2D array to pad.\n * @param maxCols - Number of columns to pad to.\n * @returns Padded 2D array.\n */\nexport function padArrayRows(data: MarkdownArrayRowType, maxCols: number): MarkdownArrayRowType {\n return data.map((row) => {\n const padding = Array.from({ length: maxCols - row.length }).fill('');\n return [...row, ...padding];\n }) as MarkdownArrayRowType;\n}\n\n/**\n * Converts a 2D array of strings to a Markdown table.\n *\n * @param data - 2D string array.\n * @returns Markdown table string.\n */\nexport function ArrayOfArraysToMarkdownTable(providedTableContent: MarkdownArrayRowType): string {\n const clonedData = cloneArray(providedTableContent);\n const { maxCols } = getColumnCounts(clonedData);\n const paddedData = padArrayRows(clonedData, maxCols);\n const maxRows = paddedData.length;\n\n const markdownArrayRowsLength = maxRows + 1;\n const markdownArrayEntriesLength = maxCols * 2 + 1;\n const markdownArrays: MarkdownArrayRowType = Array.from({ length: markdownArrayRowsLength }, () =>\n Array.from({ length: markdownArrayEntriesLength }, () => '|'),\n );\n\n const outputStrings: string[] = [];\n let i = 0;\n for (const row of markdownArrays) {\n let col = 0;\n const idx = i > 1 ? i - 1 : 0;\n const dataRow = paddedData[idx];\n for (let j = 0; j < row.length; j++) {\n let content = markdownEscapeTableCell(dataRow[col] ?? '');\n content = markdownEscapeInlineCode(content);\n if (j % 2 === 1) {\n if (i === 0) {\n markdownArrays[i][j] = ` **${content.trim()}** `;\n } else if (i === 1) {\n markdownArrays[i][j] = '---';\n } else {\n markdownArrays[i][j] = ` ${content.trim()} `;\n }\n col += 1;\n }\n }\n outputStrings.push(`${markdownArrays[i].join('')}\\n`);\n i += 1;\n }\n return outputStrings.join('');\n}\n\nexport default ArrayOfArraysToMarkdownTable;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/markdowner/index.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,YAAoB;IACzE,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACtD,OAAO,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC5F,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAyB;IAClD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAA0B;IAIxD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;QACzB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrC,OAAO,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CA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of strings for a Markdown table.\n */\nexport type MarkdownArrayRowType = string[][];\nexport type MarkdownArrayItemType = string;\n\n/**\n * Fills a string to a desired width by padding with spaces.\n *\n * @param text - The text to pad.\n * @param width - The desired total width.\n * @param paddingStart - Number of spaces to pad at the start.\n * @returns The padded string.\n */\nexport function padString(text: string, width: number, paddingStart: number): string {\n return ' '.repeat(paddingStart) + text.padEnd(width);\n}\n\n/**\n * Escapes special Markdown characters in a string.\n *\n * @param text - The text to escape.\n * @returns The escaped text.\n */\nexport function markdownEscapeTableCell(text: string): string {\n return text.replaceAll('\\n', '<br />').replaceAll('|', '\\\\|');\n}\n\n/**\n * Escapes inline code blocks in a Markdown string.\n *\n * @param content - Markdown string.\n * @returns String with escaped inline code blocks.\n */\nexport function markdownEscapeInlineCode(content: string): string {\n return content.replaceAll(/`([^`]*)`/g, '<code>$1</code>').replaceAll('><!--', '>\\\\<!--');\n}\n/**\n * Clones a 2D array.\n *\n * @param arr - Array to clone.\n * @returns Cloned array.\n */\nexport function cloneArray(arr: MarkdownArrayRowType): MarkdownArrayRowType {\n return arr.map((innerArr) => [...innerArr]);\n}\n\n/**\n * Gets max and min column counts from 2D array.\n *\n * @param data - 2D string array.\n * @returns Object with max and min cols.\n */\nexport function getColumnCounts(data: MarkdownArrayRowType): {\n maxCols: number;\n minCols: number;\n} {\n let maxCols = 0;\n let minCols = 0;\n\n for (const e of data) {\n const numCols = e.length;\n maxCols = Math.max(maxCols, numCols);\n minCols = minCols === 0 ? numCols : Math.min(minCols, numCols);\n }\n\n return { maxCols, minCols };\n}\n\n/**\n * Pads 2D array rows to equal length.\n *\n * @param data - 2D array to pad.\n * @param maxCols - Number of columns to pad to.\n * @returns Padded 2D array.\n */\nexport function padArrayRows(data: MarkdownArrayRowType, maxCols: number): MarkdownArrayRowType {\n return data.map((row) => {\n const padding = Array.from({ length: maxCols - row.length }).fill('');\n return [...row, ...padding];\n }) as MarkdownArrayRowType;\n}\n\n/**\n * Converts a 2D array of strings to a Markdown table.\n *\n * @param data - 2D string array.\n * @returns Markdown table string.\n */\nexport function ArrayOfArraysToMarkdownTable(providedTableContent: MarkdownArrayRowType): string {\n const clonedData = cloneArray(providedTableContent);\n const { maxCols } = getColumnCounts(clonedData);\n const paddedData = padArrayRows(clonedData, maxCols);\n const maxRows = paddedData.length;\n\n const markdownArrayRowsLength = maxRows + 1;\n const markdownArrayEntriesLength = maxCols * 2 + 1;\n const markdownArrays: MarkdownArrayRowType = Array.from({ length: markdownArrayRowsLength }, () =>\n Array.from({ length: markdownArrayEntriesLength }, () => '|'),\n );\n\n const outputStrings: string[] = [];\n let i = 0;\n for (const row of markdownArrays) {\n let col = 0;\n const idx = i > 1 ? i - 1 : 0;\n const dataRow = paddedData[idx];\n for (let j = 0; j < row.length; j++) {\n let content = markdownEscapeTableCell(dataRow[col] ?? '');\n content = markdownEscapeInlineCode(content);\n if (j % 2 === 1) {\n if (i === 0) {\n markdownArrays[i][j] = ` **${content.trim()}** `;\n } else if (i === 1) {\n markdownArrays[i][j] = '---';\n } else {\n markdownArrays[i][j] = ` ${content.trim()} `;\n }\n col += 1;\n }\n }\n outputStrings.push(`${markdownArrays[i].join('')}\\n`);\n i += 1;\n }\n return outputStrings.join('');\n}\n\nexport default ArrayOfArraysToMarkdownTable;\n"]}
@@ -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,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,MA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*\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,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,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC,KAAK,EAAE;QACnB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,MAAM;QACd,0BAA0B,EAAE,MAAM;QAClC,GAAG,EAAE;KACN,CAAC,CAAC;AACL,CAAC;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,CAAC,KAAK,EAAE;QACnB,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,MAAM,GAAG,QAAQ;IAEjB,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,IAAI,EAAE,CAAC;IACjC,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 = 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 +1 @@
1
- {"version":3,"file":"readme-editor.js","sourceRoot":"","sources":["../../src/readme-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAEzE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAErE,MAAM,CAAC,OAAO,OAAO,YAAY;IACvB,GAAG,GAAG,IAAI,OAAO,CAA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B,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;SACzC;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports the necessary modules and defines a class named `ReadmeEditor`.\n * The class represents an editor for modifying a README file.\n * It has methods to update specific sections within the file and dump the modified content back to the file.\n */\n\nimport * as fs from 'node:fs';\nimport { EOL } from 'node:os';\n\nimport * as core from '@actions/core';\n\nimport { indexOfRegex, lastIndexOfRegex } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport { formatMarkdown } from './prettier.js';\n\n/**\n * The format for the start token of a section.\n */\n\nexport const startTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+start\\\\s+%s\\\\s+-->';\n\n/**\n * The format for the end token of a section.\n */\nexport const endTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+end\\\\s+%s\\\\s+-->';\n\nexport default class ReadmeEditor {\n private log = new LogTask('ReadmeEditor');\n\n /**\n * The path to the README file.\n */\n private readonly filePath: string;\n\n private fileContent: string;\n\n /**\n * Creates a new instance of `ReadmeEditor`.\n * @param {string} filePath - The path to the README file.\n */\n constructor(filePath: string) {\n this.filePath = filePath;\n try {\n fs.accessSync(filePath);\n this.fileContent = fs.readFileSync(filePath, 'utf8');\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_before', this.fileContent);\n }\n } catch (error) {\n this.log.fail(`Readme at '${filePath}' does not exist.`);\n throw error;\n }\n }\n\n /**\n * Gets the indexes of the start and end tokens for a given section.\n * @param {string} token - The section token.\n * @returns {number[]} - The indexes of the start and end tokens.\n */\n getTokenIndexes(token: string, logTask?: LogTask): number[] {\n const log = logTask ?? new LogTask('getTokenIndexes');\n const startRegExp = new RegExp(startTokenFormat.replace('%s', token));\n const stopRegExp = new RegExp(endTokenFormat.replace('%s', token));\n const startIndex = lastIndexOfRegex(this.fileContent, startRegExp);\n if (startIndex === -1) {\n log.debug(`No start token found for section '${token}'. Skipping`);\n return [];\n }\n\n const stopIndex = indexOfRegex(this.fileContent, stopRegExp);\n if (stopIndex === -1) {\n log.debug(`No start or end token found for section '${token}'. Skipping`);\n return [];\n }\n\n return [startIndex, stopIndex];\n }\n\n /**\n * Updates a specific section in the README file with the provided content.\n * @param {string} name - The name of the section.\n * @param {string | string[]} providedContent - The content to update the section with.\n * @param {boolean} addNewlines - Whether to add newlines before and after the content.\n */\n updateSection(name: string, providedContent: string | string[], addNewlines = true): void {\n const log = new LogTask(name);\n const content = (\n Array.isArray(providedContent) ? providedContent.join(EOL) : (providedContent ?? '')\n ).trim();\n log.info(`Looking for the ${name} token in ${this.filePath}`);\n\n const [startIndex, stopIndex] = this.getTokenIndexes(name, log);\n if (startIndex && stopIndex) {\n const beforeContent = this.fileContent.slice(0, startIndex);\n const afterContent = this.fileContent.slice(stopIndex);\n\n this.fileContent = addNewlines\n ? `${beforeContent}\\n\\n${content}\\n${afterContent}`\n : `${beforeContent}${content}${afterContent}`;\n }\n }\n\n /**\n * Dumps the modified content back to the README file.\n * @returns {Promise<void>}\n */\n async dumpToFile(): Promise<void> {\n const content = await formatMarkdown(this.fileContent);\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_after', content);\n }\n return fs.promises.writeFile(this.filePath, content, 'utf8');\n }\n}\n"]}
1
+ {"version":3,"file":"readme-editor.js","sourceRoot":"","sources":["../../src/readme-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE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C,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 indexes of the start and end tokens for a given section.\n * @param {string} token - The section token.\n * @returns {number[]} - The indexes of the start and end tokens.\n */\n getTokenIndexes(token: string, logTask?: LogTask): number[] {\n const log = logTask ?? new LogTask('getTokenIndexes');\n const startRegExp = new RegExp(startTokenFormat.replace('%s', token));\n const stopRegExp = new RegExp(endTokenFormat.replace('%s', token));\n const startIndex = lastIndexOfRegex(this.fileContent, startRegExp);\n if (startIndex === -1) {\n log.debug(`No start token found for section '${token}'. Skipping`);\n return [];\n }\n\n const stopIndex = indexOfRegex(this.fileContent, stopRegExp);\n if (stopIndex === -1) {\n log.debug(`No start or end token found for section '${token}'. Skipping`);\n return [];\n }\n\n return [startIndex, stopIndex];\n }\n\n /**\n * Updates a specific section in the README file with the provided content.\n * @param {string} name - The name of the section.\n * @param {string | string[]} providedContent - The content to update the section with.\n * @param {boolean} addNewlines - Whether to add newlines before and after the content.\n */\n updateSection(name: string, providedContent: string | string[], addNewlines = true): void {\n const log = new LogTask(name);\n const content = (\n Array.isArray(providedContent) ? providedContent.join(EOL) : (providedContent ?? '')\n ).trim();\n log.info(`Looking for the ${name} token in ${this.filePath}`);\n\n const [startIndex, stopIndex] = this.getTokenIndexes(name, log);\n if (startIndex && stopIndex) {\n const beforeContent = this.fileContent.slice(0, startIndex);\n const afterContent = this.fileContent.slice(stopIndex);\n\n this.fileContent = addNewlines\n ? `${beforeContent}\\n\\n${content}\\n${afterContent}`\n : `${beforeContent}${content}${afterContent}`;\n }\n }\n\n /**\n * Dumps the modified content back to the README file.\n * @returns {Promise<void>}\n */\n async dumpToFile(): Promise<void> {\n const content = await formatMarkdown(this.fileContent);\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_after', content);\n }\n return fs.promises.writeFile(this.filePath, content, 'utf8');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"readme-generator.js","sourceRoot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Q,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;SAC/D;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC3C;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,mBAAoC,IAAI,CAAC,MAAM,CAAC,QAAQ;QACrE,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAE5D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports various modules and defines a function named 'generateDocs'.\n * The function is responsible for generating documentation for the README.md file based on the provided inputs.\n * It iterates through each section defined in the 'inputs.sections' array and calls the 'updateSection' function to update the corresponding section in the README.md file.\n * If an error occurs during the update of a section, it logs the error message and stops the process.\n * Finally, it saves the updated README.md file and calls the 'save' function.\n */\n\nimport * as core from '@actions/core';\n\nimport { ReadmeSection } from './constants.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\nimport updateSection from './sections/index.js';\n\nexport type SectionKV = Record<string, string>;\n/**\n * Class for managing README generation.\n */\nexport class ReadmeGenerator {\n /**\n * The Inputs instance.\n */\n private inputs: Inputs;\n\n /**\n * The Logger instance.\n */\n private log: LogTask;\n\n /**\n * Initializes the ReadmeGenerator.\n *\n * @param inputs - The Inputs instance\n * @param log - The Logger instance\n */\n constructor(inputs: Inputs, log: LogTask) {\n this.inputs = inputs;\n this.log = log;\n }\n\n /**\n * Updates the README sections.\n *\n * @param sections - The sections array\n * @returns Promise array of section KV objects\n */\n updateSections(sections: ReadmeSection[]): Promise<SectionKV>[] {\n const promises: Promise<SectionKV>[] = [];\n\n for (const section of sections) {\n promises.push(updateSection(section, this.inputs));\n }\n\n return promises;\n }\n\n /**\n * Resolves the section update promises.\n *\n * @param promises - The promise array\n * @returns Promise resolving to combined sections KV\n */\n async resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV> {\n this.log.debug('Resolving updates');\n const results = await Promise.all(promises);\n const sections: SectionKV = {};\n\n for (const result of results) {\n Object.assign(sections, result);\n }\n\n return sections;\n }\n\n /**\n * Outputs the sections KV to GitHub output.\n *\n * @param sections - The sections KV\n */\n outputSections(sections: SectionKV): void {\n if (process.env.GITHUB_ACTIONS) {\n this.log.debug('Outputting sections');\n core.setOutput('sections', JSON.stringify(sections, null, 2));\n } else {\n this.log.debug('Not outputting sections');\n }\n }\n\n /**\n * Generates the README documentation.\n *\n * @returns Promise resolving when done\n */\n async generate(providedSections: ReadmeSection[] = this.inputs.sections): Promise<void> {\n const sectionPromises = this.updateSections(providedSections);\n const sections = await this.resolveUpdates(sectionPromises);\n\n this.outputSections(sections);\n\n return this.inputs.readmeEditor.dumpToFile();\n }\n}\n"]}
1
+ {"version":3,"file":"readme-generator.js","sourceRoot":"","sources":["../../src/readme-generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAKtC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACK,MAAM,CAAS;IAEvB;;OAEG;IACK,GAAG,CAAU;IAErB;;;;;OAKG;IACH,YAAY,MAAc,EAAE,GAAY;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,QAAyB;QACtC,MAAM,QAAQ,GAAyB,EAAE,CAAC;QAE1C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,QAAQ,CAAC,IAAI,CAAC,aAAa,CA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ourcesContent":["/**\n * This TypeScript code imports various modules and defines a function named 'generateDocs'.\n * The function is responsible for generating documentation for the README.md file based on the provided inputs.\n * It iterates through each section defined in the 'inputs.sections' array and calls the 'updateSection' function to update the corresponding section in the README.md file.\n * If an error occurs during the update of a section, it logs the error message and stops the process.\n * Finally, it saves the updated README.md file and calls the 'save' function.\n */\n\nimport * as core from '@actions/core';\n\nimport { ReadmeSection } from './constants.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\nimport updateSection from './sections/index.js';\n\nexport type SectionKV = Record<string, string>;\n/**\n * Class for managing README generation.\n */\nexport class ReadmeGenerator {\n /**\n * The Inputs instance.\n */\n private inputs: Inputs;\n\n /**\n * The Logger instance.\n */\n private log: LogTask;\n\n /**\n * Initializes the ReadmeGenerator.\n *\n * @param inputs - The Inputs instance\n * @param log - The Logger instance\n */\n constructor(inputs: Inputs, log: LogTask) {\n this.inputs = inputs;\n this.log = log;\n }\n\n /**\n * Updates the README sections.\n *\n * @param sections - The sections array\n * @returns Promise array of section KV objects\n */\n updateSections(sections: ReadmeSection[]): Promise<SectionKV>[] {\n const promises: Promise<SectionKV>[] = [];\n\n for (const section of sections) {\n promises.push(updateSection(section, this.inputs));\n }\n\n return promises;\n }\n\n /**\n * Resolves the section update promises.\n *\n * @param promises - The promise array\n * @returns Promise resolving to combined sections KV\n */\n async resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV> {\n this.log.debug('Resolving updates');\n const results = await Promise.all(promises);\n const sections: SectionKV = {};\n\n for (const result of results) {\n Object.assign(sections, result);\n }\n\n return sections;\n }\n\n /**\n * Outputs the sections KV to GitHub output.\n *\n * @param sections - The sections KV\n */\n outputSections(sections: SectionKV): void {\n if (process.env.GITHUB_ACTIONS) {\n this.log.debug('Outputting sections');\n core.setOutput('sections', JSON.stringify(sections, null, 2));\n } else {\n this.log.debug('Not outputting sections');\n }\n }\n\n /**\n * Generates the README documentation.\n *\n * @returns Promise resolving when done\n */\n async generate(providedSections: ReadmeSection[] = this.inputs.sections): Promise<void> {\n const sectionPromises = this.updateSections(providedSections);\n const sections = await this.resolveUpdates(sectionPromises);\n\n this.outputSections(sections);\n\n return this.inputs.readmeEditor.dumpToFile();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc,EAAE,GAAY;IACvD,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE;QACrC,IAAI;YACF,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACpC;QAAC,OAAO,KAAK,EAAE;YACd,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;SACvB;KACF;AACH,CAAC","sourcesContent":["/**\n * This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.\n * The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.\n * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.\n * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.\n */\n\nimport { GHActionDocsConfig } from './config.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * This script rebuilds the usage section in the README.md to be consistent with the action.yml\n * @param {Inputs} inputs - the inputs class\n */\nexport default function save(inputs: Inputs, log: LogTask): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get().save === true) {\n try {\n docsConfig.save(inputs.configPath);\n } catch (error) {\n log.error(`${error}`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc,EAAE,GAAY;IACvD,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.\n * The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.\n * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.\n * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.\n */\n\nimport { GHActionDocsConfig } from './config.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * This script rebuilds the usage section in the README.md to be consistent with the action.yml\n * @param {Inputs} inputs - the inputs class\n */\nexport default function save(inputs: Inputs, log: LogTask): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get().save === true) {\n try {\n docsConfig.save(inputs.configPath);\n } catch (error) {\n log.error(`${error}`);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.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,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SACtC;QACD,KAAK,SAAS,CAAC,CAAC;YACd,OAAO,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SACvC;QACD,OAAO,CAAC,CAAC;YACP,GAAG,CAAC,KAAK,CAAC,oCAAoC,OAAO,6BAA6B,CAAC,CAAC;YACpF,OAAO,EAAE,CAAC;SACX;KACF;AACH,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating different sections of the README.md file based on the provided section input.\n * It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.\n * @param {ReadmeSection} section - The section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n * @returns {Promise<void>} A promise that resolves once the section is updated.\n */\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport updateBadges from './update-badges.js';\nimport updateBranding from './update-branding.js';\nimport updateDescription from './update-description.js';\nimport updateInputs from './update-inputs.js';\nimport updateOutputs from './update-outputs.js';\nimport updateTitle from './update-title.js';\nimport updateUsage from './update-usage.js';\n\nconst log = new LogTask('updateSection');\n\nexport default async function updateSection(\n section: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);\n // &&\n // ['branding', 'title'].includes(section) &&\n // inputs.config.get('branding_as_title_prefix') !== true\n if (startToken === -1 || stopToken === -1) {\n return {};\n }\n switch (section) {\n case 'branding': {\n return updateBranding(section, inputs);\n }\n case 'badges': {\n return updateBadges(section, inputs);\n }\n case 'usage': {\n return updateUsage(section, inputs);\n }\n case 'title': {\n return updateTitle(section, inputs);\n }\n case 'description': {\n return updateDescription(section, inputs);\n }\n case 'inputs': {\n return updateInputs(section, inputs);\n }\n case 'outputs': {\n return updateOutputs(section, inputs);\n }\n default: {\n log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);\n return {};\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;AAEzC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,OAAsB,EACtB,MAAc;IAEd,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC7E,KAAK;IACL,6CAA6C;IAC7C,yDAAyD;IACzD,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,OAAO,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,GAAG,CAAC,KAAK,CAAC,oCAAoC,OAAO,6BAA6B,CAAC,CAAC;YACpF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating different sections of the README.md file based on the provided section input.\n * It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.\n * @param {ReadmeSection} section - The section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n * @returns {Promise<void>} A promise that resolves once the section is updated.\n */\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport updateBadges from './update-badges.js';\nimport updateBranding from './update-branding.js';\nimport updateDescription from './update-description.js';\nimport updateInputs from './update-inputs.js';\nimport updateOutputs from './update-outputs.js';\nimport updateTitle from './update-title.js';\nimport updateUsage from './update-usage.js';\n\nconst log = new LogTask('updateSection');\n\nexport default async function updateSection(\n section: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);\n // &&\n // ['branding', 'title'].includes(section) &&\n // inputs.config.get('branding_as_title_prefix') !== true\n if (startToken === -1 || stopToken === -1) {\n return {};\n }\n switch (section) {\n case 'branding': {\n return updateBranding(section, inputs);\n }\n case 'badges': {\n return updateBadges(section, inputs);\n }\n case 'usage': {\n return updateUsage(section, inputs);\n }\n case 'title': {\n return updateTitle(section, inputs);\n }\n case 'description': {\n return updateDescription(section, inputs);\n }\n case 'inputs': {\n return updateInputs(section, inputs);\n }\n case 'outputs': {\n return updateOutputs(section, inputs);\n }\n default: {\n log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);\n return {};\n }\n }\n}\n"]}