commit-and-tag-version 11.3.0 → 12.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.
Files changed (52) hide show
  1. package/.eslintrc +46 -3
  2. package/.gitattributes +2 -0
  3. package/.github/dependabot.yml +19 -0
  4. package/.github/workflows/ci.yaml +12 -5
  5. package/.github/workflows/release-please.yml +3 -3
  6. package/.prettierrc +3 -0
  7. package/CHANGELOG.md +19 -0
  8. package/README.md +7 -1
  9. package/bin/cli.js +6 -6
  10. package/command.js +43 -37
  11. package/defaults.js +12 -11
  12. package/index.js +44 -42
  13. package/jest.config.js +28 -0
  14. package/lib/checkpoint.js +19 -8
  15. package/lib/configuration.js +17 -17
  16. package/lib/detect-package-manager.js +20 -20
  17. package/lib/format-commit-message.js +3 -3
  18. package/lib/latest-semver-tag.js +13 -11
  19. package/lib/lifecycles/bump.js +136 -105
  20. package/lib/lifecycles/changelog.js +88 -48
  21. package/lib/lifecycles/commit.js +41 -42
  22. package/lib/lifecycles/tag.js +41 -31
  23. package/lib/preset-loader.js +12 -10
  24. package/lib/print-error.js +10 -7
  25. package/lib/run-exec.js +10 -10
  26. package/lib/run-execFile.js +10 -10
  27. package/lib/run-lifecycle-script.js +16 -11
  28. package/lib/stringify-package.js +10 -10
  29. package/lib/updaters/index.js +40 -33
  30. package/lib/updaters/types/csproj.js +9 -7
  31. package/lib/updaters/types/gradle.js +10 -8
  32. package/lib/updaters/types/json.js +14 -14
  33. package/lib/updaters/types/plain-text.js +4 -4
  34. package/lib/write-file.js +4 -4
  35. package/package.json +20 -25
  36. package/test/commit-message-config.integration-test.js +106 -0
  37. package/test/config-files.integration-test.js +114 -0
  38. package/test/config-keys.integration-test.js +83 -0
  39. package/test/core.spec.js +1594 -874
  40. package/test/git.integration-test.js +363 -0
  41. package/test/invalid-config.integration-test.js +73 -0
  42. package/test/mocks/jest-mocks.js +48 -0
  43. package/test/mocks/updater/customer-updater.js +5 -8
  44. package/test/mocks/updater/increment-updater.js +5 -5
  45. package/test/pre-commit-hook.integration-test.js +192 -0
  46. package/test/preset.integration-test.js +56 -0
  47. package/test/stringify-package.spec.js +18 -22
  48. package/test/utils.spec.js +26 -42
  49. package/renovate.json +0 -9
  50. package/test/config-files.spec.js +0 -176
  51. package/test/git.spec.js +0 -480
  52. package/test/preset.spec.js +0 -52
package/.eslintrc CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
- "extends": "standard",
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
+ },
37
+ "plugins": [
38
+ "jest"
39
+ ],
3
40
  "rules": {
4
- "no-var": "error"
41
+ "no-var": "error",
42
+ "no-unused-vars": [
43
+ "error",
44
+ {
45
+ "argsIgnorePattern": "_.*"
46
+ }
47
+ ]
5
48
  }
6
- }
49
+ }
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ *.ts text eol=lf
2
+ *.js text eol=lf
@@ -0,0 +1,19 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ # Node / npm
9
+ - package-ecosystem: "npm" # See documentation for possible values
10
+ directory: "/" # Location of package manifests
11
+ versioning-strategy: increase
12
+ schedule:
13
+ interval: "weekly"
14
+
15
+ # Maintain dependencies for GitHub Actions
16
+ - package-ecosystem: "github-actions"
17
+ directory: "/"
18
+ schedule:
19
+ interval: "weekly"
@@ -10,23 +10,30 @@ jobs:
10
10
  runs-on: ${{ matrix.os }}
11
11
  strategy:
12
12
  matrix:
13
- node: [14, 16, 18]
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 }}
18
26
  steps:
19
- - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
27
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
20
28
  - run: git fetch --prune --unshallow
21
29
  - run: git config --global user.name 'Actions'
22
30
  - run: git config --global user.email 'dummy@example.org'
23
- - uses: actions/setup-node@v3
31
+ - uses: actions/setup-node@v4
24
32
  with:
25
33
  node-version: ${{ matrix.node }}
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:
@@ -15,13 +15,13 @@ jobs:
15
15
  release-type: node
16
16
  package-name: commit-and-tag-version
17
17
  # The logic below handles the npm publication:
18
- - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
18
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
19
19
  # these if statements ensure that a publication only occurs when
20
20
  # a new release is created:
21
21
  if: ${{ steps.release.outputs.release_created }}
22
- - uses: actions/setup-node@v3
22
+ - uses: actions/setup-node@v4
23
23
  with:
24
- node-version: 16
24
+ node-version: 20
25
25
  registry-url: 'https://registry.npmjs.org'
26
26
  if: ${{ steps.release.outputs.release_created }}
27
27
  - run: npm ci
package/.prettierrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "singleQuote": true
3
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
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.1.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.0.0...v12.1.0) (2024-01-06)
6
+
7
+
8
+ ### Features
9
+
10
+ * 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))
11
+
12
+ ## [12.0.0](https://github.com/absolute-version/commit-and-tag-version/compare/v11.3.0...v12.0.0) (2023-10-31)
13
+
14
+
15
+ ### ⚠ BREAKING CHANGES
16
+
17
+ * Drop support for node 14, 16. Now supports node 18 and 20.
18
+
19
+ ### Bug Fixes
20
+
21
+ * Drop support for node 14, 16. Now supports node 18 and 20. ([b1a58bc](https://github.com/absolute-version/commit-and-tag-version/commit/b1a58bc2a786da48fbcec248204ff8631c79606e))
22
+ * preserve frontmatter when updating changelog ([#108](https://github.com/absolute-version/commit-and-tag-version/issues/108)) ([abdcfe2](https://github.com/absolute-version/commit-and-tag-version/commit/abdcfe295023f46c8724463940fff6a220434fad))
23
+
5
24
  ## [11.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v11.2.4...v11.3.0) (2023-10-10)
6
25
 
7
26
 
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  > **`commit-and-tag-version` is a fork of `standard-version`**. Because of maintainer availability, `standard-version` was [deprecated on 15th May 2022](https://github.com/conventional-changelog/standard-version/pull/907). The previous maintainer recommends [release-please](https://github.com/googleapis/release-please) as an alternative for those who are using GitHub actions. This fork exists for those who can't switch to `release-please`, or who would like to continue using `standard-version`.
4
4
 
5
- > **`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. To migrate, you can drop in `commit-and-tag-version` in place of `standard-version`. There are no changes in 9.5.0, other than to add the package.json config key `commit-and-tag-version` (the previous configuration key `standard-version` will still work).
5
+ > **`Can I simply swap the library to migrate?`** To migrate, you can drop in `commit-and-tag-version` in place of `standard-version`. There are no changes in 9.5.0, other than to add the package.json config key `commit-and-tag-version` (the previous configuration key `standard-version` will still work). 10.x drops support for deprecated node versions, 11.x is a formatting change if you're relying on the exact markdown format in the changelog, and 12.x drops support for node 14/16.
6
+
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.
6
8
 
7
9
 
8
10
  A utility for versioning using [semver](https://semver.org/) and CHANGELOG generation powered by [Conventional Commits](https://conventionalcommits.org).
@@ -277,6 +279,10 @@ commit-and-tag-version --no-verify
277
279
 
278
280
  If you have your GPG key set up, add the `--sign` or `-s` flag to your `commit-and-tag-version` command.
279
281
 
282
+ ### Signed-off-by trailer
283
+
284
+ To add the "Signed-off-by" trailer to the commit message add the `--signoff` flag to your `commit-and-tag-version` command.
285
+
280
286
  ### Lifecycle Scripts
281
287
 
282
288
  `commit-and-tag-version` supports lifecycle scripts. These allow you to execute your
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
+ };