@appium/docutils 2.4.1 → 2.4.3
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/build/lib/builder/deploy.d.ts.map +1 -1
- package/build/lib/builder/deploy.js +2 -3
- package/build/lib/builder/deploy.js.map +1 -1
- package/build/lib/cli/check.d.ts.map +1 -1
- package/build/lib/cli/check.js +9 -11
- package/build/lib/cli/check.js.map +1 -1
- package/build/lib/cli/config.d.ts.map +1 -1
- package/build/lib/cli/config.js +1 -2
- package/build/lib/cli/config.js.map +1 -1
- package/build/lib/cli/index.d.ts.map +1 -1
- package/build/lib/cli/index.js +1 -2
- package/build/lib/cli/index.js.map +1 -1
- package/build/lib/fs.d.ts +19 -7
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +21 -18
- package/build/lib/fs.js.map +1 -1
- package/build/lib/logger.d.ts +0 -7
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +8 -6
- package/build/lib/logger.js.map +1 -1
- package/build/lib/scaffold.d.ts.map +1 -1
- package/build/lib/scaffold.js +4 -5
- package/build/lib/scaffold.js.map +1 -1
- package/build/lib/util.d.ts +16 -6
- package/build/lib/util.d.ts.map +1 -1
- package/build/lib/util.js +69 -18
- package/build/lib/util.js.map +1 -1
- package/build/lib/validate.d.ts.map +1 -1
- package/build/lib/validate.js +3 -7
- package/build/lib/validate.js.map +1 -1
- package/lib/builder/deploy.ts +10 -5
- package/lib/cli/check.ts +10 -9
- package/lib/cli/config.ts +1 -2
- package/lib/cli/index.ts +1 -2
- package/lib/fs.ts +22 -27
- package/lib/logger.ts +7 -3
- package/lib/scaffold.ts +7 -8
- package/lib/util.ts +69 -26
- package/lib/validate.ts +3 -4
- package/package.json +4 -5
- package/requirements.txt +1 -1
package/lib/util.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import _ from 'lodash';
|
|
7
1
|
import type {SpawnOptions} from 'node:child_process';
|
|
8
2
|
import {spawn} from 'node:child_process';
|
|
9
3
|
import path from 'node:path';
|
|
10
4
|
import type {ExecError, TeenProcessExecOptions} from 'teen_process';
|
|
11
5
|
import {exec} from 'teen_process';
|
|
6
|
+
import {util as supportUtil} from '@appium/support';
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
9
|
* Computes a relative path, prepending `./`
|
|
15
10
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
)
|
|
11
|
+
export function relative(from: string): (to: string) => string;
|
|
12
|
+
export function relative(from: string, to: string): string;
|
|
13
|
+
export function relative(from: string, to?: string): string | ((to: string) => string) {
|
|
14
|
+
if (to === undefined) {
|
|
15
|
+
return (nextTo: string) => `.${path.sep}${path.relative(from, nextTo)}`;
|
|
16
|
+
}
|
|
17
|
+
return `.${path.sep}${path.relative(from, to)}`;
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* A stopwatch-like thing
|
|
@@ -48,9 +48,8 @@ export type TupleToObject<
|
|
|
48
48
|
* @param value any value
|
|
49
49
|
* @returns `true` if the array is `string[]`
|
|
50
50
|
*/
|
|
51
|
-
export const isStringArray =
|
|
52
|
-
value
|
|
53
|
-
) => value is string[];
|
|
51
|
+
export const isStringArray = (value: any): value is string[] =>
|
|
52
|
+
Array.isArray(value) && value.every((item) => typeof item === 'string');
|
|
54
53
|
|
|
55
54
|
/**
|
|
56
55
|
* Converts an object of string values to an array of arguments for CLI
|
|
@@ -58,23 +57,67 @@ export const isStringArray = _.overEvery(_.isArray, _.partial(_.every, _, _.isSt
|
|
|
58
57
|
* Supports `boolean` and `number` values as well. `boolean`s are assumed to be flags which default
|
|
59
58
|
* to `false`, so they will only be added to the array if the value is `true`.
|
|
60
59
|
*/
|
|
61
|
-
export const argify
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
);
|
|
60
|
+
export const argify = (obj: Record<string, string | number | boolean | undefined>): string[] => {
|
|
61
|
+
const args: string[] = [];
|
|
62
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
63
|
+
if (value === true) {
|
|
64
|
+
args.push(`--${key}`);
|
|
65
|
+
} else if (value === false || value === undefined) {
|
|
66
|
+
continue;
|
|
67
|
+
} else {
|
|
68
|
+
args.push(`--${key}`, String(value));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return args;
|
|
72
|
+
};
|
|
75
73
|
|
|
76
74
|
export type SpawnBackgroundProcessOpts = Omit<SpawnOptions, 'stdio'>;
|
|
77
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Converts a string to kebab-case.
|
|
78
|
+
* @param value Input string
|
|
79
|
+
* @returns Kebab-cased string
|
|
80
|
+
*/
|
|
81
|
+
export function kebabCase(value: string): string {
|
|
82
|
+
return value
|
|
83
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
84
|
+
.replace(/[_\s]+/g, '-')
|
|
85
|
+
.toLowerCase();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Performs a deep "defaults" merge into a clone of `target`.
|
|
90
|
+
* Only undefined properties in `target` are filled from `defaults`.
|
|
91
|
+
* @param target Destination object
|
|
92
|
+
* @param defaults Default values object
|
|
93
|
+
* @returns Merged clone
|
|
94
|
+
*/
|
|
95
|
+
export function mergeDefaultsDeep<T extends Record<string, any>>(target: T, defaults: T): T {
|
|
96
|
+
const out = structuredClone(target);
|
|
97
|
+
const stack: Array<{dest: Record<string, any>; src: Record<string, any>}> = [
|
|
98
|
+
{dest: out, src: defaults},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
while (stack.length) {
|
|
102
|
+
const next = stack.pop();
|
|
103
|
+
if (!next) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const {dest, src} = next;
|
|
107
|
+
for (const [key, srcVal] of Object.entries(src)) {
|
|
108
|
+
const destVal = dest[key];
|
|
109
|
+
if (destVal === undefined) {
|
|
110
|
+
dest[key] = structuredClone(srcVal);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (supportUtil.isPlainObject(destVal) && supportUtil.isPlainObject(srcVal)) {
|
|
114
|
+
stack.push({dest: destVal, src: srcVal});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out as T;
|
|
119
|
+
}
|
|
120
|
+
|
|
78
121
|
/**
|
|
79
122
|
* Spawns a long-running "background" child process. This is expected to only return control to the
|
|
80
123
|
* parent process in the case of a nonzero exit code from the child process.
|
package/lib/validate.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {fs, util} from '@appium/support';
|
|
8
|
-
import _ from 'lodash';
|
|
9
8
|
import {EventEmitter} from 'node:events';
|
|
10
9
|
import {exec} from 'teen_process';
|
|
11
10
|
import {
|
|
@@ -184,7 +183,7 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
184
183
|
* @returns
|
|
185
184
|
*/
|
|
186
185
|
protected fail(err: DocutilsError | string) {
|
|
187
|
-
const dErr =
|
|
186
|
+
const dErr = typeof err === 'string' ? new DocutilsError(err) : err;
|
|
188
187
|
if (!this.emittedErrors.has(dErr.message)) {
|
|
189
188
|
this.emit(DocutilsValidator.FAILURE, dErr);
|
|
190
189
|
}
|
|
@@ -265,7 +264,7 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
265
264
|
}
|
|
266
265
|
const version = match[1];
|
|
267
266
|
const reqs = await this.parseRequirementsTxt();
|
|
268
|
-
const mkDocsPipPkg =
|
|
267
|
+
const mkDocsPipPkg = reqs.find((pkg) => pkg.name === NAME_MKDOCS);
|
|
269
268
|
if (!mkDocsPipPkg) {
|
|
270
269
|
throw new DocutilsError(
|
|
271
270
|
`No ${NAME_MKDOCS} package in ${REQUIREMENTS_TXT_PATH}. This is a bug`,
|
|
@@ -350,7 +349,7 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
350
349
|
return this.fail(`Could not parse output of "${NAME_PIP} list" as JSON: ${pipListOutput}`);
|
|
351
350
|
}
|
|
352
351
|
|
|
353
|
-
const pkgsByName =
|
|
352
|
+
const pkgsByName = Object.fromEntries(installedPkgs.map((pkg) => [pkg.name, pkg.version]));
|
|
354
353
|
log.debug('Installed Python packages: %O', pkgsByName);
|
|
355
354
|
|
|
356
355
|
const requiredPackages = await this.parseRequirementsTxt();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/docutils",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "Documentation generation utilities for Appium and related projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -46,16 +46,15 @@
|
|
|
46
46
|
"start": "node ./build/lib/cli/index.js"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@appium/support": "7.2.
|
|
49
|
+
"@appium/support": "7.2.3",
|
|
50
50
|
"consola": "3.4.2",
|
|
51
51
|
"diff": "9.0.0",
|
|
52
52
|
"lilconfig": "3.1.3",
|
|
53
|
-
"lodash": "4.18.1",
|
|
54
53
|
"package-directory": "8.2.0",
|
|
55
54
|
"read-pkg": "10.1.0",
|
|
56
55
|
"teen_process": "4.1.3",
|
|
57
56
|
"type-fest": "5.6.0",
|
|
58
|
-
"yaml": "2.
|
|
57
|
+
"yaml": "2.9.0",
|
|
59
58
|
"yargs": "18.0.0",
|
|
60
59
|
"yargs-parser": "22.0.0"
|
|
61
60
|
},
|
|
@@ -66,5 +65,5 @@
|
|
|
66
65
|
"publishConfig": {
|
|
67
66
|
"access": "public"
|
|
68
67
|
},
|
|
69
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "8018f8b70ecc975fa115e19072ef337b8473865d"
|
|
70
69
|
}
|
package/requirements.txt
CHANGED