@expo/cli 57.0.31 → 57.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/export/compileHermesArtifacts.js +28 -0
- package/build/src/export/compileHermesArtifacts.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +4 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +9 -5
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportDomComponents.js +5 -11
- package/build/src/export/exportDomComponents.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +3 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -2
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/ios/appleDevice/ClientManager.js +11 -6
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +12 -4
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +1 -1
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/createDevToolsMenuItems.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/ios/devicectl.js +2 -5
- package/build/src/start/platforms/ios/devicectl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +6 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -4
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/{DevToolsPlugin.js → devtools/DevToolsPlugin.js} +14 -5
- package/build/src/start/server/devtools/DevToolsPlugin.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js +195 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionExecutor.js → devtools/DevToolsPluginCliExtensionExecutor.js} +1 -1
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionExecutor.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionResults.js → devtools/DevToolsPluginCliExtensionResults.js} +24 -12
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionResults.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginManager.js → devtools/DevToolsPluginManager.js} +2 -2
- package/build/src/start/server/devtools/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPluginServerHelpers.js.map +1 -0
- package/build/src/start/server/{MCP.js → mcp/MCP.js} +25 -15
- package/build/src/start/server/mcp/MCP.js.map +1 -0
- package/build/src/start/server/{MCPDevToolsPluginCLIExtensions.js → mcp/MCPDevToolsPluginCLIExtensions.js} +14 -27
- package/build/src/start/server/mcp/MCPDevToolsPluginCLIExtensions.js.map +1 -0
- package/build/src/start/server/{createMCPDevToolsExtensionSchema.js → mcp/createMCPDevToolsExtensionSchema.js} +8 -15
- package/build/src/start/server/mcp/createMCPDevToolsExtensionSchema.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +2 -4
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +6 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +4 -1
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/openHandlers.js +2 -6
- package/build/src/start/server/middleware/openHandlers.js.map +1 -1
- package/build/src/start/startAsync.js +2 -4
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/open.js +47 -31
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +25 -21
- package/build/src/start/server/DevToolsPlugin.js.map +0 -1
- package/build/src/start/server/DevToolsPlugin.schema.js +0 -84
- package/build/src/start/server/DevToolsPlugin.schema.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +0 -1
- package/build/src/start/server/DevToolsPluginManager.js.map +0 -1
- package/build/src/start/server/DevToolsPluginServerHelpers.js.map +0 -1
- package/build/src/start/server/MCP.js.map +0 -1
- package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +0 -1
- package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +0 -1
- /package/build/src/start/server/{DevToolsPluginServerHelpers.js → devtools/DevToolsPluginServerHelpers.js} +0 -0
|
@@ -30,7 +30,7 @@ function _interop_require_default(obj) {
|
|
|
30
30
|
default: obj
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
async function ensureNativeProjectAsync(projectRoot, { platform, install }) {
|
|
33
|
+
async function ensureNativeProjectAsync(projectRoot, { platform, install }, onProjectReady) {
|
|
34
34
|
// If the user has an empty android folder then the project won't build, this can happen when they delete the prebuild files in git.
|
|
35
35
|
// Check to ensure most of the core files are in place, and prompt to remove the folder if they aren't.
|
|
36
36
|
await (0, _profile.profile)(_clearNativeFolder.promptToClearMalformedNativeProjectsAsync)(projectRoot, [
|
|
@@ -43,8 +43,9 @@ async function ensureNativeProjectAsync(projectRoot, { platform, install }) {
|
|
|
43
43
|
platforms: [
|
|
44
44
|
platform
|
|
45
45
|
]
|
|
46
|
-
});
|
|
46
|
+
}, onProjectReady);
|
|
47
47
|
} else {
|
|
48
|
+
await (onProjectReady == null ? void 0 : onProjectReady());
|
|
48
49
|
return true;
|
|
49
50
|
}
|
|
50
51
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/run/ensureNativeProject.ts"],"sourcesContent":["import type { ModPlatform } from '@expo/config-plugins';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { promptToClearMalformedNativeProjectsAsync } from '../prebuild/clearNativeFolder';\nimport { prebuildAsync } from '../prebuild/prebuildAsync';\nimport { profile } from '../utils/profile';\n\nexport async function ensureNativeProjectAsync(\n projectRoot: string,\n { platform, install }: { platform: ModPlatform; install?: boolean }
|
|
1
|
+
{"version":3,"sources":["../../../src/run/ensureNativeProject.ts"],"sourcesContent":["import type { ModPlatform } from '@expo/config-plugins';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { promptToClearMalformedNativeProjectsAsync } from '../prebuild/clearNativeFolder';\nimport { prebuildAsync } from '../prebuild/prebuildAsync';\nimport { profile } from '../utils/profile';\n\nexport async function ensureNativeProjectAsync(\n projectRoot: string,\n { platform, install }: { platform: ModPlatform; install?: boolean },\n onProjectReady?: () => Promise<void>\n) {\n // If the user has an empty android folder then the project won't build, this can happen when they delete the prebuild files in git.\n // Check to ensure most of the core files are in place, and prompt to remove the folder if they aren't.\n await profile(promptToClearMalformedNativeProjectsAsync)(projectRoot, [platform]);\n\n // If the project doesn't have native code, prebuild it...\n if (!fs.existsSync(path.join(projectRoot, platform))) {\n await prebuildAsync(projectRoot, { install: !!install, platforms: [platform] }, onProjectReady);\n } else {\n await onProjectReady?.();\n return true;\n }\n return false;\n}\n"],"names":["ensureNativeProjectAsync","projectRoot","platform","install","onProjectReady","profile","promptToClearMalformedNativeProjectsAsync","fs","existsSync","path","join","prebuildAsync","platforms"],"mappings":";;;;+BAQsBA;;;eAAAA;;;;gEAPP;;;;;;;gEACE;;;;;;mCAEyC;+BAC5B;yBACN;;;;;;AAEjB,eAAeA,yBACpBC,WAAmB,EACnB,EAAEC,QAAQ,EAAEC,OAAO,EAAgD,EACnEC,cAAoC;IAEpC,oIAAoI;IACpI,uGAAuG;IACvG,MAAMC,IAAAA,gBAAO,EAACC,4DAAyC,EAAEL,aAAa;QAACC;KAAS;IAEhF,0DAA0D;IAC1D,IAAI,CAACK,aAAE,CAACC,UAAU,CAACC,eAAI,CAACC,IAAI,CAACT,aAAaC,YAAY;QACpD,MAAMS,IAAAA,4BAAa,EAACV,aAAa;YAAEE,SAAS,CAAC,CAACA;YAASS,WAAW;gBAACV;aAAS;QAAC,GAAGE;IAClF,OAAO;QACL,OAAMA,kCAAAA;QACN,OAAO;IACT;IACA,OAAO;AACT"}
|
|
@@ -87,12 +87,17 @@ class ClientManager {
|
|
|
87
87
|
}
|
|
88
88
|
static async create(udid) {
|
|
89
89
|
const usbmuxClient = new _UsbmuxdClient.UsbmuxdClient(_UsbmuxdClient.UsbmuxdClient.connectUsbmuxdSocket());
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
try {
|
|
91
|
+
const device = await usbmuxClient.getDevice(udid);
|
|
92
|
+
const pairRecord = await usbmuxClient.readPairRecord(device.Properties.SerialNumber);
|
|
93
|
+
const lockdownSocket = await usbmuxClient.connect(device, 62078);
|
|
94
|
+
const lockdownClient = new _LockdowndClient.LockdowndClient(lockdownSocket);
|
|
95
|
+
await lockdownClient.doHandshake(pairRecord);
|
|
96
|
+
return new ClientManager(pairRecord, device, lockdownClient);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
usbmuxClient.socket.destroy();
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
96
101
|
}
|
|
97
102
|
async getUsbmuxdClient() {
|
|
98
103
|
const usbmuxClient = new _UsbmuxdClient.UsbmuxdClient(_UsbmuxdClient.UsbmuxdClient.connectUsbmuxdSocket());
|
|
@@ -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 type { Socket } from 'net';\nimport { Duplex } from 'stream';\nimport * as tls from 'tls';\n\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 type { ServiceClient } from './client/ServiceClient';\nimport type { UsbmuxdDevice, UsbmuxdPairRecord } from './client/UsbmuxdClient';\nimport { UsbmuxdClient } from './client/UsbmuxdClient';\nimport { CommandError } from '../../../utils/errors';\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":["ClientManager","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","tls","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"],"mappings":"AAAA;;;;;;CAMC;;;;+BAeYA;;;eAAAA;;;;yBAbU;;;;;;;iEACF;;;;;;2BAEK;mCACQ;yCAC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6C;gBAEpB,MAAM,IAAIE,QAAc,CAACC,SAASC;oBAChC,MAAMC,YAAYC,WAAW;wBAC3BF,OACE,IAAIG,oBAAY,CAAC,gBAAgB;oBAErC,GAAG;oBACHb,OAAI5B,OAAO,CAACyB,YAAY;wBACtBiB,aAAaH;wBACb,+DAA+D;wBAC/D,0EAA0E;wBAC1E,IAAI,CAACI,OAAO;wBACZN;oBACF;gBACF;YACF,OAAO;gBACLZ,WAAWpC,MAAM,GAAGmC;gBACpBA,gBAAgBI,OAAI5B,OAAO,CAACyB;YAC9B;QACF;QACA,MAAMmB,SAAS,IAAI1B,YAAYM;QAC/B,IAAI,CAACpC,WAAW,CAACiB,IAAI,CAACuC,OAAOvD,MAAM;QACnC,OAAOuD;IACT;IAEAC,MAAM;QACJ,KAAK,MAAMxD,UAAU,IAAI,CAACD,WAAW,CAAE;YACrC,wBAAwB;YACxB,IAAI;gBACFC,OAAOwD,GAAG;YACZ,EAAE,OAAM,CAAC;QACX;IACF;AACF;AAEA,MAAMV,qBAAqBW,gBAAM;IAC/B,YAAY,AAAQC,WAAmB,CAAE;QACvC,KAAK,SADaA,cAAAA;QAGlB,IAAI,CAACA,WAAW,CAACC,EAAE,CAAC,QAAQ,CAACC;YAC3B,IAAI,CAAC5C,IAAI,CAAC4C;QACZ;IACF;IAEAC,OAAOC,KAAU,EAAEC,QAAgB,EAAEC,QAA+B,EAAE;QACpE,IAAI,CAACN,WAAW,CAACO,KAAK,CAACH;QACvBE;IACF;IAEAE,MAAMC,IAAY,EAAE;IAClB,uFAAuF;IACvF,+BAA+B;IACjC;IAEAC,WAAW;QACT,IAAI,CAACV,WAAW,CAACW,kBAAkB;IACrC;AACF"}
|
|
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 type { Socket } from 'net';\nimport { Duplex } from 'stream';\nimport * as tls from 'tls';\n\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 type { ServiceClient } from './client/ServiceClient';\nimport type { UsbmuxdDevice, UsbmuxdPairRecord } from './client/UsbmuxdClient';\nimport { UsbmuxdClient } from './client/UsbmuxdClient';\nimport { CommandError } from '../../../utils/errors';\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 try {\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 } catch (error) {\n usbmuxClient.socket.destroy();\n throw error;\n }\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":["ClientManager","pairRecord","device","lockdowndClient","connections","socket","create","udid","usbmuxClient","UsbmuxdClient","connectUsbmuxdSocket","getDevice","readPairRecord","Properties","SerialNumber","lockdownSocket","connect","lockdownClient","LockdowndClient","doHandshake","error","destroy","getUsbmuxdClient","push","getLockdowndClient","getLockdowndClientWithHandshake","getAFCClient","getServiceClient","AFCClient","getInstallationProxyClient","InstallationProxyClient","getMobileImageMounterClient","MobileImageMounterClient","getDebugserverClient","DebugserverClient","name","ServiceType","disableSSL","port","servicePort","enableServiceSSL","startService","usbmuxdSocket","tlsOptions","rejectUnauthorized","secureContext","tls","createSecureContext","cert","RootCertificate","key","RootPrivateKey","proxy","UsbmuxdProxy","Promise","resolve","reject","timeoutId","setTimeout","CommandError","clearTimeout","client","end","Duplex","usbmuxdSock","on","data","_write","chunk","encoding","callback","write","_read","size","_destroy","removeAllListeners"],"mappings":"AAAA;;;;;;CAMC;;;;+BAeYA;;;eAAAA;;;;yBAbU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*#__PURE__*/ _interop_require_wildcard(require("./XcodeBuild"));
|
|
40
40
|
const _launchApp = require("./launchApp");
|
|
41
41
|
const _resolveOptions = require("./options/resolveOptions");
|
|
42
|
+
const _resolveXcodeProject = require("./options/resolveXcodeProject");
|
|
42
43
|
const _validateExternalBinary = require("./validateExternalBinary");
|
|
43
44
|
const _exportEager = require("../../export/embed/exportEager");
|
|
44
45
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../log"));
|
|
@@ -107,14 +108,21 @@ async function runIosAsync(projectRoot, options) {
|
|
|
107
108
|
(0, _nodeEnv.loadEnvFiles)(projectRoot);
|
|
108
109
|
assertPlatform();
|
|
109
110
|
const install = !!options.install;
|
|
110
|
-
|
|
111
|
+
let props;
|
|
112
|
+
const hasNativeProject = await (0, _ensureNativeProject.ensureNativeProjectAsync)(projectRoot, {
|
|
111
113
|
platform: 'ios',
|
|
112
114
|
install
|
|
113
|
-
}
|
|
115
|
+
}, async ()=>{
|
|
116
|
+
props = await (0, _profile.profile)(_resolveOptions.resolveOptionsAsync)(projectRoot, options);
|
|
117
|
+
});
|
|
118
|
+
if (!props) {
|
|
119
|
+
throw new _errors.AbortCommandError();
|
|
120
|
+
}
|
|
121
|
+
if (hasNativeProject && install) {
|
|
114
122
|
await (0, _cocoapods.maybePromptToSyncPodsAsync)(projectRoot);
|
|
115
123
|
}
|
|
116
|
-
//
|
|
117
|
-
|
|
124
|
+
// NOTE(@kitten): Pod installation may have created a workspace after options were resolved.
|
|
125
|
+
props.xcodeProject = (0, _resolveXcodeProject.resolveXcodeProject)(projectRoot);
|
|
118
126
|
// We only support build cache for simulator builds for now.
|
|
119
127
|
if (!options.binary && props.buildCacheProvider && props.isSimulator) {
|
|
120
128
|
const localPath = await (0, _buildcacheproviders.resolveBuildCache)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/run/ios/runIosAsync.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport type { Options } from './XcodeBuild.types';\nimport { getLaunchInfoForBinaryAsync, launchAppAsync } from './launchApp';\nimport { resolveOptionsAsync } from './options/resolveOptions';\nimport { getValidBinaryPathAsync } from './validateExternalBinary';\nimport { exportEagerAsync } from '../../export/embed/exportEager';\nimport * as Log from '../../log';\nimport { AppleAppIdResolver } from '../../start/platforms/ios/AppleAppIdResolver';\nimport { getContainerPathAsync, simctlAsync } from '../../start/platforms/ios/simctl';\nimport { resolveBuildCache, uploadBuildCache } from '../../utils/build-cache-providers';\nimport { maybePromptToSyncPodsAsync } from '../../utils/cocoapods';\nimport { CommandError } from '../../utils/errors';\nimport { setNodeEnv, loadEnvFiles } from '../../utils/nodeEnv';\nimport { ensurePortAvailabilityAsync } from '../../utils/port';\nimport { profile } from '../../utils/profile';\nimport { getSchemesForIosAsync } from '../../utils/scheme';\nimport { ensureNativeProjectAsync } from '../ensureNativeProject';\nimport { logProjectLogsLocation } from '../hints';\nimport { startBundlerAsync } from '../startBundler';\n\nconst debug = require('debug')('expo:run:ios');\n\nexport async function runIosAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.configuration === 'Release' ? 'production' : 'development');\n loadEnvFiles(projectRoot);\n\n assertPlatform();\n\n const install = !!options.install;\n\n if ((await ensureNativeProjectAsync(projectRoot, { platform: 'ios', install })) && install) {\n await maybePromptToSyncPodsAsync(projectRoot);\n }\n\n // Resolve the CLI arguments into useable options.\n const props = await profile(resolveOptionsAsync)(projectRoot, options);\n\n // We only support build cache for simulator builds for now.\n if (!options.binary && props.buildCacheProvider && props.isSimulator) {\n const localPath = await resolveBuildCache({\n projectRoot,\n platform: 'ios',\n runOptions: options,\n provider: props.buildCacheProvider,\n });\n if (localPath) {\n options.binary = localPath;\n }\n }\n\n if (options.rebundle) {\n Log.warn(`The --unstable-rebundle flag is experimental and may not work as expected.`);\n // Get the existing binary path to re-bundle the app.\n\n // Rebundling requires a specific device to get the container path from.\n if (!props.device) {\n throw new CommandError(\n 'Re-bundling requires a specific device. Cannot use --device generic.'\n );\n }\n\n let binaryPath: string;\n if (!options.binary) {\n if (!props.isSimulator) {\n throw new Error('Re-bundling on physical devices requires the --binary flag.');\n }\n const appId = await new AppleAppIdResolver(projectRoot).getAppIdAsync();\n const possibleBinaryPath = await getContainerPathAsync(props.device, {\n appId,\n });\n if (!possibleBinaryPath) {\n throw new CommandError(\n `Cannot rebundle because no --binary was provided and no existing binary was found on the device for ID: ${appId}.`\n );\n }\n binaryPath = possibleBinaryPath;\n Log.log('Re-using existing binary path:', binaryPath);\n // Set the binary path to the existing binary path.\n options.binary = binaryPath;\n }\n\n Log.log('Rebundling the Expo config file');\n // Re-bundle the config file the same way the app was originally bundled.\n await spawnAsync('node', [\n // TODO(@kitten): This isn't correct. The template installs expo-constants, but expo also depends on it\n // This however means that the top-level module doesn't have to exist. With isolated dependencies this will then fail\n // But we can't resolve via `expo` because that then may do something differently than autolinking if the root has a different version\n path.join(require.resolve('expo-constants/package.json'), '../scripts/getAppConfig.js'),\n projectRoot,\n path.join(options.binary, 'EXConstants.bundle'),\n ]);\n // Re-bundle the app.\n\n const possibleBundleOutput = path.join(options.binary, 'main.jsbundle');\n\n if (fs.existsSync(possibleBundleOutput)) {\n Log.log('Rebundling the app...');\n await exportEagerAsync(projectRoot, {\n resetCache: false,\n dev: false,\n platform: 'ios',\n assetsDest: path.join(options.binary, 'assets'),\n bundleOutput: possibleBundleOutput,\n });\n } else {\n Log.warn('Bundle output not found at expected location:', possibleBundleOutput);\n }\n }\n\n let binaryPath: string;\n let shouldUpdateBuildCache = false;\n if (options.binary) {\n binaryPath = await getValidBinaryPathAsync(options.binary, props);\n Log.log('Using custom binary path:', binaryPath);\n } else {\n let eagerBundleOptions: string | undefined;\n\n if (options.configuration === 'Release') {\n eagerBundleOptions = JSON.stringify(\n await exportEagerAsync(projectRoot, {\n dev: false,\n platform: 'ios',\n })\n );\n }\n\n // Spawn the `xcodebuild` process to create the app binary.\n const buildOutput = await XcodeBuild.buildAsync({\n ...props,\n eagerBundleOptions,\n });\n\n // Find the path to the built app binary, this will be used to install the binary\n // on a device.\n binaryPath = await profile(XcodeBuild.getAppBinaryPath)(buildOutput);\n // We only support build cache for simulator builds for now.\n shouldUpdateBuildCache = props.isSimulator;\n }\n\n // Copy the binary to the output directory if specified.\n if (options.output) {\n binaryPath = await copyBinaryToOutputAsync(binaryPath, options.output);\n }\n\n debug('Binary path:', binaryPath);\n\n // Generic build (--device generic) - skip install/launch, just output the binary path.\n if (!props.device) {\n Log.log(chalk`\\n{green ✓} Build complete`);\n Log.log(chalk`{bold Binary:} ${binaryPath}`);\n\n if (shouldUpdateBuildCache && props.buildCacheProvider) {\n await uploadBuildCache({\n projectRoot,\n platform: 'ios',\n provider: props.buildCacheProvider,\n buildPath: binaryPath,\n runOptions: options,\n });\n }\n return;\n }\n\n // Ensure the port hasn't become busy during the build.\n if (props.shouldStartBundler && !(await ensurePortAvailabilityAsync(projectRoot, props))) {\n props.shouldStartBundler = false;\n }\n\n const launchInfo = await getLaunchInfoForBinaryAsync(binaryPath);\n const isCustomBinary = !!options.binary;\n\n // Always close the app before launching on a simulator. Otherwise certain cached resources like the splashscreen will not be available.\n if (props.isSimulator) {\n try {\n await simctlAsync(['terminate', props.device.udid, launchInfo.bundleId]);\n } catch (error) {\n // If we failed it's likely that the app was not running to begin with and we will get an `invalid device` error\n debug('Failed to terminate app (possibly because it was not running):', error);\n }\n }\n\n // Start the dev server which creates all of the required info for\n // launching the app on a simulator.\n const manager = await startBundlerAsync(projectRoot, {\n port: props.port,\n headless: !props.shouldStartBundler,\n // If a scheme is specified then use that instead of the package name.\n\n scheme: isCustomBinary\n ? // If launching a custom binary, use the schemes in the Info.plist.\n launchInfo.schemes[0]\n : // If a scheme is specified then use that instead of the package name.\n (await getSchemesForIosAsync(projectRoot))?.[0],\n });\n\n // Install and launch the app binary on a device.\n await launchAppAsync(\n binaryPath,\n manager,\n {\n isSimulator: props.isSimulator,\n device: props.device,\n shouldStartBundler: props.shouldStartBundler,\n },\n launchInfo.bundleId\n );\n\n // Log the location of the JS logs for the device.\n if (props.shouldStartBundler) {\n logProjectLogsLocation();\n } else {\n await manager.stopAsync();\n }\n\n if (shouldUpdateBuildCache && props.buildCacheProvider) {\n await uploadBuildCache({\n projectRoot,\n platform: 'ios',\n provider: props.buildCacheProvider,\n buildPath: binaryPath,\n runOptions: options,\n });\n }\n}\n\nfunction assertPlatform() {\n if (process.platform !== 'darwin') {\n Log.exit(\n chalk`iOS apps can only be built on macOS devices. Use {cyan eas build -p ios} to build in the cloud.`\n );\n }\n}\n\n/** Copy the built binary to the specified output directory. */\nasync function copyBinaryToOutputAsync(binaryPath: string, outputDir: string): Promise<string> {\n const absoluteOutputDir = path.resolve(outputDir);\n const appName = path.basename(binaryPath);\n const outputPath = path.join(absoluteOutputDir, appName);\n\n debug('Copying binary to output directory:', outputPath);\n\n // Create the output directory if it doesn't exist.\n await fs.promises.mkdir(absoluteOutputDir, { recursive: true });\n\n // Copy the .app bundle to the output directory.\n await fs.promises.cp(binaryPath, outputPath, { recursive: true });\n\n Log.log(chalk`{dim Copied to} ${outputPath}`);\n\n return outputPath;\n}\n"],"names":["runIosAsync","debug","require","projectRoot","options","setNodeEnv","configuration","loadEnvFiles","assertPlatform","install","ensureNativeProjectAsync","platform","maybePromptToSyncPodsAsync","props","profile","resolveOptionsAsync","binary","buildCacheProvider","isSimulator","localPath","resolveBuildCache","runOptions","provider","rebundle","Log","warn","device","CommandError","binaryPath","Error","appId","AppleAppIdResolver","getAppIdAsync","possibleBinaryPath","getContainerPathAsync","log","spawnAsync","path","join","resolve","possibleBundleOutput","fs","existsSync","exportEagerAsync","resetCache","dev","assetsDest","bundleOutput","shouldUpdateBuildCache","getValidBinaryPathAsync","eagerBundleOptions","JSON","stringify","buildOutput","XcodeBuild","buildAsync","getAppBinaryPath","output","copyBinaryToOutputAsync","chalk","uploadBuildCache","buildPath","shouldStartBundler","ensurePortAvailabilityAsync","launchInfo","getLaunchInfoForBinaryAsync","isCustomBinary","simctlAsync","udid","bundleId","error","manager","startBundlerAsync","port","headless","scheme","schemes","getSchemesForIosAsync","launchAppAsync","logProjectLogsLocation","stopAsync","process","exit","outputDir","absoluteOutputDir","appName","basename","outputPath","promises","mkdir","recursive","cp"],"mappings":";;;;+BA2BsBA;;;eAAAA;;;;gEA3BC;;;;;;;gEACL;;;;;;;gEACH;;;;;;;gEACE;;;;;;oEAEW;2BAEgC;gCACxB;wCACI;6BACP;6DACZ;oCACc;wBACgB;qCACC;2BACT;wBACd;yBACY;sBACG;yBACpB;wBACc;qCACG;uBACF;8BACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,YAAYG,WAAmB,EAAEC,OAAgB;QA0K9D;IAzKPC,IAAAA,mBAAU,EAACD,QAAQE,aAAa,KAAK,YAAY,eAAe;IAChEC,IAAAA,qBAAY,EAACJ;IAEbK;IAEA,MAAMC,UAAU,CAAC,CAACL,QAAQK,OAAO;IAEjC,IAAI,AAAC,MAAMC,IAAAA,6CAAwB,EAACP,aAAa;QAAEQ,UAAU;QAAOF;IAAQ,MAAOA,SAAS;QAC1F,MAAMG,IAAAA,qCAA0B,EAACT;IACnC;IAEA,kDAAkD;IAClD,MAAMU,QAAQ,MAAMC,IAAAA,gBAAO,EAACC,mCAAmB,EAAEZ,aAAaC;IAE9D,4DAA4D;IAC5D,IAAI,CAACA,QAAQY,MAAM,IAAIH,MAAMI,kBAAkB,IAAIJ,MAAMK,WAAW,EAAE;QACpE,MAAMC,YAAY,MAAMC,IAAAA,sCAAiB,EAAC;YACxCjB;YACAQ,UAAU;YACVU,YAAYjB;YACZkB,UAAUT,MAAMI,kBAAkB;QACpC;QACA,IAAIE,WAAW;YACbf,QAAQY,MAAM,GAAGG;QACnB;IACF;IAEA,IAAIf,QAAQmB,QAAQ,EAAE;QACpB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,KAAK,UAAU;QACjCa,KAAI0D,IAAI,CACNvB,IAAAA,gBAAK,CAAA,CAAC,+FAA+F,CAAC;IAE1G;AACF;AAEA,6DAA6D,GAC7D,eAAeD,wBAAwB9B,UAAkB,EAAEuD,SAAiB;IAC1E,MAAMC,oBAAoB/C,eAAI,CAACE,OAAO,CAAC4C;IACvC,MAAME,UAAUhD,eAAI,CAACiD,QAAQ,CAAC1D;IAC9B,MAAM2D,aAAalD,eAAI,CAACC,IAAI,CAAC8C,mBAAmBC;IAEhDpF,MAAM,uCAAuCsF;IAE7C,mDAAmD;IACnD,MAAM9C,aAAE,CAAC+C,QAAQ,CAACC,KAAK,CAACL,mBAAmB;QAAEM,WAAW;IAAK;IAE7D,gDAAgD;IAChD,MAAMjD,aAAE,CAAC+C,QAAQ,CAACG,EAAE,CAAC/D,YAAY2D,YAAY;QAAEG,WAAW;IAAK;IAE/DlE,KAAIW,GAAG,CAACwB,IAAAA,gBAAK,CAAA,CAAC,gBAAgB,EAAE4B,WAAW,CAAC;IAE5C,OAAOA;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/run/ios/runIosAsync.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport type { BuildProps, Options } from './XcodeBuild.types';\nimport { getLaunchInfoForBinaryAsync, launchAppAsync } from './launchApp';\nimport { resolveOptionsAsync } from './options/resolveOptions';\nimport { resolveXcodeProject } from './options/resolveXcodeProject';\nimport { getValidBinaryPathAsync } from './validateExternalBinary';\nimport { exportEagerAsync } from '../../export/embed/exportEager';\nimport * as Log from '../../log';\nimport { AppleAppIdResolver } from '../../start/platforms/ios/AppleAppIdResolver';\nimport { getContainerPathAsync, simctlAsync } from '../../start/platforms/ios/simctl';\nimport { resolveBuildCache, uploadBuildCache } from '../../utils/build-cache-providers';\nimport { maybePromptToSyncPodsAsync } from '../../utils/cocoapods';\nimport { AbortCommandError, CommandError } from '../../utils/errors';\nimport { setNodeEnv, loadEnvFiles } from '../../utils/nodeEnv';\nimport { ensurePortAvailabilityAsync } from '../../utils/port';\nimport { profile } from '../../utils/profile';\nimport { getSchemesForIosAsync } from '../../utils/scheme';\nimport { ensureNativeProjectAsync } from '../ensureNativeProject';\nimport { logProjectLogsLocation } from '../hints';\nimport { startBundlerAsync } from '../startBundler';\n\nconst debug = require('debug')('expo:run:ios');\n\nexport async function runIosAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.configuration === 'Release' ? 'production' : 'development');\n loadEnvFiles(projectRoot);\n\n assertPlatform();\n\n const install = !!options.install;\n\n let props: BuildProps | undefined;\n const hasNativeProject = await ensureNativeProjectAsync(\n projectRoot,\n { platform: 'ios', install },\n async () => {\n props = await profile(resolveOptionsAsync)(projectRoot, options);\n }\n );\n\n if (!props) {\n throw new AbortCommandError();\n }\n if (hasNativeProject && install) {\n await maybePromptToSyncPodsAsync(projectRoot);\n }\n\n // NOTE(@kitten): Pod installation may have created a workspace after options were resolved.\n props.xcodeProject = resolveXcodeProject(projectRoot);\n\n // We only support build cache for simulator builds for now.\n if (!options.binary && props.buildCacheProvider && props.isSimulator) {\n const localPath = await resolveBuildCache({\n projectRoot,\n platform: 'ios',\n runOptions: options,\n provider: props.buildCacheProvider,\n });\n if (localPath) {\n options.binary = localPath;\n }\n }\n\n if (options.rebundle) {\n Log.warn(`The --unstable-rebundle flag is experimental and may not work as expected.`);\n // Get the existing binary path to re-bundle the app.\n\n // Rebundling requires a specific device to get the container path from.\n if (!props.device) {\n throw new CommandError(\n 'Re-bundling requires a specific device. Cannot use --device generic.'\n );\n }\n\n let binaryPath: string;\n if (!options.binary) {\n if (!props.isSimulator) {\n throw new Error('Re-bundling on physical devices requires the --binary flag.');\n }\n const appId = await new AppleAppIdResolver(projectRoot).getAppIdAsync();\n const possibleBinaryPath = await getContainerPathAsync(props.device, {\n appId,\n });\n if (!possibleBinaryPath) {\n throw new CommandError(\n `Cannot rebundle because no --binary was provided and no existing binary was found on the device for ID: ${appId}.`\n );\n }\n binaryPath = possibleBinaryPath;\n Log.log('Re-using existing binary path:', binaryPath);\n // Set the binary path to the existing binary path.\n options.binary = binaryPath;\n }\n\n Log.log('Rebundling the Expo config file');\n // Re-bundle the config file the same way the app was originally bundled.\n await spawnAsync('node', [\n // TODO(@kitten): This isn't correct. The template installs expo-constants, but expo also depends on it\n // This however means that the top-level module doesn't have to exist. With isolated dependencies this will then fail\n // But we can't resolve via `expo` because that then may do something differently than autolinking if the root has a different version\n path.join(require.resolve('expo-constants/package.json'), '../scripts/getAppConfig.js'),\n projectRoot,\n path.join(options.binary, 'EXConstants.bundle'),\n ]);\n // Re-bundle the app.\n\n const possibleBundleOutput = path.join(options.binary, 'main.jsbundle');\n\n if (fs.existsSync(possibleBundleOutput)) {\n Log.log('Rebundling the app...');\n await exportEagerAsync(projectRoot, {\n resetCache: false,\n dev: false,\n platform: 'ios',\n assetsDest: path.join(options.binary, 'assets'),\n bundleOutput: possibleBundleOutput,\n });\n } else {\n Log.warn('Bundle output not found at expected location:', possibleBundleOutput);\n }\n }\n\n let binaryPath: string;\n let shouldUpdateBuildCache = false;\n if (options.binary) {\n binaryPath = await getValidBinaryPathAsync(options.binary, props);\n Log.log('Using custom binary path:', binaryPath);\n } else {\n let eagerBundleOptions: string | undefined;\n\n if (options.configuration === 'Release') {\n eagerBundleOptions = JSON.stringify(\n await exportEagerAsync(projectRoot, {\n dev: false,\n platform: 'ios',\n })\n );\n }\n\n // Spawn the `xcodebuild` process to create the app binary.\n const buildOutput = await XcodeBuild.buildAsync({\n ...props,\n eagerBundleOptions,\n });\n\n // Find the path to the built app binary, this will be used to install the binary\n // on a device.\n binaryPath = await profile(XcodeBuild.getAppBinaryPath)(buildOutput);\n // We only support build cache for simulator builds for now.\n shouldUpdateBuildCache = props.isSimulator;\n }\n\n // Copy the binary to the output directory if specified.\n if (options.output) {\n binaryPath = await copyBinaryToOutputAsync(binaryPath, options.output);\n }\n\n debug('Binary path:', binaryPath);\n\n // Generic build (--device generic) - skip install/launch, just output the binary path.\n if (!props.device) {\n Log.log(chalk`\\n{green ✓} Build complete`);\n Log.log(chalk`{bold Binary:} ${binaryPath}`);\n\n if (shouldUpdateBuildCache && props.buildCacheProvider) {\n await uploadBuildCache({\n projectRoot,\n platform: 'ios',\n provider: props.buildCacheProvider,\n buildPath: binaryPath,\n runOptions: options,\n });\n }\n return;\n }\n\n // Ensure the port hasn't become busy during the build.\n if (props.shouldStartBundler && !(await ensurePortAvailabilityAsync(projectRoot, props))) {\n props.shouldStartBundler = false;\n }\n\n const launchInfo = await getLaunchInfoForBinaryAsync(binaryPath);\n const isCustomBinary = !!options.binary;\n\n // Always close the app before launching on a simulator. Otherwise certain cached resources like the splashscreen will not be available.\n if (props.isSimulator) {\n try {\n await simctlAsync(['terminate', props.device.udid, launchInfo.bundleId]);\n } catch (error) {\n // If we failed it's likely that the app was not running to begin with and we will get an `invalid device` error\n debug('Failed to terminate app (possibly because it was not running):', error);\n }\n }\n\n // Start the dev server which creates all of the required info for\n // launching the app on a simulator.\n const manager = await startBundlerAsync(projectRoot, {\n port: props.port,\n headless: !props.shouldStartBundler,\n // If a scheme is specified then use that instead of the package name.\n\n scheme: isCustomBinary\n ? // If launching a custom binary, use the schemes in the Info.plist.\n launchInfo.schemes[0]\n : // If a scheme is specified then use that instead of the package name.\n (await getSchemesForIosAsync(projectRoot))?.[0],\n });\n\n // Install and launch the app binary on a device.\n await launchAppAsync(\n binaryPath,\n manager,\n {\n isSimulator: props.isSimulator,\n device: props.device,\n shouldStartBundler: props.shouldStartBundler,\n },\n launchInfo.bundleId\n );\n\n // Log the location of the JS logs for the device.\n if (props.shouldStartBundler) {\n logProjectLogsLocation();\n } else {\n await manager.stopAsync();\n }\n\n if (shouldUpdateBuildCache && props.buildCacheProvider) {\n await uploadBuildCache({\n projectRoot,\n platform: 'ios',\n provider: props.buildCacheProvider,\n buildPath: binaryPath,\n runOptions: options,\n });\n }\n}\n\nfunction assertPlatform() {\n if (process.platform !== 'darwin') {\n Log.exit(\n chalk`iOS apps can only be built on macOS devices. Use {cyan eas build -p ios} to build in the cloud.`\n );\n }\n}\n\n/** Copy the built binary to the specified output directory. */\nasync function copyBinaryToOutputAsync(binaryPath: string, outputDir: string): Promise<string> {\n const absoluteOutputDir = path.resolve(outputDir);\n const appName = path.basename(binaryPath);\n const outputPath = path.join(absoluteOutputDir, appName);\n\n debug('Copying binary to output directory:', outputPath);\n\n // Create the output directory if it doesn't exist.\n await fs.promises.mkdir(absoluteOutputDir, { recursive: true });\n\n // Copy the .app bundle to the output directory.\n await fs.promises.cp(binaryPath, outputPath, { recursive: true });\n\n Log.log(chalk`{dim Copied to} ${outputPath}`);\n\n return outputPath;\n}\n"],"names":["runIosAsync","debug","require","projectRoot","options","setNodeEnv","configuration","loadEnvFiles","assertPlatform","install","props","hasNativeProject","ensureNativeProjectAsync","platform","profile","resolveOptionsAsync","AbortCommandError","maybePromptToSyncPodsAsync","xcodeProject","resolveXcodeProject","binary","buildCacheProvider","isSimulator","localPath","resolveBuildCache","runOptions","provider","rebundle","Log","warn","device","CommandError","binaryPath","Error","appId","AppleAppIdResolver","getAppIdAsync","possibleBinaryPath","getContainerPathAsync","log","spawnAsync","path","join","resolve","possibleBundleOutput","fs","existsSync","exportEagerAsync","resetCache","dev","assetsDest","bundleOutput","shouldUpdateBuildCache","getValidBinaryPathAsync","eagerBundleOptions","JSON","stringify","buildOutput","XcodeBuild","buildAsync","getAppBinaryPath","output","copyBinaryToOutputAsync","chalk","uploadBuildCache","buildPath","shouldStartBundler","ensurePortAvailabilityAsync","launchInfo","getLaunchInfoForBinaryAsync","isCustomBinary","simctlAsync","udid","bundleId","error","manager","startBundlerAsync","port","headless","scheme","schemes","getSchemesForIosAsync","launchAppAsync","logProjectLogsLocation","stopAsync","process","exit","outputDir","absoluteOutputDir","appName","basename","outputPath","promises","mkdir","recursive","cp"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;;gEA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,CAAC,+FAA+F,CAAC;IAE1G;AACF;AAEA,6DAA6D,GAC7D,eAAeD,wBAAwB9B,UAAkB,EAAEuD,SAAiB;IAC1E,MAAMC,oBAAoB/C,eAAI,CAACE,OAAO,CAAC4C;IACvC,MAAME,UAAUhD,eAAI,CAACiD,QAAQ,CAAC1D;IAC9B,MAAM2D,aAAalD,eAAI,CAACC,IAAI,CAAC8C,mBAAmBC;IAEhDxF,MAAM,uCAAuC0F;IAE7C,mDAAmD;IACnD,MAAM9C,aAAE,CAAC+C,QAAQ,CAACC,KAAK,CAACL,mBAAmB;QAAEM,WAAW;IAAK;IAE7D,gDAAgD;IAChD,MAAMjD,aAAE,CAAC+C,QAAQ,CAACG,EAAE,CAAC/D,YAAY2D,YAAY;QAAEG,WAAW;IAAK;IAE/DlE,KAAIW,GAAG,CAACwB,IAAAA,gBAAK,CAAA,CAAC,gBAAgB,EAAE4B,WAAW,CAAC;IAE5C,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/interface/cliExtensionMenuItemHandler.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Ora } from 'ora';\n\nimport * as Log from '../../log';\nimport { link } from '../../utils/link';\nimport { ora } from '../../utils/ora';\nimport { promptAsync } from '../../utils/prompts';\nimport type { DevToolsPlugin } from '../server/DevToolsPlugin';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/interface/cliExtensionMenuItemHandler.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Ora } from 'ora';\n\nimport * as Log from '../../log';\nimport { link } from '../../utils/link';\nimport { ora } from '../../utils/ora';\nimport { promptAsync } from '../../utils/prompts';\nimport type { DevToolsPlugin } from '../server/devtools/DevToolsPlugin';\nimport type {\n DevToolsPluginCommand,\n DevToolsPluginOutput,\n} from '../server/devtools/DevToolsPlugin.schema';\n\n/**\n * Handles the CLI extension menu item selection and execution of the plugin command for use\n * in the cli context, logging to the terminal.\n *\n * The function will prompt for any required parameters, confirm execution, and display\n * output from the command execution.\n *\n * @param plugin The DevTools plugin.\n * @param command The command to execute.\n * @param metroServerOrigin The Metro server origin.\n * @returns\n */\nexport const cliExtensionMenuItemHandler = async (\n plugin: DevToolsPlugin,\n command: DevToolsPluginCommand,\n metroServerOrigin: string\n) => {\n const cliExtensionsConfig = plugin.cliExtensions;\n if (cliExtensionsConfig == null) {\n return;\n }\n\n if (plugin.executor == null) {\n Log.warn(chalk`{bold ${plugin.packageName}} does not support CLI commands.`);\n return;\n }\n\n let args: Record<string, string> = {};\n if (command.parameters && command.parameters.length > 0) {\n args = await command.parameters.reduce(\n async (accPromise, param) => {\n const acc = await accPromise;\n const result = await promptAsync({\n name: param.name,\n type: param.type,\n message:\n `${param.name}${param.description ? chalk` {dim ${param.description}}` : ''}` +\n chalk` {dim (${param.type})}`,\n });\n if (result[param.name] == null) {\n throw new Error('Input cancelled');\n }\n return { ...acc, [param.name]: result[param.name] };\n },\n Promise.resolve({} as Record<string, string>)\n );\n }\n\n // Confirm execution\n const { value } = await promptAsync({\n message: chalk`{dim Execute command \"${command.title}\":} \"${plugin.executor.getCommandString({ command: command.name, args })}\"`,\n initial: false,\n name: 'value',\n type: 'confirm',\n });\n\n if (!value) {\n return;\n }\n\n const spinnerText = `Executing command '${command.title}'`;\n const spinner = ora(spinnerText).start();\n\n try {\n // Execute and stream the output\n const results = await plugin.executor.execute({\n command: command.name,\n metroServerOrigin,\n args,\n onOutput: (output) => handleOutput(output, spinner),\n });\n\n // Format with warning or success depending on wether the client reported any errors\n formatResults(command.title, results, spinner);\n } catch (error: any) {\n spinner.fail(`Failed to execute command \"${command.title}\".\\n${error.toString().trim()}`);\n }\n};\n\n//*************************** Helpers ****************************/\n\nfunction normalizeText(text: string, level: 'info' | 'warning' | 'error') {\n const trimText = text.trim();\n if (level === 'error') {\n return chalk.red(trimText);\n } else if (level === 'warning') {\n return chalk.yellow(trimText);\n } else {\n return trimText;\n }\n}\n\nfunction appendSpinnerText(text: string, spinner: Ora) {\n return (spinner.text += '\\n ' + text);\n}\n\nfunction handleOutput(output: DevToolsPluginOutput, spinner: Ora) {\n output.forEach((line) => {\n switch (line.type) {\n case 'text':\n appendSpinnerText(\n line.url\n ? link(line.url, { text: normalizeText(line.text, line.level), dim: false })\n : normalizeText(line.text, line.level),\n spinner\n );\n break;\n case 'audio':\n appendSpinnerText(link(line.url, { text: line.text ?? 'Audio', dim: false }), spinner);\n break;\n case 'image':\n appendSpinnerText(link(line.url, { text: line.text ?? 'Image', dim: false }), spinner);\n break;\n }\n });\n}\n\nfunction formatResults(command: string, results: DevToolsPluginOutput, spinner: Ora) {\n const output = spinner.text.split('\\n').slice(1).join('\\n');\n if (results.find((line) => line.type === 'text' && line.level === 'error')) {\n spinner.fail(`Command \"${command}\" completed with errors.\\n${output}`);\n } else if (results.find((line) => line.type === 'text' && line.level === 'warning')) {\n spinner.warn(`Command \"${command}\" completed with warnings.\\n${output}`);\n } else {\n spinner.succeed(`Command \"${command}\" completed successfully.\\n${output}`).stop();\n }\n}\n"],"names":["cliExtensionMenuItemHandler","plugin","command","metroServerOrigin","cliExtensionsConfig","cliExtensions","executor","Log","warn","chalk","packageName","args","parameters","length","reduce","accPromise","param","acc","result","promptAsync","name","type","message","description","Error","Promise","resolve","value","title","getCommandString","initial","spinnerText","spinner","ora","start","results","execute","onOutput","output","handleOutput","formatResults","error","fail","toString","trim","normalizeText","text","level","trimText","red","yellow","appendSpinnerText","forEach","line","url","link","dim","split","slice","join","find","succeed","stop"],"mappings":";;;;+BAyBaA;;;eAAAA;;;;gEAzBK;;;;;;6DAGG;sBACA;qBACD;yBACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBrB,MAAMA,8BAA8B,OACzCC,QACAC,SACAC;IAEA,MAAMC,sBAAsBH,OAAOI,aAAa;IAChD,IAAID,uBAAuB,MAAM;QAC/B;IACF;IAEA,IAAIH,OAAOK,QAAQ,IAAI,MAAM;QAC3BC,KAA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AG,EAAE;oBAAER,MAAMO,KAAKP,IAAI,IAAI;oBAASU,KAAK;gBAAM,IAAIxB;gBAC9E;YACF,KAAK;gBACHmB,kBAAkBI,IAAAA,UAAI,EAACF,KAAKC,GAAG,EAAE;oBAAER,MAAMO,KAAKP,IAAI,IAAI;oBAASU,KAAK;gBAAM,IAAIxB;gBAC9E;QACJ;IACF;AACF;AAEA,SAASQ,cAActC,OAAe,EAAEiC,OAA6B,EAAEH,OAAY;IACjF,MAAMM,SAASN,QAAQc,IAAI,CAACW,KAAK,CAAC,MAAMC,KAAK,CAAC,GAAGC,IAAI,CAAC;IACtD,IAAIxB,QAAQyB,IAAI,CAAC,CAACP,OAASA,KAAKhC,IAAI,KAAK,UAAUgC,KAAKN,KAAK,KAAK,UAAU;QAC1Ef,QAAQU,IAAI,CAAC,CAAC,SAAS,EAAExC,QAAQ,0BAA0B,EAAEoC,QAAQ;IACvE,OAAO,IAAIH,QAAQyB,IAAI,CAAC,CAACP,OAASA,KAAKhC,IAAI,KAAK,UAAUgC,KAAKN,KAAK,KAAK,YAAY;QACnFf,QAAQxB,IAAI,CAAC,CAAC,SAAS,EAAEN,QAAQ,4BAA4B,EAAEoC,QAAQ;IACzE,OAAO;QACLN,QAAQ6B,OAAO,CAAC,CAAC,SAAS,EAAE3D,QAAQ,2BAA2B,EAAEoC,QAAQ,EAAEwB,IAAI;IACjF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/interface/commandsTable.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nimport * as Log from '../../log';\nimport type { DependencyCheckRef } from '../checkDependenciesOnStart';\nimport type { McpServer } from '../server/MCP';\n\n// Approximately how many rows apart from the commands table (usage guide on `expo start`)\n// will be printed after the QR code? The `rows` input doesn't account for all of them,\n// so we add our best guess instead.\nconst RESERVED_ROWS = 6;\n\nexport const BLT = '\\u203A';\n\nexport type StartOptions = {\n isWebSocketsEnabled?: boolean;\n devClient?: boolean;\n reset?: boolean;\n nonPersistent?: boolean;\n maxWorkers?: number;\n platforms?: ExpoConfig['platforms'];\n mcpServer?: McpServer;\n dependencyCheckRef?: DependencyCheckRef;\n};\n\nexport const printHelp = (): void => {\n logCommandsTable([{ key: '?', msg: 'show all commands' }]).print();\n};\n\nexport const getTerminalColumns = () => process.stdout.columns || 80;\n\nexport const printItem = (text: string, opts?: { dim: boolean }): string => {\n let output = `${BLT} ` + wrapAnsi(text, getTerminalColumns()).trimStart();\n if (opts?.dim) {\n output = chalk`{dim ${output}}`;\n }\n return output;\n};\n\nexport function printUsage(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>,\n { verbose, rows }: { verbose: boolean; rows?: number }\n) {\n const isMac = process.platform === 'darwin';\n\n const { platforms = ['ios', 'android', 'web'] } = options;\n\n const isAndroidDisabled = !platforms.includes('android');\n const isIosDisabled = !platforms.includes('ios');\n const isWebDisable = !platforms.includes('web');\n\n const switchMsg = `switch to ${options.devClient === false ? 'development build' : 'Expo Go'}`;\n const target = options.devClient === false ? `Expo Go` : 'development build';\n\n const printPrefix = ({ short }: { short: boolean }) => {\n Log.log();\n let message = chalk`Using {cyan ${target}}`;\n if (!short) {\n message += chalk` {dim (Press {bold s} to ${switchMsg})}`;\n }\n Log.log(printItem(message));\n };\n\n if (verbose) {\n printPrefix({ short: true });\n return logCommandsTable([\n { key: 's', msg: switchMsg },\n {},\n { key: 'a', msg: 'open Android', disabled: isAndroidDisabled },\n { key: 'shift+a', msg: 'select an Android device or emulator', disabled: isAndroidDisabled },\n isMac && { key: 'i', msg: 'open iOS simulator', disabled: isIosDisabled },\n isMac && { key: 'shift+i', msg: 'select an iOS simulator', disabled: isIosDisabled },\n { key: 'w', msg: 'open web', disabled: isWebDisable },\n {},\n { key: 'r', msg: 'reload app' },\n !!options.isWebSocketsEnabled && { key: 'j', msg: 'open debugger' },\n !!options.isWebSocketsEnabled && { key: 'm', msg: 'toggle menu' },\n !!options.isWebSocketsEnabled && { key: 'shift+m', msg: 'more tools' },\n { key: 'o', msg: 'open project code in your editor' },\n { key: 'c', msg: 'show project QR' },\n {},\n ]).print();\n }\n\n const table = logCommandsTable([\n { key: 's', msg: switchMsg },\n {},\n { key: 'a', msg: 'open Android', disabled: isAndroidDisabled },\n isMac && { key: 'i', msg: 'open iOS simulator', disabled: isIosDisabled },\n { key: 'w', msg: 'open web', disabled: isWebDisable },\n {},\n { key: 'j', msg: 'open debugger' },\n { key: 'r', msg: 'reload app' },\n !!options.isWebSocketsEnabled && { key: 'm', msg: 'toggle menu' },\n !!options.isWebSocketsEnabled && { key: 'shift+m', msg: 'more tools' },\n { key: 'o', msg: 'open project code in your editor' },\n {},\n ]);\n\n // If we're not in verbose mode, we check if we have enough space. If we don't, we don't print\n // the full usage guide and rely on the `printHelp()` message being shown instead\n if ((rows || Infinity) - RESERVED_ROWS > table.lines) {\n printPrefix({ short: true });\n table.print();\n } else {\n printPrefix({ short: false });\n }\n}\n\nfunction logCommandsTable(\n ui: (false | { key?: string; msg?: string; status?: string; disabled?: boolean })[]\n) {\n const lines = ui\n .filter((x) => !!x)\n .map(({ key, msg, status, disabled }) => {\n if (!key) return '';\n let view = `${BLT} `;\n if (key.length === 1) view += 'Press ';\n view += chalk`{bold ${key}} {dim │} `;\n view += msg;\n if (status) {\n view += ` ${chalk.dim(`(${chalk.italic(status)})`)}`;\n }\n if (disabled) {\n view = chalk.dim(view);\n }\n return view;\n });\n return {\n lines: lines.length,\n print() {\n Log.log(lines.join('\\n'));\n },\n };\n}\n"],"names":["BLT","getTerminalColumns","printHelp","printItem","printUsage","RESERVED_ROWS","logCommandsTable","key","msg","print","process","stdout","columns","text","opts","output","wrapAnsi","trimStart","dim","chalk","options","verbose","rows","isMac","platform","platforms","isAndroidDisabled","includes","isIosDisabled","isWebDisable","switchMsg","devClient","target","printPrefix","short","Log","log","message","disabled","isWebSocketsEnabled","table","Infinity","lines","ui","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;YACZU,OAAO7B,gBAAK,CAACD,GAAG,CAAC8B;QACnB;QACA,OAAOA;IACT;IACF,OAAO;QACLN,OAAOA,MAAMO,MAAM;QACnBxC;YACE0B,KAAIC,GAAG,CAACM,MAAMS,IAAI,CAAC;QACrB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/interface/commandsTable.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nimport * as Log from '../../log';\nimport type { DependencyCheckRef } from '../checkDependenciesOnStart';\nimport type { McpServer } from '../server/mcp/MCP';\n\n// Approximately how many rows apart from the commands table (usage guide on `expo start`)\n// will be printed after the QR code? The `rows` input doesn't account for all of them,\n// so we add our best guess instead.\nconst RESERVED_ROWS = 6;\n\nexport const BLT = '\\u203A';\n\nexport type StartOptions = {\n isWebSocketsEnabled?: boolean;\n devClient?: boolean;\n reset?: boolean;\n nonPersistent?: boolean;\n maxWorkers?: number;\n platforms?: ExpoConfig['platforms'];\n mcpServer?: McpServer;\n dependencyCheckRef?: DependencyCheckRef;\n};\n\nexport const printHelp = (): void => {\n logCommandsTable([{ key: '?', msg: 'show all commands' }]).print();\n};\n\nexport const getTerminalColumns = () => process.stdout.columns || 80;\n\nexport const printItem = (text: string, opts?: { dim: boolean }): string => {\n let output = `${BLT} ` + wrapAnsi(text, getTerminalColumns()).trimStart();\n if (opts?.dim) {\n output = chalk`{dim ${output}}`;\n }\n return output;\n};\n\nexport function printUsage(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>,\n { verbose, rows }: { verbose: boolean; rows?: number }\n) {\n const isMac = process.platform === 'darwin';\n\n const { platforms = ['ios', 'android', 'web'] } = options;\n\n const isAndroidDisabled = !platforms.includes('android');\n const isIosDisabled = !platforms.includes('ios');\n const isWebDisable = !platforms.includes('web');\n\n const switchMsg = `switch to ${options.devClient === false ? 'development build' : 'Expo Go'}`;\n const target = options.devClient === false ? `Expo Go` : 'development build';\n\n const printPrefix = ({ short }: { short: boolean }) => {\n Log.log();\n let message = chalk`Using {cyan ${target}}`;\n if (!short) {\n message += chalk` {dim (Press {bold s} to ${switchMsg})}`;\n }\n Log.log(printItem(message));\n };\n\n if (verbose) {\n printPrefix({ short: true });\n return logCommandsTable([\n { key: 's', msg: switchMsg },\n {},\n { key: 'a', msg: 'open Android', disabled: isAndroidDisabled },\n { key: 'shift+a', msg: 'select an Android device or emulator', disabled: isAndroidDisabled },\n isMac && { key: 'i', msg: 'open iOS simulator', disabled: isIosDisabled },\n isMac && { key: 'shift+i', msg: 'select an iOS simulator', disabled: isIosDisabled },\n { key: 'w', msg: 'open web', disabled: isWebDisable },\n {},\n { key: 'r', msg: 'reload app' },\n !!options.isWebSocketsEnabled && { key: 'j', msg: 'open debugger' },\n !!options.isWebSocketsEnabled && { key: 'm', msg: 'toggle menu' },\n !!options.isWebSocketsEnabled && { key: 'shift+m', msg: 'more tools' },\n { key: 'o', msg: 'open project code in your editor' },\n { key: 'c', msg: 'show project QR' },\n {},\n ]).print();\n }\n\n const table = logCommandsTable([\n { key: 's', msg: switchMsg },\n {},\n { key: 'a', msg: 'open Android', disabled: isAndroidDisabled },\n isMac && { key: 'i', msg: 'open iOS simulator', disabled: isIosDisabled },\n { key: 'w', msg: 'open web', disabled: isWebDisable },\n {},\n { key: 'j', msg: 'open debugger' },\n { key: 'r', msg: 'reload app' },\n !!options.isWebSocketsEnabled && { key: 'm', msg: 'toggle menu' },\n !!options.isWebSocketsEnabled && { key: 'shift+m', msg: 'more tools' },\n { key: 'o', msg: 'open project code in your editor' },\n {},\n ]);\n\n // If we're not in verbose mode, we check if we have enough space. If we don't, we don't print\n // the full usage guide and rely on the `printHelp()` message being shown instead\n if ((rows || Infinity) - RESERVED_ROWS > table.lines) {\n printPrefix({ short: true });\n table.print();\n } else {\n printPrefix({ short: false });\n }\n}\n\nfunction logCommandsTable(\n ui: (false | { key?: string; msg?: string; status?: string; disabled?: boolean })[]\n) {\n const lines = ui\n .filter((x) => !!x)\n .map(({ key, msg, status, disabled }) => {\n if (!key) return '';\n let view = `${BLT} `;\n if (key.length === 1) view += 'Press ';\n view += chalk`{bold ${key}} {dim │} `;\n view += msg;\n if (status) {\n view += ` ${chalk.dim(`(${chalk.italic(status)})`)}`;\n }\n if (disabled) {\n view = chalk.dim(view);\n }\n return view;\n });\n return {\n lines: lines.length,\n print() {\n Log.log(lines.join('\\n'));\n },\n };\n}\n"],"names":["BLT","getTerminalColumns","printHelp","printItem","printUsage","RESERVED_ROWS","logCommandsTable","key","msg","print","process","stdout","columns","text","opts","output","wrapAnsi","trimStart","dim","chalk","options","verbose","rows","isMac","platform","platforms","isAndroidDisabled","includes","isIosDisabled","isWebDisable","switchMsg","devClient","target","printPrefix","short","Log","log","message","disabled","isWebSocketsEnabled","table","Infinity","lines","ui","filter","x","map","status","view","length","italic","join"],"mappings":";;;;;;;;;;;QAaaA;eAAAA;;QAiBAC;eAAAA;;QAJAC;eAAAA;;QAMAC;eAAAA;;QAQGC;eAAAA;;;;gEAvCE;;;;;;;gEACG;;;;;;6DAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIrB,0FAA0F;AAC1F,uFAAuF;AACvF,oCAAoC;AACpC,MAAMC,gBAAgB;AAEf,MAAML,MAAM;AAaZ,MAAME,YAAY;IACvBI,iBAAiB;QAAC;YAAEC,KAAK;YAAKC,KAAK;QAAoB;KAAE,EAAEC,KAAK;AAClE;AAEO,MAAMR,qBAAqB,IAAMS,QAAQC,MAAM,CAACC,OAAO,IAAI;AAE3D,MAAMT,YAAY,CAACU,MAAcC;IACtC,IAAIC,SAAS,GAAGf,IAAI,CAAC,CAAC,GAAGgB,IAAAA,mBAAQ,EAACH,MAAMZ,sBAAsBgB,SAAS;IACvE,IAAIH,wBAAAA,KAAMI,GAAG,EAAE;QACbH,SAASI,IAAAA,gBAAK,CAAA,CAAC,KAAK,EAAEJ,OAAO,CAAC,CAA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AQC,GACXC,MAAM,CAAC,CAACC,IAAM,CAAC,CAACA,GAChBC,GAAG,CAAC,CAAC,EAAEvC,GAAG,EAAEC,GAAG,EAAEuC,MAAM,EAAET,QAAQ,EAAE;QAClC,IAAI,CAAC/B,KAAK,OAAO;QACjB,IAAIyC,OAAO,GAAGhD,IAAI,CAAC,CAAC;QACpB,IAAIO,IAAI0C,MAAM,KAAK,GAAGD,QAAQ;QAC9BA,QAAQ7B,IAAAA,gBAAK,CAAA,CAAC,MAAM,EAAEZ,IAAI,UAAU,CAAC;QACrCyC,QAAQxC;QACR,IAAIuC,QAAQ;YACVC,QAAQ,CAAC,CAAC,EAAE7B,gBAAK,CAACD,GAAG,CAAC,CAAC,CAAC,EAAEC,gBAAK,CAAC+B,MAAM,CAACH,QAAQ,CAAC,CAAC,GAAG;QACtD;QACA,IAAIT,UAAU;YACZU,OAAO7B,gBAAK,CAACD,GAAG,CAAC8B;QACnB;QACA,OAAOA;IACT;IACF,OAAO;QACLN,OAAOA,MAAMO,MAAM;QACnBxC;YACE0B,KAAIC,GAAG,CAACM,MAAMS,IAAI,CAAC;QACrB;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/interface/createDevToolsMenuItems.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { cliExtensionMenuItemHandler } from './cliExtensionMenuItemHandler';\nimport * as Log from '../../log';\nimport { openBrowserAsync } from '../../utils/open';\nimport type { ExpoChoice } from '../../utils/prompts';\nimport { selectAsync } from '../../utils/prompts';\nimport type { DevToolsPlugin } from '../server/DevToolsPlugin';\nimport type { DevToolsPluginCommand } from '../server/DevToolsPlugin.schema';\n\nconst debug = require('debug')('expo:start:devtools') as typeof console.log;\n\nexport interface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\ntype MenuItemWithSubmenu = MoreToolMenuItem & {\n children?: MenuItemWithSubmenu[];\n};\n\ntype CliExtensionMenuItemHandler = (\n plugin: DevToolsPlugin,\n cmd: DevToolsPluginCommand,\n metroServerOrigin: string\n) => Promise<void>;\n\n/**\n * Creates the menu items for the DevTools interface.\n * @param plugins The list of DevTools plugins.\n * @param defaultServerUrl The default server URL.\n * @param metroServerOrigin The Metro server origin.\n * @param cliExtensionMenuItemHandlerFunc The function to handle CLI extension menu items.\n * @param openBrowserAsyncFunc The function to open the browser.\n * @returns The menu items for the DevTools interface.\n */\nexport const createDevToolsMenuItems = (\n plugins: DevToolsPlugin[],\n defaultServerUrl: string,\n metroServerOrigin: string,\n cliExtensionMenuItemHandlerFunc: CliExtensionMenuItemHandler = cliExtensionMenuItemHandler, // Used for injection when testing\n openBrowserAsyncFunc: typeof openBrowserAsync = openBrowserAsync // Used for injection when testing\n): MenuItemWithSubmenu[] => {\n return plugins\n .map((plugin) => {\n const commands = getCliExtensionCommands(plugin);\n if (commands.length > 0 && plugin.webpageEndpoint) {\n // Custom display/handling for plugins that support both web and CLI commands\n const children = [\n devtoolFactory(plugin, defaultServerUrl, openBrowserAsyncFunc),\n ...commands.map((descriptor) => ({\n title: descriptor.title,\n value: descriptor.name,\n action: async () =>\n await cliExtensionMenuItemHandlerFunc(plugin, descriptor, metroServerOrigin),\n })),\n ].filter((item) => item != null);\n return {\n title: chalk`{bold ${plugin.packageName}}`,\n value: '',\n children,\n action: async () => {\n try {\n const value = await selectAsync(chalk`{dim Select command}`, children);\n await children.find((item) => item.value === value)?.action?.();\n } catch (error: any) {\n // Handle aborting prompt\n debug(`Aborted selection prompt by user: ${error.toString()}`);\n }\n },\n };\n } else if (plugin.webpageEndpoint) {\n return devtoolFactory(plugin, defaultServerUrl);\n } else if (plugin.cliExtensions && commands.length > 0) {\n return cliExtensionFactory(plugin, metroServerOrigin);\n }\n return null;\n })\n .filter((menuItem) => menuItem != null);\n};\n\nconst devtoolFactory = (\n plugin: DevToolsPlugin,\n defaultServerUrl: string,\n openBrowserAsyncFunc: typeof openBrowserAsync = openBrowserAsync // Used for injection when testing\n): MoreToolMenuItem | null => {\n if (plugin.webpageEndpoint == null) {\n return null;\n }\n\n return {\n title: chalk`Open {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(plugin.webpageEndpoint!, defaultServerUrl);\n await openBrowserAsyncFunc(url.toString());\n },\n };\n};\n\nconst getCliExtensionCommands = (plugin: DevToolsPlugin): DevToolsPluginCommand[] => {\n const cliExtensionsConfig = plugin.cliExtensions;\n const commands = (cliExtensionsConfig?.commands ?? []).filter((p) =>\n p.environments?.includes('cli')\n );\n\n if (cliExtensionsConfig == null || commands.length === 0) {\n return [];\n }\n return commands;\n};\n\nconst cliExtensionFactory = (\n plugin: DevToolsPlugin,\n metroServerOrigin: string,\n cliExtensionMenuItemHandlerFunc: CliExtensionMenuItemHandler = cliExtensionMenuItemHandler // Used for injection when testing\n): MenuItemWithSubmenu | null => {\n const commands = getCliExtensionCommands(plugin);\n const children = commands.map((cmd) => ({\n title: cmd.title,\n value: cmd.name,\n }));\n\n return {\n title: chalk`{bold ${plugin.packageName}}`,\n value: `cliExtension:${plugin.packageName}`,\n children,\n action: async () => {\n try {\n const value = await selectAsync(chalk`{dim Select command}`, children);\n const cmd = commands.find((c) => c.name === value);\n if (cmd == null) {\n Log.warn(`No command found for ${plugin.packageName}`);\n } else {\n await cliExtensionMenuItemHandlerFunc(plugin, cmd, metroServerOrigin);\n }\n } catch (error: any) {\n // Handle aborting prompt\n debug(`Failed to execute command: ${error.toString()}`);\n }\n },\n };\n};\n"],"names":["createDevToolsMenuItems","debug","require","plugins","defaultServerUrl","metroServerOrigin","cliExtensionMenuItemHandlerFunc","cliExtensionMenuItemHandler","openBrowserAsyncFunc","openBrowserAsync","map","plugin","commands","getCliExtensionCommands","length","webpageEndpoint","children","devtoolFactory","descriptor","title","value","name","action","filter","item","chalk","packageName","selectAsync","find","error","toString","cliExtensions","cliExtensionFactory","menuItem","url","URL","cliExtensionsConfig","p","environments","includes","cmd","c","Log","warn"],"mappings":";;;;+B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AAM,EAAEd,OAAOe,WAAW,CAAC,CAAC,CAAC;QAC1CN,OAAO,CAAC,aAAa,EAAET,OAAOe,WAAW,EAAE;QAC3CV;QACAM,QAAQ;YACN,IAAI;gBACF,MAAMF,QAAQ,MAAMO,IAAAA,oBAAW,EAACF,IAAAA,gBAAK,CAAA,CAAC,oBAAoB,CAAC,EAAET;gBAC7D,MAAMwB,MAAM5B,SAASgB,IAAI,CAAC,CAACa,IAAMA,EAAEpB,IAAI,KAAKD;gBAC5C,IAAIoB,OAAO,MAAM;oBACfE,KAAIC,IAAI,CAAC,CAAC,qBAAqB,EAAEhC,OAAOe,WAAW,EAAE;gBACvD,OAAO;oBACL,MAAMpB,gCAAgCK,QAAQ6B,KAAKnC;gBACrD;YACF,EAAE,OAAOwB,OAAY;gBACnB,yBAAyB;gBACzB5B,MAAM,CAAC,2BAA2B,EAAE4B,MAAMC,QAAQ,IAAI;YACxD;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/interface/createDevToolsMenuItems.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { cliExtensionMenuItemHandler } from './cliExtensionMenuItemHandler';\nimport * as Log from '../../log';\nimport { openBrowserAsync } from '../../utils/open';\nimport type { ExpoChoice } from '../../utils/prompts';\nimport { selectAsync } from '../../utils/prompts';\nimport type { DevToolsPlugin } from '../server/devtools/DevToolsPlugin';\nimport type { DevToolsPluginCommand } from '../server/devtools/DevToolsPlugin.schema';\n\nconst debug = require('debug')('expo:start:devtools') as typeof console.log;\n\nexport interface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\ntype MenuItemWithSubmenu = MoreToolMenuItem & {\n children?: MenuItemWithSubmenu[];\n};\n\ntype CliExtensionMenuItemHandler = (\n plugin: DevToolsPlugin,\n cmd: DevToolsPluginCommand,\n metroServerOrigin: string\n) => Promise<void>;\n\n/**\n * Creates the menu items for the DevTools interface.\n * @param plugins The list of DevTools plugins.\n * @param defaultServerUrl The default server URL.\n * @param metroServerOrigin The Metro server origin.\n * @param cliExtensionMenuItemHandlerFunc The function to handle CLI extension menu items.\n * @param openBrowserAsyncFunc The function to open the browser.\n * @returns The menu items for the DevTools interface.\n */\nexport const createDevToolsMenuItems = (\n plugins: DevToolsPlugin[],\n defaultServerUrl: string,\n metroServerOrigin: string,\n cliExtensionMenuItemHandlerFunc: CliExtensionMenuItemHandler = cliExtensionMenuItemHandler, // Used for injection when testing\n openBrowserAsyncFunc: typeof openBrowserAsync = openBrowserAsync // Used for injection when testing\n): MenuItemWithSubmenu[] => {\n return plugins\n .map((plugin) => {\n const commands = getCliExtensionCommands(plugin);\n if (commands.length > 0 && plugin.webpageEndpoint) {\n // Custom display/handling for plugins that support both web and CLI commands\n const children = [\n devtoolFactory(plugin, defaultServerUrl, openBrowserAsyncFunc),\n ...commands.map((descriptor) => ({\n title: descriptor.title,\n value: descriptor.name,\n action: async () =>\n await cliExtensionMenuItemHandlerFunc(plugin, descriptor, metroServerOrigin),\n })),\n ].filter((item) => item != null);\n return {\n title: chalk`{bold ${plugin.packageName}}`,\n value: '',\n children,\n action: async () => {\n try {\n const value = await selectAsync(chalk`{dim Select command}`, children);\n await children.find((item) => item.value === value)?.action?.();\n } catch (error: any) {\n // Handle aborting prompt\n debug(`Aborted selection prompt by user: ${error.toString()}`);\n }\n },\n };\n } else if (plugin.webpageEndpoint) {\n return devtoolFactory(plugin, defaultServerUrl);\n } else if (plugin.cliExtensions && commands.length > 0) {\n return cliExtensionFactory(plugin, metroServerOrigin);\n }\n return null;\n })\n .filter((menuItem) => menuItem != null);\n};\n\nconst devtoolFactory = (\n plugin: DevToolsPlugin,\n defaultServerUrl: string,\n openBrowserAsyncFunc: typeof openBrowserAsync = openBrowserAsync // Used for injection when testing\n): MoreToolMenuItem | null => {\n if (plugin.webpageEndpoint == null) {\n return null;\n }\n\n return {\n title: chalk`Open {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(plugin.webpageEndpoint!, defaultServerUrl);\n await openBrowserAsyncFunc(url.toString());\n },\n };\n};\n\nconst getCliExtensionCommands = (plugin: DevToolsPlugin): DevToolsPluginCommand[] => {\n const cliExtensionsConfig = plugin.cliExtensions;\n const commands = (cliExtensionsConfig?.commands ?? []).filter((p) =>\n p.environments?.includes('cli')\n );\n\n if (cliExtensionsConfig == null || commands.length === 0) {\n return [];\n }\n return commands;\n};\n\nconst cliExtensionFactory = (\n plugin: DevToolsPlugin,\n metroServerOrigin: string,\n cliExtensionMenuItemHandlerFunc: CliExtensionMenuItemHandler = cliExtensionMenuItemHandler // Used for injection when testing\n): MenuItemWithSubmenu | null => {\n const commands = getCliExtensionCommands(plugin);\n const children = commands.map((cmd) => ({\n title: cmd.title,\n value: cmd.name,\n }));\n\n return {\n title: chalk`{bold ${plugin.packageName}}`,\n value: `cliExtension:${plugin.packageName}`,\n children,\n action: async () => {\n try {\n const value = await selectAsync(chalk`{dim Select command}`, children);\n const cmd = commands.find((c) => c.name === value);\n if (cmd == null) {\n Log.warn(`No command found for ${plugin.packageName}`);\n } else {\n await cliExtensionMenuItemHandlerFunc(plugin, cmd, metroServerOrigin);\n }\n } catch (error: any) {\n // Handle aborting prompt\n debug(`Failed to execute command: ${error.toString()}`);\n }\n },\n };\n};\n"],"names":["createDevToolsMenuItems","debug","require","plugins","defaultServerUrl","metroServerOrigin","cliExtensionMenuItemHandlerFunc","cliExtensionMenuItemHandler","openBrowserAsyncFunc","openBrowserAsync","map","plugin","commands","getCliExtensionCommands","length","webpageEndpoint","children","devtoolFactory","descriptor","title","value","name","action","filter","item","chalk","packageName","selectAsync","find","error","toString","cliExtensions","cliExtensionFactory","menuItem","url","URL","cliExtensionsConfig","p","environments","includes","cmd","c","Log","warn"],"mappings":";;;;+BAmCaA;;;eAAAA;;;;gEAnCK;;;;;;6CAE0B;6DACvB;sBACY;yBAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI5B,MAAMC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,MAAMF,QAAQ,MAAMO,IAAAA,oBAAW,EAACF,IAAAA,gBAAK,CAAA,CAAC,oBAAoB,CAAC,EAAET;gBAC7D,MAAMwB,MAAM5B,SAASgB,IAAI,CAAC,CAACa,IAAMA,EAAEpB,IAAI,KAAKD;gBAC5C,IAAIoB,OAAO,MAAM;oBACfE,KAAIC,IAAI,CAAC,CAAC,qBAAqB,EAAEhC,OAAOe,WAAW,EAAE;gBACvD,OAAO;oBACL,MAAMpB,gCAAgCK,QAAQ6B,KAAKnC;gBACrD;YACF,EAAE,OAAOwB,OAAY;gBACnB,yBAAyB;gBACzB5B,MAAM,CAAC,2BAA2B,EAAE4B,MAAMC,QAAQ,IAAI;YACxD;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport type { StartOptions } from './commandsTable';\nimport { BLT, printHelp, printItem, printUsage } from './commandsTable';\nimport { createDevToolsMenuItems } from './createDevToolsMenuItems';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { learnMore } from '../../utils/link';\nimport type { ExpoChoice } from '../../utils/prompts';\nimport { selectAsync } from '../../utils/prompts';\nimport { printQRCode } from '../../utils/qr';\nimport { getDependencyCheckMessage } from '../checkDependenciesOnStart';\nimport type { DevServerManager } from '../server/DevServerManager';\nimport type { DevToolsPlugin } from '../server/DevToolsPlugin';\nimport {\n openJsInspector,\n queryAllInspectorAppsAsync,\n promptInspectorAppAsync,\n} from '../server/middleware/inspector/JsInspector';\n\nconst debug = require('debug')('expo:start:interface:interactiveActions') as typeof console.log;\n\ninterface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\nexport function getDevToolsPluginCliBannerItems(\n plugins: DevToolsPlugin[],\n defaultServerUrl: string\n): { title: string; url: string }[] {\n return plugins\n .filter((plugin) => plugin.cliBanner && plugin.webpageEndpoint != null)\n .map((plugin) => ({\n title: plugin.bannerTitle,\n url: new URL(plugin.webpageEndpoint!, defaultServerUrl).toString(),\n }));\n}\n\nexport async function printDevToolsPluginCliBannersAsync(\n devServerManager: DevServerManager\n): Promise<number> {\n if (!devServerManager.getNativeDevServerPort()) {\n return 0;\n }\n\n try {\n const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();\n const bannerItems = getDevToolsPluginCliBannerItems(\n plugins,\n devServerManager.getDefaultDevServer().getUrlCreator().constructUrl({ scheme: 'http' })\n );\n\n for (const { title, url } of bannerItems) {\n Log.log(printItem(chalk`${title}: {underline ${url}}`));\n }\n\n return bannerItems.length;\n } catch (error: any) {\n debug(`Failed to print DevTools plugin CLI banners: ${error.toString()}`);\n return 0;\n }\n}\n\n/** Wraps the DevServerManager and adds an interface for user actions. */\nexport class DevServerManagerActions {\n constructor(\n private devServerManager: DevServerManager,\n private options: Pick<StartOptions, 'devClient' | 'platforms'>\n ) {}\n\n async printDevServerInfoAsync(\n options: Pick<\n StartOptions,\n 'devClient' | 'isWebSocketsEnabled' | 'platforms' | 'dependencyCheckRef'\n >\n ) {\n // Keep track of approximately how much space we have to print our usage guide\n let rows = process.stdout.rows || Infinity;\n\n // If native dev server is running, print its URL.\n if (this.devServerManager.getNativeDevServerPort()) {\n const devServer = this.devServerManager.getDefaultDevServer();\n try {\n const nativeRuntimeUrl = devServer.getNativeRuntimeUrl()!;\n const interstitialPageUrl = devServer.getRedirectUrl();\n\n // Print the URL to stdout for tests\n if (env.__EXPO_E2E_TEST) {\n console.info(\n `[__EXPO_E2E_TEST:server] ${JSON.stringify({ url: devServer.getDevServerUrl() })}`\n );\n rows--;\n }\n\n if (!env.EXPO_NO_QR_CODE) {\n const qr = printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n rows -= qr.lines;\n qr.print();\n\n let qrMessage = '';\n if (!options.devClient) {\n qrMessage = `Scan the QR code above to open in ${chalk`{bold Expo Go}`}.`;\n } else {\n qrMessage = chalk`Scan the QR code above to open in a {bold development build}.`;\n qrMessage += ` (${learnMore('https://expo.fyi/start')})`;\n }\n rows--;\n Log.log(printItem(qrMessage, { dim: true }));\n }\n\n if (interstitialPageUrl) {\n rows--;\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n\n rows--;\n Log.log(printItem(chalk`Metro: {underline ${nativeRuntimeUrl}}`));\n } catch (error) {\n console.log('err', error);\n // @ts-ignore: If there is no development build scheme, then skip the QR code.\n if (error.code !== 'NO_DEV_CLIENT_SCHEME') {\n throw error;\n } else {\n const serverUrl = devServer.getDevServerUrl();\n Log.log(printItem(chalk`Metro: {underline ${serverUrl}}`));\n rows--;\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\n rows--;\n }\n }\n }\n\n if (this.options.platforms?.includes('web')) {\n const webDevServer = this.devServerManager.getWebDevServer();\n const webUrl = webDevServer?.getDevServerUrl({ hostType: 'localhost' });\n if (webUrl) {\n Log.log(printItem(chalk`Web: {underline ${webUrl}}`));\n rows--;\n }\n }\n\n rows -= await printDevToolsPluginCliBannersAsync(this.devServerManager);\n\n const dependencyCheckLines = getDependencyCheckMessage(options.dependencyCheckRef?.result);\n rows -= dependencyCheckLines.length;\n\n printUsage(options, { verbose: false, rows });\n printHelp();\n Log.log();\n\n for (const line of dependencyCheckLines) {\n Log.log(line);\n }\n }\n\n async openJsInspectorAsync() {\n try {\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n if (!apps.length) {\n return Log.warn(\n chalk`{bold Debug:} No compatible apps connected, React Native DevTools can only be used with Hermes. ${learnMore(\n 'https://docs.expo.dev/guides/using-hermes/'\n )}`\n );\n }\n\n const app = await promptInspectorAppAsync(apps);\n if (!app) {\n return Log.error(chalk`{bold Debug:} No inspectable device selected`);\n }\n\n if (!(await openJsInspector(metroServerOrigin, app))) {\n Log.warn(\n chalk`{bold Debug:} Failed to open the React Native DevTools, see debug logs for more info.`\n );\n }\n } catch (error: any) {\n // Handle aborting prompt\n if (error.code === 'ABORTED') return;\n\n Log.error('Failed to open the React Native DevTools.');\n Log.exception(error);\n }\n }\n\n reloadApp() {\n Log.log(`${BLT} Reloading apps`);\n // Send reload requests over the dev servers\n this.devServerManager.broadcastMessage('reload');\n }\n\n async openMoreToolsAsync() {\n // Options match: Chrome > View > Developer\n try {\n const defaultMenuItems: MoreToolMenuItem[] = [\n { title: 'Inspect elements', value: 'toggleElementInspector' },\n { title: 'Toggle performance monitor', value: 'togglePerformanceMonitor' },\n { title: 'Toggle developer menu', value: 'toggleDevMenu' },\n { title: 'Reload app', value: 'reload' },\n // TODO: Maybe a \"View Source\" option to open code.\n ];\n\n const defaultServerUrl = this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' });\n\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const plugins = await this.devServerManager.devtoolsPluginManager.queryPluginsAsync();\n\n const menuItems = [\n ...defaultMenuItems,\n ...createDevToolsMenuItems(plugins, defaultServerUrl, metroServerOrigin),\n ];\n\n const value = await selectAsync(chalk`Dev tools {dim (native only)}`, menuItems);\n const menuItem = menuItems.find((item) => item.value === value);\n if (menuItem?.action) {\n menuItem.action();\n } else if (menuItem?.value) {\n this.devServerManager.broadcastMessage('sendDevCommand', { name: menuItem.value });\n }\n } catch (error: any) {\n debug(error);\n // do nothing\n } finally {\n printHelp();\n }\n }\n\n toggleDevMenu() {\n Log.log(`${BLT} Toggling dev menu`);\n this.devServerManager.broadcastMessage('devMenu');\n }\n}\n"],"names":["DevServerManagerActions","getDevToolsPluginCliBannerItems","printDevToolsPluginCliBannersAsync","debug","require","plugins","defaultServerUrl","filter","plugin","cliBanner","webpageEndpoint","map","title","bannerTitle","url","URL","toString","devServerManager","getNativeDevServerPort","devtoolsPluginManager","queryPluginsAsync","bannerItems","getDefaultDevServer","getUrlCreator","constructUrl","scheme","Log","log","printItem","chalk","length","error","options","printDevServerInfoAsync","rows","process","stdout","Infinity","devServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","env","__EXPO_E2E_TEST","console","info","JSON","stringify","getDevServerUrl","EXPO_NO_QR_CODE","qr","printQRCode","lines","print","qrMessage","devClient","learnMore","dim","code","serverUrl","platforms","includes","webDevServer","getWebDevServer","webUrl","hostType","dependencyCheckLines","getDependencyCheckMessage","dependencyCheckRef","result","printUsage","verbose","printHelp","line","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","warn","app","promptInspectorAppAsync","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","value","menuItems","createDevToolsMenuItems","selectAsync","menuItem","find","item","action","name","toggleDevMenu"],"mappings":";;;;;;;;;;;QAgEaA;eAAAA;;QAtCGC;eAAAA;;QAYMC;eAAAA;;;;gEAtCJ;;;;;;+BAGoC;yCACd;6DACnB;qBACD;sBACM;yBAEE;oBACA;0CACc;6BAOnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAMxB,SAASH,gCACdI,OAAyB,EACzBC,gBAAwB;IAExB,OAAOD,QACJE,MAAM,CAAC,CAACC,SAAWA,OAAOC,SAAS,IAAID,OAAOE,eAAe,IAAI,MACjEC,GAAG,CAAC,CAACH,SAAY,CAAA;YAChBI,OAAOJ,OAAOK,WAAW;YACzBC,KAAK,IAAIC,IAAIP,OAAOE,eAAe,EAAGJ,kBAAkBU,QAAQ;QAClE,CAAA;AACJ;AAEO,eAAed,mCACpBe,gBAAkC;IAElC,IAAI,CAACA,iBAAiBC,sBAAsB,IAAI;QAC9C,OAAO;IACT;IAEA,IAAI;QACF,MAAMb,UAAU,MAAMY,iBAAiBE,qBAAqB,CAACC,iBAAiB;QAC9E,MAAMC,cAAcpB,gCAClBI,SACAY,iBAAiBK,mBAAmB,G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AAA,wBAAS;QACX;IACF;IAEA0B,gBAAgB;QACdzE,KAAIC,GAAG,CAAC,GAAG2D,kBAAG,CAAC,kBAAkB,CAAC;QAClC,IAAI,CAACrE,gBAAgB,CAACsE,gBAAgB,CAAC;IACzC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport type { StartOptions } from './commandsTable';\nimport { BLT, printHelp, printItem, printUsage } from './commandsTable';\nimport { createDevToolsMenuItems } from './createDevToolsMenuItems';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { learnMore } from '../../utils/link';\nimport type { ExpoChoice } from '../../utils/prompts';\nimport { selectAsync } from '../../utils/prompts';\nimport { printQRCode } from '../../utils/qr';\nimport { getDependencyCheckMessage } from '../checkDependenciesOnStart';\nimport type { DevServerManager } from '../server/DevServerManager';\nimport type { DevToolsPlugin } from '../server/devtools/DevToolsPlugin';\nimport {\n openJsInspector,\n queryAllInspectorAppsAsync,\n promptInspectorAppAsync,\n} from '../server/middleware/inspector/JsInspector';\n\nconst debug = require('debug')('expo:start:interface:interactiveActions') as typeof console.log;\n\ninterface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\nexport function getDevToolsPluginCliBannerItems(\n plugins: DevToolsPlugin[],\n defaultServerUrl: string\n): { title: string; url: string }[] {\n return plugins\n .filter((plugin) => plugin.cliBanner && plugin.webpageEndpoint != null)\n .map((plugin) => ({\n title: plugin.bannerTitle,\n url: new URL(plugin.webpageEndpoint!, defaultServerUrl).toString(),\n }));\n}\n\nexport async function printDevToolsPluginCliBannersAsync(\n devServerManager: DevServerManager\n): Promise<number> {\n if (!devServerManager.getNativeDevServerPort()) {\n return 0;\n }\n\n try {\n const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();\n const bannerItems = getDevToolsPluginCliBannerItems(\n plugins,\n devServerManager.getDefaultDevServer().getUrlCreator().constructUrl({ scheme: 'http' })\n );\n\n for (const { title, url } of bannerItems) {\n Log.log(printItem(chalk`${title}: {underline ${url}}`));\n }\n\n return bannerItems.length;\n } catch (error: any) {\n debug(`Failed to print DevTools plugin CLI banners: ${error.toString()}`);\n return 0;\n }\n}\n\n/** Wraps the DevServerManager and adds an interface for user actions. */\nexport class DevServerManagerActions {\n constructor(\n private devServerManager: DevServerManager,\n private options: Pick<StartOptions, 'devClient' | 'platforms'>\n ) {}\n\n async printDevServerInfoAsync(\n options: Pick<\n StartOptions,\n 'devClient' | 'isWebSocketsEnabled' | 'platforms' | 'dependencyCheckRef'\n >\n ) {\n // Keep track of approximately how much space we have to print our usage guide\n let rows = process.stdout.rows || Infinity;\n\n // If native dev server is running, print its URL.\n if (this.devServerManager.getNativeDevServerPort()) {\n const devServer = this.devServerManager.getDefaultDevServer();\n try {\n const nativeRuntimeUrl = devServer.getNativeRuntimeUrl()!;\n const interstitialPageUrl = devServer.getRedirectUrl();\n\n // Print the URL to stdout for tests\n if (env.__EXPO_E2E_TEST) {\n console.info(\n `[__EXPO_E2E_TEST:server] ${JSON.stringify({ url: devServer.getDevServerUrl() })}`\n );\n rows--;\n }\n\n if (!env.EXPO_NO_QR_CODE) {\n const qr = printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n rows -= qr.lines;\n qr.print();\n\n let qrMessage = '';\n if (!options.devClient) {\n qrMessage = `Scan the QR code above to open in ${chalk`{bold Expo Go}`}.`;\n } else {\n qrMessage = chalk`Scan the QR code above to open in a {bold development build}.`;\n qrMessage += ` (${learnMore('https://expo.fyi/start')})`;\n }\n rows--;\n Log.log(printItem(qrMessage, { dim: true }));\n }\n\n if (interstitialPageUrl) {\n rows--;\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n\n rows--;\n Log.log(printItem(chalk`Metro: {underline ${nativeRuntimeUrl}}`));\n } catch (error) {\n console.log('err', error);\n // @ts-ignore: If there is no development build scheme, then skip the QR code.\n if (error.code !== 'NO_DEV_CLIENT_SCHEME') {\n throw error;\n } else {\n const serverUrl = devServer.getDevServerUrl();\n Log.log(printItem(chalk`Metro: {underline ${serverUrl}}`));\n rows--;\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\n rows--;\n }\n }\n }\n\n if (this.options.platforms?.includes('web')) {\n const webDevServer = this.devServerManager.getWebDevServer();\n const webUrl = webDevServer?.getDevServerUrl({ hostType: 'localhost' });\n if (webUrl) {\n Log.log(printItem(chalk`Web: {underline ${webUrl}}`));\n rows--;\n }\n }\n\n rows -= await printDevToolsPluginCliBannersAsync(this.devServerManager);\n\n const dependencyCheckLines = getDependencyCheckMessage(options.dependencyCheckRef?.result);\n rows -= dependencyCheckLines.length;\n\n printUsage(options, { verbose: false, rows });\n printHelp();\n Log.log();\n\n for (const line of dependencyCheckLines) {\n Log.log(line);\n }\n }\n\n async openJsInspectorAsync() {\n try {\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n if (!apps.length) {\n return Log.warn(\n chalk`{bold Debug:} No compatible apps connected, React Native DevTools can only be used with Hermes. ${learnMore(\n 'https://docs.expo.dev/guides/using-hermes/'\n )}`\n );\n }\n\n const app = await promptInspectorAppAsync(apps);\n if (!app) {\n return Log.error(chalk`{bold Debug:} No inspectable device selected`);\n }\n\n if (!(await openJsInspector(metroServerOrigin, app))) {\n Log.warn(\n chalk`{bold Debug:} Failed to open the React Native DevTools, see debug logs for more info.`\n );\n }\n } catch (error: any) {\n // Handle aborting prompt\n if (error.code === 'ABORTED') return;\n\n Log.error('Failed to open the React Native DevTools.');\n Log.exception(error);\n }\n }\n\n reloadApp() {\n Log.log(`${BLT} Reloading apps`);\n // Send reload requests over the dev servers\n this.devServerManager.broadcastMessage('reload');\n }\n\n async openMoreToolsAsync() {\n // Options match: Chrome > View > Developer\n try {\n const defaultMenuItems: MoreToolMenuItem[] = [\n { title: 'Inspect elements', value: 'toggleElementInspector' },\n { title: 'Toggle performance monitor', value: 'togglePerformanceMonitor' },\n { title: 'Toggle developer menu', value: 'toggleDevMenu' },\n { title: 'Reload app', value: 'reload' },\n // TODO: Maybe a \"View Source\" option to open code.\n ];\n\n const defaultServerUrl = this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' });\n\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const plugins = await this.devServerManager.devtoolsPluginManager.queryPluginsAsync();\n\n const menuItems = [\n ...defaultMenuItems,\n ...createDevToolsMenuItems(plugins, defaultServerUrl, metroServerOrigin),\n ];\n\n const value = await selectAsync(chalk`Dev tools {dim (native only)}`, menuItems);\n const menuItem = menuItems.find((item) => item.value === value);\n if (menuItem?.action) {\n menuItem.action();\n } else if (menuItem?.value) {\n this.devServerManager.broadcastMessage('sendDevCommand', { name: menuItem.value });\n }\n } catch (error: any) {\n debug(error);\n // do nothing\n } finally {\n printHelp();\n }\n }\n\n toggleDevMenu() {\n Log.log(`${BLT} Toggling dev menu`);\n this.devServerManager.broadcastMessage('devMenu');\n }\n}\n"],"names":["DevServerManagerActions","getDevToolsPluginCliBannerItems","printDevToolsPluginCliBannersAsync","debug","require","plugins","defaultServerUrl","filter","plugin","cliBanner","webpageEndpoint","map","title","bannerTitle","url","URL","toString","devServerManager","getNativeDevServerPort","devtoolsPluginManager","queryPluginsAsync","bannerItems","getDefaultDevServer","getUrlCreator","constructUrl","scheme","Log","log","printItem","chalk","length","error","options","printDevServerInfoAsync","rows","process","stdout","Infinity","devServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","env","__EXPO_E2E_TEST","console","info","JSON","stringify","getDevServerUrl","EXPO_NO_QR_CODE","qr","printQRCode","lines","print","qrMessage","devClient","learnMore","dim","code","serverUrl","platforms","includes","webDevServer","getWebDevServer","webUrl","hostType","dependencyCheckLines","getDependencyCheckMessage","dependencyCheckRef","result","printUsage","verbose","printHelp","line","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","warn","app","promptInspectorAppAsync","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","value","menuItems","createDevToolsMenuItems","selectAsync","menuItem","find","item","action","name","toggleDevMenu"],"mappings":";;;;;;;;;;;QAgEaA;eAAAA;;QAtCGC;eAAAA;;QAYMC;eAAAA;;;;gEAtCJ;;;;;;+BAGoC;yCACd;6DACnB;qBACD;sBACM;yBAEE;oBACA;0CACc;6BAOnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAMxB,SAASH,gCACdI,OAAyB,EACzBC,gBAAwB;IAExB,OAAOD,QACJE,MAAM,CAAC,CAACC,SAAWA,OAAOC,SAAS,IAAID,OAAOE,eAAe,IAAI,MACjEC,GAAG,CAAC,CAACH,SAAY,CAAA;YAChBI,OAAOJ,OAAOK,WAAW;YACzBC,KAAK,IAAIC,IAAIP,OAAOE,eAAe,EAAGJ,kBAAkBU,QAAQ;QAClE,CAAA;AACJ;AAEO,eAAed,mCACpBe,gBAAkC;IAElC,IAAI,CAACA,iBAAiBC,sBAAsB,IAAI;QAC9C,OAAO;IACT;IAEA,IAAI;QACF,MAAMb,UAAU,MAAMY,iBAAiBE,qBAAqB,CAACC,iBAAiB;QAC9E,MAAMC,cAAcpB,gCAClBI,SACAY,iBAAiBK,mBAAmB,GAAGC,aAAa,GAAGC,YAAY,CAAC;YAAEC,QAAQ;QAAO;QAGvF,KAAK,MAAM,EAAEb,KAAK,EAAEE,GAAG,EAAE,IAAIO,YAAa;YACxCK,KAAIC,GAAG,CAACC,IAAAA,wBAAS,EAACC,IAAAA,gBAAK,CAAA,CAAC,EAAEjB,MAAM,aAAa,EAAEE,IAAI,CAAC,CAAC;QACvD;QAEA,OAAOO,YAAYS,MAAM;IAC3B,EAAE,OAAOC,OAAY;QACnB5B,MA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AA8B8E,OAAO;gBAA2B;gBACzE;oBAAE9E,OAAO;oBAAyB8E,OAAO;gBAAgB;gBACzD;oBAAE9E,OAAO;oBAAc8E,OAAO;gBAAS;aAExC;YAED,MAAMpF,mBAAmB,IAAI,CAACW,gBAAgB,CAC3CK,mBAAmB,GACnBC,aAAa,GACbC,YAAY,CAAC;gBAAEC,QAAQ;YAAO;YAEjC,MAAMmD,oBAAoB,IAAI,CAAC3D,gBAAgB,CAACK,mBAAmB,GAAGuD,qBAAqB;YAC3F,MAAMxE,UAAU,MAAM,IAAI,CAACY,gBAAgB,CAACE,qBAAqB,CAACC,iBAAiB;YAEnF,MAAMuE,YAAY;mBACbF;mBACAG,IAAAA,gDAAuB,EAACvF,SAASC,kBAAkBsE;aACvD;YAED,MAAMc,QAAQ,MAAMG,IAAAA,oBAAW,EAAChE,IAAAA,gBAAK,CAAA,CAAC,6BAA6B,CAAC,EAAE8D;YACtE,MAAMG,WAAWH,UAAUI,IAAI,CAAC,CAACC,OAASA,KAAKN,KAAK,KAAKA;YACzD,IAAII,4BAAAA,SAAUG,MAAM,EAAE;gBACpBH,SAASG,MAAM;YACjB,OAAO,IAAIH,4BAAAA,SAAUJ,KAAK,EAAE;gBAC1B,IAAI,CAACzE,gBAAgB,CAACsE,gBAAgB,CAAC,kBAAkB;oBAAEW,MAAMJ,SAASJ,KAAK;gBAAC;YAClF;QACF,EAAE,OAAO3D,OAAY;YACnB5B,MAAM4B;QACN,aAAa;QACf,SAAU;YACR0C,IAAAA,wBAAS;QACX;IACF;IAEA0B,gBAAgB;QACdzE,KAAIC,GAAG,CAAC,GAAG2D,kBAAG,CAAC,kBAAkB,CAAC;QAClC,IAAI,CAACrE,gBAAgB,CAACsE,gBAAgB,CAAC;IACzC;AACF"}
|
|
@@ -261,7 +261,6 @@ async function installAppWithDeviceCtlInternalAsync(uuid, bundleIdOrAppPath, onP
|
|
|
261
261
|
const statusPrefix = attempt > 1 ? `Installing (attempt ${attempt})` : 'Installing';
|
|
262
262
|
onProgress({
|
|
263
263
|
progress,
|
|
264
|
-
isComplete: progress === 100,
|
|
265
264
|
status: statusPrefix
|
|
266
265
|
});
|
|
267
266
|
}
|
|
@@ -360,15 +359,13 @@ async function installAndLaunchAppAsync(props) {
|
|
|
360
359
|
if (!indicator) {
|
|
361
360
|
indicator = (0, _ora.ora)(`Connecting to: ${props.deviceName}`).start();
|
|
362
361
|
}
|
|
363
|
-
await installAppWithDeviceCtlAsync(udid, bundle, ({ status,
|
|
362
|
+
await installAppWithDeviceCtlAsync(udid, bundle, ({ status, progress })=>{
|
|
364
363
|
if (!indicator) {
|
|
365
364
|
indicator = (0, _ora.ora)(status).start();
|
|
366
365
|
}
|
|
367
366
|
indicator.text = `${_chalk().default.bold(status)} ${progress}%`;
|
|
368
|
-
if (isComplete) {
|
|
369
|
-
indicator.succeed();
|
|
370
|
-
}
|
|
371
367
|
});
|
|
368
|
+
indicator.succeed(`Installed on ${deviceName}`);
|
|
372
369
|
} catch (error) {
|
|
373
370
|
if (indicator) {
|
|
374
371
|
indicator.fail();
|