mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
cli now uses adapter logic, require node v22
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/bknd-io/bknd/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "BKND_CLI_LOG_LEVEL=debug vite",
|
||||
"build": "NODE_ENV=production bun run build.ts --minify --types",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import path from "node:path";
|
||||
import type { Config } from "@libsql/client/node";
|
||||
import { $console, config } from "core";
|
||||
import { $console } from "core";
|
||||
import type { MiddlewareHandler } from "hono";
|
||||
import open from "open";
|
||||
import { fileExists, getRelativeDistPath } from "../../utils/sys";
|
||||
@@ -27,10 +26,6 @@ export async function serveStatic(server: Platform): Promise<MiddlewareHandler>
|
||||
}
|
||||
}
|
||||
|
||||
export async function attachServeStatic(app: any, platform: Platform) {
|
||||
app.module.server.client.get(config.server.assets_path + "*", await serveStatic(platform));
|
||||
}
|
||||
|
||||
export async function startServer(
|
||||
server: Platform,
|
||||
app: App,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Config } from "@libsql/client/node";
|
||||
import { App, type CreateAppConfig } from "App";
|
||||
import { StorageLocalAdapter } from "adapter/node";
|
||||
import type { App, CreateAppConfig } from "App";
|
||||
import { StorageLocalAdapter } from "adapter/node/storage";
|
||||
import type { CliBkndConfig, CliCommand } from "cli/types";
|
||||
import { Option } from "commander";
|
||||
import { colorizeConsole, config } from "core";
|
||||
@@ -11,19 +11,19 @@ import path from "node:path";
|
||||
import {
|
||||
PLATFORMS,
|
||||
type Platform,
|
||||
attachServeStatic,
|
||||
getConfigPath,
|
||||
getConnectionCredentialsFromEnv,
|
||||
serveStatic,
|
||||
startServer,
|
||||
} from "./platform";
|
||||
import { makeConfig } from "adapter";
|
||||
import { isBun as $isBun } from "cli/utils/sys";
|
||||
import { createRuntimeApp, makeConfig } from "adapter";
|
||||
import { isBun } from "core/utils";
|
||||
|
||||
const env_files = [".env", ".dev.vars"];
|
||||
dotenv.config({
|
||||
path: env_files.map((file) => path.resolve(process.cwd(), file)),
|
||||
});
|
||||
const isBun = $isBun();
|
||||
const is_bun = isBun();
|
||||
|
||||
export const run: CliCommand = (program) => {
|
||||
program
|
||||
@@ -52,7 +52,7 @@ export const run: CliCommand = (program) => {
|
||||
.addOption(
|
||||
new Option("--server <server>", "server type")
|
||||
.choices(PLATFORMS)
|
||||
.default(isBun ? "bun" : "node"),
|
||||
.default(is_bun ? "bun" : "node"),
|
||||
)
|
||||
.addOption(new Option("--no-open", "don't open browser window on start"))
|
||||
.action(action);
|
||||
@@ -72,23 +72,9 @@ type MakeAppConfig = {
|
||||
};
|
||||
|
||||
async function makeApp(config: MakeAppConfig) {
|
||||
const app = App.create({ connection: config.connection });
|
||||
|
||||
app.emgr.onEvent(
|
||||
App.Events.AppBuiltEvent,
|
||||
async () => {
|
||||
if (config.onBuilt) {
|
||||
await config.onBuilt(app);
|
||||
}
|
||||
|
||||
await attachServeStatic(app, config.server?.platform ?? "node");
|
||||
app.registerAdminController();
|
||||
},
|
||||
"sync",
|
||||
);
|
||||
|
||||
await app.build();
|
||||
return app;
|
||||
return await createRuntimeApp({
|
||||
serveStatic: await serveStatic(config.server?.platform ?? "node"),
|
||||
});
|
||||
}
|
||||
|
||||
export async function makeConfigApp(_config: CliBkndConfig, platform?: Platform) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { CliCommand } from "cli/types";
|
||||
import { Argument } from "commander";
|
||||
import { $console } from "core";
|
||||
import c from "picocolors";
|
||||
import { isBun } from "cli/utils/sys";
|
||||
import { isBun } from "core/utils";
|
||||
|
||||
export const user: CliCommand = (program) => {
|
||||
program
|
||||
|
||||
@@ -4,14 +4,6 @@ import { readFile, writeFile as nodeWriteFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
|
||||
export function isBun(): boolean {
|
||||
try {
|
||||
return typeof Bun !== "undefined";
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getRootPath() {
|
||||
const _path = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
// because of "src", local needs one more level up
|
||||
|
||||
@@ -333,7 +333,7 @@ export class SchemaManager {
|
||||
|
||||
if (config.force) {
|
||||
try {
|
||||
$console.log("[SchemaManager]", sql);
|
||||
$console.debug("[SchemaManager]", sql);
|
||||
await qb.execute();
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to execute query: ${sql}: ${(e as any).message}`);
|
||||
|
||||
22
package.json
22
package.json
@@ -4,14 +4,7 @@
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "ALL_TESTS=1 bun test --bail",
|
||||
"test:coverage": "bun test --coverage",
|
||||
"types": "bun run --filter './packages/**' types",
|
||||
"build": "bun run clean:dist && bun run --cwd app build:all && bun build:packages",
|
||||
"build:packages": "bun run --filter './packages/{cli,plasmic}' build",
|
||||
"git:pre-commit": "bun run test",
|
||||
"updater": "bun x npm-check-updates -ui",
|
||||
"clean:dist": "find packages -name 'dist' -type d -exec rm -rf {} +",
|
||||
"ci": "find . -name 'node_modules' -type d -exec rm -rf {} + && bun install",
|
||||
"npm:local": "verdaccio --config verdaccio.yml",
|
||||
"format": "bunx biome format --write ./app",
|
||||
@@ -20,26 +13,15 @@
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@clack/prompts": "^0.10.0",
|
||||
"@tsconfig/strictest": "^2.0.5",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"bun-types": "^1.1.18",
|
||||
"dotenv": "^16.4.5",
|
||||
"esbuild": "^0.23.0",
|
||||
"esbuild-plugin-tsc": "^0.4.0",
|
||||
"miniflare": "^3.20240806.0",
|
||||
"mitata": "^0.1.11",
|
||||
"picocolors": "^1.0.1",
|
||||
"semver": "^7.6.2",
|
||||
"sql-formatter": "^15.3.2",
|
||||
"tsd": "^0.31.1",
|
||||
"tsup": "^8.1.0",
|
||||
"typescript": "^5.5.3",
|
||||
"verdaccio": "^5.32.1",
|
||||
"wrangler": "^3.108.1"
|
||||
"verdaccio": "^5.32.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
"node": ">=22"
|
||||
},
|
||||
"workspaces": ["app", "packages/*"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user