github-action-readme-generator 1.9.2 → 1.9.3
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.
- package/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/bin/index.js +130 -53
- package/dist/mjs/Action.d.ts +15 -15
- package/dist/mjs/Action.js +11 -4
- package/dist/mjs/Action.js.map +1 -1
- package/dist/mjs/constants.js.map +1 -1
- package/dist/mjs/helpers.d.ts +4 -5
- package/dist/mjs/helpers.js +104 -30
- package/dist/mjs/helpers.js.map +1 -1
- package/dist/mjs/inputs.d.ts +3 -11
- package/dist/mjs/inputs.js +14 -14
- package/dist/mjs/inputs.js.map +1 -1
- package/dist/mjs/logtask/index.js +1 -1
- package/dist/mjs/logtask/index.js.map +1 -1
- package/dist/mjs/prettier.js +4 -3
- package/dist/mjs/prettier.js.map +1 -1
- package/dist/mjs/readme-editor.js.map +1 -1
- package/dist/mjs/readme-generator.d.ts +3 -3
- package/dist/mjs/readme-generator.js.map +1 -1
- package/dist/mjs/save.d.ts +2 -2
- package/dist/mjs/save.js.map +1 -1
- package/dist/mjs/sections/index.d.ts +1 -1
- package/dist/mjs/sections/index.js +8 -8
- package/dist/mjs/sections/index.js.map +1 -1
- package/dist/mjs/sections/update-badges.d.ts +1 -1
- package/dist/mjs/sections/update-badges.js.map +1 -1
- package/dist/mjs/sections/update-branding.d.ts +1 -1
- package/dist/mjs/sections/update-branding.js.map +1 -1
- package/dist/mjs/sections/update-contents.d.ts +1 -1
- package/dist/mjs/sections/update-contents.js.map +1 -1
- package/dist/mjs/sections/update-description.d.ts +1 -1
- package/dist/mjs/sections/update-description.js.map +1 -1
- package/dist/mjs/sections/update-inputs.d.ts +1 -1
- package/dist/mjs/sections/update-inputs.js.map +1 -1
- package/dist/mjs/sections/update-outputs.d.ts +1 -1
- package/dist/mjs/sections/update-outputs.js.map +1 -1
- package/dist/mjs/sections/update-title.d.ts +1 -1
- package/dist/mjs/sections/update-title.js.map +1 -1
- package/dist/mjs/sections/update-usage.d.ts +1 -1
- package/dist/mjs/sections/update-usage.js.map +1 -1
- package/dist/mjs/svg-editor.d.mts +2 -2
- package/dist/mjs/svg-editor.mjs +3 -3
- package/dist/mjs/svg-editor.mjs.map +1 -1
- package/dist/types/index.d.ts +109 -129
- package/package.json +15 -35
package/dist/mjs/inputs.js
CHANGED
|
@@ -6,25 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import * as fs from 'node:fs';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
9
|
import * as core from '@actions/core';
|
|
11
10
|
import { Context } from '@actions/github/lib/context.js';
|
|
12
11
|
import nconf from 'nconf';
|
|
13
12
|
import YAML from 'yaml';
|
|
14
13
|
import Action from './Action.js';
|
|
15
|
-
import {
|
|
14
|
+
import { ConfigKeys, configFileName, README_SECTIONS } from './constants.js';
|
|
16
15
|
import { repositoryFinder } from './helpers.js';
|
|
17
16
|
import LogTask from './logtask/index.js';
|
|
18
17
|
import ReadmeEditor from './readme-editor.js';
|
|
19
18
|
const { Provider } = nconf;
|
|
20
|
-
/**
|
|
21
|
-
* Get the filename from the import.meta.url
|
|
22
|
-
*/
|
|
23
|
-
export const __filename = fileURLToPath(import.meta.url);
|
|
24
|
-
/**
|
|
25
|
-
* Get the directory name from the filename
|
|
26
|
-
*/
|
|
27
|
-
export const __dirname = path.dirname(__filename);
|
|
28
19
|
/**
|
|
29
20
|
* Change working directory to output of workingDirectory()
|
|
30
21
|
*/
|
|
@@ -243,12 +234,17 @@ const ConfigKeysInputsMap = {
|
|
|
243
234
|
title_prefix: ConfigKeys.TitlePrefix,
|
|
244
235
|
pretty: ConfigKeys.Prettier,
|
|
245
236
|
};
|
|
246
|
-
export function transformGitHubInputsToArgv(log,
|
|
237
|
+
export function transformGitHubInputsToArgv(log, _config, obj) {
|
|
247
238
|
/** The obj.key is always in lowercase, but it checks for it without case sensitivity */
|
|
248
239
|
if (/^(INPUT|input)_[A-Z_a-z]\w*$/.test(obj.key)) {
|
|
249
240
|
log.debug(`Parsing input: ${obj.key} with ith value: ${obj.value}`);
|
|
250
241
|
const keyParsed = obj.key.replace(/^(INPUT|input)_/, '').toLocaleLowerCase();
|
|
251
242
|
const key = ConfigKeysInputsMap[keyParsed] || keyParsed;
|
|
243
|
+
// Skip empty values for owner/repo to allow fallback detection from .git/config or GITHUB_REPOSITORY
|
|
244
|
+
if ((key === 'owner' || key === 'repo') && (!obj.value || obj.value === '')) {
|
|
245
|
+
log.debug(`Ignoring empty ${key} input to allow auto-detection`);
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
252
248
|
log.debug(`New input is ${key} with the value ${obj.value}`);
|
|
253
249
|
return { key, value: obj.value };
|
|
254
250
|
}
|
|
@@ -281,8 +277,8 @@ export function collectAllDefaultValuesFromAction(log, providedMetaActionPath, p
|
|
|
281
277
|
log.debug('Collecting default values from action.yml');
|
|
282
278
|
// This loads the defaults from THIS action's own action.yml file (github-action-readme-generator's action.yml)
|
|
283
279
|
// NOT the user's action.yml file (which is loaded separately via the 'action' input parameter)
|
|
284
|
-
// Therefore, we use
|
|
285
|
-
const thisActionPath = path.join(
|
|
280
|
+
// Therefore, we use import.meta.dirname to find this package's action.yml regardless of where it's installed
|
|
281
|
+
const thisActionPath = path.join(import.meta.dirname, providedMetaActionPath ?? metaActionPath);
|
|
286
282
|
try {
|
|
287
283
|
const defaultValues = {};
|
|
288
284
|
const thisAction = new Action(thisActionPath);
|
|
@@ -352,7 +348,11 @@ export function loadDefaultConfig(log, config, providedContext) {
|
|
|
352
348
|
const repoFromConfig = config.get('repo');
|
|
353
349
|
const ownerInput = ownerFromConfig ?? process.env.INPUT_OWNER ?? '';
|
|
354
350
|
const repoInput = repoFromConfig ?? process.env.INPUT_REPO ?? '';
|
|
355
|
-
|
|
351
|
+
// Get the action path to derive the target repo directory for .git/config lookup
|
|
352
|
+
const actionPath = config.get(ConfigKeys.pathsAction);
|
|
353
|
+
const actionDir = actionPath ? path.dirname(path.resolve(actionPath)) : undefined;
|
|
354
|
+
log.debug(`Action directory for repository detection: ${actionDir ?? 'not specified'}`);
|
|
355
|
+
const repositoryDetail = repositoryFinder(`${ownerInput}/${repoInput}`, context, actionDir);
|
|
356
356
|
log.debug(`repositoryDetail: ${repositoryDetail}`);
|
|
357
357
|
// Apply the default values from the action.yml file
|
|
358
358
|
return config.defaults({
|
package/dist/mjs/inputs.js.map
CHANGED
|
@@ -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,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MAAM,CAAC,GAAG,CAAC,UAAU,CAAqB,CAC1E,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAoB,CAAC;QAC/D,IAAI,CAAC,UAAU;YACb,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAW,CAAC,CAAC;QAC7F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF;;WAEG;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD;;WAEG;QACH,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE5D;;WAEG;QACH,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS;QACP,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;gBAC3B,WAAW;YACb,CAAC;QACH,CAAC;QACD,kEAAkE;QAClE,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * This class handles input configuration and manipulation.\n * It imports various modules and packages for file operations, configuration parsing, and logging.\n * The class has methods for initializing the input configuration, setting default values, and converting the configuration to a string.\n * It also has properties for storing the configuration values, sections, readme path, action instance, and readme editor instance.\n */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\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,CAA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AI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAoB,CAAC;QAC/D,IAAI,CAAC,UAAU;YACb,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAW,CAAC,CAAC;QAC7F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF;;WAEG;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD;;WAEG;QACH,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE5D;;WAEG;QACH,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS;QACP,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;gBAC3B,WAAW;YACb,CAAC;QACH,CAAC;QACD,kEAAkE;QAClE,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * This class handles input configuration and manipulation.\n * It imports various modules and packages for file operations, configuration parsing, and logging.\n * The class has methods for initializing the input configuration, setting default values, and converting the configuration to a string.\n * It also has properties for storing the configuration values, sections, readme path, action instance, and readme editor instance.\n */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport * as core from '@actions/core';\nimport { Context } from '@actions/github/lib/context.js';\nimport nconf from 'nconf';\nimport YAML from 'yaml';\n\nimport Action, { type Input } from './Action.js';\nimport { ConfigKeys, configFileName, README_SECTIONS, type ReadmeSection } from './constants.js';\nimport { repositoryFinder } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport ReadmeEditor from './readme-editor.js';\n\nconst { Provider }: typeof nconf = nconf;\ntype IOptions = nconf.IOptions;\n\n/**\n * Change working directory to output of workingDirectory()\n */\n// process.chdir(workingDirectory());\nexport const metaActionPath = '../../action.yml';\n\nexport type ArgvOptionProperties = {\n [key: string]: {\n alias: string | string[];\n describe: string;\n parseValues?: boolean;\n type?: string;\n };\n};\n/**\n * Represents the command line argument options for the application.\n */\nconst argvOptions: ArgvOptionProperties = {};\n\n/**\n * Save option configuration.\n * @property {string} alias - Alias for the save option.\n * @property {string} describe - Description for the save option.\n * @property {boolean} parseValues - Specifies whether to parse values for the save option.\n * @property {string} type - Type of the save option.\n */\nargvOptions[ConfigKeys.Save] = {\n alias: 'save',\n describe: `Save this config to ${configFileName}`,\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Paths action option configuration.\n * @property {string | string[]} alias - Alias(es) for the pathsAction option.\n * @property {string} type - Type of the pathsAction option.\n * @property {string} describe - Description for the pathsAction option.\n */\nargvOptions[ConfigKeys.pathsAction] = {\n alias: ['pathsAction', 'action'],\n type: 'string',\n describe: 'Path to the action.yml',\n};\n\n/**\n * Paths readme option configuration.\n * @property {string | string[]} alias - Alias(es) for the pathsReadme option.\n * @property {string} type - Type of the pathsReadme option.\n * @property {string} describe - Description for the pathsReadme option.\n */\nargvOptions[ConfigKeys.pathsReadme] = {\n alias: ['pathsReadme', 'readme'],\n type: 'string',\n describe: 'Path to the README file',\n};\n\n/**\n * Branding SVG path option configuration.\n * @property {string} alias - Alias for the svg option.\n * @property {string} type - Type of the svg option.\n * @property {string} describe - Description for the svg option.\n */\nargvOptions[ConfigKeys.BrandingSvgPath] = {\n alias: 'svg',\n type: 'string',\n describe: 'Save and load the branding svg image in the README from this path',\n};\n\n/**\n * Branding as title prefix option configuration.\n * @property {string} alias - Alias for the branding_prefix option.\n * @property {string} type - Type of the branding_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the branding_prefix option.\n * @property {string} describe - Description for the branding_prefix option.\n */\nargvOptions[ConfigKeys.BrandingAsTitlePrefix] = {\n alias: 'branding_prefix',\n type: 'boolean',\n parseValues: true,\n describe: 'Use the branding svg as a prefix for the README title',\n};\n\n/**\n * Owner option configuration.\n * @property {string} alias - Alias for the owner option.\n * @property {string} type - Type of the owner option.\n * @property {string} describe - Description for the owner option.\n */\nargvOptions[ConfigKeys.Owner] = {\n alias: 'owner',\n type: 'string',\n describe: 'The GitHub Action repository owner. i.e: `bitflight-devops`',\n};\n\n/**\n * Repo option configuration.\n * @property {string} alias - Alias for the repo option.\n * @property {string} type - Type of the repo option.\n * @property {string} describe - Description for the repo option.\n */\nargvOptions[ConfigKeys.Repo] = {\n alias: 'repo',\n type: 'string',\n describe: 'The GitHub Action repository name. i.e: `github-action-readme-generator`',\n};\n\n/**\n * Prettier option configuration.\n * @property {string | string[]} alias - Alias(es) for the prettier option.\n * @property {string} type - Type of the prettier option.\n * @property {boolean} parseValues - Specifies whether to parse values for the prettier option.\n * @property {string} describe - Description for the prettier option.\n */\nargvOptions[ConfigKeys.Prettier] = {\n alias: ['pretty', 'prettier'],\n type: 'boolean',\n parseValues: true,\n describe: 'Format the markdown using prettier formatter',\n};\n\n/**\n * Versioning enabled option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_enabled option.\n * @property {string} describe - Description for the versioning_enabled option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_enabled option.\n * @property {string} type - Type of the versioning_enabled option.\n */\nargvOptions[ConfigKeys.VersioningEnabled] = {\n alias: ['versioning', 'versioning_enabled'],\n describe:\n 'Enable the update of the usage version to match the latest version in the package.json file',\n parseValues: true,\n type: 'boolean',\n};\n\n/**\n * Versioning override option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_override option.\n * @property {string} describe - Description for the versioning_override option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_override option.\n */\nargvOptions[ConfigKeys.VersioningOverride] = {\n alias: ['setversion', 'versioning_override', 'version_override'],\n describe: 'Set a specific version to display in the README.md',\n parseValues: true,\n};\n\n/**\n * Versioning prefix option configuration.\n * @property {string | string[]} alias - Alias(es) for the version_prefix option.\n * @property {string} describe - Description for the version_prefix option.\n * @property {boolean} parseValues - Specifies whether to parse values for the version_prefix option.\n */\nargvOptions[ConfigKeys.VersioningPrefix] = {\n alias: ['vp', 'version_prefix'],\n describe: \"Prefix the version with this value (if it isn't already prefixed)\",\n parseValues: true,\n};\n\n/**\n * Versioning branch option configuration.\n * @property {string | string[]} alias - Alias(es) for the versioning_default_branch option.\n * @property {string} describe - Description for the versioning_default_branch option.\n * @property {boolean} parseValues - Specifies whether to parse values for the versioning_default_branch option.\n */\nargvOptions[ConfigKeys.VersioningBranch] = {\n alias: ['branch', 'versioning_default_branch'],\n describe: 'If versioning is disabled show this branch instead',\n parseValues: true,\n};\n\n/**\n * 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 // Skip empty values for owner/repo to allow fallback detection from .git/config or GITHUB_REPOSITORY\n if ((key === 'owner' || key === 'repo') && (!obj.value || obj.value === '')) {\n log.debug(`Ignoring empty ${key} input to allow auto-detection`);\n return undefined;\n }\n\n log.debug(`New input is ${key} with the value ${obj.value}`);\n return { key, value: obj.value };\n }\n log.debug(`Ignoring input: ${obj.key} with ith value: ${obj.value}`);\n return undefined;\n}\n\n/**\n * Sets config value from action file default\n *\n * @param {Action} actionInstance - The action instance\n * @param {string} inputName - The input name\n * @returns {string | boolean | undefined} The default value\n */\nexport function setConfigValueFromActionFileDefault(\n log: LogTask,\n actionInstance: Action,\n inputName: string,\n): string | boolean | undefined {\n if (ConfigKeysInputsMap[inputName] === undefined) {\n log.error(\n `${inputName} from ${\n actionInstance.path\n } does not match a known input. Known inputs are: ${Object.keys(ConfigKeysInputsMap)}`,\n );\n return;\n }\n\n const configName = ConfigKeysInputsMap[inputName];\n const defaultValue = actionInstance.inputDefault(inputName);\n\n log.debug(`Default Value for action.yml: ${inputName} CLI: ${configName} = ${defaultValue}`);\n\n return defaultValue;\n}\n\n/**\n * Collects all default values from action file\n *\n * @returns {IOptions} The default values object\n */\nexport function collectAllDefaultValuesFromAction(\n log: LogTask,\n providedMetaActionPath?: string,\n providedDefaults: {\n [key: string]: Input;\n } = {},\n): IOptions {\n log.debug('Collecting default values from action.yml');\n // This loads the defaults from THIS action's own action.yml file (github-action-readme-generator's action.yml)\n // NOT the user's action.yml file (which is loaded separately via the 'action' input parameter)\n // Therefore, we use import.meta.dirname to find this package's action.yml regardless of where it's installed\n const thisActionPath = path.join(import.meta.dirname, providedMetaActionPath ?? metaActionPath);\n try {\n const defaultValues = {} as IOptions;\n const thisAction = new Action(thisActionPath);\n const defaults: {\n [key: string]: Input;\n } = { ...thisAction.inputs, ...providedDefaults };\n // Collect all of the default values from the action.yml file\n if (defaults) {\n for (const key of Object.keys(defaults)) {\n const mappedKey = ConfigKeysInputsMap[key] ?? key;\n defaultValues[mappedKey] = setConfigValueFromActionFileDefault(log, thisAction, key);\n }\n }\n log.debug(JSON.stringify(defaultValues, null, 2));\n return defaultValues;\n } catch (error) {\n // When running as a CLI tool (e.g., via npx or yarn dlx), the tool's own action.yml\n // may not be present in the node_modules. This is expected behavior, as the tool\n // should still work to generate documentation for other actions.\n log.debug(`Could not load defaults from this tool's action.yml at ${thisActionPath}: ${error}`);\n log.debug('Continuing without default values from action.yml');\n return {} as IOptions;\n }\n}\n\n/**\n * Loads the configuration\n *\n * @returns {ProviderInstance} The configuration instance\n */\nexport function loadConfig(\n log: LogTask,\n providedConfig?: ProviderInstance,\n configFilePath?: string,\n): ProviderInstance {\n log.debug('Loading config from env and argv');\n const config = providedConfig ?? new Provider();\n if (process.env.GITHUB_ACTION === 'true') {\n log.info('Running in GitHub action');\n }\n if (configFilePath) {\n if (fs.existsSync(configFilePath)) {\n log.info(`Config file found: ${configFilePath}`);\n config.file(configFilePath);\n } else {\n log.debug(`Config file not found: ${configFilePath}`);\n }\n }\n\n config\n .env({\n lowerCase: true,\n parseValues: true,\n transform: (obj: KVPairType): undefined | KVPairType => {\n return transformGitHubInputsToArgv(log, config, obj);\n },\n })\n .argv(argvOptions);\n\n return config;\n}\n\n/**\n * Loads the default configuration\n *\n * @param {ProviderInstance} config - The config instance\n * @returns {ProviderInstance} The updated config instance\n */\nexport function loadDefaultConfig(\n log: LogTask,\n config: ProviderInstance,\n providedContext?: Context,\n): ProviderInstance {\n log.debug('Loading default config');\n const defaultValues = collectAllDefaultValuesFromAction(log);\n const context = providedContext ?? new Context();\n\n // Get owner/repo from config (which includes CLI args), falling back to env vars for GitHub Actions\n const ownerFromConfig = config.get('owner') as string | undefined;\n const repoFromConfig = config.get('repo') as string | undefined;\n const ownerInput = ownerFromConfig ?? process.env.INPUT_OWNER ?? '';\n const repoInput = repoFromConfig ?? process.env.INPUT_REPO ?? '';\n\n // Get the action path to derive the target repo directory for .git/config lookup\n const actionPath = config.get(ConfigKeys.pathsAction) as string | undefined;\n const actionDir = actionPath ? path.dirname(path.resolve(actionPath)) : undefined;\n log.debug(`Action directory for repository detection: ${actionDir ?? 'not specified'}`);\n\n const repositoryDetail = repositoryFinder(`${ownerInput}/${repoInput}`, context, actionDir);\n log.debug(`repositoryDetail: ${repositoryDetail}`);\n // Apply the default values from the action.yml file\n return config.defaults({\n ...defaultValues,\n owner: repositoryDetail?.owner,\n repo: repositoryDetail?.repo,\n sections: [...README_SECTIONS] as ReadmeSection[],\n });\n}\n\n/**\n * Represents the required inputs for the action.\n */\nconst RequiredInputs = [\n ConfigKeys.pathsAction,\n ConfigKeys.pathsReadme,\n ConfigKeys.Owner,\n ConfigKeys.Repo,\n] as const;\n\n/**\n * Loads the required configuration\n *\n * @param {ProviderInstance} config - The config instance\n * @returns {ProviderInstance} The updated config instance\n */\nexport function loadRequiredConfig(\n log: LogTask,\n config: ProviderInstance,\n requiredInputs: readonly string[] = RequiredInputs,\n): ProviderInstance {\n log.debug('Loading required config');\n\n return config.required([...requiredInputs]);\n}\n\n/**\n *\n */\nexport function loadAction(log: LogTask, actionPath: string): Action {\n log.debug(`Loading action from: ${actionPath}`);\n if (actionPath) {\n return new Action(path.resolve(actionPath));\n }\n throw new Error(`Action path not found: ${actionPath}`);\n}\n\nexport type InputContext = {\n /**\n * The configuration instance\n */\n config?: ProviderInstance;\n\n /**\n * The readme sections\n */\n sections?: ReadmeSection[];\n\n /**\n * The readme file path\n */\n readmePath?: string;\n\n /**\n * The config file path\n */\n configPath?: string;\n\n /**\n * The action instance\n */\n action?: Action;\n\n /**\n * The readme editor instance\n */\n readmeEditor?: ReadmeEditor;\n\n /**\n * The repository owner\n */\n owner?: string;\n\n /**\n * The repository name\n */\n repo?: string;\n};\n/**\n * Main Inputs class that handles configuration\n */\nexport default class Inputs {\n /**\n * The configuration instance\n */\n config: ProviderInstance;\n\n /**\n * The readme sections\n */\n sections: ReadmeSection[];\n\n /**\n * The readme file path\n */\n readmePath: string;\n\n /**\n * The config file path\n */\n configPath: string;\n\n /**\n * The action instance\n */\n action: Action;\n\n /**\n * The readme editor instance\n */\n readmeEditor: ReadmeEditor;\n\n /**\n * The repository owner\n */\n owner: string;\n\n /**\n * The repository name\n */\n repo: string;\n\n /** The logger for this instance */\n log: LogTask;\n\n /**\n * Initializes a new instance of the Inputs class.\n */\n constructor(providedInputContext: InputContext = {}, log: LogTask = new LogTask('inputs')) {\n this.log = log ?? new LogTask('inputs');\n this.log.debug('Initializing Inputs');\n const inputContext = providedInputContext ?? {};\n this.configPath = inputContext.configPath ?? path.resolve(configFileName);\n this.config = inputContext.config ?? new Provider();\n loadConfig(log, this.config, this.configPath);\n loadDefaultConfig(log, this.config);\n loadRequiredConfig(log, this.config);\n\n this.action = inputContext.action ?? loadAction(log, this.config.get(ConfigKeys.pathsAction));\n this.config.set(\n 'sections',\n inputContext.sections ?? (this.config.get('sections') as ReadmeSection[]),\n );\n this.sections = this.config.get('sections') as ReadmeSection[];\n this.readmePath =\n inputContext.readmePath ?? path.resolve(this.config.get(ConfigKeys.pathsReadme) as string);\n this.readmeEditor = inputContext.readmeEditor ?? new ReadmeEditor(this.readmePath);\n /**\n * Output the readme path that is being parsed\n */\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme', this.readmePath);\n }\n /**\n * owner is required, and if it doesn't exist it is handled by nconf which throws an error\n */\n this.owner = inputContext.owner ?? this.config.get('owner');\n\n /**\n * repo is required, and if it doesn't exist it is handled by nconf which throws an error\n */\n this.repo = inputContext.repo ?? this.config.get('repo');\n }\n\n stringify(): string {\n if (this?.config) {\n try {\n return YAML.stringify(this.config.get());\n } catch (error) {\n this.log.error(`${error}`);\n // continue\n }\n }\n // this is just for debug, no need to stop the process if it fails\n return '';\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import * as core from '@actions/core';
|
|
|
2
2
|
import chalkPkg from 'chalk';
|
|
3
3
|
import { notEmpty } from '../util.js';
|
|
4
4
|
// Chalk color styles
|
|
5
|
-
const { bgRedBright, cyan, green, greenBright, whiteBright, yellow, yellowBright } = chalkPkg;
|
|
5
|
+
const { bgRedBright, cyan, green, greenBright, whiteBright, yellow, yellowBright, } = chalkPkg;
|
|
6
6
|
// Constants for different log step types
|
|
7
7
|
var LogGroup;
|
|
8
8
|
(function (LogGroup) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logtask/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;AAE9F,yCAAyC;AAEzC,IAAK,QAOJ;AAPD,WAAK,QAAQ;IACX,+CAAY,CAAA;IACZ,qDAAW,CAAA;IACX,iDAAS,CAAA;IACT,+CAAQ,CAAA;IACR,iDAAS,CAAA;IACT,+CAAQ,CAAA;AACV,CAAC,EAPI,QAAQ,KAAR,QAAQ,QAOZ;AAED,SAAS,eAAe;IACtB,OAAO,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,EA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AAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;gBAC/B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpF,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,GAAG,EAAE;QAChB,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,GAAG,EAAE;QAChB,+BAA+B;QAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC","sourcesContent":["import * as core from '@actions/core';\nimport chalkPkg from 'chalk';\n\nimport { notEmpty } from '../util.js';\n\n// Chalk color styles\nconst { bgRedBright, cyan, green, greenBright, whiteBright, yellow, yellowBright } = chalkPkg;\n\n// Constants for different log step types\n\nenum LogGroup {\n NO_GROUP = 0,\n START_GROUP,\n END_GROUP,\n IS_ERROR,\n IS_FAILED,\n IS_TITLE,\n}\n\nfunction inGitHubActions(): boolean {\n return notEmpty(process.env.GITHUB_ACTIONS) && process.env.GITHUB_ACTIONS === 'true';\n}\n\nfunction highlightMessage(step: string, message: string): { desc: any; failed: any } {\n let failed = false;\n const ci = inGitHubActions();\n let desc: string;\n switch (step) {\n case 'START': {\n desc = `${message}`;\n break;\n }\n case 'INFO': {\n desc = green(`${message}`);\n break;\n }\n case 'WARN': {\n desc = yellow(`${message}`);\n break;\n }\n case 'SUCCESS': {\n desc = greenBright(`${message}`);\n break;\n }\n case 'FAILURE': {\n desc = ci ? message : yellow.bold(`${message}`);\n failed = true;\n break;\n }\n case 'ERROR': {\n desc = ci ? message : yellow(`${message}`);\n break;\n }\n case '#####': {\n desc = cyan(`${message}`);\n break;\n }\n default: {\n desc = message;\n break;\n }\n }\n return { desc, failed };\n}\nfunction highlightStep(step: string, message: string): string {\n let msg: string;\n const ci = inGitHubActions();\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n switch (step) {\n case 'START': {\n msg = yellowBright(message);\n break;\n }\n case 'SUCCESS': {\n msg = whiteBright(message);\n break;\n }\n case 'FAILURE':\n case 'ERROR': {\n msg = ci ? message : bgRedBright(message);\n break;\n }\n default: {\n msg = message;\n break;\n }\n }\n return msg;\n}\n\nfunction handleOutput(startGroup: LogGroup, msg: string, originalString?: string): void {\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n const ci = inGitHubActions();\n\n switch (startGroup) {\n case LogGroup.START_GROUP: {\n if (ci && originalString) {\n core.startGroup(originalString);\n } else {\n core.info(msg);\n }\n\n break;\n }\n case LogGroup.END_GROUP: {\n if (ci) {\n core.endGroup();\n }\n break;\n }\n // Logic to handle erroring or failed steps\n case LogGroup.IS_ERROR: {\n core.error(msg);\n break;\n }\n case LogGroup.IS_FAILED: {\n core.setFailed(msg);\n break;\n }\n default: {\n core.info(msg);\n }\n }\n}\n/**\n * Represents a logging task with various log step methods.\n */\nexport default class LogTask {\n /**\n * Map of ingroup settings per task name.\n */\n private static ingroupSettings = new Map<string, boolean>();\n\n /**\n * The width of the indentation for log messages.\n */\n private static indentWidth = 5;\n\n /**\n * Checks if debug mode is enabled.\n * @returns A boolean indicating if debug mode is enabled.\n */\n static isDebug(): boolean {\n return core.isDebug() || (notEmpty(process.env.DEBUG) && process.env.DEBUG === 'true');\n }\n\n /**\n * The name of the task.\n */\n private name: string;\n\n /**\n * Creates a new instance of the LogTask class.\n * @param name - The name of the task.\n */\n constructor(name: string) {\n this.name = name?.trim();\n }\n\n /**\n * Gets the ingroup setting for the task.\n */\n get ingroup(): boolean {\n return LogTask.ingroupSettings.get(this.name) ?? false;\n }\n\n /**\n * Sets the ingroup setting for this task.\n */\n set ingroup(value: boolean) {\n LogTask.ingroupSettings.set(this.name, value);\n }\n\n getMessageString(step: string, desc: string, emojiStr: string): string {\n let msg: string;\n if (this.ingroup) {\n const indentStr = ' '.repeat(LogTask.indentWidth);\n msg = `${indentStr} ${emojiStr}: ${this.name} > ${desc}`;\n } else {\n const stepStr = step.padEnd(LogTask.indentWidth, ' ');\n msg = `[${stepStr}][${this.name.padEnd(11, ' ')}] ${emojiStr}: ${desc}`;\n }\n return highlightStep(step, msg);\n }\n\n /**\n * Logs a step with the given emoji, type, message and group.\n * @param emojiStr - The emoji string to display.\n * @param step - The step type.\n * @param message - The message of the step.\n * @param startGroup - The start group type.\n */\n logStep(emojiStr: string, step: string, message: string, startGroup = LogGroup.NO_GROUP): void {\n // Logic to determine the log message color and format based on the step type\n if (step.length > LogTask.indentWidth) {\n LogTask.indentWidth = step.length;\n }\n const { desc } = highlightMessage(step, message);\n const msg = this.getMessageString(step, desc, emojiStr);\n\n handleOutput(startGroup, msg, message);\n }\n\n /**\n * Logs a debug message.\n * @param message - The message of the debug message.\n */\n debug(message = ''): void {\n // Logic to log a debug message\n if (LogTask.isDebug() && message !== '') {\n this.logStep('🐞', 'DEBUG', message);\n }\n }\n\n /**\n * Logs a start message.\n * @param message - The message of the start message.\n */\n start(message = ''): void {\n // Logic to log a start message\n const desc = message === '' ? `Starting ${this.name}...` : message;\n\n this.logStep('🚀', 'START', desc, LogGroup.START_GROUP);\n }\n\n /**\n * Logs an info message.\n * @param message - The message of the info message.\n */\n info(message = ''): void {\n // Logic to log an info message\n this.logStep('✨', 'INFO', message);\n }\n\n /**\n * Logs a warning message.\n * @param message - The message of the warning message.\n */\n warn(message = ''): void {\n // Logic to log a warning message\n this.logStep('⚠️', 'WARN', message);\n }\n\n /**\n * Logs a success message.\n * @param message - The message of the success message.\n * @param ingroup - Indicates whether the success message is in a group.\n */\n success(message = '', ingroup = true): void {\n // Logic to log a success message\n const desc = message === '' ? `Completed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n this.logStep('✅', 'SUCCESS', desc);\n }\n\n /**\n * Logs a failure message.\n * @param message - The message of the failure message.\n * @param ingroup - Indicates whether the failure message is in a group.\n */\n fail(message = '', ingroup = true): void {\n // Logic to log a failure message\n const desc = message === '' ? `Failed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n const msgtype = process.env.GITHUB_ACTIONS ? LogGroup.IS_FAILED : LogGroup.IS_ERROR;\n this.logStep('❌', 'FAILURE', desc, msgtype);\n }\n\n /**\n * Logs an error message.\n * @param message - The message of the error message.\n */\n error(message = ''): void {\n // Logic to log an error message\n this.logStep('🔴', 'ERROR', message, LogGroup.IS_ERROR);\n }\n\n /**\n * Logs a title message.\n * @param message - The message of the title message.\n */\n title(message = ''): void {\n // Logic to log a title message\n this.logStep('📓', '#####', message, LogGroup.IS_TITLE);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logtask/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,EACJ,WAAW,EACX,IAAI,EACJ,KAAK,EACL,WAAW,EACX,WAAW,EACX,MAAM,EACN,YAAY,GACb,GAAoB,QAAQ,CAAC;AAE9B,yCAAyC;AAEzC,IAAK,QAOJ;AAPD,WAAK,QAAQ;IACX,+CAAY,CAAA;IACZ,qDAAe,CAAA;IACf,iDAAa,CAAA;IACb,+CAAY,CAAA;IACZ,iDAAa,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AC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,UAAkB,EAAE,EAAE,UAAmB,IAAI;QAChD,iCAAiC;QACjC,MAAM,IAAI,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;QAC/D,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;gBAC/B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpF,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAkB,EAAE;QACxB,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAkB,EAAE;QACxB,+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 {\n bgRedBright,\n cyan,\n green,\n greenBright,\n whiteBright,\n yellow,\n yellowBright,\n}: typeof chalkPkg = chalkPkg;\n\n// Constants for different log step types\n\nenum LogGroup {\n NO_GROUP = 0,\n START_GROUP = 1,\n END_GROUP = 2,\n IS_ERROR = 3,\n IS_FAILED = 4,\n IS_TITLE = 5,\n}\n\nfunction inGitHubActions(): boolean {\n return notEmpty(process.env.GITHUB_ACTIONS) && process.env.GITHUB_ACTIONS === 'true';\n}\n\nfunction highlightMessage(step: string, message: string): { desc: string; failed: boolean } {\n let failed = false;\n const ci = inGitHubActions();\n let desc: string;\n switch (step) {\n case 'START': {\n desc = `${message}`;\n break;\n }\n case 'INFO': {\n desc = green(`${message}`);\n break;\n }\n case 'WARN': {\n desc = yellow(`${message}`);\n break;\n }\n case 'SUCCESS': {\n desc = greenBright(`${message}`);\n break;\n }\n case 'FAILURE': {\n desc = ci ? message : yellow.bold(`${message}`);\n failed = true;\n break;\n }\n case 'ERROR': {\n desc = ci ? message : yellow(`${message}`);\n break;\n }\n case '#####': {\n desc = cyan(`${message}`);\n break;\n }\n default: {\n desc = message;\n break;\n }\n }\n return { desc, failed };\n}\nfunction highlightStep(step: string, message: string): string {\n let msg: string;\n const ci = inGitHubActions();\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n switch (step) {\n case 'START': {\n msg = yellowBright(message);\n break;\n }\n case 'SUCCESS': {\n msg = whiteBright(message);\n break;\n }\n case 'FAILURE':\n case 'ERROR': {\n msg = ci ? message : bgRedBright(message);\n break;\n }\n default: {\n msg = message;\n break;\n }\n }\n return msg;\n}\n\nfunction handleOutput(startGroup: LogGroup, msg: string, originalString?: string): void {\n // Logic to handle different log outputs based on the environment (GitHub Actions or local)\n const ci = inGitHubActions();\n\n switch (startGroup) {\n case LogGroup.START_GROUP: {\n if (ci && originalString) {\n core.startGroup(originalString);\n } else {\n core.info(msg);\n }\n\n break;\n }\n case LogGroup.END_GROUP: {\n if (ci) {\n core.endGroup();\n }\n break;\n }\n // Logic to handle erroring or failed steps\n case LogGroup.IS_ERROR: {\n core.error(msg);\n break;\n }\n case LogGroup.IS_FAILED: {\n core.setFailed(msg);\n break;\n }\n default: {\n core.info(msg);\n }\n }\n}\n/**\n * Represents a logging task with various log step methods.\n */\nexport default class LogTask {\n /**\n * Map of ingroup settings per task name.\n */\n private static ingroupSettings = new Map<string, boolean>();\n\n /**\n * The width of the indentation for log messages.\n */\n private static indentWidth = 5;\n\n /**\n * Checks if debug mode is enabled.\n * @returns A boolean indicating if debug mode is enabled.\n */\n static isDebug(): boolean {\n return core.isDebug() || (notEmpty(process.env.DEBUG) && process.env.DEBUG === 'true');\n }\n\n /**\n * The name of the task.\n */\n private name: string;\n\n /**\n * Creates a new instance of the LogTask class.\n * @param name - The name of the task.\n */\n constructor(name: string) {\n this.name = name?.trim();\n }\n\n /**\n * Gets the ingroup setting for the task.\n */\n get ingroup(): boolean {\n return LogTask.ingroupSettings.get(this.name) ?? false;\n }\n\n /**\n * Sets the ingroup setting for this task.\n */\n set ingroup(value: boolean) {\n LogTask.ingroupSettings.set(this.name, value);\n }\n\n getMessageString(step: string, desc: string, emojiStr: string): string {\n let msg: string;\n if (this.ingroup) {\n const indentStr = ' '.repeat(LogTask.indentWidth);\n msg = `${indentStr} ${emojiStr}: ${this.name} > ${desc}`;\n } else {\n const stepStr = step.padEnd(LogTask.indentWidth, ' ');\n msg = `[${stepStr}][${this.name.padEnd(11, ' ')}] ${emojiStr}: ${desc}`;\n }\n return highlightStep(step, msg);\n }\n\n /**\n * Logs a step with the given emoji, type, message and group.\n * @param emojiStr - The emoji string to display.\n * @param step - The step type.\n * @param message - The message of the step.\n * @param startGroup - The start group type.\n */\n logStep(\n emojiStr: string,\n step: string,\n message: string,\n startGroup: LogGroup = LogGroup.NO_GROUP,\n ): void {\n // Logic to determine the log message color and format based on the step type\n if (step.length > LogTask.indentWidth) {\n LogTask.indentWidth = step.length;\n }\n const { desc } = highlightMessage(step, message);\n const msg = this.getMessageString(step, desc, emojiStr);\n\n handleOutput(startGroup, msg, message);\n }\n\n /**\n * Logs a debug message.\n * @param message - The message of the debug message.\n */\n debug(message: string = ''): void {\n // Logic to log a debug message\n if (LogTask.isDebug() && message !== '') {\n this.logStep('🐞', 'DEBUG', message);\n }\n }\n\n /**\n * Logs a start message.\n * @param message - The message of the start message.\n */\n start(message: string = ''): void {\n // Logic to log a start message\n const desc = message === '' ? `Starting ${this.name}...` : message;\n\n this.logStep('🚀', 'START', desc, LogGroup.START_GROUP);\n }\n\n /**\n * Logs an info message.\n * @param message - The message of the info message.\n */\n info(message: string = ''): void {\n // Logic to log an info message\n this.logStep('✨', 'INFO', message);\n }\n\n /**\n * Logs a warning message.\n * @param message - The message of the warning message.\n */\n warn(message: string = ''): void {\n // Logic to log a warning message\n this.logStep('⚠️', 'WARN', message);\n }\n\n /**\n * Logs a success message.\n * @param message - The message of the success message.\n * @param ingroup - Indicates whether the success message is in a group.\n */\n success(message: string = '', ingroup: boolean = true): void {\n // Logic to log a success message\n const desc = message === '' ? `Completed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n this.logStep('✅', 'SUCCESS', desc);\n }\n\n /**\n * Logs a failure message.\n * @param message - The message of the failure message.\n * @param ingroup - Indicates whether the failure message is in a group.\n */\n fail(message: string = '', ingroup: boolean = true): void {\n // Logic to log a failure message\n const desc = message === '' ? `Failed ${this.name}.` : message;\n if (ingroup) {\n this.ingroup = false;\n if (process.env.GITHUB_ACTIONS) {\n core.endGroup();\n }\n }\n const msgtype = process.env.GITHUB_ACTIONS ? LogGroup.IS_FAILED : LogGroup.IS_ERROR;\n this.logStep('❌', 'FAILURE', desc, msgtype);\n }\n\n /**\n * Logs an error message.\n * @param message - The message of the error message.\n */\n error(message: string = ''): void {\n // Logic to log an error message\n this.logStep('🔴', 'ERROR', message, LogGroup.IS_ERROR);\n }\n\n /**\n * Logs a title message.\n * @param message - The message of the title message.\n */\n title(message: string = ''): void {\n // Logic to log a title message\n this.logStep('📓', '#####', message, LogGroup.IS_TITLE);\n }\n}\n"]}
|
package/dist/mjs/prettier.js
CHANGED
|
@@ -18,7 +18,7 @@ const log = new LogTask('prettier');
|
|
|
18
18
|
*/
|
|
19
19
|
export async function formatYaml(value, filepath) {
|
|
20
20
|
const fp = filepath ? { filepath } : {};
|
|
21
|
-
return format(value, {
|
|
21
|
+
return await format(value, {
|
|
22
22
|
semi: false,
|
|
23
23
|
parser: 'yaml',
|
|
24
24
|
embeddedLanguageFormatting: 'auto',
|
|
@@ -33,7 +33,7 @@ export async function formatYaml(value, filepath) {
|
|
|
33
33
|
*/
|
|
34
34
|
export async function formatMarkdown(value, filepath) {
|
|
35
35
|
const fp = filepath ? { filepath } : {};
|
|
36
|
-
return format(value, {
|
|
36
|
+
return await format(value, {
|
|
37
37
|
semi: false,
|
|
38
38
|
parser: 'markdown',
|
|
39
39
|
embeddedLanguageFormatting: 'auto',
|
|
@@ -48,8 +48,9 @@ export async function formatMarkdown(value, filepath) {
|
|
|
48
48
|
* @returns {Promise<string[]>} A promise that resolves with the updated content array.
|
|
49
49
|
*/
|
|
50
50
|
export async function wrapDescription(value, content, prefix = ' # ') {
|
|
51
|
-
if (!value)
|
|
51
|
+
if (!value) {
|
|
52
52
|
return content ?? [];
|
|
53
|
+
}
|
|
53
54
|
// const valueWithoutPrefix = prefix && prefix.length > 0 ? value.replace(prefix, '') : value;
|
|
54
55
|
let formattedString = '';
|
|
55
56
|
try {
|
package/dist/mjs/prettier.js.map
CHANGED
|
@@ -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,
|
|
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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ACxB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9F,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * This TypeScript code exports three functions: `formatYaml`, `formatMarkdown`, and `wrapDescription`.\n *\n * - `formatYaml` takes a YAML string and an optional filepath as parameters and uses the `prettier` library to format the YAML code. It returns the formatted YAML string.\n * - `formatMarkdown` takes a Markdown string and an optional filepath as parameters and uses the `prettier` library to format the Markdown code. It returns the formatted Markdown string.\n * - `wrapDescription` takes a string value, an array of content, and an optional prefix as parameters. It wraps the description text with the specified prefix and formats it using `prettier`. It returns the updated content array with the formatted description lines.\n *\n * The code utilizes the `prettier` library for code formatting and the `LogTask` class for logging purposes.\n */\n\nimport { format } from 'prettier';\n\nimport LogTask from './logtask/index.js';\n\nconst log: LogTask = new LogTask('prettier');\n\n/**\n * Formats a YAML string using `prettier`.\n * @param {string} value - The YAML string to format.\n * @param {string} [filepath] - The optional filepath.\n * @returns {Promise<string>} A promise that resolves with the formatted YAML string.\n */\nexport async function formatYaml(value: string, filepath?: string): Promise<string> {\n const fp = filepath ? { filepath } : {};\n return await format(value, {\n semi: false,\n parser: 'yaml',\n embeddedLanguageFormatting: 'auto',\n ...fp,\n });\n}\n\n/**\n * Formats a Markdown string using `prettier`.\n * @param {string} value - The Markdown string to format.\n * @param {string} [filepath] - The optional filepath.\n * @returns {Promise<string>} A promise that resolves with the formatted Markdown string.\n */\nexport async function formatMarkdown(value: string, filepath?: string): Promise<string> {\n const fp = filepath ? { filepath } : {};\n return await format(value, {\n semi: false,\n parser: 'markdown',\n embeddedLanguageFormatting: 'auto',\n ...fp,\n });\n}\n\n/**\n * Wraps a description text with a prefix and formats it using `prettier`.\n * @param {string | undefined} value - The description text to wrap and format.\n * @param {string[]} content - The array of content to update.\n * @param {string} [prefix=' # '] - The optional prefix to wrap the description lines.\n * @returns {Promise<string[]>} A promise that resolves with the updated content array.\n */\nexport async function wrapDescription(\n value: string | undefined,\n content: string[],\n prefix: string = ' # ',\n): Promise<string[]> {\n if (!value) {\n return content ?? [];\n }\n // const valueWithoutPrefix = prefix && prefix.length > 0 ? value.replace(prefix, '') : value;\n let formattedString = '';\n try {\n formattedString = await format(value, {\n semi: false,\n parser: 'markdown',\n proseWrap: 'always',\n });\n } catch (error) {\n log.error(`${error}`);\n }\n\n content.push(...formattedString.split('\\n').map((line) => prefix + line.replace(prefix, '')));\n return content;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readme-editor.js","sourceRoot":"","sources":["../../src/readme-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAEzE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAErE,MAAM,CAAC,OAAO,OAAO,YAAY;IACvB,GAAG,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IAE1C;;OAEG;IACc,QAAQ,CAAS;IAE1B,WAAW,CAAS;IAE5B;;;OAGG;IACH,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,QA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AC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,CAAC,CACrF,CAAC,IAAI,EAAE,CAAC;QACT,GAAG,CAAC,IAAI,CAAC,mBAAmB,IAAI,aAAa,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE9D,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChE,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;YAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;YAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAEvD,IAAI,CAAC,WAAW,GAAG,WAAW;gBAC5B,CAAC,CAAC,GAAG,aAAa,OAAO,OAAO,KAAK,YAAY,EAAE;gBACnD,CAAC,CAAC,GAAG,aAAa,GAAG,OAAO,GAAG,YAAY,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports the necessary modules and defines a class named `ReadmeEditor`.\n * The class represents an editor for modifying a README file.\n * It has methods to update specific sections within the file and dump the modified content back to the file.\n */\n\nimport * as fs from 'node:fs';\nimport { EOL } from 'node:os';\n\nimport * as core from '@actions/core';\n\nimport { indexOfRegex, lastIndexOfRegex } from './helpers.js';\nimport LogTask from './logtask/index.js';\nimport { formatMarkdown } from './prettier.js';\n\n/**\n * The format for the start token of a section.\n */\n\nexport const startTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+start\\\\s+%s\\\\s+-->';\n\n/**\n * The format for the end token of a section.\n */\nexport const endTokenFormat = '(^|[^`\\\\\\\\])<!--\\\\s+end\\\\s+%s\\\\s+-->';\n\nexport default class ReadmeEditor {\n private log = new LogTask('ReadmeEditor');\n\n /**\n * The path to the README file.\n */\n private readonly filePath: string;\n\n private fileContent: string;\n\n /**\n * Creates a new instance of `ReadmeEditor`.\n * @param {string} filePath - The path to the README file.\n */\n constructor(filePath: string) {\n this.filePath = filePath;\n try {\n fs.accessSync(filePath);\n this.fileContent = fs.readFileSync(filePath, 'utf8');\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_before', this.fileContent);\n }\n } catch (error) {\n this.log.fail(`Readme at '${filePath}' does not exist.`);\n throw error;\n }\n }\n\n /**\n * Gets the current README content.\n * @returns {string} - The README file content.\n */\n getReadmeContent(): string {\n return this.fileContent;\n }\n\n /**\n * Gets the indexes of the start and end tokens for a given section.\n * @param {string} token - The section token.\n * @returns {number[]} - The indexes of the start and end tokens.\n */\n getTokenIndexes(token: string, logTask?: LogTask): number[] {\n const log = logTask ?? new LogTask('getTokenIndexes');\n const startRegExp = new RegExp(startTokenFormat.replace('%s', token));\n const stopRegExp = new RegExp(endTokenFormat.replace('%s', token));\n const startIndex = lastIndexOfRegex(this.fileContent, startRegExp);\n if (startIndex === -1) {\n log.debug(`No start token found for section '${token}'. Skipping`);\n return [];\n }\n\n const stopIndex = indexOfRegex(this.fileContent, stopRegExp);\n if (stopIndex === -1) {\n log.debug(`No start or end token found for section '${token}'. Skipping`);\n return [];\n }\n\n return [startIndex, stopIndex];\n }\n\n /**\n * Updates a specific section in the README file with the provided content.\n * @param {string} name - The name of the section.\n * @param {string | string[]} providedContent - The content to update the section with.\n * @param {boolean} addNewlines - Whether to add newlines before and after the content.\n */\n updateSection(\n name: string,\n providedContent: string | string[],\n addNewlines: boolean = true,\n ): void {\n const log = new LogTask(name);\n const content = (\n Array.isArray(providedContent) ? providedContent.join(EOL) : (providedContent ?? '')\n ).trim();\n log.info(`Looking for the ${name} token in ${this.filePath}`);\n\n const [startIndex, stopIndex] = this.getTokenIndexes(name, log);\n if (startIndex && stopIndex) {\n const beforeContent = this.fileContent.slice(0, startIndex);\n const afterContent = this.fileContent.slice(stopIndex);\n\n this.fileContent = addNewlines\n ? `${beforeContent}\\n\\n${content}\\n${afterContent}`\n : `${beforeContent}${content}${afterContent}`;\n }\n }\n\n /**\n * Dumps the modified content back to the README file.\n * @returns {Promise<void>}\n */\n async dumpToFile(): Promise<void> {\n const content = await formatMarkdown(this.fileContent);\n if (process.env.GITHUB_ACTIONS) {\n core.setOutput('readme_after', content);\n }\n return fs.promises.writeFile(this.filePath, content, 'utf8');\n }\n}\n"]}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* If an error occurs during the update of a section, it logs the error message and stops the process.
|
|
6
6
|
* Finally, it saves the updated README.md file and calls the 'save' function.
|
|
7
7
|
*/
|
|
8
|
-
import { ReadmeSection } from './constants.js';
|
|
9
|
-
import Inputs from './inputs.js';
|
|
10
|
-
import LogTask from './logtask/index.js';
|
|
8
|
+
import type { ReadmeSection } from './constants.js';
|
|
9
|
+
import type Inputs from './inputs.js';
|
|
10
|
+
import type LogTask from './logtask/index.js';
|
|
11
11
|
export type SectionKV = Record<string, string>;
|
|
12
12
|
/**
|
|
13
13
|
* Class for managing README generation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readme-generator.js","sourceRoot":"","sources":["../../src/readme-generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAKtC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,eAAe;IAC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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,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc,CAAC,QAA8B;QACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,QAAmB;QAChC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACtC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,mBAAoC,IAAI,CAAC,MAAM,CAAC,QAAQ;QACrE,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAE5D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/**\n * This TypeScript code imports various modules and defines a function named 'generateDocs'.\n * The function is responsible for generating documentation for the README.md file based on the provided inputs.\n * It iterates through each section defined in the 'inputs.sections' array and calls the 'updateSection' function to update the corresponding section in the README.md file.\n * If an error occurs during the update of a section, it logs the error message and stops the process.\n * Finally, it saves the updated README.md file and calls the 'save' function.\n */\n\nimport * as core from '@actions/core';\n\nimport type { ReadmeSection } from './constants.js';\nimport type Inputs from './inputs.js';\nimport type LogTask from './logtask/index.js';\nimport updateSection from './sections/index.js';\n\nexport type SectionKV = Record<string, string>;\n/**\n * Class for managing README generation.\n */\nexport class ReadmeGenerator {\n /**\n * The Inputs instance.\n */\n private inputs: Inputs;\n\n /**\n * The Logger instance.\n */\n private log: LogTask;\n\n /**\n * Initializes the ReadmeGenerator.\n *\n * @param inputs - The Inputs instance\n * @param log - The Logger instance\n */\n constructor(inputs: Inputs, log: LogTask) {\n this.inputs = inputs;\n this.log = log;\n }\n\n /**\n * Updates the README sections.\n *\n * @param sections - The sections array\n * @returns Promise array of section KV objects\n */\n updateSections(sections: ReadmeSection[]): Promise<SectionKV>[] {\n const promises: Promise<SectionKV>[] = [];\n\n for (const section of sections) {\n promises.push(updateSection(section, this.inputs));\n }\n\n return promises;\n }\n\n /**\n * Resolves the section update promises.\n *\n * @param promises - The promise array\n * @returns Promise resolving to combined sections KV\n */\n async resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV> {\n this.log.debug('Resolving updates');\n const results = await Promise.all(promises);\n const sections: SectionKV = {};\n\n for (const result of results) {\n Object.assign(sections, result);\n }\n\n return sections;\n }\n\n /**\n * Outputs the sections KV to GitHub output.\n *\n * @param sections - The sections KV\n */\n outputSections(sections: SectionKV): void {\n if (process.env.GITHUB_ACTIONS) {\n this.log.debug('Outputting sections');\n core.setOutput('sections', JSON.stringify(sections, null, 2));\n } else {\n this.log.debug('Not outputting sections');\n }\n }\n\n /**\n * Generates the README documentation.\n *\n * @returns Promise resolving when done\n */\n async generate(providedSections: ReadmeSection[] = this.inputs.sections): Promise<void> {\n const sectionPromises = this.updateSections(providedSections);\n const sections = await this.resolveUpdates(sectionPromises);\n\n this.outputSections(sections);\n\n return this.inputs.readmeEditor.dumpToFile();\n }\n}\n"]}
|
package/dist/mjs/save.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.
|
|
5
5
|
* This script is used to update the usage section in the README.md file to match the contents of the action.yml file.
|
|
6
6
|
*/
|
|
7
|
-
import Inputs from './inputs.js';
|
|
8
|
-
import LogTask from './logtask/index.js';
|
|
7
|
+
import type Inputs from './inputs.js';
|
|
8
|
+
import type LogTask from './logtask/index.js';
|
|
9
9
|
/**
|
|
10
10
|
* This script rebuilds the usage section in the README.md to be consistent with the action.yml
|
|
11
11
|
* @param {Inputs} inputs - the inputs class
|
package/dist/mjs/save.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc,EAAE,GAAY;IACvD,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.\n * The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.\n * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.\n * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.\n */\n\nimport { GHActionDocsConfig } from './config.js';\nimport Inputs from './inputs.js';\nimport LogTask from './logtask/index.js';\n\n/**\n * This script rebuilds the usage section in the README.md to be consistent with the action.yml\n * @param {Inputs} inputs - the inputs class\n */\nexport default function save(inputs: Inputs, log: LogTask): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get().save === true) {\n try {\n docsConfig.save(inputs.configPath);\n } catch (error) {\n log.error(`${error}`);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/save.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,MAAc,EAAE,GAAY;IACvD,MAAM,UAAU,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC5C,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.\n * The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.\n * If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.\n * This script is used to update the usage section in the README.md file to match the contents of the action.yml file.\n */\n\nimport { GHActionDocsConfig } from './config.js';\nimport type Inputs from './inputs.js';\nimport type LogTask from './logtask/index.js';\n\n/**\n * This script rebuilds the usage section in the README.md to be consistent with the action.yml\n * @param {Inputs} inputs - the inputs class\n */\nexport default function save(inputs: Inputs, log: LogTask): void {\n const docsConfig = new GHActionDocsConfig();\n docsConfig.loadInputs(inputs);\n if (inputs.config.get().save === true) {\n try {\n docsConfig.save(inputs.configPath);\n } catch (error) {\n log.error(`${error}`);\n }\n }\n}\n"]}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @param {Inputs} inputs - The Inputs class instance.
|
|
7
7
|
* @returns {Promise<void>} A promise that resolves once the section is updated.
|
|
8
8
|
*/
|
|
9
|
-
import { ReadmeSection } from '../constants.js';
|
|
9
|
+
import type { ReadmeSection } from '../constants.js';
|
|
10
10
|
import type Inputs from '../inputs.js';
|
|
11
11
|
export default function updateSection(section: ReadmeSection, inputs: Inputs): Promise<Record<string, string>>;
|
|
@@ -18,28 +18,28 @@ export default async function updateSection(section, inputs) {
|
|
|
18
18
|
}
|
|
19
19
|
switch (section) {
|
|
20
20
|
case 'branding': {
|
|
21
|
-
return updateBranding(section, inputs);
|
|
21
|
+
return await updateBranding(section, inputs);
|
|
22
22
|
}
|
|
23
23
|
case 'badges': {
|
|
24
|
-
return updateBadges(section, inputs);
|
|
24
|
+
return await updateBadges(section, inputs);
|
|
25
25
|
}
|
|
26
26
|
case 'usage': {
|
|
27
|
-
return updateUsage(section, inputs);
|
|
27
|
+
return await updateUsage(section, inputs);
|
|
28
28
|
}
|
|
29
29
|
case 'title': {
|
|
30
|
-
return updateTitle(section, inputs);
|
|
30
|
+
return await updateTitle(section, inputs);
|
|
31
31
|
}
|
|
32
32
|
case 'description': {
|
|
33
|
-
return updateDescription(section, inputs);
|
|
33
|
+
return await updateDescription(section, inputs);
|
|
34
34
|
}
|
|
35
35
|
case 'inputs': {
|
|
36
|
-
return updateInputs(section, inputs);
|
|
36
|
+
return await updateInputs(section, inputs);
|
|
37
37
|
}
|
|
38
38
|
case 'outputs': {
|
|
39
|
-
return updateOutputs(section, inputs);
|
|
39
|
+
return await updateOutputs(section, inputs);
|
|
40
40
|
}
|
|
41
41
|
case 'contents': {
|
|
42
|
-
return updateContents(section, inputs);
|
|
42
|
+
return await updateContents(section, inputs);
|
|
43
43
|
}
|
|
44
44
|
default: {
|
|
45
45
|
log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,MAAM,GAAG,GAAY,IAAI,OAAO,CAAC,eA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AC/C,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,GAAG,CAAC,KAAK,CAAC,oCAAoC,OAAO,6BAA6B,CAAC,CAAC;YACpF,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating different sections of the README.md file based on the provided section input.\n * It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.\n * @param {ReadmeSection} section - The section of the README to update.\n * @param {Inputs} inputs - The Inputs class instance.\n * @returns {Promise<void>} A promise that resolves once the section is updated.\n */\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport updateBadges from './update-badges.js';\nimport updateBranding from './update-branding.js';\nimport updateContents from './update-contents.js';\nimport updateDescription from './update-description.js';\nimport updateInputs from './update-inputs.js';\nimport updateOutputs from './update-outputs.js';\nimport updateTitle from './update-title.js';\nimport updateUsage from './update-usage.js';\n\nconst log: LogTask = new LogTask('updateSection');\n\nexport default async function updateSection(\n section: ReadmeSection,\n inputs: Inputs,\n): Promise<Record<string, string>> {\n const [startToken, stopToken] = inputs.readmeEditor.getTokenIndexes(section);\n // &&\n // ['branding', 'title'].includes(section) &&\n // inputs.config.get('branding_as_title_prefix') !== true\n if (startToken === -1 || stopToken === -1) {\n return {};\n }\n switch (section) {\n case 'branding': {\n return await updateBranding(section, inputs);\n }\n case 'badges': {\n return await updateBadges(section, inputs);\n }\n case 'usage': {\n return await updateUsage(section, inputs);\n }\n case 'title': {\n return await updateTitle(section, inputs);\n }\n case 'description': {\n return await updateDescription(section, inputs);\n }\n case 'inputs': {\n return await updateInputs(section, inputs);\n }\n case 'outputs': {\n return await updateOutputs(section, inputs);\n }\n case 'contents': {\n return await updateContents(section, inputs);\n }\n default: {\n log.debug(`unknown section found <!-- start ${section} -->. No updates were made.`);\n return {};\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* The function is responsible for updating the badges section in the README.md file based on the provided inputs.
|
|
4
4
|
* It utilizes the 'LogTask' class for logging purposes.
|
|
5
5
|
*/
|
|
6
|
-
import { ReadmeSection } from '../constants.js';
|
|
6
|
+
import type { ReadmeSection } from '../constants.js';
|
|
7
7
|
import type Inputs from '../inputs.js';
|
|
8
8
|
/**
|
|
9
9
|
* Interface for a badge.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-badges.js","sourceRoot":"","sources":["../../../src/sections/update-badges.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAW1C;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAa,EAAE,IAAY;IAC/C,MAAM,OAAO,GAAG,sBAAsB,KAAK,IAAI,IAAI,EAAE,CAAC;IACtD,OAAO;QACL;YACE,GAAG,EAAE,2CAA2C,KAAK,IAAI,IAAI,6DAA6D;YAC1H,GAAG,EAAE,gBAAgB;YACrB,GAAG,EAAE,GAAG,OAAO,kBAAkB;SAClC;QACD;YACE,GAAG,EAAE,8CAA8C,KAAK,IAAI,IAAI,6DAA6D;YAC7H,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,GAAG,OAAO,kBAAkB;SAClC;QACD;YACE,GAAG,EAAE,6CAA6C,KAAK,IAAI,IAAI,gCAAgC;YAC/F,GAAG,EAAE,QAAQ;SACd;QACD;YACE,GAAG,EAAE,wCAAwC,KAAK,IAAI,IAAI,gCAAgC;YAC1F,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,GAAG,OAAO,SAAS;SACzB;QACD;YACE,GAAG,EAAE,2CAA2C,KAAK,IAAI,IAAI,sCAAsC;YACnG,GAAG,EAAE,WAAW;SACjB;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAY,EAAE,GAAY;IAC/C,MAAM,aAAa,GAAG,aAA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IAAI,CAAC,CAAC;QACjE,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code imports necessary modules and defines a function named 'updateBadges' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the badges section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes.\n */\n\nimport { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\n/**\n * Interface for a badge.\n */\nexport interface IBadge {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generate GitHub badges.\n * @returns {IBadge[]} - The array of GitHub badges.\n */\nfunction githubBadges(owner: string, repo: string): IBadge[] {\n const repoUrl = `https://github.com/${owner}/${repo}`;\n return [\n {\n img: `https://img.shields.io/github/v/release/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by tag',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/release-date/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by date',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/last-commit/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Commit',\n },\n {\n img: `https://img.shields.io/github/issues/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Open Issues',\n url: `${repoUrl}/issues`,\n },\n {\n img: `https://img.shields.io/github/downloads/${owner}/${repo}/total?logo=github&style=flat-square`,\n alt: 'Downloads',\n },\n ];\n}\n\n/**\n * Generates a badge HTML markup.\n * @param {IBadge} item - The badge object.\n * @returns {string} - The HTML markup for the badge.\n */\nfunction generateBadge(item: IBadge, log: LogTask): string {\n const badgeTemplate = `<img src=\"${item.img}\" alt=\"${encodeURIComponent(item.alt) || ''}\" />`;\n log.info(`Generating badge ${item.alt}`);\n if (item.url) {\n return `<a href=\"${encodeURIComponent(item.url)}\">${badgeTemplate}</a>`;\n }\n return badgeTemplate;\n}\n\n/**\n * Generates all badges HTML markup.\n * @param {IBadge} badges - The array of badge objects\n * @param log - A LogTask instance\n * @returns {string[]} - The array of HTML markup for all badges.\n */\nfunction generateBadges(badges: IBadge[], log: LogTask): string[] {\n const badgeArray: string[] = [];\n for (const b of badges) {\n badgeArray.push(generateBadge(b, log));\n }\n log.debug(`Total badges: ${badgeArray.length}`);\n return badgeArray;\n}\nexport default function updateBadges(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n const config = inputs.config.get();\n\n const enableVersioning = config ? config.versioning?.badge : false;\n log.info(`Versioning badge: ${enableVersioning}`);\n\n log.start();\n let content = '';\n // Add GitHub badges\n if (enableVersioning) {\n const badges: IBadge[] = githubBadges(inputs.owner, inputs.repo);\n content = generateBadges(badges, log).join('');\n inputs.readmeEditor.updateSection(sectionToken, content);\n }\n log.success();\n const ret: Record<string, string> = {};\n ret[sectionToken] = content;\n return ret;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"update-badges.js","sourceRoot":"","sources":["../../../src/sections/update-badges.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAW1C;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAa,EAAE,IAAY;IAC/C,MAAM,OAAO,GAAG,sBAAsB,KAAK,IAAI,IAAI,EAAE,CAAC;IACtD,OAAO;QACL;YACE,GAAG,EAAE,2CAA2C,KAAK,IAAI,IAAI,6DAA6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AAE,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC;AACpB,CAAC;AACD,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,YAA2B,EAC3B,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IAEnC,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,GAAG,CAAC,IAAI,CAAC,qBAAqB,gBAAgB,EAAE,CAAC,CAAC;IAElD,GAAG,CAAC,KAAK,EAAE,CAAC;IACZ,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,oBAAoB;IACpB,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,MAAM,GAAa,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACjE,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * This TypeScript code imports necessary modules and defines a function named 'updateBadges' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.\n * The function is responsible for updating the badges section in the README.md file based on the provided inputs.\n * It utilizes the 'LogTask' class for logging purposes.\n */\n\nimport type { ReadmeSection } from '../constants.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\n\n/**\n * Interface for a badge.\n */\nexport interface IBadge {\n alt: string;\n img: string;\n url?: string;\n}\n\n/**\n * Generate GitHub badges.\n * @returns {IBadge[]} - The array of GitHub badges.\n */\nfunction githubBadges(owner: string, repo: string): IBadge[] {\n const repoUrl = `https://github.com/${owner}/${repo}`;\n return [\n {\n img: `https://img.shields.io/github/v/release/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by tag',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/release-date/${owner}/${repo}?display_name=tag&sort=semver&logo=github&style=flat-square`,\n alt: 'Release by date',\n url: `${repoUrl}/releases/latest`,\n },\n {\n img: `https://img.shields.io/github/last-commit/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Commit',\n },\n {\n img: `https://img.shields.io/github/issues/${owner}/${repo}?logo=github&style=flat-square`,\n alt: 'Open Issues',\n url: `${repoUrl}/issues`,\n },\n {\n img: `https://img.shields.io/github/downloads/${owner}/${repo}/total?logo=github&style=flat-square`,\n alt: 'Downloads',\n },\n ];\n}\n\n/**\n * Generates a badge HTML markup.\n * @param {IBadge} item - The badge object.\n * @returns {string} - The HTML markup for the badge.\n */\nfunction generateBadge(item: IBadge, log: LogTask): string {\n const badgeTemplate = `<img src=\"${item.img}\" alt=\"${encodeURIComponent(item.alt) || ''}\" />`;\n log.info(`Generating badge ${item.alt}`);\n if (item.url) {\n return `<a href=\"${encodeURIComponent(item.url)}\">${badgeTemplate}</a>`;\n }\n return badgeTemplate;\n}\n\n/**\n * Generates all badges HTML markup.\n * @param {IBadge} badges - The array of badge objects\n * @param log - A LogTask instance\n * @returns {string[]} - The array of HTML markup for all badges.\n */\nfunction generateBadges(badges: IBadge[], log: LogTask): string[] {\n const badgeArray: string[] = [];\n for (const b of badges) {\n badgeArray.push(generateBadge(b, log));\n }\n log.debug(`Total badges: ${badgeArray.length}`);\n return badgeArray;\n}\nexport default function updateBadges(\n sectionToken: ReadmeSection,\n inputs: Inputs,\n): Record<string, string> {\n const log = new LogTask(sectionToken);\n const config = inputs.config.get();\n\n const enableVersioning = config ? config.versioning?.badge : false;\n log.info(`Versioning badge: ${enableVersioning}`);\n\n log.start();\n let content = '';\n // Add GitHub badges\n if (enableVersioning) {\n const badges: IBadge[] = githubBadges(inputs.owner, inputs.repo);\n content = generateBadges(badges, log).join('');\n inputs.readmeEditor.updateSection(sectionToken, content);\n }\n log.success();\n const ret: Record<string, string> = {};\n ret[sectionToken] = content;\n return ret;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FeatherIconNames } from 'feather-icons';
|
|
2
2
|
import type { BrandColors } from '../constants.js';
|
|
3
|
-
import { ReadmeSection } from '../constants.js';
|
|
3
|
+
import { type ReadmeSection } from '../constants.js';
|
|
4
4
|
import type Inputs from '../inputs.js';
|
|
5
5
|
export interface IBranding {
|
|
6
6
|
alt: string;
|