Skip to content

Commit

Permalink
Merge pull request #82 from AuroraTeam/dev
Browse files Browse the repository at this point in the history
Промежуточный релиз 0.0.5-dev.3
  • Loading branch information
JoCat authored Jan 10, 2025
2 parents cb03eaf + b6079a4 commit ee67447
Show file tree
Hide file tree
Showing 45 changed files with 385 additions and 239 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"build:libs": "npm run build -w packages/core -w packages/api"
},
"devDependencies": {
"concurrently": "^9.0.1"
"concurrently": "^9.1.0"
}
}
12 changes: 6 additions & 6 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
},
"homepage": "https://github.com/AuroraTeam/AuroraAPI#readme",
"dependencies": {
"@aurora-launcher/core": "^0.23.0",
"aurora-rpc-client": "^0.3.3"
"@aurora-launcher/core": "^0.24.0",
"aurora-rpc-client": "^0.3.4"
},
"devDependencies": {
"@types/ws": "^8.5.10",
"concurrently": "^9.0.1",
"@types/ws": "^8.5.13",
"concurrently": "^9.1.0",
"esbuild": "^0.24.0",
"import-sort-style-module": "^6.0.0",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"prettier-plugin-import-sort": "0.0.7",
"rimraf": "^6.0.1",
"typescript": "^5.3.3"
"typescript": "^5.6.3"
},
"directories": {
"example": "example"
Expand Down
2 changes: 0 additions & 2 deletions packages/core/.eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions packages/core/.eslintrc.js

This file was deleted.

13 changes: 13 additions & 0 deletions packages/core/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import globals from "globals"
import pluginJs from "@eslint/js"
import tseslint from "typescript-eslint"

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: ["dist"] },
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
]
29 changes: 15 additions & 14 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aurora-launcher/core",
"version": "0.23.0",
"version": "0.25.0",
"description": "Base library for Aurora Launcher",
"type": "commonjs",
"main": "./dist/index.js",
Expand All @@ -15,8 +15,8 @@
"dev": "tsup --watch",
"build": "tsup",
"prettier": "prettier --write src",
"lint": "eslint . --ext .ts",
"lint:fix": "npm run lint -- --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"prepublishOnly": "npm run build"
},
"repository": {
Expand All @@ -43,21 +43,22 @@
"src"
],
"devDependencies": {
"@tsconfig/node20": "^20.1.2",
"@tsconfig/strictest": "^2.0.3",
"@types/node": "^20.11.24",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.56.0",
"@eslint/js": "^9.14.0",
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"@types/node": "^22.9.0",
"eslint": "^9.14.0",
"globals": "^15.12.0",
"import-sort-style-module": "^6.0.0",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"prettier-plugin-import-sort": "0.0.7",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
"tsup": "^8.3.5",
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0"
},
"dependencies": {
"adm-zip": "^0.5.10",
"adm-zip": "^0.5.16",
"p-map": "^7.0.2",
"undici": "^6.7.0"
"undici": "^6.20.1"
}
}
27 changes: 25 additions & 2 deletions packages/core/src/helpers/HashHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,34 @@ import { BinaryLike, createHash } from "crypto"
import { readFile } from "fs/promises"

export class HashHelper {
static getHash(str: BinaryLike, type: string) {
return createHash(type).update(str).digest("hex")
/**
* Получить хеш данных
* @param data Данные
* @param type Тип хеша
* @returns Хеш данных
*/
static getHash(data: BinaryLike, type: string) {
return createHash(type).update(data).digest("hex")
}

/**
* Получить хеш файла
* @param path Путь до файла
* @param type Тип хеша
* @returns Хеш файла
*/
static async getHashFromFile(path: string, type: string) {
return this.getHash(await readFile(path), type)
}

/**
* Сверить хеш файла с предоставленным хешем
* @param path Путь до файла
* @param type Тип хеша
* @param fileHash Хеш файла
* @returns `true` в случае совпадения, `false` в противном случае
*/
static async compareFileHash(path: string, type: string, fileHash: string) {
return (await this.getHashFromFile(path, type)) === fileHash
}
}
10 changes: 4 additions & 6 deletions packages/core/src/helpers/HttpHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class HttpHelper {
try {
const { statusCode } = await request(url, { method: "HEAD" })
return statusCode >= 200 && statusCode < 300
} catch (error) {
} catch {
return false
}
}
Expand Down Expand Up @@ -233,16 +233,14 @@ export class HttpHelper {
private static async verifyFileHash(file: File) {
if (!file.sha1) return false

let currentHash
try {
currentHash = await HashHelper.getHashFromFile(
return await HashHelper.compareFileHash(
file.destinationPath,
"sha1",
file.sha1,
)
} catch (error) {
} catch {
return false
}

return file.sha1 === currentHash
}
}
3 changes: 1 addition & 2 deletions packages/core/src/helpers/JsonHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type JsonData = Record<string, any> | any[]
export type JsonData = unknown

/**
* Класс хелпер для работы с JSON
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/helpers/ZipHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extname } from "path"

import AdmZip from "adm-zip"
import { HashHelper } from "./HashHelper"

export class ZipHelper {
/**
Expand All @@ -18,7 +19,7 @@ export class ZipHelper {
onProgress?: (size: number) => void,
) {
const zip = new AdmZip(archive)
const extractedFiles: string[] = []
const extractedFiles: { path: string; sha1: string }[] = []

zip.getEntries().forEach((entry) => {
if (
Expand All @@ -29,7 +30,11 @@ export class ZipHelper {
return

onProgress && onProgress(entry.header.compressedSize)
extractedFiles.push(entry.entryName)
const sha1 = HashHelper.getHash(entry.getData(), "sha1")
extractedFiles.push({
path: entry.entryName,
sha1,
})
zip.extractEntryTo(entry, destDir, true, true)
})

Expand Down
4 changes: 2 additions & 2 deletions packages/esbuild-decorators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const esbuildDecorators = () => ({

const result = await swc.transformFile(args.path, {
jsc,
sourceMaps: true,
sourceMaps: false,
configFile: false,
swcrc: false,
});
Expand All @@ -46,7 +46,7 @@ export const esbuildDecorators = () => ({
: source;
});
code += `//# sourceMappingURL=data:application/json;base64,${Buffer.from(
JSON.stringify(map)
JSON.stringify(map),
).toString("base64")}`;
}
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/esbuild-decorators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"dependencies": {
"@swc/core": "^1.7.26"
"@swc/core": "^1.9.1"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher
2 changes: 0 additions & 2 deletions packages/server/.eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions packages/server/.eslintrc.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/server/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pluginJs from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: ["dist"] },
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
},
];
50 changes: 25 additions & 25 deletions packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aurora-launcher/server",
"version": "0.0.5-dev.2",
"version": "0.0.5-dev.3",
"description": "LauncherServer for AuroraLauncher",
"keywords": [
"minecraft",
Expand All @@ -27,43 +27,43 @@
"dev": "node scripts/dev.mjs",
"build:dev": "node scripts/build.mjs",
"build:prod": "node scripts/build.mjs --prod",
"build:bin": "pkg dist/LauncherServer.js -t node20-linux-x64,node20-macos-x64,node20-win-x64 --out-path dist --compress GZip",
"build:bin": "pkg dist/LauncherServer.js -t node22-linux-x64,node22-macos-x64,node22-win-x64 --out-path dist --compress GZip",
"clean": "rimraf dist",
"prettier": "prettier --write src",
"typecheck": "tsc --noEmit",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"start": "node ."
},
"devDependencies": {
"@aurora-launcher/esbuild-decorators": "^0.0.1",
"@types/adm-zip": "^0.5.5",
"@types/cli-progress": "^3.11.5",
"@eslint/js": "^9.14.0",
"@types/adm-zip": "^0.5.6",
"@types/cli-progress": "^3.11.6",
"@types/hjson": "^2.4.6",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.11.24",
"@types/node": "^22.9.0",
"@types/prompts": "^2.4.9",
"@types/semver": "^7.5.8",
"@types/uuid": "^10.0.0",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@yao-pkg/pkg": "^5.11.4",
"concurrently": "^9.0.1",
"@types/ws": "^8.5.13",
"@yao-pkg/pkg": "^6.1.0",
"concurrently": "^9.1.0",
"esbuild": "^0.24.0",
"eslint": "^8.56.0",
"eslint-plugin-node": "^11.1.0",
"eslint": "^9.14.0",
"globals": "^15.12.0",
"import-sort-style-module": "^6.0.0",
"minimist": "^1.2.8",
"nodemon": "^3.1.0",
"prettier": "^3.2.5",
"nodemon": "^3.1.7",
"prettier": "^3.3.3",
"prettier-plugin-import-sort": "0.0.7",
"rimraf": "^6.0.1",
"typescript": "^5.3.3"
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0"
},
"dependencies": {
"@aurora-launcher/core": "^0.23.0",
"aurora-rpc-server": "^0.1.5",
"@aurora-launcher/core": "^0.24.0",
"aurora-rpc-server": "^0.1.6",
"chalk": "^5.3.0",
"chokidar": "^4.0.1",
"class-transformer": "^0.5.1",
Expand All @@ -74,19 +74,19 @@
"hjson": "^3.2.2",
"lodash-es": "^4.17.21",
"mssql": "^11.0.1",
"mysql2": "^3.9.2",
"oracledb": "^6.3.0",
"pg": "^8.11.3",
"mysql2": "^3.11.4",
"oracledb": "^6.6.0",
"pg": "^8.13.1",
"prompts": "^2.4.2",
"raw-body": "^3.0.0",
"reflect-metadata": "^0.2.1",
"semver": "^7.6.0",
"reflect-metadata": "^0.2.2",
"semver": "^7.6.3",
"source-map-support": "^0.5.21",
"sqlite3": "^5.1.7",
"strip-ansi": "^7.1.0",
"typedi": "^0.10.0",
"typeorm": "^0.3.20",
"uuid": "^10.0.0"
"uuid": "^11.0.2"
},
"importSort": {
".js, .mjs, .ts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export abstract class AbstractRequest {

abstract emit(req: WebRequest, res: WebResponse): PromiseOr<void>;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
protected isInvalidValue(param: any): boolean {
return typeof param !== "string" || param.trim().length === 0;
}
Expand Down
Loading

0 comments on commit ee67447

Please sign in to comment.