@expo/xdl
Version:
The Expo Development Library
83 lines (62 loc) • 2.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getXcodeVersionAsync = getXcodeVersionAsync;
exports.openAppStoreAsync = openAppStoreAsync;
exports.appStoreId = exports.minimumVersion = void 0;
function _spawnAsync() {
const data = _interopRequireDefault(require("@expo/spawn-async"));
_spawnAsync = function () {
return data;
};
return data;
}
function _Logger() {
const data = _interopRequireDefault(require("./Logger"));
_Logger = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Based on the RN docs (Aug 2020).
const minimumVersion = 9.4;
exports.minimumVersion = minimumVersion;
const appStoreId = '497799835';
exports.appStoreId = appStoreId;
async function getXcodeVersionAsync() {
try {
const {
stdout
} = await (0, _spawnAsync().default)('xcodebuild', ['-version']);
const match = stdout.match(/^Xcode (\d+\.\d+)/);
if (match === null || match === void 0 ? void 0 : match.length) {
const last = match.pop(); // Convert to a semver string
if (last) {
return `${last}.0`;
}
return null;
} // not sure what's going on
_Logger().default.global.error('Unable to check Xcode version. Command ran successfully but no version number was found.');
} catch (_unused) {// not installed
}
return null;
}
/**
* Open a link to the App Store. Just link in mobile apps, **never** redirect without prompting first.
*
* @param appId
*/
async function openAppStoreAsync(appId) {
const link = getAppStoreLink(appId);
await (0, _spawnAsync().default)('open', [link]);
}
function getAppStoreLink(appId) {
if (process.platform === 'darwin') {
// TODO: Is there ever a case where the macappstore isn't available on mac?
return `macappstore://itunes.apple.com/app/id${appId}`;
}
return `https://apps.apple.com/us/app/id${appId}`;
}
//# sourceMappingURL=__sourcemaps__/Xcode.js.map