@react-native-harness/cli 1.0.0-alpha.7 → 1.0.0-canary.1761046904277
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/README.md +23 -4
- package/dist/bundlers/metro.d.ts.map +1 -1
- package/dist/bundlers/metro.js +15 -5
- package/dist/commands/test.d.ts +2 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +23 -19
- package/dist/discovery/index.d.ts +3 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +1 -0
- package/dist/discovery/testDiscovery.d.ts +11 -0
- package/dist/discovery/testDiscovery.d.ts.map +1 -0
- package/dist/discovery/testDiscovery.js +29 -0
- package/dist/errors/errorHandler.d.ts.map +1 -1
- package/dist/errors/errorHandler.js +27 -3
- package/dist/errors/errors.d.ts +6 -2
- package/dist/errors/errors.d.ts.map +1 -1
- package/dist/errors/errors.js +14 -1
- package/dist/external.d.ts +9 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/external.js +25 -0
- package/dist/index.js +20 -4
- package/dist/platforms/android/emulator.d.ts +0 -1
- package/dist/platforms/android/emulator.d.ts.map +1 -1
- package/dist/platforms/android/emulator.js +26 -20
- package/dist/platforms/android/index.js +1 -1
- package/dist/platforms/ios/build.d.ts.map +1 -1
- package/dist/platforms/ios/build.js +5 -1
- package/dist/platforms/ios/device.d.ts +6 -2
- package/dist/platforms/ios/device.d.ts.map +1 -1
- package/dist/platforms/ios/simulator.d.ts.map +1 -1
- package/dist/platforms/ios/simulator.js +8 -3
- package/dist/platforms/platform-registry.d.ts.map +1 -1
- package/dist/platforms/platform-registry.js +3 -1
- package/dist/platforms/vega/build.d.ts +23 -0
- package/dist/platforms/vega/build.d.ts.map +1 -0
- package/dist/platforms/vega/build.js +55 -0
- package/dist/platforms/vega/device.d.ts +57 -0
- package/dist/platforms/vega/device.d.ts.map +1 -0
- package/dist/platforms/vega/device.js +206 -0
- package/dist/platforms/vega/index.d.ts +4 -0
- package/dist/platforms/vega/index.d.ts.map +1 -0
- package/dist/platforms/vega/index.js +75 -0
- package/dist/process.js +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/status-formatter.d.ts +27 -0
- package/dist/utils/status-formatter.d.ts.map +1 -0
- package/dist/utils/status-formatter.js +54 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -0
- package/eslint.config.mjs +1 -0
- package/package.json +21 -6
- package/src/bundlers/metro.ts +17 -4
- package/src/commands/test.ts +39 -25
- package/src/discovery/index.ts +2 -0
- package/src/discovery/testDiscovery.ts +50 -0
- package/src/errors/errorHandler.ts +34 -4
- package/src/errors/errors.ts +16 -4
- package/src/external.ts +44 -0
- package/src/index.ts +33 -5
- package/src/platforms/android/emulator.ts +26 -28
- package/src/platforms/android/index.ts +1 -1
- package/src/platforms/ios/build.ts +3 -0
- package/src/platforms/ios/device.ts +5 -2
- package/src/platforms/ios/simulator.ts +8 -3
- package/src/platforms/platform-registry.ts +3 -1
- package/src/platforms/vega/build.ts +85 -0
- package/src/platforms/vega/device.ts +258 -0
- package/src/platforms/vega/index.ts +107 -0
- package/src/process.ts +1 -1
- package/src/utils.ts +17 -0
- package/tsconfig.json +3 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn } from '@react-native-harness/tools';
|
|
1
|
+
import { spawn, SubprocessError } from '@react-native-harness/tools';
|
|
2
2
|
export const getSimulatorDeviceId = async (simulatorName, systemVersion) => {
|
|
3
3
|
try {
|
|
4
4
|
const { stdout } = await spawn('xcrun', [
|
|
@@ -13,6 +13,7 @@ export const getSimulatorDeviceId = async (simulatorName, systemVersion) => {
|
|
|
13
13
|
if (!runtime) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
const device = runtime.find((d) => d.name === simulatorName);
|
|
17
18
|
if (device) {
|
|
18
19
|
return device.udid;
|
|
@@ -36,6 +37,7 @@ export const getAvailableSimulators = async () => {
|
|
|
36
37
|
for (const runtime in devices.devices) {
|
|
37
38
|
if (runtime.includes('iOS')) {
|
|
38
39
|
const runtimeDevices = devices.devices[runtime];
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
41
|
runtimeDevices.forEach((device) => {
|
|
40
42
|
if (device.isAvailable) {
|
|
41
43
|
simulators.push({
|
|
@@ -65,6 +67,7 @@ export const getSimulatorStatus = async (udid) => {
|
|
|
65
67
|
for (const runtime in devices.devices) {
|
|
66
68
|
if (runtime.includes('iOS')) {
|
|
67
69
|
const runtimeDevices = devices.devices[runtime];
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
71
|
const device = runtimeDevices.find((d) => d.udid === udid);
|
|
69
72
|
if (device) {
|
|
70
73
|
switch (device.state) {
|
|
@@ -90,7 +93,8 @@ export const runSimulator = async (udid) => {
|
|
|
90
93
|
}
|
|
91
94
|
catch (bootError) {
|
|
92
95
|
// Ignore if simulator is already booted
|
|
93
|
-
if (
|
|
96
|
+
if (bootError instanceof SubprocessError &&
|
|
97
|
+
!bootError.stderr?.includes('Unable to boot device in current state: Booted')) {
|
|
94
98
|
throw bootError;
|
|
95
99
|
}
|
|
96
100
|
}
|
|
@@ -117,7 +121,8 @@ const stopSimulatorById = async (udid) => {
|
|
|
117
121
|
}
|
|
118
122
|
catch (shutdownError) {
|
|
119
123
|
// Ignore if simulator is already shut down
|
|
120
|
-
if (
|
|
124
|
+
if (shutdownError instanceof SubprocessError &&
|
|
125
|
+
!shutdownError.stderr?.includes('Unable to shutdown device in current state: Shutdown')) {
|
|
121
126
|
throw shutdownError;
|
|
122
127
|
}
|
|
123
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-registry.d.ts","sourceRoot":"","sources":["../../src/platforms/platform-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"platform-registry.d.ts","sourceRoot":"","sources":["../../src/platforms/platform-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAaxD,eAAO,MAAM,kBAAkB,GAC7B,cAAc,MAAM,KACnB,OAAO,CAAC,eAAe,CAUzB,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import androidPlatformAdapter from './android/index.js';
|
|
2
2
|
import iosPlatformAdapter from './ios/index.js';
|
|
3
3
|
import webPlatformAdapter from './web/index.js';
|
|
4
|
+
import vegaPlatformAdapter from './vega/index.js';
|
|
4
5
|
const platformAdapters = {
|
|
5
6
|
android: androidPlatformAdapter,
|
|
6
7
|
ios: iosPlatformAdapter,
|
|
7
8
|
web: webPlatformAdapter,
|
|
9
|
+
vega: vegaPlatformAdapter,
|
|
8
10
|
};
|
|
9
11
|
export const getPlatformAdapter = async (platformName) => {
|
|
10
12
|
if (!(platformName in platformAdapters)) {
|
|
@@ -13,7 +15,7 @@ export const getPlatformAdapter = async (platformName) => {
|
|
|
13
15
|
try {
|
|
14
16
|
return platformAdapters[platformName];
|
|
15
17
|
}
|
|
16
|
-
catch
|
|
18
|
+
catch {
|
|
17
19
|
throw new Error(`Platform adapter for ${platformName} not found`);
|
|
18
20
|
}
|
|
19
21
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type VegaBuildTarget = 'sim_tv_x86_64' | 'sim_tv_aarch64';
|
|
2
|
+
export type VegaBuildType = 'Debug' | 'Release';
|
|
3
|
+
/**
|
|
4
|
+
* Build Vega app and produce .vpkg file
|
|
5
|
+
*/
|
|
6
|
+
export declare const buildVegaApp: (buildType?: VegaBuildType, target?: VegaBuildTarget) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Clean build artifacts
|
|
9
|
+
*/
|
|
10
|
+
export declare const cleanBuild: () => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the expected .vpkg file path based on build configuration
|
|
13
|
+
*/
|
|
14
|
+
export declare const getVpkgPath: (appName: string, buildType?: VegaBuildType, target?: VegaBuildTarget) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Launch an already installed app on specified Vega virtual device
|
|
17
|
+
*/
|
|
18
|
+
export declare const runApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Kill/terminate app on specified Vega virtual device
|
|
21
|
+
*/
|
|
22
|
+
export declare const killApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
23
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/platforms/vega/build.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,gBAAgB,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,YAAW,aAAyB,EACpC,SAAS,eAAe,KACvB,OAAO,CAAC,IAAI,CAYd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,IAAI,CAE/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,YAAW,aAAyB,EACpC,SAAQ,eAAiC,KACxC,MAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,GACjB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CASd,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { spawn } from '@react-native-harness/tools';
|
|
3
|
+
/**
|
|
4
|
+
* Build Vega app and produce .vpkg file
|
|
5
|
+
*/
|
|
6
|
+
export const buildVegaApp = async (buildType = 'Release', target) => {
|
|
7
|
+
const args = ['run', 'build:app'];
|
|
8
|
+
if (buildType) {
|
|
9
|
+
args.push('-b', buildType);
|
|
10
|
+
}
|
|
11
|
+
if (target) {
|
|
12
|
+
args.push('-t', target);
|
|
13
|
+
}
|
|
14
|
+
await spawn('npm', args);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Clean build artifacts
|
|
18
|
+
*/
|
|
19
|
+
export const cleanBuild = async () => {
|
|
20
|
+
await spawn('kepler', ['clean']);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get the expected .vpkg file path based on build configuration
|
|
24
|
+
*/
|
|
25
|
+
export const getVpkgPath = (appName, buildType = 'Release', target = 'sim_tv_x86_64') => {
|
|
26
|
+
const buildTypeStr = buildType.toLowerCase();
|
|
27
|
+
const vpkgFileName = `${appName}_${target}.vpkg`;
|
|
28
|
+
return path.join(process.cwd(), 'build', `${target}-${buildTypeStr}`, vpkgFileName);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Launch an already installed app on specified Vega virtual device
|
|
32
|
+
*/
|
|
33
|
+
export const runApp = async (deviceId, bundleId) => {
|
|
34
|
+
await spawn('kepler', [
|
|
35
|
+
'device',
|
|
36
|
+
'launch-app',
|
|
37
|
+
'--device',
|
|
38
|
+
deviceId,
|
|
39
|
+
'--appName',
|
|
40
|
+
bundleId,
|
|
41
|
+
]);
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Kill/terminate app on specified Vega virtual device
|
|
45
|
+
*/
|
|
46
|
+
export const killApp = async (deviceId, bundleId) => {
|
|
47
|
+
await spawn('kepler', [
|
|
48
|
+
'device',
|
|
49
|
+
'terminate-app',
|
|
50
|
+
'--device',
|
|
51
|
+
deviceId,
|
|
52
|
+
'--appName',
|
|
53
|
+
bundleId,
|
|
54
|
+
]);
|
|
55
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type VegaVirtualDeviceStatus = 'running' | 'stopped';
|
|
2
|
+
/**
|
|
3
|
+
* List all available Vega virtual devices
|
|
4
|
+
* Returns array of device identifiers that can be used with kepler commands
|
|
5
|
+
*/
|
|
6
|
+
export declare const listVegaDevices: () => Promise<string[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a specific Vega virtual device is connected/available
|
|
9
|
+
*/
|
|
10
|
+
export declare const isVegaDeviceConnected: (deviceId: string) => Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if an app is installed on the specified Vega virtual device
|
|
13
|
+
*/
|
|
14
|
+
export declare const isAppInstalled: (deviceId: string, bundleId: string) => Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if an app is currently running on the specified Vega virtual device
|
|
17
|
+
*/
|
|
18
|
+
export declare const isAppRunning: (deviceId: string, bundleId: string) => Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Install app on specified Vega virtual device using .vpkg file
|
|
21
|
+
*/
|
|
22
|
+
export declare const installApp: (deviceId: string, vpkgPath: string) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Terminate app on specified Vega virtual device
|
|
25
|
+
*/
|
|
26
|
+
export declare const terminateApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Uninstall app from specified Vega virtual device
|
|
29
|
+
*/
|
|
30
|
+
export declare const uninstallApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Start port forwarding for debugging on specified Vega virtual device
|
|
33
|
+
*/
|
|
34
|
+
export declare const startPortForwarding: (deviceId: string, port: number, forward?: boolean) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Stop port forwarding on specified Vega virtual device
|
|
37
|
+
*/
|
|
38
|
+
export declare const stopPortForwarding: (deviceId: string, port: number, forward?: boolean) => Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Get status of a specific Vega virtual device
|
|
41
|
+
* Note: Vega CLI might manage virtual devices globally, so this checks if the device is available
|
|
42
|
+
*/
|
|
43
|
+
export declare const getVegaDeviceStatus: (deviceId: string) => Promise<VegaVirtualDeviceStatus>;
|
|
44
|
+
/**
|
|
45
|
+
* Start Vega Virtual Device
|
|
46
|
+
* Note: Vega might manage virtual devices globally, this starts the virtual device system
|
|
47
|
+
*/
|
|
48
|
+
export declare const startVirtualDevice: () => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Stop Vega Virtual Device
|
|
51
|
+
*/
|
|
52
|
+
export declare const stopVirtualDevice: () => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Combined install and run command for specified Vega virtual device (Vega-specific convenience method)
|
|
55
|
+
*/
|
|
56
|
+
export declare const runKepler: (deviceId: string, vpkgPath: string, bundleId: string) => Promise<void>;
|
|
57
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../src/platforms/vega/device.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,SAAS,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAa,OAAO,CAAC,MAAM,EAAE,CAwBxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAYjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAcjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAcjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,iBAAc,KACb,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,iBAAc,KACb,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,KACf,OAAO,CAAC,uBAAuB,CAkBjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,IAAI,CAqBvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,IAAI,CAEtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,UAAU,MAAM,EAChB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAEd,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { spawn } from '@react-native-harness/tools';
|
|
2
|
+
/**
|
|
3
|
+
* List all available Vega virtual devices
|
|
4
|
+
* Returns array of device identifiers that can be used with kepler commands
|
|
5
|
+
*/
|
|
6
|
+
export const listVegaDevices = async () => {
|
|
7
|
+
try {
|
|
8
|
+
const { stdout } = await spawn('kepler', ['device', 'list']);
|
|
9
|
+
const lines = stdout.trim().split('\n');
|
|
10
|
+
const devices = [];
|
|
11
|
+
for (const line of lines) {
|
|
12
|
+
if (line.trim()) {
|
|
13
|
+
// Parse device line format: "VirtualDevice : tv - x86_64 - OS - hostname"
|
|
14
|
+
// or potentially "VegaTV_1 : tv - x86_64 - OS - hostname" for named instances
|
|
15
|
+
const deviceId = line.split(' : ')[0].trim();
|
|
16
|
+
if (deviceId &&
|
|
17
|
+
(deviceId === 'VirtualDevice' || deviceId.startsWith('Vega'))) {
|
|
18
|
+
devices.push(deviceId);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return devices;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Check if a specific Vega virtual device is connected/available
|
|
30
|
+
*/
|
|
31
|
+
export const isVegaDeviceConnected = async (deviceId) => {
|
|
32
|
+
try {
|
|
33
|
+
const { stdout } = await spawn('kepler', [
|
|
34
|
+
'device',
|
|
35
|
+
'is-connected',
|
|
36
|
+
'--device',
|
|
37
|
+
deviceId,
|
|
38
|
+
]);
|
|
39
|
+
return stdout.includes('is connected');
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Check if an app is installed on the specified Vega virtual device
|
|
47
|
+
*/
|
|
48
|
+
export const isAppInstalled = async (deviceId, bundleId) => {
|
|
49
|
+
try {
|
|
50
|
+
await spawn('kepler', [
|
|
51
|
+
'device',
|
|
52
|
+
'is-app-installed',
|
|
53
|
+
'--device',
|
|
54
|
+
deviceId,
|
|
55
|
+
'--appName',
|
|
56
|
+
bundleId,
|
|
57
|
+
]);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Check if an app is currently running on the specified Vega virtual device
|
|
66
|
+
*/
|
|
67
|
+
export const isAppRunning = async (deviceId, bundleId) => {
|
|
68
|
+
try {
|
|
69
|
+
await spawn('kepler', [
|
|
70
|
+
'device',
|
|
71
|
+
'is-app-running',
|
|
72
|
+
'--device',
|
|
73
|
+
deviceId,
|
|
74
|
+
'--appName',
|
|
75
|
+
bundleId,
|
|
76
|
+
]);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Install app on specified Vega virtual device using .vpkg file
|
|
85
|
+
*/
|
|
86
|
+
export const installApp = async (deviceId, vpkgPath) => {
|
|
87
|
+
await spawn('kepler', [
|
|
88
|
+
'device',
|
|
89
|
+
'install-app',
|
|
90
|
+
'-p',
|
|
91
|
+
vpkgPath,
|
|
92
|
+
'--device',
|
|
93
|
+
deviceId,
|
|
94
|
+
]);
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Terminate app on specified Vega virtual device
|
|
98
|
+
*/
|
|
99
|
+
export const terminateApp = async (deviceId, bundleId) => {
|
|
100
|
+
await spawn('kepler', [
|
|
101
|
+
'device',
|
|
102
|
+
'terminate-app',
|
|
103
|
+
'--device',
|
|
104
|
+
deviceId,
|
|
105
|
+
'--appName',
|
|
106
|
+
bundleId,
|
|
107
|
+
]);
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Uninstall app from specified Vega virtual device
|
|
111
|
+
*/
|
|
112
|
+
export const uninstallApp = async (deviceId, bundleId) => {
|
|
113
|
+
await spawn('kepler', [
|
|
114
|
+
'device',
|
|
115
|
+
'uninstall-app',
|
|
116
|
+
'--device',
|
|
117
|
+
deviceId,
|
|
118
|
+
'--appName',
|
|
119
|
+
bundleId,
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Start port forwarding for debugging on specified Vega virtual device
|
|
124
|
+
*/
|
|
125
|
+
export const startPortForwarding = async (deviceId, port, forward = true) => {
|
|
126
|
+
await spawn('kepler', [
|
|
127
|
+
'device',
|
|
128
|
+
'start-port-forwarding',
|
|
129
|
+
'--device',
|
|
130
|
+
deviceId,
|
|
131
|
+
'--port',
|
|
132
|
+
port.toString(),
|
|
133
|
+
'--forward',
|
|
134
|
+
forward.toString(),
|
|
135
|
+
]);
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Stop port forwarding on specified Vega virtual device
|
|
139
|
+
*/
|
|
140
|
+
export const stopPortForwarding = async (deviceId, port, forward = true) => {
|
|
141
|
+
await spawn('kepler', [
|
|
142
|
+
'device',
|
|
143
|
+
'stop-port-forwarding',
|
|
144
|
+
'--device',
|
|
145
|
+
deviceId,
|
|
146
|
+
'--port',
|
|
147
|
+
port.toString(),
|
|
148
|
+
'--forward',
|
|
149
|
+
forward.toString(),
|
|
150
|
+
]);
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Get status of a specific Vega virtual device
|
|
154
|
+
* Note: Vega CLI might manage virtual devices globally, so this checks if the device is available
|
|
155
|
+
*/
|
|
156
|
+
export const getVegaDeviceStatus = async (deviceId) => {
|
|
157
|
+
try {
|
|
158
|
+
// First check if the device is connected/available
|
|
159
|
+
const isConnected = await isVegaDeviceConnected(deviceId);
|
|
160
|
+
if (isConnected) {
|
|
161
|
+
return 'running';
|
|
162
|
+
}
|
|
163
|
+
// Check general virtual device status
|
|
164
|
+
const { stdout } = await spawn('kepler', ['virtual-device', 'status']);
|
|
165
|
+
// Parse the status output to determine if VVD is running
|
|
166
|
+
return stdout.toLowerCase().includes('running') ||
|
|
167
|
+
stdout.toLowerCase().includes('ready')
|
|
168
|
+
? 'running'
|
|
169
|
+
: 'stopped';
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return 'stopped';
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Start Vega Virtual Device
|
|
177
|
+
* Note: Vega might manage virtual devices globally, this starts the virtual device system
|
|
178
|
+
*/
|
|
179
|
+
export const startVirtualDevice = async () => {
|
|
180
|
+
await spawn('kepler', ['virtual-device', 'start']);
|
|
181
|
+
// Poll for VVD status until it's running
|
|
182
|
+
let attempts = 0;
|
|
183
|
+
const maxAttempts = 30; // 30 seconds timeout
|
|
184
|
+
while (attempts < maxAttempts) {
|
|
185
|
+
const { stdout } = await spawn('kepler', ['virtual-device', 'status']);
|
|
186
|
+
if (stdout.toLowerCase().includes('running') ||
|
|
187
|
+
stdout.toLowerCase().includes('ready')) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
191
|
+
attempts++;
|
|
192
|
+
}
|
|
193
|
+
throw new Error('Vega Virtual Device failed to start within timeout');
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Stop Vega Virtual Device
|
|
197
|
+
*/
|
|
198
|
+
export const stopVirtualDevice = async () => {
|
|
199
|
+
await spawn('kepler', ['virtual-device', 'stop']);
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Combined install and run command for specified Vega virtual device (Vega-specific convenience method)
|
|
203
|
+
*/
|
|
204
|
+
export const runKepler = async (deviceId, vpkgPath, bundleId) => {
|
|
205
|
+
await spawn('kepler', ['run-kepler', vpkgPath, bundleId, '-d', deviceId]);
|
|
206
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platforms/vega/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAe9D,QAAA,MAAM,mBAAmB,EAAE,eAmF1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assertVegaRunnerConfig, } from '@react-native-harness/config';
|
|
2
|
+
import { logger } from '@react-native-harness/tools';
|
|
3
|
+
import { isAppInstalled, getVegaDeviceStatus, isVegaDeviceConnected, startVirtualDevice, stopVirtualDevice, startPortForwarding, stopPortForwarding, } from './device.js';
|
|
4
|
+
import { runApp, killApp } from './build.js';
|
|
5
|
+
import { killWithAwait } from '../../process.js';
|
|
6
|
+
import { runMetro } from '../../bundlers/metro.js';
|
|
7
|
+
import { AppNotInstalledError } from '../../errors/errors.js';
|
|
8
|
+
const vegaPlatformAdapter = {
|
|
9
|
+
name: 'vega',
|
|
10
|
+
getEnvironment: async (runner) => {
|
|
11
|
+
assertVegaRunnerConfig(runner);
|
|
12
|
+
let shouldStopVirtualDevice = false;
|
|
13
|
+
// Check if the specific Vega device is available
|
|
14
|
+
const deviceStatus = await getVegaDeviceStatus(runner.deviceId);
|
|
15
|
+
logger.debug(`Vega device ${runner.deviceId} status: ${deviceStatus}`);
|
|
16
|
+
if (deviceStatus === 'stopped') {
|
|
17
|
+
logger.debug('Starting Vega Virtual Device system');
|
|
18
|
+
await startVirtualDevice();
|
|
19
|
+
shouldStopVirtualDevice = true;
|
|
20
|
+
// Wait a bit for the device to become available
|
|
21
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
22
|
+
}
|
|
23
|
+
// Verify device is now connected
|
|
24
|
+
const isConnected = await isVegaDeviceConnected(runner.deviceId);
|
|
25
|
+
if (!isConnected) {
|
|
26
|
+
throw new Error(`Vega device ${runner.deviceId} is not available. Make sure the virtual device is configured and running.`);
|
|
27
|
+
}
|
|
28
|
+
// Start Metro bundler
|
|
29
|
+
const metroPromise = runMetro();
|
|
30
|
+
// Set up port forwarding for debugging (similar to Android)
|
|
31
|
+
await Promise.all([
|
|
32
|
+
startPortForwarding(runner.deviceId, 8081, false), // reverse port forwarding for JS debugging
|
|
33
|
+
startPortForwarding(runner.deviceId, 8080, false),
|
|
34
|
+
startPortForwarding(runner.deviceId, 3001, false),
|
|
35
|
+
]);
|
|
36
|
+
logger.debug('Port forwarding established');
|
|
37
|
+
// Check if app is installed
|
|
38
|
+
const isInstalled = await isAppInstalled(runner.deviceId, runner.bundleId);
|
|
39
|
+
logger.debug(`App is installed: ${isInstalled}`);
|
|
40
|
+
if (!isInstalled) {
|
|
41
|
+
throw new AppNotInstalledError(runner.deviceId, runner.bundleId, 'vega');
|
|
42
|
+
}
|
|
43
|
+
logger.debug('Waiting for Metro to start');
|
|
44
|
+
const metro = await metroPromise;
|
|
45
|
+
logger.debug('Metro started');
|
|
46
|
+
logger.debug('Running Vega app');
|
|
47
|
+
await runApp(runner.deviceId, runner.bundleId);
|
|
48
|
+
logger.debug('Vega app running');
|
|
49
|
+
return {
|
|
50
|
+
restart: async () => {
|
|
51
|
+
await runApp(runner.deviceId, runner.bundleId);
|
|
52
|
+
},
|
|
53
|
+
dispose: async () => {
|
|
54
|
+
// Kill the app
|
|
55
|
+
await killApp(runner.deviceId, runner.bundleId);
|
|
56
|
+
// Stop port forwarding
|
|
57
|
+
await Promise.all([
|
|
58
|
+
stopPortForwarding(runner.deviceId, 8081, false),
|
|
59
|
+
stopPortForwarding(runner.deviceId, 8080, false),
|
|
60
|
+
stopPortForwarding(runner.deviceId, 3001, false),
|
|
61
|
+
]).catch((error) => {
|
|
62
|
+
// Don't fail disposal if port forwarding cleanup fails
|
|
63
|
+
logger.debug(`Port forwarding cleanup failed: ${error.message}`);
|
|
64
|
+
});
|
|
65
|
+
// Stop Virtual Device if we started it
|
|
66
|
+
if (shouldStopVirtualDevice) {
|
|
67
|
+
await stopVirtualDevice();
|
|
68
|
+
}
|
|
69
|
+
// Kill Metro
|
|
70
|
+
await killWithAwait(metro);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
export default vegaPlatformAdapter;
|