pkg fixes

This commit is contained in:
CoolElectronics 2023-08-22 21:14:41 -04:00
parent 5ce4f60514
commit 30bf6cb8f1
No known key found for this signature in database
GPG key ID: F63593D168636C50
5 changed files with 22 additions and 6 deletions

View file

@ -12,8 +12,20 @@ build({
platform: "node", platform: "node",
// format: "esm", // format: "esm",
bundle: true, bundle: true,
minify: true,
outfile: "dist/main.js", outfile: "dist/main.js",
plugins: [ plugins: [
makeAllPackagesExternalPlugin makeAllPackagesExternalPlugin
], ],
}) })
build({
entryPoints: ["src/autoupdater.ts"],
platform: "node",
bundle: true,
minify: true,
outfile: "dist/autoupdater.js",
plugins: [
makeAllPackagesExternalPlugin
],
})

View file

@ -4,9 +4,9 @@
"description": "", "description": "",
"main": "src/main.ts", "main": "src/main.ts",
"scripts": { "scripts": {
"start": "tsx src/main.ts", "start": "tsx src/main.ts --start",
"dev": "nodemon -x tsx src/dev.ts", "dev": "nodemon -x tsx src/dev.ts",
"prod": "node esbuild.bundle.js && pkg src/main.js" "prod": "node esbuild.bundle.js && pkg dist/main.js --targets node18 -o dist/adrift-server && pkg dist/autoupdater.js --targets node18 -o dist/adrift-server-autoupdate"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

View file

@ -53,5 +53,4 @@ function start() {
} }
// downloadAndStart(); downloadAndStart();
start();

View file

@ -20,6 +20,8 @@ import { exit } from "process";
import { datadir } from "./lib"; import { datadir } from "./lib";
import { PROTOCOL_VERSION } from "protocol"; import { PROTOCOL_VERSION } from "protocol";
export const SERVER_MILESTONE = "1.0";
async function config() { async function config() {
let dir = datadir(); let dir = datadir();
@ -102,6 +104,7 @@ async function login(credentials: any) {
async function start() { async function start() {
let dir = datadir(); let dir = datadir();
let conf; let conf;
try { try {
conf = JSON.parse(fs.readFileSync(`${dir}/config.json`).toString()); conf = JSON.parse(fs.readFileSync(`${dir}/config.json`).toString());
@ -111,6 +114,8 @@ async function start() {
let tracker = TrackerList[conf.tracker as keyof typeof TrackerList]; let tracker = TrackerList[conf.tracker as keyof typeof TrackerList];
console.log(chalk.blue("Starting server!")); console.log(chalk.blue("Starting server!"));
console.log(chalk.blue(`Server version: ${SERVER_MILESTONE} - Protocol version: ${PROTOCOL_VERSION}`));
if (conf.type == "swarm") { if (conf.type == "swarm") {
let connect = () => { let connect = () => {
let trackerws = new WebSocket(`${tracker.tracker}/join?protocol=${PROTOCOL_VERSION}`); let trackerws = new WebSocket(`${tracker.tracker}/join?protocol=${PROTOCOL_VERSION}`);

View file

@ -26,5 +26,5 @@ let trackers = {
tracker: "wss://rafftracker.mercurywork.shop", tracker: "wss://rafftracker.mercurywork.shop",
description: "a second official backup tracker", description: "a second official backup tracker",
} }
}; } as const;
export default trackers; export default trackers;