1 line
10 KiB
Plaintext
1 line
10 KiB
Plaintext
|
{"version":3,"names":["runPackager","args","config","packager","result","isPackagerRunning","port","logger","info","warn","startServerInNewWindow","terminal","root","reactNativePath","error","Error","message","buildAndroid","_argv","androidProject","getAndroidProject","variant","tasks","mode","interactive","selectedTask","promptForTaskSelection","sourceDir","gradleArgs","getTaskNames","appName","extraParams","push","activeArchOnly","adbPath","getAdbPath","devices","adb","getDevices","architectures","map","device","getCPU","filter","arch","index","array","indexOf","length","join","build","process","chdir","cmd","platform","startsWith","debug","execa","sync","stdio","cwd","printRunDoctorTip","CLIError","options","name","description","default","env","RCT_METRO_PORT","parse","Number","getDefaultUserTerminal","val","split","func"],"sources":["../../../src/commands/buildAndroid/index.ts"],"sourcesContent":["import {\n CLIError,\n getDefaultUserTerminal,\n isPackagerRunning,\n logger,\n printRunDoctorTip,\n} from '@react-native-community/cli-tools';\nimport {Config} from '@react-native-community/cli-types';\nimport execa from 'execa';\nimport {getAndroidProject} from '../../config/getAndroidProject';\nimport adb from '../runAndroid/adb';\nimport getAdbPath from '../runAndroid/getAdbPath';\nimport {startServerInNewWindow} from './startServerInNewWindow';\nimport {getTaskNames} from '../runAndroid/getTaskNames';\nimport {promptForTaskSelection} from '../runAndroid/listAndroidTasks';\n\nexport interface BuildFlags {\n mode?: string;\n variant?: string;\n activeArchOnly?: boolean;\n packager?: boolean;\n port: number;\n terminal: string;\n tasks?: Array<string>;\n extraParams?: Array<string>;\n interactive?: boolean;\n}\n\nexport async function runPackager(args: BuildFlags, config: Config) {\n if (!args.packager) {\n return;\n }\n const result = await isPackagerRunning(args.port);\n if (result === 'running') {\n logger.info('JS server already running.');\n } else if (result === 'unrecognized') {\n logger.warn('JS server not recognized, continuing with build...');\n } else {\n // result == 'not_running'\n logger.info('Starting JS server...');\n\n try {\n startServerInNewWindow(\n args.port,\n args.terminal,\n config.root,\n config.reactNativePath,\n );\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(\n `Failed to automatically start the packager server. Please run \"react-native start\" manually. Error details: ${error.message}`,\n );\n }\n }\n }\n}\n\nasync function buildAndroid(\n _argv: Array<string>,\n config: Config,\n args: BuildFlags,\n) {\n const androidProject = getAndroidProject(config);\n\n if (args.variant) {\n logger.warn(\n '\"variant\" flag is deprecated and will be removed in future release. Please switch to \"mode\" flag.',\n );\n }\n\n if (args.tasks && args.mode) {\n logger.warn(\n 'Both \"tasks\" and \"mode\" parameters were passed to \"build\" command. Using \"tasks\" for building the app.',\n );\n }\n\n let {tasks} = args;\n\n if (args.interactive) {\n const selectedTask = await promptForTaskSelection(\n 'build',\n androidProject.sourceDir,\n );\n if (selectedTask) {\n tasks = [selectedTask];\n }\n }\n\n let gradleArgs = getTaskNames(\n androidProject.appName,\n args.mode || args.variant,\n tasks,\n 'bundle',\n androidProject.sourceDir,\n );\n\n if (args.extraParams) {\n gradleArgs.push(...args.extraParams);\n }\n\n if (args.activeArchOnly) {\n const adbPath = getAdbPath();\n const devices = adb.getDevices(adbPath);\n const architectures = devices\n .map((device) => {\n return adb.getCPU(adbPath, device);\n })\n .filter(\n (arch, index, array) => arch != null && array.indexOf(arch) === index,\n );\n if (architectures.length > 0) {\n logger.info(`Detected architectures ${architectures.join(', ')}`);\n // `reactNativeDebugArchitectures` was re
|