Skip to content

Commit

Permalink
refactoring, new tests, fix functionality on new node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueBurger committed Jun 16, 2024
1 parent f1462ab commit 4010e4d
Show file tree
Hide file tree
Showing 21 changed files with 3,068 additions and 3,561 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void run() {
e.printStackTrace();
}
}

}.runTaskAsynchronously(plugin);
} else pendingPackets.add(obj);
} catch (Exception e) {
Expand Down
44 changes: 12 additions & 32 deletions Server/Gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ const { series, parallel } = gulp;
import { spawnSync, execSync } from "node:child_process";
import fs, { existsSync, readdirSync, rmSync } from "node:fs";
import esbuild from "esbuild";
import { rollup } from "rollup";
import commonjs from '@rollup/plugin-commonjs';
import json from "@rollup/plugin-json"
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import packageJSON from "./package.json" assert {type: "json"}
import packageJSON from "./package.json" with {type: "json"}
import path from "path";

async function installWebIfForgotten() {
Expand Down Expand Up @@ -50,34 +45,21 @@ export async function buildServer() {
execSync("pnpm build");
}

async function runRollup() {
let build = await rollup({
input: {
input: "./dist/Server/src/index.js",
},
plugins: [commonjs(), nodeResolve({browser: false, exportConditions: ["node"]}), json(), replace({
"process.env.NODE_ENV": JSON.stringify('production'),
preventAssignment: true
})],
onwarn(msg) {
if(/Circular dependency\: dist\/(.+) -> dist\/(.+)/.test(msg.message)) {
console.warn("Warning: " + msg.message);
}
}
});
await build.write({
format: "esm",
dir: "_build",
inlineDynamicImports: true,
minifyInternalExports: true,
});
}

async function runESBuild() {
await esbuild.build({
entryPoints: ["_build/input.js"],
entryPoints: ["dist/Server/src/index.js"],
minify: true,
bundle: true,
platform: "node",
format: "esm",
target: "es2022",
banner: {
js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);" // read comments in /src/clients.ts to see explanation for this
},
define: {
"process.env.NODE_ENV": "\"production\""
},
outfile: "_build/burgerpanel.mjs",
});
}
Expand All @@ -92,7 +74,7 @@ function tryRMSync(...args) {
try {
rmSync(...args);
} catch (err) {
console.log(`Could not delete ${args[0]}: ${err}`)
console.log(`Could not delete ${args[0]}: ${err}. This is fine.`)
}
}

Expand Down Expand Up @@ -120,7 +102,6 @@ async function clean() {
}

async function copyFiles() {
fs.rmSync("_build/input.js");
fs.copyFileSync("../LICENSE", "_build/LICENSE.txt");
fs.copyFileSync("../README.md", "_build/README.txt");
if(!process.env.SKIP_WEB) fs.cpSync("../Web/dist/", "_build/Web", {recursive: true});
Expand All @@ -129,7 +110,6 @@ async function copyFiles() {

async function serverSeries() {
await buildServer();
await runRollup();
await runESBuild();
}

Expand Down
2 changes: 1 addition & 1 deletion Server/buildTools/buildInfo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ try {
gitHash = execSync("git rev-parse HEAD").toString().trim();
branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
} catch {}
import packageJSON from "../package.json" assert {type: "json"}
import packageJSON from "../package.json" with {type: "json"}
fs.writeFileSync("../Share/BuildInfo.ts", "export let buildInfo = " + JSON.stringify({
date: Date.now(),
version: packageJSON.version,
Expand Down
35 changes: 18 additions & 17 deletions Server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
"@types/express": "^4.17.18",
"@types/mime-types": "^2.1.2",
"@types/ws": "^8.5.6",
"@vitest/ui": "^0.34.6",
"esbuild": "^0.19.4",
"gulp": "^4.0.2",
"rollup": "^3.29.4",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@types/express": "^4.17.21",
"@types/mime-types": "^2.1.4",
"@types/ws": "^8.5.10",
"@vitest/ui": "^1.6.0",
"esbuild": "^0.21.5",
"gulp": "^5.0.0",
"rollup": "^4.18.0",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
},
"dependencies": {
"blueutilities": "^1.2.2",
"chalk": "^5.3.0",
"express": "^4.18.2",
"express": "^4.19.2",
"mime-types": "^2.1.35",
"mongoose": "^7.5.4",
"ws": "^8.14.2"
}
"mongoose": "^8.4.1",
"ws": "^8.17.0"
},
"packageManager": "[email protected]+sha256.22e36fba7f4880ecf749a5ca128b8435da085ecd49575e7fb9e64d6bf4fad394"
}
Loading

0 comments on commit 4010e4d

Please sign in to comment.