fnlb 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1 -1
- package/package.json +20 -20
package/README.md
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -5,21 +5,23 @@ export interface FNLBConfig {
|
|
|
5
5
|
disableErrorLogs?: boolean;
|
|
6
6
|
disableSubProcessLogs?: boolean;
|
|
7
7
|
disableSubProcessErrorLogs?: boolean;
|
|
8
|
+
clusterName?: string;
|
|
8
9
|
}
|
|
9
10
|
export interface StartConfig {
|
|
10
|
-
|
|
11
|
+
apiToken: string;
|
|
11
12
|
categories?: string[];
|
|
12
13
|
numberOfShards?: number;
|
|
13
14
|
botsPerShard?: number;
|
|
14
15
|
hideUsernames?: boolean;
|
|
15
16
|
hideEmails?: boolean;
|
|
16
|
-
|
|
17
|
+
logLevel?: "INFO" | "DEBUG";
|
|
17
18
|
}
|
|
18
19
|
declare class FNLB {
|
|
19
20
|
private isLoaded;
|
|
20
|
-
private config?;
|
|
21
|
+
private readonly config?;
|
|
21
22
|
constructor(config?: FNLBConfig);
|
|
22
23
|
private log;
|
|
24
|
+
private success;
|
|
23
25
|
private warn;
|
|
24
26
|
private error;
|
|
25
27
|
update(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fork as
|
|
1
|
+
import{fork as g}from"node:child_process";import{createHash as c}from"node:crypto";import{readFile as p,writeFile as u}from"node:fs/promises";import f from"node:path";class n{static wait(t){return new Promise((s)=>setTimeout(s,t))}}class a{isLoaded=!1;config;constructor(t){this.config=t}log(...t){if(!this.config?.disableLogs)console.log("[FNLB ShardingManager]",...t)}success(...t){if(!this.config?.disableLogs)console.log("[FNLB ShardingManager] [OK]",...t)}warn(...t){if(!this.config?.disableErrorLogs)console.warn("[FNLB ShardingManager] [WRN]",...t)}error(...t){if(!this.config?.disableErrorLogs)console.error("[FNLB ShardingManager] [ERR]",...t)}async update(){if(this.isLoaded)return;let t=f.join("zenith.js"),s=await p(t,"utf-8").catch(()=>null);this.log(s?"Checking for updates...":"Downloading FNLB...");let e=await fetch("https://dist.fnlb.net/packages/zenith/release");if(!e.ok)throw new Error(`[FNLB ShardingManager] Failed to check for updates, status code: ${e.status}`);let r=await e.json();if(s){let d=c("sha256");if(d.update(s),d.digest().toString("hex")===r.hash){this.success(`FNLB v${r.version} is up to date`),this.isLoaded=!0,this.success(`Finished loading FNLB v${r.version}`);return}this.log(`Downloading update for FNLB v${r.version}`)}let h=r.url,i=await fetch(h);if(!i.ok)throw new Error(`[FNLB ShardingManager] Failed to download update, status code: ${i.status}`);this.log(`Downloaded FNLB v${r.version}`);let l=await i.text();await u(t,l),this.isLoaded=!0,this.success(`Finished loading FNLB v${r.version}`)}async start(t){if(!t?.apiToken)throw new Error("[FNLB ShardingManager] Please provide a FNLB API token.");await this.update();let s=t.numberOfShards??1,o=[];for(let e=0;e<s;e++){let r=new Date;o.push(this.startShard(t,`${e.toString().padStart(2,"0")}/${r.getDay()}${r.getHours()}${r.getMinutes()}${r.getSeconds()}`))}return o}async startShard(t,s){if(await this.update(),!t?.apiToken)throw new Error("[FNLB ShardingManager] Please provide a FNLB API token.");this.log("Starting shard with id:",s);let o=g("zenith.js",[],{env:{...process.env,FORCE_COLOR:"1",SHARD_ID:s,API_TOKEN:t.apiToken,CATEGORIES:t.categories?.join(","),BOTS_PER_SHARD:(t.botsPerShard??1).toString(),HIDE_USERNAMES:t.hideUsernames?"true":"false",HIDE_EMAILS:t.hideEmails?"true":"false",LOG_LEVEL:t.logLevel,CLUSTER_ID:this.config?.clusterName?.trim().replace(/ +(?= )/g,"").toLowerCase().replaceAll(" ","-")??"unknown",CLUSTER_NAME:this.config?.clusterName?.trim()}});if(!this.config?.disableSubProcessLogs)o.stdout?.on("data",(e)=>{process.stdout.write(e.toString("utf8"))});if(!this.config?.disableSubProcessErrorLogs)o.stderr?.on("data",(e)=>{process.stderr.write(e.toString("utf8"))});return o.on("close",async(e)=>{if(e===0)this.warn("Child process exited with code:",e?.toString()??"none");else this.error("Child process exited with code:",e?.toString()??"none");this.log("Trying to restart process..."),await n.wait(1e4),this.startShard(t,s)}),o}}var R=a;export{R as default};
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fnlb",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"author": "FNLB-Project",
|
|
6
5
|
"main": "dist/index.js",
|
|
7
|
-
"
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@biomejs/biome": "^1.9.4",
|
|
8
|
+
"@types/bun": "^1.1.17",
|
|
9
|
+
"bun-plugin-dts": "^0.3.0",
|
|
10
|
+
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
11
|
+
"@typescript-eslint/parser": "^8.20.0",
|
|
12
|
+
"eslint": "^9.18.0"
|
|
13
|
+
},
|
|
14
|
+
"description": "Self-Host your own Fortnite LobbyBot with FNLB's system.",
|
|
15
|
+
"files": ["dist"],
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"packageManager": "bun@1.1.17",
|
|
8
19
|
"scripts": {
|
|
9
20
|
"build": "bun run src/build.ts",
|
|
10
|
-
"prepublishOnly": "bun run lint && bun run build",
|
|
21
|
+
"prepublishOnly": "bun run lint && bun run build --env=disable",
|
|
11
22
|
"test": "bun run test/index.ts",
|
|
23
|
+
"test:node": "bun run build && node test/node.js",
|
|
12
24
|
"lint": "bun run lint:biome && bun run lint:tsc",
|
|
13
25
|
"lint:biome": "bunx --bun @biomejs/biome check --write .",
|
|
14
26
|
"lint:tsc": "bun tsc --noEmit"
|
|
15
27
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"license": "ISC",
|
|
20
|
-
"dependencies": {},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@biomejs/biome": "^1.8.3",
|
|
23
|
-
"@types/bun": "^1.1.6",
|
|
24
|
-
"bun-plugin-dts": "^0.2.1",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
|
26
|
-
"@typescript-eslint/parser": "^7.14.1",
|
|
27
|
-
"eslint": "^9.6.0"
|
|
28
|
-
},
|
|
29
|
-
"packageManager": "bun@1.1.17",
|
|
30
|
-
"trustedDependencies": ["@biomejs/biome"]
|
|
28
|
+
"trustedDependencies": ["@biomejs/biome"],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"types": "dist/index.d.ts"
|
|
31
31
|
}
|