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 all commits
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
11 changes: 8 additions & 3 deletions bin/vue-init
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var request = require('request')
var logger = require('../lib/logger')
var generate = require('../lib/generate')
var checkVersion = require('../lib/check-version')
var vue2VersionWarn = require('../lib/vue2-version-warn')

/**
* Usage.
Expand Down Expand Up @@ -100,11 +101,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') {
vue2VersionWarn(template, inPlace ? '' : name)
}
checkDistBranch(officialTemplate, downloadAndGenerate)
}
} else {
downloadAndGenerate(template)
Expand Down
10 changes: 10 additions & 0 deletions lib/vue2-version-warn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var chalk = require('chalk')

module.exports = function (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 only add the name to this string if it's false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking doing this on call site:

vue2VersionWarn(template, inPlace ? '' : name)

Copy link
Contributor

Choose a reason for hiding this comment

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

That works. 👍


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()
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down