commit-and-tag-version 12.4.4 → 12.5.1

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.
@@ -12,7 +12,6 @@ jobs:
12
12
  matrix:
13
13
  node: [
14
14
  18,
15
- 20.4, # Known good version of 20 which ran the previous Mocha and mock-fs based tests. If you go back to re-run those, tests Node 20.4 is the last version mock-fs worked with
16
15
  20,
17
16
  lts/*
18
17
  ]
@@ -24,7 +23,7 @@ jobs:
24
23
  OS: ${{ matrix.os }}
25
24
  NODE_VERSION: ${{ matrix.node }}
26
25
  steps:
27
- - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
26
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
28
27
  - run: git fetch --prune --unshallow
29
28
  - run: git config --global user.name 'Actions'
30
29
  - run: git config --global user.email 'dummy@example.org'
@@ -35,6 +34,6 @@ jobs:
35
34
  - run: npm install --engine-strict
36
35
  - run: npm test
37
36
  - name: Codecov
38
- uses: codecov/codecov-action@v4
37
+ uses: codecov/codecov-action@v5
39
38
  with:
40
39
  env_vars: OS, NODE_VERSION
@@ -15,7 +15,7 @@ jobs:
15
15
  release-type: node
16
16
  package-name: commit-and-tag-version
17
17
  # The logic below handles the npm publication:
18
- - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
18
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
19
19
  # these if statements ensure that a publication only occurs when
20
20
  # a new release is created:
21
21
  if: ${{ steps.release.outputs.release_created }}
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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
+ ## [12.5.1](https://github.com/absolute-version/commit-and-tag-version/compare/v12.5.0...v12.5.1) (2025-04-09)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * ignore other prerelease tags when finding latest tag ([#211](https://github.com/absolute-version/commit-and-tag-version/issues/211)) ([#213](https://github.com/absolute-version/commit-and-tag-version/issues/213)) ([1bcdf40](https://github.com/absolute-version/commit-and-tag-version/commit/1bcdf408cac54aff37aa4d5611444f6877aad6f9))
11
+
12
+ ## [12.5.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.4.4...v12.5.0) (2024-10-10)
13
+
14
+
15
+ ### Features
16
+
17
+ * **python:** add poetry support ([#188](https://github.com/absolute-version/commit-and-tag-version/issues/188)) ([01f08e9](https://github.com/absolute-version/commit-and-tag-version/commit/01f08e9093e255f81394c97bcac59e057f5717dc))
18
+
5
19
  ## [12.4.4](https://github.com/absolute-version/commit-and-tag-version/compare/v12.4.3...v12.4.4) (2024-09-15)
6
20
 
7
21
 
@@ -0,0 +1,41 @@
1
+ # Contributing to `commit-and-tag-version`
2
+
3
+ Thank you for considering contributing to `commit-and-tag-version`! Your help is greatly appreciated.
4
+
5
+ ## How to Get Started
6
+
7
+ 1. **Fork** this repository to your GitHub account.
8
+ 2. **Clone** the forked repository to your local machine.
9
+ 3. **Create** a new branch for your contributions.
10
+ 4. **Make** your changes or additions.
11
+ 5. **Push** the branch to your forked repository.
12
+ 6. **Submit** a pull request and describe the changes made.
13
+
14
+ ## Bug Reports
15
+
16
+ If you encounter any bugs, please open an [issue](https://github.com/absolute-version/commit-and-tag-version/issues) and include:
17
+
18
+ - A detailed description of the bug.
19
+ - Steps to reproduce the bug.
20
+ - Expected and actual behavior.
21
+ - Your environment (OS, browser, etc.).
22
+
23
+ ## Feature Requests
24
+
25
+ To suggest new features or enhancements, please open an [issue](https://github.com/absolute-version/commit-and-tag-version/issues) with:
26
+
27
+ - A clear and detailed description of the feature.
28
+ - The problem it would solve or the use case it would address.
29
+ - Any implementation suggestions.
30
+
31
+ ## Pull Request Guidelines
32
+
33
+ - Ensure your code adheres to the project’s coding standards.
34
+ - Write tests for new features or bug fixes.
35
+ - Update documentation as necessary. If there are user facing changes / new features, please ensure the `Readme.md` is updated
36
+ - Provide a comprehensive description of your changes in the pull request.
37
+ - Do not include `package.lock.json` modifications; only include `package.json`. Maintainers will be responsible to generate it.
38
+ - Do not include multiple features in a single commit/PR
39
+ - Please title the PR with [conventional commits](https://www.conventionalcommits.org/), as PRs are squash merged
40
+
41
+ We look forward to your contributions and value your time and effort!
package/README.md CHANGED
@@ -24,6 +24,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
24
24
  - [.NET Support](#net-support)
25
25
  - [YAML Support](#yaml-support)
26
26
  - [OpenAPI Support](#openapi-support)
27
+ - [Python Support](#python-support)
27
28
  - [Installing `commit-and-tag-version`](#installing-commit-and-tag-version)
28
29
  - [As a local `npm run` script](#as-a-local-npm-run-script)
29
30
  - [As global `bin`](#as-global-bin)
@@ -127,6 +128,14 @@ If you are using OpenAPI, then just point to your `openapi.yaml` file.
127
128
  commit-and-tag-version --packageFiles openapi.yaml --bumpFiles openapi.yaml
128
129
  ```
129
130
 
131
+ ### Python Support
132
+
133
+ If you are using Python ***with Poetry***, then point to your `pyproject.toml` file.
134
+
135
+ ```sh
136
+ commit-and-tag-version --packageFiles pyproject.toml --bumpFiles pyproject.toml
137
+ ```
138
+
130
139
  ## Installing `commit-and-tag-version`
131
140
 
132
141
  ### As a local `npm run` script
@@ -620,6 +629,14 @@ with other package managers for other ecosystems).
620
629
 
621
630
  When you are ready to release v1.0.0, add `--release-as 1.0.0` to the options.
622
631
 
632
+ ### Why do my `refactor`, `chore` etc changes not appear in the changelog?
633
+
634
+ 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.
635
+
636
+ Conventional commits is meant to make it easy for machines to reason about the user-facing changes,
637
+ and the changelog generation makes it easy for humans to consume this information too.
638
+ Usually, you wouldn't want non-user facing changes like refactor in the changelog.
639
+
623
640
  ## License
624
641
 
625
642
  ISC
@@ -0,0 +1,67 @@
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";
5
+
6
+ /**
7
+ * @type {import("eslint").Linter.Config}
8
+ */
9
+ export default [
10
+ {
11
+ "ignores": [".git/", ".github/", ".husky/", ".scannerwork/", ".vscode/", "coverage/", "node_modules/"],
12
+ "name": "Files to ignore"
13
+ },
14
+ {
15
+ ...eslintConfigPrettier,
16
+ "name": "Prettier"
17
+ },
18
+ {
19
+ ...js.configs.recommended,
20
+ "files": ["**/*.{js,cjs,mjs}"],
21
+ "languageOptions": {
22
+ "ecmaVersion": 2023
23
+ },
24
+ "name": "JavaScript files",
25
+ "rules": {
26
+ ...js.configs.recommended.rules,
27
+ "no-var": "error",
28
+ "no-unused-vars": [
29
+ "error",
30
+ {
31
+ "argsIgnorePattern": "_.*"
32
+ }
33
+ ]
34
+ }
35
+ },
36
+ {
37
+ "files": ["**/*.mjs"],
38
+ "languageOptions": {
39
+ "sourceType": "module"
40
+ },
41
+ "name": "JavaScript modules"
42
+ },
43
+ {
44
+ "files": ["**/*.{js,cjs,mjs}"],
45
+ "languageOptions": {
46
+ "globals": {
47
+ ...globals.node
48
+ }
49
+ },
50
+ "name": "Node.js files"
51
+ },
52
+ {
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
+ }
59
+ },
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
+ }
67
+ ];
package/index.js CHANGED
@@ -69,6 +69,7 @@ module.exports = async function standardVersion(argv) {
69
69
  : false,
70
70
  };
71
71
  break;
72
+ // eslint-disable-next-line no-unused-vars
72
73
  } catch (err) {
73
74
  /* This probably shouldn't be empty? */
74
75
  }
@@ -78,7 +79,7 @@ module.exports = async function standardVersion(argv) {
78
79
  if (pkg && pkg.version) {
79
80
  version = pkg.version;
80
81
  } else if (args.gitTagFallback) {
81
- version = await latestSemverTag(args.tagPrefix);
82
+ version = await latestSemverTag(args);
82
83
  } else {
83
84
  throw new Error('no package file found');
84
85
  }
@@ -1,13 +1,28 @@
1
1
  const gitSemverTags = require('git-semver-tags');
2
2
  const semver = require('semver');
3
3
 
4
- module.exports = function (tagPrefix = undefined) {
4
+ module.exports = function ({ tagPrefix, prerelease }) {
5
5
  return new Promise((resolve, reject) => {
6
6
  gitSemverTags({ tagPrefix }, function (err, tags) {
7
7
  if (err) return reject(err);
8
8
  else if (!tags.length) return resolve('1.0.0');
9
9
  // Respect tagPrefix
10
10
  tags = tags.map((tag) => tag.replace(new RegExp('^' + tagPrefix), ''));
11
+ if (prerelease) {
12
+ // ignore any other prelease tags
13
+ tags = tags.filter((tag) => {
14
+ if (!semver.valid(tag)) return false;
15
+ if (!semver.prerelease(tag)) {
16
+ // include all non-prerelease versions
17
+ return true;
18
+ }
19
+ // check if the name of the prerelease matches the one we are looking for
20
+ if (semver.prerelease(tag)[0] === prerelease) {
21
+ return true;
22
+ }
23
+ return false;
24
+ });
25
+ }
11
26
  // ensure that the largest semver tag is at the head.
12
27
  tags = tags.map((tag) => {
13
28
  return semver.clean(tag);
@@ -8,6 +8,7 @@ const updatersByType = {
8
8
  csproj: require('./types/csproj'),
9
9
  yaml: require('./types/yaml'),
10
10
  openapi: require('./types/openapi'),
11
+ python: require('./types/python'),
11
12
  };
12
13
  const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt'];
13
14
 
@@ -41,6 +42,9 @@ function getUpdaterByFilename(filename) {
41
42
  if (/\.ya?ml$/.test(filename)) {
42
43
  return getUpdaterByType('yaml');
43
44
  }
45
+ if (/pyproject.toml/.test(filename)) {
46
+ return getUpdaterByType('python');
47
+ }
44
48
  throw Error(
45
49
  `Unsupported file (${filename}) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.`,
46
50
  );
@@ -0,0 +1,30 @@
1
+ const versionExtractRegex = /version[" ]*=[ ]*["'](.*)["']/i;
2
+
3
+ const getVersionIndex = function (lines) {
4
+ let version;
5
+ const lineNumber = lines.findIndex((line) => {
6
+ const versionMatcher = line.match(versionExtractRegex);
7
+ // if version not found in lines provided, return false
8
+ if (versionMatcher == null) {
9
+ return false;
10
+ }
11
+ version = versionMatcher[1];
12
+ return true;
13
+ });
14
+ return { version, lineNumber };
15
+ };
16
+
17
+ module.exports.readVersion = function (contents) {
18
+ const lines = contents.split('\n');
19
+ const versionIndex = getVersionIndex(lines);
20
+ return versionIndex.version;
21
+ };
22
+
23
+ module.exports.writeVersion = function (contents, version) {
24
+ const lines = contents.split('\n');
25
+ const versionIndex = getVersionIndex(lines);
26
+ const versionLine = lines[versionIndex.lineNumber];
27
+ const newVersionLine = versionLine.replace(versionIndex.version, version);
28
+ lines[versionIndex.lineNumber] = newVersionLine;
29
+ return lines.join('\n');
30
+ };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "commit-and-tag-version",
3
- "version": "12.4.4",
3
+ "version": "12.5.1",
4
4
  "description": "replacement for `npm version` with automatic CHANGELOG generation",
5
5
  "bin": "bin/cli.js",
6
6
  "scripts": {
7
- "fix": "eslint . --fix",
8
- "posttest": "eslint . && npm run format:check",
7
+ "lint": "eslint .",
8
+ "lint:fix": "npm run lint -- --fix",
9
+ "posttest": "npm run lint && npm run format:check",
9
10
  "format:base": "prettier \"./**/*.{ts,js}\"",
10
11
  "format:fix": "npm run format:base -- --write",
11
12
  "format:check": "npm run format:base -- --check",
@@ -43,29 +44,30 @@
43
44
  "conventional-changelog-config-spec": "2.1.0",
44
45
  "conventional-changelog-conventionalcommits": "6.1.0",
45
46
  "conventional-recommended-bump": "7.0.1",
46
- "detect-indent": "^6.0.0",
47
+ "detect-indent": "^6.1.0",
47
48
  "detect-newline": "^3.1.0",
48
49
  "dotgitignore": "^2.1.0",
49
- "figures": "^3.1.0",
50
+ "figures": "^3.2.0",
50
51
  "find-up": "^5.0.0",
51
- "git-semver-tags": "^5.0.0",
52
- "jsdom": "^25.0.0",
52
+ "git-semver-tags": "^5.0.1",
53
+ "jsdom": "^25.0.1",
53
54
  "semver": "^7.6.3",
54
55
  "w3c-xmlserializer": "^5.0.0",
55
- "yaml": "^2.4.1",
56
+ "yaml": "^2.6.0",
56
57
  "yargs": "^17.7.2"
57
58
  },
58
59
  "devDependencies": {
59
- "eslint": "^8.56.0",
60
+ "@eslint/js": "^9.13.0",
61
+ "eslint": "^9.13.0",
60
62
  "eslint-config-prettier": "^9.1.0",
61
- "eslint-plugin-import": "^2.29.0",
62
- "eslint-plugin-jest": "^27.6.0",
63
- "eslint-plugin-n": "^15.2.0",
64
- "eslint-plugin-promise": "^6.1.1",
63
+ "eslint-plugin-import": "^2.31.0",
64
+ "eslint-plugin-jest": "^28.8.3",
65
+ "eslint-plugin-n": "^17.11.1",
66
+ "eslint-plugin-promise": "^7.1.0",
65
67
  "jest": "^29.7.0",
66
68
  "jest-serial-runner": "^1.2.1",
67
- "prettier": "3.3.2",
69
+ "prettier": "^3.3.3",
68
70
  "shelljs": "^0.8.5",
69
- "strip-ansi": "^6.0.0"
71
+ "strip-ansi": "^6.0.1"
70
72
  }
71
73
  }
package/test/core.spec.js CHANGED
@@ -1130,6 +1130,42 @@ describe('cli', function () {
1130
1130
  console.warn = origWarn;
1131
1131
  }
1132
1132
  });
1133
+
1134
+ it('bumps version in Python `pyproject.toml` file', async function () {
1135
+ const expected = fs.readFileSync(
1136
+ './test/mocks/pyproject-1.1.0.toml',
1137
+ 'utf-8',
1138
+ );
1139
+
1140
+ const filename = 'python.toml';
1141
+ mock({
1142
+ bump: 'minor',
1143
+ realTestFiles: [
1144
+ {
1145
+ filename,
1146
+ path: './test/mocks/pyproject-1.0.0.toml',
1147
+ },
1148
+ ],
1149
+ });
1150
+
1151
+ await exec({
1152
+ packageFiles: [{ filename, type: 'python' }],
1153
+ bumpFiles: [{ filename, type: 'python' }],
1154
+ });
1155
+
1156
+ // filePath is the first arg passed to writeFileSync
1157
+ const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
1158
+ writeFileSyncSpy,
1159
+ filename,
1160
+ });
1161
+
1162
+ if (!packageJsonWriteFileSynchCall) {
1163
+ throw new Error(`writeFileSynch not invoked with path ${filename}`);
1164
+ }
1165
+
1166
+ const calledWithContentStr = packageJsonWriteFileSynchCall[1];
1167
+ expect(calledWithContentStr).toEqual(expected);
1168
+ });
1133
1169
  });
1134
1170
 
1135
1171
  it('`packageFiles` are bumped along with `bumpFiles` defaults [commit-and-tag-version#533]', async function () {
@@ -272,6 +272,14 @@ describe('git', function () {
272
272
  const output = shell.exec('git tag');
273
273
  expect(output.stdout).toContain('v5.1.0');
274
274
  });
275
+
276
+ it('uses only relevant prerelease tags', async function () {
277
+ shell.rm('package.json');
278
+ mock({ bump: 'minor', tags: ['v1.1.0-b.0', 'v1.1.0-a.0', 'v1.0.0-b.0'] });
279
+ await exec('--prerelease a');
280
+ const output = shell.exec('git tag');
281
+ expect(output.stdout).toContain('1.1.0-a.1');
282
+ });
275
283
  });
276
284
 
277
285
  describe('Run ... to publish', function () {
@@ -0,0 +1,12 @@
1
+ [tool.poetry]
2
+ name = "test"
3
+ version = "1.0.0"
4
+ description = ""
5
+ authors = []
6
+
7
+ [tool.poetry.dependencies]
8
+ python = "^3.8"
9
+
10
+ [build-system]
11
+ requires = ["poetry>=1"]
12
+ build-backend = "poetry.masonry.api"
@@ -0,0 +1,12 @@
1
+ [tool.poetry]
2
+ name = "test"
3
+ version = "1.1.0"
4
+ description = ""
5
+ authors = []
6
+
7
+ [tool.poetry.dependencies]
8
+ python = "^3.8"
9
+
10
+ [build-system]
11
+ requires = ["poetry>=1"]
12
+ build-backend = "poetry.masonry.api"
package/.eslintrc DELETED
@@ -1,49 +0,0 @@
1
- {
2
- "extends": [
3
- "prettier",
4
- "eslint:recommended"
5
- ],
6
- "env": {
7
- "node": true,
8
- "es6": true
9
- },
10
- "overrides": [
11
- {
12
- "env": {
13
- "node": true,
14
- "es6": true,
15
- "jest/globals": true
16
- },
17
- "files": [
18
- "test/**"
19
- ],
20
- "plugins": [
21
- "jest"
22
- ],
23
- "extends": [
24
- "prettier",
25
- "eslint:recommended",
26
- "plugin:jest/recommended"
27
- ],
28
- "rules": {
29
- "jest/prefer-expect-assertions": "off",
30
- "jest/expect-expect": "off"
31
- }
32
- }
33
- ],
34
- "parserOptions": {
35
- "ecmaVersion": 2023
36
- },
37
- "plugins": [
38
- "jest"
39
- ],
40
- "rules": {
41
- "no-var": "error",
42
- "no-unused-vars": [
43
- "error",
44
- {
45
- "argsIgnorePattern": "_.*"
46
- }
47
- ]
48
- }
49
- }