workflow: fix vue-cli-version-marker publish and eslint-config version sync

This commit is contained in:
Haoqun Jiang
2018-12-02 16:25:24 +08:00
parent bfe42ed1d1
commit e16e5f139e
2 changed files with 50 additions and 37 deletions

View File

@@ -103,7 +103,7 @@ const release = async () => {
}
await execa(require.resolve('lerna/cli'), lernaArgs, { stdio: 'inherit' })
// require('./genChangelog')(version)
require('./genChangelog')(version)
const packages = JSON.parse(
(await execa(require.resolve('lerna/cli'), ['list', '--json'])).stdout
@@ -121,9 +121,16 @@ const release = async () => {
const tagName = `vue-cli-version-marker@${versionMarkerPkg.version}`
await execa('git', ['add', '-A'], { stdio: 'inherit' })
await execa('git', ['commit', '-m', `chore: ${tagName}`], { stdio: 'inherit' })
// await execa('npm', ['publish'], { stdio: 'inherit', cwd: path.dirname(versionMarkerPath) })
// await execa('git', ['tag', tagName], { stdio: 'inherit' })
// await execa('git', ['push', '--tags'], { stdio: 'inherit' })
// Must specify registry url: https://github.com/lerna/lerna/issues/896#issuecomment-311894609
await execa(
'npm',
['publish', '--registry', 'https://registry.npmjs.org/'],
{ stdio: 'inherit', cwd: path.dirname(versionMarkerPath) }
)
await execa('git', ['tag', tagName], { stdio: 'inherit' })
await execa('git', ['push', '--tags'], { stdio: 'inherit' })
}
release().catch(err => {

View File

@@ -148,43 +148,49 @@ async function syncDeps ({ local, version, skipPrompt }) {
}
}
// console.log('Syncing local deps...')
// const updatedRE = new RegExp(`'(${Array.from(updatedDeps).join('|')})': '\\^(\\d+\\.\\d+\\.\\d+[^']*)'`)
// const paths = await globby(['packages/@vue/**/*.js'])
// paths
// .filter(p => !/\/files\//.test(p) && !/\/node_modules/.test(p))
// .forEach(filePath => {
// let isUpdated = false
// const makeReplacer = versionGetter => (_, pkg, curVersion) => {
// const targetVersion = versionGetter(pkg)
// if (!targetVersion) return _
// if (checkUpdate(pkg, filePath, curVersion, targetVersion)) {
// isUpdated = true
// }
// return `'${pkg}': '^${targetVersion}'`
// }
console.log('Syncing local deps...')
const updatedRE = new RegExp(`'(${Array.from(updatedDeps).join('|')})': '\\^(\\d+\\.\\d+\\.\\d+[^']*)'`)
const paths = await globby(['packages/@vue/**/*.js'])
paths
.filter(p => !/\/files\//.test(p) && !/\/node_modules/.test(p))
.forEach(filePath => {
let isUpdated = false
const makeReplacer = versionGetter => (_, pkg, curVersion) => {
const targetVersion = versionGetter(pkg)
if (!targetVersion) return _
if (checkUpdate(pkg, filePath, curVersion, targetVersion)) {
isUpdated = true
}
return `'${pkg}': '^${targetVersion}'`
}
// const localReplacer = makeReplacer(
// pkg => {
// try {
// // inline version takes priority
// return version || require(`../packages/${pkg}/package.json`).version
// } catch (e) {}
// }
// )
const localReplacer = makeReplacer(
pkg => {
try {
// for eslint-config-* packages, only use version field from package.json
// as they're published separately
if (pkg.includes('eslint-config')) {
return require(`../packages/${pkg}/package.json`).version
}
// const remoteReplacer = makeReplacer(getRemoteVersionSync)
// otherwise, inline version takes priority
return version || require(`../packages/${pkg}/package.json`).version
} catch (e) {}
}
)
// const updated = fs.readFileSync(filePath, 'utf-8')
// // update @vue packages in this repo
// .replace(localPackageRE, localReplacer)
// // also update vue, vue-template-compiler, vuex, vue-router
// .replace(updatedRE, remoteReplacer)
const remoteReplacer = makeReplacer(getRemoteVersionSync)
// if (isUpdated) {
// bufferWrite(filePath, updated)
// }
// })
const updated = fs.readFileSync(filePath, 'utf-8')
// update @vue packages in this repo
.replace(localPackageRE, localReplacer)
// also update vue, vue-template-compiler, vuex, vue-router
.replace(updatedRE, remoteReplacer)
if (isUpdated) {
bufferWrite(filePath, updated)
}
})
if (!Object.keys(writeCache).length) {
return console.log(`All packages up-to-date.`)