From 793fc556b3e0d50f15b04fa3fd67fbfebc8fe3f2 Mon Sep 17 00:00:00 2001 From: zigomir Date: Mon, 5 Sep 2016 09:43:17 -0700 Subject: [PATCH 1/3] Warn user about Vue 2.x template. - don't warn for webpack template since it's not yet in master/dist branch. --- bin/vue-init | 12 ++++++++---- lib/check-version.js | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/bin/vue-init b/bin/vue-init index 1eec8e0f43..c66feccfa9 100755 --- a/bin/vue-init +++ b/bin/vue-init @@ -12,7 +12,7 @@ var inquirer = require('inquirer') var request = require('request') var logger = require('../lib/logger') var generate = require('../lib/generate') -var checkVersion = require('../lib/check-version') +var { checkVersion, warnForVue2Version } = require('../lib/check-version') /** * Usage. @@ -100,11 +100,15 @@ function run () { checkVersion(function () { if (!hasSlash) { // use official templates - template = 'vuejs-templates/' + template + var officialTemplate = 'vuejs-templates/' + template if (template.indexOf('#') !== -1) { - downloadAndGenerate(template) + downloadAndGenerate(officialTemplate) } else { - checkDistBranch(template, downloadAndGenerate) + // until official webpack template for Vue 2.0 is released in master/dist branch + if (template !== 'webpack') { + warnForVue2Version(template, name) + } + checkDistBranch(officialTemplate, downloadAndGenerate) } } else { downloadAndGenerate(template) diff --git a/lib/check-version.js b/lib/check-version.js index d8780c370e..05d6c42545 100644 --- a/lib/check-version.js +++ b/lib/check-version.js @@ -3,7 +3,7 @@ var semver = require('semver') var chalk = require('chalk') var packageConfig = require('../package.json') -module.exports = function (done) { +function checkVersion (done) { // Parse version number from strings such as 'v4.2.0' or `>=4.0.0' function parseVersionNumber (versionString) { return parseFloat(versionString.replace(/[^\d\.]/g, '')) @@ -36,3 +36,17 @@ module.exports = function (done) { done() }) } + +function warnForVue2Version (template, name) { + var vue1InitCommand = 'vue init ' + template + '#1.0' + ' ' + name + + console.log(chalk.red(' This will install Vue 2.x version of template.')) + console.log() + console.log(chalk.yellow(' For Vue 1.x use: ') + chalk.green(vue1InitCommand)) + console.log() +} + +module.exports = { + checkVersion: checkVersion, + warnForVue2Version: warnForVue2Version +} From 2c9df9741069c5c18566f44c5228fd0d3ad21c13 Mon Sep 17 00:00:00 2001 From: zigomir Date: Mon, 5 Sep 2016 10:55:13 -0700 Subject: [PATCH 2/3] Extract to vue2-version-warn file. --- bin/vue-init | 5 +++-- lib/check-version.js | 16 +--------------- lib/vue2-version-warn.js | 10 ++++++++++ 3 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 lib/vue2-version-warn.js diff --git a/bin/vue-init b/bin/vue-init index c66feccfa9..71b02eecc0 100755 --- a/bin/vue-init +++ b/bin/vue-init @@ -12,7 +12,8 @@ var inquirer = require('inquirer') var request = require('request') var logger = require('../lib/logger') var generate = require('../lib/generate') -var { checkVersion, warnForVue2Version } = require('../lib/check-version') +var checkVersion = require('../lib/check-version') +var vue2VersionWarn = require('../lib/vue2-version-warn') /** * Usage. @@ -106,7 +107,7 @@ function run () { } else { // until official webpack template for Vue 2.0 is released in master/dist branch if (template !== 'webpack') { - warnForVue2Version(template, name) + vue2VersionWarn(template, name) } checkDistBranch(officialTemplate, downloadAndGenerate) } diff --git a/lib/check-version.js b/lib/check-version.js index 05d6c42545..d8780c370e 100644 --- a/lib/check-version.js +++ b/lib/check-version.js @@ -3,7 +3,7 @@ var semver = require('semver') var chalk = require('chalk') var packageConfig = require('../package.json') -function checkVersion (done) { +module.exports = function (done) { // Parse version number from strings such as 'v4.2.0' or `>=4.0.0' function parseVersionNumber (versionString) { return parseFloat(versionString.replace(/[^\d\.]/g, '')) @@ -36,17 +36,3 @@ function checkVersion (done) { done() }) } - -function warnForVue2Version (template, name) { - var vue1InitCommand = 'vue init ' + template + '#1.0' + ' ' + name - - console.log(chalk.red(' This will install Vue 2.x version of template.')) - console.log() - console.log(chalk.yellow(' For Vue 1.x use: ') + chalk.green(vue1InitCommand)) - console.log() -} - -module.exports = { - checkVersion: checkVersion, - warnForVue2Version: warnForVue2Version -} diff --git a/lib/vue2-version-warn.js b/lib/vue2-version-warn.js new file mode 100644 index 0000000000..b98277cb9a --- /dev/null +++ b/lib/vue2-version-warn.js @@ -0,0 +1,10 @@ +var chalk = require('chalk') + +module.exports = function (template, name) { + var vue1InitCommand = 'vue init ' + template + '#1.0' + ' ' + name + + console.log(chalk.red(' This will install Vue 2.x version of template.')) + console.log() + console.log(chalk.yellow(' For Vue 1.x use: ') + chalk.green(vue1InitCommand)) + console.log() +} From 7bc6713942fa5ab5a8e6d9a67208f3bbdeb5c330 Mon Sep 17 00:00:00 2001 From: zigomir Date: Mon, 5 Sep 2016 11:05:30 -0700 Subject: [PATCH 3/3] Bump version and use inPlace for better message. --- bin/vue-init | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/vue-init b/bin/vue-init index 71b02eecc0..08c120dd68 100755 --- a/bin/vue-init +++ b/bin/vue-init @@ -107,7 +107,7 @@ function run () { } else { // until official webpack template for Vue 2.0 is released in master/dist branch if (template !== 'webpack') { - vue2VersionWarn(template, name) + vue2VersionWarn(template, inPlace ? '' : name) } checkDistBranch(officialTemplate, downloadAndGenerate) } diff --git a/package.json b/package.json index 67fd077cff..a9a926574d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-cli", - "version": "2.2.0", + "version": "2.3.0", "description": "A simple CLI for scaffolding Vue.js projects.", "preferGlobal": true, "bin": {