Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.

Commit d3f6f8b

Browse files
feat: Integrate shared oxc and release configs (#313)
1 parent 7b503a2 commit d3f6f8b

30 files changed

Lines changed: 146 additions & 232 deletions

‎.editorconfig‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
max_line_length = 120
12+
13+
[*.md]
14+
trim_trailing_whitespace = false

‎.github/workflows/unit-test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ jobs:
3939
- run: npm run lint
4040
name: Run linter
4141
- run: npm run format:check
42-
name: Run Prettier check
42+
name: Run format check
4343
- run: npm run test
4444
name: Run unit tests

‎.releaserc‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎eslint.config.mjs‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎lib/helpers.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import * as semver from 'semver';
21
import {spawn} from 'node:child_process';
32
import {Readable} from 'node:stream';
43

4+
import * as semver from 'semver';
5+
56
export const DEFAULT_EXEC_TIMEOUT = 10 * 60 * 1000; // ms
67
export const SIM_RUNTIME_NAME = 'com.apple.CoreSimulator.SimRuntime.';
78

@@ -61,10 +62,9 @@ export async function convertPlistToJson(plistInput: string): Promise<any> {
6162
});
6263
} catch (err) {
6364
plutilProcess.kill(9);
64-
throw new Error(
65-
`Failed to convert plist to JSON: ${err instanceof Error ? err.message : String(err)}`,
66-
{cause: err},
67-
);
65+
throw new Error(`Failed to convert plist to JSON: ${err instanceof Error ? err.message : String(err)}`, {
66+
cause: err,
67+
});
6868
} finally {
6969
plutilProcess.removeAllListeners();
7070
inputStream.removeAllListeners();

‎lib/simctl.ts‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import {exec as tpExec, SubProcess} from 'teen_process';
12
import which from 'which';
2-
import {log, LOG_PREFIX} from './logger.js';
3+
34
import {DEFAULT_EXEC_TIMEOUT, getXcrunBinary} from './helpers.js';
4-
import {exec as tpExec, SubProcess} from 'teen_process';
5+
import {log, LOG_PREFIX} from './logger.js';
56
import * as addmediaCommands from './subcommands/addmedia.js';
67
import * as appinfoCommands from './subcommands/appinfo.js';
78
import * as bootCommands from './subcommands/boot.js';
@@ -10,23 +11,23 @@ import * as createCommands from './subcommands/create.js';
1011
import * as deleteCommands from './subcommands/delete.js';
1112
import * as eraseCommands from './subcommands/erase.js';
1213
import * as getappcontainerCommands from './subcommands/get_app_container.js';
14+
import * as envCommands from './subcommands/getenv.js';
1315
import * as installCommands from './subcommands/install.js';
1416
import * as ioCommands from './subcommands/io.js';
1517
import * as keychainCommands from './subcommands/keychain.js';
1618
import * as launchCommands from './subcommands/launch.js';
1719
import * as listCommands from './subcommands/list.js';
20+
import * as locationCommands from './subcommands/location.js';
1821
import * as openurlCommands from './subcommands/openurl.js';
1922
import * as pbcopyCommands from './subcommands/pbcopy.js';
2023
import * as pbpasteCommands from './subcommands/pbpaste.js';
2124
import * as privacyCommands from './subcommands/privacy.js';
2225
import * as pushCommands from './subcommands/push.js';
23-
import * as envCommands from './subcommands/getenv.js';
2426
import * as shutdownCommands from './subcommands/shutdown.js';
2527
import * as spawnCommands from './subcommands/spawn.js';
2628
import * as terminateCommands from './subcommands/terminate.js';
2729
import * as uiCommands from './subcommands/ui.js';
2830
import * as uninstallCommands from './subcommands/uninstall.js';
29-
import * as locationCommands from './subcommands/location.js';
3031
import type {XCRun, ExecOpts, SimctlOpts, ExecResult} from './types.js';
3132

3233
const SIMCTL_ENV_PREFIX = 'SIMCTL_CHILD_';
@@ -113,8 +114,7 @@ export class Simctl {
113114
requireUdid(commandName: string | null = null): string {
114115
if (!this.udid) {
115116
throw new Error(
116-
`udid is required to be set for ` +
117-
(commandName ? `the '${commandName}' command` : 'this simctl command'),
117+
`udid is required to be set for ` + (commandName ? `the '${commandName}' command` : 'this simctl command'),
118118
);
119119
}
120120
return this.udid;
@@ -130,10 +130,7 @@ export class Simctl {
130130
try {
131131
this.xcrun.path = await which(xcrunBinary);
132132
} catch {
133-
throw new Error(
134-
`${xcrunBinary} tool has not been found in PATH. ` +
135-
`Are Xcode developers tools installed?`,
136-
);
133+
throw new Error(`${xcrunBinary} tool has not been found in PATH. Are Xcode developers tools installed?`);
137134
}
138135
}
139136
if (!this.xcrun.path) {
@@ -163,12 +160,7 @@ export class Simctl {
163160
timeout,
164161
} = opts ?? ({} as T);
165162
// run a particular simctl command
166-
const args = [
167-
'simctl',
168-
...(this.devicesSetPath ? ['--set', this.devicesSetPath] : []),
169-
subcommand,
170-
...initialArgs,
171-
];
163+
const args = ['simctl', ...(this.devicesSetPath ? ['--set', this.devicesSetPath] : []), subcommand, ...initialArgs];
172164
// Prefix all passed in environment variables with 'SIMCTL_CHILD_', simctl
173165
// will then pass these to the child (spawned) process.
174166
const envWithPrefixedKeys = Object.fromEntries(
@@ -190,17 +182,16 @@ export class Simctl {
190182
try {
191183
let execArgs: [string, string[], any];
192184
if (architectures?.length) {
193-
const archArgs = (Array.isArray(architectures) ? architectures : [architectures]).flatMap(
194-
(arch) => ['-arch', arch],
195-
);
185+
const archArgs = (Array.isArray(architectures) ? architectures : [architectures]).flatMap((arch) => [
186+
'-arch',
187+
arch,
188+
]);
196189
execArgs = ['arch', [...archArgs, xcrun, ...args], execOpts];
197190
} else {
198191
execArgs = [xcrun, args, execOpts];
199192
}
200193
// We know what we are doing here - the type system can't handle the dynamic nature
201-
return (
202-
asynchronous ? new SubProcess(...execArgs) : await tpExec(...execArgs)
203-
) as ExecResult<T>;
194+
return (asynchronous ? new SubProcess(...execArgs) : await tpExec(...execArgs)) as ExecResult<T>;
204195
} catch (e: any) {
205196
if (!this.logErrors || !logErrors) {
206197
// if we don't want to see the errors, just throw and allow the calling

‎lib/subcommands/addmedia.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type {Simctl} from '../simctl.js';
21
import type {TeenProcessExecResult} from 'teen_process';
32

3+
import type {Simctl} from '../simctl.js';
4+
45
/**
56
* Add the particular media file to Simulator's library.
67
* It is required that Simulator is in _booted_ state.
@@ -12,10 +13,7 @@ import type {TeenProcessExecResult} from 'teen_process';
1213
* returns non-zero return code.
1314
* @throws {Error} If the `udid` instance property is unset
1415
*/
15-
export async function addMedia(
16-
this: Simctl,
17-
filePath: string,
18-
): Promise<TeenProcessExecResult<string>> {
16+
export async function addMedia(this: Simctl, filePath: string): Promise<TeenProcessExecResult<string>> {
1917
return await this.exec('addmedia', {
2018
args: [this.requireUdid('addmedia'), filePath],
2119
});

‎lib/subcommands/appinfo.ts‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import {convertPlistToJson} from '../helpers.js';
12
import type {Simctl} from '../simctl.js';
23
import type {AppInfo} from '../types.js';
3-
import {convertPlistToJson} from '../helpers.js';
44

55
/**
66
* Get information about an app installed on the simulator
@@ -24,19 +24,13 @@ export async function appInfo(this: Simctl, bundleId: string): Promise<AppInfo>
2424
try {
2525
result = await convertPlistToJson(stdout);
2626
} catch (err) {
27-
throw new Error(
28-
`Cannot retrieve app info for ${bundleId}: ${err instanceof Error ? err.message : String(err)}`,
29-
{cause: err},
30-
);
27+
throw new Error(`Cannot retrieve app info for ${bundleId}: ${err instanceof Error ? err.message : String(err)}`, {
28+
cause: err,
29+
});
3130
}
3231
}
3332

34-
if (
35-
!result ||
36-
typeof result !== 'object' ||
37-
Array.isArray(result) ||
38-
!('ApplicationType' in result)
39-
) {
33+
if (!result || typeof result !== 'object' || Array.isArray(result) || !('ApplicationType' in result)) {
4034
throw new Error(`App with bundle identifier "${bundleId}" not found. Is it installed?`);
4135
}
4236

‎lib/subcommands/bootstatus.ts‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {log, LOG_PREFIX} from '../logger.js';
21
import {waitForCondition} from 'asyncbox';
2+
import type {SubProcess} from 'teen_process';
3+
4+
import {log, LOG_PREFIX} from '../logger.js';
35
import type {Simctl} from '../simctl.js';
46
import type {BootMonitorOptions} from '../types.js';
5-
import type {SubProcess} from 'teen_process';
67

78
/**
89
* Start monitoring for boot status of the particular Simulator.
@@ -16,18 +17,8 @@ import type {SubProcess} from 'teen_process';
1617
* property is not set.
1718
* @throws {Error} If the `udid` instance property is unset
1819
*/
19-
export async function startBootMonitor(
20-
this: Simctl,
21-
opts: BootMonitorOptions = {},
22-
): Promise<SubProcess> {
23-
const {
24-
timeout = 240000,
25-
onWaitingDataMigration,
26-
onWaitingSystemApp,
27-
onFinished,
28-
onError,
29-
shouldPreboot,
30-
} = opts;
20+
export async function startBootMonitor(this: Simctl, opts: BootMonitorOptions = {}): Promise<SubProcess> {
21+
const {timeout = 240000, onWaitingDataMigration, onWaitingSystemApp, onFinished, onError, shouldPreboot} = opts;
3122
const udid = this.requireUdid('bootstatus');
3223

3324
const status: string[] = [];

‎lib/subcommands/create.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {log, LOG_PREFIX} from '../logger.js';
21
import {retryInterval} from 'asyncbox';
2+
33
import {SIM_RUNTIME_NAME, normalizeVersion} from '../helpers.js';
4+
import {log, LOG_PREFIX} from '../logger.js';
45
import type {Simctl} from '../simctl.js';
56
import type {SimCreationOpts} from '../types.js';
67

@@ -58,9 +59,7 @@ export async function createDevice(
5859
// add modified versions, since modern Xcodes use this, then the bare
5960
// versions, to accomodate older Xcodes
6061
runtimeIds.push(
61-
...potentialRuntimeIds.map(
62-
(id) => `${SIM_RUNTIME_NAME}${platform}-${id.replace(/\./g, '-')}`,
63-
),
62+
...potentialRuntimeIds.map((id) => `${SIM_RUNTIME_NAME}${platform}-${id.replace(/\./g, '-')}`),
6463
...potentialRuntimeIds,
6564
);
6665
}

0 commit comments

Comments
 (0)