8000 feat: implement vue upgrade by haoqunjiang · Pull Request #2428 · vuejs/vue-cli · GitHub
[go: up one dir, main page]

Skip to content

feat: implement vue upgrade #2428

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

Merged
merged 3 commits into from
Oct 30, 2018
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 upgrade command
  • Loading branch information
haoqunjiang committed Aug 31, 2018
commit fbac28b60cca241b7f2a1bd391e94432bfaf629e
3 changes: 3 additions & 0 deletions packages/@vue/cli-upgrade/bin/vue-cli-upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const vueCliUpgrade = require('../index')

vueCliUpgrade()
3 changes: 3 additions & 0 deletions packages/@vue/cli-upgrade/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function vueCliUpgrade () {
console.log('TBD')
}
22 changes: 22 additions & 0 deletions packages/@vue/cli-upgrade/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@vue/cli-upgrade",
"version": "3.0.1",
"description": "utility to upgrade vue cli service / plugins in vue apps",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vue-cli.git"
},
"keywords": [
"vue",
"cli",
"upgrade",
"update"
],
"author": "Haoqun Jiang <haoqunjiang+npm@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/vue-cli/issues"
},
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-upgrade#readme"
}
13 changes: 12 additions & 1 deletion packages/@vue/cli/bin/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ program
require('../lib/config')(value, cleanArgs(cmd))
})

program
.command('upgrade [semverLevel]')
.description('upgrade vue cli service / plugins (default semverLevel: minor)')
.action((semverLevel, cmd) => {
loadCommand('upgrade', '@vue/cli-upgrade')(semverLevel, cleanArgs(cmd))
})

// output help information on unknown commands
program
.arguments('<command>')
Expand Down Expand Up @@ -186,12 +193,16 @@ if (!process.argv.slice(2).length) {
program.outputHelp()
}

function camelize (str) {
return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : '')
}

// commander passes the Command object itself as options,
// extract only actual options into a fresh object.
function cleanArgs (cmd) {
const args = {}
cmd.options.forEach(o => {
const key = o.long.replace(/^--/, '')
const key = camelize(o.long.replace(/^--/, ''))
// if an option is not present and Command has a method with the same name
// it should not be copied
if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@vue/cli-shared-utils": "^3.0.1",
"@vue/cli-ui": "^3.0.1",
"@vue/cli-ui-addon-webpack": "^3.0.1",
"@vue/cli-upgrade": "^3.0.1",
"chalk": "^2.4.1",
"cmd-shim": "^2.0.2",
"commander": "^2.16.0",
Expand Down
0