Refactor build scripts in package.json and update changelog generation to use environment variables for versioning. This improves consistency and clarity in version handling across scripts.

This commit is contained in:
codecalm 2025-12-30 19:24:53 +01:00
parent 7358779979
commit 07d1e4a796
4 changed files with 10 additions and 13 deletions

View File

@ -1,10 +1,9 @@
import { generateIconsPreview, getAllIcons, getArgvs, getPackageJson, GITHUB_DIR } from './helpers.mjs' import { generateIconsPreview, getAllIcons, getPackageJson, GITHUB_DIR } from './helpers.mjs'
import path from 'path' import path from 'path'
const argv = getArgvs(), const p = getPackageJson()
p = getPackageJson()
const version = argv['new-version'] || `${p.version}` const version = process.env.NEW_VERSION || `${p.version}`
if (version) { if (version) {
const icons = getAllIcons() const icons = getAllIcons()

View File

@ -1,9 +1,8 @@
import cp from 'child_process' import cp from 'child_process'
import { getArgvs, getPackageJson, printChangelog } from './helpers.mjs' import { getPackageJson, printChangelog } from './helpers.mjs'
const p = getPackageJson(), const p = getPackageJson(),
argv = getArgvs(), version = process.env.LATEST_VERSION || `${p.version}`
version = argv['latest-version'] || `${p.version}`
if (version) { if (version) {
cp.exec(`git diff ${version} HEAD --name-status ./icons`, function(err, ret) { cp.exec(`git diff ${version} HEAD --name-status ./icons`, function(err, ret) {

View File

@ -1,11 +1,10 @@
import { globSync } from 'glob' import { globSync } from 'glob'
import { readFileSync, writeFileSync } from 'fs' import { readFileSync, writeFileSync } from 'fs'
import path from 'path' import path from 'path'
import { ICONS_SRC_DIR, getMaxUnicode, getArgvs, getPackageJson } from './helpers.mjs' import { ICONS_SRC_DIR, getMaxUnicode, getPackageJson } from './helpers.mjs'
const argv = getArgvs(), const pkg = getPackageJson(),
pkg = getPackageJson(), newVersion = process.env.NEW_VERSION || pkg.version
newVersion = argv['new-version'] || pkg.version
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg')) const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))

View File

@ -97,12 +97,12 @@
}, },
"npm": false, "npm": false,
"hooks": { "hooks": {
"after:bump": "pnpm run build --latest-version ${latestVersion} --new-version ${version} --verbose && pnpm install", "after:bump": "LATEST_VERSION=${latestVersion} NEW_VERSION=${version} pnpm run build --verbose && pnpm install",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}." "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
}, },
"git": { "git": {
"addUntrackedFiles": true, "addUntrackedFiles": true,
"changelog": "pnpm run --silent changelog --latest-version ${latestTag}", "changelog": "LATEST_VERSION=${latestTag} pnpm run --silent changelog",
"tagName": "v${version}", "tagName": "v${version}",
"requireBranch": "main", "requireBranch": "main",
"requireCommits": true, "requireCommits": true,