UNPKG

@johnf/react-native-owl

Version:
140 lines (139 loc) 4.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.xcrunUi = exports.xcrunTerminate = exports.xcrunStatusBar = exports.xcrunRestore = exports.xcrunLaunch = exports.xcrunInstall = void 0; var _path = _interopRequireDefault(require("path")); var _execa = _interopRequireDefault(require("execa")); var _waitFor = require("./wait-for.js"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const xcrunStatusBar = async ({ debug, binaryPath, device, configuration = 'Debug' }) => { const stdio = debug ? 'inherit' : 'ignore'; const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${configuration}-iphonesimulator`; const cwd = binaryPath ? _path.default.dirname(binaryPath) : _path.default.join(process.cwd(), DEFAULT_BINARY_DIR); const simulator = device.replace(/([ /])/g, '\\$1'); const SIMULATOR_TIME = '9:41'; const command = `xcrun simctl status_bar ${simulator} override --time ${SIMULATOR_TIME}`; await _execa.default.command(command, { stdio, cwd }); }; exports.xcrunStatusBar = xcrunStatusBar; const xcrunInstall = async ({ debug, binaryPath, device, scheme, configuration = 'Debug' }) => { const stdio = debug ? 'inherit' : 'ignore'; const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${configuration}-iphonesimulator`; const cwd = binaryPath ? _path.default.dirname(binaryPath) : _path.default.join(process.cwd(), DEFAULT_BINARY_DIR); const appFilename = binaryPath ? _path.default.basename(binaryPath) : `${scheme}.app`; const simulator = device.replace(/([ /])/g, '\\$1'); const command = `xcrun simctl install ${simulator} ${appFilename}`; await _execa.default.command(command, { stdio, cwd }); }; exports.xcrunInstall = xcrunInstall; const xcrunTerminate = async ({ debug, binaryPath, device, scheme, configuration = 'Debug' }) => { const stdio = debug ? 'inherit' : 'ignore'; const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${configuration}-iphonesimulator`; const cwd = binaryPath ? _path.default.dirname(binaryPath) : _path.default.join(process.cwd(), DEFAULT_BINARY_DIR); const appFilename = binaryPath ? _path.default.basename(binaryPath) : `${scheme}.app`; const plistPath = _path.default.join(cwd, appFilename, 'Info.plist'); const { stdout: bundleId } = await _execa.default.command(`./PlistBuddy -c 'Print CFBundleIdentifier' ${plistPath}`, { shell: true, cwd: '/usr/libexec' }); const simulator = device.replace(/([ /])/g, '\\$1'); const command = `xcrun simctl terminate ${simulator} ${bundleId}`; await _execa.default.command(command, { stdio, cwd }); }; exports.xcrunTerminate = xcrunTerminate; const xcrunLaunch = async ({ debug, binaryPath, device, scheme, configuration = 'Debug' }) => { const stdio = debug ? 'inherit' : 'ignore'; const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${configuration}-iphonesimulator`; const cwd = binaryPath ? _path.default.dirname(binaryPath) : _path.default.join(process.cwd(), DEFAULT_BINARY_DIR); const appFilename = binaryPath ? _path.default.basename(binaryPath) : `${scheme}.app`; const plistPath = _path.default.join(cwd, appFilename, 'Info.plist'); const { stdout: bundleId } = await _execa.default.command(`./PlistBuddy -c 'Print CFBundleIdentifier' ${plistPath}`, { shell: true, cwd: '/usr/libexec' }); const simulator = device.replace(/([ /])/g, '\\$1'); const command = `xcrun simctl launch ${simulator} ${bundleId}`; await _execa.default.command(command, { stdio, cwd }); }; exports.xcrunLaunch = xcrunLaunch; const xcrunUi = async ({ debug, binaryPath, device, configuration = 'Debug' }) => { const stdio = debug ? 'inherit' : 'ignore'; const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${configuration}-iphonesimulator`; const cwd = binaryPath ? _path.default.dirname(binaryPath) : _path.default.join(process.cwd(), DEFAULT_BINARY_DIR); const simulator = device.replace(/([ /])/g, '\\$1'); const command = `xcrun simctl ui ${simulator} appearance`; await _execa.default.command(`${command} dark`, { stdio, cwd }); await (0, _waitFor.waitFor)(500); await _execa.default.command(`${command} light`, { stdio, cwd }); await (0, _waitFor.waitFor)(500); }; exports.xcrunUi = xcrunUi; const xcrunRestore = async ({ debug, binaryPath, device, configuration = 'Debug' }) => { const stdio = debug ? 'inherit' : 'ignore'; const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${configuration}-iphonesimulator`; const cwd = binaryPath ? _path.default.dirname(binaryPath) : _path.default.join(process.cwd(), DEFAULT_BINARY_DIR); const simulator = device.replace(/([ /])/g, '\\$1'); const command = `xcrun simctl status_bar ${simulator} clear`; await _execa.default.command(command, { stdio, cwd }); }; exports.xcrunRestore = xcrunRestore; //# sourceMappingURL=xcrun.js.map