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
package/build/lib/cli/parser.js
CHANGED
|
@@ -11,7 +11,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
11
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
12
|
const constants_1 = require("../constants");
|
|
13
13
|
const schema_1 = require("../schema");
|
|
14
|
-
const
|
|
14
|
+
const build_1 = require("../helpers/build");
|
|
15
15
|
const args_1 = require("./args");
|
|
16
16
|
const setup_command_1 = require("./setup-command");
|
|
17
17
|
exports.EXTRA_ARGS = 'extraArgs';
|
|
@@ -20,7 +20,7 @@ exports.EXTRA_ARGS = 'extraArgs';
|
|
|
20
20
|
* will automatically inject the `server` subcommand.
|
|
21
21
|
*/
|
|
22
22
|
const NON_SERVER_ARGS = Object.freeze(new Set([constants_1.SETUP_SUBCOMMAND, constants_1.DRIVER_TYPE, constants_1.PLUGIN_TYPE, constants_1.SERVER_SUBCOMMAND, '-h', '--help', '-v', '--version']));
|
|
23
|
-
const version = support_1.fs.readPackageJsonFrom(
|
|
23
|
+
const version = support_1.fs.readPackageJsonFrom(build_1.rootDir).version;
|
|
24
24
|
/**
|
|
25
25
|
* A wrapper around `argparse`
|
|
26
26
|
*
|
|
@@ -29,8 +29,13 @@ const version = support_1.fs.readPackageJsonFrom(config_1.rootDir).version;
|
|
|
29
29
|
* - Handles error conditions, messages, and exit behavior
|
|
30
30
|
*/
|
|
31
31
|
class ArgParser {
|
|
32
|
+
prog;
|
|
33
|
+
debug;
|
|
34
|
+
parser;
|
|
35
|
+
rawArgs;
|
|
36
|
+
parse_args;
|
|
32
37
|
/**
|
|
33
|
-
* @param
|
|
38
|
+
* @param debug - if true, throw instead of exiting on parse errors
|
|
34
39
|
*/
|
|
35
40
|
constructor(debug = false) {
|
|
36
41
|
const prog = process.argv[1] ? node_path_1.default.basename(process.argv[1]) : 'appium';
|
|
@@ -41,20 +46,8 @@ class ArgParser {
|
|
|
41
46
|
prog,
|
|
42
47
|
});
|
|
43
48
|
ArgParser._patchExit(parser);
|
|
44
|
-
/**
|
|
45
|
-
* Program name (typically `appium`)
|
|
46
|
-
* @type {string}
|
|
47
|
-
*/
|
|
48
49
|
this.prog = prog;
|
|
49
|
-
/**
|
|
50
|
-
* If `true`, throw an error on parse failure instead of printing help
|
|
51
|
-
* @type {boolean}
|
|
52
|
-
*/
|
|
53
50
|
this.debug = debug;
|
|
54
|
-
/**
|
|
55
|
-
* Wrapped `ArgumentParser` instance
|
|
56
|
-
* @type {ArgumentParser}
|
|
57
|
-
*/
|
|
58
51
|
this.parser = parser;
|
|
59
52
|
parser.add_argument('-v', '--version', {
|
|
60
53
|
action: 'version',
|
|
@@ -71,74 +64,19 @@ class ArgParser {
|
|
|
71
64
|
// add the 'setup' command
|
|
72
65
|
ArgParser._addSetupToParser(subParsers);
|
|
73
66
|
// backwards compatibility / drop-in wrapper
|
|
74
|
-
/**
|
|
75
|
-
* @type {ArgParser['parseArgs']}
|
|
76
|
-
*/
|
|
77
67
|
this.parse_args = this.parseArgs;
|
|
78
68
|
}
|
|
79
69
|
/**
|
|
80
|
-
*
|
|
70
|
+
* Normalizes server arg keys from schema names to parser destination names.
|
|
81
71
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* `ArgParser.prototype.parse_args` is an alias of this method.
|
|
85
|
-
* @template {import('appium/types').CliCommand} [Cmd=import('appium/types').CliCommandServer]
|
|
86
|
-
* @param {string[]} [args] - Array of arguments, ostensibly from `process.argv`. Gathers args from `process.argv` if not provided.
|
|
87
|
-
* @returns {import('appium/types').Args<Cmd>} - The parsed arguments
|
|
88
|
-
*/
|
|
89
|
-
parseArgs(args = process.argv.slice(2)) {
|
|
90
|
-
if (!NON_SERVER_ARGS.has(args[0])) {
|
|
91
|
-
args.unshift(constants_1.SERVER_SUBCOMMAND);
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const parsed = this.parser.parse_known_args(args);
|
|
95
|
-
const [knownArgs, unknownArgs] = parsed;
|
|
96
|
-
// XXX: you'd think that argparse, when given an alias for a subcommand,
|
|
97
|
-
// would set this value to the original subcommand name, but it doesn't.
|
|
98
|
-
if (knownArgs?.driverCommand === 'ls') {
|
|
99
|
-
knownArgs.driverCommand = 'list';
|
|
100
|
-
}
|
|
101
|
-
else if (knownArgs?.pluginCommand === 'ls') {
|
|
102
|
-
knownArgs.pluginCommand = 'list';
|
|
103
|
-
}
|
|
104
|
-
if (unknownArgs?.length &&
|
|
105
|
-
(knownArgs.driverCommand === 'run' || knownArgs.pluginCommand === 'run')) {
|
|
106
|
-
return ArgParser._transformParsedArgs(knownArgs, unknownArgs);
|
|
107
|
-
}
|
|
108
|
-
else if (unknownArgs?.length) {
|
|
109
|
-
throw new Error(`[ERROR] Unrecognized arguments: ${unknownArgs.join(' ')}`);
|
|
110
|
-
}
|
|
111
|
-
return ArgParser._transformParsedArgs(knownArgs);
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
if (this.debug) {
|
|
115
|
-
throw err;
|
|
116
|
-
}
|
|
117
|
-
// this isn't tested via unit tests (we use `debug: true`) so may escape coverage.
|
|
118
|
-
/* istanbul ignore next */
|
|
119
|
-
{
|
|
120
|
-
// eslint-disable-next-line no-console
|
|
121
|
-
console.error(); // need an extra space since argparse prints usage.
|
|
122
|
-
// eslint-disable-next-line no-console
|
|
123
|
-
console.error(err.message);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Normalize hyphenated server arg keys (e.g. "log-level") to dest form (e.g. "loglevel").
|
|
130
|
-
* Use when server args come from programmatic init rather than the CLI, so they match
|
|
131
|
-
* the shape produced by parseArgs() / _transformParsedArgs().
|
|
132
|
-
* Mutates the given object.
|
|
133
|
-
*
|
|
134
|
-
* @param {object} obj - Object that may contain server args with schema property names
|
|
135
|
-
* @returns {object} The same object with keys normalized
|
|
72
|
+
* This mutates and returns the same object.
|
|
136
73
|
*/
|
|
137
74
|
static normalizeServerArgs(obj) {
|
|
75
|
+
const mutableObj = obj;
|
|
138
76
|
for (const spec of (0, schema_1.getAllArgSpecs)().values()) {
|
|
139
|
-
if (!spec.extType &&
|
|
140
|
-
|
|
141
|
-
delete
|
|
77
|
+
if (!spec.extType && mutableObj[spec.name] !== undefined && spec.rawDest !== spec.name) {
|
|
78
|
+
mutableObj[spec.rawDest] = mutableObj[spec.name] ?? mutableObj[spec.rawDest];
|
|
79
|
+
delete mutableObj[spec.name];
|
|
142
80
|
}
|
|
143
81
|
}
|
|
144
82
|
return obj;
|
|
@@ -149,14 +87,12 @@ class ArgParser {
|
|
|
149
87
|
* keys to match the intended destination.
|
|
150
88
|
*
|
|
151
89
|
* E.g., `{'driver-foo-bar': baz}` becomes `{driver: {foo: {bar: 'baz'}}}`
|
|
152
|
-
* @param {object} args
|
|
153
|
-
* @param {string[]} [unknownArgs]
|
|
154
|
-
* @returns {object}
|
|
155
90
|
*/
|
|
156
91
|
static _transformParsedArgs(args, unknownArgs = []) {
|
|
157
92
|
const result = lodash_1.default.reduce(args, (unpacked, value, key) => {
|
|
158
|
-
|
|
159
|
-
|
|
93
|
+
const spec = (0, schema_1.hasArgSpec)(key) ? (0, schema_1.getArgSpec)(key) : undefined;
|
|
94
|
+
if (!lodash_1.default.isUndefined(value) && spec) {
|
|
95
|
+
const { dest } = spec;
|
|
160
96
|
lodash_1.default.set(unpacked, dest, value);
|
|
161
97
|
}
|
|
162
98
|
else {
|
|
@@ -170,7 +106,6 @@ class ArgParser {
|
|
|
170
106
|
}
|
|
171
107
|
/**
|
|
172
108
|
* Patches the `exit()` method of the parser to throw an error, so we can handle it manually.
|
|
173
|
-
* @param {ArgumentParser} parser
|
|
174
109
|
*/
|
|
175
110
|
static _patchExit(parser) {
|
|
176
111
|
parser.exit = (code, msg) => {
|
|
@@ -181,9 +116,7 @@ class ArgParser {
|
|
|
181
116
|
};
|
|
182
117
|
}
|
|
183
118
|
/**
|
|
184
|
-
*
|
|
185
|
-
* @param {import('argparse').SubParser} subParser
|
|
186
|
-
* @returns {import('./args').ArgumentDefinitions}
|
|
119
|
+
* Adds the `server` subcommand parser and returns its argument definitions.
|
|
187
120
|
*/
|
|
188
121
|
static _addServerToParser(subParser) {
|
|
189
122
|
const serverParser = subParser.add_parser('server', {
|
|
@@ -201,11 +134,10 @@ class ArgParser {
|
|
|
201
134
|
}
|
|
202
135
|
/**
|
|
203
136
|
* Adds extension sub-sub-commands to `driver`/`plugin` subcommands
|
|
204
|
-
* @param {import('argparse').SubParser} subParsers
|
|
205
137
|
*/
|
|
206
|
-
static _addExtensionCommandsToParser(
|
|
207
|
-
for (const type of
|
|
208
|
-
const extParser =
|
|
138
|
+
static _addExtensionCommandsToParser(subParser) {
|
|
139
|
+
for (const type of [constants_1.DRIVER_TYPE, constants_1.PLUGIN_TYPE]) {
|
|
140
|
+
const extParser = subParser.add_parser(type, {
|
|
209
141
|
add_help: true,
|
|
210
142
|
help: `Manage Appium ${type}s`,
|
|
211
143
|
description: `Manage Appium ${type}s using various subcommands`,
|
|
@@ -215,9 +147,6 @@ class ArgParser {
|
|
|
215
147
|
dest: `${type}Command`,
|
|
216
148
|
});
|
|
217
149
|
const extensionArgs = (0, args_1.getExtensionArgs)();
|
|
218
|
-
/**
|
|
219
|
-
* @type { {command: import('appium/types').CliExtensionSubcommand, args: import('./args').ArgumentDefinitions, help: string, aliases?: import('argparse').SubArgumentParserOptions['aliases']}[] }
|
|
220
|
-
*/
|
|
221
150
|
const parserSpecs = [
|
|
222
151
|
{
|
|
223
152
|
command: constants_1.EXT_SUBCOMMAND_LIST,
|
|
@@ -268,7 +197,6 @@ class ArgParser {
|
|
|
268
197
|
}
|
|
269
198
|
/**
|
|
270
199
|
* Add subcommand and sub-sub commands for 'setup' subcommand.
|
|
271
|
-
* @param {import('argparse').SubParser} subParser
|
|
272
200
|
*/
|
|
273
201
|
static _addSetupToParser(subParser) {
|
|
274
202
|
const setupParser = subParser.add_parser('setup', {
|
|
@@ -309,21 +237,58 @@ class ArgParser {
|
|
|
309
237
|
ArgParser._patchExit(parser);
|
|
310
238
|
}
|
|
311
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Parses CLI args and returns Appium's normalized argument object.
|
|
242
|
+
*
|
|
243
|
+
* If no explicit subcommand is provided, this injects `server`.
|
|
244
|
+
* `parse_args` is a backwards-compatible alias of this method.
|
|
245
|
+
*/
|
|
246
|
+
parseArgs(args = process.argv.slice(2)) {
|
|
247
|
+
if (!NON_SERVER_ARGS.has(args[0])) {
|
|
248
|
+
args.unshift(constants_1.SERVER_SUBCOMMAND);
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const parsed = this.parser.parse_known_args(args);
|
|
252
|
+
const [knownArgs, unknownArgs] = parsed;
|
|
253
|
+
// XXX: you'd think that argparse, when given an alias for a subcommand,
|
|
254
|
+
// would set this value to the original subcommand name, but it doesn't.
|
|
255
|
+
if (knownArgs?.driverCommand === 'ls') {
|
|
256
|
+
knownArgs.driverCommand = 'list';
|
|
257
|
+
}
|
|
258
|
+
else if (knownArgs?.pluginCommand === 'ls') {
|
|
259
|
+
knownArgs.pluginCommand = 'list';
|
|
260
|
+
}
|
|
261
|
+
if (unknownArgs?.length &&
|
|
262
|
+
(knownArgs.driverCommand === 'run' || knownArgs.pluginCommand === 'run')) {
|
|
263
|
+
return ArgParser._transformParsedArgs(knownArgs, unknownArgs);
|
|
264
|
+
}
|
|
265
|
+
else if (unknownArgs?.length) {
|
|
266
|
+
throw new Error(`[ERROR] Unrecognized arguments: ${unknownArgs.join(' ')}`);
|
|
267
|
+
}
|
|
268
|
+
return ArgParser._transformParsedArgs(knownArgs);
|
|
269
|
+
}
|
|
270
|
+
catch (err) {
|
|
271
|
+
if (this.debug) {
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
// this isn't tested via unit tests (we use `debug: true`) so may escape coverage.
|
|
275
|
+
/* istanbul ignore next */
|
|
276
|
+
{
|
|
277
|
+
// eslint-disable-next-line no-console
|
|
278
|
+
console.error(); // need an extra space since argparse prints usage.
|
|
279
|
+
// eslint-disable-next-line no-console
|
|
280
|
+
console.error(err.message);
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
312
285
|
}
|
|
313
286
|
exports.ArgParser = ArgParser;
|
|
314
287
|
/**
|
|
315
|
-
* Creates
|
|
316
|
-
*
|
|
317
|
-
* @constructs ArgParser
|
|
318
|
-
* @param {boolean} [debug] - If `true`, throw instead of exit upon parsing error
|
|
319
|
-
* @returns {ArgParser}
|
|
288
|
+
* Creates and returns an `ArgParser` after finalizing schema state.
|
|
320
289
|
*/
|
|
321
|
-
function getParser(debug) {
|
|
322
|
-
(0, schema_1.finalizeSchema)();
|
|
290
|
+
async function getParser(debug = false) {
|
|
291
|
+
await (0, schema_1.finalizeSchema)();
|
|
323
292
|
return new ArgParser(debug);
|
|
324
293
|
}
|
|
325
|
-
/**
|
|
326
|
-
* @typedef {import('@appium/types').DriverType} DriverType
|
|
327
|
-
* @typedef {import('@appium/types').PluginType} PluginType
|
|
328
|
-
*/
|
|
329
294
|
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../lib/cli/parser.
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../lib/cli/parser.ts"],"names":[],"mappings":";;;;;;AAwWA,8BAIC;AA5WD,6CAAmC;AACnC,uCAAwC;AAExC,oDAAuB;AACvB,0DAA6B;AAG7B,4CAWsB;AACtB,sCAAiF;AACjF,4CAAyC;AACzC,iCAAuD;AAEvD,mDAQyB;AAEZ,QAAA,UAAU,GAAG,WAAW,CAAC;AAEtC;;;GAGG;AACH,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACnC,IAAI,GAAG,CAAC,CAAC,4BAAgB,EAAE,uBAAW,EAAE,uBAAW,EAAE,6BAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CA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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type { ExtMetadata, ExtRecord, InstallType } from 'appium/types';
|
|
2
|
+
import ExtensionCliCommand from './extension-command';
|
|
3
|
+
import type { ExtensionArgs, ExtensionCommandOptions, ExtensionUpdateResult, PostInstallText, RunOutput } from './extension-command';
|
|
4
|
+
type PluginInstallOpts = {
|
|
5
|
+
plugin: string;
|
|
6
|
+
installType: InstallType;
|
|
7
|
+
packageName?: string;
|
|
8
|
+
};
|
|
9
|
+
type PluginUninstallOpts = {
|
|
10
|
+
plugin: string;
|
|
11
|
+
};
|
|
12
|
+
type PluginUpdateOpts = {
|
|
13
|
+
plugin: string;
|
|
14
|
+
unsafe: boolean;
|
|
15
|
+
};
|
|
16
|
+
type PluginRunOptions = {
|
|
17
|
+
plugin: string;
|
|
18
|
+
scriptName: string;
|
|
19
|
+
extraArgs?: string[];
|
|
20
|
+
};
|
|
21
|
+
type PluginDoctorOptions = {
|
|
22
|
+
plugin: string;
|
|
23
|
+
};
|
|
24
|
+
export default class PluginCliCommand extends ExtensionCliCommand<'plugin'> {
|
|
25
|
+
constructor({ config, json }: ExtensionCommandOptions<'plugin'>);
|
|
10
26
|
/**
|
|
11
27
|
* Install a plugin
|
|
12
28
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @returns {Promise<ExtRecord<PluginType>>}
|
|
29
|
+
* @param opts - install options
|
|
15
30
|
*/
|
|
16
|
-
install({ plugin, installType, packageName }: PluginInstallOpts): Promise<ExtRecord<
|
|
31
|
+
install({ plugin, installType, packageName }: PluginInstallOpts): Promise<ExtRecord<'plugin'>>;
|
|
17
32
|
/**
|
|
18
33
|
* Uninstall a plugin
|
|
19
34
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @returns {Promise<ExtRecord<PluginType>>}
|
|
35
|
+
* @param opts - uninstall options
|
|
22
36
|
*/
|
|
23
|
-
uninstall({ plugin }: PluginUninstallOpts): Promise<ExtRecord<
|
|
37
|
+
uninstall({ plugin }: PluginUninstallOpts): Promise<ExtRecord<'plugin'>>;
|
|
24
38
|
/**
|
|
25
39
|
* Update a plugin
|
|
26
40
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns {Promise<import('./extension-command').ExtensionUpdateResult>}
|
|
41
|
+
* @param opts - update options
|
|
29
42
|
*/
|
|
30
|
-
update({ plugin, unsafe }: PluginUpdateOpts): Promise<
|
|
43
|
+
update({ plugin, unsafe }: PluginUpdateOpts): Promise<ExtensionUpdateResult>;
|
|
31
44
|
/**
|
|
32
45
|
* Run a script from a plugin
|
|
33
46
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @returns {Promise<import('./extension-command').RunOutput>}
|
|
47
|
+
* @param opts - script execution options
|
|
36
48
|
* @throws {Error} if the script fails to run
|
|
37
49
|
*/
|
|
38
|
-
run({ plugin, scriptName, extraArgs }: PluginRunOptions): Promise<
|
|
50
|
+
run({ plugin, scriptName, extraArgs }: PluginRunOptions): Promise<RunOutput>;
|
|
39
51
|
/**
|
|
40
52
|
* Runs doctor checks for the given plugin
|
|
41
53
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @returns
|
|
54
|
+
* @param opts - doctor command options
|
|
55
|
+
* @returns The amount of executed doctor checks.
|
|
44
56
|
* @throws {Error} If any of the mandatory Doctor checks fails.
|
|
45
57
|
*/
|
|
46
58
|
doctor({ plugin }: PluginDoctorOptions): Promise<number>;
|
|
47
|
-
}
|
|
48
|
-
export type ExtensionType = import("@appium/types").ExtensionType;
|
|
49
|
-
export type PluginType = import("@appium/types").PluginType;
|
|
50
|
-
export type ExtRecord<ExtType extends ExtensionType> = import("appium/types").ExtRecord<ExtType>;
|
|
51
|
-
/**
|
|
52
|
-
* Options for {@linkcode PluginCliCommand.install}
|
|
53
|
-
*/
|
|
54
|
-
export type PluginInstallOpts = {
|
|
55
59
|
/**
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* - how to install this plugin. One of the INSTALL_TYPES
|
|
61
|
-
*/
|
|
62
|
-
installType: InstallType;
|
|
63
|
-
/**
|
|
64
|
-
* - for git/github installs, the plugin node package name
|
|
65
|
-
*/
|
|
66
|
-
packageName?: string | undefined;
|
|
67
|
-
};
|
|
68
|
-
export type InstallType = import("appium/types").InstallType;
|
|
69
|
-
/**
|
|
70
|
-
* Options for {@linkcode PluginCliCommand.uninstall}
|
|
71
|
-
*/
|
|
72
|
-
export type PluginUninstallOpts = {
|
|
73
|
-
/**
|
|
74
|
-
* - the name or spec of a plugin to uninstall
|
|
75
|
-
*/
|
|
76
|
-
plugin: string;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Options for {@linkcode PluginCliCommand.update}
|
|
80
|
-
*/
|
|
81
|
-
export type PluginUpdateOpts = {
|
|
82
|
-
/**
|
|
83
|
-
* - the name of the plugin to update
|
|
84
|
-
*/
|
|
85
|
-
plugin: string;
|
|
86
|
-
/**
|
|
87
|
-
* - if true, will perform unsafe updates past major revision boundaries
|
|
88
|
-
*/
|
|
89
|
-
unsafe: boolean;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Options for {@linkcode PluginCliCommand.run}.
|
|
93
|
-
*/
|
|
94
|
-
export type PluginRunOptions = {
|
|
95
|
-
/**
|
|
96
|
-
* - name of the plugin to run a script from
|
|
97
|
-
*/
|
|
98
|
-
plugin: string;
|
|
99
|
-
/**
|
|
100
|
-
* - name of the script to run
|
|
101
|
-
*/
|
|
102
|
-
scriptName: string;
|
|
103
|
-
/**
|
|
104
|
-
* - arguments to pass to the script
|
|
60
|
+
* Builds the success message displayed after a plugin installation.
|
|
61
|
+
*
|
|
62
|
+
* @param args - installed extension name and metadata
|
|
63
|
+
* @returns formatted success text
|
|
105
64
|
*/
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Options for {@linkcode PluginCliCommand.doctor}.
|
|
110
|
-
*/
|
|
111
|
-
export type PluginDoctorOptions = {
|
|
65
|
+
getPostInstallText({ extName, extData }: ExtensionArgs<'plugin'>): PostInstallText;
|
|
112
66
|
/**
|
|
113
|
-
*
|
|
67
|
+
* Validates fields in `appium` field of `pluginMetadata`
|
|
68
|
+
*
|
|
69
|
+
* For any `package.json` fields which a plugin requires, validate the type of
|
|
70
|
+
* those fields on the `package.json` data, throwing an error if anything is
|
|
71
|
+
* amiss.
|
|
72
|
+
* @param pluginMetadata - `appium` metadata from extension package
|
|
73
|
+
* @param installSpec - install spec from CLI
|
|
114
74
|
*/
|
|
115
|
-
plugin: string;
|
|
116
|
-
}
|
|
117
|
-
|
|
75
|
+
validateExtensionFields(pluginMetadata: ExtMetadata<'plugin'>, installSpec: string): void;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
118
78
|
//# sourceMappingURL=plugin-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-command.d.ts","sourceRoot":"","sources":["../../../lib/cli/plugin-command.
|
|
1
|
+
{"version":3,"file":"plugin-command.d.ts","sourceRoot":"","sources":["../../../lib/cli/plugin-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACtE,OAAO,mBAAmB,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,SAAS,EACV,MAAM,qBAAqB,CAAC;AAI7B,KAAK,iBAAiB,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AAC1F,KAAK,mBAAmB,GAAG;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC;AAC5C,KAAK,gBAAgB,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAC,CAAC;AAC1D,KAAK,gBAAg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__importDefault(require("./extension-command"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const REQ_PLUGIN_FIELDS = ['pluginName', 'mainClass'];
|
|
10
|
-
/**
|
|
11
|
-
* @extends {ExtensionCliCommand<PluginType>}
|
|
12
|
-
*/
|
|
13
10
|
class PluginCliCommand extends extension_command_1.default {
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {import('./extension-command').ExtensionCommandOptions<PluginType>} opts
|
|
17
|
-
*/
|
|
18
11
|
constructor({ config, json }) {
|
|
19
12
|
super({ config, json });
|
|
20
13
|
this.knownExtensions = constants_1.KNOWN_PLUGINS;
|
|
@@ -22,8 +15,7 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
22
15
|
/**
|
|
23
16
|
* Install a plugin
|
|
24
17
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @returns {Promise<ExtRecord<PluginType>>}
|
|
18
|
+
* @param opts - install options
|
|
27
19
|
*/
|
|
28
20
|
async install({ plugin, installType, packageName }) {
|
|
29
21
|
return await super._install({
|
|
@@ -35,8 +27,7 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
35
27
|
/**
|
|
36
28
|
* Uninstall a plugin
|
|
37
29
|
*
|
|
38
|
-
* @param
|
|
39
|
-
* @returns {Promise<ExtRecord<PluginType>>}
|
|
30
|
+
* @param opts - uninstall options
|
|
40
31
|
*/
|
|
41
32
|
async uninstall({ plugin }) {
|
|
42
33
|
return await super._uninstall({ installSpec: plugin });
|
|
@@ -44,8 +35,7 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
44
35
|
/**
|
|
45
36
|
* Update a plugin
|
|
46
37
|
*
|
|
47
|
-
* @param
|
|
48
|
-
* @returns {Promise<import('./extension-command').ExtensionUpdateResult>}
|
|
38
|
+
* @param opts - update options
|
|
49
39
|
*/
|
|
50
40
|
async update({ plugin, unsafe }) {
|
|
51
41
|
return await super._update({ installSpec: plugin, unsafe });
|
|
@@ -53,8 +43,7 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
53
43
|
/**
|
|
54
44
|
* Run a script from a plugin
|
|
55
45
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* @returns {Promise<import('./extension-command').RunOutput>}
|
|
46
|
+
* @param opts - script execution options
|
|
58
47
|
* @throws {Error} if the script fails to run
|
|
59
48
|
*/
|
|
60
49
|
async run({ plugin, scriptName, extraArgs }) {
|
|
@@ -68,8 +57,8 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
68
57
|
/**
|
|
69
58
|
* Runs doctor checks for the given plugin
|
|
70
59
|
*
|
|
71
|
-
* @param
|
|
72
|
-
* @returns
|
|
60
|
+
* @param opts - doctor command options
|
|
61
|
+
* @returns The amount of executed doctor checks.
|
|
73
62
|
* @throws {Error} If any of the mandatory Doctor checks fails.
|
|
74
63
|
*/
|
|
75
64
|
async doctor({ plugin }) {
|
|
@@ -78,9 +67,10 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
78
67
|
});
|
|
79
68
|
}
|
|
80
69
|
/**
|
|
70
|
+
* Builds the success message displayed after a plugin installation.
|
|
81
71
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns
|
|
72
|
+
* @param args - installed extension name and metadata
|
|
73
|
+
* @returns formatted success text
|
|
84
74
|
*/
|
|
85
75
|
getPostInstallText({ extName, extData }) {
|
|
86
76
|
return `Plugin ${extName}@${extData.version} successfully installed`.green;
|
|
@@ -91,9 +81,8 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
91
81
|
* For any `package.json` fields which a plugin requires, validate the type of
|
|
92
82
|
* those fields on the `package.json` data, throwing an error if anything is
|
|
93
83
|
* amiss.
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
96
|
-
* @returns {void}
|
|
84
|
+
* @param pluginMetadata - `appium` metadata from extension package
|
|
85
|
+
* @param installSpec - install spec from CLI
|
|
97
86
|
*/
|
|
98
87
|
validateExtensionFields(pluginMetadata, installSpec) {
|
|
99
88
|
const missingFields = REQ_PLUGIN_FIELDS.reduce((acc, field) => (pluginMetadata[field] ? acc : [...acc, field]), []);
|
|
@@ -104,45 +93,4 @@ class PluginCliCommand extends extension_command_1.default {
|
|
|
104
93
|
}
|
|
105
94
|
}
|
|
106
95
|
exports.default = PluginCliCommand;
|
|
107
|
-
/**
|
|
108
|
-
* @typedef {import('@appium/types').ExtensionType} ExtensionType
|
|
109
|
-
* @typedef {import('@appium/types').PluginType} PluginType
|
|
110
|
-
*/
|
|
111
|
-
/**
|
|
112
|
-
* @template {ExtensionType} ExtType
|
|
113
|
-
* @typedef {import('appium/types').ExtRecord<ExtType>} ExtRecord
|
|
114
|
-
*/
|
|
115
|
-
/**
|
|
116
|
-
* Options for {@linkcode PluginCliCommand.install}
|
|
117
|
-
* @typedef PluginInstallOpts
|
|
118
|
-
* @property {string} plugin - the name or spec of a plugin to install
|
|
119
|
-
* @property {InstallType} installType - how to install this plugin. One of the INSTALL_TYPES
|
|
120
|
-
* @property {string} [packageName] - for git/github installs, the plugin node package name
|
|
121
|
-
*/
|
|
122
|
-
/**
|
|
123
|
-
* @typedef {import('appium/types').InstallType} InstallType
|
|
124
|
-
*/
|
|
125
|
-
/**
|
|
126
|
-
* Options for {@linkcode PluginCliCommand.uninstall}
|
|
127
|
-
* @typedef PluginUninstallOpts
|
|
128
|
-
* @property {string} plugin - the name or spec of a plugin to uninstall
|
|
129
|
-
*/
|
|
130
|
-
/**
|
|
131
|
-
* Options for {@linkcode PluginCliCommand.update}
|
|
132
|
-
* @typedef PluginUpdateOpts
|
|
133
|
-
* @property {string} plugin - the name of the plugin to update
|
|
134
|
-
* @property {boolean} unsafe - if true, will perform unsafe updates past major revision boundaries
|
|
135
|
-
*/
|
|
136
|
-
/**
|
|
137
|
-
* Options for {@linkcode PluginCliCommand.run}.
|
|
138
|
-
* @typedef PluginRunOptions
|
|
139
|
-
* @property {string} plugin - name of the plugin to run a script from
|
|
140
|
-
* @property {string} scriptName - name of the script to run
|
|
141
|
-
* @property {string[]} [extraArgs] - arguments to pass to the script
|
|
142
|
-
*/
|
|
143
|
-
/**
|
|
144
|
-
* Options for {@linkcode PluginCliCommand.doctor}.
|
|
145
|
-
* @typedef PluginDoctorOptions
|
|
146
|
-
* @property {string} plugin - name of the plugin to run doctor checks for
|
|
147
|
-
*/
|
|
148
96
|
//# sourceMappingURL=plugin-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-command.js","sourceRoot":"","sources":["../../../lib/cli/plugin-command.
|
|
1
|
+
{"version":3,"file":"plugin-command.js","sourceRoot":"","sources":["../../../lib/cli/plugin-command.ts"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AAEvB,4EAAsD;AAQtD,4CAA2C;AAE3C,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AAOtD,MAAqB,gBAAiB,SAAQ,2BAA6B;IACzE,YAAY,EAAC,MAAM,EAAE,IAAI,EAAoC;QAC3D,KAAK,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,yBAAa,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAoB;QACjE,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,MAAM;YACnB,WAAW;YACX,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,EAAC,MAAM,EAAsB;QAC3C,OAAO,MAAM,KAAK,CAAC,UAAU,CAAC,EAAC,WAAW,EAAE,MAAM,EAAC,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,MAAM,EAAmB;QAC7C,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAC,C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