mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
npx command
This commit is contained in:
parent
a85b9c2524
commit
ec488d5028
19
cli.js
19
cli.js
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
const { DOMParser } = require("@xmldom/xmldom");
|
const { DOMParser } = require("@xmldom/xmldom");
|
||||||
const fs = require("fs/promises");
|
const fs = require("fs/promises");
|
||||||
const EFI = require("./core/core");
|
const EFI = require("./core/core");
|
||||||
@ -10,15 +11,15 @@ async function main() {
|
|||||||
console.log("* EaglerForgeInjector CLI *");
|
console.log("* EaglerForgeInjector CLI *");
|
||||||
console.log("***************************");
|
console.log("***************************");
|
||||||
console.log("");
|
console.log("");
|
||||||
console.log("> npm run efi /help #shows this help text");
|
console.log("> npx efi /help #shows this help text");
|
||||||
console.log("> npm run efi my_unminified_file.html #does nothing");
|
console.log("> npx efi my_unminified_file.html #does nothing");
|
||||||
console.log("> npm run efi my_unminified_file.html /eaglerforge #injects eaglerforge");
|
console.log("> npx efi my_unminified_file.html /eaglerforge #injects eaglerforge");
|
||||||
console.log("> npm run efi my_unminified_file.html /minify #minifies file");
|
console.log("> npx efi my_unminified_file.html /minify #minifies file");
|
||||||
console.log("> npm run efi my_unminified_file.html /minify /minify_extras #minifies file with extra optimisations");
|
console.log("> npx efi my_unminified_file.html /minify /minify_extras #minifies file with extra optimisations");
|
||||||
console.log("> npm run efi my_unminified_file.html /eaglerforge /minify #minifies file and injects eaglerforge");
|
console.log("> npx efi my_unminified_file.html /eaglerforge /minify #minifies file and injects eaglerforge");
|
||||||
console.log("> npm run efi my_unminified_file.html /server_extras #inject server hosting stuff");
|
console.log("> npx efi my_unminified_file.html /server_extras #inject server hosting stuff");
|
||||||
console.log("> npm run efi my_unminified_file.html output.html /eaglerforge /minify #minifies file and injects eaglerforge, write to file named output.html");
|
console.log("> npx efi my_unminified_file.html output.html /eaglerforge /minify #minifies file and injects eaglerforge, write to file named output.html");
|
||||||
console.log("> npm run efi my_unminified_file.html /verbose #much logging");
|
console.log("> npx efi my_unminified_file.html /verbose #much logging");
|
||||||
console.log("By default, output is written to processed.html");
|
console.log("By default, output is written to processed.html");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ var modapi_preinit = `globalThis.ModAPI ||= {};
|
|||||||
`;
|
`;
|
||||||
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
||||||
const EFIConfig = {
|
const EFIConfig = {
|
||||||
ModAPIVersion: "v2.7.3",
|
ModAPIVersion: "v2.7.3", //also change in package.json
|
||||||
doEaglerforge: true,
|
doEaglerforge: true,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
doServerExtras: false,
|
doServerExtras: false,
|
||||||
|
35
npx_wrapper.js
Normal file
35
npx_wrapper.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
let cliPath = path.join(__dirname, 'cli.js');
|
||||||
|
if (!require('fs').existsSync(cliPath)) {
|
||||||
|
cliPath = path.join(__dirname, 'bin', 'cli.js');
|
||||||
|
if (!require('fs').existsSync(cliPath)) {
|
||||||
|
console.error("Error: cli.js not found. Expected it in either the same directory as this script, or in a 'bin' subdirectory.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const memUsage = Math.min(16384, Math.floor(os.totalmem() / 1024 / 1024 / 2));
|
||||||
|
|
||||||
|
const nodeOptions = ["--max-old-space-size=" + memUsage];
|
||||||
|
const cliArgs = process.argv.slice(2);
|
||||||
|
const command = process.execPath;
|
||||||
|
|
||||||
|
const child = spawn(command, [...nodeOptions, cliPath, ...cliArgs], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('error', (err) => {
|
||||||
|
console.error(err.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('close', (code) => {
|
||||||
|
if (code !== 0) {
|
||||||
|
console.error(`exited with code ${code}`);
|
||||||
|
}
|
||||||
|
process.exit(code);
|
||||||
|
});
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eaglerforgeinjector",
|
"name": "eaglerforgeinjector",
|
||||||
"version": "0.0.0",
|
"version": "2.7.3",
|
||||||
"description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.",
|
"description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.",
|
||||||
"main": "node.js",
|
"main": "node.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
@ -9,6 +9,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"efi": "node --max-old-space-size=16384 cli.js"
|
"efi": "node --max-old-space-size=16384 cli.js"
|
||||||
},
|
},
|
||||||
|
"bin": {
|
||||||
|
"efi": "./npx_wrapper.js"
|
||||||
|
},
|
||||||
"author": "EaglerForge Team",
|
"author": "EaglerForge Team",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user