1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 08:04:49 +00:00

move to bun

This commit is contained in:
zumbiepig 2024-08-27 09:17:44 -07:00
parent 1edb684662
commit 0447d8a86c
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE
13 changed files with 114 additions and 3599 deletions

View File

@ -3,6 +3,8 @@ updates:
- package-ecosystem: 'npm' - package-ecosystem: 'npm'
directory: '/' directory: '/'
schedule: schedule:
interval: 'weekly' interval: 'daily'
time: '00:00'
timezone: 'Etc/UTC'
commit-message: commit-message:
prefix: 'dependabot' prefix: 'dependabot'

View File

@ -1,6 +1,6 @@
name: Build name: Build
on: [push, pull_request, workflow_dispatch] on: [push, pull_request]
jobs: jobs:
build: build:
@ -8,13 +8,9 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Node.js - name: Install bun
uses: actions/setup-node@v3 uses: oven-sh/setup-bun@v2
with:
node-version-file: 'package.json'
- name: Install dependencies - name: Install dependencies
run: npm ci run: bun install --frozen-lockfile
- name: Lint
run: npm run lint
- name: Build - name: Build
run: npm run build run: bun run build

75
.gitignore vendored
View File

@ -1,88 +1,113 @@
# Build artifacts package-lock.json
/public/assets.json desktop.ini
/public/resources/scripts/
/public/sw.js
/public/sw-full.js
# System files public/assets.json
.desktop.ini public/resources/scripts/
.DS_Store public/sw.js
public/sw-full.js
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs # Logs
logs logs
*.log _.log
npm-debug.log* npm-debug.log_
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log* lerna-debug.log*
.pnpm-debug.log* .pnpm-debug.log*
# Caches
.cache
# Diagnostic reports (https://nodejs.org/api/report.html) # Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data # Runtime data
pids pids
*.pid _.pid
*.seed _.seed
*.pid.lock *.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover # Directory for instrumented libs generated by jscoverage/JSCover
lib-cov lib-cov
# Coverage directory used by tools like istanbul # Coverage directory used by tools like istanbul
coverage coverage
*.lcov *.lcov
# nyc test coverage # nyc test coverage
.nyc_output .nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt .grunt
# Bower dependency directory (https://bower.io/) # Bower dependency directory (https://bower.io/)
bower_components bower_components
# node-waf configuration # node-waf configuration
.lock-wscript .lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html) # Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release build/Release
# Dependency directories # Dependency directories
node_modules/ node_modules/
jspm_packages/ jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/) # Snowpack dependency directory (https://snowpack.dev/)
web_modules/ web_modules/
# TypeScript cache # TypeScript cache
*.tsbuildinfo *.tsbuildinfo
# Optional npm cache directory # Optional npm cache directory
.npm .npm
# Optional eslint cache # Optional eslint cache
.eslintcache .eslintcache
# Optional stylelint cache # Optional stylelint cache
.stylelintcache .stylelintcache
# Microbundle cache # Microbundle cache
.rpt2_cache/ .rpt2_cache/
.rts2_cache_cjs/ .rts2_cache_cjs/
.rts2_cache_es/ .rts2_cache_es/
.rts2_cache_umd/ .rts2_cache_umd/
# Optional REPL history # Optional REPL history
.node_repl_history .node_repl_history
# Output of 'npm pack' # Output of 'npm pack'
*.tgz *.tgz
# Yarn Integrity file # Yarn Integrity file
.yarn-integrity .yarn-integrity
# dotenv environment variable files # dotenv environment variable files
.env .env
.env.development.local .env.development.local
.env.test.local .env.test.local
@ -90,51 +115,69 @@ web_modules/
.env.local .env.local
# parcel-bundler cache (https://parceljs.org/) # parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache .parcel-cache
# Next.js build output # Next.js build output
.next .next
out out
# Nuxt.js build / generate output # Nuxt.js build / generate output
.nuxt .nuxt
dist dist
# Gatsby files # Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js # Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support # https://nextjs.org/blog/next-9-1#public-directory-support
# public # public
# vuepress build output # vuepress build output
.vuepress/dist .vuepress/dist
# vuepress v2.x temp and cache directory # vuepress v2.x temp and cache directory
.temp .temp
.cache
# Docusaurus cache and generated files # Docusaurus cache and generated files
.docusaurus .docusaurus
# Serverless directories # Serverless directories
.serverless/ .serverless/
# FuseBox cache # FuseBox cache
.fusebox/ .fusebox/
# DynamoDB Local files # DynamoDB Local files
.dynamodb/ .dynamodb/
# TernJS port file # TernJS port file
.tern-port .tern-port
# Stores VSCode versions used for testing VSCode extensions # Stores VSCode versions used for testing VSCode extensions
.vscode-test .vscode-test
# yarn v2 # yarn v2
.yarn/cache .yarn/cache
.yarn/unplugged .yarn/unplugged
.yarn/build-state.yml .yarn/build-state.yml
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store

View File

@ -1,3 +1,7 @@
{ {
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] "recommendations": [
"oven.bun-vscode",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
} }

View File

@ -1,7 +1,7 @@
import eslint from '@eslint/js'; import eslint from '@eslint/js';
import tseslint from 'typescript-eslint'; import tseslint from 'typescript-eslint';
export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, { export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.strict, {
rules: { rules: {
'@typescript-eslint/ban-ts-comment': [ '@typescript-eslint/ban-ts-comment': [
'error', 'error',

View File

@ -1,21 +0,0 @@
import { readdirSync, statSync, writeFileSync } from 'fs';
import { join } from 'path';
const directoryPath = join(import.meta.dirname, 'public');
function getFiles(dir, files_) {
files_ = files_ || [];
const files = readdirSync(dir);
for (let i in files) {
const name = dir + '/' + files[i];
if (statSync(name).isDirectory()) {
getFiles(name, files_);
} else {
files_.push(name.replace(`${import.meta.dirname}/public`, '').replace('/index.html', '/'));
}
}
return files_;
}
const assets = getFiles(directoryPath);
writeFileSync(join(import.meta.dirname, '/public/assets.json'), JSON.stringify(assets, null, 2));

21
generateAssetsList.ts Normal file
View File

@ -0,0 +1,21 @@
import { readdirSync, statSync, writeFileSync } from 'fs';
import { join } from 'path';
const directoryPath = join(import.meta.dir, 'public');
function getFiles(dir: string, filesArr?: string[]) {
filesArr = filesArr || [];
const files = readdirSync(dir);
for (const file of files) {
const name = join(dir, file);
if (statSync(name).isDirectory()) {
getFiles(name, filesArr);
} else {
filesArr.push(name.replace(new RegExp(`^${directoryPath}`), '').replace(/\/index\.html$/, '/'));
}
}
return filesArr;
}
const assets = getFiles(directoryPath);
writeFileSync(join(directoryPath, 'assets.json'), JSON.stringify(assets));

1
index.ts Normal file
View File

@ -0,0 +1 @@
console.log('Hello via Bun!');

3516
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,30 @@
{ {
"name": "minexlauncher",
"private": true, "private": true,
"name": "minexlauncher",
"module": "index.ts",
"type": "module", "type": "module",
"main": "./server.js",
"scripts": { "scripts": {
"start": "node ./server.js", "start": "bun run ./index.ts",
"build": "npm run build:clean && npm run build:compile && npm run build:obfuscate && npm run build:generateAssetsList", "lint": "eslint ./src",
"lint:fix": "eslint --fix ./src",
"build": "bun run lint && bun run build:clean && bun run build:compile && bun run build:obfuscate && bun run generateAssetsList",
"build:clean": "rimraf ./public/resources/scripts ./public/assets.json", "build:clean": "rimraf ./public/resources/scripts ./public/assets.json",
"build:compile": "tsc", "build:compile": "tsc",
"build:obfuscate": "javascript-obfuscator ./public/resources/scripts --output ./public/resources/scripts --options-preset high-obfuscation", "build:obfuscate": "javascript-obfuscator ./public/resources/scripts --output ./public/resources/scripts --options-preset high-obfuscation",
"build:generateAssetsList": "node ./generateAssetsList.js", "generateAssetsList": "bun run ./generateAssetsList.ts"
"lint": "eslint ./src",
"lint:fix": "eslint --fix ./src"
},
"engines": {
"node": "^20.0.0 || ^22.0.0"
}, },
"dependencies": { "dependencies": {
"express": "~4.19.2" "@types/bun": "latest"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.9.1", "@tsconfig/bun": "^1.0.7",
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5", "@tsconfig/strictest": "^2.0.5",
"@types/eslint__js": "^8.42.3", "eslint": "^9.9.1",
"eslint": "^8.57.0",
"javascript-obfuscator": "^4.1.1", "javascript-obfuscator": "^4.1.1",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"typescript": "^5.5.4",
"typescript-eslint": "^8.3.0" "typescript-eslint": "^8.3.0"
},
"peerDependencies": {
"typescript": "^5.0.0"
} }
} }

View File

@ -1,11 +0,0 @@
import express from 'express';
import path from 'path';
const app = express();
const port = process.env.PORT || 3000;
app.use(express.static(path.join(import.meta.dirname, 'public')));
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});

View File

@ -185,7 +185,6 @@ const cookie = {
}, },
}; };
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const storage = { const storage = {
local: { local: {
get: function (key: string) { get: function (key: string) {
@ -214,7 +213,7 @@ const storage = {
const item = localStorage.getItem('minexlauncher'); const item = localStorage.getItem('minexlauncher');
if (item !== null) { if (item !== null) {
const json = JSON.parse(item); const json = JSON.parse(item);
delete json[key]; json[key] = undefined;
localStorage.setItem('minexlauncher', JSON.stringify(json)); localStorage.setItem('minexlauncher', JSON.stringify(json));
} }
}, },
@ -246,7 +245,7 @@ const storage = {
const item = sessionStorage.getItem('minexlauncher'); const item = sessionStorage.getItem('minexlauncher');
if (item !== null) { if (item !== null) {
const json = JSON.parse(item); const json = JSON.parse(item);
delete json[key]; json[key] = undefined;
sessionStorage.setItem('minexlauncher', JSON.stringify(json)); sessionStorage.setItem('minexlauncher', JSON.stringify(json));
} }
}, },

View File

@ -1,11 +1,11 @@
{ {
"extends": ["@tsconfig/node20/tsconfig", "@tsconfig/strictest/tsconfig"], "extends": ["@tsconfig/bun", "@tsconfig/strictest"],
"compilerOptions": { "compilerOptions": {
"moduleResolution": "bundler",
"module": "preserve",
"lib": ["es2023", "dom"],
"rootDir": "src", "rootDir": "src",
"outDir": "public", "outDir": "public",
"moduleDetection": "auto",
"allowImportingTsExtensions": false,
"noEmit": false,
"removeComments": true "removeComments": true
}, },
"include": ["src"] "include": ["src"]