commit-and-tag-version 12.3.0 → 12.4.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 +9 -0
- package/lib/updaters/index.js +4 -0
- package/lib/updaters/types/openapi.js +15 -0
- package/package.json +1 -1
- package/test/core.spec.js +68 -0
- package/test/mocks/openapi-1.2.3-crlf.yaml +12 -0
- package/test/mocks/openapi-1.2.3-lf.yaml +12 -0
- package/test/mocks/openapi-1.3.0-crlf.yaml +12 -0
- package/test/mocks/openapi-1.3.0-lf.yaml +12 -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.4.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.3.0...v12.4.0) (2024-04-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Add OpenAPI version support ([#136](https://github.com/absolute-version/commit-and-tag-version/issues/136)) ([007b1b0](https://github.com/absolute-version/commit-and-tag-version/commit/007b1b0386651f2fbd6e8a9f552a2a34702086ca))
|
|
11
|
+
|
|
5
12
|
## [12.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.2.0...v12.3.0) (2024-04-19)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
|
|
|
22
22
|
- [Maven Support (Java/Kotlin)](#maven-support-javakotlin)
|
|
23
23
|
- [Gradle Support (Java/Kotlin)](#gradle-support-javakotlin)
|
|
24
24
|
- [.NET Support](#net-support)
|
|
25
|
+
- [OpenAPI Support](#openapi-support)
|
|
25
26
|
- [Installing `commit-and-tag-version`](#installing-commit-and-tag-version)
|
|
26
27
|
- [As a local `npm run` script](#as-a-local-npm-run-script)
|
|
27
28
|
- [As global `bin`](#as-global-bin)
|
|
@@ -117,6 +118,14 @@ This is going to read and update only the `version:` tag in the file.
|
|
|
117
118
|
commit-and-tag-version --packageFiles file.yaml --bumpFiles file.yaml
|
|
118
119
|
```
|
|
119
120
|
|
|
121
|
+
### OpenAPI Support
|
|
122
|
+
|
|
123
|
+
If you are using OpenAPI, then just point to your `openapi.yaml` file.
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
commit-and-tag-version --packageFiles openapi.yaml --bumpFiles openapi.yaml
|
|
127
|
+
```
|
|
128
|
+
|
|
120
129
|
## Installing `commit-and-tag-version`
|
|
121
130
|
|
|
122
131
|
### As a local `npm run` script
|
package/lib/updaters/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const updatersByType = {
|
|
|
7
7
|
gradle: require('./types/gradle'),
|
|
8
8
|
csproj: require('./types/csproj'),
|
|
9
9
|
yaml: require('./types/yaml'),
|
|
10
|
+
openapi: require('./types/openapi'),
|
|
10
11
|
};
|
|
11
12
|
const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt'];
|
|
12
13
|
|
|
@@ -37,6 +38,9 @@ function getUpdaterByFilename(filename) {
|
|
|
37
38
|
if (/\.ya?ml$/.test(filename)) {
|
|
38
39
|
return getUpdaterByType('yaml');
|
|
39
40
|
}
|
|
41
|
+
if (/openapi.yaml/.test(filename)) {
|
|
42
|
+
return getUpdaterByType('openapi');
|
|
43
|
+
}
|
|
40
44
|
throw Error(
|
|
41
45
|
`Unsupported file (${filename}) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.`,
|
|
42
46
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const yaml = require('yaml');
|
|
2
|
+
const detectNewline = require('detect-newline');
|
|
3
|
+
|
|
4
|
+
module.exports.readVersion = function (contents) {
|
|
5
|
+
return yaml.parse(contents).info.version;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
module.exports.writeVersion = function (contents, version) {
|
|
9
|
+
const newline = detectNewline(contents);
|
|
10
|
+
const document = yaml.parseDocument(contents);
|
|
11
|
+
|
|
12
|
+
document.get('info').set('version', version);
|
|
13
|
+
|
|
14
|
+
return document.toString().replace(/\r?\n/g, newline);
|
|
15
|
+
};
|
package/package.json
CHANGED
package/test/core.spec.js
CHANGED
|
@@ -1180,6 +1180,74 @@ describe('cli', function () {
|
|
|
1180
1180
|
});
|
|
1181
1181
|
});
|
|
1182
1182
|
|
|
1183
|
+
it('bumps version in OpenAPI `openapi.yaml` file with CRLF Line Endings', async function () {
|
|
1184
|
+
const expected = fs.readFileSync(
|
|
1185
|
+
'./test/mocks/openapi-1.3.0-crlf.yaml',
|
|
1186
|
+
'utf-8',
|
|
1187
|
+
);
|
|
1188
|
+
const filename = 'openapi.yaml';
|
|
1189
|
+
mock({
|
|
1190
|
+
bump: 'minor',
|
|
1191
|
+
realTestFiles: [
|
|
1192
|
+
{
|
|
1193
|
+
filename,
|
|
1194
|
+
path: './test/mocks/openapi-1.2.3-crlf.yaml',
|
|
1195
|
+
},
|
|
1196
|
+
],
|
|
1197
|
+
});
|
|
1198
|
+
await exec({
|
|
1199
|
+
packageFiles: [{ filename, type: 'openapi' }],
|
|
1200
|
+
bumpFiles: [{ filename, type: 'openapi' }],
|
|
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 OpenAPI `openapi.yaml` file with LF Line Endings', async function () {
|
|
1218
|
+
const expected = fs.readFileSync(
|
|
1219
|
+
'./test/mocks/openapi-1.3.0-lf.yaml',
|
|
1220
|
+
'utf-8',
|
|
1221
|
+
);
|
|
1222
|
+
const filename = 'openapi.yaml';
|
|
1223
|
+
mock({
|
|
1224
|
+
bump: 'minor',
|
|
1225
|
+
realTestFiles: [
|
|
1226
|
+
{
|
|
1227
|
+
filename,
|
|
1228
|
+
path: './test/mocks/openapi-1.2.3-lf.yaml',
|
|
1229
|
+
},
|
|
1230
|
+
],
|
|
1231
|
+
});
|
|
1232
|
+
await exec({
|
|
1233
|
+
packageFiles: [{ filename, type: 'openapi' }],
|
|
1234
|
+
bumpFiles: [{ filename, type: 'openapi' }],
|
|
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 Maven `pom.xml` file with CRLF Line Endings', async function () {
|
|
1184
1252
|
const expected = fs.readFileSync(
|
|
1185
1253
|
'./test/mocks/pom-6.4.0-crlf.xml',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
openapi: "3.0.2"
|
|
2
|
+
info:
|
|
3
|
+
title: Mock API
|
|
4
|
+
description: >-
|
|
5
|
+
Description of Mock API
|
|
6
|
+
version: "1.2.3"
|
|
7
|
+
termsOfService: http://swagger.io/terms/
|
|
8
|
+
externalDocs:
|
|
9
|
+
description: Find out more
|
|
10
|
+
url: https://example.com/foo/bar
|
|
11
|
+
servers:
|
|
12
|
+
- url: http://example.com
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
openapi: "3.0.2"
|
|
2
|
+
info:
|
|
3
|
+
title: Mock API
|
|
4
|
+
description: >-
|
|
5
|
+
Description of Mock API
|
|
6
|
+
version: "1.2.3"
|
|
7
|
+
termsOfService: http://swagger.io/terms/
|
|
8
|
+
externalDocs:
|
|
9
|
+
description: Find out more
|
|
10
|
+
url: https://example.com/foo/bar
|
|
11
|
+
servers:
|
|
12
|
+
- url: http://example.com
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
openapi: "3.0.2"
|
|
2
|
+
info:
|
|
3
|
+
title: Mock API
|
|
4
|
+
description: >-
|
|
5
|
+
Description of Mock API
|
|
6
|
+
version: "1.3.0"
|
|
7
|
+
termsOfService: http://swagger.io/terms/
|
|
8
|
+
externalDocs:
|
|
9
|
+
description: Find out more
|
|
10
|
+
url: https://example.com/foo/bar
|
|
11
|
+
servers:
|
|
12
|
+
- url: http://example.com
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
openapi: "3.0.2"
|
|
2
|
+
info:
|
|
3
|
+
title: Mock API
|
|
4
|
+
description: >-
|
|
5
|
+
Description of Mock API
|
|
6
|
+
version: "1.3.0"
|
|
7
|
+
termsOfService: http://swagger.io/terms/
|
|
8
|
+
externalDocs:
|
|
9
|
+
description: Find out more
|
|
10
|
+
url: https://example.com/foo/bar
|
|
11
|
+
servers:
|
|
12
|
+
- url: http://example.com
|