commit-and-tag-version 12.1.0 → 12.2.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.
- package/CHANGELOG.md +7 -0
- package/README.md +13 -4
- package/lib/updaters/index.js +4 -0
- package/lib/updaters/types/maven.js +44 -0
- package/package.json +3 -1
- package/test/core.spec.js +72 -4
- package/test/mocks/pom-6.3.1-crlf.xml +30 -0
- package/test/mocks/pom-6.3.1-lf.xml +30 -0
- package/test/mocks/pom-6.4.0-crlf.xml +30 -0
- package/test/mocks/pom-6.4.0-lf.xml +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.2.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.1.0...v12.2.0) (2024-01-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **updater:** add maven pom.xml file support ([#33](https://github.com/absolute-version/commit-and-tag-version/issues/33), [#109](https://github.com/absolute-version/commit-and-tag-version/issues/109)) ([#123](https://github.com/absolute-version/commit-and-tag-version/issues/123)) ([6466beb](https://github.com/absolute-version/commit-and-tag-version/commit/6466bebf849bbdcdaebf493a1ccce9670c469fde))
|
|
11
|
+
|
|
5
12
|
## [12.1.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.0.0...v12.1.0) (2024-01-06)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
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
|
-
|
|
10
9
|
A utility for versioning using [semver](https://semver.org/) and CHANGELOG generation powered by [Conventional Commits](https://conventionalcommits.org).
|
|
11
10
|
|
|
12
11
|

|
|
@@ -20,6 +19,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
|
|
|
20
19
|
- [Commit and Tag Version](#commit-and-tag-version)
|
|
21
20
|
- [How It Works:](#how-it-works)
|
|
22
21
|
- [`bumpFiles`, `packageFiles` and `updaters`](#bumpfiles-packagefiles-and-updaters)
|
|
22
|
+
- [Maven Support (Java/Kotlin)](#maven-support-javakotlin)
|
|
23
23
|
- [Gradle Support (Java/Kotlin)](#gradle-support-javakotlin)
|
|
24
24
|
- [.NET Support](#net-support)
|
|
25
25
|
- [Installing `commit-and-tag-version`](#installing-commit-and-tag-version)
|
|
@@ -55,7 +55,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
|
|
|
55
55
|
- [License](#license)
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
### How It Works
|
|
58
|
+
### How It Works
|
|
59
59
|
|
|
60
60
|
1. Follow the [Conventional Commits Specification](https://conventionalcommits.org) in your repository.
|
|
61
61
|
2. When you're ready to release, run `commit-and-tag-version`.
|
|
@@ -83,6 +83,14 @@ By default, `commit-and-tag-version` assumes you're working in a NodeJS based pr
|
|
|
83
83
|
|
|
84
84
|
That said, if you find your self asking [How can I use commit-and-tag-version for additional metadata files, languages or version files?](#can-i-use-commit-and-tag-version-for-additional-metadata-files-languages-or-version-files) – these configuration options will help!
|
|
85
85
|
|
|
86
|
+
### Maven Support (Java/Kotlin)
|
|
87
|
+
|
|
88
|
+
If you are using Maven, then just point to your `pom.xml` file.
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
commit-and-tag-version --packageFiles pom.xml --bumpFiles pom.xml
|
|
92
|
+
```
|
|
93
|
+
|
|
86
94
|
### Gradle Support (Java/Kotlin)
|
|
87
95
|
|
|
88
96
|
If you are using Gradle, then just point to your `build.gradle` file (or `build.gradle.kts` if using Kotlin DSL).
|
|
@@ -95,6 +103,7 @@ commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle
|
|
|
95
103
|
|
|
96
104
|
If you are using .NET with `.csproj` files.
|
|
97
105
|
This is going to read and update only the `<Version>` tag in the file.
|
|
106
|
+
|
|
98
107
|
```sh
|
|
99
108
|
commit-and-tag-version --packageFiles <YOUR-PROJECT-NAME>.csproj --bumpFiles <YOUR-PROJECT-NAME>.csproj
|
|
100
109
|
```
|
|
@@ -148,7 +157,7 @@ You can configure `commit-and-tag-version` either by:
|
|
|
148
157
|
1. Placing a `commit-and-tag-version` stanza in your `package.json` (assuming
|
|
149
158
|
your project is JavaScript).
|
|
150
159
|
|
|
151
|
-
> Note for users who have migrated to
|
|
160
|
+
> Note for users who have migrated to
|
|
152
161
|
`commit-and-tag-version` from `standard-version`: the previous package.json configuration key of `standard-version` will still work.
|
|
153
162
|
|
|
154
163
|
2. Creating a `.versionrc`, `.versionrc.json` or `.versionrc.js`.
|
|
@@ -312,7 +321,7 @@ Simply add the following to your package.json to configure lifecycle scripts:
|
|
|
312
321
|
```
|
|
313
322
|
|
|
314
323
|
As an example to change from using GitHub to track your items to using your projects Jira use a
|
|
315
|
-
`postchangelog` script to replace the url fragment containing 'https://github.com/`myproject`/issues
|
|
324
|
+
`postchangelog` script to replace the url fragment containing '<https://github.com/`myproject`/issues/>'
|
|
316
325
|
with a link to your Jira - assuming you have already installed [replace](https://www.npmjs.com/package/replace)
|
|
317
326
|
|
|
318
327
|
```json
|
package/lib/updaters/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const JSON_BUMP_FILES = require('../../defaults').bumpFiles;
|
|
|
3
3
|
const updatersByType = {
|
|
4
4
|
json: require('./types/json'),
|
|
5
5
|
'plain-text': require('./types/plain-text'),
|
|
6
|
+
maven: require('./types/maven'),
|
|
6
7
|
gradle: require('./types/gradle'),
|
|
7
8
|
csproj: require('./types/csproj'),
|
|
8
9
|
};
|
|
@@ -23,6 +24,9 @@ function getUpdaterByFilename(filename) {
|
|
|
23
24
|
if (PLAIN_TEXT_BUMP_FILES.includes(filename)) {
|
|
24
25
|
return getUpdaterByType('plain-text');
|
|
25
26
|
}
|
|
27
|
+
if (/pom.xml/.test(filename)) {
|
|
28
|
+
return getUpdaterByType('maven');
|
|
29
|
+
}
|
|
26
30
|
if (/build.gradle/.test(filename)) {
|
|
27
31
|
return getUpdaterByType('gradle');
|
|
28
32
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const jsdom = require('jsdom');
|
|
2
|
+
const serialize = require('w3c-xmlserializer');
|
|
3
|
+
const detectNewline = require('detect-newline');
|
|
4
|
+
const CRLF = '\r\n';
|
|
5
|
+
const LF = '\n';
|
|
6
|
+
|
|
7
|
+
function pomDocument(contents) {
|
|
8
|
+
const dom = new jsdom.JSDOM('');
|
|
9
|
+
const parser = new dom.window.DOMParser();
|
|
10
|
+
return parser.parseFromString(contents, 'application/xml');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function pomVersionElement(document) {
|
|
14
|
+
const versionElement = document.querySelector('project > version');
|
|
15
|
+
|
|
16
|
+
if (!versionElement) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
'Failed to read the version field in your pom file - is it present?',
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return versionElement;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports.readVersion = function (contents) {
|
|
26
|
+
const document = pomDocument(contents);
|
|
27
|
+
return pomVersionElement(document).textContent;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports.writeVersion = function (contents, version) {
|
|
31
|
+
const newline = detectNewline(contents);
|
|
32
|
+
const document = pomDocument(contents);
|
|
33
|
+
const versionElement = pomVersionElement(document);
|
|
34
|
+
|
|
35
|
+
versionElement.textContent = version;
|
|
36
|
+
|
|
37
|
+
const xml = serialize(document);
|
|
38
|
+
|
|
39
|
+
if (newline === CRLF) {
|
|
40
|
+
return xml.replace(/\n/g, CRLF) + CRLF;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return xml + LF;
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"bin": "bin/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,7 +49,9 @@
|
|
|
49
49
|
"figures": "^3.1.0",
|
|
50
50
|
"find-up": "^5.0.0",
|
|
51
51
|
"git-semver-tags": "^5.0.0",
|
|
52
|
+
"jsdom": "^23.2.0",
|
|
52
53
|
"semver": "^7.5.4",
|
|
54
|
+
"w3c-xmlserializer": "^5.0.0",
|
|
53
55
|
"yargs": "^17.7.2"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
package/test/core.spec.js
CHANGED
|
@@ -1180,29 +1180,97 @@ describe('cli', function () {
|
|
|
1180
1180
|
});
|
|
1181
1181
|
});
|
|
1182
1182
|
|
|
1183
|
+
it('bumps version in Maven `pom.xml` file with CRLF Line Endings', async function () {
|
|
1184
|
+
const expected = fs.readFileSync(
|
|
1185
|
+
'./test/mocks/pom-6.4.0-crlf.xml',
|
|
1186
|
+
'utf-8',
|
|
1187
|
+
);
|
|
1188
|
+
const filename = 'pom.xml';
|
|
1189
|
+
mock({
|
|
1190
|
+
bump: 'minor',
|
|
1191
|
+
realTestFiles: [
|
|
1192
|
+
{
|
|
1193
|
+
filename,
|
|
1194
|
+
path: './test/mocks/pom-6.3.1-crlf.xml',
|
|
1195
|
+
},
|
|
1196
|
+
],
|
|
1197
|
+
});
|
|
1198
|
+
await exec({
|
|
1199
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1200
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
// filePath is the first arg passed to writeFileSync
|
|
1204
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1205
|
+
writeFileSyncSpy,
|
|
1206
|
+
filename,
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1210
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1214
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
it('bumps version in Maven `pom.xml` file with LF Line Endings', async function () {
|
|
1218
|
+
const expected = fs.readFileSync(
|
|
1219
|
+
'./test/mocks/pom-6.4.0-lf.xml',
|
|
1220
|
+
'utf-8',
|
|
1221
|
+
);
|
|
1222
|
+
const filename = 'pom.xml';
|
|
1223
|
+
mock({
|
|
1224
|
+
bump: 'minor',
|
|
1225
|
+
realTestFiles: [
|
|
1226
|
+
{
|
|
1227
|
+
filename,
|
|
1228
|
+
path: './test/mocks/pom-6.3.1-lf.xml',
|
|
1229
|
+
},
|
|
1230
|
+
],
|
|
1231
|
+
});
|
|
1232
|
+
await exec({
|
|
1233
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1234
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// filePath is the first arg passed to writeFileSync
|
|
1238
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1239
|
+
writeFileSyncSpy,
|
|
1240
|
+
filename,
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1244
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1248
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1183
1251
|
it('bumps version in Gradle `build.gradle.kts` file', async function () {
|
|
1184
1252
|
const expected = fs.readFileSync(
|
|
1185
1253
|
'./test/mocks/build-6.4.0.gradle.kts',
|
|
1186
1254
|
'utf-8',
|
|
1187
1255
|
);
|
|
1188
1256
|
|
|
1257
|
+
const filename = 'build.gradle.kts';
|
|
1189
1258
|
mock({
|
|
1190
1259
|
bump: 'minor',
|
|
1191
1260
|
realTestFiles: [
|
|
1192
1261
|
{
|
|
1193
|
-
filename
|
|
1262
|
+
filename,
|
|
1194
1263
|
path: './test/mocks/build-6.3.1.gradle.kts',
|
|
1195
1264
|
},
|
|
1196
1265
|
],
|
|
1197
1266
|
});
|
|
1198
1267
|
|
|
1199
1268
|
await exec({
|
|
1200
|
-
packageFiles: [{ filename
|
|
1201
|
-
bumpFiles: [{ filename
|
|
1269
|
+
packageFiles: [{ filename, type: 'gradle' }],
|
|
1270
|
+
bumpFiles: [{ filename, type: 'gradle' }],
|
|
1202
1271
|
});
|
|
1203
1272
|
|
|
1204
1273
|
// filePath is the first arg passed to writeFileSync
|
|
1205
|
-
const filename = 'build.gradle.kts';
|
|
1206
1274
|
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1207
1275
|
writeFileSyncSpy,
|
|
1208
1276
|
filename,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-module</artifactId>
|
|
12
|
+
<version>6.3.1</version>
|
|
13
|
+
|
|
14
|
+
<properties>
|
|
15
|
+
<some.version>2.0.0</some.version>
|
|
16
|
+
</properties>
|
|
17
|
+
|
|
18
|
+
<dependencies>
|
|
19
|
+
<dependency>
|
|
20
|
+
<groupId>org.some.dependency</groupId>
|
|
21
|
+
<artifactId>some-artifact</artifactId>
|
|
22
|
+
<version>${some.version}</version>
|
|
23
|
+
</dependency>
|
|
24
|
+
<dependency>
|
|
25
|
+
<groupId>org.another.dependency</groupId>
|
|
26
|
+
<artifactId>another-artifact</artifactId>
|
|
27
|
+
<version>1.0.0</version>
|
|
28
|
+
</dependency>
|
|
29
|
+
</dependencies>
|
|
30
|
+
</project>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-module</artifactId>
|
|
12
|
+
<version>6.3.1</version>
|
|
13
|
+
|
|
14
|
+
<properties>
|
|
15
|
+
<some.version>2.0.0</some.version>
|
|
16
|
+
</properties>
|
|
17
|
+
|
|
18
|
+
<dependencies>
|
|
19
|
+
<dependency>
|
|
20
|
+
<groupId>org.some.dependency</groupId>
|
|
21
|
+
<artifactId>some-artifact</artifactId>
|
|
22
|
+
<version>${some.version}</version>
|
|
23
|
+
</dependency>
|
|
24
|
+
<dependency>
|
|
25
|
+
<groupId>org.another.dependency</groupId>
|
|
26
|
+
<artifactId>another-artifact</artifactId>
|
|
27
|
+
<version>1.0.0</version>
|
|
28
|
+
</dependency>
|
|
29
|
+
</dependencies>
|
|
30
|
+
</project>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-module</artifactId>
|
|
12
|
+
<version>6.4.0</version>
|
|
13
|
+
|
|
14
|
+
<properties>
|
|
15
|
+
<some.version>2.0.0</some.version>
|
|
16
|
+
</properties>
|
|
17
|
+
|
|
18
|
+
<dependencies>
|
|
19
|
+
<dependency>
|
|
20
|
+
<groupId>org.some.dependency</groupId>
|
|
21
|
+
<artifactId>some-artifact</artifactId>
|
|
22
|
+
<version>${some.version}</version>
|
|
23
|
+
</dependency>
|
|
24
|
+
<dependency>
|
|
25
|
+
<groupId>org.another.dependency</groupId>
|
|
26
|
+
<artifactId>another-artifact</artifactId>
|
|
27
|
+
<version>1.0.0</version>
|
|
28
|
+
</dependency>
|
|
29
|
+
</dependencies>
|
|
30
|
+
</project>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-module</artifactId>
|
|
12
|
+
<version>6.4.0</version>
|
|
13
|
+
|
|
14
|
+
<properties>
|
|
15
|
+
<some.version>2.0.0</some.version>
|
|
16
|
+
</properties>
|
|
17
|
+
|
|
18
|
+
<dependencies>
|
|
19
|
+
<dependency>
|
|
20
|
+
<groupId>org.some.dependency</groupId>
|
|
21
|
+
<artifactId>some-artifact</artifactId>
|
|
22
|
+
<version>${some.version}</version>
|
|
23
|
+
</dependency>
|
|
24
|
+
<dependency>
|
|
25
|
+
<groupId>org.another.dependency</groupId>
|
|
26
|
+
<artifactId>another-artifact</artifactId>
|
|
27
|
+
<version>1.0.0</version>
|
|
28
|
+
</dependency>
|
|
29
|
+
</dependencies>
|
|
30
|
+
</project>
|