@expo/cli 54.0.10 → 54.1.0-canary-20251003-7b9d7ff
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/run/ios/runIosAsync.js +0 -8
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/interface/cliExtensionMenuItemHandler.js +173 -0
- package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +1 -0
- package/build/src/start/interface/createDevToolsMenuItems.js +159 -0
- package/build/src/start/interface/createDevToolsMenuItems.js.map +1 -0
- package/build/src/start/interface/interactiveActions.js +8 -12
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +1 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/server/DevToolsPlugin.js +60 -0
- package/build/src/start/server/DevToolsPlugin.js.map +1 -0
- package/build/src/start/server/DevToolsPlugin.schema.js +79 -0
- package/build/src/start/server/DevToolsPlugin.schema.js.map +1 -0
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js +119 -0
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +1 -0
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js +61 -0
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +1 -0
- package/build/src/start/server/DevToolsPluginManager.js +4 -8
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +125 -9
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +2 -2
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/DataLoaderModuleMiddleware.js +75 -0
- package/build/src/start/server/middleware/DataLoaderModuleMiddleware.js.map +1 -0
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +20 -20
package/build/bin/cli
CHANGED
|
@@ -123,7 +123,7 @@ const args = (0, _arg().default)({
|
|
|
123
123
|
});
|
|
124
124
|
if (args['--version']) {
|
|
125
125
|
// Version is added in the build script.
|
|
126
|
-
console.log("54.0
|
|
126
|
+
console.log("54.1.0-canary-20251003-7b9d7ff");
|
|
127
127
|
process.exit(0);
|
|
128
128
|
}
|
|
129
129
|
if (args['--non-interactive']) {
|
|
@@ -8,13 +8,6 @@ Object.defineProperty(exports, "runIosAsync", {
|
|
|
8
8
|
return runIosAsync;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
function _config() {
|
|
12
|
-
const data = require("@expo/config");
|
|
13
|
-
_config = function() {
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
11
|
function _spawnasync() {
|
|
19
12
|
const data = /*#__PURE__*/ _interop_require_default(require("@expo/spawn-async"));
|
|
20
13
|
_spawnasync = function() {
|
|
@@ -122,7 +115,6 @@ async function runIosAsync(projectRoot, options) {
|
|
|
122
115
|
}
|
|
123
116
|
// Resolve the CLI arguments into useable options.
|
|
124
117
|
const props = await (0, _profile.profile)(_resolveOptions.resolveOptionsAsync)(projectRoot, options);
|
|
125
|
-
const projectConfig = (0, _config().getConfig)(projectRoot);
|
|
126
118
|
// We only support build cache for simulator builds for now.
|
|
127
119
|
if (!options.binary && props.buildCacheProvider && props.isSimulator) {
|
|
128
120
|
const localPath = await (0, _buildcacheproviders.resolveBuildCache)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/run/ios/runIosAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport { 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 } 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 require('@expo/env').load(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 const projectConfig = getConfig(projectRoot);\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 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 debug('Binary path:', binaryPath);\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"],"names":["runIosAsync","debug","require","projectRoot","options","setNodeEnv","configuration","load","assertPlatform","install","ensureNativeProjectAsync","platform","maybePromptToSyncPodsAsync","props","profile","resolveOptionsAsync","projectConfig","getConfig","binary","buildCacheProvider","isSimulator","localPath","resolveBuildCache","runOptions","provider","rebundle","Log","warn","binaryPath","Error","appId","AppleAppIdResolver","getAppIdAsync","possibleBinaryPath","getContainerPathAsync","device","CommandError","log","spawnAsync","path","join","resolve","possibleBundleOutput","fs","existsSync","exportEagerAsync","resetCache","dev","assetsDest","bundleOutput","shouldUpdateBuildCache","getValidBinaryPathAsync","eagerBundleOptions","JSON","stringify","buildOutput","XcodeBuild","buildAsync","getAppBinaryPath","shouldStartBundler","ensurePortAvailabilityAsync","launchInfo","getLaunchInfoForBinaryAsync","isCustomBinary","simctlAsync","udid","bundleId","error","manager","startBundlerAsync","port","headless","scheme","schemes","getSchemesForIosAsync","launchAppAsync","logProjectLogsLocation","stopAsync","uploadBuildCache","buildPath","process","exit","chalk"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;;yBA5BI;;;;;;;gEACH;;;;;;;gEACL;;;;;;;gEACH;;;;;;;gEACE;;;;;;oEAEW;2BAEgC;gCACxB;wCACI;6BACP;6DACZ;oCACc;wBACgB;qCACC;2BACT;wBACd;yBACF;sBACiB;yBACpB;wBACc;qCACG;uBACF;8BACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,YAAYG,WAAmB,EAAEC,OAAgB;QA6I9D;IA5IPC,IAAAA,mBAAU,EAACD,QAAQE,aAAa,KAAK,YAAY,eAAe;IAChEJ,QAAQ,aAAaK,IAAI,CAACJ;IAE1BK;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,MAAMY,gBAAgBC,IAAAA,mBAAS,EAACd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,MAAM,CAAC8B,IAAI;gBAAEJ,WAAWK,QAAQ;aAAC;QACzE,EAAE,OAAOC,OAAO;YACd,gHAAgH;YAChHlE,MAAM,kEAAkEkE;QAC1E;IACF;IAEA,kEAAkE;IAClE,oCAAoC;IACpC,MAAMC,UAAU,MAAMC,IAAAA,+BAAiB,EAAClE,aAAa;QACnDmE,MAAMzD,MAAMyD,IAAI;QAChBC,UAAU,CAAC1D,MAAM8C,kBAAkB;QACnC,sEAAsE;QAEtEa,QAAQT,iBAEJF,WAAWY,OAAO,CAAC,EAAE,IAEpB,QAAA,MAAMC,IAAAA,6BAAqB,EAACvE,iCAA7B,AAAC,KAA2C,CAAC,EAAE;IACrD;IAEA,iDAAiD;IACjD,MAAMwE,IAAAA,yBAAc,EAClB/C,YACAwC,SACA;QACEhD,aAAaP,MAAMO,WAAW;QAC9Be,QAAQtB,MAAMsB,MAAM;QACpBwB,oBAAoB9C,MAAM8C,kBAAkB;IAC9C,GACAE,WAAWK,QAAQ;IAGrB,kDAAkD;IAClD,IAAIrD,MAAM8C,kBAAkB,EAAE;QAC5BiB,IAAAA,6BAAsB;IACxB,OAAO;QACL,MAAMR,QAAQS,SAAS;IACzB;IAEA,IAAI3B,0BAA0BrC,MAAMM,kBAAkB,EAAE;QACtD,MAAM2D,IAAAA,qCAAgB,EAAC;YACrB3E;YACAQ,UAAU;YACVa,UAAUX,MAAMM,kBAAkB;YAClC4D,WAAWnD;YACXL,YAAYnB;QACd;IACF;AACF;AAEA,SAASI;IACP,IAAIwE,QAAQrE,QAAQ,KAAK,UAAU;QACjCe,KAAIuD,IAAI,CACNC,IAAAA,gBAAK,CAAA,CAAC,+FAA+F,CAAC;IAE1G;AACF"}
|
|
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 { 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 } 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 require('@expo/env').load(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 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 debug('Binary path:', binaryPath);\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"],"names":["runIosAsync","debug","require","projectRoot","options","setNodeEnv","configuration","load","assertPlatform","install","ensureNativeProjectAsync","platform","maybePromptToSyncPodsAsync","props","profile","resolveOptionsAsync","binary","buildCacheProvider","isSimulator","localPath","resolveBuildCache","runOptions","provider","rebundle","Log","warn","binaryPath","Error","appId","AppleAppIdResolver","getAppIdAsync","possibleBinaryPath","getContainerPathAsync","device","CommandError","log","spawnAsync","path","join","resolve","possibleBundleOutput","fs","existsSync","exportEagerAsync","resetCache","dev","assetsDest","bundleOutput","shouldUpdateBuildCache","getValidBinaryPathAsync","eagerBundleOptions","JSON","stringify","buildOutput","XcodeBuild","buildAsync","getAppBinaryPath","shouldStartBundler","ensurePortAvailabilityAsync","launchInfo","getLaunchInfoForBinaryAsync","isCustomBinary","simctlAsync","udid","bundleId","error","manager","startBundlerAsync","port","headless","scheme","schemes","getSchemesForIosAsync","launchAppAsync","logProjectLogsLocation","stopAsync","uploadBuildCache","buildPath","process","exit","chalk"],"mappings":";;;;+BA2BsBA;;;eAAAA;;;;gEA3BC;;;;;;;gEACL;;;;;;;gEACH;;;;;;;gEACE;;;;;;oEAEW;2BAEgC;gCACxB;wCACI;6BACP;6DACZ;oCACc;wBACgB;qCACC;2BACT;wBACd;yBACF;sBACiB;yBACpB;wBACc;qCACG;uBACF;8BACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,YAAYG,WAAmB,EAAEC,OAAgB;QA4I9D;IA3IPC,IAAAA,mBAAU,EAACD,QAAQE,aAAa,KAAK,YAAY,eAAe;IAChEJ,QAAQ,aAAaK,IAAI,CAACJ;IAE1BK;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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;gBAAEJ,WAAWK,QAAQ;aAAC;QACzE,EAAE,OAAOC,OAAO;YACd,gHAAgH;YAChHhE,MAAM,kEAAkEgE;QAC1E;IACF;IAEA,kEAAkE;IAClE,oCAAoC;IACpC,MAAMC,UAAU,MAAMC,IAAAA,+BAAiB,EAAChE,aAAa;QACnDiE,MAAMvD,MAAMuD,IAAI;QAChBC,UAAU,CAACxD,MAAM4C,kBAAkB;QACnC,sEAAsE;QAEtEa,QAAQT,iBAEJF,WAAWY,OAAO,CAAC,EAAE,IAEpB,QAAA,MAAMC,IAAAA,6BAAqB,EAACrE,iCAA7B,AAAC,KAA2C,CAAC,EAAE;IACrD;IAEA,iDAAiD;IACjD,MAAMsE,IAAAA,yBAAc,EAClB/C,YACAwC,SACA;QACEhD,aAAaL,MAAMK,WAAW;QAC9Be,QAAQpB,MAAMoB,MAAM;QACpBwB,oBAAoB5C,MAAM4C,kBAAkB;IAC9C,GACAE,WAAWK,QAAQ;IAGrB,kDAAkD;IAClD,IAAInD,MAAM4C,kBAAkB,EAAE;QAC5BiB,IAAAA,6BAAsB;IACxB,OAAO;QACL,MAAMR,QAAQS,SAAS;IACzB;IAEA,IAAI3B,0BAA0BnC,MAAMI,kBAAkB,EAAE;QACtD,MAAM2D,IAAAA,qCAAgB,EAAC;YACrBzE;YACAQ,UAAU;YACVW,UAAUT,MAAMI,kBAAkB;YAClC4D,WAAWnD;YACXL,YAAYjB;QACd;IACF;AACF;AAEA,SAASI;IACP,IAAIsE,QAAQnE,QAAQ,KAAK,UAAU;QACjCa,KAAIuD,IAAI,CACNC,IAAAA,gBAAK,CAAA,CAAC,+FAA+F,CAAC;IAE1G;AACF"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "cliExtensionMenuItemHandler", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return cliExtensionMenuItemHandler;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _chalk() {
|
|
12
|
+
const data = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
13
|
+
_chalk = function() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../log"));
|
|
19
|
+
const _link = require("../../utils/link");
|
|
20
|
+
const _ora = require("../../utils/ora");
|
|
21
|
+
const _prompts = require("../../utils/prompts");
|
|
22
|
+
function _interop_require_default(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
28
|
+
if (typeof WeakMap !== "function") return null;
|
|
29
|
+
var cacheBabelInterop = new WeakMap();
|
|
30
|
+
var cacheNodeInterop = new WeakMap();
|
|
31
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
32
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
33
|
+
})(nodeInterop);
|
|
34
|
+
}
|
|
35
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
36
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
40
|
+
return {
|
|
41
|
+
default: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
45
|
+
if (cache && cache.has(obj)) {
|
|
46
|
+
return cache.get(obj);
|
|
47
|
+
}
|
|
48
|
+
var newObj = {
|
|
49
|
+
__proto__: null
|
|
50
|
+
};
|
|
51
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
52
|
+
for(var key in obj){
|
|
53
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
54
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
55
|
+
if (desc && (desc.get || desc.set)) {
|
|
56
|
+
Object.defineProperty(newObj, key, desc);
|
|
57
|
+
} else {
|
|
58
|
+
newObj[key] = obj[key];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
newObj.default = obj;
|
|
63
|
+
if (cache) {
|
|
64
|
+
cache.set(obj, newObj);
|
|
65
|
+
}
|
|
66
|
+
return newObj;
|
|
67
|
+
}
|
|
68
|
+
const cliExtensionMenuItemHandler = async (plugin, command, metroServerOrigin)=>{
|
|
69
|
+
const cliExtensionsConfig = plugin.cliExtensions;
|
|
70
|
+
if (cliExtensionsConfig == null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (plugin.executor == null) {
|
|
74
|
+
_log.warn((0, _chalk().default)`{bold ${plugin.packageName}} does not support CLI commands.`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let args = {};
|
|
78
|
+
if (command.parameters && command.parameters.length > 0) {
|
|
79
|
+
args = await command.parameters.reduce(async (accPromise, param)=>{
|
|
80
|
+
const acc = await accPromise;
|
|
81
|
+
const result = await (0, _prompts.promptAsync)({
|
|
82
|
+
name: param.name,
|
|
83
|
+
type: param.type,
|
|
84
|
+
message: `${param.name}${param.description ? (0, _chalk().default)` {dim ${param.description}}` : ''}` + (0, _chalk().default)` {dim (${param.type})}`
|
|
85
|
+
});
|
|
86
|
+
if (result[param.name] == null) {
|
|
87
|
+
throw new Error('Input cancelled');
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
...acc,
|
|
91
|
+
[param.name]: result[param.name]
|
|
92
|
+
};
|
|
93
|
+
}, Promise.resolve({}));
|
|
94
|
+
}
|
|
95
|
+
// Confirm execution
|
|
96
|
+
const { value } = await (0, _prompts.promptAsync)({
|
|
97
|
+
message: (0, _chalk().default)`{dim Execute command "${command.title}":} "${plugin.executor.getCommandString({
|
|
98
|
+
command: command.name,
|
|
99
|
+
args
|
|
100
|
+
})}"`,
|
|
101
|
+
initial: false,
|
|
102
|
+
name: 'value',
|
|
103
|
+
type: 'confirm'
|
|
104
|
+
});
|
|
105
|
+
if (!value) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const spinnerText = `Executing command '${command.title}'`;
|
|
109
|
+
const spinner = (0, _ora.ora)(spinnerText).start();
|
|
110
|
+
try {
|
|
111
|
+
// Execute and stream the output
|
|
112
|
+
const results = await plugin.executor.execute({
|
|
113
|
+
command: command.name,
|
|
114
|
+
metroServerOrigin,
|
|
115
|
+
args,
|
|
116
|
+
onOutput: (output)=>handleOutput(output, spinner)
|
|
117
|
+
});
|
|
118
|
+
// Format with warning or success depending on wether the client reported any errors
|
|
119
|
+
formatResults(command.title, results, spinner);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
spinner.fail(`Failed to execute command "${command.title}".\n${error.toString().trim()}`);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//*************************** Helpers ****************************/
|
|
125
|
+
function normalizeText(text, level) {
|
|
126
|
+
const trimText = text.trim();
|
|
127
|
+
if (level === 'error') {
|
|
128
|
+
return _chalk().default.red(trimText);
|
|
129
|
+
} else if (level === 'warning') {
|
|
130
|
+
return _chalk().default.yellow(trimText);
|
|
131
|
+
} else {
|
|
132
|
+
return trimText;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function appendSpinnerText(text, spinner) {
|
|
136
|
+
return spinner.text += '\n ' + text;
|
|
137
|
+
}
|
|
138
|
+
function handleOutput(output, spinner) {
|
|
139
|
+
output.forEach((line)=>{
|
|
140
|
+
switch(line.type){
|
|
141
|
+
case 'text':
|
|
142
|
+
appendSpinnerText(line.url ? (0, _link.link)(line.url, {
|
|
143
|
+
text: normalizeText(line.text, line.level),
|
|
144
|
+
dim: false
|
|
145
|
+
}) : normalizeText(line.text, line.level), spinner);
|
|
146
|
+
break;
|
|
147
|
+
case 'audio':
|
|
148
|
+
appendSpinnerText((0, _link.link)(line.url, {
|
|
149
|
+
text: line.text ?? 'Audio',
|
|
150
|
+
dim: false
|
|
151
|
+
}), spinner);
|
|
152
|
+
break;
|
|
153
|
+
case 'image':
|
|
154
|
+
appendSpinnerText((0, _link.link)(line.url, {
|
|
155
|
+
text: line.text ?? 'Image',
|
|
156
|
+
dim: false
|
|
157
|
+
}), spinner);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function formatResults(command, results, spinner) {
|
|
163
|
+
const output = spinner.text.split('\n').slice(1).join('\n');
|
|
164
|
+
if (results.find((line)=>line.type === 'text' && line.level === 'error')) {
|
|
165
|
+
spinner.fail(`Command "${command}" completed with errors.\n${output}`);
|
|
166
|
+
} else if (results.find((line)=>line.type === 'text' && line.level === 'warning')) {
|
|
167
|
+
spinner.warn(`Command "${command}" completed with warnings.\n${output}`);
|
|
168
|
+
} else {
|
|
169
|
+
spinner.succeed(`Command "${command}" completed successfully.\n${output}`).stop();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=cliExtensionMenuItemHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/interface/cliExtensionMenuItemHandler.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { 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 { DevToolsPlugin } from '../server/DevToolsPlugin';\nimport { DevToolsPluginCommand, DevToolsPluginOutput } from '../server/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":";;;;+BAsBaA;;;eAAAA;;;;gEAtBK;;;;;;6DAGG;sBACA;qBACD;yBACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBrB,MAAMA,8BAA8B,OACzCC,QACAC,SACAC;IAEA,MAAMC,sBAAsBH,OAAOI,aAAa;IAChD,IAAID,uBAAuB,MAAM;QAC/B;IACF;IAEA,IAAIH,OAAOK,QAAQ,IAAI,MAAM;QAC3BC,KAAIC,IAAI,CAACC,IAAAA,gBAAK,CAAA,CAAC,MAAM,EAAER,OAAOS,WA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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"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createDevToolsMenuItems", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createDevToolsMenuItems;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _chalk() {
|
|
12
|
+
const data = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
13
|
+
_chalk = function() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
const _cliExtensionMenuItemHandler = require("./cliExtensionMenuItemHandler");
|
|
19
|
+
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../log"));
|
|
20
|
+
const _open = require("../../utils/open");
|
|
21
|
+
const _prompts = require("../../utils/prompts");
|
|
22
|
+
function _interop_require_default(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
28
|
+
if (typeof WeakMap !== "function") return null;
|
|
29
|
+
var cacheBabelInterop = new WeakMap();
|
|
30
|
+
var cacheNodeInterop = new WeakMap();
|
|
31
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
32
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
33
|
+
})(nodeInterop);
|
|
34
|
+
}
|
|
35
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
36
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
40
|
+
return {
|
|
41
|
+
default: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
45
|
+
if (cache && cache.has(obj)) {
|
|
46
|
+
return cache.get(obj);
|
|
47
|
+
}
|
|
48
|
+
var newObj = {
|
|
49
|
+
__proto__: null
|
|
50
|
+
};
|
|
51
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
52
|
+
for(var key in obj){
|
|
53
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
54
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
55
|
+
if (desc && (desc.get || desc.set)) {
|
|
56
|
+
Object.defineProperty(newObj, key, desc);
|
|
57
|
+
} else {
|
|
58
|
+
newObj[key] = obj[key];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
newObj.default = obj;
|
|
63
|
+
if (cache) {
|
|
64
|
+
cache.set(obj, newObj);
|
|
65
|
+
}
|
|
66
|
+
return newObj;
|
|
67
|
+
}
|
|
68
|
+
const debug = require('debug')('expo:start:devtools');
|
|
69
|
+
const createDevToolsMenuItems = (plugins, defaultServerUrl, metroServerOrigin, cliExtensionMenuItemHandlerFunc = _cliExtensionMenuItemHandler.cliExtensionMenuItemHandler, openBrowserAsyncFunc = _open // Used for injection when testing
|
|
70
|
+
.openBrowserAsync)=>{
|
|
71
|
+
return plugins.map((plugin)=>{
|
|
72
|
+
const commands = getCliExtensionCommands(plugin);
|
|
73
|
+
if (commands.length > 0 && plugin.webpageEndpoint) {
|
|
74
|
+
// Custom display/handling for plugins that support both web and CLI commands
|
|
75
|
+
const children = [
|
|
76
|
+
devtoolFactory(plugin, defaultServerUrl, openBrowserAsyncFunc),
|
|
77
|
+
...commands.map((descriptor)=>({
|
|
78
|
+
title: descriptor.title,
|
|
79
|
+
value: descriptor.name,
|
|
80
|
+
action: async ()=>await cliExtensionMenuItemHandlerFunc(plugin, descriptor, metroServerOrigin)
|
|
81
|
+
}))
|
|
82
|
+
].filter((item)=>item != null);
|
|
83
|
+
return {
|
|
84
|
+
title: (0, _chalk().default)`{bold ${plugin.packageName}}`,
|
|
85
|
+
value: '',
|
|
86
|
+
children,
|
|
87
|
+
action: async ()=>{
|
|
88
|
+
try {
|
|
89
|
+
var _children_find_action, _children_find;
|
|
90
|
+
const value = await (0, _prompts.selectAsync)((0, _chalk().default)`{dim Select command}`, children);
|
|
91
|
+
await ((_children_find = children.find((item)=>item.value === value)) == null ? void 0 : (_children_find_action = _children_find.action) == null ? void 0 : _children_find_action.call(_children_find));
|
|
92
|
+
} catch (error) {
|
|
93
|
+
// Handle aborting prompt
|
|
94
|
+
debug(`Aborted selection prompt by user: ${error.toString()}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
} else if (plugin.webpageEndpoint) {
|
|
99
|
+
return devtoolFactory(plugin, defaultServerUrl);
|
|
100
|
+
} else if (plugin.cliExtensions && commands.length > 0) {
|
|
101
|
+
return cliExtensionFactory(plugin, metroServerOrigin);
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}).filter((menuItem)=>menuItem != null);
|
|
105
|
+
};
|
|
106
|
+
const devtoolFactory = (plugin, defaultServerUrl, openBrowserAsyncFunc = _open // Used for injection when testing
|
|
107
|
+
.openBrowserAsync)=>{
|
|
108
|
+
if (plugin.webpageEndpoint == null) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
title: (0, _chalk().default)`Open {bold ${plugin.packageName}}`,
|
|
113
|
+
value: `devtoolsPlugin:${plugin.packageName}`,
|
|
114
|
+
action: async ()=>{
|
|
115
|
+
const url = new URL(plugin.webpageEndpoint, defaultServerUrl);
|
|
116
|
+
await openBrowserAsyncFunc(url.toString());
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const getCliExtensionCommands = (plugin)=>{
|
|
121
|
+
const cliExtensionsConfig = plugin.cliExtensions;
|
|
122
|
+
const commands = ((cliExtensionsConfig == null ? void 0 : cliExtensionsConfig.commands) ?? []).filter((p)=>{
|
|
123
|
+
var _p_environments;
|
|
124
|
+
return (_p_environments = p.environments) == null ? void 0 : _p_environments.includes('cli');
|
|
125
|
+
});
|
|
126
|
+
if (cliExtensionsConfig == null || commands.length === 0) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
return commands;
|
|
130
|
+
};
|
|
131
|
+
const cliExtensionFactory = (plugin, metroServerOrigin, cliExtensionMenuItemHandlerFunc = _cliExtensionMenuItemHandler // Used for injection when testing
|
|
132
|
+
.cliExtensionMenuItemHandler)=>{
|
|
133
|
+
const commands = getCliExtensionCommands(plugin);
|
|
134
|
+
const children = commands.map((cmd)=>({
|
|
135
|
+
title: cmd.title,
|
|
136
|
+
value: cmd.name
|
|
137
|
+
}));
|
|
138
|
+
return {
|
|
139
|
+
title: (0, _chalk().default)`{bold ${plugin.packageName}}`,
|
|
140
|
+
value: `cliExtension:${plugin.packageName}`,
|
|
141
|
+
children,
|
|
142
|
+
action: async ()=>{
|
|
143
|
+
try {
|
|
144
|
+
const value = await (0, _prompts.selectAsync)((0, _chalk().default)`{dim Select command}`, children);
|
|
145
|
+
const cmd = commands.find((c)=>c.name === value);
|
|
146
|
+
if (cmd == null) {
|
|
147
|
+
_log.warn(`No command found for ${plugin.packageName}`);
|
|
148
|
+
} else {
|
|
149
|
+
await cliExtensionMenuItemHandlerFunc(plugin, cmd, metroServerOrigin);
|
|
150
|
+
}
|
|
151
|
+
} catch (error) {
|
|
152
|
+
// Handle aborting prompt
|
|
153
|
+
debug(`Failed to execute command: ${error.toString()}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=createDevToolsMenuItems.js.map
|
|
@@ -0,0 +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 { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevToolsPlugin } from '../server/DevToolsPlugin';\nimport { 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":";;;;+BAkCaA;;;eAAAA;;;;gEAlCK;;;;;;6CAE0B;6DACvB;sBACY;yBACO;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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"}
|
|
@@ -16,10 +16,10 @@ function _chalk() {
|
|
|
16
16
|
return data;
|
|
17
17
|
}
|
|
18
18
|
const _commandsTable = require("./commandsTable");
|
|
19
|
+
const _createDevToolsMenuItems = require("./createDevToolsMenuItems");
|
|
19
20
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../log"));
|
|
20
21
|
const _env = require("../../utils/env");
|
|
21
22
|
const _link = require("../../utils/link");
|
|
22
|
-
const _open = require("../../utils/open");
|
|
23
23
|
const _prompts = require("../../utils/prompts");
|
|
24
24
|
const _JsInspector = require("../server/middleware/inspector/JsInspector");
|
|
25
25
|
function _interop_require_default(obj) {
|
|
@@ -174,19 +174,15 @@ class DevServerManagerActions {
|
|
|
174
174
|
value: 'reload'
|
|
175
175
|
}
|
|
176
176
|
];
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}));
|
|
184
|
-
await (0, _open.openBrowserAsync)(url.toString());
|
|
185
|
-
}
|
|
186
|
-
}));
|
|
177
|
+
const defaultServerUrl = this.devServerManager.getDefaultDevServer().getUrlCreator().constructUrl({
|
|
178
|
+
scheme: 'http'
|
|
179
|
+
});
|
|
180
|
+
const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();
|
|
181
|
+
const plugins = await this.devServerManager.devtoolsPluginManager.queryPluginsAsync();
|
|
182
|
+
_log.log();
|
|
187
183
|
const menuItems = [
|
|
188
184
|
...defaultMenuItems,
|
|
189
|
-
...
|
|
185
|
+
...(0, _createDevToolsMenuItems.createDevToolsMenuItems)(plugins, defaultServerUrl, metroServerOrigin)
|
|
190
186
|
];
|
|
191
187
|
const value = await (0, _prompts.selectAsync)((0, _chalk().default)`Dev tools {dim (native only)}`, menuItems);
|
|
192
188
|
const menuItem = menuItems.find((item)=>item.value === value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { BLT, printHelp, printItem, printQRCode, printUsage, StartOptions } from './commandsTable';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { learnMore } from '../../utils/link';\nimport { openBrowserAsync } from '../../utils/open';\nimport { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevServerManager } from '../server/DevServerManager';\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\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 printDevServerInfo(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>\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 printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n\n if (interstitialPageUrl) {\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n\n if (env.__EXPO_E2E_TEST) {\n // Print the URL to stdout for tests\n console.info(\n `[__EXPO_E2E_TEST:server] ${JSON.stringify({ url: devServer.getDevServerUrl() })}`\n );\n }\n\n Log.log(printItem(chalk`Metro waiting on {underline ${nativeRuntimeUrl}}`));\n if (options.devClient === false) {\n // TODO: if development build, change this message!\n Log.log(\n printItem('Scan the QR code above with Expo Go (Android) or the Camera app (iOS)')\n );\n } else {\n Log.log(\n printItem(\n 'Scan the QR code above to open the project in a development build. ' +\n learnMore('https://expo.fyi/start')\n )\n );\n }\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 waiting on {underline ${serverUrl}}`));\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\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();\n Log.log(printItem(chalk`Web is waiting on {underline ${webUrl}}`));\n }\n }\n\n printUsage(options, { verbose: false });\n printHelp();\n Log.log();\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 const pluginMenuItems = (\n await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()\n ).map((plugin) => ({\n title: chalk`Open {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(\n plugin.webpageEndpoint,\n this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' })\n );\n await openBrowserAsync(url.toString());\n },\n }));\n const menuItems = [...defaultMenuItems, ...pluginMenuItems];\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","debug","require","constructor","devServerManager","options","printDevServerInfo","getNativeDevServerPort","devServer","getDefaultDevServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","printQRCode","Log","log","printItem","chalk","env","__EXPO_E2E_TEST","console","info","JSON","stringify","url","getDevServerUrl","devClient","learnMore","error","code","serverUrl","platforms","includes","webDevServer","getWebDevServer","webUrl","hostType","printUsage","verbose","printHelp","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","length","warn","app","promptInspectorAppAsync","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","title","value","pluginMenuItems","devtoolsPluginManager","queryPluginsAsync","map","plugin","packageName","action","URL","webpageEndpoint","getUrlCreator","constructUrl","scheme","openBrowserAsync","toString","menuItems","selectAsync","menuItem","find","item","name","toggleDevMenu"],"mappings":";;;;+BAsBaA;;;eAAAA;;;;gEAtBK;;;;;;+BAE+D;6DAC5D;qBACD;sBACM;sBACO;yBACO;6BAMjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAOxB,MAAMF;IACXG,YACE,AAAQC,gBAAkC,EAC1C,AAAQC,OAAsD,CAC9D;aAFQD,mBAAAA;aACAC,UAAAA;IACP;IAEHC,mBACED,OAA8E,EAC9E;YAoDI;QAnDJ,kDAAkD;QAClD,IAAI,IAAI,CAACD,gBAAgB,CAACG,sBAAsB,IAAI;YAClD,MAAMC,YAAY,IAAI,CAACJ,gBAAgB,CAACK,mBAAmB;YAC3D,IAAI;gBACF,MAAMC,mBAAmBF,UAAUG,mBAAmB;gBACtD,MAAMC,sBAAsBJ,UAAUK,cAAc;gBAEpDC,IAAAA,0BAAW,EAACF,uBAAuBF;gBAEnC,IAAIE,qBAAqB;oBACvBG,KAAIC,GAAG,CACLC,IAAAA,wBAAS,EACPC,IAAAA,gBAAK,CAAA,CAAC,iDAAiD,EAAEN,oBAAoB,CAAC,CAAC;gBAGrF;gBAEA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sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { BLT, printHelp, printItem, printQRCode, printUsage, StartOptions } from './commandsTable';\nimport { createDevToolsMenuItems } from './createDevToolsMenuItems';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { learnMore } from '../../utils/link';\nimport { openBrowserAsync } from '../../utils/open';\nimport { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevServerManager } from '../server/DevServerManager';\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\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 printDevServerInfo(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>\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 printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n\n if (interstitialPageUrl) {\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n\n if (env.__EXPO_E2E_TEST) {\n // Print the URL to stdout for tests\n console.info(\n `[__EXPO_E2E_TEST:server] ${JSON.stringify({ url: devServer.getDevServerUrl() })}`\n );\n }\n\n Log.log(printItem(chalk`Metro waiting on {underline ${nativeRuntimeUrl}}`));\n if (options.devClient === false) {\n // TODO: if development build, change this message!\n Log.log(\n printItem('Scan the QR code above with Expo Go (Android) or the Camera app (iOS)')\n );\n } else {\n Log.log(\n printItem(\n 'Scan the QR code above to open the project in a development build. ' +\n learnMore('https://expo.fyi/start')\n )\n );\n }\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 waiting on {underline ${serverUrl}}`));\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\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();\n Log.log(printItem(chalk`Web is waiting on {underline ${webUrl}}`));\n }\n }\n\n printUsage(options, { verbose: false });\n printHelp();\n Log.log();\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 Log.log();\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","debug","require","constructor","devServerManager","options","printDevServerInfo","getNativeDevServerPort","devServer","getDefaultDevServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","printQRCode","Log","log","printItem","chalk","env","__EXPO_E2E_TEST","console","info","JSON","stringify","url","getDevServerUrl","devClient","learnMore","error","code","serverUrl","platforms","includes","webDevServer","getWebDevServer","webUrl","hostType","printUsage","verbose","printHelp","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","length","warn","app","promptInspectorAppAsync","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","title","value","defaultServerUrl","getUrlCreator","constructUrl","scheme","plugins","devtoolsPluginManager","queryPluginsAsync","menuItems","createDevToolsMenuItems","selectAsync","menuItem","find","item","action","name","toggleDevMenu"],"m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E,MAAMG,WAAWH,UAAUI,IAAI,CAAC,CAACC,OAASA,KAAKb,KAAK,KAAKA;YACzD,IAAIW,4BAAAA,SAAUG,MAAM,EAAE;gBACpBH,SAASG,MAAM;YACjB,OAAO,IAAIH,4BAAAA,SAAUX,KAAK,EAAE;gBAC1B,IAAI,CAACtD,gBAAgB,CAACkD,gBAAgB,CAAC,kBAAkB;oBAAEmB,MAAMJ,SAASX,KAAK;gBAAC;YAClF;QACF,EAAE,OAAO7B,OAAY;YACnB5B,MAAM4B;QACN,aAAa;QACf,SAAU;YACRW,IAAAA,wBAAS;QACX;IACF;IAEAkC,gBAAgB;QACd3D,KAAIC,GAAG,CAAC,GAAGqC,kBAAG,CAAC,kBAAkB,CAAC;QAClC,IAAI,CAACjD,gBAAgB,CAACkD,gBAAgB,CAAC;IACzC;AACF"}
|
|
@@ -190,7 +190,7 @@ async function launchActivityAsync(device, { launchActivity, url }) {
|
|
|
190
190
|
return openAsync(adbArgs(device.pid, ...args));
|
|
191
191
|
}
|
|
192
192
|
async function openAppIdAsync(device, { applicationId }) {
|
|
193
|
-
return openAsync(adbArgs(device.pid, 'shell', 'monkey', '-p', applicationId, '-c', 'android.intent.category.LAUNCHER', '1'));
|
|
193
|
+
return openAsync(adbArgs(device.pid, 'shell', 'monkey', '--pct-syskeys', '0', '-p', applicationId, '-c', 'android.intent.category.LAUNCHER', '1'));
|
|
194
194
|
}
|
|
195
195
|
async function openUrlAsync(device, { url }) {
|
|
196
196
|
return openAsync(adbArgs(device.pid, 'shell', 'am', 'start', '-a', 'android.intent.action.VIEW', '-d', // ADB requires ampersands to be escaped.
|