commit-and-tag-version 12.7.1 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.github/workflows/ci.yaml +8 -15
  2. package/.github/workflows/release-please.yml +7 -5
  3. package/CHANGELOG.md +36 -0
  4. package/MIGRATION.md +51 -0
  5. package/README.md +22 -21
  6. package/bin/cli.js +2 -2
  7. package/command.js +9 -4
  8. package/defaults.js +5 -3
  9. package/eslint.config.mjs +52 -42
  10. package/index.js +12 -12
  11. package/lib/checkpoint.js +5 -5
  12. package/lib/configuration.js +9 -6
  13. package/lib/detect-package-manager.js +4 -8
  14. package/lib/format-commit-message.js +2 -2
  15. package/lib/latest-semver-tag.js +30 -30
  16. package/lib/lifecycles/bump.js +97 -65
  17. package/lib/lifecycles/changelog.js +48 -60
  18. package/lib/lifecycles/commit.js +8 -8
  19. package/lib/lifecycles/tag.js +10 -10
  20. package/lib/preset-loader.js +73 -9
  21. package/lib/print-error.js +3 -3
  22. package/lib/run-exec.js +6 -5
  23. package/lib/run-execFile.js +6 -5
  24. package/lib/run-lifecycle-script.js +6 -6
  25. package/lib/stringify-package.js +1 -5
  26. package/lib/updaters/index.js +25 -12
  27. package/lib/updaters/types/csproj.js +4 -4
  28. package/lib/updaters/types/gradle.js +4 -4
  29. package/lib/updaters/types/json.js +9 -9
  30. package/lib/updaters/types/maven.js +25 -8
  31. package/lib/updaters/types/openapi.js +6 -6
  32. package/lib/updaters/types/plain-text.js +4 -4
  33. package/lib/updaters/types/python.js +4 -4
  34. package/lib/updaters/types/yaml.js +6 -6
  35. package/lib/write-file.js +3 -3
  36. package/package.json +25 -15
  37. package/test/commit-message-config.integration-test.js +23 -10
  38. package/test/config-files.integration-test.js +25 -10
  39. package/test/config-keys.integration-test.js +20 -7
  40. package/test/core.spec.js +103 -37
  41. package/test/git.integration-test.js +23 -15
  42. package/test/invalid-config.integration-test.js +19 -9
  43. package/test/mocks/pom-6.3.1-attrs-lf.xml +28 -0
  44. package/test/mocks/pom-6.4.0-attrs-lf.xml +29 -0
  45. package/test/mocks/vitest-mocks.js +260 -0
  46. package/test/package.json +3 -0
  47. package/test/pre-commit-hook.integration-test.js +22 -14
  48. package/test/preset.integration-test.js +7 -5
  49. package/test/setup-coverage.js +47 -0
  50. package/test/stringify-package.spec.js +1 -3
  51. package/test/utils.spec.js +3 -4
  52. package/vitest.config.js +26 -0
  53. package/jest.config.js +0 -28
  54. package/test/mocks/jest-mocks.js +0 -66
@@ -3,37 +3,30 @@ on:
3
3
  branches:
4
4
  - master
5
5
  pull_request:
6
- types: [ assigned, opened, synchronize, reopened, labeled ]
6
+ types: [assigned, opened, synchronize, reopened, labeled]
7
7
  name: ci
8
8
  jobs:
9
9
  test:
10
10
  runs-on: ${{ matrix.os }}
11
11
  strategy:
12
12
  matrix:
13
- node: [
14
- 18,
15
- 20,
16
- lts/*
17
- ]
18
- os: [
19
- ubuntu-latest,
20
- windows-latest
21
- ]
13
+ node: [22, lts/*, 24]
14
+ os: [ubuntu-latest, windows-latest]
22
15
  env:
23
- OS: ${{ matrix.os }}
24
- NODE_VERSION: ${{ matrix.node }}
16
+ OS: ${{ matrix.os }}
17
+ NODE_VERSION: ${{ matrix.node }}
25
18
  steps:
26
- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
19
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4
27
20
  - run: git fetch --prune --unshallow
28
21
  - run: git config --global user.name 'Actions'
29
22
  - run: git config --global user.email 'dummy@example.org'
30
- - uses: actions/setup-node@v4
23
+ - uses: actions/setup-node@v6
31
24
  with:
32
25
  node-version: ${{ matrix.node }}
33
26
  - run: node --version
34
27
  - run: npm install --engine-strict
35
28
  - run: npm test
36
29
  - name: Codecov
37
- uses: codecov/codecov-action@v5
30
+ uses: codecov/codecov-action@v7
38
31
  with:
39
32
  env_vars: OS, NODE_VERSION
@@ -14,23 +14,25 @@ jobs:
14
14
  release-please:
15
15
  runs-on: ubuntu-latest
16
16
  steps:
17
- - uses: GoogleCloudPlatform/release-please-action@v4
17
+ - uses: GoogleCloudPlatform/release-please-action@v5
18
18
  id: release
19
19
  with:
20
20
  token: ${{ secrets.GITHUB_TOKEN }}
21
21
  release-type: node
22
22
  package-name: commit-and-tag-version
23
23
  # The logic below handles the npm publication:
24
- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
24
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4
25
25
  # these if statements ensure that a publication only occurs when
26
26
  # a new release is created:
27
27
  if: ${{ steps.release.outputs.release_created }}
28
- - uses: actions/setup-node@v4
28
+ - uses: actions/setup-node@v6
29
29
  with:
30
- node-version: 20
30
+ node-version: 22
31
31
  registry-url: 'https://registry.npmjs.org'
32
32
  if: ${{ steps.release.outputs.release_created }}
33
+ - run: npm install -g npm@latest
34
+ if: ${{ steps.release.outputs.release_created }}
33
35
  - run: npm ci
34
36
  if: ${{ steps.release.outputs.release_created }}
35
- - run: npm publish
37
+ - run: npm publish --provenance
36
38
  if: ${{ steps.release.outputs.release_created }}
package/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  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.
4
4
 
5
+ ## [13.0.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.7.3...v13.0.0) (2026-07-18)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * Update all conventional-changelog dependencies to their modern version. There are a few breaking changes that will affect users with custom presets, please see MIGRATION.md. This also raises the node minimum to node 22.
11
+ * This package is now pure ESM. CLI uses should be unaffected. This raises the minimum engine to 20.19, and anyone using require will need to `require('commit-and-tag-version').default`
12
+
13
+ ### deps
14
+
15
+ * Update all conventional-changelog dependencies to their modern version. There are a few breaking changes that will affect users with custom presets, please see MIGRATION.md. This also raises the node minimum to node 22. ([c2d26bf](https://github.com/absolute-version/commit-and-tag-version/commit/c2d26bf0b5692de6c357104613557f5bd41c95da))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **maven:** preserve comments in pom.xml ([#294](https://github.com/absolute-version/commit-and-tag-version/issues/294)) ([cbb6010](https://github.com/absolute-version/commit-and-tag-version/commit/cbb60100f194877924d9cb98587aa8b2591b8318))
21
+
22
+
23
+ ### Code Refactoring
24
+
25
+ * This package is now pure ESM. CLI uses should be unaffected. This raises the minimum engine to 20.19, and anyone using require will need to `require('commit-and-tag-version').default` ([89ba82e](https://github.com/absolute-version/commit-and-tag-version/commit/89ba82eae4e2a167a5272c88a51d24a4e0a6b5da))
26
+
27
+ ## [12.7.3](https://github.com/absolute-version/commit-and-tag-version/compare/v12.7.2...v12.7.3) (2026-03-18)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * update release workflow for npm OIDC trusted publishing ([#281](https://github.com/absolute-version/commit-and-tag-version/issues/281)) ([d0e3408](https://github.com/absolute-version/commit-and-tag-version/commit/d0e3408a17ad9e20ab2e7d9b187d0a22da012cf7))
33
+
34
+ ## [12.7.2](https://github.com/absolute-version/commit-and-tag-version/compare/v12.7.1...v12.7.2) (2026-03-18)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **maven:** Preserve XML attributes when updating pom.xml files ([#279](https://github.com/absolute-version/commit-and-tag-version/issues/279)) ([81b4f98](https://github.com/absolute-version/commit-and-tag-version/commit/81b4f98319b88793f406139aa102d17a422cb8de))
40
+
5
41
  ## [12.7.1](https://github.com/absolute-version/commit-and-tag-version/compare/v12.7.0...v12.7.1) (2026-03-18)
6
42
 
7
43
 
package/MIGRATION.md ADDED
@@ -0,0 +1,51 @@
1
+ # Migration notes
2
+
3
+ ## Upgrading to v13
4
+
5
+ v13 upgrades the underlying [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) packages from versions that were several majors behind (`conventional-changelog` 4 → 8, `conventional-changelog-conventionalcommits` 6 → 10, `conventional-recommended-bump` 7 → 12), and makes the package pure ESM. Sorry it took so long to get here!
6
+
7
+ Most users don't need to change anything: your `.versionrc` / `package.json` configuration, CLI flags, changelog format and version bump behaviour all work exactly as before. The changes below only affect you if one of these applies:
8
+
9
+ ### Presets other than `conventionalcommits` must be installed separately
10
+
11
+ Older versions of `commit-and-tag-version` bundled all of the conventional-changelog presets (angular, atom, ember, and so on) via the old `conventional-changelog` metapackage. The new version only ships with the default [conventionalcommits](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits) preset.
12
+
13
+ If you use `--preset` (or the `preset` config key) with anything other than the default, you will need to install that preset alongside `commit-and-tag-version`:
14
+
15
+ ```sh
16
+ npm install --save-dev conventional-changelog-angular
17
+ ```
18
+
19
+ Presets must also use the modern conventional-changelog preset interface (a factory function). All official presets released since mid-2023 do; if you use a custom or third-party preset that hasn't been updated, you'll see an error like _"The preset does not export a function. Maybe you are using an old version of the preset. Please upgrade your preset."_
20
+
21
+ ### Pure ESM
22
+
23
+ The package is now pure ESM. CLI usage is unaffected. If you use the programmatic API:
24
+
25
+ - `import commitAndTagVersion from 'commit-and-tag-version'` works as before.
26
+ - CommonJS callers need `require('commit-and-tag-version').default` (on Node 22+, `require()` of an ES module is supported natively).
27
+
28
+ ### Changelog formatting: section spacing
29
+
30
+ The changelog writer now emits a single blank line between sections where it previously emitted two:
31
+
32
+ ```diff
33
+ ## [2.0.0](https://github.com/you/repo/compare/v1.0.0...v2.0.0) (2026-07-18)
34
+
35
+ -
36
+ ### ⚠ BREAKING CHANGES
37
+ ```
38
+
39
+ The content of the changelog is otherwise unchanged. This only affects newly generated releases; existing changelog content is never rewritten (unless you use `--releaseCount 0`).
40
+
41
+ ### Node.js 22 or newer is required
42
+
43
+ The new conventional-changelog packages require Node.js >= 22, so `commit-and-tag-version` now does too. Node 20 reached end-of-life in April 2026, so I expect this won't affect most users.
44
+
45
+ ### Behaviour that is intentionally preserved
46
+
47
+ The upstream packages made some breaking changes that `commit-and-tag-version` shields you from, so no action is needed for these — they're listed here for the record:
48
+
49
+ - **`types[].hidden` and the URL format options still work.** conventional-changelog-conventionalcommits 10 replaced `types[].hidden` with `types[].effect`, and replaced the `commitUrlFormat`, `compareUrlFormat`, `issueUrlFormat` and `userUrlFormat` template strings with callback functions. `commit-and-tag-version` translates the [config-spec](https://github.com/conventional-changelog/conventional-changelog-config-spec) options for you, so existing configuration keeps working. (If you supply the new-style `effect` / `format*Url` options, they're passed through untouched.)
50
+ - **Version bump recommendations are unchanged.** The new preset only recommends a release when there's at least one `feat`, `fix`, `perf`, `revert` or breaking change; `commit-and-tag-version` keeps its historical behaviour of always recommending at least a patch. Use `--noBumpWhenEmptyChanges` if you don't want a release when there are no relevant commits, as before. In a future major release, we might change this default, depending on feedback.
51
+ - **`parserOpts` and `writerOpts` overrides work as before**, merged over the preset's options.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **`Can I simply swap the library to migrate?`** To migrate, you can drop in `commit-and-tag-version` in place of `standard-version`. There are no changes in 9.5.0, other than to add the package.json config key `commit-and-tag-version` (the previous configuration key `standard-version` will still work). 10.x drops support for deprecated node versions, 11.x is a formatting change if you're relying on the exact markdown format in the changelog, and 12.x drops support for node 14/16.
6
6
 
7
- > **`Why was it renamed commit-and-tag-version?`**. I didn't want to scope the package or name it `standard-version-fork`, and it was a good opportunity to make the purpose of the tool clearer. I also wanted to distinguish it from the other tool in this organisation, [`absolute-version`](https://github.com/absolute-version/absolute-version-js), which just prints version information for pre-releases.
7
+ > **`Why was it renamed commit-and-tag-version?`**. I didn't want to scope the package or name it `standard-version-fork`, and it was a good opportunity to make the purpose of the tool clearer. I also wanted to distinguish it from the other tool in this organisation, [`absolute-version`](https://github.com/absolute-version/absolute-version-js), which just prints version information for pre-releases.
8
8
 
9
9
  A utility for versioning using [semver](https://semver.org/) and CHANGELOG generation powered by [Conventional Commits](https://conventionalcommits.org).
10
10
 
@@ -17,14 +17,14 @@ A utility for versioning using [semver](https://semver.org/) and CHANGELOG gener
17
17
  _Having problems? Want to contribute? Join us on the [node-tooling community Slack](http://devtoolscommunity.herokuapp.com)_.
18
18
 
19
19
  - [Commit and Tag Version](#commit-and-tag-version)
20
- - [How It Works:](#how-it-works)
21
- - [`bumpFiles`, `packageFiles` and `updaters`](#bumpfiles-packagefiles-and-updaters)
22
- - [Maven Support (Java/Kotlin)](#maven-support-javakotlin)
23
- - [Gradle Support (Java/Kotlin)](#gradle-support-javakotlin)
24
- - [.NET Support](#net-support)
25
- - [YAML Support](#yaml-support)
26
- - [OpenAPI Support](#openapi-support)
27
- - [Python Support](#python-support)
20
+ - [How It Works:](#how-it-works)
21
+ - [`bumpFiles`, `packageFiles` and `updaters`](#bumpfiles-packagefiles-and-updaters)
22
+ - [Maven Support (Java/Kotlin)](#maven-support-javakotlin)
23
+ - [Gradle Support (Java/Kotlin)](#gradle-support-javakotlin)
24
+ - [.NET Support](#net-support)
25
+ - [YAML Support](#yaml-support)
26
+ - [OpenAPI Support](#openapi-support)
27
+ - [Python Support](#python-support)
28
28
  - [Installing `commit-and-tag-version`](#installing-commit-and-tag-version)
29
29
  - [As a local `npm run` script](#as-a-local-npm-run-script)
30
30
  - [As global `bin`](#as-global-bin)
@@ -58,7 +58,6 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
58
58
  - [`writeVersion(contents = string, version: string): string`](#writeversioncontents--string-version-string-string)
59
59
  - [License](#license)
60
60
 
61
-
62
61
  ### How It Works
63
62
 
64
63
  1. Follow the [Conventional Commits Specification](https://conventionalcommits.org) in your repository.
@@ -131,7 +130,7 @@ commit-and-tag-version --packageFiles openapi.yaml --bumpFiles openapi.yaml
131
130
 
132
131
  ### Python Support
133
132
 
134
- If you are using Python ***with Poetry***, then point to your `pyproject.toml` file.
133
+ If you are using Python **_with Poetry_**, then point to your `pyproject.toml` file.
135
134
 
136
135
  ```sh
137
136
  commit-and-tag-version --packageFiles pyproject.toml --bumpFiles pyproject.toml
@@ -187,7 +186,7 @@ You can configure `commit-and-tag-version` either by:
187
186
  your project is JavaScript).
188
187
 
189
188
  > Note for users who have migrated to
190
- `commit-and-tag-version` from `standard-version`: the previous package.json configuration key of `standard-version` will still work.
189
+ > `commit-and-tag-version` from `standard-version`: the previous package.json configuration key of `standard-version` will still work.
191
190
 
192
191
  2. Creating a `.versionrc`, `.versionrc.json` or `.versionrc.js`.
193
192
 
@@ -202,6 +201,8 @@ By default, `commit-and-tag-version` uses the [conventionalcommits preset](https
202
201
 
203
202
  This preset adheres closely to the [conventionalcommits.org](https://www.conventionalcommits.org) specification.
204
203
 
204
+ If you want to use a different preset (for example `--preset angular`), you can install its package (for example `conventional-changelog-angular`). Presets must use the modern conventional-changelog preset interface (a factory function, used by presets released since mid-2023).
205
+
205
206
  Suppose you're using GitLab, rather than GitHub, you might modify the following variables:
206
207
 
207
208
  - `commitUrlFormat`: the URL format of commit SHAs detected in commit messages.
@@ -496,13 +497,13 @@ commit-and-tag-version --help
496
497
  ## Code Usage
497
498
 
498
499
  ```js
499
- const commitAndTagVersion = require("commit-and-tag-version");
500
+ const commitAndTagVersion = require('commit-and-tag-version');
500
501
 
501
502
  // Options are the same as command line, except camelCase
502
503
  // commitAndTagVersion returns a Promise
503
504
  commitAndTagVersion({
504
505
  noVerify: true,
505
- infile: "docs/CHANGELOG.md",
506
+ infile: 'docs/CHANGELOG.md',
506
507
  silent: true,
507
508
  })
508
509
  .then(() => {
@@ -574,8 +575,8 @@ If using `.versionrc.js` as your configuration file, the `updater` may also be s
574
575
  ```js
575
576
  // .versionrc.js
576
577
  const tracker = {
577
- filename: "VERSION_TRACKER.json",
578
- updater: require("./path/to/custom-version-updater"),
578
+ filename: 'VERSION_TRACKER.json',
579
+ updater: require('./path/to/custom-version-updater'),
579
580
  };
580
581
 
581
582
  module.exports = {
@@ -618,9 +619,9 @@ An acceptable `commit-and-tag-version-updater.js` would be:
618
619
 
619
620
  ```js
620
621
  // commit-and-tag-version-updater.js
621
- const stringifyPackage = require("stringify-package");
622
- const detectIndent = require("detect-indent");
623
- const detectNewline = require("detect-newline");
622
+ const stringifyPackage = require('stringify-package');
623
+ const detectIndent = require('detect-indent');
624
+ const detectNewline = require('detect-newline');
624
625
 
625
626
  module.exports.readVersion = function (contents) {
626
627
  return JSON.parse(contents).tracker.package.version;
@@ -666,8 +667,8 @@ When you are ready to release v1.0.0, add `--release-as 1.0.0` to the options.
666
667
  By default, the conventional commits preset is used. This means that only `fix`, `feat` and anything marked as a breaking change will appear in the changelog.
667
668
 
668
669
  Conventional commits is meant to make it easy for machines to reason about the user-facing changes,
669
- and the changelog generation makes it easy for humans to consume this information too.
670
- Usually, you wouldn't want non-user facing changes like refactor in the changelog.
670
+ and the changelog generation makes it easy for humans to consume this information too.
671
+ Usually, you wouldn't want non-user facing changes like refactor in the changelog.
671
672
 
672
673
  ## License
673
674
 
package/bin/cli.js CHANGED
@@ -6,8 +6,8 @@ if (process.version.match(/v(\d+)\./)[1] < 6) {
6
6
  'commit-and-tag-version: Node v6 or greater is required. `commit-and-tag-version` did not run.',
7
7
  );
8
8
  } else {
9
- const standardVersion = require('../index');
10
- const cmdParser = require('../command');
9
+ const { default: standardVersion } = await import('../index.js');
10
+ const { default: cmdParser } = await import('../command.js');
11
11
  standardVersion(cmdParser.argv).catch(() => {
12
12
  process.exit(1);
13
13
  });
package/command.js CHANGED
@@ -1,7 +1,12 @@
1
- const spec = require('conventional-changelog-config-spec');
2
- const { getConfiguration } = require('./lib/configuration');
3
- const defaults = require('./defaults');
1
+ import { createRequire } from 'module';
2
+ import spec from 'conventional-changelog-config-spec';
3
+ import { getConfiguration } from './lib/configuration.js';
4
+ import defaults from './defaults.js';
4
5
 
6
+ const require = createRequire(import.meta.url);
7
+
8
+ // Load the CommonJS build of yargs: the yargs ESM entrypoint does not provide
9
+ // the argv singleton, and its help output wraps differently.
5
10
  const yargs = require('yargs')
6
11
  .usage('Usage: $0 [options]')
7
12
  .option('packageFiles', {
@@ -176,4 +181,4 @@ Object.keys(spec.properties).forEach((propertyKey) => {
176
181
  });
177
182
  });
178
183
 
179
- module.exports = yargs;
184
+ export default yargs;
package/defaults.js CHANGED
@@ -1,4 +1,4 @@
1
- const spec = require('conventional-changelog-config-spec');
1
+ import spec from 'conventional-changelog-config-spec';
2
2
 
3
3
  const defaults = {
4
4
  infile: 'CHANGELOG.md',
@@ -15,7 +15,7 @@ const defaults = {
15
15
  dryRun: false,
16
16
  tagForce: false,
17
17
  gitTagFallback: true,
18
- preset: require.resolve('conventional-changelog-conventionalcommits'),
18
+ preset: 'conventional-changelog-conventionalcommits',
19
19
  npmPublishHint: undefined,
20
20
  config: undefined,
21
21
  };
@@ -42,4 +42,6 @@ defaults.bumpFiles = defaults.packageFiles.concat([
42
42
  'npm-shrinkwrap.json',
43
43
  ]);
44
44
 
45
- module.exports = defaults;
45
+ export const header = defaults.header;
46
+
47
+ export default defaults;
package/eslint.config.mjs CHANGED
@@ -1,67 +1,77 @@
1
- import globals from "globals";
2
- import js from "@eslint/js";
3
- import jest from "eslint-plugin-jest";
4
- import eslintConfigPrettier from "eslint-config-prettier";
1
+ import globals from 'globals';
2
+ import js from '@eslint/js';
3
+ import vitest from '@vitest/eslint-plugin';
4
+ import eslintConfigPrettier from 'eslint-config-prettier';
5
5
 
6
6
  /**
7
7
  * @type {import("eslint").Linter.Config}
8
8
  */
9
9
  export default [
10
10
  {
11
- "ignores": [".git/", ".github/", ".husky/", ".scannerwork/", ".vscode/", "coverage/", "node_modules/"],
12
- "name": "Files to ignore"
11
+ ignores: [
12
+ '.git/',
13
+ '.github/',
14
+ '.husky/',
15
+ '.scannerwork/',
16
+ '.vscode/',
17
+ 'coverage/',
18
+ 'node_modules/',
19
+ ],
20
+ name: 'Files to ignore',
13
21
  },
14
22
  {
15
23
  ...eslintConfigPrettier,
16
- "name": "Prettier"
24
+ name: 'Prettier',
17
25
  },
18
26
  {
19
27
  ...js.configs.recommended,
20
- "files": ["**/*.{js,cjs,mjs}"],
21
- "languageOptions": {
22
- "ecmaVersion": 2023
28
+ files: ['**/*.{js,cjs,mjs}'],
29
+ languageOptions: {
30
+ ecmaVersion: 2023,
23
31
  },
24
- "name": "JavaScript files",
25
- "rules": {
32
+ name: 'JavaScript files',
33
+ rules: {
26
34
  ...js.configs.recommended.rules,
27
- "no-var": "error",
28
- "no-unused-vars": [
29
- "error",
35
+ 'no-var': 'error',
36
+ 'no-unused-vars': [
37
+ 'error',
30
38
  {
31
- "argsIgnorePattern": "_.*"
32
- }
33
- ]
34
- }
39
+ argsIgnorePattern: '_.*',
40
+ },
41
+ ],
42
+ },
35
43
  },
36
44
  {
37
- "files": ["**/*.mjs"],
38
- "languageOptions": {
39
- "sourceType": "module"
45
+ files: ['**/*.mjs'],
46
+ languageOptions: {
47
+ sourceType: 'module',
40
48
  },
41
- "name": "JavaScript modules"
49
+ name: 'JavaScript modules',
42
50
  },
43
51
  {
44
- "files": ["**/*.{js,cjs,mjs}"],
45
- "languageOptions": {
46
- "globals": {
47
- ...globals.node
48
- }
52
+ files: ['**/*.{js,cjs,mjs}'],
53
+ languageOptions: {
54
+ globals: {
55
+ ...globals.node,
56
+ },
49
57
  },
50
- "name": "Node.js files"
58
+ name: 'Node.js files',
51
59
  },
52
60
  {
53
- ...jest.configs["flat/recommended"],
54
- "files": ["test/**/*{spec,test}.{js,cjs,mjs}", "test/mocks/jest-mocks.js"],
55
- "languageOptions": {
56
- "globals": {
57
- ...globals.jest
58
- }
61
+ ...vitest.configs.recommended,
62
+ files: [
63
+ 'test/**/*{spec,test,integration-test}.{js,cjs,mjs}',
64
+ 'test/mocks/vitest-mocks.js',
65
+ ],
66
+ languageOptions: {
67
+ globals: {
68
+ ...vitest.environments.env.globals,
69
+ },
70
+ },
71
+ name: 'Test files',
72
+ rules: {
73
+ ...vitest.configs.recommended.rules,
74
+ 'vitest/expect-expect': 'off',
59
75
  },
60
- "name": "Test files",
61
- "rules": {
62
- ...jest.configs["flat/recommended"].rules,
63
- "jest/prefer-expect-assertions": "off",
64
- "jest/expect-expect": "off"
65
- }
66
- }
76
+ },
67
77
  ];
package/index.js CHANGED
@@ -1,15 +1,15 @@
1
- const bump = require('./lib/lifecycles/bump');
2
- const changelog = require('./lib/lifecycles/changelog');
3
- const commit = require('./lib/lifecycles/commit');
4
- const fs = require('fs');
5
- const latestSemverTag = require('./lib/latest-semver-tag');
6
- const path = require('path');
7
- const printError = require('./lib/print-error');
8
- const tag = require('./lib/lifecycles/tag');
9
- const { resolveUpdaterObjectFromArgument } = require('./lib/updaters');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import bump from './lib/lifecycles/bump.js';
4
+ import changelog from './lib/lifecycles/changelog.js';
5
+ import commit from './lib/lifecycles/commit.js';
6
+ import latestSemverTag from './lib/latest-semver-tag.js';
7
+ import printError from './lib/print-error.js';
8
+ import tag from './lib/lifecycles/tag.js';
9
+ import { resolveUpdaterObjectFromArgument } from './lib/updaters/index.js';
10
+ import defaults from './defaults.js';
10
11
 
11
- module.exports = async function standardVersion(argv) {
12
- const defaults = require('./defaults');
12
+ export default async function standardVersion(argv) {
13
13
  /**
14
14
  * `--message` (`-m`) support will be removed in the next major version.
15
15
  */
@@ -93,4 +93,4 @@ module.exports = async function standardVersion(argv) {
93
93
  printError(args, err.message);
94
94
  throw err;
95
95
  }
96
- };
96
+ }
package/lib/checkpoint.js CHANGED
@@ -1,8 +1,8 @@
1
- const chalk = require('chalk');
2
- const figures = require('figures');
3
- const util = require('util');
1
+ import chalk from 'chalk';
2
+ import figures from 'figures';
3
+ import util from 'util';
4
4
 
5
- module.exports = function (argv, msg, args, figure) {
5
+ export default function (argv, msg, args, figure) {
6
6
  const defaultFigure = argv.dryRun
7
7
  ? chalk.yellow(figures.tick)
8
8
  : chalk.green(figures.tick);
@@ -20,4 +20,4 @@ module.exports = function (argv, msg, args, figure) {
20
20
  ),
21
21
  );
22
22
  }
23
- };
23
+ }
@@ -1,6 +1,9 @@
1
- const path = require('path');
2
- const findUp = require('find-up');
3
- const { readFileSync } = require('fs');
1
+ import path from 'path';
2
+ import { createRequire } from 'module';
3
+ import fs from 'fs';
4
+ import findUp from 'find-up';
5
+
6
+ const require = createRequire(import.meta.url);
4
7
 
5
8
  const CONFIGURATION_FILES = [
6
9
  '.versionrc',
@@ -9,7 +12,7 @@ const CONFIGURATION_FILES = [
9
12
  '.versionrc.js',
10
13
  ];
11
14
 
12
- module.exports.getConfiguration = function (configFile) {
15
+ export function getConfiguration(configFile) {
13
16
  let config = {};
14
17
 
15
18
  // If the user has provided a configuration file via the `--config` argument, we use that.
@@ -28,7 +31,7 @@ module.exports.getConfiguration = function (configFile) {
28
31
  config = jsConfiguration;
29
32
  }
30
33
  } else {
31
- config = JSON.parse(readFileSync(configPath));
34
+ config = JSON.parse(fs.readFileSync(configPath));
32
35
  }
33
36
 
34
37
  /**
@@ -42,4 +45,4 @@ module.exports.getConfiguration = function (configFile) {
42
45
  }
43
46
 
44
47
  return config;
45
- };
48
+ }
@@ -4,15 +4,15 @@
4
4
  * modified to support only detecting lock file and not detecting global package manager
5
5
  */
6
6
 
7
- const { promises: fs } = require('fs');
8
- const { resolve } = require('path');
7
+ import fs from 'fs';
8
+ import { resolve } from 'path';
9
9
 
10
10
  /**
11
11
  * Check if a path exists
12
12
  */
13
13
  async function pathExists(p) {
14
14
  try {
15
- await fs.access(p);
15
+ await fs.promises.access(p);
16
16
  return true;
17
17
  } catch {
18
18
  return false;
@@ -39,7 +39,7 @@ function getTypeofLockFile(cwd = '.') {
39
39
  });
40
40
  }
41
41
 
42
- const detectPMByLockFile = async (cwd) => {
42
+ export const detectPMByLockFile = async (cwd) => {
43
43
  const type = await getTypeofLockFile(cwd);
44
44
  if (type) {
45
45
  return type;
@@ -47,7 +47,3 @@ const detectPMByLockFile = async (cwd) => {
47
47
 
48
48
  return 'npm';
49
49
  };
50
-
51
- module.exports = {
52
- detectPMByLockFile,
53
- };
@@ -1,4 +1,4 @@
1
- module.exports = function (rawMsg, newVersion) {
1
+ export default function (rawMsg, newVersion) {
2
2
  const message = String(rawMsg);
3
3
  return message.replace(/{{currentTag}}/g, newVersion);
4
- };
4
+ }