-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Warn user about Vue 2.x template. #162
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- don't warn for webpack template since it's not yet in master/dist branch.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the addition of |
||
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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also pass in |
||
|
||
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 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering if it would be better to just create a new file for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love destructuring too, 😃 but it's unfortunately only available in Node 6+ and I believe we're supporting down to v4.