Remove fs-extra and klaw (#882)

These packages are obsoleted by the promises API to the built-in Node fs
module.  The fs-extra package is also causing problems with broken APIs
that don't behave the same as Node's fs module, and throwing errors
without code properties on them.
This commit is contained in:
Hornwitser authored and GitHub committed 2026-04-09 22:53:13 +02:00
1 parent 130dca4261
commit 2e48b728dd
74 files changed
+570 -529

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@
*/
import path from "path";
import fs from "fs-extra";
import fs from "node:fs/promises";
import crypto from "crypto";
import setBlocking from "set-blocking";
+15 -17
View File
@@ -22,40 +22,38 @@
"dependencies": {
"@clusterio/lib": "workspace:*",
"@sinclair/typebox": "catalog:",
"set-blocking": "catalog:",
"jsonwebtoken": "catalog:",
"express": "catalog:",
"fs-extra": "catalog:",
"ws": "catalog:",
"jszip": "catalog:",
"winston": "catalog:",
"winston-daily-rotate-file": "catalog:",
"busboy": "^1.6.0",
"compression": "^1.8.0",
"express": "catalog:",
"finalhandler": "^1.3.1",
"jsonwebtoken": "catalog:",
"jszip": "catalog:",
"set-blocking": "catalog:",
"winston": "catalog:",
"winston-daily-rotate-file": "catalog:",
"ws": "catalog:",
"yargs": "^17.7.2"
},
"devDependencies": {
"@clusterio/web_ui": "workspace:*",
"@types/jsonwebtoken": "catalog:",
"@types/set-blocking": "catalog:",
"@types/finalhandler": "catalog:",
"@swc/core": "catalog:",
"@types/busboy": "^1.5.0",
"@types/compression": "^1.7.2",
"@types/express": "catalog:",
"@types/fs-extra": "catalog:",
"@types/finalhandler": "catalog:",
"@types/jsonwebtoken": "catalog:",
"@types/node": "catalog:",
"@types/set-blocking": "catalog:",
"@types/ws": "catalog:",
"@types/yargs": "^17.0.33",
"@types/compression": "^1.7.2",
"@types/busboy": "^1.5.0",
"@swc/core": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
"react-router-dom": "catalog:",
"typescript": "catalog:",
"webpack": "catalog:",
"webpack-cli": "catalog:",
"webpack-merge": "catalog:",
"webpack-dev-middleware": "^6.1.1"
"webpack-dev-middleware": "^6.1.1",
"webpack-merge": "catalog:"
},
"publishConfig": {
"access": "public"
+4 -2
View File
@@ -1,5 +1,5 @@
import path from "path";
import fs from "fs-extra";
import fs from "node:fs/promises";
import type Controller from "./Controller";
import type WsServerConnector from "./WsServerConnector";
@@ -94,10 +94,12 @@ export default class BaseConnection extends lib.Link {
async handleModDownloadRequest(request: lib.ModDownloadRequest) {
let mod = this.getMod(request);
let modPath = path.join(this._controller.config.get("controller.mods_directory"), mod.filename);
// Open source file before creating the stream in case it throws.
let source = (await fs.open(modPath)).createReadStream();
let stream = await routes.createProxyStream(this._controller.app);
stream.filename = mod.filename;
stream.source = fs.createReadStream(modPath);
stream.source = source;
stream.mime = "application/zip";
stream.size = String(mod.size);
+5 -5
View File
@@ -7,7 +7,7 @@ import finalhandler from "finalhandler";
import compression from "compression";
import events from "events";
import fs from "fs-extra";
import fs from "node:fs/promises";
import http from "http";
import https from "https";
import jwt from "jsonwebtoken";
@@ -123,7 +123,7 @@ export default class Controller {
static async bootstrap(config: lib.ControllerConfig) {
let databaseDirectory = config.get("controller.database_directory");
await fs.ensureDir(databaseDirectory);
await fs.mkdir(databaseDirectory, { recursive: true });
// Migrate combined user and role file from 2.0.0-alpha.22
await UserManager.attemptMigrateLegacyUsersFile(
@@ -173,7 +173,7 @@ export default class Controller {
).bootstrap());
let modsDirectory = config.get("controller.mods_directory");
await fs.ensureDir(modsDirectory);
await fs.mkdir(modsDirectory, { recursive: true });
const modStore = await lib.ModStore.fromDirectory(modsDirectory);
// Add default mod packs
@@ -602,7 +602,7 @@ export default class Controller {
// First check the clusterio version
const runningVersion = this.config.get("controller.version");
const packageJsonPath = require.resolve("@clusterio/controller/package.json");
const packageJson = await fs.readJSON(packageJsonPath);
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
if (runningVersion !== packageJson.version) {
this.config.restartRequired = true;
return true;
@@ -619,7 +619,7 @@ export default class Controller {
packageName = pluginInfo.npmPackage ?? pluginInfo.name;
const pluginPackageJsonPath = require.resolve(path.posix.join(pluginInfo.requirePath, "package.json"));
const pluginPackageJson = await fs.readJSON(pluginPackageJsonPath);
const pluginPackageJson = JSON.parse(await fs.readFile(pluginPackageJsonPath, "utf8"));
if (pluginInfo.version !== pluginPackageJson.version) {
this.config.restartRequired = true;
return true;
+1 -1
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import jwt from "jsonwebtoken";
import * as lib from "@clusterio/lib";
+1 -1
View File
@@ -4,7 +4,7 @@ import Controller from "./Controller";
import busboy from "busboy";
import crypto from "crypto";
import events from "events";
import fs from "fs-extra";
import fs from "node:fs/promises";
import JSZip from "jszip";
import jwt from "jsonwebtoken";
import path from "path";
+36 -22
View File
@@ -2,7 +2,7 @@
"use strict";
const child_process = require("child_process");
const fs = require("fs-extra");
const fs = require("node:fs/promises");
const inquirer = require("inquirer");
const os = require("os");
const path = require("path");
@@ -97,11 +97,24 @@ class LineSplitter extends stream.Transform {
class InstallError extends Error { }
async function pathExists(filePath) {
try {
await fs.access(filePath);
} catch (err) {
if (err.code === "ENOENT" || err.code === "ENOTDIR") {
return false;
}
}
return true;
}
async function safeOutputFile(file, data, options={}) {
let { dir, name, ext } = path.parse(file);
let temporary = path.join(dir, `${name}.tmp${ext}`);
await fs.outputFile(temporary, data, options);
if (dir) {
await fs.mkdir(dir, { recursive: true });
}
await fs.writeFile(temporary, data, { ...options, flush: true });
await fs.rename(temporary, file);
}
@@ -221,7 +234,7 @@ async function migrateRename(args) {
}
async function migrateConfig(source, destination) {
if (await fs.pathExists(source) && !await fs.pathExists(destination)) {
if (await pathExists(source) && !await pathExists(destination)) {
await safeOutputFile(destination, JSON.stringify(
renameConfig(JSON.parse(await fs.readFile(source))), null, "\t"
));
@@ -233,7 +246,7 @@ async function migrateRename(args) {
await migrateConfig("config-slave.json", "config-host.json");
let instancesFile = path.join("database", "instances.json");
if (await fs.pathExists(instancesFile)) {
if (await pathExists(instancesFile)) {
await safeOutputFile(instancesFile, JSON.stringify(
JSON.parse(await fs.readFile(instancesFile)).map(renameConfig), null, "\t"
));
@@ -241,7 +254,7 @@ async function migrateRename(args) {
}
let usersFile = path.join("database", "users.json");
if (await fs.pathExists(usersFile)) {
if (await pathExists(usersFile)) {
let users = JSON.parse(await fs.readFile(usersFile));
for (let role of users["roles"]) {
role["permissions"] = role["permissions"].map(rename);
@@ -258,7 +271,7 @@ async function migrateRename(args) {
async function migrateLog(inputFile, outputFile) {
let lineStream = new LineSplitter({ readableObjectMode: true });
let fileStream = fs.createReadStream(inputFile);
let fileStream = (await fs.open(inputFile)).createReadStream();
fileStream.pipe(lineStream);
let lines = [];
@@ -278,7 +291,7 @@ async function migrateRename(args) {
}
async function migrateLogsDir(inputLogs, outputLogs) {
if (await fs.pathExists(inputLogs)) {
if (await pathExists(inputLogs)) {
logger.info(`Migrating ${inputLogs} to ${outputLogs}`);
for (let logFile of await fs.readdir(inputLogs)) {
if (!logFile.endsWith(".log")) {
@@ -286,7 +299,7 @@ async function migrateRename(args) {
}
let inputFile = path.join(inputLogs, logFile);
let outputFile = path.join(outputLogs, rename(logFile));
if (!await fs.pathExists(outputFile)) {
if (!await pathExists(outputFile)) {
await migrateLog(inputFile, outputFile);
logger.verbose(`Migrated ${inputFile} to ${outputFile}`);
}
@@ -297,16 +310,16 @@ async function migrateRename(args) {
await migrateLogsDir(path.join("logs", "master"), path.join("logs", "controller"));
await migrateLogsDir(path.join("logs", "slave"), path.join("logs", "host"));
if (
await fs.pathExists(path.join("logs", "cluster"))
&& !await fs.pathExists(path.join("logs", "cluster-prerename"))
await pathExists(path.join("logs", "cluster"))
&& !await pathExists(path.join("logs", "cluster-prerename"))
) {
await fs.rename(path.join("logs", "cluster"), path.join("logs", "cluster-prerename"));
await migrateLogsDir(path.join("logs", "cluster-prerename"), path.join("logs", "cluster"));
}
if (
await fs.pathExists("sharedMods")
&& !await fs.pathExists("mods")
await pathExists("sharedMods")
&& !await pathExists("mods")
) {
logger.info("Moving sharedMods/ to mods/");
await fs.rename("sharedMods", "mods");
@@ -328,8 +341,8 @@ async function migrateRename(args) {
await execFile(`npm${scriptExt}`, ["update"]);
}
const hasRunMaster = await fs.pathExists("run-master.sh") || await fs.pathExists("run-master.cmd");
const hasRunSlave = await fs.pathExists("run-slave.sh") || await fs.pathExists("run-slave.cmd");
const hasRunMaster = await pathExists("run-master.sh") || await pathExists("run-master.cmd");
const hasRunSlave = await pathExists("run-slave.sh") || await pathExists("run-slave.cmd");
if (hasRunMaster || hasRunSlave) {
logger.info("Writing run scripts");
let mode = "standalone";
@@ -354,7 +367,7 @@ async function migrateRename(args) {
async function installClusterio(mode, plugins) {
try {
await fs.outputFile("package.json", JSON.stringify({
await fs.writeFile("package.json", JSON.stringify({
name: "clusterio-install",
private: true,
}, null, 2), { flag: "wx" });
@@ -643,7 +656,7 @@ async function inquirerMissingArgs(args) {
let locations = factorioLocations[process.platform] || [];
let foundLocations = [];
for (let location of locations) {
if (await fs.pathExists(path.join(location, "data", "changelog.txt"))) {
if (await pathExists(path.join(location, "data", "changelog.txt"))) {
foundLocations.push(location);
}
}
@@ -687,7 +700,7 @@ async function inquirerMissingArgs(args) {
},
], answers);
} else if (answers.factorioDir === "factorio") {
await fs.ensureDir("factorio");
await fs.mkdir("factorio", { recursive: true });
}
}
@@ -772,20 +785,21 @@ async function downloadLinuxServer() {
const factorioDir = `factorio/${version}/`;
const tmpFactorioDir = tmpDir + version;
if (await fs.pathExists(factorioDir)) {
if (await pathExists(factorioDir)) {
logger.warn(`setting downloadDir to ${factorioDir}, but not downloading because already existing`);
} else {
await fs.emptyDir(tmpDir);
await fs.rm(tmpDir, { force: true, recursive: true, maxRetries: 10 });
await fs.mkdir(tmpDir, { recursive: true });
logger.info("Downloading latest Factorio server release. This may take a while.");
const writeStream = fs.createWriteStream(tmpArchivePath);
const writeStream = (await fs.open(tmpArchivePath, "w")).createWriteStream();
stream.Readable.fromWeb(res.body).pipe(writeStream);
await finished(writeStream);
await fs.rename(tmpArchivePath, archivePath);
try {
await fs.ensureDir(tmpFactorioDir);
await fs.mkdir(tmpFactorioDir, { recursive: true });
await execFile("tar", [
"xf", archivePath, "-C", tmpFactorioDir, "--strip-components", "1",
]);
@@ -794,7 +808,7 @@ async function downloadLinuxServer() {
throw e;
}
await fs.ensureDir("factorio");
await fs.mkdir("factorio", { recursive: true });
await fs.rename(tmpFactorioDir, factorioDir);
await fs.unlink(archivePath);
await fs.rm(tmpDir);
-1
View File
@@ -17,7 +17,6 @@
},
"dependencies": {
"chalk": "catalog:",
"fs-extra": "catalog:",
"inquirer": "^8.2.4",
"yargs": "^17.7.2"
},
+8 -2
View File
@@ -1,6 +1,6 @@
"use strict";
const { logger } = require("./logging");
const fs = require("fs-extra");
const fs = require("node:fs/promises");
const path = require("path");
const _package = require("./package.json");
@@ -61,9 +61,15 @@ async function copyTemplateFile(src, dst, properties) {
return include ? content : "";
});
// Create folder for output file
const dir = path.parse(dst);
if (dir) {
await fs.mkdir(dir, { recursive: true });
}
// Attempt to write the output file, warn if it already exists
try {
await fs.outputFile(dst, outputData, { flag: "wx" });
await fs.writeFile(dst, outputData, { flag: "wx" });
} catch (err) {
if (err.code === "EEXIST") {
logger.warn(`Could not create file ${dst} because it already exists`);
+1 -1
View File
@@ -4,7 +4,7 @@
* Command line interface for controlling a Clusterio cluster
* @module ctl/ctl
*/
import fs from "fs-extra";
import fs from "node:fs/promises";
import yargs, { type Argv } from "yargs";
import path from "path";
import { version } from "./package.json";
+2 -4
View File
@@ -21,17 +21,15 @@
},
"dependencies": {
"@clusterio/lib": "workspace:*",
"set-blocking": "catalog:",
"fs-extra": "catalog:",
"winston": "catalog:",
"as-table": "^1.0.55",
"set-blocking": "catalog:",
"winston": "catalog:",
"yargs": "^17.7.2"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/fs-extra": "catalog:",
"@types/node": "catalog:",
"@types/set-blocking": "catalog:",
"@types/yargs": "^17.0.33",
+1 -1
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import asTableModule from "as-table";
import events from "events";
import os from "os";
+2 -2
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import asTableModule from "as-table";
import events from "events";
import os from "os";
@@ -87,7 +87,7 @@ hostCommands.add(new lib.Command({
} else {
logger.info(`Writing ${args.output}`);
try {
await fs.outputFile(args.output, content, { flag: "wx" });
await fs.writeFile(args.output, content, { flag: "wx" });
} catch (err: any) {
if (err.code === "EEXIST") {
throw new lib.CommandError(`File ${args.output} already exists`);
+2 -2
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import asTableModule from "as-table";
import events from "events";
import path from "path";
@@ -338,7 +338,7 @@ instanceSaveCommands.add(new lib.Command({
const response = await fetch(url, {
method: "POST",
body: await fs.createReadStream(args.filepath),
body: (await fs.open(args.filepath)).createReadStream(),
duplex: "half",
headers: {
"X-Access-Token": control.config.get("control.controller_token")!,
+2 -2
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import asTableModule from "as-table";
import events from "events";
import path from "path";
@@ -151,7 +151,7 @@ modCommands.add(new lib.Command({
let response = await fetch(url, {
method: "POST",
body: fs.createReadStream(args.file),
body: (await fs.open(args.file)).createReadStream(),
duplex: "half",
headers: {
"X-Access-Token": control.config.get("control.controller_token")!,
+4 -4
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import asTableModule from "as-table";
import path from "path";
@@ -224,7 +224,7 @@ async function handleImportOrRestore(args: {
print(`${restore ? "Restored" : "Imported"} ${importType} from ${args.filepath}`);
if (restore && backup && !args.noBackup) {
await fs.writeJSON(`${importType}-backup.json`, backup, { spaces: 2 });
await fs.writeFile(`${importType}-backup.json`, JSON.stringify(backup, undefined, "\t"));
print(`Wrote backup to ${importType}-backup.json`);
}
}
@@ -296,9 +296,9 @@ userCommands.add(new lib.Command({
exportType = "whitelist";
}
await fs.writeJSON(args.filepath, await control.send(
await fs.writeFile(args.filepath, JSON.stringify(await control.send(
new lib.UserBulkExportRequest(exportType)
), { spaces: 2 });
), undefined, "\t"));
print(`Exported ${exportType} to ${args.filepath}`);
},
}));
+4 -4
View File
@@ -12,7 +12,7 @@
* @example
* npx clusteriohost run
*/
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import yargs from "yargs";
import setBlocking from "set-blocking";
@@ -199,9 +199,9 @@ async function startHost() {
await hostConfigLock.acquire();
// If we get here the command was run
await fs.ensureDir(hostConfig.get("host.instances_directory"));
await fs.ensureDir(hostConfig.get("host.mods_directory"));
await fs.ensureDir("modules");
await fs.mkdir(hostConfig.get("host.instances_directory"), { recursive: true });
await fs.mkdir(hostConfig.get("host.mods_directory"), { recursive: true });
await fs.mkdir("modules", { recursive: true });
// Set the process title, shows up as the title of the CMD window on windows
// and as the process name in ps/top on linux.
-2
View File
@@ -23,7 +23,6 @@
"dependencies": {
"@clusterio/lib": "workspace:*",
"@sinclair/typebox": "catalog:",
"fs-extra": "catalog:",
"jimp": "^1.6.0",
"jszip": "catalog:",
"pidusage": "^3.0.2",
@@ -38,7 +37,6 @@
"access": "public"
},
"devDependencies": {
"@types/fs-extra": "catalog:",
"@types/node": "catalog:",
"@types/pidusage": "^2.0.2",
"@types/semver": "^7.5.0",
+19 -17
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import events from "events";
import pidusage from "pidusage";
@@ -294,7 +294,7 @@ export default class Host extends lib.Link {
static async bootstrap(hostConfig: lib.HostConfig) {
const modsDirectory = hostConfig.get("host.mods_directory");
await fs.ensureDir(modsDirectory);
await fs.mkdir(modsDirectory, { recursive: true });
return [
await lib.ModStore.fromDirectory(modsDirectory),
] as const;
@@ -847,7 +847,7 @@ export default class Host extends lib.Link {
// First check the clusterio version
const runningVersion = this.config.get("host.version");
const packageJsonPath = require.resolve("@clusterio/host/package.json");
const packageJson = await fs.readJSON(packageJsonPath);
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
if (runningVersion !== packageJson.version) {
this.config.restartRequired = true;
return true;
@@ -864,7 +864,7 @@ export default class Host extends lib.Link {
packageName = pluginInfo.npmPackage ?? pluginInfo.name;
const pluginPackageJsonPath = require.resolve(path.posix.join(pluginInfo.requirePath, "package.json"));
const pluginPackageJson = await fs.readJSON(pluginPackageJsonPath);
const pluginPackageJson = JSON.parse(await fs.readFile(pluginPackageJsonPath, "utf8"));
if (pluginInfo.version !== pluginPackageJson.version) {
this.config.restartRequired = true;
return true;
@@ -931,12 +931,17 @@ export default class Host extends lib.Link {
checkRequestSaveName(newName);
let instance = this.getRequestInstance(instanceId);
try {
await fs.move(
// Link save in the new location.
await fs.link(
path.join(instance.path, "saves", oldName),
path.join(instance.path, "saves", newName),
{ overwrite: false },
);
// Unlink save in old location.
await fs.unlink(path.join(instance.path, "saves", oldName));
} catch (err: any) {
if (err.code === "EEXIST") {
throw new lib.RequestError(`${newName} already exists`);
}
if (err.code === "ENOENT") {
throw new lib.RequestError(`${oldName} does not exist`);
}
@@ -951,10 +956,10 @@ export default class Host extends lib.Link {
checkRequestSaveName(destination);
let instance = this.getRequestInstance(instanceId);
try {
await fs.copy(
await fs.copyFile(
path.join(instance.path, "saves", source),
path.join(instance.path, "saves", destination),
{ overwrite: false, errorOnExist: true },
fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE
);
} catch (err: any) {
if (err.code === "ENOENT") {
@@ -980,16 +985,15 @@ export default class Host extends lib.Link {
try {
if (copy) {
await fs.copy(
await fs.copyFile(
path.join(sourceInstance.path, "saves", sourceName),
path.join(targetInstance.path, "saves", targetName),
{ overwrite: true },
fs.constants.COPYFILE_FICLONE
);
} else {
await fs.move(
await fs.rename(
path.join(sourceInstance.path, "saves", sourceName),
path.join(targetInstance.path, "saves", targetName),
{ overwrite: true },
);
}
} catch (err: any) {
@@ -1051,11 +1055,9 @@ export default class Host extends lib.Link {
checkRequestSaveName(name);
let instance = this.getRequestInstance(instanceId);
let content = fs.createReadStream(path.join(instance.path, "saves", name));
let content;
try {
// TODO: Due to a bug in fs-extra the ready event is not emitted here. Replace
// "open" with "ready" when fs-extra is replaced with node's fs module.
await events.once(content, "open");
content = (await fs.open(path.join(instance.path, "saves", name))).createReadStream();
} catch (err: any) {
if (err.code === "ENOENT") {
throw new lib.RequestError(`${name} does not exist`);
@@ -1087,7 +1089,7 @@ export default class Host extends lib.Link {
this.discoveredInstances.delete(instanceId);
this.assignedInstances.delete(instanceId);
await fs.remove(instance.path);
await fs.rm(instance.path, { recursive: true, maxRetries: 10 });
}
async handleHostUpdateRequest(request: lib.HostUpdateRequest) {
+12 -7
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import pidusage from "pidusage";
import util from "util";
@@ -755,8 +755,8 @@ end`.replace(/\r?\n/g, " ");
* @param instanceDir -
*/
static async populate_folders(instanceDir: string) {
await fs.ensureDir(path.join(instanceDir, "script-output"));
await fs.ensureDir(path.join(instanceDir, "saves"));
await fs.mkdir(path.join(instanceDir, "script-output"), { recursive: true });
await fs.mkdir(path.join(instanceDir, "saves"), { recursive: true });
}
/**
@@ -786,7 +786,7 @@ end`.replace(/\r?\n/g, " ");
const mods = await this._host.fetchMods(modPack.mods.values());
await fs.ensureDir(this.path("mods"));
await fs.mkdir(this.path("mods"), { recursive: true });
// Remove all files
for (let entry of await fs.readdir(this.path("mods"), { withFileTypes: true })) {
@@ -825,12 +825,12 @@ end`.replace(/\r?\n/g, " ");
}
// Write mod-list.json
await fs.outputFile(this.path("mods", "mod-list.json"), JSON.stringify({
await fs.writeFile(this.path("mods", "mod-list.json"), JSON.stringify({
mods: [...this.activeModPack.mods.values()],
}, null, "\t"));
// Write mod-settings.dat
await fs.outputFile(this.path("mods", "mod-settings.dat"), this.activeModPack.toModSettingsDat());
await fs.writeFile(this.path("mods", "mod-settings.dat"), this.activeModPack.toModSettingsDat());
}
/**
@@ -921,7 +921,12 @@ end`.replace(/\r?\n/g, " ");
now.getUTCMinutes().toLocaleString("en", { minimumIntegerDigits: 2 }),
saveName,
);
await fs.copy(this.path("saves", saveName), this.path("saves", newName));
// This will overwrite the save if this runs twice in the same minute.
await fs.copyFile(
this.path("saves", saveName),
this.path("saves", newName),
fs.constants.COPYFILE_FICLONE,
);
saveName = newName;
}
+1 -1
View File
@@ -1,5 +1,5 @@
// Export of item icons and locale
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import { Jimp, JimpMime, type JimpInstance } from "jimp";
import JSZip from "jszip";
+4 -2
View File
@@ -1,7 +1,7 @@
// Library for patching Factorio saves with scenario code.
import events from "events";
import fs from "fs-extra";
import fs from "node:fs/promises";
import JSZip from "jszip";
import path from "path";
import semver from "semver";
@@ -93,7 +93,9 @@ export class SaveModule {
static async fromPlugin(plugin: BaseInstancePlugin) {
let pluginPackagePath = require.resolve(path.posix.join(plugin.info.requirePath, "package.json"));
let moduleDirectory = path.join(path.dirname(pluginPackagePath), "module");
if (!await fs.pathExists(moduleDirectory)) {
try {
await fs.access(moduleDirectory);
} catch (err: any) {
return null;
}
+13 -12
View File
@@ -1,5 +1,6 @@
// Factorio Server interface
import fs from "fs-extra";
import fs from "node:fs/promises";
import { type FSWatcher, watch as fsWatch, writeFileSync } from "node:fs";
import child_process from "child_process";
import path from "path";
import JSZip from "jszip";
@@ -116,7 +117,7 @@ async function downloadAndExtractZip(url: string, targetDir: string) {
const zip = await JSZip.loadAsync(buffer);
// Extract each file/folder
await fs.ensureDir(targetDir);
await fs.mkdir(targetDir, { recursive: true });
await Promise.all(
Object.values(zip.files).map(async (entry) => {
const parts = entry.name.split("/").filter(Boolean);
@@ -127,9 +128,9 @@ async function downloadAndExtractZip(url: string, targetDir: string) {
const entryPath = path.join(targetDir, strippedPath);
if (entry.dir) {
await fs.ensureDir(entryPath);
await fs.mkdir(entryPath, { recursive: true });
} else {
await fs.ensureDir(path.dirname(entryPath));
await fs.mkdir(path.dirname(entryPath), { recursive: true });
await fs.writeFile(entryPath, await entry.async("nodebuffer"));
}
})
@@ -153,7 +154,7 @@ async function downloadAndExtractTar(url: string, targetDir: string) {
const tmpFilePath = `${targetDir}.tmp`;
const buffer = Buffer.from(await res.arrayBuffer());
await fs.writeFile(tmpFilePath, buffer);
await fs.ensureDir(targetDir);
await fs.mkdir(targetDir, { recursive: true });
// Execute tar CLI to extract
try {
@@ -165,7 +166,7 @@ async function downloadAndExtractTar(url: string, targetDir: string) {
throw err;
} finally {
// Clean up temp file
await fs.remove(tmpFilePath);
await fs.rm(tmpFilePath);
}
}
@@ -631,7 +632,7 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
// Due to inconsistencies in the factorio api, we must manually watch the whitelist
// https://forums.factorio.com/viewtopic.php?t=123673
_whitelistWatcher: fs.FSWatcher | null = null;
_whitelistWatcher: FSWatcher | null = null;
_whitelist = new Set<string>();
_logger: lib.Logger;
@@ -885,7 +886,7 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
const filePath = this.writePath("server-whitelist.json");
try {
this._whitelistWatcher = fs.watch(filePath);
this._whitelistWatcher = fsWatch(filePath);
} catch (err: any) {
this._logger.warn(`Unable to watch whitelist, bidirectional sync will not be available:\n${err}`);
return;
@@ -907,7 +908,7 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
let newWhitelistJson;
try {
newWhitelistJson = await fs.readJSON(filePath);
newWhitelistJson = JSON.parse(await fs.readFile(filePath, "utf8"));
} catch (err: any) {
this._logger.error(`Unable to read whitelist, bidirectional sync will not be available:\n${err}`);
return;
@@ -1527,20 +1528,20 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
});
// Must be sync to allow process spawn without awaiting
// eslint-disable-next-line node/no-sync
fs.writeFileSync(this.writePath("config.ini"), content);
writeFileSync(this.writePath("config.ini"), content);
}
_writeMapSettingsSync(mapGenSettings?: object, mapSettings?: object) {
// Must be sync to allow process spawn without awaiting
if (mapGenSettings) {
// eslint-disable-next-line node/no-sync
fs.writeFileSync(
writeFileSync(
this.writePath("map-gen-settings.json"), JSON.stringify(mapGenSettings, null, "\t")
);
}
if (mapSettings) {
// eslint-disable-next-line node/no-sync
fs.writeFileSync(
writeFileSync(
this.writePath("map-settings.json"), JSON.stringify(mapSettings, null, "\t")
);
}
+38 -26
View File
@@ -1,9 +1,7 @@
/* eslint-disable no-console */
"use strict";
const events = require("events");
const fs = require("fs-extra");
const fs = require("node:fs/promises");
const JSZip = require("jszip");
const klaw = require("klaw");
const path = require("path");
const stream = require("stream");
const util = require("util");
@@ -14,30 +12,36 @@ const finished = util.promisify(stream.finished);
async function buildMod(args, info, modName) {
if (args.build) {
await fs.ensureDir(args.outputDir);
await fs.mkdir(args.outputDir, { recursive: true });
modName = args.modName ?? `${info.name}_${info.version}`;
if (args.pack) {
let zip = new JSZip();
let walker = klaw(args.sourceDir)
.on("data", item => {
if (item.stats.isFile()) {
// On Windows the path created uses backslashes as the directory sepparator
// but the zip file needs to use forward slashes. We can't use the posix
// version of relative here as it doesn't work with Windows style paths.
let basePath = path.relative(args.sourceDir, item.path).replace(/\\/g, "/");
zip.file(path.posix.join(modName, basePath), fs.createReadStream(item.path));
for await (const dirent of await fs.opendir(args.sourceDir, { recursive: true })) {
if (dirent.isFile()) {
const itemPath = path.join(dirent.parentPath, dirent.name);
// On Windows the path created uses backslashes as the directory sepparator
// but the zip file needs to use forward slashes. We can't use the posix
// version of relative here as it doesn't work with Windows style paths.
let basePath = path.relative(args.sourceDir, itemPath).replace(/\\/g, "/");
// eslint-disable-next-line max-depth
if (basePath === "info.json") {
// The info.json file is overridden later.
continue;
}
})
;
await events.once(walker, "end");
zip.file(path.posix.join(modName, basePath), (await fs.open(itemPath)).createReadStream());
}
}
for (let [fileName, pathParts] of Object.entries(info.additional_files || {})) {
let filePath = path.join(args.sourceDir, ...pathParts);
if (!await fs.pathExists(filePath)) {
throw new Error(`Additional file ${filePath} does not exist`);
let fileStream;
try {
fileStream = (await fs.open(filePath)).createReadStream();
} catch (err) {
throw new Error(`Error reading additional file ${filePath}`, { cause: err });
}
zip.file(path.posix.join(modName, fileName), fs.createReadStream(filePath));
zip.file(path.posix.join(modName, fileName), fileStream);
}
delete info.additional_files;
@@ -45,20 +49,28 @@ async function buildMod(args, info, modName) {
let modPath = path.join(args.outputDir, `${modName}.zip`);
console.log(`Writing ${modPath}`);
let writeStream = zip.generateNodeStream().pipe(fs.createWriteStream(modPath));
let writeStream = zip.generateNodeStream().pipe(
(await fs.open(modPath, "w")).createWriteStream()
);
await finished(writeStream);
} else {
let modDir = path.join(args.outputDir, modName);
if (await fs.exists(modDir)) {
console.log(`Removing existing build ${modDir}`);
await fs.remove(modDir);
}
console.log(`Removing potentially existing build ${modDir}`);
await fs.rm(modDir, { force: true, recursive: true, maxRetries: 10 });
console.log(`Building ${modDir}`);
await fs.copy(args.sourceDir, modDir);
await fs.cp(args.sourceDir, modDir, {
errorOnExists: true,
mode: fs.constants.COPYFILE_FICLONE,
recursive: true,
});
for (let [fileName, pathParts] of Object.entries(info.additional_files) || []) {
let filePath = path.join(...pathParts);
await fs.copy(filePath, path.join(modDir, fileName));
await fs.copyFile(
filePath,
path.join(modDir, fileName),
fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE,
);
}
delete info.additional_files;
@@ -87,7 +99,7 @@ async function build(args) {
if (name === info.name) {
let modPath = path.join(args.outputDir, entry);
console.log(`Removing ${modPath}`);
await fs.remove(modPath);
await fs.rm(modPath, { force: true, recursive: true, maxRetries: 10 });
}
}
}
+7 -10
View File
@@ -19,28 +19,25 @@
},
"dependencies": {
"@sinclair/typebox": "catalog:",
"set-blocking": "catalog:",
"fs-extra": "catalog:",
"jszip": "catalog:",
"ajv": "^8.17.1",
"chalk": "catalog:",
"ws": "catalog:",
"fast-deep-equal": "^3.1.3",
"jszip": "catalog:",
"set-blocking": "catalog:",
"triple-beam": "^1.4.1",
"winston": "catalog:",
"winston-transport": "catalog:",
"fast-deep-equal": "^3.1.3",
"triple-beam": "^1.4.1",
"ajv": "^8.17.1",
"klaw": "^4.1.0",
"ws": "catalog:",
"yargs": "^17.7.2"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/fs-extra": "catalog:",
"@types/node": "catalog:",
"@types/ws": "catalog:",
"@types/set-blocking": "catalog:",
"@types/triple-beam": "^1.3.2",
"@types/ws": "catalog:",
"@types/yargs": "^17.0.33",
"typescript": "catalog:"
}
+3 -3
View File
@@ -1,5 +1,5 @@
"use strict";
const fs = require("fs-extra");
const fs = require("node:fs");
const path = require("path");
const Ajv = require("ajv");
const standaloneCode = require("ajv/dist/standalone").default;
@@ -7,7 +7,7 @@ const standaloneCode = require("ajv/dist/standalone").default;
/* eslint-disable node/no-sync */
// Provide an empty file for message_core to load
fs.outputFileSync(path.join(__dirname, "../dist/node/src/data/message_validate.js"), "");
fs.writeFileSync(path.join(__dirname, "../dist/node/src/data/message_validate.js"), "");
const { Message } = require("../dist/node/src/data/messages_core");
@@ -23,7 +23,7 @@ const ajv = new Ajv({
const validate = ajv.compile(Message.jsonSchema);
let moduleCode = standaloneCode(ajv, validate);
function write(output) {
fs.outputFileSync(
fs.writeFileSync(
path.join(__dirname, output),
`// generated by scripts/compile_validator.js\n// @ts-nocheck\n/* eslint-disable */\n${moduleCode}`
);
+2 -2
View File
@@ -1,5 +1,5 @@
import { FileHandle, open, unlink, readFile } from "fs/promises";
import { unlinkSync } from "fs";
import { FileHandle, open, unlink, readFile } from "node:fs/promises";
import { unlinkSync } from "node:fs";
import assert from "assert";
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import events from "events";
import { Static } from "@sinclair/typebox";
+2 -2
View File
@@ -1,6 +1,6 @@
// Configuration classes
import { Type, Static } from "@sinclair/typebox";
import * as fs from "fs-extra";
import * as fs from "node:fs/promises";
import events from "events";
import isDeepStrictEqual from "../is_deep_strict_equal";
@@ -446,7 +446,7 @@ export class Config<
* @returns Instance of this config
*/
static async fromFile(location: ConfigLocation, filepath: string) {
const fields = await fs.readJson(filepath, { encoding: "utf8" });
const fields = JSON.parse(await fs.readFile(filepath, { encoding: "utf8" }));
return this.fromJSON(fields, location, filepath);
}
+1 -1
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import JSZip from "jszip";
import { Type, Static } from "@sinclair/typebox";
+1 -1
View File
@@ -4,7 +4,7 @@
* @module lib/database
* @author Hornwitser
*/
import fs from "fs-extra";
import fs from "node:fs/promises";
import * as libFileOps from "./file_ops";
import { basicType } from "./helpers";
+1 -1
View File
@@ -1,5 +1,5 @@
import path from "path";
import fs from "fs-extra";
import fs from "node:fs/promises";
import { EventEmitter } from "events";
import { safeOutputFile } from "./file_ops";
+36 -29
View File
@@ -3,7 +3,7 @@
*/
import crypto from "crypto";
import events from "events";
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import stream from "stream";
@@ -46,7 +46,7 @@ export async function getNewestFile(directory: string, filter = (_name: string)
* @returns The size in bytes of all files in the directory.
*/
export async function directorySize(directory: string) {
let dirEntries: fs.Dirent[];
let dirEntries;
try {
dirEntries = await fs.readdir(directory, { withFileTypes: true });
} catch (err: any) {
@@ -91,8 +91,12 @@ export async function findUnusedName(directory: string, name: string, extension
}
while (true) {
if (!await fs.pathExists(path.join(directory, `${name}${extension}`))) {
return `${name}${extension}`;
try {
await fs.access(path.join(directory, `${name}${extension}`));
} catch (err: any) {
if (err.code === "ENOENT") {
return `${name}${extension}`;
}
}
let match = /^(.*?)(-(\d+))?$/.exec(name)!;
@@ -125,12 +129,13 @@ export async function getTempFile(prefix = "tmp.", suffix = "", tmpdir = "./") {
}
/**
* Safely write data to a file
* Safely overwrite file data
*
* Same as fs-extra.outputFile except the data is written to a temporary
* file that's renamed over the target file. The name of the temporary file
* is the same as the target file with the suffix `.tmp` added before the
* extension.
* Writes the passed data to a temporary file and rename it over the target
* file. If the operation fails because the parent directory does not exist, it
* attempts to create the directory, including any ancestors and then retries
* the operation. The name of the temporary file is the same as the target file
* with the suffix `.tmp` added before the extension.
*
* If the operation fails it may leave behind the temporary file. This
* should not be too much of an issue as the next time the same file is
@@ -138,26 +143,32 @@ export async function getTempFile(prefix = "tmp.", suffix = "", tmpdir = "./") {
*
* @param file - Path to file to write.
* @param data - Content to write.
* @param options - see fs.writeFile, `flag` must not be set.
* @param options - see fs.writeFile, `flag` and `flush` may not be used.
*/
export async function safeOutputFile(file: string, data: string | Buffer, options: fs.WriteFileOptions ={}) {
export async function safeOutputFile(
file: string,
data: string | Buffer,
options?: Omit<
Extract<Parameters<typeof fs.writeFile>[2], { flush?: boolean }>,
"flag" | "flush"
>,
) {
let { dir, name, ext } = path.parse(file);
if (dir && !await fs.pathExists(dir)) {
await fs.mkdirs(dir);
}
let temporary = path.join(dir, `${name}.tmp${ext}`);
let fd = await fs.open(temporary, "w");
try {
await fs.writeFile(fd, data, options);
await fs.fsync(fd);
} finally {
await fs.close(fd);
await fs.writeFile(temporary, data, { ...options, flush: true });
} catch (err: any) {
if (err.code === "ENOENT") {
// Try creating the folder and then retry the operation.
await fs.mkdir(dir, { recursive: true });
await fs.writeFile(temporary, data, { ...options, flush: true });
} else {
throw err;
}
}
await fs.rename(temporary, file);
}
// Reserved names by almost all filesystems
const badNames = [".", ".."];
@@ -246,16 +257,14 @@ export function cleanFilename(name: string) {
* @param filePath - The target file to create a temporary stream for.
* @returns The path to the temporary file that was opened and the write stream to it.
*/
export async function createTempWriteStream(filePath: string): Promise<[string, fs.WriteStream]> {
export async function createTempWriteStream(filePath: string) {
const { dir, name: fileName, ext } = path.parse(filePath);
let increment = 1;
let writeStream;
let tempFilePath = path.format({ dir, name: `${fileName}.tmp`, ext });
while (true) {
try {
writeStream = fs.createWriteStream(tempFilePath, { flags: "wx", flush: true });
// replace "open" event with "ready" after removing fs-extra
await events.once(writeStream, "open");
writeStream = (await fs.open(tempFilePath, "wx")).createWriteStream({ flush: true });
break;
} catch (err: any) {
if (err.code === "EEXIST") {
@@ -267,7 +276,7 @@ export async function createTempWriteStream(filePath: string): Promise<[string,
}
}
return [tempFilePath, writeStream];
return [tempFilePath, writeStream] as const;
}
/**
@@ -291,9 +300,7 @@ export async function downloadFile(
let tempFilePath;
if (overwriteMode === "error") {
tempFilePath = filePath;
writeStream = fs.createWriteStream(tempFilePath, { flags: "wx", flush: true });
// replace "open" event with "ready" after removing fs-extra
await events.once(writeStream, "open");
writeStream = (await fs.open(tempFilePath, "wx")).createWriteStream({ flush: true });
} else {
[tempFilePath, writeStream] = await createTempWriteStream(filePath);
}
+3 -3
View File
@@ -3,7 +3,7 @@
* @module lib/hash
*/
import crypto from "crypto";
import fs from "fs-extra";
import fs from "node:fs/promises";
/**
@@ -35,6 +35,6 @@ export function hashStream(stream: NodeJS.ReadableStream): Promise<string> {
* @param path - Path to the file to hash.
* @returns hash of the file given.
*/
export function hashFile(path: string) {
return hashStream(fs.createReadStream(path));
export async function hashFile(path: string) {
return hashStream((await fs.open(path)).createReadStream());
}
+8 -5
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import path from "path";
import { logger } from "./logging";
import * as libFileOps from "./file_ops";
@@ -174,12 +174,15 @@ export async function loadPluginList(pluginListPath: string, findLocal = true):
*/
async function checkPackageJson(pluginPath: string): Promise<boolean> {
const packageJsonPath = path.join(pluginPath, "package.json");
if (!await fs.exists(packageJsonPath)) {
return false;
}
// Read and parse package.json
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, { encoding: "utf8" }));
let content;
try {
content = await fs.readFile(packageJsonPath, { encoding: "utf8" });
} catch (err: any) {
return false;
}
const packageJson = JSON.parse(content);
// Check if package has the clusterio-plugin keyword
return packageJson.keywords?.includes("clusterio-plugin");
+5 -4
View File
@@ -4,7 +4,8 @@
* @author Hornwitser
* @module lib/logging_utils
*/
import fs from "fs-extra";
import fs from "node:fs/promises";
import type { ReadStream } from "node:fs";
import path from "path";
import stream from "stream";
import util from "util";
@@ -320,7 +321,7 @@ export class LogIndex {
async indexFile(file: string) {
let filePath = path.join(this.logDirectory, file);
let lineStream = new libStream.LineSplitter({ readableObjectMode: true });
let fileStream = fs.createReadStream(filePath);
let fileStream = (await fs.open(filePath)).createReadStream();
fileStream.pipe(lineStream);
let entry = {
levels: new Set() as Set<keyof typeof levels>,
@@ -478,11 +479,11 @@ export async function queryLog(logDirectory: string, filter: QueryLogFilter, ind
continue;
}
let filePath = path.join(logDirectory, file);
let fileStream: fs.ReadStream;
let fileStream: ReadStream;
let lineStream: libStream.LineSplitter;
if (filter.order === "asc") {
lineStream = new libStream.LineSplitter({ readableObjectMode: true });
fileStream = fs.createReadStream(filePath);
fileStream = (await fs.open(filePath)).createReadStream();
} else {
lineStream = new libStream.ReverseLineSplitter({ readableObjectMode: true });
fileStream = await libStream.createReverseReadStream(filePath);
+1 -1
View File
@@ -4,7 +4,7 @@
* @module lib/plugin_loader
*/
import path from "path";
import fs from "fs/promises";
import fs from "node:fs/promises";
import * as libErrors from "./errors";
import * as libPlugin from "./plugin";
import { logger } from "./logging";
+9 -8
View File
@@ -1,6 +1,10 @@
import assert from "assert";
import fs from "fs-extra";
import fs from "node:fs"; // Need the non-promise api for reverse stream
import stream from "stream";
import util from "node:util";
const fsOpen = util.promisify(fs.open);
const fsFstat = util.promisify(fs.fstat);
/**
@@ -13,7 +17,7 @@ import stream from "stream";
* ```ts
* let lineStream = new lib.LineSplitter({ readableObjectMode: true });
* lineStream.on("data", line => { console.log(line.toString("utf8")); });
* let fileStream = fs.createReadStream(path);
* let fileStream = (await fs.open(path)).createReadStream();
* fileStream.pipe(lineStream);
* ```
*/
@@ -141,8 +145,8 @@ export async function createReverseReadStream(path: string, options?: ReadStream
if (typeof options === "string") {
options = { encoding: options };
}
const fileFd = await fs.open(path, "r");
const fileSize = (await fs.fstat(fileFd)).size;
const fileFd = await fsOpen(path, "r");
const fileSize = (await fsFstat(fileFd)).size;
let filePosition = fileSize;
const reverseFs = {
read(
@@ -162,8 +166,5 @@ export async function createReverseReadStream(path: string, options?: ReadStream
open() { assert(false); },
close(fd: number, callback: () => void) { return fs.close(fd, callback); },
};
return fs.createReadStream(
"",
{ ...options, fd: fileFd, fs: reverseFs } as ReadStreamOptions, // type specification is missing fs prop.
);
return fs.createReadStream("", { ...options, fd: fileFd, fs: reverseFs });
}
+6 -24
View File
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "node:fs/promises";
import os from "os";
import util from "util";
import { Gauge } from "./prometheus";
@@ -92,14 +92,7 @@ export const systemDiskCapacityBytes = new Gauge(
"Size of the filesystem of the current working directory Node.js runs on",
{
callback: async function(collector) {
// statfs was added in Node.js v18.15.0 and may not be present.
// TODO: remove this check once minimum supported Node.js >= v18.15.0.
if (!fs.statfs) {
collector.set(0);
return;
}
const statFsAsync = util.promisify(fs.statfs);
const stats = await statFsAsync(".");
const stats = await fs.statfs(".");
collector.set(stats.blocks * stats.bsize);
},
},
@@ -110,13 +103,7 @@ export const systemDiskAvailableBytes = new Gauge(
"Available space on the filesystem of the current working directory Node.js runs on",
{
callback: async function(collector) {
// TODO: remove this check once minimum supported Node.js >= v18.15.0.
if (!fs.statfs) {
collector.set(0);
return;
}
const statFsAsync = util.promisify(fs.statfs);
const stats = await statFsAsync(".");
const stats = await fs.statfs(".");
collector.set(stats.bavail * stats.bsize);
},
},
@@ -148,14 +135,9 @@ export async function gatherSystemInfo(
const cpuUsage = minZip(deltaTotalCpuMs, deltaIdleCpuMs).map(([total, idle]) => (total - idle) / total);
previousTotalCpuMs = currentTotalCpuMs;
previousIdleCpuMs = currentIdleCpuMs;
let diskCapacity = 0;
let diskAvailable = 0;
if (fs.statfs) { // TODO: remove this check once minimum supported Node.js >= v18.15.0.
const statFsAsync = util.promisify(fs.statfs);
const stats = await statFsAsync(".");
diskCapacity = stats.blocks * stats.bsize;
diskAvailable = stats.bavail * stats.bsize;
}
const stats = await fs.statfs(".");
let diskCapacity = stats.blocks * stats.bsize;
let diskAvailable = stats.bavail * stats.bsize;
const now = Date.now();
return new SystemInfo(
+2 -4
View File
@@ -45,10 +45,6 @@ module.exports = (env = {}, argv = {}) => ({
],
module: {
rules: [
{
test: /node_modules.fs-extra/,
use: require.resolve("null-loader"),
},
{
test: /node_modules.winston.dist.winston.transports.(http|file)/,
use: require.resolve("null-loader"),
@@ -124,6 +120,8 @@ module.exports = (env = {}, argv = {}) => ({
extensions: [".js", ".ts", ".json", ".jsx", ".tsx"],
fallback: {
"crypto": false,
"fs": false,
"fs/promises": false,
// Required for winston
"util": require.resolve("util/"),