chore: 部分小更改
This commit is contained in:
@@ -100,7 +100,7 @@ export class Dex {
|
||||
zip.forEach(async (e) => {
|
||||
if (important_name.includes(e.fileName)) {
|
||||
contain = e.fileName;
|
||||
this.in = JSON.parse(e.ReadEntrySync.toString());
|
||||
this.in = JSON.parse((await e.ReadEntry).toString());
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
import config from "./utils/config.js";
|
||||
import fsp from "node:fs/promises";
|
||||
import fs from "node:fs";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import { yauzl_promise } from "./utils/yauzl.promise.js";
|
||||
import { Core } from "./core.js";
|
||||
import { DeEarth } from "./utils/DeEarth.js";
|
||||
import { version_compare } from "./utils/utils.js";
|
||||
import { Forge } from "./modloader/forge.js";
|
||||
import { Minecraft } from "./modloader/minecraft.js";
|
||||
import { Fabric } from "./modloader/fabric.js";
|
||||
import { NeoForge } from "./modloader/neoforge.js";
|
||||
|
||||
const core = new Core(config);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import got from "got";
|
||||
import got, { Got } from "got";
|
||||
import { WebSocket } from "ws";
|
||||
import { join } from "node:path";
|
||||
import { Wfastdownload, Utils } from "../utils/utils.js";
|
||||
@@ -14,8 +14,18 @@ export interface CurseForgeManifest {
|
||||
|
||||
export class CurseForge implements XPlatform {
|
||||
private utils: Utils;
|
||||
private got:Got;
|
||||
constructor() {
|
||||
this.utils = new Utils();
|
||||
this.got = got.extend({
|
||||
prefixUrl: this.utils.curseforge_url,
|
||||
headers:{
|
||||
"User-Agent": "DeEarthX",
|
||||
"x-api-key":
|
||||
"$2a$10$ydk0TLDG/Gc6uPMdz7mad.iisj2TaMDytVcIW4gcVP231VKngLBKy",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
})
|
||||
}
|
||||
async getinfo(manifest: object): Promise<modpack_info> {
|
||||
let result: modpack_info = Object.create({});
|
||||
@@ -40,15 +50,9 @@ export class CurseForge implements XPlatform {
|
||||
),
|
||||
});
|
||||
let tmp: [string, string] | string[][] = [];
|
||||
await got
|
||||
.post(this.utils.curseforge_url + "/v1/mods/files", {
|
||||
await this.got
|
||||
.post("v1/mods/files", {
|
||||
body: FileID,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key":
|
||||
"$2a$10$ydk0TLDG/Gc6uPMdz7mad.iisj2TaMDytVcIW4gcVP231VKngLBKy",
|
||||
"User-Agent": "DeEarthX",
|
||||
},
|
||||
})
|
||||
.json()
|
||||
.then((res: any) => {
|
||||
|
||||
@@ -3,8 +3,6 @@ import crypto from "node:crypto"
|
||||
import { yauzl_promise } from "./yauzl.promise.js"
|
||||
import got from "got"
|
||||
import { Utils } from "./utils.js"
|
||||
import pa from "node:path"
|
||||
import WebSocket from "ws"
|
||||
import config from "./config.js"
|
||||
interface IMixins{
|
||||
name: string
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
class Debugger{
|
||||
static log(msg: any){
|
||||
if (process.env.DEBUG){
|
||||
console.log(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
7
backend/src/utils/logger.ts
Normal file
7
backend/src/utils/logger.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
const env = process.env.DEBUG;
|
||||
|
||||
export function debug(msg: string){
|
||||
if (env === "true"){
|
||||
console.info(msg);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import Stream from "node:stream"
|
||||
export interface IentryP extends yauzl.Entry {
|
||||
openReadStream: Promise<Stream.Readable>;
|
||||
ReadEntry: Promise<Buffer>;
|
||||
ReadEntrySync: Buffer;
|
||||
}
|
||||
|
||||
export async function yauzl_promise(buffer: Buffer): Promise<IentryP[]>{
|
||||
@@ -29,7 +28,6 @@ export async function yauzl_promise(buffer: Buffer): Promise<IentryP[]>{
|
||||
isCompressed: entry.isCompressed,
|
||||
openReadStream: _openReadStream(zip,entry),
|
||||
ReadEntry: _ReadEntry(zip,entry),
|
||||
ReadEntrySync: (await _ReadEntry(zip,entry))
|
||||
}
|
||||
entries.push(_entry)
|
||||
if (zip.entryCount === entries.length){
|
||||
|
||||
Reference in New Issue
Block a user