Skip to content

Commit

Permalink
feat!: redesigns vue upgrade, supports code migration (#4090)
Browse files Browse the repository at this point in the history
  • Loading branch information
sodatea committed Jul 2, 2019
1 parent 273d05f commit 867c6ea
Show file tree
Hide file tree
Showing 29 changed files with 619 additions and 304 deletions.
26 changes: 26 additions & 0 deletions packages/@vue/cli-plugin-babel/migrator/index.js
@@ -0,0 +1,26 @@
const { chalk } = require('@vue/cli-shared-utils')

module.exports = (api) => {
// TODO: backport this part to v3
// if (api.fromVersion('<=3.5.3')) {
// // add core-js@2 as dependency
// api.extendPackage({
// dependencies: {
// 'core-js': '^2.6.5'
// }
// })
// }

if (api.fromVersion('^3')) {
api.extendPackage({
dependencies: {
'core-js': '^3.1.2'
}
}, true)

// TODO: implement a codemod to migrate polyfills
api.exitLog(`core-js has been upgraded from v2 to v3.
If you have any custom polyfills defined in ${chalk.yellow('babael.config.js')}, please be aware their names may have been changed.
For more complete changelog, see https://github.com/zloirock/core-js/blob/master/CHANGELOG.md#300---20190319`)
}
}
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-typescript/generator/index.js
Expand Up @@ -3,6 +3,7 @@ module.exports = (api, {
tsLint,
lintOn = []
}, _, invoking) => {
debugger
if (typeof lintOn === 'string') {
lintOn = lintOn.split(',')
}
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-shared-utils/index.js
Expand Up @@ -17,3 +17,4 @@

exports.chalk = require('chalk')
exports.execa = require('execa')
exports.semver = require('semver')
4 changes: 4 additions & 0 deletions packages/@vue/cli-shared-utils/lib/spinner.js
Expand Up @@ -43,6 +43,10 @@ exports.resumeSpinner = () => {
spinner.start()
}

exports.failSpinner = (text) => {
spinner.fail(text)
}

// silent all logs except errors during tests and keep record
if (process.env.VUE_CLI_TEST) {
require('./_silence')('spinner', exports)
Expand Down
8 changes: 4 additions & 4 deletions packages/@vue/cli-ui/apollo-server/connectors/dependencies.js
Expand Up @@ -211,7 +211,7 @@ function install ({ id, type, range }, context) {
arg = id
}

await installPackage(cwd.get(), getCommand(cwd.get()), null, arg, type === 'devDependencies')
await installPackage(cwd.get(), getCommand(cwd.get()), arg, type === 'devDependencies')

logs.add({
message: `Dependency ${id} installed`,
Expand Down Expand Up @@ -239,7 +239,7 @@ function uninstall ({ id }, context) {

const dep = findOne(id, context)

await uninstallPackage(cwd.get(), getCommand(cwd.get()), null, id)
await uninstallPackage(cwd.get(), getCommand(cwd.get()), id)

logs.add({
message: `Dependency ${id} uninstalled`,
Expand All @@ -265,7 +265,7 @@ function update ({ id }, context) {

const dep = findOne(id, context)
const { current, wanted } = await getVersion(dep, context)
await updatePackage(cwd.get(), getCommand(cwd.get()), null, id)
await updatePackage(cwd.get(), getCommand(cwd.get()), id)

logs.add({
message: `Dependency ${id} updated from ${current} to ${wanted}`,
Expand Down Expand Up @@ -310,7 +310,7 @@ function updateAll (context) {
args: [updatedDeps.length]
})

await updatePackage(cwd.get(), getCommand(cwd.get()), null, updatedDeps.map(
await updatePackage(cwd.get(), getCommand(cwd.get()), updatedDeps.map(
p => p.id
).join(' '))

Expand Down
8 changes: 4 additions & 4 deletions packages/@vue/cli-ui/apollo-server/connectors/plugins.js
Expand Up @@ -334,7 +334,7 @@ function install (id, context) {
if (process.env.VUE_CLI_DEBUG && isOfficialPlugin(id)) {
mockInstall(id, context)
} else {
await installPackage(cwd.get(), getCommand(cwd.get()), null, id)
await installPackage(cwd.get(), getCommand(cwd.get()), id)
}
await initPrompts(id, context)
installationStep = 'config'
Expand Down Expand Up @@ -412,7 +412,7 @@ function uninstall (id, context) {
if (process.env.VUE_CLI_DEBUG && isOfficialPlugin(id)) {
mockUninstall(id, context)
} else {
await uninstallPackage(cwd.get(), getCommand(cwd.get()), null, id)
await uninstallPackage(cwd.get(), getCommand(cwd.get()), id)
}
currentPluginId = null
installationStep = null
Expand Down Expand Up @@ -520,7 +520,7 @@ function update ({ id, full }, context) {
if (localPath) {
await updateLocalPackage({ cwd: cwd.get(), id, localPath, full }, context)
} else {
await updatePackage(cwd.get(), getCommand(cwd.get()), null, id)
await updatePackage(cwd.get(), getCommand(cwd.get()), id)
}

logs.add({
Expand Down Expand Up @@ -583,7 +583,7 @@ async function updateAll (context) {
args: [updatedPlugins.length]
})

await updatePackage(cwd.get(), getCommand(cwd.get()), null, updatedPlugins.map(
await updatePackage(cwd.get(), getCommand(cwd.get()), updatedPlugins.map(
p => p.id
).join(' '))

Expand Down
3 changes: 0 additions & 3 deletions packages/@vue/cli-upgrade/bin/vue-cli-upgrade.js

This file was deleted.

38 changes: 0 additions & 38 deletions packages/@vue/cli-upgrade/get-upgradable-version.js

This file was deleted.

153 changes: 0 additions & 153 deletions packages/@vue/cli-upgrade/index.js

This file was deleted.

30 changes: 0 additions & 30 deletions packages/@vue/cli-upgrade/package.json

This file was deleted.

0 comments on commit 867c6ea

Please sign in to comment.