commit-and-tag-version 10.0.1 → 10.1.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.
@@ -1,4 +1,5 @@
1
1
  on:
2
+ workflow_dispatch:
2
3
  push:
3
4
  branches:
4
5
  - master
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
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
+ ## [10.1.0](https://github.com/absolute-version/commit-and-tag-version/compare/v10.0.1...v10.1.0) (2022-08-11)
6
+
7
+
8
+ ### Features
9
+
10
+ * **options:** Expose parser and writer options from `conventional-commits-parser` and `conventional-commits-writer` ([185a461](https://github.com/absolute-version/commit-and-tag-version/commit/185a461acc1caf947bf78dd2185f4687afad66fc))
11
+ * **updater:** add Gradle support ([0cf439f](https://github.com/absolute-version/commit-and-tag-version/commit/0cf439fe4047ffa10d21196714c25517535b6302))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * use correct param for dryRun check ([300b907](https://github.com/absolute-version/commit-and-tag-version/commit/300b90777c5c8c9cca15f69122af1d41981ca47d))
17
+
5
18
  ### [10.0.1](https://github.com/absolute-version/commit-and-tag-version/compare/v10.0.0...v10.0.1) (2022-05-28)
6
19
 
7
20
 
package/README.md CHANGED
@@ -43,6 +43,15 @@ By default, `commit-and-tag-version` assumes you're working in a NodeJS based pr
43
43
 
44
44
  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!
45
45
 
46
+ ### Gradle Support (Java/Kotlin)
47
+
48
+ If you are using Gradle, then just point to your `build.gradle` file (or `build.gradle.kts` if using Kotlin DSL).
49
+
50
+ ```sh
51
+ commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle
52
+ ```
53
+
54
+
46
55
  ## Installing `commit-and-tag-version`
47
56
 
48
57
  ### As a local `npm run` script
@@ -99,8 +108,6 @@ You can configure `commit-and-tag-version` either by:
99
108
 
100
109
  - If you are using a `.versionrc.js` your default export must be a configuration object, or a function returning a configuration object.
101
110
 
102
-
103
-
104
111
  Any of the command line parameters accepted by `commit-and-tag-version` can instead
105
112
  be provided via configuration. Please refer to the [conventional-changelog-config-spec](https://github.com/conventional-changelog/conventional-changelog-config-spec/) for details on available configuration options.
106
113
 
@@ -108,17 +115,9 @@ be provided via configuration. Please refer to the [conventional-changelog-confi
108
115
 
109
116
  By default, `commit-and-tag-version` uses the [conventionalcommits preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits).
110
117
 
111
- This preset:
112
-
113
- - Adheres closely to the [conventionalcommits.org](https://www.conventionalcommits.org)
114
- specification.
115
- - Is highly configurable, following the configuration specification
116
- [maintained here](https://github.com/conventional-changelog/conventional-changelog-config-spec).
117
- - _We've documented these config settings as a recommendation to other tooling makers._
118
-
119
- There are a variety of dials and knobs you can turn related to CHANGELOG generation.
118
+ This preset adheres closely to the [conventionalcommits.org](https://www.conventionalcommits.org) specification.
120
119
 
121
- As an example, suppose you're using GitLab, rather than GitHub, you might modify the following variables:
120
+ Suppose you're using GitLab, rather than GitHub, you might modify the following variables:
122
121
 
123
122
  - `commitUrlFormat`: the URL format of commit SHAs detected in commit messages.
124
123
  - `compareUrlFormat`: the URL format used to compare two tags.
@@ -126,6 +125,20 @@ As an example, suppose you're using GitLab, rather than GitHub, you might modify
126
125
 
127
126
  Making these URLs match GitLab's format, rather than GitHub's.
128
127
 
128
+ ### Deeper customization
129
+
130
+ You can override both [parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser) and [writer](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer) options (they will be merged into the preset we just mentioned). As an example, to list commits in the order that they were committed:
131
+
132
+ ```json
133
+ {
134
+ "commit-and-tag-version": {
135
+ "writerOpts": {
136
+ "commitsSort": false
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
129
142
  ## CLI Usage
130
143
 
131
144
  > **NOTE:** To pass nested configurations to the CLI without defining them in the `package.json` use dot notation as the parameters `e.g. --skip.changelog`.
@@ -326,7 +339,9 @@ If you do not want to have any tag prefix you can use the `-t` flag and provide
326
339
 
327
340
  ### Tag replacement
328
341
 
329
- If you've already run `standard-version` when creating your release, you may want to alter the release content and changelog without bumping the version, by using `standard-version --skip.bump`. By default, tagging with an already existing tag make `git` fails. You can add the `--tag-force` flag to make use of `-f` option when calling `git tag`, then the existing version tag will be replaced.
342
+ If you've already run `commit-and-tag-version` when creating your release, you may want to alter the release content and changelog without bumping
343
+ the version, by using `commit-and-tag-version --skip.bump`. By default, tagging with an already existing tag make `git` fails.
344
+ You can add the `--tag-force` flag to make use of `-f` option when calling `git tag`, then the existing version tag will be replaced.
330
345
 
331
346
  ### CLI Help
332
347
 
@@ -340,11 +355,11 @@ commit-and-tag-version --help
340
355
  ## Code Usage
341
356
 
342
357
  ```js
343
- const standardVersion = require("commit-and-tag-version");
358
+ const commitAndTagVersion = require("commit-and-tag-version");
344
359
 
345
360
  // Options are the same as command line, except camelCase
346
- // standardVersion returns a Promise
347
- standardVersion({
361
+ // commitAndTagVersion returns a Promise
362
+ commitAndTagVersion({
348
363
  noVerify: true,
349
364
  infile: "docs/CHANGELOG.md",
350
365
  silent: true,
package/lib/checkpoint.js CHANGED
@@ -3,7 +3,7 @@ const figures = require('figures')
3
3
  const util = require('util')
4
4
 
5
5
  module.exports = function (argv, msg, args, figure) {
6
- const defaultFigure = args.dryRun ? chalk.yellow(figures.tick) : chalk.green(figures.tick)
6
+ const defaultFigure = argv.dryRun ? chalk.yellow(figures.tick) : chalk.green(figures.tick)
7
7
  if (!argv.silent) {
8
8
  console.info((figure || defaultFigure) + ' ' + util.format.apply(util, [msg].concat(args.map(function (arg) {
9
9
  return chalk.bold(arg)
@@ -35,7 +35,7 @@ function outputChangelog (args, newVersion) {
35
35
  debug: args.verbose && console.info.bind(console, 'conventional-changelog'),
36
36
  preset: presetLoader(args),
37
37
  tagPrefix: args.tagPrefix
38
- }, context, { merges: null, path: args.path })
38
+ }, context, { merges: null, path: args.path }, args.parserOpts, args.writerOpts)
39
39
  .on('error', function (err) {
40
40
  return reject(err)
41
41
  })
@@ -2,7 +2,8 @@ const path = require('path')
2
2
  const JSON_BUMP_FILES = require('../../defaults').bumpFiles
3
3
  const updatersByType = {
4
4
  json: require('./types/json'),
5
- 'plain-text': require('./types/plain-text')
5
+ 'plain-text': require('./types/plain-text'),
6
+ gradle: require('./types/gradle')
6
7
  }
7
8
  const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt']
8
9
 
@@ -21,6 +22,9 @@ function getUpdaterByFilename (filename) {
21
22
  if (PLAIN_TEXT_BUMP_FILES.includes(filename)) {
22
23
  return getUpdaterByType('plain-text')
23
24
  }
25
+ if (/build.gradle/.test(filename)) {
26
+ return getUpdaterByType('gradle')
27
+ }
24
28
  throw Error(
25
29
  `Unsupported file (${filename}) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.`
26
30
  )
@@ -0,0 +1,16 @@
1
+ const versionRegex = /^version\s+=\s+['"]([\d.]+)['"]/m
2
+
3
+ module.exports.readVersion = function (contents) {
4
+ const matches = versionRegex.exec(contents)
5
+ if (matches === null) {
6
+ throw new Error('Failed to read the version field in your gradle file - is it present?')
7
+ }
8
+
9
+ return matches[1]
10
+ }
11
+
12
+ module.exports.writeVersion = function (contents, version) {
13
+ return contents.replace(versionRegex, () => {
14
+ return `version = "${version}"`
15
+ })
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commit-and-tag-version",
3
- "version": "10.0.1",
3
+ "version": "10.1.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
@@ -678,6 +678,21 @@ describe('commit-and-tag-version', function () {
678
678
  ).version.should.equal('6.4.0')
679
679
  })
680
680
 
681
+ it('bumps version in Gradle `build.gradle.kts` file', async function () {
682
+ const expected = fs.readFileSync('./test/mocks/build-6.4.0.gradle.kts', 'utf-8')
683
+ mock({
684
+ bump: 'minor',
685
+ fs: {
686
+ 'build.gradle.kts': fs.readFileSync('./test/mocks/build-6.3.1.gradle.kts')
687
+ }
688
+ })
689
+ await exec({
690
+ packageFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }],
691
+ bumpFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }]
692
+ })
693
+ fs.readFileSync('build.gradle.kts', 'utf-8').should.equal(expected)
694
+ })
695
+
681
696
  it('bumps version # in npm-shrinkwrap.json', async function () {
682
697
  mock({
683
698
  bump: 'minor',
@@ -0,0 +1,14 @@
1
+ plugins {
2
+ id("org.springframework.boot") version "2.4.6"
3
+ kotlin("jvm") version "1.4.31"
4
+ kotlin("plugin.spring") version "1.4.31"
5
+ }
6
+
7
+ version = "6.3.1"
8
+ java.sourceCompatibility = JavaVersion.VERSION_1_8
9
+
10
+ repositories {
11
+ mavenLocal()
12
+ mavenCentral()
13
+ }
14
+
@@ -0,0 +1,14 @@
1
+ plugins {
2
+ id("org.springframework.boot") version "2.4.6"
3
+ kotlin("jvm") version "1.4.31"
4
+ kotlin("plugin.spring") version "1.4.31"
5
+ }
6
+
7
+ version = "6.4.0"
8
+ java.sourceCompatibility = JavaVersion.VERSION_1_8
9
+
10
+ repositories {
11
+ mavenLocal()
12
+ mavenCentral()
13
+ }
14
+