commit-and-tag-version
Advanced tools
Comparing version 12.2.0 to 12.3.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [12.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.2.0...v12.3.0) (2024-04-19) | ||
### Features | ||
* **updater:** add YAML support ([#137](https://github.com/absolute-version/commit-and-tag-version/issues/137)) ([b9dccc2](https://github.com/absolute-version/commit-and-tag-version/commit/b9dccc23ec05e4026899c676f3275d4dedf8c686)) | ||
### Bug Fixes | ||
* Add debug messages for exclusions during bump lifecycle ([#131](https://github.com/absolute-version/commit-and-tag-version/issues/131)) ([a9191f2](https://github.com/absolute-version/commit-and-tag-version/commit/a9191f293eb9302afb1093ad37e9fa076f6b37a2)) | ||
## [12.2.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.1.0...v12.2.0) (2024-01-15) | ||
@@ -7,0 +19,0 @@ |
@@ -225,6 +225,16 @@ 'use strict'; | ||
try { | ||
if (dotgit.ignore(updater.filename)) return; | ||
if (dotgit.ignore(updater.filename)) { | ||
console.debug( | ||
`Not updating file '${updater.filename}', as it is ignored in Git`, | ||
); | ||
return; | ||
} | ||
const stat = fs.lstatSync(configPath); | ||
if (!stat.isFile()) return; | ||
if (!stat.isFile()) { | ||
console.debug( | ||
`Not updating '${updater.filename}', as it is not a file`, | ||
); | ||
return; | ||
} | ||
const contents = fs.readFileSync(configPath, 'utf8'); | ||
@@ -231,0 +241,0 @@ const newContents = updater.updater.writeVersion(contents, newVersion); |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
csproj: require('./types/csproj'), | ||
yaml: require('./types/yaml'), | ||
}; | ||
@@ -37,2 +38,5 @@ const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt']; | ||
} | ||
if (/\.ya?ml$/.test(filename)) { | ||
return getUpdaterByType('yaml'); | ||
} | ||
throw Error( | ||
@@ -39,0 +43,0 @@ `Unsupported file (${filename}) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.`, |
{ | ||
"name": "commit-and-tag-version", | ||
"version": "12.2.0", | ||
"version": "12.3.0", | ||
"description": "replacement for `npm version` with automatic CHANGELOG generation", | ||
@@ -55,2 +55,3 @@ "bin": "bin/cli.js", | ||
"w3c-xmlserializer": "^5.0.0", | ||
"yaml": "^2.4.1", | ||
"yargs": "^17.7.2" | ||
@@ -57,0 +58,0 @@ }, |
@@ -111,2 +111,11 @@ # Commit and Tag Version | ||
### YAML Support | ||
If you are using YAML files. | ||
This is going to read and update only the `version:` tag in the file. | ||
```sh | ||
commit-and-tag-version --packageFiles file.yaml --bumpFiles file.yaml | ||
``` | ||
## Installing `commit-and-tag-version` | ||
@@ -113,0 +122,0 @@ |
@@ -1368,2 +1368,74 @@ 'use strict'; | ||
it('bumps version in Dart `pubspec.yaml` file', async function () { | ||
const expected = fs.readFileSync( | ||
'./test/mocks/pubspec-6.4.0.yaml', | ||
'utf-8', | ||
); | ||
const filename = 'pubspec.yaml'; | ||
mock({ | ||
bump: 'minor', | ||
realTestFiles: [ | ||
{ | ||
filename, | ||
path: './test/mocks/pubspec-6.3.1.yaml', | ||
}, | ||
], | ||
}); | ||
await exec({ | ||
packageFiles: [{ filename, type: 'yaml' }], | ||
bumpFiles: [{ filename, type: 'yaml' }], | ||
}); | ||
// filePath is the first arg passed to writeFileSync | ||
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({ | ||
writeFileSyncSpy, | ||
filename, | ||
}); | ||
if (!packageJsonWriteFileSynchCall) { | ||
throw new Error(`writeFileSynch not invoked with path ${filename}`); | ||
} | ||
const calledWithContentStr = packageJsonWriteFileSynchCall[1]; | ||
expect(calledWithContentStr).toEqual(expected); | ||
}); | ||
it('bumps version in Dart `pubspec.yaml` file with CRLF line endings', async function () { | ||
const expected = fs.readFileSync( | ||
'./test/mocks/pubspec-6.4.0-crlf.yaml', | ||
'utf-8', | ||
); | ||
const filename = 'pubspec.yaml'; | ||
mock({ | ||
bump: 'minor', | ||
realTestFiles: [ | ||
{ | ||
filename, | ||
path: './test/mocks/pubspec-6.3.1-crlf.yaml', | ||
}, | ||
], | ||
}); | ||
await exec({ | ||
packageFiles: [{ filename, type: 'yaml' }], | ||
bumpFiles: [{ filename, type: 'yaml' }], | ||
}); | ||
// filePath is the first arg passed to writeFileSync | ||
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({ | ||
writeFileSyncSpy, | ||
filename, | ||
}); | ||
if (!packageJsonWriteFileSynchCall) { | ||
throw new Error(`writeFileSynch not invoked with path ${filename}`); | ||
} | ||
const calledWithContentStr = packageJsonWriteFileSynchCall[1]; | ||
expect(calledWithContentStr).toEqual(expected); | ||
}); | ||
describe('skip', function () { | ||
@@ -1370,0 +1442,0 @@ it('allows bump and changelog generation to be skipped', async function () { |
218628
73
3781
616
16
+ Addedyaml@^2.4.1
+ Addedyaml@2.4.5(transitive)