1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const json_file_1 = __importDefault(require("@expo/json-file"));
|
7 | const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));
|
8 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
9 | const path_1 = __importDefault(require("path"));
|
10 | const Errors_1 = require("./Errors");
|
11 | const Modules_1 = require("./Modules");
|
12 | function isUsingYarn(projectRoot) {
|
13 | const workspaceRoot = find_yarn_workspace_root_1.default(projectRoot);
|
14 | if (workspaceRoot) {
|
15 | return fs_extra_1.default.existsSync(path_1.default.join(workspaceRoot, 'yarn.lock'));
|
16 | }
|
17 | else {
|
18 | return fs_extra_1.default.existsSync(path_1.default.join(projectRoot, 'yarn.lock'));
|
19 | }
|
20 | }
|
21 | exports.isUsingYarn = isUsingYarn;
|
22 | function getExpoSDKVersion(projectRoot, exp) {
|
23 | if (exp && exp.sdkVersion) {
|
24 | return exp.sdkVersion;
|
25 | }
|
26 | const packageJsonPath = Modules_1.projectHasModule('expo/package.json', projectRoot, exp);
|
27 | if (packageJsonPath) {
|
28 | const expoPackageJson = json_file_1.default.read(packageJsonPath, { json5: true });
|
29 | const { version: packageVersion } = expoPackageJson;
|
30 | if (typeof packageVersion === 'string') {
|
31 | const majorVersion = packageVersion.split('.').shift();
|
32 | return `${majorVersion}.0.0`;
|
33 | }
|
34 | }
|
35 | throw new Errors_1.ConfigError(`Cannot determine which native SDK version your project uses because the module \`expo\` is not installed. Please install it with \`yarn add expo\` and try again.`, 'MODULE_NOT_FOUND');
|
36 | }
|
37 | exports.getExpoSDKVersion = getExpoSDKVersion;
|
38 |
|
\ | No newline at end of file |