@expo/cli 0.20.0 → 0.20.2
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/start/server/middleware/DomComponentsMiddleware.js +1 -0
- package/build/src/start/server/middleware/DomComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +9 -2
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/resolveRuntimeVersionWithExpoUpdatesAsync.js +36 -0
- package/build/src/start/server/middleware/resolveRuntimeVersionWithExpoUpdatesAsync.js.map +1 -0
- package/build/src/utils/expoUpdatesCli.js +110 -0
- package/build/src/utils/expoUpdatesCli.js.map +1 -0
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +3 -3
package/build/bin/cli
CHANGED
|
@@ -70,6 +70,7 @@ function createDomComponentsMiddleware({ metroRoot , projectRoot }, instanceMet
|
|
|
70
70
|
const metroUrl = new URL((0, _metroOptions.createBundleUrlPath)({
|
|
71
71
|
...instanceMetroOptions,
|
|
72
72
|
domRoot: encodeURI(relativeImport),
|
|
73
|
+
baseUrl: "/",
|
|
73
74
|
mainModuleName: _path().default.relative(metroRoot, virtualEntry),
|
|
74
75
|
bytecode: false,
|
|
75
76
|
platform: "web",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/DomComponentsMiddleware.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { createBundleUrlPath, ExpoMetroOptions } from './metroOptions';\nimport type { ServerRequest, ServerResponse } from './server.types';\nimport { Log } from '../../../log';\nimport { memoize } from '../../../utils/fn';\nimport { fileURLToFilePath } from '../metro/createServerComponentsMiddleware';\n\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport const DOM_COMPONENTS_BUNDLE_DIR = 'www.bundle';\n\nconst warnUnstable = memoize(() =>\n Log.warn('Using experimental DOM Components API. Production exports may not work as expected.')\n);\n\nconst checkWebViewInstalled = memoize((projectRoot: string) => {\n const webViewInstalled =\n resolveFrom.silent(projectRoot, 'react-native-webview') ||\n resolveFrom.silent(projectRoot, '@expo/dom-webview');\n if (!webViewInstalled) {\n throw new Error(\n `To use DOM Components, you must install the 'react-native-webview' package. Run 'npx expo install react-native-webview' to install it.`\n );\n }\n});\n\ntype CreateDomComponentsMiddlewareOptions = {\n /** The absolute metro or server root, used to calculate the relative dom entry path */\n metroRoot: string;\n /** The absolute project root, used to resolve the `expo/dom/entry.js` path */\n projectRoot: string;\n};\n\nexport function createDomComponentsMiddleware(\n { metroRoot, projectRoot }: CreateDomComponentsMiddlewareOptions,\n instanceMetroOptions: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'platform' | 'bytecode'>\n) {\n return (req: ServerRequest, res: ServerResponse, next: (err?: Error) => void) => {\n if (!req.url) return next();\n\n const url = coerceUrl(req.url);\n\n // Match `/_expo/@dom`.\n // This URL can contain additional paths like `/_expo/@dom/foo.js?file=...` to help the Safari dev tools.\n if (!url.pathname.startsWith('/_expo/@dom')) {\n return next();\n }\n\n const file = url.searchParams.get('file');\n\n if (!file || !file.startsWith('file://')) {\n res.statusCode = 400;\n res.statusMessage = 'Invalid file path: ' + file;\n return res.end();\n }\n\n checkWebViewInstalled(projectRoot);\n warnUnstable();\n\n // Generate a unique entry file for the webview.\n const generatedEntry = file.startsWith('file://') ? fileURLToFilePath(file) : file;\n const virtualEntry = resolveFrom(projectRoot, 'expo/dom/entry.js');\n const relativeImport = './' + path.relative(path.dirname(virtualEntry), generatedEntry);\n // Create the script URL\n const requestUrlBase = `http://${req.headers.host}`;\n const metroUrl = new URL(\n createBundleUrlPath({\n ...instanceMetroOptions,\n domRoot: encodeURI(relativeImport),\n mainModuleName: path.relative(metroRoot, virtualEntry),\n bytecode: false,\n platform: 'web',\n isExporting: false,\n engine: 'hermes',\n // Required for ensuring bundler errors are caught in the root entry / async boundary and can be recovered from automatically.\n lazy: true,\n }),\n requestUrlBase\n ).toString();\n\n res.statusCode = 200;\n // Return HTML file\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n // Create the entry HTML file.\n getDomComponentHtml(metroUrl, { title: path.basename(file) })\n );\n };\n}\n\nfunction coerceUrl(url: string) {\n try {\n return new URL(url);\n } catch {\n return new URL(url, 'https://localhost:0');\n }\n}\n\nexport function getDomComponentHtml(src?: string, { title }: { title?: string } = {}) {\n // This HTML is not optimized for `react-native-web` since DOM Components are meant for general React DOM web development.\n return `\n<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta httpEquiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">\n ${title ? `<title>${title}</title>` : ''}\n <style id=\"expo-dom-component-style\">\n /* These styles make the body full-height */\n html,\n body {\n -webkit-overflow-scrolling: touch; /* Enables smooth momentum scrolling */\n }\n /* These styles make the root element full-height */\n #root {\n display: flex;\n flex: 1;\n }\n </style>\n </head>\n <body>\n <noscript>DOM Components require <code>javaScriptEnabled</code></noscript>\n <!-- Root element for the DOM component. -->\n <div id=\"root\"></div>\n ${src ? `<script crossorigin src=\"${src}\"></script>` : ''}\n </body>\n</html>`;\n}\n"],"names":["DOM_COMPONENTS_BUNDLE_DIR","createDomComponentsMiddleware","getDomComponentHtml","warnUnstable","memoize","Log","warn","checkWebViewInstalled","projectRoot","webViewInstalled","resolveFrom","silent","Error","metroRoot","instanceMetroOptions","req","res","next","url","coerceUrl","pathname","startsWith","file","searchParams","get","statusCode","statusMessage","end","generatedEntry","fileURLToFilePath","virtualEntry","relativeImport","path","relative","dirname","requestUrlBase","headers","host","metroUrl","URL","createBundleUrlPath","domRoot","encodeURI","mainModuleName","bytecode","platform","isExporting","engine","lazy","toString","setHeader","title","basename","src"],"mappings":"AAAA;;;;;;;;;;;IAWaA,yBAAyB,MAAzBA,yBAAyB;IAwBtBC,6BAA6B,MAA7BA,6BAA6B;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/DomComponentsMiddleware.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { createBundleUrlPath, ExpoMetroOptions } from './metroOptions';\nimport type { ServerRequest, ServerResponse } from './server.types';\nimport { Log } from '../../../log';\nimport { memoize } from '../../../utils/fn';\nimport { fileURLToFilePath } from '../metro/createServerComponentsMiddleware';\n\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport const DOM_COMPONENTS_BUNDLE_DIR = 'www.bundle';\n\nconst warnUnstable = memoize(() =>\n Log.warn('Using experimental DOM Components API. Production exports may not work as expected.')\n);\n\nconst checkWebViewInstalled = memoize((projectRoot: string) => {\n const webViewInstalled =\n resolveFrom.silent(projectRoot, 'react-native-webview') ||\n resolveFrom.silent(projectRoot, '@expo/dom-webview');\n if (!webViewInstalled) {\n throw new Error(\n `To use DOM Components, you must install the 'react-native-webview' package. Run 'npx expo install react-native-webview' to install it.`\n );\n }\n});\n\ntype CreateDomComponentsMiddlewareOptions = {\n /** The absolute metro or server root, used to calculate the relative dom entry path */\n metroRoot: string;\n /** The absolute project root, used to resolve the `expo/dom/entry.js` path */\n projectRoot: string;\n};\n\nexport function createDomComponentsMiddleware(\n { metroRoot, projectRoot }: CreateDomComponentsMiddlewareOptions,\n instanceMetroOptions: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'platform' | 'bytecode'>\n) {\n return (req: ServerRequest, res: ServerResponse, next: (err?: Error) => void) => {\n if (!req.url) return next();\n\n const url = coerceUrl(req.url);\n\n // Match `/_expo/@dom`.\n // This URL can contain additional paths like `/_expo/@dom/foo.js?file=...` to help the Safari dev tools.\n if (!url.pathname.startsWith('/_expo/@dom')) {\n return next();\n }\n\n const file = url.searchParams.get('file');\n\n if (!file || !file.startsWith('file://')) {\n res.statusCode = 400;\n res.statusMessage = 'Invalid file path: ' + file;\n return res.end();\n }\n\n checkWebViewInstalled(projectRoot);\n warnUnstable();\n\n // Generate a unique entry file for the webview.\n const generatedEntry = file.startsWith('file://') ? fileURLToFilePath(file) : file;\n const virtualEntry = resolveFrom(projectRoot, 'expo/dom/entry.js');\n const relativeImport = './' + path.relative(path.dirname(virtualEntry), generatedEntry);\n // Create the script URL\n const requestUrlBase = `http://${req.headers.host}`;\n const metroUrl = new URL(\n createBundleUrlPath({\n ...instanceMetroOptions,\n domRoot: encodeURI(relativeImport),\n baseUrl: '/',\n mainModuleName: path.relative(metroRoot, virtualEntry),\n bytecode: false,\n platform: 'web',\n isExporting: false,\n engine: 'hermes',\n // Required for ensuring bundler errors are caught in the root entry / async boundary and can be recovered from automatically.\n lazy: true,\n }),\n requestUrlBase\n ).toString();\n\n res.statusCode = 200;\n // Return HTML file\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n // Create the entry HTML file.\n getDomComponentHtml(metroUrl, { title: path.basename(file) })\n );\n };\n}\n\nfunction coerceUrl(url: string) {\n try {\n return new URL(url);\n } catch {\n return new URL(url, 'https://localhost:0');\n }\n}\n\nexport function getDomComponentHtml(src?: string, { title }: { title?: string } = {}) {\n // This HTML is not optimized for `react-native-web` since DOM Components are meant for general React DOM web development.\n return `\n<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta httpEquiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">\n ${title ? `<title>${title}</title>` : ''}\n <style id=\"expo-dom-component-style\">\n /* These styles make the body full-height */\n html,\n body {\n -webkit-overflow-scrolling: touch; /* Enables smooth momentum scrolling */\n }\n /* These styles make the root element full-height */\n #root {\n display: flex;\n flex: 1;\n }\n </style>\n </head>\n <body>\n <noscript>DOM Components require <code>javaScriptEnabled</code></noscript>\n <!-- Root element for the DOM component. -->\n <div id=\"root\"></div>\n ${src ? `<script crossorigin src=\"${src}\"></script>` : ''}\n </body>\n</html>`;\n}\n"],"names":["DOM_COMPONENTS_BUNDLE_DIR","createDomComponentsMiddleware","getDomComponentHtml","warnUnstable","memoize","Log","warn","checkWebViewInstalled","projectRoot","webViewInstalled","resolveFrom","silent","Error","metroRoot","instanceMetroOptions","req","res","next","url","coerceUrl","pathname","startsWith","file","searchParams","get","statusCode","statusMessage","end","generatedEntry","fileURLToFilePath","virtualEntry","relativeImport","path","relative","dirname","requestUrlBase","headers","host","metroUrl","URL","createBundleUrlPath","domRoot","encodeURI","baseUrl","mainModuleName","bytecode","platform","isExporting","engine","lazy","toString","setHeader","title","basename","src"],"mappings":"AAAA;;;;;;;;;;;IAWaA,yBAAyB,MAAzBA,yBAAyB;IAwBtBC,6BAA6B,MAA7BA,6BAA6B;IAmE7BC,mBAAmB,MAAnBA,mBAAmB;;;8DAtGlB,MAAM;;;;;;;8DACC,cAAc;;;;;;8BAEgB,gBAAgB;qBAElD,cAAc;oBACV,mBAAmB;kDACT,2CAA2C;;;;;;AAItE,MAAMF,yBAAyB,GAAG,YAAY,AAAC;AAEtD,MAAMG,YAAY,GAAGC,IAAAA,GAAO,QAAA,EAAC,IAC3BC,IAAG,IAAA,CAACC,IAAI,CAAC,qFAAqF,CAAC,CAChG,AAAC;AAEF,MAAMC,qBAAqB,GAAGH,IAAAA,GAAO,QAAA,EAAC,CAACI,WAAmB,GAAK;IAC7D,MAAMC,gBAAgB,GACpBC,YAAW,EAAA,QAAA,CAACC,MAAM,CAACH,WAAW,EAAE,sBAAsB,CAAC,IACvDE,YAAW,EAAA,QAAA,CAACC,MAAM,CAACH,WAAW,EAAE,mBAAmB,CAAC,AAAC;IACvD,IAAI,CAACC,gBAAgB,EAAE;QACrB,MAAM,IAAIG,KAAK,CACb,CAAC,sIAAsI,CAAC,CACzI,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,AAAC;AASI,SAASX,6BAA6B,CAC3C,EAAEY,SAAS,CA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C,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;QAkBzC,EAAEE,GAAG,GAAG,CAAC,yBAAyB,EAAEA,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;;OAE3D,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -49,6 +49,7 @@ function _structuredHeaders() {
|
|
|
49
49
|
}
|
|
50
50
|
const _manifestMiddleware = require("./ManifestMiddleware");
|
|
51
51
|
const _resolvePlatform = require("./resolvePlatform");
|
|
52
|
+
const _resolveRuntimeVersionWithExpoUpdatesAsync = require("./resolveRuntimeVersionWithExpoUpdatesAsync");
|
|
52
53
|
const _userSettings = require("../../../api/user/UserSettings");
|
|
53
54
|
const _user = require("../../../api/user/user");
|
|
54
55
|
const _codesigning = require("../../../utils/codesigning");
|
|
@@ -122,12 +123,18 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
|
|
|
122
123
|
async _getManifestResponseAsync(requestOptions) {
|
|
123
124
|
var ref, ref1;
|
|
124
125
|
const { exp , hostUri , expoGoConfig , bundleUrl } = await this._resolveProjectSettingsAsync(requestOptions);
|
|
125
|
-
const runtimeVersion = await
|
|
126
|
+
const runtimeVersion = await (0, _resolveRuntimeVersionWithExpoUpdatesAsync.resolveRuntimeVersionWithExpoUpdatesAsync)({
|
|
127
|
+
projectRoot: this.projectRoot,
|
|
128
|
+
platform: requestOptions.platform
|
|
129
|
+
}) ?? // if expo-updates can't determine runtime version, fall back to calculation from config-plugin.
|
|
130
|
+
// this happens when expo-updates is installed but runtimeVersion hasn't yet been configured or when
|
|
131
|
+
// expo-updates is not installed.
|
|
132
|
+
(await _configPlugins().Updates.getRuntimeVersionAsync(this.projectRoot, {
|
|
126
133
|
...exp,
|
|
127
134
|
runtimeVersion: exp.runtimeVersion ?? {
|
|
128
135
|
policy: "sdkVersion"
|
|
129
136
|
}
|
|
130
|
-
}, requestOptions.platform);
|
|
137
|
+
}, requestOptions.platform));
|
|
131
138
|
if (!runtimeVersion) {
|
|
132
139
|
throw new _errors.CommandError("MANIFEST_MIDDLEWARE", `Unable to determine runtime version for platform '${requestOptions.platform}'`);
|
|
133
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\nimport { getAnonymousIdAsync } from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME } from '../../../api/user/user';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { stripPort } from '../../../utils/url';\n\nconst debug = require('debug')('expo:start:server:middleware:ExpoGoManifestHandlerMiddleware');\n\nexport enum ResponseContentType {\n TEXT_PLAIN,\n APPLICATION_JSON,\n APPLICATION_EXPO_JSON,\n MULTIPART_MIXED,\n}\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n responseContentType: ResponseContentType;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n let platform = parsePlatformHeader(req);\n\n if (!platform) {\n debug(\n `No \"expo-platform\" header or \"platform\" query parameter specified. Falling back to \"ios\".`\n );\n platform = 'ios';\n }\n\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const acceptedType = accept.types([\n 'unknown/unknown',\n 'multipart/mixed',\n 'application/json',\n 'application/expo+json',\n 'text/plain',\n ]);\n\n let responseContentType;\n switch (acceptedType) {\n case 'multipart/mixed':\n responseContentType = ResponseContentType.MULTIPART_MIXED;\n break;\n case 'application/json':\n responseContentType = ResponseContentType.APPLICATION_JSON;\n break;\n case 'application/expo+json':\n responseContentType = ResponseContentType.APPLICATION_EXPO_JSON;\n break;\n default:\n responseContentType = ResponseContentType.TEXT_PLAIN;\n break;\n }\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n responseContentType,\n platform,\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n protocol: req.headers['x-forwarded-proto'] as 'http' | 'https' | undefined,\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } =\n await this._resolveProjectSettingsAsync(requestOptions);\n\n const runtimeVersion = await Updates.getRuntimeVersionAsync(\n this.projectRoot,\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId as string | undefined | null;\n const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({\n slug: exp.slug,\n codeSigningInfo,\n });\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: codeSigningInfo.keyId,\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const headers = this.getDefaultResponseHeaders();\n\n switch (requestOptions.responseContentType) {\n case ResponseContentType.MULTIPART_MIXED: {\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n headers.set('content-type', `multipart/mixed; boundary=${form.getBoundary()}`);\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n case ResponseContentType.APPLICATION_EXPO_JSON:\n case ResponseContentType.APPLICATION_JSON:\n case ResponseContentType.TEXT_PLAIN: {\n headers.set(\n 'content-type',\n ExpoGoManifestHandlerMiddleware.getContentTypeForResponseContentType(\n requestOptions.responseContentType\n )\n );\n if (manifestPartHeaders) {\n Object.entries(manifestPartHeaders).forEach(([key, value]) => {\n headers.set(key, value);\n });\n }\n\n return {\n body: stringifiedManifest,\n version: runtimeVersion,\n headers,\n };\n }\n }\n }\n\n private static getContentTypeForResponseContentType(\n responseContentType: ResponseContentType\n ): string {\n switch (responseContentType) {\n case ResponseContentType.MULTIPART_MIXED:\n return 'multipart/mixed';\n case ResponseContentType.APPLICATION_EXPO_JSON:\n return 'application/expo+json';\n case ResponseContentType.APPLICATION_JSON:\n return 'application/json';\n case ResponseContentType.TEXT_PLAIN:\n return 'text/plain';\n }\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n private static async getScopeKeyAsync({\n slug,\n codeSigningInfo,\n }: {\n slug: string;\n codeSigningInfo: CodeSigningInfo | null;\n }): Promise<string> {\n const scopeKeyFromCodeSigningInfo = codeSigningInfo?.scopeKey;\n if (scopeKeyFromCodeSigningInfo) {\n return scopeKeyFromCodeSigningInfo;\n }\n\n // Log.warn(\n // env.EXPO_OFFLINE\n // ? 'Using anonymous scope key in manifest for offline mode.'\n // : 'Using anonymous scope key in manifest.'\n // );\n return await getAnonymousScopeKeyAsync(slug);\n }\n}\n\nasync function getAnonymousScopeKeyAsync(slug: string): Promise<string> {\n const userAnonymousIdentifier = await getAnonymousIdAsync();\n return `@${ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["ExpoGoManifestHandlerMiddleware","debug","require","ResponseContentType","TEXT_PLAIN","APPLICATION_JSON","APPLICATION_EXPO_JSON","MULTIPART_MIXED","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","acceptedType","types","responseContentType","expectSignature","headers","String","hostname","stripPort","protocol","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersionAsync","projectRoot","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","scopeKey","getScopeKeyAsync","slug","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","getContentTypeForResponseContentType","Object","entries","forEach","value","FormData","append","header","length","scopeKeyFromCodeSigningInfo","getAnonymousScopeKeyAsync","userAnonymousIdentifier","getAnonymousIdAsync","ANONYMOUS_USERNAME","obj","map","k","v"],"mappings":"AAAA;;;;;;;;;;;;IAkCaA,+BAA+B,MAA/BA,+BAA+B;;;yBAjCpB,sBAAsB;;;;;;;8DAC1B,SAAS;;;;;;;8DACV,QAAQ;;;;;;;8DACN,WAAW;;;;;;;yBACgB,oBAAoB;;;;;;oCAEZ,sBAAsB;iCACnB,mBAAmB;8BAE1C,gCAAgC;sBACjC,wBAAwB;6BAKpD,4BAA4B;wBACN,uBAAuB;qBAC1B,oBAAoB;;;;;;AAE9C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,AAAC;IAExF,mBAKN;UALWC,mBAAmB;IAAnBA,mBAAmB,CAAnBA,mBAAmB,CAC7BC,YAAU,IAAVA,CAAU,IAAVA,YAAU;IADAD,mBAAmB,CAAnBA,mBAAmB,CAE7BE,kBAAgB,IAAhBA,CAAgB,IAAhBA,kBAAgB;IAFNF,mBAAmB,CAAnBA,mBA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ED,YAAY;QACZ,qBAAqB;QACrB,kEAAkE;QAClE,iDAAiD;QACjD,KAAK;QACL,OAAO,MAAMC,yBAAyB,CAACjD,IAAI,CAAC,CAAC;IAC/C;CACD;AAED,eAAeiD,yBAAyB,CAACjD,IAAY,EAAmB;IACtE,MAAMkD,uBAAuB,GAAG,MAAMC,IAAAA,aAAmB,oBAAA,GAAE,AAAC;IAC5D,OAAO,CAAC,CAAC,EAAEC,KAAkB,mBAAA,CAAC,CAAC,EAAEpD,IAAI,CAAC,CAAC,EAAEkD,uBAAuB,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAASzB,sCAAsC,CAAC4B,GAA8B,EAAc;IAC1F,OAAO,IAAI9E,GAAG,CACZiE,MAAM,CAACC,OAAO,CAACY,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAIjF,GAAG,EAAE;aAAC;SAAC,CAAC;IAC7B,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { resolveRuntimeVersionWithExpoUpdatesAsync } from './resolveRuntimeVersionWithExpoUpdatesAsync';\nimport { ServerHeaders, ServerRequest } from './server.types';\nimport { getAnonymousIdAsync } from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME } from '../../../api/user/user';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { stripPort } from '../../../utils/url';\n\nconst debug = require('debug')('expo:start:server:middleware:ExpoGoManifestHandlerMiddleware');\n\nexport enum ResponseContentType {\n TEXT_PLAIN,\n APPLICATION_JSON,\n APPLICATION_EXPO_JSON,\n MULTIPART_MIXED,\n}\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n responseContentType: ResponseContentType;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n let platform = parsePlatformHeader(req);\n\n if (!platform) {\n debug(\n `No \"expo-platform\" header or \"platform\" query parameter specified. Falling back to \"ios\".`\n );\n platform = 'ios';\n }\n\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const acceptedType = accept.types([\n 'unknown/unknown',\n 'multipart/mixed',\n 'application/json',\n 'application/expo+json',\n 'text/plain',\n ]);\n\n let responseContentType;\n switch (acceptedType) {\n case 'multipart/mixed':\n responseContentType = ResponseContentType.MULTIPART_MIXED;\n break;\n case 'application/json':\n responseContentType = ResponseContentType.APPLICATION_JSON;\n break;\n case 'application/expo+json':\n responseContentType = ResponseContentType.APPLICATION_EXPO_JSON;\n break;\n default:\n responseContentType = ResponseContentType.TEXT_PLAIN;\n break;\n }\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n responseContentType,\n platform,\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n protocol: req.headers['x-forwarded-proto'] as 'http' | 'https' | undefined,\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } =\n await this._resolveProjectSettingsAsync(requestOptions);\n\n const runtimeVersion =\n (await resolveRuntimeVersionWithExpoUpdatesAsync({\n projectRoot: this.projectRoot,\n platform: requestOptions.platform,\n })) ??\n // if expo-updates can't determine runtime version, fall back to calculation from config-plugin.\n // this happens when expo-updates is installed but runtimeVersion hasn't yet been configured or when\n // expo-updates is not installed.\n (await Updates.getRuntimeVersionAsync(\n this.projectRoot,\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n ));\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId as string | undefined | null;\n const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({\n slug: exp.slug,\n codeSigningInfo,\n });\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: codeSigningInfo.keyId,\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const headers = this.getDefaultResponseHeaders();\n\n switch (requestOptions.responseContentType) {\n case ResponseContentType.MULTIPART_MIXED: {\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n headers.set('content-type', `multipart/mixed; boundary=${form.getBoundary()}`);\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n case ResponseContentType.APPLICATION_EXPO_JSON:\n case ResponseContentType.APPLICATION_JSON:\n case ResponseContentType.TEXT_PLAIN: {\n headers.set(\n 'content-type',\n ExpoGoManifestHandlerMiddleware.getContentTypeForResponseContentType(\n requestOptions.responseContentType\n )\n );\n if (manifestPartHeaders) {\n Object.entries(manifestPartHeaders).forEach(([key, value]) => {\n headers.set(key, value);\n });\n }\n\n return {\n body: stringifiedManifest,\n version: runtimeVersion,\n headers,\n };\n }\n }\n }\n\n private static getContentTypeForResponseContentType(\n responseContentType: ResponseContentType\n ): string {\n switch (responseContentType) {\n case ResponseContentType.MULTIPART_MIXED:\n return 'multipart/mixed';\n case ResponseContentType.APPLICATION_EXPO_JSON:\n return 'application/expo+json';\n case ResponseContentType.APPLICATION_JSON:\n return 'application/json';\n case ResponseContentType.TEXT_PLAIN:\n return 'text/plain';\n }\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n private static async getScopeKeyAsync({\n slug,\n codeSigningInfo,\n }: {\n slug: string;\n codeSigningInfo: CodeSigningInfo | null;\n }): Promise<string> {\n const scopeKeyFromCodeSigningInfo = codeSigningInfo?.scopeKey;\n if (scopeKeyFromCodeSigningInfo) {\n return scopeKeyFromCodeSigningInfo;\n }\n\n // Log.warn(\n // env.EXPO_OFFLINE\n // ? 'Using anonymous scope key in manifest for offline mode.'\n // : 'Using anonymous scope key in manifest.'\n // );\n return await getAnonymousScopeKeyAsync(slug);\n }\n}\n\nasync function getAnonymousScopeKeyAsync(slug: string): Promise<string> {\n const userAnonymousIdentifier = await getAnonymousIdAsync();\n return `@${ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["ExpoGoManifestHandlerMiddleware","debug","require","ResponseContentType","TEXT_PLAIN","APPLICATION_JSON","APPLICATION_EXPO_JSON","MULTIPART_MIXED","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","acceptedType","types","responseContentType","expectSignature","headers","String","hostname","stripPort","protocol","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","resolveRuntimeVersionWithExpoUpdatesAsync","projectRoot","Updates","getRuntimeVersionAsync","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","scopeKey","getScopeKeyAsync","slug","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","getContentTypeForResponseContentType","Object","entries","forEach","value","FormData","append","header","length","scopeKeyFromCodeSigningInfo","getAnonymousScopeKeyAsync","userAnonymousIdentifier","getAnonymousIdAsync","ANONYMOUS_USERNAME","obj","map","k","v"],"mappings":"AAAA;;;;;;;;;;;;IAmCaA,+BAA+B,MAA/BA,+BAA+B;;;yBAlCpB,sBAAsB;;;;;;;8DAC1B,SAAS;;;;;;;8DACV,QAAQ;;;;;;;8DACN,WAAW;;;;;;;yBACgB,oBAAoB;;;;;;oCAEZ,sBAAsB;iCACnB,mBAAmB;2DACpB,6CAA6C;8BAEnE,gCAAgC;sBACjC,wBAAwB;6BAKpD,4BAA4B;wBACN,uBAAuB;qBAC1B,oBAAoB;;;;;;AAE9C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,AAAC;IAExF,mBAKN;UALWC,mBAAmB;IAAnBA,mBAAmB,CAAnBA,mBAAmB,CAC7BC,YAAU,IAAVA,CAAU,IAAVA,YAAU;IADAD,mBAAmB,CAAnBA,mBAAmB,CAE7BE,kBAAgB,IAAhBA,CAAgB,IAAhBA,kBAAgB;IAFNF,mBAAmB,CAAnBA,mBAAmB,CAG7BG,uBAAqB,IAArBA,CAAqB,IAArBA,uBAAqB;IAHXH,mBAAmB,CAAnBA,mBAAmB,CAI7BI,iBAAe,IAAfA,CAAe,IAAfA,iBAAe;GAJLJ,mBAAmB,KAAnBA,mBAAmB;AAYxB,MAAMH,+BAA+B,SAASQ,mBAAkB,mBAAA;IAC9DC,gBAAgB,CAACC,GAAkB,EAA6B;QACrE,IAAIC,QAAQ,GAAGC,IAAAA,gBAAmB,oBAAA,EAACF,GAAG,CAAC,AAAC;QAExC,IAAI,CAACC,QAAQ,EAAE;YACbV,KAAK,CACH,CAAC,yFAAyF,CA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MkD,uBAAuB,GAAG,MAAMC,IAAAA,aAAmB,oBAAA,GAAE,AAAC;IAC5D,OAAO,CAAC,CAAC,EAAEC,KAAkB,mBAAA,CAAC,CAAC,EAAEpD,IAAI,CAAC,CAAC,EAAEkD,uBAAuB,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAASzB,sCAAsC,CAAC4B,GAA8B,EAAc;IAC1F,OAAO,IAAI/E,GAAG,CACZkE,MAAM,CAACC,OAAO,CAACY,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAIlF,GAAG,EAAE;aAAC;SAAC,CAAC;IAC7B,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "resolveRuntimeVersionWithExpoUpdatesAsync", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>resolveRuntimeVersionWithExpoUpdatesAsync
|
|
8
|
+
});
|
|
9
|
+
const _env = require("../../../utils/env");
|
|
10
|
+
const _expoUpdatesCli = require("../../../utils/expoUpdatesCli");
|
|
11
|
+
const debug = require("debug")("expo:start:server:middleware:resolveRuntimeVersion");
|
|
12
|
+
async function resolveRuntimeVersionWithExpoUpdatesAsync({ projectRoot , platform }) {
|
|
13
|
+
try {
|
|
14
|
+
debug("Using expo-updates runtimeversion:resolve CLI for runtime version resolution");
|
|
15
|
+
const extraArgs = _env.env.EXPO_DEBUG ? [
|
|
16
|
+
"--debug"
|
|
17
|
+
] : [];
|
|
18
|
+
const resolvedRuntimeVersionJSONResult = await (0, _expoUpdatesCli.expoUpdatesCommandAsync)(projectRoot, [
|
|
19
|
+
"runtimeversion:resolve",
|
|
20
|
+
"--platform",
|
|
21
|
+
platform,
|
|
22
|
+
...extraArgs,
|
|
23
|
+
]);
|
|
24
|
+
const runtimeVersionResult = JSON.parse(resolvedRuntimeVersionJSONResult);
|
|
25
|
+
debug("runtimeversion:resolve output:");
|
|
26
|
+
debug(resolvedRuntimeVersionJSONResult);
|
|
27
|
+
return runtimeVersionResult.runtimeVersion ?? null;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
if (e instanceof _expoUpdatesCli.ExpoUpdatesCLIModuleNotFoundError) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=resolveRuntimeVersionWithExpoUpdatesAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/resolveRuntimeVersionWithExpoUpdatesAsync.ts"],"sourcesContent":["import { RuntimePlatform } from './resolvePlatform';\nimport { env } from '../../../utils/env';\nimport {\n ExpoUpdatesCLIModuleNotFoundError,\n expoUpdatesCommandAsync,\n} from '../../../utils/expoUpdatesCli';\n\nconst debug = require('debug')('expo:start:server:middleware:resolveRuntimeVersion');\n\nexport async function resolveRuntimeVersionWithExpoUpdatesAsync({\n projectRoot,\n platform,\n}: {\n projectRoot: string;\n platform: RuntimePlatform;\n}): Promise<string | null> {\n try {\n debug('Using expo-updates runtimeversion:resolve CLI for runtime version resolution');\n const extraArgs = env.EXPO_DEBUG ? ['--debug'] : [];\n const resolvedRuntimeVersionJSONResult = await expoUpdatesCommandAsync(projectRoot, [\n 'runtimeversion:resolve',\n '--platform',\n platform,\n ...extraArgs,\n ]);\n const runtimeVersionResult: { runtimeVersion: string | null } = JSON.parse(\n resolvedRuntimeVersionJSONResult\n );\n debug('runtimeversion:resolve output:');\n debug(resolvedRuntimeVersionJSONResult);\n\n return runtimeVersionResult.runtimeVersion ?? null;\n } catch (e: any) {\n if (e instanceof ExpoUpdatesCLIModuleNotFoundError) {\n return null;\n }\n throw e;\n }\n}\n"],"names":["resolveRuntimeVersionWithExpoUpdatesAsync","debug","require","projectRoot","platform","extraArgs","env","EXPO_DEBUG","resolvedRuntimeVersionJSONResult","expoUpdatesCommandAsync","runtimeVersionResult","JSON","parse","runtimeVersion","e","ExpoUpdatesCLIModuleNotFoundError"],"mappings":"AAAA;;;;+BASsBA,2CAAyC;;aAAzCA,yCAAyC;;qBAR3C,oBAAoB;gCAIjC,+BAA+B;AAEtC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,AAAC;AAE9E,eAAeF,yCAAyC,CAAC,EAC9DG,WAAW,CAAA,EACXC,QAAQ,CAAA,EAIT,EAA0B;IACzB,IAAI;QACFH,KAAK,CAAC,8EAA8E,CAAC,CAAC;QACtF,MAAMI,SAAS,GAAGC,IAAG,IAAA,CAACC,UAAU,GAAG;YAAC,SAAS;SAAC,GAAG,EAAE,AAAC;QACpD,MAAMC,gCAAgC,GAAG,MAAMC,IAAAA,eAAuB,wBAAA,EAACN,WAAW,EAAE;YAClF,wBAAwB;YACxB,YAAY;YACZC,QAAQ;eACLC,SAAS;SACb,CAAC,AAAC;QACH,MAAMK,oBAAoB,GAAsCC,IAAI,CAACC,KAAK,CACxEJ,gCAAgC,CACjC,AAAC;QACFP,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACxCA,KAAK,CAACO,gCAAgC,CAAC,CAAC;QAExC,OAAOE,oBAAoB,CAACG,cAAc,IAAI,IAAI,CAAC;IACrD,EAAE,OAAOC,CAAC,EAAO;QACf,IAAIA,CAAC,YAAYC,eAAiC,kCAAA,EAAE;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAMD,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
ExpoUpdatesCLIModuleNotFoundError: ()=>ExpoUpdatesCLIModuleNotFoundError,
|
|
13
|
+
ExpoUpdatesCLIInvalidCommandError: ()=>ExpoUpdatesCLIInvalidCommandError,
|
|
14
|
+
ExpoUpdatesCLICommandFailedError: ()=>ExpoUpdatesCLICommandFailedError,
|
|
15
|
+
expoUpdatesCommandAsync: ()=>expoUpdatesCommandAsync
|
|
16
|
+
});
|
|
17
|
+
function _spawnAsync() {
|
|
18
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("@expo/spawn-async"));
|
|
19
|
+
_spawnAsync = function() {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function _resolveFrom() {
|
|
25
|
+
const data = /*#__PURE__*/ _interopRequireWildcard(require("resolve-from"));
|
|
26
|
+
_resolveFrom = function() {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _interopRequireDefault(obj) {
|
|
32
|
+
return obj && obj.__esModule ? obj : {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
37
|
+
if (typeof WeakMap !== "function") return null;
|
|
38
|
+
var cacheBabelInterop = new WeakMap();
|
|
39
|
+
var cacheNodeInterop = new WeakMap();
|
|
40
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
41
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
42
|
+
})(nodeInterop);
|
|
43
|
+
}
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
45
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
49
|
+
return {
|
|
50
|
+
default: obj
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
54
|
+
if (cache && cache.has(obj)) {
|
|
55
|
+
return cache.get(obj);
|
|
56
|
+
}
|
|
57
|
+
var newObj = {};
|
|
58
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
59
|
+
for(var key in obj){
|
|
60
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
61
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
62
|
+
if (desc && (desc.get || desc.set)) {
|
|
63
|
+
Object.defineProperty(newObj, key, desc);
|
|
64
|
+
} else {
|
|
65
|
+
newObj[key] = obj[key];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
newObj.default = obj;
|
|
70
|
+
if (cache) {
|
|
71
|
+
cache.set(obj, newObj);
|
|
72
|
+
}
|
|
73
|
+
return newObj;
|
|
74
|
+
}
|
|
75
|
+
class ExpoUpdatesCLIModuleNotFoundError extends Error {
|
|
76
|
+
}
|
|
77
|
+
class ExpoUpdatesCLIInvalidCommandError extends Error {
|
|
78
|
+
}
|
|
79
|
+
class ExpoUpdatesCLICommandFailedError extends Error {
|
|
80
|
+
}
|
|
81
|
+
async function expoUpdatesCommandAsync(projectDir, args) {
|
|
82
|
+
let expoUpdatesCli;
|
|
83
|
+
try {
|
|
84
|
+
expoUpdatesCli = (0, _resolveFrom().silent)(projectDir, "expo-updates/bin/cli") ?? (0, _resolveFrom().default)(projectDir, "expo-updates/bin/cli.js");
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
87
|
+
throw new ExpoUpdatesCLIModuleNotFoundError(`The \`expo-updates\` package was not found. `);
|
|
88
|
+
}
|
|
89
|
+
throw e;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
return (await (0, _spawnAsync().default)(expoUpdatesCli, args, {
|
|
93
|
+
stdio: "pipe",
|
|
94
|
+
env: {
|
|
95
|
+
...process.env
|
|
96
|
+
}
|
|
97
|
+
})).stdout;
|
|
98
|
+
} catch (e1) {
|
|
99
|
+
if (e1.stderr && typeof e1.stderr === "string") {
|
|
100
|
+
if (e1.stderr.includes("Invalid command")) {
|
|
101
|
+
throw new ExpoUpdatesCLIInvalidCommandError(`The command specified by ${args} was not valid in the \`expo-updates\` CLI.`);
|
|
102
|
+
} else {
|
|
103
|
+
throw new ExpoUpdatesCLICommandFailedError(e1.stderr);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw e1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=expoUpdatesCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/expoUpdatesCli.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport resolveFrom, { silent as silentResolveFrom } from 'resolve-from';\n\nexport class ExpoUpdatesCLIModuleNotFoundError extends Error {}\nexport class ExpoUpdatesCLIInvalidCommandError extends Error {}\nexport class ExpoUpdatesCLICommandFailedError extends Error {}\n\nexport async function expoUpdatesCommandAsync(projectDir: string, args: string[]): Promise<string> {\n let expoUpdatesCli;\n try {\n expoUpdatesCli =\n silentResolveFrom(projectDir, 'expo-updates/bin/cli') ??\n resolveFrom(projectDir, 'expo-updates/bin/cli.js');\n } catch (e: any) {\n if (e.code === 'MODULE_NOT_FOUND') {\n throw new ExpoUpdatesCLIModuleNotFoundError(`The \\`expo-updates\\` package was not found. `);\n }\n throw e;\n }\n\n try {\n return (\n await spawnAsync(expoUpdatesCli, args, {\n stdio: 'pipe',\n env: { ...process.env },\n })\n ).stdout;\n } catch (e: any) {\n if (e.stderr && typeof e.stderr === 'string') {\n if (e.stderr.includes('Invalid command')) {\n throw new ExpoUpdatesCLIInvalidCommandError(\n `The command specified by ${args} was not valid in the \\`expo-updates\\` CLI.`\n );\n } else {\n throw new ExpoUpdatesCLICommandFailedError(e.stderr);\n }\n }\n\n throw e;\n }\n}\n"],"names":["ExpoUpdatesCLIModuleNotFoundError","ExpoUpdatesCLIInvalidCommandError","ExpoUpdatesCLICommandFailedError","expoUpdatesCommandAsync","Error","projectDir","args","expoUpdatesCli","silentResolveFrom","resolveFrom","e","code","spawnAsync","stdio","env","process","stdout","stderr","includes"],"mappings":"AAAA;;;;;;;;;;;IAGaA,iCAAiC,MAAjCA,iCAAiC;IACjCC,iCAAiC,MAAjCA,iCAAiC;IACjCC,gCAAgC,MAAhCA,gCAAgC;IAEvBC,uBAAuB,MAAvBA,uBAAuB;;;8DAPtB,mBAAmB;;;;;;;+DACe,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhE,MAAMH,iCAAiC,SAASI,KAAK;CAAG;AACxD,MAAMH,iCAAiC,SAASG,KAAK;CAAG;AACxD,MAAMF,gCAAgC,SAASE,KAAK;CAAG;AAEvD,eAAeD,uBAAuB,CAACE,UAAkB,EAAEC,IAAc,EAAmB;IACjG,IAAIC,cAAc,AAAC;IACnB,IAAI;QACFA,cAAc,GACZC,IAAAA,YAAiB,EAAA,OAAA,EAACH,UAAU,EAAE,sBAAsB,CAAC,IACrDI,IAAAA,YAAW,EAAA,QAAA,EAACJ,UAAU,EAAE,yBAAyB,CAAC,CAAC;IACvD,EAAE,OAAOK,CAAC,EAAO;QACf,IAAIA,CAAC,CAACC,IAAI,KAAK,kBAAkB,EAAE;YACjC,MAAM,IAAIX,iCAAiC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC;QAC9F,CAAC;QACD,MAAMU,CAAC,CAAC;IACV,CAAC;IAED,IAAI;QACF,OAAO,CACL,MAAME,IAAAA,WAAU,EAAA,QAAA,EAACL,cAAc,EAAED,IAAI,EAAE;YACrCO,KAAK,EAAE,MAAM;YACbC,GAAG,EAAE;gBAAE,GAAGC,OAAO,CAACD,GAAG;aAAE;SACxB,CAAC,CACH,CAACE,MAAM,CAAC;IACX,EAAE,OAAON,EAAC,EAAO;QACf,IAAIA,EAAC,CAACO,MAAM,IAAI,OAAOP,EAAC,CAACO,MAAM,KAAK,QAAQ,EAAE;YAC5C,IAAIP,EAAC,CAACO,MAAM,CAACC,QAAQ,CAAC,iBAAiB,CAAC,EAAE;gBACxC,MAAM,IAAIjB,iCAAiC,CACzC,CAAC,yBAAyB,EAAEK,IAAI,CAAC,2CAA2C,CAAC,CAC9E,CAAC;YACJ,OAAO;gBACL,MAAM,IAAIJ,gCAAgC,CAACQ,EAAC,CAACO,MAAM,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAED,MAAMP,EAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -31,7 +31,7 @@ class FetchClient {
|
|
|
31
31
|
this.headers = {
|
|
32
32
|
accept: "application/json",
|
|
33
33
|
"content-type": "application/json",
|
|
34
|
-
"user-agent": `expo-cli/${"0.20.
|
|
34
|
+
"user-agent": `expo-cli/${"0.20.2"}`,
|
|
35
35
|
authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
|
|
36
36
|
};
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@expo/osascript": "^2.0.31",
|
|
53
53
|
"@expo/package-manager": "^1.5.0",
|
|
54
54
|
"@expo/plist": "^0.2.0",
|
|
55
|
-
"@expo/prebuild-config": "^8.0.
|
|
55
|
+
"@expo/prebuild-config": "^8.0.9",
|
|
56
56
|
"@expo/rudder-sdk-node": "^1.1.1",
|
|
57
57
|
"@expo/spawn-async": "^1.7.2",
|
|
58
58
|
"@expo/xcpretty": "^4.3.0",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"tree-kill": "^1.2.2",
|
|
168
168
|
"tsd": "^0.28.1"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "c0899e56c5be08b0142f06f05aa7bac8d6bc18b8"
|
|
171
171
|
}
|