Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Simctl} from './simctl';
import {Simctl} from './simctl.js';
export type {
SimctlOpts,
DeviceInfo,
Expand All @@ -7,7 +7,7 @@ export type {
CertOptions,
XCRun,
AppInfo,
} from './types';
} from './types.js';

export {Simctl};
export default Simctl;
2 changes: 1 addition & 1 deletion lib/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import appiumLogger from '@appium/logger';
import {log as appiumLogger} from '@appium/logger';

export const LOG_PREFIX = 'simctl';

Expand Down
56 changes: 28 additions & 28 deletions lib/simctl.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import which from 'which';
import {log, LOG_PREFIX} from './logger';
import {DEFAULT_EXEC_TIMEOUT, getXcrunBinary} from './helpers';
import {log, LOG_PREFIX} from './logger.js';
import {DEFAULT_EXEC_TIMEOUT, getXcrunBinary} from './helpers.js';
import {exec as tpExec, SubProcess} from 'teen_process';
import * as addmediaCommands from './subcommands/addmedia';
import * as appinfoCommands from './subcommands/appinfo';
import * as bootCommands from './subcommands/boot';
import * as bootstatusCommands from './subcommands/bootstatus';
import * as createCommands from './subcommands/create';
import * as deleteCommands from './subcommands/delete';
import * as eraseCommands from './subcommands/erase';
import * as getappcontainerCommands from './subcommands/get_app_container';
import * as installCommands from './subcommands/install';
import * as ioCommands from './subcommands/io';
import * as keychainCommands from './subcommands/keychain';
import * as launchCommands from './subcommands/launch';
import * as listCommands from './subcommands/list';
import * as openurlCommands from './subcommands/openurl';
import * as pbcopyCommands from './subcommands/pbcopy';
import * as pbpasteCommands from './subcommands/pbpaste';
import * as privacyCommands from './subcommands/privacy';
import * as pushCommands from './subcommands/push';
import * as envCommands from './subcommands/getenv';
import * as shutdownCommands from './subcommands/shutdown';
import * as spawnCommands from './subcommands/spawn';
import * as terminateCommands from './subcommands/terminate';
import * as uiCommands from './subcommands/ui';
import * as uninstallCommands from './subcommands/uninstall';
import * as locationCommands from './subcommands/location';
import type {XCRun, ExecOpts, SimctlOpts, ExecResult} from './types';
import * as addmediaCommands from './subcommands/addmedia.js';
import * as appinfoCommands from './subcommands/appinfo.js';
import * as bootCommands from './subcommands/boot.js';
import * as bootstatusCommands from './subcommands/bootstatus.js';
import * as createCommands from './subcommands/create.js';
import * as deleteCommands from './subcommands/delete.js';
import * as eraseCommands from './subcommands/erase.js';
import * as getappcontainerCommands from './subcommands/get_app_container.js';
import * as installCommands from './subcommands/install.js';
import * as ioCommands from './subcommands/io.js';
import * as keychainCommands from './subcommands/keychain.js';
import * as launchCommands from './subcommands/launch.js';
import * as listCommands from './subcommands/list.js';
import * as openurlCommands from './subcommands/openurl.js';
import * as pbcopyCommands from './subcommands/pbcopy.js';
import * as pbpasteCommands from './subcommands/pbpaste.js';
import * as privacyCommands from './subcommands/privacy.js';
import * as pushCommands from './subcommands/push.js';
import * as envCommands from './subcommands/getenv.js';
import * as shutdownCommands from './subcommands/shutdown.js';
import * as spawnCommands from './subcommands/spawn.js';
import * as terminateCommands from './subcommands/terminate.js';
import * as uiCommands from './subcommands/ui.js';
import * as uninstallCommands from './subcommands/uninstall.js';
import * as locationCommands from './subcommands/location.js';
import type {XCRun, ExecOpts, SimctlOpts, ExecResult} from './types.js';

const SIMCTL_ENV_PREFIX = 'SIMCTL_CHILD_';

Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/addmedia.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';
import type {TeenProcessExecResult} from 'teen_process';

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/subcommands/appinfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Simctl} from '../simctl';
import type {AppInfo} from '../types';
import {convertPlistToJson} from '../helpers';
import type {Simctl} from '../simctl.js';
import type {AppInfo} from '../types.js';
import {convertPlistToJson} from '../helpers.js';

/**
* Get information about an app installed on the simulator
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/boot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {log, LOG_PREFIX} from '../logger';
import type {Simctl} from '../simctl';
import {log, LOG_PREFIX} from '../logger.js';
import type {Simctl} from '../simctl.js';

/**
* Boot the particular Simulator if it is not running.
Expand Down
6 changes: 3 additions & 3 deletions lib/subcommands/bootstatus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {log, LOG_PREFIX} from '../logger';
import {log, LOG_PREFIX} from '../logger.js';
import {waitForCondition} from 'asyncbox';
import type {Simctl} from '../simctl';
import type {BootMonitorOptions} from '../types';
import type {Simctl} from '../simctl.js';
import type {BootMonitorOptions} from '../types.js';
import type {SubProcess} from 'teen_process';

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/subcommands/create.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {log, LOG_PREFIX} from '../logger';
import {log, LOG_PREFIX} from '../logger.js';
import {retryInterval} from 'asyncbox';
import {SIM_RUNTIME_NAME, normalizeVersion} from '../helpers';
import type {Simctl} from '../simctl';
import type {SimCreationOpts} from '../types';
import {SIM_RUNTIME_NAME, normalizeVersion} from '../helpers.js';
import type {Simctl} from '../simctl.js';
import type {SimCreationOpts} from '../types.js';

const SIM_RUNTIME_NAME_SUFFIX_IOS = 'iOS';
const DEFAULT_CREATE_SIMULATOR_TIMEOUT = 10000;
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Delete the particular Simulator from available devices list.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/erase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {retryInterval} from 'asyncbox';
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Reset the content and settings of the particular Simulator.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/get_app_container.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Get the full path to the particular application container
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/getenv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Retrieves the value of a Simulator environment variable
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/install.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Install the particular application package on Simulator.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {randomUUID} from 'node:crypto';
import path from 'node:path';
import os from 'node:os';
import fs from 'node:fs/promises';
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Gets base64 screenshot for device
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/keychain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import fs from 'node:fs/promises';
import {randomUUID} from 'node:crypto';
import path from 'node:path';
import {rimraf} from 'rimraf';
import type {Simctl} from '../simctl';
import type {CertOptions} from '../types';
import type {Simctl} from '../simctl.js';
import type {CertOptions} from '../types.js';

/**
* Adds the given certificate to the Trusted Root Store on the simulator
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/launch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {retryInterval} from 'asyncbox';
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Execute the particular application package on Simulator.
Expand Down
8 changes: 4 additions & 4 deletions lib/subcommands/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {SIM_RUNTIME_NAME, normalizeVersion} from '../helpers';
import {log, LOG_PREFIX} from '../logger';
import type {Simctl} from '../simctl';
import type {DeviceInfo} from '../types';
import {SIM_RUNTIME_NAME, normalizeVersion} from '../helpers.js';
import {log, LOG_PREFIX} from '../logger.js';
import type {Simctl} from '../simctl.js';
import type {DeviceInfo} from '../types.js';

/**
* Parse the list of existing Simulator devices to represent
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/location.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Set the Simulator location to a specific latitude and longitude.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/openurl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';
import type {TeenProcessExecResult} from 'teen_process';

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/pbcopy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';
import type {SubProcess} from 'teen_process';

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/pbpaste.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Get the content of Simulator pasteboard.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/privacy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Grants the given permission on the app with the given bundle identifier
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {randomUUID} from 'node:crypto';
import path from 'node:path';
import os from 'node:os';
import fs from 'node:fs/promises';
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Send a simulated push notification
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/shutdown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {log, LOG_PREFIX} from '../logger';
import type {Simctl} from '../simctl';
import {log, LOG_PREFIX} from '../logger.js';
import type {Simctl} from '../simctl.js';

/**
* Shutdown the given Simulator if it is running.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';
import type {TeenProcessExecResult, SubProcess} from 'teen_process';

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/terminate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Terminate the given running application on Simulator.
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/ui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Retrieves the current UI appearance value from the given simulator
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/uninstall.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Simctl} from '../simctl';
import type {Simctl} from '../simctl.js';

/**
* Remove the particular application package from Simulator.
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"format": "prettier -w ./lib ./test",
"format:check": "prettier --check ./lib ./test",
"prepare": "npm run build",
"test": "node --test --test-timeout=60000 \"./build/test/unit/**/*.spec.js\"",
"e2e-test": "node --test --test-force-exit --test-concurrency=1 --test-timeout=300000 \"./build/test/e2e/**/*.spec.js\""
"test": "node --enable-source-maps --test --test-timeout=60000 \"./build/test/unit/**/*.spec.js\"",
"e2e-test": "node --enable-source-maps --test --test-force-exit --test-concurrency=1 --test-timeout=300000 \"./build/test/e2e/**/*.spec.js\""
},
"prettier": {
"bracketSpacing": false,
Expand Down Expand Up @@ -77,5 +77,13 @@
"sinon": "^22.0.0",
"typescript": "^6.0.2"
},
"types": "./build/lib/index.d.ts"
"types": "./build/lib/index.d.ts",
"type": "module",
"exports": {
".": {
"types": "./build/lib/index.d.ts",
"import": "./build/lib/index.js"
},
"./package.json": "./package.json"
}
}
2 changes: 1 addition & 1 deletion test/e2e/simctl-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Simctl} from '../../lib/simctl';
import {Simctl} from '../../lib/simctl.js';
import {rimraf} from 'rimraf';
import {randomUUID} from 'node:crypto';
import path from 'node:path';
Expand Down
5 changes: 3 additions & 2 deletions test/unit/simctl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sinon from 'sinon';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {expect, use} from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {Simctl} from '../../lib/simctl';
import {Simctl} from '../../lib/simctl.js';
import {describe, it, beforeEach, afterEach, after} from 'node:test';

use(chaiAsPromised);
Expand Down Expand Up @@ -321,7 +322,7 @@ describe('simctl', function () {
});

function getModuleRootSync(): string {
let currentDir = path.dirname(path.resolve(__filename));
let currentDir = path.dirname(fileURLToPath(import.meta.url));
let isAtFsRoot = false;
while (!isAtFsRoot) {
const manifestPath = path.join(currentDir, 'package.json');
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"esModuleInterop": true,
"outDir": "build",
"types": ["node"],
"strict": true
"strict": true,
"module": "NodeNext",
"moduleResolution": "NodeNext"
},
"include": [
"lib",
Expand Down