Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/infra/build-binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const WINDOWS_ICON = join(ROOT, "infra", "base44.ico");
for (const required of [
"dist/cli/index.js",
"dist/assets/templates/templates.json",
"dist/assets/deno-runtime/main.js",
"dist/assets/deno-runtime/main.ts",
]) {
if (!existsSync(join(ROOT, required))) {
console.error(
Expand Down
41 changes: 24 additions & 17 deletions packages/cli/infra/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { watch } from "node:fs";
import { watch, copyFileSync, mkdirSync } from "node:fs";
import type { BuildConfig } from "bun";
import chalk from "chalk";

Expand All @@ -25,18 +25,22 @@ const runBuild = async (config: BuildConfig) => {
return result;
};

const copyDenoRuntime = () => {
const outDir = "./dist/assets/deno-runtime";
mkdirSync(outDir, { recursive: true });
copyFileSync("./deno-runtime/main.ts", `${outDir}/main.ts`);
return `${outDir}/main.ts`;
};

const runAllBuilds = async () => {
const cli = await runBuild({
entrypoints: ["./src/cli/index.ts"],
outdir: "./dist/cli",
});
const denoRuntime = await runBuild({
entrypoints: ["./deno-runtime/main.ts"],
outdir: "./dist/assets/deno-runtime",
});
const denoRuntimePath = copyDenoRuntime();
return {
cli,
denoRuntime,
denoRuntimePath,
};
};

Expand All @@ -54,16 +58,19 @@ if (process.argv.includes("--watch")) {
const time = new Date().toLocaleTimeString();
console.log(chalk.dim(`[${time}]`), chalk.gray(`${filename} ${event}d`));

const { cli, denoRuntime } = await runAllBuilds();
for (const result of [cli, denoRuntime]) {
if (result.success && result.outputs.length > 0) {
console.log(
chalk.green(` ✓ Rebuilt`),
chalk.dim(`→`),
formatOutput(result.outputs),
);
}
const { cli, denoRuntimePath } = await runAllBuilds();
if (cli.success && cli.outputs.length > 0) {
console.log(
chalk.green(` ✓ Rebuilt`),
chalk.dim(`→`),
formatOutput(cli.outputs),
);
}
console.log(
chalk.green(` ✓ Copied`),
chalk.dim(`→`),
chalk.cyan(denoRuntimePath),
);
};

await runAllBuilds();
Expand All @@ -75,9 +82,9 @@ if (process.argv.includes("--watch")) {
// Keep process alive
await new Promise(() => {});
} else {
const { cli, denoRuntime } = await runAllBuilds();
const { cli, denoRuntimePath } = await runAllBuilds();
console.log(chalk.green.bold(`\n✓ Build complete\n`));
console.log(chalk.dim(" Output:"));
console.log(` ${formatOutput(cli.outputs)}`);
console.log(` ${formatOutput(denoRuntime.outputs)}`);
console.log(` ${chalk.cyan(denoRuntimePath)}`);
}
2 changes: 1 addition & 1 deletion packages/cli/src/core/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getTemplatesIndexPath(): string {
}

export function getDenoWrapperPath(): string {
return join(ASSETS_DIR, "deno-runtime", "main.js");
return join(ASSETS_DIR, "deno-runtime", "main.ts");
}

/**
Expand Down