2022-04-09 04:32:01 +08:00
|
|
|
import { writeFile } from 'fs/promises'
|
2021-08-24 13:36:48 +08:00
|
|
|
import path from 'path'
|
2022-04-09 04:32:01 +08:00
|
|
|
import consola from 'consola'
|
|
|
|
import { epRoot } from '@element-plus/build-utils'
|
2021-08-24 13:36:48 +08:00
|
|
|
import pkg from '../packages/element-plus/package.json' // need to be checked
|
|
|
|
|
2022-04-09 04:32:01 +08:00
|
|
|
function getVersion() {
|
|
|
|
const tagVer = process.env.TAG_VERSION
|
|
|
|
if (tagVer) {
|
|
|
|
return tagVer.startsWith('v') ? tagVer.slice(1) : tagVer
|
|
|
|
} else {
|
|
|
|
return pkg.version
|
|
|
|
}
|
2020-12-23 16:57:31 +08:00
|
|
|
}
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2022-04-09 04:32:01 +08:00
|
|
|
const version = getVersion()
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
consola.info(`Version: ${version}`)
|
|
|
|
await writeFile(
|
|
|
|
path.resolve(epRoot, 'version.ts'),
|
|
|
|
`export const version = '${version}'\n`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|