@appium/docutils 2.3.0 → 2.3.1

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 (47) hide show
  1. package/build/lib/builder/deploy.d.ts +5 -5
  2. package/build/lib/builder/deploy.d.ts.map +1 -1
  3. package/build/lib/builder/deploy.js +41 -41
  4. package/build/lib/builder/deploy.js.map +1 -1
  5. package/build/lib/builder/site.d.ts +5 -5
  6. package/build/lib/builder/site.d.ts.map +1 -1
  7. package/build/lib/builder/site.js +23 -23
  8. package/build/lib/builder/site.js.map +1 -1
  9. package/build/lib/cli/check.d.ts.map +1 -1
  10. package/build/lib/cli/check.js +10 -10
  11. package/build/lib/cli/check.js.map +1 -1
  12. package/build/lib/cli/index.d.ts +4 -0
  13. package/build/lib/cli/index.d.ts.map +1 -1
  14. package/build/lib/cli/index.js +4 -0
  15. package/build/lib/cli/index.js.map +1 -1
  16. package/build/lib/fs.d.ts.map +1 -1
  17. package/build/lib/fs.js.map +1 -1
  18. package/build/lib/init.d.ts +12 -12
  19. package/build/lib/init.d.ts.map +1 -1
  20. package/build/lib/init.js.map +1 -1
  21. package/build/lib/logger.d.ts +5 -0
  22. package/build/lib/logger.d.ts.map +1 -1
  23. package/build/lib/logger.js +5 -0
  24. package/build/lib/logger.js.map +1 -1
  25. package/build/lib/scaffold.d.ts +10 -10
  26. package/build/lib/scaffold.d.ts.map +1 -1
  27. package/build/lib/scaffold.js +10 -10
  28. package/build/lib/scaffold.js.map +1 -1
  29. package/build/lib/util.d.ts +1 -1
  30. package/build/lib/util.d.ts.map +1 -1
  31. package/build/lib/util.js.map +1 -1
  32. package/build/lib/validate.d.ts +42 -45
  33. package/build/lib/validate.d.ts.map +1 -1
  34. package/build/lib/validate.js +20 -20
  35. package/build/lib/validate.js.map +1 -1
  36. package/lib/builder/deploy.ts +120 -120
  37. package/lib/builder/site.ts +68 -68
  38. package/lib/cli/check.ts +13 -13
  39. package/lib/cli/index.ts +4 -0
  40. package/lib/fs.ts +2 -2
  41. package/lib/init.ts +54 -54
  42. package/lib/logger.ts +5 -0
  43. package/lib/scaffold.ts +94 -94
  44. package/lib/util.ts +2 -2
  45. package/lib/validate.ts +47 -51
  46. package/package.json +6 -6
  47. package/requirements.txt +1 -1
package/lib/cli/index.ts CHANGED
@@ -23,6 +23,10 @@ const pkg = readPackageSync({cwd: fs.findRoot(__dirname)});
23
23
  const log = getLogger('cli');
24
24
  const IMPLICATIONS_FAILED_REGEX = /implications\s+failed:\n\s*(.+)\s->\s(.+)$/i;
25
25
 
26
+ /**
27
+ * Entry point for the docutils CLI.
28
+ * @param argv Raw argv values (without node/bin by default).
29
+ */
26
30
  export async function main(argv = hideBin(process.argv)) {
27
31
  const config = await findConfig(argv);
28
32
 
package/lib/fs.ts CHANGED
@@ -140,6 +140,8 @@ export const readJson = _.memoize(
140
140
  JSON.parse(await fs.readFile(filepath, 'utf8')),
141
141
  );
142
142
 
143
+ type WhichFunction = (cmd: string, opts?: {nothrow: boolean}) => Promise<string | null>;
144
+
143
145
  /**
144
146
  * Writes contents to a file. Any JSON objects are stringified
145
147
  * @param filepath - Path to file
@@ -152,8 +154,6 @@ export function writeFileString(filepath: string, content: JsonValue) {
152
154
  });
153
155
  }
154
156
 
155
- type WhichFunction = (cmd: string, opts?: {nothrow: boolean}) => Promise<string | null>;
156
-
157
157
  /**
158
158
  * `which` with memoization
159
159
  */
package/lib/init.ts CHANGED
@@ -83,6 +83,60 @@ export const initMkDocs: ScaffoldTask<InitMkDocsOptions, MkDocsYml> = createScaf
83
83
  },
84
84
  );
85
85
 
86
+ /**
87
+ * Options for {@linkcode initMkDocs}
88
+ */
89
+ export interface InitMkDocsOptions extends ScaffoldTaskOptions {
90
+ copyright?: string;
91
+ repoName?: string;
92
+ repoUrl?: string;
93
+ siteDescription?: string;
94
+ siteName?: string;
95
+ }
96
+
97
+ export interface InitPythonOptions extends ScaffoldTaskOptions {
98
+ /**
99
+ * Path to `python` (v3.x) executable
100
+ */
101
+ pythonPath?: string;
102
+
103
+ /**
104
+ * If true, upgrade only
105
+ */
106
+ upgrade?: boolean;
107
+ }
108
+
109
+ /**
110
+ * Options for `init` command handler
111
+ *
112
+ * The props of the various "path" options are rewritten as `dest` for the scaffold tasks functions.
113
+ */
114
+ export type InitOptions = Simplify<
115
+ Omit<InitPythonOptions & InitMkDocsOptions, 'dest'> & {
116
+ /**
117
+ * If `true` will install Python deps
118
+ */
119
+ python?: boolean;
120
+ /**
121
+ * If `true` will initialize a `mkdocs.yml` file
122
+ */
123
+ mkdocs?: boolean;
124
+ /**
125
+ * Path to existing `package.json` file
126
+ */
127
+ packageJson?: string;
128
+ /**
129
+ * Path to new or existing `mkdocs.yml` file
130
+ */
131
+ mkdocsYml?: string;
132
+
133
+ /**
134
+ * If `true`, upgrade only
135
+ */
136
+ upgrade?: boolean;
137
+ }
138
+ >;
139
+
86
140
  /**
87
141
  * Installs Python dependencies
88
142
  * @param opts Options
@@ -127,17 +181,6 @@ export async function initPython({
127
181
  log.success('Successfully installed Python dependencies');
128
182
  }
129
183
 
130
- /**
131
- * Options for {@linkcode initMkDocs}
132
- */
133
- export interface InitMkDocsOptions extends ScaffoldTaskOptions {
134
- copyright?: string;
135
- repoName?: string;
136
- repoUrl?: string;
137
- siteDescription?: string;
138
- siteName?: string;
139
- }
140
-
141
184
  /**
142
185
  * Main handler for `init` command.
143
186
  *
@@ -177,46 +220,3 @@ export async function init({
177
220
  });
178
221
  }
179
222
  }
180
-
181
- export interface InitPythonOptions extends ScaffoldTaskOptions {
182
- /**
183
- * Path to `python` (v3.x) executable
184
- */
185
- pythonPath?: string;
186
-
187
- /**
188
- * If true, upgrade only
189
- */
190
- upgrade?: boolean;
191
- }
192
-
193
- /**
194
- * Options for `init` command handler
195
- *
196
- * The props of the various "path" options are rewritten as `dest` for the scaffold tasks functions.
197
- */
198
- export type InitOptions = Simplify<
199
- Omit<InitPythonOptions & InitMkDocsOptions, 'dest'> & {
200
- /**
201
- * If `true` will install Python deps
202
- */
203
- python?: boolean;
204
- /**
205
- * If `true` will initialize a `mkdocs.yml` file
206
- */
207
- mkdocs?: boolean;
208
- /**
209
- * Path to existing `package.json` file
210
- */
211
- packageJson?: string;
212
- /**
213
- * Path to new or existing `mkdocs.yml` file
214
- */
215
- mkdocsYml?: string;
216
-
217
- /**
218
- * If `true`, upgrade only
219
- */
220
- upgrade?: boolean;
221
- }
222
- >;
package/lib/logger.ts CHANGED
@@ -47,6 +47,11 @@ rootLogger.pauseLogs();
47
47
  */
48
48
  const loggers: Map<string, WeakRef<typeof ConsolaInstance>> = new Map();
49
49
 
50
+ /**
51
+ * Returns a tagged logger, creating and caching one if needed.
52
+ * @param tag Logger tag.
53
+ * @param parent Parent logger to derive from.
54
+ */
50
55
  export function getLogger(tag: string, parent = rootLogger) {
51
56
  if (loggers.has(tag)) {
52
57
  const logger = loggers.get(tag)?.deref();
package/lib/scaffold.ts CHANGED
@@ -18,26 +18,6 @@ import {NAME_ERR_ENOENT} from './constants';
18
18
  const log = getLogger('init');
19
19
  const dryRunLog = getLogger('dry-run', log);
20
20
 
21
- /**
22
- * Creates a unified patch for display in "dry run" mode
23
- * @param filename - File name to use
24
- * @param oldData - Old data
25
- * @param newData - New Data
26
- * @returns Patch string
27
- */
28
- function makePatch<T extends JsonValue>(
29
- filename: string,
30
- oldData: T | string,
31
- newData: T | string,
32
- serializer: ScaffoldTaskSerializer<T> = stringifyJson
33
- ) {
34
- return createPatch(
35
- filename,
36
- _.isString(oldData) ? oldData : serializer(oldData),
37
- _.isString(newData) ? newData : serializer(newData)
38
- );
39
- }
40
-
41
21
  /**
42
22
  * Options for a task which are not the {@link ScaffoldTaskOptions base options}
43
23
  */
@@ -55,6 +35,84 @@ export type ScaffoldTask<Opts extends ScaffoldTaskOptions, T extends JsonObject>
55
35
  opts: Opts
56
36
  ) => Promise<ScaffoldTaskResult<T>>;
57
37
 
38
+ /**
39
+ * Optional function which can be used to post-process the content of a file. Usually used to merge
40
+ * various options with existing content
41
+ */
42
+ export type ScaffoldTaskTransformer<Opts extends ScaffoldTaskOptions, T extends JsonValue> = (
43
+ content: Readonly<T>,
44
+ opts: TaskSpecificOpts<Opts>,
45
+ pkg: Readonly<NormalizedPackageJson>
46
+ ) => T;
47
+
48
+ /**
49
+ * A function which deserializes a string into a JS value.
50
+ */
51
+ export type ScaffoldTaskDeserializer<T> = (content: string) => T;
52
+
53
+ /**
54
+ * A function which serializes a JS value into a string.
55
+ */
56
+ export type ScaffoldTaskSerializer<T> = (content: T) => string;
57
+
58
+ /**
59
+ * Options for {@linkcode createScaffoldTask}
60
+ */
61
+ export interface CreateScaffoldTaskOptions<Opts extends ScaffoldTaskOptions, T extends JsonValue> {
62
+ /**
63
+ * Transformer function
64
+ */
65
+ transform?: ScaffoldTaskTransformer<Opts, T>;
66
+ /**
67
+ * Deserializer function
68
+ */
69
+ deserialize?: ScaffoldTaskDeserializer<T>;
70
+ /**
71
+ * Serializer function
72
+ */
73
+ serialize?: ScaffoldTaskSerializer<T>;
74
+ }
75
+
76
+ /**
77
+ * Base options for all scaffold tasks
78
+ */
79
+ export interface ScaffoldTaskOptions {
80
+ /**
81
+ * Current working directory
82
+ */
83
+ cwd?: string;
84
+ /**
85
+ * Destination file
86
+ */
87
+ dest?: string;
88
+ /**
89
+ * If `true` will not write files
90
+ */
91
+ dryRun?: boolean;
92
+ /**
93
+ * If `true` will overwrite fields in `typedoc.json`
94
+ */
95
+ overwrite?: boolean;
96
+ /**
97
+ * Path to `package.json`
98
+ */
99
+ packageJson?: string;
100
+ }
101
+
102
+ /**
103
+ * The return value of a {@linkcode ScaffoldTask}
104
+ */
105
+ export interface ScaffoldTaskResult<T> {
106
+ /**
107
+ * The content of whatever it wrote or would write
108
+ */
109
+ content: T;
110
+ /**
111
+ * The filepath of whatever it wrote or would write
112
+ */
113
+ path: string;
114
+ }
115
+
58
116
  /**
59
117
  * Factory for a {@linkcode ScaffoldTask}.
60
118
  *
@@ -153,79 +211,21 @@ export function createScaffoldTask<Opts extends ScaffoldTaskOptions, T extends J
153
211
  }
154
212
 
155
213
  /**
156
- * Optional function which can be used to post-process the content of a file. Usually used to merge
157
- * various options with existing content
158
- */
159
- export type ScaffoldTaskTransformer<Opts extends ScaffoldTaskOptions, T extends JsonValue> = (
160
- content: Readonly<T>,
161
- opts: TaskSpecificOpts<Opts>,
162
- pkg: Readonly<NormalizedPackageJson>
163
- ) => T;
164
-
165
- /**
166
- * A function which deserializes a string into a JS value.
167
- */
168
- export type ScaffoldTaskDeserializer<T> = (content: string) => T;
169
-
170
- /**
171
- * A function which serializes a JS value into a string.
172
- */
173
- export type ScaffoldTaskSerializer<T> = (content: T) => string;
174
-
175
- /**
176
- * Options for {@linkcode createScaffoldTask}
177
- */
178
- export interface CreateScaffoldTaskOptions<Opts extends ScaffoldTaskOptions, T extends JsonValue> {
179
- /**
180
- * Transformer function
181
- */
182
- transform?: ScaffoldTaskTransformer<Opts, T>;
183
- /**
184
- * Deserializer function
185
- */
186
- deserialize?: ScaffoldTaskDeserializer<T>;
187
- /**
188
- * Serializer function
189
- */
190
- serialize?: ScaffoldTaskSerializer<T>;
191
- }
192
-
193
- /**
194
- * Base options for all scaffold tasks
195
- */
196
- export interface ScaffoldTaskOptions {
197
- /**
198
- * Current working directory
199
- */
200
- cwd?: string;
201
- /**
202
- * Destination file
203
- */
204
- dest?: string;
205
- /**
206
- * If `true` will not write files
207
- */
208
- dryRun?: boolean;
209
- /**
210
- * If `true` will overwrite fields in `typedoc.json`
211
- */
212
- overwrite?: boolean;
213
- /**
214
- * Path to `package.json`
215
- */
216
- packageJson?: string;
217
- }
218
-
219
- /**
220
- * The return value of a {@linkcode ScaffoldTask}
214
+ * Creates a unified patch for display in "dry run" mode
215
+ * @param filename - File name to use
216
+ * @param oldData - Old data
217
+ * @param newData - New Data
218
+ * @returns Patch string
221
219
  */
222
- export interface ScaffoldTaskResult<T> {
223
- /**
224
- * The content of whatever it wrote or would write
225
- */
226
- content: T;
227
- /**
228
- * The filepath of whatever it wrote or would write
229
- */
230
- path: string;
220
+ function makePatch<T extends JsonValue>(
221
+ filename: string,
222
+ oldData: T | string,
223
+ newData: T | string,
224
+ serializer: ScaffoldTaskSerializer<T> = stringifyJson
225
+ ) {
226
+ return createPatch(
227
+ filename,
228
+ _.isString(oldData) ? oldData : serializer(oldData),
229
+ _.isString(newData) ? newData : serializer(newData)
230
+ );
231
231
  }
package/lib/util.ts CHANGED
@@ -73,6 +73,8 @@ export const argify: (obj: Record<string, string | number | boolean | undefined>
73
73
  _.flatten
74
74
  );
75
75
 
76
+ export type SpawnBackgroundProcessOpts = Omit<SpawnOptions, 'stdio'>;
77
+
76
78
  /**
77
79
  * Spawns a long-running "background" child process. This is expected to only return control to the
78
80
  * parent process in the case of a nonzero exit code from the child process.
@@ -97,8 +99,6 @@ export async function spawnBackgroundProcess(command: string, args: string[], op
97
99
  });
98
100
  }
99
101
 
100
- export type SpawnBackgroundProcessOpts = Omit<SpawnOptions, 'stdio'>;
101
-
102
102
  /**
103
103
  * Wraps {@linkcode exec} with error handling that appends stderr to the thrown error message.
104
104
  */
package/lib/validate.ts CHANGED
@@ -41,6 +41,29 @@ const log = getLogger('validate');
41
41
  */
42
42
  export type ValidationKind = typeof NAME_PYTHON | typeof NAME_MKDOCS;
43
43
 
44
+ export interface DocutilsValidatorOpts {
45
+ /**
46
+ * Current working directory
47
+ */
48
+ cwd?: string;
49
+ /**
50
+ * Path to `mkdocs.yml`
51
+ */
52
+ mkdocsYml?: string;
53
+ /**
54
+ * If `true`, run Python validation
55
+ */
56
+ python?: boolean;
57
+ /**
58
+ * Path to `python` executable
59
+ */
60
+ pythonPath?: string;
61
+ /**
62
+ * If `true`, run MkDocs validation
63
+ */
64
+ mkdocs?: boolean;
65
+ }
66
+
44
67
  /**
45
68
  * This class is designed to run _all_ validation checks (as requested by the user), and emit events for
46
69
  * each failure encountered.
@@ -51,6 +74,30 @@ export type ValidationKind = typeof NAME_PYTHON | typeof NAME_MKDOCS;
51
74
  * @todo Use [`strict-event-emitter-types`](https://npm.im/strict-event-emitter-types)
52
75
  */
53
76
  export class DocutilsValidator extends EventEmitter {
77
+ /**
78
+ * Emitted when validation begins with a list of validation kinds to be performed
79
+ * @event
80
+ */
81
+ public static readonly BEGIN = 'begin';
82
+
83
+ /**
84
+ * Emitted when validation ends with an error count
85
+ * @event
86
+ */
87
+ public static readonly END = 'end';
88
+
89
+ /**
90
+ * Emitted when a validation fails, with the associated {@linkcode DocutilsError}
91
+ * @event
92
+ */
93
+ public static readonly FAILURE = 'fail';
94
+
95
+ /**
96
+ * Emitted when a validation succeeds
97
+ * @event
98
+ */
99
+ public static readonly SUCCESS = 'ok';
100
+
54
101
  /**
55
102
  * Current working directory. Defaults to `process.cwd()`
56
103
  * @todo This cannot yet be overridden by user
@@ -82,30 +129,6 @@ export class DocutilsValidator extends EventEmitter {
82
129
  */
83
130
  protected mkDocsYmlPath?: string;
84
131
 
85
- /**
86
- * Emitted when validation begins with a list of validation kinds to be performed
87
- * @event
88
- */
89
- public static readonly BEGIN = 'begin';
90
-
91
- /**
92
- * Emitted when validation ends with an error count
93
- * @event
94
- */
95
- public static readonly END = 'end';
96
-
97
- /**
98
- * Emitted when a validation fails, with the associated {@linkcode DocutilsError}
99
- * @event
100
- */
101
- public static readonly FAILURE = 'fail';
102
-
103
- /**
104
- * Emitted when a validation succeeds
105
- * @event
106
- */
107
- public static readonly SUCCESS = 'ok';
108
-
109
132
  private requirementsTxt: PipPackage[] | undefined;
110
133
 
111
134
  /**
@@ -392,30 +415,3 @@ export class DocutilsValidator extends EventEmitter {
392
415
  this.ok('Python version OK');
393
416
  }
394
417
  }
395
-
396
- /**
397
- * Options for {@linkcode DocutilsValidator} constructor
398
- */
399
-
400
- export interface DocutilsValidatorOpts {
401
- /**
402
- * Current working directory
403
- */
404
- cwd?: string;
405
- /**
406
- * Path to `mkdocs.yml`
407
- */
408
- mkdocsYml?: string;
409
- /**
410
- * If `true`, run Python validation
411
- */
412
- python?: boolean;
413
- /**
414
- * Path to `python` executable
415
- */
416
- pythonPath?: string;
417
- /**
418
- * If `true`, run MkDocs validation
419
- */
420
- mkdocs?: boolean;
421
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/docutils",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Documentation generation utilities for Appium and related projects",
5
5
  "keywords": [
6
6
  "automation",
@@ -46,15 +46,15 @@
46
46
  "start": "node ./build/lib/cli/index.js"
47
47
  },
48
48
  "dependencies": {
49
- "@appium/support": "7.1.0",
49
+ "@appium/support": "7.1.1",
50
50
  "consola": "3.4.2",
51
- "diff": "8.0.4",
51
+ "diff": "9.0.0",
52
52
  "lilconfig": "3.1.3",
53
53
  "lodash": "4.18.1",
54
54
  "package-directory": "8.2.0",
55
55
  "read-pkg": "10.1.0",
56
- "teen_process": "4.1.0",
57
- "type-fest": "5.5.0",
56
+ "teen_process": "4.1.1",
57
+ "type-fest": "5.6.0",
58
58
  "yaml": "2.8.3",
59
59
  "yargs": "18.0.0",
60
60
  "yargs-parser": "22.0.0"
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "7a8965f5c30ffec2ad04ce75903b3960537cef06"
69
+ "gitHead": "17f84265d10944fec06ae7684ae8ad77d1224b50"
70
70
  }
package/requirements.txt CHANGED
@@ -2,4 +2,4 @@ mkdocs==1.6.1
2
2
  mkdocs-git-revision-date-localized-plugin==1.5.1
3
3
  mkdocs-material==9.7.6
4
4
  mkdocs-redirects==1.2.3
5
- mike==2.1.4
5
+ mike==2.2.0