2022-03-15 19:23:38 +08:00
|
|
|
import consola from 'consola'
|
|
|
|
import chalk from 'chalk'
|
2022-04-09 04:32:01 +08:00
|
|
|
import { errorAndExit, getWorkspacePackages } from '@element-plus/build-utils'
|
|
|
|
import type { Project } from '@pnpm/find-workspace-packages'
|
2022-03-15 19:23:38 +08:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const tagVersion = process.env.TAG_VERSION
|
|
|
|
const gitHead = process.env.GIT_HEAD
|
|
|
|
if (!tagVersion || !gitHead) {
|
2022-04-09 04:32:01 +08:00
|
|
|
errorAndExit(
|
2022-03-15 19:23:38 +08:00
|
|
|
new Error(
|
|
|
|
'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
|
|
|
|
2022-03-15 19:23:38 +08:00
|
|
|
consola.log(chalk.cyan('Start updating version'))
|
|
|
|
consola.log(chalk.cyan(`$TAG_VERSION: ${tagVersion}`))
|
|
|
|
consola.log(chalk.cyan(`$GIT_HEAD: ${gitHead}`))
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2022-03-15 19:23:38 +08:00
|
|
|
consola.debug(chalk.yellow(`Updating package.json for element-plus`))
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2022-04-09 04:32:01 +08:00
|
|
|
const pkgs = Object.fromEntries(
|
|
|
|
(await getWorkspacePackages()).map((pkg) => [pkg.manifest.name!, pkg])
|
|
|
|
)
|
2022-05-06 20:02:46 +08:00
|
|
|
const elementPlus = pkgs['element-plus'] || pkgs['@element-plus/nightly']
|
2022-04-09 04:32:01 +08:00
|
|
|
const eslintConfig = pkgs['@element-plus/eslint-config']
|
|
|
|
const metadata = pkgs['@element-plus/metadata']
|
|
|
|
|
|
|
|
const writeVersion = async (project: Project) => {
|
|
|
|
await project.writeProjectManifest({
|
|
|
|
...project.manifest,
|
|
|
|
version: tagVersion,
|
|
|
|
gitHead,
|
|
|
|
} as any)
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2022-05-06 20:02:46 +08:00
|
|
|
await writeVersion(elementPlus)
|
|
|
|
await writeVersion(eslintConfig)
|
|
|
|
await writeVersion(metadata)
|
2022-05-24 22:54:34 +08:00
|
|
|
} catch (err: any) {
|
2022-04-09 04:32:01 +08:00
|
|
|
errorAndExit(err)
|
2021-08-24 13:36:48 +08:00
|
|
|
}
|
|
|
|
|
2022-03-15 19:23:38 +08:00
|
|
|
consola.debug(chalk.green(`$GIT_HEAD: ${gitHead}`))
|
|
|
|
consola.success(chalk.green(`Git head updated to ${gitHead}`))
|
|
|
|
}
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2022-03-15 19:23:38 +08:00
|
|
|
main()
|