From e39c0694a60a82925235c8c450aac346f3bae860 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Aug 2025 21:23:03 +1000 Subject: [PATCH 1/4] build(deps): bump actions/checkout from 4.2.2 to 5.0.0 (#245) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.2 to 5.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/11bd71901bbe5b1630ceea73d27597364c9af683...08c6903cd8c0fde910a37f88322edcfb5dd907a8) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 2 +- .github/workflows/release-please.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bb920942a..d17b4fcc5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: OS: ${{ matrix.os }} NODE_VERSION: ${{ matrix.node }} steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4 - run: git fetch --prune --unshallow - run: git config --global user.name 'Actions' - run: git config --global user.email 'dummy@example.org' diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 9fdbbe7b8..c3ffddc2b 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -15,7 +15,7 @@ jobs: release-type: node package-name: commit-and-tag-version # The logic below handles the npm publication: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4 # these if statements ensure that a publication only occurs when # a new release is created: if: ${{ steps.release.outputs.release_created }} From c9f9410ceeb803b5a6fa211d654ab69b79789648 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Aug 2025 21:24:37 +1000 Subject: [PATCH 2/4] build(deps-dev): bump shelljs from 0.8.5 to 0.10.0 (#243) Bumps [shelljs](https://github.com/shelljs/shelljs) from 0.8.5 to 0.10.0. - [Release notes](https://github.com/shelljs/shelljs/releases) - [Changelog](https://github.com/shelljs/shelljs/blob/main/CHANGELOG.md) - [Commits](https://github.com/shelljs/shelljs/compare/v0.8.5...v0.10.0) --- updated-dependencies: - dependency-name: shelljs dependency-version: 0.10.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 34 +++++++--------------------------- package.json | 2 +- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index f46c12f94..96b96315e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "jest": "^29.7.0", "jest-serial-runner": "^1.2.1", "prettier": "^3.3.3", - "shelljs": "^0.8.5", + "shelljs": "^0.10.0", "strip-ansi": "^6.0.1" }, "engines": { @@ -4504,14 +4504,6 @@ "node": ">= 0.4" } }, - "node_modules/interpret": { - "version": "1.4.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/is-array-buffer": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", @@ -7531,16 +7523,6 @@ "node": ">= 6" } }, - "node_modules/rechoir": { - "version": "0.6.2", - "dev": true, - "dependencies": { - "resolve": "^1.1.6" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/redent": { "version": "3.0.0", "license": "MIT", @@ -7798,19 +7780,17 @@ } }, "node_modules/shelljs": { - "version": "0.8.5", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.10.0.tgz", + "integrity": "sha512-Jex+xw5Mg2qMZL3qnzXIfaxEtBaC4n7xifqaqtrZDdlheR70OGkydrPJWT0V1cA1k3nanC86x9FwAmQl6w3Klw==", "dev": true, "license": "BSD-3-Clause", "dependencies": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - }, - "bin": { - "shjs": "bin/shjs" + "execa": "^5.1.1", + "fast-glob": "^3.3.2" }, "engines": { - "node": ">=4" + "node": ">=18" } }, "node_modules/side-channel": { diff --git a/package.json b/package.json index 466aad691..aca29fcd4 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "jest": "^29.7.0", "jest-serial-runner": "^1.2.1", "prettier": "^3.3.3", - "shelljs": "^0.8.5", + "shelljs": "^0.10.0", "strip-ansi": "^6.0.1" } } From 3958e688a60df4f1ba46137d1f4147a65817c8d7 Mon Sep 17 00:00:00 2001 From: sameerthekhans Date: Wed, 27 Aug 2025 18:38:29 +0530 Subject: [PATCH 3/4] feat: add --config option to allow custom config file path (#237) --- README.md | 18 ++++++++++++++++++ command.js | 9 ++++++++- defaults.js | 1 + lib/configuration.js | 8 ++++++-- test/config-files.integration-test.js | 24 ++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 85a850241..b466a5e13 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla - [Release as a Pre-Release](#release-as-a-pre-release) - [Release as a Target Type Imperatively (`npm version`-like)](#release-as-a-target-type-imperatively-npm-version-like) - [Prevent Git Hooks](#prevent-git-hooks) + - [Custom Config Path](#custom-config-path) - [Signing Commits and Tags](#signing-commits-and-tags) - [Lifecycle Scripts](#lifecycle-scripts) - [Skipping Lifecycle Steps](#skipping-lifecycle-steps) @@ -312,6 +313,23 @@ npm run release -- --no-verify commit-and-tag-version --no-verify ``` +### Custom Config Path + +Specify a custom path to the configuration file using the `--config` option + +```sh +commit-and-tag-version --config ./path/to/.versionrc.js + +# or using alias +commit-and-tag-version -c ./path/to/.versionrc.js +``` + +All config file formats can be used: + +```sh +commit-and-tag-version -c ./path/to/.versionrc[.js|.cjs|.json] +``` + ### Signing Commits and Tags If you have your GPG key set up, add the `--sign` or `-s` flag to your `commit-and-tag-version` command. diff --git a/command.js b/command.js index c5d98480e..8d04da3d6 100755 --- a/command.js +++ b/command.js @@ -132,6 +132,12 @@ const yargs = require('yargs') default: defaults.npmPublishHint, describe: 'Customized publishing hint', }) + .option('config', { + type: 'string', + default: defaults.config, + alias: 'c', + describe: 'Path to a custom configuration file', + }) .check((argv) => { if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) { throw Error('scripts must be an object'); @@ -150,9 +156,10 @@ const yargs = require('yargs') ) .pkgConf('standard-version') .pkgConf('commit-and-tag-version') - .config(getConfiguration()) .wrap(97); +yargs.config(getConfiguration(yargs.argv.config)); + Object.keys(spec.properties).forEach((propertyKey) => { const property = spec.properties[propertyKey]; yargs.option(propertyKey, { diff --git a/defaults.js b/defaults.js index 9cf40e034..83d69d225 100644 --- a/defaults.js +++ b/defaults.js @@ -17,6 +17,7 @@ const defaults = { gitTagFallback: true, preset: require.resolve('conventional-changelog-conventionalcommits'), npmPublishHint: undefined, + config: undefined, }; /** diff --git a/lib/configuration.js b/lib/configuration.js index f169631ea..be8c634ef 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -9,9 +9,13 @@ const CONFIGURATION_FILES = [ '.versionrc.js', ]; -module.exports.getConfiguration = function () { +module.exports.getConfiguration = function (configFile) { let config = {}; - const configPath = findUp.sync(CONFIGURATION_FILES); + + // If the user has provided a configuration file via the `--config` argument, we use that. + const configurationFiles = configFile ?? CONFIGURATION_FILES; + + const configPath = findUp.sync(configurationFiles); if (!configPath) { return config; } diff --git a/test/config-files.integration-test.js b/test/config-files.integration-test.js index e1c54f3c9..dba07a780 100644 --- a/test/config-files.integration-test.js +++ b/test/config-files.integration-test.js @@ -86,6 +86,30 @@ describe('config files', function () { expect(content).toContain(issueUrlFormat); }); + it('reads config from custom path', async function () { + const issueUrlFormat = 'http://www.foo.com/{{id}}'; + const changelog = ({ preset }) => preset.issueUrlFormat; + mock({ bump: 'minor', changelog }); + fs.mkdirSync('custom-folder'); + fs.writeFileSync( + 'custom-folder/.versionrc.json', + JSON.stringify({ issueUrlFormat }), + 'utf-8', + ); + + // Override process.argv to simulate CLI arguments before `exec`. + // This ensures yargs parses the custom config argument. + const originalArgv = process.argv; + process.argv = ['node', 'script.js', '-c', 'custom-folder/.versionrc.json']; + + await exec(['-c', 'custom-folder/.versionrc.json']); + const content = fs.readFileSync('CHANGELOG.md', 'utf-8'); + expect(content).toContain(issueUrlFormat); + + // Restore original process.argv + process.argv = originalArgv; + }); + it('evaluates a config-function from .versionrc.js', async function () { const issueUrlFormat = 'http://www.foo.com/{{id}}'; const src = `module.exports = function() { return ${JSON.stringify({ From 3bea4afbbb8e14b30e02c4d7705a7d9ff6bbaddf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Aug 2025 23:09:19 +1000 Subject: [PATCH 4/4] chore(master): release 12.6.0 (#247) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 770201d3b..79efe5bc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [12.6.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.5.2...v12.6.0) (2025-08-27) + + +### Features + +* add --config option to allow custom config file path ([#237](https://github.com/absolute-version/commit-and-tag-version/issues/237)) ([3958e68](https://github.com/absolute-version/commit-and-tag-version/commit/3958e688a60df4f1ba46137d1f4147a65817c8d7)) + ## [12.5.2](https://github.com/absolute-version/commit-and-tag-version/compare/v12.5.1...v12.5.2) (2025-07-30) diff --git a/package-lock.json b/package-lock.json index 96b96315e..69bd560bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "commit-and-tag-version", - "version": "12.5.2", + "version": "12.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "commit-and-tag-version", - "version": "12.5.2", + "version": "12.6.0", "license": "ISC", "dependencies": { "chalk": "^2.4.2", diff --git a/package.json b/package.json index aca29fcd4..46f347be2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commit-and-tag-version", - "version": "12.5.2", + "version": "12.6.0", "description": "replacement for `npm version` with automatic CHANGELOG generation", "bin": "bin/cli.js", "scripts": {