eas-cli
Version:
EAS command line tool
83 lines (82 loc) • 3.69 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateSystemRequirementsAsync = void 0;
const tslib_1 = require("tslib");
const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const semver_1 = tslib_1.__importDefault(require("semver"));
const simulator_1 = require("./simulator");
const xcode = tslib_1.__importStar(require("./xcode"));
const xcrun_1 = require("./xcrun");
const log_1 = tslib_1.__importDefault(require("../../log"));
const prompts_1 = require("../../prompts");
function assertPlatform() {
if (process.platform !== 'darwin') {
log_1.default.error('iOS simulator apps can only be run on macOS devices.');
throw Error('iOS simulator apps can only be run on macOS devices.');
}
}
async function assertCorrectXcodeVersionInstalledAsync() {
const xcodeVersion = await xcode.getXcodeVersionAsync();
if (!xcodeVersion) {
const { goToAppStore } = await (0, prompts_1.promptAsync)({
type: 'select',
message: 'Xcode needs to be installed, would you like to continue to the App Store?',
name: 'goToAppStore',
choices: [
{ title: 'Yes', value: true },
{ title: 'No', value: false },
],
});
if (goToAppStore) {
await xcode.openAppStoreAsync(xcode.APP_STORE_ID);
}
throw Error('Please try again once Xcode is installed');
}
if (semver_1.default.lt(xcodeVersion, xcode.MIN_XCODE_VERSION)) {
throw Error(`Xcode version ${chalk_1.default.bold(xcodeVersion)} is too old. Please upgrade to version ${chalk_1.default.bold(xcode.MIN_XCODE_VERSION)} or higher.`);
}
}
async function ensureXcrunInstalledAsync() {
if (!(await (0, xcrun_1.isXcrunInstalledAsync)())) {
const { installXcrun } = await (0, prompts_1.promptAsync)({
type: 'select',
message: 'Xcode Command Line Tools need to be installed, continue?',
name: 'installXcrun',
choices: [
{ title: 'Yes', value: true },
{ title: 'No', value: false },
],
});
if (installXcrun) {
await (0, xcrun_1.installXcrunAsync)();
return;
}
throw Error('Please try again once Xcode Command Line Tools are installed');
}
}
async function assertSimulatorAppInstalledAsync() {
const simulatorAppId = await (0, simulator_1.getSimulatorAppIdAsync)();
if (!simulatorAppId) {
throw new Error(`Can't determine id of Simulator app; the Simulator is most likely not installed on this machine. Run 'sudo xcode-select -s /Applications/Xcode.app'`);
}
if (simulatorAppId !== 'com.apple.iphonesimulator' &&
simulatorAppId !== 'com.apple.CoreSimulator.SimulatorTrampoline') {
throw new Error(`Simulator is installed but is identified as '${simulatorAppId}', can't recognize what that is`);
}
try {
// make sure we can run simctl
await (0, spawn_async_1.default)('xcrun', ['simctl', 'help']);
}
catch (error) {
log_1.default.warn(`Unable to run simctl:\n${error.toString()}`);
throw new Error('xcrun is not configured correctly. Ensure `sudo xcode-select --reset` works before running this command again.');
}
}
async function validateSystemRequirementsAsync() {
assertPlatform();
await assertCorrectXcodeVersionInstalledAsync();
await ensureXcrunInstalledAsync();
await assertSimulatorAppInstalledAsync();
}
exports.validateSystemRequirementsAsync = validateSystemRequirementsAsync;
;