@picgo/bump-version 1.1.2 → 2.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.
@@ -0,0 +1,42 @@
1
+ name: publish
2
+ permissions:
3
+ contents: read
4
+ id-token: write
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - master
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Setup pnpm
20
+ uses: pnpm/action-setup@v4
21
+ with:
22
+ run_install: false
23
+ version: 10
24
+
25
+ - name: Setup Node.js
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: 25
29
+ registry-url: https://registry.npmjs.org
30
+ cache: pnpm
31
+
32
+ - name: Install dependencies
33
+ run: pnpm install --frozen-lockfile
34
+
35
+ - name: Lint
36
+ run: pnpm run lint
37
+
38
+ - name: Unset NODE_AUTH_TOKEN
39
+ run: unset NODE_AUTH_TOKEN
40
+
41
+ - name: Publish
42
+ run: npm publish --access public --provenance --no-git-checks
package/.node-version ADDED
@@ -0,0 +1 @@
1
+ 22
package/CHANGELOG.md CHANGED
@@ -1,3 +1,40 @@
1
+ # :tada: 2.1.0 (2026-08-22)
2
+
3
+
4
+ ### :sparkles: Features
5
+
6
+ * add non-interactive mode and an explicit --version ([278d034](https://github.com/PicGo/bump-version/commit/278d034))
7
+
8
+
9
+ ### :bug: Bug Fixes
10
+
11
+ * fix deps bug ([caba420](https://github.com/PicGo/bump-version/commit/caba420))
12
+ * github actions error ([03c0733](https://github.com/PicGo/bump-version/commit/03c0733))
13
+ * write the version when --no-dry is passed ([1c042cd](https://github.com/PicGo/bump-version/commit/1c042cd))
14
+
15
+
16
+ ### :package: Chore
17
+
18
+ * update actions ([4b0c924](https://github.com/PicGo/bump-version/commit/4b0c924))
19
+ * update readme ([1819726](https://github.com/PicGo/bump-version/commit/1819726))
20
+
21
+
22
+
23
+ # :tada: 2.0.0 (2025-12-10)
24
+
25
+
26
+ ### :bug: Bug Fixes
27
+
28
+ * some deps not installed ([f2a4f74](https://github.com/PicGo/bump-version/commit/f2a4f74))
29
+
30
+
31
+ ### :package: Chore
32
+
33
+ * add pnpm-lock to npmignore ([6de1b65](https://github.com/PicGo/bump-version/commit/6de1b65))
34
+ * update deps \&\& add node 20 limit ([d2d96e9](https://github.com/PicGo/bump-version/commit/d2d96e9))
35
+
36
+
37
+
1
38
  ## :tada: 1.1.2 (2021-09-16)
2
39
 
3
40
 
package/README.md CHANGED
@@ -4,6 +4,8 @@ A full `git commit` -> `changelog` -> `release` workflow & convention.
4
4
 
5
5
  It's now only available for Node.js projects. Thanks [standard-version](https://github.com/conventional-changelog/standard-version) for the inspiration.
6
6
 
7
+ > Starting from v1.2.0, bump-version requires Node.js 20 or higher.
8
+
7
9
  <p align="center">
8
10
  <img src="https://raw.githubusercontent.com/Molunerfinn/test/master/picgo/New%20LOGO-150.png" alt="">
9
11
  </p>
@@ -22,11 +24,15 @@ It's now only available for Node.js projects. Thanks [standard-version](https://
22
24
  ## Installation
23
25
 
24
26
  ```bash
25
- npm install -D @picgo/bump-version
27
+ npm install -D @picgo/bump-version commitizen cz-customizable
26
28
 
27
29
  #or
28
30
 
29
- yarn add -D @picgo/bump-version
31
+ yarn add -D @picgo/bump-version commitizen cz-customizable
32
+
33
+ #or
34
+
35
+ pnpm add -D @picgo/bump-version commitizen cz-customizable
30
36
  ```
31
37
 
32
38
  Also, add the following data at the top level in your `package.json` to properly config `bump-version` (replace old `config` if you have already configured `commitizen` or `cz-customizable` before):
@@ -121,7 +127,10 @@ Usage
121
127
  bump-version
122
128
 
123
129
  Example
124
- bump-version -t major
130
+ bump-version -t major Interactive, confirms before running
131
+ bump-version -t minor -y Non-interactive, no TTY needed
132
+ bump-version --version 1.0.0 -y Bump to an exact version
133
+ bump-version -t minor -y -d Preview without changing anything
125
134
 
126
135
  Options
127
136
  -a, --preid-alpha Prerelease id: alpha. Exp. 1.0.0.alpha-0
@@ -141,6 +150,13 @@ Options
141
150
  -t, --type Release type. [major, minor, patch, premajor, preminor, prepatch, prerelease]
142
151
  Default: patch
143
152
 
153
+ -y, --yes Skip all prompts and run immediately. Needs no TTY,
154
+ so it works in CI and in scripts
155
+ Default: false
156
+
157
+ --version Bump to this exact version instead of deriving one
158
+ from --type. A leading "v" is accepted. Exp. 1.0.0
159
+
144
160
  --push Auto push commits to origin master
145
161
  Default: false
146
162
 
@@ -151,6 +167,24 @@ Options
151
167
  Default: changelog will be created
152
168
  ```
153
169
 
170
+ #### Non-interactive use
171
+
172
+ Without `-y` the tool always asks for confirmation, which needs a TTY and therefore fails in CI, in `npm run` chains and in agent sessions. `-y` skips every prompt:
173
+
174
+ ```bash
175
+ bump-version -t minor -y # 0.1.0 -> 0.2.0
176
+ bump-version --version 1.0.0 -y # bump to exactly 1.0.0
177
+ bump-version --version v1.0.0 -y # same; a leading "v" is accepted
178
+ ```
179
+
180
+ `--version` takes precedence over `--type`, and is rejected when it is not valid semver or is not greater than the current version. Invalid input exits with code `1`, so a CI step fails rather than tagging the wrong version.
181
+
182
+ Pair it with `-d` to see exactly what a release would do — the new version, the generated changelog — without writing, committing or tagging anything:
183
+
184
+ ```bash
185
+ bump-version -t minor -y -d
186
+ ```
187
+
154
188
  Don't know which version should be the next? Never mind:
155
189
 
156
190
  If you reject the default next version, then you can choose which version you want or customize one.
package/bin/bump-version CHANGED
@@ -2,8 +2,7 @@
2
2
  const minimist = require('minimist')
3
3
  const semver = require('semver')
4
4
  const path = require('path')
5
- const inquirer = require('inquirer')
6
- const _ = require('lodash')
5
+ const inquirer = require('inquirer').default
7
6
  const logger = require('../src/logger')
8
7
  const mainLifeCycle = require('../src/mainLifeCycle')
9
8
  const utils = require('../src/utils')
@@ -23,8 +22,12 @@ let argv = minimist(process.argv.slice(2), {
23
22
  'file': 'f', // changelog file,
24
23
  'path': 'p', // package.json's path
25
24
  'help': 'h', // help message
26
- 'type': 't' // bump type
27
- }
25
+ 'type': 't', // bump type
26
+ 'yes': 'y' // skip prompts
27
+ },
28
+ // Without this, `--version 1.0.0-beta.1` is parsed as a number and loses
29
+ // everything after the first dot.
30
+ string: ['version', 'type', 'file', 'path']
28
31
  })
29
32
 
30
33
  if (argv.h) {
@@ -39,9 +42,32 @@ if (currentVersion === undefined) {
39
42
  process.exit(0)
40
43
  }
41
44
  let preid = argv.a ? 'alpha' : argv.b ? 'beta' : ''
42
- let nextVersion = semver.inc(currentVersion, releaseType, preid)
43
45
  let releaseTypes = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease']
44
46
 
47
+ // An explicit --version wins over --type: naming a version is unambiguous,
48
+ // so silently deriving a different one from the type would be surprising.
49
+ let explicitVersion = typeof argv.version === 'string' ? argv.version.trim() : ''
50
+ let nextVersion
51
+ if (explicitVersion !== '') {
52
+ // Accept a leading `v` because that is how the tag is written and how
53
+ // people say it out loud.
54
+ nextVersion = semver.valid(explicitVersion.replace(/^v/, ''))
55
+ if (nextVersion === null) {
56
+ logger(`Invalid version: ${explicitVersion}`, 'error')
57
+ process.exit(1)
58
+ }
59
+ if (semver.lte(nextVersion, currentVersion)) {
60
+ logger(`Version ${nextVersion} is not greater than the current ${currentVersion}!`, 'error')
61
+ process.exit(1)
62
+ }
63
+ } else {
64
+ if (!releaseTypes.includes(releaseType)) {
65
+ logger(`Invalid release type: ${releaseType}. Expected one of ${releaseTypes.join(', ')}`, 'error')
66
+ process.exit(1)
67
+ }
68
+ nextVersion = semver.inc(currentVersion, releaseType, preid)
69
+ }
70
+
45
71
  function generateReleaseTypes (types) {
46
72
  return types.map(item => {
47
73
  let version = semver.inc(currentVersion, item, (preid || 'alpha'))
@@ -57,7 +83,7 @@ let defaultObj = {
57
83
  file: 'CHANGELOG.md'
58
84
  }
59
85
 
60
- argv = _.assign({}, defaultObj, argv)
86
+ argv = Object.assign({}, defaultObj, argv)
61
87
 
62
88
  let promptList = [
63
89
  {
@@ -72,13 +98,21 @@ BumpVersion -- By PicGo Group
72
98
  `
73
99
  );
74
100
  (async () => {
101
+ // Non-interactive path: no prompt is written at all, so this works with no
102
+ // TTY attached (CI, `pnpm release` from a script, an agent session).
103
+ if (argv.yes) {
104
+ console.log(`Bumping ${currentVersion} -> ${nextVersion}${argv.dry ? ' (dry run)' : ''}`)
105
+ await mainLifeCycle(argv, currentVersion, nextVersion)
106
+ return
107
+ }
108
+
75
109
  let answer = await inquirer.prompt(promptList)
76
110
  if (answer.confirmVersion) {
77
111
  await mainLifeCycle(argv, currentVersion, nextVersion)
78
112
  } else {
79
113
  promptList = [
80
114
  {
81
- type: 'list',
115
+ type: 'select',
82
116
  name: 'version',
83
117
  message: `The current version is ${currentVersion}\n Which version would you like to bump it?`,
84
118
  choices: [
@@ -0,0 +1,32 @@
1
+ const { FlatCompat } = require('@eslint/eslintrc')
2
+ const js = require('@eslint/js')
3
+
4
+ const compat = new FlatCompat({
5
+ baseDirectory: __dirname,
6
+ recommendedConfig: js.configs.recommended,
7
+ allConfig: js.configs.all
8
+ })
9
+
10
+ module.exports = [
11
+ {
12
+ ignores: ['node_modules', 'dist']
13
+ },
14
+ ...compat.extends(
15
+ 'eslint:recommended',
16
+ 'plugin:import/recommended',
17
+ 'plugin:n/recommended',
18
+ 'plugin:promise/recommended'
19
+ ),
20
+ {
21
+ languageOptions: {
22
+ ecmaVersion: 2022,
23
+ sourceType: 'script'
24
+ }
25
+ },
26
+ {
27
+ files: ['eslint.config.js'],
28
+ rules: {
29
+ 'n/no-unpublished-require': 'off'
30
+ }
31
+ }
32
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picgo/bump-version",
3
- "version": "1.1.2",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -13,8 +13,8 @@
13
13
  "test": "echo \"Error: no test specified\"",
14
14
  "cz": "git-cz",
15
15
  "release": "node ./bin/bump-version",
16
- "lint": "eslint --ext .js -f ./node_modules/eslint-friendly-formatter .",
17
- "lint:fix": "eslint --ext .js -f ./node_modules/eslint-friendly-formatter --fix ."
16
+ "lint": "eslint --ext .js .",
17
+ "lint:fix": "eslint --ext .js --fix ."
18
18
  },
19
19
  "husky": {
20
20
  "hooks": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/PicGo/bump-version.git"
27
+ "url": "https://github.com/PicGo/bump-version"
28
28
  },
29
29
  "author": "Molunerfinn",
30
30
  "license": "MIT",
@@ -33,13 +33,12 @@
33
33
  },
34
34
  "homepage": "https://github.com/PicGo/bump-version#readme",
35
35
  "devDependencies": {
36
- "eslint": "^5.16.0",
37
- "eslint-config-standard": "^12.0.0",
38
- "eslint-friendly-formatter": "^4.0.1",
39
- "eslint-plugin-import": "^2.16.0",
40
- "eslint-plugin-node": "^8.0.1",
41
- "eslint-plugin-promise": "^4.1.1",
42
- "eslint-plugin-standard": "^4.0.0"
36
+ "@eslint/eslintrc": "^3.3.3",
37
+ "@eslint/js": "^9.39.1",
38
+ "eslint": "^9.39.1",
39
+ "eslint-plugin-import": "^2.32.0",
40
+ "eslint-plugin-n": "^17.23.1",
41
+ "eslint-plugin-promise": "^7.2.1"
43
42
  },
44
43
  "config": {
45
44
  "commitizen": {
@@ -56,10 +55,19 @@
56
55
  },
57
56
  "dependencies": {
58
57
  "@commitlint/cli": "^7.5.2",
58
+ "chalk": "^4.1.2",
59
59
  "commitizen": "^4.2.3",
60
+ "compare-func": "^2.0.0",
60
61
  "conventional-changelog": "^3.0.6",
61
- "cz-customizable": "^5.8.0",
62
+ "cz-customizable": "^7.5.1",
63
+ "husky": "^1.3.1",
64
+ "inquirer": "^13.0.2",
65
+ "minimist": "^1.2.8",
62
66
  "ora": "^3.4.0",
63
- "husky": "^1.3.1"
67
+ "q": "^1.5.1",
68
+ "semver": "^7.7.3"
69
+ },
70
+ "engines": {
71
+ "node": ">=20.0.0"
64
72
  }
65
73
  }
@@ -2,9 +2,9 @@ const fs = require('fs')
2
2
  const checkFileAndGetPath = require('./utils').checkFileAndGetPath
3
3
  let versionFiles = ['package.json', 'package-lock.json']
4
4
  module.exports = (argv, version) => {
5
- if (argv.dry === false) {
6
- return Promise.resolve()
7
- }
5
+ // No early return for `dry` here: the write itself is guarded below, so
6
+ // bailing out would also skip it for `--no-dry`, leaving commit and tag to
7
+ // run against an unchanged version.
8
8
  versionFiles = checkFileAndGetPath(argv, versionFiles)
9
9
 
10
10
  for (let file of versionFiles) {
package/src/changelog.js CHANGED
@@ -11,7 +11,7 @@ module.exports = (argv, newVersion) => {
11
11
  let oldContent = ''
12
12
  try {
13
13
  oldContent = fs.readFileSync(argv.file, 'utf8')
14
- } catch (e) {
14
+ } catch {
15
15
  oldContent = ''
16
16
  }
17
17
  let context = ''
@@ -5,21 +5,28 @@ const tag = require('./tag')
5
5
  const spinner = require('./ora')
6
6
  module.exports = (argv, currentVersion, newVersion) => {
7
7
  spinner.start()
8
- return new Promise((resolve, reject) => {
9
- spinner.text = 'Bumping version...'
10
- return resolve(bumpVersion(argv, newVersion))
11
- }).then(() => {
12
- spinner.text = 'Generating changelog...'
13
- return changeLog(argv, newVersion)
14
- }).then(() => {
15
- spinner.text = 'Commiting changes...'
16
- return commit(argv, newVersion)
17
- }).then(() => {
18
- spinner.text = 'Creating tag...'
19
- return tag(argv, newVersion)
20
- }).then(() => {
21
- spinner.succeed('Done!')
22
- }).catch(e => {
23
- spinner.fail('Failed!')
24
- })
8
+ return Promise.resolve()
9
+ .then(() => {
10
+ spinner.text = 'Bumping version...'
11
+ return bumpVersion(argv, newVersion)
12
+ })
13
+ .then(() => {
14
+ spinner.text = 'Generating changelog...'
15
+ return changeLog(argv, newVersion)
16
+ })
17
+ .then(() => {
18
+ spinner.text = 'Commiting changes...'
19
+ return commit(argv, newVersion)
20
+ })
21
+ .then(() => {
22
+ spinner.text = 'Creating tag...'
23
+ return tag(argv, newVersion)
24
+ })
25
+ .then(() => {
26
+ return spinner.succeed('Done!')
27
+ })
28
+ .catch(err => {
29
+ spinner.fail('Failed!')
30
+ throw err
31
+ })
25
32
  }
package/src/tag.js CHANGED
@@ -9,11 +9,10 @@ module.exports = (argv, newVersion) => {
9
9
  } else {
10
10
  flow = exec(argv, `git tag -a v${newVersion} -m v${newVersion}`)
11
11
  }
12
- return flow
13
- .then(async () => {
14
- if (argv.push) {
15
- await exec(`git push --follow-tags origin master`)
16
- }
17
- return Promise.resolve()
18
- })
12
+ return flow.then(async () => {
13
+ if (argv.push) {
14
+ await exec(`git push --follow-tags origin master`)
15
+ }
16
+ return null
17
+ })
19
18
  }
package/src/utils.js CHANGED
@@ -17,7 +17,10 @@ Usage
17
17
  bump-version
18
18
 
19
19
  Example
20
- bump-version -t major
20
+ bump-version -t major Interactive, confirms before running
21
+ bump-version -t minor -y Non-interactive, no TTY needed
22
+ bump-version --version 1.0.0 -y Bump to an exact version
23
+ bump-version -t minor -y -d Preview without changing anything
21
24
 
22
25
  Options
23
26
  -a, --preid-alpha Prerelease id: alpha. Exp. 1.0.0.alpha-0
@@ -37,6 +40,13 @@ Options
37
40
  -t, --type Release type. [major, minor, patch, premajor, preminor, prepatch, prerelease]
38
41
  Default: patch
39
42
 
43
+ -y, --yes Skip all prompts and run immediately. Needs no TTY,
44
+ so it works in CI and in scripts
45
+ Default: false
46
+
47
+ --version Bump to this exact version instead of deriving one
48
+ from --type. A leading "v" is accepted. Exp. 1.0.0
49
+
40
50
  --push Auto push commits to origin master
41
51
  Default: false
42
52
 
package/.eslintrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "env": {
3
- "node": true
4
- },
5
- "extends": "standard"
6
- }
@@ -1,21 +0,0 @@
1
- name: publish
2
- on:
3
- push:
4
- branches:
5
- - master
6
- jobs:
7
- build:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - name: Clone repo
11
- uses: actions/checkout@v1
12
- - name: Setup node
13
- uses: actions/setup-node@v1
14
- with:
15
- node-version: '12.x'
16
- registry-url: 'https://registry.npmjs.org'
17
- - name: Install modules
18
- run: yarn
19
- - run: npm publish --access public
20
- env:
21
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,18 +0,0 @@
1
- name: manually-trigger
2
- on: workflow_dispatch
3
- jobs:
4
- build:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - name: Clone repo
8
- uses: actions/checkout@v1
9
- - name: Setup node
10
- uses: actions/setup-node@v1
11
- with:
12
- node-version: '12.x'
13
- registry-url: 'https://registry.npmjs.org'
14
- - name: Install modules
15
- run: yarn
16
- - run: npm publish --access public
17
- env:
18
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,24 +0,0 @@
1
- language: node_js
2
- node_js: stable
3
-
4
- # Travis-CI Caching
5
- cache:
6
- directories:
7
- - node_modules
8
-
9
- stages:
10
- - name: deploy
11
-
12
- jobs:
13
- include:
14
- - stage: deploy
15
- deploy:
16
- provider: npm
17
- email: "marksz@teamsz.xyz"
18
- api_key: "${NPM_TOKEN}"
19
- skip_cleanup: true
20
- on:
21
- branch: master
22
- branches:
23
- only:
24
- - master