feat: publish eslint config and metadata (#7063)

This commit is contained in:
三咲智子
2022-04-09 04:32:01 +08:00
committed by GitHub
parent 1aba790bdb
commit 2ca93aabd7
44 changed files with 246 additions and 265 deletions

View File

@@ -1,8 +1,6 @@
import fs from 'fs/promises'
import path from 'path'
main()
async function main() {
const threshold = process.env.THRESHOLD || 40
let output: string
@@ -54,3 +52,5 @@ ${table}
await fs.writeFile(path.resolve(__dirname, '..', 'tmp/diff.md'), output)
}
main()

View File

@@ -1,17 +1,26 @@
import fs from 'fs'
import { writeFile } from 'fs/promises'
import path from 'path'
import consola from 'consola'
import { epRoot } from '@element-plus/build-utils'
import pkg from '../packages/element-plus/package.json' // need to be checked
const tagVer = process.env.TAG_VERSION
let version = ''
if (tagVer) {
version = tagVer.startsWith('v') ? tagVer.slice(1) : tagVer
} else {
version = pkg.version
function getVersion() {
const tagVer = process.env.TAG_VERSION
if (tagVer) {
return tagVer.startsWith('v') ? tagVer.slice(1) : tagVer
} else {
return pkg.version
}
}
fs.writeFileSync(
path.resolve(__dirname, '../packages/element-plus/version.ts'),
`export const version = '${version}'
`
)
const version = getVersion()
async function main() {
consola.info(`Version: ${version}`)
await writeFile(
path.resolve(epRoot, 'version.ts'),
`export const version = '${version}'\n`
)
}
main()

View File

@@ -8,7 +8,16 @@ pnpm update:version
pnpm build
cd dist/element-plus
npm publish --access public
npm publish
cd -
cd internal/eslint-config
npm publish
cd -
cd internal/metadata
pnpm build
npm publish
cd -
echo "✅ Publish completed"

View File

@@ -1,18 +1,17 @@
import { writeFile } from 'fs/promises'
import consola from 'consola'
import chalk from 'chalk'
import { epPackage, getPackageManifest } from '@element-plus/build'
import { errorAndExit, getWorkspacePackages } from '@element-plus/build-utils'
import type { Project } from '@pnpm/find-workspace-packages'
async function main() {
const tagVersion = process.env.TAG_VERSION
const gitHead = process.env.GIT_HEAD
if (!tagVersion || !gitHead) {
consola.error(
errorAndExit(
new Error(
'No tag version or git head were found, make sure that you set the environment variable $TAG_VERSION \n'
)
)
process.exit(1)
}
consola.log(chalk.cyan('Start updating version'))
@@ -21,21 +20,27 @@ async function main() {
consola.debug(chalk.yellow(`Updating package.json for element-plus`))
const json: Record<string, any> = getPackageManifest(epPackage)
const pkgs = Object.fromEntries(
(await getWorkspacePackages()).map((pkg) => [pkg.manifest.name!, pkg])
)
const elementPlus = pkgs['element-plus']
const eslintConfig = pkgs['@element-plus/eslint-config']
const metadata = pkgs['@element-plus/metadata']
json.version = tagVersion
json.gitHead = gitHead
const writeVersion = async (project: Project) => {
await project.writeProjectManifest({
...project.manifest,
version: tagVersion,
gitHead,
} as any)
}
if (!(process.argv.includes('-d') || process.argv.includes('--dry-run'))) {
try {
await writeFile(epPackage, JSON.stringify(json, null, 2), {
encoding: 'utf-8',
})
} catch {
process.exit(1)
}
} else {
consola.log(json)
try {
writeVersion(elementPlus)
writeVersion(eslintConfig)
writeVersion(metadata)
} catch (err) {
errorAndExit(err)
}
consola.debug(chalk.green(`$GIT_HEAD: ${gitHead}`))