|
1 |
| -const chalk = require("chalk"); |
2 |
| -const updateNotifier = require("update-notifier"); |
| 1 | +const chalk = require('chalk') |
| 2 | +const updateNotifier = require('update-notifier') |
3 | 3 |
|
4 |
| -const pkg = require("../package.json"); |
5 |
| -const run = require("../lib"); |
| 4 | +const pkg = require('../package.json') |
| 5 | +const run = require('../lib') |
6 | 6 |
|
7 |
| -updateNotifier({ pkg: pkg }).notify(); |
| 7 | +updateNotifier({pkg: pkg}).notify() |
8 | 8 |
|
9 |
| -const Locales = require("../tools/locales"); |
10 |
| -const y18n = new Locales(); |
| 9 | +const Locales = require('../tools/locales') |
| 10 | +const y18n = new Locales() |
11 | 11 |
|
12 |
| -require("yargonaut") |
13 |
| - .style("yellow", "required") |
14 |
| - .helpStyle("green") |
15 |
| - .errorsStyle("red.bold"); |
| 12 | +require('yargonaut') |
| 13 | + .style('yellow', 'required') |
| 14 | + .helpStyle('green') |
| 15 | + .errorsStyle('red.bold') |
16 | 16 |
|
17 |
| -const yargs = require("yargs") |
18 |
| - .demandCommand(1, chalk.red("[ERROR] 0 arguments passed. Please specify a command")) |
| 17 | +const yargs = require('yargs') |
| 18 | + .demandCommand(1, chalk.red('[ERROR] 0 arguments passed. Please specify a command')) |
19 | 19 | .strict()
|
20 | 20 | .recommendCommands()
|
21 |
| - .usage(chalk.bold(y18n.__("usage") + ": docsify <init|serve> <path>")) |
| 21 | + .usage(chalk.bold(y18n.__('usage') + ': docsify <init|serve> <path>')) |
22 | 22 | .command({
|
23 |
| - command: "init [path]", |
24 |
| - alias: "i", |
25 |
| - desc: chalk.gray(y18n.__("init")), |
| 23 | + command: 'init [path]', |
| 24 | + alias: 'i', |
| 25 | + desc: chalk.gray(y18n.__('init')), |
26 | 26 | builder: yargs =>
|
27 | 27 | yargs.options({
|
28 | 28 | local: {
|
29 |
| - alias: "l", |
| 29 | + alias: 'l', |
30 | 30 | default: false,
|
31 |
| - desc: chalk.gray(y18n.__("init.local")), |
| 31 | + desc: chalk.gray(y18n.__('init.local')), |
32 | 32 | nargs: 0,
|
33 | 33 | requiresArg: false,
|
34 |
| - type: "boolean" |
| 34 | + type: 'boolean' |
35 | 35 | },
|
36 | 36 | theme: {
|
37 |
| - alias: "t", |
38 |
| - default: "vue", |
39 |
| - desc: chalk.gray(y18n.__("init.theme")), |
40 |
| - choices: ["vue", "buble", "dark", "pure"], |
| 37 | + alias: 't', |
| 38 | + default: 'vue', |
| 39 | + desc: chalk.gray(y18n.__('init.theme')), |
| 40 | + choices: ['vue', 'buble', 'dark', 'pure'], |
41 | 41 | nargs: 1,
|
42 | 42 | requiresArg: true,
|
43 |
| - type: "string" |
| 43 | + type: 'string' |
44 | 44 | }
|
45 | 45 | }),
|
46 | 46 | handler: argv => run.init(argv.path, argv.local, argv.theme)
|
47 | 47 | })
|
48 | 48 | .command({
|
49 |
| - command: "serve [path]", |
50 |
| - alias: "s", |
51 |
| - desc: chalk.gray(y18n.__("serve")), |
| 49 | + command: 'serve [path]', |
| 50 | + alias: 's', |
| 51 | + desc: chalk.gray(y18n.__('serve')), |
52 | 52 | builder: yargs =>
|
53 | 53 | yargs.options({
|
54 | 54 | open: {
|
55 |
| - alias: "o", |
| 55 | + alias: 'o', |
56 | 56 | default: false,
|
57 |
| - desc: chalk.gray(y18n.__("serve.open")), |
| 57 | + desc: chalk.gray(y18n.__('serve.open')), |
58 | 58 | nargs: 0,
|
59 | 59 | requiresArg: false,
|
60 |
| - type: "boolean" |
| 60 | + type: 'boolean' |
61 | 61 | },
|
62 | 62 | port: {
|
63 |
| - alias: "p", |
| 63 | + alias: 'p', |
64 | 64 | default: 3000,
|
65 |
| - desc: chalk.gray(y18n.__("serve.port")), |
| 65 | + desc: chalk.gray(y18n.__('serve.port')), |
66 | 66 | nargs: 1,
|
67 | 67 | requiresArg: true,
|
68 |
| - type: "number" |
| 68 | + type: 'number' |
69 | 69 | },
|
70 |
| - "livereload-port": { |
71 |
| - alias: "P", |
| 70 | + 'livereload-port': { |
| 71 | + alias: 'P', |
72 | 72 | default: 35729,
|
73 |
| - desc: chalk.gray(y18n.__("livereload.port")), |
| 73 | + desc: chalk.gray(y18n.__('livereload.port')), |
74 | 74 | nargs: 1,
|
75 | 75 | requiresArg: true,
|
76 |
| - type: "number" |
| 76 | + type: 'number' |
77 | 77 | },
|
78 |
| - "index-name": { |
79 |
| - alias: "i", |
80 |
| - desc: chalk.gray(y18n.__("serve.indexname")), |
| 78 | + 'index-name': { |
| 79 | + alias: 'i', |
| 80 | + desc: chalk.gray(y18n.__('serve.indexname')), |
81 | 81 | nargs: 1,
|
82 | 82 | requiresArg: true,
|
83 |
| - type: "string" |
| 83 | + type: 'string' |
84 | 84 | }
|
85 | 85 | }),
|
86 | 86 | handler: argv => run.serve(argv.path, argv.open, argv.port, argv.P, argv.i)
|
87 | 87 | })
|
88 | 88 | .command({
|
89 |
| - command: "start <path>", |
90 |
| - desc: chalk.gray(y18n.__("start")), |
| 89 | + command: 'start <path>', |
| 90 | + desc: chalk.gray(y18n.__('start')), |
91 | 91 | builder: yargs =>
|
92 | 92 | yargs.options({
|
93 | 93 | config: {
|
94 |
| - alias: "c", |
| 94 | + alias: 'c', |
95 | 95 | default: false,
|
96 |
| - desc: chalk.gray(y18n.__("start.config")), |
| 96 | + desc: chalk.gray(y18n.__('start.config')), |
97 | 97 | nargs: 0,
|
98 | 98 | requiresArg: false,
|
99 |
| - type: "string" |
| 99 | + type: 'string' |
100 | 100 | },
|
101 | 101 | port: {
|
102 |
| - alias: "p", |
| 102 | + alias: 'p', |
103 | 103 | default: 4000,
|
104 |
| - desc: chalk.gray(y18n.__("start.port")), |
| 104 | + desc: chalk.gray(y18n.__('start.port')), |
105 | 105 | nargs: 1,
|
106 | 106 | requiresArg: true,
|
107 |
| - type: "number" |
| 107 | + type: 'number' |
108 | 108 | }
|
109 | 109 | }),
|
110 | 110 | handler: argv => run.start(argv.path, argv.config, argv.port)
|
111 | 111 | })
|
112 | 112 | .help()
|
113 |
| - .option("help", { |
114 |
| - alias: "h", |
115 |
| - type: "boolean", |
116 |
| - desc: chalk.gray(y18n.__("help")), |
117 |
| - group: chalk.green(y18n.__("group.globaloptions")) |
| 113 | + .option('help', { |
| 114 | + alias: 'h', |
| 115 | + type: 'boolean', |
| 116 | + desc: chalk.gray(y18n.__('help')), |
| 117 | + group: chalk.green(y18n.__('group.globaloptions')) |
118 | 118 | })
|
119 |
| - .version("\ndocsify-cli version:\n " + pkg.version + "\n") |
120 |
| - .option("version", { |
121 |
| - alias: "v", |
122 |
| - type: "boolean", |
123 |
| - desc: chalk.gray(y18n.__("version")), |
124 |
| - group: chalk.green(y18n.__("group.globaloptions")) |
| 119 | + .version('\ndocsify-cli version:\n ' + pkg.version + '\n') |
| 120 | + .option('version', { |
| 121 | + alias: 'v', |
| 122 | + type: 'boolean', |
| 123 | + desc: chalk.gray(y18n.__('version')), |
| 124 | + group: chalk.green(y18n.__('group.globaloptions')) |
125 | 125 | })
|
126 |
| - .epilog(chalk.gray(y18n.__("epilog"))).argv; |
| 126 | + .epilog(chalk.gray(y18n.__('epilog'))).argv |
0 commit comments