GT2/GT2-Android/node_modules/react-native-scripts/build/util/packager.js.map

1 line
18 KiB
Plaintext

{"version":3,"sources":["packager.js"],"names":["projectDir","race","stopAsync","resolve","reject","setTimeout","result","readPackagerInfoAsync","packagerPid","process","kill","exit","cleanUpPackager","installExitHooks","isInteractive","platform","require","createInterface","input","stdin","output","stdout","on","emit","withTimestamp","then","green","shouldIgnoreMsg","msg","indexOf","run","onReady","options","packagerReady","needsClear","logBuffer","progressBar","cwd","watchmanExists","sync","status","watcherDetails","toString","parseInt","split","trim","red","cyan","e","handleLogChunk","chunk","devEnabled","includes","deviceName","message","logWithLevel","level","ERROR","yellow","packagerLogsStream","projectRoot","onStartBuildBundle","total","clear","complete","incomplete","setBundleProgressBar","onProgressBuildBundle","ticks","percent","curr","tick","onFinishBuildBundle","err","startTime","endTime","duration","updateLogs","newLogChunks","updater","forEach","map","attachLoggerStream","stream","write","tag","type","startAsync","reason","stack","logStackTrace","logFn","nestedLogFn","colorFn","traceInfo","JSON","parse","bold","isLibraryFrame","line","startsWith","stackFrames","compact","lastAppCodeFrameIndex","findLastIndex","lastFrameIndexToLog","Math","min","length","unloggedFrames","i","match","str","WARN","includesStack","logLines"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;sFAuCA,iBAA+BA,UAA/B;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACuB,kBAAQC,IAAR,CAAa,CAChC,aAAQC,SAAR,CAAkBF,UAAlB,CADgC,EAEhC,sBAAY,UAACG,OAAD,EAAUC,MAAV;AAAA,qBAAqBC,WAAWF,OAAX,EAAoB,IAApB,EAA0B,YAA1B,CAArB;AAAA,aAAZ,CAFgC,CAAb,CADvB;;AAAA;AACQG,kBADR;;AAAA,kBAMMA,WAAW,YANjB;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,mBASoC,qBAAgBC,qBAAhB,CAC5BP,UAD4B,CATpC;;AAAA;AAAA;AAScQ,uBATd,SAScA,WATd;;AAYMC,oBAAQC,IAAR,CAAa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AMsB,WAAW,SAAXA,QAAW,CAACvF,GAAD,EAAM+D,KAAN,EAAaE,OAAb,EAAyB;AAAA;AAAA;AAAA;;AAAA;AACxC,oDAAiBjE,IAAIgB,KAAJ,CAAU,IAAV,CAAjB,4GAAkC;AAAA,UAAzBuD,IAAyB;;AAChCR,YAAME,QAAQM,IAAR,CAAN;AACD;AAHuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIzC,CAJD;;kBAMe,EAAErE,QAAF,E","file":"packager.js","sourcesContent":["// @flow\n\nimport {\n PackagerLogsStream,\n Project,\n ProjectSettings,\n ProjectUtils,\n} from 'xdl';\n\nimport _ from 'lodash';\nimport spawn from 'cross-spawn';\nimport ProgressBar from 'progress';\nimport bunyan from '@expo/bunyan';\nimport chalk from 'chalk';\n\nimport log from './log';\n\nfunction installExitHooks(projectDir, isInteractive) {\n if (!isInteractive && process.platform === 'win32') {\n require('readline')\n .createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n .on('SIGINT', () => {\n process.emit('SIGINT');\n });\n }\n\n process.on('SIGINT', () => {\n log.withTimestamp('Stopping packager...');\n cleanUpPackager(projectDir).then(() => {\n // TODO: this shows up after process exits, fix it\n log.withTimestamp(chalk.green('Packager stopped.'));\n process.exit();\n });\n });\n}\n\nasync function cleanUpPackager(projectDir) {\n const result = await Promise.race([\n Project.stopAsync(projectDir),\n new Promise((resolve, reject) => setTimeout(resolve, 1000, 'stopFailed')),\n ]);\n\n if (result === 'stopFailed') {\n // find RN packager pid, attempt to kill manually\n try {\n const { packagerPid } = await ProjectSettings.readPackagerInfoAsync(\n projectDir\n );\n process.kill(packagerPid);\n } catch (e) {\n process.exit(1);\n }\n }\n}\n\nfunction shouldIgnoreMsg(msg) {\n return msg.indexOf('Duplicate module name: bser') >= 0 ||\n msg.indexOf('Duplicate module name: fb-watchman') >= 0 ||\n msg.indexOf('Warning: React.createClass is no longer supported') >= 0 ||\n msg.indexOf('Warning: PropTypes has been moved to a separate package') >= 0;\n}\n\nfunction run(\n onReady: () => ?any,\n options: Object = {},\n isInteractive?: boolean = false\n) {\n let packagerReady = false;\n let needsClear = false;\n let logBuffer = '';\n let progressBar;\n const projectDir = process.cwd();\n\n if (process.platform !== 'win32') {\n const watchmanExists = spawn.sync('which', ['watchman']).status === 0;\n\n if (process.platform === 'darwin' && !watchmanExists) {\n const watcherDetails = spawn\n .sync('sysctl', ['kern.maxfiles'])\n .stdout.toString();\n if (parseInt(watcherDetails.split(':')[1].trim()) < 5242880) {\n log.withTimestamp(\n `${chalk.red(`Unable to start server`)}\nSee https://git.io/v5vcn for more information, either install watchman or run the following snippet:\n${chalk.cyan(` sudo sysctl -w kern.maxfiles=5242880\n sudo sysctl -w kern.maxfilesperproc=524288`)}\n `\n );\n process.exit(1);\n }\n } else if (!watchmanExists) {\n try {\n const watcherDetails = spawn\n .sync('sysctl', ['fs.inotify.max_user_watches'])\n .stdout.toString();\n if (parseInt(watcherDetails.split('=')[1].trim()) < 12288) {\n log.withTimestamp(\n `${chalk.red(`Unable to start server`)}\n See https://git.io/v5vcn for more information, either install watchman or run the following snippet:\n ${chalk.cyan(` sudo sysctl -w fs.inotify.max_user_instances=1024\n sudo sysctl -w fs.inotify.max_user_watches=12288`)}`\n );\n process.exit(1);\n }\n } catch (e) {\n // note(brentvatne): I'm not sure why stdout is null for some OS's\n // https://github.com/react-community/create-react-native-app/issues/391\n log.withTimestamp(\n 'Warning: Unable to run `sysctl fs.inotify.max_user_watches`. If you encounter issues, please refer to https://git.io/v5vcn'\n );\n }\n }\n }\n\n const handleLogChunk = chunk => {\n // pig, meet lipstick\n // 1. https://github.com/facebook/react-native/issues/14620\n // 2. https://github.com/facebook/react-native/issues/14610\n // 3. https://github.com/react-community/create-react-native-app/issues/229#issuecomment-308654303\n // @ide is investigating 3), the first two are upstream issues that will\n // likely be resolved by others\n if (shouldIgnoreMsg(chunk.msg)) {\n return;\n }\n\n // we don't need to print the entire manifest when loading the app\n if (chunk.msg.indexOf(' with appParams: ') >= 0) {\n if (needsClear) {\n // this is set when we previously encountered an error\n // TODO clearConsole();\n }\n let devEnabled = chunk.msg.includes('__DEV__ === true');\n log.withTimestamp(\n `Running app on ${chunk.deviceName} in ${devEnabled ? 'development' : 'production'} mode\\n`\n );\n return;\n }\n\n if (chunk.msg === 'Dependency graph loaded.') {\n packagerReady = true;\n onReady();\n return;\n }\n\n if (packagerReady) {\n const message = `${chunk.msg.trim()}\\n`;\n logWithLevel(chunk);\n\n if (chunk.level === bunyan.ERROR) {\n // if you run into a syntax error then we should clear log output on reload\n needsClear = message.indexOf('SyntaxError') >= 0;\n }\n } else {\n if (chunk.level >= bunyan.ERROR) {\n log(chalk.yellow('***ERROR STARTING PACKAGER***'));\n log(logBuffer);\n log(chalk.red(chunk.msg));\n logBuffer = '';\n } else {\n logBuffer += chunk.msg + '\\n';\n }\n }\n };\n\n // Subscribe to packager/server logs\n let packagerLogsStream = new PackagerLogsStream({\n projectRoot: projectDir,\n onStartBuildBundle: () => {\n progressBar = new ProgressBar(\n 'Building JavaScript bundle [:bar] :percent',\n {\n total: 100,\n clear: true,\n complete: '=',\n incomplete: ' ',\n }\n );\n\n log.setBundleProgressBar(progressBar);\n },\n onProgressBuildBundle: percent => {\n if (!progressBar || progressBar.complete) return;\n let ticks = percent - progressBar.curr;\n ticks > 0 && progressBar.tick(ticks);\n },\n onFinishBuildBundle: (err, startTime, endTime) => {\n if (progressBar && !progressBar.complete) {\n progressBar.tick(100 - progressBar.curr);\n }\n\n if (progressBar) {\n log.setBundleProgressBar(null);\n progressBar = null;\n\n if (err) {\n log.withTimestamp(chalk.red(`Failed building JavaScript bundle`));\n } else {\n let duration = endTime - startTime;\n log.withTimestamp(\n chalk.green(`Finished building JavaScript bundle in ${duration}ms`)\n );\n }\n }\n },\n updateLogs: updater => {\n let newLogChunks = updater([]);\n\n if (progressBar) {\n // Restarting watchman causes `onFinishBuildBundle` to not fire. Until\n // this is handled upstream in xdl, reset progress bar with error here.\n newLogChunks.forEach(chunk => {\n if (chunk.msg === 'Restarted watchman.') {\n progressBar.tick(100 - progressBar.curr);\n log.setBundleProgressBar(null);\n progressBar = null;\n log.withTimestamp(chalk.red('Failed building JavaScript bundle'));\n }\n });\n }\n\n newLogChunks.map(handleLogChunk);\n },\n });\n\n // Subscribe to device updates separately from packager/server updates\n ProjectUtils.attachLoggerStream(projectDir, {\n stream: {\n write: chunk => {\n if (chunk.tag === 'device') {\n handleLogChunk(chunk);\n }\n },\n },\n type: 'raw',\n });\n\n installExitHooks(projectDir, isInteractive);\n log.withTimestamp('Starting packager...');\n\n Project.startAsync(projectDir, options).then(\n () => {},\n reason => {\n log.withTimestamp(chalk.red(`Error starting packager: ${reason.stack}`));\n process.exit(1);\n }\n );\n}\n\nconst logStackTrace = (chunk, logFn, nestedLogFn, colorFn) => {\n let traceInfo;\n try {\n traceInfo = JSON.parse(chunk.msg);\n } catch (e) {\n return logFn(colorFn(chunk.msg));\n }\n\n let { message, stack } = traceInfo;\n logFn(colorFn(chalk.bold(message)));\n\n const isLibraryFrame = line => {\n return line.startsWith('node_modules');\n };\n\n let stackFrames = _.compact(stack.split('\\n'));\n let lastAppCodeFrameIndex = _.findLastIndex(stackFrames, line => {\n return !isLibraryFrame(line);\n });\n let lastFrameIndexToLog = Math.min(\n stackFrames.length - 1,\n lastAppCodeFrameIndex + 2 // show max two more frames after last app code frame\n );\n let unloggedFrames = stackFrames.length - lastFrameIndexToLog;\n\n // If we're only going to exclude one frame, just log them all\n if (unloggedFrames === 1) {\n lastFrameIndexToLog = stackFrames.length - 1;\n unloggedFrames = 0;\n }\n\n for (let i = 0; i <= lastFrameIndexToLog; i++) {\n let line = stackFrames[i];\n if (!line) {\n continue;\n } else if (line.match(/react-native\\/.*YellowBox.js/)) {\n continue;\n }\n\n if (line.startsWith('node_modules')) {\n nestedLogFn(colorFn('- ' + line));\n } else {\n nestedLogFn(colorFn('* ' + line));\n }\n }\n\n if (unloggedFrames > 0) {\n nestedLogFn(\n colorFn(\n `- ... ${unloggedFrames} more stack frames from framework internals`\n )\n );\n }\n};\n\nconst logWithLevel = chunk => {\n if (!chunk.msg) {\n return;\n }\n\n let colorFn = (str) => str;\n if (chunk.level === bunyan.WARN) {\n colorFn = chalk.yellow;\n } else if (chunk.level === bunyan.ERROR) {\n colorFn = chalk.red;\n }\n\n if (chunk.includesStack) {\n logStackTrace(chunk, log.withTimestamp, log, colorFn);\n } else {\n logLines(chunk.msg, log.withTimestamp, colorFn);\n }\n};\n\nconst logLines = (msg, logFn, colorFn) => {\n for (let line of msg.split('\\n')) {\n logFn(colorFn(line));\n }\n};\n\nexport default { run };\n"]}