2021-08-24 13:36:48 +08:00
|
|
|
import fs from 'fs'
|
2021-10-25 17:07:48 +08:00
|
|
|
import { epPackage } from '../build/utils/paths'
|
|
|
|
import { cyan, red, yellow, green } from '../build/utils/log'
|
|
|
|
import { getPackageManifest } from '../build/utils/pkg'
|
2021-08-24 13:36:48 +08:00
|
|
|
|
|
|
|
const tagVersion = process.env.TAG_VERSION
|
|
|
|
const gitHead = process.env.GIT_HEAD
|
|
|
|
if (!tagVersion || !gitHead) {
|
2021-09-26 01:29:07 +08:00
|
|
|
red(
|
|
|
|
'No tag version or git head were found, make sure that you set the environment variable $TAG_VERSION \n'
|
2021-08-24 13:36:48 +08:00
|
|
|
)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
cyan('Start updating version')
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
cyan(
|
|
|
|
['NOTICE:', `$TAG_VERSION: ${tagVersion}`, `$GIT_HEAD: ${gitHead}`].join('\n')
|
2021-09-04 19:29:28 +08:00
|
|
|
)
|
|
|
|
;(async () => {
|
2021-09-26 01:29:07 +08:00
|
|
|
yellow(`Updating package.json for element-plus`)
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
const json: Record<string, any> = getPackageManifest(epPackage)
|
2021-08-24 13:36:48 +08:00
|
|
|
|
|
|
|
json.version = tagVersion
|
|
|
|
json.gitHead = gitHead
|
|
|
|
|
|
|
|
if (!(process.argv.includes('-d') || process.argv.includes('--dry-run'))) {
|
|
|
|
try {
|
2021-09-26 01:29:07 +08:00
|
|
|
await fs.promises.writeFile(epPackage, JSON.stringify(json, null, 2), {
|
2021-08-24 13:36:48 +08:00
|
|
|
encoding: 'utf-8',
|
|
|
|
})
|
2022-03-08 14:03:32 +08:00
|
|
|
} catch {
|
2021-08-24 13:36:48 +08:00
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log(json)
|
|
|
|
}
|
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
green(`Version updated to ${tagVersion}`)
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
green(`Git head updated to ${gitHead}`)
|
2021-08-24 13:36:48 +08:00
|
|
|
})()
|