appium 3.3.0 → 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} +9 -26
- 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/{grid-register.js → bootstrap/grid-v3-register.js} +28 -13
- 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.map +1 -1
- package/build/lib/cli/args.js +9 -9
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +95 -95
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +18 -18
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts +1 -1
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +5 -5
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/parser.d.ts +8 -8
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +49 -49
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/setup-command.js +6 -6
- package/build/lib/cli/setup-command.js.map +1 -1
- package/build/lib/cli/utils.d.ts +17 -17
- package/build/lib/cli/utils.d.ts.map +1 -1
- package/build/lib/cli/utils.js +29 -29
- package/build/lib/cli/utils.js.map +1 -1
- package/build/lib/doctor/doctor.d.ts +2 -2
- package/build/lib/doctor/doctor.d.ts.map +1 -1
- package/build/lib/doctor/doctor.js +6 -6
- 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/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/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.js +2 -2
- package/build/lib/schema/cli-args.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 +2 -0
- 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/schema.d.ts +15 -15
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +37 -37
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils.d.ts +0 -81
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +1 -248
- 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/{config-file.ts → bootstrap/config-file.ts} +29 -63
- package/lib/{grid-register.ts → bootstrap/grid-v3-register.ts} +35 -35
- 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.ts +10 -10
- package/lib/cli/extension-command.ts +132 -132
- package/lib/cli/extension.ts +7 -7
- package/lib/cli/parser.ts +50 -50
- package/lib/cli/setup-command.ts +2 -2
- package/lib/cli/utils.ts +33 -33
- package/lib/doctor/doctor.ts +8 -8
- 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/main.ts +60 -0
- package/lib/schema/cli-args-guards.ts +67 -0
- package/lib/schema/cli-args.ts +1 -1
- package/lib/schema/format-errors.ts +43 -0
- package/lib/schema/index.ts +2 -0
- package/lib/schema/schema.ts +51 -52
- package/lib/utils.ts +0 -331
- package/package.json +12 -13
- package/scripts/autoinstall-extensions.js +3 -0
- package/build/lib/config-file.d.ts +0 -57
- 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 -68
- package/build/lib/config.d.ts.map +0 -1
- package/build/lib/config.js +0 -358
- package/build/lib/config.js.map +0 -1
- package/build/lib/grid-register.d.ts +0 -35
- package/build/lib/grid-register.d.ts.map +0 -1
- package/build/lib/grid-register.js.map +0 -1
- package/lib/config.ts +0 -377
- 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/main.js +0 -545
|
@@ -33,9 +33,6 @@ import * as semver from 'semver';
|
|
|
33
33
|
const UPDATE_ALL = 'installed';
|
|
34
34
|
const MAX_CONCURRENT_REPO_FETCHES = 5;
|
|
35
35
|
|
|
36
|
-
class NotUpdatableError extends Error {}
|
|
37
|
-
class NoUpdatesAvailableError extends Error {}
|
|
38
|
-
|
|
39
36
|
/**
|
|
40
37
|
* Options for the {@linkcode ExtensionCliCommand} constructor
|
|
41
38
|
*/
|
|
@@ -43,15 +40,15 @@ export type ExtensionCommandOptions<ExtType extends ExtensionType = ExtensionTyp
|
|
|
43
40
|
config: ExtensionConfig<ExtType>;
|
|
44
41
|
json: boolean;
|
|
45
42
|
};
|
|
46
|
-
|
|
47
43
|
export type ExtensionConfig<ExtType extends ExtensionType = ExtensionType> = BaseExtensionConfig<ExtType>;
|
|
44
|
+
|
|
48
45
|
export type ExtRecord<ExtType extends ExtensionType = ExtensionType> = AppiumExtRecord<ExtType>;
|
|
46
|
+
|
|
49
47
|
export type ExtMetadata<ExtType extends ExtensionType = ExtensionType> = AppiumExtMetadata<ExtType>;
|
|
50
48
|
export type ExtManifest<ExtType extends ExtensionType = ExtensionType> = AppiumExtManifest<ExtType>;
|
|
51
49
|
export type ExtPackageJson<ExtType extends ExtensionType = ExtensionType> = AppiumExtPackageJson<ExtType>;
|
|
52
50
|
export type ExtInstallReceipt<ExtType extends ExtensionType = ExtensionType> =
|
|
53
51
|
AppiumExtInstallReceipt<ExtType>;
|
|
54
|
-
|
|
55
52
|
/**
|
|
56
53
|
* Extra stuff about extensions; used indirectly by {@linkcode ExtensionCliCommand.list}.
|
|
57
54
|
*/
|
|
@@ -64,7 +61,6 @@ export type ExtensionListMetadata = {
|
|
|
64
61
|
devMode?: boolean;
|
|
65
62
|
repositoryUrl?: string;
|
|
66
63
|
};
|
|
67
|
-
|
|
68
64
|
/**
|
|
69
65
|
* Possible return value for {@linkcode ExtensionCliCommand.list}
|
|
70
66
|
*/
|
|
@@ -85,32 +81,92 @@ export type ExtensionList<ExtType extends ExtensionType = ExtensionType> = Recor
|
|
|
85
81
|
>;
|
|
86
82
|
|
|
87
83
|
/**
|
|
88
|
-
*
|
|
84
|
+
* Return value of {@linkcode ExtensionCliCommand._run}
|
|
89
85
|
*/
|
|
90
|
-
|
|
91
|
-
receipt: ExtInstallReceipt<ExtType>
|
|
92
|
-
): ExtManifest<ExtType> {
|
|
93
|
-
return _.omit(receipt, 'driverName', 'pluginName') as ExtManifest<ExtType>;
|
|
94
|
-
}
|
|
86
|
+
export type RunOutput = {output?: string[]};
|
|
95
87
|
|
|
96
88
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @param pkgName Extension name
|
|
100
|
-
* @param [pkgVer] Extension version (if not provided then the latest is assumed)
|
|
89
|
+
* Return type of {@linkcode ExtensionCliCommand.getPostInstallText}.
|
|
101
90
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
export type PostInstallText = string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Return value of {@linkcode ExtensionCliCommand._update}.
|
|
95
|
+
*/
|
|
96
|
+
export type ExtensionUpdateResult = {errors: Record<string, Error>; updates: Record<string, UpdateReport>};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Used by {@linkcode ExtensionCliCommand.getPostInstallText}
|
|
100
|
+
*/
|
|
101
|
+
export type ExtensionArgs<ExtType extends ExtensionType = ExtensionType> = {
|
|
102
|
+
extName: string;
|
|
103
|
+
extData: ExtInstallReceipt<ExtType>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Options for {@linkcode ExtensionCliCommand._run}.
|
|
108
|
+
*/
|
|
109
|
+
type RunOptions = {
|
|
110
|
+
installSpec: string;
|
|
111
|
+
scriptName?: string;
|
|
112
|
+
extraArgs?: string[];
|
|
113
|
+
bufferOutput?: boolean;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Options for {@linkcode ExtensionCliCommand.doctor}.
|
|
118
|
+
*/
|
|
119
|
+
type DoctorOptions = {installSpec: string};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Options for {@linkcode ExtensionCliCommand._update}.
|
|
123
|
+
*/
|
|
124
|
+
type ExtensionUpdateOpts = {installSpec: string; unsafe: boolean};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Part of result of {@linkcode ExtensionCliCommand._update}.
|
|
128
|
+
*/
|
|
129
|
+
type UpdateReport = {from: string; to: string | null};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Options for {@linkcode ExtensionCliCommand._uninstall}.
|
|
133
|
+
*/
|
|
134
|
+
type UninstallOpts = {installSpec: string};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Options for {@linkcode ExtensionCliCommand.installViaNpm}
|
|
138
|
+
*/
|
|
139
|
+
type InstallViaNpmArgs = {
|
|
140
|
+
installSpec: string;
|
|
141
|
+
pkgName: string;
|
|
142
|
+
installType: InstallType;
|
|
143
|
+
pkgVer?: string;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Object returned by {@linkcode ExtensionCliCommand.checkForExtensionUpdate}
|
|
148
|
+
*/
|
|
149
|
+
type PossibleUpdates = {current: string; safeUpdate: string | null; unsafeUpdate: string | null};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Options for {@linkcode ExtensionCliCommand._install}
|
|
153
|
+
*/
|
|
154
|
+
type InstallOpts = {installSpec: string; installType: InstallType; packageName?: string};
|
|
155
|
+
|
|
156
|
+
type ListOptions = {showInstalled: boolean; showUpdates: boolean; verbose?: boolean};
|
|
157
|
+
|
|
158
|
+
type GetInstallationReceiptOpts<ExtType extends ExtensionType = ExtensionType> = {
|
|
159
|
+
installPath: string;
|
|
160
|
+
installSpec: string;
|
|
161
|
+
pkg: ExtPackageJson<ExtType>;
|
|
162
|
+
installType: InstallType;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
type InstalledExtensionLike = {installType?: InstallType; installPath?: string};
|
|
166
|
+
|
|
167
|
+
class NotUpdatableError extends Error {}
|
|
168
|
+
|
|
169
|
+
class NoUpdatesAvailableError extends Error {}
|
|
114
170
|
|
|
115
171
|
abstract class ExtensionCliCommand<ExtType extends ExtensionType = ExtensionType> {
|
|
116
172
|
/**
|
|
@@ -190,19 +246,6 @@ abstract class ExtensionCliCommand<ExtType extends ExtensionType = ExtensionType
|
|
|
190
246
|
return await this._displayNormalListOutput(listData, showUpdates);
|
|
191
247
|
}
|
|
192
248
|
|
|
193
|
-
/**
|
|
194
|
-
* For any `package.json` fields which a particular type of extension requires, validate the
|
|
195
|
-
* presence and form of those fields on the `package.json` data, throwing an error if anything is
|
|
196
|
-
* amiss.
|
|
197
|
-
*
|
|
198
|
-
* @param extMetadata - the data in the "appium" field of `package.json` for an extension
|
|
199
|
-
* @param installSpec - Extension name/spec
|
|
200
|
-
*/
|
|
201
|
-
protected abstract validateExtensionFields(
|
|
202
|
-
extMetadata: ExtMetadata<ExtType>,
|
|
203
|
-
installSpec: string
|
|
204
|
-
): void;
|
|
205
|
-
|
|
206
249
|
/**
|
|
207
250
|
* Logs a message and returns an {@linkcode Error} to throw.
|
|
208
251
|
*
|
|
@@ -373,13 +416,6 @@ abstract class ExtensionCliCommand<ExtType extends ExtensionType = ExtensionType
|
|
|
373
416
|
return this.config.installedExtensions;
|
|
374
417
|
}
|
|
375
418
|
|
|
376
|
-
/**
|
|
377
|
-
* Get the text which should be displayed to the user after an extension has been installed. This
|
|
378
|
-
* is designed to be overridden by drivers/plugins with their own particular text.
|
|
379
|
-
*
|
|
380
|
-
*/
|
|
381
|
-
protected abstract getPostInstallText(args: ExtensionArgs<ExtType>): PostInstallText;
|
|
382
|
-
|
|
383
419
|
/**
|
|
384
420
|
* Uninstall an extension.
|
|
385
421
|
*
|
|
@@ -1124,6 +1160,26 @@ abstract class ExtensionCliCommand<ExtType extends ExtensionType = ExtensionType
|
|
|
1124
1160
|
}
|
|
1125
1161
|
});
|
|
1126
1162
|
}
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* For any `package.json` fields which a particular type of extension requires, validate the
|
|
1166
|
+
* presence and form of those fields on the `package.json` data, throwing an error if anything is
|
|
1167
|
+
* amiss.
|
|
1168
|
+
*
|
|
1169
|
+
* @param extMetadata - the data in the "appium" field of `package.json` for an extension
|
|
1170
|
+
* @param installSpec - Extension name/spec
|
|
1171
|
+
*/
|
|
1172
|
+
protected abstract validateExtensionFields(
|
|
1173
|
+
extMetadata: ExtMetadata<ExtType>,
|
|
1174
|
+
installSpec: string
|
|
1175
|
+
): void;
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Get the text which should be displayed to the user after an extension has been installed. This
|
|
1179
|
+
* is designed to be overridden by drivers/plugins with their own particular text.
|
|
1180
|
+
*
|
|
1181
|
+
*/
|
|
1182
|
+
protected abstract getPostInstallText(args: ExtensionArgs<ExtType>): PostInstallText;
|
|
1127
1183
|
}
|
|
1128
1184
|
|
|
1129
1185
|
/**
|
|
@@ -1164,6 +1220,34 @@ export async function injectAppiumSymlinks(
|
|
|
1164
1220
|
);
|
|
1165
1221
|
}
|
|
1166
1222
|
|
|
1223
|
+
/**
|
|
1224
|
+
* Omits `driverName`/`pluginName` props from the receipt to make a {@linkcode ExtManifest}
|
|
1225
|
+
*/
|
|
1226
|
+
function receiptToManifest<ExtType extends ExtensionType>(
|
|
1227
|
+
receipt: ExtInstallReceipt<ExtType>
|
|
1228
|
+
): ExtManifest<ExtType> {
|
|
1229
|
+
return _.omit(receipt, 'driverName', 'pluginName') as ExtManifest<ExtType>;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* Fetches the remote extension version requirements
|
|
1234
|
+
*
|
|
1235
|
+
* @param pkgName Extension name
|
|
1236
|
+
* @param [pkgVer] Extension version (if not provided then the latest is assumed)
|
|
1237
|
+
*/
|
|
1238
|
+
async function getRemoteExtensionVersionReq(
|
|
1239
|
+
pkgName: string,
|
|
1240
|
+
pkgVer?: string
|
|
1241
|
+
): Promise<[string, string | null]> {
|
|
1242
|
+
const allDeps = await npm.getPackageInfo(
|
|
1243
|
+
`${pkgName}${pkgVer ? `@${pkgVer}` : ``}`,
|
|
1244
|
+
['peerDependencies', 'dependencies']
|
|
1245
|
+
);
|
|
1246
|
+
const requiredVersionPair = _.flatMap(_.values(allDeps).map(_.toPairs))
|
|
1247
|
+
.find(([name]) => name === 'appium');
|
|
1248
|
+
return [npmPackage.version, requiredVersionPair ? requiredVersionPair[1] : null];
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1167
1251
|
/**
|
|
1168
1252
|
* This is needed to ensure proper module resolution for installed extensions,
|
|
1169
1253
|
* especially ESM ones.
|
|
@@ -1187,90 +1271,6 @@ async function injectAppiumSymlink(dstFolder: string, logger: AppiumLogger): Pro
|
|
|
1187
1271
|
}
|
|
1188
1272
|
}
|
|
1189
1273
|
|
|
1190
|
-
/**
|
|
1191
|
-
* Options for {@linkcode ExtensionCliCommand._run}.
|
|
1192
|
-
*/
|
|
1193
|
-
type RunOptions = {
|
|
1194
|
-
installSpec: string;
|
|
1195
|
-
scriptName?: string;
|
|
1196
|
-
extraArgs?: string[];
|
|
1197
|
-
bufferOutput?: boolean;
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* Options for {@linkcode ExtensionCliCommand.doctor}.
|
|
1202
|
-
*/
|
|
1203
|
-
type DoctorOptions = {installSpec: string};
|
|
1204
|
-
|
|
1205
|
-
/**
|
|
1206
|
-
* Return value of {@linkcode ExtensionCliCommand._run}
|
|
1207
|
-
*/
|
|
1208
|
-
export type RunOutput = {output?: string[]};
|
|
1209
|
-
|
|
1210
|
-
/**
|
|
1211
|
-
* Return type of {@linkcode ExtensionCliCommand.getPostInstallText}.
|
|
1212
|
-
*/
|
|
1213
|
-
export type PostInstallText = string;
|
|
1214
|
-
|
|
1215
|
-
/**
|
|
1216
|
-
* Options for {@linkcode ExtensionCliCommand._update}.
|
|
1217
|
-
*/
|
|
1218
|
-
type ExtensionUpdateOpts = {installSpec: string; unsafe: boolean};
|
|
1219
|
-
|
|
1220
|
-
/**
|
|
1221
|
-
* Part of result of {@linkcode ExtensionCliCommand._update}.
|
|
1222
|
-
*/
|
|
1223
|
-
type UpdateReport = {from: string; to: string | null};
|
|
1224
|
-
|
|
1225
|
-
/**
|
|
1226
|
-
* Return value of {@linkcode ExtensionCliCommand._update}.
|
|
1227
|
-
*/
|
|
1228
|
-
export type ExtensionUpdateResult = {errors: Record<string, Error>; updates: Record<string, UpdateReport>};
|
|
1229
|
-
|
|
1230
|
-
/**
|
|
1231
|
-
* Options for {@linkcode ExtensionCliCommand._uninstall}.
|
|
1232
|
-
*/
|
|
1233
|
-
type UninstallOpts = {installSpec: string};
|
|
1234
|
-
|
|
1235
|
-
/**
|
|
1236
|
-
* Used by {@linkcode ExtensionCliCommand.getPostInstallText}
|
|
1237
|
-
*/
|
|
1238
|
-
export type ExtensionArgs<ExtType extends ExtensionType = ExtensionType> = {
|
|
1239
|
-
extName: string;
|
|
1240
|
-
extData: ExtInstallReceipt<ExtType>;
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
/**
|
|
1244
|
-
* Options for {@linkcode ExtensionCliCommand.installViaNpm}
|
|
1245
|
-
*/
|
|
1246
|
-
type InstallViaNpmArgs = {
|
|
1247
|
-
installSpec: string;
|
|
1248
|
-
pkgName: string;
|
|
1249
|
-
installType: InstallType;
|
|
1250
|
-
pkgVer?: string;
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
|
-
/**
|
|
1254
|
-
* Object returned by {@linkcode ExtensionCliCommand.checkForExtensionUpdate}
|
|
1255
|
-
*/
|
|
1256
|
-
type PossibleUpdates = {current: string; safeUpdate: string | null; unsafeUpdate: string | null};
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* Options for {@linkcode ExtensionCliCommand._install}
|
|
1260
|
-
*/
|
|
1261
|
-
type InstallOpts = {installSpec: string; installType: InstallType; packageName?: string};
|
|
1262
|
-
|
|
1263
|
-
type ListOptions = {showInstalled: boolean; showUpdates: boolean; verbose?: boolean};
|
|
1264
|
-
|
|
1265
|
-
type GetInstallationReceiptOpts<ExtType extends ExtensionType = ExtensionType> = {
|
|
1266
|
-
installPath: string;
|
|
1267
|
-
installSpec: string;
|
|
1268
|
-
pkg: ExtPackageJson<ExtType>;
|
|
1269
|
-
installType: InstallType;
|
|
1270
|
-
};
|
|
1271
|
-
|
|
1272
|
-
type InstalledExtensionLike = {installType?: InstallType; installPath?: string};
|
|
1273
|
-
|
|
1274
1274
|
export default ExtensionCliCommand;
|
|
1275
1275
|
export {ExtensionCliCommand as ExtensionCommand};
|
|
1276
1276
|
|
package/lib/cli/extension.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {Class, DriverType, ExtensionType, PluginType} from '@appium/types';
|
|
|
3
3
|
import type {Args, CliExtensionCommand, CliExtensionSubcommand} from 'appium/types';
|
|
4
4
|
import type {ExtensionConfig} from '../extension/extension-config';
|
|
5
5
|
import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
6
|
-
import {isExtensionCommandArgs} from '../
|
|
6
|
+
import {isExtensionCommandArgs} from '../schema/cli-args-guards';
|
|
7
7
|
import DriverCliCommand from './driver-command';
|
|
8
8
|
import PluginCliCommand from './plugin-command';
|
|
9
9
|
import {errAndQuit, JSON_SPACES} from './utils';
|
|
@@ -15,6 +15,12 @@ export const commandClasses = Object.freeze(
|
|
|
15
15
|
} as const
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
+
export type ExtCommand<ExtType extends ExtensionType> = ExtType extends DriverType
|
|
19
|
+
? Class<DriverCliCommand>
|
|
20
|
+
: ExtType extends PluginType
|
|
21
|
+
? Class<PluginCliCommand>
|
|
22
|
+
: never;
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* Executes a driver/plugin extension subcommand and returns the command result.
|
|
20
26
|
*
|
|
@@ -57,9 +63,3 @@ export async function runExtensionCommand<
|
|
|
57
63
|
|
|
58
64
|
return jsonResult;
|
|
59
65
|
}
|
|
60
|
-
|
|
61
|
-
export type ExtCommand<ExtType extends ExtensionType> = ExtType extends DriverType
|
|
62
|
-
? Class<DriverCliCommand>
|
|
63
|
-
: ExtType extends PluginType
|
|
64
|
-
? Class<PluginCliCommand>
|
|
65
|
-
: never;
|
package/lib/cli/parser.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
SETUP_SUBCOMMAND
|
|
19
19
|
} from '../constants';
|
|
20
20
|
import {finalizeSchema, getAllArgSpecs, getArgSpec, hasArgSpec} from '../schema';
|
|
21
|
-
import {rootDir} from '../
|
|
21
|
+
import {rootDir} from '../helpers/build';
|
|
22
22
|
import {getExtensionArgs, getServerArgs} from './args';
|
|
23
23
|
import type {ArgumentDefinitions} from './args';
|
|
24
24
|
import {
|
|
@@ -104,53 +104,6 @@ export class ArgParser {
|
|
|
104
104
|
this.parse_args = this.parseArgs;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
/**
|
|
108
|
-
* Parses CLI args and returns Appium's normalized argument object.
|
|
109
|
-
*
|
|
110
|
-
* If no explicit subcommand is provided, this injects `server`.
|
|
111
|
-
* `parse_args` is a backwards-compatible alias of this method.
|
|
112
|
-
*/
|
|
113
|
-
parseArgs(args: string[] = process.argv.slice(2)): TransformedArgsMap {
|
|
114
|
-
if (!NON_SERVER_ARGS.has(args[0])) {
|
|
115
|
-
args.unshift(SERVER_SUBCOMMAND);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const parsed = this.parser.parse_known_args(args);
|
|
120
|
-
const [knownArgs, unknownArgs] = parsed;
|
|
121
|
-
// XXX: you'd think that argparse, when given an alias for a subcommand,
|
|
122
|
-
// would set this value to the original subcommand name, but it doesn't.
|
|
123
|
-
if (knownArgs?.driverCommand === 'ls') {
|
|
124
|
-
knownArgs.driverCommand = 'list';
|
|
125
|
-
} else if (knownArgs?.pluginCommand === 'ls') {
|
|
126
|
-
knownArgs.pluginCommand = 'list';
|
|
127
|
-
}
|
|
128
|
-
if (
|
|
129
|
-
unknownArgs?.length &&
|
|
130
|
-
(knownArgs.driverCommand === 'run' || knownArgs.pluginCommand === 'run')
|
|
131
|
-
) {
|
|
132
|
-
return ArgParser._transformParsedArgs(knownArgs, unknownArgs);
|
|
133
|
-
} else if (unknownArgs?.length) {
|
|
134
|
-
throw new Error(`[ERROR] Unrecognized arguments: ${unknownArgs.join(' ')}`);
|
|
135
|
-
}
|
|
136
|
-
return ArgParser._transformParsedArgs(knownArgs);
|
|
137
|
-
} catch (err) {
|
|
138
|
-
if (this.debug) {
|
|
139
|
-
throw err;
|
|
140
|
-
}
|
|
141
|
-
// this isn't tested via unit tests (we use `debug: true`) so may escape coverage.
|
|
142
|
-
|
|
143
|
-
/* istanbul ignore next */
|
|
144
|
-
{
|
|
145
|
-
// eslint-disable-next-line no-console
|
|
146
|
-
console.error(); // need an extra space since argparse prints usage.
|
|
147
|
-
// eslint-disable-next-line no-console
|
|
148
|
-
console.error(err.message);
|
|
149
|
-
process.exit(1);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
107
|
/**
|
|
155
108
|
* Normalizes server arg keys from schema names to parser destination names.
|
|
156
109
|
*
|
|
@@ -353,13 +306,60 @@ export class ArgParser {
|
|
|
353
306
|
ArgParser._patchExit(parser);
|
|
354
307
|
}
|
|
355
308
|
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Parses CLI args and returns Appium's normalized argument object.
|
|
312
|
+
*
|
|
313
|
+
* If no explicit subcommand is provided, this injects `server`.
|
|
314
|
+
* `parse_args` is a backwards-compatible alias of this method.
|
|
315
|
+
*/
|
|
316
|
+
parseArgs(args: string[] = process.argv.slice(2)): TransformedArgsMap {
|
|
317
|
+
if (!NON_SERVER_ARGS.has(args[0])) {
|
|
318
|
+
args.unshift(SERVER_SUBCOMMAND);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
const parsed = this.parser.parse_known_args(args);
|
|
323
|
+
const [knownArgs, unknownArgs] = parsed;
|
|
324
|
+
// XXX: you'd think that argparse, when given an alias for a subcommand,
|
|
325
|
+
// would set this value to the original subcommand name, but it doesn't.
|
|
326
|
+
if (knownArgs?.driverCommand === 'ls') {
|
|
327
|
+
knownArgs.driverCommand = 'list';
|
|
328
|
+
} else if (knownArgs?.pluginCommand === 'ls') {
|
|
329
|
+
knownArgs.pluginCommand = 'list';
|
|
330
|
+
}
|
|
331
|
+
if (
|
|
332
|
+
unknownArgs?.length &&
|
|
333
|
+
(knownArgs.driverCommand === 'run' || knownArgs.pluginCommand === 'run')
|
|
334
|
+
) {
|
|
335
|
+
return ArgParser._transformParsedArgs(knownArgs, unknownArgs);
|
|
336
|
+
} else if (unknownArgs?.length) {
|
|
337
|
+
throw new Error(`[ERROR] Unrecognized arguments: ${unknownArgs.join(' ')}`);
|
|
338
|
+
}
|
|
339
|
+
return ArgParser._transformParsedArgs(knownArgs);
|
|
340
|
+
} catch (err) {
|
|
341
|
+
if (this.debug) {
|
|
342
|
+
throw err;
|
|
343
|
+
}
|
|
344
|
+
// this isn't tested via unit tests (we use `debug: true`) so may escape coverage.
|
|
345
|
+
|
|
346
|
+
/* istanbul ignore next */
|
|
347
|
+
{
|
|
348
|
+
// eslint-disable-next-line no-console
|
|
349
|
+
console.error(); // need an extra space since argparse prints usage.
|
|
350
|
+
// eslint-disable-next-line no-console
|
|
351
|
+
console.error(err.message);
|
|
352
|
+
process.exit(1);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
/**
|
|
359
359
|
* Creates and returns an `ArgParser` after finalizing schema state.
|
|
360
360
|
*/
|
|
361
|
-
export function getParser(debug = false) {
|
|
362
|
-
finalizeSchema();
|
|
361
|
+
export async function getParser(debug = false): Promise<ArgParser> {
|
|
362
|
+
await finalizeSchema();
|
|
363
363
|
|
|
364
364
|
return new ArgParser(debug);
|
|
365
365
|
}
|
package/lib/cli/setup-command.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '../constants';
|
|
14
14
|
import {runExtensionCommand} from './extension';
|
|
15
15
|
import { system, fs } from '@appium/support';
|
|
16
|
-
import log from '../logger';
|
|
16
|
+
import {log} from '../logger';
|
|
17
17
|
import type {ExtensionConfig} from '../extension/extension-config';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -131,7 +131,7 @@ async function resetAllExtensions(driverConfig: DriverConfig, pluginConfig: Plug
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
const manifestPath = config.manifestPath;
|
|
134
|
-
if (!await fs.exists(manifestPath)) {
|
|
134
|
+
if (!manifestPath || !await fs.exists(manifestPath)) {
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
137
|
|
package/lib/cli/utils.ts
CHANGED
|
@@ -6,6 +6,39 @@ export const JSON_SPACES = 4;
|
|
|
6
6
|
|
|
7
7
|
type ErrorLike = Error & {stderr?: unknown};
|
|
8
8
|
|
|
9
|
+
export class RingBuffer<T = any> {
|
|
10
|
+
private readonly size: number;
|
|
11
|
+
private readonly buffer: T[] = [];
|
|
12
|
+
|
|
13
|
+
constructor(size = 50) {
|
|
14
|
+
this.size = size;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the current buffer contents.
|
|
19
|
+
*/
|
|
20
|
+
getBuff(): T[] {
|
|
21
|
+
return this.buffer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Add an item to the buffer.
|
|
26
|
+
*/
|
|
27
|
+
enqueue(item: T): void {
|
|
28
|
+
if (this.buffer.length >= this.size) {
|
|
29
|
+
this.dequeue();
|
|
30
|
+
}
|
|
31
|
+
this.buffer.push(item);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Remove the oldest item from the buffer.
|
|
36
|
+
*/
|
|
37
|
+
dequeue(): void {
|
|
38
|
+
this.buffer.shift();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
9
42
|
/**
|
|
10
43
|
* Log an error to the console and exit the process.
|
|
11
44
|
*
|
|
@@ -62,36 +95,3 @@ export async function spinWith<T>(
|
|
|
62
95
|
throw err;
|
|
63
96
|
}
|
|
64
97
|
}
|
|
65
|
-
|
|
66
|
-
export class RingBuffer<T = any> {
|
|
67
|
-
private readonly size: number;
|
|
68
|
-
private readonly buffer: T[] = [];
|
|
69
|
-
|
|
70
|
-
constructor(size = 50) {
|
|
71
|
-
this.size = size;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get the current buffer contents.
|
|
76
|
-
*/
|
|
77
|
-
getBuff(): T[] {
|
|
78
|
-
return this.buffer;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Add an item to the buffer.
|
|
83
|
-
*/
|
|
84
|
-
enqueue(item: T): void {
|
|
85
|
-
if (this.buffer.length >= this.size) {
|
|
86
|
-
this.dequeue();
|
|
87
|
-
}
|
|
88
|
-
this.buffer.push(item);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Remove the oldest item from the buffer.
|
|
93
|
-
*/
|
|
94
|
-
dequeue(): void {
|
|
95
|
-
this.buffer.shift();
|
|
96
|
-
}
|
|
97
|
-
}
|
package/lib/doctor/doctor.ts
CHANGED
|
@@ -42,6 +42,14 @@ export class Doctor {
|
|
|
42
42
|
this.foundIssues = [];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
private get issuesRequiredToFix(): DoctorIssue[] {
|
|
46
|
+
return this.foundIssues.filter((f) => !f.check.isOptional());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private get issuesOptionalToFix(): DoctorIssue[] {
|
|
50
|
+
return this.foundIssues.filter((f) => f.check.isOptional());
|
|
51
|
+
}
|
|
52
|
+
|
|
45
53
|
/**
|
|
46
54
|
* Runs diagnostics, reports issues, attempts automatic fixes where supported, and returns an exit code.
|
|
47
55
|
*
|
|
@@ -62,14 +70,6 @@ export class Doctor {
|
|
|
62
70
|
return EXIT_CODE.SUCCESS;
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
private get issuesRequiredToFix(): DoctorIssue[] {
|
|
66
|
-
return this.foundIssues.filter((f) => !f.check.isOptional());
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private get issuesOptionalToFix(): DoctorIssue[] {
|
|
70
|
-
return this.foundIssues.filter((f) => f.check.isOptional());
|
|
71
|
-
}
|
|
72
|
-
|
|
73
73
|
/**
|
|
74
74
|
* The doctor shows the report
|
|
75
75
|
*/
|