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yB;AAE9B;AAF8B,OAA1B,CAAN;AAID;AACF,G;;kBAzDW,O","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { asArray, log, spawn } from \"builder-util\"\nimport { exists } from \"builder-util/out/fs\"\nimport { Lazy } from \"lazy-val\"\nimport { homedir } from \"os\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { Dependency } from \"./packageDependencies\"\n\nexport async function installOrRebuild(config: Configuration, appDir: string, options: RebuildOptions, forceInstall: boolean = false) {\n const effectiveOptions = {\n buildFromSource: config.buildDependenciesFromSource === true,\n additionalArgs: asArray(config.npmArgs), ...options\n }\n\n if (forceInstall || !(await exists(path.join(appDir, \"node_modules\")))) {\n await installDependencies(appDir, effectiveOptions)\n }\n else {\n await rebuild(appDir, effectiveOptions)\n }\n}\n\nexport interface DesktopFrameworkInfo {\n version: string\n useCustomDist: boolean\n}\n\nfunction getElectronGypCacheDir() {\n return path.join(homedir(), \".electron-gyp\")\n}\n\nexport function getGypEnv(frameworkInfo: DesktopFrameworkInfo, platform: NodeJS.Platform, arch: string, buildFromSource: boolean) {\n const npmConfigArch = arch === \"armv7l\" ? \"arm\" : arch\n const common: any = {\n ...process.env,\n npm_config_arch: npmConfigArch,\n npm_config_target_arch: npmConfigArch,\n npm_config_platform: platform,\n npm_config_build_from_source: buildFromSource,\n // required for node-pre-gyp\n npm_config_target_platform: platform,\n npm_config_update_binary: true,\n npm_config_fallback_to_build: true,\n }\n\n if (platform === \"win32\") {\n common.npm_config_target_libc = \"unknown\"\n }\n\n if (!frameworkInfo.useCustomDist) {\n return common\n }\n\n // https://github.com/nodejs/node-gyp/issues/21\n return {\n ...common,\n npm_config_disturl: \"https://atom.io/download/electron\",\n npm_config_target: frameworkInfo.version,\n npm_config_runtime: \"electron\",\n npm_config_devdir: getElectronGypCacheDir(),\n }\n}\n\nfunction installDependencies(appDir: string, options: RebuildOptions): Promise<any> {\n const platform = options.platform || process.platform\n const arch = options.arch || process.arch\n const additionalArgs = options.additionalArgs\n\n log.info({platform, arch, appDir}, `installing production dependencies`)\n let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS\n const execArgs = [\"install\", \"--production\"]\n\n if (!isYarnPath(execPath)) {\n if (process.env.NPM_NO_BIN_LINKS === \"true\") {\n execArgs.push(\"--no-bin-links\")\n }\n execArgs.push(\"--cache-min\", \"999999999\")\n }\n\n if (execPath == null) {\n execPath = getPackageToolPath()\n }\n else {\n execArgs.unshift(execPath)\n execPath = process.env.npm_node_execpath || process.env.NODE_EXE || \"node\"\n }\n\n if (additionalArgs != null) {\n execArgs.push(...additionalArgs)\n }\n return spawn(execPath, execArgs, {\n cwd: appDir,\n env: getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),\n })\n}\n\nfunction getPackageToolPath() {\n if (process.env.FORCE_YARN === \"true\") {\n return process.platform === \"win32\" ? \"yarn.cmd\" : \"yarn\"\n }\n else {\n return process.platform === \"win32\" ? \"npm.cmd\" : \"npm\"\n }\n}\n\nfunction isYarnPath(execPath: string | null | undefined) {\n return process.env.FORCE_YARN === \"true\" || (execPath != null && path.basename(execPath).startsWith(\"yarn\"))\n}\n\nexport interface RebuildOptions {\n frameworkInfo: DesktopFrameworkInfo\n productionDeps?: Lazy<Array<Dependency>>\n\n platform?: NodeJS.Platform\n arch?: string\n\n buildFromSource?: boolean\n\n additionalArgs?: Array<string> | null\n}\n\n/** @internal */\nexport async function rebuild(appDir: string, options: RebuildOptions) {\n const nativeDeps = await BluebirdPromise.filter(await options.productionDeps!.value, it => exists(path.join(it.path, \"binding.gyp\")), {concurrency: 8})\n if (nativeDeps.length === 0) {\n log.info(\"no native production dependencies\")\n return\n }\n\n const platform = options.platform || process.platform\n const arch = options.arch || process.arch\n const additionalArgs = options.additionalArgs\n\n log.info({platform, arch}, \"rebuilding native production dependencies\")\n\n let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS\n const isYarn = isYarnPath(execPath)\n const execArgs: Array<string> = []\n if (execPath == null) {\n execPath = getPackageToolPath()\n }\n else {\n execArgs.push(execPath)\n execPath = process.env.npm_node_execpath || process.env.NODE_EXE || \"node\"\n }\n\n const env = getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true)\n if (isYarn) {\n execArgs.push(\"run\", \"install\")\n if (additionalArgs != null) {\n execArgs.push(...additionalArgs)\n }\n await BluebirdPromise.map(nativeDeps, dep => {\n log.info({name: dep.name}, `rebuilding native dependency`)\n return spawn(execPath!, execArgs, {\n cwd: dep.path,\n env,\n })\n .catch(error => {\n if (dep.optional) {\n log.warn({dep: dep.name}, \"cannot build optional native dep\")\n }\n else {\n throw error\n }\n })\n }, {concurrency: process.platform === \"win32\" ? 1 : 2})\n }\n else {\n execArgs.push(\"rebuild\")\n if (additionalArgs != null) {\n execArgs.push(...additionalArgs)\n }\n execArgs.push(...nativeDeps.map(it => `${it.name}@${it.version}`))\n await spawn(execPath, execArgs, {\n cwd: appDir,\n env,\n })\n }\n}\n"],"sourceRoot":""}