commit-and-tag-version 12.4.3 → 12.5.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.
@@ -24,7 +24,7 @@ jobs:
24
24
  OS: ${{ matrix.os }}
25
25
  NODE_VERSION: ${{ matrix.node }}
26
26
  steps:
27
- - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
27
+ - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4
28
28
  - run: git fetch --prune --unshallow
29
29
  - run: git config --global user.name 'Actions'
30
30
  - run: git config --global user.email 'dummy@example.org'
@@ -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@d632683dd7b4114ad314bca15554477dd762a938 # 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.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.4.4...v12.5.0) (2024-10-10)
6
+
7
+
8
+ ### Features
9
+
10
+ * **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))
11
+
12
+ ## [12.4.4](https://github.com/absolute-version/commit-and-tag-version/compare/v12.4.3...v12.4.4) (2024-09-15)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * sanitize double quotes result from stdout ([#186](https://github.com/absolute-version/commit-and-tag-version/issues/186)) ([8dbeb79](https://github.com/absolute-version/commit-and-tag-version/commit/8dbeb794b960c6ea27527353ad2c55884f48b469))
18
+
5
19
  ## [12.4.3](https://github.com/absolute-version/commit-and-tag-version/compare/v12.4.2...v12.4.3) (2024-09-09)
6
20
 
7
21
 
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
@@ -13,6 +13,7 @@ const semver = require('semver');
13
13
  const writeFile = require('../write-file');
14
14
  const { resolveUpdaterObjectFromArgument } = require('../updaters');
15
15
  let configsToUpdate = {};
16
+ const sanitizeQuotesRegex = /['"]+/g;
16
17
 
17
18
  async function Bump(args, version) {
18
19
  // reset the cache of updated config files each
@@ -37,7 +38,7 @@ async function Bump(args, version) {
37
38
  await runLifecycleScript(args, 'prerelease');
38
39
  const stdout = await runLifecycleScript(args, 'prebump');
39
40
  if (stdout?.trim().length) {
40
- const prebumpString = stdout.trim();
41
+ const prebumpString = stdout.trim().replace(sanitizeQuotesRegex, '');
41
42
  if (semver.valid(prebumpString)) args.releaseAs = prebumpString;
42
43
  }
43
44
  if (!args.firstRelease) {
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "commit-and-tag-version",
3
- "version": "12.4.3",
3
+ "version": "12.5.0",
4
4
  "description": "replacement for `npm version` with automatic CHANGELOG generation",
5
5
  "bin": "bin/cli.js",
6
6
  "scripts": {
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 () {
@@ -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"