UNPKG

eas-cli

Version:
53 lines (52 loc) 2.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveRuntimeVersionAsync = exports.resolveRuntimeVersionUsingCLIAsync = void 0; const tslib_1 = require("tslib"); const config_plugins_1 = require("@expo/config-plugins"); const projectUtils_1 = require("./projectUtils"); const log_1 = tslib_1.__importDefault(require("../log")); const expoUpdatesCli_1 = require("../utils/expoUpdatesCli"); async function resolveRuntimeVersionUsingCLIAsync({ platform, workflow, projectDir, env, cwd, }) { log_1.default.debug('Using expo-updates runtimeversion:resolve CLI for runtime version resolution'); const useDebugFingerprintSource = log_1.default.isDebug; const extraArgs = useDebugFingerprintSource ? ['--debug'] : []; const resolvedRuntimeVersionJSONResult = await (0, expoUpdatesCli_1.expoUpdatesCommandAsync)(projectDir, ['runtimeversion:resolve', '--platform', platform, '--workflow', workflow, ...extraArgs], { env, cwd }); const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult); log_1.default.debug('runtimeversion:resolve output:'); log_1.default.debug(resolvedRuntimeVersionJSONResult); return { runtimeVersion: runtimeVersionResult.runtimeVersion ?? null, fingerprint: runtimeVersionResult.fingerprintSources ? { fingerprintSources: runtimeVersionResult.fingerprintSources, isDebugFingerprintSource: useDebugFingerprintSource, } : null, fingerprintHash: runtimeVersionResult.fingerprintSources ? runtimeVersionResult.runtimeVersion : null, }; } exports.resolveRuntimeVersionUsingCLIAsync = resolveRuntimeVersionUsingCLIAsync; async function resolveRuntimeVersionAsync({ exp, platform, workflow, projectDir, env, cwd, }) { if (!(await (0, projectUtils_1.isModernExpoUpdatesCLIWithRuntimeVersionCommandSupportedAsync)(projectDir))) { // fall back to the previous behavior (using the @expo/config-plugins eas-cli dependency rather // than the versioned @expo/config-plugins dependency in the project) return { runtimeVersion: await config_plugins_1.Updates.getRuntimeVersionNullableAsync(projectDir, exp, platform), fingerprint: null, fingerprintHash: null, }; } try { return await resolveRuntimeVersionUsingCLIAsync({ platform, workflow, projectDir, env, cwd }); } catch (e) { // if expo-updates is not installed, there's no need for a runtime version in the build if (e instanceof expoUpdatesCli_1.ExpoUpdatesCLIModuleNotFoundError) { return null; } throw e; } } exports.resolveRuntimeVersionAsync = resolveRuntimeVersionAsync;