Skip to content

Commit fbd592e

Browse files
authored
feat: add vue outdated command & make vue upgrade interactive (#4497)
1 parent 8f2d470 commit fbd592e

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

packages/@vue/cli/bin/vue.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ program
166166
require('../lib/config')(value, cleanArgs(cmd))
167167
})
168168

169+
program
170+
.command('outdated')
171+
.description('(experimental) check for outdated vue cli service / plugins')
172+
.option('--next', 'Also check for alpha / beta / rc versions when upgrading')
173+
.action((cmd) => {
174+
require('../lib/outdated')(cleanArgs(cmd))
175+
})
176+
169177
program
170178
.command('upgrade [plugin-name]')
171179
.description('(experimental) upgrade vue cli service / plugins')

packages/@vue/cli/lib/Upgrader.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ module.exports = class Upgrader {
257257
console.log(' ' + fields.map((x, i) => x.padEnd(pads[i])).join(''))
258258
}
259259

260-
console.log(`Run ${chalk.yellow('vue upgrade --all')} to upgrade all the above plugins`)
261-
262260
return upgradable
263261
}
264262
}

packages/@vue/cli/lib/outdated.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { error } = require('@vue/cli-shared-utils')
2+
3+
const Upgrader = require('./Upgrader')
4+
5+
async function outdated (options, context = process.cwd()) {
6+
const upgrader = new Upgrader(context)
7+
return upgrader.checkForUpdates(options.next)
8+
}
9+
10+
module.exports = (...args) => {
11+
return outdated(...args).catch(err => {
12+
error(err)
13+
if (!process.env.VUE_CLI_TEST) {
14+
process.exit(1)
15+
}
16+
})
17+
}

packages/@vue/cli/lib/upgrade.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const inquirer = require('inquirer')
12
const { error } = require('@vue/cli-shared-utils')
23

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

23-
return upgrader.checkForUpdates(options.next)
24+
const upgradable = await upgrader.checkForUpdates(options.next)
25+
if (upgradable) {
26+
const { ok } = await inquirer.prompt([
27+
{
28+
name: 'ok',
29+
type: 'confirm',
30+
message: 'Continue to upgrade these plugins?',
31+
default: true
32+
}
33+
])
34+
35+
if (ok) {
36+
return upgrader.upgradeAll(options.next)
37+
}
38+
}
39+
40+
return
2441
}
2542

2643
return upgrader.upgrade(packageName, options)

0 commit comments

Comments
 (0)