mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
chore(workflow): support nextVersion for dev version base
- Add optional `nextVersion` field in package.json to override the auto-incremented patch version used for dev builds - In prod mode, automatically remove `nextVersion` field after release - Fix packages tsconfig.json: switch to `module/moduleResolution: nodenext`, remove unsupported `baseUrl` and `jsx` options Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -33,6 +33,10 @@
|
|||||||
{{- if (gt $latest $version) | and $devOpts.c4u -}}
|
{{- if (gt $latest $version) | and $devOpts.c4u -}}
|
||||||
{{- warnf "FixIt %v (⬆️ %v)\n%v`git submodule update --remote --merge`\n\n" $version $latest (T "init.quicklyUpgrade") -}}
|
{{- warnf "FixIt %v (⬆️ %v)\n%v`git submodule update --remote --merge`\n\n" $version $latest (T "init.quicklyUpgrade") -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{- /* [todo] remove this temporary warning after v1.0.0 release */ -}}
|
||||||
|
{{- if hasPrefix $version "v1." -}}
|
||||||
|
{{- warnidf "warning-v1-dev" "FixIt %v\n⚠️ You are using a v1.0.0 development version, which may contain breaking changes.\nIt is recommended to use the latest stable release v0.4.5: https://github.com/hugo-fixit/FixIt/releases/tag/v0.4.5\n" $version -}}
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- hugo.Store.Set "latest" $latest -}}
|
{{- hugo.Store.Set "latest" $latest -}}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{{- hugo.Store.Set "version" "v0.4.6-20260517062719-ed8ec5c2" -}}
|
{{- hugo.Store.Set "version" "v1.0.0-20260528064828-5b43c2b6" -}}
|
||||||
{{- .Store.Set "this" dict -}}
|
{{- .Store.Set "this" dict -}}
|
||||||
|
|
||||||
{{- partial "init/detection-env.html" . -}}
|
{{- partial "init/detection-env.html" . -}}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"name": "@hugo-fixit/core",
|
"name": "@hugo-fixit/core",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.4.5",
|
"version": "0.4.5",
|
||||||
|
"nextVersion": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@11.1.0",
|
"packageManager": "pnpm@11.1.0",
|
||||||
"description": "Hugo FixIt core theme component source files",
|
"description": "Hugo FixIt core theme component source files",
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"jsx": "preserve",
|
"lib": ["ESNext"],
|
||||||
"lib": ["DOM", "ESNext"],
|
"module": "nodenext",
|
||||||
"baseUrl": ".",
|
"moduleResolution": "nodenext",
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"jsx": "preserve",
|
"lib": ["ESNext"],
|
||||||
"lib": ["DOM", "ESNext"],
|
"module": "nodenext",
|
||||||
"baseUrl": ".",
|
"moduleResolution": "nodenext",
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
@@ -55,8 +55,11 @@ export function updateVersion(type: 'dev' | 'prod') {
|
|||||||
const shortHash: string = execSync('git rev-parse --short HEAD').toString().trim()
|
const shortHash: string = execSync('git rev-parse --short HEAD').toString().trim()
|
||||||
// Build the development version v{major}.{minor}.{patch+1}-{timestamp}-{shortHash}
|
// Build the development version v{major}.{minor}.{patch+1}-{timestamp}-{shortHash}
|
||||||
// e.g. v0.3.21-20250702061540-abcdefg
|
// e.g. v0.3.21-20250702061540-abcdefg
|
||||||
|
// If `nextVersion` is set in package.json, use it as the base instead of auto-incrementing patch.
|
||||||
const timestamp: string = new Date().toISOString().replace(ISO_TIMESTAMP_CLEAN_RE, '').slice(0, -4)
|
const timestamp: string = new Date().toISOString().replace(ISO_TIMESTAMP_CLEAN_RE, '').slice(0, -4)
|
||||||
const devVersion: string = `${version.replace(VERSION_PATCH_RE, (_versionPatchMatch, part) => (Number.parseInt(part, 10) + 1).toString())}-${timestamp}-${shortHash}`
|
const nextVersion: string | undefined = packageJson.nextVersion
|
||||||
|
const devBaseVersion: string = nextVersion ?? version.replace(VERSION_PATCH_RE, (_versionPatchMatch, part) => (Number.parseInt(part, 10) + 1).toString())
|
||||||
|
const devVersion: string = `${devBaseVersion}-${timestamp}-${shortHash}`
|
||||||
const initHtml: string = fs.readFileSync(initHtmlPath, 'utf8')
|
const initHtml: string = fs.readFileSync(initHtmlPath, 'utf8')
|
||||||
const latestVersion: string = type === 'prod' ? version : devVersion
|
const latestVersion: string = type === 'prod' ? version : devVersion
|
||||||
const versionMatch = initHtml.match(VERSION_RE)
|
const versionMatch = initHtml.match(VERSION_RE)
|
||||||
@@ -74,6 +77,12 @@ export function updateVersion(type: 'dev' | 'prod') {
|
|||||||
|
|
||||||
// Update the version number in layouts/_partials/init/index.html
|
// Update the version number in layouts/_partials/init/index.html
|
||||||
fs.writeFileSync(initHtmlPath, newInitHtml)
|
fs.writeFileSync(initHtmlPath, newInitHtml)
|
||||||
|
// In prod mode, remove the `nextVersion` field from package.json if present
|
||||||
|
if (type === 'prod' && nextVersion) {
|
||||||
|
delete packageJson.nextVersion
|
||||||
|
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`)
|
||||||
|
console.log('Removed nextVersion field from package.json.')
|
||||||
|
}
|
||||||
// Add the updated files to the git stage
|
// Add the updated files to the git stage
|
||||||
const toStageFiles: string[] = [
|
const toStageFiles: string[] = [
|
||||||
'layouts/_partials/init/index.html',
|
'layouts/_partials/init/index.html',
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"jsx": "preserve",
|
"lib": ["ESNext"],
|
||||||
"lib": ["DOM", "ESNext"],
|
"module": "nodenext",
|
||||||
"baseUrl": ".",
|
"moduleResolution": "nodenext",
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user