@appium/docutils 1.1.1 → 2.0.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/build/lib/cli/command/init.d.ts +0 -27
- package/build/lib/cli/command/init.d.ts.map +1 -1
- package/build/lib/cli/command/init.js +0 -31
- package/build/lib/cli/command/init.js.map +1 -1
- package/build/lib/cli/command/validate.d.ts +0 -24
- package/build/lib/cli/command/validate.d.ts.map +1 -1
- package/build/lib/cli/command/validate.js +2 -26
- package/build/lib/cli/command/validate.js.map +1 -1
- package/build/lib/cli/config.d.ts.map +1 -1
- package/build/lib/cli/config.js +0 -9
- package/build/lib/cli/config.js.map +1 -1
- package/build/lib/constants.d.ts +0 -17
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +1 -18
- package/build/lib/constants.js.map +1 -1
- package/build/lib/fs.d.ts +0 -24
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +4 -55
- package/build/lib/fs.js.map +1 -1
- package/build/lib/init.d.ts +3 -21
- package/build/lib/init.d.ts.map +1 -1
- package/build/lib/init.js +2 -85
- package/build/lib/init.js.map +1 -1
- package/build/lib/model.d.ts +1 -7
- package/build/lib/model.d.ts.map +1 -1
- package/build/lib/validate.d.ts +2 -52
- package/build/lib/validate.d.ts.map +1 -1
- package/build/lib/validate.js +0 -118
- package/build/lib/validate.js.map +1 -1
- package/lib/cli/command/init.ts +0 -28
- package/lib/cli/command/validate.ts +2 -26
- package/lib/cli/config.ts +0 -9
- package/lib/constants.ts +0 -23
- package/lib/fs.ts +1 -26
- package/lib/init.ts +4 -79
- package/lib/model.ts +1 -8
- package/lib/validate.ts +2 -193
- package/package.json +10 -15
- package/requirements.txt +1 -1
package/lib/constants.ts
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const {LogLevels} = require('consola');
|
|
7
|
-
import {readFileSync} from 'node:fs';
|
|
8
7
|
import {fs} from '@appium/support';
|
|
9
8
|
import path from 'node:path';
|
|
10
|
-
import {PackageJson} from 'type-fest';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* CLI executable name
|
|
@@ -19,10 +17,6 @@ export const NAME_BIN = 'appium-docs';
|
|
|
19
17
|
*/
|
|
20
18
|
export const NAME_MKDOCS_YML = 'mkdocs.yml';
|
|
21
19
|
|
|
22
|
-
/**
|
|
23
|
-
* Default name of the `tsconfig.json` config file
|
|
24
|
-
*/
|
|
25
|
-
export const NAME_TSCONFIG_JSON = 'tsconfig.json';
|
|
26
20
|
/**
|
|
27
21
|
* `python` executable
|
|
28
22
|
*/
|
|
@@ -58,16 +52,6 @@ export const NAME_MIKE = 'mike';
|
|
|
58
52
|
*/
|
|
59
53
|
export const NAME_PIP = 'pip';
|
|
60
54
|
|
|
61
|
-
/**
|
|
62
|
-
* Name of the `npm` executable, which we use to check for
|
|
63
|
-
*/
|
|
64
|
-
export const NAME_NPM = 'npm';
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The name of the `typescript` package (not the `tsc` executable)
|
|
68
|
-
*/
|
|
69
|
-
export const NAME_TYPESCRIPT = 'typescript';
|
|
70
|
-
|
|
71
55
|
/**
|
|
72
56
|
* Code for a "file not found" error
|
|
73
57
|
*/
|
|
@@ -86,13 +70,6 @@ export const DEFAULT_LOG_LEVEL = 'info';
|
|
|
86
70
|
* Blocking I/O
|
|
87
71
|
*/
|
|
88
72
|
export const PKG_ROOT_DIR = fs.findRoot(__dirname);
|
|
89
|
-
/**
|
|
90
|
-
* Blocking I/O
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
export const DOCUTILS_PKG: PackageJson = JSON.parse(
|
|
94
|
-
readFileSync(path.join(PKG_ROOT_DIR, NAME_PACKAGE_JSON), 'utf8'),
|
|
95
|
-
);
|
|
96
73
|
|
|
97
74
|
/**
|
|
98
75
|
* Path to the `requirements.txt` file (in this package)
|
package/lib/fs.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {fs} from '@appium/support';
|
|
7
|
-
import * as JSON5 from 'json5';
|
|
8
7
|
import _ from 'lodash';
|
|
9
8
|
import path from 'node:path';
|
|
10
9
|
import _pkgDir from 'pkg-dir';
|
|
@@ -16,7 +15,6 @@ import {
|
|
|
16
15
|
NAME_MIKE,
|
|
17
16
|
NAME_MKDOCS,
|
|
18
17
|
NAME_MKDOCS_YML,
|
|
19
|
-
NAME_NPM,
|
|
20
18
|
NAME_PACKAGE_JSON,
|
|
21
19
|
NAME_PYTHON,
|
|
22
20
|
} from './constants';
|
|
@@ -32,7 +30,7 @@ const log = getLogger('fs');
|
|
|
32
30
|
*
|
|
33
31
|
* Caches result
|
|
34
32
|
*/
|
|
35
|
-
|
|
33
|
+
const findPkgDir = _.memoize(_pkgDir);
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
36
|
* Stringifies a thing into a YAML
|
|
@@ -45,16 +43,6 @@ export const stringifyYaml: (value: JsonValue) => string = _.partialRight(
|
|
|
45
43
|
undefined,
|
|
46
44
|
);
|
|
47
45
|
|
|
48
|
-
/**
|
|
49
|
-
* Stringifies something into JSON5. I think the only difference between this and `JSON.stringify`
|
|
50
|
-
* is that if an object has a `toJSON5()` method, it will be used.
|
|
51
|
-
* @param value Something to stringify
|
|
52
|
-
* @returns JSON5 string
|
|
53
|
-
*/
|
|
54
|
-
export const stringifyJson5: (value: JsonValue) => string = _.partialRight(JSON5.stringify, {
|
|
55
|
-
indent: 2,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
46
|
/**
|
|
59
47
|
* Pretty-stringifies a JSON value
|
|
60
48
|
* @param value Something to stringify
|
|
@@ -143,14 +131,6 @@ async function _readPkgJson(
|
|
|
143
131
|
*/
|
|
144
132
|
export const readPackageJson = _.memoize(_readPkgJson);
|
|
145
133
|
|
|
146
|
-
/**
|
|
147
|
-
* Reads a JSON5 file and parses it
|
|
148
|
-
*/
|
|
149
|
-
export const readJson5 = _.memoize(
|
|
150
|
-
async <T extends JsonValue>(filepath: string): Promise<T> =>
|
|
151
|
-
JSON5.parse(await fs.readFile(filepath, 'utf8')),
|
|
152
|
-
);
|
|
153
|
-
|
|
154
134
|
/**
|
|
155
135
|
* Reads a JSON file and parses it
|
|
156
136
|
*/
|
|
@@ -178,11 +158,6 @@ type WhichFunction = (cmd: string, opts?: {nothrow: boolean}) => Promise<string|
|
|
|
178
158
|
*/
|
|
179
159
|
const cachedWhich = _.memoize(fs.which as WhichFunction);
|
|
180
160
|
|
|
181
|
-
/**
|
|
182
|
-
* Finds `npm` executable
|
|
183
|
-
*/
|
|
184
|
-
export const whichNpm = _.partial(cachedWhich, NAME_NPM, {nothrow: true});
|
|
185
|
-
|
|
186
161
|
/**
|
|
187
162
|
* Finds `python` executable
|
|
188
163
|
*/
|
package/lib/init.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import {NAME_MKDOCS_YML, NAME_TSCONFIG_JSON, PIP_ENV_VARS, REQUIREMENTS_TXT_PATH} from './constants';
|
|
7
|
+
import {NAME_MKDOCS_YML, PIP_ENV_VARS, REQUIREMENTS_TXT_PATH} from './constants';
|
|
9
8
|
import YAML from 'yaml';
|
|
10
9
|
import {exec} from 'teen_process';
|
|
11
10
|
import {Simplify} from 'type-fest';
|
|
@@ -13,9 +12,8 @@ import {DocutilsError} from './error';
|
|
|
13
12
|
import {createScaffoldTask, ScaffoldTaskOptions} from './scaffold';
|
|
14
13
|
import type { ScaffoldTask } from './scaffold';
|
|
15
14
|
import {getLogger} from './logger';
|
|
16
|
-
import {MkDocsYml
|
|
17
|
-
import
|
|
18
|
-
import {requirePython, stringifyJson5, stringifyYaml} from './fs';
|
|
15
|
+
import {MkDocsYml} from './model';
|
|
16
|
+
import {requirePython, stringifyYaml} from './fs';
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* Data for the base `mkdocs.yml` file
|
|
@@ -26,54 +24,9 @@ const BASE_MKDOCS_YML: Readonly<MkDocsYml> = Object.freeze({
|
|
|
26
24
|
site_dir: 'site',
|
|
27
25
|
});
|
|
28
26
|
|
|
29
|
-
/**
|
|
30
|
-
* Data for the base `tsconfig.json` file
|
|
31
|
-
*/
|
|
32
|
-
const BASE_TSCONFIG_JSON: Readonly<TsConfigJson> = Object.freeze({
|
|
33
|
-
$schema: 'https://json.schemastore.org/tsconfig',
|
|
34
|
-
extends: '@appium/tsconfig/tsconfig.json',
|
|
35
|
-
compilerOptions: {
|
|
36
|
-
outDir: 'build',
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
27
|
const log = getLogger('init');
|
|
41
28
|
const dryRunLog = getLogger('dry-run', log);
|
|
42
29
|
|
|
43
|
-
/**
|
|
44
|
-
* Files included, by default, in `tsconfig.json`
|
|
45
|
-
*/
|
|
46
|
-
const DEFAULT_INCLUDE = ['lib', 'test', 'index.js'];
|
|
47
|
-
/**
|
|
48
|
-
* Function which scaffolds a `tsconfig.json` file
|
|
49
|
-
*/
|
|
50
|
-
export const initTsConfigJson = createScaffoldTask<InitTsConfigOptions, TsConfigJson>(
|
|
51
|
-
NAME_TSCONFIG_JSON,
|
|
52
|
-
BASE_TSCONFIG_JSON,
|
|
53
|
-
'TypeScript configuration',
|
|
54
|
-
{
|
|
55
|
-
/**
|
|
56
|
-
* Merges the contents of the `include` property with any passed on the CLI. If neither exists,
|
|
57
|
-
* uses the default set of includes.
|
|
58
|
-
* @param content Parsed and/or scaffolded `tsconfig.json`
|
|
59
|
-
* @param opts Options specific to this task
|
|
60
|
-
* @returns `tsconfig.json` content with potentially-modified `include` prop
|
|
61
|
-
*/
|
|
62
|
-
transform: (content, {include}) => {
|
|
63
|
-
include = [...(content.include ?? include ?? [])];
|
|
64
|
-
if (_.isEmpty(include)) {
|
|
65
|
-
include = [...DEFAULT_INCLUDE];
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
...content,
|
|
69
|
-
include: _.uniq(include),
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
deserialize: JSON5.parse,
|
|
73
|
-
serialize: stringifyJson5,
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
|
|
77
30
|
/**
|
|
78
31
|
* Function which scaffolds an `mkdocs.yml` file
|
|
79
32
|
*/
|
|
@@ -192,12 +145,9 @@ export interface InitMkDocsOptions extends ScaffoldTaskOptions {
|
|
|
192
145
|
* console output which would need mitigation.
|
|
193
146
|
*/
|
|
194
147
|
export async function init({
|
|
195
|
-
typescript,
|
|
196
148
|
python,
|
|
197
|
-
tsconfigJson: tsconfigJsonPath,
|
|
198
149
|
packageJson: packageJsonPath,
|
|
199
150
|
overwrite,
|
|
200
|
-
include,
|
|
201
151
|
mkdocs,
|
|
202
152
|
mkdocsYml: mkdocsYmlPath,
|
|
203
153
|
siteName,
|
|
@@ -209,17 +159,6 @@ export async function init({
|
|
|
209
159
|
pythonPath,
|
|
210
160
|
upgrade,
|
|
211
161
|
}: InitOptions = {}): Promise<void> {
|
|
212
|
-
if (typescript && !upgrade) {
|
|
213
|
-
await initTsConfigJson({
|
|
214
|
-
dest: tsconfigJsonPath,
|
|
215
|
-
packageJson: packageJsonPath,
|
|
216
|
-
overwrite,
|
|
217
|
-
include,
|
|
218
|
-
dryRun,
|
|
219
|
-
cwd,
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
162
|
if (python) {
|
|
224
163
|
await initPython({pythonPath, dryRun, upgrade});
|
|
225
164
|
}
|
|
@@ -239,12 +178,6 @@ export async function init({
|
|
|
239
178
|
}
|
|
240
179
|
}
|
|
241
180
|
|
|
242
|
-
export interface InitTsConfigOptions extends ScaffoldTaskOptions {
|
|
243
|
-
/**
|
|
244
|
-
* List of source files (globs supported); typically `src` or `lib`
|
|
245
|
-
*/
|
|
246
|
-
include?: string[];
|
|
247
|
-
}
|
|
248
181
|
export interface InitPythonOptions extends ScaffoldTaskOptions {
|
|
249
182
|
/**
|
|
250
183
|
* Path to `python` (v3.x) executable
|
|
@@ -263,11 +196,7 @@ export interface InitPythonOptions extends ScaffoldTaskOptions {
|
|
|
263
196
|
* The props of the various "path" options are rewritten as `dest` for the scaffold tasks functions.
|
|
264
197
|
*/
|
|
265
198
|
export type InitOptions = Simplify<
|
|
266
|
-
Omit<InitPythonOptions &
|
|
267
|
-
/**
|
|
268
|
-
* If `true` will initialize a `tsconfig.json` file
|
|
269
|
-
*/
|
|
270
|
-
typescript?: boolean;
|
|
199
|
+
Omit<InitPythonOptions & InitMkDocsOptions, 'dest'> & {
|
|
271
200
|
/**
|
|
272
201
|
* If `true` will install Python deps
|
|
273
202
|
*/
|
|
@@ -276,10 +205,6 @@ export type InitOptions = Simplify<
|
|
|
276
205
|
* If `true` will initialize a `mkdocs.yml` file
|
|
277
206
|
*/
|
|
278
207
|
mkdocs?: boolean;
|
|
279
|
-
/**
|
|
280
|
-
* Path to new or existing `tsconfig.json` file
|
|
281
|
-
*/
|
|
282
|
-
tsconfigJson?: string;
|
|
283
208
|
/**
|
|
284
209
|
* Path to existing `package.json` file
|
|
285
210
|
*/
|
package/lib/model.ts
CHANGED
|
@@ -4,14 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {Jsonify, JsonValue
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A `tsconfig.json` file w/ `$schema` prop
|
|
11
|
-
*/
|
|
12
|
-
export type TsConfigJson = TsConfigJsonBase & {
|
|
13
|
-
$schema?: string;
|
|
14
|
-
};
|
|
7
|
+
import type {Jsonify, JsonValue} from 'type-fest';
|
|
15
8
|
|
|
16
9
|
/**
|
|
17
10
|
* The `nav` prop of an `mkdocs.yml` file
|
package/lib/validate.ts
CHANGED
|
@@ -4,53 +4,37 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {fs,
|
|
7
|
+
import {fs, util} from '@appium/support';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import {EventEmitter} from 'node:events';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
import {satisfies} from 'semver';
|
|
13
11
|
import {exec} from 'teen_process';
|
|
14
12
|
import {
|
|
15
|
-
DOCUTILS_PKG,
|
|
16
13
|
MESSAGE_PYTHON_MISSING,
|
|
17
14
|
NAME_BIN,
|
|
18
15
|
NAME_ERR_ENOENT,
|
|
19
16
|
NAME_MKDOCS,
|
|
20
17
|
NAME_MKDOCS_YML,
|
|
21
|
-
NAME_NPM,
|
|
22
|
-
NAME_PACKAGE_JSON,
|
|
23
18
|
NAME_PIP,
|
|
24
19
|
NAME_PYTHON,
|
|
25
20
|
NAME_REQUIREMENTS_TXT,
|
|
26
|
-
NAME_TSCONFIG_JSON,
|
|
27
|
-
NAME_TYPESCRIPT,
|
|
28
21
|
REQUIREMENTS_TXT_PATH,
|
|
29
22
|
} from './constants';
|
|
30
23
|
import {DocutilsError} from './error';
|
|
31
24
|
import {
|
|
32
25
|
findMkDocsYml,
|
|
33
|
-
findPkgDir,
|
|
34
26
|
isMkDocsInstalled,
|
|
35
|
-
readJson5,
|
|
36
27
|
readMkDocsYml,
|
|
37
|
-
whichNpm,
|
|
38
28
|
findPython,
|
|
39
29
|
} from './fs';
|
|
40
30
|
import {getLogger} from './logger';
|
|
41
31
|
import {MkDocsYml, PipPackage} from './model';
|
|
42
|
-
import {relative} from './util';
|
|
43
32
|
|
|
44
33
|
/**
|
|
45
34
|
* Matches the Python version string from `python --version`
|
|
46
35
|
*/
|
|
47
36
|
const PYTHON_VER_STR = 'Python 3.';
|
|
48
37
|
|
|
49
|
-
/**
|
|
50
|
-
* Matches the TypeScript version string from `tsc --version`
|
|
51
|
-
*/
|
|
52
|
-
const TYPESCRIPT_VERSION_REGEX = /Version\s(\d+\.\d+\..+)/;
|
|
53
|
-
|
|
54
38
|
/**
|
|
55
39
|
* Matches the MkDocs version string from `mkdocs --version`
|
|
56
40
|
*/
|
|
@@ -61,11 +45,7 @@ const log = getLogger('validate');
|
|
|
61
45
|
/**
|
|
62
46
|
* The "kinds" of validation which were requested to be performed
|
|
63
47
|
*/
|
|
64
|
-
export type ValidationKind =
|
|
65
|
-
| typeof NAME_PYTHON
|
|
66
|
-
| typeof NAME_TYPESCRIPT
|
|
67
|
-
| typeof NAME_NPM
|
|
68
|
-
| typeof NAME_MKDOCS;
|
|
48
|
+
export type ValidationKind = typeof NAME_PYTHON | typeof NAME_MKDOCS;
|
|
69
49
|
|
|
70
50
|
/**
|
|
71
51
|
* This class is designed to run _all_ validation checks (as requested by the user), and emit events for
|
|
@@ -83,11 +63,6 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
83
63
|
*/
|
|
84
64
|
protected readonly cwd: string;
|
|
85
65
|
|
|
86
|
-
/**
|
|
87
|
-
* Path to `npm` executable.
|
|
88
|
-
*/
|
|
89
|
-
protected readonly npmPath?: string;
|
|
90
|
-
|
|
91
66
|
/**
|
|
92
67
|
* Path to `python` executable.
|
|
93
68
|
*/
|
|
@@ -113,21 +88,6 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
113
88
|
*/
|
|
114
89
|
protected mkDocsYmlPath?: string;
|
|
115
90
|
|
|
116
|
-
/**
|
|
117
|
-
* Path to `package.json`. If not provided, will be lazily resolved.
|
|
118
|
-
*/
|
|
119
|
-
protected packageJsonPath?: string;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Path to the package directory. If not provided, will be lazily resolved.
|
|
123
|
-
*/
|
|
124
|
-
protected pkgDir?: string;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Path to `tsconfig.json`. If not provided, will be lazily resolved.
|
|
128
|
-
*/
|
|
129
|
-
protected tsconfigJsonPath?: string;
|
|
130
|
-
|
|
131
91
|
/**
|
|
132
92
|
* Emitted when validation begins with a list of validation kinds to be performed
|
|
133
93
|
* @event
|
|
@@ -160,21 +120,13 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
160
120
|
constructor(opts: DocutilsValidatorOpts = {}) {
|
|
161
121
|
super();
|
|
162
122
|
|
|
163
|
-
this.packageJsonPath = opts.packageJson;
|
|
164
123
|
this.pythonPath = opts.pythonPath;
|
|
165
124
|
this.cwd = opts.cwd ?? process.cwd();
|
|
166
|
-
this.tsconfigJsonPath = opts.tsconfigJson;
|
|
167
|
-
this.npmPath = opts.npm;
|
|
168
125
|
this.mkDocsYmlPath = opts.mkdocsYml;
|
|
169
126
|
|
|
170
127
|
if (opts.python) {
|
|
171
128
|
this.validations.add(NAME_PYTHON);
|
|
172
129
|
}
|
|
173
|
-
if (opts.typescript) {
|
|
174
|
-
this.validations.add(NAME_TYPESCRIPT);
|
|
175
|
-
// npm validation is required for typescript
|
|
176
|
-
this.validations.add(NAME_NPM);
|
|
177
|
-
}
|
|
178
130
|
if (opts.mkdocs) {
|
|
179
131
|
this.validations.add(NAME_MKDOCS);
|
|
180
132
|
}
|
|
@@ -202,15 +154,6 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
202
154
|
await this.validateMkDocsConfig();
|
|
203
155
|
}
|
|
204
156
|
|
|
205
|
-
if (this.validations.has(NAME_NPM)) {
|
|
206
|
-
await this.validateNpmVersion();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (this.validations.has(NAME_TYPESCRIPT)) {
|
|
210
|
-
await this.validateTypeScript();
|
|
211
|
-
await this.validateTypeScriptConfig();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
157
|
this.emit(DocutilsValidator.END, this.emittedErrors.size);
|
|
215
158
|
} finally {
|
|
216
159
|
this.reset();
|
|
@@ -230,18 +173,6 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
230
173
|
}
|
|
231
174
|
}
|
|
232
175
|
|
|
233
|
-
/**
|
|
234
|
-
* Resolves with a the parent directory of `package.json`, if we can find it.
|
|
235
|
-
*/
|
|
236
|
-
protected async findPkgDir(): Promise<string | undefined> {
|
|
237
|
-
return (
|
|
238
|
-
this.pkgDir ??
|
|
239
|
-
(this.pkgDir = this.packageJsonPath
|
|
240
|
-
? path.dirname(this.packageJsonPath)
|
|
241
|
-
: await findPkgDir(this.cwd))
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
176
|
/**
|
|
246
177
|
* Emits a {@linkcode DocutilsValidator.SUCCESS} event
|
|
247
178
|
* @param message Success message
|
|
@@ -363,35 +294,6 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
363
294
|
this.ok(`MkDocs config at ${mkDocsYmlPath} OK`);
|
|
364
295
|
}
|
|
365
296
|
|
|
366
|
-
/**
|
|
367
|
-
* Validates that the version of `npm` matches what's described in this package's `engines` field.
|
|
368
|
-
*
|
|
369
|
-
* This is required because other validators need `npm exec` to work, which is only available in npm 7+.
|
|
370
|
-
*/
|
|
371
|
-
protected async validateNpmVersion() {
|
|
372
|
-
log.debug(`Validating ${NAME_NPM} version`);
|
|
373
|
-
|
|
374
|
-
const npmEngineRange = DOCUTILS_PKG.engines?.npm;
|
|
375
|
-
if (!npmEngineRange) {
|
|
376
|
-
throw new DocutilsError(`Could not find property 'engines.npm' in ${NAME_PACKAGE_JSON}. This is a bug`);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const npmPath = this.npmPath ?? (await whichNpm());
|
|
380
|
-
if (!npmPath) {
|
|
381
|
-
throw new DocutilsError(`Could not find ${NAME_NPM} in PATH. That seems weird, doesn't it?`);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
try {
|
|
385
|
-
const {stdout: npmVersion} = await npm.exec('-v', [], {cwd: this.cwd});
|
|
386
|
-
if (!satisfies(npmVersion.trim(), npmEngineRange)) {
|
|
387
|
-
return this.fail(`${NAME_NPM} v${npmVersion} is installed, but ${npmEngineRange} is required`);
|
|
388
|
-
}
|
|
389
|
-
} catch {
|
|
390
|
-
return this.fail(`Could not retrieve ${NAME_NPM} version`);
|
|
391
|
-
}
|
|
392
|
-
this.ok(`${NAME_NPM} version OK`);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
297
|
/**
|
|
396
298
|
* Asserts that the dependencies as listed in `requirements.txt` are installed.
|
|
397
299
|
*
|
|
@@ -495,83 +397,6 @@ export class DocutilsValidator extends EventEmitter {
|
|
|
495
397
|
}
|
|
496
398
|
this.ok('Python version OK');
|
|
497
399
|
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Asserts that TypeScript is installed, runnable, and the correct version.
|
|
501
|
-
*/
|
|
502
|
-
protected async validateTypeScript() {
|
|
503
|
-
log.debug(`Validating ${NAME_TYPESCRIPT} version`);
|
|
504
|
-
|
|
505
|
-
const pkgDir = await this.findPkgDir();
|
|
506
|
-
if (!pkgDir) {
|
|
507
|
-
return this.fail(`Could not find ${NAME_PACKAGE_JSON} in ${this.cwd}`);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
const npmPath = this.npmPath ?? (await whichNpm());
|
|
511
|
-
if (!npmPath) {
|
|
512
|
-
throw new DocutilsError(`Could not find ${NAME_NPM} in PATH. That seems weird, doesn't it?`);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
let typeScriptVersion: string;
|
|
516
|
-
let rawTypeScriptVersion: string;
|
|
517
|
-
try {
|
|
518
|
-
({stdout: rawTypeScriptVersion} = await npm.exec('exec', ['tsc', '--', '--version'], {
|
|
519
|
-
cwd: pkgDir,
|
|
520
|
-
}));
|
|
521
|
-
} catch {
|
|
522
|
-
return this.fail(`Could not find TypeScript compiler ("tsc") from ${pkgDir}`);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const match = rawTypeScriptVersion.match(TYPESCRIPT_VERSION_REGEX);
|
|
526
|
-
if (match) {
|
|
527
|
-
typeScriptVersion = match[1];
|
|
528
|
-
} else {
|
|
529
|
-
return this.fail(
|
|
530
|
-
`Could not parse TypeScript version from "tsc --version"; output was:\n ${rawTypeScriptVersion}`,
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
const reqdTypeScriptVersion = DOCUTILS_PKG.dependencies?.typescript;
|
|
535
|
-
if (!reqdTypeScriptVersion) {
|
|
536
|
-
throw new DocutilsError(
|
|
537
|
-
`Could not find ${NAME_TYPESCRIPT} dependency in ${NAME_PACKAGE_JSON}. This is a bug`,
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (!satisfies(typeScriptVersion, reqdTypeScriptVersion)) {
|
|
542
|
-
return this.fail(
|
|
543
|
-
`TypeScript v${typeScriptVersion} is installed, but v${reqdTypeScriptVersion} is required`,
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
this.ok('TypeScript install OK');
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Validates a `tsconfig.json` file
|
|
551
|
-
*/
|
|
552
|
-
protected async validateTypeScriptConfig() {
|
|
553
|
-
log.debug(`Validating ${NAME_TSCONFIG_JSON}`);
|
|
554
|
-
|
|
555
|
-
const pkgDir = await this.findPkgDir();
|
|
556
|
-
if (!pkgDir) {
|
|
557
|
-
return this.fail(`Could not find ${NAME_PACKAGE_JSON} in ${this.cwd}`);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
const tsconfigJsonPath = this.tsconfigJsonPath ?? path.join(pkgDir, NAME_TSCONFIG_JSON);
|
|
561
|
-
const relTsconfigJsonPath = relative(this.cwd, tsconfigJsonPath);
|
|
562
|
-
try {
|
|
563
|
-
await readJson5(tsconfigJsonPath);
|
|
564
|
-
} catch (e) {
|
|
565
|
-
if (e instanceof SyntaxError) {
|
|
566
|
-
return this.fail(`Could not parse ${NAME_TSCONFIG_JSON} at ${relTsconfigJsonPath}: ${e}`);
|
|
567
|
-
}
|
|
568
|
-
return this.fail(
|
|
569
|
-
`Could not find ${NAME_TSCONFIG_JSON} at ${relTsconfigJsonPath}; please run "${NAME_BIN} init"`,
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
this.ok('TypeScript config OK');
|
|
574
|
-
}
|
|
575
400
|
}
|
|
576
401
|
|
|
577
402
|
/**
|
|
@@ -587,14 +412,6 @@ export interface DocutilsValidatorOpts {
|
|
|
587
412
|
* Path to `mkdocs.yml`
|
|
588
413
|
*/
|
|
589
414
|
mkdocsYml?: string;
|
|
590
|
-
/**
|
|
591
|
-
* Path to `npm` executable
|
|
592
|
-
*/
|
|
593
|
-
npm?: string;
|
|
594
|
-
/**
|
|
595
|
-
* Path to `package.json`
|
|
596
|
-
*/
|
|
597
|
-
packageJson?: string;
|
|
598
415
|
/**
|
|
599
416
|
* If `true`, run Python validation
|
|
600
417
|
*/
|
|
@@ -603,14 +420,6 @@ export interface DocutilsValidatorOpts {
|
|
|
603
420
|
* Path to `python` executable
|
|
604
421
|
*/
|
|
605
422
|
pythonPath?: string;
|
|
606
|
-
/**
|
|
607
|
-
* Path to `tsconfig.json`
|
|
608
|
-
*/
|
|
609
|
-
tsconfigJson?: string;
|
|
610
|
-
/**
|
|
611
|
-
* If `true`, run TypeScript validation
|
|
612
|
-
*/
|
|
613
|
-
typescript?: boolean;
|
|
614
423
|
/**
|
|
615
424
|
* If `true`, run MkDocs validation
|
|
616
425
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/docutils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Documentation generation utilities for Appium and related projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -48,32 +48,27 @@
|
|
|
48
48
|
"start": "node ./build/lib/cli/index.js"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@appium/support": "^
|
|
52
|
-
"@appium/tsconfig": "^0.3.5",
|
|
53
|
-
"@sliphua/lilconfig-ts-loader": "3.2.2",
|
|
51
|
+
"@appium/support": "^7.0.0",
|
|
54
52
|
"chalk": "4.1.2",
|
|
55
53
|
"consola": "3.4.2",
|
|
56
|
-
"diff": "8.0.
|
|
57
|
-
"json5": "2.2.3",
|
|
54
|
+
"diff": "8.0.02",
|
|
58
55
|
"lilconfig": "3.1.3",
|
|
59
56
|
"lodash": "4.17.21",
|
|
60
57
|
"pkg-dir": "5.0.0",
|
|
61
58
|
"read-pkg": "5.2.0",
|
|
62
|
-
"semver": "7.7.2",
|
|
63
59
|
"source-map-support": "0.5.21",
|
|
64
|
-
"teen_process": "
|
|
60
|
+
"teen_process": "3.0.0",
|
|
65
61
|
"type-fest": "4.41.0",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"yargs": "
|
|
69
|
-
"yargs-parser": "21.1.1"
|
|
62
|
+
"yaml": "2.8.1",
|
|
63
|
+
"yargs": "18.0.0",
|
|
64
|
+
"yargs-parser": "22.0.0"
|
|
70
65
|
},
|
|
71
66
|
"engines": {
|
|
72
|
-
"node": "^
|
|
73
|
-
"npm": ">=
|
|
67
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
|
|
68
|
+
"npm": ">=10"
|
|
74
69
|
},
|
|
75
70
|
"publishConfig": {
|
|
76
71
|
"access": "public"
|
|
77
72
|
},
|
|
78
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "284da50353921343fa5a7f82574e64ce0c146db7"
|
|
79
74
|
}
|
package/requirements.txt
CHANGED