commit-and-tag-version 12.0.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.
Files changed (54) hide show
  1. package/.eslintrc +43 -8
  2. package/.gitattributes +2 -0
  3. package/.github/workflows/ci.yaml +10 -3
  4. package/.prettierrc +3 -0
  5. package/CHANGELOG.md +14 -0
  6. package/README.md +17 -4
  7. package/bin/cli.js +6 -6
  8. package/command.js +43 -37
  9. package/defaults.js +12 -11
  10. package/index.js +44 -42
  11. package/jest.config.js +28 -0
  12. package/lib/checkpoint.js +19 -8
  13. package/lib/configuration.js +17 -17
  14. package/lib/detect-package-manager.js +20 -20
  15. package/lib/format-commit-message.js +3 -3
  16. package/lib/latest-semver-tag.js +13 -11
  17. package/lib/lifecycles/bump.js +136 -105
  18. package/lib/lifecycles/changelog.js +70 -51
  19. package/lib/lifecycles/commit.js +41 -42
  20. package/lib/lifecycles/tag.js +41 -31
  21. package/lib/preset-loader.js +12 -10
  22. package/lib/print-error.js +10 -7
  23. package/lib/run-exec.js +10 -10
  24. package/lib/run-execFile.js +10 -10
  25. package/lib/run-lifecycle-script.js +16 -11
  26. package/lib/stringify-package.js +10 -10
  27. package/lib/updaters/index.js +44 -33
  28. package/lib/updaters/types/csproj.js +9 -7
  29. package/lib/updaters/types/gradle.js +10 -8
  30. package/lib/updaters/types/json.js +14 -14
  31. package/lib/updaters/types/maven.js +44 -0
  32. package/lib/updaters/types/plain-text.js +4 -4
  33. package/lib/write-file.js +4 -4
  34. package/package.json +16 -21
  35. package/test/commit-message-config.integration-test.js +106 -0
  36. package/test/config-files.integration-test.js +114 -0
  37. package/test/config-keys.integration-test.js +83 -0
  38. package/test/core.spec.js +1438 -705
  39. package/test/git.integration-test.js +363 -0
  40. package/test/invalid-config.integration-test.js +73 -0
  41. package/test/mocks/jest-mocks.js +48 -0
  42. package/test/mocks/pom-6.3.1-crlf.xml +30 -0
  43. package/test/mocks/pom-6.3.1-lf.xml +30 -0
  44. package/test/mocks/pom-6.4.0-crlf.xml +30 -0
  45. package/test/mocks/pom-6.4.0-lf.xml +30 -0
  46. package/test/mocks/updater/customer-updater.js +5 -8
  47. package/test/mocks/updater/increment-updater.js +5 -5
  48. package/test/pre-commit-hook.integration-test.js +192 -0
  49. package/test/preset.integration-test.js +56 -0
  50. package/test/stringify-package.spec.js +18 -22
  51. package/test/utils.spec.js +25 -41
  52. package/test/config-files.spec.js +0 -176
  53. package/test/git.spec.js +0 -480
  54. package/test/preset.spec.js +0 -52
package/.eslintrc CHANGED
@@ -1,14 +1,49 @@
1
1
  {
2
- "extends": ["standard", "plugin:mocha/recommended"],
2
+ "extends": [
3
+ "prettier",
4
+ "eslint:recommended"
5
+ ],
6
+ "env": {
7
+ "node": true,
8
+ "es6": true
9
+ },
10
+ "overrides": [
11
+ {
12
+ "env": {
13
+ "node": true,
14
+ "es6": true,
15
+ "jest/globals": true
16
+ },
17
+ "files": [
18
+ "test/**"
19
+ ],
20
+ "plugins": [
21
+ "jest"
22
+ ],
23
+ "extends": [
24
+ "prettier",
25
+ "eslint:recommended",
26
+ "plugin:jest/recommended"
27
+ ],
28
+ "rules": {
29
+ "jest/prefer-expect-assertions": "off",
30
+ "jest/expect-expect": "off"
31
+ }
32
+ }
33
+ ],
34
+ "parserOptions": {
35
+ "ecmaVersion": 2023
36
+ },
3
37
  "plugins": [
4
- "mocha",
5
- "@fintechstudios/eslint-plugin-chai-as-promised",
38
+ "jest"
6
39
  ],
7
40
  "rules": {
8
41
  "no-var": "error",
9
- "mocha/max-top-level-suites": "off",
10
- "mocha/no-setup-in-describe": "off",
11
- "@fintechstudios/chai-as-promised/no-unhandled-promises": "error",
12
- "@fintechstudios/chai-as-promised/no-await-in-condition": "error"
42
+ "no-unused-vars": [
43
+ "error",
44
+ {
45
+ "argsIgnorePattern": "_.*"
46
+ }
47
+ ]
13
48
  }
14
- }
49
+ }
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ *.ts text eol=lf
2
+ *.js text eol=lf
@@ -10,8 +10,16 @@ jobs:
10
10
  runs-on: ${{ matrix.os }}
11
11
  strategy:
12
12
  matrix:
13
- node: [18, 20.4]
14
- os: [ubuntu-latest, windows-latest]
13
+ node: [
14
+ 18,
15
+ 20.4, # Known good version of 20 which ran the previous Mocha and mock-fs based tests. If you go back to re-run those, tests Node 20.4 is the last version mock-fs worked with
16
+ 20,
17
+ lts/*
18
+ ]
19
+ os: [
20
+ ubuntu-latest,
21
+ windows-latest
22
+ ]
15
23
  env:
16
24
  OS: ${{ matrix.os }}
17
25
  NODE_VERSION: ${{ matrix.node }}
@@ -26,7 +34,6 @@ jobs:
26
34
  - run: node --version
27
35
  - run: npm install --engine-strict
28
36
  - run: npm test
29
- - run: npm run coverage
30
37
  - name: Codecov
31
38
  uses: codecov/codecov-action@v3
32
39
  with:
package/.prettierrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "singleQuote": true
3
+ }
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.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
+
12
+ ## [12.1.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.0.0...v12.1.0) (2024-01-06)
13
+
14
+
15
+ ### Features
16
+
17
+ * Add signoff option ([#120](https://github.com/absolute-version/commit-and-tag-version/issues/120)) ([d107e38](https://github.com/absolute-version/commit-and-tag-version/commit/d107e38eb906dfb21658d12803b7308f2e3dda7d))
18
+
5
19
  ## [12.0.0](https://github.com/absolute-version/commit-and-tag-version/compare/v11.3.0...v12.0.0) (2023-10-31)
6
20
 
7
21
 
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
  ![ci](https://github.com/absolute-version/commit-and-tag-version/workflows/ci/badge.svg)
@@ -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`.
@@ -279,6 +288,10 @@ commit-and-tag-version --no-verify
279
288
 
280
289
  If you have your GPG key set up, add the `--sign` or `-s` flag to your `commit-and-tag-version` command.
281
290
 
291
+ ### Signed-off-by trailer
292
+
293
+ To add the "Signed-off-by" trailer to the commit message add the `--signoff` flag to your `commit-and-tag-version` command.
294
+
282
295
  ### Lifecycle Scripts
283
296
 
284
297
  `commit-and-tag-version` supports lifecycle scripts. These allow you to execute your
@@ -308,7 +321,7 @@ Simply add the following to your package.json to configure lifecycle scripts:
308
321
  ```
309
322
 
310
323
  As an example to change from using GitHub to track your items to using your projects Jira use a
311
- `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/>'
312
325
  with a link to your Jira - assuming you have already installed [replace](https://www.npmjs.com/package/replace)
313
326
 
314
327
  ```json
package/bin/cli.js CHANGED
@@ -3,12 +3,12 @@
3
3
  /* istanbul ignore if */
4
4
  if (process.version.match(/v(\d+)\./)[1] < 6) {
5
5
  console.error(
6
- 'commit-and-tag-version: Node v6 or greater is required. `commit-and-tag-version` did not run.'
7
- )
6
+ 'commit-and-tag-version: Node v6 or greater is required. `commit-and-tag-version` did not run.',
7
+ );
8
8
  } else {
9
- const standardVersion = require('../index')
10
- const cmdParser = require('../command')
9
+ const standardVersion = require('../index');
10
+ const cmdParser = require('../command');
11
11
  standardVersion(cmdParser.argv).catch(() => {
12
- process.exit(1)
13
- })
12
+ process.exit(1);
13
+ });
14
14
  }
package/command.js CHANGED
@@ -1,138 +1,144 @@
1
- const spec = require('conventional-changelog-config-spec')
2
- const { getConfiguration } = require('./lib/configuration')
3
- const defaults = require('./defaults')
1
+ const spec = require('conventional-changelog-config-spec');
2
+ const { getConfiguration } = require('./lib/configuration');
3
+ const defaults = require('./defaults');
4
4
 
5
5
  const yargs = require('yargs')
6
6
  .usage('Usage: $0 [options]')
7
7
  .option('packageFiles', {
8
8
  default: defaults.packageFiles,
9
- array: true
9
+ array: true,
10
10
  })
11
11
  .option('bumpFiles', {
12
12
  default: defaults.bumpFiles,
13
- array: true
13
+ array: true,
14
14
  })
15
15
  .option('release-as', {
16
16
  alias: 'r',
17
17
  describe:
18
18
  'Specify the release type manually (like npm version <major|minor|patch>)',
19
19
  requiresArg: true,
20
- string: true
20
+ string: true,
21
21
  })
22
22
  .option('prerelease', {
23
23
  alias: 'p',
24
24
  describe:
25
25
  'make a pre-release with optional option value to specify a tag id',
26
- string: true
26
+ string: true,
27
27
  })
28
28
  .option('infile', {
29
29
  alias: 'i',
30
30
  describe: 'Read the CHANGELOG from this file',
31
- default: defaults.infile
31
+ default: defaults.infile,
32
32
  })
33
33
  .option('message', {
34
34
  alias: ['m'],
35
35
  describe:
36
36
  '[DEPRECATED] Commit message, replaces %s with new version.\nThis option will be removed in the next major version, please use --releaseCommitMessageFormat.',
37
- type: 'string'
37
+ type: 'string',
38
38
  })
39
39
  .option('first-release', {
40
40
  alias: 'f',
41
41
  describe: 'Is this the first release?',
42
42
  type: 'boolean',
43
- default: defaults.firstRelease
43
+ default: defaults.firstRelease,
44
44
  })
45
45
  .option('sign', {
46
46
  alias: 's',
47
47
  describe: 'Should the git commit and tag be signed?',
48
48
  type: 'boolean',
49
- default: defaults.sign
49
+ default: defaults.sign,
50
+ })
51
+ .option('signoff', {
52
+ describe: 'Should the git commit have a "Signed-off-by" trailer',
53
+ type: 'boolean',
54
+ default: defaults.signoff,
50
55
  })
51
56
  .option('no-verify', {
52
57
  alias: 'n',
53
58
  describe:
54
59
  'Bypass pre-commit or commit-msg git hooks during the commit phase',
55
60
  type: 'boolean',
56
- default: defaults.noVerify
61
+ default: defaults.noVerify,
57
62
  })
58
63
  .option('commit-all', {
59
64
  alias: 'a',
60
65
  describe:
61
66
  'Commit all staged changes, not just files affected by commit-and-tag-version',
62
67
  type: 'boolean',
63
- default: defaults.commitAll
68
+ default: defaults.commitAll,
64
69
  })
65
70
  .option('silent', {
66
71
  describe: "Don't print logs and errors",
67
72
  type: 'boolean',
68
- default: defaults.silent
73
+ default: defaults.silent,
69
74
  })
70
75
  .option('tag-prefix', {
71
76
  alias: 't',
72
77
  describe: 'Set a custom prefix for the git tag to be created',
73
78
  type: 'string',
74
- default: defaults.tagPrefix
79
+ default: defaults.tagPrefix,
75
80
  })
76
81
  .option('release-count', {
77
- describe: 'How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to 0 to regenerate all.',
82
+ describe:
83
+ 'How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to 0 to regenerate all.',
78
84
  type: 'number',
79
- default: defaults.releaseCount
85
+ default: defaults.releaseCount,
80
86
  })
81
87
  .option('tag-force', {
82
88
  describe: 'Allow tag replacement',
83
89
  type: 'boolean',
84
- default: defaults.tagForce
90
+ default: defaults.tagForce,
85
91
  })
86
92
  .option('scripts', {
87
93
  describe:
88
94
  'Provide scripts to execute for lifecycle events (prebump, precommit, etc.,)',
89
- default: defaults.scripts
95
+ default: defaults.scripts,
90
96
  })
91
97
  .option('skip', {
92
98
  describe: 'Map of steps in the release process that should be skipped',
93
- default: defaults.skip
99
+ default: defaults.skip,
94
100
  })
95
101
  .option('dry-run', {
96
102
  type: 'boolean',
97
103
  default: defaults.dryRun,
98
- describe: 'See the commands that running commit-and-tag-version would run'
104
+ describe: 'See the commands that running commit-and-tag-version would run',
99
105
  })
100
106
  .option('git-tag-fallback', {
101
107
  type: 'boolean',
102
108
  default: defaults.gitTagFallback,
103
109
  describe:
104
- 'fallback to git tags for version, if no meta-information file is found (e.g., package.json)'
110
+ 'fallback to git tags for version, if no meta-information file is found (e.g., package.json)',
105
111
  })
106
112
  .option('path', {
107
113
  type: 'string',
108
- describe: 'Only populate commits made under this path'
114
+ describe: 'Only populate commits made under this path',
109
115
  })
110
116
  .option('changelogHeader', {
111
117
  type: 'string',
112
118
  describe:
113
- '[DEPRECATED] Use a custom header when generating and updating changelog.\nThis option will be removed in the next major version, please use --header.'
119
+ '[DEPRECATED] Use a custom header when generating and updating changelog.\nThis option will be removed in the next major version, please use --header.',
114
120
  })
115
121
  .option('preset', {
116
122
  type: 'string',
117
123
  default: defaults.preset,
118
- describe: 'Commit message guideline preset'
124
+ describe: 'Commit message guideline preset',
119
125
  })
120
126
  .option('lerna-package', {
121
127
  type: 'string',
122
- describe: 'Name of the package from which the tags will be extracted'
128
+ describe: 'Name of the package from which the tags will be extracted',
123
129
  })
124
130
  .option('npmPublishHint', {
125
131
  type: 'string',
126
132
  default: defaults.npmPublishHint,
127
- describe: 'Customized publishing hint'
133
+ describe: 'Customized publishing hint',
128
134
  })
129
135
  .check((argv) => {
130
136
  if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
131
- throw Error('scripts must be an object')
137
+ throw Error('scripts must be an object');
132
138
  } else if (typeof argv.skip !== 'object' || Array.isArray(argv.skip)) {
133
- throw Error('skip must be an object')
139
+ throw Error('skip must be an object');
134
140
  } else {
135
- return true
141
+ return true;
136
142
  }
137
143
  })
138
144
  .alias('version', 'v')
@@ -140,21 +146,21 @@ const yargs = require('yargs')
140
146
  .example('$0', 'Update changelog and tag release')
141
147
  .example(
142
148
  '$0 -m "%s: see changelog for details"',
143
- 'Update changelog and tag release with custom commit message'
149
+ 'Update changelog and tag release with custom commit message',
144
150
  )
145
151
  .pkgConf('standard-version')
146
152
  .pkgConf('commit-and-tag-version')
147
153
  .config(getConfiguration())
148
- .wrap(97)
154
+ .wrap(97);
149
155
 
150
156
  Object.keys(spec.properties).forEach((propertyKey) => {
151
- const property = spec.properties[propertyKey]
157
+ const property = spec.properties[propertyKey];
152
158
  yargs.option(propertyKey, {
153
159
  type: property.type,
154
160
  describe: property.description,
155
161
  default: defaults[propertyKey] ? defaults[propertyKey] : property.default,
156
- group: 'Preset Configuration:'
157
- })
158
- })
162
+ group: 'Preset Configuration:',
163
+ });
164
+ });
159
165
 
160
- module.exports = yargs
166
+ module.exports = yargs;
package/defaults.js CHANGED
@@ -1,9 +1,10 @@
1
- const spec = require('conventional-changelog-config-spec')
1
+ const spec = require('conventional-changelog-config-spec');
2
2
 
3
3
  const defaults = {
4
4
  infile: 'CHANGELOG.md',
5
5
  firstRelease: false,
6
6
  sign: false,
7
+ signoff: false,
7
8
  noVerify: false,
8
9
  commitAll: false,
9
10
  silent: false,
@@ -15,29 +16,29 @@ const defaults = {
15
16
  tagForce: false,
16
17
  gitTagFallback: true,
17
18
  preset: require.resolve('conventional-changelog-conventionalcommits'),
18
- npmPublishHint: undefined
19
- }
19
+ npmPublishHint: undefined,
20
+ };
20
21
 
21
22
  /**
22
23
  * Merge in defaults provided by the spec
23
24
  */
24
25
  Object.keys(spec.properties).forEach((propertyKey) => {
25
- const property = spec.properties[propertyKey]
26
- defaults[propertyKey] = property.default
27
- })
26
+ const property = spec.properties[propertyKey];
27
+ defaults[propertyKey] = property.default;
28
+ });
28
29
 
29
30
  /**
30
31
  * Sets the default for `header` (provided by the spec) for backwards
31
32
  * compatibility. This should be removed in the next major version.
32
33
  */
33
34
  defaults.header =
34
- '# Changelog\n\nAll 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.\n'
35
+ '# Changelog\n\nAll 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.\n';
35
36
 
36
- defaults.packageFiles = ['package.json', 'bower.json', 'manifest.json']
37
+ defaults.packageFiles = ['package.json', 'bower.json', 'manifest.json'];
37
38
 
38
39
  defaults.bumpFiles = defaults.packageFiles.concat([
39
40
  'package-lock.json',
40
- 'npm-shrinkwrap.json'
41
- ])
41
+ 'npm-shrinkwrap.json',
42
+ ]);
42
43
 
43
- module.exports = defaults
44
+ module.exports = defaults;
package/index.js CHANGED
@@ -1,39 +1,39 @@
1
- const bump = require('./lib/lifecycles/bump')
2
- const changelog = require('./lib/lifecycles/changelog')
3
- const commit = require('./lib/lifecycles/commit')
4
- const fs = require('fs')
5
- const latestSemverTag = require('./lib/latest-semver-tag')
6
- const path = require('path')
7
- const printError = require('./lib/print-error')
8
- const tag = require('./lib/lifecycles/tag')
9
- const { resolveUpdaterObjectFromArgument } = require('./lib/updaters')
1
+ const bump = require('./lib/lifecycles/bump');
2
+ const changelog = require('./lib/lifecycles/changelog');
3
+ const commit = require('./lib/lifecycles/commit');
4
+ const fs = require('fs');
5
+ const latestSemverTag = require('./lib/latest-semver-tag');
6
+ const path = require('path');
7
+ const printError = require('./lib/print-error');
8
+ const tag = require('./lib/lifecycles/tag');
9
+ const { resolveUpdaterObjectFromArgument } = require('./lib/updaters');
10
10
 
11
- module.exports = async function standardVersion (argv) {
12
- const defaults = require('./defaults')
11
+ module.exports = async function standardVersion(argv) {
12
+ const defaults = require('./defaults');
13
13
  /**
14
14
  * `--message` (`-m`) support will be removed in the next major version.
15
15
  */
16
- const message = argv.m || argv.message
16
+ const message = argv.m || argv.message;
17
17
  if (message) {
18
18
  /**
19
19
  * The `--message` flag uses `%s` for version substitutions, we swap this
20
20
  * for the substitution defined in the config-spec for future-proofing upstream
21
21
  * handling.
22
22
  */
23
- argv.releaseCommitMessageFormat = message.replace(/%s/g, '{{currentTag}}')
23
+ argv.releaseCommitMessageFormat = message.replace(/%s/g, '{{currentTag}}');
24
24
  if (!argv.silent) {
25
25
  console.warn(
26
- '[commit-and-tag-version]: --message (-m) will be removed in the next major release. Use --releaseCommitMessageFormat.'
27
- )
26
+ '[commit-and-tag-version]: --message (-m) will be removed in the next major release. Use --releaseCommitMessageFormat.',
27
+ );
28
28
  }
29
29
  }
30
30
 
31
31
  if (argv.changelogHeader) {
32
- argv.header = argv.changelogHeader
32
+ argv.header = argv.changelogHeader;
33
33
  if (!argv.silent) {
34
34
  console.warn(
35
- '[commit-and-tag-version]: --changelogHeader will be removed in the next major release. Use --header.'
36
- )
35
+ '[commit-and-tag-version]: --changelogHeader will be removed in the next major release. Use --header.',
36
+ );
37
37
  }
38
38
  }
39
39
 
@@ -42,51 +42,53 @@ module.exports = async function standardVersion (argv) {
42
42
  argv.header.search(changelog.START_OF_LAST_RELEASE_PATTERN) !== -1
43
43
  ) {
44
44
  throw Error(
45
- `custom changelog header must not match ${changelog.START_OF_LAST_RELEASE_PATTERN}`
46
- )
45
+ `custom changelog header must not match ${changelog.START_OF_LAST_RELEASE_PATTERN}`,
46
+ );
47
47
  }
48
48
 
49
49
  /**
50
50
  * If an argument for `packageFiles` provided, we include it as a "default" `bumpFile`.
51
51
  */
52
52
  if (argv.packageFiles) {
53
- defaults.bumpFiles = defaults.bumpFiles.concat(argv.packageFiles)
53
+ defaults.bumpFiles = defaults.bumpFiles.concat(argv.packageFiles);
54
54
  }
55
55
 
56
- const args = Object.assign({}, defaults, argv)
57
- let pkg
56
+ const args = Object.assign({}, defaults, argv);
57
+ let pkg;
58
58
  for (const packageFile of args.packageFiles) {
59
- const updater = resolveUpdaterObjectFromArgument(packageFile)
60
- if (!updater) return
61
- const pkgPath = path.resolve(process.cwd(), updater.filename)
59
+ const updater = resolveUpdaterObjectFromArgument(packageFile);
60
+ if (!updater) return;
61
+ const pkgPath = path.resolve(process.cwd(), updater.filename);
62
62
  try {
63
- const contents = fs.readFileSync(pkgPath, 'utf8')
63
+ const contents = fs.readFileSync(pkgPath, 'utf8');
64
64
  pkg = {
65
65
  version: updater.updater.readVersion(contents),
66
66
  private:
67
67
  typeof updater.updater.isPrivate === 'function'
68
68
  ? updater.updater.isPrivate(contents)
69
- : false
70
- }
71
- break
72
- } catch (err) {}
69
+ : false,
70
+ };
71
+ break;
72
+ } catch (err) {
73
+ /* This probably shouldn't be empty? */
74
+ }
73
75
  }
74
76
  try {
75
- let version
77
+ let version;
76
78
  if (pkg && pkg.version) {
77
- version = pkg.version
79
+ version = pkg.version;
78
80
  } else if (args.gitTagFallback) {
79
- version = await latestSemverTag(args.tagPrefix)
81
+ version = await latestSemverTag(args.tagPrefix);
80
82
  } else {
81
- throw new Error('no package file found')
83
+ throw new Error('no package file found');
82
84
  }
83
85
 
84
- const newVersion = await bump(args, version)
85
- await changelog(args, newVersion)
86
- await commit(args, newVersion)
87
- await tag(newVersion, pkg ? pkg.private : false, args)
86
+ const newVersion = await bump(args, version);
87
+ await changelog(args, newVersion);
88
+ await commit(args, newVersion);
89
+ await tag(newVersion, pkg ? pkg.private : false, args);
88
90
  } catch (err) {
89
- printError(args, err.message)
90
- throw err
91
+ printError(args, err.message);
92
+ throw err;
91
93
  }
92
- }
94
+ };
package/jest.config.js ADDED
@@ -0,0 +1,28 @@
1
+ const config = {
2
+ collectCoverage: true,
3
+ collectCoverageFrom: [
4
+ '**/*.{js,jsx,ts}',
5
+ '!**/node_modules/**',
6
+ '!**/tmp/**',
7
+ '!**/test/**',
8
+ '!**/coverage/**',
9
+ '!**/bin/**',
10
+ ],
11
+ coverageReporters: ['lcov', 'text'],
12
+ projects: [
13
+ {
14
+ displayName: 'Unit Test',
15
+ testMatch: ['**/test/*.spec.js'],
16
+ },
17
+ {
18
+ displayName: 'Integration Test',
19
+ runner: 'jest-serial-runner',
20
+ testMatch: ['**/test/*.integration-test.js'],
21
+ },
22
+ ],
23
+ silent: true, // Suppresses runtime console logs during test runs
24
+ testTimeout: 30000,
25
+ verbose: true, // Prints test describe/it names into console during test runs
26
+ };
27
+
28
+ module.exports = config;
package/lib/checkpoint.js CHANGED
@@ -1,12 +1,23 @@
1
- const chalk = require('chalk')
2
- const figures = require('figures')
3
- const util = require('util')
1
+ const chalk = require('chalk');
2
+ const figures = require('figures');
3
+ const util = require('util');
4
4
 
5
5
  module.exports = function (argv, msg, args, figure) {
6
- const defaultFigure = argv.dryRun ? chalk.yellow(figures.tick) : chalk.green(figures.tick)
6
+ const defaultFigure = argv.dryRun
7
+ ? chalk.yellow(figures.tick)
8
+ : chalk.green(figures.tick);
7
9
  if (!argv.silent) {
8
- console.info((figure || defaultFigure) + ' ' + util.format.apply(util, [msg].concat(args.map(function (arg) {
9
- return chalk.bold(arg)
10
- }))))
10
+ console.info(
11
+ (figure || defaultFigure) +
12
+ ' ' +
13
+ util.format.apply(
14
+ util,
15
+ [msg].concat(
16
+ args.map(function (arg) {
17
+ return chalk.bold(arg);
18
+ }),
19
+ ),
20
+ ),
21
+ );
11
22
  }
12
- }
23
+ };