@expo/cli 56.1.4 → 56.1.6
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/user/actions.js +7 -0
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/api/user/expoSsoLauncher.js +2 -8
- package/build/src/api/user/expoSsoLauncher.js.map +1 -1
- package/build/src/api/user/user.js +12 -0
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +1 -1
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/exportServer.js +1 -1
- package/build/src/export/embed/exportServer.js.map +1 -1
- package/build/src/export/exportApp.js +1 -1
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/publicFolder.js +19 -1
- package/build/src/export/publicFolder.js.map +1 -1
- package/build/src/login/index.js +25 -5
- package/build/src/login/index.js.map +1 -1
- package/build/src/run/android/resolveLaunchProps.js +4 -1
- package/build/src/run/android/resolveLaunchProps.js.map +1 -1
- package/build/src/start/doctor/dependencies/reactNativeTv.js +149 -0
- package/build/src/start/doctor/dependencies/reactNativeTv.js.map +1 -0
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +28 -3
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +4 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/server/DevToolsPlugin.js +26 -1
- package/build/src/start/server/DevToolsPlugin.js.map +1 -1
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js +57 -22
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +1 -1
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js +29 -0
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +1 -1
- package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js +15 -5
- package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +4 -0
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/createMCPDevToolsExtensionSchema.js +13 -1
- package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +95 -32
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +13 -13
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMessageSocket.js +13 -2
- package/build/src/start/server/metro/dev-server/createMessageSocket.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +2 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +5 -4
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/router.js +10 -1
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +8 -4
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/OpenMiddleware.js +150 -0
- package/build/src/start/server/middleware/OpenMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +13 -4
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ServeStaticMiddleware.js +2 -9
- package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/openHandlers.js +157 -0
- package/build/src/start/server/middleware/openHandlers.js.map +1 -0
- package/build/src/start/server/type-generation/routes.js +1 -3
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/server/webTemplate.js +3 -5
- package/build/src/start/server/webTemplate.js.map +1 -1
- package/build/src/utils/net.js +7 -1
- package/build/src/utils/net.js.map +1 -1
- package/build/src/utils/open.js +243 -11
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/tar.js +2 -2
- package/build/src/utils/tar.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +17 -18
- package/static/loading-page/index.html +35 -1
package/build/bin/cli
CHANGED
|
@@ -35,6 +35,7 @@ const _user = require("./user");
|
|
|
35
35
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../log"));
|
|
36
36
|
const _env = require("../../utils/env");
|
|
37
37
|
const _errors = require("../../utils/errors");
|
|
38
|
+
const _interactive = require("../../utils/interactive");
|
|
38
39
|
const _link = require("../../utils/link");
|
|
39
40
|
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("../../utils/prompts"));
|
|
40
41
|
const _client = require("../rest/client");
|
|
@@ -142,6 +143,12 @@ async function tryGetUserAsync() {
|
|
|
142
143
|
if (user) {
|
|
143
144
|
return user;
|
|
144
145
|
}
|
|
146
|
+
// In non-interactive environments (CI, non-TTY) we can't prompt for login. Proceed
|
|
147
|
+
// anonymously so callers like the Expo Go manifest code-signing flow degrade
|
|
148
|
+
// gracefully instead of bubbling a NON_INTERACTIVE error to the client.
|
|
149
|
+
if (!(0, _interactive.isInteractive)()) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
145
152
|
const choices = [
|
|
146
153
|
{
|
|
147
154
|
title: 'Log in',
|
|
@@ -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 type { Actor } from './user';\nimport { getUserAsync, loginAsync, browserLoginAsync } from './user';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport type { Question } from '../../utils/prompts';\nimport promptAsync, { selectAsync } 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 browser?: 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 const browser = options.browser;\n\n if (printNewLine) {\n Log.log();\n }\n\n if (sso || browser) {\n await browserLoginAsync({ sso: !!sso });\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\nexport async function tryGetUserAsync(): Promise<Actor | null> {\n const user = await getUserAsync().catch(() => null);\n\n if (user) {\n return user;\n }\n\n const choices = [\n {\n title: 'Log in',\n value: true,\n },\n {\n title: 'Proceed anonymously',\n value: false,\n },\n ];\n\n const value = await selectAsync(\n chalk`\\n\\nIt is recommended to log in with your Expo account before proceeding. \\n{dim ${learnMore(\n 'https://expo.fyi/unverified-app-expo-go'\n )}}\\n`,\n choices,\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\n if (value) {\n await showLoginPromptAsync({ printNewLine: true });\n return (await getUserAsync()) ?? null;\n }\n\n return null;\n}\n"],"names":["showLoginPromptAsync","tryGetUserAsync","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","sso","browser","Log","log","browserLoginAsync","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","choices","title","value","selectAsync","chalk"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport type { Actor } from './user';\nimport { getUserAsync, loginAsync, browserLoginAsync } from './user';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { isInteractive } from '../../utils/interactive';\nimport { learnMore } from '../../utils/link';\nimport type { Question } from '../../utils/prompts';\nimport promptAsync, { selectAsync } 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 browser?: 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 const browser = options.browser;\n\n if (printNewLine) {\n Log.log();\n }\n\n if (sso || browser) {\n await browserLoginAsync({ sso: !!sso });\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\nexport async function tryGetUserAsync(): Promise<Actor | null> {\n const user = await getUserAsync().catch(() => null);\n\n if (user) {\n return user;\n }\n\n // In non-interactive environments (CI, non-TTY) we can't prompt for login. Proceed\n // anonymously so callers like the Expo Go manifest code-signing flow degrade\n // gracefully instead of bubbling a NON_INTERACTIVE error to the client.\n if (!isInteractive()) {\n return null;\n }\n\n const choices = [\n {\n title: 'Log in',\n value: true,\n },\n {\n title: 'Proceed anonymously',\n value: false,\n },\n ];\n\n const value = await selectAsync(\n chalk`\\n\\nIt is recommended to log in with your Expo account before proceeding. \\n{dim ${learnMore(\n 'https://expo.fyi/unverified-app-expo-go'\n )}}\\n`,\n choices,\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\n if (value) {\n await showLoginPromptAsync({ printNewLine: true });\n return (await getUserAsync()) ?? null;\n }\n\n return null;\n}\n"],"names":["showLoginPromptAsync","tryGetUserAsync","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","sso","browser","Log","log","browserLoginAsync","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","isInteractive","choices","title","value","selectAsync","chalk"],"mappings":";;;;;;;;;;;QAgBsBA;eAAAA;;QAkFAC;eAAAA;;;;gEAlGH;;;;;;;gEACD;;;;;;qBAEoC;sBAEM;6DACvC;qBACD;wBACS;6BACC;sBACJ;iEAEe;wBACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpB,eAAeD,qBAAqB,EACzCE,eAAe,KAAK,EACpBC,GAAG,EACH,GAAGC,SAQJ,GAAG,CAAC,CAAC;IACJ,IAAIC,QAAG,CAACC,YAAY,EAAE;QACpB,MAAM,IAAIC,oBAAY,CAAC,WAAW;IACpC;IACA,MAAMC,iBAAiBJ,QAAQK,QAAQ,IAAIL,QAAQM,QAAQ;IAC3D,MAAMC,MAAMP,QAAQO,GAAG;IACvB,MAAMC,UAAUR,QAAQQ,OAAO;IAE/B,IAAIV,cAAc;QAChBW,KAAIC,GAAG;IACT;IAEA,IAAIH,OAAOC,SAAS;QAClB,MAAMG,IAAAA,uBAAiB,EAAC;YAAEJ,KAAK,CAAC,CAACA;QAAI;QACrC;IACF;IAEAE,KAAIC,GAAG,CACLN,iBACI,CAAC,uGAAuG,CAAC,GACzG,CAAC,mGAAmG,CAAC;IAG3G,IAAIC,WAAWL,QAAQK,QAAQ;IAC/B,IAAIC,WAAWN,QAAQM,QAAQ;IAE/B,IAAI,CAACF,gBAAgB;QACnB,MAAMQ,WAAW,MAAMC,IAAA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EE,cAAc;QAAK;QAChD,OAAO,AAAC,MAAM+B,IAAAA,kBAAY,OAAO;IACnC;IAEA,OAAO;AACT"}
|
|
@@ -15,13 +15,6 @@ function _assert() {
|
|
|
15
15
|
};
|
|
16
16
|
return data;
|
|
17
17
|
}
|
|
18
|
-
function _betteropn() {
|
|
19
|
-
const data = /*#__PURE__*/ _interop_require_default(require("better-opn"));
|
|
20
|
-
_betteropn = function() {
|
|
21
|
-
return data;
|
|
22
|
-
};
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
25
18
|
function _crypto() {
|
|
26
19
|
const data = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
|
27
20
|
_crypto = function() {
|
|
@@ -38,6 +31,7 @@ function _http() {
|
|
|
38
31
|
}
|
|
39
32
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../log"));
|
|
40
33
|
const _errors = require("../../utils/errors");
|
|
34
|
+
const _open = require("../../utils/open");
|
|
41
35
|
const _client = require("../rest/client");
|
|
42
36
|
function _interop_require_default(obj) {
|
|
43
37
|
return obj && obj.__esModule ? obj : {
|
|
@@ -191,7 +185,7 @@ async function getSessionUsingBrowserAuthFlowAsync({ expoWebsiteUrl, sso = false
|
|
|
191
185
|
const port = address.port;
|
|
192
186
|
const authorizeUrl = buildExpoLoginUrl(port, sso);
|
|
193
187
|
_log.log(`If your browser doesn't automatically open, visit this link to log in: ${authorizeUrl}`);
|
|
194
|
-
(0,
|
|
188
|
+
(0, _open.openBrowserAsync)(authorizeUrl);
|
|
195
189
|
});
|
|
196
190
|
server.on('connection', (connection)=>{
|
|
197
191
|
connections.add(connection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/expoSsoLauncher.ts"],"sourcesContent":["import assert from 'assert';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/expoSsoLauncher.ts"],"sourcesContent":["import assert from 'assert';\nimport crypto from 'crypto';\nimport http from 'http';\nimport type { Socket } from 'node:net';\n\nimport * as Log from '../../log';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport { fetchAsync, getResponseDataOrThrow } from '../rest/client';\n\nconst CLIENT_ID = 'expo-cli';\n\nfunction generateCodeVerifier(): string {\n return crypto.randomBytes(32).toString('base64url');\n}\n\nfunction generateCodeChallenge(codeVerifier: string): string {\n return crypto.createHash('sha256').update(codeVerifier).digest('base64url');\n}\n\nfunction generateState(): string {\n return crypto.randomBytes(32).toString('base64url');\n}\n\nasync function exchangeCodeForSessionSecretAsync({\n code,\n codeVerifier,\n redirectUri,\n}: {\n code: string;\n codeVerifier: string;\n redirectUri: string;\n}): Promise<string> {\n const response = await fetchAsync('auth/token', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n grant_type: 'authorization_code',\n code,\n redirect_uri: redirectUri,\n code_verifier: codeVerifier,\n client_id: CLIENT_ID,\n }),\n });\n const { session_secret: sessionSecret } = getResponseDataOrThrow<{ session_secret?: string }>(\n await response.json()\n );\n if (!sessionSecret) {\n throw new CommandError('BROWSER_AUTH', 'Failed to obtain session secret from token exchange.');\n }\n return sessionSecret;\n}\n\nexport async function getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl,\n sso = false,\n}: {\n expoWebsiteUrl: string;\n sso?: boolean;\n}): Promise<string> {\n const scheme = 'http';\n const hostname = 'localhost';\n const callbackPath = '/auth/callback';\n\n const codeVerifier = generateCodeVerifier();\n const codeChallenge = generateCodeChallenge(codeVerifier);\n const state = generateState();\n\n const buildRedirectUri = (port: number): string =>\n `${scheme}://${hostname}:${port}${callbackPath}`;\n\n const buildExpoLoginUrl = (port: number, sso: boolean): string => {\n // Note: we avoid URLSearchParams here because better-opn calls encodeURI()\n // on the URL before passing it to AppleScript, which would double-encode\n // the percent-encoded values from URLSearchParams.toString().\n const params = [\n `client_id=${CLIENT_ID}`,\n `redirect_uri=${buildRedirectUri(port)}`,\n `response_type=code`,\n `code_challenge=${codeChallenge}`,\n `code_challenge_method=S256`,\n `state=${state}`,\n `confirm_account=true`,\n ].join('&');\n return `${expoWebsiteUrl}${sso ? '/sso-login' : '/login'}?${params}`;\n };\n\n // Start server and begin auth flow\n const executeAuthFlow = (): Promise<string> => {\n return new Promise<string>(async (resolve, reject) => {\n const connections = new Set<Socket>();\n\n const server = http.createServer(\n (request: http.IncomingMessage, response: http.ServerResponse) => {\n const redirectAndCleanup = (result: 'success' | 'error'): void => {\n const redirectUrl = `${expoWebsiteUrl}/oauth/expo-cli?result=${result}`;\n response.writeHead(302, { Location: redirectUrl });\n response.end();\n server.close();\n for (const connection of connections) {\n connection.destroy();\n }\n };\n\n const handleRequestAsync = async (): Promise<void> => {\n if (!(request.method === 'GET' && request.url?.includes(callbackPath))) {\n throw new CommandError('BROWSER_AUTH', 'Unexpected login response.');\n }\n const url = new URL(request.url, `http:${request.headers.host}`);\n const code = url.searchParams.get('code');\n const returnedState = url.searchParams.get('state');\n\n if (!code) {\n throw new CommandError('BROWSER_AUTH', 'Request missing code search parameter.');\n }\n if (returnedState !== state) {\n throw new CommandError('BROWSER_AUTH', 'State mismatch. Possible CSRF attack.');\n }\n\n const address = server.address();\n assert(address !== null && typeof address === 'object');\n const redirectUri = buildRedirectUri(address.port);\n\n const sessionSecret = await exchangeCodeForSessionSecretAsync({\n code,\n codeVerifier,\n redirectUri,\n });\n\n resolve(sessionSecret);\n redirectAndCleanup('success');\n };\n\n handleRequestAsync().catch((error) => {\n redirectAndCleanup('error');\n reject(error);\n });\n }\n );\n\n server.listen(0, hostname, () => {\n Log.log('Waiting for browser login...');\n\n const address = server.address();\n assert(\n address !== null && typeof address === 'object',\n 'Server address and port should be set after listening has begun'\n );\n const port = address.port;\n const authorizeUrl = buildExpoLoginUrl(port, sso);\n Log.log(\n `If your browser doesn't automatically open, visit this link to log in: ${authorizeUrl}`\n );\n openBrowserAsync(authorizeUrl);\n });\n\n server.on('connection', (connection) => {\n connections.add(connection);\n\n connection.on('close', () => {\n connections.delete(connection);\n });\n });\n });\n };\n\n return await executeAuthFlow();\n}\n"],"names":["getSessionUsingBrowserAuthFlowAsync","CLIENT_ID","generateCodeVerifier","crypto","randomBytes","toString","generateCodeChallenge","codeVerifier","createHash","update","digest","generateState","exchangeCodeForSessionSecretAsync","code","redirectUri","response","fetchAsync","method","headers","body","JSON","stringify","grant_type","redirect_uri","code_verifier","client_id","session_secret","sessionSecret","getResponseDataOrThrow","json","CommandError","expoWebsiteUrl","sso","scheme","hostname","callbackPath","codeChallenge","state","buildRedirectUri","port","buildExpoLoginUrl","params","join","executeAuthFlow","Promise","resolve","reject","connections","Set","server","http","createServer","request","redirectAndCleanup","result","redirectUrl","writeHead","Location","end","close","connection","destroy","handleRequestAsync","url","includes","URL","host","searchParams","get","returnedState","address","assert","catch","error","listen","Log","log","authorizeUrl","openBrowserAsync","on","add","delete"],"mappings":";;;;+BAqDsBA;;;eAAAA;;;;gEArDH;;;;;;;gEACA;;;;;;;gEACF;;;;;;6DAGI;wBACQ;sBACI;wBACkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnD,MAAMC,YAAY;AAElB,SAASC;IACP,OAAOC,iBAAM,CAACC,WAAW,CAAC,IAAIC,QAAQ,CAAC;AACzC;AAEA,SAASC,sBAAsBC,YAAoB;IACjD,OAAOJ,iBAAM,CAACK,UAAU,CAAC,UAAUC,MAAM,CAACF,cAAcG,MAAM,CAAC;AACjE;AAEA,SAASC;IACP,OAAOR,iBAAM,CAACC,WAAW,CAAC,IAAIC,QAAQ,CAAC;AACzC;AAEA,eAAeO,kCAAkC,EAC/CC,IAAI,EACJN,YAAY,EACZO,WAAW,EAKZ;IACC,MAAMC,WAAW,MAAMC,IAAAA,kBAAU,EAAC,cAAc;QAC9CC,QAAQ;QACRC,SAAS;YAAE,gBAAgB;QAAmB;QAC9CC,MAAMC,KAAKC,SAAS,CAAC;YACnBC,YAAY;YACZT;YACAU,cAAcT;YACdU,eAAejB;YACfkB,WAAWxB;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C,kBAAkBD,MAAMP;gBAC7C2C,KAAIC,GAAG,CACL,CAAC,uEAAuE,EAAEC,cAAc;gBAE1FC,IAAAA,sBAAgB,EAACD;YACnB;YAEA5B,OAAO8B,EAAE,CAAC,cAAc,CAACnB;gBACvBb,YAAYiC,GAAG,CAACpB;gBAEhBA,WAAWmB,EAAE,CAAC,SAAS;oBACrBhC,YAAYkC,MAAM,CAACrB;gBACrB;YACF;QACF;IACF;IAEA,OAAO,MAAMjB;AACf"}
|
|
@@ -84,6 +84,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
84
84
|
}
|
|
85
85
|
return newObj;
|
|
86
86
|
}
|
|
87
|
+
const debug = require('debug')('expo:api:user');
|
|
87
88
|
let currentUser;
|
|
88
89
|
const ANONYMOUS_USERNAME = 'anonymous';
|
|
89
90
|
function getActorDisplayName(user) {
|
|
@@ -140,6 +141,17 @@ async function browserLoginAsync({ sso = false }) {
|
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
143
|
async function logoutAsync() {
|
|
144
|
+
var _getSession;
|
|
145
|
+
const sessionSecret = (_getSession = (0, _UserSettings.getSession)()) == null ? void 0 : _getSession.sessionSecret;
|
|
146
|
+
if (sessionSecret) {
|
|
147
|
+
try {
|
|
148
|
+
await (0, _client.fetchAsync)('auth/logout', {
|
|
149
|
+
method: 'POST'
|
|
150
|
+
});
|
|
151
|
+
} catch (error) {
|
|
152
|
+
debug('Failed to invalidate session secret on server:', error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
143
155
|
currentUser = undefined;
|
|
144
156
|
await Promise.all([
|
|
145
157
|
_fs().promises.rm((0, _codesigning.getDevelopmentCodeSigningDirectory)(), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\n\nimport { getAccessToken, getSession, setSessionAsync } from './UserSettings';\nimport { getSessionUsingBrowserAuthFlowAsync } from './expoSsoLauncher';\nimport * as Log from '../../log';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { getExpoWebsiteBaseUrl } from '../endpoint';\nimport { UserQuery, type Actor } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\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 type { Actor };\n\nexport async function getUserAsync(): Promise<Actor | undefined> {\n const hasCredentials = getAccessToken() || getSession()?.sessionSecret;\n if (!env.EXPO_OFFLINE && !currentUser && hasCredentials) {\n const user = await UserQuery.currentUserAsync();\n currentUser = user ?? undefined;\n }\n return currentUser;\n}\n\nexport async function loginAsync(credentials: {\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(credentials),\n });\n const json: any = await res.json();\n const sessionSecret = json.data.sessionSecret;\n\n const userData = await UserQuery.meUserActorAsync({\n 'expo-session': sessionSecret,\n });\n\n await setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function browserLoginAsync({ sso = false }): Promise<void> {\n const sessionSecret = await getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl: getExpoWebsiteBaseUrl(),\n sso,\n });\n const userData = await UserQuery.meUserActorAsync({\n 'expo-session': sessionSecret,\n });\n await 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 setSessionAsync(undefined),\n ]);\n Log.log('Logged out');\n}\n"],"names":["ANONYMOUS_USERNAME","browserLoginAsync","getActorDisplayName","getUserAsync","loginAsync","logoutAsync","currentUser","user","__typename","username","firstName","getSession","hasCredentials","getAccessToken","sessionSecret","env","EXPO_OFFLINE","UserQuery","currentUserAsync","undefined","credentials","res","fetchAsync","method","body","JSON","stringify","json","data","userData","meUserActorAsync","setSessionAsync","userId","id","currentConnection","sso","getSessionUsingBrowserAuthFlowAsync","expoWebsiteUrl","getExpoWebsiteBaseUrl","Promise","all","fs","rm","getDevelopmentCodeSigningDirectory","recursive","force","Log","log"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\n\nimport { getAccessToken, getSession, setSessionAsync } from './UserSettings';\nimport { getSessionUsingBrowserAuthFlowAsync } from './expoSsoLauncher';\nimport * as Log from '../../log';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { getExpoWebsiteBaseUrl } from '../endpoint';\nimport { UserQuery, type Actor } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\n\nconst debug = require('debug')('expo:api:user') as typeof console.log;\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 type { Actor };\n\nexport async function getUserAsync(): Promise<Actor | undefined> {\n const hasCredentials = getAccessToken() || getSession()?.sessionSecret;\n if (!env.EXPO_OFFLINE && !currentUser && hasCredentials) {\n const user = await UserQuery.currentUserAsync();\n currentUser = user ?? undefined;\n }\n return currentUser;\n}\n\nexport async function loginAsync(credentials: {\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(credentials),\n });\n const json: any = await res.json();\n const sessionSecret = json.data.sessionSecret;\n\n const userData = await UserQuery.meUserActorAsync({\n 'expo-session': sessionSecret,\n });\n\n await setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function browserLoginAsync({ sso = false }): Promise<void> {\n const sessionSecret = await getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl: getExpoWebsiteBaseUrl(),\n sso,\n });\n const userData = await UserQuery.meUserActorAsync({\n 'expo-session': sessionSecret,\n });\n await 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 const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n try {\n await fetchAsync('auth/logout', { method: 'POST' });\n } catch (error) {\n debug('Failed to invalidate session secret on server:', error);\n }\n }\n currentUser = undefined;\n await Promise.all([\n fs.rm(getDevelopmentCodeSigningDirectory(), { recursive: true, force: true }),\n setSessionAsync(undefined),\n ]);\n Log.log('Logged out');\n}\n"],"names":["ANONYMOUS_USERNAME","browserLoginAsync","getActorDisplayName","getUserAsync","loginAsync","logoutAsync","debug","require","currentUser","user","__typename","username","firstName","getSession","hasCredentials","getAccessToken","sessionSecret","env","EXPO_OFFLINE","UserQuery","currentUserAsync","undefined","credentials","res","fetchAsync","method","body","JSON","stringify","json","data","userData","meUserActorAsync","setSessionAsync","userId","id","currentConnection","sso","getSessionUsingBrowserAuthFlowAsync","expoWebsiteUrl","getExpoWebsiteBaseUrl","error","Promise","all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ACAkB,QAAQH,SAASI,EAAE;QACnBxB,UAAUoB,SAASpB,QAAQ;QAC3ByB,mBAAmB;IACrB;AACF;AAEO,eAAenC,kBAAkB,EAAEoC,MAAM,KAAK,EAAE;IACrD,MAAMrB,gBAAgB,MAAMsB,IAAAA,oDAAmC,EAAC;QAC9DC,gBAAgBC,IAAAA,+BAAqB;QACrCH;IACF;IACA,MAAMN,WAAW,MAAMZ,oBAAS,CAACa,gBAAgB,CAAC;QAChD,gBAAgBhB;IAClB;IACA,MAAMiB,IAAAA,6BAAe,EAAC;QACpBjB;QACAkB,QAAQH,SAASI,EAAE;QACnBxB,UAAUoB,SAASpB,QAAQ;QAC3ByB,mBAAmB;IACrB;AACF;AAEO,eAAe/B;QACEQ;IAAtB,MAAMG,iBAAgBH,cAAAA,IAAAA,wBAAU,wBAAVA,YAAcG,aAAa;IACjD,IAAIA,eAAe;QACjB,IAAI;YACF,MAAMQ,IAAAA,kBAAU,EAAC,eAAe;gBAAEC,QAAQ;YAAO;QACnD,EAAE,OAAOgB,OAAO;YACdnC,MAAM,kDAAkDmC;QAC1D;IACF;IACAjC,cAAca;IACd,MAAMqB,QAAQC,GAAG,CAAC;QAChBC,cAAE,CAACC,EAAE,CAACC,IAAAA,+CAAkC,KAAI;YAAEC,WAAW;YAAMC,OAAO;QAAK;QAC3Ef,IAAAA,6BAAe,EAACZ;KACjB;IACD4B,KAAIC,GAAG,CAAC;AACV"}
|
|
@@ -263,7 +263,7 @@ async function exportEmbedInternalAsync(projectRoot, options) {
|
|
|
263
263
|
// Write dom components proxy files.
|
|
264
264
|
hasDomComponents ? (0, _saveAssets.persistMetroFilesAsync)(files, domComponentProxyOutputDir) : null,
|
|
265
265
|
// Copy public folder for dom components only if
|
|
266
|
-
hasDomComponents ? (0, _publicFolder.copyPublicFolderAsync)(
|
|
266
|
+
hasDomComponents ? (0, _publicFolder.copyPublicFolderAsync)((0, _publicFolder.getPublicFolderPath)(projectRoot), _path().default.join(domComponentProxyOutputDir, _DomComponentsMiddleware.DOM_COMPONENTS_BUNDLE_DIR)) : null,
|
|
267
267
|
// NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native
|
|
268
268
|
// platforms when doing production embeds (unlikely).
|
|
269
269
|
options.assetsDest ? (0, _persistMetroAssets.persistMetroAssetsAsync)(projectRoot, assets, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport { convertEntryPointToRelative } from '@expo/config/paths';\nimport Server from '@expo/metro/metro/Server';\nimport splitBundleOptions from '@expo/metro/metro/lib/splitBundleOptions';\nimport * as output from '@expo/metro/metro/shared/output/bundle';\nimport type { BundleOptions } from '@expo/metro/metro/shared/types';\nimport { patchTransformFileForPackedMaps } from '@expo/metro-config/build/serializer/packedMap';\nimport { patchMetroSourceMapStringForPackedMaps } from '@expo/metro-config/build/serializer/sourceMap';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport type { Options } from './resolveOptions';\nimport { deserializeEagerKey, getExportEmbedOptionsKey } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { replaceMetroFileMap } from '../../start/server/metro/createFileMap-fork';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { DOM_COMPONENTS_BUNDLE_DIR } from '../../start/server/middleware/DomComponentsMiddleware';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { copyAsync, removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { setNodeEnv, loadEnvFiles } from '../../utils/nodeEnv';\nimport { exportDomComponentAsync } from '../exportDomComponents';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport type { BundleAssetWithFileHashes, ExportAssetMap } from '../saveAssets';\nimport { persistMetroFilesAsync } from '../saveAssets';\nimport { exportStandaloneServerAsync } from './exportServer';\nimport { ensureProcessExitsAfterDelay } from '../../utils/exit';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (\n !bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//) &&\n !bundleOutput.match(/\\/CoreSimulator\\/Devices\\/.*\\/data\\/Containers\\/Bundle\\/Application\\//)\n ) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(`*.app/${bundleName}`, {\n cwd: bundleParent,\n absolute: true,\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n // The React Native build scripts always enable the cache reset but we shouldn't need this in CI environments.\n // By disabling it, we can eagerly bundle code before the build and reuse the cached artifacts in subsequent builds.\n if (env.CI && options.resetCache) {\n debug('CI environment detected, disabling automatic cache reset');\n options.resetCache = false;\n }\n\n setNodeEnv(options.dev ? 'development' : 'production');\n loadEnvFiles(projectRoot);\n\n // This is an optimized codepath that can occur during `npx expo run` and does not occur during builds from Xcode or Android Studio.\n // Here we reconcile a bundle pass that was run before the native build process. This order can fail faster and is show better errors since the logs won't be obscured by Xcode and Android Studio.\n // This path is also used for automatically deploying server bundles to a remote host.\n const eagerBundleOptions = env.__EXPO_EAGER_BUNDLE_OPTIONS\n ? deserializeEagerKey(env.__EXPO_EAGER_BUNDLE_OPTIONS)\n : null;\n if (eagerBundleOptions) {\n // Get the cache key for the current process to compare against the eager key.\n const inputKey = getExportEmbedOptionsKey(options);\n\n // If the app was bundled previously in the same process, then we should reuse the Metro cache.\n options.resetCache = false;\n\n if (eagerBundleOptions.key === inputKey) {\n // Copy the eager bundleOutput and assets to the new locations.\n await removeAsync(options.bundleOutput);\n\n copyAsync(eagerBundleOptions.options.bundleOutput, options.bundleOutput);\n\n if (eagerBundleOptions.options.assetsDest && options.assetsDest) {\n copyAsync(eagerBundleOptions.options.assetsDest, options.assetsDest);\n }\n\n console.log('info: Copied output to binary:', options.bundleOutput);\n return;\n }\n // TODO: sourcemapOutput is set on Android but not during eager. This is tolerable since it doesn't invalidate the Metro cache.\n console.log(' Eager key:', eagerBundleOptions.key);\n console.log('Request key:', inputKey);\n\n // TODO: We may want an analytic event here in the future to understand when this happens.\n console.warn('warning: Eager bundle does not match new options, bundling again.');\n }\n\n await exportEmbedInternalAsync(projectRoot, options);\n\n // Ensure the process closes after bundling\n ensureProcessExitsAfterDelay();\n}\n\nexport async function exportEmbedInternalAsync(projectRoot: string, options: Options) {\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets, files } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // On Android, dom components proxy files should write to the assets directory instead of the res directory.\n // We use the bundleOutput directory to get the assets directory.\n const domComponentProxyOutputDir =\n options.platform === 'android' ? path.dirname(options.bundleOutput) : options.assetsDest;\n const hasDomComponents = domComponentProxyOutputDir && files.size > 0;\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n\n // Write dom components proxy files.\n hasDomComponents ? persistMetroFilesAsync(files, domComponentProxyOutputDir) : null,\n // Copy public folder for dom components only if\n hasDomComponents\n ? copyPublicFolderAsync(\n path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER),\n path.join(domComponentProxyOutputDir, DOM_COMPONENTS_BUNDLE_DIR)\n )\n : null,\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n files: ExportAssetMap;\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const { exp, pkg } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const files: ExportAssetMap = new Map();\n\n try {\n const bundles = await devServer.nativeExportBundleAsync(\n exp,\n {\n // TODO: Re-enable when we get bytecode chunk splitting working again.\n splitChunks: false, //devServer.isReactServerComponentsEnabled,\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n bytecode: options.bytecode ?? false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files,\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n // We optimistically build the server-side API routes code here, to ensure they're\n // valid or to enable parallel deployment in the future (TBD). This is disabled using\n // the explicit `--skip-server` flag.\n const apiRoutesEnabled =\n devServer.isReactServerComponentsEnabled || exp.web?.output === 'server';\n if (!options.skipServer && apiRoutesEnabled) {\n await exportStandaloneServerAsync(projectRoot, devServer, {\n exp,\n pkg,\n files,\n options,\n });\n }\n\n const expoDomComponentReferences = [\n ...new Set(\n bundles.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat()\n ),\n ];\n if (expoDomComponentReferences.length > 0) {\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle } = await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev: options.dev,\n devServer,\n isHermes,\n includeSourceMaps: !!sourceMapUrl,\n exp,\n files,\n });\n\n if (options.assetsDest) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // This is saving web-style inside of a native app's binary.\n await persistMetroAssetsAsync(\n projectRoot,\n bundle.assets.map((asset) => ({\n ...asset,\n httpServerLocation: path.join(DOM_COMPONENTS_BUNDLE_DIR, asset.httpServerLocation),\n })),\n {\n files,\n platform: 'web',\n outputDirectory: options.assetsDest,\n }\n );\n }\n })\n );\n }\n\n return {\n files,\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0]?.source!,\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString()!,\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n maxWorkers: options.maxWorkers,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const directBundleOptions = getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n // TODO(@kitten): This currently has to match a filename exactly\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile, null),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n hosted: false,\n });\n\n // TODO(cedric): check if we can use the proper `bundleType=bundle` and `entryPoint=mainModuleName` properties\n const bundleRequest: BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...directBundleOptions,\n\n // NOTE(@kitten): Cast non-optional defaults\n lazy: directBundleOptions.lazy ?? Server.DEFAULT_BUNDLE_OPTIONS.lazy,\n modulesOnly: directBundleOptions.modulesOnly ?? Server.DEFAULT_BUNDLE_OPTIONS.modulesOnly,\n runModule: directBundleOptions.runModule ?? Server.DEFAULT_BUNDLE_OPTIONS.runModule,\n\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const { metro } = await replaceMetroFileMap(() => ({\n metro: new Server(config, {\n watch: false,\n }),\n }));\n\n // The dev server applies the same patch from `instantiateMetro.ts`;\n // this is the export-embed / `expo-updates` path, where `data.map`\n // would otherwise reach Metro's readers in the unwrapped wire shape.\n patchTransformFileForPackedMaps(metro.getBundler().getBundler());\n patchMetroSourceMapStringForPackedMaps();\n\n return { server: metro, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n // @ts-ignore-error TODO(@kitten): Very unclear why this is here. Remove?\n bundleType: 'todo',\n });\n\n const dependencies = await server._bundler.getDependencies(\n // NOTE(@kitten): This isn't an `entryFile`, but instead a `mainModuleName`, that's been renamed\n // in `getMetroDirectBundleOptions`, where we've passed the already converted name\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n isHosted: false,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","exportEmbedAsync","exportEmbedBundleAndAssetsAsync","exportEmbedInternalAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","cwd","absolute","dot","projectRoot","options","env","CI","resetCache","setNodeEnv","dev","loadEnvFiles","eagerBundleOptions","__EXPO_EAGER_BUNDLE_OPTIONS","deserializeEagerKey","inputKey","getExportEmbedOptionsKey","key","removeAsync","copyAsync","assetsDest","console","log","warn","ensureProcessExitsAfterDelay","platform","previousPath","fs","existsSync","bundle","assets","files","mkdirSync","recursive","mode","domComponentProxyOutputDir","hasDomComponents","size","Promise","all","output","save","Log","persistMetroFilesAsync","copyPublicFolderAsync","resolve","EXPO_PUBLIC_FOLDER","join","DOM_COMPONENTS_BUNDLE_DIR","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","pkg","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","Map","bundles","nativeExportBundleAsync","splitChunks","mainModuleName","convertEntryPointToRelative","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","apiRoutesEnabled","isReactServerComponentsEnabled","web","skipServer","exportStandaloneServerAsync","expoDomComponentReferences","Set","artifacts","map","artifact","Array","isArray","metadata","flat","length","filePath","exportDomComponentAsync","includeSourceMaps","asset","httpServerLocation","code","filter","a","type","source","toString","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","metro","getBundler","directBundleOptions","getMetroDirectBundleOptionsForExpoConfig","hosted","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","lazy","modulesOnly","runModule","replaceMetroFileMap","watch","patchTransformFileForPackedMaps","patchMetroSourceMapStringForPackedMaps","server","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","dependencies","_bundler","getDependencies","shallow","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","isHosted","Error"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAiTqBA;eAAAA;;QAsFAC;eAAAA;;QA1UAC;eAAAA;;QAqGAC;eAAAA;;QAlDAC;eAAAA;;;;yBA/GI;;;;;;;yBACkB;;;;;;;gEACzB;;;;;;;gEACY;;;;;;;iEACP;;;;;;;yBAEwB;;;;;;;yBACO;;;;;;;gEAC5B;;;;;;;gEACR;;;;;;;gEACJ;;;;;;;yBACkB;;;;;;;gEAChB;;;;;;gCAG6C;qCACE;qBAC5C;kCACa;uCACK;mCACF;kCACC;yCACK;8BACe;sBAC/B;qBACa;qBACnB;yBACqB;qCACD;8BACF;oCACE;8BACF;4BAEC;8BACK;sBACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,2BAA2BC,YAAoB;IACtD,+CAA+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AAiI;YACjI,IAAI/G,QAAQoB,QAAQ,KAAK,OAAO;gBAC9B,8FAA8F;gBAC9F,IAAI,aAAa2F,SAASE,IAAAA,8CAAyB,KAAI;oBACrDF,MAAMG,OAAO,GAAGC,IAAAA,eAAS,EAACJ,MAAMG,OAAO;gBACzC;gBACAE,IAAAA,yCAAoB,EAACrH,aAAagH;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASC,QAAQD,KAAU;IACzB,OAAOA,iBAAiB2C;AAC1B"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport { convertEntryPointToRelative } from '@expo/config/paths';\nimport Server from '@expo/metro/metro/Server';\nimport splitBundleOptions from '@expo/metro/metro/lib/splitBundleOptions';\nimport * as output from '@expo/metro/metro/shared/output/bundle';\nimport type { BundleOptions } from '@expo/metro/metro/shared/types';\nimport { patchTransformFileForPackedMaps } from '@expo/metro-config/build/serializer/packedMap';\nimport { patchMetroSourceMapStringForPackedMaps } from '@expo/metro-config/build/serializer/sourceMap';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport type { Options } from './resolveOptions';\nimport { deserializeEagerKey, getExportEmbedOptionsKey } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { replaceMetroFileMap } from '../../start/server/metro/createFileMap-fork';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { DOM_COMPONENTS_BUNDLE_DIR } from '../../start/server/middleware/DomComponentsMiddleware';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { copyAsync, removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { setNodeEnv, loadEnvFiles } from '../../utils/nodeEnv';\nimport { exportDomComponentAsync } from '../exportDomComponents';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { copyPublicFolderAsync, getPublicFolderPath } from '../publicFolder';\nimport type { BundleAssetWithFileHashes, ExportAssetMap } from '../saveAssets';\nimport { persistMetroFilesAsync } from '../saveAssets';\nimport { exportStandaloneServerAsync } from './exportServer';\nimport { ensureProcessExitsAfterDelay } from '../../utils/exit';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (\n !bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//) &&\n !bundleOutput.match(/\\/CoreSimulator\\/Devices\\/.*\\/data\\/Containers\\/Bundle\\/Application\\//)\n ) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(`*.app/${bundleName}`, {\n cwd: bundleParent,\n absolute: true,\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n // The React Native build scripts always enable the cache reset but we shouldn't need this in CI environments.\n // By disabling it, we can eagerly bundle code before the build and reuse the cached artifacts in subsequent builds.\n if (env.CI && options.resetCache) {\n debug('CI environment detected, disabling automatic cache reset');\n options.resetCache = false;\n }\n\n setNodeEnv(options.dev ? 'development' : 'production');\n loadEnvFiles(projectRoot);\n\n // This is an optimized codepath that can occur during `npx expo run` and does not occur during builds from Xcode or Android Studio.\n // Here we reconcile a bundle pass that was run before the native build process. This order can fail faster and is show better errors since the logs won't be obscured by Xcode and Android Studio.\n // This path is also used for automatically deploying server bundles to a remote host.\n const eagerBundleOptions = env.__EXPO_EAGER_BUNDLE_OPTIONS\n ? deserializeEagerKey(env.__EXPO_EAGER_BUNDLE_OPTIONS)\n : null;\n if (eagerBundleOptions) {\n // Get the cache key for the current process to compare against the eager key.\n const inputKey = getExportEmbedOptionsKey(options);\n\n // If the app was bundled previously in the same process, then we should reuse the Metro cache.\n options.resetCache = false;\n\n if (eagerBundleOptions.key === inputKey) {\n // Copy the eager bundleOutput and assets to the new locations.\n await removeAsync(options.bundleOutput);\n\n copyAsync(eagerBundleOptions.options.bundleOutput, options.bundleOutput);\n\n if (eagerBundleOptions.options.assetsDest && options.assetsDest) {\n copyAsync(eagerBundleOptions.options.assetsDest, options.assetsDest);\n }\n\n console.log('info: Copied output to binary:', options.bundleOutput);\n return;\n }\n // TODO: sourcemapOutput is set on Android but not during eager. This is tolerable since it doesn't invalidate the Metro cache.\n console.log(' Eager key:', eagerBundleOptions.key);\n console.log('Request key:', inputKey);\n\n // TODO: We may want an analytic event here in the future to understand when this happens.\n console.warn('warning: Eager bundle does not match new options, bundling again.');\n }\n\n await exportEmbedInternalAsync(projectRoot, options);\n\n // Ensure the process closes after bundling\n ensureProcessExitsAfterDelay();\n}\n\nexport async function exportEmbedInternalAsync(projectRoot: string, options: Options) {\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets, files } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // On Android, dom components proxy files should write to the assets directory instead of the res directory.\n // We use the bundleOutput directory to get the assets directory.\n const domComponentProxyOutputDir =\n options.platform === 'android' ? path.dirname(options.bundleOutput) : options.assetsDest;\n const hasDomComponents = domComponentProxyOutputDir && files.size > 0;\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n\n // Write dom components proxy files.\n hasDomComponents ? persistMetroFilesAsync(files, domComponentProxyOutputDir) : null,\n // Copy public folder for dom components only if\n hasDomComponents\n ? copyPublicFolderAsync(\n getPublicFolderPath(projectRoot),\n path.join(domComponentProxyOutputDir, DOM_COMPONENTS_BUNDLE_DIR)\n )\n : null,\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n files: ExportAssetMap;\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const { exp, pkg } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const files: ExportAssetMap = new Map();\n\n try {\n const bundles = await devServer.nativeExportBundleAsync(\n exp,\n {\n // TODO: Re-enable when we get bytecode chunk splitting working again.\n splitChunks: false, //devServer.isReactServerComponentsEnabled,\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n bytecode: options.bytecode ?? false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files,\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n // We optimistically build the server-side API routes code here, to ensure they're\n // valid or to enable parallel deployment in the future (TBD). This is disabled using\n // the explicit `--skip-server` flag.\n const apiRoutesEnabled =\n devServer.isReactServerComponentsEnabled || exp.web?.output === 'server';\n if (!options.skipServer && apiRoutesEnabled) {\n await exportStandaloneServerAsync(projectRoot, devServer, {\n exp,\n pkg,\n files,\n options,\n });\n }\n\n const expoDomComponentReferences = [\n ...new Set(\n bundles.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat()\n ),\n ];\n if (expoDomComponentReferences.length > 0) {\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle } = await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev: options.dev,\n devServer,\n isHermes,\n includeSourceMaps: !!sourceMapUrl,\n exp,\n files,\n });\n\n if (options.assetsDest) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // This is saving web-style inside of a native app's binary.\n await persistMetroAssetsAsync(\n projectRoot,\n bundle.assets.map((asset) => ({\n ...asset,\n httpServerLocation: path.join(DOM_COMPONENTS_BUNDLE_DIR, asset.httpServerLocation),\n })),\n {\n files,\n platform: 'web',\n outputDirectory: options.assetsDest,\n }\n );\n }\n })\n );\n }\n\n return {\n files,\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0]?.source!,\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString()!,\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n maxWorkers: options.maxWorkers,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const directBundleOptions = getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n // TODO(@kitten): This currently has to match a filename exactly\n mainModuleName: convertEntryPointToRelative(projectRoot, options.entryFile, null),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n hosted: false,\n });\n\n // TODO(cedric): check if we can use the proper `bundleType=bundle` and `entryPoint=mainModuleName` properties\n const bundleRequest: BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...directBundleOptions,\n\n // NOTE(@kitten): Cast non-optional defaults\n lazy: directBundleOptions.lazy ?? Server.DEFAULT_BUNDLE_OPTIONS.lazy,\n modulesOnly: directBundleOptions.modulesOnly ?? Server.DEFAULT_BUNDLE_OPTIONS.modulesOnly,\n runModule: directBundleOptions.runModule ?? Server.DEFAULT_BUNDLE_OPTIONS.runModule,\n\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const { metro } = await replaceMetroFileMap(() => ({\n metro: new Server(config, {\n watch: false,\n }),\n }));\n\n // The dev server applies the same patch from `instantiateMetro.ts`;\n // this is the export-embed / `expo-updates` path, where `data.map`\n // would otherwise reach Metro's readers in the unwrapped wire shape.\n patchTransformFileForPackedMaps(metro.getBundler().getBundler());\n patchMetroSourceMapStringForPackedMaps();\n\n return { server: metro, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n // @ts-ignore-error TODO(@kitten): Very unclear why this is here. Remove?\n bundleType: 'todo',\n });\n\n const dependencies = await server._bundler.getDependencies(\n // NOTE(@kitten): This isn't an `entryFile`, but instead a `mainModuleName`, that's been renamed\n // in `getMetroDirectBundleOptions`, where we've passed the already converted name\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n isHosted: false,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","exportEmbedAsync","exportEmbedBundleAndAssetsAsync","exportEmbedInternalAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","cwd","absolute","dot","projectRoot","options","env","CI","resetCache","setNodeEnv","dev","loadEnvFiles","eagerBundleOptions","__EXPO_EAGER_BUNDLE_OPTIONS","deserializeEagerKey","inputKey","getExportEmbedOptionsKey","key","removeAsync","copyAsync","assetsDest","console","log","warn","ensureProcessExitsAfterDelay","platform","previousPath","fs","existsSync","bundle","assets","files","mkdirSync","recursive","mode","domComponentProxyOutputDir","hasDomComponents","size","Promise","all","output","save","Log","persistMetroFilesAsync","copyPublicFolderAsync","getPublicFolderPath","join","DOM_COMPONENTS_BUNDLE_DIR","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","pkg","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","Map","bundles","nativeExportBundleAsync","splitChunks","mainModuleName","convertEntryPointToRelative","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","apiRoutesEnabled","isReactServerComponentsEnabled","web","skipServer","exportStandaloneServerAsync","expoDomComponentReferences","Set","artifacts","map","artifact","Array","isArray","metadata","flat","length","filePath","exportDomComponentAsync","includeSourceMaps","asset","httpServerLocation","code","filter","a","type","source","toString","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","metro","getBundler","directBundleOptions","getMetroDirectBundleOptionsForExpoConfig","hosted","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","lazy","modulesOnly","runModule","replaceMetroFileMap","watch","patchTransformFileForPackedMaps","patchMetroSourceMapStringForPackedMaps","server","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","dependencies","_bundler","getDependencies","shallow","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","isHosted","Error"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAiTqBA;eAAAA;;QAsFAC;eAAAA;;QA1UAC;eAAAA;;QAqGAC;eAAAA;;QAlDAC;eAAAA;;;;yBA/GI;;;;;;;yBACkB;;;;;;;gEACzB;;;;;;;gEACY;;;;;;;iEACP;;;;;;;yBAEwB;;;;;;;yBACO;;;;;;;gEAC5B;;;;;;;gEACR;;;;;;;gEACJ;;;;;;;yBACkB;;;;;;;gEAChB;;;;;;gCAG6C;qCACE;qBAC5C;kCACa;uCACK;mCACF;kCACC;yCACK;8BACe;sBAC/B;qBACa;qBACnB;yBACqB;qCACD;8BACF;oCACE;8BACmB;4BAEpB;8BACK;sBACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,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D,QAAQ;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAI9G,QAAQoB,QAAQ,KAAK,OAAO;gBAC9B,8FAA8F;gBAC9F,IAAI,aAAa0F,SAASE,IAAAA,8CAAyB,KAAI;oBACrDF,MAAMG,OAAO,GAAGC,IAAAA,eAAS,EAACJ,MAAMG,OAAO;gBACzC;gBACAE,IAAAA,yCAAoB,EAACpH,aAAa+G;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASC,QAAQD,KAAU;IACzB,OAAOA,iBAAiB2C;AAC1B"}
|
|
@@ -87,7 +87,7 @@ async function exportStandaloneServerAsync(projectRoot, devServer, { exp, pkg, f
|
|
|
87
87
|
platform: 'web',
|
|
88
88
|
apiRoutesOnly: true
|
|
89
89
|
});
|
|
90
|
-
const publicPath =
|
|
90
|
+
const publicPath = (0, _publicFolder.getPublicFolderPath)(projectRoot);
|
|
91
91
|
// Copy over public folder items
|
|
92
92
|
await (0, _publicFolder.copyPublicFolderAsync)(publicPath, serverOutput);
|
|
93
93
|
// Copy over the server output on top of the public folder.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/export/embed/exportServer.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport type { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { modifyConfigAsync } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { execSync } from 'node:child_process';\nimport path from 'path';\n\nimport { disableNetwork } from '../../api/settings';\nimport { Log } from '../../log';\nimport { isSpawnResultError } from '../../start/platforms/ios/xcrun';\nimport type { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { exportApiRoutesStandaloneAsync } from '../exportStaticAsync';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport type { ExportAssetMap } from '../saveAssets';\nimport { persistMetroFilesAsync } from '../saveAssets';\nimport type { Options } from './resolveOptions';\nimport {\n isExecutingFromXcodebuild,\n logInXcode,\n logMetroErrorInXcode,\n warnInXcode,\n} from './xcodeCompilerLogger';\n\nconst debug = require('debug')('expo:export:server');\n\ntype ServerDeploymentResults = {\n url: string;\n dashboardUrl?: string;\n};\n\nexport async function exportStandaloneServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n exp,\n pkg,\n files,\n options,\n }: { exp: ExpoConfig; pkg: PackageJSONConfig; files: ExportAssetMap; options: Options }\n) {\n if (!options.eager) {\n await tryRemovingGeneratedOriginAsync(projectRoot, exp);\n }\n\n logInXcode('Exporting server');\n\n // Store the server output in the project's .expo directory.\n const serverOutput = path.join(projectRoot, '.expo/server', options.platform);\n\n // Remove the previous server output to prevent stale files.\n await removeAsync(serverOutput);\n\n // Export the API routes for server rendering the React Server Components.\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n // Copy over public folder items\n await copyPublicFolderAsync(publicPath, serverOutput);\n\n // Copy over the server output on top of the public folder.\n await persistMetroFilesAsync(files, serverOutput);\n\n [...files.entries()].forEach(([key, value]) => {\n if (value.targetDomain === 'server') {\n // Delete server resources to prevent them from being exposed in the binary.\n files.delete(key);\n }\n });\n\n // TODO: Deprecate this in favor of a built-in prop that users should avoid setting.\n const userDefinedServerUrl = exp.extra?.router?.origin;\n let serverUrl = userDefinedServerUrl;\n\n const shouldSkipServerDeployment = (() => {\n if (!options.eager) {\n logInXcode('Skipping server deployment because the script is not running in eager mode.');\n return true;\n }\n\n // Add an opaque flag to disable server deployment.\n if (env.EXPO_NO_DEPLOY) {\n warnInXcode('Skipping server deployment because environment variable EXPO_NO_DEPLOY is set.');\n return true;\n }\n\n // Can't safely deploy from Xcode since the PATH isn't set up correctly. We could amend this in the future and allow users who customize the PATH to deploy from Xcode.\n if (isExecutingFromXcodebuild()) {\n // TODO: Don't warn when the eager bundle has been run.\n warnInXcode(\n 'Skipping server deployment because the build is running from an Xcode run script. Build with Expo CLI or EAS Build to deploy the server automatically.'\n );\n return true;\n }\n\n return false;\n })();\n\n // Deploy the server output to a hosting provider.\n const deployedServerUrl = shouldSkipServerDeployment\n ? false\n : await runServerDeployCommandAsync(projectRoot, {\n distDirectory: serverOutput,\n deployScript: getServerDeploymentScript(pkg.scripts, options.platform),\n });\n\n if (!deployedServerUrl) {\n return;\n }\n\n if (serverUrl) {\n logInXcode(\n `Using custom server URL: ${serverUrl} (ignoring deployment URL: ${deployedServerUrl})`\n );\n }\n\n // If the user-defined server URL is not defined, use the deployed server URL.\n // This allows for overwriting the server URL in the project's native files.\n serverUrl ||= deployedServerUrl;\n\n // If the user hasn't manually defined the server URL, write the deployed server URL to the app.json.\n if (userDefinedServerUrl) {\n Log.log('Skip automatically linking server origin to native container');\n return;\n }\n Log.log('Writing generated server URL to app.json');\n\n // NOTE: Is is it possible to assert that the config needs to be modifiable before building the app?\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: serverUrl,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n throw new CommandError(\n `Failed to write generated server origin to app.json because the file is dynamic and does not extend the static config. The client will not be able to make server requests to API routes or static files. You can disable server linking with EXPO_NO_DEPLOY=1 or by disabling server output in the app.json.`\n );\n }\n}\n\nasync function dumpDeploymentLogs(projectRoot: string, logs: string, name = 'deploy') {\n const outputPath = path.join(projectRoot, `.expo/logs/${name}.log`);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n debug('Dumping server deployment logs to: ' + outputPath);\n await fs.promises.writeFile(outputPath, logs);\n return outputPath;\n}\n\nfunction getCommandBin(command: string) {\n try {\n return execSync(`command -v ${command}`, { stdio: 'pipe' }).toString().trim();\n } catch {\n return null;\n }\n}\n\nasync function runServerDeployCommandAsync(\n projectRoot: string,\n {\n distDirectory,\n deployScript,\n }: { distDirectory: string; deployScript: { scriptName: string; script: string } | null }\n): Promise<string | false> {\n const logOfflineError = () => {\n const manualScript = deployScript\n ? `npm run ${deployScript.scriptName}`\n : `npx eas deploy --export-dir ${distDirectory}`;\n\n logMetroErrorInXcode(\n projectRoot,\n chalk.red`Running CLI in offline mode, skipping server deployment. Deploy manually with: ${manualScript}`\n );\n };\n if (env.EXPO_OFFLINE) {\n logOfflineError();\n return false;\n }\n\n // TODO: Only allow EAS deployments when staging is enabled, this is because the feature is still staging-only.\n if (!env.EXPO_UNSTABLE_DEPLOY_SERVER) {\n return false;\n }\n\n if (!env.EAS_BUILD) {\n // This check helps avoid running EAS if the user isn't a user of EAS.\n // We only need to run it when building outside of EAS.\n const globalBin = getCommandBin('eas');\n if (!globalBin) {\n // This should never happen from EAS Builds.\n // Possible to happen when building locally with `npx expo run`\n logMetroErrorInXcode(\n projectRoot,\n `eas-cli is not installed globally, skipping server deployment. Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n debug('Found eas-cli:', globalBin);\n }\n\n let json: any;\n try {\n let results: spawnAsync.SpawnResult;\n\n const spawnOptions: spawnAsync.SpawnOptions = {\n cwd: projectRoot,\n // Ensures that errors can be caught.\n stdio: 'pipe',\n };\n // TODO: Support absolute paths in EAS CLI\n const exportDir = path.relative(projectRoot, distDirectory);\n if (deployScript) {\n logInXcode(`Using custom server deploy script: ${deployScript.scriptName}`);\n // Amend the path to try and make the custom scripts work.\n\n results = await spawnAsync(\n 'npm',\n ['run', deployScript.scriptName, `--export-dir=${exportDir}`],\n spawnOptions\n );\n } else {\n logInXcode('Deploying server to link with client');\n\n // results = DEPLOYMENT_SUCCESS_FIXTURE;\n results = await spawnAsync(\n 'npx',\n ['eas-cli', 'deploy', '--non-interactive', '--json', `--export-dir=${exportDir}`],\n spawnOptions\n );\n\n debug('Server deployment stdout:', results.stdout);\n\n // Send stderr to stderr. stdout is parsed as JSON.\n if (results.stderr) {\n process.stderr.write(results.stderr);\n }\n }\n\n const logPath = await dumpDeploymentLogs(projectRoot, results.output.join('\\n'));\n\n try {\n // {\n // \"dashboardUrl\": \"https://staging.expo.dev/projects/6460c11c-e1bc-4084-882a-fd9f57b825b1/hosting/deployments\",\n // \"identifier\": \"8a1pwbv6c5\",\n // \"url\": \"https://sep30--8a1pwbv6c5.staging.expo.app\"\n // }\n json = JSON.parse(results.stdout.trim());\n } catch {\n logMetroErrorInXcode(\n projectRoot,\n `Failed to parse server deployment JSON output. Check the logs for more information: ${logPath}`\n );\n return false;\n }\n } catch (error) {\n if (isSpawnResultError(error)) {\n const output = error.output.join('\\n').trim() || error.toString();\n Log.log(\n chalk.dim(\n 'An error occurred while deploying server. Logs stored at: ' +\n (await dumpDeploymentLogs(projectRoot, output, 'deploy-error'))\n )\n );\n\n // Likely a server offline or network error.\n if (output.match(/ENOTFOUND/)) {\n logOfflineError();\n // Print the raw error message to help provide more context.\n Log.log(chalk.dim(output));\n // Prevent any other network requests (unlikely for this command).\n disableNetwork();\n return false;\n }\n\n logInXcode(output);\n if (output.match(/spawn eas ENOENT/)) {\n // EAS not installed.\n logMetroErrorInXcode(\n projectRoot,\n `Server deployment failed because eas-cli cannot be accessed from the build script's environment (ENOENT). Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n\n if (error.stderr.match(/Must configure EAS project by running/)) {\n // EAS not configured, this can happen when building a project locally before building in EAS.\n // User must run `eas init`, `eas deploy`, or `eas build` first.\n\n // TODO: Should we fail the build here or just warn users?\n logMetroErrorInXcode(\n projectRoot,\n `Skipping server deployment because EAS is not configured. Run 'eas init' before trying again, or disable server output in the project.`\n );\n return false;\n }\n }\n\n // Throw unhandled server deployment errors.\n throw error;\n }\n\n // Assert json format\n assertDeploymentJsonOutput(json);\n\n // Warn about the URL not being valid. This should never happen, but might be possible with third-parties.\n if (!canParseURL(json.url)) {\n warnInXcode(`The server deployment URL is not a valid URL: ${json.url}`);\n }\n\n if (json.dashboardUrl) {\n logInXcode(`Server dashboard: ${json.dashboardUrl}`);\n }\n\n logInXcode(`Server deployed to: ${json.url}`);\n\n return json.url;\n}\n\nfunction canParseURL(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction assertDeploymentJsonOutput(json: any): asserts json is ServerDeploymentResults {\n if (!json || typeof json !== 'object' || typeof json.url !== 'string') {\n throw new Error(\n 'JSON output of server deployment command are not in the expected format: { url: \"https://...\" }'\n );\n }\n}\n\nfunction getServerDeploymentScript(\n scripts: Record<string, string> | undefined,\n platform: string\n): { scriptName: string; script: string } | null {\n // Users can overwrite the default deployment script with:\n // { scripts: { \"native:deploy\": \"eas deploy --json --non-interactive\" } }\n // A quick search on GitHub showed that `native:deploy` is not used in any public repos yet.\n // https://github.com/search?q=%22native%3Adeploy%22+path%3Apackage.json&type=code\n const DEFAULT_SCRIPT_NAME = 'native:deploy';\n\n const scriptNames = [\n // DEFAULT_SCRIPT_NAME + ':' + platform,\n DEFAULT_SCRIPT_NAME,\n ];\n\n for (const scriptName of scriptNames) {\n if (scripts?.[scriptName]) {\n return { scriptName, script: scripts[scriptName] };\n }\n }\n\n return null;\n}\n\n/** We can try to remove the generated origin from the manifest when running outside of eager mode. Bundling is the last operation to run so the config will already be embedded with the origin. */\nasync function tryRemovingGeneratedOriginAsync(projectRoot: string, exp: ExpoConfig) {\n if (env.CI) {\n // Skip in CI since nothing is committed.\n return;\n }\n if (exp.extra?.router?.generatedOrigin == null) {\n debug('No generated origin needs removing');\n return;\n }\n\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: undefined,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n debug('Could not remove generated origin from manifest');\n } else {\n debug('Generated origin has been removed from manifest');\n }\n}\n"],"names":["exportStandaloneServerAsync","debug","require","projectRoot","devServer","exp","pkg","files","options","eager","tryRemovingGeneratedOriginAsync","logInXcode","serverOutput","path","join","platform","removeAsync","exportApiRoutesStandaloneAsync","apiRoutesOnly","publicPath","resolve","env","EXPO_PUBLIC_FOLDER","copyPublicFolderAsync","persistMetroFilesAsync","entries","forEach","key","value","targetDomain","delete","userDefinedServerUrl","extra","router","origin","serverUrl","shouldSkipServerDeployment","EXPO_NO_DEPLOY","warnInXcode","isExecutingFromXcodebuild","deployedServerUrl","runServerDeployCommandAsync","distDirectory","deployScript","getServerDeploymentScript","scripts","Log","log","modification","modifyConfigAsync","generatedOrigin","skipSDKVersionRequirement","type","CommandError","dumpDeploymentLogs","logs","name","outputPath","fs","promises","mkdir","dirname","recursive","writeFile","getCommandBin","command","execSync","stdio","toString","trim","logOfflineError","manualScript","scriptName","logMetroErrorInXcode","chalk","red","EXPO_OFFLINE","EXPO_UNSTABLE_DEPLOY_SERVER","EAS_BUILD","globalBin","json","results","spawnOptions","cwd","exportDir","relative","spawnAsync","stdout","stderr","process","write","logPath","output","JSON","parse","error","isSpawnResultError","dim","match","disableNetwork","assertDeploymentJsonOutput","canParseURL","url","dashboardUrl","URL","Error","DEFAULT_SCRIPT_NAME","scriptNames","script","CI","undefined"],"mappings":"AAAA;;;;;CAKC;;;;+BAmCqBA;;;eAAAA;;;;yBAjCY;;;;;;;gEACX;;;;;;;gEACL;;;;;;;gEACH;;;;;;;yBACU;;;;;;;gEACR;;;;;;0BAEc;qBACX;uBACe;qBAEP;qBACR;wBACS;mCACkB;8BACT;4BAEC;qCAOhC;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAOxB,eAAeF,4BACpBG,WAAmB,EACnBC,SAAgC,EAChC,EACEC,GAAG,EACHC,GAAG,EACHC,KAAK,EACLC,OAAO,EAC8E;QAqC1DH,mBAAAA,YA+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gBAAYoC,QAAQ/D,OAAO,CAAC2B,WAAW;YAAC;QACnD;IACF;IAEA,OAAO;AACT;AAEA,kMAAkM,GAClM,eAAe9D,gCAAgCP,WAAmB,EAAEE,GAAe;QAK7EA,mBAAAA,YAWQA;IAfZ,IAAIgB,QAAG,CAACwF,EAAE,EAAE;QACV,yCAAyC;QACzC;IACF;IACA,IAAIxG,EAAAA,aAAAA,IAAI2B,KAAK,sBAAT3B,oBAAAA,WAAW4B,MAAM,qBAAjB5B,kBAAmB6C,eAAe,KAAI,MAAM;QAC9CjD,MAAM;QACN;IACF;IAEA,MAAM+C,eAAe,MAAMC,IAAAA,2BAAiB,EAC1C9C,aACA;QACE6B,OAAO;YACL,GAAI3B,IAAI2B,KAAK,IAAI,CAAC,CAAC;YACnBC,QAAQ;gBACN,GAAI5B,EAAAA,cAAAA,IAAI2B,KAAK,qBAAT3B,YAAW4B,MAAM,KAAI,CAAC,CAAC;gBAC3BiB,iBAAiB4D;YACnB;QACF;IACF,GACA;QACE3D,2BAA2B;IAC7B;IAGF,IAAIH,aAAaI,IAAI,KAAK,WAAW;QACnCnD,MAAM;IACR,OAAO;QACLA,MAAM;IACR;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/export/embed/exportServer.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport type { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { modifyConfigAsync } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { execSync } from 'node:child_process';\nimport path from 'path';\n\nimport { disableNetwork } from '../../api/settings';\nimport { Log } from '../../log';\nimport { isSpawnResultError } from '../../start/platforms/ios/xcrun';\nimport type { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { exportApiRoutesStandaloneAsync } from '../exportStaticAsync';\nimport { copyPublicFolderAsync, getPublicFolderPath } from '../publicFolder';\nimport type { ExportAssetMap } from '../saveAssets';\nimport { persistMetroFilesAsync } from '../saveAssets';\nimport type { Options } from './resolveOptions';\nimport {\n isExecutingFromXcodebuild,\n logInXcode,\n logMetroErrorInXcode,\n warnInXcode,\n} from './xcodeCompilerLogger';\n\nconst debug = require('debug')('expo:export:server');\n\ntype ServerDeploymentResults = {\n url: string;\n dashboardUrl?: string;\n};\n\nexport async function exportStandaloneServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n exp,\n pkg,\n files,\n options,\n }: { exp: ExpoConfig; pkg: PackageJSONConfig; files: ExportAssetMap; options: Options }\n) {\n if (!options.eager) {\n await tryRemovingGeneratedOriginAsync(projectRoot, exp);\n }\n\n logInXcode('Exporting server');\n\n // Store the server output in the project's .expo directory.\n const serverOutput = path.join(projectRoot, '.expo/server', options.platform);\n\n // Remove the previous server output to prevent stale files.\n await removeAsync(serverOutput);\n\n // Export the API routes for server rendering the React Server Components.\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n const publicPath = getPublicFolderPath(projectRoot);\n\n // Copy over public folder items\n await copyPublicFolderAsync(publicPath, serverOutput);\n\n // Copy over the server output on top of the public folder.\n await persistMetroFilesAsync(files, serverOutput);\n\n [...files.entries()].forEach(([key, value]) => {\n if (value.targetDomain === 'server') {\n // Delete server resources to prevent them from being exposed in the binary.\n files.delete(key);\n }\n });\n\n // TODO: Deprecate this in favor of a built-in prop that users should avoid setting.\n const userDefinedServerUrl = exp.extra?.router?.origin;\n let serverUrl = userDefinedServerUrl;\n\n const shouldSkipServerDeployment = (() => {\n if (!options.eager) {\n logInXcode('Skipping server deployment because the script is not running in eager mode.');\n return true;\n }\n\n // Add an opaque flag to disable server deployment.\n if (env.EXPO_NO_DEPLOY) {\n warnInXcode('Skipping server deployment because environment variable EXPO_NO_DEPLOY is set.');\n return true;\n }\n\n // Can't safely deploy from Xcode since the PATH isn't set up correctly. We could amend this in the future and allow users who customize the PATH to deploy from Xcode.\n if (isExecutingFromXcodebuild()) {\n // TODO: Don't warn when the eager bundle has been run.\n warnInXcode(\n 'Skipping server deployment because the build is running from an Xcode run script. Build with Expo CLI or EAS Build to deploy the server automatically.'\n );\n return true;\n }\n\n return false;\n })();\n\n // Deploy the server output to a hosting provider.\n const deployedServerUrl = shouldSkipServerDeployment\n ? false\n : await runServerDeployCommandAsync(projectRoot, {\n distDirectory: serverOutput,\n deployScript: getServerDeploymentScript(pkg.scripts, options.platform),\n });\n\n if (!deployedServerUrl) {\n return;\n }\n\n if (serverUrl) {\n logInXcode(\n `Using custom server URL: ${serverUrl} (ignoring deployment URL: ${deployedServerUrl})`\n );\n }\n\n // If the user-defined server URL is not defined, use the deployed server URL.\n // This allows for overwriting the server URL in the project's native files.\n serverUrl ||= deployedServerUrl;\n\n // If the user hasn't manually defined the server URL, write the deployed server URL to the app.json.\n if (userDefinedServerUrl) {\n Log.log('Skip automatically linking server origin to native container');\n return;\n }\n Log.log('Writing generated server URL to app.json');\n\n // NOTE: Is is it possible to assert that the config needs to be modifiable before building the app?\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: serverUrl,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n throw new CommandError(\n `Failed to write generated server origin to app.json because the file is dynamic and does not extend the static config. The client will not be able to make server requests to API routes or static files. You can disable server linking with EXPO_NO_DEPLOY=1 or by disabling server output in the app.json.`\n );\n }\n}\n\nasync function dumpDeploymentLogs(projectRoot: string, logs: string, name = 'deploy') {\n const outputPath = path.join(projectRoot, `.expo/logs/${name}.log`);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n debug('Dumping server deployment logs to: ' + outputPath);\n await fs.promises.writeFile(outputPath, logs);\n return outputPath;\n}\n\nfunction getCommandBin(command: string) {\n try {\n return execSync(`command -v ${command}`, { stdio: 'pipe' }).toString().trim();\n } catch {\n return null;\n }\n}\n\nasync function runServerDeployCommandAsync(\n projectRoot: string,\n {\n distDirectory,\n deployScript,\n }: { distDirectory: string; deployScript: { scriptName: string; script: string } | null }\n): Promise<string | false> {\n const logOfflineError = () => {\n const manualScript = deployScript\n ? `npm run ${deployScript.scriptName}`\n : `npx eas deploy --export-dir ${distDirectory}`;\n\n logMetroErrorInXcode(\n projectRoot,\n chalk.red`Running CLI in offline mode, skipping server deployment. Deploy manually with: ${manualScript}`\n );\n };\n if (env.EXPO_OFFLINE) {\n logOfflineError();\n return false;\n }\n\n // TODO: Only allow EAS deployments when staging is enabled, this is because the feature is still staging-only.\n if (!env.EXPO_UNSTABLE_DEPLOY_SERVER) {\n return false;\n }\n\n if (!env.EAS_BUILD) {\n // This check helps avoid running EAS if the user isn't a user of EAS.\n // We only need to run it when building outside of EAS.\n const globalBin = getCommandBin('eas');\n if (!globalBin) {\n // This should never happen from EAS Builds.\n // Possible to happen when building locally with `npx expo run`\n logMetroErrorInXcode(\n projectRoot,\n `eas-cli is not installed globally, skipping server deployment. Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n debug('Found eas-cli:', globalBin);\n }\n\n let json: any;\n try {\n let results: spawnAsync.SpawnResult;\n\n const spawnOptions: spawnAsync.SpawnOptions = {\n cwd: projectRoot,\n // Ensures that errors can be caught.\n stdio: 'pipe',\n };\n // TODO: Support absolute paths in EAS CLI\n const exportDir = path.relative(projectRoot, distDirectory);\n if (deployScript) {\n logInXcode(`Using custom server deploy script: ${deployScript.scriptName}`);\n // Amend the path to try and make the custom scripts work.\n\n results = await spawnAsync(\n 'npm',\n ['run', deployScript.scriptName, `--export-dir=${exportDir}`],\n spawnOptions\n );\n } else {\n logInXcode('Deploying server to link with client');\n\n // results = DEPLOYMENT_SUCCESS_FIXTURE;\n results = await spawnAsync(\n 'npx',\n ['eas-cli', 'deploy', '--non-interactive', '--json', `--export-dir=${exportDir}`],\n spawnOptions\n );\n\n debug('Server deployment stdout:', results.stdout);\n\n // Send stderr to stderr. stdout is parsed as JSON.\n if (results.stderr) {\n process.stderr.write(results.stderr);\n }\n }\n\n const logPath = await dumpDeploymentLogs(projectRoot, results.output.join('\\n'));\n\n try {\n // {\n // \"dashboardUrl\": \"https://staging.expo.dev/projects/6460c11c-e1bc-4084-882a-fd9f57b825b1/hosting/deployments\",\n // \"identifier\": \"8a1pwbv6c5\",\n // \"url\": \"https://sep30--8a1pwbv6c5.staging.expo.app\"\n // }\n json = JSON.parse(results.stdout.trim());\n } catch {\n logMetroErrorInXcode(\n projectRoot,\n `Failed to parse server deployment JSON output. Check the logs for more information: ${logPath}`\n );\n return false;\n }\n } catch (error) {\n if (isSpawnResultError(error)) {\n const output = error.output.join('\\n').trim() || error.toString();\n Log.log(\n chalk.dim(\n 'An error occurred while deploying server. Logs stored at: ' +\n (await dumpDeploymentLogs(projectRoot, output, 'deploy-error'))\n )\n );\n\n // Likely a server offline or network error.\n if (output.match(/ENOTFOUND/)) {\n logOfflineError();\n // Print the raw error message to help provide more context.\n Log.log(chalk.dim(output));\n // Prevent any other network requests (unlikely for this command).\n disableNetwork();\n return false;\n }\n\n logInXcode(output);\n if (output.match(/spawn eas ENOENT/)) {\n // EAS not installed.\n logMetroErrorInXcode(\n projectRoot,\n `Server deployment failed because eas-cli cannot be accessed from the build script's environment (ENOENT). Install EAS CLI with 'npm install -g eas-cli'.`\n );\n return false;\n }\n\n if (error.stderr.match(/Must configure EAS project by running/)) {\n // EAS not configured, this can happen when building a project locally before building in EAS.\n // User must run `eas init`, `eas deploy`, or `eas build` first.\n\n // TODO: Should we fail the build here or just warn users?\n logMetroErrorInXcode(\n projectRoot,\n `Skipping server deployment because EAS is not configured. Run 'eas init' before trying again, or disable server output in the project.`\n );\n return false;\n }\n }\n\n // Throw unhandled server deployment errors.\n throw error;\n }\n\n // Assert json format\n assertDeploymentJsonOutput(json);\n\n // Warn about the URL not being valid. This should never happen, but might be possible with third-parties.\n if (!canParseURL(json.url)) {\n warnInXcode(`The server deployment URL is not a valid URL: ${json.url}`);\n }\n\n if (json.dashboardUrl) {\n logInXcode(`Server dashboard: ${json.dashboardUrl}`);\n }\n\n logInXcode(`Server deployed to: ${json.url}`);\n\n return json.url;\n}\n\nfunction canParseURL(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction assertDeploymentJsonOutput(json: any): asserts json is ServerDeploymentResults {\n if (!json || typeof json !== 'object' || typeof json.url !== 'string') {\n throw new Error(\n 'JSON output of server deployment command are not in the expected format: { url: \"https://...\" }'\n );\n }\n}\n\nfunction getServerDeploymentScript(\n scripts: Record<string, string> | undefined,\n platform: string\n): { scriptName: string; script: string } | null {\n // Users can overwrite the default deployment script with:\n // { scripts: { \"native:deploy\": \"eas deploy --json --non-interactive\" } }\n // A quick search on GitHub showed that `native:deploy` is not used in any public repos yet.\n // https://github.com/search?q=%22native%3Adeploy%22+path%3Apackage.json&type=code\n const DEFAULT_SCRIPT_NAME = 'native:deploy';\n\n const scriptNames = [\n // DEFAULT_SCRIPT_NAME + ':' + platform,\n DEFAULT_SCRIPT_NAME,\n ];\n\n for (const scriptName of scriptNames) {\n if (scripts?.[scriptName]) {\n return { scriptName, script: scripts[scriptName] };\n }\n }\n\n return null;\n}\n\n/** We can try to remove the generated origin from the manifest when running outside of eager mode. Bundling is the last operation to run so the config will already be embedded with the origin. */\nasync function tryRemovingGeneratedOriginAsync(projectRoot: string, exp: ExpoConfig) {\n if (env.CI) {\n // Skip in CI since nothing is committed.\n return;\n }\n if (exp.extra?.router?.generatedOrigin == null) {\n debug('No generated origin needs removing');\n return;\n }\n\n const modification = await modifyConfigAsync(\n projectRoot,\n {\n extra: {\n ...(exp.extra ?? {}),\n router: {\n ...(exp.extra?.router ?? {}),\n generatedOrigin: undefined,\n },\n },\n },\n {\n skipSDKVersionRequirement: true,\n }\n );\n\n if (modification.type !== 'success') {\n debug('Could not remove generated origin from manifest');\n } else {\n debug('Generated origin has been removed from manifest');\n }\n}\n"],"names":["exportStandaloneServerAsync","debug","require","projectRoot","devServer","exp","pkg","files","options","eager","tryRemovingGeneratedOriginAsync","logInXcode","serverOutput","path","join","platform","removeAsync","exportApiRoutesStandaloneAsync","apiRoutesOnly","publicPath","getPublicFolderPath","copyPublicFolderAsync","persistMetroFilesAsync","entries","forEach","key","value","targetDomain","delete","userDefinedServerUrl","extra","router","origin","serverUrl","shouldSkipServerDeployment","env","EXPO_NO_DEPLOY","warnInXcode","isExecutingFromXcodebuild","deployedServerUrl","runServerDeployCommandAsync","distDirectory","deployScript","getServerDeploymentScript","scripts","Log","log","modification","modifyConfigAsync","generatedOrigin","skipSDKVersionRequirement","type","CommandError","dumpDeploymentLogs","logs","name","outputPath","fs","promises","mkdir","dirname","recursive","writeFile","getCommandBin","command","execSync","stdio","toString","trim","logOfflineError","manualScript","scriptName","logMetroErrorInXcode","chalk","red","EXPO_OFFLINE","EXPO_UNSTABLE_DEPLOY_SERVER","EAS_BUILD","globalBin","json","results","spawnOptions","cwd","exportDir","relative","spawnAsync","stdout","stderr","process","write","logPath","output","JSON","parse","error","isSpawnResultError","dim","match","disableNetwork","assertDeploymentJsonOutput","canParseURL","url","dashboardUrl","URL","Error","DEFAULT_SCRIPT_NAME","scriptNames","script","CI","undefined"],"mappings":"AAAA;;;;;CAKC;;;;+BAmCqBA;;;eAAAA;;;;yBAjCY;;;;;;;gEACX;;;;;;;gEACL;;;;;;;gEACH;;;;;;;yBACU;;;;;;;gEACR;;;;;;0BAEc;qBACX;uBACe;qBAEP;qBACR;wBACS;mCACkB;8BACY;4BAEpB;qCAOhC;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAOxB,eAAeF,4BACpBG,WAAmB,EACnBC,SAAgC,EAChC,EACEC,GAAG,EACHC,GAAG,EACHC,KAAK,EACLC,OAAO,EAC8E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C,QAAQ/D,OAAO,CAAC2B,WAAW;YAAC;QACnD;IACF;IAEA,OAAO;AACT;AAEA,kMAAkM,GAClM,eAAe7D,gCAAgCP,WAAmB,EAAEE,GAAe;QAK7EA,mBAAAA,YAWQA;IAfZ,IAAI8B,QAAG,CAACyE,EAAE,EAAE;QACV,yCAAyC;QACzC;IACF;IACA,IAAIvG,EAAAA,aAAAA,IAAIyB,KAAK,sBAATzB,oBAAAA,WAAW0B,MAAM,qBAAjB1B,kBAAmB4C,eAAe,KAAI,MAAM;QAC9ChD,MAAM;QACN;IACF;IAEA,MAAM8C,eAAe,MAAMC,IAAAA,2BAAiB,EAC1C7C,aACA;QACE2B,OAAO;YACL,GAAIzB,IAAIyB,KAAK,IAAI,CAAC,CAAC;YACnBC,QAAQ;gBACN,GAAI1B,EAAAA,cAAAA,IAAIyB,KAAK,qBAATzB,YAAW0B,MAAM,KAAI,CAAC,CAAC;gBAC3BkB,iBAAiB4D;YACnB;QACF;IACF,GACA;QACE3D,2BAA2B;IAC7B;IAGF,IAAIH,aAAaI,IAAI,KAAK,WAAW;QACnClD,MAAM;IACR,OAAO;QACLA,MAAM;IACR;AACF"}
|
|
@@ -153,7 +153,7 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
const mode = dev ? 'development' : 'production';
|
|
156
|
-
const publicPath =
|
|
156
|
+
const publicPath = (0, _publicFolder.getPublicFolderPath)(projectRoot);
|
|
157
157
|
const outputPath = _path().default.resolve(projectRoot, outputDir);
|
|
158
158
|
// Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).
|
|
159
159
|
const files = new Map();
|