@expo/cli 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +2 -2
- package/build/src/api/rest/client.js +29 -18
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithOffline.js +2 -2
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
- package/build/src/api/settings.js +14 -5
- package/build/src/api/settings.js.map +1 -1
- package/build/src/api/user/actions.js +5 -0
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/api/user/user.js +2 -2
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/register/registerAsync.js +3 -0
- package/build/src/register/registerAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +8 -4
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +25 -8
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +2 -2
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/index.js +18 -11
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/interface/commandsTable.js +12 -0
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +7 -2
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +9 -0
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +7 -6
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/resolveOptions.js +17 -33
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +1 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +22 -0
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +3 -3
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +2 -2
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +6 -3
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/device.js +19 -0
- package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/index.js +1 -1
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +22 -7
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +1 -1
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -7
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ContextModuleSourceMapsMiddleware.js +27 -0
- package/build/src/start/server/middleware/ContextModuleSourceMapsMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +2 -2
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +4 -4
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/type-generation/{index.js → startTypescriptTypeGeneration.js} +13 -12
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +3 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/utils/analytics/getDevClientProperties.js +6 -0
- package/build/src/utils/analytics/getDevClientProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/ansi.js.map +1 -1
- package/build/src/utils/codesigning.js +4 -3
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/env.js +5 -5
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/mergeGitIgnorePaths.js +3 -3
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +21 -19
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/package.json +7 -7
- package/build/src/start/server/type-generation/index.js.map +0 -1
package/build/bin/cli
CHANGED
|
@@ -132,7 +132,7 @@ const args = (0, _arg).default({
|
|
|
132
132
|
});
|
|
133
133
|
if (args["--version"]) {
|
|
134
134
|
// Version is added in the build script.
|
|
135
|
-
console.log("0.
|
|
135
|
+
console.log("0.10.0");
|
|
136
136
|
process.exit(0);
|
|
137
137
|
}
|
|
138
138
|
if (args["--non-interactive"]) {
|
|
@@ -262,7 +262,7 @@ commands[command]().then((exec)=>{
|
|
|
262
262
|
logEventAsync("action", {
|
|
263
263
|
action: `expo ${command}`,
|
|
264
264
|
source: "expo/cli",
|
|
265
|
-
source_version: "0.
|
|
265
|
+
source_version: "0.10.0"
|
|
266
266
|
});
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -9,7 +9,9 @@ var _getUserState = require("@expo/config/build/getUserState");
|
|
|
9
9
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _env = require("../../utils/env");
|
|
12
|
+
var _errors = require("../../utils/errors");
|
|
12
13
|
var _endpoint = require("../endpoint");
|
|
14
|
+
var _settings = require("../settings");
|
|
13
15
|
var _userSettings = _interopRequireDefault(require("../user/UserSettings"));
|
|
14
16
|
var _fileSystemCache = require("./cache/FileSystemCache");
|
|
15
17
|
var _wrapFetchWithCache = require("./cache/wrapFetchWithCache");
|
|
@@ -55,27 +57,36 @@ function wrapFetchWithCredentials(fetchFunction) {
|
|
|
55
57
|
resolvedHeaders["expo-session"] = sessionSecret;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
try {
|
|
61
|
+
const results = await fetchFunction(url, {
|
|
62
|
+
...options,
|
|
63
|
+
headers: resolvedHeaders
|
|
64
|
+
});
|
|
65
|
+
if (results.status >= 400 && results.status < 500) {
|
|
66
|
+
const body = await results.text();
|
|
67
|
+
try {
|
|
68
|
+
var ref1;
|
|
69
|
+
const data = JSON.parse(body);
|
|
70
|
+
if (data == null ? void 0 : (ref1 = data.errors) == null ? void 0 : ref1.length) {
|
|
71
|
+
throw new ApiV2Error(data.errors[0]);
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// Server returned non-json response.
|
|
75
|
+
if (error.message.includes("in JSON at position")) {
|
|
76
|
+
throw new UnexpectedServerError(body);
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
69
79
|
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
// Server returned non-json response.
|
|
72
|
-
if (error.message.includes("in JSON at position")) {
|
|
73
|
-
throw new UnexpectedServerError(body);
|
|
74
|
-
}
|
|
75
|
-
throw error;
|
|
76
80
|
}
|
|
81
|
+
return results;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
// Specifically, when running `npx expo start` and the wifi is connected but not really (public wifi, airplanes, etc).
|
|
84
|
+
if ("code" in error && error.code === "ENOTFOUND") {
|
|
85
|
+
(0, _settings).disableNetwork();
|
|
86
|
+
throw new _errors.CommandError("OFFLINE", "Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.");
|
|
87
|
+
}
|
|
88
|
+
throw error;
|
|
77
89
|
}
|
|
78
|
-
return results;
|
|
79
90
|
};
|
|
80
91
|
}
|
|
81
92
|
const fetchWithOffline = (0, _wrapFetchWithOffline).wrapFetchWithOffline(_nodeFetch.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport { JSONValue } from '@expo/json-file';\nimport fetchInstance from 'node-fetch';\nimport path from 'path';\n\nimport { env } from '../../utils/env';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport UserSettings from '../user/UserSettings';\nimport { FileSystemCache } from './cache/FileSystemCache';\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = UserSettings.getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = UserSettings.getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n const results = await fetchFunction(url, {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport { JSONValue } from '@expo/json-file';\nimport fetchInstance from 'node-fetch';\nimport path from 'path';\n\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport UserSettings from '../user/UserSettings';\nimport { FileSystemCache } from './cache/FileSystemCache';\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = UserSettings.getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = UserSettings.getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const results = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n if (results.status >= 400 && results.status < 500) {\n const body = await results.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n return results;\n } catch (error: any) {\n // Specifically, when running `npx expo start` and the wifi is connected but not really (public wifi, airplanes, etc).\n if ('code' in error && error.code === 'ENOTFOUND') {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetchInstance);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["wrapFetchWithCredentials","createCachedFetch","ApiV2Error","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","UnexpectedServerError","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","UserSettings","getAccessToken","authorization","sessionSecret","getSession","results","status","body","text","data","JSON","parse","errors","length","error","includes","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","fetchInstance","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","fetch","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","wrapFetchWithCache","FileSystemCache","path","join","getExpoHomeDirectory","fetchAsync"],"mappings":"AAAA;;;;QAqDgBA,wBAAwB,GAAxBA,wBAAwB;QAoExBC,iBAAiB,GAAjBA,iBAAiB;;AAzHI,IAAA,aAAiC,WAAjC,iCAAiC,CAAA;AAE5C,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACrB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEH,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACf,IAAA,SAAa,WAAb,aAAa,CAAA;AAChB,IAAA,SAAa,WAAb,aAAa,CAAA;AACnB,IAAA,aAAsB,kCAAtB,sBAAsB,EAAA;AACf,IAAA,gBAAyB,WAAzB,yB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CAACC,CAAAA,GAAAA,aAAoB,AAAE,CAAA,qBAAF,EAAE,EAAEV,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;CACH;AAGM,MAAMU,UAAU,GAAGb,CAAAA,GAAAA,sBAAqB,AAA0C,CAAA,sBAA1C,CAACpD,wBAAwB,CAACkD,cAAc,CAAC,CAAC,AAAC;QAA7Ee,UAAU,GAAVA,UAAU"}
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.wrapFetchWithOffline = wrapFetchWithOffline;
|
|
6
|
-
var
|
|
6
|
+
var _env = require("../../utils/env");
|
|
7
7
|
const debug = require("debug")("expo:api:fetch:offline");
|
|
8
8
|
function wrapFetchWithOffline(fetchFunction) {
|
|
9
9
|
// NOTE(EvanBacon): DO NOT RETURN AN ASYNC WRAPPER. THIS BREAKS LOADING INDICATORS.
|
|
10
10
|
return function fetchWithOffline(url, options = {}) {
|
|
11
|
-
if (
|
|
11
|
+
if (_env.env.EXPO_OFFLINE) {
|
|
12
12
|
debug("Skipping network request: " + url);
|
|
13
13
|
options.timeout = 1;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/rest/wrapFetchWithOffline.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/rest/wrapFetchWithOffline.ts"],"sourcesContent":["import { env } from '../../utils/env';\nimport { FetchLike } from './client.types';\n\nconst debug = require('debug')('expo:api:fetch:offline') as typeof console.log;\n\n/** Wrap fetch with support for `EXPO_OFFLINE` to disable network requests. */\nexport function wrapFetchWithOffline(fetchFunction: FetchLike): FetchLike {\n // NOTE(EvanBacon): DO NOT RETURN AN ASYNC WRAPPER. THIS BREAKS LOADING INDICATORS.\n return function fetchWithOffline(url, options = {}) {\n if (env.EXPO_OFFLINE) {\n debug('Skipping network request: ' + url);\n options.timeout = 1;\n }\n return fetchFunction(url, options);\n };\n}\n"],"names":["wrapFetchWithOffline","debug","require","fetchFunction","fetchWithOffline","url","options","env","EXPO_OFFLINE","timeout"],"mappings":"AAAA;;;;QAMgBA,oBAAoB,GAApBA,oBAAoB;AANhB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAGrC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,AAAsB,AAAC;AAGxE,SAASF,oBAAoB,CAACG,aAAwB,EAAa;IACxE,mFAAmF;IACnF,OAAO,SAASC,gBAAgB,CAACC,GAAG,EAAEC,OAAO,GAAG,EAAE,EAAE;QAClD,IAAIC,IAAG,IAAA,CAACC,YAAY,EAAE;YACpBP,KAAK,CAAC,4BAA4B,GAAGI,GAAG,CAAC,CAAC;YAC1CC,OAAO,CAACG,OAAO,GAAG,CAAC,CAAC;SACrB;QACD,OAAON,aAAa,CAACE,GAAG,EAAEC,OAAO,CAAC,CAAC;KACpC,CAAC;CACH"}
|
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
exports.disableNetwork = disableNetwork;
|
|
6
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
7
|
+
var _log = require("../log");
|
|
8
|
+
var _env = require("../utils/env");
|
|
9
|
+
function _interopRequireDefault(obj) {
|
|
10
|
+
return obj && obj.__esModule ? obj : {
|
|
11
|
+
default: obj
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function disableNetwork() {
|
|
15
|
+
if (_env.env.EXPO_OFFLINE) return;
|
|
16
|
+
process.env.EXPO_OFFLINE = "1";
|
|
17
|
+
_log.Log.log(_chalk.default.gray("Networking has been disabled"));
|
|
18
|
+
}
|
|
10
19
|
|
|
11
20
|
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/settings.ts"],"sourcesContent":["// This file represents temporary globals for the CLI when using the API.\n// Settings should be as minimal as possible since they are globals.\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/api/settings.ts"],"sourcesContent":["// This file represents temporary globals for the CLI when using the API.\n// Settings should be as minimal as possible since they are globals.\nimport chalk from 'chalk';\n\nimport { Log } from '../log';\nimport { env } from '../utils/env';\n\nexport function disableNetwork() {\n if (env.EXPO_OFFLINE) return;\n process.env.EXPO_OFFLINE = '1';\n Log.log(chalk.gray('Networking has been disabled'));\n}\n"],"names":["disableNetwork","env","EXPO_OFFLINE","process","Log","log","chalk","gray"],"mappings":"AAEA;;;;QAKgBA,cAAc,GAAdA,cAAc;AALZ,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEL,IAAA,IAAQ,WAAR,QAAQ,CAAA;AACR,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAE3B,SAASA,cAAc,GAAG;IAC/B,IAAIC,IAAG,IAAA,CAACC,YAAY,EAAE,OAAO;IAC7BC,OAAO,CAACF,GAAG,CAACC,YAAY,GAAG,GAAG,CAAC;IAC/BE,IAAG,IAAA,CAACC,GAAG,CAACC,MAAK,QAAA,CAACC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;CACrD"}
|
|
@@ -7,6 +7,8 @@ exports.ensureLoggedInAsync = ensureLoggedInAsync;
|
|
|
7
7
|
var _assert = _interopRequireDefault(require("assert"));
|
|
8
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
9
|
var Log = _interopRequireWildcard(require("../../log"));
|
|
10
|
+
var _env = require("../../utils/env");
|
|
11
|
+
var _errors = require("../../utils/errors");
|
|
10
12
|
var _link = require("../../utils/link");
|
|
11
13
|
var _prompts = _interopRequireDefault(require("../../utils/prompts"));
|
|
12
14
|
var _client = require("../rest/client");
|
|
@@ -39,6 +41,9 @@ function _interopRequireWildcard(obj) {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
async function showLoginPromptAsync({ printNewLine =false , otp , ...options } = {}) {
|
|
44
|
+
if (_env.env.EXPO_OFFLINE) {
|
|
45
|
+
throw new _errors.CommandError("OFFLINE", "Cannot authenticate in offline-mode");
|
|
46
|
+
}
|
|
42
47
|
const hasCredentials = options.username && options.password;
|
|
43
48
|
if (printNewLine) {
|
|
44
49
|
Log.log();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport * as Log from '../../log';\nimport { learnMore } from '../../utils/link';\nimport promptAsync, { Question } from '../../utils/prompts';\nimport { ApiV2Error } from '../rest/client';\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport { Actor, getUserAsync, loginAsync } from './user';\n\n/** Show login prompt while prompting for missing credentials. */\nexport async function showLoginPromptAsync({\n printNewLine = false,\n otp,\n ...options\n}: {\n printNewLine?: boolean;\n username?: string;\n password?: string;\n otp?: string;\n} = {}): Promise<void> {\n const hasCredentials = options.username && options.password;\n\n if (printNewLine) {\n Log.log();\n }\n\n Log.log(hasCredentials ? 'Logging in to EAS' : 'Log in to EAS');\n\n let username = options.username;\n let password = options.password;\n\n if (!hasCredentials) {\n const resolved = await promptAsync(\n [\n !options.username && {\n type: 'text',\n name: 'username',\n message: 'Email or username',\n },\n !options.password && {\n type: 'password',\n name: 'password',\n message: 'Password',\n },\n ].filter(Boolean) as Question<string>[],\n {\n nonInteractiveHelp: `Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`,\n }\n );\n username ??= resolved.username;\n password ??= resolved.password;\n }\n // This is just for the types.\n assert(username && password);\n\n try {\n await loginAsync({\n username,\n password,\n otp,\n });\n } catch (e) {\n if (e instanceof ApiV2Error && e.expoApiV2ErrorCode === 'ONE_TIME_PASSWORD_REQUIRED') {\n await retryUsernamePasswordAuthWithOTPAsync(\n username,\n password,\n e.expoApiV2ErrorMetadata as any\n );\n } else {\n throw e;\n }\n }\n}\n\n/** Ensure the user is logged in, if not, prompt to login. */\nexport async function ensureLoggedInAsync(): Promise<Actor> {\n let user = await getUserAsync().catch(() => null);\n\n if (!user) {\n Log.warn(chalk.yellow`An Expo user account is required to proceed.`);\n await showLoginPromptAsync({ printNewLine: true });\n user = await getUserAsync();\n }\n\n assert(user, 'User should be logged in');\n return user;\n}\n"],"names":["showLoginPromptAsync","ensureLoggedInAsync","Log","printNewLine","otp","options","hasCredentials","username","password","log","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","warn","chalk","yellow"],"mappings":"AAAA;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport promptAsync, { Question } from '../../utils/prompts';\nimport { ApiV2Error } from '../rest/client';\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport { Actor, getUserAsync, loginAsync } from './user';\n\n/** Show login prompt while prompting for missing credentials. */\nexport async function showLoginPromptAsync({\n printNewLine = false,\n otp,\n ...options\n}: {\n printNewLine?: boolean;\n username?: string;\n password?: string;\n otp?: string;\n} = {}): Promise<void> {\n if (env.EXPO_OFFLINE) {\n throw new CommandError('OFFLINE', 'Cannot authenticate in offline-mode');\n }\n const hasCredentials = options.username && options.password;\n\n if (printNewLine) {\n Log.log();\n }\n\n Log.log(hasCredentials ? 'Logging in to EAS' : 'Log in to EAS');\n\n let username = options.username;\n let password = options.password;\n\n if (!hasCredentials) {\n const resolved = await promptAsync(\n [\n !options.username && {\n type: 'text',\n name: 'username',\n message: 'Email or username',\n },\n !options.password && {\n type: 'password',\n name: 'password',\n message: 'Password',\n },\n ].filter(Boolean) as Question<string>[],\n {\n nonInteractiveHelp: `Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`,\n }\n );\n username ??= resolved.username;\n password ??= resolved.password;\n }\n // This is just for the types.\n assert(username && password);\n\n try {\n await loginAsync({\n username,\n password,\n otp,\n });\n } catch (e) {\n if (e instanceof ApiV2Error && e.expoApiV2ErrorCode === 'ONE_TIME_PASSWORD_REQUIRED') {\n await retryUsernamePasswordAuthWithOTPAsync(\n username,\n password,\n e.expoApiV2ErrorMetadata as any\n );\n } else {\n throw e;\n }\n }\n}\n\n/** Ensure the user is logged in, if not, prompt to login. */\nexport async function ensureLoggedInAsync(): Promise<Actor> {\n let user = await getUserAsync().catch(() => null);\n\n if (!user) {\n Log.warn(chalk.yellow`An Expo user account is required to proceed.`);\n await showLoginPromptAsync({ printNewLine: true });\n user = await getUserAsync();\n }\n\n assert(user, 'User should be logged in');\n return user;\n}\n"],"names":["showLoginPromptAsync","ensureLoggedInAsync","Log","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","log","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","warn","chalk","yellow"],"mappings":"AAAA;;;;QAasBA,oBAAoB,GAApBA,oBAAoB;QAsEpBC,mBAAmB,GAAnBA,mBAAmB;AAnFtB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACK,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACvB,IAAA,KAAkB,WAAlB,kBAAkB,CAA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IAAI,EAAE,0BAA0B,CAAC,CAAC;IACzC,OAAOA,IAAI,CAAC;CACb"}
|
|
@@ -12,10 +12,10 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
|
12
12
|
var Log = _interopRequireWildcard(require("../../log"));
|
|
13
13
|
var Analytics = _interopRequireWildcard(require("../../utils/analytics/rudderstackClient"));
|
|
14
14
|
var _codesigning = require("../../utils/codesigning");
|
|
15
|
+
var _env = require("../../utils/env");
|
|
15
16
|
var _client = require("../graphql/client");
|
|
16
17
|
var _userQuery = require("../graphql/queries/UserQuery");
|
|
17
18
|
var _client1 = require("../rest/client");
|
|
18
|
-
var _settings = require("../settings");
|
|
19
19
|
var _userSettings = _interopRequireDefault(require("./UserSettings"));
|
|
20
20
|
function _interopRequireDefault(obj) {
|
|
21
21
|
return obj && obj.__esModule ? obj : {
|
|
@@ -59,7 +59,7 @@ function getActorDisplayName(user) {
|
|
|
59
59
|
async function getUserAsync() {
|
|
60
60
|
var ref;
|
|
61
61
|
const hasCredentials = _userSettings.default.getAccessToken() || ((ref = _userSettings.default.getSession()) == null ? void 0 : ref.sessionSecret);
|
|
62
|
-
if (!
|
|
62
|
+
if (!_env.env.EXPO_OFFLINE && !currentUser && hasCredentials) {
|
|
63
63
|
const user = await _userQuery.UserQuery.currentUserAsync();
|
|
64
64
|
currentUser = user != null ? user : undefined;
|
|
65
65
|
if (user) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport gql from 'graphql-tag';\n\nimport { CurrentUserQuery } from '../../graphql/generated';\nimport * as Log from '../../log';\nimport * as Analytics from '../../utils/analytics/rudderstackClient';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport gql from 'graphql-tag';\n\nimport { CurrentUserQuery } from '../../graphql/generated';\nimport * as Log from '../../log';\nimport * as Analytics from '../../utils/analytics/rudderstackClient';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { graphqlClient } from '../graphql/client';\nimport { UserQuery } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\nimport UserSettings from './UserSettings';\n\nexport type Actor = NonNullable<CurrentUserQuery['meActor']>;\n\nlet currentUser: Actor | undefined;\n\nexport const ANONYMOUS_USERNAME = 'anonymous';\n\n/**\n * Resolve the name of the actor, either normal user or robot user.\n * This should be used whenever the \"current user\" needs to be displayed.\n * The display name CANNOT be used as project owner.\n */\nexport function getActorDisplayName(user?: Actor): string {\n switch (user?.__typename) {\n case 'User':\n return user.username;\n case 'Robot':\n return user.firstName ? `${user.firstName} (robot)` : 'robot';\n default:\n return ANONYMOUS_USERNAME;\n }\n}\n\nexport async function getUserAsync(): Promise<Actor | undefined> {\n const hasCredentials = UserSettings.getAccessToken() || UserSettings.getSession()?.sessionSecret;\n if (!env.EXPO_OFFLINE && !currentUser && hasCredentials) {\n const user = await UserQuery.currentUserAsync();\n currentUser = user ?? undefined;\n if (user) {\n await Analytics.setUserDataAsync(user.id, {\n username: getActorDisplayName(user),\n user_id: user.id,\n user_type: user.__typename,\n });\n }\n }\n return currentUser;\n}\n\nexport async function loginAsync(json: {\n username: string;\n password: string;\n otp?: string;\n}): Promise<void> {\n const res = await fetchAsync('auth/loginAsync', {\n method: 'POST',\n body: JSON.stringify(json),\n });\n const {\n data: { sessionSecret },\n } = await res.json();\n const result = await graphqlClient\n .query(\n gql`\n query UserQuery {\n viewer {\n id\n username\n }\n }\n `,\n {},\n {\n fetchOptions: {\n headers: {\n 'expo-session': sessionSecret,\n },\n },\n additionalTypenames: [] /* UserQuery has immutable fields */,\n }\n )\n .toPromise();\n const {\n data: { viewer },\n } = result;\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: viewer.id,\n username: viewer.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function logoutAsync(): Promise<void> {\n currentUser = undefined;\n await Promise.all([\n fs.rm(getDevelopmentCodeSigningDirectory(), { recursive: true, force: true }),\n UserSettings.setSessionAsync(undefined),\n ]);\n Log.log('Logged out');\n}\n"],"names":["getActorDisplayName","getUserAsync","loginAsync","logoutAsync","Log","Analytics","currentUser","ANONYMOUS_USERNAME","user","__typename","username","firstName","UserSettings","hasCredentials","getAccessToken","getSession","sessionSecret","env","EXPO_OFFLINE","UserQuery","currentUserAsync","undefined","setUserDataAsync","id","user_id","user_type","json","res","fetchAsync","method","body","JSON","stringify","data","result","graphqlClient","query","gql","fetchOptions","headers","additionalTypenames","toPromise","viewer","setSessionAsync","userId","currentConnection","Promise","all","fs","rm","getDevelopmentCodeSigningDirectory","recursive","force","log"],"mappings":"AAAA;;;;QAwBgBA,mBAAmB,GAAnBA,mBAAmB;QAWbC,YAAY,GAAZA,YAAY;QAgBZC,UAAU,GAAVA,UAAU;QA4CVC,WAAW,GAAXA,WAAW;;AA/FF,IAAA,GAAI,WAAJ,IAAI,CAAA;AACnB,IAAA,WAAa,kCAAb,aAAa,EAAA;AAGjBC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACHC,IAAAA,SAAS,mCAAM,yCAAyC,EAA/C;AAC8B,IAAA,YAAyB,WAAzB,yBAAyB,CAAA;AACxD,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACP,IAAA,OAAmB,WAAnB,mBAAmB,CAAA;AACvB,IAAA,UAA8B,WAA9B,8BAA8B,CAAA;AAC7B,IAAA,QAAgB,WAAhB,gBAAgB,CAAA;AAClB,IAAA,aAAgB,kCAAhB,gBAAgB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIzC,IAAIC,WAAW,AAAmB,AAAC;AAE5B,MAAMC,kBAAkB,GAAG,WAAW,AAAC;QAAjCA,kBAAkB,GAAlBA,kBAAkB;AAOxB,SAASP,mBAAmB,CAACQ,IAAY,EAAU;IACxD,OAA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C;KAC3B,CAAC,AAAC;IACH,MAAM,EACJO,IAAI,EAAE,EAAEjB,aAAa,CAAA,EAAE,CAAA,IACxB,GAAG,MAAMW,GAAG,CAACD,IAAI,EAAE,AAAC;IACrB,MAAMQ,MAAM,GAAG,MAAMC,OAAa,cAAA,CAC/BC,KAAK,CACJC,WAAG,QAAA,CAAC;;;;;;;MAOJ,CAAC,EACD,EAAE,EACF;QACEC,YAAY,EAAE;YACZC,OAAO,EAAE;gBACP,cAAc,EAAEvB,aAAa;aAC9B;SACF;QACDwB,mBAAmB,EAAE,EAAE;KACxB,CACF,CACAC,SAAS,EAAE,AAAC;IACf,MAAM,EACJR,IAAI,EAAE,EAAES,MAAM,CAAA,EAAE,CAAA,IACjB,GAAGR,MAAM,AAAC;IACX,MAAMtB,aAAY,QAAA,CAAC+B,eAAe,CAAC;QACjC3B,aAAa;QACb4B,MAAM,EAAEF,MAAM,CAACnB,EAAE;QACjBb,QAAQ,EAAEgC,MAAM,CAAChC,QAAQ;QACzBmC,iBAAiB,EAAE,kCAAkC;KACtD,CAAC,CAAC;CACJ;AAEM,eAAe1C,WAAW,GAAkB;IACjDG,WAAW,GAAGe,SAAS,CAAC;IACxB,MAAMyB,OAAO,CAACC,GAAG,CAAC;QAChBC,GAAE,SAAA,CAACC,EAAE,CAACC,CAAAA,GAAAA,YAAkC,AAAE,CAAA,mCAAF,EAAE,EAAE;YAAEC,SAAS,EAAE,IAAI;YAAEC,KAAK,EAAE,IAAI;SAAE,CAAC;QAC7ExC,aAAY,QAAA,CAAC+B,eAAe,CAACtB,SAAS,CAAC;KACxC,CAAC,CAAC;IACHjB,GAAG,CAACiD,GAAG,CAAC,YAAY,CAAC,CAAC;CACvB"}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.registerAsync = registerAsync;
|
|
6
6
|
var _betterOpn = _interopRequireDefault(require("better-opn"));
|
|
7
|
+
var _env = require("../utils/env");
|
|
7
8
|
var _errors = require("../utils/errors");
|
|
8
9
|
var _interactive = require("../utils/interactive");
|
|
9
10
|
var _link = require("../utils/link");
|
|
@@ -16,6 +17,8 @@ function _interopRequireDefault(obj) {
|
|
|
16
17
|
async function registerAsync() {
|
|
17
18
|
if (!(0, _interactive).isInteractive()) {
|
|
18
19
|
throw new _errors.CommandError("NON_INTERACTIVE", `Cannot register an account in CI. Use the EXPO_TOKEN environment variable to authenticate in CI (${(0, _link).learnMore("https://docs.expo.dev/accounts/programmatic-access/")})`);
|
|
20
|
+
} else if (_env.env.EXPO_OFFLINE) {
|
|
21
|
+
throw new _errors.CommandError("OFFLINE", `Cannot register an account in offline-mode`);
|
|
19
22
|
}
|
|
20
23
|
const registrationUrl = `https://expo.dev/signup`;
|
|
21
24
|
const failedMessage = `Unable to open a web browser. Register an account at: ${registrationUrl}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/register/registerAsync.ts"],"sourcesContent":["import openBrowserAsync from 'better-opn';\n\nimport { CommandError } from '../utils/errors';\nimport { isInteractive } from '../utils/interactive';\nimport { learnMore } from '../utils/link';\nimport { ora } from '../utils/ora';\n\nexport async function registerAsync() {\n if (!isInteractive()) {\n throw new CommandError(\n 'NON_INTERACTIVE',\n `Cannot register an account in CI. Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`\n );\n }\n\n const registrationUrl = `https://expo.dev/signup`;\n const failedMessage = `Unable to open a web browser. Register an account at: ${registrationUrl}`;\n const spinner = ora(`Opening ${registrationUrl}`).start();\n try {\n const opened = await openBrowserAsync(registrationUrl);\n\n if (opened) {\n spinner.succeed(`Opened ${registrationUrl}`);\n } else {\n spinner.fail(failedMessage);\n }\n return;\n } catch (error) {\n spinner.fail(failedMessage);\n throw error;\n }\n}\n"],"names":["registerAsync","isInteractive","CommandError","learnMore","registrationUrl","failedMessage","spinner","ora","start","opened","openBrowserAsync","succeed","fail","error"],"mappings":"AAAA;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/register/registerAsync.ts"],"sourcesContent":["import openBrowserAsync from 'better-opn';\n\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { isInteractive } from '../utils/interactive';\nimport { learnMore } from '../utils/link';\nimport { ora } from '../utils/ora';\n\nexport async function registerAsync() {\n if (!isInteractive()) {\n throw new CommandError(\n 'NON_INTERACTIVE',\n `Cannot register an account in CI. Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`\n );\n } else if (env.EXPO_OFFLINE) {\n throw new CommandError('OFFLINE', `Cannot register an account in offline-mode`);\n }\n\n const registrationUrl = `https://expo.dev/signup`;\n const failedMessage = `Unable to open a web browser. Register an account at: ${registrationUrl}`;\n const spinner = ora(`Opening ${registrationUrl}`).start();\n try {\n const opened = await openBrowserAsync(registrationUrl);\n\n if (opened) {\n spinner.succeed(`Opened ${registrationUrl}`);\n } else {\n spinner.fail(failedMessage);\n }\n return;\n } catch (error) {\n spinner.fail(failedMessage);\n throw error;\n }\n}\n"],"names":["registerAsync","isInteractive","CommandError","learnMore","env","EXPO_OFFLINE","registrationUrl","failedMessage","spinner","ora","start","opened","openBrowserAsync","succeed","fail","error"],"mappings":"AAAA;;;;QAQsBA,aAAa,GAAbA,aAAa;AARN,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAErB,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAChB,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,KAAe,WAAf,eAAe,CAAA;AACrB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAE3B,eAAeA,aAAa,GAAG;IACpC,IAAI,CAACC,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,EAAE;QACpB,MAAM,IAAIC,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,iGAAiG,EAAEC,CAAAA,GAAAA,KAAS,AAE5G,CAAA,UAF4G,CAC3G,qDAAqD,CACtD,CAAC,CAAC,CAAC,CACL,CAAC;KACH,MAAM,IAAIC,IAAG,IAAA,CAACC,YAAY,EAAE;QAC3B,MAAM,IAAIH,OAAY,aAAA,CAAC,SAAS,EAAE,CAAC,0CAA0C,CAAC,CAAC,CAAC;KACjF;IAED,MAAMI,eAAe,GAAG,CAAC,uBAAuB,CAAC,AAAC;IAClD,MAAMC,aAAa,GAAG,CAAC,sDAAsD,EAAED,eAAe,CAAC,CAAC,AAAC;IACjG,MAAME,OAAO,GAAGC,CAAAA,GAAAA,IAAG,AAA8B,CAAA,IAA9B,CAAC,CAAC,QAAQ,EAAEH,eAAe,CAAC,CAAC,CAAC,CAACI,KAAK,EAAE,AAAC;IAC1D,IAAI;QACF,MAAMC,MAAM,GAAG,MAAMC,CAAAA,GAAAA,UAAgB,AAAiB,CAAA,QAAjB,CAACN,eAAe,CAAC,AAAC;QAEvD,IAAIK,MAAM,EAAE;YACVH,OAAO,CAACK,OAAO,CAAC,CAAC,OAAO,EAAEP,eAAe,CAAC,CAAC,CAAC,CAAC;SAC9C,MAAM;YACLE,OAAO,CAACM,IAAI,CAACP,aAAa,CAAC,CAAC;SAC7B;QACD,OAAO;KACR,CAAC,OAAOQ,KAAK,EAAE;QACdP,OAAO,CAACM,IAAI,CAACP,aAAa,CAAC,CAAC;QAC5B,MAAMQ,KAAK,CAAC;KACb;CACF"}
|
|
@@ -7,8 +7,8 @@ var _jsonFile = _interopRequireDefault(require("@expo/json-file"));
|
|
|
7
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
8
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
9
9
|
var _getNativeModuleVersions = require("../../../api/getNativeModuleVersions");
|
|
10
|
-
var _settings = require("../../../api/settings");
|
|
11
10
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
11
|
+
var _env = require("../../../utils/env");
|
|
12
12
|
var _errors = require("../../../utils/errors");
|
|
13
13
|
function _interopRequireDefault(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : {
|
|
@@ -38,12 +38,16 @@ function _interopRequireWildcard(obj) {
|
|
|
38
38
|
}
|
|
39
39
|
const debug = require("debug")("expo:doctor:dependencies:bundledNativeModules");
|
|
40
40
|
async function getVersionedNativeModulesAsync(projectRoot, sdkVersion) {
|
|
41
|
-
if (sdkVersion !== "UNVERSIONED" && !
|
|
41
|
+
if (sdkVersion !== "UNVERSIONED" && !_env.env.EXPO_OFFLINE) {
|
|
42
42
|
try {
|
|
43
43
|
debug("Fetching bundled native modules from the server...");
|
|
44
44
|
return await (0, _getNativeModuleVersions).getNativeModuleVersionsAsync(sdkVersion);
|
|
45
|
-
} catch
|
|
46
|
-
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof _errors.CommandError && (error.code === "OFFLINE" || error.code === "API")) {
|
|
47
|
+
Log.warn(_chalk.default`Unable to reach well-known versions endpoint. Using local dependency map {bold expo/bundledNativeModules.json} for version validation`);
|
|
48
|
+
} else {
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
debug("Fetching bundled native modules from the local JSON file...");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/bundledNativeModules.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\n\nimport { getNativeModuleVersionsAsync } from '../../../api/getNativeModuleVersions';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/bundledNativeModules.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\n\nimport { getNativeModuleVersionsAsync } from '../../../api/getNativeModuleVersions';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')(\n 'expo:doctor:dependencies:bundledNativeModules'\n) as typeof console.log;\n\nexport type BundledNativeModules = Record<string, string>;\n\n/**\n * Gets the bundledNativeModules.json for a given SDK version:\n * - Tries to fetch the data from the /sdks/:sdkVersion/native-modules API endpoint.\n * - If the data is missing on the server (it can happen for SDKs that are yet fully released)\n * or there's a downtime, reads the local .json file from the \"expo\" package.\n * - For UNVERSIONED, returns the local .json file contents.\n */\nexport async function getVersionedNativeModulesAsync(\n projectRoot: string,\n sdkVersion: string\n): Promise<BundledNativeModules> {\n if (sdkVersion !== 'UNVERSIONED' && !env.EXPO_OFFLINE) {\n try {\n debug('Fetching bundled native modules from the server...');\n return await getNativeModuleVersionsAsync(sdkVersion);\n } catch (error: any) {\n if (error instanceof CommandError && (error.code === 'OFFLINE' || error.code === 'API')) {\n Log.warn(\n chalk`Unable to reach well-known versions endpoint. Using local dependency map {bold expo/bundledNativeModules.json} for version validation`\n );\n } else {\n throw error;\n }\n }\n }\n\n debug('Fetching bundled native modules from the local JSON file...');\n return await getBundledNativeModulesAsync(projectRoot);\n}\n\n/**\n * Get the legacy static `bundledNativeModules.json` file\n * that's shipped with the version of `expo` that the project has installed.\n */\nasync function getBundledNativeModulesAsync(projectRoot: string): Promise<BundledNativeModules> {\n // TODO: Revisit now that this code is in the `expo` package.\n const bundledNativeModulesPath = resolveFrom.silent(\n projectRoot,\n 'expo/bundledNativeModules.json'\n );\n if (!bundledNativeModulesPath) {\n Log.log();\n throw new CommandError(\n chalk`The dependency map {bold expo/bundledNativeModules.json} cannot be found, please ensure you have the package \"{bold expo}\" installed in your project.`\n );\n }\n return await JsonFile.readAsync<BundledNativeModules>(bundledNativeModulesPath);\n}\n"],"names":["getVersionedNativeModulesAsync","Log","debug","require","projectRoot","sdkVersion","env","EXPO_OFFLINE","getNativeModuleVersionsAsync","error","CommandError","code","warn","chalk","getBundledNativeModulesAsync","bundledNativeModulesPath","resolveFrom","silent","log","JsonFile","readAsync"],"mappings":"AAAA;;;;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CAAgC,CACjC,AAAC;IACF,IAAI,CAACW,wBAAwB,EAAE;QAC7Bd,GAAG,CAACiB,GAAG,EAAE,CAAC;QACV,MAAM,IAAIR,OAAY,aAAA,CACpBG,MAAK,QAAA,CAAC,qJAAqJ,CAAC,CAC7J,CAAC;KACH;IACD,OAAO,MAAMM,SAAQ,QAAA,CAACC,SAAS,CAAuBL,wBAAwB,CAAC,CAAC;CACjF"}
|
|
@@ -8,6 +8,9 @@ exports.getVersionedPackagesAsync = getVersionedPackagesAsync;
|
|
|
8
8
|
exports.getOperationLog = getOperationLog;
|
|
9
9
|
var _npmPackageArg = _interopRequireDefault(require("npm-package-arg"));
|
|
10
10
|
var _getVersions = require("../../../api/getVersions");
|
|
11
|
+
var _log = require("../../../log");
|
|
12
|
+
var _env = require("../../../utils/env");
|
|
13
|
+
var _errors = require("../../../utils/errors");
|
|
11
14
|
var _bundledNativeModules = require("./bundledNativeModules");
|
|
12
15
|
function _interopRequireDefault(obj) {
|
|
13
16
|
return obj && obj.__esModule ? obj : {
|
|
@@ -42,16 +45,30 @@ async function getCombinedKnownVersionsAsync({ projectRoot , sdkVersion , skipCa
|
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
async function getRemoteVersionsForSdkAsync({ sdkVersion , skipCache } = {}) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
// We only want versioned dependencies so skip if they cannot be found.
|
|
49
|
-
if (!sdkVersion || !(sdkVersion in sdkVersions)) {
|
|
50
|
-
debug(`Skipping versioned dependencies because the SDK version is not found. (sdkVersion: ${sdkVersion}, available: ${Object.keys(sdkVersions).join(", ")})`);
|
|
48
|
+
if (_env.env.EXPO_OFFLINE) {
|
|
49
|
+
_log.Log.warn("Dependency validation is unreliable in offline-mode");
|
|
51
50
|
return {};
|
|
52
51
|
}
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
try {
|
|
53
|
+
const { sdkVersions } = await (0, _getVersions).getVersionsAsync({
|
|
54
|
+
skipCache
|
|
55
|
+
});
|
|
56
|
+
// We only want versioned dependencies so skip if they cannot be found.
|
|
57
|
+
if (!sdkVersion || !(sdkVersion in sdkVersions)) {
|
|
58
|
+
debug(`Skipping versioned dependencies because the SDK version is not found. (sdkVersion: ${sdkVersion}, available: ${Object.keys(sdkVersions).join(", ")})`);
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
const version = sdkVersions[sdkVersion];
|
|
62
|
+
return normalizeSdkVersionObject(version);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (error instanceof _errors.CommandError && error.code === "OFFLINE") {
|
|
65
|
+
return getRemoteVersionsForSdkAsync({
|
|
66
|
+
sdkVersion,
|
|
67
|
+
skipCache
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
55
72
|
}
|
|
56
73
|
async function getVersionedPackagesAsync(projectRoot, { packages , sdkVersion , pkg }) {
|
|
57
74
|
const versionsForSdk = await getCombinedKnownVersionsAsync({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/getVersionedPackages.ts"],"sourcesContent":["import { PackageJSONConfig } from '@expo/config';\nimport npmPackageArg from 'npm-package-arg';\n\nimport { getVersionsAsync, SDKVersion } from '../../../api/getVersions';\nimport { getVersionedNativeModulesAsync } from './bundledNativeModules';\n\nconst debug = require('debug')(\n 'expo:doctor:dependencies:getVersionedPackages'\n) as typeof console.log;\n\nexport type DependencyList = Record<string, string>;\n\n/** Adds `react-dom`, `react`, and `react-native` to the list of known package versions (`relatedPackages`) */\nfunction normalizeSdkVersionObject(version?: SDKVersion): Record<string, string> {\n if (!version) {\n return {};\n }\n const { relatedPackages, facebookReactVersion, facebookReactNativeVersion } = version;\n\n const reactVersion = facebookReactVersion\n ? {\n react: facebookReactVersion,\n 'react-dom': facebookReactVersion,\n }\n : undefined;\n\n return {\n ...relatedPackages,\n ...reactVersion,\n 'react-native': facebookReactNativeVersion,\n };\n}\n\n/** Get the known versions for a given SDK, combines all sources. */\nexport async function getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion,\n skipCache,\n}: {\n projectRoot: string;\n sdkVersion?: string;\n skipCache?: boolean;\n}) {\n const bundledNativeModules = sdkVersion\n ? await getVersionedNativeModulesAsync(projectRoot, sdkVersion)\n : {};\n const versionsForSdk = await getRemoteVersionsForSdkAsync({ sdkVersion, skipCache });\n return {\n ...versionsForSdk,\n ...bundledNativeModules,\n };\n}\n\n/** @returns a key/value list of known dependencies and their version (including range). */\nexport async function getRemoteVersionsForSdkAsync({\n sdkVersion,\n skipCache,\n}: { sdkVersion?: string; skipCache?: boolean } = {}): Promise<DependencyList> {\n const { sdkVersions } = await getVersionsAsync({ skipCache });\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/getVersionedPackages.ts"],"sourcesContent":["import { PackageJSONConfig } from '@expo/config';\nimport npmPackageArg from 'npm-package-arg';\n\nimport { getVersionsAsync, SDKVersion } from '../../../api/getVersions';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { getVersionedNativeModulesAsync } from './bundledNativeModules';\n\nconst debug = require('debug')(\n 'expo:doctor:dependencies:getVersionedPackages'\n) as typeof console.log;\n\nexport type DependencyList = Record<string, string>;\n\n/** Adds `react-dom`, `react`, and `react-native` to the list of known package versions (`relatedPackages`) */\nfunction normalizeSdkVersionObject(version?: SDKVersion): Record<string, string> {\n if (!version) {\n return {};\n }\n const { relatedPackages, facebookReactVersion, facebookReactNativeVersion } = version;\n\n const reactVersion = facebookReactVersion\n ? {\n react: facebookReactVersion,\n 'react-dom': facebookReactVersion,\n }\n : undefined;\n\n return {\n ...relatedPackages,\n ...reactVersion,\n 'react-native': facebookReactNativeVersion,\n };\n}\n\n/** Get the known versions for a given SDK, combines all sources. */\nexport async function getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion,\n skipCache,\n}: {\n projectRoot: string;\n sdkVersion?: string;\n skipCache?: boolean;\n}) {\n const bundledNativeModules = sdkVersion\n ? await getVersionedNativeModulesAsync(projectRoot, sdkVersion)\n : {};\n const versionsForSdk = await getRemoteVersionsForSdkAsync({ sdkVersion, skipCache });\n return {\n ...versionsForSdk,\n ...bundledNativeModules,\n };\n}\n\n/** @returns a key/value list of known dependencies and their version (including range). */\nexport async function getRemoteVersionsForSdkAsync({\n sdkVersion,\n skipCache,\n}: { sdkVersion?: string; skipCache?: boolean } = {}): Promise<DependencyList> {\n if (env.EXPO_OFFLINE) {\n Log.warn('Dependency validation is unreliable in offline-mode');\n return {};\n }\n\n try {\n const { sdkVersions } = await getVersionsAsync({ skipCache });\n\n // We only want versioned dependencies so skip if they cannot be found.\n if (!sdkVersion || !(sdkVersion in sdkVersions)) {\n debug(\n `Skipping versioned dependencies because the SDK version is not found. (sdkVersion: ${sdkVersion}, available: ${Object.keys(\n sdkVersions\n ).join(', ')})`\n );\n return {};\n }\n\n const version = sdkVersions[sdkVersion as keyof typeof sdkVersions] as unknown as SDKVersion;\n\n return normalizeSdkVersionObject(version);\n } catch (error: any) {\n if (error instanceof CommandError && error.code === 'OFFLINE') {\n return getRemoteVersionsForSdkAsync({ sdkVersion, skipCache });\n }\n throw error;\n }\n}\n\n/**\n * Versions a list of `packages` against a given `sdkVersion` based on local and remote versioning resources.\n *\n * @param projectRoot\n * @param param1\n * @returns\n */\nexport async function getVersionedPackagesAsync(\n projectRoot: string,\n {\n packages,\n sdkVersion,\n pkg,\n }: {\n /** List of npm packages to process. */\n packages: string[];\n /** Target SDK Version number to version the `packages` for. */\n sdkVersion: string;\n pkg: PackageJSONConfig;\n }\n): Promise<{\n packages: string[];\n messages: string[];\n excludedNativeModules: { name: string; bundledNativeVersion: string }[];\n}> {\n const versionsForSdk = await getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion,\n skipCache: true,\n });\n\n let nativeModulesCount = 0;\n let othersCount = 0;\n const excludedNativeModules: { name: string; bundledNativeVersion: string }[] = [];\n\n const versionedPackages = packages.map((arg) => {\n const { name, type, raw } = npmPackageArg(arg);\n\n if (['tag', 'version', 'range'].includes(type) && name && versionsForSdk[name]) {\n // Unimodule packages from npm registry are modified to use the bundled version.\n // Some packages have the recommended version listed in https://exp.host/--/api/v2/versions.\n if (pkg?.expo?.install?.exclude?.includes(name)) {\n othersCount++;\n excludedNativeModules.push({ name, bundledNativeVersion: versionsForSdk[name] });\n return raw;\n }\n nativeModulesCount++;\n return `${name}@${versionsForSdk[name]}`;\n } else {\n // Other packages are passed through unmodified.\n othersCount++;\n return raw;\n }\n });\n\n const messages = getOperationLog({\n othersCount,\n nativeModulesCount,\n sdkVersion,\n });\n\n return {\n packages: versionedPackages,\n messages,\n excludedNativeModules,\n };\n}\n\n/** Craft a set of messages regarding the install operations. */\nexport function getOperationLog({\n nativeModulesCount,\n sdkVersion,\n othersCount,\n}: {\n nativeModulesCount: number;\n othersCount: number;\n sdkVersion: string;\n}): string[] {\n return [\n nativeModulesCount > 0 &&\n `${nativeModulesCount} SDK ${sdkVersion} compatible native ${\n nativeModulesCount === 1 ? 'module' : 'modules'\n }`,\n othersCount > 0 && `${othersCount} other ${othersCount === 1 ? 'package' : 'packages'}`,\n ].filter(Boolean) as string[];\n}\n"],"names":["getCombinedKnownVersionsAsync","getRemoteVersionsForSdkAsync","getVersionedPackagesAsync","getOperationLog","debug","require","normalizeSdkVersionObject","version","relatedPackages","facebookReactVersion","facebookReactNativeVersion","reactVersion","react","undefined","projectRoot","sdkVersion","skipCache","bundledNativeModules","getVersionedNativeModulesAsync","versionsForSdk","env","EXPO_OFFLINE","Log","warn","sdkVersions","getVersionsAsync","Object","keys","join","error","CommandError","code","packages","pkg","nativeModulesCount","othersCount","excludedNativeModules","versionedPackages","map","arg","name","type","raw","npmPackageArg","includes","expo","install","exclude","push","bundledNativeVersion","messages","filter","Boolean"],"mappings":"AAAA;;;;QAqCsBA,6BAA6B,GAA7BA,6BAA6B;QAoB7BC,4BAA4B,GAA5B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ACXD,kBAAkB;QAClBnB,UAAU;KACX,CAAC,AAAC;IAEH,OAAO;QACLiB,QAAQ,EAAEK,iBAAiB;QAC3Ba,QAAQ;QACRd,qBAAqB;KACtB,CAAC;CACH;AAGM,SAASjC,eAAe,CAAC,EAC9B+B,kBAAkB,CAAA,EAClBnB,UAAU,CAAA,EACVoB,WAAW,CAAA,EAKZ,EAAY;IACX,OAAO;QACLD,kBAAkB,GAAG,CAAC,IACpB,CAAC,EAAEA,kBAAkB,CAAC,KAAK,EAAEnB,UAAU,CAAC,mBAAmB,EACzDmB,kBAAkB,KAAK,CAAC,GAAG,QAAQ,GAAG,SAAS,CAChD,CAAC;QACJC,WAAW,GAAG,CAAC,IAAI,CAAC,EAAEA,WAAW,CAAC,OAAO,EAAEA,WAAW,KAAK,CAAC,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC;KACxF,CAACgB,MAAM,CAACC,OAAO,CAAC,CAAa;CAC/B"}
|
|
@@ -10,8 +10,8 @@ var _assert = _interopRequireDefault(require("assert"));
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
12
12
|
var _semver = _interopRequireDefault(require("semver"));
|
|
13
|
-
var _settings = require("../../../api/settings");
|
|
14
13
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
14
|
+
var _env = require("../../../utils/env");
|
|
15
15
|
var _errors = require("../../../utils/errors");
|
|
16
16
|
var _getVersionedPackages = require("./getVersionedPackages");
|
|
17
17
|
function _interopRequireDefault(obj) {
|
|
@@ -42,7 +42,7 @@ function _interopRequireWildcard(obj) {
|
|
|
42
42
|
}
|
|
43
43
|
const debug = require("debug")("expo:doctor:dependencies:validate");
|
|
44
44
|
async function validateDependenciesVersionsAsync(projectRoot, exp, pkg, packagesToCheck) {
|
|
45
|
-
if (
|
|
45
|
+
if (_env.env.EXPO_OFFLINE) {
|
|
46
46
|
Log.warn("Skipping dependency validation in offline mode");
|
|
47
47
|
return null;
|
|
48
48
|
}
|