@appium/docutils 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/lib/builder/deploy.d.ts.map +1 -1
- package/build/lib/builder/deploy.js +6 -2
- package/build/lib/builder/deploy.js.map +1 -1
- package/build/lib/builder/index.d.ts +4 -0
- package/build/lib/builder/index.d.ts.map +1 -1
- package/build/lib/builder/index.js +4 -0
- package/build/lib/builder/index.js.map +1 -1
- package/build/lib/builder/nav.d.ts +1 -1
- package/build/lib/builder/nav.d.ts.map +1 -1
- package/build/lib/builder/nav.js +3 -3
- package/build/lib/builder/nav.js.map +1 -1
- package/build/lib/builder/reference.d.ts.map +1 -1
- package/build/lib/builder/reference.js +1 -19
- package/build/lib/builder/reference.js.map +1 -1
- package/build/lib/builder/site.d.ts.map +1 -1
- package/build/lib/builder/site.js +4 -3
- package/build/lib/builder/site.js.map +1 -1
- package/build/lib/cli/check.d.ts +19 -0
- package/build/lib/cli/check.d.ts.map +1 -0
- package/build/lib/cli/check.js +58 -0
- package/build/lib/cli/check.js.map +1 -0
- package/build/lib/cli/command/build.d.ts +189 -174
- package/build/lib/cli/command/build.d.ts.map +1 -1
- package/build/lib/cli/command/build.js +56 -38
- package/build/lib/cli/command/build.js.map +1 -1
- package/build/lib/cli/command/index.d.ts +4 -0
- package/build/lib/cli/command/index.d.ts.map +1 -1
- package/build/lib/cli/command/index.js +4 -0
- package/build/lib/cli/command/index.js.map +1 -1
- package/build/lib/cli/command/init.d.ts +156 -139
- package/build/lib/cli/command/init.d.ts.map +1 -1
- package/build/lib/cli/command/init.js +52 -27
- package/build/lib/cli/command/init.js.map +1 -1
- package/build/lib/cli/command/validate.d.ts +71 -63
- package/build/lib/cli/command/validate.d.ts.map +1 -1
- package/build/lib/cli/command/validate.js +31 -20
- package/build/lib/cli/command/validate.js.map +1 -1
- package/build/lib/cli/index.d.ts.map +1 -1
- package/build/lib/cli/index.js +29 -12
- package/build/lib/cli/index.js.map +1 -1
- package/build/lib/constants.d.ts +4 -0
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +5 -1
- package/build/lib/constants.js.map +1 -1
- package/build/lib/error.d.ts +5 -0
- package/build/lib/error.d.ts.map +1 -1
- package/build/lib/error.js +5 -0
- package/build/lib/error.js.map +1 -1
- package/build/lib/fs.d.ts +1 -1
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +2 -2
- package/build/lib/fs.js.map +1 -1
- package/build/lib/index.d.ts +4 -0
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +4 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/init.d.ts +12 -5
- package/build/lib/init.d.ts.map +1 -1
- package/build/lib/init.js +12 -7
- package/build/lib/init.js.map +1 -1
- package/build/lib/mike.d.ts.map +1 -1
- package/build/lib/mike.js +4 -0
- package/build/lib/mike.js.map +1 -1
- package/build/lib/util.d.ts +4 -1
- package/build/lib/util.d.ts.map +1 -1
- package/build/lib/util.js.map +1 -1
- package/build/lib/validate.d.ts +4 -1
- package/build/lib/validate.d.ts.map +1 -1
- package/build/lib/validate.js +9 -7
- package/build/lib/validate.js.map +1 -1
- package/lib/builder/deploy.ts +9 -3
- package/lib/builder/index.ts +5 -0
- package/lib/builder/nav.ts +2 -3
- package/lib/builder/reference.ts +2 -22
- package/lib/builder/site.ts +6 -5
- package/lib/cli/check.ts +87 -0
- package/lib/cli/command/build.ts +61 -43
- package/lib/cli/command/index.ts +5 -0
- package/lib/cli/command/init.ts +54 -29
- package/lib/cli/command/validate.ts +33 -25
- package/lib/cli/index.ts +23 -4
- package/lib/constants.ts +5 -0
- package/lib/error.ts +6 -0
- package/lib/fs.ts +6 -3
- package/lib/index.ts +5 -0
- package/lib/init.ts +23 -6
- package/lib/mike.js +5 -0
- package/lib/util.ts +4 -1
- package/lib/validate.ts +10 -9
- package/package.json +8 -10
- package/requirements.txt +1 -1
package/lib/cli/command/build.ts
CHANGED
|
@@ -1,53 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Yargs command module for the `build` command.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import type {CommandModule, InferredOptionTypes, Options} from 'yargs';
|
|
2
8
|
import {buildReferenceDocs, buildSite, deploy, updateNav} from '../../builder';
|
|
3
9
|
import {NAME_BIN} from '../../constants';
|
|
4
10
|
import logger from '../../logger';
|
|
5
11
|
import {stopwatch} from '../../util';
|
|
12
|
+
import {checkMissingPaths} from '../check';
|
|
6
13
|
|
|
7
14
|
const log = logger.withTag('build');
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
enum BuildCommandGroup {
|
|
17
|
+
Build = 'Build Config:',
|
|
18
|
+
Deploy = 'Deployment Config:',
|
|
19
|
+
Serve = 'Dev Server Config:',
|
|
20
|
+
BuildPaths = 'Custom Paths:',
|
|
21
|
+
}
|
|
13
22
|
|
|
14
|
-
const opts =
|
|
23
|
+
const opts = {
|
|
15
24
|
reference: {
|
|
16
25
|
describe: 'Run TypeDoc command API reference build (Markdown)',
|
|
17
|
-
group:
|
|
26
|
+
group: BuildCommandGroup.Build,
|
|
18
27
|
type: 'boolean',
|
|
19
28
|
default: true,
|
|
20
29
|
},
|
|
21
30
|
site: {
|
|
22
31
|
describe: 'Run MkDocs build (HTML)',
|
|
23
|
-
group:
|
|
32
|
+
group: BuildCommandGroup.Build,
|
|
24
33
|
type: 'boolean',
|
|
25
34
|
default: true,
|
|
26
35
|
},
|
|
27
36
|
'site-dir': {
|
|
28
37
|
alias: 'd',
|
|
29
38
|
describe: 'HTML output directory',
|
|
30
|
-
group:
|
|
39
|
+
group: BuildCommandGroup.Build,
|
|
31
40
|
nargs: 1,
|
|
32
41
|
requiresArg: true,
|
|
33
42
|
type: 'string',
|
|
34
43
|
normalize: true,
|
|
44
|
+
coerce: path.resolve,
|
|
35
45
|
implies: 'site',
|
|
36
46
|
defaultDescription: '(from mkdocs.yml)',
|
|
37
47
|
},
|
|
38
48
|
'package-json': {
|
|
39
49
|
defaultDescription: './package.json',
|
|
40
50
|
describe: 'Path to package.json',
|
|
41
|
-
group:
|
|
51
|
+
group: BuildCommandGroup.BuildPaths,
|
|
42
52
|
nargs: 1,
|
|
43
53
|
normalize: true,
|
|
54
|
+
coerce: path.resolve,
|
|
44
55
|
requiresArg: true,
|
|
45
56
|
type: 'string',
|
|
46
57
|
},
|
|
47
58
|
title: {
|
|
48
59
|
defaultDescription: '(extension package name)',
|
|
49
60
|
describe: 'Title of the API reference',
|
|
50
|
-
group:
|
|
61
|
+
group: BuildCommandGroup.Build,
|
|
51
62
|
nargs: 1,
|
|
52
63
|
requiresArg: true,
|
|
53
64
|
type: 'string',
|
|
@@ -55,45 +66,48 @@ const opts = Object.freeze({
|
|
|
55
66
|
'tsconfig-json': {
|
|
56
67
|
defaultDescription: './tsconfig.json',
|
|
57
68
|
describe: 'Path to tsconfig.json',
|
|
58
|
-
group:
|
|
69
|
+
group: BuildCommandGroup.BuildPaths,
|
|
59
70
|
nargs: 1,
|
|
60
71
|
normalize: true,
|
|
61
72
|
requiresArg: true,
|
|
73
|
+
coerce: path.resolve,
|
|
62
74
|
type: 'string',
|
|
63
75
|
},
|
|
64
76
|
'mkdocs-yml': {
|
|
65
77
|
defaultDescription: './mkdocs.yml',
|
|
66
78
|
description: 'Path to mkdocs.yml',
|
|
67
|
-
group:
|
|
79
|
+
group: BuildCommandGroup.BuildPaths,
|
|
68
80
|
nargs: 1,
|
|
69
81
|
normalize: true,
|
|
70
82
|
requiresArg: true,
|
|
83
|
+
coerce: path.resolve,
|
|
71
84
|
type: 'string',
|
|
72
85
|
},
|
|
73
86
|
'typedoc-json': {
|
|
74
87
|
defaultDescription: './typedoc.json',
|
|
75
88
|
describe: 'Path to typedoc.json',
|
|
76
|
-
group:
|
|
89
|
+
group: BuildCommandGroup.BuildPaths,
|
|
77
90
|
nargs: 1,
|
|
78
91
|
normalize: true,
|
|
79
92
|
requiresArg: true,
|
|
93
|
+
coerce: path.resolve,
|
|
80
94
|
type: 'string',
|
|
81
95
|
},
|
|
82
96
|
all: {
|
|
83
97
|
describe: 'Output all reference docs (not just Appium comands)',
|
|
84
|
-
group:
|
|
98
|
+
group: BuildCommandGroup.Build,
|
|
85
99
|
implies: 'site',
|
|
86
100
|
type: 'boolean',
|
|
87
101
|
},
|
|
88
102
|
deploy: {
|
|
89
|
-
describe: 'Commit HTML output',
|
|
90
|
-
group:
|
|
103
|
+
describe: 'Commit HTML output to a branch using mike',
|
|
104
|
+
group: BuildCommandGroup.Deploy,
|
|
91
105
|
type: 'boolean',
|
|
92
106
|
implies: 'site',
|
|
93
107
|
},
|
|
94
108
|
push: {
|
|
95
109
|
describe: 'Push after deploy',
|
|
96
|
-
group:
|
|
110
|
+
group: BuildCommandGroup.Deploy,
|
|
97
111
|
type: 'boolean',
|
|
98
112
|
implies: 'deploy',
|
|
99
113
|
},
|
|
@@ -101,7 +115,7 @@ const opts = Object.freeze({
|
|
|
101
115
|
alias: 'b',
|
|
102
116
|
describe: 'Branch to commit to',
|
|
103
117
|
implies: 'deploy',
|
|
104
|
-
group:
|
|
118
|
+
group: BuildCommandGroup.Deploy,
|
|
105
119
|
type: 'string',
|
|
106
120
|
requiresArg: true,
|
|
107
121
|
nargs: 1,
|
|
@@ -111,7 +125,7 @@ const opts = Object.freeze({
|
|
|
111
125
|
alias: 'r',
|
|
112
126
|
describe: 'Remote to push to',
|
|
113
127
|
implies: ['deploy', 'push'],
|
|
114
|
-
group:
|
|
128
|
+
group: BuildCommandGroup.Deploy,
|
|
115
129
|
type: 'string',
|
|
116
130
|
requiresArg: true,
|
|
117
131
|
nargs: 1,
|
|
@@ -120,16 +134,16 @@ const opts = Object.freeze({
|
|
|
120
134
|
prefix: {
|
|
121
135
|
describe: 'Subdirectory within <branch> to commit to',
|
|
122
136
|
implies: ['deploy', 'branch'],
|
|
123
|
-
group:
|
|
137
|
+
group: BuildCommandGroup.Deploy,
|
|
124
138
|
type: 'string',
|
|
125
139
|
nargs: 1,
|
|
126
140
|
requiresArg: true,
|
|
127
141
|
},
|
|
128
142
|
message: {
|
|
129
143
|
alias: 'm',
|
|
130
|
-
describe: 'Commit message',
|
|
144
|
+
describe: 'Commit message. Use "%s" for version placeholder',
|
|
131
145
|
implies: 'deploy',
|
|
132
|
-
group:
|
|
146
|
+
group: BuildCommandGroup.Deploy,
|
|
133
147
|
type: 'string',
|
|
134
148
|
nargs: 1,
|
|
135
149
|
requiresArg: true,
|
|
@@ -137,7 +151,7 @@ const opts = Object.freeze({
|
|
|
137
151
|
'deploy-version': {
|
|
138
152
|
describe: 'Version (directory) to deploy build to',
|
|
139
153
|
implies: 'deploy',
|
|
140
|
-
group:
|
|
154
|
+
group: BuildCommandGroup.Deploy,
|
|
141
155
|
type: 'string',
|
|
142
156
|
nargs: 1,
|
|
143
157
|
requiresArg: true,
|
|
@@ -146,7 +160,7 @@ const opts = Object.freeze({
|
|
|
146
160
|
alias: {
|
|
147
161
|
describe: 'Alias for the build (e.g., "latest"); triggers alias update',
|
|
148
162
|
implies: 'deploy',
|
|
149
|
-
group:
|
|
163
|
+
group: BuildCommandGroup.Deploy,
|
|
150
164
|
type: 'string',
|
|
151
165
|
nargs: 1,
|
|
152
166
|
requiresArg: true,
|
|
@@ -155,18 +169,18 @@ const opts = Object.freeze({
|
|
|
155
169
|
rebase: {
|
|
156
170
|
describe: 'Rebase <branch> with remote before deploy',
|
|
157
171
|
implies: ['deploy', 'branch', 'remote'],
|
|
158
|
-
group:
|
|
172
|
+
group: BuildCommandGroup.Deploy,
|
|
159
173
|
type: 'boolean',
|
|
160
174
|
},
|
|
161
175
|
serve: {
|
|
162
176
|
describe: 'Start development server',
|
|
163
|
-
group:
|
|
177
|
+
group: BuildCommandGroup.Serve,
|
|
164
178
|
type: 'boolean',
|
|
165
179
|
},
|
|
166
180
|
port: {
|
|
167
181
|
alias: 'p',
|
|
168
182
|
describe: 'Development server port',
|
|
169
|
-
group:
|
|
183
|
+
group: BuildCommandGroup.Serve,
|
|
170
184
|
type: 'number',
|
|
171
185
|
defaultDescription: '8000',
|
|
172
186
|
implies: 'serve',
|
|
@@ -176,31 +190,35 @@ const opts = Object.freeze({
|
|
|
176
190
|
host: {
|
|
177
191
|
alias: 'h',
|
|
178
192
|
describe: 'Development server host',
|
|
179
|
-
group:
|
|
193
|
+
group: BuildCommandGroup.Serve,
|
|
180
194
|
type: 'string',
|
|
181
195
|
nargs: 1,
|
|
182
196
|
requiresArg: true,
|
|
183
197
|
implies: 'serve',
|
|
184
198
|
defaultDescription: 'localhost',
|
|
185
199
|
},
|
|
186
|
-
}
|
|
200
|
+
} as const satisfies Record<string, Options>;
|
|
187
201
|
|
|
188
202
|
type BuildOptions = InferredOptionTypes<typeof opts>;
|
|
189
203
|
|
|
190
204
|
export default {
|
|
191
205
|
command: 'build',
|
|
192
|
-
describe: 'Build Appium extension documentation',
|
|
193
|
-
builder
|
|
194
|
-
yargs
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
describe: 'Build Appium extension documentation using TypeDoc & MkDocs',
|
|
207
|
+
builder(yargs) {
|
|
208
|
+
return yargs
|
|
209
|
+
.options(opts)
|
|
210
|
+
.check(async (argv) => {
|
|
211
|
+
// either this method doesn't provide camel-cased props, or the types are wrong.
|
|
212
|
+
if (argv.deploy === true && argv['site-dir']) {
|
|
213
|
+
return `--site-dir is unsupported when running "${NAME_BIN} deploy"; use --prefix if needed, but remember that the default behavior is to deploy to the root of the branch (${argv.branch}) instead of a subdirectory`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return await checkMissingPaths(opts, BuildCommandGroup.BuildPaths, argv);
|
|
217
|
+
})
|
|
218
|
+
.epilog(
|
|
219
|
+
'For help with further configuration, see:\n - MkDocs: https://www.mkdocs.org\n - TypeDoc: https://typedoc.org\n - Mike: https://github.com/jimporter/mike'
|
|
220
|
+
);
|
|
221
|
+
},
|
|
204
222
|
async handler(args) {
|
|
205
223
|
const stop = stopwatch('build');
|
|
206
224
|
log.debug('Build command called with args: %O', args);
|
|
@@ -223,4 +241,4 @@ export default {
|
|
|
223
241
|
}
|
|
224
242
|
log.success('Done! (total: %dms)', stop());
|
|
225
243
|
},
|
|
226
|
-
} as CommandModule<
|
|
244
|
+
} as CommandModule<object, BuildOptions>;
|
package/lib/cli/command/index.ts
CHANGED
package/lib/cli/command/init.ts
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yargs command module for the `init` command.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import _ from 'lodash';
|
|
2
|
-
import {CommandModule, InferredOptionTypes, Options} from 'yargs';
|
|
7
|
+
import type {CommandModule, InferredOptionTypes, Options} from 'yargs';
|
|
3
8
|
import {init} from '../../init';
|
|
4
9
|
import logger from '../../logger';
|
|
5
10
|
import {stopwatch} from '../../util';
|
|
11
|
+
import {checkMissingPaths} from '../check';
|
|
6
12
|
|
|
7
13
|
const log = logger.withTag('init');
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
enum InitCommandGroup {
|
|
16
|
+
MkDocs = 'MkDocs Config:',
|
|
17
|
+
Paths = 'Custom Paths:',
|
|
18
|
+
Behavior = 'Initialization Behavior:',
|
|
19
|
+
}
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Note the groups here; _some_ opts are paths and would usually be checked via
|
|
23
|
+
* {@linkcode checkMissingPaths}, but in this case we do not care if the path exists or not, because
|
|
24
|
+
* we may create it.
|
|
25
|
+
*/
|
|
26
|
+
const opts = {
|
|
14
27
|
copyright: {
|
|
15
28
|
description: 'Copyright notice',
|
|
16
|
-
group:
|
|
29
|
+
group: InitCommandGroup.MkDocs,
|
|
17
30
|
nargs: 1,
|
|
18
31
|
requiresArg: true,
|
|
19
32
|
type: 'string',
|
|
@@ -22,19 +35,19 @@ const opts = Object.freeze({
|
|
|
22
35
|
default: '.',
|
|
23
36
|
defaultDescription: '(current directory)',
|
|
24
37
|
description: 'Directory of package',
|
|
25
|
-
group:
|
|
38
|
+
group: InitCommandGroup.Paths,
|
|
26
39
|
normalize: true,
|
|
27
40
|
type: 'string',
|
|
28
41
|
},
|
|
29
42
|
'dry-run': {
|
|
30
43
|
describe: 'Do not write any files; show what would be done',
|
|
31
|
-
group:
|
|
44
|
+
group: InitCommandGroup.Behavior,
|
|
32
45
|
type: 'boolean',
|
|
33
46
|
},
|
|
34
47
|
force: {
|
|
35
48
|
alias: 'f',
|
|
36
49
|
describe: 'Overwrite existing configurations',
|
|
37
|
-
group:
|
|
50
|
+
group: InitCommandGroup.Behavior,
|
|
38
51
|
type: 'boolean',
|
|
39
52
|
},
|
|
40
53
|
include: {
|
|
@@ -43,19 +56,20 @@ const opts = Object.freeze({
|
|
|
43
56
|
coerce: (value: string | string[]) => _.castArray(value),
|
|
44
57
|
description: 'Files to include in compilation (globs OK)',
|
|
45
58
|
nargs: 1,
|
|
59
|
+
group: InitCommandGroup.MkDocs,
|
|
46
60
|
requiresArg: true,
|
|
47
61
|
type: 'string',
|
|
48
62
|
},
|
|
49
63
|
mkdocs: {
|
|
50
64
|
default: true,
|
|
51
65
|
description: 'Create mkdocs.yml if needed',
|
|
52
|
-
group:
|
|
66
|
+
group: InitCommandGroup.Behavior,
|
|
53
67
|
type: 'boolean',
|
|
54
68
|
},
|
|
55
69
|
'mkdocs-yml': {
|
|
56
70
|
defaultDescription: './mkdocs.yml',
|
|
57
|
-
description: 'Path to mkdocs.yml',
|
|
58
|
-
group:
|
|
71
|
+
description: 'Path to new or existing mkdocs.yml',
|
|
72
|
+
group: InitCommandGroup.MkDocs,
|
|
59
73
|
nargs: 1,
|
|
60
74
|
normalize: true,
|
|
61
75
|
requiresArg: true,
|
|
@@ -63,8 +77,8 @@ const opts = Object.freeze({
|
|
|
63
77
|
},
|
|
64
78
|
'package-json': {
|
|
65
79
|
defaultDescription: './package.json',
|
|
66
|
-
describe: 'Path to package.json',
|
|
67
|
-
group:
|
|
80
|
+
describe: 'Path to existing package.json',
|
|
81
|
+
group: InitCommandGroup.Paths,
|
|
68
82
|
nargs: 1,
|
|
69
83
|
normalize: true,
|
|
70
84
|
requiresArg: true,
|
|
@@ -73,13 +87,13 @@ const opts = Object.freeze({
|
|
|
73
87
|
python: {
|
|
74
88
|
default: true,
|
|
75
89
|
description: 'Install Python dependencies if needed',
|
|
76
|
-
group:
|
|
90
|
+
group: InitCommandGroup.Behavior,
|
|
77
91
|
type: 'boolean',
|
|
78
92
|
},
|
|
79
93
|
'python-path': {
|
|
80
94
|
defaultDescription: '(derived from shell)',
|
|
81
95
|
description: 'Path to python 3 executable',
|
|
82
|
-
group:
|
|
96
|
+
group: InitCommandGroup.Paths,
|
|
83
97
|
nargs: 1,
|
|
84
98
|
normalize: true,
|
|
85
99
|
requiresArg: true,
|
|
@@ -88,7 +102,7 @@ const opts = Object.freeze({
|
|
|
88
102
|
'repo-name': {
|
|
89
103
|
defaultDescription: '(derived from --repo-url)',
|
|
90
104
|
description: 'Name of extension repository',
|
|
91
|
-
group:
|
|
105
|
+
group: InitCommandGroup.MkDocs,
|
|
92
106
|
nargs: 1,
|
|
93
107
|
requiresArg: true,
|
|
94
108
|
type: 'string',
|
|
@@ -96,7 +110,7 @@ const opts = Object.freeze({
|
|
|
96
110
|
'repo-url': {
|
|
97
111
|
defaultDescription: '(from package.json)',
|
|
98
112
|
description: 'URL of extension repository',
|
|
99
|
-
group:
|
|
113
|
+
group: InitCommandGroup.MkDocs,
|
|
100
114
|
nargs: 1,
|
|
101
115
|
requiresArg: true,
|
|
102
116
|
type: 'string',
|
|
@@ -104,7 +118,7 @@ const opts = Object.freeze({
|
|
|
104
118
|
'site-description': {
|
|
105
119
|
defaultDescription: '(from package.json)',
|
|
106
120
|
description: 'Site description',
|
|
107
|
-
group:
|
|
121
|
+
group: InitCommandGroup.MkDocs,
|
|
108
122
|
nargs: 1,
|
|
109
123
|
requiresArg: true,
|
|
110
124
|
type: 'string',
|
|
@@ -112,15 +126,15 @@ const opts = Object.freeze({
|
|
|
112
126
|
'site-name': {
|
|
113
127
|
defaultDescription: '(extension package name)',
|
|
114
128
|
description: 'Name of site',
|
|
115
|
-
group:
|
|
129
|
+
group: InitCommandGroup.MkDocs,
|
|
116
130
|
nargs: 1,
|
|
117
131
|
requiresArg: true,
|
|
118
132
|
type: 'string',
|
|
119
133
|
},
|
|
120
134
|
'tsconfig-json': {
|
|
121
135
|
defaultDescription: './tsconfig.json',
|
|
122
|
-
describe: 'Path to tsconfig.json',
|
|
123
|
-
group:
|
|
136
|
+
describe: 'Path to new or existing tsconfig.json',
|
|
137
|
+
group: InitCommandGroup.Behavior,
|
|
124
138
|
nargs: 1,
|
|
125
139
|
normalize: true,
|
|
126
140
|
requiresArg: true,
|
|
@@ -129,13 +143,13 @@ const opts = Object.freeze({
|
|
|
129
143
|
typedoc: {
|
|
130
144
|
default: true,
|
|
131
145
|
description: 'Create typedoc.json if needed',
|
|
132
|
-
group:
|
|
146
|
+
group: InitCommandGroup.Behavior,
|
|
133
147
|
type: 'boolean',
|
|
134
148
|
},
|
|
135
149
|
'typedoc-json': {
|
|
136
150
|
defaultDescription: './typedoc.json',
|
|
137
|
-
describe: 'Path to typedoc.json',
|
|
138
|
-
group:
|
|
151
|
+
describe: 'Path to new or existing typedoc.json',
|
|
152
|
+
group: InitCommandGroup.Behavior,
|
|
139
153
|
nargs: 1,
|
|
140
154
|
normalize: true,
|
|
141
155
|
requiresArg: true,
|
|
@@ -144,20 +158,31 @@ const opts = Object.freeze({
|
|
|
144
158
|
typescript: {
|
|
145
159
|
default: true,
|
|
146
160
|
description: 'Create tsconfig.json if needed',
|
|
147
|
-
group:
|
|
161
|
+
group: InitCommandGroup.Behavior,
|
|
162
|
+
type: 'boolean',
|
|
163
|
+
},
|
|
164
|
+
upgrade: {
|
|
165
|
+
alias: 'up',
|
|
166
|
+
describe: 'Only upgrade Python dependencies if out-of-date',
|
|
167
|
+
group: InitCommandGroup.Behavior,
|
|
148
168
|
type: 'boolean',
|
|
169
|
+
conflicts: 'force',
|
|
149
170
|
},
|
|
150
|
-
}
|
|
171
|
+
} as const satisfies Record<string, Options>;
|
|
151
172
|
|
|
152
173
|
type InitOptions = InferredOptionTypes<typeof opts>;
|
|
153
174
|
|
|
154
175
|
export default {
|
|
155
176
|
command: 'init',
|
|
156
177
|
describe: 'Initialize package for doc generation',
|
|
157
|
-
builder
|
|
178
|
+
builder(yargs) {
|
|
179
|
+
return yargs
|
|
180
|
+
.options(opts)
|
|
181
|
+
.check(async (argv) => checkMissingPaths(opts, InitCommandGroup.Paths, argv));
|
|
182
|
+
},
|
|
158
183
|
async handler(args) {
|
|
159
184
|
const done = stopwatch('init');
|
|
160
185
|
await init({...args, overwrite: args.force, cwd: args.dir});
|
|
161
186
|
log.success('Done (%dms)', done());
|
|
162
187
|
},
|
|
163
|
-
} as CommandModule<
|
|
188
|
+
} as CommandModule<object, InitOptions>;
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Yargs command module for the `validate` command.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {util} from '@appium/support';
|
|
7
|
+
import type {CommandModule, InferredOptionTypes, Options} from 'yargs';
|
|
3
8
|
import {DocutilsError} from '../../error';
|
|
4
9
|
import {DocutilsValidator, ValidationKind} from '../../validate';
|
|
5
10
|
import logger from '../../logger';
|
|
11
|
+
import {checkMissingPaths} from '../check';
|
|
6
12
|
|
|
7
13
|
const log = logger.withTag('validate');
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
enum ValidateCommandGroup {
|
|
16
|
+
Behavior = 'Validation Behavior:',
|
|
17
|
+
Paths = 'Custom Paths:',
|
|
18
|
+
}
|
|
11
19
|
|
|
12
|
-
const opts =
|
|
20
|
+
const opts = {
|
|
13
21
|
mkdocs: {
|
|
14
22
|
default: true,
|
|
15
23
|
description: 'Validate MkDocs environment',
|
|
16
|
-
group:
|
|
24
|
+
group: ValidateCommandGroup.Behavior,
|
|
17
25
|
type: 'boolean',
|
|
18
26
|
},
|
|
19
27
|
'mkdocs-yml': {
|
|
20
28
|
defaultDescription: './mkdocs.yml',
|
|
21
29
|
description: 'Path to mkdocs.yml',
|
|
22
|
-
group:
|
|
30
|
+
group: ValidateCommandGroup.Paths,
|
|
23
31
|
nargs: 1,
|
|
24
32
|
normalize: true,
|
|
25
33
|
requiresArg: true,
|
|
@@ -28,7 +36,7 @@ const opts = Object.freeze({
|
|
|
28
36
|
'npm-path': {
|
|
29
37
|
defaultDescription: '(derived from shell)',
|
|
30
38
|
description: 'Path to npm executable',
|
|
31
|
-
group:
|
|
39
|
+
group: ValidateCommandGroup.Paths,
|
|
32
40
|
nargs: 1,
|
|
33
41
|
normalize: true,
|
|
34
42
|
requiresArg: true,
|
|
@@ -37,13 +45,13 @@ const opts = Object.freeze({
|
|
|
37
45
|
python: {
|
|
38
46
|
default: true,
|
|
39
47
|
description: 'Validate Python 3 environment',
|
|
40
|
-
group:
|
|
48
|
+
group: ValidateCommandGroup.Behavior,
|
|
41
49
|
type: 'boolean',
|
|
42
50
|
},
|
|
43
51
|
'python-path': {
|
|
44
52
|
defaultDescription: '(derived from shell)',
|
|
45
53
|
description: 'Path to python 3 executable',
|
|
46
|
-
group:
|
|
54
|
+
group: ValidateCommandGroup.Paths,
|
|
47
55
|
nargs: 1,
|
|
48
56
|
normalize: true,
|
|
49
57
|
requiresArg: true,
|
|
@@ -52,7 +60,7 @@ const opts = Object.freeze({
|
|
|
52
60
|
'tsconfig-json': {
|
|
53
61
|
defaultDescription: './tsconfig.json',
|
|
54
62
|
describe: 'Path to tsconfig.json',
|
|
55
|
-
group:
|
|
63
|
+
group: ValidateCommandGroup.Paths,
|
|
56
64
|
nargs: 1,
|
|
57
65
|
normalize: true,
|
|
58
66
|
requiresArg: true,
|
|
@@ -61,13 +69,13 @@ const opts = Object.freeze({
|
|
|
61
69
|
typedoc: {
|
|
62
70
|
default: true,
|
|
63
71
|
description: 'Validate TypoDoc environment',
|
|
64
|
-
group:
|
|
72
|
+
group: ValidateCommandGroup.Behavior,
|
|
65
73
|
type: 'boolean',
|
|
66
74
|
},
|
|
67
75
|
'typedoc-json': {
|
|
68
76
|
defaultDescription: './typedoc.json',
|
|
69
77
|
describe: 'Path to typedoc.json',
|
|
70
|
-
group:
|
|
78
|
+
group: ValidateCommandGroup.Paths,
|
|
71
79
|
nargs: 1,
|
|
72
80
|
normalize: true,
|
|
73
81
|
requiresArg: true,
|
|
@@ -76,25 +84,25 @@ const opts = Object.freeze({
|
|
|
76
84
|
typescript: {
|
|
77
85
|
default: true,
|
|
78
86
|
description: 'Validate TypeScript environment',
|
|
79
|
-
group:
|
|
87
|
+
group: ValidateCommandGroup.Behavior,
|
|
80
88
|
type: 'boolean',
|
|
81
89
|
},
|
|
82
|
-
}
|
|
90
|
+
} as const satisfies Record<string, Options>;
|
|
83
91
|
|
|
84
92
|
type ValidateOptions = InferredOptionTypes<typeof opts>;
|
|
85
93
|
|
|
86
94
|
export default {
|
|
87
95
|
command: 'validate',
|
|
88
96
|
describe: 'Validate Environment',
|
|
89
|
-
builder
|
|
97
|
+
builder(yargs) {
|
|
98
|
+
return yargs.options(opts).check(async (argv) => {
|
|
99
|
+
if (!argv.python && !argv.typedoc && !argv.typescript && !argv.mkdocs) {
|
|
100
|
+
return 'No validation targets specified; one or more of --python, --typescript, --typedoc or --mkdocs must be provided';
|
|
101
|
+
}
|
|
102
|
+
return checkMissingPaths(opts, ValidateCommandGroup.Paths, argv);
|
|
103
|
+
});
|
|
104
|
+
},
|
|
90
105
|
async handler(args) {
|
|
91
|
-
if (!args.python && !args.typedoc && !args.typescript && !args.mkdocs) {
|
|
92
|
-
// specifically not a DocutilsError
|
|
93
|
-
throw new Error(
|
|
94
|
-
'No validation targets specified; one or more of --python, --typescript, --typedoc or --mkdocs must be provided'
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
106
|
let errorCount = 0;
|
|
99
107
|
const validator = new DocutilsValidator(args)
|
|
100
108
|
.once(DocutilsValidator.BEGIN, (kinds: ValidationKind[]) => {
|
|
@@ -114,8 +122,8 @@ export default {
|
|
|
114
122
|
|
|
115
123
|
if (errorCount) {
|
|
116
124
|
throw new DocutilsError(
|
|
117
|
-
`Validation failed with ${errorCount} ${pluralize('error', errorCount)}`
|
|
125
|
+
`Validation failed with ${errorCount} ${util.pluralize('error', errorCount)}`
|
|
118
126
|
);
|
|
119
127
|
}
|
|
120
128
|
},
|
|
121
|
-
} as CommandModule<
|
|
129
|
+
} as CommandModule<object, ValidateOptions>;
|
package/lib/cli/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main CLI entry point for `@appium/docutils`
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
2
9
|
import logger from '../logger';
|
|
3
10
|
|
|
4
11
|
import _ from 'lodash';
|
|
@@ -8,6 +15,10 @@ import {DEFAULT_LOG_LEVEL, LogLevelMap, NAME_BIN} from '../constants';
|
|
|
8
15
|
import {DocutilsError} from '../error';
|
|
9
16
|
import {build, init, validate} from './command';
|
|
10
17
|
import {findConfig} from './config';
|
|
18
|
+
import {fs} from '@appium/support';
|
|
19
|
+
import {sync as readPkg} from 'read-pkg';
|
|
20
|
+
|
|
21
|
+
const pkg = readPkg({cwd: fs.findRoot(__dirname)});
|
|
11
22
|
|
|
12
23
|
const log = logger.withTag('cli');
|
|
13
24
|
export async function main(argv = hideBin(process.argv)) {
|
|
@@ -45,7 +56,7 @@ export async function main(argv = hideBin(process.argv)) {
|
|
|
45
56
|
describe: 'Disable config file discovery',
|
|
46
57
|
},
|
|
47
58
|
})
|
|
48
|
-
.middleware(
|
|
59
|
+
.middleware([
|
|
49
60
|
/**
|
|
50
61
|
* Configures logging; `--verbose` implies `--log-level=debug`
|
|
51
62
|
*/
|
|
@@ -55,8 +66,15 @@ export async function main(argv = hideBin(process.argv)) {
|
|
|
55
66
|
log.debug('Debug logging enabled via --verbose');
|
|
56
67
|
}
|
|
57
68
|
log.level = LogLevelMap[argv.logLevel];
|
|
58
|
-
}
|
|
59
|
-
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Writes a startup message, if logging is enabled
|
|
72
|
+
*/
|
|
73
|
+
async () => {
|
|
74
|
+
log.info(`${pkg.name} @ v${pkg.version} (Node.js ${process.version})`);
|
|
75
|
+
},
|
|
76
|
+
])
|
|
77
|
+
.epilog(`Please report bugs at ${pkg.bugs?.url}`)
|
|
60
78
|
.fail(
|
|
61
79
|
/**
|
|
62
80
|
* Custom failure handler so we can log nicely.
|
|
@@ -67,6 +85,7 @@ export async function main(argv = hideBin(process.argv)) {
|
|
|
67
85
|
log.error(error.message);
|
|
68
86
|
} else {
|
|
69
87
|
y.showHelp();
|
|
88
|
+
console.log();
|
|
70
89
|
log.error(msg ?? error.message);
|
|
71
90
|
}
|
|
72
91
|
y.exit(1, error);
|
|
@@ -81,7 +100,7 @@ export async function main(argv = hideBin(process.argv)) {
|
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
if (require.main === module) {
|
|
84
|
-
// eslint-disable-next-line promise/prefer-await-to-then
|
|
103
|
+
// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-await-to-callbacks
|
|
85
104
|
main().catch((err) => {
|
|
86
105
|
log.error('Caught otherwise-unhandled rejection (this is probably a bug):', err);
|
|
87
106
|
});
|