diff --git a/README.md b/README.md index 48d4b23..bf9de09 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # MineXLauncher -### Update data in [updates.json](/public/resources/data/updates.json) +## Usage + +**Prerequisites:** + +- bun installed (install using `npm install --global bun`) + +**Steps:** + +1. Install packages: `bun install --frozen-lockfile` +2. Build: `bun run build` +3. Run server: `PORT=3000 bun run start` ## Client versions @@ -10,8 +20,8 @@ | Name | Version/commit | Date updated | Link | | ------------------ | --------------------------------- | ------------ | ----------------------------------------------------------------------------------------------- | -| 1.9.4 | v0.7.0 | 07/24/2024 | [Gitea](https://git.zelz.net/Eagler-Lambda/hoosiertransfer-mod/releases) | -| 1.8.8 | u35 | 07/24/2024 | [Eagler Archive](https://archive.eaglercraft.rip/EaglercraftX_1.8/client/?sort=time&order=desc) | +| 1.9.4 | v0.6.1 | 07/24/2024 | [Gitea](https://git.zelz.net/Eagler-Lambda/hoosiertransfer-mod/releases) | +| 1.8.8 | auto updated using github actions | | 1.5.2 | sp1.01 | 07/24/2024 | [Eagler Archive](https://archive.eaglercraft.rip/Eaglercraft_1.5/client/?sort=time&order=desc) | | b1.7.3 | `38809105d2` | 09/07/2024 | [Gitea](https://git.eaglercraft.rip/3rdparty/peytonplayz585-b1.7.3) | | b1.3 | 23w49a | 07/24/2024 | [Eagler Archive](https://archive.eaglercraft.rip/Eaglercraft_b1.3/client/?sort=time&order=desc) | diff --git a/build.ts b/build.ts index 040964b..d0288e6 100644 --- a/build.ts +++ b/build.ts @@ -5,11 +5,10 @@ import { statSync, writeFileSync, readFileSync, - // rmSync, + rmSync, } from 'fs'; -import { resolve, dirname, basename } from 'path'; +import { resolve, dirname } from 'path'; import { minify } from 'html-minifier'; -import javascriptObfuscator from 'javascript-obfuscator'; import chalk from 'chalk'; function getFiles(baseDir: string, dir?: string, filesArr?: string[]) { @@ -27,7 +26,6 @@ function getFiles(baseDir: string, dir?: string, filesArr?: string[]) { return filesArr; } -const isDev = process.env.NODE_ENV === 'development' ? true : false; const srcDir = resolve(import.meta.dir, 'src'); const publicDir = resolve( import.meta.dir, @@ -40,22 +38,16 @@ const copyFiles: string[] = []; srcFiles.forEach((file) => { const strippedPath = file.replace(new RegExp(`^${srcDir}`), ''); if (file.endsWith('.ts')) bundleFiles.push(file); - else if (isDev) copyFiles.push(file); - else if (/\.(html|css|js|json)$/.test(strippedPath)) { - if ( - (strippedPath.startsWith('/game/') && - strippedPath.endsWith('/offline.html')) || - basename(strippedPath) === 'classes.js' - ) - copyFiles.push(file); - else minifyFiles.push(file); - } else copyFiles.push(file); + else if ( + /\.(?:html|css|js|json)$/.test(strippedPath) && + !/^\/game\/.*(?:\/offline\.html|\/classes\.js)$/.test(strippedPath) + ) + minifyFiles.push(file); + else copyFiles.push(file); }); -/* if (!isDev) { - console.log(chalk.cyan('Removing old build artifacts...\n')); - rmSync(publicDir, { force: true, recursive: true }); -} */ +console.log(chalk.cyan('Removing old build artifacts...\n')); +rmSync(publicDir, { force: true, recursive: true }); console.log(chalk.cyan('Bundling TypeScript and modules...\n')); await build({ @@ -70,39 +62,21 @@ await build({ }, }); -if (!isDev) { - console.log(chalk.cyan('Minifying HTML, JS, CSS, and JSON...\n')); - minifyFiles.forEach((file) => { - const outputPath = file.replace(new RegExp(`^${srcDir}`), publicDir); - mkdirSync(dirname(outputPath), { recursive: true }); - writeFileSync( - outputPath, - minify(readFileSync(file, 'utf-8'), { - collapseWhitespace: true, - removeComments: true, - minifyCSS: true, - minifyJS: true, - continueOnParseError: true, - }), - ); - }); - - console.log(chalk.cyan('Obfuscating JavaScript...\n')); - bundleFiles.forEach((file) => { - const outputPath = file - .replace(new RegExp(`^${srcDir}`), publicDir) - .replace(/\.ts$/, '.js'); - writeFileSync( - outputPath, - javascriptObfuscator - .obfuscate(readFileSync(outputPath, 'utf-8'), { - //optionsPreset: 'medium-obfuscation', - target: 'browser', - }) - .getObfuscatedCode(), - ); - }); -} +console.log(chalk.cyan('Minifying HTML, JS, CSS, and JSON...\n')); +minifyFiles.forEach((file) => { + const outputPath = file.replace(new RegExp(`^${srcDir}`), publicDir); + mkdirSync(dirname(outputPath), { recursive: true }); + writeFileSync( + outputPath, + minify(readFileSync(file, 'utf-8'), { + collapseWhitespace: true, + removeComments: true, + minifyCSS: true, + minifyJS: true, + continueOnParseError: true, + }), + ); +}); console.log(chalk.cyan('Copying other files...\n')); copyFiles.forEach((file) => { diff --git a/bun.lockb b/bun.lockb index 31eee5b..f409260 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 1e08e64..13a42bf 100644 --- a/package.json +++ b/package.json @@ -4,17 +4,17 @@ "type": "module", "scripts": { "start": "NODE_ENV=production bun run ./server.ts", - "dev": "NODE_ENV=development DEBUG=minexlauncher:* bun --hot run ./server.ts", + "dev": "NODE_ENV=development bun --hot run ./server.ts", "lint": "eslint ./src/resources/scripts/ && tsc", "lint:fix": "eslint --fix ./src/resources/scripts/ && tsc", "build": "NODE_ENV=production bun run ./build.ts", - "build:dev": "NODE_ENV=development bun run ./build.ts", "format": "prettier --write --list-different .", "format:check": "prettier --check .", "proxy": "bun run ./proxy.ts", "proxy:build": "bun build ./proxy.ts --compile --minify --target=bun-linux-x64-modern --outfile ./proxy_linux-x64" }, "dependencies": { + "bun": "^1.1.29", "chalk": "^5.3.0", "compression": "^1.7.4", "cookie-parser": "^1.4.6", @@ -48,7 +48,6 @@ "eslint": "^9.11.1", "eslint-config-prettier": "^9.1.0", "html-minifier": "^4.0.0", - "javascript-obfuscator": "^4.1.1", "prettier": "^3.3.3", "typescript": "^5.6.2", "typescript-eslint": "^8.7.0"