mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-19 13:56:04 +00:00
fix: cli: user command now uses the same app env setup as run
This commit is contained in:
@@ -17,12 +17,13 @@ import {
|
||||
startServer,
|
||||
} from "./platform";
|
||||
import { makeConfig } from "adapter";
|
||||
import { isBun as $isBun } from "cli/utils/sys";
|
||||
|
||||
const env_files = [".env", ".dev.vars"];
|
||||
dotenv.config({
|
||||
path: env_files.map((file) => path.resolve(process.cwd(), file)),
|
||||
});
|
||||
const isBun = typeof Bun !== "undefined";
|
||||
const isBun = $isBun();
|
||||
|
||||
export const run: CliCommand = (program) => {
|
||||
program
|
||||
@@ -98,7 +99,7 @@ export async function makeConfigApp(_config: CliBkndConfig, platform?: Platform)
|
||||
});
|
||||
}
|
||||
|
||||
async function action(options: {
|
||||
type RunOptions = {
|
||||
port: number;
|
||||
memory?: boolean;
|
||||
config?: string;
|
||||
@@ -106,8 +107,9 @@ async function action(options: {
|
||||
dbToken?: string;
|
||||
server: Platform;
|
||||
open?: boolean;
|
||||
}) {
|
||||
colorizeConsole(console);
|
||||
};
|
||||
|
||||
export async function makeAppFromEnv(options: Partial<RunOptions> = {}) {
|
||||
const configFilePath = await getConfigPath(options.config);
|
||||
|
||||
let app: App | undefined = undefined;
|
||||
@@ -147,12 +149,19 @@ async function action(options: {
|
||||
// if nothing helps, create a file based app
|
||||
if (!app) {
|
||||
const connection = { url: "file:data.db" } as Config;
|
||||
console.info("Using connection", c.cyan(connection.url));
|
||||
console.info("Using fallback connection", c.cyan(connection.url));
|
||||
app = await makeApp({
|
||||
connection,
|
||||
server: { platform: options.server },
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
async function action(options: RunOptions) {
|
||||
colorizeConsole(console);
|
||||
|
||||
const app = await makeAppFromEnv(options);
|
||||
await startServer(options.server, app, { port: options.port, open: options.open });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user