1 line
8.6 KiB
Plaintext
1 line
8.6 KiB
Plaintext
{"version":3,"names":["buildProject","xcodeProject","udid","scheme","args","Promise","resolve","reject","xcodebuildArgs","isWorkspace","name","xcconfig","buildFolder","mode","destination","extraParams","push","loader","getLoader","logger","info","chalk","dim","join","xcodebuildOutputFormatter","verbose","xcbeautifyAvailable","child_process","spawn","stdio","process","stdout","stderr","xcprettyAvailable","buildProcess","getProcessOptions","buildOutput","errorOutput","on","data","stringData","toString","stdin","write","isVerbose","debug","start","repeat","length","code","end","stop","printRunDoctorTip","CLIError","undefined","success","execSync","error","packager","terminal","port","env","RCT_TERMINAL","RCT_METRO_PORT","RCT_NO_LAUNCH_PACKAGER"],"sources":["../../../src/commands/buildIOS/buildProject.ts"],"sourcesContent":["import child_process, {\n ChildProcess,\n SpawnOptionsWithoutStdio,\n} from 'child_process';\nimport chalk from 'chalk';\nimport {IOSProjectInfo} from '@react-native-community/cli-types';\nimport {\n logger,\n CLIError,\n printRunDoctorTip,\n getLoader,\n} from '@react-native-community/cli-tools';\n\nexport type BuildFlags = {\n mode: string;\n packager: boolean;\n verbose: boolean;\n xcconfig?: string;\n buildFolder?: string;\n port: number;\n terminal: string | undefined;\n interactive?: boolean;\n destination?: string;\n extraParams?: string[];\n};\n\nexport function buildProject(\n xcodeProject: IOSProjectInfo,\n udid: string | undefined,\n scheme: string,\n args: BuildFlags,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n const xcodebuildArgs = [\n xcodeProject.isWorkspace ? '-workspace' : '-project',\n xcodeProject.name,\n ...(args.xcconfig ? ['-xcconfig', args.xcconfig] : []),\n ...(args.buildFolder ? ['-derivedDataPath', args.buildFolder] : []),\n '-configuration',\n args.mode,\n '-scheme',\n scheme,\n '-destination',\n (udid\n ? `id=${udid}`\n : args.mode === 'Debug'\n ? 'generic/platform=iOS Simulator'\n : 'generic/platform=iOS') +\n (args.destination ? ',' + args.destination : ''),\n ];\n\n if (args.extraParams) {\n xcodebuildArgs.push(...args.extraParams);\n }\n\n const loader = getLoader();\n logger.info(\n `Building ${chalk.dim(\n `(using \"xcodebuild ${xcodebuildArgs.join(' ')}\")`,\n )}`,\n );\n let xcodebuildOutputFormatter: ChildProcess | any;\n if (!args.verbose) {\n if (xcbeautifyAvailable()) {\n xcodebuildOutputFormatter = child_process.spawn('xcbeautify', [], {\n stdio: ['pipe', process.stdout, process.stderr],\n });\n } else if (xcprettyAvailable()) {\n xcodebuildOutputFormatter = child_process.spawn('xcpretty', [], {\n stdio: ['pipe', process.stdout, process.stderr],\n });\n }\n }\n const buildProcess = child_process.spawn(\n 'xcodebuild',\n xcodebuildArgs,\n getProcessOptions(args),\n );\n let buildOutput = '';\n let errorOutput = '';\n buildProcess.stdout.on('data', (data: Buffer) => {\n const stringData = data.toString();\n buildOutput += stringData;\n if (xcodebuildOutputFormatter) {\n xcodebuildOutputFormatter.stdin.write(data);\n } else {\n if (logger.isVerbose()) {\n logger.debug(stringData);\n } else {\n loader.start(\n `Building the app${'.'.repeat(buildOutput.length % 10)}`,\n );\n }\n }\n });\n\n buildProcess.stderr.on('data', (data: Buffer) => {\n errorOutput += data;\n });\n buildProcess.on('close', (code: number) => {\n if (xcodebuildOutputFormatter) {\n xcodebuildOutputFormatter.stdin.end();\n } else {\n loader.stop();\n }\n if (code !== 0) {\n printRunDoctorTip();\n reject(\n new CLIError(\n `\n Failed to build iOS project.\n\n We ran \"xcodebuild\" command but it exited with error code ${code}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${xcodeProject.name}.\n `,\n xcodebuildOutputFormatter\n ? undefined\n : buildOutput + '\\n' + errorOutput,\n ),\n );\n return;\n }\n logger.success('Successfully built the app');\n resolve(buildOutput);\n });\n });\n}\n\nfunction xcbeautifyAvailable() {\n try {\n child_process.execSync('xcbeautify --version', {\n stdio: [0, 'pipe', 'ignore'],\n });\n } catch (error) {\n return false;\n }\n return true;\n}\n\nfunction xcprettyAvailable() {\n try {\n child_process.execSync('xcpretty --version', {\n stdio: [0, 'pipe', 'ignore'],\n });\n } catch (error) {\n return false;\n }\n return true;\n}\n\nfunction getProcessOptions({\n packager,\n terminal,\n port,\n}: {\n packager: boolean;\n terminal: string | undefined;\n port: number;\n}): SpawnOptionsWithoutStdio {\n if (packager) {\n return {\n env: {\n ...process.env,\n RCT_TERMINAL: terminal,\n RCT_METRO_PORT: port.toString(),\n },\n };\n }\n\n return {\n env: {\n ...process.env,\n RCT_TERMINAL: terminal,\n RCT_NO_LAUNCH_PACKAGER: 'true',\n },\n };\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAK2C;AAepC,SAASA,YAAY,CAC1BC,YAA4B,EAC5BC,IAAwB,EACxBC,MAAc,EACdC,IAAgB,EACC;EACjB,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,MAAMC,cAAc,GAAG,CACrBP,YAAY,CAACQ,WAAW,GAAG,YAAY,GAAG,UAAU,EACpDR,YAAY,CAACS,IAAI,EACjB,IAAIN,IAAI,CAACO,QAAQ,GAAG,CAAC,WAAW,EAAEP,IAAI,CAACO,QAAQ,CAAC,GAAG,EAAE,CAAC,EACtD,IAAIP,IAAI,CAACQ,WAAW,GAAG,CAAC,kBAAkB,EAAER,IAAI,CAACQ,WAAW,CAAC,GAAG,EAAE,CAAC,EACnE,gBAAgB,EAChBR,IAAI,CAACS,IAAI,EACT,SAAS,EACTV,MAAM,EACN,cAAc,EACd,CAACD,IAAI,GACA,MAAKA,IAAK,EAAC,GACZE,IAAI,CAACS,IAAI,KAAK,OAAO,GACrB,gCAAgC,GAChC,sBAAsB,KACvBT,IAAI,CAACU,WAAW,GAAG,GAAG,GAAGV,IAAI,CAACU,WAAW,GAAG,EAAE,CAAC,CACnD;IAED,IAAIV,IAAI,CAACW,WAAW,EAAE;MACpBP,cAAc,CAACQ,I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