10000 Warn user about Vue 2.x template. by zigomir · Pull Request #162 · vuejs/vue-cli · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 3 commits into from
Sep 6, 2016
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
Warn user about Vue 2.x template.
- don't warn for webpack template since it's not yet in master/dist branch.
  • Loading branch information
zigomir committed Sep 5, 2016
commit 793fc556b3e0d50f15b04fa3fd67fbfebc8fe3f2
12 changes: 8 additions & 4 deletions bin/vue-init
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Contributor
10000

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.


/**
* Usage.
Expand Down Expand Up @@ -100,11 +100,15 @@ function run () {
checkVersion(function () {
if (!hasSlash) {
// use official templates
template = 'vuejs-templates/' + template
var officialTemplate = 'vuejs-templates/' + template
Copy link
Contributor
@chrisvfritz chrisvfritz Sep 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the addition of officialTemplate! Makes the code a bit clearer and keeps the value of template more predictable as exactly what the user entered or the computed working directory. 👍

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)
Expand Down
16 changes: 15 additions & 1 deletion lib/check-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ''))
Expand Down Expand Up @@ -36,3 +36,17 @@ module.exports = function (done) {
done()
})
}

function warnForVue2Version (template, name) {
var vue1InitCommand = 'vue init ' + template + '#1.0' + ' ' + name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also pass in inPlace and then only show the name in the command if it's false?


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
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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 warnForVue2Version. It doesn't have anything to do with checking the node version, so having it in here might make it difficult to find in a quick search. What do you think?

0