@expo/cli 0.18.19 → 0.19.0-canary-20240627-1402f4b
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 +1 -1
- package/build/src/api/rest/client.js +1 -2
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/user/UserSettings.js +2 -4
- package/build/src/api/user/UserSettings.js.map +1 -1
- package/build/src/api/user/actions.js +2 -2
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/api/user/user.js +1 -1
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/customize/customizeAsync.js +1 -2
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/customize/generate.js +4 -42
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/customize/templates.js +30 -18
- package/build/src/customize/templates.js.map +1 -1
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +111 -42
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/index.js +1 -1
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +5 -9
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +135 -95
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +3 -4
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +17 -5
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +10 -55
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +6 -6
- package/build/src/export/favicon.js.map +1 -1
- package/build/src/export/persistMetroAssets.js +18 -14
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/publicFolder.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -2
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +40 -18
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/install/installAsync.js +1 -2
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/lint/ESlintPrerequisite.js +11 -12
- package/build/src/lint/ESlintPrerequisite.js.map +1 -1
- package/build/src/prebuild/configureProjectAsync.js +1 -2
- package/build/src/prebuild/configureProjectAsync.js.map +1 -1
- package/build/src/prebuild/renameTemplateAppName.js +1 -1
- package/build/src/prebuild/renameTemplateAppName.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +2 -4
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/index.js +1 -1
- package/build/src/run/android/index.js.map +1 -1
- package/build/src/run/android/resolveGradlePropsAsync.js +1 -1
- package/build/src/run/android/resolveGradlePropsAsync.js.map +1 -1
- package/build/src/run/android/resolveOptions.js +1 -2
- package/build/src/run/android/resolveOptions.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +2 -3
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/index.js +1 -2
- package/build/src/run/index.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +1 -2
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +1 -2
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
- package/build/src/run/ios/codeSigning/Security.js +2 -4
- package/build/src/run/ios/codeSigning/Security.js.map +1 -1
- package/build/src/run/ios/codeSigning/settings.js +1 -1
- package/build/src/run/ios/codeSigning/settings.js.map +1 -1
- package/build/src/run/ios/index.js +1 -1
- package/build/src/run/ios/index.js.map +1 -1
- package/build/src/run/ios/options/resolveNativeScheme.js +3 -6
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
- package/build/src/run/resolveBundlerProps.js +1 -2
- package/build/src/run/resolveBundlerProps.js.map +1 -1
- package/build/src/run/startBundler.js +2 -10
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/resolvePackages.js +1 -2
- package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +3 -6
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +1 -2
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js +1 -3
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
- package/build/src/start/interface/commandsTable.js +4 -0
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +2 -3
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +1 -2
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +1 -2
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +1 -2
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/AndroidDeviceManager.js +2 -4
- package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
- package/build/src/start/platforms/android/AndroidPlatformManager.js +1 -2
- package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +6 -10
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +2 -3
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/devicectl.js +2 -3
- package/build/src/start/platforms/ios/devicectl.js.map +1 -1
- package/build/src/start/platforms/ios/getBestSimulator.js +1 -2
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +4 -7
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/platforms/ios/simctlLogging.js +2 -4
- package/build/src/start/platforms/ios/simctlLogging.js.map +1 -1
- package/build/src/start/resolveOptions.js +2 -4
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +1 -2
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +24 -17
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +25 -14
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +1 -2
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +21 -11
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/ReactDevToolsProxy.js +1 -2
- package/build/src/start/server/ReactDevToolsProxy.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +3 -6
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +9 -123
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +500 -196
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +17 -6
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +15 -4
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +5 -9
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +1 -10
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeGetProperties.js +2 -4
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeGetProperties.js.map +1 -1
- package/build/src/start/server/metro/debugging/pageIsSupported.js +1 -2
- package/build/src/start/server/metro/debugging/pageIsSupported.js.map +1 -1
- package/build/src/start/server/metro/getCssModulesFromBundler.js +1 -2
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +38 -33
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +77 -12
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/metroPrivateServer.js +26 -0
- package/build/src/start/server/metro/metroPrivateServer.js.map +1 -0
- package/build/src/start/server/metro/router.js +2 -4
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +31 -21
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +130 -55
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +13 -18
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -2
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +2 -3
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +7 -12
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +14 -16
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ReactDevToolsPageMiddleware.js +3 -5
- package/build/src/start/server/middleware/ReactDevToolsPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +1 -2
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +4 -8
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js +2 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +1 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
- package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +2 -4
- package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +36 -17
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/start/server/middleware/resolvePlatform.js +1 -2
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
- package/build/src/start/server/platformBundlers.js +2 -3
- package/build/src/start/server/platformBundlers.js.map +1 -1
- package/build/src/start/server/serverLogLikeMetro.js +2 -4
- package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
- package/build/src/start/server/webTemplate.js +2 -3
- package/build/src/start/server/webTemplate.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +13 -19
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/server/webpack/resolveFromProject.js.map +1 -1
- package/build/src/start/startAsync.js +2 -4
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +1 -1
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/dir.js +2 -4
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/errors.js +3 -6
- package/build/src/utils/errors.js.map +1 -1
- package/build/src/utils/exit.js +1 -2
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/getOrPromptApplicationId.js +66 -57
- package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
- package/build/src/utils/git.js +7 -8
- package/build/src/utils/git.js.map +1 -1
- package/build/src/utils/link.js +1 -1
- package/build/src/utils/link.js.map +1 -1
- package/build/src/utils/mergeGitIgnorePaths.js +1 -1
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/modifyConfigAsync.js +1 -3
- package/build/src/utils/modifyConfigAsync.js.map +1 -1
- package/build/src/utils/npm.js +2 -3
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/open.js +1 -2
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/port.js +1 -1
- package/build/src/utils/port.js.map +1 -1
- package/build/src/utils/profile.js +1 -1
- package/build/src/utils/profile.js.map +1 -1
- package/build/src/utils/prompts.js +2 -2
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/telemetry/getContext.js +2 -3
- package/build/src/utils/telemetry/getContext.js.map +1 -1
- package/build/src/utils/tsconfig/evaluateTsConfig.js +1 -2
- package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -1
- package/build/src/utils/tsconfig/loadTsConfigPaths.js +4 -5
- package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
- package/build/src/utils/url.js +1 -2
- package/build/src/utils/url.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +48 -6
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/package.json +39 -44
- package/static/template/.eslintrc.js +4 -0
- package/build/src/export/fork-bundleAsync.js +0 -284
- package/build/src/export/fork-bundleAsync.js.map +0 -1
- package/static/template/serve.json +0 -13
package/build/bin/cli
CHANGED
|
@@ -120,7 +120,7 @@ const args = (0, _arg().default)({
|
|
|
120
120
|
});
|
|
121
121
|
if (args["--version"]) {
|
|
122
122
|
// Version is added in the build script.
|
|
123
|
-
console.log("0.
|
|
123
|
+
console.log("0.19.0-canary-20240627-1402f4b");
|
|
124
124
|
process.exit(0);
|
|
125
125
|
}
|
|
126
126
|
if (args["--non-interactive"]) {
|
|
@@ -70,8 +70,7 @@ function wrapFetchWithCredentials(fetchFunction) {
|
|
|
70
70
|
if (Array.isArray(options.headers)) {
|
|
71
71
|
throw new Error("request headers must be in object form");
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
const resolvedHeaders = (_headers = options.headers) != null ? _headers : {};
|
|
73
|
+
const resolvedHeaders = options.headers ?? {};
|
|
75
74
|
const token = _userSettings.default.getAccessToken();
|
|
76
75
|
if (token) {
|
|
77
76
|
resolvedHeaders.authorization = `Bearer ${token}`;
|
|
@@ -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 { 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';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport UserSettings from '../user/UserSettings';\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 const { FileSystemCache } =\n require('./cache/FileSystemCache') as typeof import('./cache/FileSystemCache');\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":["ApiV2Error","UnexpectedServerError","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","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","FileSystemCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;;;;;;;;IAiBaA,UAAU,MAAVA,UAAU;IA4BVC,qBAAqB,MAArBA,qBAAqB;IAOlBC,wBAAwB,MAAxBA,wBAAwB;IAoExBC,iBAAiB,MAAjBA,iBAAiB;IA6BpBC,UAAU,MAAVA,UAAU;;;yBArJc,iCAAiC;;;;;;;8DAE5C,YAAY;;;;;;;8DACrB,MAAM;;;;;;oCAEY,4BAA4B;sCAE1B,wBAAwB;sCACxB,wBAAwB;uCACvB,yBAAyB;oCAC5B,sBAAsB;qBACrC,iBAAiB;wBACR,oBAAoB;0BACf,aAAa;0BAChB,aAAa;mEACnB,sBAAsB;;;;;;AAExC,MAAMJ,UAAU,SAASK,KAAK;IACnC,AAASC,IAAI,GAAG,YAAY,CAAC;IAO7BC,YAAYC,QAMX,CAAE;QACD,KAAK,CAACA,QAAQ,CAACC,OAAO,CAAC,CAAC;QACxB,IAAI,CAACC,IAAI,GAAGF,QAAQ,CAACE,IAAI,CAAC;QAC1B,IAAI,CAACC,kBAAkB,GAAGH,QAAQ,CAACE,IAAI,CAAC;QACxC,IAAI,CAACE,qBAAqB,GAAGJ,QAAQ,CAACK,OAAO,CAAC;QAC9C,IAAI,CAACC,yBAAyB,GAAGN,QAAQ,CAACO,KAAK,CAAC;QAChD,IAAI,CAACC,sBAAsB,GAAGR,QAAQ,CAACS,QAAQ,CAAC;IAClD;CACD;AAMM,MAAMhB,qBAAqB,SAASI,KAAK;IAC9C,AAASC,IAAI,GAAG,uBAAuB,CAAC;CACzC;AAKM,SAASJ,wBAAwB,CAACgB,aAAwB,EAAa;IAC5E,OAAO,eAAeC,oBAAoB,CAACC,GAAG,EAAEC,OAAO,GAAG,EAAE,EAAE;QAC5D,IAAIC,KAAK,CAACC,OAAO,CAACF,OAAO,CAACG,OAAO,CAAC,EAAE;YAClC,MAAM,IAAInB,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;
|
|
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 { 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';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport UserSettings from '../user/UserSettings';\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 const { FileSystemCache } =\n require('./cache/FileSystemCache') as typeof import('./cache/FileSystemCache');\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":["ApiV2Error","UnexpectedServerError","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","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","FileSystemCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;;;;;;;;IAiBaA,UAAU,MAAVA,UAAU;IA4BVC,qBAAqB,MAArBA,qBAAqB;IAOlBC,wBAAwB,MAAxBA,wBAAwB;IAoExBC,iBAAiB,MAAjBA,iBAAiB;IA6BpBC,UAAU,MAAVA,UAAU;;;yBArJc,iCAAiC;;;;;;;8DAE5C,YAAY;;;;;;;8DACrB,MAAM;;;;;;oCAEY,4BAA4B;sCAE1B,wBAAwB;sCACxB,wBAAwB;uCACvB,yBAAyB;oCAC5B,sBAAsB;qBACrC,iBAAiB;wBACR,oBAAoB;0BACf,aAAa;0BAChB,aAAa;mEACnB,sBAAsB;;;;;;AAExC,MAAMJ,UAAU,SAASK,KAAK;IACnC,AAASC,IAAI,GAAG,YAAY,CAAC;IAO7BC,YAAYC,QAMX,CAAE;QACD,KAAK,CAACA,QAAQ,CAACC,OAAO,CAAC,CAAC;QACxB,IAAI,CAACC,IAAI,GAAGF,QAAQ,CAACE,IAAI,CAAC;QAC1B,IAAI,CAACC,kBAAkB,GAAGH,QAAQ,CAACE,IAAI,CAAC;QACxC,IAAI,CAACE,qBAAqB,GAAGJ,QAAQ,CAACK,OAAO,CAAC;QAC9C,IAAI,CAACC,yBAAyB,GAAGN,QAAQ,CAACO,KAAK,CAAC;QAChD,IAA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AwB,CAACiD,cAAc,CAAC,CAAC,AAAC;AAMtF,SAAShD,iBAAiB,CAAC,EAChCmD,KAAK,EAAGnC,oBAAoB,CAAA,EAC5BoC,cAAc,CAAA,EACdC,GAAG,CAAA,EACHC,SAAS,CAAA,EAMV,EAAa;IACZ,oCAAoC;IACpC,IAAIA,SAAS,IAAIC,IAAG,IAAA,CAACC,SAAS,IAAID,IAAG,IAAA,CAACE,aAAa,EAAE;QACnD,OAAON,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAEO,eAAe,CAAA,EAAE,GACvBC,OAAO,CAAC,yBAAyB,CAAC,AAA4C,AAAC;IAEjF,OAAOC,IAAAA,mBAAkB,mBAAA,EACvBT,KAAK,EACL,IAAIO,eAAe,CAAC;QAClBN,cAAc,EAAES,KAAI,EAAA,QAAA,CAACC,IAAI,CAACC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,EAAEX,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;AACJ,CAAC;AAGM,MAAMpD,UAAU,GAAGiD,IAAAA,sBAAqB,sBAAA,EAACnD,wBAAwB,CAACiD,cAAc,CAAC,CAAC,AAAC"}
|
|
@@ -54,8 +54,7 @@ async function setSessionAsync(sessionData) {
|
|
|
54
54
|
function getSession() {
|
|
55
55
|
try {
|
|
56
56
|
var ref;
|
|
57
|
-
|
|
58
|
-
return (ref1 = (ref = _jsonFile().default.read((0, _getUserState().getUserStatePath)())) == null ? void 0 : ref.auth) != null ? ref1 : null;
|
|
57
|
+
return ((ref = _jsonFile().default.read((0, _getUserState().getUserStatePath)())) == null ? void 0 : ref.auth) ?? null;
|
|
59
58
|
} catch (error) {
|
|
60
59
|
if (error.code === "ENOENT") {
|
|
61
60
|
return null;
|
|
@@ -64,8 +63,7 @@ function getSession() {
|
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
function getAccessToken() {
|
|
67
|
-
|
|
68
|
-
return (_EXPO_TOKEN = process.env.EXPO_TOKEN) != null ? _EXPO_TOKEN : null;
|
|
66
|
+
return process.env.EXPO_TOKEN ?? null;
|
|
69
67
|
}
|
|
70
68
|
// returns an anonymous, unique identifier for a user on the current computer
|
|
71
69
|
async function getAnonymousIdentifierAsync() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nfunction getDirectory() {\n return getExpoHomeDirectory();\n}\n\nfunction getFilePath(): string {\n return getUserStatePath();\n}\n\nfunction userSettingsJsonFile(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nasync function setSessionAsync(sessionData?: SessionData): Promise<void> {\n await UserSettings.setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\nfunction getSession(): SessionData | null {\n try {\n return JsonFile.read<UserSettingsData>(getUserStatePath())?.auth ?? null;\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n}\n\nfunction getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\n// returns an anonymous, unique identifier for a user on the current computer\nasync function getAnonymousIdentifierAsync(): Promise<string> {\n const settings = await userSettingsJsonFile();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\nconst UserSettings = Object.assign(userSettingsJsonFile(), {\n getSession,\n setSessionAsync,\n getAccessToken,\n getDirectory,\n getFilePath,\n userSettingsJsonFile,\n getAnonymousIdentifierAsync,\n});\n\nexport default UserSettings;\n"],"names":["getDirectory","getExpoHomeDirectory","getFilePath","getUserStatePath","userSettingsJsonFile","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","setSessionAsync","sessionData","UserSettings","setAsync","default","getSession","read","auth","error","code","getAccessToken","process","env","EXPO_TOKEN","getAnonymousIdentifierAsync","settings","id","getAsync","crypto","randomUUID","Object","assign"],"mappings":"AAAA;;;;+BAoFA,SAA4B;;aAA5B,QAA4B;;;yBApF2B,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAoB3B,qCAAqC,GACrC,SAASA,YAAY,GAAG;IACtB,OAAOC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAED,SAASC,WAAW,GAAW;IAC7B,OAAOC,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAED,SAASC,oBAAoB,GAA+B;IAC1D,OAAO,IAAIC,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBH,WAAW,EAAE,EAAE;QACnDI,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAED,eAAeC,eAAe,CAACC,WAAyB,EAAiB;IACvE,MAAMC,YAAY,CAACC,QAAQ,CAAC,MAAM,EAAEF,WAAW,EAAE;QAC/CG,OAAO,EAAE,EAAE;QACXP,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAED,SAASQ,UAAU,GAAuB;IACxC,IAAI;YACKT,GAAmD;
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nfunction getDirectory() {\n return getExpoHomeDirectory();\n}\n\nfunction getFilePath(): string {\n return getUserStatePath();\n}\n\nfunction userSettingsJsonFile(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nasync function setSessionAsync(sessionData?: SessionData): Promise<void> {\n await UserSettings.setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\nfunction getSession(): SessionData | null {\n try {\n return JsonFile.read<UserSettingsData>(getUserStatePath())?.auth ?? null;\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n}\n\nfunction getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\n// returns an anonymous, unique identifier for a user on the current computer\nasync function getAnonymousIdentifierAsync(): Promise<string> {\n const settings = await userSettingsJsonFile();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\nconst UserSettings = Object.assign(userSettingsJsonFile(), {\n getSession,\n setSessionAsync,\n getAccessToken,\n getDirectory,\n getFilePath,\n userSettingsJsonFile,\n getAnonymousIdentifierAsync,\n});\n\nexport default UserSettings;\n"],"names":["getDirectory","getExpoHomeDirectory","getFilePath","getUserStatePath","userSettingsJsonFile","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","setSessionAsync","sessionData","UserSettings","setAsync","default","getSession","read","auth","error","code","getAccessToken","process","env","EXPO_TOKEN","getAnonymousIdentifierAsync","settings","id","getAsync","crypto","randomUUID","Object","assign"],"mappings":"AAAA;;;;+BAoFA,SAA4B;;aAA5B,QAA4B;;;yBApF2B,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAoB3B,qCAAqC,GACrC,SAASA,YAAY,GAAG;IACtB,OAAOC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAED,SAASC,WAAW,GAAW;IAC7B,OAAOC,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAED,SAASC,oBAAoB,GAA+B;IAC1D,OAAO,IAAIC,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBH,WAAW,EAAE,EAAE;QACnDI,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAED,eAAeC,eAAe,CAACC,WAAyB,EAAiB;IACvE,MAAMC,YAAY,CAACC,QAAQ,CAAC,MAAM,EAAEF,WAAW,EAAE;QAC/CG,OAAO,EAAE,EAAE;QACXP,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAED,SAASQ,UAAU,GAAuB;IACxC,IAAI;YACKT,GAAmD;QAA1D,OAAOA,CAAAA,CAAAA,GAAmD,GAAnDA,SAAQ,EAAA,QAAA,CAACU,IAAI,CAAmBZ,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC,SAAM,GAAzDE,KAAAA,CAAyD,GAAzDA,GAAmD,CAAEW,IAAI,CAAA,IAAI,IAAI,CAAC;IAC3E,EAAE,OAAOC,KAAK,EAAO;QACnB,IAAIA,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAMD,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAASE,cAAc,GAAkB;IACvC,OAAOC,OAAO,CAACC,GAAG,CAACC,UAAU,IAAI,IAAI,CAAC;AACxC,CAAC;AAED,6EAA6E;AAC7E,eAAeC,2BAA2B,GAAoB;IAC5D,MAAMC,QAAQ,GAAG,MAAMpB,oBAAoB,EAAE,AAAC;IAC9C,IAAIqB,EAAE,GAAG,MAAMD,QAAQ,CAACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAE/C,IAAI,CAACD,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzB,MAAMJ,QAAQ,CAACZ,QAAQ,CAAC,MAAM,EAAEa,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC;AAED,MAAMd,YAAY,GAAGkB,MAAM,CAACC,MAAM,CAAC1B,oBAAoB,EAAE,EAAE;IACzDU,UAAU;IACVL,eAAe;IACfU,cAAc;IACdnB,YAAY;IACZE,WAAW;IACXE,oBAAoB;IACpBmB,2BAA2B;CAC5B,CAAC,AAAC;MAEH,QAA4B,GAAbZ,YAAY"}
|
|
@@ -109,8 +109,8 @@ async function showLoginPromptAsync({ printNewLine =false , otp , ...options } =
|
|
|
109
109
|
].filter(Boolean), {
|
|
110
110
|
nonInteractiveHelp: `Use the EXPO_TOKEN environment variable to authenticate in CI (${(0, _link.learnMore)("https://docs.expo.dev/accounts/programmatic-access/")})`
|
|
111
111
|
});
|
|
112
|
-
username
|
|
113
|
-
password
|
|
112
|
+
username ??= resolved.username;
|
|
113
|
+
password ??= resolved.password;
|
|
114
114
|
}
|
|
115
115
|
// This is just for the types.
|
|
116
116
|
(0, _assert().default)(username && password);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport { Actor, getUserAsync, loginAsync, ssoLoginAsync } from './user';\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';\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 sso?: boolean | undefined;\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 const sso = options.sso;\n\n if (printNewLine) {\n Log.log();\n }\n\n if (sso) {\n await ssoLoginAsync();\n return;\n }\n\n Log.log(\n hasCredentials\n ? `Logging in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n : `Log in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n );\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","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","sso","Log","log","ssoLoginAsync","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","warn","chalk","yellow"],"mappings":"AAAA;;;;;;;;;;;IAasBA,oBAAoB,MAApBA,oBAAoB;IAiFpBC,mBAAmB,MAAnBA,mBAAmB;;;8DA9FtB,QAAQ;;;;;;;8DACT,OAAO;;;;;;qBAE6B,OAAO;sBACE,QAAQ;2DAClD,WAAW;qBACZ,iBAAiB;wBACR,oBAAoB;sBACvB,kBAAkB;8DACN,qBAAqB;wBAChC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpC,eAAeD,oBAAoB,CAAC,EACzCE,YAAY,EAAG,KAAK,CAAA,EACpBC,GAAG,CAAA,EACH,GAAGC,OAAO,EAOX,GAAG,EAAE,EAAiB;IACrB,IAAIC,IAAG,IAAA,CAACC,YAAY,EAAE;QACpB,MAAM,IAAIC,OAAY,aAAA,CAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;IAC3E,CAAC;IACD,MAAMC,cAAc,GAAGJ,OAAO,CAACK,QAAQ,IAAIL,OAAO,CAACM,QAAQ,AAAC;IAC5D,MAAMC,GAAG,GAAGP,OAAO,CAACO,GAAG,AAAC;IAExB,IAAIT,YAAY,EAAE;QAChBU,IAAG,CAACC,GAAG,EAAE,CAAC;IACZ,CAAC;IAED,IAAIF,GAAG,EAAE;QACP,MAAMG,IAAAA,KAAa,cAAA,GAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAEDF,IAAG,CAACC,GAAG,CACLL,cAAc,GACV,CAAC,uGAAuG,CAAC,GACzG,CAAC,mGAAmG,CAAC,CAC1G,CAAC;IAEF,IAAIC,QAAQ,GAAGL,OAAO,CAACK,QAAQ,AAAC;IAChC,IAAIC,QAAQ,GAAGN,OAAO,CAACM,QAAQ,AAAC;IAEhC,IAAI,CAACF,cAAc,EAAE;QACnB,MAAMO,QAAQ,GAAG,MAAMC,IAAAA,QAAW,QAAA,EAChC;YACE,CAACZ,OAAO,CAACK,QAAQ,IAAI;gBACnBQ,IAAI,EAAE,MAAM;gBACZC,IAAI,EAAE,UAAU;gBAChBC,OAAO,EAAE,mBAAmB;aAC7B;YACD,CAACf,OAAO,CAACM,QAAQ,IAAI;gBACnBO,IAAI,EAAE,UAAU;gBAChBC,IAAI,EAAE,UAAU;gBAChBC,OAAO,EAAE,UAAU;aACpB;SACF,CAACC,MAAM,CAACC,OAAO,CAAC,EACjB;YACEC,kBAAkB,EAAE,CAAC,+DAA+D,EAAEC,IAAAA,KAAS,UAAA,EAC7F,qDAAqD,CACtD,CAAC,CAAC,CAAC;SACL,CACF,AAAC;QACFd,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport { Actor, getUserAsync, loginAsync, ssoLoginAsync } from './user';\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';\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 sso?: boolean | undefined;\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 const sso = options.sso;\n\n if (printNewLine) {\n Log.log();\n }\n\n if (sso) {\n await ssoLoginAsync();\n return;\n }\n\n Log.log(\n hasCredentials\n ? `Logging in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n : `Log in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n );\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","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","sso","Log","log","ssoLoginAsync","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","warn","chalk","yellow"],"mappings":"AAAA;;;;;;;;;;;IAasBA,oBAAoB,MAApBA,oBAAoB;IAiFpBC,mBAAmB,MAAnBA,mBAAmB;;;8DA9FtB,QAAQ;;;;;;;8DACT,OAAO;;;;;;qBAE6B,OAAO;sBACE,QAAQ;2DAClD,WAAW;qBACZ,iBAAiB;wBACR,oBAAoB;sBACvB,kBAAkB;8DACN,qBAAqB;wBAChC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpC,eAAeD,oBAAoB,CAAC,EACzCE,YAAY,EAAG,KAAK,CAAA,EACpBC,GAAG,CAAA,EACH,GAAGC,OAAO,EAOX,GAAG,EAAE,EAAiB;IACrB,IAAIC,IAAG,IAAA,CAACC,YAAY,EAAE;QACpB,MAAM,IAAIC,OAAY,aAAA,CAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;IAC3E,CAAC;IACD,MAAMC,cAAc,GAAGJ,OAAO,CAACK,QAAQ,IAAIL,OAAO,CAACM,QAAQ,AAAC;IAC5D,MAAMC,GAAG,GAAGP,OAAO,CAACO,GAAG,AAAC;IAExB,IAAIT,YAAY,EAAE;QAChBU,IAAG,CAACC,GAAG,EAAE,CAAC;IACZ,CAAC;IAED,IAAIF,GAAG,EAAE;QACP,MAAMG,IAAAA,KAAa,cAAA,GAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAEDF,IAAG,CAACC,GAAG,CACLL,cAAc,GACV,CAAC,uGAAuG,CAAC,GACzG,CAAC,mGAAmG,CAAC,CAC1G,CAAC;IAEF,IAAIC,QAAQ,GAAGL,OAAO,CAACK,QAAQ,AAAC;IAChC,IAAIC,QAAQ,GAAGN,OAAO,CAACM,QAAQ,AAAC;IAEhC,IAAI,CAACF,cAAc,EAAE;QACnB,MAAMO,QAAQ,GAAG,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AAA,QAAA,CAACC,MAAM,CAAC,4CAA4C,CAAC,CAAC,CAAC;QACrE,MAAMpC,oBAAoB,CAAC;YAAEE,YAAY,EAAE,IAAI;SAAE,CAAC,CAAC;QACnD6B,IAAI,GAAG,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAAC;IAC9B,CAAC;IAEDR,IAAAA,OAAM,EAAA,QAAA,EAACO,IAAI,EAAE,0BAA0B,CAAC,CAAC;IACzC,OAAOA,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -104,7 +104,7 @@ async function getUserAsync() {
|
|
|
104
104
|
if (!_env.env.EXPO_OFFLINE && !currentUser && hasCredentials) {
|
|
105
105
|
var ref1;
|
|
106
106
|
const user = await _userQuery.UserQuery.currentUserAsync();
|
|
107
|
-
currentUser = user
|
|
107
|
+
currentUser = user ?? undefined;
|
|
108
108
|
(ref1 = (0, _telemetry.getTelemetry)()) == null ? void 0 : ref1.identify(currentUser);
|
|
109
109
|
}
|
|
110
110
|
return currentUser;
|
|
@@ -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 UserSettings from './UserSettings';\nimport { getSessionUsingBrowserAuthFlowAsync } from './expoSsoLauncher';\nimport { CurrentUserQuery } from '../../graphql/generated';\nimport * as Log from '../../log';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { getTelemetry } from '../../utils/telemetry';\nimport { getExpoWebsiteBaseUrl } from '../endpoint';\nimport { graphqlClient } from '../graphql/client';\nimport { UserQuery } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\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 'SSOUser':\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 getTelemetry()?.identify(currentUser);\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\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function ssoLoginAsync(): Promise<void> {\n const sessionSecret = await getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl: getExpoWebsiteBaseUrl(),\n });\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Browser-Flow-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\nasync function fetchUserAsync({\n sessionSecret,\n}: {\n sessionSecret: string;\n}): Promise<{ id: string; username: string }> {\n const result = await graphqlClient\n .query(\n gql`\n query UserQuery {\n meUserActor {\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 { data } = result;\n return {\n id: data.meUserActor.id,\n username: data.meUserActor.username,\n };\n}\n"],"names":["ANONYMOUS_USERNAME","getActorDisplayName","getUserAsync","loginAsync","ssoLoginAsync","logoutAsync","currentUser","user","__typename","username","firstName","UserSettings","hasCredentials","getAccessToken","getSession","sessionSecret","env","EXPO_OFFLINE","getTelemetry","UserQuery","currentUserAsync","undefined","identify","json","res","fetchAsync","method","body","JSON","stringify","data","userData","fetchUserAsync","setSessionAsync","userId","id","currentConnection","getSessionUsingBrowserAuthFlowAsync","expoWebsiteUrl","getExpoWebsiteBaseUrl","Promise","all","fs","rm","getDevelopmentCodeSigningDirectory","recursive","force","Log","log","result","graphqlClient","query","gql","fetchOptions","headers","additionalTypenames","toPromise","meUserActor"],"mappings":"AAAA;;;;;;;;;;;IAmBaA,kBAAkB,MAAlBA,kBAAkB;IAOfC,mBAAmB,MAAnBA,mBAAmB;IAabC,YAAY,MAAZA,YAAY;IAUZC,UAAU,MAAVA,UAAU;IAuBVC,aAAa,MAAbA,aAAa;IAcbC,WAAW,MAAXA,WAAW;;;yBAtFF,IAAI;;;;;;;8DACnB,aAAa;;;;;;mEAEJ,gBAAgB;iCACW,mBAAmB;2DAElD,WAAW;6BACmB,yBAAyB;qBACxD,iBAAiB;2BACR,uBAAuB;0BACd,aAAa;wBACrB,mBAAmB;2BACvB,8BAA8B;yBAC7B,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3C,IAAIC,WAAW,AAAmB,AAAC;AAE5B,MAAMN,kBAAkB,GAAG,WAAW,AAAC;AAOvC,SAASC,mBAAmB,CAACM,IAAY,EAAU;IACxD,OAAQA,IAAI,QAAY,GAAhBA,KAAAA,CAAgB,GAAhBA,IAAI,CAAEC,UAAU;QACtB,KAAK,MAAM;YACT,OAAOD,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,SAAS;YACZ,OAAOF,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,OAAO;YACV,OAAOF,IAAI,CAACG,SAAS,GAAG,CAAC,EAAEH,IAAI,CAACG,SAAS,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;QAChE;YACE,OAAOV,kBAAkB,CAAC;KAC7B;AACH,CAAC;AAEM,eAAeE,YAAY,GAA+B;QACPS,GAAyB;IAAjF,MAAMC,cAAc,GAAGD,aAAY,QAAA,CAACE,cAAc,EAAE,IAAIF,CAAAA,CAAAA,GAAyB,GAAzBA,aAAY,QAAA,CAACG,UAAU,EAAE,SAAe,GAAxCH,KAAAA,CAAwC,GAAxCA,GAAyB,CAAEI,aAAa,CAAA,AAAC;IACjG,IAAI,CAACC,IAAG,IAAA,CAACC,YAAY,IAAI,CAACX,WAAW,IAAIM,cAAc,EAAE;YAGvDM,IAAc;QAFd,MAAMX,IAAI,GAAG,MAAMY,UAAS,UAAA,CAACC,gBAAgB,EAAE,AAAC;QAChDd,WAAW,GAAGC,IAAI,
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport gql from 'graphql-tag';\n\nimport UserSettings from './UserSettings';\nimport { getSessionUsingBrowserAuthFlowAsync } from './expoSsoLauncher';\nimport { CurrentUserQuery } from '../../graphql/generated';\nimport * as Log from '../../log';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { getTelemetry } from '../../utils/telemetry';\nimport { getExpoWebsiteBaseUrl } from '../endpoint';\nimport { graphqlClient } from '../graphql/client';\nimport { UserQuery } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\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 'SSOUser':\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 getTelemetry()?.identify(currentUser);\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\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function ssoLoginAsync(): Promise<void> {\n const sessionSecret = await getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl: getExpoWebsiteBaseUrl(),\n });\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Browser-Flow-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\nasync function fetchUserAsync({\n sessionSecret,\n}: {\n sessionSecret: string;\n}): Promise<{ id: string; username: string }> {\n const result = await graphqlClient\n .query(\n gql`\n query UserQuery {\n meUserActor {\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 { data } = result;\n return {\n id: data.meUserActor.id,\n username: data.meUserActor.username,\n };\n}\n"],"names":["ANONYMOUS_USERNAME","getActorDisplayName","getUserAsync","loginAsync","ssoLoginAsync","logoutAsync","currentUser","user","__typename","username","firstName","UserSettings","hasCredentials","getAccessToken","getSession","sessionSecret","env","EXPO_OFFLINE","getTelemetry","UserQuery","currentUserAsync","undefined","identify","json","res","fetchAsync","method","body","JSON","stringify","data","userData","fetchUserAsync","setSessionAsync","userId","id","currentConnection","getSessionUsingBrowserAuthFlowAsync","expoWebsiteUrl","getExpoWebsiteBaseUrl","Promise","all","fs","rm","getDevelopmentCodeSigningDirectory","recursive","force","Log","log","result","graphqlClient","query","gql","fetchOptions","headers","additionalTypenames","toPromise","meUserActor"],"mappings":"AAAA;;;;;;;;;;;IAmBaA,kBAAkB,MAAlBA,kBAAkB;IAOfC,mBAAmB,MAAnBA,mBAAmB;IAabC,YAAY,MAAZA,YAAY;IAUZC,UAAU,MAAVA,UAAU;IAuBVC,aAAa,MAAbA,aAAa;IAcbC,WAAW,MAAXA,WAAW;;;yBAtFF,IAAI;;;;;;;8DACnB,aAAa;;;;;;mEAEJ,gBAAgB;iCACW,mBAAmB;2DAElD,WAAW;6BACmB,yBAAyB;qBACxD,iBAAiB;2BACR,uBAAuB;0BACd,aAAa;wBACrB,mBAAmB;2BACvB,8BAA8B;yBAC7B,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3C,IAAIC,WAAW,AAAmB,AAAC;AAE5B,MAAMN,kBAAkB,GAAG,WAAW,AAAC;AAOvC,SAASC,mBAAmB,CAACM,IAAY,EAAU;IACxD,OAAQA,IAAI,QAAY,GAAhBA,KAAAA,CAAgB,GAAhBA,IAAI,CAAEC,UAAU;QACtB,KAAK,MAAM;YACT,OAAOD,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,SAAS;YACZ,OAAOF,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK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AEvC,aAAa;aAC9B;SACF;QACDwC,mBAAmB,EAAE,EAAE;KACxB,CACF,CACAC,SAAS,EAAE,AAAC;IACf,MAAM,EAAE1B,IAAI,CAAA,EAAE,GAAGmB,MAAM,AAAC;IACxB,OAAO;QACLd,EAAE,EAAEL,IAAI,CAAC2B,WAAW,CAACtB,EAAE;QACvB1B,QAAQ,EAAEqB,IAAI,CAAC2B,WAAW,CAAChD,QAAQ;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -29,11 +29,10 @@ async function customizeAsync(files, options, extras) {
|
|
|
29
29
|
const { exp } = (0, _config().getConfig)(projectRoot, {
|
|
30
30
|
skipSDKVersionRequirement: true
|
|
31
31
|
});
|
|
32
|
-
var ref1;
|
|
33
32
|
// Create the destination resolution props which are used in both
|
|
34
33
|
// the query and select functions.
|
|
35
34
|
const props = {
|
|
36
|
-
webStaticPath: ((
|
|
35
|
+
webStaticPath: ((ref = exp.web) == null ? void 0 : ref.staticPath) ?? (0, _platformBundlers.getPlatformBundlers)(projectRoot, exp).web === "webpack" ? "web" : "public"
|
|
37
36
|
};
|
|
38
37
|
// If the user provided files, we'll generate them without prompting.
|
|
39
38
|
if (files.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/customize/customizeAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\n\nimport { queryAndGenerateAsync, selectAndGenerateAsync } from './generate';\nimport { Options } from './resolveOptions';\nimport { DestinationResolutionProps } from './templates';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function customizeAsync(files: string[], options: Options, extras: any[]) {\n setNodeEnv('development');\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo customize` from a subdirectory of the project.\n const projectRoot = findUpProjectRootOrAssert(process.cwd());\n\n require('@expo/env').load(projectRoot);\n\n // Get the static path (defaults to 'web/')\n // Doesn't matter if expo is installed or which mode is used.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n // Create the destination resolution props which are used in both\n // the query and select functions.\n const props: DestinationResolutionProps = {\n webStaticPath:\n exp.web?.staticPath ?? getPlatformBundlers(projectRoot, exp).web === 'webpack'\n ? 'web'\n : 'public',\n };\n\n // If the user provided files, we'll generate them without prompting.\n if (files.length) {\n return queryAndGenerateAsync(projectRoot, {\n files,\n props,\n extras,\n });\n }\n\n // Otherwise, we'll prompt the user to select which files to generate.\n await selectAndGenerateAsync(projectRoot, {\n props,\n extras,\n });\n}\n"],"names":["customizeAsync","files","options","extras","exp","setNodeEnv","projectRoot","findUpProjectRootOrAssert","process","cwd","require","load","getConfig","skipSDKVersionRequirement","props","webStaticPath","web","staticPath","getPlatformBundlers","length","queryAndGenerateAsync","selectAndGenerateAsync"],"mappings":"AAAA;;;;+BASsBA,gBAAc;;aAAdA,cAAc;;;yBATV,cAAc;;;;;;0BAEsB,YAAY;kCAGtC,kCAAkC;wBAC5B,iBAAiB;yBAChC,kBAAkB;AAEtC,eAAeA,cAAc,CAACC,KAAe,EAAEC,OAAgB,EAAEC,MAAa,EAAE;QAkBjFC,GAAO;IAjBXC,IAAAA,QAAU,WAAA,EAAC,aAAa,CAAC,CAAC;IAC1B,0EAA0E;IAC1E,qFAAqF;IACrF,MAAMC,WAAW,GAAGC,IAAAA,OAAyB,0BAAA,EAACC,OAAO,CAACC,GAAG,EAAE,CAAC,AAAC;IAE7DC,OAAO,CAAC,WAAW,CAAC,CAACC,IAAI,CAACL,WAAW,CAAC,CAAC;IAEvC,2CAA2C;IAC3C,6DAA6D;IAC7D,MAAM,EAAEF,GAAG,CAAA,EAAE,GAAGQ,IAAAA,OAAS,EAAA,UAAA,EAACN,WAAW,EAAE;QACrCO,yBAAyB,EAAE,IAAI;KAChC,CAAC,AAAC;
|
|
1
|
+
{"version":3,"sources":["../../../src/customize/customizeAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\n\nimport { queryAndGenerateAsync, selectAndGenerateAsync } from './generate';\nimport { Options } from './resolveOptions';\nimport { DestinationResolutionProps } from './templates';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function customizeAsync(files: string[], options: Options, extras: any[]) {\n setNodeEnv('development');\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo customize` from a subdirectory of the project.\n const projectRoot = findUpProjectRootOrAssert(process.cwd());\n\n require('@expo/env').load(projectRoot);\n\n // Get the static path (defaults to 'web/')\n // Doesn't matter if expo is installed or which mode is used.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n // Create the destination resolution props which are used in both\n // the query and select functions.\n const props: DestinationResolutionProps = {\n webStaticPath:\n exp.web?.staticPath ?? getPlatformBundlers(projectRoot, exp).web === 'webpack'\n ? 'web'\n : 'public',\n };\n\n // If the user provided files, we'll generate them without prompting.\n if (files.length) {\n return queryAndGenerateAsync(projectRoot, {\n files,\n props,\n extras,\n });\n }\n\n // Otherwise, we'll prompt the user to select which files to generate.\n await selectAndGenerateAsync(projectRoot, {\n props,\n extras,\n });\n}\n"],"names":["customizeAsync","files","options","extras","exp","setNodeEnv","projectRoot","findUpProjectRootOrAssert","process","cwd","require","load","getConfig","skipSDKVersionRequirement","props","webStaticPath","web","staticPath","getPlatformBundlers","length","queryAndGenerateAsync","selectAndGenerateAsync"],"mappings":"AAAA;;;;+BASsBA,gBAAc;;aAAdA,cAAc;;;yBATV,cAAc;;;;;;0BAEsB,YAAY;kCAGtC,kCAAkC;wBAC5B,iBAAiB;yBAChC,kBAAkB;AAEtC,eAAeA,cAAc,CAACC,KAAe,EAAEC,OAAgB,EAAEC,MAAa,EAAE;QAkBjFC,GAAO;IAjBXC,IAAAA,QAAU,WAAA,EAAC,aAAa,CAAC,CAAC;IAC1B,0EAA0E;IAC1E,qFAAqF;IACrF,MAAMC,WAAW,GAAGC,IAAAA,OAAyB,0BAAA,EAACC,OAAO,CAACC,GAAG,EAAE,CAAC,AAAC;IAE7DC,OAAO,CAAC,WAAW,CAAC,CAACC,IAAI,CAACL,WAAW,CAAC,CAAC;IAEvC,2CAA2C;IAC3C,6DAA6D;IAC7D,MAAM,EAAEF,GAAG,CAAA,EAAE,GAAGQ,IAAAA,OAAS,EAAA,UAAA,EAACN,WAAW,EAAE;QACrCO,yBAAyB,EAAE,IAAI;KAChC,CAAC,AAAC;IAEH,iEAAiE;IACjE,kCAAkC;IAClC,MAAMC,KAAK,GAA+B;QACxCC,aAAa,EACXX,CAAAA,CAAAA,GAAO,GAAPA,GAAG,CAACY,GAAG,SAAY,GAAnBZ,KAAAA,CAAmB,GAAnBA,GAAO,CAAEa,UAAU,CAAA,IAAIC,IAAAA,iBAAmB,oBAAA,EAACZ,WAAW,EAAEF,GAAG,CAAC,CAACY,GAAG,KAAK,SAAS,GAC1E,KAAK,GACL,QAAQ;KACf,AAAC;IAEF,qEAAqE;IACrE,IAAIf,KAAK,CAACkB,MAAM,EAAE;QAChB,OAAOC,IAAAA,SAAqB,sBAAA,EAACd,WAAW,EAAE;YACxCL,KAAK;YACLa,KAAK;YACLX,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,sEAAsE;IACtE,MAAMkB,IAAAA,SAAsB,uBAAA,EAACf,WAAW,EAAE;QACxCQ,KAAK;QACLX,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -36,45 +36,6 @@ function _interopRequireDefault(obj) {
|
|
|
36
36
|
default: obj
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
40
|
-
if (typeof WeakMap !== "function") return null;
|
|
41
|
-
var cacheBabelInterop = new WeakMap();
|
|
42
|
-
var cacheNodeInterop = new WeakMap();
|
|
43
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
44
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
45
|
-
})(nodeInterop);
|
|
46
|
-
}
|
|
47
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
48
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
49
|
-
return obj;
|
|
50
|
-
}
|
|
51
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
52
|
-
return {
|
|
53
|
-
default: obj
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
57
|
-
if (cache && cache.has(obj)) {
|
|
58
|
-
return cache.get(obj);
|
|
59
|
-
}
|
|
60
|
-
var newObj = {};
|
|
61
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
62
|
-
for(var key in obj){
|
|
63
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
64
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
65
|
-
if (desc && (desc.get || desc.set)) {
|
|
66
|
-
Object.defineProperty(newObj, key, desc);
|
|
67
|
-
} else {
|
|
68
|
-
newObj[key] = obj[key];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
newObj.default = obj;
|
|
73
|
-
if (cache) {
|
|
74
|
-
cache.set(obj, newObj);
|
|
75
|
-
}
|
|
76
|
-
return newObj;
|
|
77
|
-
}
|
|
78
39
|
async function queryAndGenerateAsync(projectRoot, { files , props , extras }) {
|
|
79
40
|
const valid = files.filter((file)=>!!_templates.TEMPLATES.find((template)=>template.destination(props) === file));
|
|
80
41
|
if (valid.length !== files.length) {
|
|
@@ -106,9 +67,10 @@ async function generateAsync(projectRoot, { answer , props , extras }) {
|
|
|
106
67
|
// Copy files
|
|
107
68
|
await Promise.all(answer.map(async (file)=>{
|
|
108
69
|
const template = _templates.TEMPLATES[file];
|
|
109
|
-
if (template.
|
|
110
|
-
|
|
111
|
-
|
|
70
|
+
if (template.configureAsync) {
|
|
71
|
+
if (await template.configureAsync(projectRoot)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
112
74
|
}
|
|
113
75
|
const projectFilePath = _path().default.resolve(projectRoot, template.destination(props));
|
|
114
76
|
// copy the file from template
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/customize/generate.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { DestinationResolutionProps, selectTemplatesAsync, TEMPLATES } from './templates';\nimport { installAsync } from '../install/installAsync';\nimport { Log } from '../log';\nimport { copyAsync } from '../utils/dir';\nimport { CommandError } from '../utils/errors';\n\nexport async function queryAndGenerateAsync(\n projectRoot: string,\n {\n files,\n props,\n extras,\n }: {\n files: string[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const valid = files.filter(\n (file) => !!TEMPLATES.find((template) => template.destination(props) === file)\n );\n\n if (valid.length !== files.length) {\n const diff = files.filter(\n (file) => !TEMPLATES.find((template) => template.destination(props) === file)\n );\n throw new CommandError(\n `Invalid files: ${diff.join(', ')}. Allowed: ${TEMPLATES.map((template) =>\n template.destination(props)\n ).join(', ')}`\n );\n }\n\n if (!valid.length) {\n return;\n }\n Log.log(`Generating: ${valid.join(', ')}`);\n return generateAsync(projectRoot, {\n answer: files.map((file) =>\n TEMPLATES.findIndex((template) => template.destination(props) === file)\n ),\n props,\n extras,\n });\n}\n\n/** Select templates to generate then generate and install. */\nexport async function selectAndGenerateAsync(\n projectRoot: string,\n {\n props,\n extras,\n }: {\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const answer = await selectTemplatesAsync(projectRoot, props);\n\n if (!answer?.length) {\n Log.exit('\\n\\u203A Exiting with no change...', 0);\n }\n\n await generateAsync(projectRoot, {\n answer,\n props,\n extras,\n });\n}\n\nasync function generateAsync(\n projectRoot: string,\n {\n answer,\n props,\n extras,\n }: {\n answer: number[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n // Copy files\n await Promise.all(\n answer.map(async (file) => {\n const template = TEMPLATES[file];\n\n if (template.
|
|
1
|
+
{"version":3,"sources":["../../../src/customize/generate.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { DestinationResolutionProps, selectTemplatesAsync, TEMPLATES } from './templates';\nimport { installAsync } from '../install/installAsync';\nimport { Log } from '../log';\nimport { copyAsync } from '../utils/dir';\nimport { CommandError } from '../utils/errors';\n\nexport async function queryAndGenerateAsync(\n projectRoot: string,\n {\n files,\n props,\n extras,\n }: {\n files: string[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const valid = files.filter(\n (file) => !!TEMPLATES.find((template) => template.destination(props) === file)\n );\n\n if (valid.length !== files.length) {\n const diff = files.filter(\n (file) => !TEMPLATES.find((template) => template.destination(props) === file)\n );\n throw new CommandError(\n `Invalid files: ${diff.join(', ')}. Allowed: ${TEMPLATES.map((template) =>\n template.destination(props)\n ).join(', ')}`\n );\n }\n\n if (!valid.length) {\n return;\n }\n Log.log(`Generating: ${valid.join(', ')}`);\n return generateAsync(projectRoot, {\n answer: files.map((file) =>\n TEMPLATES.findIndex((template) => template.destination(props) === file)\n ),\n props,\n extras,\n });\n}\n\n/** Select templates to generate then generate and install. */\nexport async function selectAndGenerateAsync(\n projectRoot: string,\n {\n props,\n extras,\n }: {\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const answer = await selectTemplatesAsync(projectRoot, props);\n\n if (!answer?.length) {\n Log.exit('\\n\\u203A Exiting with no change...', 0);\n }\n\n await generateAsync(projectRoot, {\n answer,\n props,\n extras,\n });\n}\n\nasync function generateAsync(\n projectRoot: string,\n {\n answer,\n props,\n extras,\n }: {\n answer: number[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n // Copy files\n await Promise.all(\n answer.map(async (file) => {\n const template = TEMPLATES[file];\n\n if (template.configureAsync) {\n if (await template.configureAsync(projectRoot)) {\n return;\n }\n }\n\n const projectFilePath = path.resolve(projectRoot, template.destination(props));\n // copy the file from template\n return copyAsync(template.file(projectRoot), projectFilePath, {\n overwrite: true,\n recursive: true,\n });\n })\n );\n\n // Install dependencies\n const packages = answer\n .map((file) => TEMPLATES[file].dependencies)\n .flat()\n .filter((pkg) => !resolveFrom.silent(projectRoot, pkg));\n if (packages.length) {\n Log.debug('Installing ' + packages.join(', '));\n await installAsync(packages, {}, ['--dev', ...extras]);\n }\n}\n"],"names":["queryAndGenerateAsync","selectAndGenerateAsync","projectRoot","files","props","extras","valid","filter","file","TEMPLATES","find","template","destination","length","diff","CommandError","join","map","Log","log","generateAsync","answer","findIndex","selectTemplatesAsync","exit","Promise","all","configureAsync","projectFilePath","path","resolve","copyAsync","overwrite","recursive","packages","dependencies","flat","pkg","resolveFrom","silent","debug","installAsync"],"mappings":"AAAA;;;;;;;;;;;IASsBA,qBAAqB,MAArBA,qBAAqB;IA0CrBC,sBAAsB,MAAtBA,sBAAsB;;;8DAnD3B,MAAM;;;;;;;8DACC,cAAc;;;;;;2BAEsC,aAAa;8BAC5D,yBAAyB;qBAClC,QAAQ;qBACF,cAAc;wBACX,iBAAiB;;;;;;AAEvC,eAAeD,qBAAqB,CACzCE,WAAmB,EACnB,EACEC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,MAAM,CAAA,EAMP,EACD;IACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CACxB,CAACC,IAAI,GAAK,CAAC,CAACC,UAAS,UAAA,CAACC,IAAI,CAAC,CAACC,QAAQ,GAAKA,QAAQ,CAACC,WAAW,CAACR,KAAK,CAAC,KAAKI,IAAI,CAAC,CAC/E,AAAC;IAEF,IAAIF,KAAK,CAACO,MAAM,KAAKV,KAAK,CAACU,MAAM,EAAE;QACjC,MAAMC,IAAI,GAAGX,KAAK,CAACI,MAAM,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Q,CAAClB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,MAAMyB,IAAAA,aAAY,aAAA,EAACP,QAAQ,EAAE,EAAE,EAAE;YAAC,OAAO;eAAK7B,MAAM;SAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -79,14 +79,6 @@ const TEMPLATES = [
|
|
|
79
79
|
"babel-preset-expo",
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
-
{
|
|
83
|
-
id: "webpack.config.js",
|
|
84
|
-
file: (projectRoot)=>importFromExpoWebpackConfig(projectRoot, "template", "webpack.config.js"),
|
|
85
|
-
destination: ()=>"webpack.config.js",
|
|
86
|
-
dependencies: [
|
|
87
|
-
"@expo/webpack-config"
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
82
|
{
|
|
91
83
|
id: "metro.config.js",
|
|
92
84
|
dependencies: [
|
|
@@ -96,11 +88,30 @@ const TEMPLATES = [
|
|
|
96
88
|
file: (projectRoot)=>importFromVendor(projectRoot, "metro.config.js")
|
|
97
89
|
},
|
|
98
90
|
{
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
destination: (
|
|
103
|
-
|
|
91
|
+
// `tsconfig.json` is special-cased and doesn't follow the template.
|
|
92
|
+
id: "tsconfig.json",
|
|
93
|
+
dependencies: [],
|
|
94
|
+
destination: ()=>"tsconfig.json",
|
|
95
|
+
file: ()=>"",
|
|
96
|
+
configureAsync: async (projectRoot)=>{
|
|
97
|
+
const { typescript } = require("./typescript");
|
|
98
|
+
await typescript(projectRoot);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: ".eslintrc.js",
|
|
104
|
+
dependencies: [],
|
|
105
|
+
destination: ()=>".eslintrc.js",
|
|
106
|
+
file: (projectRoot)=>importFromVendor(projectRoot, ".eslintrc.js"),
|
|
107
|
+
configureAsync: async (projectRoot)=>{
|
|
108
|
+
const { ESLintProjectPrerequisite } = require("../lint/ESlintPrerequisite");
|
|
109
|
+
const prerequisite = new ESLintProjectPrerequisite(projectRoot);
|
|
110
|
+
if (!await prerequisite.assertAsync()) {
|
|
111
|
+
await prerequisite.bootstrapAsync();
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
104
115
|
},
|
|
105
116
|
{
|
|
106
117
|
id: "index.html",
|
|
@@ -110,11 +121,12 @@ const TEMPLATES = [
|
|
|
110
121
|
dependencies: []
|
|
111
122
|
},
|
|
112
123
|
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
id: "webpack.config.js",
|
|
125
|
+
file: (projectRoot)=>importFromExpoWebpackConfig(projectRoot, "template", "webpack.config.js"),
|
|
126
|
+
destination: ()=>"webpack.config.js",
|
|
127
|
+
dependencies: [
|
|
128
|
+
"@expo/webpack-config"
|
|
129
|
+
]
|
|
118
130
|
},
|
|
119
131
|
];
|
|
120
132
|
/** Generate the prompt choices. */ function createChoices(projectRoot, props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/customize/templates.ts"],"sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport prompt, { ExpoChoice } from '../utils/prompts';\n\nconst debug = require('debug')('expo:customize:templates');\n\nexport type DestinationResolutionProps = {\n /** Web 'public' folder path (defaults to `/web`). This technically can be changed but shouldn't be. */\n webStaticPath: string;\n};\n\nfunction importFromExpoWebpackConfig(projectRoot: string, folder: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, `@expo/webpack-config/${folder}/${moduleId}`);\n debug(`Using @expo/webpack-config template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n debug(`@expo/webpack-config template for \"${moduleId}\" not found, falling back on @expo/cli`);\n }\n return importFromVendor(projectRoot, moduleId);\n}\n\nfunction importFromVendor(projectRoot: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, '@expo/cli/static/template/' + moduleId);\n debug(`Using @expo/cli template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n // For dev mode, testing and other cases where @expo/cli is not installed\n const filePath = require.resolve(`@expo/cli/static/template/${moduleId}`);\n debug(\n `Local @expo/cli template for \"${moduleId}\" not found, falling back on template relative to @expo/cli: ${filePath}`\n );\n\n return filePath;\n }\n}\n\nexport const TEMPLATES: {\n /** Unique ID for easily indexing. */\n id: string;\n /** Template file path to copy into the project. */\n file: (projectRoot: string) => string;\n /** Output location for the file in the user project. */\n destination: (props: DestinationResolutionProps) => string;\n /** List of dependencies to install in the project. These are used inside of the template file. */\n dependencies: string[];\n}[] = [\n {\n id: 'babel.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'babel.config.js'),\n destination: () => 'babel.config.js',\n dependencies: [\n // Even though this is installed in `expo`, we should add it for now.\n 'babel-preset-expo',\n ],\n },\n {\n id: '
|
|
1
|
+
{"version":3,"sources":["../../../src/customize/templates.ts"],"sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport prompt, { ExpoChoice } from '../utils/prompts';\n\nconst debug = require('debug')('expo:customize:templates');\n\nexport type DestinationResolutionProps = {\n /** Web 'public' folder path (defaults to `/web`). This technically can be changed but shouldn't be. */\n webStaticPath: string;\n};\n\nfunction importFromExpoWebpackConfig(projectRoot: string, folder: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, `@expo/webpack-config/${folder}/${moduleId}`);\n debug(`Using @expo/webpack-config template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n debug(`@expo/webpack-config template for \"${moduleId}\" not found, falling back on @expo/cli`);\n }\n return importFromVendor(projectRoot, moduleId);\n}\n\nfunction importFromVendor(projectRoot: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, '@expo/cli/static/template/' + moduleId);\n debug(`Using @expo/cli template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n // For dev mode, testing and other cases where @expo/cli is not installed\n const filePath = require.resolve(`@expo/cli/static/template/${moduleId}`);\n debug(\n `Local @expo/cli template for \"${moduleId}\" not found, falling back on template relative to @expo/cli: ${filePath}`\n );\n\n return filePath;\n }\n}\n\nexport const TEMPLATES: {\n /** Unique ID for easily indexing. */\n id: string;\n /** Template file path to copy into the project. */\n file: (projectRoot: string) => string;\n /** Output location for the file in the user project. */\n destination: (props: DestinationResolutionProps) => string;\n /** List of dependencies to install in the project. These are used inside of the template file. */\n dependencies: string[];\n\n /** Custom step for configuring the file. Return true to exit early. */\n configureAsync?: (projectRoot: string) => Promise<boolean>;\n}[] = [\n {\n id: 'babel.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'babel.config.js'),\n destination: () => 'babel.config.js',\n dependencies: [\n // Even though this is installed in `expo`, we should add it for now.\n 'babel-preset-expo',\n ],\n },\n {\n id: 'metro.config.js',\n dependencies: ['@expo/metro-config'],\n destination: () => 'metro.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'metro.config.js'),\n },\n {\n // `tsconfig.json` is special-cased and doesn't follow the template.\n id: 'tsconfig.json',\n dependencies: [],\n destination: () => 'tsconfig.json',\n file: () => '',\n configureAsync: async (projectRoot) => {\n const { typescript } = require('./typescript') as typeof import('./typescript');\n await typescript(projectRoot);\n return true;\n },\n },\n {\n id: '.eslintrc.js',\n dependencies: [],\n destination: () => '.eslintrc.js',\n file: (projectRoot) => importFromVendor(projectRoot, '.eslintrc.js'),\n configureAsync: async (projectRoot) => {\n const { ESLintProjectPrerequisite } =\n require('../lint/ESlintPrerequisite') as typeof import('../lint/ESlintPrerequisite.js');\n const prerequisite = new ESLintProjectPrerequisite(projectRoot);\n if (!(await prerequisite.assertAsync())) {\n await prerequisite.bootstrapAsync();\n }\n return false;\n },\n },\n {\n id: 'index.html',\n file: (projectRoot) => importFromExpoWebpackConfig(projectRoot, 'web-default', 'index.html'),\n // web/index.html\n destination: ({ webStaticPath }) => webStaticPath + '/index.html',\n dependencies: [],\n },\n {\n id: 'webpack.config.js',\n file: (projectRoot) =>\n importFromExpoWebpackConfig(projectRoot, 'template', 'webpack.config.js'),\n destination: () => 'webpack.config.js',\n dependencies: ['@expo/webpack-config'],\n },\n];\n\n/** Generate the prompt choices. */\nfunction createChoices(\n projectRoot: string,\n props: DestinationResolutionProps\n): ExpoChoice<number>[] {\n return TEMPLATES.map((template, index) => {\n const destination = template.destination(props);\n const localProjectFile = path.resolve(projectRoot, destination);\n const exists = fs.existsSync(localProjectFile);\n\n return {\n title: destination,\n value: index,\n description: exists ? chalk.red('This will overwrite the existing file') : undefined,\n };\n });\n}\n\n/** Prompt to select templates to add. */\nexport async function selectTemplatesAsync(projectRoot: string, props: DestinationResolutionProps) {\n const options = createChoices(projectRoot, props);\n\n const { answer } = await prompt({\n type: 'multiselect',\n name: 'answer',\n message: 'Which files would you like to generate?',\n hint: '- Space to select. Return to submit',\n warn: 'File already exists.',\n limit: options.length,\n instructions: '',\n choices: options,\n });\n return answer;\n}\n"],"names":["TEMPLATES","selectTemplatesAsync","debug","require","importFromExpoWebpackConfig","projectRoot","folder","moduleId","filePath","resolveFrom","importFromVendor","resolve","id","file","destination","dependencies","configureAsync","typescript","ESLintProjectPrerequisite","prerequisite","assertAsync","bootstrapAsync","webStaticPath","createChoices","props","map","template","index","localProjectFile","path","exists","fs","existsSync","title","value","description","chalk","red","undefined","options","answer","prompt","type","name","message","hint","warn","limit","length","instructions","choices"],"mappings":"AAAA;;;;;;;;;;;IAyCaA,SAAS,MAATA,SAAS;IA0FAC,oBAAoB,MAApBA,oBAAoB;;;8DAnIxB,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;;8DACC,cAAc;;;;;;8DAEH,kBAAkB;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,AAAC;AAO3D,SAASC,2BAA2B,CAACC,WAAmB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CAAyC;QAClDC,IAAI,EAAE,qCAAqC;QAC3CC,IAAI,EAAE,sBAAsB;QAC5BC,KAAK,EAAER,OAAO,CAACS,MAAM;QACrBC,YAAY,EAAE,EAAE;QAChBC,OAAO,EAAEX,OAAO;KACjB,CAAC,AAAC;IACH,OAAOC,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/createMetadataJson.ts"],"sourcesContent":["import path from 'path';\n\nimport { BundleOutput } from './
|
|
1
|
+
{"version":3,"sources":["../../../src/export/createMetadataJson.ts"],"sourcesContent":["import path from 'path';\n\nimport type { BundleOutput } from './saveAssets';\n\nexport type BundlePlatform = 'android' | 'ios';\n\ntype PlatformMetadataAsset = { path: string; ext: string };\n\ntype PlatformMetadata = { bundle: string; assets: PlatformMetadataAsset[] };\n\ntype FileMetadata = {\n [key in BundlePlatform]: PlatformMetadata;\n};\n\nexport function createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n}: {\n bundles: Partial<Record<BundlePlatform, Pick<BundleOutput, 'assets'>>>;\n fileNames: Record<string, string[]>;\n embeddedHashSet?: Set<string>;\n}): {\n version: 0;\n bundler: 'metro';\n fileMetadata: FileMetadata;\n} {\n // Build metadata.json\n return {\n version: 0,\n bundler: 'metro',\n fileMetadata: Object.entries(bundles).reduce<Record<string, Partial<PlatformMetadata>>>(\n (metadata, [platform, bundle]) => {\n if (platform === 'web') return metadata;\n\n return {\n ...metadata,\n [platform]: {\n // Get the filename for each platform's bundle.\n // TODO: Add multi-bundle support to EAS Update!!\n bundle: fileNames[platform][0],\n // Collect all of the assets and convert them to the serial format.\n assets: bundle.assets\n .filter((asset) => !embeddedHashSet || !embeddedHashSet.has(asset.hash))\n .map((asset) =>\n // Each asset has multiple hashes which we convert and then flatten.\n asset.fileHashes?.map((hash) => ({\n path: path.join('assets', hash),\n ext: asset.type,\n }))\n )\n .filter(Boolean)\n .flat(),\n },\n };\n },\n {}\n ) as FileMetadata,\n };\n}\n"],"names":["createMetadataJson","bundles","fileNames","embeddedHashSet","version","bundler","fileMetadata","Object","entries","reduce","metadata","platform","bundle","assets","filter","asset","has","hash","map","fileHashes","path","join","ext","type","Boolean","flat"],"mappings":"AAAA;;;;+BAcgBA,oBAAkB;;aAAlBA,kBAAkB;;;8DAdjB,MAAM;;;;;;;;;;;AAchB,SAASA,kBAAkB,CAAC,EACjCC,OAAO,CAAA,EACPC,SAAS,CAAA,EACTC,eAAe,CAAA,EAKhB,EAIC;IACA,sBAAsB;IACtB,OAAO;QACLC,OAAO,EAAE,CAAC;QACVC,OAAO,EAAE,OAAO;QAChBC,YAAY,EAAEC,MAAM,CAACC,OAAO,CAACP,OAAO,CAAC,CAACQ,MAAM,CAC1C,CAACC,QAAQ,EAAE,CAACC,QAAQ,EAAEC,MAAM,CAAC,GAAK;YAChC,IAAID,QAAQ,KAAK,KAAK,EAAE,OAAOD,QAAQ,CAAC;YAExC,OAAO;gBACL,GAAGA,QAAQ;gBACX,CAACC,QAAQ,CAAC,EAAE;oBACV,+CAA+C;oBAC/C,iDAAiD;oBACjDC,MAAM,EAAEV,SAAS,CAACS,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAC9B,mEAAmE;oBACnEE,MAAM,EAAED,MAAM,CAACC,MAAM,CAClBC,MAAM,CAAC,CAACC,KAAK,GAAK,CAACZ,eAAe,IAAI,CAACA,eAAe,CAACa,GAAG,CAACD,KAAK,CAACE,IAAI,CAAC,CAAC,CACvEC,GAAG,CAAC,CAACH,KAAK;4BACT,oEAAoE;wBACpEA,GAAgB;wBAAhBA,OAAAA,CAAAA,GAAgB,GAAhBA,KAAK,CAACI,UAAU,SAAK,GAArBJ,KAAAA,CAAqB,GAArBA,GAAgB,CAAEG,GAAG,CAAC,CAACD,IAAI,GAAK,CAAC;gCAC/BG,IAAI,EAAEA,KAAI,EAAA,QAAA,CAACC,IAAI,CAAC,QAAQ,EAAEJ,IAAI,CAAC;gCAC/BK,GAAG,EAAEP,K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