1 line
14 KiB
Plaintext
1 line
14 KiB
Plaintext
|
{"version":3,"names":["buildIOS","_","ctx","args","project","ios","CLIError","xcodeProject","sourceDir","process","chdir","configuration","logger","warn","mode","projectInfo","getProjectInfo","checkIfConfigurationExists","inferredSchemeName","path","basename","name","extname","scheme","interactive","selection","selectFromInteractiveMode","modifiedArgs","getConfigurationScheme","info","isWorkspace","chalk","bold","extendedArgs","packager","device","udid","simulator","buildProject","undefined","fallbackSimulators","selectedSimulator","getDestinationSimulator","error","devices","listIOSDevices","find","d","printFoundDevices","physicalDevices","filter","type","matchingDevice","deviceName","firstIOSDevice","deviceByName","formattedDeviceName","String","version","map","join","iosBuildOptions","description","default","env","RCT_METRO_PORT","parse","Number","getDefaultUserTerminal","val","split","func","examples","desc","cmd","options"],"sources":["../../../src/commands/buildIOS/index.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\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 *\n */\n\nimport path from 'path';\nimport chalk from 'chalk';\nimport {Config} from '@react-native-community/cli-types';\nimport {\n logger,\n CLIError,\n getDefaultUserTerminal,\n} from '@react-native-community/cli-tools';\nimport {Device} from '../../types';\nimport {BuildFlags, buildProject} from './buildProject';\nimport {getDestinationSimulator} from '../../tools/getDestinationSimulator';\nimport {selectFromInteractiveMode} from '../../tools/selectFromInteractiveMode';\nimport {getProjectInfo} from '../../tools/getProjectInfo';\nimport {checkIfConfigurationExists} from '../../tools/checkIfConfigurationExists';\nimport {getConfigurationScheme} from '../../tools/getConfigurationScheme';\nimport listIOSDevices from '../../tools/listIOSDevices';\n\nexport interface FlagsT extends BuildFlags {\n configuration?: string;\n simulator?: string;\n device?: string | true;\n udid?: string;\n scheme?: string;\n}\n\nasync function buildIOS(_: Array<string>, ctx: Config, args: FlagsT) {\n if (!ctx.project.ios) {\n throw new CLIError(\n 'iOS project folder not found. Are you sure this is a React Native project?',\n );\n }\n\n const {xcodeProject, sourceDir} = ctx.project.ios;\n\n if (!xcodeProject) {\n throw new CLIError(\n `Could not find Xcode project files in \"${sourceDir}\" folder`,\n );\n }\n\n process.chdir(sourceDir);\n\n if (args.configuration) {\n logger.warn('--configuration has been deprecated. Use --mode instead.');\n logger.warn(\n 'Parameters were automatically reassigned to --mode on this run.',\n );\n args.mode = args.configuration;\n }\n\n const projectInfo = getProjectInfo();\n\n if (args.mode) {\n checkIfConfigurationExists(projectInfo, args.mode);\n }\n\n const inferredSchemeName = path.basename(\n xcodeProject.name,\n path.extname(xcodeProject.name),\n );\n\n let scheme = args.scheme || inferredSchemeName;\n let mode = args.mode;\n\n if (args.interactive) {\n const selection = await selectFromInteractiveMode({scheme, mode});\n\n if (selection.scheme) {\n scheme = selection.scheme;\n }\n\n if (selection.mode) {\n mode = selection.mode;\n }\n }\n\n const modifiedArgs = {...args, scheme, mode};\n\n args.mode = getConfigurationScheme(\n {scheme: args.scheme, mode: args.mode},\n sourceDir,\n );\n\n logger.info(\n `Found Xcode ${\n xcodeProject.isWorkspace ? 'workspace' : 'project'\n } \"${chalk.bold(xcodeProject.name)}\"`,\n );\n\n const extendedArgs = {\n ...modifiedArgs,\n packager: false,\n };\n\n // // No need to load all available devices\n if (!args.device && !args.udid) {\n if (!args.simulator) {\n return buildProject(xcodeProject, undefined, scheme, extendedArgs);\n }\n\n /**\n * If provided simulator does not exist, try simulators in following order\n * - iPhone 14\n
|