appium 2.0.0-beta.56 → 2.0.0-beta.58
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/LICENSE +1 -1
- package/README.md +6 -8
- package/build/lib/appium.d.ts +43 -35
- package/build/lib/appium.d.ts.map +1 -1
- package/build/lib/appium.js +38 -30
- package/build/lib/appium.js.map +1 -1
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +10 -0
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts +7 -7
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +13 -8
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +60 -43
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +133 -65
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts +5 -5
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +1 -1
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts +7 -7
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +13 -8
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/config.d.ts +1 -1
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +3 -2
- package/build/lib/config.js.map +1 -1
- package/build/lib/constants.d.ts +8 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +9 -2
- package/build/lib/constants.js.map +1 -1
- package/build/lib/extension/driver-config.d.ts +6 -6
- package/build/lib/extension/driver-config.d.ts.map +1 -1
- package/build/lib/extension/driver-config.js +5 -7
- package/build/lib/extension/driver-config.js.map +1 -1
- package/build/lib/extension/extension-config.d.ts +31 -10
- package/build/lib/extension/extension-config.d.ts.map +1 -1
- package/build/lib/extension/extension-config.js +44 -24
- package/build/lib/extension/extension-config.js.map +1 -1
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -1
- package/build/lib/extension/manifest-migrations.js +29 -13
- package/build/lib/extension/manifest-migrations.js.map +1 -1
- package/build/lib/extension/manifest.d.ts +5 -5
- package/build/lib/extension/manifest.d.ts.map +1 -1
- package/build/lib/extension/manifest.js +19 -12
- package/build/lib/extension/manifest.js.map +1 -1
- package/build/lib/main.d.ts.map +1 -1
- package/build/lib/main.js +3 -3
- package/build/lib/main.js.map +1 -1
- package/build/lib/schema/cli-args.d.ts +1 -1
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +1 -1
- package/build/lib/utils.d.ts +118 -12
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +8 -10
- package/build/lib/utils.js.map +1 -1
- package/build/types/manifest/index.d.ts +4 -2
- package/build/types/manifest/index.d.ts.map +1 -1
- package/build/types/manifest/index.js +4 -2
- package/build/types/manifest/index.js.map +1 -1
- package/build/types/manifest/v4.d.ts +139 -0
- package/build/types/manifest/v4.d.ts.map +1 -0
- package/build/types/manifest/v4.js +3 -0
- package/build/types/manifest/v4.js.map +1 -0
- package/lib/appium.js +43 -32
- package/lib/cli/args.js +10 -0
- package/lib/cli/driver-command.js +13 -8
- package/lib/cli/extension-command.js +146 -75
- package/lib/cli/extension.js +5 -5
- package/lib/cli/plugin-command.js +13 -8
- package/lib/config.js +3 -2
- package/lib/constants.js +9 -1
- package/lib/extension/driver-config.js +5 -8
- package/lib/extension/extension-config.js +42 -15
- package/lib/extension/manifest-migrations.js +31 -15
- package/lib/extension/manifest.js +26 -19
- package/lib/main.js +7 -4
- package/lib/schema/cli-args.js +1 -1
- package/lib/utils.js +8 -10
- package/package.json +11 -11
- package/scripts/autoinstall-extensions.js +23 -0
- package/types/manifest/index.ts +4 -3
- package/types/manifest/v4.ts +161 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {util} from '@appium/support';
|
|
2
2
|
import B from 'bluebird';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import resolveFrom from 'resolve-from';
|
|
5
6
|
import {satisfies} from 'semver';
|
|
6
|
-
import {util} from '@appium/support';
|
|
7
7
|
import {commandClasses} from '../cli/extension';
|
|
8
8
|
import {APPIUM_VER} from '../config';
|
|
9
9
|
import log from '../logger';
|
|
@@ -13,17 +13,41 @@ import {
|
|
|
13
13
|
registerSchema,
|
|
14
14
|
} from '../schema/schema';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
/**
|
|
17
|
+
* "npm" install type
|
|
18
|
+
* Used when extension was installed by npm package name
|
|
19
|
+
* @remarks _All_ extensions are installed _by_ `npm`, but only this one means the package name was
|
|
20
|
+
* used to specify it
|
|
21
|
+
*/
|
|
22
|
+
export const INSTALL_TYPE_NPM = 'npm';
|
|
23
|
+
/**
|
|
24
|
+
* "local" install type
|
|
25
|
+
* Used when extension was installed from a local path
|
|
26
|
+
*/
|
|
27
|
+
export const INSTALL_TYPE_LOCAL = 'local';
|
|
28
|
+
/**
|
|
29
|
+
* "github" install type
|
|
30
|
+
* Used when extension was installed via GitHub URL
|
|
31
|
+
*/
|
|
32
|
+
export const INSTALL_TYPE_GITHUB = 'github';
|
|
33
|
+
/**
|
|
34
|
+
* "git" install type
|
|
35
|
+
* Used when extensions was installed via Git URL
|
|
36
|
+
*/
|
|
37
|
+
export const INSTALL_TYPE_GIT = 'git';
|
|
38
|
+
/**
|
|
39
|
+
* "dev" install type
|
|
40
|
+
* Used when automatically detected as a working copy
|
|
41
|
+
*/
|
|
42
|
+
export const INSTALL_TYPE_DEV = 'dev';
|
|
20
43
|
|
|
21
44
|
/** @type {Set<InstallType>} */
|
|
22
|
-
const INSTALL_TYPES = new Set([
|
|
45
|
+
export const INSTALL_TYPES = new Set([
|
|
23
46
|
INSTALL_TYPE_GIT,
|
|
24
47
|
INSTALL_TYPE_GITHUB,
|
|
25
48
|
INSTALL_TYPE_LOCAL,
|
|
26
49
|
INSTALL_TYPE_NPM,
|
|
50
|
+
INSTALL_TYPE_DEV,
|
|
27
51
|
]);
|
|
28
52
|
|
|
29
53
|
/**
|
|
@@ -54,7 +78,7 @@ export class ExtensionConfig {
|
|
|
54
78
|
manifest;
|
|
55
79
|
|
|
56
80
|
/**
|
|
57
|
-
* @type {
|
|
81
|
+
* @type {import('../cli/extension-command').ExtensionList<ExtType>|undefined}
|
|
58
82
|
*/
|
|
59
83
|
#listDataCache;
|
|
60
84
|
|
|
@@ -239,7 +263,7 @@ export class ExtensionConfig {
|
|
|
239
263
|
* This is an expensive operation, so the result is cached. Currently, there is no
|
|
240
264
|
* use case for invalidating the cache.
|
|
241
265
|
* @protected
|
|
242
|
-
* @returns {Promise<
|
|
266
|
+
* @returns {Promise<import('../cli/extension-command').ExtensionList<ExtType>>}
|
|
243
267
|
*/
|
|
244
268
|
async getListData() {
|
|
245
269
|
if (this.#listDataCache) {
|
|
@@ -300,7 +324,10 @@ export class ExtensionConfig {
|
|
|
300
324
|
|
|
301
325
|
if (_.isString(appiumVersion) && !satisfies(APPIUM_VER, appiumVersion)) {
|
|
302
326
|
const listData = await this.getListData();
|
|
303
|
-
const extListData =
|
|
327
|
+
const extListData =
|
|
328
|
+
/** @type {import('../cli/extension-command').ExtensionListData<ExtType>} */ (
|
|
329
|
+
listData[extName]
|
|
330
|
+
);
|
|
304
331
|
if (extListData?.installed) {
|
|
305
332
|
const {updateVersion, upToDate} = extListData;
|
|
306
333
|
if (!upToDate) {
|
|
@@ -319,7 +346,10 @@ export class ExtensionConfig {
|
|
|
319
346
|
}
|
|
320
347
|
} else if (!_.isString(appiumVersion)) {
|
|
321
348
|
const listData = await this.getListData();
|
|
322
|
-
const extListData =
|
|
349
|
+
const extListData =
|
|
350
|
+
/** @type {import('../cli/extension-command').InstalledExtensionListData<ExtType>} */ (
|
|
351
|
+
listData[extName]
|
|
352
|
+
);
|
|
323
353
|
if (!extListData?.upToDate && extListData?.updateVersion) {
|
|
324
354
|
warnings.push(
|
|
325
355
|
createPeerWarning(
|
|
@@ -544,6 +574,7 @@ export class ExtensionConfig {
|
|
|
544
574
|
delete require.cache[reqResolved];
|
|
545
575
|
}
|
|
546
576
|
log.debug(`Requiring ${this.extensionType} at ${reqPath}`);
|
|
577
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
547
578
|
const MainClass = require(reqPath)[mainClass];
|
|
548
579
|
if (!MainClass) {
|
|
549
580
|
throw new ReferenceError(
|
|
@@ -619,8 +650,6 @@ export class ExtensionConfig {
|
|
|
619
650
|
}
|
|
620
651
|
}
|
|
621
652
|
|
|
622
|
-
export {INSTALL_TYPE_NPM, INSTALL_TYPE_GIT, INSTALL_TYPE_LOCAL, INSTALL_TYPE_GITHUB, INSTALL_TYPES};
|
|
623
|
-
|
|
624
653
|
/**
|
|
625
654
|
* An issue with the {@linkcode ExtManifest} for a particular extension.
|
|
626
655
|
*
|
|
@@ -640,8 +669,6 @@ export {INSTALL_TYPE_NPM, INSTALL_TYPE_GIT, INSTALL_TYPE_LOCAL, INSTALL_TYPE_GIT
|
|
|
640
669
|
/**
|
|
641
670
|
* @typedef {import('@appium/types').ExtensionType} ExtensionType
|
|
642
671
|
* @typedef {import('./manifest').Manifest} Manifest
|
|
643
|
-
* @typedef {import('../cli/extension-command').ExtensionListData} ExtensionListData
|
|
644
|
-
* @typedef {import('../cli/extension-command').InstalledExtensionListData} InstalledExtensionListData
|
|
645
672
|
* @typedef {import('appium/types').InstallType} InstallType
|
|
646
673
|
*/
|
|
647
674
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
1
|
+
import {CURRENT_SCHEMA_REV, DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
2
2
|
import log from '../logger';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,6 +12,11 @@ import log from '../logger';
|
|
|
12
12
|
*/
|
|
13
13
|
const SCHEMA_REV_3 = 3;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Constant for v4 of the schema rev.
|
|
17
|
+
*/
|
|
18
|
+
const SCHEMA_REV_4 = 4;
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* Collection of functions to migrate from one version to another.
|
|
17
22
|
*
|
|
@@ -20,7 +25,7 @@ const SCHEMA_REV_3 = 3;
|
|
|
20
25
|
* itself will happen within {@linkcode Manifest.syncWithInstalledExtensions}; the extensions
|
|
21
26
|
* will be checked and the manifest file updated per the state of the filesystem.
|
|
22
27
|
*
|
|
23
|
-
* @type {{[P in keyof ManifestDataVersions]?: Migration}}
|
|
28
|
+
* @type { {[P in keyof ManifestDataVersions]?: Migration} }
|
|
24
29
|
*/
|
|
25
30
|
const Migrations = {
|
|
26
31
|
/**
|
|
@@ -32,19 +37,32 @@ const Migrations = {
|
|
|
32
37
|
* @type {Migration}
|
|
33
38
|
*/
|
|
34
39
|
[SCHEMA_REV_3]: (manifest) => {
|
|
35
|
-
let shouldSync = false;
|
|
36
40
|
/** @type {Array<ExtManifest<PluginType>|ExtManifest<DriverType>>} */
|
|
37
41
|
const allExtData = [
|
|
38
42
|
...Object.values(manifest.getExtensionData(DRIVER_TYPE)),
|
|
39
43
|
...Object.values(manifest.getExtensionData(PLUGIN_TYPE)),
|
|
40
44
|
];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
return allExtData.some((metadata) => !('installPath' in metadata));
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Updates installed extensions to use `InstallType` of `dev` if appropriate.
|
|
49
|
+
*
|
|
50
|
+
* Previously, these types of extensions (automatically discovered) would use the default `InstallType` of `npm`, so we need
|
|
51
|
+
* to refresh any with this install type.
|
|
52
|
+
*
|
|
53
|
+
* This should only happen once; we do not want to re-check everything with `npm` install type
|
|
54
|
+
* every time.
|
|
55
|
+
* @type {Migration}
|
|
56
|
+
*/
|
|
57
|
+
[SCHEMA_REV_4]: (manifest) => {
|
|
58
|
+
if (manifest.schemaRev < SCHEMA_REV_4) {
|
|
59
|
+
const allExtData = [
|
|
60
|
+
...Object.values(manifest.getExtensionData(DRIVER_TYPE)),
|
|
61
|
+
...Object.values(manifest.getExtensionData(PLUGIN_TYPE)),
|
|
62
|
+
];
|
|
63
|
+
return allExtData.some((metadata) => metadata.installType === 'npm');
|
|
46
64
|
}
|
|
47
|
-
return
|
|
65
|
+
return false;
|
|
48
66
|
},
|
|
49
67
|
};
|
|
50
68
|
|
|
@@ -61,7 +79,7 @@ const Migrations = {
|
|
|
61
79
|
* @returns {boolean} Whether the data was modified
|
|
62
80
|
*/
|
|
63
81
|
function setSchemaRev(manifest, version) {
|
|
64
|
-
if (manifest.schemaRev ?? 0 < version) {
|
|
82
|
+
if ((manifest.schemaRev ?? 0) < version) {
|
|
65
83
|
manifest.setSchemaRev(version);
|
|
66
84
|
return true;
|
|
67
85
|
}
|
|
@@ -78,15 +96,13 @@ function setSchemaRev(manifest, version) {
|
|
|
78
96
|
*/
|
|
79
97
|
export async function migrate(manifest) {
|
|
80
98
|
let didChange = false;
|
|
81
|
-
for await (const
|
|
82
|
-
const version = /** @type {keyof ManifestDataVersions} */ (Number(v));
|
|
99
|
+
for await (const migration of Object.values(Migrations)) {
|
|
83
100
|
didChange = (await migration(manifest)) || didChange;
|
|
84
|
-
didChange = setSchemaRev(manifest, version) || didChange;
|
|
85
101
|
}
|
|
86
|
-
|
|
102
|
+
didChange = setSchemaRev(manifest, CURRENT_SCHEMA_REV) || didChange;
|
|
87
103
|
if (didChange) {
|
|
88
104
|
// this is not _technically_ true, since we don't actually write the file here.
|
|
89
|
-
log.
|
|
105
|
+
log.debug(`Upgraded extension manifest to schema v${manifest.schemaRev}`);
|
|
90
106
|
}
|
|
91
107
|
|
|
92
108
|
return didChange;
|
|
@@ -10,7 +10,7 @@ import path from 'path';
|
|
|
10
10
|
import YAML from 'yaml';
|
|
11
11
|
import {CURRENT_SCHEMA_REV, DRIVER_TYPE, PLUGIN_TYPE} from '../constants';
|
|
12
12
|
import log from '../logger';
|
|
13
|
-
import {INSTALL_TYPE_NPM} from './extension-config';
|
|
13
|
+
import {INSTALL_TYPE_NPM, INSTALL_TYPE_DEV} from './extension-config';
|
|
14
14
|
import {packageDidChange} from './package-changed';
|
|
15
15
|
import {migrate} from './manifest-migrations';
|
|
16
16
|
|
|
@@ -148,27 +148,33 @@ export class Manifest {
|
|
|
148
148
|
* Returns a new or existing {@link Manifest} instance, based on the value of `appiumHome`.
|
|
149
149
|
*
|
|
150
150
|
* Maintains one instance per value of `appiumHome`.
|
|
151
|
-
* @param {string} appiumHome - Path to `APPIUM_HOME`
|
|
152
|
-
* @returns {Manifest}
|
|
153
151
|
*/
|
|
154
|
-
static getInstance = _.memoize(
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
static getInstance = _.memoize(
|
|
153
|
+
/**
|
|
154
|
+
* @param {string} appiumHome - Path to `APPIUM_HOME`
|
|
155
|
+
* @returns {Manifest}
|
|
156
|
+
*/
|
|
157
|
+
function _getInstance(appiumHome) {
|
|
158
|
+
return new Manifest(appiumHome);
|
|
159
|
+
}
|
|
160
|
+
);
|
|
157
161
|
|
|
158
162
|
/**
|
|
159
163
|
* Searches `APPIUM_HOME` for installed extensions and adds them to the manifest.
|
|
164
|
+
* @param {boolean} hasAppiumDependency - This affects whether or not the "dev" `InstallType` is used
|
|
160
165
|
* @returns {Promise<boolean>} `true` if any extensions were added, `false` otherwise.
|
|
161
166
|
*/
|
|
162
|
-
async syncWithInstalledExtensions() {
|
|
167
|
+
async syncWithInstalledExtensions(hasAppiumDependency = false) {
|
|
163
168
|
// this could be parallelized, but we can't use fs.walk as an async iterator
|
|
164
169
|
let didChange = false;
|
|
165
170
|
|
|
166
171
|
/**
|
|
167
172
|
* Listener for the `match` event of a `glob` instance
|
|
168
173
|
* @param {string} filepath - Path to a `package.json`
|
|
174
|
+
* @param {boolean} [devType] - If `true`, this is an extension in "dev mode"
|
|
169
175
|
* @returns {Promise<void>}
|
|
170
176
|
*/
|
|
171
|
-
const onMatch = async (filepath) => {
|
|
177
|
+
const onMatch = async (filepath, devType = false) => {
|
|
172
178
|
try {
|
|
173
179
|
const pkg = JSON.parse(await fs.readFile(filepath, 'utf8'));
|
|
174
180
|
if (isExtension(pkg)) {
|
|
@@ -188,7 +194,8 @@ export class Manifest {
|
|
|
188
194
|
) {
|
|
189
195
|
log.info(`Discovered installed ${extType} "${name}"`);
|
|
190
196
|
}
|
|
191
|
-
const
|
|
197
|
+
const installType = devType && hasAppiumDependency ? INSTALL_TYPE_DEV : INSTALL_TYPE_NPM;
|
|
198
|
+
const changed = this.addExtensionFromPackage(pkg, filepath, installType);
|
|
192
199
|
didChange = didChange || changed;
|
|
193
200
|
}
|
|
194
201
|
} catch {}
|
|
@@ -199,8 +206,9 @@ export class Manifest {
|
|
|
199
206
|
* @type {Promise<void>[]}
|
|
200
207
|
*/
|
|
201
208
|
const queue = [
|
|
202
|
-
// look at `package.json` in `APPIUM_HOME` only
|
|
203
|
-
|
|
209
|
+
// look at `package.json` in `APPIUM_HOME` only.
|
|
210
|
+
// this causes extensions in "dev mode" to be automatically found
|
|
211
|
+
onMatch(path.join(this.#appiumHome, 'package.json'), true),
|
|
204
212
|
];
|
|
205
213
|
|
|
206
214
|
// add dependencies to the queue
|
|
@@ -252,9 +260,10 @@ export class Manifest {
|
|
|
252
260
|
* @template {ExtensionType} ExtType
|
|
253
261
|
* @param {ExtPackageJson<ExtType>} pkgJson
|
|
254
262
|
* @param {string} pkgPath
|
|
263
|
+
* @param {typeof INSTALL_TYPE_NPM | typeof INSTALL_TYPE_DEV} [installType]
|
|
255
264
|
* @returns {boolean} - `true` if this method did anything.
|
|
256
265
|
*/
|
|
257
|
-
addExtensionFromPackage(pkgJson, pkgPath) {
|
|
266
|
+
addExtensionFromPackage(pkgJson, pkgPath, installType = INSTALL_TYPE_NPM) {
|
|
258
267
|
const extensionPath = path.dirname(pkgPath);
|
|
259
268
|
|
|
260
269
|
/**
|
|
@@ -264,7 +273,7 @@ export class Manifest {
|
|
|
264
273
|
pkgName: pkgJson.name,
|
|
265
274
|
version: pkgJson.version,
|
|
266
275
|
appiumVersion: pkgJson.peerDependencies?.appium,
|
|
267
|
-
installType
|
|
276
|
+
installType,
|
|
268
277
|
installSpec: `${pkgJson.name}@${pkgJson.version}`,
|
|
269
278
|
installPath: extensionPath,
|
|
270
279
|
};
|
|
@@ -434,6 +443,8 @@ export class Manifest {
|
|
|
434
443
|
shouldWrite = await migrate(this);
|
|
435
444
|
}
|
|
436
445
|
|
|
446
|
+
const hasAppiumDependency = await env.hasAppiumDependency(this.appiumHome);
|
|
447
|
+
|
|
437
448
|
/**
|
|
438
449
|
* we still may want to sync with installed extensions even if we have a
|
|
439
450
|
* new file. right now this is limited to the following cases:
|
|
@@ -445,13 +456,9 @@ export class Manifest {
|
|
|
445
456
|
* It may also make sense to sync with the extensions in an arbitrary
|
|
446
457
|
* `APPIUM_HOME`, but we don't do that here.
|
|
447
458
|
*/
|
|
448
|
-
if (
|
|
449
|
-
shouldWrite ||
|
|
450
|
-
((await env.hasAppiumDependency(this.appiumHome)) &&
|
|
451
|
-
(await packageDidChange(this.appiumHome)))
|
|
452
|
-
) {
|
|
459
|
+
if (shouldWrite || (hasAppiumDependency && (await packageDidChange(this.appiumHome)))) {
|
|
453
460
|
log.debug('Discovering newly installed extensions...');
|
|
454
|
-
shouldWrite = (await this.syncWithInstalledExtensions()) || shouldWrite;
|
|
461
|
+
shouldWrite = (await this.syncWithInstalledExtensions(hasAppiumDependency)) || shouldWrite;
|
|
455
462
|
}
|
|
456
463
|
|
|
457
464
|
if (shouldWrite) {
|
package/lib/main.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import {init as logsinkInit} from './logsink'; // this import needs to come first since it sets up global npmlog
|
|
4
4
|
import logger from './logger'; // logger needs to remain second
|
|
5
|
-
// @ts-ignore
|
|
6
5
|
import {routeConfiguringFunction as makeRouter, server as baseServer} from '@appium/base-driver';
|
|
7
6
|
import {logger as logFactory, util, env} from '@appium/support';
|
|
8
7
|
import {asyncify} from 'asyncbox';
|
|
@@ -23,7 +22,7 @@ import {
|
|
|
23
22
|
} from './config';
|
|
24
23
|
import {readConfigFile} from './config-file';
|
|
25
24
|
import {loadExtensions, getActivePlugins, getActiveDrivers} from './extension';
|
|
26
|
-
import {SERVER_SUBCOMMAND} from './constants';
|
|
25
|
+
import {SERVER_SUBCOMMAND, LONG_STACKTRACE_LIMIT} from './constants';
|
|
27
26
|
import registerNode from './grid-register';
|
|
28
27
|
import {getDefaultsForSchema, validate} from './schema/schema';
|
|
29
28
|
import {
|
|
@@ -47,7 +46,7 @@ async function preflightChecks(args, throwInsteadOfExit = false) {
|
|
|
47
46
|
checkNodeOk();
|
|
48
47
|
await checkNpmOk();
|
|
49
48
|
if (args.longStacktrace) {
|
|
50
|
-
|
|
49
|
+
Error.stackTraceLimit = LONG_STACKTRACE_LIMIT;
|
|
51
50
|
}
|
|
52
51
|
if (args.showBuildInfo) {
|
|
53
52
|
await showBuildInfo();
|
|
@@ -245,7 +244,11 @@ async function init(args) {
|
|
|
245
244
|
}
|
|
246
245
|
}
|
|
247
246
|
|
|
248
|
-
const appiumDriver = new AppiumDriver(
|
|
247
|
+
const appiumDriver = new AppiumDriver(
|
|
248
|
+
/** @type {import('@appium/types').DriverOpts<import('./appium').AppiumDriverConstraints>} */ (
|
|
249
|
+
serverArgs
|
|
250
|
+
)
|
|
251
|
+
);
|
|
249
252
|
// set the config on the umbrella driver so it can match drivers to caps
|
|
250
253
|
appiumDriver.driverConfig = driverConfig;
|
|
251
254
|
await preflightChecks(serverArgs, throwInsteadOfExit);
|
package/lib/schema/cli-args.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -223,7 +223,8 @@ function adjustNodePath() {
|
|
|
223
223
|
// ! statements in client modules. It uses a private API though,
|
|
224
224
|
// ! so it could break (maybe, eventually).
|
|
225
225
|
// See https://gist.github.com/branneman/8048520#7-the-hack
|
|
226
|
-
// @ts-ignore
|
|
226
|
+
// @ts-ignore see above comment
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
227
228
|
require('module').Module._initPaths();
|
|
228
229
|
return true;
|
|
229
230
|
} catch (e) {
|
|
@@ -368,21 +369,18 @@ export {
|
|
|
368
369
|
*/
|
|
369
370
|
|
|
370
371
|
/**
|
|
371
|
-
* @template {Constraints}
|
|
372
|
-
* @
|
|
373
|
-
* @typedef {import('@appium/types').Capabilities<C, Extra>} Capabilities
|
|
372
|
+
* @template {Constraints} C
|
|
373
|
+
* @typedef {import('@appium/types').Capabilities<C>} Capabilities
|
|
374
374
|
*/
|
|
375
375
|
|
|
376
376
|
/**
|
|
377
|
-
* @template {Constraints}
|
|
378
|
-
* @
|
|
379
|
-
* @typedef {import('@appium/types').W3CCapabilities<C, Extra>} W3CCapabilities
|
|
377
|
+
* @template {Constraints} C
|
|
378
|
+
* @typedef {import('@appium/types').W3CCapabilities<C>} W3CCapabilities
|
|
380
379
|
*/
|
|
381
380
|
|
|
382
381
|
/**
|
|
383
|
-
* @template {Constraints}
|
|
384
|
-
* @
|
|
385
|
-
* @typedef {import('@appium/types').NSCapabilities<C, Extra>} NSCapabilities
|
|
382
|
+
* @template {Constraints} C
|
|
383
|
+
* @typedef {import('@appium/types').NSCapabilities<C>} NSCapabilities
|
|
386
384
|
*/
|
|
387
385
|
|
|
388
386
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.58",
|
|
4
4
|
"description": "Automation for Apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
],
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build:docs": "node docs/scripts/build-docs.js",
|
|
47
|
+
"build:docs:preview": "cross-env APPIUM_DOCS_PREVIEW=1 npm run build:docs",
|
|
47
48
|
"build:docs:assets": "node docs/scripts/copy-assets.js",
|
|
48
49
|
"build:docs:cli": "node docs/scripts/gen-cli-args-docs.js",
|
|
49
50
|
"build:docs:reference": "node docs/scripts/build-reference.js",
|
|
@@ -59,12 +60,12 @@
|
|
|
59
60
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@appium/base-driver": "^9.3.
|
|
63
|
-
"@appium/base-plugin": "^2.2.
|
|
64
|
-
"@appium/docutils": "^0.
|
|
65
|
-
"@appium/schema": "^0.2.
|
|
66
|
-
"@appium/support": "^3.1.
|
|
67
|
-
"@appium/types": "^0.10.
|
|
63
|
+
"@appium/base-driver": "^9.3.4",
|
|
64
|
+
"@appium/base-plugin": "^2.2.4",
|
|
65
|
+
"@appium/docutils": "^0.3.1",
|
|
66
|
+
"@appium/schema": "^0.2.6",
|
|
67
|
+
"@appium/support": "^3.1.8",
|
|
68
|
+
"@appium/types": "^0.10.2",
|
|
68
69
|
"@sidvind/better-ajv-errors": "2.1.0",
|
|
69
70
|
"@types/argparse": "2.0.10",
|
|
70
71
|
"@types/bluebird": "3.5.38",
|
|
@@ -82,9 +83,8 @@
|
|
|
82
83
|
"cross-env": "7.0.3",
|
|
83
84
|
"find-up": "5.0.0",
|
|
84
85
|
"glob": "8.1.0",
|
|
85
|
-
"lilconfig": "2.0
|
|
86
|
+
"lilconfig": "2.1.0",
|
|
86
87
|
"lodash": "4.17.21",
|
|
87
|
-
"longjohn": "0.2.12",
|
|
88
88
|
"npmlog": "7.0.1",
|
|
89
89
|
"ora": "5.4.1",
|
|
90
90
|
"package-changed": "2.0.0",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"semver": "7.3.8",
|
|
93
93
|
"source-map-support": "0.5.21",
|
|
94
94
|
"teen_process": "2.0.2",
|
|
95
|
-
"type-fest": "3.
|
|
95
|
+
"type-fest": "3.7.1",
|
|
96
96
|
"winston": "3.8.2",
|
|
97
97
|
"wrap-ansi": "7.0.0",
|
|
98
98
|
"yaml": "2.2.1"
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"access": "public",
|
|
106
106
|
"tag": "next"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "d514ebdd7ebd27bb236509d0a3d580f0f18a34e5",
|
|
109
109
|
"typedoc": {
|
|
110
110
|
"entryPoint": "./lib/main.js"
|
|
111
111
|
}
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
const B = require('bluebird');
|
|
25
|
+
const path = require('node:path');
|
|
26
|
+
const {realpath} = require('node:fs/promises');
|
|
25
27
|
|
|
26
28
|
B.config({
|
|
27
29
|
cancellation: true,
|
|
@@ -55,11 +57,32 @@ function log(message) {
|
|
|
55
57
|
console.error(wrap(`[Appium] ${message}`));
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* This is a naive attempt at determining whether or not we are in a dev environment; in other
|
|
62
|
+
* words, is `postinstall` being run from within the `appium` monorepo?
|
|
63
|
+
*
|
|
64
|
+
* When we're in the monorepo, `npm_config_local_prefix` will be set to the root of the monorepo root
|
|
65
|
+
* dir when running this lifecycle script from an `npm install` in the monorepo root.
|
|
66
|
+
*
|
|
67
|
+
* `realpath` is necessary due to macOS omitting `/private` from paths
|
|
68
|
+
*/
|
|
69
|
+
async function isDevEnvironment() {
|
|
70
|
+
return (
|
|
71
|
+
process.env.npm_config_local_prefix &&
|
|
72
|
+
path.join(process.env.npm_config_local_prefix, 'packages', 'appium') ===
|
|
73
|
+
(await realpath(path.join(__dirname, '..')))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
58
77
|
/**
|
|
59
78
|
* Setup / check environment if we should do anything here
|
|
60
79
|
* @returns {Promise<boolean>} `true` if Appium is built and ready to go
|
|
61
80
|
*/
|
|
62
81
|
async function init() {
|
|
82
|
+
if (await isDevEnvironment()) {
|
|
83
|
+
log('Dev environment likely; skipping automatic installation of extensions');
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
63
86
|
try {
|
|
64
87
|
({env, util, logger} = require('@appium/support'));
|
|
65
88
|
// @ts-ignore
|
package/types/manifest/index.ts
CHANGED
|
@@ -5,17 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
import * as ManifestV2 from './base';
|
|
7
7
|
import * as ManifestV3 from './v3';
|
|
8
|
-
|
|
8
|
+
import * as ManifestV4 from './v4';
|
|
9
9
|
// add `import * as ManifestV<new-version> from './v<new-version>';` above
|
|
10
10
|
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './v4';
|
|
12
12
|
// replace above line with `export * from './v<new-version>';`
|
|
13
13
|
|
|
14
|
-
export {ManifestV2, ManifestV3};
|
|
14
|
+
export {ManifestV2, ManifestV3, ManifestV4};
|
|
15
15
|
|
|
16
16
|
export interface ManifestDataVersions {
|
|
17
17
|
2: ManifestV2.ManifestData;
|
|
18
18
|
3: ManifestV3.ManifestData;
|
|
19
|
+
4: ManifestV4.ManifestData;
|
|
19
20
|
}
|
|
20
21
|
// append to this interface your new version of `ManifestData`
|
|
21
22
|
|