GT2/GT2-iOS/node_modules/xdl/build/__sourcemaps__/Project.js.map

1 line
108 KiB
Plaintext

{"version":3,"sources":["Project.js"],"names":["async","projectDir","manifestUrl","await","UrlUtils","constructManifestUrlAsync","urlType","packagerUrl","constructBundleUrlAsync","let","packagerRunning","res","request","statusCode","body","includes","e","manifestServerRunning","currentStatus","projectRoot","packagerInfo","ProjectSettings","readPackagerInfoAsync","packagerNgrokUrl","expoServerNgrokUrl","status","_areTunnelsHealthy","projectSettings","readAsync","hostType","Config","offline","url","isUrlFallback","getManifestUrlWithFallbackAsync","ErrorCode","NO_PROJECT_ROOT","_assertValidProjectRoot","rangeStart","port","freeportAsync","NO_PORT_FOUND","_getFreePortAsync","platform","errorCode","minLength","getPlatformSpecificBundleUrl","fullUrl","response","get","headers","JSON","parse","ProjectUtils","logError","undefined","message","length","_getForPlatformAsync","manifest","resolver","strict","assetSchemas","ExpSchema","getAssetSchemasAsync","sdkVersion","filter","fieldPath","_","urls","Promise","all","map","pathOrURL","match","fs","existsSync","path","resolve","err","Error","localAssetPath","manifestField","forEach","index","set","logMethod","logWarning","_resolveManifestAssets","options","exp","pkg","readConfigJsonAsync","configName","configFilenameAsync","NO_PACKAGE_JSON","slug","name","INVALID_MANIFEST","getSlugAsync","formData","append","releaseChannel","queryResult","Api","callMethodAsync","getLatestReleaseAsync","user","UserManager","ensureLoggedInAsync","_validatePackagerReadyAsync","Analytics","logEvent","validationStatus","Doctor","validateWithNetworkAsync","ERROR","FATAL","PUBLISH_VALIDATION_ERROR","_getPublishExpConfigAsync","hooks","validPostPublishHooks","postPublish","hook","file","config","fn","_requireFromProject","logger","global","error","_fn","push","HOOK_INITIALIZATION_ERROR","iosBundle","androidBundle","_buildPublishBundlesAsync","_fetchAndUploadAssetsAsync","iosSourceMap","androidSourceMap","_maybeBuildSourceMapsAsync","force","_uploadArtifactsAsync","serverError","_maybeWriteArtifactsToDiskAsync","ios","publishManifestPath","android","androidManifest","iosManifest","ExponentTools","getManifestAsync","hookOptions","log","msg","info","quiet","result","then","warn","stack","_writeArtifactSafelyAsync","stringify","isKernel","_handleKernelPublishedAsync","publishAsync","_createBlob","packagerPort","NO_PACKAGER_PORT","schema","joi","object","keys","string","joiValidateAsync","INVALID_OPTIONS","toString","version","process","env","entryPoint","Exp","determineEntryPointAsync","publishUrl","constructPublishUrlAsync","INVALID_BUNDLE","MINIMUM_BUNDLE_SIZE","sourceMapUrl","constructSourceMapUrlAsync","assetsUrl","constructAssetsUrlAsync","iosAssetsJson","INVALID_ASSETS","androidAssetsJson","manifestAssets","assetPath","absolutePath","contents","readFile","hash","md5hex","files","fileHashes","iosAssets","androidAssets","assets","concat","uploadAssetsAsync","assetBundlePatterns","fullPatterns","p","join","bundledAssets","Set","asset","__packager_asset","some","minimatch","add","type","keyName","artifactPath","artifact","pathToWrite","dirname","writeFile","publishBundlePath","publishSourceMapPath","kernelBundleUrl","api","scheme","host","username","kernel","androidManifestPath","bundleUrl","iosManifestPath","paths","metas","Object","metadata","missing","key","exists","chunk","logDebug","relativePath","replace","_readFileForUpload","isNode","createReadStream","data","Blob","current","boolean","mode","any","valid","expIds","array","regex","configPrefix","bundleIdentifier","package","buildAsync","delayAsync","_waitForRunningAsync","spawnAsync","stdout","logInfo","_restartWatchmanAsync","verbose","stopReactNativeServerAsync","Watchman","addToPathAsync","unblockAndGetVersionAsync","nodeModulesPath","packagerOpts","customLogReporterPath","assetExts","nonPersistent","Versions","gteSdkVersion","userPackagerOpts","uniq","cliOpts","reduce","opts","val","reset","defaultCliPath","cliPath","nodePath","rnCliPath","_nodePathForProjectRoot","packagerProcess","child_process","fork","cwd","REACT_NATIVE_APP_ROOT","NODE_PATH","ELECTRON_RUN_AS_NODE","silent","setPackagerInfoAsync","packagerPid","pid","on","treekill","setEncoding","stderr","pipe","split","_logPackagerOutput","code","startReactNativeServerAsync","treekillAsync","stopExpoServerAsync","app","express","use","bodyParser","json","limit","urlencoded","extended","manifestHandler","req","getPackagerOptsAsync","bundleUrlPackagerOpts","xde","developer","tool","developerTool","startsWith","mainModuleName","guessMainModulePath","queryParams","constructBundleQueryParamsAsync","hostname","debuggerHost","constructDebuggerHostAsync","logUrl","constructLogUrlAsync","hostUUID","UserSettings","anonymousIdentifier","id","manifestString","currentUser","getCurrentUserAsync","_cachedSignedManifest","signedManifest","unsignedManifest","signature","publishInfo","getPublishInfoAsync","args","hostInfo","server","serverVersion","require","serverDriver","serverOS","os","serverOSVersion","release","send","post","deviceId","deviceName","_handleDeviceLogs","close","expRc","readExpRcAsync","expoServerPort","manifestPort","listen","address","saveRecentExpRootAsync","startExpoServerAsync","hostnameAsync","ngrokPid","attempts","configPath","dotExpoHomeDirectory","ngrokConnectAsync","NGROK_ERROR","error_code","kill","ngrokKillAsync","resetProjectRandomnessAsync","_connectToNgrokAsync","NO_EXPO_SERVER_PORT","stopTunnelsAsync","Android","startAdbReverseAsync","clearNotification","packageShortName","base","ngrok","addListener","startedTunnelsSuccessfully","race","TUNNEL_TIMEOUT","authtoken","authToken","proto","randomness","manifestTunnelRandomness","getProjectRandomnessAsync","domainify","domain","startTunnelsAsync","ngrokProcess","ngrokProcessPid","removeAllListeners","stopAdbReverseAsync","number","integer","setOptionsAsync","getUrlAsync","startAsync","_stopInternalAsync","reject","setTimeout","stopAsync","promisify","validate","connect","Request","defaults","resolveWithFullResponse","modulePath","indexOf","fullPath","decache","_stripPackagerOutputBox","output","re","found","_processPackagerLine","line","timestampRe","sdk11AndUpTimestampRe","_parseModuleResolutionError","errorMessage","parts","moduleName","trim","NODE_STDLIB_MODULES","_logModuleResolutionError","DOCS_PAGE_URL","level","isPlatformSupported","_isIgnorableDuplicateModuleWarning","lines","i","reactNativeNodeModulesPath","reactNativeNodeModulesPattern","escapeRegExp","reactNativeNodeModulesCollisionRegex","RegExp","test","logs","obj","groupDepth","shouldHide","includesStack","logWithLevel","tag","directory","parentDirectory","delimiter"],"mappings":";;;;;;;;;;+BAwEOA,WAA6BC,UAA7BD,EAAyE;AAC9E,UAAME,cAAcC,MAA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c,gBAAgB1T,IAAI0T,aAAxB1c;;AAEA4C,4CAAa+Z,YAAb/Z,CACElC,WADFkC,EAEE+Y,KAFF/Y,EAGE;AACEga,WAAK,QADP;AAEErG,cAFF;AAGEC,gBAHF;AAIEgG,gBAJF;AAKEC,gBALF;AAMEC;AANF,KAHF9Z,EAWEwH,MAXFxH;AAaF;AACF;AAqHA,SAASiP,uBAAT,CAAiCnR,WAAjC,EAA8D;AAC5DV,MAAIoO,QAAQ,EAAZpO;AACAA,MAAI6c,YAAYzY,cAAKC,OAALD,CAAa1D,WAAb0D,CAAhBpE;AACA,SAAO,IAAP,EAAa;AACXoO,UAAMzG,IAANyG,CAAWhK,cAAKsI,IAALtI,CAAUyY,SAAVzY,EAAqB,cAArBA,CAAXgK;AACApO,QAAI8c,kBAAkB1Y,cAAKmJ,OAALnJ,CAAayY,SAAbzY,CAAtBpE;AACA,QAAI6c,cAAcC,eAAlB,EAAmC;AACjC;AACF;AACAD,gBAAYC,eAAZD;AACF;AACA,SAAOzO,MAAM1B,IAAN0B,CAAWhK,cAAK2Y,SAAhB3O,CAAP;AACF","file":"../Project.js","sourcesContent":["/**\n * @flow\n */\n\nimport bodyParser from 'body-parser';\nimport child_process from 'child_process';\nimport delayAsync from 'delay-async';\nimport decache from 'decache';\nimport express from 'express';\nimport freeportAsync from 'freeport-async';\nimport fs from 'fs-extra';\nimport joi from 'joi';\nimport promisify from 'util.promisify';\nimport _ from 'lodash';\nimport isEmpty from 'lodash/isEmpty';\nimport minimatch from 'minimatch';\nimport ngrok from '@expo/ngrok';\nimport os from 'os';\nimport path from 'path';\nimport Request from 'request-promise-native';\nimport spawnAsync from '@expo/spawn-async';\nimport split from 'split';\nimport treekill from 'tree-kill';\nimport md5hex from 'md5hex';\n\nimport * as Analytics from './Analytics';\nimport * as Android from './Android';\nimport Api from './Api';\nimport Config from './Config';\nimport * as Doctor from './project/Doctor';\nimport ErrorCode from './ErrorCode';\nimport logger from './Logger';\nimport * as ExponentTools from './detach/ExponentTools';\nimport * as Exp from './Exp';\nimport * as ExpSchema from './project/ExpSchema';\nimport FormData from './tools/FormData';\nimport { isNode } from './tools/EnvironmentHelper';\nimport * as ProjectSettings from './ProjectSettings';\nimport * as ProjectUtils from './project/ProjectUtils';\nimport * as UrlUtils from './UrlUtils';\nimport UserManager from './User';\nimport UserSettings from './UserSettings';\nimport * as Versions from './Versions';\nimport * as Watchman from './Watchman';\nimport XDLError from './XDLError';\n\nimport type { User as ExpUser } from './User'; //eslint-disable-line\n\nconst MINIMUM_BUNDLE_SIZE = 500;\nconst TUNNEL_TIMEOUT = 10 * 1000;\n\nconst joiValidateAsync = promisify(joi.validate);\nconst treekillAsync = promisify(treekill);\nconst ngrokConnectAsync = promisify(ngrok.connect);\nconst ngrokKillAsync = promisify(ngrok.kill);\n\nconst request = Request.defaults({\n resolveWithFullResponse: true,\n});\n\ntype CachedSignedManifest = {\n manifestString: ?string,\n signedManifest: ?string,\n};\n\nlet _cachedSignedManifest: CachedSignedManifest = {\n manifestString: null,\n signedManifest: null,\n};\n\nexport type ProjectStatus = 'running' | 'ill' | 'exited';\n\nexport async function currentStatus(projectDir: string): Promise<ProjectStatus> {\n const manifestUrl = await UrlUtils.constructManifestUrlAsync(projectDir, {\n urlType: 'http',\n });\n const packagerUrl = await UrlUtils.constructBundleUrlAsync(projectDir, {\n urlType: 'http',\n });\n\n let packagerRunning = false;\n try {\n const res = await request(`${packagerUrl}/status`);\n\n if (res.statusCode < 400 && res.body && res.body.includes('packager-status:running')) {\n packagerRunning = true;\n }\n } catch (e) {}\n\n let manifestServerRunning = false;\n try {\n const res = await request(manifestUrl);\n if (res.statusCode < 400) {\n manifestServerRunning = true;\n }\n } catch (e) {}\n\n if (packagerRunning && manifestServerRunning) {\n return 'running';\n } else if (packagerRunning || manifestServerRunning) {\n return 'ill';\n } else {\n return 'exited';\n }\n}\n\nasync function _areTunnelsHealthy(projectRoot: string) {\n const packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n if (!packagerInfo.packagerNgrokUrl || !packagerInfo.expoServerNgrokUrl) {\n return false;\n }\n const status = await currentStatus(projectRoot);\n return status === 'running';\n}\n\nexport async function getManifestUrlWithFallbackAsync(projectRoot: string) {\n const projectSettings = await ProjectSettings.readAsync(projectRoot);\n if (\n projectSettings.hostType === 'tunnel' &&\n !Config.offline &&\n !await _areTunnelsHealthy(projectRoot)\n ) {\n // Fall back to LAN URL if tunnels are not available.\n return {\n url: await UrlUtils.constructManifestUrlAsync(projectRoot, {\n hostType: 'lan',\n }),\n isUrlFallback: true,\n };\n } else {\n return {\n url: await UrlUtils.constructManifestUrlAsync(projectRoot),\n isUrlFallback: false,\n };\n }\n}\n\nasync function _assertValidProjectRoot(projectRoot) {\n if (!projectRoot) {\n throw new XDLError(ErrorCode.NO_PROJECT_ROOT, 'No project root specified');\n }\n}\n\nasync function _getFreePortAsync(rangeStart) {\n let port = await freeportAsync(rangeStart);\n if (!port) {\n throw new XDLError(ErrorCode.NO_PORT_FOUND, 'No available port found');\n }\n\n return port;\n}\n\nasync function _getForPlatformAsync(projectRoot, url, platform, { errorCode, minLength }) {\n url = UrlUtils.getPlatformSpecificBundleUrl(url, platform);\n\n let fullUrl = `${url}&platform=${platform}`;\n let response = await request.get({\n url: fullUrl,\n headers: {\n 'Exponent-Platform': platform,\n },\n });\n\n if (response.statusCode !== 200) {\n if (response.body) {\n let body;\n try {\n body = JSON.parse(response.body);\n } catch (e) {\n ProjectUtils.logError(projectRoot, 'expo', response.body);\n }\n\n if (body !== undefined) {\n if (body.message) {\n ProjectUtils.logError(projectRoot, 'expo', body.message);\n } else {\n ProjectUtils.logError(projectRoot, 'expo', response.body);\n }\n }\n }\n throw new XDLError(\n errorCode,\n `Packager URL ${fullUrl} returned unexpected code ${response.statusCode}. Please open your project in the Expo app and see if there are any errors. Also scroll up and make sure there were no errors or warnings when opening your project.`\n );\n }\n\n if (!response.body || (minLength && response.body.length < minLength)) {\n throw new XDLError(errorCode, `Body is: ${response.body}`);\n }\n\n return response.body;\n}\n\nasync function _resolveManifestAssets(projectRoot, manifest, resolver, strict = false) {\n try {\n // Asset fields that the user has set\n const assetSchemas = (await ExpSchema.getAssetSchemasAsync(\n manifest.sdkVersion\n )).filter(({ fieldPath }) => _.get(manifest, fieldPath));\n\n // Get the URLs\n const urls = await Promise.all(\n assetSchemas.map(async ({ fieldPath }) => {\n const pathOrURL = _.get(manifest, fieldPath);\n if (pathOrURL.match(/^https?:\\/\\/(.*)$/)) {\n // It's a remote URL\n return pathOrURL;\n } else if (fs.existsSync(path.resolve(projectRoot, pathOrURL))) {\n return await resolver(pathOrURL);\n } else {\n const err = new Error('Could not resolve local asset.');\n // $FlowFixMe\n err.localAssetPath = pathOrURL;\n // $FlowFixMe\n err.manifestField = fieldPath;\n throw err;\n }\n })\n );\n\n // Set the corresponding URL fields\n assetSchemas.forEach(({ fieldPath }, index) => _.set(manifest, fieldPath + 'Url', urls[index]));\n } catch (e) {\n let logMethod = ProjectUtils.logWarning;\n if (strict) {\n logMethod = ProjectUtils.logError;\n }\n if (e.localAssetPath) {\n logMethod(\n projectRoot,\n 'expo',\n `Unable to resolve asset \"${e.localAssetPath}\" from \"${e.manifestField}\" in your app/exp.json.`\n );\n } else {\n logMethod(\n projectRoot,\n 'expo',\n `Warning: Unable to resolve manifest assets. Icons might not work. ${e.message}.`\n );\n }\n\n if (strict) {\n throw new Error('Resolving assets failed.');\n }\n }\n}\n\nfunction _requireFromProject(modulePath, projectRoot) {\n try {\n if (modulePath.indexOf('.') === 0) {\n let fullPath = path.resolve(projectRoot, modulePath);\n\n // Clear the require cache for this module so get a fresh version of it\n // without requiring the user to restart XDE\n decache(fullPath);\n\n // $FlowIssue: doesn't work with dynamic requires\n return require(fullPath);\n } else {\n let fullPath = path.resolve(projectRoot, 'node_modules', modulePath);\n\n // Clear the require cache for this module so get a fresh version of it\n // without requiring the user to restart XDE\n decache(fullPath);\n\n // $FlowIssue: doesn't work with dynamic requires\n return require(fullPath);\n }\n } catch (e) {\n return null;\n }\n}\n\nexport async function getSlugAsync(projectRoot: string, options: Object = {}) {\n // Verify that exp/app.json exist\n let { exp, pkg } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n if (!exp || !pkg) {\n const configName = await ProjectUtils.configFilenameAsync(projectRoot);\n throw new XDLError(\n ErrorCode.NO_PACKAGE_JSON,\n `Couldn't read ${configName} file in project at ${projectRoot}`\n );\n }\n\n if (!exp.slug && pkg.name) {\n exp.slug = pkg.name;\n } else if (!exp.slug) {\n const configName = await ProjectUtils.configFilenameAsync(projectRoot);\n throw new XDLError(\n ErrorCode.INVALID_MANIFEST,\n `${configName} in ${projectRoot} must contain the slug field`\n );\n }\n return exp.slug;\n}\n\nexport async function getLatestReleaseAsync(\n projectRoot: string,\n options: {\n releaseChannel: string,\n platform: string,\n }\n) {\n // TODO(ville): move request from multipart/form-data to JSON once supported by the endpoint.\n let formData = new FormData();\n formData.append('queryType', 'history');\n formData.append('slug', await getSlugAsync(projectRoot));\n formData.append('version', '2');\n formData.append('count', '1');\n formData.append('releaseChannel', options.releaseChannel);\n formData.append('platform', options.platform);\n const { queryResult } = await Api.callMethodAsync('publishInfo', [], 'post', null, {\n formData,\n });\n if (queryResult && queryResult.length > 0) {\n return queryResult[0];\n } else {\n return null;\n }\n}\n\nexport async function publishAsync(\n projectRoot: string,\n options: Object = {}\n): Promise<{ url: string, ids: string[], err: ?string }> {\n const user = await UserManager.ensureLoggedInAsync();\n await _validatePackagerReadyAsync(projectRoot);\n Analytics.logEvent('Publish', { projectRoot });\n\n const validationStatus = await Doctor.validateWithNetworkAsync(projectRoot);\n if (validationStatus == Doctor.ERROR || validationStatus === Doctor.FATAL) {\n throw new XDLError(\n ErrorCode.PUBLISH_VALIDATION_ERROR,\n \"Couldn't publish because errors were found. (See logs above.) Please fix the errors and try again.\"\n );\n }\n\n // Get project config\n let exp = await _getPublishExpConfigAsync(projectRoot, options);\n\n // TODO: refactor this out to a function, throw error if length doesn't match\n let { hooks } = exp;\n delete exp.hooks;\n let validPostPublishHooks = [];\n if (hooks && hooks.postPublish) {\n hooks.postPublish.forEach(hook => {\n let { file, config } = hook;\n let fn = _requireFromProject(file, projectRoot);\n if (fn === null) {\n logger.global.error(`Unable to load postPublishHook: '${file}'`);\n } else {\n hook._fn = fn;\n validPostPublishHooks.push(hook);\n }\n });\n\n if (validPostPublishHooks.length !== hooks.postPublish.length) {\n logger.global.error();\n\n throw new XDLError(\n ErrorCode.HOOK_INITIALIZATION_ERROR,\n 'Please fix your postPublish hook configuration.'\n );\n }\n }\n\n let { iosBundle, androidBundle } = await _buildPublishBundlesAsync(projectRoot);\n\n await _fetchAndUploadAssetsAsync(projectRoot, exp);\n\n let { iosSourceMap, androidSourceMap } = await _maybeBuildSourceMapsAsync(projectRoot, exp, {\n force: validPostPublishHooks.length,\n });\n\n let response;\n try {\n response = await _uploadArtifactsAsync({\n exp,\n iosBundle,\n androidBundle,\n options,\n });\n } catch (e) {\n if (e.serverError === 'SCHEMA_VALIDATION_ERROR') {\n throw new Error(\n `There was an error validating your project schema. Check for any warnings about the contents of your app/exp.json.`\n );\n }\n throw new Error(`There was an error publishing your project. Please check for any warnings.`);\n }\n\n await _maybeWriteArtifactsToDiskAsync({\n exp,\n projectRoot,\n iosBundle,\n androidBundle,\n iosSourceMap,\n androidSourceMap,\n });\n\n if (\n validPostPublishHooks.length ||\n (exp.ios && exp.ios.publishManifestPath) ||\n (exp.android && exp.android.publishManifestPath)\n ) {\n let [androidManifest, iosManifest] = await Promise.all([\n ExponentTools.getManifestAsync(response.url, {\n 'Exponent-SDK-Version': exp.sdkVersion,\n 'Exponent-Platform': 'android',\n 'Expo-Release-Channel': options.releaseChannel,\n }),\n ExponentTools.getManifestAsync(response.url, {\n 'Exponent-SDK-Version': exp.sdkVersion,\n 'Exponent-Platform': 'ios',\n 'Expo-Release-Channel': options.releaseChannel,\n }),\n ]);\n\n const hookOptions = {\n url: response.url,\n exp,\n iosBundle,\n iosSourceMap,\n iosManifest,\n androidBundle,\n androidSourceMap,\n androidManifest,\n projectRoot,\n log: msg => {\n logger.global.info({ quiet: true }, msg);\n },\n };\n\n for (let hook of validPostPublishHooks) {\n logger.global.info(`Running postPublish hook: ${hook.file}`);\n try {\n let result = hook._fn({\n config: hook.config,\n ...hookOptions,\n });\n\n // If it's a promise, wait for it to resolve\n if (result && result.then) {\n result = await result;\n }\n\n if (result) {\n logger.global.info({ quiet: true }, result);\n }\n } catch (e) {\n logger.global.warn(`Warning: postPublish hook '${hook.file}' failed: ${e.stack}`);\n }\n }\n\n if (exp.ios && exp.ios.publishManifestPath) {\n await _writeArtifactSafelyAsync(\n projectRoot,\n 'ios.publishManifestPath',\n exp.ios.publishManifestPath,\n JSON.stringify(iosManifest)\n );\n }\n\n if (exp.android && exp.android.publishManifestPath) {\n await _writeArtifactSafelyAsync(\n projectRoot,\n 'android.publishManifestPath',\n exp.android.publishManifestPath,\n JSON.stringify(androidManifest)\n );\n }\n }\n\n // TODO: move to postPublish hook\n if (exp.isKernel) {\n await _handleKernelPublishedAsync({\n user,\n exp,\n projectRoot,\n url: response.url,\n });\n }\n\n return response;\n}\n\nasync function _uploadArtifactsAsync({ exp, iosBundle, androidBundle, options }) {\n logger.global.info('Uploading JavaScript bundles');\n let formData = new FormData();\n\n formData.append('expJson', JSON.stringify(exp));\n formData.append('iosBundle', _createBlob(iosBundle), 'iosBundle');\n formData.append('androidBundle', _createBlob(androidBundle), 'androidBundle');\n formData.append('options', JSON.stringify(options));\n let response = await Api.callMethodAsync('publish', null, 'put', null, {\n formData,\n });\n return response;\n}\n\nasync function _validatePackagerReadyAsync(projectRoot) {\n _assertValidProjectRoot(projectRoot);\n\n // Ensure the packager is started\n let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n if (!packagerInfo.packagerPort) {\n throw new XDLError(\n ErrorCode.NO_PACKAGER_PORT,\n `No packager found for project at ${projectRoot}.`\n );\n }\n}\n\nasync function _getPublishExpConfigAsync(projectRoot, options) {\n let schema = joi.object().keys({\n releaseChannel: joi.string(),\n });\n\n // Validate schema\n try {\n await joiValidateAsync(options, schema);\n options.releaseChannel = options.releaseChannel || 'default'; // joi default not enforcing this :/\n } catch (e) {\n throw new XDLError(ErrorCode.INVALID_OPTIONS, e.toString());\n }\n\n // Verify that exp/app.json and package.json exist\n let { exp, pkg } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n if (!exp || !pkg) {\n const configName = await ProjectUtils.configFilenameAsync(projectRoot);\n throw new XDLError(\n ErrorCode.NO_PACKAGE_JSON,\n `Couldn't read ${configName} file in project at ${projectRoot}`\n );\n }\n\n // Support version and name being specified in package.json for legacy\n // support pre: exp.json\n if (!exp.version && pkg.version) {\n exp.version = pkg.version;\n }\n\n if (!exp.slug && pkg.name) {\n exp.slug = pkg.name;\n }\n\n if (exp.android && exp.android.config) {\n delete exp.android.config;\n }\n\n if (exp.ios && exp.ios.config) {\n delete exp.ios.config;\n }\n\n // Only allow projects to be published with UNVERSIONED if a correct token is set in env\n if (exp.sdkVersion === 'UNVERSIONED' && !process.env['EXPO_SKIP_MANIFEST_VALIDATION_TOKEN']) {\n throw new XDLError(ErrorCode.INVALID_OPTIONS, 'Cannot publish with sdkVersion UNVERSIONED.');\n }\n\n return exp;\n}\n\n// Fetch iOS and Android bundles for publishing\nasync function _buildPublishBundlesAsync(projectRoot) {\n let entryPoint = await Exp.determineEntryPointAsync(projectRoot);\n let publishUrl = await UrlUtils.constructPublishUrlAsync(projectRoot, entryPoint);\n\n logger.global.info('Building iOS bundle');\n let iosBundle = await _getForPlatformAsync(projectRoot, publishUrl, 'ios', {\n errorCode: ErrorCode.INVALID_BUNDLE,\n minLength: MINIMUM_BUNDLE_SIZE,\n });\n\n logger.global.info('Building Android bundle');\n let androidBundle = await _getForPlatformAsync(projectRoot, publishUrl, 'android', {\n errorCode: ErrorCode.INVALID_BUNDLE,\n minLength: MINIMUM_BUNDLE_SIZE,\n });\n\n return { iosBundle, androidBundle };\n}\n\n// note(brentvatne): currently we build source map anytime there is a\n// postPublish hook -- we may have an option in the future to manually\n// enable sourcemap building, but for now it's very fast, most apps in\n// production should use sourcemaps for error reporting, and in the worst\n// case, adding a few seconds to a postPublish hook isn't too annoying\nasync function _maybeBuildSourceMapsAsync(projectRoot, exp, options = {}) {\n if (!options.force) {\n return { iosSourceMap: null, androidSourceMap: null };\n }\n\n let entryPoint = await Exp.determineEntryPointAsync(projectRoot);\n let sourceMapUrl = await UrlUtils.constructSourceMapUrlAsync(projectRoot, entryPoint);\n\n logger.global.info('Building sourcemaps');\n let iosSourceMap = await _getForPlatformAsync(projectRoot, sourceMapUrl, 'ios', {\n errorCode: ErrorCode.INVALID_BUNDLE,\n minLength: MINIMUM_BUNDLE_SIZE,\n });\n\n let androidSourceMap = await _getForPlatformAsync(projectRoot, sourceMapUrl, 'android', {\n errorCode: ErrorCode.INVALID_BUNDLE,\n minLength: MINIMUM_BUNDLE_SIZE,\n });\n\n return { iosSourceMap, androidSourceMap };\n}\n\nasync function _fetchAndUploadAssetsAsync(projectRoot, exp) {\n logger.global.info('Analyzing assets');\n\n let entryPoint = await Exp.determineEntryPointAsync(projectRoot);\n let assetsUrl = await UrlUtils.constructAssetsUrlAsync(projectRoot, entryPoint);\n\n let iosAssetsJson = await _getForPlatformAsync(projectRoot, assetsUrl, 'ios', {\n errorCode: ErrorCode.INVALID_ASSETS,\n });\n\n let androidAssetsJson = await _getForPlatformAsync(projectRoot, assetsUrl, 'android', {\n errorCode: ErrorCode.INVALID_ASSETS,\n });\n\n // Resolve manifest assets to their S3 URL and add them to the list of assets to\n // be uploaded\n const manifestAssets = [];\n await _resolveManifestAssets(\n projectRoot,\n exp,\n async assetPath => {\n const absolutePath = path.resolve(projectRoot, assetPath);\n const contents = await fs.readFile(absolutePath);\n const hash = md5hex(contents);\n manifestAssets.push({ files: [absolutePath], fileHashes: [hash] });\n return 'https://d1wp6m56sqw74a.cloudfront.net/~assets/' + hash;\n },\n true\n );\n\n logger.global.info('Uploading assets');\n\n // Upload asset files\n const iosAssets = JSON.parse(iosAssetsJson);\n const androidAssets = JSON.parse(androidAssetsJson);\n const assets = iosAssets.concat(androidAssets).concat(manifestAssets);\n if (assets.length > 0 && assets[0].fileHashes) {\n await uploadAssetsAsync(projectRoot, assets);\n } else {\n logger.global.info({ quiet: true }, 'No assets to upload, skipped.');\n }\n\n // Convert asset patterns to a list of asset strings that match them.\n // Assets strings are formatted as `asset_<hash>.<type>` and represent\n // the name that the file will have in the app bundle. The `asset_` prefix is\n // needed because android doesn't support assets that start with numbers.\n if (exp.assetBundlePatterns) {\n const fullPatterns = exp.assetBundlePatterns.map(p => path.join(projectRoot, p));\n // The assets returned by the RN packager has duplicates so make sure we\n // only bundle each once.\n const bundledAssets = new Set();\n for (const asset of assets) {\n const file = asset.files && asset.files[0];\n if (asset.__packager_asset && file && fullPatterns.some(p => minimatch(file, p))) {\n bundledAssets.add('asset_' + asset.hash + (asset.type ? '.' + asset.type : ''));\n }\n }\n exp.bundledAssets = [...bundledAssets];\n delete exp.assetBundlePatterns;\n }\n\n return exp;\n}\n\nasync function _writeArtifactSafelyAsync(projectRoot, keyName, artifactPath, artifact) {\n const pathToWrite = path.resolve(projectRoot, artifactPath);\n if (!fs.existsSync(path.dirname(pathToWrite))) {\n logger.global.warn(\n `app.json specifies ${keyName}: ${pathToWrite}, but that directory does not exist.`\n );\n } else {\n await fs.writeFile(pathToWrite, artifact);\n }\n}\n\nasync function _maybeWriteArtifactsToDiskAsync({\n exp,\n projectRoot,\n iosBundle,\n androidBundle,\n iosSourceMap,\n androidSourceMap,\n}) {\n if (exp.android && exp.android.publishBundlePath) {\n await _writeArtifactSafelyAsync(\n projectRoot,\n 'android.publishBundlePath',\n exp.android.publishBundlePath,\n androidBundle\n );\n }\n\n if (exp.ios && exp.ios.publishBundlePath) {\n await _writeArtifactSafelyAsync(\n projectRoot,\n 'ios.publishBundlePath',\n exp.ios.publishBundlePath,\n iosBundle\n );\n }\n\n if (exp.android && exp.android.publishSourceMapPath) {\n await _writeArtifactSafelyAsync(\n projectRoot,\n 'android.publishSourceMapPath',\n exp.android.publishSourceMapPath,\n androidSourceMap\n );\n }\n\n if (exp.ios && exp.ios.publishSourceMapPath) {\n await _writeArtifactSafelyAsync(\n projectRoot,\n 'ios.publishSourceMapPath',\n exp.ios.publishSourceMapPath,\n iosSourceMap\n );\n }\n}\n\nasync function _handleKernelPublishedAsync({ projectRoot, user, exp, url }) {\n let kernelBundleUrl = `${Config.api.scheme}://${Config.api.host}`;\n if (Config.api.port) {\n kernelBundleUrl = `${kernelBundleUrl}:${Config.api.port}`;\n }\n kernelBundleUrl = `${kernelBundleUrl}/@${user.username}/${exp.slug}/bundle`;\n\n if (exp.kernel.androidManifestPath) {\n let manifest = await ExponentTools.getManifestAsync(url, {\n 'Exponent-SDK-Version': exp.sdkVersion,\n 'Exponent-Platform': 'android',\n });\n manifest.bundleUrl = kernelBundleUrl;\n manifest.sdkVersion = 'UNVERSIONED';\n await fs.writeFile(\n path.resolve(projectRoot, exp.kernel.androidManifestPath),\n JSON.stringify(manifest)\n );\n }\n\n if (exp.kernel.iosManifestPath) {\n let manifest = await ExponentTools.getManifestAsync(url, {\n 'Exponent-SDK-Version': exp.sdkVersion,\n 'Exponent-Platform': 'ios',\n });\n manifest.bundleUrl = kernelBundleUrl;\n manifest.sdkVersion = 'UNVERSIONED';\n await fs.writeFile(\n path.resolve(projectRoot, exp.kernel.iosManifestPath),\n JSON.stringify(manifest)\n );\n }\n}\n\n// TODO(jesse): Add analytics for upload\nasync function uploadAssetsAsync(projectRoot, assets) {\n // Collect paths by key, also effectively handles duplicates in the array\n const paths = {};\n assets.forEach(asset => {\n asset.files.forEach((path, index) => {\n paths[asset.fileHashes[index]] = path;\n });\n });\n\n // Collect list of assets missing on host\n const metas = (await Api.callMethodAsync('assetsMetadata', [], 'post', {\n keys: Object.keys(paths),\n })).metadata;\n const missing = Object.keys(paths).filter(key => !metas[key].exists);\n\n if (missing.length === 0) {\n logger.global.info({ quiet: true }, `No assets changed, skipped.`);\n }\n\n // Upload them!\n await Promise.all(\n _.chunk(missing, 5).map(async keys => {\n let formData = new FormData();\n for (const key of keys) {\n ProjectUtils.logDebug(projectRoot, 'expo', `uploading ${paths[key]}`);\n\n let relativePath = paths[key].replace(projectRoot, '');\n logger.global.info({ quiet: true }, `Uploading ${relativePath}`);\n\n formData.append(key, await _readFileForUpload(paths[key]), paths[key]);\n }\n await Api.callMethodAsync('uploadAssets', [], 'put', null, { formData });\n })\n );\n}\n\nfunction _createBlob(string) {\n if (isNode()) {\n return string;\n } else {\n return new Blob([string]);\n }\n}\n\nasync function _readFileForUpload(path) {\n if (isNode()) {\n return fs.createReadStream(path);\n } else {\n const data = await fs.readFile(path);\n return new Blob([data]);\n }\n}\n\nexport async function buildAsync(\n projectRoot: string,\n options: {\n current?: boolean,\n mode?: string,\n platform?: string,\n expIds?: Array<string>,\n type?: string,\n releaseChannel?: string,\n } = {}\n) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n\n Analytics.logEvent('Build Shell App', {\n projectRoot,\n });\n\n let schema = joi.object().keys({\n current: joi.boolean(),\n mode: joi.string(),\n platform: joi.any().valid('ios', 'android', 'all'),\n expIds: joi.array(),\n type: joi.any().valid('archive', 'simulator'),\n releaseChannel: joi.string().regex(/[a-z\\d][a-z\\d._-]*/),\n });\n\n try {\n await joiValidateAsync(options, schema);\n } catch (e) {\n throw new XDLError(ErrorCode.INVALID_OPTIONS, e.toString());\n }\n\n let { exp, pkg } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n const configName = await ProjectUtils.configFilenameAsync(projectRoot);\n const configPrefix = configName === 'app.json' ? 'expo.' : '';\n\n if (!exp || !pkg) {\n throw new XDLError(\n ErrorCode.NO_PACKAGE_JSON,\n `Couldn't read ${configName} file in project at ${projectRoot}`\n );\n }\n\n // Support version and name being specified in package.json for legacy\n // support pre: exp.json\n if (!exp.version && pkg.version) {\n exp.version = pkg.version;\n }\n if (!exp.slug && pkg.name) {\n exp.slug = pkg.name;\n }\n\n if (options.platform === 'ios' || options.platform === 'all') {\n if (!exp.ios || !exp.ios.bundleIdentifier) {\n throw new XDLError(\n ErrorCode.INVALID_MANIFEST,\n `Must specify a bundle identifier in order to build this experience for iOS. Please specify one in ${configName} at \"${configPrefix}ios.bundleIdentifier\"`\n );\n }\n }\n\n if (options.platform === 'android' || options.platform === 'all') {\n if (!exp.android || !exp.android.package) {\n throw new XDLError(\n ErrorCode.INVALID_MANIFEST,\n `Must specify a java package in order to build this experience for Android. Please specify one in ${configName} at \"${configPrefix}android.package\"`\n );\n }\n }\n\n let response = await Api.callMethodAsync('build', [], 'put', {\n manifest: exp,\n options,\n });\n\n return response;\n}\n\nasync function _waitForRunningAsync(url) {\n try {\n let response = await request(url);\n // Looking for \"Cached Bundles\" string is hacky, but unfortunately\n // ngrok returns a 200 when it succeeds but the port it's proxying\n // isn't bound.\n if (\n response.statusCode >= 200 &&\n response.statusCode < 300 &&\n response.body &&\n response.body.includes('packager-status:running')\n ) {\n return true;\n }\n } catch (e) {\n // Try again after delay\n }\n\n await delayAsync(100);\n return _waitForRunningAsync(url);\n}\n\nfunction _stripPackagerOutputBox(output: string) {\n let re = /Running packager on port (\\d+)/;\n let found = output.match(re);\n if (found && found.length >= 2) {\n return `Running packager on port ${found[1]}\\n`;\n } else {\n return null;\n }\n}\n\nfunction _processPackagerLine(line: string) {\n // [10:02:59 AM]\n let timestampRe = /\\s*\\[\\d+\\:\\d+\\:\\d+\\ (AM)?(PM)?\\]\\s+/;\n // [11/8/2016, 10:02:59 AM]\n let sdk11AndUpTimestampRe = /\\s*\\[\\d+\\/\\d+\\/\\d+, \\d+\\:\\d+\\:\\d+\\ (AM)?(PM)?\\]\\s+/;\n return line.replace(timestampRe, '').replace(sdk11AndUpTimestampRe, '');\n}\n\nasync function _restartWatchmanAsync(projectRoot: string) {\n try {\n let result = await spawnAsync('watchman', ['watch-del', projectRoot]);\n await spawnAsync('watchman', ['watch-project', projectRoot]);\n if (result.stdout.includes('root')) {\n ProjectUtils.logInfo(projectRoot, 'expo', 'Restarted watchman.');\n return;\n }\n } catch (e) {}\n\n ProjectUtils.logError(\n projectRoot,\n 'expo',\n 'Attempted to restart watchman but failed. Please try running `watchman watch-del-all`.'\n );\n}\n\nfunction _parseModuleResolutionError(projectRoot: string, errorMessage: string) {\n let parts = errorMessage.split(' from ');\n let moduleName = parts[0]\n .replace(/.*?Unable to resolve module /, '')\n .replace(/`/g, '')\n .trim();\n let path = parts[1]\n .replace(/`: Module .*/, '')\n .replace(/`/, '')\n .trim();\n let relativePath = path.replace(projectRoot, '').trim();\n\n return {\n moduleName,\n relativePath,\n path,\n };\n}\n\nconst NODE_STDLIB_MODULES = [\n 'assert',\n 'async_hooks',\n 'buffer',\n 'child_process',\n 'cluster',\n 'crypto',\n 'dgram',\n 'dns',\n 'domain',\n 'events',\n 'fs',\n 'http',\n 'https',\n 'net',\n 'os',\n 'path',\n 'punycode',\n 'querystring',\n 'readline',\n 'repl',\n 'stream',\n 'string_decoder',\n 'tls',\n 'tty',\n 'url',\n 'util',\n 'v8',\n 'vm',\n 'zlib',\n];\n\nfunction _logModuleResolutionError(projectRoot: string, errorMessage: string) {\n let { moduleName, relativePath, path } = _parseModuleResolutionError(projectRoot, errorMessage);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.io/versions/latest/introduction/faq.html#can-i-use-nodejs-packages-with-expo';\n\n if (NODE_STDLIB_MODULES.includes(moduleName)) {\n if (path.includes('node_modules')) {\n ProjectUtils.logError(\n projectRoot,\n 'packager',\n `The package at \".${relativePath}\" attempted to import the Node standard library module \"${moduleName}\". It failed because React Native does not include the Node standard library. Read more at ${DOCS_PAGE_URL}`\n );\n } else {\n ProjectUtils.logError(\n projectRoot,\n 'packager',\n `You attempted attempted to import the Node standard library module \"${moduleName}\" from \".${relativePath}\". It failed because React Native does not include the Node standard library. Read more at ${DOCS_PAGE_URL}`\n );\n }\n } else {\n ProjectUtils.logError(\n projectRoot,\n 'packager',\n `Unable to resolve ${moduleName}\" from \"./${relativePath}\"`\n );\n }\n}\n\nfunction _logPackagerOutput(projectRoot: string, level: string, data: Object) {\n let output = data.toString();\n if (output.includes('─────')) {\n output = _stripPackagerOutputBox(output);\n if (output) {\n ProjectUtils.logInfo(projectRoot, 'expo', output);\n }\n return;\n }\n if (!output) {\n return;\n } // Fix watchman if it's being dumb\n if (Watchman.isPlatformSupported() && output.includes('watchman watch-del')) {\n // Skip this as it is likely no longer needed. We may want to add a message\n // in this place in the event that there are still issues reported that could\n // be resolved by restarting watchman when the log output includes this message.\n // _restartWatchmanAsync(projectRoot);\n return;\n }\n\n if (output.includes('Unable to resolve module')) {\n _logModuleResolutionError(projectRoot, output);\n }\n\n // Temporarily hide warnings about duplicate providesModule declarations\n // under react-native\n if (_isIgnorableDuplicateModuleWarning(projectRoot, level, output)) {\n ProjectUtils.logDebug(\n projectRoot,\n 'expo',\n `Suppressing @providesModule warning: ${output}`,\n 'project-suppress-providesmodule-warning'\n );\n return;\n }\n let lines = output.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i++) {\n lines[i] = _processPackagerLine(lines[i]);\n }\n output = lines.join('\\n');\n if (level === 'info') {\n ProjectUtils.logInfo(projectRoot, 'packager', output);\n } else {\n ProjectUtils.logError(projectRoot, 'packager', output);\n }\n}\n\nfunction _isIgnorableDuplicateModuleWarning(\n projectRoot: string,\n level: string,\n output: string\n): boolean {\n if (\n level !== 'error' ||\n !output.startsWith('jest-haste-map: @providesModule naming collision:')\n ) {\n return false;\n }\n\n let reactNativeNodeModulesPath = path.join(\n projectRoot,\n 'node_modules',\n 'react-native',\n 'node_modules'\n );\n let reactNativeNodeModulesPattern = _.escapeRegExp(reactNativeNodeModulesPath);\n let reactNativeNodeModulesCollisionRegex = new RegExp(\n `Paths: ${reactNativeNodeModulesPattern}.+ collides with ${reactNativeNodeModulesPattern}.+`\n );\n return reactNativeNodeModulesCollisionRegex.test(output);\n}\n\nfunction _handleDeviceLogs(projectRoot: string, deviceId: string, deviceName: string, logs: any) {\n for (let i = 0; i < logs.length; i++) {\n let log = logs[i];\n let body = typeof log.body === 'string' ? [log.body] : log.body;\n let string = body\n .map(obj => {\n if (typeof obj === 'undefined') {\n return 'undefined';\n }\n if (obj === 'null') {\n return 'null';\n }\n if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {\n return obj;\n }\n try {\n return JSON.stringify(obj);\n } catch (e) {\n return obj.toString();\n }\n })\n .join(' ');\n let level = log.level;\n let groupDepth = log.groupDepth;\n let shouldHide = log.shouldHide;\n let includesStack = log.includesStack;\n\n ProjectUtils.logWithLevel(\n projectRoot,\n level,\n {\n tag: 'device',\n deviceId,\n deviceName,\n groupDepth,\n shouldHide,\n includesStack,\n },\n string\n );\n }\n}\nexport async function startReactNativeServerAsync(\n projectRoot: string,\n options: Object = {},\n verbose: boolean = true\n) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n await stopReactNativeServerAsync(projectRoot);\n await Watchman.addToPathAsync(); // Attempt to fix watchman if it's hanging\n await Watchman.unblockAndGetVersionAsync(projectRoot);\n\n let { exp } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n\n let packagerPort = await _getFreePortAsync(19001); // Create packager options\n let nodeModulesPath = exp.nodeModulesPath\n ? path.join(path.resolve(projectRoot, exp.nodeModulesPath), 'node_modules')\n : path.join(projectRoot, 'node_modules');\n let packagerOpts = {\n port: packagerPort,\n customLogReporterPath: path.join(nodeModulesPath, 'expo', 'tools', 'LogReporter'),\n assetExts: ['ttf'],\n nonPersistent: !!options.nonPersistent,\n };\n\n if (!Versions.gteSdkVersion(exp, '16.0.0')) {\n delete packagerOpts.customLogReporterPath;\n }\n const userPackagerOpts = _.get(exp, 'packagerOpts');\n if (userPackagerOpts) {\n // The RN CLI expects rn-cli.config.js's path to be absolute. We use the\n // project root to resolve relative paths since that was the original\n // behavior of the RN CLI.\n if (userPackagerOpts.config) {\n userPackagerOpts.config = path.resolve(projectRoot, userPackagerOpts.config);\n }\n\n packagerOpts = {\n ...packagerOpts,\n ...userPackagerOpts,\n ...(userPackagerOpts.assetExts\n ? {\n assetExts: _.uniq([...packagerOpts.assetExts, ...userPackagerOpts.assetExts]),\n }\n : {}),\n };\n }\n let cliOpts = _.reduce(\n packagerOpts,\n (opts, val, key) => {\n // If the packager opt value is boolean, don't set\n // --[opt] [value], just set '--opt'\n if (val && typeof val === 'boolean') {\n opts.push(`--${key}`);\n } else if (val) {\n opts.push(`--${key}`, val);\n }\n return opts;\n },\n ['start']\n );\n if (options.reset) {\n cliOpts.push('--reset-cache');\n } // Get custom CLI path from project package.json, but fall back to node_module path\n let defaultCliPath = path.join(\n projectRoot,\n 'node_modules',\n 'react-native',\n 'local-cli',\n 'cli.js'\n );\n const cliPath = _.get(exp, 'rnCliPath', defaultCliPath);\n let nodePath; // When using a custom path for the RN CLI, we want it to use the project // root to look up config files and Node modules\n if (exp.rnCliPath) {\n nodePath = _nodePathForProjectRoot(projectRoot);\n } else {\n nodePath = null;\n }\n ProjectUtils.logInfo(projectRoot, 'expo', 'Starting React Native packager...'); // Run the copy of Node that's embedded in Electron by setting the // ELECTRON_RUN_AS_NODE environment variable // Note: the CLI script sets up graceful-fs and sets ulimit to 4096 in the // child process\n let packagerProcess = child_process.fork(cliPath, cliOpts, {\n cwd: projectRoot,\n env: {\n ...process.env,\n REACT_NATIVE_APP_ROOT: projectRoot,\n NODE_PATH: nodePath,\n ELECTRON_RUN_AS_NODE: 1,\n },\n silent: true,\n });\n await ProjectSettings.setPackagerInfoAsync(projectRoot, {\n packagerPort,\n packagerPid: packagerProcess.pid,\n }); // TODO: do we need this? don't know if it's ever called\n process.on('exit', () => {\n treekill(packagerProcess.pid);\n });\n packagerProcess.stdout.setEncoding('utf8');\n packagerProcess.stderr.setEncoding('utf8');\n packagerProcess.stdout.pipe(split()).on('data', data => {\n if (verbose) {\n _logPackagerOutput(projectRoot, 'info', data);\n }\n });\n packagerProcess.stderr.on('data', data => {\n if (verbose) {\n _logPackagerOutput(projectRoot, 'error', data);\n }\n });\n packagerProcess.on('exit', async code => {\n ProjectUtils.logDebug(projectRoot, 'expo', `packager process exited with code ${code}`);\n });\n let packagerUrl = await UrlUtils.constructBundleUrlAsync(projectRoot, {\n urlType: 'http',\n hostType: 'localhost',\n });\n await _waitForRunningAsync(`${packagerUrl}/status`);\n} // Simulate the node_modules resolution // If you project dir is /Jesse/Expo/Universe/BubbleBounce, returns // \"/Jesse/node_modules:/Jesse/Expo/node_modules:/Jesse/Expo/Universe/node_modules:/Jesse/Expo/Universe/BubbleBounce/node_modules\"\nfunction _nodePathForProjectRoot(projectRoot: string): string {\n let paths = [];\n let directory = path.resolve(projectRoot);\n while (true) {\n paths.push(path.join(directory, 'node_modules'));\n let parentDirectory = path.dirname(directory);\n if (directory === parentDirectory) {\n break;\n }\n directory = parentDirectory;\n }\n return paths.join(path.delimiter);\n}\nexport async function stopReactNativeServerAsync(projectRoot: string) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n if (!packagerInfo.packagerPort || !packagerInfo.packagerPid) {\n ProjectUtils.logDebug(projectRoot, 'expo', `No packager found for project at ${projectRoot}.`);\n return;\n }\n ProjectUtils.logDebug(\n projectRoot,\n 'expo',\n `Killing packager process tree: ${packagerInfo.packagerPid}`\n );\n try {\n await treekillAsync(packagerInfo.packagerPid, 'SIGKILL');\n } catch (e) {\n ProjectUtils.logDebug(projectRoot, 'expo', `Error stopping packager process: ${e.toString()}`);\n }\n await ProjectSettings.setPackagerInfoAsync(projectRoot, {\n packagerPort: null,\n packagerPid: null,\n });\n}\nexport async function startExpoServerAsync(projectRoot: string) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n await stopExpoServerAsync(projectRoot);\n let app = express();\n app.use(\n bodyParser.json({\n limit: '10mb',\n })\n );\n app.use(\n bodyParser.urlencoded({\n limit: '10mb',\n extended: true,\n })\n );\n if ((await Doctor.validateWithNetworkAsync(projectRoot)) === Doctor.FATAL) {\n throw new Error(`Couldn't start project. Please fix the errors and restart the project.`);\n } // Serve the manifest.\n let manifestHandler = async (req, res) => {\n try {\n // We intentionally don't `await`. We want to continue trying even\n // if there is a potential error in the package.json and don't want to slow\n // down the request\n Doctor.validateWithNetworkAsync(projectRoot);\n let { exp: manifest } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n if (!manifest) {\n const configName = await ProjectUtils.configFilenameAsync(projectRoot);\n throw new Error(`No ${configName} file found`);\n } // Get packager opts and then copy into bundleUrlPackagerOpts\n let packagerOpts = await ProjectSettings.getPackagerOptsAsync(projectRoot);\n let bundleUrlPackagerOpts = JSON.parse(JSON.stringify(packagerOpts));\n bundleUrlPackagerOpts.urlType = 'http';\n if (bundleUrlPackagerOpts.hostType === 'redirect') {\n bundleUrlPackagerOpts.hostType = 'tunnel';\n }\n manifest.xde = true; // deprecated\n manifest.developer = {\n tool: Config.developerTool,\n projectRoot,\n };\n manifest.packagerOpts = packagerOpts;\n manifest.env = {};\n for (let key of Object.keys(process.env)) {\n if (key.startsWith('REACT_NATIVE_') || key.startsWith('EXPO_')) {\n manifest.env[key] = process.env[key];\n }\n }\n let entryPoint = await Exp.determineEntryPointAsync(projectRoot);\n let platform = req.headers['exponent-platform'] || 'ios';\n entryPoint = UrlUtils.getPlatformSpecificBundleUrl(entryPoint, platform);\n let mainModuleName = UrlUtils.guessMainModulePath(entryPoint);\n let queryParams = await UrlUtils.constructBundleQueryParamsAsync(\n projectRoot,\n packagerOpts,\n req.hostname\n );\n let path = `/${mainModuleName}.bundle?platform=${platform}&${queryParams}`;\n manifest.bundleUrl =\n (await UrlUtils.constructBundleUrlAsync(projectRoot, bundleUrlPackagerOpts, req.hostname)) +\n path;\n manifest.debuggerHost = await UrlUtils.constructDebuggerHostAsync(projectRoot, req.hostname);\n manifest.mainModuleName = mainModuleName;\n manifest.logUrl = await UrlUtils.constructLogUrlAsync(projectRoot, req.hostname);\n await _resolveManifestAssets(\n projectRoot,\n manifest,\n async path => manifest.bundleUrl.match(/^https?:\\/\\/.*?\\//)[0] + 'assets/' + path\n ); // the server normally inserts this but if we're offline we'll do it here\n const hostUUID = await UserSettings.anonymousIdentifier();\n if (Config.offline) {\n manifest.id = `@anonymous/${manifest.slug}-${hostUUID}`;\n }\n let manifestString = JSON.stringify(manifest);\n let currentUser;\n if (!Config.offline) {\n currentUser = await UserManager.getCurrentUserAsync();\n }\n if (req.headers['exponent-accept-signature'] && (currentUser || Config.offline)) {\n if (_cachedSignedManifest.manifestString === manifestString) {\n manifestString = _cachedSignedManifest.signedManifest;\n } else {\n if (Config.offline) {\n const unsignedManifest = {\n manifestString,\n signature: 'UNSIGNED',\n };\n _cachedSignedManifest.manifestString = manifestString;\n manifestString = JSON.stringify(unsignedManifest);\n _cachedSignedManifest.signedManifest = manifestString;\n } else {\n let publishInfo = await Exp.getPublishInfoAsync(projectRoot);\n let signedManifest = await Api.callMethodAsync(\n 'signManifest',\n [publishInfo.args],\n 'post',\n manifest\n );\n _cachedSignedManifest.manifestString = manifestString;\n _cachedSignedManifest.signedManifest = signedManifest.response;\n manifestString = signedManifest.response;\n }\n }\n }\n const hostInfo = {\n host: hostUUID,\n server: 'xdl',\n serverVersion: require('../package.json').version,\n serverDriver: Config.developerTool,\n serverOS: os.platform(),\n serverOSVersion: os.release(),\n };\n res.append('Exponent-Server', JSON.stringify(hostInfo));\n res.send(manifestString);\n Analytics.logEvent('Serve Manifest', {\n projectRoot,\n });\n } catch (e) {\n ProjectUtils.logDebug(projectRoot, 'expo', `Error in manifestHandler: ${e} ${e.stack}`); // 5xx = Server Error HTTP code\n res.status(520).send({\n error: e.toString(),\n });\n }\n };\n app.get('/', manifestHandler);\n app.get('/manifest', manifestHandler);\n app.get('/index.exp', manifestHandler);\n app.post('/logs', async (req, res) => {\n try {\n let deviceId = req.get('Device-Id');\n let deviceName = req.get('Device-Name');\n if (deviceId && deviceName && req.body) {\n _handleDeviceLogs(projectRoot, deviceId, deviceName, req.body);\n }\n } catch (e) {\n ProjectUtils.logError(projectRoot, 'expo', `Error getting device logs: ${e} ${e.stack}`);\n }\n res.send('Success');\n });\n app.post('/shutdown', async (req, res) => {\n server.close();\n res.send('Success');\n });\n let expRc = await ProjectUtils.readExpRcAsync(projectRoot);\n let expoServerPort = expRc.manifestPort ? expRc.manifestPort : await _getFreePortAsync(19000);\n await ProjectSettings.setPackagerInfoAsync(projectRoot, {\n expoServerPort,\n });\n let server = app.listen(expoServerPort, () => {\n let host = server.address().address;\n let port = server.address().port;\n ProjectUtils.logDebug(projectRoot, 'expo', `Local server listening at http://${host}:${port}`);\n });\n await Exp.saveRecentExpRootAsync(projectRoot);\n}\nexport async function stopExpoServerAsync(projectRoot: string) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n if (packagerInfo && packagerInfo.expoServerPort) {\n try {\n await request.post(`http://localhost:${packagerInfo.expoServerPort}/shutdown`);\n } catch (e) {}\n }\n await ProjectSettings.setPackagerInfoAsync(projectRoot, {\n expoServerPort: null,\n });\n}\nasync function _connectToNgrokAsync(\n projectRoot: string,\n args: mixed,\n hostnameAsync: Function,\n ngrokPid: ?number,\n attempts: number = 0\n) {\n try {\n let configPath = path.join(UserSettings.dotExpoHomeDirectory(), 'ngrok.yml');\n let hostname = await hostnameAsync();\n let url = await ngrokConnectAsync({\n hostname,\n configPath,\n ...args,\n });\n return url;\n } catch (e) {\n // Attempt to connect 3 times\n if (attempts >= 2) {\n if (e.message) {\n throw new XDLError(ErrorCode.NGROK_ERROR, e.toString());\n } else {\n throw new XDLError(ErrorCode.NGROK_ERROR, JSON.stringify(e));\n }\n }\n if (!attempts) {\n attempts = 0;\n } // Attempt to fix the issue\n if (e.error_code && e.error_code === 103) {\n if (attempts === 0) {\n // Failed to start tunnel. Might be because url already bound to another session.\n if (ngrokPid) {\n try {\n process.kill(ngrokPid, 'SIGKILL');\n } catch (e) {\n ProjectUtils.logDebug(projectRoot, 'expo', `Couldn't kill ngrok with PID ${ngrokPid}`);\n }\n } else {\n await ngrokKillAsync();\n }\n } else {\n // Change randomness to avoid conflict if killing ngrok didn't help\n await Exp.resetProjectRandomnessAsync(projectRoot);\n }\n } // Wait 100ms and then try again\n await delayAsync(100);\n return _connectToNgrokAsync(projectRoot, args, hostnameAsync, null, attempts + 1);\n }\n}\n\nexport async function startTunnelsAsync(projectRoot: string) {\n const user = await UserManager.ensureLoggedInAsync();\n if (!user) {\n throw new Error('Internal error -- tunnel started in offline mode.');\n }\n _assertValidProjectRoot(projectRoot);\n let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n if (!packagerInfo.packagerPort) {\n throw new XDLError(\n ErrorCode.NO_PACKAGER_PORT,\n `No packager found for project at ${projectRoot}.`\n );\n }\n if (!packagerInfo.expoServerPort) {\n throw new XDLError(\n ErrorCode.NO_EXPO_SERVER_PORT,\n `No Expo server found for project at ${projectRoot}.`\n );\n }\n await stopTunnelsAsync(projectRoot);\n if (await Android.startAdbReverseAsync(projectRoot)) {\n ProjectUtils.logInfo(\n projectRoot,\n 'expo',\n 'Successfully ran `adb reverse`. Localhost urls should work on the connected Android device.',\n 'project-adb-reverse'\n );\n } else {\n ProjectUtils.clearNotification(projectRoot, 'project-adb-reverse');\n }\n const { username } = user;\n let packageShortName = path.parse(projectRoot).base;\n let expRc = await ProjectUtils.readExpRcAsync(projectRoot);\n\n ngrok.addListener('statuschange', status => {\n if (status === 'reconnecting') {\n ProjectUtils.logError(\n projectRoot,\n 'expo',\n 'We noticed your tunnel is having issues. This may be due to intermittent problems with our tunnel provider. If you have trouble connecting to your app, try to Restart the project, or switch Host to LAN.'\n );\n } else if (status === 'online') {\n ProjectUtils.logInfo(projectRoot, 'expo', 'Tunnel connected.');\n }\n });\n\n try {\n let startedTunnelsSuccessfully = false;\n\n // Some issues with ngrok cause it to hang indefinitely. After\n // TUNNEL_TIMEOUTms we just throw an error.\n await Promise.race([\n (async () => {\n await delayAsync(TUNNEL_TIMEOUT);\n if (!startedTunnelsSuccessfully) {\n throw new Error('Starting tunnels timed out');\n }\n })(),\n (async () => {\n let expoServerNgrokUrl = await _connectToNgrokAsync(\n projectRoot,\n {\n authtoken: Config.ngrok.authToken,\n port: packagerInfo.expoServerPort,\n proto: 'http',\n },\n async () => {\n let randomness = expRc.manifestTunnelRandomness\n ? expRc.manifestTunnelRandomness\n : await Exp.getProjectRandomnessAsync(projectRoot);\n return [\n randomness,\n UrlUtils.domainify(username),\n UrlUtils.domainify(packageShortName),\n Config.ngrok.domain,\n ].join('.');\n },\n packagerInfo.ngrokPid\n );\n let packagerNgrokUrl = await _connectToNgrokAsync(\n projectRoot,\n {\n authtoken: Config.ngrok.authToken,\n port: packagerInfo.packagerPort,\n proto: 'http',\n },\n async () => {\n let randomness = expRc.manifestTunnelRandomness\n ? expRc.manifestTunnelRandomness\n : await Exp.getProjectRandomnessAsync(projectRoot);\n return [\n 'packager',\n randomness,\n UrlUtils.domainify(username),\n UrlUtils.domainify(packageShortName),\n Config.ngrok.domain,\n ].join('.');\n },\n packagerInfo.ngrokPid\n );\n await ProjectSettings.setPackagerInfoAsync(projectRoot, {\n expoServerNgrokUrl,\n packagerNgrokUrl,\n ngrokPid: ngrok.process().pid,\n });\n\n startedTunnelsSuccessfully = true;\n })(),\n ]);\n } catch (e) {\n ProjectUtils.logError(projectRoot, 'expo', `Error starting tunnel: ${e.toString()}`);\n throw e;\n }\n}\nexport async function stopTunnelsAsync(projectRoot: string) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot); // This will kill all ngrok tunnels in the process. // We'll need to change this if we ever support more than one project // open at a time in XDE.\n let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n let ngrokProcess = ngrok.process();\n let ngrokProcessPid = ngrokProcess ? ngrokProcess.pid : null;\n ngrok.removeAllListeners('statuschange');\n if (packagerInfo.ngrokPid && packagerInfo.ngrokPid !== ngrokProcessPid) {\n // Ngrok is running in some other process. Kill at the os level.\n try {\n process.kill(packagerInfo.ngrokPid);\n } catch (e) {\n ProjectUtils.logDebug(\n projectRoot,\n 'expo',\n `Couldn't kill ngrok with PID ${packagerInfo.ngrokPid}`\n );\n }\n } else {\n // Ngrok is running from the current process. Kill using ngrok api.\n await ngrokKillAsync();\n }\n await ProjectSettings.setPackagerInfoAsync(projectRoot, {\n expoServerNgrokUrl: null,\n packagerNgrokUrl: null,\n ngrokPid: null,\n });\n await Android.stopAdbReverseAsync(projectRoot);\n}\n\nexport async function setOptionsAsync(\n projectRoot: string,\n options: {\n packagerPort?: number,\n }\n) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot); // Check to make sure all options are valid\n let schema = joi.object().keys({\n packagerPort: joi.number().integer(),\n });\n try {\n await joiValidateAsync(options, schema);\n } catch (e) {\n throw new XDLError(ErrorCode.INVALID_OPTIONS, e.toString());\n }\n await ProjectSettings.setPackagerInfoAsync(projectRoot, options);\n}\nexport async function getUrlAsync(projectRoot: string, options: Object = {}) {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n return await UrlUtils.constructManifestUrlAsync(projectRoot, options);\n}\n\nexport async function startAsync(\n projectRoot: string,\n options: Object = {},\n verbose: boolean = true\n): Promise<any> {\n await UserManager.ensureLoggedInAsync();\n _assertValidProjectRoot(projectRoot);\n Analytics.logEvent('Start Project', {\n projectRoot,\n });\n await startExpoServerAsync(projectRoot);\n await startReactNativeServerAsync(projectRoot, options, verbose);\n if (!Config.offline) {\n try {\n await startTunnelsAsync(projectRoot);\n } catch (e) {\n ProjectUtils.logDebug(projectRoot, 'expo', `Error starting ngrok ${e.message}`);\n }\n }\n let { exp } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n return exp;\n}\nasync function _stopInternalAsync(projectRoot: string): Promise<void> {\n await stopExpoServerAsync(projectRoot);\n await stopReactNativeServerAsync(projectRoot);\n if (!Config.offline) {\n try {\n await stopTunnelsAsync(projectRoot);\n } catch (e) {\n ProjectUtils.logDebug(projectRoot, 'expo', `Error stopping ngrok ${e.message}`);\n }\n }\n}\nexport async function stopAsync(projectDir: string): Promise<void> {\n const result = await Promise.race([\n _stopInternalAsync(projectDir),\n new Promise((resolve, reject) => setTimeout(resolve, 2000, 'stopFailed')),\n ]);\n if (result === 'stopFailed') {\n // find RN packager and ngrok pids, attempt to kill them manually\n const { packagerPid, ngrokPid } = await ProjectSettings.readPackagerInfoAsync(projectDir);\n if (packagerPid) {\n try {\n process.kill(packagerPid);\n } catch (e) {}\n }\n if (ngrokPid) {\n try {\n process.kill(ngrokPid);\n } catch (e) {}\n }\n await ProjectSettings.setPackagerInfoAsync(projectDir, {\n expoServerPort: null,\n packagerPort: null,\n packagerPid: null,\n expoServerNgrokUrl: null,\n packagerNgrokUrl: null,\n ngrokPid: null,\n });\n }\n}\n"],"sourceRoot":"/xdl/src"}