appium 3.2.2 → 3.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.
- package/build/lib/appium.d.ts +147 -205
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +169 -282
- package/build/lib/appium.js.map +1 -1
- package/build/lib/bidi-commands.d.ts.map +1 -1
- package/build/lib/bidi-commands.js +11 -11
- package/build/lib/bidi-commands.js.map +1 -1
- package/build/lib/bootstrap/appium-initializer.d.ts +21 -0
- package/build/lib/bootstrap/appium-initializer.d.ts.map +1 -0
- package/build/lib/bootstrap/appium-initializer.js +146 -0
- package/build/lib/bootstrap/appium-initializer.js.map +1 -0
- package/build/lib/bootstrap/appium-main-runner.d.ts +22 -0
- package/build/lib/bootstrap/appium-main-runner.d.ts.map +1 -0
- package/build/lib/bootstrap/appium-main-runner.js +109 -0
- package/build/lib/bootstrap/appium-main-runner.js.map +1 -0
- package/build/lib/bootstrap/config-file.d.ts +37 -0
- package/build/lib/bootstrap/config-file.d.ts.map +1 -0
- package/build/lib/{config-file.js → bootstrap/config-file.js} +62 -138
- package/build/lib/bootstrap/config-file.js.map +1 -0
- package/build/lib/bootstrap/grid-v3-register.d.ts +20 -0
- package/build/lib/bootstrap/grid-v3-register.d.ts.map +1 -0
- package/build/lib/bootstrap/grid-v3-register.js +185 -0
- package/build/lib/bootstrap/grid-v3-register.js.map +1 -0
- package/build/lib/bootstrap/init-types.d.ts +16 -0
- package/build/lib/bootstrap/init-types.d.ts.map +1 -0
- package/build/lib/bootstrap/init-types.js +3 -0
- package/build/lib/bootstrap/init-types.js.map +1 -0
- package/build/lib/bootstrap/main-helpers.d.ts +55 -0
- package/build/lib/bootstrap/main-helpers.d.ts.map +1 -0
- package/build/lib/bootstrap/main-helpers.js +187 -0
- package/build/lib/bootstrap/main-helpers.js.map +1 -0
- package/build/lib/bootstrap/node-helpers.d.ts +32 -0
- package/build/lib/bootstrap/node-helpers.d.ts.map +1 -0
- package/build/lib/bootstrap/node-helpers.js +201 -0
- package/build/lib/bootstrap/node-helpers.js.map +1 -0
- package/build/lib/bootstrap/startup-config.d.ts +22 -0
- package/build/lib/bootstrap/startup-config.d.ts.map +1 -0
- package/build/lib/bootstrap/startup-config.js +111 -0
- package/build/lib/bootstrap/startup-config.js.map +1 -0
- package/build/lib/cli/args.d.ts +16 -12
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +20 -40
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts +51 -93
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +11 -66
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +173 -377
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +387 -656
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts +10 -15
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +15 -33
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/parser.d.ts +37 -66
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +69 -104
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts +50 -90
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +11 -63
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/cli/setup-command.d.ts +21 -26
- package/build/lib/cli/setup-command.d.ts.map +1 -1
- package/build/lib/cli/setup-command.js +19 -61
- package/build/lib/cli/setup-command.js.map +1 -1
- package/build/lib/cli/utils.d.ts +33 -35
- package/build/lib/cli/utils.d.ts.map +1 -1
- package/build/lib/cli/utils.js +48 -50
- package/build/lib/cli/utils.js.map +1 -1
- package/build/lib/constants.d.ts +23 -23
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +10 -15
- package/build/lib/constants.js.map +1 -1
- package/build/lib/doctor/doctor.d.ts +40 -57
- package/build/lib/doctor/doctor.d.ts.map +1 -1
- package/build/lib/doctor/doctor.js +31 -62
- package/build/lib/doctor/doctor.js.map +1 -1
- package/build/lib/extension/driver-config.d.ts +18 -77
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +37 -125
- package/build/lib/extension/driver-config.js.map +1 -1
- package/build/lib/extension/extension-config.d.ts +103 -210
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +180 -342
- package/build/lib/extension/extension-config.js.map +1 -1
- package/build/lib/extension/index.d.ts +12 -29
- package/build/lib/extension/index.d.ts.map +1 -1
- package/build/lib/extension/index.js +33 -75
- package/build/lib/extension/index.js.map +1 -1
- package/build/lib/extension/manifest-migrations.d.ts +3 -20
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -1
- package/build/lib/extension/manifest-migrations.js +20 -101
- package/build/lib/extension/manifest-migrations.js.map +1 -1
- package/build/lib/extension/manifest.d.ts +61 -107
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +181 -356
- package/build/lib/extension/manifest.js.map +1 -1
- package/build/lib/extension/package-changed.d.ts +1 -3
- package/build/lib/extension/package-changed.d.ts.map +1 -1
- package/build/lib/extension/package-changed.js +8 -15
- package/build/lib/extension/package-changed.js.map +1 -1
- package/build/lib/extension/plugin-config.d.ts +10 -52
- package/build/lib/extension/plugin-config.d.ts.map +1 -1
- package/build/lib/extension/plugin-config.js +11 -63
- package/build/lib/extension/plugin-config.js.map +1 -1
- package/build/lib/helpers/build.d.ts +22 -0
- package/build/lib/helpers/build.d.ts.map +1 -0
- package/build/lib/helpers/build.js +109 -0
- package/build/lib/helpers/build.js.map +1 -0
- package/build/lib/helpers/capability.d.ts +38 -0
- package/build/lib/helpers/capability.d.ts.map +1 -0
- package/build/lib/helpers/capability.js +128 -0
- package/build/lib/helpers/capability.js.map +1 -0
- package/build/lib/helpers/network.d.ts +14 -0
- package/build/lib/helpers/network.d.ts.map +1 -0
- package/build/lib/helpers/network.js +35 -0
- package/build/lib/helpers/network.js.map +1 -0
- package/build/lib/insecure-features.js +6 -6
- package/build/lib/insecure-features.js.map +1 -1
- package/build/lib/inspector-commands.d.ts +6 -0
- package/build/lib/inspector-commands.d.ts.map +1 -1
- package/build/lib/inspector-commands.js +6 -0
- package/build/lib/inspector-commands.js.map +1 -1
- package/build/lib/logger.d.ts +2 -3
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +2 -3
- package/build/lib/logger.js.map +1 -1
- package/build/lib/logsink.d.ts +13 -22
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +48 -103
- package/build/lib/logsink.js.map +1 -1
- package/build/lib/main.d.ts +15 -58
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +25 -425
- package/build/lib/main.js.map +1 -1
- package/build/lib/schema/arg-spec.d.ts +32 -107
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +11 -107
- package/build/lib/schema/arg-spec.js.map +1 -1
- package/build/lib/schema/cli-args-guards.d.ts +34 -0
- package/build/lib/schema/cli-args-guards.d.ts.map +1 -0
- package/build/lib/schema/cli-args-guards.js +49 -0
- package/build/lib/schema/cli-args-guards.js.map +1 -0
- package/build/lib/schema/cli-args.d.ts +3 -15
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +17 -107
- package/build/lib/schema/cli-args.js.map +1 -1
- package/build/lib/schema/cli-transformers.d.ts +15 -12
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +15 -45
- package/build/lib/schema/cli-transformers.js.map +1 -1
- package/build/lib/schema/format-errors.d.ts +28 -0
- package/build/lib/schema/format-errors.d.ts.map +1 -0
- package/build/lib/schema/format-errors.js +29 -0
- package/build/lib/schema/format-errors.js.map +1 -0
- package/build/lib/schema/index.d.ts +4 -2
- package/build/lib/schema/index.d.ts.map +1 -1
- package/build/lib/schema/index.js +2 -0
- package/build/lib/schema/index.js.map +1 -1
- package/build/lib/schema/keywords.d.ts +12 -20
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +6 -51
- package/build/lib/schema/keywords.js.map +1 -1
- package/build/lib/schema/schema.d.ts +106 -231
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +88 -358
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils.d.ts +7 -267
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +10 -409
- package/build/lib/utils.js.map +1 -1
- package/lib/{appium.js → appium.ts} +297 -341
- package/lib/bidi-commands.ts +10 -14
- package/lib/bootstrap/appium-initializer.ts +212 -0
- package/lib/bootstrap/appium-main-runner.ts +172 -0
- package/lib/bootstrap/config-file.ts +178 -0
- package/lib/bootstrap/grid-v3-register.ts +250 -0
- package/lib/bootstrap/init-types.ts +31 -0
- package/lib/bootstrap/main-helpers.ts +223 -0
- package/lib/bootstrap/node-helpers.ts +180 -0
- package/lib/bootstrap/startup-config.ts +143 -0
- package/lib/cli/{args.js → args.ts} +45 -56
- package/lib/cli/driver-command.ts +122 -0
- package/lib/cli/{extension-command.js → extension-command.ts} +827 -906
- package/lib/cli/extension.ts +65 -0
- package/lib/cli/{parser.js → parser.ts} +93 -116
- package/lib/cli/plugin-command.ts +117 -0
- package/lib/cli/{setup-command.js → setup-command.ts} +59 -74
- package/lib/cli/utils.ts +97 -0
- package/lib/{constants.js → constants.ts} +30 -41
- package/lib/doctor/{doctor.js → doctor.ts} +82 -92
- package/lib/extension/driver-config.ts +165 -0
- package/lib/extension/{extension-config.js → extension-config.ts} +291 -405
- package/lib/extension/index.ts +143 -0
- package/lib/extension/manifest-migrations.ts +57 -0
- package/lib/extension/manifest.ts +369 -0
- package/lib/extension/{package-changed.js → package-changed.ts} +9 -18
- package/lib/extension/plugin-config.ts +62 -0
- package/lib/helpers/build.ts +111 -0
- package/lib/helpers/capability.ts +171 -0
- package/lib/helpers/network.ts +30 -0
- package/lib/insecure-features.ts +1 -1
- package/lib/inspector-commands.ts +6 -1
- package/lib/{logger.js → logger.ts} +1 -2
- package/lib/{logsink.js → logsink.ts} +91 -137
- package/lib/main.ts +60 -0
- package/lib/schema/arg-spec.ts +131 -0
- package/lib/schema/cli-args-guards.ts +67 -0
- package/lib/schema/cli-args.ts +171 -0
- package/lib/schema/cli-transformers.ts +83 -0
- package/lib/schema/format-errors.ts +43 -0
- package/lib/schema/index.ts +4 -0
- package/lib/schema/keywords.ts +96 -0
- package/lib/schema/schema.ts +448 -0
- package/lib/utils.ts +73 -0
- package/package.json +17 -18
- package/scripts/autoinstall-extensions.js +3 -0
- package/build/lib/config-file.d.ts +0 -100
- package/build/lib/config-file.d.ts.map +0 -1
- package/build/lib/config-file.js.map +0 -1
- package/build/lib/config.d.ts +0 -70
- package/build/lib/config.d.ts.map +0 -1
- package/build/lib/config.js +0 -390
- package/build/lib/config.js.map +0 -1
- package/build/lib/grid-register.d.ts +0 -10
- package/build/lib/grid-register.d.ts.map +0 -1
- package/build/lib/grid-register.js +0 -134
- package/build/lib/grid-register.js.map +0 -1
- package/lib/cli/driver-command.js +0 -174
- package/lib/cli/extension.js +0 -74
- package/lib/cli/plugin-command.js +0 -164
- package/lib/cli/utils.js +0 -91
- package/lib/config-file.js +0 -228
- package/lib/config.js +0 -389
- package/lib/extension/driver-config.js +0 -245
- package/lib/extension/index.js +0 -169
- package/lib/extension/manifest-migrations.js +0 -136
- package/lib/extension/manifest.js +0 -550
- package/lib/extension/plugin-config.js +0 -112
- package/lib/grid-register.js +0 -146
- package/lib/main.js +0 -545
- package/lib/schema/arg-spec.js +0 -229
- package/lib/schema/cli-args.js +0 -254
- package/lib/schema/cli-transformers.js +0 -113
- package/lib/schema/index.js +0 -2
- package/lib/schema/keywords.js +0 -136
- package/lib/schema/schema.js +0 -725
- package/lib/utils.js +0 -512
|
@@ -6,18 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.toParserArgs = toParserArgs;
|
|
7
7
|
const argparse_1 = require("argparse");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const
|
|
9
|
+
const format_errors_1 = require("./format-errors");
|
|
10
10
|
const schema_1 = require("./schema");
|
|
11
11
|
const cli_transformers_1 = require("./cli-transformers");
|
|
12
|
-
/**
|
|
13
|
-
* This module concerns functions which convert schema definitions to
|
|
14
|
-
* `argparse`-compatible data structures, for deriving CLI arguments from a
|
|
15
|
-
* schema.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Lookup of possible values for the `type` field in a JSON schema.
|
|
19
|
-
* @type {Readonly<Record<string, import('json-schema').JSONSchema7TypeName>>}
|
|
20
|
-
*/
|
|
21
12
|
const TYPENAMES = Object.freeze({
|
|
22
13
|
ARRAY: 'array',
|
|
23
14
|
OBJECT: 'object',
|
|
@@ -27,15 +18,17 @@ const TYPENAMES = Object.freeze({
|
|
|
27
18
|
NULL: 'null',
|
|
28
19
|
STRING: 'string',
|
|
29
20
|
});
|
|
21
|
+
const SHORT_ARG_CUTOFF = 3;
|
|
30
22
|
/**
|
|
31
|
-
*
|
|
23
|
+
* Converts the finalized, flattened schema representation into
|
|
24
|
+
* `ArgumentDefinitions` for handoff to `argparse`.
|
|
32
25
|
*/
|
|
33
|
-
|
|
26
|
+
function toParserArgs() {
|
|
27
|
+
const flattened = (0, schema_1.flattenSchema)().filter(({ schema }) => !schema.appiumCliIgnored);
|
|
28
|
+
return new Map(lodash_1.default.map(flattened, ({ schema, argSpec }) => subSchemaToArgDef(schema, argSpec)));
|
|
29
|
+
}
|
|
34
30
|
/**
|
|
35
|
-
* Convert an alias (`foo`) to a flag (`--foo`) or
|
|
36
|
-
* @param {ArgSpec} argSpec - the argument specification
|
|
37
|
-
* @param {string} [alias] - the alias to convert to a flag
|
|
38
|
-
* @returns {string} the flag
|
|
31
|
+
* Convert an alias (`foo`) to a flag (`--foo`) or short flag (`-f`).
|
|
39
32
|
*/
|
|
40
33
|
function aliasToFlag(argSpec, alias) {
|
|
41
34
|
const { extType, extName, name } = argSpec;
|
|
@@ -48,37 +41,20 @@ function aliasToFlag(argSpec, alias) {
|
|
|
48
41
|
}
|
|
49
42
|
return isShort ? `-${arg}` : `--${lodash_1.default.kebabCase(arg)}`;
|
|
50
43
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Converts a string to SCREAMING_SNAKE_CASE
|
|
53
|
-
*/
|
|
54
44
|
const screamingSnakeCase = lodash_1.default.flow(lodash_1.default.snakeCase, lodash_1.default.toUpper);
|
|
55
45
|
/**
|
|
56
|
-
* Given
|
|
57
|
-
* against a property within the schema.
|
|
58
|
-
* @template Coerced
|
|
59
|
-
* @param {ArgSpec} argSpec - Argument name
|
|
60
|
-
* @param {(value: string) => Coerced} [coerce] - Function to coerce to a different
|
|
61
|
-
* primitive
|
|
62
|
-
* @todo See if we can remove `coerce` by allowing Ajv to coerce in its
|
|
63
|
-
* constructor options
|
|
64
|
-
* @returns
|
|
46
|
+
* Given an argument spec, return a validator/coercer function backed by schema validation.
|
|
65
47
|
*/
|
|
66
48
|
function getSchemaValidator({ ref: schemaId }, coerce = lodash_1.default.identity) {
|
|
67
|
-
/** @param {string} value */
|
|
68
49
|
return (value) => {
|
|
69
50
|
const coerced = coerce(value);
|
|
70
51
|
const errors = (0, schema_1.validate)(coerced, schemaId);
|
|
71
52
|
if (lodash_1.default.isEmpty(errors)) {
|
|
72
53
|
return coerced;
|
|
73
54
|
}
|
|
74
|
-
throw new argparse_1.ArgumentTypeError('\n\n' + (0,
|
|
55
|
+
throw new argparse_1.ArgumentTypeError('\n\n' + (0, format_errors_1.formatErrors)(errors, value, { schemaId }));
|
|
75
56
|
};
|
|
76
57
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Determine the description for display on the CLI, given the schema.
|
|
79
|
-
* @param {AppiumJSONSchema} schema
|
|
80
|
-
* @returns {string}
|
|
81
|
-
*/
|
|
82
58
|
function makeDescription(schema) {
|
|
83
59
|
const { appiumCliDescription, description = '', appiumDeprecated } = schema;
|
|
84
60
|
let desc = appiumCliDescription ?? description;
|
|
@@ -87,46 +63,22 @@ function makeDescription(schema) {
|
|
|
87
63
|
}
|
|
88
64
|
return desc;
|
|
89
65
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Given arg `name`, a JSON schema `subSchema`, and options, return an argument definition
|
|
92
|
-
* as understood by `argparse`.
|
|
93
|
-
* @param {AppiumJSONSchema} subSchema - JSON schema for the option
|
|
94
|
-
* @param {ArgSpec} argSpec - Argument spec tuple
|
|
95
|
-
* @returns {[[string]|[string, string], import('argparse').ArgumentOptions]} Tuple of flag and options
|
|
96
|
-
*/
|
|
97
66
|
function subSchemaToArgDef(subSchema, argSpec) {
|
|
98
|
-
|
|
67
|
+
const { type, appiumCliAliases, appiumCliTransformer, enum: enumValues } = subSchema;
|
|
99
68
|
const { name, arg } = argSpec;
|
|
100
69
|
const aliases = [
|
|
101
70
|
aliasToFlag(argSpec),
|
|
102
|
-
...
|
|
71
|
+
...(appiumCliAliases ?? []).map((alias) => aliasToFlag(argSpec, alias)),
|
|
103
72
|
];
|
|
104
|
-
|
|
105
|
-
let argOpts = {
|
|
73
|
+
const argOpts = {
|
|
106
74
|
required: false,
|
|
107
75
|
help: makeDescription(subSchema),
|
|
108
76
|
};
|
|
109
|
-
// argparse infers dest from the option string (e.g. --log-level → log_level).
|
|
110
|
-
// We need schema dest (e.g. loglevel) so merged server args and logsink use the right key.
|
|
111
77
|
if (!argSpec.extType) {
|
|
112
78
|
argOpts.dest = argSpec.rawDest;
|
|
113
79
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Generally we will provide a `type` to `argparse` as a function which
|
|
116
|
-
* validates using ajv (which is much more full-featured than what `argparse`
|
|
117
|
-
* can offer). The exception is `boolean`-type options, which have no
|
|
118
|
-
* `argType`.
|
|
119
|
-
*
|
|
120
|
-
* Not sure if this type is correct, but it's not doing what I want. I want
|
|
121
|
-
* to say "this is a function which returns something of type `T` where `T` is
|
|
122
|
-
* never a `Promise`". This function must be sync.
|
|
123
|
-
* @type {((value: string) => unknown)|undefined}
|
|
124
|
-
*/
|
|
125
80
|
let argTypeFunction;
|
|
126
|
-
// handle special cases for various types
|
|
127
81
|
switch (type) {
|
|
128
|
-
// booleans do not have a type per `ArgumentOptions`, just an "action"
|
|
129
|
-
// NOTE: due to limitations of `argparse`, we cannot provide fancy help text, and must rely on its internal error messaging.
|
|
130
82
|
case TYPENAMES.BOOLEAN: {
|
|
131
83
|
argOpts.action = 'store_const';
|
|
132
84
|
argOpts.const = true;
|
|
@@ -134,54 +86,40 @@ function subSchemaToArgDef(subSchema, argSpec) {
|
|
|
134
86
|
}
|
|
135
87
|
case TYPENAMES.OBJECT: {
|
|
136
88
|
argTypeFunction = lodash_1.default.flow(cli_transformers_1.transformers.json, (o) => {
|
|
137
|
-
// Arrays and plain strings are also valid JSON
|
|
138
89
|
if (!lodash_1.default.isPlainObject(o)) {
|
|
139
|
-
throw new argparse_1.ArgumentTypeError(`'${lodash_1.default.truncate(o, { length: 100 })}' must be a plain object`);
|
|
140
|
-
;
|
|
90
|
+
throw new argparse_1.ArgumentTypeError(`'${lodash_1.default.truncate(String(o), { length: 100 })}' must be a plain object`);
|
|
141
91
|
}
|
|
142
92
|
return o;
|
|
143
93
|
});
|
|
144
94
|
break;
|
|
145
95
|
}
|
|
146
|
-
// arrays are treated as CSVs, because `argparse` doesn't handle array data.
|
|
147
96
|
case TYPENAMES.ARRAY: {
|
|
148
97
|
argTypeFunction = cli_transformers_1.parseCsvLine;
|
|
149
98
|
break;
|
|
150
99
|
}
|
|
151
|
-
// "number" type is coerced to float. `argparse` does this for us if we use `float` type, but
|
|
152
|
-
// we don't.
|
|
153
100
|
case TYPENAMES.NUMBER: {
|
|
154
101
|
argTypeFunction = getSchemaValidator(argSpec, parseFloat);
|
|
155
102
|
break;
|
|
156
103
|
}
|
|
157
|
-
// "integer" is coerced to an .. integer. again, `argparse` would do this for us if we used `int`.
|
|
158
104
|
case TYPENAMES.INTEGER: {
|
|
159
105
|
argTypeFunction = getSchemaValidator(argSpec, lodash_1.default.parseInt);
|
|
160
106
|
break;
|
|
161
107
|
}
|
|
162
|
-
// strings (like number and integer) are subject to further validation
|
|
163
|
-
// (e.g., must satisfy a mask or regex or even some custom validation
|
|
164
|
-
// function)
|
|
165
108
|
case TYPENAMES.STRING: {
|
|
166
109
|
argTypeFunction = getSchemaValidator(argSpec);
|
|
167
110
|
break;
|
|
168
111
|
}
|
|
169
|
-
// TODO: there may be some way to restrict this at the Ajv level --
|
|
170
|
-
// that may involve patching the metaschema.
|
|
171
112
|
case TYPENAMES.NULL:
|
|
172
|
-
// falls through
|
|
173
113
|
default: {
|
|
174
114
|
throw new TypeError(`Schema property "${arg}": \`${type}\` type unknown or disallowed`);
|
|
175
115
|
}
|
|
176
116
|
}
|
|
177
|
-
// metavar is used in help text. `boolean` cannot have a metavar--it is not
|
|
178
|
-
// displayed--and `argparse` throws if you give it one.
|
|
179
117
|
if (type !== TYPENAMES.BOOLEAN) {
|
|
180
118
|
argOpts.metavar = screamingSnakeCase(name);
|
|
181
119
|
}
|
|
182
120
|
if (appiumCliTransformer && cli_transformers_1.transformers[appiumCliTransformer]) {
|
|
183
121
|
if (type === TYPENAMES.ARRAY) {
|
|
184
|
-
const csvTransformer =
|
|
122
|
+
const csvTransformer = argTypeFunction;
|
|
185
123
|
argTypeFunction = (val) => lodash_1.default.flatMap(csvTransformer(val).map(cli_transformers_1.transformers[appiumCliTransformer]));
|
|
186
124
|
}
|
|
187
125
|
else {
|
|
@@ -191,9 +129,6 @@ function subSchemaToArgDef(subSchema, argSpec) {
|
|
|
191
129
|
if (argTypeFunction) {
|
|
192
130
|
argOpts.type = argTypeFunction;
|
|
193
131
|
}
|
|
194
|
-
// convert JSON schema `enum` to `choices`. `enum` can contain any JSON type, but `argparse`
|
|
195
|
-
// is limited to a single type per arg (I think). so let's make everything a string.
|
|
196
|
-
// and might as well _require_ the `type: string` while we're at it.
|
|
197
132
|
if (enumValues && !lodash_1.default.isEmpty(enumValues)) {
|
|
198
133
|
if (type === TYPENAMES.STRING) {
|
|
199
134
|
argOpts.choices = enumValues.map(String);
|
|
@@ -202,32 +137,7 @@ function subSchemaToArgDef(subSchema, argSpec) {
|
|
|
202
137
|
throw new TypeError(`Problem with schema for ${arg}; \`enum\` is only supported for \`type: 'string'\``);
|
|
203
138
|
}
|
|
204
139
|
}
|
|
205
|
-
|
|
206
|
-
// will be silently discarded.
|
|
207
|
-
const finalAliases = /** @type {[string]|[string, string]} */ (aliases);
|
|
140
|
+
const finalAliases = aliases;
|
|
208
141
|
return [finalAliases, argOpts];
|
|
209
142
|
}
|
|
210
|
-
/**
|
|
211
|
-
* Converts the finalized, flattened schema representation into
|
|
212
|
-
* ArgumentDefinitions for handoff to `argparse`.
|
|
213
|
-
*
|
|
214
|
-
* @throws If schema has not been added to ajv (via `finalizeSchema()`)
|
|
215
|
-
* @returns {import('../cli/args').ArgumentDefinitions} A map of arrays of
|
|
216
|
-
* aliases to `argparse` arguments; empty if no schema found
|
|
217
|
-
*/
|
|
218
|
-
function toParserArgs() {
|
|
219
|
-
const flattened = (0, schema_1.flattenSchema)().filter(({ schema }) => !schema.appiumCliIgnored);
|
|
220
|
-
return new Map(lodash_1.default.map(flattened, ({ schema, argSpec }) => subSchemaToArgDef(schema, argSpec)));
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* @template {string|number} T
|
|
224
|
-
* @typedef {import('ajv/dist/types').FormatValidator<T>} FormatValidator<T>
|
|
225
|
-
*/
|
|
226
|
-
/**
|
|
227
|
-
* A JSON 7 schema with our custom keywords.
|
|
228
|
-
* @typedef {import('./keywords').AppiumJSONSchemaKeywords & import('json-schema').JSONSchema7} AppiumJSONSchema
|
|
229
|
-
*/
|
|
230
|
-
/**
|
|
231
|
-
* @typedef {import('./arg-spec').ArgSpec} ArgSpec
|
|
232
|
-
*/
|
|
233
143
|
//# sourceMappingURL=cli-args.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../../lib/schema/cli-args.
|
|
1
|
+
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../../lib/schema/cli-args.ts"],"names":[],"mappings":";;;;;AA6BA,oCAKC;AAlCD,uCAAiE;AACjE,oDAAuB;AAEvB,mDAA6C;AAC7C,qCAAiD;AACjD,yDAA8D;AAQ9D,MAAM,SAAS,GAAkD,MAAM,CAAC,MAAM,CAAC;IAC7E,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B;;;GAGG;AACH,SAAgB,YAAY;IAC1B,MAAM,SAAS,GAAG,IAAA,sBAAa,GAAE,CAAC,MAAM,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACjF,OAAO,IAAI,GAAG,CACZ,gBAAC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAA0B,EAAE,OAAO,CAAC,CAAC,CAChG,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,OAAgB,EAAE,KAAc;IACnD,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,GAAG,OAAO,CAAC;IACzC,MAAM,GAAG,GAAG,KAAK,IAAI,IAAI,CAAC;IAC1B,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,gBAAgB,CAAC;IAC9C,IAAI,OAAO,I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,+BAAY,CAAC,oBAAgD,CAAC,CAAC,CAAC,CAAC;QACvG,CAAC;aAAM,CAAC;YACN,eAAe,GAAG,gBAAC,CAAC,IAAI,CACtB,eAAe,IAAI,gBAAC,CAAC,QAAQ,EAC7B,+BAAY,CAAC,oBAAgD,CAAC,CACjC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,GAAG,eAAe,CAAC;IACjC,CAAC;IAED,IAAI,UAAU,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,IAAI,IAAI,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;YAC9B,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,SAAS,CACjB,2BAA2B,GAAG,qDAAqD,CACpF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,OAAsC,CAAC;IAC5D,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This module provides
|
|
3
|
-
* "transformers" (see `argTransformers` below).
|
|
2
|
+
* This module provides transformer functions for CLI arguments.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* are usable by extensions, as well.
|
|
4
|
+
* Use case: config schemas can accept richer types (arrays/objects), but CLI
|
|
5
|
+
* values are strings. Transformers convert string input into those richer types.
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
8
|
* Splits a CSV string into an array
|
|
11
|
-
* @param {string} value
|
|
12
|
-
* @returns {string[]}
|
|
13
9
|
*/
|
|
14
|
-
export function parseCsvLine(value: string): string[];
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
export declare function parseCsvLine(value: string): string[];
|
|
11
|
+
export declare const transformers: {
|
|
12
|
+
/**
|
|
13
|
+
* Given a CSV-style string or pathname, parse it into an array.
|
|
14
|
+
* The file can also be split on newlines.
|
|
15
|
+
*/
|
|
16
|
+
readonly csv: (csvOrPath: string) => string[];
|
|
17
|
+
/**
|
|
18
|
+
* Parse a string which could be a path to a JSON file or a JSON string.
|
|
19
|
+
*/
|
|
20
|
+
readonly json: (jsonOrPath: string) => Record<string, any>;
|
|
21
|
+
};
|
|
19
22
|
//# sourceMappingURL=cli-transformers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-transformers.d.ts","sourceRoot":"","sources":["../../../lib/schema/cli-transformers.
|
|
1
|
+
{"version":3,"file":"cli-transformers.d.ts","sourceRoot":"","sources":["../../../lib/schema/cli-transformers.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKpD;AAED,eAAO,MAAM,YAAY;IACvB;;;OAGG;8BACc,MAAM,KAAG,MAAM,EAAE;IAsBlC;;OAEG;gCACgB,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAqBvC,CAAC"}
|
|
@@ -5,17 +5,13 @@ exports.parseCsvLine = parseCsvLine;
|
|
|
5
5
|
const argparse_1 = require("argparse");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
/**
|
|
8
|
-
* This module provides
|
|
9
|
-
* "transformers" (see `argTransformers` below).
|
|
8
|
+
* This module provides transformer functions for CLI arguments.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* are usable by extensions, as well.
|
|
10
|
+
* Use case: config schemas can accept richer types (arrays/objects), but CLI
|
|
11
|
+
* values are strings. Transformers convert string input into those richer types.
|
|
14
12
|
*/
|
|
15
13
|
/**
|
|
16
14
|
* Splits a CSV string into an array
|
|
17
|
-
* @param {string} value
|
|
18
|
-
* @returns {string[]}
|
|
19
15
|
*/
|
|
20
16
|
function parseCsvLine(value) {
|
|
21
17
|
return value
|
|
@@ -23,45 +19,15 @@ function parseCsvLine(value) {
|
|
|
23
19
|
.map((v) => v.trim())
|
|
24
20
|
.filter(Boolean);
|
|
25
21
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Split a file by newline then calls {@link parseCsvLine} on each line.
|
|
28
|
-
* @param {string} value
|
|
29
|
-
* @returns {string[]}
|
|
30
|
-
*/
|
|
31
|
-
function parseCsvFile(value) {
|
|
32
|
-
return value
|
|
33
|
-
.split(/\r?\n/)
|
|
34
|
-
.map((v) => v.trim())
|
|
35
|
-
.filter(Boolean)
|
|
36
|
-
.flatMap(parseCsvLine);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Namespace containing _transformers_ for CLI arguments. "Validators" and
|
|
40
|
-
* "formatters" do not actually modify the value, but these do.
|
|
41
|
-
*
|
|
42
|
-
* Use case is for when the config file can accept e.g., a `string[]`, but the
|
|
43
|
-
* CLI can only take a `string` (as `argparse` seems to be limited in that
|
|
44
|
-
* fashion; it also cannot understand an argument having multiple types).
|
|
45
|
-
*
|
|
46
|
-
* For example, the `csv` transform takes a `string` and returns a `string[]` by
|
|
47
|
-
* splitting it by comma--_or_ if that `string` happens to be a
|
|
48
|
-
* filepath--reading the file as a `.csv`.
|
|
49
|
-
*
|
|
50
|
-
* This contains some copy-pasted code from `lib/cli/parser-helpers.js`, which was
|
|
51
|
-
* obliterated.
|
|
52
|
-
*/
|
|
53
22
|
exports.transformers = {
|
|
54
23
|
/**
|
|
55
24
|
* Given a CSV-style string or pathname, parse it into an array.
|
|
56
25
|
* The file can also be split on newlines.
|
|
57
|
-
* @param {string} csvOrPath
|
|
58
|
-
* @returns {string[]}
|
|
59
26
|
*/
|
|
60
27
|
csv: (csvOrPath) => {
|
|
61
28
|
let csv = csvOrPath;
|
|
62
29
|
let loadedFromFile = false;
|
|
63
|
-
//
|
|
64
|
-
// to attempt to parse it as a file _first_.
|
|
30
|
+
// Value could be a single CSV token or a filepath; attempt file first.
|
|
65
31
|
if ((0, node_fs_1.existsSync)(csvOrPath)) {
|
|
66
32
|
try {
|
|
67
33
|
csv = (0, node_fs_1.readFileSync)(csvOrPath, 'utf8');
|
|
@@ -83,19 +49,13 @@ exports.transformers = {
|
|
|
83
49
|
},
|
|
84
50
|
/**
|
|
85
51
|
* Parse a string which could be a path to a JSON file or a JSON string.
|
|
86
|
-
* @param {string} jsonOrPath
|
|
87
|
-
* @returns {object}
|
|
88
52
|
*/
|
|
89
53
|
json: (jsonOrPath) => {
|
|
90
54
|
let json = jsonOrPath;
|
|
91
55
|
let loadedFromFile = false;
|
|
92
56
|
if ((0, node_fs_1.existsSync)(jsonOrPath)) {
|
|
93
57
|
try {
|
|
94
|
-
//
|
|
95
|
-
// awaiting or using callbacks. This step happens in startup, in what is
|
|
96
|
-
// effectively command-line code, so nothing is blocked in terms of
|
|
97
|
-
// sessions, so holding up the event loop does not incur the usual
|
|
98
|
-
// drawbacks.
|
|
58
|
+
// Intentionally sync: argparse type hooks are synchronous.
|
|
99
59
|
json = (0, node_fs_1.readFileSync)(jsonOrPath, 'utf8');
|
|
100
60
|
}
|
|
101
61
|
catch (err) {
|
|
@@ -114,4 +74,14 @@ exports.transformers = {
|
|
|
114
74
|
}
|
|
115
75
|
},
|
|
116
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Split a file by newline then calls {@link parseCsvLine} on each line.
|
|
79
|
+
*/
|
|
80
|
+
function parseCsvFile(value) {
|
|
81
|
+
return value
|
|
82
|
+
.split(/\r?\n/)
|
|
83
|
+
.map((v) => v.trim())
|
|
84
|
+
.filter(Boolean)
|
|
85
|
+
.flatMap(parseCsvLine);
|
|
86
|
+
}
|
|
117
87
|
//# sourceMappingURL=cli-transformers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-transformers.js","sourceRoot":"","sources":["../../../lib/schema/cli-transformers.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,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,EAAE,CAAC,UAAkB,EAAuB,EAAE;QAChD,IAAI,IAAI,GAAG,UAAU,CAAC;QACtB,IAAI,cAAc,GAAG,KAAK,CAAC;QAC3B,IAAI,IAAA,oBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,2DAA2D;gBAC3D,IAAI,GAAG,IAAA,sBAAY,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC1C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,IAAI,4BAAiB,CAAC,wBAAwB,UAAU,MAAO,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YAChG,CAAC;YACD,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,cAAc;gBACxB,CAAC,CAAC,IAAI,UAAU,wBAAwB;gBACxC,CAAC,CAAC,yCAAyC,CAAC;YAC9C,MAAM,IAAI,SAAS,CAAC,GAAG,GAAG,qBAAsB,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACO,CAAC;AAEX;;GAEG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK;SACT,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC;SACf,OAAO,CAAC,YAAY,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type IOutputError } from '@sidvind/better-ajv-errors';
|
|
2
|
+
import type { ErrorObject } from 'ajv';
|
|
3
|
+
import type { NormalizedAppiumConfig } from '@appium/types';
|
|
4
|
+
/**
|
|
5
|
+
* The string should be a raw JSON string.
|
|
6
|
+
*/
|
|
7
|
+
export type RawJson = string;
|
|
8
|
+
/**
|
|
9
|
+
* Options for {@link formatErrors}.
|
|
10
|
+
*/
|
|
11
|
+
export interface FormatConfigErrorsOptions {
|
|
12
|
+
json?: RawJson;
|
|
13
|
+
pretty?: boolean;
|
|
14
|
+
schemaId?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Given an array of errors and the result of loading a config file, generate a
|
|
18
|
+
* helpful string for the user.
|
|
19
|
+
*
|
|
20
|
+
* - If `opts` contains a `json` property, this should be the original JSON
|
|
21
|
+
* _string_ of the config file. This is only applicable if the config file
|
|
22
|
+
* was in JSON format. If present, it will associate line numbers with errors.
|
|
23
|
+
* - If `errors` happens to be empty, this will throw.
|
|
24
|
+
*
|
|
25
|
+
* @throws {TypeError} If `errors` is empty
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatErrors(errors?: ErrorObject[], config?: NormalizedAppiumConfig | Record<string, unknown> | string | undefined, opts?: FormatConfigErrorsOptions): string | IOutputError[];
|
|
28
|
+
//# sourceMappingURL=format-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-errors.d.ts","sourceRoot":"","sources":["../../../lib/schema/format-errors.ts"],"names":[],"mappings":"AAAA,OAAwB,EAAC,KAAK,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAG1D;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,GAAE,WAAW,EAAO,EAC1B,MAAM,GAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAc,EAClF,IAAI,GAAE,yBAA8B,GACnC,MAAM,GAAG,YAAY,EAAE,CAQzB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatErrors = formatErrors;
|
|
7
|
+
const better_ajv_errors_1 = __importDefault(require("@sidvind/better-ajv-errors"));
|
|
8
|
+
const schema_1 = require("./schema");
|
|
9
|
+
/**
|
|
10
|
+
* Given an array of errors and the result of loading a config file, generate a
|
|
11
|
+
* helpful string for the user.
|
|
12
|
+
*
|
|
13
|
+
* - If `opts` contains a `json` property, this should be the original JSON
|
|
14
|
+
* _string_ of the config file. This is only applicable if the config file
|
|
15
|
+
* was in JSON format. If present, it will associate line numbers with errors.
|
|
16
|
+
* - If `errors` happens to be empty, this will throw.
|
|
17
|
+
*
|
|
18
|
+
* @throws {TypeError} If `errors` is empty
|
|
19
|
+
*/
|
|
20
|
+
function formatErrors(errors = [], config = {}, opts = {}) {
|
|
21
|
+
if (errors && !errors.length) {
|
|
22
|
+
throw new TypeError('Array of errors must be non-empty');
|
|
23
|
+
}
|
|
24
|
+
return (0, better_ajv_errors_1.default)((0, schema_1.getSchema)(opts.schemaId), config, errors, {
|
|
25
|
+
json: opts.json,
|
|
26
|
+
format: opts.pretty === false ? 'js' : 'cli',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=format-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-errors.js","sourceRoot":"","sources":["../../../lib/schema/format-errors.ts"],"names":[],"mappings":";;;;;AA8BA,oCAYC;AA1CD,mFAA8E;AAG9E,qCAAmC;AAgBnC;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAC1B,SAAwB,EAAE,EAC1B,SAAgF,EAAE,EAClF,OAAkC,EAAE;IAEpC,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,IAAA,2BAAe,EAAC,IAAA,kBAAS,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;QAC/D,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;KAC7C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/schema/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
|
@@ -15,5 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./schema"), exports);
|
|
18
|
+
__exportStar(require("./format-errors"), exports);
|
|
18
19
|
__exportStar(require("./cli-args"), exports);
|
|
20
|
+
__exportStar(require("./cli-args-guards"), exports);
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/schema/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,oDAAkC"}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
+
import type { KeywordDefinition } from 'ajv';
|
|
2
|
+
import { transformers } from './cli-transformers';
|
|
3
|
+
export type AppiumCliTransformerName = keyof typeof transformers;
|
|
4
|
+
export interface AppiumJSONSchemaKeywords {
|
|
5
|
+
appiumCliDest?: string;
|
|
6
|
+
appiumCliDescription?: string;
|
|
7
|
+
appiumCliAliases?: string[];
|
|
8
|
+
appiumCliIgnored?: boolean;
|
|
9
|
+
appiumCliTransformer?: AppiumCliTransformerName;
|
|
10
|
+
appiumDeprecated?: boolean;
|
|
11
|
+
}
|
|
1
12
|
/**
|
|
2
13
|
* Collection of keyword definitions to add to the singleton `Ajv` instance.
|
|
3
|
-
* @type {Record<string,KeywordDefinition>}
|
|
4
14
|
*/
|
|
5
|
-
export const keywords: Record<string, KeywordDefinition>;
|
|
6
|
-
/**
|
|
7
|
-
* These are the valid values for the `appiumCliTransformer` keyword.
|
|
8
|
-
* Unfortunately, TS cannot infer this in a JS context. In TS, we'd use
|
|
9
|
-
* `as const` when defining `argTransformers`, then get `keyof typeof argTransformers`. alas.
|
|
10
|
-
*/
|
|
11
|
-
export type AppiumCliTransformerName = "csv" | "json";
|
|
12
|
-
/**
|
|
13
|
-
* These are the custom keywords that Appium recognizes.
|
|
14
|
-
*/
|
|
15
|
-
export type AppiumJSONSchemaKeywords = {
|
|
16
|
-
appiumCliDest?: string | undefined;
|
|
17
|
-
appiumCliDescription?: string | undefined;
|
|
18
|
-
appiumCliAliases?: string[] | undefined;
|
|
19
|
-
appiumCliIgnored?: boolean | undefined;
|
|
20
|
-
appiumCliTransformer?: AppiumCliTransformerName | undefined;
|
|
21
|
-
appiumDeprecated?: boolean | undefined;
|
|
22
|
-
};
|
|
23
|
-
export type KeywordDefinition = import("ajv").KeywordDefinition;
|
|
15
|
+
export declare const keywords: Record<string, KeywordDefinition>;
|
|
24
16
|
//# sourceMappingURL=keywords.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keywords.d.ts","sourceRoot":"","sources":["../../../lib/schema/keywords.
|
|
1
|
+
{"version":3,"file":"keywords.d.ts","sourceRoot":"","sources":["../../../lib/schema/keywords.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,YAAY,CAAC;AAEjE,MAAM,WAAW,wBAAwB;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CA8EtD,CAAC"}
|