@react-native-harness/cli 1.0.0-alpha.19 → 1.0.0-alpha.21
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/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/bundlers/metro.d.ts +0 -5
- package/dist/bundlers/metro.d.ts.map +0 -1
- package/dist/bundlers/metro.js +0 -48
- package/dist/bundlers/webpack.d.ts +0 -2
- package/dist/bundlers/webpack.d.ts.map +0 -1
- package/dist/bundlers/webpack.js +0 -49
- package/dist/platforms/android/build.d.ts +0 -4
- package/dist/platforms/android/build.d.ts.map +0 -1
- package/dist/platforms/android/build.js +0 -54
- package/dist/platforms/android/emulator.d.ts +0 -11
- package/dist/platforms/android/emulator.d.ts.map +0 -1
- package/dist/platforms/android/emulator.js +0 -147
- package/dist/platforms/android/index.d.ts +0 -4
- package/dist/platforms/android/index.d.ts.map +0 -1
- package/dist/platforms/android/index.js +0 -52
- package/dist/platforms/ios/build.d.ts +0 -9
- package/dist/platforms/ios/build.d.ts.map +0 -1
- package/dist/platforms/ios/build.js +0 -123
- package/dist/platforms/ios/index.d.ts +0 -4
- package/dist/platforms/ios/index.d.ts.map +0 -1
- package/dist/platforms/ios/index.js +0 -51
- package/dist/platforms/ios/simulator.d.ts +0 -11
- package/dist/platforms/ios/simulator.d.ts.map +0 -1
- package/dist/platforms/ios/simulator.js +0 -156
- package/dist/platforms/platform-adapter.d.ts +0 -12
- package/dist/platforms/platform-adapter.d.ts.map +0 -1
- package/dist/platforms/platform-adapter.js +0 -1
- package/dist/platforms/platform-registry.d.ts +0 -3
- package/dist/platforms/platform-registry.d.ts.map +0 -1
- package/dist/platforms/platform-registry.js +0 -17
- package/dist/platforms/web/index.d.ts +0 -2
- package/dist/platforms/web/index.d.ts.map +0 -1
- package/dist/platforms/web/index.js +0 -50
- package/dist/process.d.ts +0 -3
- package/dist/process.d.ts.map +0 -1
- package/dist/process.js +0 -28
- package/dist/reporters/default-reporter.d.ts +0 -3
- package/dist/reporters/default-reporter.d.ts.map +0 -1
- package/dist/reporters/default-reporter.js +0 -111
package/dist/bundlers/webpack.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// import { ChildProcess, spawn } from 'node:child_process';
|
|
2
|
-
export {};
|
|
3
|
-
// export const runWebpack = async (configPath: string): Promise<ChildProcess> => {
|
|
4
|
-
// const webpack = await new Promise<ChildProcess>((resolve) => {
|
|
5
|
-
// const webpackProcess = spawn(
|
|
6
|
-
// 'webpack',
|
|
7
|
-
// [
|
|
8
|
-
// 'serve',
|
|
9
|
-
// '--config',
|
|
10
|
-
// configPath,
|
|
11
|
-
// '--mode',
|
|
12
|
-
// 'development',
|
|
13
|
-
// '--hot',
|
|
14
|
-
// '--port',
|
|
15
|
-
// '8081',
|
|
16
|
-
// ],
|
|
17
|
-
// {
|
|
18
|
-
// stdio: 'ignore',
|
|
19
|
-
// env: {
|
|
20
|
-
// ...process.env,
|
|
21
|
-
// RN_HARNESS: 'true',
|
|
22
|
-
// },
|
|
23
|
-
// }
|
|
24
|
-
// );
|
|
25
|
-
// resolve(webpackProcess);
|
|
26
|
-
// });
|
|
27
|
-
// await waitForWebpack(8081);
|
|
28
|
-
// return webpack;
|
|
29
|
-
// };
|
|
30
|
-
// export const waitForWebpack = async (
|
|
31
|
-
// port: number = 8081,
|
|
32
|
-
// maxRetries: number = 10,
|
|
33
|
-
// retryDelay: number = 2000
|
|
34
|
-
// ): Promise<void> => {
|
|
35
|
-
// let attempts = 0;
|
|
36
|
-
// while (attempts < maxRetries) {
|
|
37
|
-
// attempts++;
|
|
38
|
-
// try {
|
|
39
|
-
// const response = await fetch(`http://localhost:${port}`);
|
|
40
|
-
// if (response.ok) {
|
|
41
|
-
// return;
|
|
42
|
-
// }
|
|
43
|
-
// } catch {}
|
|
44
|
-
// if (attempts < maxRetries) {
|
|
45
|
-
// await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
// throw new Error(`Metro bundler is not ready after ${maxRetries} attempts`);
|
|
49
|
-
// };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const buildAndroidApp: (deviceId: string, maxRetries?: number) => Promise<void>;
|
|
2
|
-
export declare const killApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
3
|
-
export declare const runApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
4
|
-
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/platforms/android/build.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,mBAAc,KACb,OAAO,CAAC,IAAI,CAiCd,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAgBd,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { exec } from 'node:child_process';
|
|
2
|
-
import { reloadApp } from '../../bundlers/metro.js';
|
|
3
|
-
export const buildAndroidApp = async (deviceId, maxRetries = 2) => {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
let attempts = 0;
|
|
6
|
-
const attemptBuild = () => {
|
|
7
|
-
attempts++;
|
|
8
|
-
exec(`react-native run-android --deviceId=${deviceId} --no-packager`, async (error) => {
|
|
9
|
-
if (error) {
|
|
10
|
-
if (attempts <= maxRetries) {
|
|
11
|
-
try {
|
|
12
|
-
await reloadApp(8081);
|
|
13
|
-
// Wait a bit before retrying
|
|
14
|
-
setTimeout(attemptBuild, 3000);
|
|
15
|
-
}
|
|
16
|
-
catch (reloadError) {
|
|
17
|
-
console.warn('Reload failed, retrying build anyway...');
|
|
18
|
-
setTimeout(attemptBuild, 3000);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
reject(error);
|
|
23
|
-
}
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
resolve();
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
attemptBuild();
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
export const killApp = async (deviceId, bundleId) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
exec(`adb -s ${deviceId} shell am force-stop ${bundleId}`, (error) => {
|
|
35
|
-
if (error) {
|
|
36
|
-
reject(error);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
resolve();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
export const runApp = async (deviceId, bundleId) => {
|
|
44
|
-
await killApp(deviceId, bundleId);
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
exec(`adb -s ${deviceId} shell am start -n ${bundleId}/.MainActivity`, (error) => {
|
|
47
|
-
if (error) {
|
|
48
|
-
reject(error);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
resolve();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ChildProcess } from 'node:child_process';
|
|
2
|
-
export type AndroidEmulatorStatus = 'running' | 'loading' | 'stopped';
|
|
3
|
-
export declare const getEmulatorNameFromId: (emulatorId: string) => Promise<string | null>;
|
|
4
|
-
export declare const getEmulatorDeviceId: (avdName: string) => Promise<string | null>;
|
|
5
|
-
export declare const getEmulatorStatus: (avdName: string) => Promise<AndroidEmulatorStatus>;
|
|
6
|
-
export declare const runEmulator: (name: string) => Promise<ChildProcess>;
|
|
7
|
-
export declare const stopEmulator: (avdName: string) => Promise<void>;
|
|
8
|
-
export declare const isAppInstalled: (emulatorId: string, bundleId: string) => Promise<boolean>;
|
|
9
|
-
export declare const reversePort: (port: number) => Promise<void>;
|
|
10
|
-
export declare const getEmulatorScreenshot: (emulatorId: string, name?: string) => Promise<string>;
|
|
11
|
-
//# sourceMappingURL=emulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.d.ts","sourceRoot":"","sources":["../../../src/platforms/android/emulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAQ,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE,eAAO,MAAM,qBAAqB,GAChC,YAAY,MAAM,KACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAYvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAwBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,KACd,OAAO,CAAC,qBAAqB,CAuB/B,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,YAAY,CAgC9D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CAY1D,CAAC;AAiBF,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAejB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAW5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,YAAY,MAAM,EAClB,OAAM,MAGsB,KAC3B,OAAO,CAAC,MAAM,CAchB,CAAC"}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { exec } from 'node:child_process';
|
|
2
|
-
export const getEmulatorNameFromId = async (emulatorId) => {
|
|
3
|
-
return new Promise((resolve) => {
|
|
4
|
-
exec(`adb -s ${emulatorId} emu avd name`, (error, stdout) => {
|
|
5
|
-
if (error) {
|
|
6
|
-
resolve(null);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const avdName = stdout.split('\n')[0].trim();
|
|
10
|
-
resolve(avdName || null);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
export const getEmulatorDeviceId = async (avdName) => {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
exec('adb devices', async (error, stdout) => {
|
|
17
|
-
if (error) {
|
|
18
|
-
resolve(null);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const lines = stdout.split('\n');
|
|
22
|
-
for (const line of lines) {
|
|
23
|
-
const parts = line.trim().split('\t');
|
|
24
|
-
if (parts.length === 2 && parts[0].startsWith('emulator-')) {
|
|
25
|
-
const emulatorId = parts[0].trim();
|
|
26
|
-
const name = await getEmulatorNameFromId(emulatorId);
|
|
27
|
-
if (name === avdName) {
|
|
28
|
-
resolve(emulatorId);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
resolve(null);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
export const getEmulatorStatus = (avdName) => {
|
|
38
|
-
return new Promise((resolve) => {
|
|
39
|
-
getEmulatorDeviceId(avdName).then((emulatorId) => {
|
|
40
|
-
if (!emulatorId) {
|
|
41
|
-
resolve('stopped');
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
// Check if device is fully booted by checking boot completion
|
|
45
|
-
exec(`adb -s ${emulatorId} shell getprop sys.boot_completed`, (bootError, bootStdout) => {
|
|
46
|
-
if (bootError) {
|
|
47
|
-
resolve('loading');
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const bootCompleted = bootStdout.trim() === '1';
|
|
51
|
-
resolve(bootCompleted ? 'running' : 'loading');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
export const runEmulator = (name) => {
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
// Start the emulator
|
|
59
|
-
const process = exec(`emulator -avd ${name}`, (error) => {
|
|
60
|
-
if (error) {
|
|
61
|
-
reject(error);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
// Poll for emulator status until it's fully running
|
|
66
|
-
const checkStatus = async () => {
|
|
67
|
-
try {
|
|
68
|
-
const status = await getEmulatorStatus(name);
|
|
69
|
-
if (status === 'running') {
|
|
70
|
-
resolve(process);
|
|
71
|
-
}
|
|
72
|
-
else if (status === 'loading') {
|
|
73
|
-
// Check again in 2 seconds
|
|
74
|
-
setTimeout(checkStatus, 2000);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
// Still stopped, check again in 1 second
|
|
78
|
-
setTimeout(checkStatus, 1000);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
reject(error);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
// Start checking status after a brief delay to allow emulator to start
|
|
86
|
-
setTimeout(checkStatus, 3000);
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
export const stopEmulator = (avdName) => {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
// First, get the emulator device ID
|
|
92
|
-
getEmulatorDeviceId(avdName).then((emulatorId) => {
|
|
93
|
-
if (!emulatorId) {
|
|
94
|
-
resolve(); // No emulator running, nothing to stop
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
stopEmulatorById(emulatorId, resolve, reject);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
const stopEmulatorById = (emulatorId, resolve, reject) => {
|
|
102
|
-
// Stop the emulator using the found ID
|
|
103
|
-
exec(`adb -s ${emulatorId} emu kill`, (killError) => {
|
|
104
|
-
if (killError) {
|
|
105
|
-
reject(killError);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
resolve();
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
export const isAppInstalled = async (emulatorId, bundleId) => {
|
|
112
|
-
return new Promise((resolve) => {
|
|
113
|
-
exec(`adb -s ${emulatorId} shell pm list packages ${bundleId}`, (error, stdout) => {
|
|
114
|
-
if (error) {
|
|
115
|
-
resolve(false);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const installed = stdout.trim() !== '';
|
|
119
|
-
resolve(installed);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
export const reversePort = async (port) => {
|
|
124
|
-
return new Promise((resolve, reject) => {
|
|
125
|
-
exec(`adb reverse tcp:${port} tcp:${port}`, (error) => {
|
|
126
|
-
if (error) {
|
|
127
|
-
reject(error);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
resolve();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
export const getEmulatorScreenshot = async (emulatorId, name = `${emulatorId}-${new Date()
|
|
135
|
-
.toISOString()
|
|
136
|
-
.replace(/:/g, '-')
|
|
137
|
-
.replace(/\//g, '-')}.png`) => {
|
|
138
|
-
return new Promise((resolve, reject) => {
|
|
139
|
-
exec(`adb -s ${emulatorId} exec-out screencap -p > ${name}`, (error) => {
|
|
140
|
-
if (error) {
|
|
141
|
-
reject(error);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
resolve(name);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platforms/android/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAY9D,QAAA,MAAM,sBAAsB,EAAE,eAuD7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getAppiumInteractionEngine } from '@react-native-harness/interaction-engine';
|
|
2
|
-
import { assertNativeRunner } from '@react-native-harness/config';
|
|
3
|
-
import { runEmulator, getEmulatorDeviceId, reversePort, isAppInstalled, getEmulatorStatus, } from './emulator.js';
|
|
4
|
-
import { buildAndroidApp, runApp, killApp } from './build.js';
|
|
5
|
-
import { killWithAwait } from '../../process.js';
|
|
6
|
-
import { runMetro } from '../../bundlers/metro.js';
|
|
7
|
-
const androidPlatformAdapter = {
|
|
8
|
-
name: 'android',
|
|
9
|
-
getEnvironment: async (config) => {
|
|
10
|
-
assertNativeRunner(config);
|
|
11
|
-
let emulator = null;
|
|
12
|
-
const emulatorStatus = await getEmulatorStatus(config.runner.deviceId);
|
|
13
|
-
const metroPromise = runMetro();
|
|
14
|
-
if (emulatorStatus === 'stopped') {
|
|
15
|
-
emulator = await runEmulator(config.runner.deviceId);
|
|
16
|
-
}
|
|
17
|
-
const interactionEnginePromise = getAppiumInteractionEngine(config);
|
|
18
|
-
const deviceId = await getEmulatorDeviceId(config.runner.deviceId);
|
|
19
|
-
if (!deviceId) {
|
|
20
|
-
throw new Error('Emulator not found');
|
|
21
|
-
}
|
|
22
|
-
await Promise.all([
|
|
23
|
-
reversePort(8081),
|
|
24
|
-
reversePort(8080),
|
|
25
|
-
reversePort(3001),
|
|
26
|
-
]);
|
|
27
|
-
const isInstalled = await isAppInstalled(deviceId, config.runner.bundleId);
|
|
28
|
-
if (!isInstalled) {
|
|
29
|
-
await buildAndroidApp(deviceId);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
await runApp(deviceId, config.runner.bundleId);
|
|
33
|
-
}
|
|
34
|
-
const interactionEngine = await interactionEnginePromise;
|
|
35
|
-
const metro = await metroPromise;
|
|
36
|
-
return {
|
|
37
|
-
restart: async () => {
|
|
38
|
-
await runApp(config.runner.deviceId, config.runner.bundleId);
|
|
39
|
-
},
|
|
40
|
-
dispose: async () => {
|
|
41
|
-
if (emulator) {
|
|
42
|
-
await killWithAwait(emulator);
|
|
43
|
-
}
|
|
44
|
-
await interactionEngine.close();
|
|
45
|
-
await killWithAwait(metro);
|
|
46
|
-
await killApp(deviceId, config.runner.bundleId);
|
|
47
|
-
},
|
|
48
|
-
interactionEngine,
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
export default androidPlatformAdapter;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const listDevices: () => Promise<any>;
|
|
2
|
-
export declare const getDeviceByName: (simulatorName: string) => Promise<any | null>;
|
|
3
|
-
export declare const installPods: () => Promise<void>;
|
|
4
|
-
export declare const listApps: (udid: string) => Promise<string>;
|
|
5
|
-
export declare const isAppInstalled: (simulatorName: string, bundleId: string) => Promise<boolean>;
|
|
6
|
-
export declare const buildIOSApp: (simulatorName: string, maxRetries?: number) => Promise<void>;
|
|
7
|
-
export declare const runApp: (simulatorName: string, appName: string) => Promise<void>;
|
|
8
|
-
export declare const killApp: (simulatorName: string, appName: string) => Promise<void>;
|
|
9
|
-
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/platforms/ios/build.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,GAAG,CAgB/C,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,eAAe,MAAM,KACpB,OAAO,CAAC,GAAG,GAAG,IAAI,CAiBpB,CAAC;AAEF,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,IAAI,CAYhD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,CAW3D,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,eAAe,MAAM,EACrB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAajB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,eAAe,MAAM,EACrB,aAAY,MAAU,KACrB,OAAO,CAAC,IAAI,CAoCd,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,eAAe,MAAM,EACrB,SAAS,MAAM,KACd,OAAO,CAAC,IAAI,CAgBd,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,eAAe,MAAM,EACrB,SAAS,MAAM,KACd,OAAO,CAAC,IAAI,CAMd,CAAC"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { exec } from 'node:child_process';
|
|
2
|
-
import { reloadApp } from '../../bundlers/metro.js';
|
|
3
|
-
export const listDevices = async () => {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
exec('xcrun simctl list devices --json', (error, stdout) => {
|
|
6
|
-
if (error) {
|
|
7
|
-
reject(error);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
const devices = JSON.parse(stdout);
|
|
12
|
-
resolve(devices);
|
|
13
|
-
}
|
|
14
|
-
catch (parseError) {
|
|
15
|
-
reject(parseError);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
export const getDeviceByName = async (simulatorName) => {
|
|
21
|
-
try {
|
|
22
|
-
const devices = await listDevices();
|
|
23
|
-
for (const runtime in devices.devices) {
|
|
24
|
-
const runtimeDevices = devices.devices[runtime];
|
|
25
|
-
for (const device of runtimeDevices) {
|
|
26
|
-
if (device.name === simulatorName && device.isAvailable) {
|
|
27
|
-
return device;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export const installPods = async () => {
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
exec('cd ios && bundle exec pod install', (error) => {
|
|
40
|
-
if (error) {
|
|
41
|
-
console.warn('CocoaPods install failed:', error.message);
|
|
42
|
-
reject(error);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
resolve();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
export const listApps = async (udid) => {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
exec(`xcrun simctl listapps ${udid}`, (error, stdout) => {
|
|
52
|
-
if (error) {
|
|
53
|
-
reject(error);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
resolve(stdout);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
export const isAppInstalled = async (simulatorName, bundleId) => {
|
|
61
|
-
try {
|
|
62
|
-
const device = await getDeviceByName(simulatorName);
|
|
63
|
-
if (!device) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
const appList = await listApps(device.udid);
|
|
67
|
-
return appList.includes(bundleId);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
export const buildIOSApp = async (simulatorName, maxRetries = 2) => {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
let attempts = 0;
|
|
76
|
-
const attemptBuild = async () => {
|
|
77
|
-
attempts++;
|
|
78
|
-
try {
|
|
79
|
-
await installPods();
|
|
80
|
-
}
|
|
81
|
-
catch { }
|
|
82
|
-
exec(`npx react-native run-ios --simulator="${simulatorName}" --no-packager`, async (error) => {
|
|
83
|
-
if (error) {
|
|
84
|
-
if (attempts <= maxRetries) {
|
|
85
|
-
try {
|
|
86
|
-
await reloadApp(8081);
|
|
87
|
-
setTimeout(attemptBuild, 3000);
|
|
88
|
-
}
|
|
89
|
-
catch (reloadError) {
|
|
90
|
-
setTimeout(attemptBuild, 3000);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
reject(error);
|
|
95
|
-
}
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
resolve();
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
attemptBuild();
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
export const runApp = async (simulatorName, appName) => {
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
exec(`xcrun simctl terminate "${simulatorName}" ${appName}`, () => {
|
|
107
|
-
exec(`xcrun simctl launch "${simulatorName}" ${appName}`, (error) => {
|
|
108
|
-
if (error) {
|
|
109
|
-
reject(error);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
resolve();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
export const killApp = async (simulatorName, appName) => {
|
|
118
|
-
return new Promise((resolve) => {
|
|
119
|
-
exec(`xcrun simctl terminate "${simulatorName}" ${appName}`, () => {
|
|
120
|
-
resolve();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platforms/ios/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAc9D,QAAA,MAAM,kBAAkB,EAAE,eAgDzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { getAppiumInteractionEngine } from '@react-native-harness/interaction-engine';
|
|
2
|
-
import { assertNativeRunner } from '@react-native-harness/config';
|
|
3
|
-
import { runSimulator } from './simulator.js';
|
|
4
|
-
import { buildIOSApp, isAppInstalled, runApp, killApp } from './build.js';
|
|
5
|
-
import { killWithAwait } from '../../process.js';
|
|
6
|
-
import { runMetro } from '../../bundlers/metro.js';
|
|
7
|
-
const measure = async (fn, name) => {
|
|
8
|
-
const start = performance.now();
|
|
9
|
-
const result = await fn();
|
|
10
|
-
const end = performance.now();
|
|
11
|
-
console.log(`${name} took ${end - start}ms`);
|
|
12
|
-
return result;
|
|
13
|
-
};
|
|
14
|
-
const iosPlatformAdapter = {
|
|
15
|
-
name: 'ios',
|
|
16
|
-
getEnvironment: async (config) => {
|
|
17
|
-
assertNativeRunner(config);
|
|
18
|
-
let simulator = null;
|
|
19
|
-
// Start metro and interaction engine in parallel
|
|
20
|
-
const metroPromise = runMetro();
|
|
21
|
-
const interactionEnginePromise = getAppiumInteractionEngine(config);
|
|
22
|
-
// Start simulator
|
|
23
|
-
simulator = (await measure(() => runSimulator(config.runner.deviceId), 'runSimulator'));
|
|
24
|
-
console.log('simulator started');
|
|
25
|
-
const isInstalled = await measure(() => isAppInstalled(config.runner.deviceId, config.runner.bundleId), 'isAppInstalled');
|
|
26
|
-
console.log(isInstalled);
|
|
27
|
-
if (!isInstalled) {
|
|
28
|
-
await buildIOSApp(config.runner.deviceId);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
await runApp(config.runner.deviceId, config.runner.bundleId);
|
|
32
|
-
}
|
|
33
|
-
const interactionEngine = await interactionEnginePromise;
|
|
34
|
-
const metro = await metroPromise;
|
|
35
|
-
return {
|
|
36
|
-
restart: async () => {
|
|
37
|
-
await runApp(config.runner.deviceId, config.runner.bundleId);
|
|
38
|
-
},
|
|
39
|
-
dispose: async () => {
|
|
40
|
-
if (simulator) {
|
|
41
|
-
await killWithAwait(simulator);
|
|
42
|
-
}
|
|
43
|
-
await interactionEngine.close();
|
|
44
|
-
await killWithAwait(metro);
|
|
45
|
-
await killApp(config.runner.deviceId, config.runner.bundleId);
|
|
46
|
-
},
|
|
47
|
-
interactionEngine,
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
export default iosPlatformAdapter;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type IOSSimulatorStatus = 'stopped' | 'loading' | 'running';
|
|
2
|
-
export declare const getSimulatorDeviceId: (simulatorName: string) => Promise<string | null>;
|
|
3
|
-
export declare const getAvailableSimulators: () => Promise<Array<{
|
|
4
|
-
name: string;
|
|
5
|
-
udid: string;
|
|
6
|
-
runtime: string;
|
|
7
|
-
}>>;
|
|
8
|
-
export declare const getSimulatorStatus: (simulatorName: string) => Promise<IOSSimulatorStatus>;
|
|
9
|
-
export declare const runSimulator: (name: string) => Promise<void>;
|
|
10
|
-
export declare const stopSimulator: (name: string) => Promise<void>;
|
|
11
|
-
//# sourceMappingURL=simulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../../../src/platforms/ios/simulator.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE,eAAO,MAAM,oBAAoB,GAC/B,eAAe,MAAM,KACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAgCvB,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAO,OAAO,CAC/C,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAsCvD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,eAAe,MAAM,KACpB,OAAO,CAAC,kBAAkB,CAwC5B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAmD7D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAWxD,CAAC"}
|