diff --git a/esbuild.config.js b/esbuild.config.js index 96b0e32..805b345 100644 --- a/esbuild.config.js +++ b/esbuild.config.js @@ -4,248 +4,354 @@ const fs = require("fs"); const zlib = require("zlib"); const ejs = require("ejs"); const archiver = require("archiver"); -const dependencies = - JSON.parse(fs.readFileSync(__dirname + "/package.json")).dependencies || {}; -const requiredDependencyList = Object.keys(dependencies); -let dependencyList = Object.keys(dependencies); +const chokidar = require("chokidar"); const svrjsInfo = JSON.parse(fs.readFileSync(__dirname + "/svrjs.json")); -const { name, version, documentationURL, changes } = svrjsInfo; +const { version } = svrjsInfo; +const isDev = process.env.NODE_ENV == "development"; -// Function to find and add all dependencies into the dependencyList array. -function findAllDependencies(curList) { - // If no curList parameter is specified, use dependencyList. - if (!curList) curList = dependencyList; - curList.forEach((dependency) => { - const newDeplist = Object.keys( - JSON.parse( - fs - .readFileSync( - __dirname + - "/node_modules/" + - dependency.replace(/\/\.\./g, "") + - "/package.json" - ) - .toString() - ).dependencies || {} - ); - let noDupNewDepList = []; - newDeplist.forEach((dep) => { - // Ignore duplicates - if (dependencyList.indexOf(dep) == -1) { - noDupNewDepList.push(dep); - dependencyList.push(dep); - } - }); - // Call findAllDependencies for the dependency list. - findAllDependencies(noDupNewDepList); - }); -} +// Create the dist directory if it doesn't exist +if (!fs.existsSync(__dirname + "/dist")) fs.mkdirSync(__dirname + "/dist"); +if (!fs.existsSync(__dirname + "/dist/log")) + fs.mkdirSync(__dirname + "/dist/log"); +if (!fs.existsSync(__dirname + "/dist/mods")) + fs.mkdirSync(__dirname + "/dist/mods"); +if (!fs.existsSync(__dirname + "/dist/temp")) + fs.mkdirSync(__dirname + "/dist/temp"); -// Get list of all dependencies -findAllDependencies(); -dependencyList = dependencyList.sort(); +// Create the out directory if it doesn't exist +if (!fs.existsSync(__dirname + "/out")) fs.mkdirSync(__dirname + "/out"); -// Create and populate an object, where whenever the dependencies are required are listed. -let dependenciesAreRequired = {}; -dependencyList.forEach((dependency) => { - dependenciesAreRequired[dependency] = false; -}); -requiredDependencyList.forEach((dependency) => { - dependenciesAreRequired[dependency] = true; -}); +function generateAssets() { + // Variables from "svrjs.json" file + const svrjsInfo = JSON.parse(fs.readFileSync(__dirname + "/svrjs.json")); + const { name, version, documentationURL, changes } = svrjsInfo; -// Create the template functions using EJS -const layoutTemplate = ejs.compile( - fs.readFileSync(__dirname + "/templates/layout.ejs").toString() -); -const testsTemplate = ejs.compile( - fs.readFileSync(__dirname + "/templates/tests.ejs").toString() -); -const indexTemplate = ejs.compile( - fs.readFileSync(__dirname + "/templates/index.ejs").toString() -); -const licensesTemplate = ejs.compile( - fs.readFileSync(__dirname + "/templates/licenses.ejs").toString() -); -const licenseElementTemplate = ejs.compile( - fs.readFileSync(__dirname + "/templates/licenseElement.ejs").toString() -); + // Dependency-related variables + const dependencies = + JSON.parse(fs.readFileSync(__dirname + "/package.json")).dependencies || {}; + const requiredDependencyList = Object.keys(dependencies); + let dependencyList = Object.keys(dependencies); -let licenseElements = ""; - -// Generate the licenses list in HTML -dependencyList.forEach((dependency) => { - const packageJSON = JSON.parse( - fs - .readFileSync( - __dirname + - "/node_modules/" + - dependency.replace(/\/\.\./g, "") + - "/package.json" - ) - .toString() - ); - licenseElements += licenseElementTemplate({ - moduleName: packageJSON.name, - name: name, - license: packageJSON.license, - description: packageJSON.description || "No description", - author: packageJSON.author ? packageJSON.author.name : packageJSON.author, - required: dependenciesAreRequired[dependency] - }); -}); - -// Generate pages -const licensesPage = layoutTemplate({ - title: name + " " + version + " Licenses", - content: licensesTemplate({ - name: name, - version: version, - licenses: licenseElements - }) -}); - -const testsPage = layoutTemplate({ - title: name + " " + version + " Tests", - content: testsTemplate({ - name: name, - version: version - }) -}); - -const indexPage = layoutTemplate({ - title: name + " " + version, - content: indexTemplate({ - name: name, - version: version, - documentationURL: documentationURL, - changes: changes - }) -}); - -// Remove the generated assets directory if exists, and create a new one. -if (fs.existsSync(__dirname + "/generatedAssets")) { - if (fs.rmSync) fs.rmSync(__dirname + "/generatedAssets", { recursive: true }); - else fs.rmdirSync(__dirname + "/generatedAssets", { recursive: true }); -} -fs.mkdirSync(__dirname + "/generatedAssets"); - -// Remove the dist directory if exists, and create a new one. -if (fs.existsSync(__dirname + "/dist")) { - if (fs.rmSync) fs.rmSync(__dirname + "/dist", { recursive: true }); - else fs.rmdirSync(__dirname + "/dist", { recursive: true }); -} -fs.mkdirSync(__dirname + "/dist"); -fs.mkdirSync(__dirname + "/dist/log"); -fs.mkdirSync(__dirname + "/dist/mods"); -fs.mkdirSync(__dirname + "/dist/temp"); - -// Remove the out directory if exists, and create a new one. -if (fs.existsSync(__dirname + "/out")) { - if (fs.rmSync) fs.rmSync(__dirname + "/out", { recursive: true }); - else fs.rmdirSync(__dirname + "/out", { recursive: true }); -} -fs.mkdirSync(__dirname + "/out"); - -// Create a licenses directory -fs.mkdirSync(__dirname + "/generatedAssets/licenses"); - -// Write to HTML files -fs.writeFileSync(__dirname + "/generatedAssets/index.html", indexPage); -fs.writeFileSync(__dirname + "/generatedAssets/tests.html", testsPage); -fs.writeFileSync( - __dirname + "/generatedAssets/licenses/index.html", - licensesPage -); - -// Bundle the source and copy the assets using esbuild and esbuild-plugin-copy -esbuild - .build({ - entryPoints: ["src/index.js"], - bundle: true, - outfile: "dist/svr.js", - platform: "node", - target: "es2017", - plugins: [ - esbuildCopyPlugin.copy({ - resolveFrom: __dirname, - assets: { - from: ["./assets/**/*"], - to: ["./dist"] - }, - globbyOptions: { - dot: true + // Function to find and add all dependencies into the dependencyList array. + const findAllDependencies = (curList) => { + // If no curList parameter is specified, use dependencyList. + if (!curList) curList = dependencyList; + curList.forEach((dependency) => { + const newDeplist = Object.keys( + JSON.parse( + fs + .readFileSync( + __dirname + + "/node_modules/" + + dependency.replace(/\/\.\./g, "") + + "/package.json" + ) + .toString() + ).dependencies || {} + ); + let noDupNewDepList = []; + newDeplist.forEach((dep) => { + // Ignore duplicates + if (dependencyList.indexOf(dep) == -1) { + noDupNewDepList.push(dep); + dependencyList.push(dep); } - }), - esbuildCopyPlugin.copy({ - resolveFrom: __dirname, - assets: { - from: ["./generatedAssets/**/*"], - to: ["./dist"] - } - }) - ] - }) - .then(() => { - const utilFilesAndDirectories = fs.existsSync( - __dirname + "/src/extraScripts" - ) - ? fs.readdirSync(__dirname + "/src/extraScripts") - : []; - const utilFiles = []; - utilFilesAndDirectories.forEach((entry) => { - if (fs.statSync(__dirname + "/src/extraScripts/" + entry).isFile()) - utilFiles.push(entry); - }); - - // Transpile utilities using esbuild - esbuild - .build({ - entryPoints: utilFiles.map( - (filename) => "src/extraScripts/" + filename - ), - bundle: true, - outdir: "dist", - platform: "node", - target: "es2017" - }) - .then(() => { - const archiveName = - "svr.js." + - version.toLowerCase().replace(/[^0-9a-z]+/g, ".") + - ".zip"; - const output = fs.createWriteStream(__dirname + "/out/" + archiveName); - const archive = archiver("zip", { - zlib: { level: 9 } - }); - archive.pipe(output); - - // Add everything in the "dist" directory except for "svr.js" and "svr.compressed" - archive.glob("**/*", { - cwd: __dirname + "/dist", - ignore: ["svr.js", "svr.compressed"], - dot: true - }); - - // Create a stream for the "svr.compressed" file - const compressedSVRJSFileStream = fs - .createReadStream(__dirname + "/dist/svr.js") - .pipe( - zlib.createGzip({ - level: 9 - }) - ); - archive.append(compressedSVRJSFileStream, { name: "svr.compressed" }); - archive.append( - 'const zlib = require("zlib");\nconst fs = require("fs");\nconsole.log("Deleting SVR.JS stub...");\nfs.unlinkSync("svr.js");\nconsole.log("Decompressing SVR.JS...");\nconst script = zlib.gunzipSync(fs.readFileSync("svr.compressed"));\nfs.unlinkSync("svr.compressed");\nfs.writeFileSync("svr.js",script);\nconsole.log("Restart SVR.JS to get server interface.");', - { name: "svr.js" } - ); - archive.finalize(); - }) - .catch((err) => { - throw err; }); - }) - .catch((err) => { - throw err; + // Call findAllDependencies for the dependency list. + findAllDependencies(noDupNewDepList); + }); + }; + + // Get list of all dependencies + findAllDependencies(); + dependencyList = dependencyList.sort(); + + // Create and populate an object, where whenever the dependencies are required are listed. + let dependenciesAreRequired = {}; + dependencyList.forEach((dependency) => { + dependenciesAreRequired[dependency] = false; }); + requiredDependencyList.forEach((dependency) => { + dependenciesAreRequired[dependency] = true; + }); + + // Create the template functions using EJS + const layoutTemplate = ejs.compile( + fs.readFileSync(__dirname + "/templates/layout.ejs").toString() + ); + const testsTemplate = ejs.compile( + fs.readFileSync(__dirname + "/templates/tests.ejs").toString() + ); + const indexTemplate = ejs.compile( + fs.readFileSync(__dirname + "/templates/index.ejs").toString() + ); + const licensesTemplate = ejs.compile( + fs.readFileSync(__dirname + "/templates/licenses.ejs").toString() + ); + const licenseElementTemplate = ejs.compile( + fs.readFileSync(__dirname + "/templates/licenseElement.ejs").toString() + ); + + let licenseElements = ""; + + // Generate the licenses list in HTML + dependencyList.forEach((dependency) => { + const packageJSON = JSON.parse( + fs + .readFileSync( + __dirname + + "/node_modules/" + + dependency.replace(/\/\.\./g, "") + + "/package.json" + ) + .toString() + ); + licenseElements += licenseElementTemplate({ + moduleName: packageJSON.name, + name: name, + license: packageJSON.license, + description: packageJSON.description || "No description", + author: packageJSON.author ? packageJSON.author.name : packageJSON.author, + required: dependenciesAreRequired[dependency] + }); + }); + + // Generate pages + const licensesPage = layoutTemplate({ + title: name + " " + version + " Licenses", + content: licensesTemplate({ + name: name, + version: version, + licenses: licenseElements + }) + }); + + const testsPage = layoutTemplate({ + title: name + " " + version + " Tests", + content: testsTemplate({ + name: name, + version: version + }) + }); + + const indexPage = layoutTemplate({ + title: name + " " + version, + content: indexTemplate({ + name: name, + version: version, + documentationURL: documentationURL, + changes: changes + }) + }); + + // Create the generated assets directory if it doesn't exist + if (!fs.existsSync(__dirname + "/generatedAssets")) + fs.mkdirSync(__dirname + "/generatedAssets"); + + // Create a licenses directory + if (!fs.existsSync(__dirname + "/generatedAssets/licenses")) + fs.mkdirSync(__dirname + "/generatedAssets/licenses"); + + // Write to HTML files + fs.writeFileSync(__dirname + "/generatedAssets/index.html", indexPage); + fs.writeFileSync(__dirname + "/generatedAssets/tests.html", testsPage); + fs.writeFileSync( + __dirname + "/generatedAssets/licenses/index.html", + licensesPage + ); +} + +if (!isDev) { + // Generate assets + generateAssets(); +} else { + // Generate assets with watching + const watcher = chokidar.watch([ + __dirname + "/templates", + __dirname + "/package.json", + __dirname + "/svrjs.json" + ]); + watcher.on("change", () => { + try { + generateAssets(); + } catch (err) { + console.error("There is a problem when regenerating assets!"); + console.error("Stack:"); + console.error(err.stack); + } + }); +} + +if (!isDev) { + // Bundle the source and copy the assets using esbuild and esbuild-plugin-copy + esbuild + .build({ + entryPoints: ["src/index.js"], + bundle: true, + outfile: "dist/svr.js", + platform: "node", + target: "es2017", + plugins: [ + esbuildCopyPlugin.copy({ + resolveFrom: __dirname, + assets: { + from: ["./assets/**/*"], + to: ["./dist"] + }, + globbyOptions: { + dot: true + } + }), + esbuildCopyPlugin.copy({ + resolveFrom: __dirname, + assets: { + from: ["./generatedAssets/**/*"], + to: ["./dist"] + } + }) + ] + }) + .then(() => { + const utilFilesAndDirectories = fs.existsSync( + __dirname + "/src/extraScripts" + ) + ? fs.readdirSync(__dirname + "/src/extraScripts") + : []; + const utilFiles = []; + utilFilesAndDirectories.forEach((entry) => { + if (fs.statSync(__dirname + "/src/extraScripts/" + entry).isFile()) + utilFiles.push(entry); + }); + + // Transpile utilities using esbuild + esbuild + .build({ + entryPoints: utilFiles.map( + (filename) => "src/extraScripts/" + filename + ), + bundle: true, + outdir: "dist", + platform: "node", + target: "es2017" + }) + .then(() => { + const archiveName = + "svr.js." + + version.toLowerCase().replace(/[^0-9a-z]+/g, ".") + + ".zip"; + const output = fs.createWriteStream( + __dirname + "/out/" + archiveName + ); + const archive = archiver("zip", { + zlib: { level: 9 } + }); + archive.pipe(output); + + // Add everything in the "dist" directory except for "svr.js" and "svr.compressed" + archive.glob("**/*", { + cwd: __dirname + "/dist", + ignore: ["svr.js", "svr.compressed"], + dot: true + }); + + // Create a stream for the "svr.compressed" file + const compressedSVRJSFileStream = fs + .createReadStream(__dirname + "/dist/svr.js") + .pipe( + zlib.createGzip({ + level: 9 + }) + ); + archive.append(compressedSVRJSFileStream, { name: "svr.compressed" }); + archive.append( + 'const zlib = require("zlib");\nconst fs = require("fs");\nconsole.log("Deleting SVR.JS stub...");\nfs.unlinkSync("svr.js");\nconsole.log("Decompressing SVR.JS...");\nconst script = zlib.gunzipSync(fs.readFileSync("svr.compressed"));\nfs.unlinkSync("svr.compressed");\nfs.writeFileSync("svr.js",script);\nconsole.log("Restart SVR.JS to get server interface.");', + { name: "svr.js" } + ); + archive.finalize(); + }) + .catch((err) => { + throw err; + }); + }) + .catch((err) => { + throw err; + }); +} else { + // Bundle the source and copy the assets using esbuild and esbuild-plugin-copy with watching + esbuild + .context({ + entryPoints: ["src/index.js"], + bundle: true, + outfile: "dist/svr.js", + platform: "node", + target: "es2017", + plugins: [ + esbuildCopyPlugin.copy({ + resolveFrom: __dirname, + assets: { + from: ["./assets/**/*"], + to: ["./dist"] + }, + globbyOptions: { + dot: true + }, + watch: {} + }), + esbuildCopyPlugin.copy({ + resolveFrom: __dirname, + assets: { + from: ["./generatedAssets/**/*"], + to: ["./dist"] + }, + watch: {} + }) + ] + }) + .then((ctx) => { + ctx + .watch() + .then(() => { + const utilFilesAndDirectories = fs.existsSync( + __dirname + "/src/extraScripts" + ) + ? fs.readdirSync(__dirname + "/src/extraScripts") + : []; + const utilFiles = []; + utilFilesAndDirectories.forEach((entry) => { + if (fs.statSync(__dirname + "/src/extraScripts/" + entry).isFile()) + utilFiles.push(entry); + }); + + // Transpile utilities using esbuild + esbuild + .context({ + entryPoints: utilFiles.map( + (filename) => "src/extraScripts/" + filename + ), + bundle: true, + outdir: "dist", + platform: "node", + target: "es2017" + }) + .then((ctx) => { + ctx + .watch() + .then(() => { + console.log("Watching for changes in SVR.JS source code..."); + }) + .catch((err) => { + throw err; + }); + }) + .catch((err) => { + throw err; + }); + }) + .catch((err) => { + throw err; + }); + }) + .catch((err) => { + throw err; + }); +} diff --git a/nodemon.json b/nodemon.json new file mode 100644 index 0000000..029eec6 --- /dev/null +++ b/nodemon.json @@ -0,0 +1,6 @@ +{ + "watch": [ + "dist/svr.js", + "dist/config.json" + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f393e07..411a557 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,9 @@ "@commitlint/config-conventional": "^19.4.1", "@eslint/js": "^9.9.0", "archiver": "^7.0.1", + "chokidar": "^4.0.1", "commitizen": "^4.3.0", + "concurrently": "^9.1.0", "cz-conventional-changelog": "^3.3.0", "ejs": "^3.1.10", "esbuild": "^0.23.1", @@ -32,7 +34,10 @@ "jest": "^29.7.0", "lint-staged": "^15.2.10", "node-mocks-http": "^1.15.1", - "prettier": "^3.3.3" + "nodemon": "^3.1.7", + "prettier": "^3.3.3", + "rimraf": "^5.0.10", + "wait-on": "^8.0.1" } }, "node_modules/@ampproject/remapping": { @@ -1300,6 +1305,21 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@hapi/hoek": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", + "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==", + "dev": true + }, + "node_modules/@hapi/topo": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", + "integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==", + "dev": true, + "dependencies": { + "@hapi/hoek": "^9.0.0" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -2111,6 +2131,27 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@sideway/address": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", + "integrity": "sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==", + "dev": true, + "dependencies": { + "@hapi/hoek": "^9.0.0" + } + }, + "node_modules/@sideway/formula": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.1.tgz", + "integrity": "sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==", + "dev": true + }, + "node_modules/@sideway/pinpoint": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", + "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", + "dev": true + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -2601,6 +2642,12 @@ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "dev": true }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -2610,6 +2657,17 @@ "node": ">= 4.0.0" } }, + "node_modules/axios": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/b4a": { "version": "1.6.7", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", @@ -3036,27 +3094,18 @@ "dev": true }, "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.1.tgz", + "integrity": "sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==", "dev": true, "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" + "readdirp": "^4.0.1" }, "engines": { - "node": ">= 8.10.0" + "node": ">= 14.16.0" }, "funding": { "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" } }, "node_modules/chownr": { @@ -3250,6 +3299,18 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "12.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", @@ -3351,6 +3412,89 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/concurrently": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.1.0.tgz", + "integrity": "sha512-VxkzwMAn4LP7WyMnJNbHN5mKV9L2IbyDjpzemKr99sXNR3GqRNMMHdm7prV1ws9wg7ETj6WUkNOigZVsptwbgg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -3726,6 +3870,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -3983,6 +4136,30 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/esbuild-plugin-copy/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/esbuild-plugin-copy/node_modules/fs-extra": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", @@ -3997,6 +4174,18 @@ "node": ">=12" } }, + "node_modules/esbuild-plugin-copy/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -4684,6 +4873,26 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", @@ -4700,6 +4909,20 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/formidable": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", @@ -5191,6 +5414,12 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -6685,6 +6914,19 @@ "jiti": "bin/jiti.js" } }, + "node_modules/joi": { + "version": "17.13.3", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.3.tgz", + "integrity": "sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==", + "dev": true, + "dependencies": { + "@hapi/hoek": "^9.3.0", + "@hapi/topo": "^5.1.0", + "@sideway/address": "^4.1.5", + "@sideway/formula": "^3.0.1", + "@sideway/pinpoint": "^2.0.0" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -7764,6 +8006,91 @@ "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "dev": true }, + "node_modules/nodemon": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -8290,6 +8617,18 @@ "node": ">= 6" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -8441,15 +8780,16 @@ } }, "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.0.2.tgz", + "integrity": "sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==", "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, "engines": { - "node": ">=8.10.0" + "node": ">= 14.16.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" } }, "node_modules/require-directory": { @@ -8565,6 +8905,21 @@ "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", "dev": true }, + "node_modules/rimraf": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz", + "integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==", + "dev": true, + "dependencies": { + "glob": "^10.3.7" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -8681,6 +9036,15 @@ "node": ">=8" } }, + "node_modules/shell-quote": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", + "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/side-channel": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", @@ -8715,6 +9079,18 @@ "resolved": "https://registry.npmjs.org/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz", "integrity": "sha512-uEv/AFO0ADI7d99OHDmh1QfYzQk/izT1vCmu/riQfh7qjBVUUgRT87E5s5h7CxWCA/+YoZerykpEthzVrW3LIw==" }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -9141,6 +9517,24 @@ "node": ">=8.0" } }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/ts-api-utils": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", @@ -9219,6 +9613,12 @@ "node": ">=14.17" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "node_modules/undici-types": { "version": "6.19.8", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", @@ -9305,6 +9705,25 @@ "node": ">=10.12.0" } }, + "node_modules/wait-on": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-8.0.1.tgz", + "integrity": "sha512-1wWQOyR2LVVtaqrcIL2+OM+x7bkpmzVROa0Nf6FryXkS+er5Sa1kzFGjzZRqLnHa3n1rACFLeTwUqE1ETL9Mig==", + "dev": true, + "dependencies": { + "axios": "^1.7.7", + "joi": "^17.13.3", + "lodash": "^4.17.21", + "minimist": "^1.2.8", + "rxjs": "^7.8.1" + }, + "bin": { + "wait-on": "bin/wait-on" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index 3f83045..b83c1ca 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,10 @@ "version": "0.0.0", "private": true, "scripts": { - "build": "node esbuild.config.js", + "build": "npm run clean && NODE_ENV=production node esbuild.config.js", "cz": "cz", - "dev": "npm run build && npm run start", + "clean": "rimraf dist && rimraf out && rimraf generatedAssets", + "dev": "npm run clean && concurrently \"NODE_ENV=development node esbuild.config.js\" \"wait-on dist/svr.js && nodemon dist/svr.js --stdout-notty\"", "lint": "eslint --no-error-on-unmatched-pattern src/**/*.js src/*.js tests/**/*.test.js tests/**/*.js tests/*.test.js tests/*.js", "lint:fix": "npm run lint -- --fix", "prepare": "husky", @@ -20,7 +21,9 @@ "@commitlint/config-conventional": "^19.4.1", "@eslint/js": "^9.9.0", "archiver": "^7.0.1", + "chokidar": "^4.0.1", "commitizen": "^4.3.0", + "concurrently": "^9.1.0", "cz-conventional-changelog": "^3.3.0", "ejs": "^3.1.10", "esbuild": "^0.23.1", @@ -34,7 +37,10 @@ "jest": "^29.7.0", "lint-staged": "^15.2.10", "node-mocks-http": "^1.15.1", - "prettier": "^3.3.3" + "nodemon": "^3.1.7", + "prettier": "^3.3.3", + "rimraf": "^5.0.10", + "wait-on": "^8.0.1" }, "dependencies": { "formidable": "^2.1.2", diff --git a/src/index.js b/src/index.js index 0f1d155..f9f6f41 100644 --- a/src/index.js +++ b/src/index.js @@ -117,7 +117,7 @@ if (process.versions) process.versions.svrjs = version; // Inject SVR.JS into pr function printUsage() { console.log(`${name} usage:`); console.log( - "node svr.js [-h] [--help] [-?] [/h] [/?] [--secure] [--reset] [--clean] [--disable-mods] [--single-threaded] [-v] [--version]" + "node svr.js [-h] [--help] [-?] [/h] [/?] [--secure] [--reset] [--clean] [--disable-mods] [--single-threaded] [--stdout-notty] [-v] [--version]" ); console.log("-h -? /h /? --help -- Displays help"); console.log("--clean -- Cleans up files created by " + name); @@ -127,12 +127,16 @@ function printUsage() { console.log("--secure -- Runs HTTPS server"); console.log("--disable-mods -- Disables mods (safe mode)"); console.log("--single-threaded -- Run single-threaded"); + console.log( + "--stdout-notty -- Enable stdout even when stdout is not a TTY. May decrease the performace" + ); console.log("-v --version -- Display server version"); } let exiting = false; let forceSecure = false; let disableMods = false; +let stdoutNoTTY = false; // Handle command line arguments const args = process.argv; @@ -184,6 +188,8 @@ for ( disableMods = true; } else if (args[i] == "--single-threaded") { process.singleThreaded = true; + } else if (args[i] == "--stdout-notty") { + stdoutNoTTY = true; } else { console.log(`Unrecognized argument: ${args[i]}`); printUsage(); @@ -385,7 +391,7 @@ try { // Failed to get inspector URL } -if (!process.stdout.isTTY && !inspectorURL) { +if (!stdoutNoTTY && !process.stdout.isTTY && !inspectorURL) { // When stdout is not a terminal and not attached to an Node.JS inspector, disable it to improve performance of SVR.JS console.log = () => {}; process.stdout.write = () => {};