update electron to v43

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -1,9 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.copyFiles = exports.getFileMatchers = exports.getNodeModuleFileMatcher = exports.getMainFileMatchers = exports.FileMatcher = exports.excludedExts = exports.excludedNames = void 0;
const bluebird_lst_1 = require("bluebird-lst");
exports.FileMatcher = exports.excludedExts = exports.excludedNames = void 0;
exports.getMainFileMatchers = getMainFileMatchers;
exports.getNodeModuleFileMatcher = getNodeModuleFileMatcher;
exports.getFileMatchers = getFileMatchers;
exports.copyFiles = copyFiles;
const builder_util_1 = require("builder-util");
const fs_1 = require("builder-util/out/fs");
const promises_1 = require("fs/promises");
const minimatch_1 = require("minimatch");
const path = require("path");
@ -14,9 +16,11 @@ const minimatchOptions = { dot: true };
exports.excludedNames = ".git,.hg,.svn,CVS,RCS,SCCS," +
"__pycache__,.DS_Store,thumbs.db,.gitignore,.gitkeep,.gitattributes,.npmignore," +
".idea,.vs,.flowconfig,.jshintrc,.eslintrc,.circleci," +
".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log," +
"appveyor.yml,.travis.yml,circle.yml,.nyc_output";
exports.excludedExts = "iml,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,suo,xproj,cc,d.ts";
".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log,pnpm-lock.yaml,bun.lock,bun.lockb," +
"appveyor.yml,.travis.yml,circle.yml,.nyc_output,.husky,.github,electron-builder.env";
exports.excludedExts = "iml,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,suo,xproj,cc,d.ts," +
// https://github.com/electron-userland/electron-builder/issues/7512
"mk,a,o,obj,forge-meta";
function ensureNoEndSlash(file) {
if (path.sep !== "/") {
file = file.replace(/\//g, path.sep);
@ -31,14 +35,13 @@ function ensureNoEndSlash(file) {
return file;
}
}
/** @internal */
class FileMatcher {
constructor(from, to, macroExpander, patterns) {
this.macroExpander = macroExpander;
this.excludePatterns = null;
this.from = ensureNoEndSlash(macroExpander(from));
this.to = ensureNoEndSlash(macroExpander(to));
this.patterns = builder_util_1.asArray(patterns).map(it => this.normalizePattern(it));
this.patterns = (0, builder_util_1.asArray)(patterns).map(it => this.normalizePattern(it));
this.isSpecifiedAsEmptyArray = Array.isArray(patterns) && patterns.length === 0;
}
normalizePattern(pattern) {
@ -73,7 +76,7 @@ class FileMatcher {
const parsedPattern = new minimatch_1.Minimatch(pattern, minimatchOptions);
result.push(parsedPattern);
// do not add if contains dot (possibly file if has extension)
if (!pattern.includes(".") && !filter_1.hasMagic(parsedPattern)) {
if (!pattern.includes(".") && !(0, filter_1.hasMagic)(parsedPattern)) {
// https://github.com/electron-userland/electron-builder/issues/545
// add **/*
result.push(new minimatch_1.Minimatch(`${pattern}/**/*`, minimatchOptions));
@ -83,7 +86,7 @@ class FileMatcher {
createFilter() {
const parsedPatterns = [];
this.computeParsedPatterns(parsedPatterns);
return filter_1.createFilter(this.from, parsedPatterns, this.excludePatterns);
return (0, filter_1.createFilter)(this.from, parsedPatterns, this.excludePatterns);
}
toString() {
return `from: ${this.from}, to: ${this.to}, patterns: ${this.patterns.join(", ")}`;
@ -120,7 +123,19 @@ function getMainFileMatchers(appDir, destination, macroExpander, platformSpecifi
else if (!patterns.includes("package.json")) {
patterns.push("package.json");
}
customFirstPatterns.push("!**/node_modules");
let insertExculdeNodeModulesIndex = -1;
for (let i = 0; i < patterns.length; i++) {
if (!patterns[i].startsWith("!") && (patterns[i].includes("/node_modules") || patterns[i].includes("node_modules/"))) {
insertExculdeNodeModulesIndex = i;
break;
}
}
if (insertExculdeNodeModulesIndex !== -1) {
patterns.splice(insertExculdeNodeModulesIndex, 0, ...["!**/node_modules/**"]);
}
else {
customFirstPatterns.push("!**/node_modules/**");
}
// https://github.com/electron-userland/electron-builder/issues/1482
const relativeBuildResourceDir = path.relative(matcher.from, buildResourceDir);
if (relativeBuildResourceDir.length !== 0 && !relativeBuildResourceDir.startsWith(".")) {
@ -141,7 +156,7 @@ function getMainFileMatchers(appDir, destination, macroExpander, platformSpecifi
patterns.splice(insertIndex, 0, ...customFirstPatterns);
patterns.push(`!**/*.{${exports.excludedExts}${packager.config.includePdb === true ? "" : ",pdb"}}`);
patterns.push("!**/._*");
patterns.push("!**/electron-builder.{yaml,yml,json,json5,toml}");
patterns.push("!**/electron-builder.{yaml,yml,json,json5,toml,ts}");
patterns.push(`!**/{${exports.excludedNames}}`);
if (isElectronCompile) {
patterns.push("!.cache{,/**/*}");
@ -158,7 +173,6 @@ function getMainFileMatchers(appDir, destination, macroExpander, platformSpecifi
}
return matchers;
}
exports.getMainFileMatchers = getMainFileMatchers;
/** @internal */
function getNodeModuleFileMatcher(appDir, destination, macroExpander, platformSpecificBuildOptions, packager) {
// https://github.com/electron-userland/electron-builder/pull/2948#issuecomment-392241632
@ -185,7 +199,7 @@ function getNodeModuleFileMatcher(appDir, destination, macroExpander, platformSp
else {
const fileSet = pattern;
if (fileSet.from == null || fileSet.from === ".") {
for (const p of builder_util_1.asArray(fileSet.filter)) {
for (const p of (0, builder_util_1.asArray)(fileSet.filter)) {
matcher.addPattern(p);
}
}
@ -204,8 +218,6 @@ function getNodeModuleFileMatcher(appDir, destination, macroExpander, platformSp
}
return matcher;
}
exports.getNodeModuleFileMatcher = getNodeModuleFileMatcher;
/** @internal */
function getFileMatchers(config, name, defaultDestination, options) {
const defaultMatcher = new FileMatcher(options.defaultSrc, defaultDestination, options.macroExpander);
const fileMatchers = [];
@ -250,33 +262,31 @@ function getFileMatchers(config, name, defaultDestination, options) {
}
return fileMatchers.length === 0 ? null : fileMatchers;
}
exports.getFileMatchers = getFileMatchers;
/** @internal */
function copyFiles(matchers, transformer, isUseHardLink) {
if (matchers == null || matchers.length === 0) {
return Promise.resolve();
}
return bluebird_lst_1.default.map(matchers, async (matcher) => {
const fromStat = await fs_1.statOrNull(matcher.from);
return Promise.all(matchers.map(async (matcher) => {
const fromStat = await (0, builder_util_1.statOrNull)(matcher.from);
if (fromStat == null) {
builder_util_1.log.warn({ from: matcher.from }, `file source doesn't exist`);
return;
}
if (fromStat.isFile()) {
const toStat = await fs_1.statOrNull(matcher.to);
const toStat = await (0, builder_util_1.statOrNull)(matcher.to);
// https://github.com/electron-userland/electron-builder/issues/1245
if (toStat != null && toStat.isDirectory()) {
return await fs_1.copyOrLinkFile(matcher.from, path.join(matcher.to, path.basename(matcher.from)), fromStat, isUseHardLink);
return await (0, builder_util_1.copyOrLinkFile)(matcher.from, path.join(matcher.to, path.basename(matcher.from)), fromStat, isUseHardLink);
}
await promises_1.mkdir(path.dirname(matcher.to), { recursive: true });
return await fs_1.copyOrLinkFile(matcher.from, matcher.to, fromStat);
await (0, promises_1.mkdir)(path.dirname(matcher.to), { recursive: true });
return await (0, builder_util_1.copyOrLinkFile)(matcher.from, matcher.to, fromStat);
}
if (matcher.isEmpty() || matcher.containsOnlyIgnore()) {
matcher.prependPattern("**/*");
}
builder_util_1.log.debug({ matcher }, "copying files using pattern");
return await fs_1.copyDir(matcher.from, matcher.to, { filter: matcher.createFilter(), transformer, isUseHardLink: isUseHardLink ? fs_1.USE_HARD_LINKS : null });
});
return await (0, builder_util_1.copyDir)(matcher.from, matcher.to, { filter: matcher.createFilter(), transformer, isUseHardLink: isUseHardLink ? builder_util_1.USE_HARD_LINKS : null });
}));
}
exports.copyFiles = copyFiles;
//# sourceMappingURL=fileMatcher.js.map