@appium/docutils 0.2.1 → 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.
Files changed (201) hide show
  1. package/LICENSE +1 -1
  2. package/build/lib/builder/deploy.d.ts.map +1 -1
  3. package/build/lib/builder/deploy.js +6 -2
  4. package/build/lib/builder/deploy.js.map +1 -1
  5. package/build/lib/builder/index.d.ts +4 -0
  6. package/build/lib/builder/index.d.ts.map +1 -1
  7. package/build/lib/builder/index.js +4 -0
  8. package/build/lib/builder/index.js.map +1 -1
  9. package/build/lib/builder/nav.d.ts +1 -1
  10. package/build/lib/builder/nav.d.ts.map +1 -1
  11. package/build/lib/builder/nav.js +3 -3
  12. package/build/lib/builder/nav.js.map +1 -1
  13. package/build/lib/builder/reference.d.ts +1 -1
  14. package/build/lib/builder/reference.d.ts.map +1 -1
  15. package/build/lib/builder/reference.js +1 -19
  16. package/build/lib/builder/reference.js.map +1 -1
  17. package/build/lib/builder/site.d.ts.map +1 -1
  18. package/build/lib/builder/site.js +4 -3
  19. package/build/lib/builder/site.js.map +1 -1
  20. package/build/lib/cli/check.d.ts +19 -0
  21. package/build/lib/cli/check.d.ts.map +1 -0
  22. package/build/lib/cli/check.js +58 -0
  23. package/build/lib/cli/check.js.map +1 -0
  24. package/build/lib/cli/command/build.d.ts +42 -29
  25. package/build/lib/cli/command/build.d.ts.map +1 -1
  26. package/build/lib/cli/command/build.js +55 -39
  27. package/build/lib/cli/command/build.js.map +1 -1
  28. package/build/lib/cli/command/index.d.ts +4 -0
  29. package/build/lib/cli/command/index.d.ts.map +1 -1
  30. package/build/lib/cli/command/index.js +4 -0
  31. package/build/lib/cli/command/index.js.map +1 -1
  32. package/build/lib/cli/command/init.d.ts +42 -27
  33. package/build/lib/cli/command/init.d.ts.map +1 -1
  34. package/build/lib/cli/command/init.js +51 -28
  35. package/build/lib/cli/command/init.js.map +1 -1
  36. package/build/lib/cli/command/validate.d.ts +21 -15
  37. package/build/lib/cli/command/validate.d.ts.map +1 -1
  38. package/build/lib/cli/command/validate.js +30 -21
  39. package/build/lib/cli/command/validate.js.map +1 -1
  40. package/build/lib/cli/config.js +1 -1
  41. package/build/lib/cli/config.js.map +1 -1
  42. package/build/lib/cli/index.d.ts.map +1 -1
  43. package/build/lib/cli/index.js +29 -12
  44. package/build/lib/cli/index.js.map +1 -1
  45. package/build/lib/constants.d.ts +4 -0
  46. package/build/lib/constants.d.ts.map +1 -1
  47. package/build/lib/constants.js +5 -1
  48. package/build/lib/constants.js.map +1 -1
  49. package/build/lib/error.d.ts +5 -0
  50. package/build/lib/error.d.ts.map +1 -1
  51. package/build/lib/error.js +5 -0
  52. package/build/lib/error.js.map +1 -1
  53. package/build/lib/fs.d.ts +1 -1
  54. package/build/lib/fs.d.ts.map +1 -1
  55. package/build/lib/fs.js +2 -2
  56. package/build/lib/fs.js.map +1 -1
  57. package/build/lib/index.d.ts +4 -0
  58. package/build/lib/index.d.ts.map +1 -1
  59. package/build/lib/index.js +4 -0
  60. package/build/lib/index.js.map +1 -1
  61. package/build/lib/init.d.ts +24 -26
  62. package/build/lib/init.d.ts.map +1 -1
  63. package/build/lib/init.js +12 -7
  64. package/build/lib/init.js.map +1 -1
  65. package/build/lib/logger.js +0 -4
  66. package/build/lib/logger.js.map +1 -1
  67. package/build/lib/mike.d.ts.map +1 -1
  68. package/build/lib/mike.js +4 -0
  69. package/build/lib/mike.js.map +1 -1
  70. package/build/lib/model.d.ts +6 -10
  71. package/build/lib/model.d.ts.map +1 -1
  72. package/build/lib/scaffold.d.ts +5 -5
  73. package/build/lib/scaffold.d.ts.map +1 -1
  74. package/build/lib/util.d.ts +6 -3
  75. package/build/lib/util.d.ts.map +1 -1
  76. package/build/lib/util.js.map +1 -1
  77. package/build/lib/validate.d.ts +5 -2
  78. package/build/lib/validate.d.ts.map +1 -1
  79. package/build/lib/validate.js +9 -7
  80. package/build/lib/validate.js.map +1 -1
  81. package/lib/builder/deploy.ts +9 -3
  82. package/lib/builder/index.ts +5 -0
  83. package/lib/builder/nav.ts +2 -3
  84. package/lib/builder/reference.ts +2 -22
  85. package/lib/builder/site.ts +6 -5
  86. package/lib/cli/check.ts +87 -0
  87. package/lib/cli/command/build.ts +61 -46
  88. package/lib/cli/command/index.ts +5 -0
  89. package/lib/cli/command/init.ts +54 -32
  90. package/lib/cli/command/validate.ts +35 -28
  91. package/lib/cli/index.ts +23 -4
  92. package/lib/constants.ts +5 -0
  93. package/lib/error.ts +6 -0
  94. package/lib/fs.ts +6 -3
  95. package/lib/index.ts +5 -0
  96. package/lib/init.ts +23 -6
  97. package/lib/logger.ts +6 -11
  98. package/lib/mike.js +5 -0
  99. package/lib/model.ts +3 -9
  100. package/lib/util.ts +4 -1
  101. package/lib/validate.ts +10 -9
  102. package/package.json +10 -12
  103. package/requirements.txt +1 -1
  104. package/build/lib/build/mkdocs.d.ts +0 -58
  105. package/build/lib/build/mkdocs.d.ts.map +0 -1
  106. package/build/lib/build/mkdocs.js +0 -80
  107. package/build/lib/build/mkdocs.js.map +0 -1
  108. package/build/lib/build/typedoc.d.ts +0 -55
  109. package/build/lib/build/typedoc.d.ts.map +0 -1
  110. package/build/lib/build/typedoc.js +0 -120
  111. package/build/lib/build/typedoc.js.map +0 -1
  112. package/build/lib/build-api.d.ts +0 -18
  113. package/build/lib/build-api.d.ts.map +0 -1
  114. package/build/lib/build-api.js +0 -75
  115. package/build/lib/build-api.js.map +0 -1
  116. package/build/lib/build.d.ts +0 -21
  117. package/build/lib/build.d.ts.map +0 -1
  118. package/build/lib/build.js +0 -71
  119. package/build/lib/build.js.map +0 -1
  120. package/build/lib/cli/command/deploy.d.ts +0 -1
  121. package/build/lib/cli/command/deploy.d.ts.map +0 -1
  122. package/build/lib/cli/command/deploy.js +0 -2
  123. package/build/lib/cli/command/deploy.js.map +0 -1
  124. package/build/lib/cli/command-init.d.ts +0 -143
  125. package/build/lib/cli/command-init.d.ts.map +0 -1
  126. package/build/lib/cli/command-init.js +0 -164
  127. package/build/lib/cli/command-init.js.map +0 -1
  128. package/build/lib/cli/command-validate.d.ts +0 -52
  129. package/build/lib/cli/command-validate.d.ts.map +0 -1
  130. package/build/lib/cli/command-validate.js +0 -66
  131. package/build/lib/cli/command-validate.js.map +0 -1
  132. package/build/lib/cli/init.d.ts +0 -143
  133. package/build/lib/cli/init.d.ts.map +0 -1
  134. package/build/lib/cli/init.js +0 -164
  135. package/build/lib/cli/init.js.map +0 -1
  136. package/build/lib/cli/options.d.ts +0 -1
  137. package/build/lib/cli/options.d.ts.map +0 -1
  138. package/build/lib/cli/options.js +0 -2
  139. package/build/lib/cli/options.js.map +0 -1
  140. package/build/lib/cli/validate.d.ts +0 -1
  141. package/build/lib/cli/validate.d.ts.map +0 -1
  142. package/build/lib/cli/validate.js +0 -2
  143. package/build/lib/cli/validate.js.map +0 -1
  144. package/build/lib/cli.d.ts +0 -10
  145. package/build/lib/cli.d.ts.map +0 -1
  146. package/build/lib/cli.js +0 -328
  147. package/build/lib/cli.js.map +0 -1
  148. package/build/lib/init-task.d.ts +0 -49
  149. package/build/lib/init-task.d.ts.map +0 -1
  150. package/build/lib/init-task.js +0 -95
  151. package/build/lib/init-task.js.map +0 -1
  152. package/build/lib/io.d.ts +0 -1
  153. package/build/lib/io.d.ts.map +0 -1
  154. package/build/lib/io.js +0 -2
  155. package/build/lib/io.js.map +0 -1
  156. package/build/lib/mkdocs.d.ts +0 -58
  157. package/build/lib/mkdocs.d.ts.map +0 -1
  158. package/build/lib/mkdocs.js +0 -77
  159. package/build/lib/mkdocs.js.map +0 -1
  160. package/build/lib/nav.d.ts +0 -47
  161. package/build/lib/nav.d.ts.map +0 -1
  162. package/build/lib/nav.js +0 -132
  163. package/build/lib/nav.js.map +0 -1
  164. package/build/lib/test.d.ts +0 -9
  165. package/build/lib/test.d.ts.map +0 -1
  166. package/build/lib/test.js +0 -2
  167. package/build/lib/test.js.map +0 -1
  168. package/build/lib/typedoc.d.ts +0 -55
  169. package/build/lib/typedoc.d.ts.map +0 -1
  170. package/build/lib/typedoc.js +0 -122
  171. package/build/lib/typedoc.js.map +0 -1
  172. package/build/lib/types.d.ts +0 -52
  173. package/build/lib/types.d.ts.map +0 -1
  174. package/build/lib/types.js +0 -7
  175. package/build/lib/types.js.map +0 -1
  176. package/build/lib/validation/base-validator.d.ts +0 -218
  177. package/build/lib/validation/base-validator.d.ts.map +0 -1
  178. package/build/lib/validation/base-validator.js +0 -453
  179. package/build/lib/validation/base-validator.js.map +0 -1
  180. package/build/lib/validation/mkdocs-validator.d.ts +0 -5
  181. package/build/lib/validation/mkdocs-validator.d.ts.map +0 -1
  182. package/build/lib/validation/mkdocs-validator.js +0 -54
  183. package/build/lib/validation/mkdocs-validator.js.map +0 -1
  184. package/build/lib/validation/python-validator.d.ts +0 -1
  185. package/build/lib/validation/python-validator.d.ts.map +0 -1
  186. package/build/lib/validation/python-validator.js +0 -2
  187. package/build/lib/validation/python-validator.js.map +0 -1
  188. package/build/lib/validation/python.d.ts +0 -1
  189. package/build/lib/validation/python.d.ts.map +0 -1
  190. package/build/lib/validation/python.js +0 -2
  191. package/build/lib/validation/python.js.map +0 -1
  192. package/build/lib/validation/validate.d.ts +0 -221
  193. package/build/lib/validation/validate.d.ts.map +0 -1
  194. package/build/lib/validation/validate.js +0 -508
  195. package/build/lib/validation/validate.js.map +0 -1
  196. package/build/lib/validation/validator.d.ts +0 -220
  197. package/build/lib/validation/validator.d.ts.map +0 -1
  198. package/build/lib/validation/validator.js +0 -470
  199. package/build/lib/validation/validator.js.map +0 -1
  200. package/build/test/unit/mike.spec.js +0 -17
  201. package/build/test/unit/mike.spec.js.map +0 -1
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Exports all command modules
3
+ * @module
4
+ */
5
+
1
6
  export {default as init} from './init';
2
7
  export {default as validate} from './validate';
3
8
  export {default as build} from './build';
@@ -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
- const NAME_GROUP_INIT_MKDOCS = 'MkDocs Config:';
10
- const NAME_GROUP_INIT_PATHS = 'Paths:';
11
- const NAME_GROUP_INIT_BEHAVIOR = 'Initialization Behavior:';
15
+ enum InitCommandGroup {
16
+ MkDocs = 'MkDocs Config:',
17
+ Paths = 'Custom Paths:',
18
+ Behavior = 'Initialization Behavior:',
19
+ }
12
20
 
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
+ */
13
26
  const opts = {
14
27
  copyright: {
15
28
  description: 'Copyright notice',
16
- group: NAME_GROUP_INIT_MKDOCS,
29
+ group: InitCommandGroup.MkDocs,
17
30
  nargs: 1,
18
31
  requiresArg: true,
19
32
  type: 'string',
@@ -22,19 +35,19 @@ const opts = {
22
35
  default: '.',
23
36
  defaultDescription: '(current directory)',
24
37
  description: 'Directory of package',
25
- group: NAME_GROUP_INIT_PATHS,
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: NAME_GROUP_INIT_BEHAVIOR,
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: NAME_GROUP_INIT_BEHAVIOR,
50
+ group: InitCommandGroup.Behavior,
38
51
  type: 'boolean',
39
52
  },
40
53
  include: {
@@ -43,19 +56,20 @@ const opts = {
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: NAME_GROUP_INIT_BEHAVIOR,
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: NAME_GROUP_INIT_PATHS,
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 = {
63
77
  },
64
78
  'package-json': {
65
79
  defaultDescription: './package.json',
66
- describe: 'Path to package.json',
67
- group: NAME_GROUP_INIT_PATHS,
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 = {
73
87
  python: {
74
88
  default: true,
75
89
  description: 'Install Python dependencies if needed',
76
- group: NAME_GROUP_INIT_BEHAVIOR,
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: NAME_GROUP_INIT_PATHS,
96
+ group: InitCommandGroup.Paths,
83
97
  nargs: 1,
84
98
  normalize: true,
85
99
  requiresArg: true,
@@ -88,7 +102,7 @@ const opts = {
88
102
  'repo-name': {
89
103
  defaultDescription: '(derived from --repo-url)',
90
104
  description: 'Name of extension repository',
91
- group: NAME_GROUP_INIT_MKDOCS,
105
+ group: InitCommandGroup.MkDocs,
92
106
  nargs: 1,
93
107
  requiresArg: true,
94
108
  type: 'string',
@@ -96,7 +110,7 @@ const opts = {
96
110
  'repo-url': {
97
111
  defaultDescription: '(from package.json)',
98
112
  description: 'URL of extension repository',
99
- group: NAME_GROUP_INIT_MKDOCS,
113
+ group: InitCommandGroup.MkDocs,
100
114
  nargs: 1,
101
115
  requiresArg: true,
102
116
  type: 'string',
@@ -104,7 +118,7 @@ const opts = {
104
118
  'site-description': {
105
119
  defaultDescription: '(from package.json)',
106
120
  description: 'Site description',
107
- group: NAME_GROUP_INIT_MKDOCS,
121
+ group: InitCommandGroup.MkDocs,
108
122
  nargs: 1,
109
123
  requiresArg: true,
110
124
  type: 'string',
@@ -112,15 +126,15 @@ const opts = {
112
126
  'site-name': {
113
127
  defaultDescription: '(extension package name)',
114
128
  description: 'Name of site',
115
- group: NAME_GROUP_INIT_MKDOCS,
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: NAME_GROUP_INIT_PATHS,
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 = {
129
143
  typedoc: {
130
144
  default: true,
131
145
  description: 'Create typedoc.json if needed',
132
- group: NAME_GROUP_INIT_BEHAVIOR,
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: NAME_GROUP_INIT_PATHS,
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,23 +158,31 @@ const opts = {
144
158
  typescript: {
145
159
  default: true,
146
160
  description: 'Create tsconfig.json if needed',
147
- group: NAME_GROUP_INIT_BEHAVIOR,
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
- } as const;
151
- opts as Record<string, Options>; // type check
171
+ } as const satisfies Record<string, Options>;
152
172
 
153
173
  type InitOptions = InferredOptionTypes<typeof opts>;
154
174
 
155
- const initCommand: CommandModule<{}, InitOptions> = {
175
+ export default {
156
176
  command: 'init',
157
177
  describe: 'Initialize package for doc generation',
158
- builder: opts,
178
+ builder(yargs) {
179
+ return yargs
180
+ .options(opts)
181
+ .check(async (argv) => checkMissingPaths(opts, InitCommandGroup.Paths, argv));
182
+ },
159
183
  async handler(args) {
160
184
  const done = stopwatch('init');
161
185
  await init({...args, overwrite: args.force, cwd: args.dir});
162
186
  log.success('Done (%dms)', done());
163
187
  },
164
- };
165
-
166
- export default initCommand;
188
+ } as CommandModule<object, InitOptions>;
@@ -1,25 +1,33 @@
1
- import pluralize from 'pluralize';
2
- import {CommandModule, InferredOptionTypes, Options} from 'yargs';
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
- const NAME_GROUP_VALIDATE = 'Validation Behavior:';
10
- const NAME_GROUP_VALIDATE_PATHS = 'Paths:';
15
+ enum ValidateCommandGroup {
16
+ Behavior = 'Validation Behavior:',
17
+ Paths = 'Custom Paths:',
18
+ }
11
19
 
12
20
  const opts = {
13
21
  mkdocs: {
14
22
  default: true,
15
23
  description: 'Validate MkDocs environment',
16
- group: NAME_GROUP_VALIDATE,
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: NAME_GROUP_VALIDATE_PATHS,
30
+ group: ValidateCommandGroup.Paths,
23
31
  nargs: 1,
24
32
  normalize: true,
25
33
  requiresArg: true,
@@ -28,7 +36,7 @@ const opts = {
28
36
  'npm-path': {
29
37
  defaultDescription: '(derived from shell)',
30
38
  description: 'Path to npm executable',
31
- group: NAME_GROUP_VALIDATE_PATHS,
39
+ group: ValidateCommandGroup.Paths,
32
40
  nargs: 1,
33
41
  normalize: true,
34
42
  requiresArg: true,
@@ -37,13 +45,13 @@ const opts = {
37
45
  python: {
38
46
  default: true,
39
47
  description: 'Validate Python 3 environment',
40
- group: NAME_GROUP_VALIDATE,
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: NAME_GROUP_VALIDATE_PATHS,
54
+ group: ValidateCommandGroup.Paths,
47
55
  nargs: 1,
48
56
  normalize: true,
49
57
  requiresArg: true,
@@ -52,7 +60,7 @@ const opts = {
52
60
  'tsconfig-json': {
53
61
  defaultDescription: './tsconfig.json',
54
62
  describe: 'Path to tsconfig.json',
55
- group: NAME_GROUP_VALIDATE_PATHS,
63
+ group: ValidateCommandGroup.Paths,
56
64
  nargs: 1,
57
65
  normalize: true,
58
66
  requiresArg: true,
@@ -61,13 +69,13 @@ const opts = {
61
69
  typedoc: {
62
70
  default: true,
63
71
  description: 'Validate TypoDoc environment',
64
- group: NAME_GROUP_VALIDATE,
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: NAME_GROUP_VALIDATE_PATHS,
78
+ group: ValidateCommandGroup.Paths,
71
79
  nargs: 1,
72
80
  normalize: true,
73
81
  requiresArg: true,
@@ -76,24 +84,25 @@ const opts = {
76
84
  typescript: {
77
85
  default: true,
78
86
  description: 'Validate TypeScript environment',
79
- group: NAME_GROUP_VALIDATE,
87
+ group: ValidateCommandGroup.Behavior,
80
88
  type: 'boolean',
81
89
  },
82
- } as const;
83
- opts as Record<string, Options>;
90
+ } as const satisfies Record<string, Options>;
91
+
84
92
  type ValidateOptions = InferredOptionTypes<typeof opts>;
85
- const validateCommand: CommandModule<{}, ValidateOptions> = {
93
+
94
+ export default {
86
95
  command: 'validate',
87
96
  describe: 'Validate Environment',
88
- builder: opts,
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
+ },
89
105
  async handler(args) {
90
- if (!args.python && !args.typedoc && !args.typescript && !args.mkdocs) {
91
- // specifically not a DocutilsError
92
- throw new Error(
93
- 'No validation targets specified; one or more of --python, --typescript, --typedoc or --mkdocs must be provided'
94
- );
95
- }
96
-
97
106
  let errorCount = 0;
98
107
  const validator = new DocutilsValidator(args)
99
108
  .once(DocutilsValidator.BEGIN, (kinds: ValidationKind[]) => {
@@ -113,10 +122,8 @@ const validateCommand: CommandModule<{}, ValidateOptions> = {
113
122
 
114
123
  if (errorCount) {
115
124
  throw new DocutilsError(
116
- `Validation failed with ${errorCount} ${pluralize('error', errorCount)}`
125
+ `Validation failed with ${errorCount} ${util.pluralize('error', errorCount)}`
117
126
  );
118
127
  }
119
128
  },
120
- };
121
-
122
- export default validateCommand;
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
  });
package/lib/constants.ts CHANGED
@@ -86,6 +86,11 @@ export const NAME_ERR_ENOENT = 'ENOENT';
86
86
  */
87
87
  export const NAME_ERR_EEXIST = 'EEXIST';
88
88
 
89
+ /**
90
+ * Name of the default theme
91
+ */
92
+ export const NAME_THEME = 'material';
93
+
89
94
  /**
90
95
  * Default log level
91
96
  */
package/lib/error.ts CHANGED
@@ -1 +1,7 @@
1
+ /**
2
+ * A custom error class. This exists so we can use `instanceof` to differentiate between "expected"
3
+ * exceptions and unexpected ones.
4
+ * @module
5
+ */
6
+
1
7
  export class DocutilsError extends Error {}
package/lib/fs.ts CHANGED
@@ -127,7 +127,10 @@ async function _readPkgJson(
127
127
  cwd: string,
128
128
  normalize: true
129
129
  ): Promise<{pkgPath: string; pkg: NormalizedPackageJson}>;
130
- async function _readPkgJson(cwd: string): Promise<{pkgPath: string; pkg: PackageJson}>;
130
+ async function _readPkgJson(
131
+ cwd: string,
132
+ normalize?: false
133
+ ): Promise<{pkgPath: string; pkg: PackageJson}>;
131
134
  async function _readPkgJson(
132
135
  cwd: string,
133
136
  normalize?: boolean
@@ -236,14 +239,14 @@ export const whichMike = _.partial(cachedWhich, NAME_MIKE);
236
239
  */
237
240
  export const readMkDocsYml = _.memoize(
238
241
  async (filepath: string, cwd = process.cwd()): Promise<MkDocsYml> => {
239
- let mkDocsYml = <MkDocsYml>await readYaml(filepath);
242
+ let mkDocsYml = (await readYaml(filepath)) as MkDocsYml;
240
243
  if (mkDocsYml.site_dir) {
241
244
  mkDocsYml.site_dir = path.resolve(cwd, path.dirname(filepath), mkDocsYml.site_dir);
242
245
  }
243
246
  if (mkDocsYml.INHERIT) {
244
247
  let inheritPath: string | undefined = path.resolve(path.dirname(filepath), mkDocsYml.INHERIT);
245
248
  while (inheritPath) {
246
- const inheritYml = <MkDocsYml>await readYaml(inheritPath);
249
+ const inheritYml = (await readYaml(inheritPath)) as MkDocsYml;
247
250
  if (inheritYml.site_dir) {
248
251
  inheritYml.site_dir = path.resolve(path.dirname(inheritPath), inheritYml.site_dir);
249
252
  log.debug('Resolved site_dir to %s', inheritYml.site_dir);
package/lib/index.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Main entry point
3
+ * @module
4
+ */
5
+
1
6
  export * from './mike';
2
7
  export * from './builder';
3
8
  export * from './validate';
package/lib/init.ts CHANGED
@@ -126,7 +126,9 @@ export const initMkDocs = createScaffoldTask<InitMkDocsOptions, MkDocsYml>(
126
126
  if (repoUrl && !repoName) {
127
127
  let {pathname} = new URL(repoUrl);
128
128
  pathname = pathname.slice(1);
129
- let [owner, repo] = pathname.split('/');
129
+ const pathparts = pathname.split('/');
130
+ const owner = pathparts[0];
131
+ let repo = pathparts[1];
130
132
  repo = repo.replace(/\.git$/, '');
131
133
  repoName = [owner, repo].join('/');
132
134
  if (repoName) {
@@ -158,8 +160,12 @@ export const initMkDocs = createScaffoldTask<InitMkDocsOptions, MkDocsYml>(
158
160
  export async function initPython({
159
161
  pythonPath = NAME_PYTHON,
160
162
  dryRun = false,
163
+ upgrade = false,
161
164
  }: InitPythonOptions = {}): Promise<void> {
162
165
  const args = ['-m', 'pip', 'install', '-r', REQUIREMENTS_TXT_PATH];
166
+ if (upgrade) {
167
+ args.push('--upgrade');
168
+ }
163
169
  if (dryRun) {
164
170
  dryRunLog.info('Would execute command: %s %s', pythonPath, args.join(' '));
165
171
  } else {
@@ -214,6 +220,7 @@ export async function init({
214
220
  dryRun,
215
221
  cwd,
216
222
  pythonPath,
223
+ upgrade,
217
224
  typedocJson: typeDocJsonPath,
218
225
  }: InitOptions = {}): Promise<void> {
219
226
  if (!typescript && typedoc) {
@@ -222,7 +229,7 @@ export async function init({
222
229
  );
223
230
  }
224
231
 
225
- if (typescript) {
232
+ if (typescript && !upgrade) {
226
233
  await initTsConfigJson({
227
234
  dest: tsconfigJsonPath,
228
235
  packageJson: packageJsonPath,
@@ -233,7 +240,7 @@ export async function init({
233
240
  });
234
241
  }
235
242
 
236
- if (typedoc) {
243
+ if (typedoc && !upgrade) {
237
244
  await initTypeDocJson({
238
245
  dest: typeDocJsonPath,
239
246
  packageJson: packageJsonPath,
@@ -244,10 +251,10 @@ export async function init({
244
251
  }
245
252
 
246
253
  if (python) {
247
- await initPython({pythonPath, dryRun});
254
+ await initPython({pythonPath, dryRun, upgrade});
248
255
  }
249
256
 
250
- if (mkdocs) {
257
+ if (mkdocs && !upgrade) {
251
258
  await initMkDocs({
252
259
  dest: mkdocsYmlPath,
253
260
  cwd,
@@ -262,7 +269,7 @@ export async function init({
262
269
  }
263
270
  }
264
271
 
265
- export interface InitTypeDocOptions extends ScaffoldTaskOptions {}
272
+ export type InitTypeDocOptions = ScaffoldTaskOptions;
266
273
  export interface InitTsConfigOptions extends ScaffoldTaskOptions {
267
274
  /**
268
275
  * List of source files (globs supported); typically `src` or `lib`
@@ -274,6 +281,11 @@ export interface InitPythonOptions extends ScaffoldTaskOptions {
274
281
  * Path to `python` (v3.x) executable
275
282
  */
276
283
  pythonPath?: string;
284
+
285
+ /**
286
+ * If true, upgrade only
287
+ */
288
+ upgrade?: boolean;
277
289
  }
278
290
 
279
291
  /**
@@ -315,5 +327,10 @@ export type InitOptions = Simplify<
315
327
  * Path to new or existing `mkdocs.yml` file
316
328
  */
317
329
  mkdocsYml?: string;
330
+
331
+ /**
332
+ * If `true`, upgrade only
333
+ */
334
+ upgrade?: boolean;
318
335
  }
319
336
  >;
package/lib/logger.ts CHANGED
@@ -32,34 +32,34 @@ class DocutilsReporter extends FancyReporter {
32
32
  /**
33
33
  * Mapping of log types (the name of the logging method called) to chalk fg colors
34
34
  */
35
- static TYPE_COLOR_MAP = {
35
+ static readonly TYPE_COLOR_MAP = {
36
36
  info: 'cyan',
37
37
  success: 'green',
38
38
  error: 'red',
39
39
  warn: 'yellow',
40
- } as const;
40
+ } satisfies {[k in LogType]?: typeof ForegroundColor};
41
41
 
42
42
  /**
43
43
  * Mapping of log levels to chalk fg colors
44
44
  */
45
- static LEVEL_COLORS = {
45
+ static readonly LEVEL_COLORS = {
46
46
  0: 'red',
47
47
  1: 'yellow',
48
48
  2: 'white',
49
49
  3: 'green',
50
- } as const;
50
+ } satisfies {[k in LogLevel]?: typeof ForegroundColor};
51
51
 
52
52
  /**
53
53
  * Mapping of log types to icons/symbols
54
54
  */
55
- static TYPE_ICONS = {
55
+ static readonly TYPE_ICONS = {
56
56
  info: logSymbols.info,
57
57
  success: logSymbols.success,
58
58
  error: logSymbols.error,
59
59
  warn: logSymbols.warning,
60
60
  debug: figures('›'),
61
61
  trace: figures('›'),
62
- } as const;
62
+ } satisfies {[k in LogType]?: string};
63
63
 
64
64
  /**
65
65
  * Default color to use if we can't find a color for the log type or level
@@ -191,8 +191,3 @@ function createLogProxy(logger: Consola): Consola {
191
191
  * @see {createLogProxy}
192
192
  */
193
193
  export default rootLogger;
194
-
195
- // these are just type-sanity checks
196
- <{[k in LogType]?: typeof ForegroundColor}>DocutilsReporter.TYPE_COLOR_MAP;
197
- <{[k in LogLevel]?: typeof ForegroundColor}>DocutilsReporter.LEVEL_COLORS;
198
- <{[k in LogType]?: string}>DocutilsReporter.TYPE_ICONS;
package/lib/mike.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * API around `mike`, a tool for deploying multiple versions of MkDocs-built sites to GitHub Pages
3
+ * @module
4
+ */
5
+
1
6
  import {exec} from 'teen_process';
2
7
  // eslint-disable-next-line import/no-unresolved
3
8
  import log from './logger';
package/lib/model.ts CHANGED
@@ -9,16 +9,10 @@ import type {TypeDocOptions} from 'typedoc';
9
9
 
10
10
  /**
11
11
  * A `tsconfig.json` file w/ `$schema` prop
12
- *
13
- * Due to some `unknown` types in {@linkcode type-fest.TsConfigJson}, we cannot use that type
14
- * directly and need to use `Jsonify`.
15
- *
16
12
  */
17
- export type TsConfigJson = Jsonify<
18
- TsConfigJsonBase & {
19
- $schema?: string;
20
- }
21
- >;
13
+ export type TsConfigJson = TsConfigJsonBase & {
14
+ $schema?: string;
15
+ };
22
16
 
23
17
  /**
24
18
  * A `typedoc.json` file w/ `$schema` and `extends` props
package/lib/util.ts CHANGED
@@ -32,6 +32,9 @@ export function stopwatch(id: string) {
32
32
  }
33
33
  stopwatch.cache = new Map<string, number>();
34
34
 
35
+ /**
36
+ * Converts a tuple to an object; use for extracting parameter types from a function signature
37
+ */
35
38
  export type TupleToObject<
36
39
  T extends readonly any[],
37
40
  M extends Record<Exclude<keyof T, keyof any[]>, PropertyKey>
@@ -69,7 +72,7 @@ export const argify: (obj: Record<string, string | number | boolean | undefined>
69
72
  );
70
73
 
71
74
  /**
72
- * Conversion of the parameters of {@linkcode Subprocess.start} to an object.
75
+ * Conversion of the parameters of {@linkcode SubProcess.start} to an object.
73
76
  */
74
77
  export type TeenProcessSubprocessStartOpts = Partial<
75
78
  TupleToObject<Parameters<SubProcess['start']>, ['startDetector', 'detach', 'timeoutMs']>