update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
23
electron/node_modules/app-builder-lib/out/electron/ElectronFramework.d.ts
generated
vendored
23
electron/node_modules/app-builder-lib/out/electron/ElectronFramework.d.ts
generated
vendored
|
|
@ -1,7 +1,9 @@
|
|||
import { Configuration } from "../configuration";
|
||||
import { Framework } from "../Framework";
|
||||
import { Packager } from "../index";
|
||||
export declare type ElectronPlatformName = "darwin" | "linux" | "win32" | "mas";
|
||||
import { ElectronDownloadOptions } from "../util/electronGet";
|
||||
export { ElectronDownloadOptions };
|
||||
export type ElectronPlatformName = "darwin" | "linux" | "win32" | "mas";
|
||||
/**
|
||||
* Electron distributables branding options.
|
||||
* @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).
|
||||
|
|
@ -11,23 +13,4 @@ export interface ElectronBrandingOptions {
|
|||
productName?: string;
|
||||
}
|
||||
export declare function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions>;
|
||||
export interface ElectronDownloadOptions {
|
||||
version?: string;
|
||||
/**
|
||||
* The [cache location](https://github.com/electron-userland/electron-download#cache-location).
|
||||
*/
|
||||
cache?: string | null;
|
||||
/**
|
||||
* The mirror.
|
||||
*/
|
||||
mirror?: string | null;
|
||||
/** @private */
|
||||
customDir?: string | null;
|
||||
/** @private */
|
||||
customFilename?: string | null;
|
||||
strictSSL?: boolean;
|
||||
isVerifyChecksum?: boolean;
|
||||
platform?: ElectronPlatformName;
|
||||
arch?: string;
|
||||
}
|
||||
export declare function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework>;
|
||||
|
|
|
|||
223
electron/node_modules/app-builder-lib/out/electron/ElectronFramework.js
generated
vendored
223
electron/node_modules/app-builder-lib/out/electron/ElectronFramework.js
generated
vendored
|
|
@ -1,18 +1,19 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createElectronFrameworkSupport = exports.createBrandingOpts = void 0;
|
||||
const bluebird_lst_1 = require("bluebird-lst");
|
||||
exports.createBrandingOpts = createBrandingOpts;
|
||||
exports.createElectronFrameworkSupport = createElectronFrameworkSupport;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const fs_1 = require("builder-util/out/fs");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const lazy_val_1 = require("lazy-val");
|
||||
const path = require("path");
|
||||
const tiny_async_pool_1 = require("tiny-async-pool");
|
||||
const index_1 = require("../index");
|
||||
const platformPackager_1 = require("../platformPackager");
|
||||
const pathManager_1 = require("../util/pathManager");
|
||||
const resolve_1 = require("../util/resolve");
|
||||
const electronGet_1 = require("../util/electronGet");
|
||||
const electronMac_1 = require("./electronMac");
|
||||
const electronVersion_1 = require("./electronVersion");
|
||||
const fs = require("fs/promises");
|
||||
const electronWin_1 = require("./electronWin");
|
||||
const injectFFMPEG_1 = require("./injectFFMPEG");
|
||||
function createBrandingOpts(opts) {
|
||||
var _a, _b;
|
||||
return {
|
||||
|
|
@ -20,56 +21,89 @@ function createBrandingOpts(opts) {
|
|||
productName: ((_b = opts.electronBranding) === null || _b === void 0 ? void 0 : _b.productName) || "Electron",
|
||||
};
|
||||
}
|
||||
exports.createBrandingOpts = createBrandingOpts;
|
||||
function createDownloadOpts(opts, platform, arch, electronVersion) {
|
||||
return {
|
||||
platform,
|
||||
arch,
|
||||
version: electronVersion,
|
||||
...opts.electronDownload,
|
||||
};
|
||||
var _a;
|
||||
const base = { platform, arch, version: electronVersion };
|
||||
const dl = opts.electronDownload;
|
||||
if (dl == null) {
|
||||
return base;
|
||||
}
|
||||
if (Object.hasOwnProperty.call(dl, "mirrorOptions")) {
|
||||
// ElectronGetOptions: flatten mirrorOptions.mirror for the app-builder binary
|
||||
const { mirrorOptions } = dl;
|
||||
return { ...base, mirror: (_a = mirrorOptions === null || mirrorOptions === void 0 ? void 0 : mirrorOptions.mirror) !== null && _a !== void 0 ? _a : undefined };
|
||||
}
|
||||
return { ...base, ...dl };
|
||||
}
|
||||
async function beforeCopyExtraFiles(options) {
|
||||
const packager = options.packager;
|
||||
const appOutDir = options.appOutDir;
|
||||
const { appOutDir, packager } = options;
|
||||
const electronBranding = createBrandingOpts(packager.config);
|
||||
if (packager.platform === index_1.Platform.LINUX) {
|
||||
if (!platformPackager_1.isSafeToUnpackElectronOnRemoteBuildServer(packager)) {
|
||||
const linuxPackager = packager;
|
||||
const executable = path.join(appOutDir, linuxPackager.executableName);
|
||||
await fs_extra_1.rename(path.join(appOutDir, electronBranding.projectName), executable);
|
||||
}
|
||||
const linuxPackager = packager;
|
||||
const executable = path.join(appOutDir, linuxPackager.executableName);
|
||||
await (0, fs_extra_1.rename)(path.join(appOutDir, electronBranding.projectName), executable);
|
||||
}
|
||||
else if (packager.platform === index_1.Platform.WINDOWS) {
|
||||
const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`);
|
||||
await fs_extra_1.rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable);
|
||||
await (0, fs_extra_1.rename)(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable);
|
||||
if (options.asarIntegrity) {
|
||||
await (0, electronWin_1.addWinAsarIntegrity)(executable, options.asarIntegrity);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await electronMac_1.createMacApp(packager, appOutDir, options.asarIntegrity, options.platformName === "mas");
|
||||
const wantedLanguages = builder_util_1.asArray(packager.platformSpecificBuildOptions.electronLanguages);
|
||||
if (wantedLanguages.length === 0) {
|
||||
return;
|
||||
await (0, electronMac_1.createMacApp)(packager, appOutDir, options.asarIntegrity, options.platformName === "mas");
|
||||
}
|
||||
await removeUnusedLanguagesIfNeeded(options);
|
||||
}
|
||||
async function removeUnusedLanguagesIfNeeded(options) {
|
||||
const { packager, appOutDir } = options;
|
||||
const { config, platformSpecificBuildOptions, platform } = packager;
|
||||
const getLocalesConfig = () => {
|
||||
if (platform === index_1.Platform.MAC) {
|
||||
return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: ".lproj" };
|
||||
}
|
||||
// noinspection SpellCheckingInspection
|
||||
const langFileExt = ".lproj";
|
||||
const resourcesDir = packager.getResourcesDir(appOutDir);
|
||||
await bluebird_lst_1.default.map(fs_extra_1.readdir(resourcesDir), file => {
|
||||
if (!file.endsWith(langFileExt)) {
|
||||
return { dirs: [path.join(packager.getResourcesDir(appOutDir), "..", "locales")], langFileExt: ".pak" };
|
||||
};
|
||||
const wantedLanguages = (0, builder_util_1.asArray)(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)
|
||||
.map(it => it.trim().toLowerCase())
|
||||
.filter(it => it.length > 0);
|
||||
if (!wantedLanguages.length) {
|
||||
return;
|
||||
}
|
||||
const { dirs, langFileExt } = getLocalesConfig();
|
||||
// noinspection SpellCheckingInspection
|
||||
const deleteNonMatchedLanguages = async (dir) => {
|
||||
const files = await (0, fs_extra_1.readdir)(dir);
|
||||
return files.map(async (file) => {
|
||||
if (path.extname(file) !== langFileExt) {
|
||||
return;
|
||||
}
|
||||
const language = file.substring(0, file.length - langFileExt.length);
|
||||
if (!wantedLanguages.includes(language)) {
|
||||
return fs.rm(path.join(resourcesDir, file), { recursive: true, force: true });
|
||||
const language = path.basename(file, langFileExt).toLowerCase();
|
||||
const isWantedLocale = wantedLanguages.some(wantedLanguage =>
|
||||
// exact file
|
||||
wantedLanguage === language ||
|
||||
// prefix (e.g. "en" matches "en-US")
|
||||
wantedLanguage.startsWith(`${language}-`) ||
|
||||
// prefix (e.g. "en" matches "en_US")
|
||||
wantedLanguage.startsWith(`${language}_`));
|
||||
if (isWantedLocale) {
|
||||
return undefined;
|
||||
}
|
||||
return;
|
||||
}, fs_1.CONCURRENCY);
|
||||
return (0, fs_extra_1.rm)(path.join(dir, file), { recursive: true, force: true });
|
||||
});
|
||||
};
|
||||
const allDeletedFiles = (await Promise.all(dirs.map(deleteNonMatchedLanguages))).flat().filter((it) => it != null);
|
||||
if (allDeletedFiles.length === 0) {
|
||||
builder_util_1.log.warn({ electronLanguages: wantedLanguages }, "no locales found matching wanted languages, skipping cleanup");
|
||||
return;
|
||||
}
|
||||
await (0, tiny_async_pool_1.default)(builder_util_1.MAX_FILE_REQUESTS, allDeletedFiles, it => it);
|
||||
}
|
||||
class ElectronFramework {
|
||||
constructor(name, version, distMacOsAppName) {
|
||||
constructor(name, version, macOsProductName) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.distMacOsAppName = distMacOsAppName;
|
||||
this.macOsProductName = macOsProductName;
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
this.macOsDefaultTargets = ["zip", "dmg"];
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
|
|
@ -79,17 +113,26 @@ class ElectronFramework {
|
|||
// noinspection JSUnusedGlobalSymbols
|
||||
this.isNpmRebuildRequired = true;
|
||||
}
|
||||
get distMacOsAppName() {
|
||||
return `${this.macOsProductName}.app`;
|
||||
}
|
||||
getDefaultIcon(platform) {
|
||||
if (platform === index_1.Platform.LINUX) {
|
||||
return path.join(pathManager_1.getTemplatePath("icons"), "electron-linux");
|
||||
return path.join((0, pathManager_1.getTemplatePath)("icons"), "electron-linux");
|
||||
}
|
||||
else {
|
||||
// default icon is embedded into app skeleton
|
||||
return null;
|
||||
}
|
||||
}
|
||||
prepareApplicationStageDirectory(options) {
|
||||
return unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version), this.distMacOsAppName);
|
||||
async prepareApplicationStageDirectory(options) {
|
||||
const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version);
|
||||
const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName);
|
||||
await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup);
|
||||
if (options.packager.config.downloadAlternateFFmpeg) {
|
||||
const injector = new injectFFMPEG_1.FFMPEGInjector(options, this.version, createBrandingOpts(options.packager.config));
|
||||
await injector.inject();
|
||||
}
|
||||
}
|
||||
beforeCopyExtraFiles(options) {
|
||||
return beforeCopyExtraFiles(options);
|
||||
|
|
@ -100,62 +143,98 @@ async function createElectronFrameworkSupport(configuration, packager) {
|
|||
if (version == null) {
|
||||
// for prepacked app asar no dev deps in the app.asar
|
||||
if (packager.isPrepackedAppAsar) {
|
||||
version = await electronVersion_1.getElectronVersionFromInstalled(packager.projectDir);
|
||||
version = await (0, electronVersion_1.getElectronVersionFromInstalled)(packager.projectDir);
|
||||
if (version == null) {
|
||||
throw new Error(`Cannot compute electron version for prepacked asar`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
version = await electronVersion_1.computeElectronVersion(packager.projectDir, new lazy_val_1.Lazy(() => Promise.resolve(packager.metadata)));
|
||||
version = await (0, electronVersion_1.computeElectronVersion)(packager.projectDir);
|
||||
}
|
||||
configuration.electronVersion = version;
|
||||
}
|
||||
const branding = createBrandingOpts(configuration);
|
||||
return new ElectronFramework(branding.projectName, version, `${branding.productName}.app`);
|
||||
return new ElectronFramework(branding.projectName, version, branding.productName);
|
||||
}
|
||||
exports.createElectronFrameworkSupport = createElectronFrameworkSupport;
|
||||
async function unpack(prepareOptions, options, distMacOsAppName) {
|
||||
/**
|
||||
* Unpacks a custom or default Electron distribution into the app output directory.
|
||||
*/
|
||||
async function unpack(prepareOptions, downloadOptions, _distMacOsAppName) {
|
||||
var _a, _b, _c;
|
||||
async function selectElectron(filepath) {
|
||||
const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath);
|
||||
const electronDistStats = await (0, builder_util_1.statOrNull)(resolvedDist);
|
||||
if (!electronDistStats) {
|
||||
throw new Error(`The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`);
|
||||
}
|
||||
if (resolvedDist.endsWith(".zip")) {
|
||||
builder_util_1.log.info({ zipFile: resolvedDist }, "using custom electronDist zip file");
|
||||
await (0, electronGet_1.extractArchive)(resolvedDist, appOutDir);
|
||||
return false; // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required
|
||||
}
|
||||
if (electronDistStats.isDirectory()) {
|
||||
// backward compatibility: if electronDist is a directory, check for the default zip file inside it
|
||||
const files = await (0, fs_extra_1.readdir)(resolvedDist);
|
||||
if (files.includes(defaultZipName)) {
|
||||
builder_util_1.log.info({ electronDist: builder_util_1.log.filePath(resolvedDist) }, "using custom electronDist directory");
|
||||
await (0, electronGet_1.extractArchive)(path.join(resolvedDist, defaultZipName), appOutDir);
|
||||
return false; // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required
|
||||
}
|
||||
// if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file
|
||||
// e.g. we treat it as a custom already-unpacked Electron distribution
|
||||
builder_util_1.log.info({ electronDist: builder_util_1.log.filePath(resolvedDist) }, "using custom unpacked Electron distribution");
|
||||
const source = packager.getElectronSrcDir(resolvedDist);
|
||||
const destination = packager.getElectronDestinationDir(prepareOptions.appOutDir);
|
||||
builder_util_1.log.info({ source, destination }, "copying unpacked Electron");
|
||||
await (0, fs_extra_1.emptyDir)(prepareOptions.appOutDir);
|
||||
await (0, builder_util_1.copyDir)(source, destination, {
|
||||
isUseHardLink: builder_util_1.DO_NOT_USE_HARD_LINKS,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`);
|
||||
}
|
||||
const { packager, appOutDir, platformName } = prepareOptions;
|
||||
const { version, arch } = downloadOptions;
|
||||
const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`;
|
||||
const electronDist = packager.config.electronDist;
|
||||
let dist = typeof electronDist === "function" ? electronDist(prepareOptions) : electronDist;
|
||||
if (dist != null) {
|
||||
const zipFile = `electron-v${options.version}-${platformName}-${options.arch}.zip`;
|
||||
const resolvedDist = path.isAbsolute(dist) ? dist : path.resolve(packager.projectDir, dist);
|
||||
if ((await fs_1.statOrNull(path.join(resolvedDist, zipFile))) != null) {
|
||||
builder_util_1.log.info({ resolvedDist, zipFile }, "Resolved electronDist");
|
||||
options.cache = resolvedDist;
|
||||
dist = null;
|
||||
}
|
||||
if (typeof electronDist === "string" && !(0, builder_util_1.isEmptyOrSpaces)(electronDist)) {
|
||||
return selectElectron(electronDist);
|
||||
}
|
||||
let isFullCleanup = false;
|
||||
if (dist == null) {
|
||||
if (platformPackager_1.isSafeToUnpackElectronOnRemoteBuildServer(packager)) {
|
||||
return;
|
||||
}
|
||||
await builder_util_1.executeAppBuilder(["unpack-electron", "--configuration", JSON.stringify([options]), "--output", appOutDir, "--distMacOsAppName", distMacOsAppName]);
|
||||
let resolvedDist = null;
|
||||
try {
|
||||
const electronDistHook = await (0, resolve_1.resolveFunction)(packager.appInfo.type, electronDist, "electronDist", await packager.info.getWorkspaceRoot());
|
||||
resolvedDist = typeof electronDistHook === "function" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook;
|
||||
}
|
||||
else {
|
||||
isFullCleanup = true;
|
||||
const source = packager.getElectronSrcDir(dist);
|
||||
const destination = packager.getElectronDestinationDir(appOutDir);
|
||||
builder_util_1.log.info({ source, destination }, "copying Electron");
|
||||
await fs_extra_1.emptyDir(appOutDir);
|
||||
await fs_1.copyDir(source, destination, {
|
||||
isUseHardLink: fs_1.DO_NOT_USE_HARD_LINKS,
|
||||
catch (error) {
|
||||
builder_util_1.log.warn({ error }, "Failed to resolve electronDist, using default unpack logic");
|
||||
}
|
||||
if (resolvedDist == null) {
|
||||
// if no custom electronDist is provided, use the default unpack logic
|
||||
builder_util_1.log.debug(null, "no custom electronDist provided, unpacking default Electron distribution");
|
||||
const zipPath = await (0, electronGet_1.downloadElectronArtifactZip)({
|
||||
electronDownload: downloadOptions,
|
||||
artifactName: "electron",
|
||||
platformName: (_a = downloadOptions.platform) !== null && _a !== void 0 ? _a : prepareOptions.platformName,
|
||||
arch: (_b = downloadOptions.arch) !== null && _b !== void 0 ? _b : prepareOptions.arch,
|
||||
version: (_c = downloadOptions.version) !== null && _c !== void 0 ? _c : prepareOptions.version,
|
||||
});
|
||||
await (0, electronGet_1.extractArchive)(zipPath, appOutDir);
|
||||
builder_util_1.log.info({ output: appOutDir }, "downloaded electron zip extracted successfully");
|
||||
return true; // indicates that we should clean up after unpacking
|
||||
}
|
||||
await cleanupAfterUnpack(prepareOptions, distMacOsAppName, isFullCleanup);
|
||||
return selectElectron(resolvedDist);
|
||||
}
|
||||
function cleanupAfterUnpack(prepareOptions, distMacOsAppName, isFullCleanup) {
|
||||
const out = prepareOptions.appOutDir;
|
||||
const isMac = prepareOptions.packager.platform === index_1.Platform.MAC;
|
||||
const resourcesPath = isMac ? path.join(out, distMacOsAppName, "Contents", "Resources") : path.join(out, "resources");
|
||||
return Promise.all([
|
||||
isFullCleanup ? fs_1.unlinkIfExists(path.join(resourcesPath, "default_app.asar")) : Promise.resolve(),
|
||||
isFullCleanup ? fs_1.unlinkIfExists(path.join(out, "version")) : Promise.resolve(),
|
||||
isFullCleanup ? (0, builder_util_1.unlinkIfExists)(path.join(resourcesPath, "default_app.asar")) : Promise.resolve(),
|
||||
isFullCleanup ? (0, builder_util_1.unlinkIfExists)(path.join(out, "version")) : Promise.resolve(),
|
||||
isMac
|
||||
? Promise.resolve()
|
||||
: fs_extra_1.rename(path.join(out, "LICENSE"), path.join(out, "LICENSE.electron.txt")).catch(() => {
|
||||
: (0, fs_extra_1.rename)(path.join(out, "LICENSE"), path.join(out, "LICENSE.electron.txt")).catch(() => {
|
||||
/* ignore */
|
||||
}),
|
||||
]);
|
||||
|
|
|
|||
2
electron/node_modules/app-builder-lib/out/electron/ElectronFramework.js.map
generated
vendored
2
electron/node_modules/app-builder-lib/out/electron/ElectronFramework.js.map
generated
vendored
File diff suppressed because one or more lines are too long
153
electron/node_modules/app-builder-lib/out/electron/electronMac.js
generated
vendored
153
electron/node_modules/app-builder-lib/out/electron/electronMac.js
generated
vendored
|
|
@ -1,23 +1,22 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createMacApp = void 0;
|
||||
const bluebird_lst_1 = require("bluebird-lst");
|
||||
exports.createMacApp = createMacApp;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const fs_1 = require("builder-util/out/fs");
|
||||
const promises_1 = require("fs/promises");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const appInfo_1 = require("../appInfo");
|
||||
const platformPackager_1 = require("../platformPackager");
|
||||
const appBuilder_1 = require("../util/appBuilder");
|
||||
const plist_1 = require("../util/plist");
|
||||
const ElectronFramework_1 = require("./ElectronFramework");
|
||||
function doRename(basePath, oldName, newName) {
|
||||
return promises_1.rename(path.join(basePath, oldName), path.join(basePath, newName));
|
||||
return (0, promises_1.rename)(path.join(basePath, oldName), path.join(basePath, newName));
|
||||
}
|
||||
function moveHelpers(helperSuffixes, frameworksPath, appName, prefix) {
|
||||
return bluebird_lst_1.default.map(helperSuffixes, suffix => {
|
||||
return Promise.all(helperSuffixes.map(suffix => {
|
||||
const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, "Contents", "MacOS");
|
||||
return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix).then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`));
|
||||
});
|
||||
}));
|
||||
}
|
||||
function getAvailableHelperSuffixes(helperEHPlist, helperNPPlist, helperRendererPlist, helperPluginPlist, helperGPUPlist) {
|
||||
const result = [" Helper"];
|
||||
|
|
@ -40,9 +39,13 @@ function getAvailableHelperSuffixes(helperEHPlist, helperNPPlist, helperRenderer
|
|||
}
|
||||
/** @internal */
|
||||
async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
||||
var _a, _b;
|
||||
const appInfo = packager.appInfo;
|
||||
const appFilename = appInfo.productFilename;
|
||||
const electronBranding = ElectronFramework_1.createBrandingOpts(packager.config);
|
||||
// Electon uses the application name (CFBundleName) to resolve helper apps
|
||||
// https://github.com/electron/electron/blob/main/shell/app/electron_main_delegate_mac.mm
|
||||
// https://github.com/electron-userland/electron-builder/issues/6962
|
||||
const appFilename = appInfo.sanitizedProductName;
|
||||
const electronBranding = (0, ElectronFramework_1.createBrandingOpts)(packager.config);
|
||||
const contentsPath = path.join(appOutDir, packager.info.framework.distMacOsAppName, "Contents");
|
||||
const frameworksPath = path.join(contentsPath, "Frameworks");
|
||||
const loginItemPath = path.join(contentsPath, "Library", "LoginItems");
|
||||
|
|
@ -54,40 +57,24 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
const helperPluginPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Plugin).app`, "Contents", "Info.plist");
|
||||
const helperGPUPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (GPU).app`, "Contents", "Info.plist");
|
||||
const helperLoginPlistFilename = path.join(loginItemPath, `${electronBranding.productName} Login Helper.app`, "Contents", "Info.plist");
|
||||
const plistContent = await appBuilder_1.executeAppBuilderAsJson([
|
||||
"decode-plist",
|
||||
"-f",
|
||||
appPlistFilename,
|
||||
"-f",
|
||||
helperPlistFilename,
|
||||
"-f",
|
||||
helperEHPlistFilename,
|
||||
"-f",
|
||||
helperNPPlistFilename,
|
||||
"-f",
|
||||
helperRendererPlistFilename,
|
||||
"-f",
|
||||
helperPluginPlistFilename,
|
||||
"-f",
|
||||
helperGPUPlistFilename,
|
||||
"-f",
|
||||
helperLoginPlistFilename,
|
||||
]);
|
||||
if (plistContent[0] == null) {
|
||||
const safeParsePlistFile = async (filePath) => {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return null;
|
||||
}
|
||||
return await (0, plist_1.parsePlistFile)(filePath);
|
||||
};
|
||||
const appPlist = (await safeParsePlistFile(appPlistFilename));
|
||||
if (appPlist == null) {
|
||||
throw new Error("corrupted Electron dist");
|
||||
}
|
||||
const appPlist = plistContent[0];
|
||||
const helperPlist = plistContent[1];
|
||||
const helperEHPlist = plistContent[2];
|
||||
const helperNPPlist = plistContent[3];
|
||||
const helperRendererPlist = plistContent[4];
|
||||
const helperPluginPlist = plistContent[5];
|
||||
const helperGPUPlist = plistContent[6];
|
||||
const helperLoginPlist = plistContent[7];
|
||||
// if an extend-info file was supplied, copy its contents in first
|
||||
if (plistContent[8] != null) {
|
||||
Object.assign(appPlist, plistContent[8]);
|
||||
}
|
||||
// Replace the multiple parsePlistFile calls with:
|
||||
const helperPlist = await safeParsePlistFile(helperPlistFilename);
|
||||
const helperEHPlist = await safeParsePlistFile(helperEHPlistFilename);
|
||||
const helperNPPlist = await safeParsePlistFile(helperNPPlistFilename);
|
||||
const helperRendererPlist = await safeParsePlistFile(helperRendererPlistFilename);
|
||||
const helperPluginPlist = await safeParsePlistFile(helperPluginPlistFilename);
|
||||
const helperGPUPlist = await safeParsePlistFile(helperGPUPlistFilename);
|
||||
const helperLoginPlist = await safeParsePlistFile(helperLoginPlistFilename);
|
||||
const buildMetadata = packager.config;
|
||||
/**
|
||||
* Configure bundleIdentifier for the generic Electron Helper process
|
||||
|
|
@ -99,16 +86,22 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
if (oldHelperBundleId != null) {
|
||||
builder_util_1.log.warn("build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId");
|
||||
}
|
||||
const helperBundleIdentifier = appInfo_1.filterCFBundleIdentifier(packager.platformSpecificBuildOptions.helperBundleId || oldHelperBundleId || `${appInfo.macBundleIdentifier}.helper`);
|
||||
const defaultAppId = packager.platformSpecificBuildOptions.appId;
|
||||
const cfBundleIdentifier = (0, appInfo_1.filterCFBundleIdentifier)((isMas ? (_a = packager.config.mas) === null || _a === void 0 ? void 0 : _a.appId : defaultAppId) || defaultAppId || appInfo.macBundleIdentifier);
|
||||
const defaultHelperId = packager.platformSpecificBuildOptions.helperBundleId;
|
||||
const helperBundleIdentifier = (0, appInfo_1.filterCFBundleIdentifier)((isMas ? (_b = packager.config.mas) === null || _b === void 0 ? void 0 : _b.helperBundleId : defaultHelperId) || defaultHelperId || oldHelperBundleId || `${cfBundleIdentifier}.helper`);
|
||||
appPlist.CFBundleIdentifier = cfBundleIdentifier;
|
||||
await packager.applyCommonInfo(appPlist, contentsPath);
|
||||
// required for electron-updater proxy
|
||||
if (!isMas) {
|
||||
configureLocalhostAts(appPlist);
|
||||
}
|
||||
helperPlist.CFBundleExecutable = `${appFilename} Helper`;
|
||||
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`;
|
||||
helperPlist.CFBundleIdentifier = helperBundleIdentifier;
|
||||
helperPlist.CFBundleVersion = appPlist.CFBundleVersion;
|
||||
if (helperPlist != null) {
|
||||
helperPlist.CFBundleExecutable = `${appFilename} Helper`;
|
||||
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`;
|
||||
helperPlist.CFBundleIdentifier = helperBundleIdentifier;
|
||||
helperPlist.CFBundleVersion = appPlist.CFBundleVersion;
|
||||
}
|
||||
/**
|
||||
* Configure bundleIdentifier for Electron 5+ Helper processes
|
||||
*
|
||||
|
|
@ -121,8 +114,8 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`;
|
||||
helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`;
|
||||
helper.CFBundleIdentifier = userProvidedBundleIdentifier
|
||||
? appInfo_1.filterCFBundleIdentifier(userProvidedBundleIdentifier)
|
||||
: appInfo_1.filterCFBundleIdentifier(`${helperBundleIdentifier}.${postfix}`);
|
||||
? (0, appInfo_1.filterCFBundleIdentifier)(userProvidedBundleIdentifier)
|
||||
: (0, appInfo_1.filterCFBundleIdentifier)(`${helperBundleIdentifier}.${postfix}`);
|
||||
helper.CFBundleVersion = appPlist.CFBundleVersion;
|
||||
}
|
||||
if (helperRendererPlist != null) {
|
||||
|
|
@ -144,13 +137,13 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`;
|
||||
helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`;
|
||||
// noinspection SpellCheckingInspection
|
||||
helperLoginPlist.CFBundleIdentifier = `${appInfo.macBundleIdentifier}.loginhelper`;
|
||||
helperLoginPlist.CFBundleIdentifier = `${cfBundleIdentifier}.loginhelper`;
|
||||
helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion;
|
||||
}
|
||||
const protocols = builder_util_1.asArray(buildMetadata.protocols).concat(builder_util_1.asArray(packager.platformSpecificBuildOptions.protocols));
|
||||
const protocols = (0, builder_util_1.asArray)(buildMetadata.protocols).concat((0, builder_util_1.asArray)(packager.platformSpecificBuildOptions.protocols));
|
||||
if (protocols.length > 0) {
|
||||
appPlist.CFBundleURLTypes = protocols.map(protocol => {
|
||||
const schemes = builder_util_1.asArray(protocol.schemes);
|
||||
const schemes = (0, builder_util_1.asArray)(protocol.schemes);
|
||||
if (schemes.length === 0) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`Protocol "${protocol.name}": must be at least one scheme specified`);
|
||||
}
|
||||
|
|
@ -163,13 +156,13 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
}
|
||||
const fileAssociations = packager.fileAssociations;
|
||||
if (fileAssociations.length > 0) {
|
||||
appPlist.CFBundleDocumentTypes = await bluebird_lst_1.default.map(fileAssociations, async (fileAssociation) => {
|
||||
const extensions = builder_util_1.asArray(fileAssociation.ext).map(platformPackager_1.normalizeExt);
|
||||
const customIcon = await packager.getResource(builder_util_1.getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`);
|
||||
const documentTypes = await Promise.all(fileAssociations.map(async (fileAssociation) => {
|
||||
const extensions = (0, builder_util_1.asArray)(fileAssociation.ext).map(platformPackager_1.normalizeExt);
|
||||
const customIcon = await packager.getResource((0, builder_util_1.getPlatformIconFileName)(fileAssociation.icon, true), `${extensions[0]}.icns`);
|
||||
let iconFile = appPlist.CFBundleIconFile;
|
||||
if (customIcon != null) {
|
||||
iconFile = path.basename(customIcon);
|
||||
await fs_1.copyOrLinkFile(customIcon, path.join(path.join(contentsPath, "Resources"), iconFile));
|
||||
await (0, builder_util_1.copyOrLinkFile)(customIcon, path.join(path.join(contentsPath, "Resources"), iconFile));
|
||||
}
|
||||
const result = {
|
||||
CFBundleTypeExtensions: extensions,
|
||||
|
|
@ -182,38 +175,49 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
result.LSTypeIsPackage = true;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}));
|
||||
// `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case
|
||||
appPlist.CFBundleDocumentTypes = [...(appPlist.CFBundleDocumentTypes || []), ...documentTypes];
|
||||
}
|
||||
if (asarIntegrity != null) {
|
||||
appPlist.ElectronAsarIntegrity = asarIntegrity;
|
||||
}
|
||||
const plistDataToWrite = {
|
||||
[appPlistFilename]: appPlist,
|
||||
[helperPlistFilename]: helperPlist,
|
||||
const toPlistObject = (asarIntegrity) => {
|
||||
const result = {};
|
||||
for (const [filePath, headerHash] of Object.entries(asarIntegrity)) {
|
||||
result[filePath] = {
|
||||
algorithm: headerHash.algorithm,
|
||||
hash: headerHash.hash,
|
||||
};
|
||||
}
|
||||
return result;
|
||||
};
|
||||
if (asarIntegrity != null) {
|
||||
appPlist.ElectronAsarIntegrity = toPlistObject(asarIntegrity);
|
||||
}
|
||||
if (helperEHPlist != null) {
|
||||
plistDataToWrite[helperEHPlistFilename] = helperEHPlist;
|
||||
await (0, plist_1.savePlistFile)(helperEHPlistFilename, helperEHPlist);
|
||||
}
|
||||
if (helperNPPlist != null) {
|
||||
plistDataToWrite[helperNPPlistFilename] = helperNPPlist;
|
||||
await (0, plist_1.savePlistFile)(helperNPPlistFilename, helperNPPlist);
|
||||
}
|
||||
if (helperRendererPlist != null) {
|
||||
plistDataToWrite[helperRendererPlistFilename] = helperRendererPlist;
|
||||
await (0, plist_1.savePlistFile)(helperRendererPlistFilename, helperRendererPlist);
|
||||
}
|
||||
if (helperPluginPlist != null) {
|
||||
plistDataToWrite[helperPluginPlistFilename] = helperPluginPlist;
|
||||
await (0, plist_1.savePlistFile)(helperPluginPlistFilename, helperPluginPlist);
|
||||
}
|
||||
if (helperGPUPlist != null) {
|
||||
plistDataToWrite[helperGPUPlistFilename] = helperGPUPlist;
|
||||
await (0, plist_1.savePlistFile)(helperGPUPlistFilename, helperGPUPlist);
|
||||
}
|
||||
if (helperLoginPlist != null) {
|
||||
plistDataToWrite[helperLoginPlistFilename] = helperLoginPlist;
|
||||
await (0, plist_1.savePlistFile)(helperLoginPlistFilename, helperLoginPlist);
|
||||
}
|
||||
await (0, plist_1.savePlistFile)(appPlistFilename, appPlist);
|
||||
if (helperPlist != null) {
|
||||
await (0, plist_1.savePlistFile)(helperPlistFilename, helperPlist);
|
||||
}
|
||||
await Promise.all([
|
||||
appBuilder_1.executeAppBuilderAndWriteJson(["encode-plist"], plistDataToWrite),
|
||||
doRename(path.join(contentsPath, "MacOS"), electronBranding.productName, appPlist.CFBundleExecutable),
|
||||
fs_1.unlinkIfExists(path.join(appOutDir, "LICENSE")),
|
||||
fs_1.unlinkIfExists(path.join(appOutDir, "LICENSES.chromium.html")),
|
||||
(0, builder_util_1.unlinkIfExists)(path.join(appOutDir, "LICENSE")),
|
||||
(0, builder_util_1.unlinkIfExists)(path.join(appOutDir, "LICENSES.chromium.html")),
|
||||
]);
|
||||
await moveHelpers(getAvailableHelperSuffixes(helperEHPlist, helperNPPlist, helperRendererPlist, helperPluginPlist, helperGPUPlist), frameworksPath, appFilename, electronBranding.productName);
|
||||
if (helperLoginPlist != null) {
|
||||
|
|
@ -222,13 +226,12 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|||
const executableBasePath = path.join(loginItemPath, `${prefix}${suffix}.app`, "Contents", "MacOS");
|
||||
await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix).then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`));
|
||||
}
|
||||
const appPath = path.join(appOutDir, `${appFilename}.app`);
|
||||
await promises_1.rename(path.dirname(contentsPath), appPath);
|
||||
const appPath = path.join(appOutDir, `${appInfo.productFilename}.app`);
|
||||
await (0, promises_1.rename)(path.dirname(contentsPath), appPath);
|
||||
// https://github.com/electron-userland/electron-builder/issues/840
|
||||
const now = Date.now() / 1000;
|
||||
await promises_1.utimes(appPath, now, now);
|
||||
await (0, promises_1.utimes)(appPath, now, now);
|
||||
}
|
||||
exports.createMacApp = createMacApp;
|
||||
function configureLocalhostAts(appPlist) {
|
||||
// https://bencoding.com/2015/07/20/app-transport-security-and-localhost/
|
||||
let ats = appPlist.NSAppTransportSecurity;
|
||||
|
|
|
|||
2
electron/node_modules/app-builder-lib/out/electron/electronMac.js.map
generated
vendored
2
electron/node_modules/app-builder-lib/out/electron/electronMac.js.map
generated
vendored
File diff suppressed because one or more lines are too long
8
electron/node_modules/app-builder-lib/out/electron/electronVersion.d.ts
generated
vendored
8
electron/node_modules/app-builder-lib/out/electron/electronVersion.d.ts
generated
vendored
|
|
@ -1,8 +1,6 @@
|
|||
import { Lazy } from "lazy-val";
|
||||
import { Configuration } from "../configuration";
|
||||
export declare type MetadataValue = Lazy<{
|
||||
[key: string]: any;
|
||||
} | null>;
|
||||
export declare function getElectronVersion(projectDir: string, config?: Configuration, projectMetadata?: MetadataValue): Promise<string>;
|
||||
export declare function getElectronVersionFromInstalled(projectDir: string): Promise<any>;
|
||||
export type MetadataValue = Lazy<Record<string, any> | null>;
|
||||
export declare function getElectronVersion(projectDir: string, config?: Configuration): Promise<string>;
|
||||
export declare function getElectronVersionFromInstalled(projectDir: string): Promise<string | null>;
|
||||
export declare function getElectronPackage(projectDir: string): Promise<any>;
|
||||
|
|
|
|||
57
electron/node_modules/app-builder-lib/out/electron/electronVersion.js
generated
vendored
57
electron/node_modules/app-builder-lib/out/electron/electronVersion.js
generated
vendored
|
|
@ -1,30 +1,31 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.computeElectronVersion = exports.getElectronPackage = exports.getElectronVersionFromInstalled = exports.getElectronVersion = void 0;
|
||||
exports.getElectronVersion = getElectronVersion;
|
||||
exports.getElectronVersionFromInstalled = getElectronVersionFromInstalled;
|
||||
exports.getElectronPackage = getElectronPackage;
|
||||
exports.computeElectronVersion = computeElectronVersion;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const builder_util_runtime_1 = require("builder-util-runtime");
|
||||
const nodeHttpExecutor_1 = require("builder-util/out/nodeHttpExecutor");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const lazy_val_1 = require("lazy-val");
|
||||
const path = require("path");
|
||||
const read_config_file_1 = require("read-config-file");
|
||||
const semver = require("semver");
|
||||
const config_1 = require("../util/config");
|
||||
const config_1 = require("../util/config/config");
|
||||
const load_1 = require("../util/config/load");
|
||||
const search_module_1 = require("./search-module");
|
||||
const electronPackages = ["electron", "electron-prebuilt", "electron-prebuilt-compile", "electron-nightly"];
|
||||
async function getElectronVersion(projectDir, config, projectMetadata = new lazy_val_1.Lazy(() => read_config_file_1.orNullIfFileNotExist(fs_extra_1.readJson(path.join(projectDir, "package.json"))))) {
|
||||
async function getElectronVersion(projectDir, config) {
|
||||
if (config == null) {
|
||||
config = await config_1.getConfig(projectDir, null, null);
|
||||
config = await (0, config_1.getConfig)(projectDir, null, null);
|
||||
}
|
||||
if (config.electronVersion != null) {
|
||||
return config.electronVersion;
|
||||
}
|
||||
return await computeElectronVersion(projectDir, projectMetadata);
|
||||
return computeElectronVersion(projectDir);
|
||||
}
|
||||
exports.getElectronVersion = getElectronVersion;
|
||||
async function getElectronVersionFromInstalled(projectDir) {
|
||||
for (const name of electronPackages) {
|
||||
try {
|
||||
return (await fs_extra_1.readJson(path.join(projectDir, "node_modules", name, "package.json"))).version;
|
||||
return (await (0, fs_extra_1.readJson)(path.join(projectDir, "node_modules", name, "package.json"))).version;
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== "ENOENT") {
|
||||
|
|
@ -34,11 +35,10 @@ async function getElectronVersionFromInstalled(projectDir) {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
exports.getElectronVersionFromInstalled = getElectronVersionFromInstalled;
|
||||
async function getElectronPackage(projectDir) {
|
||||
for (const name of electronPackages) {
|
||||
try {
|
||||
return await fs_extra_1.readJson(path.join(projectDir, "node_modules", name, "package.json"));
|
||||
return await (0, fs_extra_1.readJson)(path.join(projectDir, "node_modules", name, "package.json"));
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== "ENOENT") {
|
||||
|
|
@ -48,24 +48,31 @@ async function getElectronPackage(projectDir) {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
exports.getElectronPackage = getElectronPackage;
|
||||
/** @internal */
|
||||
async function computeElectronVersion(projectDir, projectMetadata) {
|
||||
async function computeElectronVersion(projectDir) {
|
||||
const result = await getElectronVersionFromInstalled(projectDir);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
const dependency = findFromPackageMetadata(await projectMetadata.value);
|
||||
const potentialRootDirs = [projectDir, await (0, search_module_1.getProjectRootPath)(projectDir)];
|
||||
let dependency = null;
|
||||
for (const dir of potentialRootDirs) {
|
||||
const metadata = await (0, load_1.orNullIfFileNotExist)((0, fs_extra_1.readJson)(path.join(dir, "package.json")));
|
||||
dependency = metadata ? findFromPackageMetadata(metadata) : null;
|
||||
if (dependency) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((dependency === null || dependency === void 0 ? void 0 : dependency.name) === "electron-nightly") {
|
||||
builder_util_1.log.info("You are using a nightly version of electron, be warned that those builds are highly unstable.");
|
||||
const feedXml = await nodeHttpExecutor_1.httpExecutor.request({
|
||||
const feedXml = await builder_util_1.httpExecutor.request({
|
||||
hostname: "github.com",
|
||||
path: `/electron/nightlies/releases.atom`,
|
||||
headers: {
|
||||
accept: "application/xml, application/atom+xml, text/xml, */*",
|
||||
},
|
||||
});
|
||||
const feed = builder_util_runtime_1.parseXml(feedXml);
|
||||
const feed = (0, builder_util_runtime_1.parseXml)(feedXml);
|
||||
const latestRelease = feed.element("entry", false, `No published versions on GitHub`);
|
||||
const v = /\/tag\/v?([^/]+)$/.exec(latestRelease.element("link").attribute("href"))[1];
|
||||
return v.startsWith("v") ? v.substring(1) : v;
|
||||
|
|
@ -73,7 +80,7 @@ async function computeElectronVersion(projectDir, projectMetadata) {
|
|||
else if ((dependency === null || dependency === void 0 ? void 0 : dependency.version) === "latest") {
|
||||
builder_util_1.log.warn('Electron version is set to "latest", but it is recommended to set it to some more restricted version range.');
|
||||
try {
|
||||
const releaseInfo = JSON.parse((await nodeHttpExecutor_1.httpExecutor.request({
|
||||
const releaseInfo = JSON.parse((await builder_util_1.httpExecutor.request({
|
||||
hostname: "github.com",
|
||||
path: `/electron/${dependency.name === "electron-nightly" ? "nightlies" : "electron"}/releases/latest`,
|
||||
headers: {
|
||||
|
|
@ -90,13 +97,17 @@ async function computeElectronVersion(projectDir, projectMetadata) {
|
|||
throw new builder_util_1.InvalidConfigurationError(`Cannot find electron dependency to get electron version in the '${path.join(projectDir, "package.json")}'`);
|
||||
}
|
||||
const version = dependency === null || dependency === void 0 ? void 0 : dependency.version;
|
||||
if (version == null || !/^\d/.test(version)) {
|
||||
const versionMessage = version == null ? "" : ` and version ("${version}") is not fixed in project`;
|
||||
throw new builder_util_1.InvalidConfigurationError(`Cannot compute electron version from installed node modules - none of the possible electron modules are installed${versionMessage}.\nSee https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246`);
|
||||
if (version == null) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`Cannot compute electron version from installed node modules - none of the possible electron modules are installed.\nSee https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246`);
|
||||
}
|
||||
return semver.coerce(version).toString();
|
||||
const pinnedVersion = semver.valid(version);
|
||||
if (pinnedVersion === null) {
|
||||
builder_util_1.log.error({ version }, `Electron version "${version}" is a range, not a fixed version. electron-builder requires an exact version because it downloads platform-specific binaries for a specific release — a range cannot be resolved without electron installed in node_modules. ` +
|
||||
`Pin the version in package.json (e.g. "15.3.0" instead of "^15.3.0") or set "electronVersion" explicitly in your electron-builder config.`);
|
||||
throw new builder_util_1.InvalidConfigurationError(`Cannot compute electron version from installed node modules - version ("${version}") is not fixed in project.\nSee https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246`);
|
||||
}
|
||||
return pinnedVersion;
|
||||
}
|
||||
exports.computeElectronVersion = computeElectronVersion;
|
||||
function findFromPackageMetadata(packageData) {
|
||||
for (const name of electronPackages) {
|
||||
const devDependencies = packageData.devDependencies;
|
||||
|
|
|
|||
2
electron/node_modules/app-builder-lib/out/electron/electronVersion.js.map
generated
vendored
2
electron/node_modules/app-builder-lib/out/electron/electronVersion.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
electron/node_modules/app-builder-lib/out/electron/electronWin.d.ts
generated
vendored
Normal file
1
electron/node_modules/app-builder-lib/out/electron/electronWin.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export {};
|
||||
38
electron/node_modules/app-builder-lib/out/electron/electronWin.js
generated
vendored
Normal file
38
electron/node_modules/app-builder-lib/out/electron/electronWin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addWinAsarIntegrity = addWinAsarIntegrity;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const promises_1 = require("fs/promises");
|
||||
const path = require("path");
|
||||
const resedit_1 = require("resedit");
|
||||
/** @internal */
|
||||
async function addWinAsarIntegrity(executablePath, asarIntegrity) {
|
||||
const buffer = await (0, promises_1.readFile)(executablePath);
|
||||
const executable = resedit_1.NtExecutable.from(buffer);
|
||||
const resource = resedit_1.NtExecutableResource.from(executable);
|
||||
const versionInfo = resedit_1.Resource.VersionInfo.fromEntries(resource.entries);
|
||||
if (versionInfo.length !== 1) {
|
||||
throw new Error(`Failed to parse version info in ${executablePath}`);
|
||||
}
|
||||
const languages = versionInfo[0].getAllLanguagesForStringValues();
|
||||
if (languages.length !== 1) {
|
||||
throw new Error(`Failed to locate languages in ${executablePath}`);
|
||||
}
|
||||
// See: https://github.com/electron/packager/blob/00d20b99cf4aa4621103dbbd09ff7de7d2f7f539/src/resedit.ts#L124
|
||||
const integrityList = Array.from(Object.entries(asarIntegrity)).map(([file, { algorithm: alg, hash: value }]) => ({
|
||||
file: path.win32.normalize(file),
|
||||
alg,
|
||||
value,
|
||||
}));
|
||||
resource.entries.push({
|
||||
type: "INTEGRITY",
|
||||
id: "ELECTRONASAR",
|
||||
bin: Buffer.from(JSON.stringify(integrityList)),
|
||||
lang: languages[0].lang,
|
||||
codepage: languages[0].codepage,
|
||||
});
|
||||
resource.outputResource(executable);
|
||||
await (0, promises_1.writeFile)(executablePath, Buffer.from(executable.generate()));
|
||||
builder_util_1.log.info({ executablePath: builder_util_1.log.filePath(executablePath) }, "updating asar integrity executable resource");
|
||||
}
|
||||
//# sourceMappingURL=electronWin.js.map
|
||||
1
electron/node_modules/app-builder-lib/out/electron/electronWin.js.map
generated
vendored
Normal file
1
electron/node_modules/app-builder-lib/out/electron/electronWin.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"electronWin.js","sourceRoot":"","sources":["../../src/electron/electronWin.ts"],"names":[],"mappings":";;AAOA,kDAkCC;AAzCD,+CAAkC;AAClC,0CAAiD;AACjD,6BAA4B;AAC5B,qCAAsE;AAGtE,gBAAgB;AACT,KAAK,UAAU,mBAAmB,CAAC,cAAsB,EAAE,aAA4B;IAC5F,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,cAAc,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,sBAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,8BAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAEtD,MAAM,WAAW,GAAG,kBAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACtE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,mCAAmC,cAAc,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAA;IACjE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,cAAc,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,8GAA8G;IAC9G,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChH,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;QAChC,GAAG;QACH,KAAK;KACN,CAAC,CAAC,CAAA;IAEH,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,IAAI,EAAE,WAAW;QACjB,EAAE,EAAE,cAAc;QAClB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;QACvB,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ;KAChC,CAAC,CAAA;IAEF,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IAEnC,MAAM,IAAA,oBAAS,EAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACnE,kBAAG,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,kBAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,6CAA6C,CAAC,CAAA;AAC3G,CAAC","sourcesContent":["import { log } from \"builder-util\"\nimport { readFile, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport { NtExecutable, NtExecutableResource, Resource } from \"resedit\"\nimport { AsarIntegrity } from \"../asar/integrity\"\n\n/** @internal */\nexport async function addWinAsarIntegrity(executablePath: string, asarIntegrity: AsarIntegrity) {\n const buffer = await readFile(executablePath)\n const executable = NtExecutable.from(buffer)\n const resource = NtExecutableResource.from(executable)\n\n const versionInfo = Resource.VersionInfo.fromEntries(resource.entries)\n if (versionInfo.length !== 1) {\n throw new Error(`Failed to parse version info in ${executablePath}`)\n }\n\n const languages = versionInfo[0].getAllLanguagesForStringValues()\n if (languages.length !== 1) {\n throw new Error(`Failed to locate languages in ${executablePath}`)\n }\n\n // See: https://github.com/electron/packager/blob/00d20b99cf4aa4621103dbbd09ff7de7d2f7f539/src/resedit.ts#L124\n const integrityList = Array.from(Object.entries(asarIntegrity)).map(([file, { algorithm: alg, hash: value }]) => ({\n file: path.win32.normalize(file),\n alg,\n value,\n }))\n\n resource.entries.push({\n type: \"INTEGRITY\",\n id: \"ELECTRONASAR\",\n bin: Buffer.from(JSON.stringify(integrityList)),\n lang: languages[0].lang,\n codepage: languages[0].codepage,\n })\n\n resource.outputResource(executable)\n\n await writeFile(executablePath, Buffer.from(executable.generate()))\n log.info({ executablePath: log.filePath(executablePath) }, \"updating asar integrity executable resource\")\n}\n"]}
|
||||
11
electron/node_modules/app-builder-lib/out/electron/injectFFMPEG.d.ts
generated
vendored
Normal file
11
electron/node_modules/app-builder-lib/out/electron/injectFFMPEG.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { PrepareApplicationStageDirectoryOptions } from "../Framework";
|
||||
import { ElectronBrandingOptions } from "./ElectronFramework";
|
||||
export declare class FFMPEGInjector {
|
||||
private readonly options;
|
||||
private readonly electronVersion;
|
||||
private readonly branding;
|
||||
constructor(options: PrepareApplicationStageDirectoryOptions, electronVersion: string, branding: Required<ElectronBrandingOptions>);
|
||||
inject(): Promise<string>;
|
||||
private downloadFFMPEG;
|
||||
private copyFFMPEG;
|
||||
}
|
||||
57
electron/node_modules/app-builder-lib/out/electron/injectFFMPEG.js
generated
vendored
Normal file
57
electron/node_modules/app-builder-lib/out/electron/injectFFMPEG.js
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FFMPEGInjector = void 0;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const core_1 = require("../core");
|
||||
const electronGet_1 = require("../util/electronGet");
|
||||
class FFMPEGInjector {
|
||||
constructor(options, electronVersion, branding) {
|
||||
this.options = options;
|
||||
this.electronVersion = electronVersion;
|
||||
this.branding = branding;
|
||||
}
|
||||
async inject() {
|
||||
const libPath = this.options.platformName === core_1.Platform.MAC.nodeName
|
||||
? path.join(this.options.appOutDir, `${this.branding.productName}.app`, "Contents", "Frameworks", `${this.branding.productName} Framework.framework`, "Versions", "A", "Libraries")
|
||||
: this.options.appOutDir;
|
||||
const ffmpegDir = await this.downloadFFMPEG();
|
||||
return this.copyFFMPEG(libPath, ffmpegDir);
|
||||
}
|
||||
async downloadFFMPEG() {
|
||||
const ffmpegFileName = `ffmpeg-v${this.electronVersion}-${this.options.platformName}-${this.options.arch}`;
|
||||
builder_util_1.log.info({ ffmpegFileName }, "downloading");
|
||||
const { packager: { config: { electronDownload }, }, platformName, arch, } = this.options;
|
||||
return (0, electronGet_1.downloadElectronArtifact)({
|
||||
electronDownload,
|
||||
artifactName: "ffmpeg",
|
||||
platformName,
|
||||
arch,
|
||||
version: this.electronVersion,
|
||||
});
|
||||
}
|
||||
async copyFFMPEG(targetPath, sourcePath) {
|
||||
let fileName = "ffmpeg.dll";
|
||||
if (["darwin", "mas"].includes(this.options.platformName)) {
|
||||
fileName = "libffmpeg.dylib";
|
||||
}
|
||||
else if (this.options.platformName === "linux") {
|
||||
fileName = "libffmpeg.so";
|
||||
}
|
||||
const libPath = path.resolve(sourcePath, fileName);
|
||||
const libTargetPath = path.resolve(targetPath, fileName);
|
||||
builder_util_1.log.info({ lib: builder_util_1.log.filePath(libPath), target: libTargetPath }, "copying non-proprietary FFMPEG");
|
||||
// If the source doesn't exist we have a problem
|
||||
if (!fs.existsSync(libPath)) {
|
||||
throw new Error(`Failed to find FFMPEG library file at path: ${libPath}`);
|
||||
}
|
||||
// If we are copying to the source we can stop immediately
|
||||
if (libPath !== libTargetPath) {
|
||||
await fs.copyFile(libPath, libTargetPath);
|
||||
}
|
||||
return libTargetPath;
|
||||
}
|
||||
}
|
||||
exports.FFMPEGInjector = FFMPEGInjector;
|
||||
//# sourceMappingURL=injectFFMPEG.js.map
|
||||
1
electron/node_modules/app-builder-lib/out/electron/injectFFMPEG.js.map
generated
vendored
Normal file
1
electron/node_modules/app-builder-lib/out/electron/injectFFMPEG.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"injectFFMPEG.js","sourceRoot":"","sources":["../../src/electron/injectFFMPEG.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,+BAA8B;AAC9B,6BAA4B;AAC5B,kCAAkC;AAElC,qDAA8D;AAG9D,MAAa,cAAc;IACzB,YACmB,OAAgD,EAChD,eAAuB,EACvB,QAA2C;QAF3C,YAAO,GAAP,OAAO,CAAyC;QAChD,oBAAe,GAAf,eAAe,CAAQ;QACvB,aAAQ,GAAR,QAAQ,CAAmC;IAC3D,CAAC;IAEJ,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,GACX,IAAI,CAAC,OAAO,CAAC,YAAY,KAAK,eAAQ,CAAC,GAAG,CAAC,QAAQ;YACjD,CAAC,CAAC,IAAI,CAAC,IAAI,CACP,IAAI,CAAC,OAAO,CAAC,SAAS,EACtB,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,MAAM,EAClC,UAAU,EACV,YAAY,EACZ,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,sBAAsB,EAClD,UAAU,EACV,GAAG,EACH,WAAW,CACZ;YACH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAA;QAE5B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC5C,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,MAAM,cAAc,GAAG,WAAW,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;QAE1G,kBAAG,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,EAAE,aAAa,CAAC,CAAA;QAE3C,MAAM,EACJ,QAAQ,EAAE,EACR,MAAM,EAAE,EAAE,gBAAgB,EAAE,GAC7B,EACD,YAAY,EACZ,IAAI,GACL,GAAG,IAAI,CAAC,OAAO,CAAA;QAEhB,OAAO,IAAA,sCAAwB,EAAC;YAC9B,gBAAgB;YAChB,YAAY,EAAE,QAAQ;YACtB,YAAY;YACZ,IAAI;YACJ,OAAO,EAAE,IAAI,CAAC,eAAe;SAC9B,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,UAAkB,EAAE,UAAkB;QAC7D,IAAI,QAAQ,GAAG,YAAY,CAAA;QAC3B,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1D,QAAQ,GAAG,iBAAiB,CAAA;QAC9B,CAAC;aAAM,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,EAAE,CAAC;YACjD,QAAQ,GAAG,cAAc,CAAA;QAC3B,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAClD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QACxD,kBAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,kBAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,gCAAgC,CAAC,CAAA;QAEjG,gDAAgD;QAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,+CAA+C,OAAO,EAAE,CAAC,CAAA;QAC3E,CAAC;QAED,0DAA0D;QAC1D,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;YAC9B,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;QAC3C,CAAC;QACD,OAAO,aAAa,CAAA;IACtB,CAAC;CACF;AAvED,wCAuEC","sourcesContent":["import { log } from \"builder-util\"\nimport * as fs from \"fs-extra\"\nimport * as path from \"path\"\nimport { Platform } from \"../core\"\nimport { PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { downloadElectronArtifact } from \"../util/electronGet\"\nimport { ElectronBrandingOptions } from \"./ElectronFramework\"\n\nexport class FFMPEGInjector {\n constructor(\n private readonly options: PrepareApplicationStageDirectoryOptions,\n private readonly electronVersion: string,\n private readonly branding: Required<ElectronBrandingOptions>\n ) {}\n\n async inject() {\n const libPath =\n this.options.platformName === Platform.MAC.nodeName\n ? path.join(\n this.options.appOutDir,\n `${this.branding.productName}.app`,\n \"Contents\",\n \"Frameworks\",\n `${this.branding.productName} Framework.framework`,\n \"Versions\",\n \"A\",\n \"Libraries\"\n )\n : this.options.appOutDir\n\n const ffmpegDir = await this.downloadFFMPEG()\n return this.copyFFMPEG(libPath, ffmpegDir)\n }\n\n private async downloadFFMPEG(): Promise<string> {\n const ffmpegFileName = `ffmpeg-v${this.electronVersion}-${this.options.platformName}-${this.options.arch}`\n\n log.info({ ffmpegFileName }, \"downloading\")\n\n const {\n packager: {\n config: { electronDownload },\n },\n platformName,\n arch,\n } = this.options\n\n return downloadElectronArtifact({\n electronDownload,\n artifactName: \"ffmpeg\",\n platformName,\n arch,\n version: this.electronVersion,\n })\n }\n\n private async copyFFMPEG(targetPath: string, sourcePath: string) {\n let fileName = \"ffmpeg.dll\"\n if ([\"darwin\", \"mas\"].includes(this.options.platformName)) {\n fileName = \"libffmpeg.dylib\"\n } else if (this.options.platformName === \"linux\") {\n fileName = \"libffmpeg.so\"\n }\n\n const libPath = path.resolve(sourcePath, fileName)\n const libTargetPath = path.resolve(targetPath, fileName)\n log.info({ lib: log.filePath(libPath), target: libTargetPath }, \"copying non-proprietary FFMPEG\")\n\n // If the source doesn't exist we have a problem\n if (!fs.existsSync(libPath)) {\n throw new Error(`Failed to find FFMPEG library file at path: ${libPath}`)\n }\n\n // If we are copying to the source we can stop immediately\n if (libPath !== libTargetPath) {\n await fs.copyFile(libPath, libTargetPath)\n }\n return libTargetPath\n }\n}\n"]}
|
||||
23
electron/node_modules/app-builder-lib/out/electron/search-module.d.ts
generated
vendored
Normal file
23
electron/node_modules/app-builder-lib/out/electron/search-module.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Find all instances of a given module in node_modules subdirectories while traversing up
|
||||
* ancestor directories.
|
||||
*
|
||||
* @param cwd the initial directory to traverse
|
||||
* @param moduleName the Node module name (should work for scoped modules as well)
|
||||
* @param rootPath the project's root path. If provided, the traversal will stop at this path.
|
||||
*/
|
||||
export declare function searchForModule(cwd: string, moduleName: string, rootPath?: string): Promise<string[]>;
|
||||
/**
|
||||
* Find all instances of node_modules subdirectories while traversing up ancestor directories.
|
||||
*
|
||||
* @param cwd the initial directory to traverse
|
||||
* @param rootPath the project's root path. If provided, the traversal will stop at this path.
|
||||
*/
|
||||
export declare function searchForNodeModules(cwd: string, rootPath?: string): Promise<string[]>;
|
||||
/**
|
||||
* Determine the root directory of a given project, by looking for a directory with an
|
||||
* NPM or yarn lockfile or pnpm lockfile.
|
||||
*
|
||||
* @param cwd the initial directory to traverse
|
||||
*/
|
||||
export declare function getProjectRootPath(cwd: string): Promise<string>;
|
||||
73
electron/node_modules/app-builder-lib/out/electron/search-module.js
generated
vendored
Normal file
73
electron/node_modules/app-builder-lib/out/electron/search-module.js
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.searchForModule = searchForModule;
|
||||
exports.searchForNodeModules = searchForNodeModules;
|
||||
exports.getProjectRootPath = getProjectRootPath;
|
||||
const fs = require("fs-extra");
|
||||
const path = require("node:path");
|
||||
async function shouldContinueSearch(traversedPath, rootPath, stopAtPackageJSON) {
|
||||
if (rootPath) {
|
||||
return Promise.resolve(traversedPath !== path.dirname(rootPath));
|
||||
}
|
||||
else if (stopAtPackageJSON) {
|
||||
return fs.existsSync(path.join(traversedPath, "package.json"));
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
async function traverseAncestorDirectories(cwd, pathGenerator, rootPath, maxItems, stopAtPackageJSON) {
|
||||
const paths = [];
|
||||
let traversedPath = path.resolve(cwd);
|
||||
while (await shouldContinueSearch(traversedPath, rootPath, stopAtPackageJSON)) {
|
||||
const generatedPath = pathGenerator(traversedPath);
|
||||
if (fs.existsSync(generatedPath)) {
|
||||
paths.push(generatedPath);
|
||||
}
|
||||
const parentPath = path.dirname(traversedPath);
|
||||
if (parentPath === traversedPath || (maxItems && paths.length >= maxItems)) {
|
||||
break;
|
||||
}
|
||||
traversedPath = parentPath;
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
/**
|
||||
* Find all instances of a given module in node_modules subdirectories while traversing up
|
||||
* ancestor directories.
|
||||
*
|
||||
* @param cwd the initial directory to traverse
|
||||
* @param moduleName the Node module name (should work for scoped modules as well)
|
||||
* @param rootPath the project's root path. If provided, the traversal will stop at this path.
|
||||
*/
|
||||
async function searchForModule(cwd, moduleName, rootPath) {
|
||||
const pathGenerator = traversedPath => path.join(traversedPath, "node_modules", moduleName);
|
||||
return traverseAncestorDirectories(cwd, pathGenerator, rootPath, undefined, true);
|
||||
}
|
||||
/**
|
||||
* Find all instances of node_modules subdirectories while traversing up ancestor directories.
|
||||
*
|
||||
* @param cwd the initial directory to traverse
|
||||
* @param rootPath the project's root path. If provided, the traversal will stop at this path.
|
||||
*/
|
||||
async function searchForNodeModules(cwd, rootPath) {
|
||||
const pathGenerator = traversedPath => path.join(traversedPath, "node_modules");
|
||||
return traverseAncestorDirectories(cwd, pathGenerator, rootPath, undefined, true);
|
||||
}
|
||||
/**
|
||||
* Determine the root directory of a given project, by looking for a directory with an
|
||||
* NPM or yarn lockfile or pnpm lockfile.
|
||||
*
|
||||
* @param cwd the initial directory to traverse
|
||||
*/
|
||||
async function getProjectRootPath(cwd) {
|
||||
for (const lockFilename of ["yarn.lock", "package-lock.json", "pnpm-lock.yaml", "bun.lock", "bun.lockb"]) {
|
||||
const pathGenerator = traversedPath => path.join(traversedPath, lockFilename);
|
||||
const lockPaths = await traverseAncestorDirectories(cwd, pathGenerator, undefined, 1);
|
||||
if (lockPaths.length > 0) {
|
||||
return path.dirname(lockPaths[0]);
|
||||
}
|
||||
}
|
||||
return cwd;
|
||||
}
|
||||
//# sourceMappingURL=search-module.js.map
|
||||
1
electron/node_modules/app-builder-lib/out/electron/search-module.js.map
generated
vendored
Normal file
1
electron/node_modules/app-builder-lib/out/electron/search-module.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue