build: release script
This commit is contained in:
parent
cd5ba7cfcc
commit
8ed04ed503
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
@ -52,6 +52,7 @@
|
|||||||
"rollup": "^1.19.4",
|
"rollup": "^1.19.4",
|
||||||
"rollup-plugin-terser": "^5.1.1",
|
"rollup-plugin-terser": "^5.1.1",
|
||||||
"rollup-plugin-typescript2": "^0.24.0",
|
"rollup-plugin-typescript2": "^0.24.0",
|
||||||
|
"semver": "^6.3.0",
|
||||||
"ts-jest": "^24.0.2",
|
"ts-jest": "^24.0.2",
|
||||||
"tsd": "^0.11.0",
|
"tsd": "^0.11.0",
|
||||||
"typescript": "^3.7.0",
|
"typescript": "^3.7.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/compiler-core",
|
"name": "@vue/compiler-core",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/compiler-core",
|
"description": "@vue/compiler-core",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/compiler-core.esm-bundler.js",
|
"module": "dist/compiler-core.esm-bundler.js",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/compiler-dom",
|
"name": "@vue/compiler-dom",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/compiler-dom",
|
"description": "@vue/compiler-dom",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/compiler-dom.esm-bundler.js",
|
"module": "dist/compiler-dom.esm-bundler.js",
|
||||||
@ -13,7 +13,11 @@
|
|||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "VueDOMCompiler",
|
"name": "VueDOMCompiler",
|
||||||
"formats": ["cjs", "global", "esm-browser"]
|
"formats": [
|
||||||
|
"cjs",
|
||||||
|
"global",
|
||||||
|
"esm-browser"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -29,6 +33,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-dom#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-dom#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/compiler-core": "3.0.0-alpha.1"
|
"@vue/compiler-core": "3.0.0-alpha.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/compiler-sfc",
|
"name": "@vue/compiler-sfc",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/compiler-sfc",
|
"description": "@vue/compiler-sfc",
|
||||||
"main": "dist/compiler-sfc.cjs.js",
|
"main": "dist/compiler-sfc.cjs.js",
|
||||||
"files": [
|
"files": [
|
||||||
@ -27,7 +27,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-sfc#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-sfc#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/compiler-core": "3.0.0-alpha.1",
|
"@vue/compiler-core": "3.0.0-alpha.0",
|
||||||
"consolidate": "^0.15.1",
|
"consolidate": "^0.15.1",
|
||||||
"hash-sum": "^2.0.0",
|
"hash-sum": "^2.0.0",
|
||||||
"lru-cache": "^5.1.1",
|
"lru-cache": "^5.1.1",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/reactivity",
|
"name": "@vue/reactivity",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/reactivity",
|
"description": "@vue/reactivity",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/reactivity.esm-bundler.js",
|
"module": "dist/reactivity.esm-bundler.js",
|
||||||
@ -17,7 +17,12 @@
|
|||||||
},
|
},
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "VueObserver",
|
"name": "VueObserver",
|
||||||
"formats": ["esm", "cjs", "global", "esm-browser"]
|
"formats": [
|
||||||
|
"esm",
|
||||||
|
"cjs",
|
||||||
|
"global",
|
||||||
|
"esm-browser"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"vue"
|
"vue"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/runtime-core",
|
"name": "@vue/runtime-core",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/runtime-core",
|
"description": "@vue/runtime-core",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/runtime-core.esm-bundler.js",
|
"module": "dist/runtime-core.esm-bundler.js",
|
||||||
@ -24,6 +24,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-core#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-core#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/reactivity": "3.0.0-alpha.1"
|
"@vue/reactivity": "3.0.0-alpha.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/runtime-dom",
|
"name": "@vue/runtime-dom",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/runtime-dom",
|
"description": "@vue/runtime-dom",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/runtime-dom.esm-bundler.js",
|
"module": "dist/runtime-dom.esm-bundler.js",
|
||||||
@ -13,8 +13,15 @@
|
|||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "VueDOMRuntime",
|
"name": "VueDOMRuntime",
|
||||||
"formats": ["esm", "cjs", "global", "esm-browser"],
|
"formats": [
|
||||||
"dts": ["jsx.d.ts"]
|
"esm",
|
||||||
|
"cjs",
|
||||||
|
"global",
|
||||||
|
"esm-browser"
|
||||||
|
],
|
||||||
|
"dts": [
|
||||||
|
"jsx.d.ts"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -30,6 +37,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-dom#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-dom#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/runtime-core": "3.0.0-alpha.1"
|
"@vue/runtime-core": "3.0.0-alpha.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/runtime-test",
|
"name": "@vue/runtime-test",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/runtime-test",
|
"description": "@vue/runtime-test",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/runtime-test.esm-bundler.js",
|
"module": "dist/runtime-test.esm-bundler.js",
|
||||||
@ -15,7 +15,11 @@
|
|||||||
},
|
},
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "VueTestRuntime",
|
"name": "VueTestRuntime",
|
||||||
"formats": ["esm", "cjs", "global"]
|
"formats": [
|
||||||
|
"esm",
|
||||||
|
"cjs",
|
||||||
|
"global"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"vue"
|
"vue"
|
||||||
@ -27,6 +31,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-test#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-test#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/runtime-core": "3.0.0-alpha.1"
|
"@vue/runtime-core": "3.0.0-alpha.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/server-renderer",
|
"name": "@vue/server-renderer",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "@vue/server-renderer",
|
"description": "@vue/server-renderer",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
@ -9,7 +9,9 @@
|
|||||||
],
|
],
|
||||||
"types": "dist/server-renderer.d.ts",
|
"types": "dist/server-renderer.d.ts",
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"formats": ["cjs"]
|
"formats": [
|
||||||
|
"cjs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/shared",
|
"name": "@vue/shared",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"private": true
|
"private": true
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/size-check",
|
"name": "@vue/size-check",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "Vue",
|
"name": "Vue",
|
||||||
"formats": ["global"]
|
"formats": [
|
||||||
|
"global"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vue/template-explorer",
|
"name": "@vue/template-explorer",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"formats": [
|
"formats": [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue",
|
"name": "vue",
|
||||||
"version": "3.0.0-alpha.1",
|
"version": "3.0.0-alpha.0",
|
||||||
"description": "vue",
|
"description": "vue",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/vue.esm-bundler.js",
|
"module": "dist/vue.esm-bundler.js",
|
||||||
@ -12,7 +12,12 @@
|
|||||||
"unpkg": "dist/vue.global.js",
|
"unpkg": "dist/vue.global.js",
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"name": "Vue",
|
"name": "Vue",
|
||||||
"formats": ["esm", "cjs", "global", "esm-browser"]
|
"formats": [
|
||||||
|
"esm",
|
||||||
|
"cjs",
|
||||||
|
"global",
|
||||||
|
"esm-browser"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -28,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/compiler-dom": "3.0.0-alpha.1",
|
"@vue/compiler-dom": "3.0.0-alpha.0",
|
||||||
"@vue/runtime-dom": "3.0.0-alpha.1"
|
"@vue/runtime-dom": "3.0.0-alpha.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
152
scripts/release.js
Normal file
152
scripts/release.js
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
const args = require('minimist')(process.argv.slice(2))
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const semver = require('semver')
|
||||||
|
const currentVersion = require('../package.json').version
|
||||||
|
const { prompt } = require('enquirer')
|
||||||
|
const execa = require('execa')
|
||||||
|
|
||||||
|
const preId = args.preid || semver.prerelease(currentVersion)[0] || 'alpha'
|
||||||
|
const isDryRun = args.dry
|
||||||
|
const skipTests = args.skipTests
|
||||||
|
const skipBuild = args.skipBuild
|
||||||
|
const packages = fs
|
||||||
|
.readdirSync(path.resolve(__dirname, '../packages'))
|
||||||
|
.filter(p => !p.endsWith('.ts') && !p.startsWith('.'))
|
||||||
|
|
||||||
|
const versionIncrements = [
|
||||||
|
'patch',
|
||||||
|
'minor',
|
||||||
|
'major',
|
||||||
|
'prepatch',
|
||||||
|
'preminor',
|
||||||
|
'premajor',
|
||||||
|
'prerelease'
|
||||||
|
]
|
||||||
|
|
||||||
|
const inc = i => semver.inc(currentVersion, i, preId)
|
||||||
|
const bin = name => path.resolve(__dirname, '../node_modules/.bin/' + name)
|
||||||
|
const run = (bin, args, opts = {}) =>
|
||||||
|
execa(bin, args, { stdio: 'inherit', ...opts })
|
||||||
|
const getPkgRoot = pkg => path.resolve(__dirname, '../packages/' + pkg)
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
let targetVersion = args._[0]
|
||||||
|
|
||||||
|
if (!targetVersion) {
|
||||||
|
// no explicit version, offer suggestions
|
||||||
|
const { release } = await prompt({
|
||||||
|
type: 'select',
|
||||||
|
name: 'release',
|
||||||
|
message: 'Select release type',
|
||||||
|
choices: versionIncrements.map(i => `${i} (${inc(i)})`).concat(['custom'])
|
||||||
|
})
|
||||||
|
|
||||||
|
if (release === 'custom') {
|
||||||
|
targetVersion = (await prompt({
|
||||||
|
type: 'input',
|
||||||
|
name: 'version',
|
||||||
|
message: 'Input custom version',
|
||||||
|
initial: currentVersion
|
||||||
|
})).version
|
||||||
|
} else {
|
||||||
|
targetVersion = release.match(/\((.*)\)/)[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!semver.valid(targetVersion)) {
|
||||||
|
throw new Error(`invalid target version: ${targetVersion}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const { yes } = await prompt({
|
||||||
|
type: 'confirm',
|
||||||
|
name: 'yes',
|
||||||
|
message: `Releasing v${targetVersion}. Confirm?`
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!yes) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// run tests before release
|
||||||
|
if (!skipTests) {
|
||||||
|
await run(bin('jest'), ['--clearCache'])
|
||||||
|
await run('yarn', ['test'])
|
||||||
|
}
|
||||||
|
|
||||||
|
// update all package versions and inter-dependencies
|
||||||
|
updateVersions(targetVersion)
|
||||||
|
|
||||||
|
// build all packages with types
|
||||||
|
if (!skipBuild) {
|
||||||
|
await run('yarn', ['build', '-t'])
|
||||||
|
// test generated dts files
|
||||||
|
await run(bin('tsd'))
|
||||||
|
}
|
||||||
|
|
||||||
|
// all good...
|
||||||
|
if (isDryRun) {
|
||||||
|
// stop here so we can inspect changes to be committed
|
||||||
|
// and packages built
|
||||||
|
console.log('Dry run finished.')
|
||||||
|
} else {
|
||||||
|
// commit all changes
|
||||||
|
console.log('Committing changes...')
|
||||||
|
await run('git', ['add', '-A'])
|
||||||
|
await run('git', ['commit', '-m', `release: v${targetVersion}`])
|
||||||
|
|
||||||
|
// publish packages
|
||||||
|
const releaseTag = semver.prerelease(targetVersion)[0] || 'latest'
|
||||||
|
for (const pkg of packagesToPublish) {
|
||||||
|
await publish(pkg, releaseTag)
|
||||||
|
}
|
||||||
|
|
||||||
|
// push to GitHub
|
||||||
|
await run('git', ['tag', `v${targetVersion}`])
|
||||||
|
await run('git', ['push', 'origin', `refs/tags/v${targetVersion}`])
|
||||||
|
await run('git', ['push'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateVersions(version) {
|
||||||
|
console.log('Updating versions...')
|
||||||
|
// 1. update root package.json
|
||||||
|
updatePackage(path.resolve(__dirname, '..'), version)
|
||||||
|
// 2. update all packages
|
||||||
|
packages.forEach(p => updatePackage(getPkgRoot(p), version))
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePackage(pkgRoot, version) {
|
||||||
|
const pkg = readPkg(pkgRoot)
|
||||||
|
pkg.version = version
|
||||||
|
if (pkg.dependencies) {
|
||||||
|
Object.keys(pkg.dependencies).forEach(dep => {
|
||||||
|
if (
|
||||||
|
dep.startsWith('@vue') &&
|
||||||
|
packages.includes(dep.replace(/^@vue\//, ''))
|
||||||
|
) {
|
||||||
|
pkg.dependencies[dep] = version
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
function readPkg(pkgRoot) {
|
||||||
|
const pkgPath = path.resolve(pkgRoot, 'package.json')
|
||||||
|
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function publish(pkgName, releaseTag) {
|
||||||
|
const pkgRoot = getPkgRoot(pkgName)
|
||||||
|
const pkg = readPkg(pkgRoot)
|
||||||
|
if (!pkg.private) {
|
||||||
|
await run('npm', ['publish', '--tag', releaseTag], {
|
||||||
|
cwd: pkgRoot
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(err => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
@ -6,7 +6,7 @@ const msg = require('fs')
|
|||||||
.readFileSync(msgPath, 'utf-8')
|
.readFileSync(msgPath, 'utf-8')
|
||||||
.trim()
|
.trim()
|
||||||
|
|
||||||
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,50}/
|
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
|
||||||
|
|
||||||
if (!commitRE.test(msg)) {
|
if (!commitRE.test(msg)) {
|
||||||
console.log()
|
console.log()
|
||||||
|
@ -4819,7 +4819,7 @@ semver-diff@^2.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
||||||
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
||||||
|
|
||||||
semver@^6.0.0, semver@^6.2.0:
|
semver@^6.0.0, semver@^6.2.0, semver@^6.3.0:
|
||||||
version "6.3.0"
|
version "6.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||||
|
Loading…
Reference in New Issue
Block a user