forked from olcxjas-softworks/LarpixClient
update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
151
electron/node_modules/app-builder-lib/out/util/NodeModuleCopyHelper.js
generated
vendored
151
electron/node_modules/app-builder-lib/out/util/NodeModuleCopyHelper.js
generated
vendored
|
|
@ -1,16 +1,27 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NodeModuleCopyHelper = void 0;
|
||||
const bluebird_lst_1 = require("bluebird-lst");
|
||||
const fs_1 = require("builder-util/out/fs");
|
||||
const builder_util_1 = require("builder-util");
|
||||
const fs_1 = require("fs");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const path = require("path");
|
||||
const tiny_async_pool_1 = require("tiny-async-pool");
|
||||
const fileMatcher_1 = require("../fileMatcher");
|
||||
const platformPackager_1 = require("../platformPackager");
|
||||
const AppFileWalker_1 = require("./AppFileWalker");
|
||||
const excludedFiles = new Set([".DS_Store", "node_modules" /* already in the queue */, "CHANGELOG.md", "ChangeLog", "changelog.md", "Changelog.md", "Changelog", "binding.gyp", ".npmignore"].concat(fileMatcher_1.excludedNames.split(",")));
|
||||
const resolve_1 = require("./resolve");
|
||||
const excludedFiles = new Set([
|
||||
".DS_Store",
|
||||
"node_modules" /* already in the queue */,
|
||||
"CHANGELOG.md",
|
||||
"ChangeLog",
|
||||
"changelog.md",
|
||||
"Changelog.md",
|
||||
"Changelog",
|
||||
"binding.gyp",
|
||||
".npmignore",
|
||||
"node_gyp_bins",
|
||||
].concat(fileMatcher_1.excludedNames.split(",")));
|
||||
const topLevelExcludedFiles = new Set([
|
||||
"test.js",
|
||||
"karma.conf.js",
|
||||
".coveralls.yml",
|
||||
"README.md",
|
||||
|
|
@ -21,8 +32,8 @@ const topLevelExcludedFiles = new Set([
|
|||
"Readme",
|
||||
"readme",
|
||||
"test",
|
||||
"__tests__",
|
||||
"tests",
|
||||
"__tests__",
|
||||
"powered-test",
|
||||
"example",
|
||||
"examples",
|
||||
|
|
@ -33,32 +44,37 @@ class NodeModuleCopyHelper extends AppFileWalker_1.FileCopyHelper {
|
|||
constructor(matcher, packager) {
|
||||
super(matcher, matcher.isEmpty() ? null : matcher.createFilter(), packager);
|
||||
}
|
||||
async collectNodeModules(baseDir, moduleNames, nodeModuleExcludedExts) {
|
||||
async collectNodeModules(moduleInfo, nodeModuleExcludedExts, destination) {
|
||||
var _a;
|
||||
const filter = this.filter;
|
||||
const metadata = this.metadata;
|
||||
const onNodeModuleFile = platformPackager_1.resolveFunction(this.packager.config.onNodeModuleFile, "onNodeModuleFile");
|
||||
const onNodeModuleFile = await (0, resolve_1.resolveFunction)(this.packager.appInfo.type, this.packager.config.onNodeModuleFile, "onNodeModuleFile", await this.packager.getWorkspaceRoot());
|
||||
const result = [];
|
||||
const queue = [];
|
||||
for (const moduleName of moduleNames) {
|
||||
const tmpPath = baseDir + path.sep + moduleName;
|
||||
queue.length = 1;
|
||||
// The path should be corrected in Windows that when the moduleName is Scoped packages named.
|
||||
const depPath = path.normalize(tmpPath);
|
||||
queue[0] = depPath;
|
||||
while (queue.length > 0) {
|
||||
const dirPath = queue.pop();
|
||||
const childNames = await fs_extra_1.readdir(dirPath);
|
||||
childNames.sort();
|
||||
const isTopLevel = dirPath === depPath;
|
||||
const dirs = [];
|
||||
// our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map
|
||||
const sortedFilePaths = await bluebird_lst_1.default.map(childNames, name => {
|
||||
if (onNodeModuleFile != null) {
|
||||
onNodeModuleFile(dirPath + path.sep + name);
|
||||
}
|
||||
if (excludedFiles.has(name) || name.startsWith("._")) {
|
||||
return null;
|
||||
}
|
||||
const emptyDirs = new Set();
|
||||
const symlinkFiles = new Map();
|
||||
const tmpPath = moduleInfo.dir;
|
||||
const moduleName = moduleInfo.name;
|
||||
queue.length = 1;
|
||||
// The path should be corrected in Windows that when the moduleName is Scoped packages named.
|
||||
const depPath = path.normalize(tmpPath);
|
||||
queue[0] = depPath;
|
||||
while (queue.length > 0) {
|
||||
const dirPath = queue.pop();
|
||||
const childNames = await (0, fs_extra_1.readdir)(dirPath);
|
||||
childNames.sort();
|
||||
const isTopLevel = dirPath === depPath;
|
||||
const dirs = [];
|
||||
// our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map
|
||||
const sortedFilePaths = await (0, tiny_async_pool_1.default)(builder_util_1.MAX_FILE_REQUESTS, childNames, async (name) => {
|
||||
const filePath = path.join(dirPath, name);
|
||||
const forceIncluded = onNodeModuleFile != null && !!onNodeModuleFile(filePath);
|
||||
if (excludedFiles.has(name) || name.startsWith("._")) {
|
||||
return null;
|
||||
}
|
||||
// check if filematcher matches the files array as more important than the default excluded files.
|
||||
const fileMatched = filter != null && filter(dirPath, (0, fs_extra_1.lstatSync)(dirPath));
|
||||
if (!fileMatched || !forceIncluded || !!this.packager.config.disableDefaultIgnoredFiles) {
|
||||
for (const ext of nodeModuleExcludedExts) {
|
||||
if (name.endsWith(ext)) {
|
||||
return null;
|
||||
|
|
@ -82,50 +98,67 @@ class NodeModuleCopyHelper extends AppFileWalker_1.FileCopyHelper {
|
|||
else if (dirPath.endsWith("lzma-native") && (name === "build" || name === "deps")) {
|
||||
return null;
|
||||
}
|
||||
const filePath = dirPath + path.sep + name;
|
||||
return fs_extra_1.lstat(filePath).then(stat => {
|
||||
if (filter != null && !filter(filePath, stat)) {
|
||||
}
|
||||
return (0, fs_extra_1.lstat)(filePath).then((stat) => {
|
||||
stat.moduleName = moduleName;
|
||||
stat.moduleRootPath = destination;
|
||||
stat.moduleFullFilePath = path.join(destination, path.relative(depPath, filePath));
|
||||
if (filter != null && !filter(filePath, stat)) {
|
||||
return null;
|
||||
}
|
||||
if (!stat.isDirectory()) {
|
||||
metadata.set(filePath, stat);
|
||||
}
|
||||
const consumerResult = this.handleFile(filePath, dirPath, stat);
|
||||
if (consumerResult == null) {
|
||||
if (stat.isDirectory()) {
|
||||
dirs.push(name);
|
||||
return null;
|
||||
}
|
||||
if (!stat.isDirectory()) {
|
||||
metadata.set(filePath, stat);
|
||||
else {
|
||||
return filePath;
|
||||
}
|
||||
const consumerResult = this.handleFile(filePath, dirPath, stat);
|
||||
if (consumerResult == null) {
|
||||
if (stat.isDirectory()) {
|
||||
}
|
||||
else {
|
||||
return consumerResult.then(it => {
|
||||
// asarUtil can return modified stat (symlink handling)
|
||||
if ((it == null ? stat : it).isDirectory()) {
|
||||
dirs.push(name);
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return consumerResult.then(it => {
|
||||
// asarUtil can return modified stat (symlink handling)
|
||||
if ((it == null ? stat : it).isDirectory()) {
|
||||
dirs.push(name);
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return filePath;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, fs_1.CONCURRENCY);
|
||||
for (const child of sortedFilePaths) {
|
||||
if (child != null) {
|
||||
result.push(child);
|
||||
});
|
||||
}
|
||||
}
|
||||
dirs.sort();
|
||||
for (const child of dirs) {
|
||||
queue.push(dirPath + path.sep + child);
|
||||
});
|
||||
});
|
||||
let isEmpty = true;
|
||||
for (const child of sortedFilePaths) {
|
||||
if (child != null) {
|
||||
result.push(child);
|
||||
if ((_a = this.metadata.get(child)) === null || _a === void 0 ? void 0 : _a.isSymbolicLink()) {
|
||||
symlinkFiles.set(child, result.length - 1);
|
||||
}
|
||||
isEmpty = false;
|
||||
}
|
||||
}
|
||||
if (isEmpty) {
|
||||
emptyDirs.add(dirPath);
|
||||
}
|
||||
dirs.sort();
|
||||
for (const child of dirs) {
|
||||
queue.push(dirPath + path.sep + child);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
for (const [file, index] of symlinkFiles) {
|
||||
const resolvedPath = (0, fs_1.realpathSync)(file);
|
||||
if (emptyDirs.has(resolvedPath)) {
|
||||
// delete symlink file if target is a empty dir
|
||||
result[index] = undefined;
|
||||
}
|
||||
}
|
||||
return result.filter((it) => it !== undefined);
|
||||
}
|
||||
}
|
||||
exports.NodeModuleCopyHelper = NodeModuleCopyHelper;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue