feat(init): init with vite by default and move builder to flag (#3309)
This commit is contained in:
@@ -51,7 +51,7 @@ OPTIONS:
|
|||||||
--tailwind Use Tailwind for styling
|
--tailwind Use Tailwind for styling
|
||||||
--vscode Setup project for VS Code
|
--vscode Setup project for VS Code
|
||||||
--docker Setup Project to use Docker
|
--docker Setup Project to use Docker
|
||||||
--vite Setup as a vite project
|
--builder Setup with builder instead of vite
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const CONFIRM_EMPTY_MESSAGE =
|
export const CONFIRM_EMPTY_MESSAGE =
|
||||||
@@ -72,7 +72,7 @@ export async function initProject(
|
|||||||
force?: boolean | null;
|
force?: boolean | null;
|
||||||
tailwind?: boolean | null;
|
tailwind?: boolean | null;
|
||||||
vscode?: boolean | null;
|
vscode?: boolean | null;
|
||||||
vite?: boolean | null;
|
builder?: boolean | null;
|
||||||
} = {},
|
} = {},
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
console.log();
|
console.log();
|
||||||
@@ -115,14 +115,7 @@ export async function initProject(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let useVite = flags.vite || false;
|
const useVite = !flags.builder;
|
||||||
if (flags.vite == null) {
|
|
||||||
if (
|
|
||||||
confirm(CONFIRM_VITE_MESSAGE)
|
|
||||||
) {
|
|
||||||
useVite = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const useDocker = flags.docker;
|
const useDocker = flags.docker;
|
||||||
let useTailwind = flags.tailwind || false;
|
let useTailwind = flags.tailwind || false;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ Deno.test("init - new project", async () => {
|
|||||||
using _promptStub = stubPrompt("fresh-init");
|
using _promptStub = stubPrompt("fresh-init");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
|
|
||||||
await initProject(tmp.dir, [], {});
|
await initProject(tmp.dir, [], { builder: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("init - create project dir", async () => {
|
Deno.test("init - create project dir", async () => {
|
||||||
@@ -88,7 +88,7 @@ Deno.test("init - create project dir", async () => {
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt("fresh-init");
|
using _promptStub = stubPrompt("fresh-init");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
|
|
||||||
const root = path.join(dir, "fresh-init");
|
const root = path.join(dir, "fresh-init");
|
||||||
await expectProjectFile(root, "deno.json");
|
await expectProjectFile(root, "deno.json");
|
||||||
@@ -105,7 +105,7 @@ Deno.test("init - with tailwind", async () => {
|
|||||||
using _confirmStub = stubConfirm({
|
using _confirmStub = stubConfirm({
|
||||||
[CONFIRM_TAILWIND_MESSAGE]: true,
|
[CONFIRM_TAILWIND_MESSAGE]: true,
|
||||||
});
|
});
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
|
|
||||||
const css = await readProjectFile(dir, "static/styles.css");
|
const css = await readProjectFile(dir, "static/styles.css");
|
||||||
expect(css).toMatch(/@import "tailwindcss"/);
|
expect(css).toMatch(/@import "tailwindcss"/);
|
||||||
@@ -123,7 +123,7 @@ Deno.test("init - with vscode", async () => {
|
|||||||
using _confirmStub = stubConfirm({
|
using _confirmStub = stubConfirm({
|
||||||
[CONFIRM_VSCODE_MESSAGE]: true,
|
[CONFIRM_VSCODE_MESSAGE]: true,
|
||||||
});
|
});
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
|
|
||||||
await expectProjectFile(dir, ".vscode/settings.json");
|
await expectProjectFile(dir, ".vscode/settings.json");
|
||||||
await expectProjectFile(dir, ".vscode/extensions.json");
|
await expectProjectFile(dir, ".vscode/extensions.json");
|
||||||
@@ -139,7 +139,7 @@ Deno.test({
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt(".");
|
using _promptStub = stubPrompt(".");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
await expectProjectFile(dir, "main.ts");
|
await expectProjectFile(dir, "main.ts");
|
||||||
await expectProjectFile(dir, "dev.ts");
|
await expectProjectFile(dir, "dev.ts");
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ Deno.test(
|
|||||||
[CONFIRM_TAILWIND_MESSAGE]: true,
|
[CONFIRM_TAILWIND_MESSAGE]: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
await expectProjectFile(dir, "main.ts");
|
await expectProjectFile(dir, "main.ts");
|
||||||
await expectProjectFile(dir, "dev.ts");
|
await expectProjectFile(dir, "dev.ts");
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ Deno.test({
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt(".");
|
using _promptStub = stubPrompt(".");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
await expectProjectFile(dir, "main.ts");
|
await expectProjectFile(dir, "main.ts");
|
||||||
await expectProjectFile(dir, "dev.ts");
|
await expectProjectFile(dir, "dev.ts");
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ Deno.test("init - can start built project", async () => {
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt(".");
|
using _promptStub = stubPrompt(".");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
await expectProjectFile(dir, "main.ts");
|
await expectProjectFile(dir, "main.ts");
|
||||||
await expectProjectFile(dir, "dev.ts");
|
await expectProjectFile(dir, "dev.ts");
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ Deno.test("init - errors on missing build cache in prod", async () => {
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt(".");
|
using _promptStub = stubPrompt(".");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], {});
|
await initProject(dir, [], { builder: true });
|
||||||
await expectProjectFile(dir, "main.ts");
|
await expectProjectFile(dir, "main.ts");
|
||||||
await expectProjectFile(dir, "dev.ts");
|
await expectProjectFile(dir, "dev.ts");
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ Deno.test.ignore("init - vite dev server", async () => {
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt(".");
|
using _promptStub = stubPrompt(".");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], { vite: true });
|
await initProject(dir, [], {});
|
||||||
|
|
||||||
await expectProjectFile(dir, "vite.config.ts");
|
await expectProjectFile(dir, "vite.config.ts");
|
||||||
await expectNotProjectFile(dir, "dev.ts");
|
await expectNotProjectFile(dir, "dev.ts");
|
||||||
@@ -297,7 +297,7 @@ Deno.test.ignore("init - vite build", async () => {
|
|||||||
const dir = tmp.dir;
|
const dir = tmp.dir;
|
||||||
using _promptStub = stubPrompt(".");
|
using _promptStub = stubPrompt(".");
|
||||||
using _confirmStub = stubConfirm();
|
using _confirmStub = stubConfirm();
|
||||||
await initProject(dir, [], { vite: true });
|
await initProject(dir, [], {});
|
||||||
|
|
||||||
await expectProjectFile(dir, "vite.config.ts");
|
await expectProjectFile(dir, "vite.config.ts");
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import { initProject } from "./init.ts";
|
|||||||
import { InitError } from "./init.ts";
|
import { InitError } from "./init.ts";
|
||||||
|
|
||||||
const flags = parseArgs(Deno.args, {
|
const flags = parseArgs(Deno.args, {
|
||||||
boolean: ["force", "tailwind", "vscode", "docker", "help", "vite"],
|
boolean: ["force", "tailwind", "vscode", "docker", "help", "builder"],
|
||||||
default: {
|
default: {
|
||||||
force: null,
|
force: null,
|
||||||
tailwind: null,
|
tailwind: null,
|
||||||
vscode: null,
|
vscode: null,
|
||||||
docker: null,
|
docker: null,
|
||||||
vite: null,
|
builder: null,
|
||||||
},
|
},
|
||||||
alias: {
|
alias: {
|
||||||
help: "h",
|
help: "h",
|
||||||
|
|||||||
Reference in New Issue
Block a user