fg-devkit 1.25.1 → 1.26.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/package.json +1 -1
- package/scaffold/vue/package.json +1 -1
- package/scripts/fg-devkit.mjs +42 -3
package/package.json
CHANGED
package/scripts/fg-devkit.mjs
CHANGED
|
@@ -81,6 +81,42 @@ function runNode(scriptRelative, args = [], options = {}) {
|
|
|
81
81
|
return r.status ?? 1
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
function readNextReleaseVersions(releaseKind) {
|
|
85
|
+
let currentVersion
|
|
86
|
+
try {
|
|
87
|
+
currentVersion = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8')).version
|
|
88
|
+
} catch {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
const match = typeof currentVersion === 'string' && currentVersion.match(/^(\d+)\.(\d+)\.(\d+)(-.+)?$/)
|
|
92
|
+
if (!match) return null
|
|
93
|
+
|
|
94
|
+
const bumpTypes = ['patch', 'minor', 'major']
|
|
95
|
+
if (releaseKind === 'candidate') {
|
|
96
|
+
const nextVersions = {}
|
|
97
|
+
for (const bumpType of bumpTypes) {
|
|
98
|
+
const result = spawnSync(process.execPath, [path.join(scriptDir, 'resolve-candidate-version.mjs'), bumpType], {
|
|
99
|
+
cwd: process.cwd(),
|
|
100
|
+
encoding: 'utf8',
|
|
101
|
+
})
|
|
102
|
+
if (result.status !== 0) return null
|
|
103
|
+
nextVersions[bumpType] = result.stdout.trim()
|
|
104
|
+
}
|
|
105
|
+
return { currentVersion, nextVersions }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const [major, minor, patch] = match.slice(1, 4).map(Number)
|
|
109
|
+
const isPrerelease = Boolean(match[4])
|
|
110
|
+
return {
|
|
111
|
+
currentVersion,
|
|
112
|
+
nextVersions: {
|
|
113
|
+
patch: isPrerelease ? `${major}.${minor}.${patch}` : `${major}.${minor}.${patch + 1}`,
|
|
114
|
+
minor: isPrerelease && patch === 0 ? `${major}.${minor}.0` : `${major}.${minor + 1}.0`,
|
|
115
|
+
major: isPrerelease && minor === 0 && patch === 0 ? `${major}.0.0` : `${major + 1}.0.0`,
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
84
120
|
/**
|
|
85
121
|
* Menu label with dimmed tags: `Upgrade packages [interactive, auto-commit]`.
|
|
86
122
|
* interactive: the action stops and asks for input while it runs. autoCommit: it commits on its own.
|
|
@@ -737,12 +773,15 @@ async function runInteractiveMenu() {
|
|
|
737
773
|
})
|
|
738
774
|
if (releaseMode === 'cancel') continue
|
|
739
775
|
|
|
776
|
+
const releaseVersions = readNextReleaseVersions(releaseKind)
|
|
777
|
+
const versionChange = (bumpType) =>
|
|
778
|
+
releaseVersions ? `: ${releaseVersions.currentVersion} → ${releaseVersions.nextVersions[bumpType]}` : ''
|
|
740
779
|
const bumpChoice = await selectPrompt({
|
|
741
780
|
message: releaseKind === 'candidate' ? 'Release candidate' : 'Release',
|
|
742
781
|
choices: [
|
|
743
|
-
{ name: 'Patch', value: 'patch', description:
|
|
744
|
-
{ name: 'Minor', value: 'minor', description:
|
|
745
|
-
{ name: 'Major', value: 'major', description:
|
|
782
|
+
{ name: 'Patch', value: 'patch', description: `Bug fixes only${versionChange('patch')}` },
|
|
783
|
+
{ name: 'Minor', value: 'minor', description: `New features, backwards compatible${versionChange('minor')}` },
|
|
784
|
+
{ name: 'Major', value: 'major', description: `Breaking changes${versionChange('major')}` },
|
|
746
785
|
{ name: 'Cancel', value: 'cancel' },
|
|
747
786
|
],
|
|
748
787
|
default: 'patch',
|