Add features: custom server and websocket. Minor refactoring

This commit is contained in:
2026-03-21 07:42:38 +01:00
parent 1611c845b9
commit 98d3cf7da7
29 changed files with 321 additions and 286 deletions
+2 -10
View File
@@ -1,21 +1,13 @@
import { Command } from "commander";
import grabConfig from "../../functions/grab-config";
import init from "../../functions/init";
import allPagesBundler from "../../functions/bundler/all-pages-bundler";
import { log } from "../../utils/log";
export default function () {
return new Command("build")
.description("Build Project")
.action(async () => {
log.banner();
log.build("Building Project ...");
process.env.NODE_ENV = "production";
await init();
const config = (await grabConfig()) || {};
global.CONFIG = {
...config,
development: true,
};
process.env.BUILD = "true";
log.build("Building Project ...");
allPagesBundler({
exit_after_first_build: true,
});
+4 -10
View File
@@ -1,20 +1,14 @@
import { Command } from "commander";
import grabConfig from "../../functions/grab-config";
import startServer from "../../functions/server/start-server";
import init from "../../functions/init";
import { log } from "../../utils/log";
import bunextInit from "../../functions/bunext-init";
export default function () {
return new Command("dev")
.description("Run development server")
.action(async () => {
log.banner();
process.env.NODE_ENV == "development";
log.info("Running development server ...");
await init();
const config = (await grabConfig()) || {};
global.CONFIG = {
...config,
development: true,
};
await startServer({ dev: true });
await bunextInit();
await startServer();
});
}
+1 -25
View File
@@ -1,26 +1,2 @@
#!/usr/bin/env bun
import { type Ora } from "ora";
import type { BundlerCTXMap, BunextConfig, GlobalHMRControllerObject, PageFiles } from "../types";
import type { FileSystemRouter, Server } from "bun";
import type { BuildContext } from "esbuild";
import type { FSWatcher } from "fs";
/**
* # Declare Global Variables
*/
declare global {
var ORA_SPINNER: Ora;
var CONFIG: BunextConfig;
var SERVER: Server | undefined;
var RECOMPILING: boolean;
var WATCHER_TIMEOUT: any;
var ROUTER: FileSystemRouter;
var HMR_CONTROLLERS: GlobalHMRControllerObject[];
var LAST_BUILD_TIME: number;
var BUNDLER_CTX: BuildContext | undefined;
var BUNDLER_CTX_MAP: BundlerCTXMap[] | undefined;
var IS_FIRST_BUNDLE_READY: boolean;
var BUNDLER_REBUILDS: 0;
var PAGES_SRC_WATCHER: FSWatcher | undefined;
var CURRENT_VERSION: string | undefined;
var PAGE_FILES: PageFiles[];
}
export {};
-16
View File
@@ -2,23 +2,7 @@
import { program } from "commander";
import start from "./start";
import dev from "./dev";
import ora, {} from "ora";
import init from "../functions/init";
import grabDirNames from "../utils/grab-dir-names";
import build from "./build";
global.ORA_SPINNER = ora();
global.ORA_SPINNER.clear();
global.HMR_CONTROLLERS = [];
global.IS_FIRST_BUNDLE_READY = false;
global.BUNDLER_REBUILDS = 0;
global.PAGE_FILES = [];
await init();
const { PAGES_DIR } = grabDirNames();
const router = new Bun.FileSystemRouter({
style: "nextjs",
dir: PAGES_DIR,
});
global.ROUTER = router;
/**
* # Describe Program
*/
+3 -7
View File
@@ -1,18 +1,14 @@
import { Command } from "commander";
import grabConfig from "../../functions/grab-config";
import startServer from "../../functions/server/start-server";
import init from "../../functions/init";
import { log } from "../../utils/log";
import bunextInit from "../../functions/bunext-init";
export default function () {
return new Command("start")
.description("Start production server")
.action(async () => {
log.banner();
log.info("Starting production server ...");
process.env.NODE_ENV = "production";
await init();
const config = await grabConfig();
global.CONFIG = { ...config };
log.info("Starting production server ...");
await bunextInit();
await startServer();
});
}