Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vue outdated command & make vue upgrade interactive #4497

Merged
merged 2 commits into from
Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add vue outdated command & make vue upgrade interactive
  • Loading branch information
haoqunjiang committed Aug 24, 2019
commit 3d7af8a898be213a2568833e7827a8dbe2583c7a
8 changes: 8 additions & 0 deletions packages/@vue/cli/bin/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ program
require('../lib/config')(value, cleanArgs(cmd))
})

program
.command('outdated')
.description('(experimental) check for outdated vue cli service / plugins')
.option('--next', 'Also check for alpha / beta / rc versions when upgrading')
.action((cmd) => {
require('../lib/outdated')(cleanArgs(cmd))
})

program
.command('upgrade [plugin-name]')
.description('(experimental) upgrade vue cli service / plugins')
Expand Down
2 changes: 0 additions & 2 deletions packages/@vue/cli/lib/Upgrader.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ module.exports = class Upgrader {
console.log(' ' + fields.map((x, i) => x.padEnd(pads[i])).join(''))
}

console.log(`Run ${chalk.yellow('vue upgrade --all')} to upgrade all the above plugins`)

return upgradable
}
}
17 changes: 17 additions & 0 deletions packages/@vue/cli/lib/outdated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { error } = require('@vue/cli-shared-utils')

const Upgrader = require('./Upgrader')

async function outdated (options, context = process.cwd()) {
const upgrader = new Upgrader(context)
return upgrader.checkForUpdates(options.next)
}

module.exports = (...args) => {
return outdated(...args).catch(err => {
error(err)
if (!process.env.VUE_CLI_TEST) {
process.exit(1)
}
})
}
19 changes: 18 additions & 1 deletion packages/@vue/cli/lib/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const inquirer = require('inquirer')
const { error } = require('@vue/cli-shared-utils')

const Upgrader = require('./Upgrader')
Expand All @@ -20,7 +21,23 @@ async function upgrade (packageName, options, context = process.cwd()) {
return upgrader.upgradeAll(options.next)
}

return upgrader.checkForUpdates(options.next)
const upgradable = await upgrader.checkForUpdates(options.next)
if (upgradable) {
const { ok } = await inquirer.prompt([
{
name: 'ok',
type: 'confirm',
message: 'Continue to upgrade these plugins?',
default: false
}
])

if (ok) {
return upgrader.upgradeAll(options.next)
}
}

return
}

return upgrader.upgrade(packageName, options)
Expand Down