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