1
1
const chalk = require ( 'chalk' )
2
+ const custom = require ( '../customcolors' )
3
+ const colorComment = custom . colorComment
4
+ const colorPrimitive = custom . colorPrimitive
5
+ const colorError = custom . colorError
2
6
3
- colorComment = comment => chalk . gray ( comment )
4
-
5
- colorPrimitive = primitive => chalk . magentaBright ( primitive )
6
7
7
8
const SILENT = {
8
9
category : 'Global Config' ,
@@ -18,12 +19,12 @@ const OPTION_MERGE_STRATEGIES = {
18
19
type : '{ [key: string]: Function }' ,
19
20
default : '{}' ,
20
21
usage : `Vue.config.optionMergeStrategies._my_option = ${ chalk . magentaBright ( 'function' ) } (parent,child,vm){
21
- ${ chalk . magentaBright ( 'return' ) } child + 1
22
+ ${ chalk . magentaBright ( 'return' ) } child + ${ colorPrimitive ( '1' ) }
22
23
}
23
24
${ chalk . magentaBright ( 'const' ) } Profile = Vue.extend({
24
- _my_option: 1
25
+ _my_option: ${ colorPrimitive ( '1' ) }
25
26
})
26
- // Profile.options._my_option = 2\n` ,
27
+ ${ colorComment ( " // Profile.options._my_option = 2" ) } \n` ,
27
28
details : `Define custom merging strategies for options.
28
29
The merge strategy receives the value of that option defined
29
30
on the parent and child instances as the first and second arguments,
@@ -34,7 +35,7 @@ const DEVTOOLS = {
34
35
name : 'devtools' ,
35
36
type : 'boolean' ,
36
37
default : `true ${ chalk . white ( '(' ) } false ${ chalk . white ( 'in production builds)' ) } ` ,
37
- usage : `// make sure to set this synchronously immediately after loading Vue
38
+ usage : `${ colorComment ( " // make sure to set this synchronously immediately after loading Vue" ) }
38
39
Vue.config.devtools = ${ chalk . magentaBright ( 'true' ) } ` ,
39
40
details : `Check whether to allow ${ chalk . green ( 'vue-devtools' ) } inspection.
40
41
This option's default value is ${ chalk . magentaBright ( 'true' ) } in development builds and ${ chalk . magentaBright ( 'false' ) } in production builds.
@@ -46,9 +47,9 @@ const ERROR_HANDLER = {
46
47
type : 'Function' ,
47
48
default : 'undefined' ,
48
49
usage : `Vue.config.errorHandler = ${ chalk . magentaBright ( 'function' ) } (err,vm,info){
49
- // handle error
50
- // 'info' is a Vue-specific error info, e.g. which lifecycle hook
51
- // the error was found in. Only available in 2.2.0+
50
+ ${ colorComment ( " // handle error" ) }
51
+ ${ colorComment ( " // 'info' is a Vue-specific error info, e.g. which lifecycle hook" ) }
52
+ ${ colorComment ( " // the error was found in. Only available in 2.2.0+" ) }
52
53
}` ,
53
54
details : `Assign a handler for uncaught errors during component render function
54
55
and watchers. The handler gets called with the error and the Vue instance.`
@@ -59,8 +60,8 @@ const WARN_HANDLER = {
59
60
name : 'warnHandler' ,
60
61
type : 'Function' ,
61
62
default : 'undefined' ,
62
- usage : `Vue.config.warnHandler = ${ chalk . magentaBright ( 'function' ) } (msg, vm, trace) {
63
- // trace is the component hierarchy trace
63
+ usage : `Vue.config.warnHandler = ${ chalk . magentaBright ( 'function' ) } (msg,vm,trace){
64
+ ${ colorComment ( " // trace is the component hierarchy trace" ) }
64
65
}` ,
65
66
details : `Assign a custom handler for runtime Vue warnings. Note this only works
66
67
during development and is ignored in production.`
@@ -75,7 +76,7 @@ const IGNORED_ELEMENTS = {
75
76
]` ,
76
77
details : `Make Vue ignore custom elements defined outside of Vue
77
78
(e.g., using the Web Components APIs). Otherwise, it will throw
78
- a warning about an ${ chalk . magentaBright ( ' Unknown custom element' ) } , assuming that you forgot to
79
+ a warning about an ${ colorError ( " Unknown custom element" ) } , assuming that you forgot to
79
80
register a global component or misspelled a component name.`
80
81
}
81
82
@@ -99,53 +100,26 @@ const KEY_CODES = {
99
100
details : 'Define custom key alias(es) for v-on.'
100
101
}
101
102
102
- /*const SILENT = {
103
- category: 'Global Config',
104
- name: '#silent',
105
- type: 'boolean',
106
- default: 'false',
107
- arguments: '',
108
- readOption: '',
109
- usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
110
- details: 'Suppress all Vue logs and warnings',
111
- example: ''
112
- }
113
- const SILENT = {
114
- category: 'Global Config',
115
- name: '#silent',
116
- type: 'boolean',
117
- default: 'false',
118
- arguments: '',
119
- readOption: '',
120
- usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
121
- details: 'Suppress all Vue logs and warnings',
122
- example: ''
123
- }
124
-
125
- const SILENT = {
103
+ const PERFORMANCE = {
126
104
category : 'Global Config' ,
127
- name: '#silent ',
105
+ name : 'performance ' ,
128
106
type : 'boolean' ,
129
- default: 'false',
130
- arguments: '' ,
131
- readOption: '' ,
132
- usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
133
- details: 'Suppress all Vue logs and warnings',
134
- example: ''
107
+ default : 'false (from 2.2.3) ' ,
108
+ usage : `Vue.config.performance = ${ chalk . magentaBright ( 'true' ) } ` ,
109
+ details : `Set this to ${ colorPrimitive ( "true" ) } to enable component init, compile ,
110
+ render, and patch performance in the browser devtool timeline.
111
+ Only works in development mode and in browsers that support the
112
+ ${ chalk . green ( "performance.mark" ) } API.` ,
135
113
}
136
-
137
- const SILENT = {
114
+ const PRODUCTION_TIP = {
138
115
category : 'Global Config' ,
139
- name: '#silent ',
116
+ name : 'productionTip ' ,
140
117
type : 'boolean' ,
141
- default: 'false',
142
- arguments: '',
143
- readOption: '',
144
- usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
145
- details: 'Suppress all Vue logs and warnings',
146
- example: ''
118
+ default : 'true' ,
119
+ usage : `Vue.config.productionTip = ${ chalk . magentaBright ( 'false' ) } ` ,
120
+ details : `Set this to ${ colorPrimitive ( "false" ) } to prevent the production
121
+ tip on Vue startup.`
147
122
}
148
- */
149
123
150
124
module . exports = {
151
125
SILENT ,
@@ -154,5 +128,7 @@ module.exports = {
154
128
ERROR_HANDLER ,
155
129
WARN_HANDLER ,
156
130
IGNORED_ELEMENTS ,
157
- KEY_CODES
131
+ KEY_CODES ,
132
+ PERFORMANCE ,
133
+ PRODUCTION_TIP
158
134
}
0 commit comments