Skip to content

Commit

Permalink
feat: add vue outdated command & make vue upgrade interactive (vu…
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang authored Sep 2, 2019
1 parent 8f2d470 commit fbd592e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
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: true
}
])

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

return
}

return upgrader.upgrade(packageName, options)
Expand Down

0 comments on commit fbd592e

Please sign in to comment.