Add features: custom server and websocket. Minor refactoring
This commit is contained in:
Vendored
+2
-10
@@ -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,
|
||||
});
|
||||
|
||||
Vendored
+4
-10
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+1
-25
@@ -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 {};
|
||||
|
||||
Vendored
-16
@@ -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
|
||||
*/
|
||||
|
||||
Vendored
+3
-7
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user