Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x | const { color, OPTIONS } = require('./global'); const { commitFiles, getOverrideVersion, getVersion } = require('./cmds'); const { parseCommits, semverBump } = require('./parse'); const { updateChangelog, updatePackage } = require('./files'); /** * Start `changelog` updates * * @module Init */ /** * Updates changelog and package.json files based on commit history. * * This function analyzes commit messages, determines the appropriate semantic version bump, * updates the changelog with formatted commit messages, and optionally commits the changes. * * @param {object} [options=OPTIONS] - Configuration options for the changelog update * @param {string} options.changelogFile - Path to the changelog file * @param {string} options.contextPath - Base directory path for operations * @param {boolean} options.isCommit - Whether to commit changes to git * @param {boolean} options.isDryRun - Whether to perform a dry run without writing files * @param {string} options.overrideVersion - Optional version to use instead of calculated version * @param {object} [settings={}] - Function overrides for testing or customization * @param {commitFiles} [settings.commitFiles=commitFiles] - Function to commit changes to git * @param {getOverrideVersion} [settings.getOverrideVersion=getOverrideVersion] - Function to get the override version * @param {getVersion} [settings.getVersion=getVersion] - Function to calculate the new version * @param {parseCommits} [settings.parseCommits=parseCommits] - Function to parse commit messages * @param {semverBump} [settings.semverBump=semverBump] - Function to determine semantic version bump * @param {updateChangelog} [settings.updateChangelog=updateChangelog] - Function to update the changelog file * @param {updatePackage} [settings.updatePackage=updatePackage] - Function to update the package.json file * @returns {{parsedCommits: {"Bug Fixes": {commits: string[], title: string}, Chores: {commits: string[], * title: string}, Features: {commits: string[], title: string}}, semverBump: ("major"|"minor"|"patch"), * package: string, versionClean: string, changelog: string, semverWeight: number, version: string}} Result of the changelog update */ const commitChangelog = ( { changelogFile, contextPath, isCommit, isDryRun, overrideVersion } = OPTIONS, { commitFiles: commitAliasFiles = commitFiles, getOverrideVersion: getAliasOverrideVersion = getOverrideVersion, getVersion: getAliasVersion = getVersion, parseCommits: parseAliasCommits = parseCommits, semverBump: semverAliasBump = semverBump, updateChangelog: updateAliasChangelog = updateChangelog, updatePackage: updateAliasPackage = updatePackage } = {} ) => { Iif (process.env.NODE_ENV !== 'test') { process.chdir(contextPath); } const { commits, isBreakingChanges } = parseAliasCommits(); const { bump, weight } = semverAliasBump({ commits, isBreakingChanges }); const { clean: cleanVersion, version } = (overrideVersion && getAliasOverrideVersion()) || getAliasVersion(bump); Iif (isDryRun) { console.info( color.CYAN, `\nDry run ${changelogFile} output...\nVersion: ${version}\nSemver bump: ${bump}\nSemver weight: ${weight}` ); } const changelog = updateAliasChangelog({ commits, packageVersion: cleanVersion, isBreakingChanges }); const packageJSON = updateAliasPackage((overrideVersion && cleanVersion) || bump); Iif (isCommit && !isDryRun) { commitAliasFiles(cleanVersion); } Iif (isDryRun) { console.info(color.NOCOLOR); } return { changelog, package: packageJSON, parsedCommits: commits, semverBump: bump, semverWeight: weight, version, versionClean: cleanVersion }; }; module.exports = { commitChangelog, OPTIONS }; |