Files
Archive/aliyunpan/version.mjs
2025-09-22 20:36:25 +02:00

22 lines
683 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import dayjs from 'dayjs'
import { execSync } from 'node:child_process'
import fs from 'node:fs'
import semver from 'semver'
process.env.TZ = 'Asia/Shanghai'
const packageJsonStr = fs.readFileSync('./package.json').toString()
try {
const tmp = `3.${dayjs().format('YY.MDDHH')}`
const packageJson = JSON.parse(packageJsonStr)
if (semver.gt(tmp, packageJson.version)) {
packageJson.version = tmp
console.info('版本升级为' + packageJson.version)
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2))
execSync(`git add package.json`)
}
} catch (e) {
console.error('处理package.json失败请重试', e.message)
process.exit(1)
}