@expo/cli 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +2 -2
- package/build/src/export/createBundles.js.map +1 -1
- package/build/src/export/exportApp.js +1 -2
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +3 -0
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/install/checkPackages.js +3 -6
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/installAsync.js +37 -3
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/run/ios/appleDevice/ClientManager.js +5 -1
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js +5 -1
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +18 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +13 -3
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +6 -2
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +7 -2
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +14 -10
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +4 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +5 -0
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/resolveFromProject.js +4 -0
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +29 -0
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +30 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +5 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +1 -1
- package/build/src/utils/FileNotifier.js +11 -2
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/getMetroDebugProperties.js +16 -0
- package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -0
- package/build/src/utils/analytics/getMetroProperties.js +29 -0
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -0
- package/build/src/utils/analytics/metroDebuggerMiddleware.js +50 -0
- package/build/src/utils/analytics/metroDebuggerMiddleware.js.map +1 -0
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
- package/build/src/utils/array.js +11 -0
- package/build/src/utils/array.js.map +1 -1
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/package.json +4 -4
package/build/bin/cli
CHANGED
|
@@ -121,7 +121,7 @@ const args = (0, _arg).default({
|
|
|
121
121
|
});
|
|
122
122
|
if (args["--version"]) {
|
|
123
123
|
// Version is added in the build script.
|
|
124
|
-
console.log("0.
|
|
124
|
+
console.log("0.6.0");
|
|
125
125
|
process.exit(0);
|
|
126
126
|
}
|
|
127
127
|
if (args["--non-interactive"]) {
|
|
@@ -248,7 +248,7 @@ commands[command]().then((exec)=>{
|
|
|
248
248
|
logEventAsync("action", {
|
|
249
249
|
action: `expo ${command}`,
|
|
250
250
|
source: "expo/cli",
|
|
251
|
-
source_version: "0.
|
|
251
|
+
source_version: "0.6.0"
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/createBundles.ts"],"sourcesContent":["import { getConfig, Platform, ProjectTarget } from '@expo/config';\n\nimport * as Log from '../log';\nimport { resolveEntryPoint } from '../start/server/middleware/resolveEntryPoint';\nimport { bundleAsync, BundleOutput } from './fork-bundleAsync';\n\nexport type PublishOptions = {\n releaseChannel?: string;\n target?: ProjectTarget;\n resetCache?: boolean;\n maxWorkers?: number;\n};\n\n// TODO: Reduce layers of indirection\nexport async function createBundlesAsync(\n projectRoot: string,\n publishOptions: PublishOptions = {},\n bundleOptions: { platforms: Platform[]; dev?: boolean
|
|
1
|
+
{"version":3,"sources":["../../../src/export/createBundles.ts"],"sourcesContent":["import { getConfig, Platform, ProjectTarget } from '@expo/config';\n\nimport * as Log from '../log';\nimport { resolveEntryPoint } from '../start/server/middleware/resolveEntryPoint';\nimport { bundleAsync, BundleOutput } from './fork-bundleAsync';\n\nexport type PublishOptions = {\n releaseChannel?: string;\n target?: ProjectTarget;\n resetCache?: boolean;\n maxWorkers?: number;\n};\n\n// TODO: Reduce layers of indirection\nexport async function createBundlesAsync(\n projectRoot: string,\n publishOptions: PublishOptions = {},\n bundleOptions: { platforms: Platform[]; dev?: boolean }\n): Promise<Partial<Record<Platform, BundleOutput>>> {\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n\n const bundles = await bundleAsync(\n projectRoot,\n exp,\n {\n // If not legacy, ignore the target option to prevent warnings from being thrown.\n resetCache: publishOptions.resetCache,\n maxWorkers: publishOptions.maxWorkers,\n logger: {\n info(tag: unknown, message: string) {\n Log.log(message);\n },\n error(tag: unknown, message: string) {\n Log.error(message);\n },\n } as any,\n quiet: false,\n },\n bundleOptions.platforms.map((platform: Platform) => ({\n platform,\n entryPoint: resolveEntryPoint(projectRoot, platform),\n dev: bundleOptions.dev,\n }))\n );\n\n // { ios: bundle, android: bundle }\n return bundleOptions.platforms.reduce<Partial<Record<Platform, BundleOutput>>>(\n (prev, platform, index) => ({\n ...prev,\n [platform]: bundles[index],\n }),\n {}\n );\n}\n"],"names":["createBundlesAsync","Log","projectRoot","publishOptions","bundleOptions","exp","getConfig","skipSDKVersionRequirement","bundles","bundleAsync","resetCache","maxWorkers","logger","info","tag","message","log","error","quiet","platforms","map","platform","entryPoint","resolveEntryPoint","dev","reduce","prev","index"],"mappings":"AAAA;;;;QAcsBA,kBAAkB,GAAlBA,kBAAkB;AAdW,IAAA,OAAc,WAAd,cAAc,CAAA;AAErDC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA8C,WAA9C,8CAA8C,CAAA;AACtC,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAUvD,eAAeD,kBAAkB,CACtCE,WAAmB,EACnBC,cAA8B,GAAG,EAAE,EACnCC,aAAuD,EACL;IAClD,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAAkD,CAAA,UAAlD,CAACJ,WAAW,EAAE;QAAEK,yBAAyB,EAAE,IAAI;KAAE,CAAC,AAAC;IAE5E,MAAMC,OAAO,GAAG,MAAMC,CAAAA,GAAAA,gBAAW,AAsBhC,CAAA,YAtBgC,CAC/BP,WAAW,EACXG,GAAG,EACH;QACE,iFAAiF;QACjFK,UAAU,EAAEP,cAAc,CAACO,UAAU;QACrCC,UAAU,EAAER,cAAc,CAACQ,UAAU;QACrCC,MAAM,EAAE;YACNC,IAAI,EAACC,GAAY,EAAEC,OAAe,EAAE;gBAClCd,GAAG,CAACe,GAAG,CAACD,OAAO,CAAC,CAAC;aAClB;YACDE,KAAK,EAACH,GAAY,EAAEC,OAAe,EAAE;gBACnCd,GAAG,CAACgB,KAAK,CAACF,OAAO,CAAC,CAAC;aACpB;SACF;QACDG,KAAK,EAAE,KAAK;KACb,EACDd,aAAa,CAACe,SAAS,CAACC,GAAG,CAAC,CAACC,QAAkB,GAAK,CAAC;YACnDA,QAAQ;YACRC,UAAU,EAAEC,CAAAA,GAAAA,kBAAiB,AAAuB,CAAA,kBAAvB,CAACrB,WAAW,EAAEmB,QAAQ,CAAC;YACpDG,GAAG,EAAEpB,aAAa,CAACoB,GAAG;SACvB,CAAC;IAAA,CAAC,CACJ,AAAC;IAEF,mCAAmC;IACnC,OAAOpB,aAAa,CAACe,SAAS,CAACM,MAAM,CACnC,CAACC,IAAI,EAAEL,QAAQ,EAAEM,KAAK,GAAK,CAAC;YAC1B,GAAGD,IAAI;YACP,CAACL,QAAQ,CAAC,EAAEb,OAAO,CAACmB,KAAK,CAAC;SAC3B,CAAC;IAAA,EACF,EAAE,CACH,CAAC;CACH"}
|
|
@@ -57,8 +57,7 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
|
|
|
57
57
|
resetCache: !!clear
|
|
58
58
|
}, {
|
|
59
59
|
platforms,
|
|
60
|
-
dev
|
|
61
|
-
useDevServer: true
|
|
60
|
+
dev
|
|
62
61
|
});
|
|
63
62
|
// Log bundle size info to the user
|
|
64
63
|
(0, _printBundleSizes).printBundleSizes(Object.fromEntries(Object.entries(bundles).map(([key, value])=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { importCliSaveAssetsFromProject } from '../start/server/metro/resolveFromProject';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync } from './exportAssets';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n }: Pick<Options, 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms'>\n): Promise<void> {\n const exp = await getPublicExpoManifestAsync(projectRoot);\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const assetsPath = path.join(outputPath, 'assets');\n const bundlesPath = path.join(outputPath, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, outputDir);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n dev,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { importCliSaveAssetsFromProject } from '../start/server/metro/resolveFromProject';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync } from './exportAssets';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n }: Pick<Options, 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms'>\n): Promise<void> {\n const exp = await getPublicExpoManifestAsync(projectRoot);\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const assetsPath = path.join(outputPath, 'assets');\n const bundlesPath = path.join(outputPath, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, outputDir);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n dev,\n // TODO: Disable source map generation if we aren't outputting them.\n }\n );\n\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n Object.entries(bundles).map(([key, value]) => {\n if (!dumpSourcemap) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({ bundles, outputDir: bundlesPath });\n\n Log.log('Finished saving JS Bundles');\n\n if (fileNames.web) {\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(\n path.join(outputPath, 'index.html'),\n await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`/bundles/${fileNames.web}`],\n })\n );\n\n // Save assets like a typical bundler, preserving the file paths on web.\n const saveAssets = importCliSaveAssetsFromProject(projectRoot);\n await Promise.all(\n Object.entries(bundles).map(([platform, bundle]) => {\n return saveAssets(\n // @ts-expect-error: tolerable type mismatches: unused `readonly` (common in Metro) and `undefined` instead of `null`.\n bundle.assets,\n platform,\n outputPath,\n undefined\n );\n })\n );\n }\n\n const { assets } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: outputPath,\n bundles,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: outputPath, assets });\n }\n\n // build source maps\n if (dumpSourcemap) {\n Log.log('Dumping source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: outputPath,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir: outputPath, bundles, fileNames });\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","dumpSourcemap","exp","getPublicExpoManifestAsync","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","resetCache","printBundleSizes","Object","fromEntries","entries","key","value","undefined","hashes","fileNames","writeBundlesAsync","log","web","fs","promises","writeFile","createTemplateHtmlFromExpoConfigAsync","scripts","saveAssets","importCliSaveAssetsFromProject","platform","bundle","assets","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","publicFolder","outputFolder","existsSync","copyAsync"],"mapp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e,CAAAA,GAAAA,cAAmB,AAGvB,CAAA,oBAHuB,CAAC;YACxBjD,SAAS,EAAEY,UAAU;YACrBoB,SAAS;SACV,CAAC,CAAC;KACJ;IAED,yDAAyD;IACzD,MAAMkB,CAAAA,GAAAA,cAAsB,AAA+C,CAAA,uBAA/C,CAAC;QAAElD,SAAS,EAAEY,UAAU;QAAES,OAAO;QAAEW,SAAS;KAAE,CAAC,CAAC;CAC7E;AAED;;;;;;;GAOG,CACH,eAAeZ,qBAAqB,CAAC+B,YAAoB,EAAEC,YAAoB,EAAE;IAC/E,IAAIhB,GAAE,QAAA,CAACiB,UAAU,CAACF,YAAY,CAAC,EAAE;QAC/B,MAAMG,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACH,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}
|
|
@@ -11,6 +11,8 @@ var _metroCore = require("metro-core");
|
|
|
11
11
|
var _metroTerminalReporter = require("../start/server/metro/MetroTerminalReporter");
|
|
12
12
|
var _withMetroMultiPlatform = require("../start/server/metro/withMetroMultiPlatform");
|
|
13
13
|
var _platformBundlers = require("../start/server/platformBundlers");
|
|
14
|
+
var _getMetroProperties = require("../utils/analytics/getMetroProperties");
|
|
15
|
+
var _rudderstackClient = require("../utils/analytics/rudderstackClient");
|
|
14
16
|
function _interopRequireDefault(obj) {
|
|
15
17
|
return obj && obj.__esModule ? obj : {
|
|
16
18
|
default: obj
|
|
@@ -61,6 +63,7 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
|
|
|
61
63
|
});
|
|
62
64
|
const bundlerPlatforms = (0, _platformBundlers).getPlatformBundlers(exp);
|
|
63
65
|
config = await (0, _withMetroMultiPlatform).withMetroMultiPlatformAsync(projectRoot, config, bundlerPlatforms);
|
|
66
|
+
(0, _rudderstackClient).logEventAsync("metro config", (0, _getMetroProperties).getMetroProperties(projectRoot, exp, config));
|
|
64
67
|
const metroServer = await metro.runMetro(config, {
|
|
65
68
|
watch: false
|
|
66
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\nimport { withMetroMultiPlatformAsync } from '../start/server/metro/withMetroMultiPlatform';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: import('@expo/bunyan');\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map?: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nasync function assertEngineMismatchAsync(projectRoot: string, exp: ExpoConfig, platform: Platform) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n const bundlerPlatforms = getPlatformBundlers(exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, config, bundlerPlatforms);\n\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const isHermes = isEnableHermesManaged(expoConfig, bundle.platform);\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: !isHermes && (bundle.minify ?? !bundle.dev),\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n terminalReporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n terminalReporter.update({\n buildID,\n type: 'bundle_build_started',\n // @ts-expect-error: TODO\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n terminalReporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n } catch (error) {\n terminalReporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n terminalReporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map!,\n bundle.minify ?? !bundle.dev\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","assertEngineMismatchAsync","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","expoConfig","options","bundles","Promise","all","map","metro","importMetroFromProject","Server","importMetroServerFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","getConfig","skipSDKVersionRequirement","config","loadAsync","bundlerPlatforms","getPlatformBundlers","withMetroMultiPlatformAsync","metroServer","runMetro","watch","buildAsync","bundle","buildID","isHermes","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","build","assets","getAssets","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","ios","android","web","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","length","push","console","end"],"mappings":"AAAA;;;;QAgFsBA,WAAW,GAAXA,WAAW;AAhFmC,IAAA,OAAc,WAAd,cAAc,CAAA;AAK3E,IAAA,cAAsC,WAAtC,sCAAsC,CAAA;AAKtC,IAAA,uBAAqD,WAArD,qDAAqD,CAAA;AAE1C,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEA,IAAA,UAAY,WAAZ,YAAY,CAAA;AAEC,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AACvC,IAAA,uBAA8C,WAA9C,8CAA8C,CAAA;AACtD,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;;;;;;AAwBtE,SAASC,kBAAkB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,KAAK,CAAC;KACb,QAAS;QACR5B,WAAW,CAACgD,GAAG,EAAE,CAAC;KACnB;CACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\nimport { withMetroMultiPlatformAsync } from '../start/server/metro/withMetroMultiPlatform';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\nimport { getMetroProperties } from '../utils/analytics/getMetroProperties';\nimport { logEventAsync } from '../utils/analytics/rudderstackClient';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: import('@expo/bunyan');\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map?: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nasync function assertEngineMismatchAsync(projectRoot: string, exp: ExpoConfig, platform: Platform) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n const bundlerPlatforms = getPlatformBundlers(exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, config, bundlerPlatforms);\n\n logEventAsync('metro config', getMetroProperties(projectRoot, exp, config));\n\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const isHermes = isEnableHermesManaged(expoConfig, bundle.platform);\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: !isHermes && (bundle.minify ?? !bundle.dev),\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n terminalReporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n terminalReporter.update({\n buildID,\n type: 'bundle_build_started',\n // @ts-expect-error: TODO\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n terminalReporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n } catch (error) {\n terminalReporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n terminalReporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map!,\n bundle.minify ?? !bundle.dev\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","assertEngineMismatchAsync","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","expoConfig","options","bundles","Promise","all","map","metro","importMetroFromProject","Server","importMetroServerFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","getConfig","skipSDKVersionRequirement","config","loadAsync","bundlerPlatforms","getPlatformBundlers","withMetroMultiPlatformAsync","logEventAsync","getMetroProperties","metroServer","runMetro","watch","buildAsync","bundle","buildID","isHermes","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","build","assets","getAssets","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","ios","android","web","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","length","push","console","end"],"mappings":"AAAA;;;;QAkFsBA,WAAW,GAAXA,WAAW;AAlFmC,IAAA,OAAc,WAAd,cAAc,CAAA;AAK3E,IAAA,cAAsC,WAAtC,sCAAsC,CAAA;AAKtC,IAAA,uBAAqD,WAArD,qDAAqD,CAAA;AAE1C,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEA,IAAA,UAA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QAC3F,MAAMuC,aAAa,GAAmB,EAAE,AAAC;QACzC,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGvE,OAAO,CAACwE,MAAM,EAAE,EAAED,CAAC,CAAE;YACvC,sEAAsE;YACtE,qCAAqC;YACrCD,aAAa,CAACG,IAAI,CAAC,MAAMjB,yBAAyB,CAACxD,OAAO,CAACuE,CAAC,CAAC,EAAEF,mBAAmB,CAACE,CAAC,CAAC,CAAC,CAAC,CAAC;SACzF;QACD,OAAOD,aAAa,CAAC;KACtB,CAAC,OAAOf,KAAK,EAAE;QACd,gEAAgE;QAChEmB,OAAO,CAACZ,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,MAAMP,KAAK,CAAC;KACb,QAAS;QACR5B,WAAW,CAACgD,GAAG,EAAE,CAAC;KACnB;CACF"}
|
|
@@ -56,14 +56,11 @@ async function checkPackagesAsync(projectRoot, { packages , packageManager , opt
|
|
|
56
56
|
}).catch(()=>false
|
|
57
57
|
));
|
|
58
58
|
if (value) {
|
|
59
|
-
|
|
60
|
-
const fixedDependencies = dependencies.map((dependency)=>dependency.packageName
|
|
61
|
-
);
|
|
62
|
-
debug("Installing fixed dependencies:", fixedDependencies);
|
|
59
|
+
debug("Installing fixed dependencies:", dependencies);
|
|
63
60
|
// Install the corrected dependencies.
|
|
64
|
-
return (0, _installAsync).
|
|
61
|
+
return (0, _installAsync).fixPackagesAsync(projectRoot, {
|
|
65
62
|
packageManager,
|
|
66
|
-
packages:
|
|
63
|
+
packages: dependencies,
|
|
67
64
|
packageManagerArguments,
|
|
68
65
|
sdkVersion: exp.sdkVersion
|
|
69
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/install/checkPackages.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport {\n getVersionedDependenciesAsync,\n logIncorrectDependencies,\n} from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { isInteractive } from '../utils/interactive';\nimport { confirmAsync } from '../utils/prompts';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/install/checkPackages.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport {\n getVersionedDependenciesAsync,\n logIncorrectDependencies,\n} from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { isInteractive } from '../utils/interactive';\nimport { confirmAsync } from '../utils/prompts';\nimport { fixPackagesAsync } from './installAsync';\nimport { Options } from './resolveOptions';\n\nconst debug = require('debug')('expo:install:check') as typeof console.log;\n\n// Exposed for testing.\nexport async function checkPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n options: { fix },\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager: PackageManager.NodePackageManager;\n\n /** How the check should resolve */\n options: Pick<Options, 'fix'>;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n) {\n // Read the project Expo config without plugins.\n const { exp, pkg } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n const dependencies = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packages);\n\n if (!dependencies.length) {\n Log.exit(chalk.greenBright('Dependencies are up to date'), 0);\n }\n\n logIncorrectDependencies(dependencies);\n\n const value =\n // If `--fix` then always fix.\n fix ||\n // Otherwise prompt to fix when not running in CI.\n (isInteractive() && (await confirmAsync({ message: 'Fix dependencies?' }).catch(() => false)));\n\n if (value) {\n debug('Installing fixed dependencies:', dependencies);\n // Install the corrected dependencies.\n return fixPackagesAsync(projectRoot, {\n packageManager,\n packages: dependencies,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n }\n // Exit with non-zero exit code if any of the dependencies are out of date.\n Log.exit(chalk.red('Found outdated dependencies'), 1);\n}\n"],"names":["checkPackagesAsync","Log","debug","require","projectRoot","packages","packageManager","options","fix","packageManagerArguments","exp","pkg","getConfig","skipPlugins","dependencies","getVersionedDependenciesAsync","length","exit","chalk","greenBright","logIncorrectDependencies","value","isInteractive","confirmAsync","message","catch","fixPackagesAsync","sdkVersion","red"],"mappings":"AAAA;;;;QAiBsBA,kBAAkB,GAAlBA,kBAAkB;AAjBd,IAAA,OAAc,WAAd,cAAc,CAAA;AAEtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAIR,IAAA,6BAA2D,WAA3D,2DAA2D,CAAA;AACpC,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACd,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGjD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAGpE,eAAeH,kBAAkB,CACtCI,WAAmB,EACnB,EACEC,QAAQ,CAAA,EACRC,cAAc,CAAA,EACdC,OAAO,EAAE,EAAEC,GAAG,CAAA,EAAE,CAAA,EAChBC,uBAAuB,CAAA,EAiBxB,EACD;IACA,gDAAgD;IAChD,MAAM,EAAEC,GAAG,CAAA,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAI5B,CAAA,UAJ4B,CAACR,WAAW,EAAE;QAC1C,iFAAiF;QACjF,yEAAyE;QACzES,WAAW,EAAE,IAAI;KAClB,CAAC,AAAC;IAEH,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,6BAA6B,AAAiC,CAAA,8BAAjC,CAACX,WAAW,EAAEM,GAAG,EAAEC,GAAG,EAAEN,QAAQ,CAAC,AAAC;IAE1F,IAAI,CAACS,YAAY,CAACE,MAAM,EAAE;QACxBf,GAAG,CAACgB,IAAI,CAACC,MAAK,QAAA,CAACC,WAAW,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;KAC/D;IAEDC,CAAAA,GAAAA,6BAAwB,AAAc,CAAA,yBAAd,CAACN,YAAY,CAAC,CAAC;IAEvC,MAAMO,KAAK,GACT,8BAA8B;IAC9Bb,GAAG,IACH,kDAAkD;IAClD,CAACc,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,IAAK,MAAMC,CAAAA,GAAAA,QAAY,AAAkC,CAAA,aAAlC,CAAC;QAAEC,OAAO,EAAE,mBAAmB;KAAE,CAAC,CAACC,KAAK,CAAC,IAAM,KAAK;IAAA,CAAC,AAAC,CAAC,AAAC;IAEjG,IAAIJ,KAAK,EAAE;QACTnB,KAAK,CAAC,gCAAgC,EAAEY,YAAY,CAAC,CAAC;QACtD,sCAAsC;QACtC,OAAOY,CAAAA,GAAAA,aAAgB,AAKrB,CAAA,iBALqB,CAACtB,WAAW,EAAE;YACnCE,cAAc;YACdD,QAAQ,EAAES,YAAY;YACtBL,uBAAuB;YACvBkB,UAAU,EAAEjB,GAAG,CAACiB,UAAU;SAC3B,CAAC,CAAC;KACJ;IACD,2EAA2E;IAC3E1B,GAAG,CAACgB,IAAI,CAACC,MAAK,QAAA,CAACU,GAAG,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;CACvD"}
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.installAsync = installAsync;
|
|
6
6
|
exports.installPackagesAsync = installPackagesAsync;
|
|
7
|
+
exports.fixPackagesAsync = fixPackagesAsync;
|
|
7
8
|
var _config = require("@expo/config");
|
|
8
9
|
var PackageManager = _interopRequireWildcard(require("@expo/package-manager"));
|
|
9
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
11
|
var Log = _interopRequireWildcard(require("../log"));
|
|
11
12
|
var _getVersionedPackages = require("../start/doctor/dependencies/getVersionedPackages");
|
|
13
|
+
var _array = require("../utils/array");
|
|
12
14
|
var _findUp = require("../utils/findUp");
|
|
13
15
|
var _checkPackages = require("./checkPackages");
|
|
14
16
|
function _interopRequireDefault(obj) {
|
|
@@ -47,8 +49,8 @@ async function installAsync(packages, options, packageManagerArguments = []) {
|
|
|
47
49
|
npm: options.npm,
|
|
48
50
|
yarn: options.yarn,
|
|
49
51
|
pnpm: options.pnpm,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
silent: options.silent,
|
|
53
|
+
log: Log.log
|
|
52
54
|
});
|
|
53
55
|
if (options.check || options.fix) {
|
|
54
56
|
return await (0, _checkPackages).checkPackagesAsync(projectRoot, {
|
|
@@ -79,9 +81,41 @@ async function installPackagesAsync(projectRoot, { packages , packageManager , s
|
|
|
79
81
|
sdkVersion
|
|
80
82
|
});
|
|
81
83
|
Log.log(_chalk.default`\u203A Installing ${versioning.messages.length ? versioning.messages.join(" and ") + " " : ""}using {bold ${packageManager.name}}`);
|
|
82
|
-
await packageManager.
|
|
84
|
+
await packageManager.addAsync([
|
|
85
|
+
...packageManagerArguments,
|
|
86
|
+
...versioning.packages
|
|
87
|
+
]);
|
|
83
88
|
await applyPluginsAsync(projectRoot, versioning.packages);
|
|
84
89
|
}
|
|
90
|
+
async function fixPackagesAsync(projectRoot, { packages , packageManager , sdkVersion , packageManagerArguments }) {
|
|
91
|
+
if (!packages.length) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const { dependencies =[] , devDependencies =[] } = (0, _array).groupBy(packages, (dep)=>dep.packageType
|
|
95
|
+
);
|
|
96
|
+
const versioningMessages = (0, _getVersionedPackages).getOperationLog({
|
|
97
|
+
othersCount: 0,
|
|
98
|
+
nativeModulesCount: packages.length,
|
|
99
|
+
sdkVersion
|
|
100
|
+
});
|
|
101
|
+
Log.log(_chalk.default`\u203A Installing ${versioningMessages.length ? versioningMessages.join(" and ") + " " : ""}using {bold ${packageManager.name}}`);
|
|
102
|
+
if (dependencies.length) {
|
|
103
|
+
const versionedPackages = dependencies.map((dep)=>`${dep.packageName}@${dep.expectedVersionOrRange}`
|
|
104
|
+
);
|
|
105
|
+
await packageManager.addAsync([
|
|
106
|
+
...packageManagerArguments,
|
|
107
|
+
...versionedPackages
|
|
108
|
+
]);
|
|
109
|
+
await applyPluginsAsync(projectRoot, versionedPackages);
|
|
110
|
+
}
|
|
111
|
+
if (devDependencies.length) {
|
|
112
|
+
await packageManager.addDevAsync([
|
|
113
|
+
...packageManagerArguments,
|
|
114
|
+
...devDependencies.map((dep)=>`${dep.packageName}@${dep.expectedVersionOrRange}`
|
|
115
|
+
),
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
85
119
|
/**
|
|
86
120
|
* A convenience feature for automatically applying Expo Config Plugins to the `app.json` after installing them.
|
|
87
121
|
* This should be dropped in favor of autolinking in the future.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/install/installAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { getVersionedPackagesAsync } from '../start/doctor/dependencies/getVersionedPackages';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { checkPackagesAsync } from './checkPackages';\nimport { Options } from './resolveOptions';\n\nexport async function installAsync(\n packages: string[],\n options: Options & { projectRoot?: string },\n packageManagerArguments: string[] = []\n) {\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo install` from a subdirectory of the project.\n const projectRoot = options.projectRoot ?? findUpProjectRootOrAssert(process.cwd());\n\n // Resolve the package manager used by the project, or based on the provided arguments.\n const packageManager = PackageManager.createForProject(projectRoot, {\n npm: options.npm,\n yarn: options.yarn,\n pnpm: options.pnpm,\n log: Log.log,\n silent: options.silent,\n });\n\n if (options.check || options.fix) {\n return await checkPackagesAsync(projectRoot, {\n packages,\n options,\n packageManager,\n packageManagerArguments,\n });\n }\n\n // Read the project Expo config without plugins.\n const { exp } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n // Resolve the versioned packages, then install them.\n return installPackagesAsync(projectRoot, {\n packageManager,\n packages,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n}\n\n/** Version packages and install in a project. */\nexport async function installPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n sdkVersion,\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager:\n | PackageManager.NpmPackageManager\n | PackageManager.YarnPackageManager\n | PackageManager.PnpmPackageManager;\n /**\n * SDK to version `packages` for.\n * @example '44.0.0'\n */\n sdkVersion: string;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n): Promise<void> {\n const versioning = await getVersionedPackagesAsync(projectRoot, {\n packages,\n // sdkVersion is always defined because we don't skipSDKVersionRequirement in getConfig.\n sdkVersion,\n });\n\n Log.log(\n chalk`\\u203A Installing ${\n versioning.messages.length ? versioning.messages.join(' and ') + ' ' : ''\n }using {bold ${packageManager.name}}`\n );\n\n await packageManager.addWithParametersAsync(versioning.packages, packageManagerArguments);\n\n await applyPluginsAsync(projectRoot, versioning.packages);\n}\n\n/**\n * A convenience feature for automatically applying Expo Config Plugins to the `app.json` after installing them.\n * This should be dropped in favor of autolinking in the future.\n */\nasync function applyPluginsAsync(projectRoot: string, packages: string[]) {\n const { autoAddConfigPluginsAsync } = await import('./utils/autoAddConfigPlugins');\n\n try {\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n\n // Only auto add plugins if the plugins array is defined or if the project is using SDK +42.\n await autoAddConfigPluginsAsync(\n projectRoot,\n exp,\n // Split any possible NPM tags. i.e. `expo@latest` -> `expo`\n packages.map((pkg) => pkg.split('@')[0]).filter(Boolean)\n );\n } catch (error: any) {\n // If we fail to apply plugins, the log a warning and continue.\n if (error.isPluginError) {\n Log.warn(`Skipping config plugin check: ` + error.message);\n return;\n }\n // Any other error, rethrow.\n throw error;\n }\n}\n"],"names":["installAsync","installPackagesAsync","PackageManager","Log","packages","options","packageManagerArguments","projectRoot","findUpProjectRootOrAssert","process","cwd","packageManager","createForProject","npm","yarn","pnpm","log","silent","check","fix","checkPackagesAsync","exp","getConfig","skipPlugins","sdkVersion","versioning","getVersionedPackagesAsync","chalk","messages","length","join","name","addWithParametersAsync","applyPluginsAsync","autoAddConfigPluginsAsync","skipSDKVersionRequirement","map","pkg","split","filter","Boolean","error","isPluginError","warn","message"],"mappings":"AAAA;;;;QAUsBA,YAAY,GAAZA,YAAY;QA4CZC,oBAAoB,GAApBA,oBAAoB;AAtDhB,IAAA,OAAc,WAAd,cAAc,CAAA;AAC5BC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AACR,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,qBAAmD,WAAnD,mDAAmD,CAAA;AACnD,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACxB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG7C,eAAeH,YAAY,CAChCI,QAAkB,EAClBC,OAA2C,EAC3CC,uBAAiC,GAAG,EAAE,EACtC;QAGoBD,YAAmB;IAFvC,0EAA0E;IAC1E,mFAAmF;IACnF,MAAME,WAAW,GAAGF,CAAAA,YAAmB,GAAnBA,OAAO,CAACE,WAAW,YAAnBF,YAAmB,GAAIG,CAAAA,GAAAA,OAAyB,AAAe,CAAA,0BAAf,CAACC,OAAO,CAACC,GAAG,EAAE,CAAC,AAAC;IAEpF,uF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,MAAM,GAAGJ,UAAU,CAACG,QAAQ,CAACE,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,EAAE,CAC1E,YAAY,EAAEnB,cAAc,CAACoB,IAAI,CAAC,CAAC,CAAC,CACtC,CAAC;IAEF,MAAMpB,cAAc,CAACqB,sBAAsB,CAACP,UAAU,CAACrB,QAAQ,EAAEE,uBAAuB,CAAC,CAAC;IAE1F,MAAM2B,iBAAiB,CAAC1B,WAAW,EAAEkB,UAAU,CAACrB,QAAQ,CAAC,CAAC;CAC3D;AAED;;;GAGG,CACH,eAAe6B,iBAAiB,CAAC1B,WAAmB,EAAEH,QAAkB,EAAE;IACxE,MAAM,EAAE8B,yBAAyB,CAAA,EAAE,GAAG,MAAM;+CAAO,8BAA8B;MAAC,AAAC;IAEnF,IAAI;QACF,MAAM,EAAEb,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAAkD,CAAA,UAAlD,CAACf,WAAW,EAAE;YAAE4B,yBAAyB,EAAE,IAAI;SAAE,CAAC,AAAC;QAE5E,4FAA4F;QAC5F,MAAMD,yBAAyB,CAC7B3B,WAAW,EACXc,GAAG,EACH,4DAA4D;QAC5DjB,QAAQ,CAACgC,GAAG,CAAC,CAACC,GAAG,GAAKA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAAA,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CACzD,CAAC;KACH,CAAC,OAAOC,KAAK,EAAO;QACnB,+DAA+D;QAC/D,IAAIA,KAAK,CAACC,aAAa,EAAE;YACvBvC,GAAG,CAACwC,IAAI,CAAC,CAAC,8BAA8B,CAAC,GAAGF,KAAK,CAACG,OAAO,CAAC,CAAC;YAC3D,OAAO;SACR;QACD,4BAA4B;QAC5B,MAAMH,KAAK,CAAC;KACb;CACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/install/installAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport {\n getOperationLog,\n getVersionedPackagesAsync,\n} from '../start/doctor/dependencies/getVersionedPackages';\nimport { getVersionedDependenciesAsync } from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { groupBy } from '../utils/array';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { checkPackagesAsync } from './checkPackages';\nimport { Options } from './resolveOptions';\n\nexport async function installAsync(\n packages: string[],\n options: Options & { projectRoot?: string },\n packageManagerArguments: string[] = []\n) {\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo install` from a subdirectory of the project.\n const projectRoot = options.projectRoot ?? findUpProjectRootOrAssert(process.cwd());\n\n // Resolve the package manager used by the project, or based on the provided arguments.\n const packageManager = PackageManager.createForProject(projectRoot, {\n npm: options.npm,\n yarn: options.yarn,\n pnpm: options.pnpm,\n silent: options.silent,\n log: Log.log,\n });\n\n if (options.check || options.fix) {\n return await checkPackagesAsync(projectRoot, {\n packages,\n options,\n packageManager,\n packageManagerArguments,\n });\n }\n\n // Read the project Expo config without plugins.\n const { exp } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n // Resolve the versioned packages, then install them.\n return installPackagesAsync(projectRoot, {\n packageManager,\n packages,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n}\n\n/** Version packages and install in a project. */\nexport async function installPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n sdkVersion,\n packageManagerArguments,\n }: {\n /**\n * List of packages to version, grouped by the type of dependency.\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager: PackageManager.NodePackageManager;\n /**\n * SDK to version `packages` for.\n * @example '44.0.0'\n */\n sdkVersion: string;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n): Promise<void> {\n const versioning = await getVersionedPackagesAsync(projectRoot, {\n packages,\n // sdkVersion is always defined because we don't skipSDKVersionRequirement in getConfig.\n sdkVersion,\n });\n\n Log.log(\n chalk`\\u203A Installing ${\n versioning.messages.length ? versioning.messages.join(' and ') + ' ' : ''\n }using {bold ${packageManager.name}}`\n );\n\n await packageManager.addAsync([...packageManagerArguments, ...versioning.packages]);\n\n await applyPluginsAsync(projectRoot, versioning.packages);\n}\n\nexport async function fixPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n sdkVersion,\n packageManagerArguments,\n }: {\n packages: Awaited<ReturnType<typeof getVersionedDependenciesAsync>>;\n /** Package manager to use when installing the versioned packages. */\n packageManager: PackageManager.NodePackageManager;\n /**\n * SDK to version `packages` for.\n * @example '44.0.0'\n */\n sdkVersion: string;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n): Promise<void> {\n if (!packages.length) {\n return;\n }\n\n const { dependencies = [], devDependencies = [] } = groupBy(packages, (dep) => dep.packageType);\n const versioningMessages = getOperationLog({\n othersCount: 0, // All fixable packages are versioned\n nativeModulesCount: packages.length,\n sdkVersion,\n });\n\n Log.log(\n chalk`\\u203A Installing ${\n versioningMessages.length ? versioningMessages.join(' and ') + ' ' : ''\n }using {bold ${packageManager.name}}`\n );\n\n if (dependencies.length) {\n const versionedPackages = dependencies.map(\n (dep) => `${dep.packageName}@${dep.expectedVersionOrRange}`\n );\n\n await packageManager.addAsync([...packageManagerArguments, ...versionedPackages]);\n\n await applyPluginsAsync(projectRoot, versionedPackages);\n }\n\n if (devDependencies.length) {\n await packageManager.addDevAsync([\n ...packageManagerArguments,\n ...devDependencies.map((dep) => `${dep.packageName}@${dep.expectedVersionOrRange}`),\n ]);\n }\n}\n\n/**\n * A convenience feature for automatically applying Expo Config Plugins to the `app.json` after installing them.\n * This should be dropped in favor of autolinking in the future.\n */\nasync function applyPluginsAsync(projectRoot: string, packages: string[]) {\n const { autoAddConfigPluginsAsync } = await import('./utils/autoAddConfigPlugins');\n\n try {\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n\n // Only auto add plugins if the plugins array is defined or if the project is using SDK +42.\n await autoAddConfigPluginsAsync(\n projectRoot,\n exp,\n // Split any possible NPM tags. i.e. `expo@latest` -> `expo`\n packages.map((pkg) => pkg.split('@')[0]).filter(Boolean)\n );\n } catch (error: any) {\n // If we fail to apply plugins, the log a warning and continue.\n if (error.isPluginError) {\n Log.warn(`Skipping config plugin check: ` + error.message);\n return;\n }\n // Any other error, rethrow.\n throw error;\n }\n}\n"],"names":["installAsync","installPackagesAsync","fixPackagesAsync","PackageManager","Log","packages","options","packageManagerArguments","projectRoot","findUpProjectRootOrAssert","process","cwd","packageManager","createForProject","npm","yarn","pnpm","silent","log","check","fix","checkPackagesAsync","exp","getConfig","skipPlugins","sdkVersion","versioning","getVersionedPackagesAsync","chalk","messages","length","join","name","addAsync","applyPluginsAsync","dependencies","devDependencies","groupBy","dep","packageType","versioningMessages","getOperationLog","othersCount","nativeModulesCount","versionedPackages","map","packageName","expectedVersionOrRange","addDevAsync","autoAddConfigPluginsAsync","skipSDKVersionRequirement","pkg","split","filter","Boolean","error","isPluginError","warn","message"],"mappings":"AAAA;;;;QAesBA,YAAY,GAAZA,YAAY;QA4CZC,oBAAoB,GAApBA,oBAAoB;QA4CpBC,gBAAgB,GAAhBA,gBAAgB;AAvGZ,IAAA,OAAc,WAAd,cAAc,CAAA;AAC5BC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AACR,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAIR,IAAA,qBAAmD,WAAnD,mDAAmD,CAAA;AAElC,IAAA,MAAgB,WAAhB,gBAAgB,CAAA;AACE,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACxB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;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AAMD,yBAAyB,CAC7BzC,WAAW,EACXc,GAAG,EACH,4DAA4D;QAC5DjB,QAAQ,CAACwC,GAAG,CAAC,CAACM,GAAG,GAAKA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAAA,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CACzD,CAAC;KACH,CAAC,OAAOC,KAAK,EAAO;QACnB,+DAA+D;QAC/D,IAAIA,KAAK,CAACC,aAAa,EAAE;YACvBpD,GAAG,CAACqD,IAAI,CAAC,CAAC,8BAA8B,CAAC,GAAGF,KAAK,CAACG,OAAO,CAAC,CAAC;YAC3D,OAAO;SACR;QACD,4BAA4B;QAC5B,MAAMH,KAAK,CAAC;KACb;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/install/resolveOptions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/install/resolveOptions.ts"],"sourcesContent":["import { NodePackageManagerForProject } from '@expo/package-manager';\n\nimport { CommandError } from '../utils/errors';\nimport { assertUnexpectedVariadicFlags, parseVariadicArguments } from '../utils/variadic';\n\nexport type Options = Pick<NodePackageManagerForProject, 'npm' | 'pnpm' | 'yarn'> & {\n /** Check which packages need to be updated, does not install any provided packages. */\n check?: boolean;\n /** Should the dependencies be fixed automatically. */\n fix?: boolean;\n /** Should disable install output, used for commands like `prebuild` that run install internally. */\n silent?: boolean;\n};\n\nfunction resolveOptions(options: Options): Options {\n if (options.fix && options.check) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --check, --fix');\n }\n if ([options.npm, options.pnpm, options.yarn].filter(Boolean).length > 1) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --npm, --pnpm, --yarn');\n }\n return {\n ...options,\n };\n}\n\nexport async function resolveArgsAsync(\n argv: string[]\n): Promise<{ variadic: string[]; options: Options; extras: string[] }> {\n const { variadic, extras, flags } = parseVariadicArguments(argv);\n\n assertUnexpectedVariadicFlags(\n ['--check', '--fix', '--npm', '--pnpm', '--yarn'],\n { variadic, extras, flags },\n 'npx expo install'\n );\n\n return {\n // Variadic arguments like `npx expo install react react-dom` -> ['react', 'react-dom']\n variadic,\n options: resolveOptions({\n fix: !!flags['--fix'],\n check: !!flags['--check'],\n yarn: !!flags['--yarn'],\n npm: !!flags['--npm'],\n pnpm: !!flags['--pnpm'],\n }),\n extras,\n };\n}\n"],"names":["resolveArgsAsync","resolveOptions","options","fix","check","CommandError","npm","pnpm","yarn","filter","Boolean","length","argv","variadic","extras","flags","parseVariadicArguments","assertUnexpectedVariadicFlags"],"mappings":"AAAA;;;;QA0BsBA,gBAAgB,GAAhBA,gBAAgB;AAxBT,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACwB,IAAA,SAAmB,WAAnB,mBAAmB,CAAA;AAWzF,SAASC,cAAc,CAACC,OAAgB,EAAW;IACjD,IAAIA,OAAO,CAACC,GAAG,IAAID,OAAO,CAACE,KAAK,EAAE;QAChC,MAAM,IAAIC,OAAY,aAAA,CAAC,UAAU,EAAE,wCAAwC,CAAC,CAAC;KAC9E;IACD,IAAI;QAACH,OAAO,CAACI,GAAG;QAAEJ,OAAO,CAACK,IAAI;QAAEL,OAAO,CAACM,IAAI;KAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;QACxE,MAAM,IAAIN,OAAY,aAAA,CAAC,UAAU,EAAE,+CAA+C,CAAC,CAAC;KACrF;IACD,OAAO;QACL,GAAGH,OAAO;KACX,CAAC;CACH;AAEM,eAAeF,gBAAgB,CACpCY,IAAc,EACuD;IACrE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGC,CAAAA,GAAAA,SAAsB,AAAM,CAAA,uBAAN,CAACJ,IAAI,CAAC,AAAC;IAEjEK,CAAAA,GAAAA,SAA6B,AAI5B,CAAA,8BAJ4B,CAC3B;QAAC,SAAS;QAAE,OAAO;QAAE,OAAO;QAAE,QAAQ;QAAE,QAAQ;KAAC,EACjD;QAAEJ,QAAQ;QAAEC,MAAM;QAAEC,KAAK;KAAE,EAC3B,kBAAkB,CACnB,CAAC;IAEF,OAAO;QACL,uFAAuF;QACvFF,QAAQ;QACRX,OAAO,EAAED,cAAc,CAAC;YACtBE,GAAG,EAAE,CAAC,CAACY,KAAK,CAAC,OAAO,CAAC;YACrBX,KAAK,EAAE,CAAC,CAACW,KAAK,CAAC,SAAS,CAAC;YACzBP,IAAI,EAAE,CAAC,CAACO,KAAK,CAAC,QAAQ,CAAC;YACvBT,GAAG,EAAE,CAAC,CAACS,KAAK,CAAC,OAAO,CAAC;YACrBR,IAAI,EAAE,CAAC,CAACQ,KAAK,CAAC,QAAQ,CAAC;SACxB,CAAC;QACFD,MAAM;KACP,CAAC;CACH"}
|
|
@@ -93,7 +93,11 @@ class ClientManager {
|
|
|
93
93
|
const tlsOptions = {
|
|
94
94
|
rejectUnauthorized: false,
|
|
95
95
|
secureContext: tls.createSecureContext({
|
|
96
|
-
secureProtocol
|
|
96
|
+
// Avoid using `secureProtocol` fixing the socket to a single TLS version.
|
|
97
|
+
// Newer Node versions might not support older TLS versions.
|
|
98
|
+
// By using the default `minVersion` and `maxVersion` options,
|
|
99
|
+
// The socket will automatically use the appropriate TLS version.
|
|
100
|
+
// See: https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
|
|
97
101
|
cert: this.pairRecord.RootCertificate,
|
|
98
102
|
key: this.pairRecord.RootPrivateKey
|
|
99
103
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/run/ios/appleDevice/ClientManager.ts"],"sourcesContent":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\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 { Socket } from 'net';\nimport { Duplex } from 'stream';\nimport * as tls from 'tls';\n\nimport { CommandError } from '../../../utils/errors';\nimport { AFCClient } from './client/AFCClient';\nimport { DebugserverClient } from './client/DebugserverClient';\nimport { InstallationProxyClient } from './client/InstallationProxyClient';\nimport { LockdowndClient } from './client/LockdowndClient';\nimport { MobileImageMounterClient } from './client/MobileImageMounterClient';\nimport { ServiceClient } from './client/ServiceClient';\nimport { UsbmuxdClient, UsbmuxdDevice, UsbmuxdPairRecord } from './client/UsbmuxdClient';\n\nexport class ClientManager {\n private connections: Socket[];\n constructor(\n public pairRecord: UsbmuxdPairRecord,\n public device: UsbmuxdDevice,\n private lockdowndClient: LockdowndClient\n ) {\n this.connections = [lockdowndClient.socket];\n }\n\n static async create(udid?: string) {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n const device = await usbmuxClient.getDevice(udid);\n const pairRecord = await usbmuxClient.readPairRecord(device.Properties.SerialNumber);\n const lockdownSocket = await usbmuxClient.connect(device, 62078);\n const lockdownClient = new LockdowndClient(lockdownSocket);\n await lockdownClient.doHandshake(pairRecord);\n return new ClientManager(pairRecord, device, lockdownClient);\n }\n\n async getUsbmuxdClient() {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n this.connections.push(usbmuxClient.socket);\n return usbmuxClient;\n }\n\n async getLockdowndClient() {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n const lockdownSocket = await usbmuxClient.connect(this.device, 62078);\n const lockdownClient = new LockdowndClient(lockdownSocket);\n this.connections.push(lockdownClient.socket);\n return lockdownClient;\n }\n\n async getLockdowndClientWithHandshake() {\n const lockdownClient = await this.getLockdowndClient();\n await lockdownClient.doHandshake(this.pairRecord);\n return lockdownClient;\n }\n\n async getAFCClient() {\n return this.getServiceClient('com.apple.afc', AFCClient);\n }\n\n async getInstallationProxyClient() {\n return this.getServiceClient('com.apple.mobile.installation_proxy', InstallationProxyClient);\n }\n\n async getMobileImageMounterClient() {\n return this.getServiceClient('com.apple.mobile.mobile_image_mounter', MobileImageMounterClient);\n }\n\n async getDebugserverClient() {\n try {\n // iOS 14 added support for a secure debug service so try to connect to that first\n return await this.getServiceClient(\n 'com.apple.debugserver.DVTSecureSocketProxy',\n DebugserverClient\n );\n } catch {\n // otherwise, fall back to the previous implementation\n return this.getServiceClient('com.apple.debugserver', DebugserverClient, true);\n }\n }\n\n private async getServiceClient<T extends ServiceClient<any>>(\n name: string,\n ServiceType: new (...args: any[]) => T,\n disableSSL = false\n ) {\n const { port: servicePort, enableServiceSSL } = await this.lockdowndClient.startService(name);\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n let usbmuxdSocket = await usbmuxClient.connect(this.device, servicePort);\n\n if (enableServiceSSL) {\n const tlsOptions: tls.ConnectionOptions = {\n rejectUnauthorized: false,\n secureContext: tls.createSecureContext({\n secureProtocol: 'TLSv1_method',\n cert: this.pairRecord.RootCertificate,\n key: this.pairRecord.RootPrivateKey,\n }),\n };\n\n // Some services seem to not support TLS/SSL after the initial handshake\n // More info: https://github.com/libimobiledevice/libimobiledevice/issues/793\n if (disableSSL) {\n // According to https://nodejs.org/api/tls.html#tls_tls_connect_options_callback we can\n // pass any Duplex in to tls.connect instead of a Socket. So we'll use our proxy to keep\n // the TLS wrapper and underlying usbmuxd socket separate.\n const proxy: any = new UsbmuxdProxy(usbmuxdSocket);\n tlsOptions.socket = proxy;\n\n await new Promise<void>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(\n new CommandError('APPLE_DEVICE', 'The TLS handshake failed to complete after 5s.')\n );\n }, 5000);\n tls.connect(tlsOptions, function (this: tls.TLSSocket) {\n clearTimeout(timeoutId);\n // After the handshake, we don't need TLS or the proxy anymore,\n // since we'll just pass in the naked usbmuxd socket to the service client\n this.destroy();\n resolve();\n });\n });\n } else {\n tlsOptions.socket = usbmuxdSocket;\n usbmuxdSocket = tls.connect(tlsOptions);\n }\n }\n const client = new ServiceType(usbmuxdSocket);\n this.connections.push(client.socket);\n return client;\n }\n\n end() {\n for (const socket of this.connections) {\n // may already be closed\n try {\n socket.end();\n } catch {}\n }\n }\n}\n\nclass UsbmuxdProxy extends Duplex {\n constructor(private usbmuxdSock: Socket) {\n super();\n\n this.usbmuxdSock.on('data', (data) => {\n this.push(data);\n });\n }\n\n _write(chunk: any, encoding: string, callback: (err?: Error) => void) {\n this.usbmuxdSock.write(chunk);\n callback();\n }\n\n _read(size: number) {\n // Stub so we don't error, since we push everything we get from usbmuxd as it comes in.\n // TODO: better way to do this?\n }\n\n _destroy() {\n this.usbmuxdSock.removeAllListeners();\n }\n}\n"],"names":["tls","ClientManager","constructor","pairRecord","device","lockdowndClient","connections","socket","create","udid","usbmuxClient","UsbmuxdClient","connectUsbmuxdSocket","getDevice","readPairRecord","Properties","SerialNumber","lockdownSocket","connect","lockdownClient","LockdowndClient","doHandshake","getUsbmuxdClient","push","getLockdowndClient","getLockdowndClientWithHandshake","getAFCClient","getServiceClient","AFCClient","getInstallationProxyClient","InstallationProxyClient","getMobileImageMounterClient","MobileImageMounterClient","getDebugserverClient","DebugserverClient","name","ServiceType","disableSSL","port","servicePort","enableServiceSSL","startService","usbmuxdSocket","tlsOptions","rejectUnauthorized","secureContext","createSecureContext","secureProtocol","cert","RootCertificate","key","RootPrivateKey","proxy","UsbmuxdProxy","Promise","resolve","reject","timeoutId","setTimeout","CommandError","clearTimeout","destroy","client","end","Duplex","usbmuxdSock","on","data","_write","chunk","encoding","callback","write","_read","size","_destroy","removeAllListeners"],"mappings":"AAOA;;;;AACuB,IAAA,OAAQ,WAAR,QAAQ,CAAA;AACnBA,IAAAA,GAAG,mCAAM,KAAK,EAAX;AAEc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,UAAoB,WAApB,oBAAoB,CAAA;AACZ,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AACtB,IAAA,wBAAkC,WAAlC,kCAAkC,CAAA;AAC1C,IAAA,gBAA0B,WAA1B,0BAA0B,CAAA;AACjB,IAAA,yBAAm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Content":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\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 { Socket } from 'net';\nimport { Duplex } from 'stream';\nimport * as tls from 'tls';\n\nimport { CommandError } from '../../../utils/errors';\nimport { AFCClient } from './client/AFCClient';\nimport { DebugserverClient } from './client/DebugserverClient';\nimport { InstallationProxyClient } from './client/InstallationProxyClient';\nimport { LockdowndClient } from './client/LockdowndClient';\nimport { MobileImageMounterClient } from './client/MobileImageMounterClient';\nimport { ServiceClient } from './client/ServiceClient';\nimport { UsbmuxdClient, UsbmuxdDevice, UsbmuxdPairRecord } from './client/UsbmuxdClient';\n\nexport class ClientManager {\n private connections: Socket[];\n constructor(\n public pairRecord: UsbmuxdPairRecord,\n public device: UsbmuxdDevice,\n private lockdowndClient: LockdowndClient\n ) {\n this.connections = [lockdowndClient.socket];\n }\n\n static async create(udid?: string) {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n const device = await usbmuxClient.getDevice(udid);\n const pairRecord = await usbmuxClient.readPairRecord(device.Properties.SerialNumber);\n const lockdownSocket = await usbmuxClient.connect(device, 62078);\n const lockdownClient = new LockdowndClient(lockdownSocket);\n await lockdownClient.doHandshake(pairRecord);\n return new ClientManager(pairRecord, device, lockdownClient);\n }\n\n async getUsbmuxdClient() {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n this.connections.push(usbmuxClient.socket);\n return usbmuxClient;\n }\n\n async getLockdowndClient() {\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n const lockdownSocket = await usbmuxClient.connect(this.device, 62078);\n const lockdownClient = new LockdowndClient(lockdownSocket);\n this.connections.push(lockdownClient.socket);\n return lockdownClient;\n }\n\n async getLockdowndClientWithHandshake() {\n const lockdownClient = await this.getLockdowndClient();\n await lockdownClient.doHandshake(this.pairRecord);\n return lockdownClient;\n }\n\n async getAFCClient() {\n return this.getServiceClient('com.apple.afc', AFCClient);\n }\n\n async getInstallationProxyClient() {\n return this.getServiceClient('com.apple.mobile.installation_proxy', InstallationProxyClient);\n }\n\n async getMobileImageMounterClient() {\n return this.getServiceClient('com.apple.mobile.mobile_image_mounter', MobileImageMounterClient);\n }\n\n async getDebugserverClient() {\n try {\n // iOS 14 added support for a secure debug service so try to connect to that first\n return await this.getServiceClient(\n 'com.apple.debugserver.DVTSecureSocketProxy',\n DebugserverClient\n );\n } catch {\n // otherwise, fall back to the previous implementation\n return this.getServiceClient('com.apple.debugserver', DebugserverClient, true);\n }\n }\n\n private async getServiceClient<T extends ServiceClient<any>>(\n name: string,\n ServiceType: new (...args: any[]) => T,\n disableSSL = false\n ) {\n const { port: servicePort, enableServiceSSL } = await this.lockdowndClient.startService(name);\n const usbmuxClient = new UsbmuxdClient(UsbmuxdClient.connectUsbmuxdSocket());\n let usbmuxdSocket = await usbmuxClient.connect(this.device, servicePort);\n\n if (enableServiceSSL) {\n const tlsOptions: tls.ConnectionOptions = {\n rejectUnauthorized: false,\n secureContext: tls.createSecureContext({\n // Avoid using `secureProtocol` fixing the socket to a single TLS version.\n // Newer Node versions might not support older TLS versions.\n // By using the default `minVersion` and `maxVersion` options,\n // The socket will automatically use the appropriate TLS version.\n // See: https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions\n cert: this.pairRecord.RootCertificate,\n key: this.pairRecord.RootPrivateKey,\n }),\n };\n\n // Some services seem to not support TLS/SSL after the initial handshake\n // More info: https://github.com/libimobiledevice/libimobiledevice/issues/793\n if (disableSSL) {\n // According to https://nodejs.org/api/tls.html#tls_tls_connect_options_callback we can\n // pass any Duplex in to tls.connect instead of a Socket. So we'll use our proxy to keep\n // the TLS wrapper and underlying usbmuxd socket separate.\n const proxy: any = new UsbmuxdProxy(usbmuxdSocket);\n tlsOptions.socket = proxy;\n\n await new Promise<void>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(\n new CommandError('APPLE_DEVICE', 'The TLS handshake failed to complete after 5s.')\n );\n }, 5000);\n tls.connect(tlsOptions, function (this: tls.TLSSocket) {\n clearTimeout(timeoutId);\n // After the handshake, we don't need TLS or the proxy anymore,\n // since we'll just pass in the naked usbmuxd socket to the service client\n this.destroy();\n resolve();\n });\n });\n } else {\n tlsOptions.socket = usbmuxdSocket;\n usbmuxdSocket = tls.connect(tlsOptions);\n }\n }\n const client = new ServiceType(usbmuxdSocket);\n this.connections.push(client.socket);\n return client;\n }\n\n end() {\n for (const socket of this.connections) {\n // may already be closed\n try {\n socket.end();\n } catch {}\n }\n }\n}\n\nclass UsbmuxdProxy extends Duplex {\n constructor(private usbmuxdSock: Socket) {\n super();\n\n this.usbmuxdSock.on('data', (data) => {\n this.push(data);\n });\n }\n\n _write(chunk: any, encoding: string, callback: (err?: Error) => void) {\n this.usbmuxdSock.write(chunk);\n callback();\n }\n\n _read(size: number) {\n // Stub so we don't error, since we push everything we get from usbmuxd as it comes in.\n // TODO: better way to do this?\n }\n\n _destroy() {\n this.usbmuxdSock.removeAllListeners();\n }\n}\n"],"names":["tls","ClientManager","constructor","pairRecord","device","lockdowndClient","connections","socket","create","udid","usbmuxClient","UsbmuxdClient","connectUsbmuxdSocket","getDevice","readPairRecord","Properties","SerialNumber","lockdownSocket","connect","lockdownClient","LockdowndClient","doHandshake","getUsbmuxdClient","push","getLockdowndClient","getLockdowndClientWithHandshake","getAFCClient","getServiceClient","AFCClient","getInstallationProxyClient","InstallationProxyClient","getMobileImageMounterClient","MobileImageMounterClient","getDebugserverClient","DebugserverClient","name","ServiceType","disableSSL","port","servicePort","enableServiceSSL","startService","usbmuxdSocket","tlsOptions","rejectUnauthorized","secureContext","createSecureContext","cert","RootCertificate","key","RootPrivateKey","proxy","UsbmuxdProxy","Promise","resolve","reject","timeoutId","setTimeout","CommandError","clearTimeout","destroy","client","end","Duplex","usbmuxdSock","on","data","_write","chunk","encoding","callback","write","_read","size","_destroy","removeAllListeners"],"mapp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KACJ;IAEDC,MAAM,CAACC,KAAU,EAAEC,QAAgB,EAAEC,QAA+B,EAAE;QACpE,IAAI,CAACN,WAAW,CAACO,KAAK,CAACH,KAAK,CAAC,CAAC;QAC9BE,QAAQ,EAAE,CAAC;KACZ;IAEDE,KAAK,CAACC,IAAY,EAAE;IAClB,uFAAuF;IACvF,+BAA+B;KAChC;IAEDC,QAAQ,GAAG;QACT,IAAI,CAACV,WAAW,CAACW,kBAAkB,EAAE,CAAC;KACvC;CACF"}
|
|
@@ -79,7 +79,11 @@ class LockdowndClient extends _serviceClient.ServiceClient {
|
|
|
79
79
|
if (resp.EnableSessionSSL) {
|
|
80
80
|
this.protocolClient.socket = new tls.TLSSocket(this.protocolClient.socket, {
|
|
81
81
|
secureContext: tls.createSecureContext({
|
|
82
|
-
secureProtocol
|
|
82
|
+
// Avoid using `secureProtocol` fixing the socket to a single TLS version.
|
|
83
|
+
// Newer Node versions might not support older TLS versions.
|
|
84
|
+
// By using the default `minVersion` and `maxVersion` options,
|
|
85
|
+
// The socket will automatically use the appropriate TLS version.
|
|
86
|
+
// See: https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
|
|
83
87
|
cert: pairRecord.RootCertificate,
|
|
84
88
|
key: pairRecord.RootPrivateKey
|
|
85
89
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/LockdowndClient.ts"],"sourcesContent":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\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 Debug from 'debug';\nimport { Socket } from 'net';\nimport * as tls from 'tls';\n\nimport { LockdownProtocolClient } from '../protocol/LockdownProtocol';\nimport { ResponseError, ServiceClient } from './ServiceClient';\nimport { UsbmuxdPairRecord } from './UsbmuxdClient';\n\nconst debug = Debug('expo:apple-device:client:lockdownd');\n\nexport interface DeviceValues {\n BasebandCertId: number;\n BasebandKeyHashInformation: {\n AKeyStatus: number;\n SKeyHash: Buffer;\n SKeyStatus: number;\n };\n BasebandSerialNumber: Buffer;\n BasebandVersion: string;\n BoardId: number;\n BuildVersion: string;\n ChipID: number;\n ConnectionType: 'USB' | 'Network';\n DeviceClass: string;\n DeviceColor: string;\n DeviceName: string;\n DieID: number;\n HardwareModel: string;\n HasSiDP: boolean;\n PartitionType: string;\n ProductName: string;\n ProductType: string;\n ProductVersion: string;\n ProductionSOC: boolean;\n ProtocolVersion: string;\n TelephonyCapability: boolean;\n UniqueChipID: number;\n UniqueDeviceID: string;\n WiFiAddress: string;\n [key: string]: any;\n}\n\ninterface LockdowndServiceResponse {\n Request: 'StartService';\n Service: string;\n Port: number;\n EnableServiceSSL?: boolean; // Only on iOS 13+\n}\n\ninterface LockdowndSessionResponse {\n Request: 'StartSession';\n EnableSessionSSL: boolean;\n}\n\ninterface LockdowndAllValuesResponse {\n Request: 'GetValue';\n Value: DeviceValues;\n}\n\ninterface LockdowndValueResponse {\n Request: 'GetValue';\n Key: string;\n Value: string;\n}\n\ninterface LockdowndQueryTypeResponse {\n Request: 'QueryType';\n Type: string;\n}\n\nfunction isLockdowndServiceResponse(resp: any): resp is LockdowndServiceResponse {\n return resp.Request === 'StartService' && resp.Service !== undefined && resp.Port !== undefined;\n}\n\nfunction isLockdowndSessionResponse(resp: any): resp is LockdowndSessionResponse {\n return resp.Request === 'StartSession';\n}\n\nfunction isLockdowndAllValuesResponse(resp: any): resp is LockdowndAllValuesResponse {\n return resp.Request === 'GetValue' && resp.Value !== undefined;\n}\n\nfunction isLockdowndValueResponse(resp: any): resp is LockdowndValueResponse {\n return resp.Request === 'GetValue' && resp.Key !== undefined && typeof resp.Value === 'string';\n}\n\nfunction isLockdowndQueryTypeResponse(resp: any): resp is LockdowndQueryTypeResponse {\n return resp.Request === 'QueryType' && resp.Type !== undefined;\n}\n\nexport class LockdowndClient extends ServiceClient<LockdownProtocolClient> {\n constructor(public socket: Socket) {\n super(socket, new LockdownProtocolClient(socket));\n }\n\n async startService(name: string) {\n debug(`startService: ${name}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'StartService',\n Service: name,\n });\n\n if (isLockdowndServiceResponse(resp)) {\n return { port: resp.Port, enableServiceSSL: !!resp.EnableServiceSSL };\n } else {\n throw new ResponseError(`Error starting service ${name}`, resp);\n }\n }\n\n async startSession(pairRecord: UsbmuxdPairRecord) {\n debug(`startSession: ${pairRecord}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'StartSession',\n HostID: pairRecord.HostID,\n SystemBUID: pairRecord.SystemBUID,\n });\n\n if (isLockdowndSessionResponse(resp)) {\n if (resp.EnableSessionSSL) {\n this.protocolClient.socket = new tls.TLSSocket(this.protocolClient.socket, {\n secureContext: tls.createSecureContext({\n secureProtocol: 'TLSv1_method',\n cert: pairRecord.RootCertificate,\n key: pairRecord.RootPrivateKey,\n }),\n });\n debug(`Socket upgraded to TLS connection`);\n }\n // TODO: save sessionID for StopSession?\n } else {\n throw new ResponseError('Error starting session', resp);\n }\n }\n\n async getAllValues() {\n debug(`getAllValues`);\n\n const resp = await this.protocolClient.sendMessage({ Request: 'GetValue' });\n\n if (isLockdowndAllValuesResponse(resp)) {\n return resp.Value;\n } else {\n throw new ResponseError('Error getting lockdown value', resp);\n }\n }\n\n async getValue(val: string) {\n debug(`getValue: ${val}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'GetValue',\n Key: val,\n });\n\n if (isLockdowndValueResponse(resp)) {\n return resp.Value;\n } else {\n throw new ResponseError('Error getting lockdown value', resp);\n }\n }\n\n async queryType() {\n debug('queryType');\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'QueryType',\n });\n\n if (isLockdowndQueryTypeResponse(resp)) {\n return resp.Type;\n } else {\n throw new ResponseError('Error getting lockdown query type', resp);\n }\n }\n\n async doHandshake(pairRecord: UsbmuxdPairRecord) {\n debug('doHandshake');\n\n // if (await this.lockdownQueryType() !== 'com.apple.mobile.lockdown') {\n // throw new CommandError('Invalid type received from lockdown handshake');\n // }\n // await this.getLockdownValue('ProductVersion');\n // TODO: validate pair and pair\n await this.startSession(pairRecord);\n }\n}\n"],"names":["tls","debug","Debug","isLockdowndServiceResponse","resp","Request","Service","undefined","Port","isLockdowndSessionResponse","isLockdowndAllValuesResponse","Value","isLockdowndValueResponse","Key","isLockdowndQueryTypeResponse","Type","LockdowndClient","ServiceClient","constructor","socket","LockdownProtocolClient","startService","name","protocolClient","sendMessage","port","enableServiceSSL","EnableServiceSSL","ResponseError","startSession","pairRecord","HostID","SystemBUID","EnableSessionSSL","TLSSocket","secureContext","createSecureContext","secureProtocol","cert","RootCertificate","key","RootPrivateKey","getAllValues","getValue","val","queryType","doHandshake"],"mappings":"AAOA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbA,IAAAA,GAAG,mCAAM,KAAK,EAAX;AAEwB,IAAA,iBAA8B,WAA9B,8BAA8B,CAAA;AACxB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9D,MAAMC,KAAK,GAAGC,CAAAA,GAAAA,MAAK,AAAsC,CAAA,QAAtC,CAAC,oCAAoC,CAAC,AAAC;AA8D1D,SAASC,0BAA0B,CAACC,IAAS,EAAoC;IAC/E,OAAOA,IAAI,CAACC,OAAO,KAAK,cAAc,IAAID,IAAI,CAACE,OAAO,KAAKC,SAAS,IAAIH,IAAI,CAACI,IAAI,KAAKD,SAAS,CAAC;CACjG;AAED,SAASE,0BAA0B,CAACL,IAAS,EAAoC;IAC/E,OAAOA,IAAI,CAACC,OAAO,KAAK,cAAc,CAAC;CACxC;AAED,SAASK,4BAA4B,CAACN,IAAS,EAAsC;IACnF,OAAOA,IAAI,CAACC,OAAO,KAAK,UAAU,IAAID,IAAI,CAACO,KAAK,KAAKJ,SAAS,CAAC;CAChE;AAED,SAASK,wBAAwB,CAACR,IAAS,EAAkC;IAC3E,OAAOA,IAAI,CAACC,OAAO,KAAK,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AACR,IAAI,CAAC,EAAE;YAClC,OAAOA,IAAI,CAACO,KAAK,CAAC;SACnB,MAAM;YACL,MAAM,IAAIiB,cAAa,cAAA,CAAC,8BAA8B,EAAExB,IAAI,CAAC,CAAC;SAC/D;KACF;IAED,MAAMyC,SAAS,GAAG;QAChB5C,KAAK,CAAC,WAAW,CAAC,CAAC;QAEnB,MAAMG,IAAI,GAAG,MAAM,IAAI,CAACmB,cAAc,CAACC,WAAW,CAAC;YACjDnB,OAAO,EAAE,WAAW;SACrB,CAAC,AAAC;QAEH,IAAIS,4BAA4B,CAACV,IAAI,CAAC,EAAE;YACtC,OAAOA,IAAI,CAACW,IAAI,CAAC;SAClB,MAAM;YACL,MAAM,IAAIa,cAAa,cAAA,CAAC,mCAAmC,EAAExB,IAAI,CAAC,CAAC;SACpE;KACF;IAED,MAAM0C,WAAW,CAAChB,UAA6B,EAAE;QAC/C7B,KAAK,CAAC,aAAa,CAAC,CAAC;QAErB,wEAAwE;QACxE,6EAA6E;QAC7E,IAAI;QACJ,iDAAiD;QACjD,+BAA+B;QAC/B,MAAM,IAAI,CAAC4B,YAAY,CAACC,UAAU,CAAC,CAAC;KACrC;CACF;QAjGYd,eAAe,GAAfA,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/run/ios/appleDevice/client/LockdowndClient.ts"],"sourcesContent":["/**\n * Copyright (c) 2021 Expo, Inc.\n * Copyright (c) 2018 Drifty Co.\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 Debug from 'debug';\nimport { Socket } from 'net';\nimport * as tls from 'tls';\n\nimport { LockdownProtocolClient } from '../protocol/LockdownProtocol';\nimport { ResponseError, ServiceClient } from './ServiceClient';\nimport { UsbmuxdPairRecord } from './UsbmuxdClient';\n\nconst debug = Debug('expo:apple-device:client:lockdownd');\n\nexport interface DeviceValues {\n BasebandCertId: number;\n BasebandKeyHashInformation: {\n AKeyStatus: number;\n SKeyHash: Buffer;\n SKeyStatus: number;\n };\n BasebandSerialNumber: Buffer;\n BasebandVersion: string;\n BoardId: number;\n BuildVersion: string;\n ChipID: number;\n ConnectionType: 'USB' | 'Network';\n DeviceClass: string;\n DeviceColor: string;\n DeviceName: string;\n DieID: number;\n HardwareModel: string;\n HasSiDP: boolean;\n PartitionType: string;\n ProductName: string;\n ProductType: string;\n ProductVersion: string;\n ProductionSOC: boolean;\n ProtocolVersion: string;\n TelephonyCapability: boolean;\n UniqueChipID: number;\n UniqueDeviceID: string;\n WiFiAddress: string;\n [key: string]: any;\n}\n\ninterface LockdowndServiceResponse {\n Request: 'StartService';\n Service: string;\n Port: number;\n EnableServiceSSL?: boolean; // Only on iOS 13+\n}\n\ninterface LockdowndSessionResponse {\n Request: 'StartSession';\n EnableSessionSSL: boolean;\n}\n\ninterface LockdowndAllValuesResponse {\n Request: 'GetValue';\n Value: DeviceValues;\n}\n\ninterface LockdowndValueResponse {\n Request: 'GetValue';\n Key: string;\n Value: string;\n}\n\ninterface LockdowndQueryTypeResponse {\n Request: 'QueryType';\n Type: string;\n}\n\nfunction isLockdowndServiceResponse(resp: any): resp is LockdowndServiceResponse {\n return resp.Request === 'StartService' && resp.Service !== undefined && resp.Port !== undefined;\n}\n\nfunction isLockdowndSessionResponse(resp: any): resp is LockdowndSessionResponse {\n return resp.Request === 'StartSession';\n}\n\nfunction isLockdowndAllValuesResponse(resp: any): resp is LockdowndAllValuesResponse {\n return resp.Request === 'GetValue' && resp.Value !== undefined;\n}\n\nfunction isLockdowndValueResponse(resp: any): resp is LockdowndValueResponse {\n return resp.Request === 'GetValue' && resp.Key !== undefined && typeof resp.Value === 'string';\n}\n\nfunction isLockdowndQueryTypeResponse(resp: any): resp is LockdowndQueryTypeResponse {\n return resp.Request === 'QueryType' && resp.Type !== undefined;\n}\n\nexport class LockdowndClient extends ServiceClient<LockdownProtocolClient> {\n constructor(public socket: Socket) {\n super(socket, new LockdownProtocolClient(socket));\n }\n\n async startService(name: string) {\n debug(`startService: ${name}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'StartService',\n Service: name,\n });\n\n if (isLockdowndServiceResponse(resp)) {\n return { port: resp.Port, enableServiceSSL: !!resp.EnableServiceSSL };\n } else {\n throw new ResponseError(`Error starting service ${name}`, resp);\n }\n }\n\n async startSession(pairRecord: UsbmuxdPairRecord) {\n debug(`startSession: ${pairRecord}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'StartSession',\n HostID: pairRecord.HostID,\n SystemBUID: pairRecord.SystemBUID,\n });\n\n if (isLockdowndSessionResponse(resp)) {\n if (resp.EnableSessionSSL) {\n this.protocolClient.socket = new tls.TLSSocket(this.protocolClient.socket, {\n secureContext: tls.createSecureContext({\n // Avoid using `secureProtocol` fixing the socket to a single TLS version.\n // Newer Node versions might not support older TLS versions.\n // By using the default `minVersion` and `maxVersion` options,\n // The socket will automatically use the appropriate TLS version.\n // See: https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions\n cert: pairRecord.RootCertificate,\n key: pairRecord.RootPrivateKey,\n }),\n });\n debug(`Socket upgraded to TLS connection`);\n }\n // TODO: save sessionID for StopSession?\n } else {\n throw new ResponseError('Error starting session', resp);\n }\n }\n\n async getAllValues() {\n debug(`getAllValues`);\n\n const resp = await this.protocolClient.sendMessage({ Request: 'GetValue' });\n\n if (isLockdowndAllValuesResponse(resp)) {\n return resp.Value;\n } else {\n throw new ResponseError('Error getting lockdown value', resp);\n }\n }\n\n async getValue(val: string) {\n debug(`getValue: ${val}`);\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'GetValue',\n Key: val,\n });\n\n if (isLockdowndValueResponse(resp)) {\n return resp.Value;\n } else {\n throw new ResponseError('Error getting lockdown value', resp);\n }\n }\n\n async queryType() {\n debug('queryType');\n\n const resp = await this.protocolClient.sendMessage({\n Request: 'QueryType',\n });\n\n if (isLockdowndQueryTypeResponse(resp)) {\n return resp.Type;\n } else {\n throw new ResponseError('Error getting lockdown query type', resp);\n }\n }\n\n async doHandshake(pairRecord: UsbmuxdPairRecord) {\n debug('doHandshake');\n\n // if (await this.lockdownQueryType() !== 'com.apple.mobile.lockdown') {\n // throw new CommandError('Invalid type received from lockdown handshake');\n // }\n // await this.getLockdownValue('ProductVersion');\n // TODO: validate pair and pair\n await this.startSession(pairRecord);\n }\n}\n"],"names":["tls","debug","Debug","isLockdowndServiceResponse","resp","Request","Service","undefined","Port","isLockdowndSessionResponse","isLockdowndAllValuesResponse","Value","isLockdowndValueResponse","Key","isLockdowndQueryTypeResponse","Type","LockdowndClient","ServiceClient","constructor","socket","LockdownProtocolClient","startService","name","protocolClient","sendMessage","port","enableServiceSSL","EnableServiceSSL","ResponseError","startSession","pairRecord","HostID","SystemBUID","EnableSessionSSL","TLSSocket","secureContext","createSecureContext","cert","RootCertificate","key","RootPrivateKey","getAllValues","getValue","val","queryType","doHandshake"],"mappings":"AAOA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbA,IAAAA,GAAG,mCAAM,KAAK,EAAX;AAEwB,IAAA,iBAA8B,WAA9B,8BAA8B,CAAA;AACxB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9D,MAAMC,KAAK,GAAGC,CAAAA,GAAAA,MAAK,AAAsC,CAAA,QAAtC,CAAC,oCAAoC,CAAC,AAAC;AA8D1D,SAASC,0BAA0B,CAACC,IAAS,EAAoC;IAC/E,OAAOA,IAAI,CAACC,OAAO,KAAK,cAAc,IAAID,IAAI,CAACE,OAAO,KAAKC,SAAS,IAAIH,IAAI,CAACI,IAAI,KAAKD,SAAS,CAAC;CACjG;AAED,SAASE,0BAA0B,CAACL,IAAS,EAAoC;IAC/E,OAAOA,IAAI,CAACC,OAAO,KAAK,cAAc,CAAC;CACxC;AAED,SAASK,4BAA4B,CAACN,IAAS,EAAsC;IACnF,OAAOA,IAAI,CAACC,OAAO,KAAK,UAAU,IAAID,IAAI,CAACO,KAAK,KAAKJ,SAAS,CAAC;CAChE;AAED,SAASK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B,cAAc,CAACC,WAAW,CAAC;YACjDnB,OAAO,EAAE,UAAU;YACnBQ,GAAG,EAAE8B,GAAG;SACT,CAAC,AAAC;QAEH,IAAI/B,wBAAwB,CAACR,IAAI,CAAC,EAAE;YAClC,OAAOA,IAAI,CAACO,KAAK,CAAC;SACnB,MAAM;YACL,MAAM,IAAIiB,cAAa,cAAA,CAAC,8BAA8B,EAAExB,IAAI,CAAC,CAAC;SAC/D;KACF;IAED,MAAMwC,SAAS,GAAG;QAChB3C,KAAK,CAAC,WAAW,CAAC,CAAC;QAEnB,MAAMG,IAAI,GAAG,MAAM,IAAI,CAACmB,cAAc,CAACC,WAAW,CAAC;YACjDnB,OAAO,EAAE,WAAW;SACrB,CAAC,AAAC;QAEH,IAAIS,4BAA4B,CAACV,IAAI,CAAC,EAAE;YACtC,OAAOA,IAAI,CAACW,IAAI,CAAC;SAClB,MAAM;YACL,MAAM,IAAIa,cAAa,cAAA,CAAC,mCAAmC,EAAExB,IAAI,CAAC,CAAC;SACpE;KACF;IAED,MAAMyC,WAAW,CAACf,UAA6B,EAAE;QAC/C7B,KAAK,CAAC,aAAa,CAAC,CAAC;QAErB,wEAAwE;QACxE,6EAA6E;QAC7E,IAAI;QACJ,iDAAiD;QACjD,+BAA+B;QAC/B,MAAM,IAAI,CAAC4B,YAAY,CAACC,UAAU,CAAC,CAAC;KACrC;CACF;QArGYd,eAAe,GAAfA,eAAe"}
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
var _plist = _interopRequireDefault(require("@expo/plist"));
|
|
6
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
7
|
+
var _errors = require("../../../../utils/errors");
|
|
6
8
|
var _plist1 = require("../../../../utils/plist");
|
|
7
9
|
function _interopRequireDefault(obj) {
|
|
8
10
|
return obj && obj.__esModule ? obj : {
|
|
@@ -10,6 +12,15 @@ function _interopRequireDefault(obj) {
|
|
|
10
12
|
};
|
|
11
13
|
}
|
|
12
14
|
const BPLIST_MAGIC = Buffer.from("bplist00");
|
|
15
|
+
const debug = (0, _debug).default("expo:apple-device:protocol");
|
|
16
|
+
class ProtocolClientError extends _errors.CommandError {
|
|
17
|
+
constructor(msg, error, protocolMessage){
|
|
18
|
+
super(msg);
|
|
19
|
+
this.error = error;
|
|
20
|
+
this.protocolMessage = protocolMessage;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ProtocolClientError = ProtocolClientError;
|
|
13
24
|
class ProtocolReaderFactory {
|
|
14
25
|
constructor(ProtocolReader1){
|
|
15
26
|
this.ProtocolReader = ProtocolReader1;
|
|
@@ -89,6 +100,10 @@ class ProtocolClient {
|
|
|
89
100
|
this.writer = writer;
|
|
90
101
|
}
|
|
91
102
|
sendMessage(msg, callback) {
|
|
103
|
+
const onError = (error)=>{
|
|
104
|
+
debug("Unexpected protocol socket error encountered: %s", error);
|
|
105
|
+
throw new ProtocolClientError(`Unexpected protocol error encountered: ${error.message}`, error, msg);
|
|
106
|
+
};
|
|
92
107
|
return new Promise((resolve, reject)=>{
|
|
93
108
|
const reader = this.readerFactory.create(async (response, error)=>{
|
|
94
109
|
if (error) {
|
|
@@ -98,14 +113,17 @@ class ProtocolClient {
|
|
|
98
113
|
if (callback) {
|
|
99
114
|
callback(response, (value)=>{
|
|
100
115
|
this.socket.removeListener("data", reader.onData);
|
|
116
|
+
this.socket.removeListener("error", onError);
|
|
101
117
|
resolve(value);
|
|
102
118
|
}, reject);
|
|
103
119
|
} else {
|
|
104
120
|
this.socket.removeListener("data", reader.onData);
|
|
121
|
+
this.socket.removeListener("error", onError);
|
|
105
122
|
resolve(response);
|
|
106
123
|
}
|
|
107
124
|
});
|
|
108
125
|
this.socket.on("data", reader.onData);
|
|
126
|
+
this.socket.on("error", onError);
|
|
109
127
|
this.writer.write(this.socket, msg);
|
|
110
128
|
});
|
|
111
129
|
}
|