Skip to content

Commit b67f9bc

Browse files
committed
finalize cli output
1 parent 4045a0f commit b67f9bc

File tree

6 files changed

+34
-16
lines changed

6 files changed

+34
-16
lines changed

packages/@vue/cli-service/generator/files/src/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Vue from 'vue'
22
import App from './App.vue'
33

4+
Vue.config.productionTip = false
5+
46
new Vue({
57
el: '#app',
68
render: h => h(App)

packages/@vue/cli-service/lib/command-plugins/help.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const chalk = require('chalk')
22
const padEnd = require('string.prototype.padend')
3+
const getPadLength = require('../util/getPadLength')
34

45
module.exports = (api, options) => {
56
api.registerCommand('help', args => {
@@ -17,7 +18,7 @@ module.exports = (api, options) => {
1718
`\n Commands:\n`
1819
)
1920
const commands = api.service.commands
20-
const padLength = getLongest(commands)
21+
const padLength = getPadLength(commands)
2122
for (const name in commands) {
2223
if (name !== 'help') {
2324
const opts = commands[name].opts || {}
@@ -43,7 +44,7 @@ module.exports = (api, options) => {
4344
}
4445
if (opts.options) {
4546
console.log(`\n Options:\n`)
46-
const padLength = getLongest(opts.options)
47+
const padLength = getPadLength(opts.options)
4748
for (const name in opts.options) {
4849
console.log(` ${
4950
chalk.blue(padEnd(name, padLength))
@@ -56,13 +57,3 @@ module.exports = (api, options) => {
5657
}
5758
}
5859
}
59-
60-
function getLongest (commands) {
61-
let longest = 10
62-
for (const name in commands) {
63-
if (name.length + 1 > longest) {
64-
longest = name.length + 1
65-
}
66-
}
67-
return longest
68-
}

packages/@vue/cli-service/lib/command-plugins/serve.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { info, error } = require('@vue/cli-shared-utils')
1+
const { info, error, hasYarn } = require('@vue/cli-shared-utils')
22

33
module.exports = (api, options) => {
44
api.registerCommand('serve', {
@@ -73,9 +73,10 @@ module.exports = (api, options) => {
7373

7474
if (isFirstCompile) {
7575
isFirstCompile = false
76+
const buildCommand = hasYarn ? `yarn build` : `npm run build`
7677
console.log([
7778
` Note that the development build is not optimized.`,
78-
` To create a production build, run ${chalk.cyan(`npm run build`)} or ${chalk.cyan(`yarn build`)}.`
79+
` To create a production build, run ${chalk.cyan(buildCommand)}.`
7980
].join('\n'))
8081
console.log()
8182

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = function getPadLength (obj) {
2+
let longest = 10
3+
for (const name in obj) {
4+
if (name.length + 1 > longest) {
5+
longest = name.length + 1
6+
}
7+
}
8+
return longest
9+
}

packages/@vue/cli-shared-utils/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ exports.error = (msg) => {
2828
}
2929
}
3030

31+
const cliVersion = require('@vue/cli/package.json').version
3132
exports.clearConsole = function () {
3233
if (process.stdout.isTTY) {
3334
process.stdout.write(
3435
process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H'
3536
)
37+
let title = chalk.bold.green(`Vue CLI v${cliVersion}`)
38+
if (process.env.VUE_CLI_DEBUG) {
39+
title += ' ' + chalk.bgRed(' DEBUG MODE ')
40+
}
41+
console.log(title)
42+
console.log()
3643
}
3744
}
3845

packages/@vue/cli/lib/Creator.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ module.exports = class Creator {
7676
debug('options')(options)
7777

7878
// write base package.json to disk
79-
logWithSpinner(emoji.get('sparkles'), `Creating project in ${chalk.green(targetDir)}.`)
79+
clearConsole()
80+
logWithSpinner(emoji.get('sparkles'), `Creating project in ${chalk.yellow(targetDir)}.`)
8081
writeFileTree(targetDir, {
8182
'package.json': JSON.stringify({
8283
name,
@@ -105,7 +106,14 @@ module.exports = class Creator {
105106
logWithSpinner(emoji.get('package'), `Installing additional dependencies...`)
106107
await installDeps(options.packageManager, targetDir)
107108
stopSpinner()
108-
console.log(`${chalk.green('✔')} Successfully created project ${chalk.green(name)}.`)
109+
console.log(`${chalk.green('✔')} Successfully created project ${chalk.yellow(name)}.`)
110+
console.log()
111+
console.log(
112+
`${emoji.get('point_right')} Get started with the following commands:\n\n` +
113+
chalk.cyan(` ${chalk.gray('$')} cd ${name}\n`) +
114+
chalk.cyan(` ${chalk.gray('$')} ${options.packageManager === 'yarn' ? 'yarn dev' : 'npm run dev'}`)
115+
)
116+
console.log()
109117
}
110118

111119
resolveIntroPrompts () {

0 commit comments

Comments
 (0)