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
1 change: 1 addition & 0 deletions lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function convertPlistToJson(plistInput: string): Promise<any> {
plutilProcess.kill(9);
throw new Error(
`Failed to convert plist to JSON: ${err instanceof Error ? err.message : String(err)}`,
{cause: err},
);
} finally {
plutilProcess.removeAllListeners();
Expand Down
10 changes: 1 addition & 9 deletions lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,4 @@ import appiumLogger from '@appium/logger';

export const LOG_PREFIX = 'simctl';

function getLogger() {
const logger = global._global_npmlog || appiumLogger;
if (!logger.debug) {
logger.addLevel('debug', 1000, {fg: 'blue', bg: 'black'}, 'dbug');
}
return logger;
}

export const log = getLogger();
export const log = appiumLogger;
1 change: 1 addition & 0 deletions lib/subcommands/appinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function appInfo(this: Simctl, bundleId: string): Promise<AppInfo>
} catch (err) {
throw new Error(
`Cannot retrieve app info for ${bundleId}: ${err instanceof Error ? err.message : String(err)}`,
{cause: err},
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/bootstatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {log} from '../logger';
import {log, LOG_PREFIX} from '../logger';
import {waitForCondition} from 'asyncbox';
import type {Simctl} from '../simctl';
import type {BootMonitorOptions} from '../types';
Expand Down Expand Up @@ -79,7 +79,7 @@ export async function startBootMonitor(
try {
await bootMonitor.stop();
} catch (e: any) {
log.warn(e.message);
log.warn(LOG_PREFIX, e.message);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/subcommands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function createDevice(
try {
runtimeId = await this.getRuntimeForPlatformVersion(platformVersion, platform);
} catch {
log.warn(`Unable to find runtime for iOS '${platformVersion}'. Continuing`);
log.warn(LOG_PREFIX, `Unable to find runtime for iOS '${platformVersion}'. Continuing`);
runtimeId = platformVersion;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/subcommands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export async function getDeviceTypes(this: Simctl): Promise<string[]> {
const deviceTypes = JSON.parse(stdout.trim());
return deviceTypes.devicetypes.map((type: any) => type.name);
} catch (err: any) {
throw new Error(`Unable to get list of device types: ${err.message}`);
throw new Error(`Unable to get list of device types: ${err.message}`, {cause: err});
}
}

Expand Down Expand Up @@ -313,7 +313,7 @@ export async function list(this: Simctl): Promise<any> {
try {
return JSON.parse(stdout.trim());
} catch (e: any) {
throw new Error(`Unable to parse simctl list: ${e.message}`);
throw new Error(`Unable to parse simctl list: ${e.message}`, {cause: e});
}
}

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@
"@appium/types": "^1.0.0-rc.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/chai": "^5.2.3",
"@types/chai-as-promised": "^8.0.2",
"@types/mocha": "^10.0.1",
"@types/node": "^25.0.0",
"@types/semver": "^7.7.1",
"@types/sinon": "^21.0.1",
"@types/which": "^3.0.4",
"appium-xcode": "^6.0.0",
"chai": "^6.0.0",
"chai-as-promised": "^8.0.0",
Expand Down
11 changes: 7 additions & 4 deletions test/e2e/simctl-e2e-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,15 @@ describe('simctl', function () {
expect(fullList.devicetypes.length).to.be.above(1);
// at least one type, no matter the version of Xcode, should be an iPhone
expect(
fullList.devicetypes.filter((el) => el.identifier.includes('iPhone')).length,
fullList.devicetypes.filter((el: {identifier: string}) =>
el.identifier.includes('iPhone'),
).length,
).to.be.above(0);
// at least one runtime should be iOS
expect(fullList.runtimes.filter((el) => el.identifier.includes('iOS')).length).to.be.above(
0,
);
expect(
fullList.runtimes.filter((el: {identifier: string}) => el.identifier.includes('iOS'))
.length,
).to.be.above(0);
});
});

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"compilerOptions": {
"esModuleInterop": true,
"outDir": "build",
"types": ["node", "mocha"]
"types": ["node", "mocha"],
"strict": true
},
"ts-node": {
"transpileOnly": true,
Expand Down
Loading