@mobilewright/driver-mobilecli 0.0.53 → 0.0.55
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/dist/resolve-binary.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
interface PlatformBinary {
|
|
2
|
+
packageName: string;
|
|
3
|
+
binaryName: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Map a platform/arch pair to the @mobilenext platform package that ships
|
|
7
|
+
* the mobilecli binary, and the binary's file name inside that package.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPlatformBinary(platform: string, arch: string): PlatformBinary;
|
|
1
10
|
/**
|
|
2
11
|
* Resolve the mobilecli binary using Node's module resolution so it works
|
|
3
|
-
* from npx caches, global installs, and local node_modules alike.
|
|
12
|
+
* from npx caches, global installs, and local node_modules alike. The binary
|
|
13
|
+
* ships in a per-platform optionalDependency of mobilecli, so it is resolved
|
|
14
|
+
* from mobilecli's own location.
|
|
4
15
|
*
|
|
5
16
|
* @param explicitPath Use this path directly instead of resolving one.
|
|
6
17
|
*/
|
|
7
18
|
export declare function resolveMobilecliBinary(explicitPath?: string): string;
|
|
19
|
+
export {};
|
|
8
20
|
//# sourceMappingURL=resolve-binary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-binary.d.ts","sourceRoot":"","sources":["../src/resolve-binary.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"resolve-binary.d.ts","sourceRoot":"","sources":["../src/resolve-binary.ts"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CA6BhF;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBpE"}
|
package/dist/resolve-binary.js
CHANGED
|
@@ -1,37 +1,61 @@
|
|
|
1
1
|
import { join, dirname } from 'node:path';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param explicitPath Use this path directly instead of resolving one.
|
|
4
|
+
* Map a platform/arch pair to the @mobilenext platform package that ships
|
|
5
|
+
* the mobilecli binary, and the binary's file name inside that package.
|
|
8
6
|
*/
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
let binary;
|
|
14
|
-
switch (`${process.platform}-${process.arch}`) {
|
|
7
|
+
export function getPlatformBinary(platform, arch) {
|
|
8
|
+
let name;
|
|
9
|
+
switch (`${platform}-${arch}`) {
|
|
15
10
|
case 'darwin-arm64':
|
|
16
|
-
|
|
11
|
+
name = 'mobilecli-darwin-arm64';
|
|
17
12
|
break;
|
|
18
13
|
case 'darwin-x64':
|
|
19
|
-
|
|
14
|
+
name = 'mobilecli-darwin-amd64';
|
|
20
15
|
break;
|
|
21
16
|
case 'linux-arm64':
|
|
22
|
-
|
|
17
|
+
name = 'mobilecli-linux-arm64';
|
|
23
18
|
break;
|
|
24
19
|
case 'linux-x64':
|
|
25
|
-
|
|
20
|
+
name = 'mobilecli-linux-amd64';
|
|
21
|
+
break;
|
|
22
|
+
case 'win32-arm64':
|
|
23
|
+
name = 'mobilecli-windows-arm64';
|
|
26
24
|
break;
|
|
27
25
|
case 'win32-x64':
|
|
28
|
-
|
|
26
|
+
name = 'mobilecli-windows-amd64';
|
|
29
27
|
break;
|
|
30
28
|
default:
|
|
31
|
-
throw new Error(`Unsupported platform: ${
|
|
29
|
+
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
packageName: `@mobilenext/${name}`,
|
|
33
|
+
binaryName: platform === 'win32' ? `${name}.exe` : name,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the mobilecli binary using Node's module resolution so it works
|
|
38
|
+
* from npx caches, global installs, and local node_modules alike. The binary
|
|
39
|
+
* ships in a per-platform optionalDependency of mobilecli, so it is resolved
|
|
40
|
+
* from mobilecli's own location.
|
|
41
|
+
*
|
|
42
|
+
* @param explicitPath Use this path directly instead of resolving one.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveMobilecliBinary(explicitPath) {
|
|
45
|
+
if (explicitPath) {
|
|
46
|
+
return explicitPath;
|
|
32
47
|
}
|
|
48
|
+
const { packageName, binaryName } = getPlatformBinary(process.platform, process.arch);
|
|
33
49
|
const _require = createRequire(import.meta.url);
|
|
34
|
-
const
|
|
35
|
-
|
|
50
|
+
const mobilecliPkg = _require.resolve('mobilecli/package.json');
|
|
51
|
+
const requireFromMobilecli = createRequire(mobilecliPkg);
|
|
52
|
+
let platformPkg;
|
|
53
|
+
try {
|
|
54
|
+
platformPkg = requireFromMobilecli.resolve(`${packageName}/package.json`);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw new Error(`Failed to find ${packageName}. Please reinstall mobilecli.`);
|
|
58
|
+
}
|
|
59
|
+
return join(dirname(platformPkg), binaryName);
|
|
36
60
|
}
|
|
37
61
|
//# sourceMappingURL=resolve-binary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-binary.js","sourceRoot":"","sources":["../src/resolve-binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-binary.js","sourceRoot":"","sources":["../src/resolve-binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1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AAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAEzD,IAAI,WAAmB,CAAC;IACxB,IAAI,CAAC;QACH,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,WAAW,eAAe,CAAC,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,kBAAkB,WAAW,+BAA+B,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,46 +1,50 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import { test, expect } from '@playwright/test';
|
|
2
|
-
import { resolveMobilecliBinary } from './resolve-binary.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(process, 'arch', { value: arch, configurable: true });
|
|
8
|
-
try {
|
|
9
|
-
fn();
|
|
10
|
-
}
|
|
11
|
-
finally {
|
|
12
|
-
Object.defineProperty(process, 'platform', platformDescriptor);
|
|
13
|
-
Object.defineProperty(process, 'arch', archDescriptor);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
test('resolveMobilecliBinary returns a path to the darwin-arm64 binary', () => {
|
|
17
|
-
simulatePlatform('darwin', 'arm64', () => {
|
|
18
|
-
expect(resolveMobilecliBinary()).toContain('mobilecli-darwin-arm64');
|
|
3
|
+
import { getPlatformBinary, resolveMobilecliBinary } from './resolve-binary.js';
|
|
4
|
+
test('darwin-arm64 maps to the @mobilenext darwin-arm64 package', () => {
|
|
5
|
+
expect(getPlatformBinary('darwin', 'arm64')).toEqual({
|
|
6
|
+
packageName: '@mobilenext/mobilecli-darwin-arm64',
|
|
7
|
+
binaryName: 'mobilecli-darwin-arm64',
|
|
19
8
|
});
|
|
20
9
|
});
|
|
21
|
-
test('
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
test('darwin-x64 maps to the @mobilenext darwin-amd64 package', () => {
|
|
11
|
+
expect(getPlatformBinary('darwin', 'x64')).toEqual({
|
|
12
|
+
packageName: '@mobilenext/mobilecli-darwin-amd64',
|
|
13
|
+
binaryName: 'mobilecli-darwin-amd64',
|
|
24
14
|
});
|
|
25
15
|
});
|
|
26
|
-
test('
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
test('linux-arm64 maps to the @mobilenext linux-arm64 package', () => {
|
|
17
|
+
expect(getPlatformBinary('linux', 'arm64')).toEqual({
|
|
18
|
+
packageName: '@mobilenext/mobilecli-linux-arm64',
|
|
19
|
+
binaryName: 'mobilecli-linux-arm64',
|
|
29
20
|
});
|
|
30
21
|
});
|
|
31
|
-
test('
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
test('linux-x64 maps to the @mobilenext linux-amd64 package', () => {
|
|
23
|
+
expect(getPlatformBinary('linux', 'x64')).toEqual({
|
|
24
|
+
packageName: '@mobilenext/mobilecli-linux-amd64',
|
|
25
|
+
binaryName: 'mobilecli-linux-amd64',
|
|
34
26
|
});
|
|
35
27
|
});
|
|
36
|
-
test('
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
test('win32-x64 maps to the @mobilenext windows-amd64 package with an .exe binary', () => {
|
|
29
|
+
expect(getPlatformBinary('win32', 'x64')).toEqual({
|
|
30
|
+
packageName: '@mobilenext/mobilecli-windows-amd64',
|
|
31
|
+
binaryName: 'mobilecli-windows-amd64.exe',
|
|
39
32
|
});
|
|
40
33
|
});
|
|
41
|
-
test('
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
test('win32-arm64 maps to the @mobilenext windows-arm64 package with an .exe binary', () => {
|
|
35
|
+
expect(getPlatformBinary('win32', 'arm64')).toEqual({
|
|
36
|
+
packageName: '@mobilenext/mobilecli-windows-arm64',
|
|
37
|
+
binaryName: 'mobilecli-windows-arm64.exe',
|
|
44
38
|
});
|
|
45
39
|
});
|
|
40
|
+
test('an unsupported platform throws an error', () => {
|
|
41
|
+
expect(() => getPlatformBinary('freebsd', 'x64')).toThrow('Unsupported platform: freebsd-x64');
|
|
42
|
+
});
|
|
43
|
+
test('an explicit path is returned as-is', () => {
|
|
44
|
+
expect(resolveMobilecliBinary('/opt/bin/mobilecli')).toBe('/opt/bin/mobilecli');
|
|
45
|
+
});
|
|
46
|
+
test('the resolved binary for this machine exists on disk', () => {
|
|
47
|
+
const binaryPath = resolveMobilecliBinary();
|
|
48
|
+
expect(existsSync(binaryPath)).toBe(true);
|
|
49
|
+
});
|
|
46
50
|
//# sourceMappingURL=resolve-binary.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-binary.test.js","sourceRoot":"","sources":["../src/resolve-binary.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-binary.test.js","sourceRoot":"","sources":["../src/resolve-binary.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEhF,IAAI,CAAC,2DAA2D,EAAE,GAAG,EAAE;IACrE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QACnD,WAAW,EAAE,oCAAoC;QACjD,UAAU,EAAE,wBAAwB;KACrC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;IACnE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;QACjD,WAAW,EAAE,oCAAoC;QACjD,UAAU,EAAE,wBA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AoB,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qDAAqD,EAAE,GAAG,EAAE;IAC/D,MAAM,UAAU,GAAG,sBAAsB,EAAE,CAAC;IAC5C,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilewright/driver-mobilecli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "mobilecli driver for Mobilewright",
|
|
5
5
|
"homepage": "https://mobilewright.dev",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mobilewright/protocol": "^0.0.
|
|
32
|
+
"@mobilewright/protocol": "^0.0.55",
|
|
33
33
|
"debug": "^4.4.3",
|
|
34
|
-
"mobilecli": "1.0.
|
|
34
|
+
"mobilecli": "1.0.7",
|
|
35
35
|
"ws": "^8.18.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|