fix(init): document Vite and ask in init (#3281) (#3286)

Expands #3277

---------

Co-authored-by: fry69 <142489379+fry69@users.noreply.github.com>
This commit is contained in:
Marvin Hagemeister
2025-09-01 07:58:37 +02:00
committed by GitHub
co-authored by fry69
parent e33b447768
commit 33cb164b7d
4 changed files with 100 additions and 8 deletions
+11 -1
View File
@@ -58,6 +58,9 @@ export const CONFIRM_TAILWIND_MESSAGE = `Set up ${
colors.cyan("Tailwind CSS")
} for styling?`;
export const CONFIRM_VSCODE_MESSAGE = `Do you use ${colors.cyan("VS Code")}?`;
export const CONFIRM_VITE_MESSAGE = `Set up ${
colors.cyan("Vite")
} for build tooling?`;
export async function initProject(
cwd = Deno.cwd(),
@@ -110,7 +113,14 @@ export async function initProject(
}
}
const useVite = flags.vite ?? false;
let useVite = flags.vite || false;
if (flags.vite == null) {
if (
confirm(CONFIRM_VITE_MESSAGE)
) {
useVite = true;
}
}
const useDocker = flags.docker;
let useTailwind = flags.tailwind || false;
+14
View File
@@ -1,6 +1,7 @@
import { expect } from "@std/expect";
import {
CONFIRM_TAILWIND_MESSAGE,
CONFIRM_VITE_MESSAGE,
CONFIRM_VSCODE_MESSAGE,
initProject,
} from "./init.ts";
@@ -322,3 +323,16 @@ Deno.test.ignore("init - vite build", async () => {
},
);
});
Deno.test("init - with vite", async () => {
await using tmp = await withTmpDir();
const dir = tmp.dir;
using _promptStub = stubPrompt(".");
using _confirmStub = stubConfirm({
[CONFIRM_VITE_MESSAGE]: true,
});
await initProject(dir, [], {});
await expectProjectFile(dir, "vite.config.ts");
await expectNotProjectFile(dir, "dev.ts");
});