diff --git a/app/package.json b/app/package.json index 2ab50e9..1952b4d 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "type": "module", "sideEffects": false, "bin": "./dist/cli/index.js", - "version": "0.8.0-rc.1", + "version": "0.8.0-rc.3", "description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, Remix, Astro, Cloudflare, Bun, Node, AWS Lambda & more.", "homepage": "https://bknd.io", "repository": { diff --git a/app/src/cli/commands/create/create.ts b/app/src/cli/commands/create/create.ts index 8c73e6a..81a5c9a 100644 --- a/app/src/cli/commands/create/create.ts +++ b/app/src/cli/commands/create/create.ts @@ -3,7 +3,7 @@ import { downloadTemplate } from "@bluwy/giget-core"; import * as $p from "@clack/prompts"; import type { CliCommand } from "cli/types"; import { typewriter, wait } from "cli/utils/cli"; -import { exec, getVersion } from "cli/utils/sys"; +import { execAsync, getVersion } from "cli/utils/sys"; import { Option } from "commander"; import color from "picocolors"; import { overridePackageJson, updateBkndPackages } from "./npm"; @@ -190,7 +190,7 @@ async function action(options: { template?: string; dir?: string; integration?: //console.log("url", url); const s = $p.spinner(); - s.start("Downloading template..."); + await s.start("Downloading template..."); try { await downloadTemplate(url, { dir: ctx.dir, @@ -236,9 +236,9 @@ async function action(options: { template?: string; dir?: string; integration?: const install_cmd = template.scripts?.install || "npm install"; const s = $p.spinner(); - s.start("Installing dependencies..."); + await s.start("Installing dependencies..."); try { - exec(`cd ${ctx.dir} && ${install_cmd}`, { silent: true }); + await execAsync(`cd ${ctx.dir} && ${install_cmd}`, { silent: true }); } catch (e) { if (e instanceof Error) { s.stop("Failed to install: " + color.red(e.message), 1); diff --git a/app/src/cli/utils/sys.ts b/app/src/cli/utils/sys.ts index 4bedace..4ea3531 100644 --- a/app/src/cli/utils/sys.ts +++ b/app/src/cli/utils/sys.ts @@ -1,4 +1,4 @@ -import { execSync } from "node:child_process"; +import { execSync, exec as nodeExec } from "node:child_process"; import { readFile } from "node:fs/promises"; import path from "node:path"; import url from "node:url"; @@ -51,3 +51,23 @@ export function exec(command: string, opts?: { silent?: boolean; env?: Record } +) { + return new Promise((resolve, reject) => { + nodeExec( + command, + { + env: { ...process.env, ...opts?.env } + }, + (err, stdout, stderr) => { + if (err) { + return reject(err); + } + resolve(stdout); + } + ); + }); +}