mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-23 19:41:22 -05:00
feat: add vue outdated command & make vue upgrade interactive (#4497)
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
packages/@vue/cli/lib/outdated.js
Normal file
17
packages/@vue/cli/lib/outdated.js
Normal file
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
const inquirer = require('inquirer')
|
||||
const { error } = require('@vue/cli-shared-utils')
|
||||
|
||||
const Upgrader = require('./Upgrader')
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user