From 70e9c556c35306ea5f6fe465531a58faf7e23f66 Mon Sep 17 00:00:00 2001 From: Reed von Redwitz Date: Sat, 1 Jul 2023 12:59:10 +0200 Subject: [PATCH] feat(starter): always initialize _app.tsx (#1380) --- init.ts | 24 +++++++++++++++++------- tests/cli_test.ts | 2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/init.ts b/init.ts index 3220d7ed..3c139b5d 100644 --- a/init.ts +++ b/init.ts @@ -401,8 +401,18 @@ html { } `; -const NO_TWIND_APP_WRAPPER = ` -import { AppProps } from "$fresh/server.ts"; +const APP_WRAPPER = useTwind + ? `import { AppProps } from "$fresh/server.ts"; + +export default function App({ Component }: AppProps) { + return ( + <> + + + ); +} +` + : `import { AppProps } from "$fresh/server.ts"; import { Head } from "$fresh/runtime.ts"; export default function App({ Component }: AppProps) { @@ -422,13 +432,13 @@ if (!useTwind) { join(resolvedDirectory, "static", "styles.css"), NO_TWIND_STYLES, ); - - await Deno.writeTextFile( - join(resolvedDirectory, "routes", "_app.tsx"), - NO_TWIND_APP_WRAPPER, - ); } +await Deno.writeTextFile( + join(resolvedDirectory, "routes", "_app.tsx"), + APP_WRAPPER, +); + const STATIC_LOGO = ` diff --git a/tests/cli_test.ts b/tests/cli_test.ts index 6ec5b4b2..96b24617 100644 --- a/tests/cli_test.ts +++ b/tests/cli_test.ts @@ -53,6 +53,7 @@ Deno.test({ `/main.ts`, `/routes/greet/[name].tsx`, `/routes/api/joke.ts`, + `/routes/_app.tsx`, `/routes/index.tsx`, `/static/logo.svg`, ]; @@ -138,6 +139,7 @@ Deno.test({ "/main.ts", "/routes/greet/[name].tsx", "/routes/api/joke.ts", + "/routes/_app.tsx", "/routes/index.tsx", "/static/logo.svg", "/.vscode/settings.json",