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nC,CADhB,IAEJ,SAAS,IAAI,IAAb,IAAqB,WAAW,IAAX,CAAgB,SAAhB,CAFxB;AAGD;AAcD;;;AACO,eAAe,OAAf,CAAuB,MAAvB,EAAuC,OAAvC,EAA8D;AACnE,QAAM,aAAa,GAAQ;AACzB,IAAA,YAAY,EAAE,MAAM,OAAO,CAAC,cAAR,CAAyB,KADpB;AAEzB,IAAA,YAAY,EAAE,OAAO,CAAC,QAFG;AAGzB,IAAA,QAAQ,EAAE,OAAO,CAAC,QAAR,IAAoB,OAAO,CAAC,QAHb;AAIzB,IAAA,IAAI,EAAE,OAAO,CAAC,IAAR,IAAgB,OAAO,CAAC,IAJL;AAKzB,IAAA,cAAc,EAAE,OAAO,CAAC,cALC;AAMzB,IAAA,QAAQ,EAAE,OAAO,CAAC,GAAR,CAAY,YAAZ,IAA4B,OAAO,CAAC,GAAR,CAAY,UANzB;AAOzB,IAAA,eAAe,EAAE,OAAO,CAAC,eAAR,KAA4B;AAPpB,GAA3B;AAUA,QAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,aAAT,EAAwB,aAAa,CAAC,QAAtC,EAAgD,aAAa,CAAC,IAA9D,EAAoE,OAAO,CAAC,eAAR,KAA4B,IAAhG,CAArB;AACA,QAAM,iDAA8B,CAAC,sBAAD,CAA9B,EAAwD,aAAxD,EAAuE;AAAC,IAAA,GAAD;AAAM,IAAA,GAAG,EAAE;AAAX,GAAvE,CAAN;AACD,C","sourcesContent":["import { asArray, log, spawn } from \"builder-util\"\nimport { pathExists } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport { homedir } from \"os\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { executeAppBuilderAndWriteJson } from \"./appBuilder\"\nimport { NodeModuleDirInfo } 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 pathExists(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 !== process.platform) {\n common.npm_config_force = \"true\"\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://electronjs.org/headers\",\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 (!isRunningYarn(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 isRunningYarn(execPath: string | null | undefined) {\n const userAgent = process.env.npm_config_user_agent\n return process.env.FORCE_YARN === \"true\" ||\n (execPath != null && path.basename(execPath).startsWith(\"yarn\")) ||\n (userAgent != null && /\\byarn\\b/.test(userAgent))\n}\n\nexport interface RebuildOptions {\n frameworkInfo: DesktopFrameworkInfo\n productionDeps?: Lazy<Array<NodeModuleDirInfo>>\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 configuration: any = {\n dependencies: await options.productionDeps!!.value,\n nodeExecPath: process.execPath,\n platform: options.platform || process.platform,\n arch: options.arch || process.arch,\n additionalArgs: options.additionalArgs,\n execPath: process.env.npm_execpath || process.env.NPM_CLI_JS,\n buildFromSource: options.buildFromSource === true,\n }\n\n const env = getGypEnv(options.frameworkInfo, configuration.platform, configuration.arch, options.buildFromSource === true)\n await executeAppBuilderAndWriteJson([\"rebuild-node-modules\"], configuration, {env, cwd: appDir})\n}\n"],"sourceRoot":""}
|