@picgo/bump-version 2.1.0 → 3.0.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.
- package/CHANGELOG.md +39 -0
- package/README.md +8 -6
- package/bin/bump-version +23 -37
- package/commitlint-picgo/{index.js → index.cjs} +2 -2
- package/conventional-changelog-picgo/conventional-changelog.cjs +9 -0
- package/conventional-changelog-picgo/{conventional-recommended-bump.js → conventional-recommended-bump.cjs} +1 -1
- package/conventional-changelog-picgo/index.cjs +10 -0
- package/conventional-changelog-picgo/{writer-opts.js → writer-opts.cjs} +7 -6
- package/eslint.config.js +32 -5
- package/package.json +24 -22
- package/src/bumpVersion.js +11 -6
- package/src/changelog.js +4 -4
- package/src/commit.js +8 -8
- package/src/exec.js +3 -3
- package/src/logger.js +5 -3
- package/src/mainLifeCycle.js +6 -6
- package/src/ora.js +9 -2
- package/src/resolveVersion.js +48 -0
- package/src/tag.js +3 -3
- package/src/utils.js +4 -8
- package/.github/workflows/publish.yml +0 -42
- package/conventional-changelog-picgo/conventional-changelog.js +0 -10
- package/conventional-changelog-picgo/index.js +0 -11
- /package/{.cz-config.js → .cz-config.cjs} +0 -0
- /package/commitlint-picgo/{types.js → types.cjs} +0 -0
- /package/conventional-changelog-picgo/{parser-opts.js → parser-opts.cjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
# :tada: 3.0.0 (2026-08-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### :sparkles: Features
|
|
5
|
+
|
|
6
|
+
* convert the CLI to ESM and upgrade its dependencies ([9165570](https://github.com/PicGo/bump-version/commit/9165570))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
* stop dropping Upgrade, Style, Refactor and Test from changelogs ([cd252e2](https://github.com/PicGo/bump-version/commit/cd252e2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### :arrow_up: Dependencies Upgrade
|
|
15
|
+
|
|
16
|
+
* clear the remaining dev vulnerabilities ([bdd1fb2](https://github.com/PicGo/bump-version/commit/bdd1fb2))
|
|
17
|
+
* move contributor tooling out of dependencies ([08093ca](https://github.com/PicGo/bump-version/commit/08093ca))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### :package: Chore
|
|
21
|
+
|
|
22
|
+
* update actions and run tests before publishing ([3317c25](https://github.com/PicGo/bump-version/commit/3317c25))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### :white_check_mark: Tests
|
|
26
|
+
|
|
27
|
+
* cover version resolution and the version write ([4b98e2a](https://github.com/PicGo/bump-version/commit/4b98e2a))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* note — otherwise it was silently discarded. Four of the
|
|
33
|
+
PicGo convention's own types never appeared in a changelog.
|
|
34
|
+
|
|
35
|
+
Moved the discard branch below them, where it now only catches genuinely
|
|
36
|
+
unrecognised types, and kept WIP and Release excluded explicitly.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
1
40
|
# :tada: 2.1.0 (2026-08-22)
|
|
2
41
|
|
|
3
42
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
|
7
|
+
> Starting from v3.0.0, bump-version is an ESM package and requires Node.js 22 or higher. The configs it ships for `commitlint` and `cz-customizable` remain CommonJS, so those tools keep loading them as before.
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img src="https://raw.githubusercontent.com/Molunerfinn/test/master/picgo/New%20LOGO-150.png" alt="">
|
|
@@ -24,17 +24,19 @@ It's now only available for Node.js projects. Thanks [standard-version](https://
|
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
npm install -D @picgo/bump-version commitizen cz-customizable
|
|
27
|
+
npm install -D @picgo/bump-version commitizen cz-customizable @commitlint/cli husky
|
|
28
28
|
|
|
29
29
|
#or
|
|
30
30
|
|
|
31
|
-
yarn add -D @picgo/bump-version commitizen cz-customizable
|
|
31
|
+
yarn add -D @picgo/bump-version commitizen cz-customizable @commitlint/cli husky
|
|
32
32
|
|
|
33
33
|
#or
|
|
34
34
|
|
|
35
|
-
pnpm add -D @picgo/bump-version commitizen cz-customizable
|
|
35
|
+
pnpm add -D @picgo/bump-version commitizen cz-customizable @commitlint/cli husky
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
> `commitizen`, `cz-customizable`, `@commitlint/cli` and `husky` are the tools that provide the `git-cz` and `commitlint` commands and the git hooks. They are peer tooling rather than dependencies of `bump-version` itself, so install the ones you actually use — if you only want `bump-version` to bump versions and write changelogs, `@picgo/bump-version` alone is enough.
|
|
39
|
+
|
|
38
40
|
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):
|
|
39
41
|
|
|
40
42
|
```json
|
|
@@ -48,11 +50,11 @@ Also, add the following data at the top level in your `package.json` to properly
|
|
|
48
50
|
"path": "./node_modules/cz-customizable"
|
|
49
51
|
},
|
|
50
52
|
"cz-customizable": {
|
|
51
|
-
"config": "./node_modules/@picgo/bump-version/.cz-config.
|
|
53
|
+
"config": "./node_modules/@picgo/bump-version/.cz-config.cjs"
|
|
52
54
|
}
|
|
53
55
|
},
|
|
54
56
|
"commitlint": {
|
|
55
|
-
"extends": ["./node_modules/@picgo/bump-version/commitlint-picgo"]
|
|
57
|
+
"extends": ["./node_modules/@picgo/bump-version/commitlint-picgo/index.cjs"]
|
|
56
58
|
}
|
|
57
59
|
```
|
|
58
60
|
|
package/bin/bump-version
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import minimist from 'minimist'
|
|
3
|
+
import semver from 'semver'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import fs from 'node:fs'
|
|
6
|
+
import { Separator } from '@inquirer/prompts'
|
|
7
|
+
import inquirer from 'inquirer'
|
|
8
|
+
import logger from '../src/logger.js'
|
|
9
|
+
import mainLifeCycle from '../src/mainLifeCycle.js'
|
|
10
|
+
import resolveVersion, { releaseTypes } from '../src/resolveVersion.js'
|
|
11
|
+
import * as utils from '../src/utils.js'
|
|
9
12
|
|
|
10
13
|
let pkg
|
|
11
14
|
try {
|
|
12
|
-
pkg =
|
|
15
|
+
pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'))
|
|
13
16
|
} catch (e) {
|
|
14
17
|
logger('package.json not found!', 'error')
|
|
15
18
|
process.exit(0)
|
|
@@ -35,38 +38,19 @@ if (argv.h) {
|
|
|
35
38
|
process.exit(0)
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
let releaseType = typeof argv.t === 'string' ? argv.t : 'patch'
|
|
39
41
|
let currentVersion = pkg.version
|
|
40
42
|
if (currentVersion === undefined) {
|
|
41
43
|
logger('Version field is not found in package.json!', 'error')
|
|
42
44
|
process.exit(0)
|
|
43
45
|
}
|
|
44
46
|
let preid = argv.a ? 'alpha' : argv.b ? 'beta' : ''
|
|
45
|
-
let releaseTypes = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease']
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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)
|
|
48
|
+
let resolved = resolveVersion(argv, currentVersion)
|
|
49
|
+
if (resolved.error) {
|
|
50
|
+
logger(resolved.error, 'error')
|
|
51
|
+
process.exit(1)
|
|
69
52
|
}
|
|
53
|
+
let nextVersion = resolved.version
|
|
70
54
|
|
|
71
55
|
function generateReleaseTypes (types) {
|
|
72
56
|
return types.map(item => {
|
|
@@ -117,7 +101,7 @@ BumpVersion -- By PicGo Group
|
|
|
117
101
|
message: `The current version is ${currentVersion}\n Which version would you like to bump it?`,
|
|
118
102
|
choices: [
|
|
119
103
|
...generateReleaseTypes(releaseTypes),
|
|
120
|
-
new
|
|
104
|
+
new Separator(),
|
|
121
105
|
'custom version',
|
|
122
106
|
'never mind~'
|
|
123
107
|
],
|
|
@@ -136,11 +120,13 @@ BumpVersion -- By PicGo Group
|
|
|
136
120
|
}
|
|
137
121
|
]
|
|
138
122
|
let result = await inquirer.prompt(promptList)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
123
|
+
// Same validator as --version, so a typed version and a flagged one are
|
|
124
|
+
// held to one rule.
|
|
125
|
+
let custom = resolveVersion({ version: result.version }, currentVersion)
|
|
126
|
+
if (custom.error) {
|
|
127
|
+
return logger(custom.error, 'error')
|
|
143
128
|
}
|
|
129
|
+
await mainLifeCycle(argv, currentVersion, custom.version)
|
|
144
130
|
} else {
|
|
145
131
|
await mainLifeCycle(argv, currentVersion, answer.version)
|
|
146
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const typeEnum = require('./types')
|
|
1
|
+
const typeEnum = require('./types.cjs')
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
parserPreset: '../conventional-changelog-picgo/parser-opts',
|
|
4
|
+
parserPreset: '../conventional-changelog-picgo/parser-opts.cjs',
|
|
5
5
|
rules: {
|
|
6
6
|
'body-leading-blank': [1, 'always'],
|
|
7
7
|
'footer-leading-blank': [1, 'always'],
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const conventionalChangelog = require(`./conventional-changelog.cjs`)
|
|
3
|
+
const parserOpts = require(`./parser-opts.cjs`)
|
|
4
|
+
const recommendedBumpOpts = require(`./conventional-recommended-bump.cjs`)
|
|
5
|
+
const writerOpts = require(`./writer-opts.cjs`)
|
|
6
|
+
|
|
7
|
+
module.exports = Promise.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts])
|
|
8
|
+
.then(([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]) => {
|
|
9
|
+
return { conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts }
|
|
10
|
+
})
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const compareFunc = require(`compare-func`)
|
|
4
|
-
const
|
|
5
|
-
const readFile = Q.denodeify(require(`fs`).readFile)
|
|
4
|
+
const readFile = require(`fs`).promises.readFile
|
|
6
5
|
const resolve = require(`path`).resolve
|
|
7
6
|
const headerPattern = /^(:.*: (.*))$/
|
|
8
7
|
|
|
@@ -18,13 +17,13 @@ const compareTitleFunc = (a, b) => {
|
|
|
18
17
|
return (sortMap[typeB] || 0) - (sortMap[typeA] || 0)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
module.exports =
|
|
20
|
+
module.exports = Promise.all([
|
|
22
21
|
readFile(resolve(__dirname, `./templates/template.hbs`), `utf-8`),
|
|
23
22
|
readFile(resolve(__dirname, `./templates/header.hbs`), `utf-8`),
|
|
24
23
|
readFile(resolve(__dirname, `./templates/commit.hbs`), `utf-8`),
|
|
25
24
|
readFile(resolve(__dirname, `./templates/footer.hbs`), `utf-8`)
|
|
26
25
|
])
|
|
27
|
-
.
|
|
26
|
+
.then(([template, header, commit, footer]) => {
|
|
28
27
|
const writerOpts = getWriterOpts()
|
|
29
28
|
|
|
30
29
|
writerOpts.mainTemplate = template
|
|
@@ -60,8 +59,6 @@ function getWriterOpts () {
|
|
|
60
59
|
commit.type = `:package: Chore`
|
|
61
60
|
} else if (commit.type === `:pushpin: Init`) {
|
|
62
61
|
commit.type = `:pushpin: Init`
|
|
63
|
-
} else if (discard) {
|
|
64
|
-
return
|
|
65
62
|
} else if (commit.type === `:arrow_up: Upgrade`) {
|
|
66
63
|
commit.type = `:arrow_up: Dependencies Upgrade`
|
|
67
64
|
} else if (commit.type === `:art: Style`) {
|
|
@@ -71,6 +68,10 @@ function getWriterOpts () {
|
|
|
71
68
|
} else if (commit.type === `:white_check_mark: Test`) {
|
|
72
69
|
commit.type = `:white_check_mark: Tests`
|
|
73
70
|
} else if (commit.type === `:construction: WIP` || commit.type === ':tada: Release') {
|
|
71
|
+
// WIP is noise and Release is this tool's own commit.
|
|
72
|
+
return
|
|
73
|
+
} else if (discard) {
|
|
74
|
+
// Anything unrecognised, unless it carries a BREAKING CHANGE note.
|
|
74
75
|
return
|
|
75
76
|
}
|
|
76
77
|
|
package/eslint.config.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { FlatCompat } from '@eslint/eslintrc'
|
|
2
|
+
import js from '@eslint/js'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
3
7
|
|
|
4
8
|
const compat = new FlatCompat({
|
|
5
9
|
baseDirectory: __dirname,
|
|
@@ -7,7 +11,7 @@ const compat = new FlatCompat({
|
|
|
7
11
|
allConfig: js.configs.all
|
|
8
12
|
})
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
export default [
|
|
11
15
|
{
|
|
12
16
|
ignores: ['node_modules', 'dist']
|
|
13
17
|
},
|
|
@@ -18,15 +22,38 @@ module.exports = [
|
|
|
18
22
|
'plugin:promise/recommended'
|
|
19
23
|
),
|
|
20
24
|
{
|
|
25
|
+
// The CLI and its src/ modules are ESM, as is this config.
|
|
21
26
|
languageOptions: {
|
|
22
27
|
ecmaVersion: 2022,
|
|
23
|
-
sourceType: '
|
|
28
|
+
sourceType: 'module'
|
|
29
|
+
},
|
|
30
|
+
rules: {
|
|
31
|
+
// Resolution of bare ESM specifiers is handled by Node, not the plugin.
|
|
32
|
+
'import/no-unresolved': 'off'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
// Configs consumed by other tools' CommonJS loaders stay CJS.
|
|
37
|
+
files: ['**/*.cjs'],
|
|
38
|
+
languageOptions: {
|
|
39
|
+
sourceType: 'commonjs',
|
|
40
|
+
globals: {
|
|
41
|
+
module: 'writable',
|
|
42
|
+
require: 'readonly',
|
|
43
|
+
__dirname: 'readonly'
|
|
44
|
+
}
|
|
24
45
|
}
|
|
25
46
|
},
|
|
26
47
|
{
|
|
27
48
|
files: ['eslint.config.js'],
|
|
28
49
|
rules: {
|
|
29
|
-
'n/no-unpublished-
|
|
50
|
+
'n/no-unpublished-import': 'off'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
files: ['test/**/*.js'],
|
|
55
|
+
rules: {
|
|
56
|
+
'n/no-unpublished-import': 'off'
|
|
30
57
|
}
|
|
31
58
|
}
|
|
32
59
|
]
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picgo/bump-version",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
5
|
"bin": {
|
|
7
6
|
"bump-version": "./bin/bump-version"
|
|
8
7
|
},
|
|
@@ -10,17 +9,13 @@
|
|
|
10
9
|
"access": "public"
|
|
11
10
|
},
|
|
12
11
|
"scripts": {
|
|
13
|
-
"test": "
|
|
12
|
+
"test": "vitest run",
|
|
14
13
|
"cz": "git-cz",
|
|
15
14
|
"release": "node ./bin/bump-version",
|
|
16
15
|
"lint": "eslint --ext .js .",
|
|
17
|
-
"lint:fix": "eslint --ext .js --fix ."
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"hooks": {
|
|
21
|
-
"pre-commit": "npm run lint",
|
|
22
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
23
|
-
}
|
|
16
|
+
"lint:fix": "eslint --ext .js --fix .",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"prepare": "husky || true"
|
|
24
19
|
},
|
|
25
20
|
"repository": {
|
|
26
21
|
"type": "git",
|
|
@@ -33,41 +28,48 @@
|
|
|
33
28
|
},
|
|
34
29
|
"homepage": "https://github.com/PicGo/bump-version#readme",
|
|
35
30
|
"devDependencies": {
|
|
31
|
+
"@commitlint/cli": "^21.2.2",
|
|
36
32
|
"@eslint/eslintrc": "^3.3.3",
|
|
37
33
|
"@eslint/js": "^9.39.1",
|
|
34
|
+
"commitizen": "^4.3.2",
|
|
35
|
+
"cz-customizable": "^7.5.4",
|
|
38
36
|
"eslint": "^9.39.1",
|
|
39
37
|
"eslint-plugin-import": "^2.32.0",
|
|
40
38
|
"eslint-plugin-n": "^17.23.1",
|
|
41
|
-
"eslint-plugin-promise": "^7.2.1"
|
|
39
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
40
|
+
"husky": "^9.1.7",
|
|
41
|
+
"vitest": "^4.1.11"
|
|
42
42
|
},
|
|
43
43
|
"config": {
|
|
44
44
|
"commitizen": {
|
|
45
45
|
"path": "node_modules/cz-customizable"
|
|
46
46
|
},
|
|
47
47
|
"cz-customizable": {
|
|
48
|
-
"config": ".cz-config.
|
|
48
|
+
"config": ".cz-config.cjs"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"commitlint": {
|
|
52
52
|
"extends": [
|
|
53
|
-
"./commitlint-picgo"
|
|
53
|
+
"./commitlint-picgo/index.cjs"
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"chalk": "^
|
|
59
|
-
"commitizen": "^4.2.3",
|
|
57
|
+
"@inquirer/prompts": "^8.6.0",
|
|
58
|
+
"chalk": "^6.0.0",
|
|
60
59
|
"compare-func": "^2.0.0",
|
|
61
60
|
"conventional-changelog": "^3.0.6",
|
|
62
|
-
"
|
|
63
|
-
"husky": "^1.3.1",
|
|
64
|
-
"inquirer": "^13.0.2",
|
|
61
|
+
"inquirer": "^14.1.0",
|
|
65
62
|
"minimist": "^1.2.8",
|
|
66
|
-
"ora": "^3.
|
|
67
|
-
"q": "^1.5.1",
|
|
63
|
+
"ora": "^6.3.1",
|
|
68
64
|
"semver": "^7.7.3"
|
|
69
65
|
},
|
|
70
66
|
"engines": {
|
|
71
|
-
"node": ">=
|
|
67
|
+
"node": ">=22.0.0"
|
|
68
|
+
},
|
|
69
|
+
"type": "module",
|
|
70
|
+
"pnpm": {
|
|
71
|
+
"overrides": {
|
|
72
|
+
"tmp": "^0.2.5"
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
}
|
package/src/bumpVersion.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { checkFileAndGetPath } from './utils.js'
|
|
3
|
+
|
|
4
|
+
// Resolved per call rather than cached at module scope: the resolved list is
|
|
5
|
+
// absolute and tied to one `argv.path`, so reusing it across calls would
|
|
6
|
+
// silently target the previous directory.
|
|
7
|
+
const VERSION_FILES = ['package.json', 'package-lock.json']
|
|
8
|
+
|
|
9
|
+
export default (argv, version) => {
|
|
5
10
|
// No early return for `dry` here: the write itself is guarded below, so
|
|
6
11
|
// bailing out would also skip it for `--no-dry`, leaving commit and tag to
|
|
7
12
|
// run against an unchanged version.
|
|
8
|
-
versionFiles = checkFileAndGetPath(argv,
|
|
13
|
+
const versionFiles = checkFileAndGetPath(argv, VERSION_FILES)
|
|
9
14
|
|
|
10
|
-
for (
|
|
15
|
+
for (const file of versionFiles) {
|
|
11
16
|
let content = fs.readFileSync(file, 'utf8')
|
|
12
17
|
try {
|
|
13
18
|
content = JSON.parse(content)
|
package/src/changelog.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import cc from 'conventional-changelog'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import config from '../conventional-changelog-picgo/index.cjs'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default (argv, newVersion) => {
|
|
6
6
|
if (argv.changelog === false) {
|
|
7
7
|
return Promise.resolve()
|
|
8
8
|
}
|
package/src/commit.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { checkFileAndGetPath } from './utils.js'
|
|
2
|
+
import exec from './exec.js'
|
|
3
|
+
const VERSION_FILES = [
|
|
4
4
|
'package.json',
|
|
5
5
|
'package-lock.json'
|
|
6
6
|
]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export default (argv, newVersion) => {
|
|
8
|
+
// Built per call: reassigning a module-level array leaks the previous
|
|
9
|
+
// run's resolved paths into the next one.
|
|
10
|
+
const files = argv.changelog !== false ? [...VERSION_FILES, argv.file] : [...VERSION_FILES]
|
|
11
11
|
const releaseMsg = `:tada: Release: v${newVersion}`
|
|
12
12
|
if (argv.skipCommit) return Promise.resolve()
|
|
13
|
-
changedFiles =
|
|
13
|
+
const changedFiles = checkFileAndGetPath(argv, files).join(' ')
|
|
14
14
|
if (changedFiles === '' || argv.dry) {
|
|
15
15
|
return Promise.resolve()
|
|
16
16
|
}
|
package/src/exec.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { exec } from 'node:child_process'
|
|
2
|
+
import logger from './logger.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default (argv, cmd) => {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
6
|
// Exec given cmd and handle possible errors
|
|
7
7
|
exec(cmd, { cwd: argv.path }, function (err, stdout, stderr) {
|
package/src/logger.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import ora from './ora.js'
|
|
3
|
+
|
|
3
4
|
const level = {
|
|
4
5
|
success: 'green',
|
|
5
6
|
info: 'blue',
|
|
6
7
|
warn: 'yellow',
|
|
7
8
|
error: 'red'
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
export default (msg, type) => {
|
|
10
12
|
let log = chalk[level[type]](`[Bump ${type.toUpperCase()}]: `)
|
|
11
13
|
log += msg
|
|
12
14
|
ora.clear()
|
package/src/mainLifeCycle.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import bumpVersion from './bumpVersion.js'
|
|
2
|
+
import commit from './commit.js'
|
|
3
|
+
import changeLog from './changelog.js'
|
|
4
|
+
import tag from './tag.js'
|
|
5
|
+
import spinner from './ora.js'
|
|
6
|
+
export default (argv, currentVersion, newVersion) => {
|
|
7
7
|
spinner.start()
|
|
8
8
|
return Promise.resolve()
|
|
9
9
|
.then(() => {
|
package/src/ora.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import Ora from 'ora'
|
|
2
|
+
|
|
3
|
+
// Pinned to ora 6.x in package.json on purpose. From ora 7 onwards the spinner
|
|
4
|
+
// kills the process when it is started after an inquirer prompt has restored
|
|
5
|
+
// the TTY: the confirm is answered, the spinner draws one frame, and the
|
|
6
|
+
// process exits before the release finishes — leaving a bumped package.json
|
|
7
|
+
// with no commit and no tag. Verified against ora 3/4/5/6 (fine) and 7/8/9
|
|
8
|
+
// (broken), with inquirer 13 and 14 alike.
|
|
9
|
+
export default new Ora({
|
|
3
10
|
text: ''
|
|
4
11
|
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import semver from 'semver'
|
|
2
|
+
|
|
3
|
+
const RELEASE_TYPES = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease']
|
|
4
|
+
|
|
5
|
+
export const releaseTypes = RELEASE_TYPES
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Work out which version to bump to.
|
|
9
|
+
*
|
|
10
|
+
* Pure on purpose: the CLI turns the result into either an error exit or a
|
|
11
|
+
* lifecycle run, and keeping the decision separate is what makes it testable
|
|
12
|
+
* without spawning a process or touching a git repo.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} argv parsed arguments; reads `version`, `t`/`type`, `a`, `b`
|
|
15
|
+
* @param {string} currentVersion the version currently in package.json
|
|
16
|
+
* @returns {{ version: string } | { error: string }}
|
|
17
|
+
*/
|
|
18
|
+
export default (argv, currentVersion) => {
|
|
19
|
+
// An explicit --version wins over --type: naming a version is unambiguous,
|
|
20
|
+
// so silently deriving a different one from the type would be surprising.
|
|
21
|
+
const explicit = typeof argv.version === 'string' ? argv.version.trim() : ''
|
|
22
|
+
|
|
23
|
+
if (explicit !== '') {
|
|
24
|
+
// Accept a leading `v` because that is how the tag is written and how
|
|
25
|
+
// people say it out loud.
|
|
26
|
+
const version = semver.valid(explicit.replace(/^v/, ''))
|
|
27
|
+
if (version === null) {
|
|
28
|
+
return { error: `Invalid version: ${explicit}` }
|
|
29
|
+
}
|
|
30
|
+
if (semver.lte(version, currentVersion)) {
|
|
31
|
+
return { error: `Version ${version} is not greater than the current ${currentVersion}!` }
|
|
32
|
+
}
|
|
33
|
+
return { version }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const releaseType = typeof argv.t === 'string' ? argv.t : 'patch'
|
|
37
|
+
if (!RELEASE_TYPES.includes(releaseType)) {
|
|
38
|
+
return { error: `Invalid release type: ${releaseType}. Expected one of ${RELEASE_TYPES.join(', ')}` }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const preid = argv.a ? 'alpha' : argv.b ? 'beta' : ''
|
|
42
|
+
const version = semver.inc(currentVersion, releaseType, preid)
|
|
43
|
+
if (version === null) {
|
|
44
|
+
return { error: `Cannot bump ${currentVersion} with release type ${releaseType}` }
|
|
45
|
+
}
|
|
46
|
+
return { version }
|
|
47
|
+
}
|
|
48
|
+
|
package/src/tag.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import exec from './exec.js'
|
|
2
|
+
export default (argv, newVersion) => {
|
|
3
3
|
if (argv.dry) {
|
|
4
4
|
return Promise.resolve()
|
|
5
5
|
}
|
|
@@ -11,7 +11,7 @@ module.exports = (argv, newVersion) => {
|
|
|
11
11
|
}
|
|
12
12
|
return flow.then(async () => {
|
|
13
13
|
if (argv.push) {
|
|
14
|
-
await exec(`git push --follow-tags origin master`)
|
|
14
|
+
await exec(argv, `git push --follow-tags origin master`)
|
|
15
15
|
}
|
|
16
16
|
return null
|
|
17
17
|
})
|
package/src/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const checkFileAndGetPath = (argv, files) => {
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
export const checkFileAndGetPath = (argv, files) => {
|
|
4
4
|
return files.map(item => {
|
|
5
5
|
if (path.isAbsolute(item)) {
|
|
6
6
|
return item
|
|
@@ -10,7 +10,7 @@ const checkFileAndGetPath = (argv, files) => {
|
|
|
10
10
|
return fs.existsSync(item)
|
|
11
11
|
})
|
|
12
12
|
}
|
|
13
|
-
const helperMsg = `
|
|
13
|
+
export const helperMsg = `
|
|
14
14
|
BumpVersion -- By PicGo Group
|
|
15
15
|
|
|
16
16
|
Usage
|
|
@@ -57,7 +57,3 @@ Options
|
|
|
57
57
|
Default: changelog will be created
|
|
58
58
|
`
|
|
59
59
|
|
|
60
|
-
module.exports = {
|
|
61
|
-
checkFileAndGetPath,
|
|
62
|
-
helperMsg
|
|
63
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Q = require(`q`)
|
|
4
|
-
const parserOpts = require(`./parser-opts`)
|
|
5
|
-
const writerOpts = require(`./writer-opts`)
|
|
6
|
-
|
|
7
|
-
module.exports = Q.all([parserOpts, writerOpts])
|
|
8
|
-
.spread((parserOpts, writerOpts) => {
|
|
9
|
-
return { parserOpts, writerOpts }
|
|
10
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const Q = require(`q`)
|
|
3
|
-
const conventionalChangelog = require(`./conventional-changelog`)
|
|
4
|
-
const parserOpts = require(`./parser-opts`)
|
|
5
|
-
const recommendedBumpOpts = require(`./conventional-recommended-bump`)
|
|
6
|
-
const writerOpts = require(`./writer-opts`)
|
|
7
|
-
|
|
8
|
-
module.exports = Q.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts])
|
|
9
|
-
.spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
|
|
10
|
-
return { conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts }
|
|
11
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|