@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.
Files changed (41) hide show
  1. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  2. package/package.json +3 -3
  3. package/dist/bundlers/metro.d.ts +0 -5
  4. package/dist/bundlers/metro.d.ts.map +0 -1
  5. package/dist/bundlers/metro.js +0 -48
  6. package/dist/bundlers/webpack.d.ts +0 -2
  7. package/dist/bundlers/webpack.d.ts.map +0 -1
  8. package/dist/bundlers/webpack.js +0 -49
  9. package/dist/platforms/android/build.d.ts +0 -4
  10. package/dist/platforms/android/build.d.ts.map +0 -1
  11. package/dist/platforms/android/build.js +0 -54
  12. package/dist/platforms/android/emulator.d.ts +0 -11
  13. package/dist/platforms/android/emulator.d.ts.map +0 -1
  14. package/dist/platforms/android/emulator.js +0 -147
  15. package/dist/platforms/android/index.d.ts +0 -4
  16. package/dist/platforms/android/index.d.ts.map +0 -1
  17. package/dist/platforms/android/index.js +0 -52
  18. package/dist/platforms/ios/build.d.ts +0 -9
  19. package/dist/platforms/ios/build.d.ts.map +0 -1
  20. package/dist/platforms/ios/build.js +0 -123
  21. package/dist/platforms/ios/index.d.ts +0 -4
  22. package/dist/platforms/ios/index.d.ts.map +0 -1
  23. package/dist/platforms/ios/index.js +0 -51
  24. package/dist/platforms/ios/simulator.d.ts +0 -11
  25. package/dist/platforms/ios/simulator.d.ts.map +0 -1
  26. package/dist/platforms/ios/simulator.js +0 -156
  27. package/dist/platforms/platform-adapter.d.ts +0 -12
  28. package/dist/platforms/platform-adapter.d.ts.map +0 -1
  29. package/dist/platforms/platform-adapter.js +0 -1
  30. package/dist/platforms/platform-registry.d.ts +0 -3
  31. package/dist/platforms/platform-registry.d.ts.map +0 -1
  32. package/dist/platforms/platform-registry.js +0 -17
  33. package/dist/platforms/web/index.d.ts +0 -2
  34. package/dist/platforms/web/index.d.ts.map +0 -1
  35. package/dist/platforms/web/index.js +0 -50
  36. package/dist/process.d.ts +0 -3
  37. package/dist/process.d.ts.map +0 -1
  38. package/dist/process.js +0 -28
  39. package/dist/reporters/default-reporter.d.ts +0 -3
  40. package/dist/reporters/default-reporter.d.ts.map +0 -1
  41. package/dist/reporters/default-reporter.js +0 -111
@@ -1,156 +0,0 @@
1
- import { exec } from 'node:child_process';
2
- export const getSimulatorDeviceId = (simulatorName) => {
3
- return new Promise((resolve) => {
4
- exec(`xcrun simctl list devices --json`, (error, stdout) => {
5
- if (error) {
6
- resolve(null);
7
- return;
8
- }
9
- try {
10
- const devices = JSON.parse(stdout);
11
- // Find the device across all iOS versions
12
- for (const runtime in devices.devices) {
13
- if (runtime.includes('iOS')) {
14
- const runtimeDevices = devices.devices[runtime];
15
- const device = runtimeDevices.find((d) => d.name === simulatorName && d.state === 'Booted');
16
- if (device) {
17
- resolve(device.udid);
18
- return;
19
- }
20
- }
21
- }
22
- resolve(null);
23
- }
24
- catch (parseError) {
25
- resolve(null);
26
- }
27
- });
28
- });
29
- };
30
- export const getAvailableSimulators = () => {
31
- return new Promise((resolve) => {
32
- exec(`xcrun simctl list devices --json`, (error, stdout) => {
33
- if (error) {
34
- resolve([]);
35
- return;
36
- }
37
- try {
38
- const devices = JSON.parse(stdout);
39
- const simulators = [];
40
- for (const runtime in devices.devices) {
41
- if (runtime.includes('iOS')) {
42
- const runtimeDevices = devices.devices[runtime];
43
- runtimeDevices.forEach((device) => {
44
- if (device.isAvailable) {
45
- simulators.push({
46
- name: device.name,
47
- udid: device.udid,
48
- runtime: runtime,
49
- });
50
- }
51
- });
52
- }
53
- }
54
- resolve(simulators);
55
- }
56
- catch (parseError) {
57
- resolve([]);
58
- }
59
- });
60
- });
61
- };
62
- export const getSimulatorStatus = (simulatorName) => {
63
- return new Promise((resolve) => {
64
- exec(`xcrun simctl list devices --json`, (error, stdout) => {
65
- if (error) {
66
- resolve('stopped');
67
- return;
68
- }
69
- try {
70
- const devices = JSON.parse(stdout);
71
- for (const runtime in devices.devices) {
72
- if (runtime.includes('iOS')) {
73
- const runtimeDevices = devices.devices[runtime];
74
- const device = runtimeDevices.find((d) => d.name === simulatorName);
75
- if (device) {
76
- switch (device.state) {
77
- case 'Booted':
78
- resolve('running');
79
- return;
80
- case 'Booting':
81
- resolve('loading');
82
- return;
83
- default:
84
- resolve('stopped');
85
- return;
86
- }
87
- }
88
- }
89
- }
90
- resolve('stopped');
91
- }
92
- catch (parseError) {
93
- resolve('stopped');
94
- }
95
- });
96
- });
97
- };
98
- export const runSimulator = async (name) => {
99
- const deviceId = await getSimulatorDeviceId(name);
100
- if (!deviceId) {
101
- throw new Error('Simulator not found');
102
- }
103
- await new Promise((resolve, reject) => {
104
- exec(`xcrun simctl boot ${deviceId}`, (bootError) => {
105
- if (bootError &&
106
- !bootError.message.includes('Unable to boot device in current state: Booted')) {
107
- reject(bootError);
108
- return;
109
- }
110
- resolve();
111
- });
112
- });
113
- await new Promise((resolve, reject) => {
114
- exec('open -a Simulator', (error) => {
115
- if (error) {
116
- reject(error);
117
- return;
118
- }
119
- resolve();
120
- });
121
- });
122
- let attempts = 0;
123
- while (true) {
124
- attempts++;
125
- const status = await getSimulatorStatus(name);
126
- if (status === 'running') {
127
- break;
128
- }
129
- if (attempts > 10) {
130
- throw new Error('Simulator not running');
131
- }
132
- await new Promise((resolve) => setTimeout(resolve, 1000));
133
- }
134
- };
135
- export const stopSimulator = (name) => {
136
- return new Promise((resolve, reject) => {
137
- getSimulatorDeviceId(name).then((simulatorId) => {
138
- if (!simulatorId) {
139
- resolve(); // Already stopped
140
- return;
141
- }
142
- stopSimulatorById(simulatorId, resolve, reject);
143
- });
144
- });
145
- };
146
- const stopSimulatorById = (simulatorId, resolve, reject) => {
147
- // Shutdown the simulator
148
- exec(`xcrun simctl shutdown ${simulatorId}`, (shutdownError) => {
149
- if (shutdownError &&
150
- !shutdownError.message.includes('Unable to shutdown device in current state: Shutdown')) {
151
- reject(shutdownError);
152
- return;
153
- }
154
- resolve();
155
- });
156
- };
@@ -1,12 +0,0 @@
1
- import { Config } from '@react-native-harness/config';
2
- import { InteractionEngine } from '@react-native-harness/interaction-engine';
3
- export type Environment = {
4
- restart: () => Promise<void>;
5
- dispose: () => Promise<void>;
6
- interactionEngine: InteractionEngine;
7
- };
8
- export type PlatformAdapter = {
9
- name: string;
10
- getEnvironment: (config: Config) => Promise<Environment>;
11
- };
12
- //# sourceMappingURL=platform-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform-adapter.d.ts","sourceRoot":"","sources":["../../src/platforms/platform-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CAC1D,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { PlatformAdapter } from './platform-adapter.js';
2
- export declare const getPlatformAdapter: (platformName: string) => Promise<PlatformAdapter>;
3
- //# sourceMappingURL=platform-registry.d.ts.map
@@ -1 +0,0 @@
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;AASxD,eAAO,MAAM,kBAAkB,GAC7B,cAAc,MAAM,KACnB,OAAO,CAAC,eAAe,CAUzB,CAAC"}
@@ -1,17 +0,0 @@
1
- import androidPlatformAdapter from './android/index.js';
2
- import iosPlatformAdapter from './ios/index.js';
3
- const platformAdapters = {
4
- android: androidPlatformAdapter,
5
- ios: iosPlatformAdapter,
6
- };
7
- export const getPlatformAdapter = async (platformName) => {
8
- if (!(platformName in platformAdapters)) {
9
- throw new Error(`Platform adapter for ${platformName} not found`);
10
- }
11
- try {
12
- return platformAdapters[platformName];
13
- }
14
- catch (error) {
15
- throw new Error(`Platform adapter for ${platformName} not found`);
16
- }
17
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platforms/web/index.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- // import path from 'path';
2
- // import { runWebpack } from '../../bundlers/webpack.js';
3
- // import { PlatformAdapter } from '../platform-adapter.js';
4
- // import { killWithAwait } from '../../process.js';
5
- // import { Browser, firefox, Page } from 'playwright';
6
- // import { Config } from '@react-native-harness/config';
7
- export {};
8
- // const runBrowser = async (
9
- // url: string
10
- // ): Promise<{ browser: Browser; page: Page }> => {
11
- // const browser = await firefox.launch({
12
- // headless: false,
13
- // devtools: false,
14
- // args: [
15
- // '--no-sandbox',
16
- // '--disable-setuid-sandbox',
17
- // '--disable-dev-shm-usage',
18
- // '--disable-web-security',
19
- // '--allow-insecure-localhost',
20
- // '--ignore-certificate-errors',
21
- // ],
22
- // ignoreDefaultArgs: ['--disable-extensions'],
23
- // });
24
- // const context = await browser.newContext({
25
- // bypassCSP: true,
26
- // ignoreHTTPSErrors: true,
27
- // });
28
- // const page = await context.newPage();
29
- // await page.setViewportSize({ width: 1280, height: 720 });
30
- // await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 });
31
- // return { browser, page };
32
- // };
33
- // export const webPlatformAdapter: PlatformAdapter = {
34
- // name: 'web',
35
- // getEnvironment: async (_config: Config) => {
36
- // const webpackConfigPath = path.resolve(process.cwd(), 'webpack.config.js');
37
- // const webpack = await runWebpack(webpackConfigPath);
38
- // const { browser, page } = await runBrowser('http://localhost:8081');
39
- // return {
40
- // restart: async () => {
41
- // await page.reload({ waitUntil: 'domcontentloaded', timeout: 60000 });
42
- // },
43
- // dispose: async () => {
44
- // await browser.close();
45
- // await killWithAwait(webpack);
46
- // },
47
- // };
48
- // },
49
- // };
50
- // export default webPlatformAdapter;
package/dist/process.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { type ChildProcess } from 'node:child_process';
2
- export declare const killWithAwait: (child: ChildProcess) => Promise<void>;
3
- //# sourceMappingURL=process.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,aAAa,GAAI,OAAO,YAAY,KAAG,OAAO,CAAC,IAAI,CA8B/D,CAAC"}
package/dist/process.js DELETED
@@ -1,28 +0,0 @@
1
- export const killWithAwait = (child) => {
2
- return new Promise((resolve) => {
3
- const timeout = setTimeout(() => {
4
- child.kill('SIGTERM');
5
- resolve();
6
- }, 10000);
7
- if (child.killed || child.exitCode !== null) {
8
- clearTimeout(timeout);
9
- resolve();
10
- return;
11
- }
12
- child.on('exit', () => {
13
- clearTimeout(timeout);
14
- resolve();
15
- });
16
- child.on('error', () => {
17
- clearTimeout(timeout);
18
- resolve();
19
- });
20
- try {
21
- child.kill();
22
- }
23
- catch (error) {
24
- clearTimeout(timeout);
25
- resolve();
26
- }
27
- });
28
- };
@@ -1,3 +0,0 @@
1
- import { Reporter } from '@react-native-harness/config';
2
- export declare const defaultReporter: Reporter;
3
- //# sourceMappingURL=default-reporter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-reporter.d.ts","sourceRoot":"","sources":["../../src/reporters/default-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,eAAO,MAAM,eAAe,EAAE,QAoC7B,CAAC"}
@@ -1,111 +0,0 @@
1
- import chalk from 'chalk';
2
- export const defaultReporter = {
3
- report: async (results) => {
4
- console.log('\nšŸ“‹ Test Results:');
5
- console.log(chalk.gray('━'.repeat(40)));
6
- for (const suite of results) {
7
- console.log(formatSuiteResult(suite));
8
- }
9
- console.log(chalk.gray('━'.repeat(40)));
10
- // Summary
11
- let totalPassed = 0, totalFailed = 0, totalSkipped = 0, totalTodo = 0;
12
- let totalDuration = 0;
13
- for (const suite of results) {
14
- const summary = getTestSummary(suite);
15
- totalPassed += summary.passed;
16
- totalFailed += summary.failed;
17
- totalSkipped += summary.skipped;
18
- totalTodo += summary.todo;
19
- totalDuration += suite.duration || 0;
20
- }
21
- console.log(`\nšŸ“Š Summary: ${chalk.green(`${totalPassed} passed`)}, ${chalk.red(`${totalFailed} failed`)}, ${chalk.yellow(`${totalSkipped} skipped`)}, ${chalk.blue(`${totalTodo} todo`)}`);
22
- console.log(`ā±ļø Total time: ${formatDuration(totalDuration)}`);
23
- },
24
- };
25
- const formatDuration = (duration) => {
26
- if (!duration)
27
- return '';
28
- return chalk.gray(` (${duration}ms)`);
29
- };
30
- const getStatusIcon = (status) => {
31
- switch (status) {
32
- case 'passed':
33
- return chalk.green('āœ“');
34
- case 'failed':
35
- return chalk.red('āœ—');
36
- case 'skipped':
37
- return chalk.yellow('ā—‹');
38
- case 'todo':
39
- return chalk.blue('◐');
40
- default:
41
- return '?';
42
- }
43
- };
44
- const formatTestResult = (test, indent = '') => {
45
- const icon = getStatusIcon(test.status);
46
- const name = test.status === 'failed' ? chalk.red(test.name) : test.name;
47
- const duration = formatDuration(test.duration);
48
- let result = `${indent}${icon} ${name}${duration}`;
49
- if (test.error) {
50
- const errorLines = test.error.message?.split('\n') || [];
51
- result +=
52
- '\n' +
53
- errorLines
54
- .map((line) => `${indent} ${chalk.red(line)}`)
55
- .join('\n');
56
- }
57
- return result;
58
- };
59
- const formatSuiteResult = (suite, indent = '') => {
60
- const icon = getStatusIcon(suite.status);
61
- const name = suite.status === 'failed' ? chalk.red(suite.name) : chalk.bold(suite.name);
62
- const duration = formatDuration(suite.duration);
63
- let result = `${indent}${icon} ${name}${duration}`;
64
- if (suite.error) {
65
- const errorLines = suite.error.message.split('\n');
66
- result +=
67
- '\n' +
68
- errorLines
69
- .map((line) => `${indent} ${chalk.red(line)}`)
70
- .join('\n');
71
- }
72
- const childIndent = indent + ' ';
73
- // Format tests
74
- for (const test of suite.tests) {
75
- result += '\n' + formatTestResult(test, childIndent);
76
- }
77
- // Format nested suites
78
- for (const childSuite of suite.suites) {
79
- result += '\n' + formatSuiteResult(childSuite, childIndent);
80
- }
81
- return result;
82
- };
83
- const getTestSummary = (suite) => {
84
- let passed = 0, failed = 0, skipped = 0, todo = 0;
85
- // Count tests in current suite
86
- for (const test of suite.tests) {
87
- switch (test.status) {
88
- case 'passed':
89
- passed++;
90
- break;
91
- case 'failed':
92
- failed++;
93
- break;
94
- case 'skipped':
95
- skipped++;
96
- break;
97
- case 'todo':
98
- todo++;
99
- break;
100
- }
101
- }
102
- // Count tests in nested suites
103
- for (const childSuite of suite.suites) {
104
- const childSummary = getTestSummary(childSuite);
105
- passed += childSummary.passed;
106
- failed += childSummary.failed;
107
- skipped += childSummary.skipped;
108
- todo += childSummary.todo;
109
- }
110
- return { passed, failed, skipped, todo };
111
- };