Skip to content

Commit 4e806bc

Browse files
author
User
committed
added API
1 parent 864edcf commit 4e806bc

File tree

3 files changed

+130
-15
lines changed

3 files changed

+130
-15
lines changed

API.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const G_C = require('./globalconfig/globalconfig')
2-
const SILENT = G_C.SILENT
32

43
const GlobalConfig = [
5-
SILENT
4+
G_C.SILENT,
5+
G_C.OPTION_MERGE_STRATEGIES,
6+
G_C.DEVTOOLS
67
]
78

89

globalconfig/globalconfig.js

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,87 @@
11
const chalk = require('chalk')
2+
const SILENT = {
3+
category: 'Global Config',
4+
name: '#silent',
5+
type: 'boolean',
6+
default: 'false',
7+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
8+
details: 'Suppress all Vue logs and warnings',
9+
}
10+
const OPTION_MERGE_STRATEGIES = {
11+
category: 'Global Config',
12+
name: '#optionMergeStrategies',
13+
type: '{ [key: string]: Function }',
14+
default: '{}',
15+
usage: `Vue.config.optionMergeStrategies._my_option = ${chalk.magentaBright('function')} (parent, child, vm) {
16+
${chalk.magentaBright('return')} child + 1
17+
}
18+
${chalk.magentaBright('const')} Profile = Vue.extend({
19+
_my_option: 1
20+
})
21+
// Profile.options._my_option = 2\n`,
22+
details: `Define custom merging strategies for options.
23+
The merge strategy receives the value of that option defined
24+
on the parent and child instances as the first and second arguments, respectively.
25+
The context Vue instance is passed as the third argument.`
26+
}
27+
const DEVTOOLS = {
28+
category: 'Global Config',
29+
name: '#devtools',
30+
type: 'boolean',
31+
default: `true ${chalk.white('(')} false ${chalk.white('in production builds)')}`,
32+
usage: `// make sure to set this synchronously immediately after loading Vue
33+
Vue.config.devtools = ${chalk.magentaBright('true')}`,
34+
details: `Check whether to allow ${chalk.green('vue-devtools')} inspection.
35+
This option's default value is ${chalk.magentaBright('true')} in development builds and ${chalk.magentaBright('false')} in production builds.
36+
You can set it to ${chalk.magentaBright('true')} to enable inspection for production builds`
37+
}
38+
/*const SILENT = {
39+
category: 'Global Config',
40+
name: '#silent',
41+
type: 'boolean',
42+
default: 'false',
43+
arguments: '',
44+
readOption: '',
45+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
46+
details: 'Suppress all Vue logs and warnings',
47+
example: ''
48+
}
49+
50+
const SILENT = {
51+
category: 'Global Config',
52+
name: '#silent',
53+
type: 'boolean',
54+
default: 'false',
55+
arguments: '',
56+
readOption: '',
57+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
58+
details: 'Suppress all Vue logs and warnings',
59+
example: ''
60+
}
61+
62+
const SILENT = {
63+
category: 'Global Config',
64+
name: '#silent',
65+
type: 'boolean',
66+
default: 'false',
67+
arguments: '',
68+
readOption: '',
69+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
70+
details: 'Suppress all Vue logs and warnings',
71+
example: ''
72+
}
73+
74+
const SILENT = {
75+
category: 'Global Config',
76+
name: '#silent',
77+
type: 'boolean',
78+
default: 'false',
79+
arguments: '',
80+
readOption: '',
81+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
82+
details: 'Suppress all Vue logs and warnings',
83+
example: ''
84+
}
285
const SILENT = {
386
category: 'Global Config',
487
name: '#silent',
@@ -11,7 +94,33 @@ const SILENT = {
1194
example: ''
1295
}
1396
97+
const SILENT = {
98+
category: 'Global Config',
99+
name: '#silent',
100+
type: 'boolean',
101+
default: 'false',
102+
arguments: '',
103+
readOption: '',
104+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
105+
details: 'Suppress all Vue logs and warnings',
106+
example: ''
107+
}
108+
109+
const SILENT = {
110+
category: 'Global Config',
111+
name: '#silent',
112+
type: 'boolean',
113+
default: 'false',
114+
arguments: '',
115+
readOption: '',
116+
usage: `Vue.config.silent = ${chalk.magentaBright('true')}`,
117+
details: 'Suppress all Vue logs and warnings',
118+
example: ''
119+
}
120+
*/
14121

15122
module.exports = {
16-
SILENT
123+
SILENT,
124+
OPTION_MERGE_STRATEGIES,
125+
DEVTOOLS
17126
}

vue-help.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
const V = require('vorpal')()
2-
const api = require('./API')
32
const LGC = require('./logfunctions/logglobalconfig')
3+
const api = require('./API')
44
const gc = api.GlobalConfig
55

66

7-
87
V.delimiter('vue-help$').show()
8+
9+
910
V.command('silent', 'Outputs').action(function(args, callback){
10-
const s = gc[0]
11-
this.log(LGC.logGlobalConfig(s))
12-
/*this.log(`
13-
Category: ${s.category}
14-
Name: ${s.name + '\n'}
15-
* Type: ${s.type}
16-
* Default: ${s.default}
17-
* Usage: ${s.usage}
18-
* Details: ${s.details}
19-
`)*/
11+
const silent= gc[0]
12+
this.log(LGC.logGlobalConfig(silent))
13+
callback()
14+
})
15+
16+
V.command('optionMergeStrategies', 'Outputs').action(function(args, callback){
17+
const optMergeStrat = gc[1]
18+
this.log(LGC.logGlobalConfig(optMergeStrat))
19+
callback()
20+
})
21+
22+
V.command('devtools', 'Outputs').action(function(args, callback){
23+
const devtools = gc[2]
24+
this.log(LGC.logGlobalConfig(devtools))
2025
callback()
2126
})

0 commit comments

Comments
 (0)