mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add ai and todo example templates for native frontends (#293)
This commit is contained in:
@@ -145,9 +145,17 @@ function getNativeInstructions(isConvex: boolean): string {
|
||||
? "your Convex deployment URL (find after running 'dev:setup')"
|
||||
: "your local IP address";
|
||||
|
||||
return `${pc.yellow(
|
||||
let instructions = `${pc.yellow(
|
||||
"NOTE:",
|
||||
)} For Expo connectivity issues, update apps/native/${envFileName} \nwith ${ipNote}:\n${`${envVar}=${exampleUrl}`}\n`;
|
||||
|
||||
if (isConvex) {
|
||||
instructions += `\n${pc.yellow(
|
||||
"IMPORTANT:",
|
||||
)} When using local development with Convex and native apps, ensure you use your local IP address \ninstead of localhost or 127.0.0.1 for proper connectivity.\n`;
|
||||
}
|
||||
|
||||
return instructions;
|
||||
}
|
||||
|
||||
function getLintingInstructions(runCmd?: string): string {
|
||||
|
||||
@@ -599,6 +599,8 @@ export async function setupExamplesTemplate(
|
||||
|
||||
const serverAppDirExists = await fs.pathExists(serverAppDir);
|
||||
const webAppDirExists = await fs.pathExists(webAppDir);
|
||||
const nativeAppDir = path.join(projectDir, "apps/native");
|
||||
const nativeAppDirExists = await fs.pathExists(nativeAppDir);
|
||||
|
||||
const hasReactWeb = context.frontend.some((f) =>
|
||||
["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
|
||||
@@ -758,6 +760,34 @@ export async function setupExamplesTemplate(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nativeAppDirExists) {
|
||||
const hasNativeWind = context.frontend.includes("native-nativewind");
|
||||
const hasUnistyles = context.frontend.includes("native-unistyles");
|
||||
|
||||
if (hasNativeWind || hasUnistyles) {
|
||||
let nativeFramework = "";
|
||||
if (hasNativeWind) {
|
||||
nativeFramework = "nativewind";
|
||||
} else if (hasUnistyles) {
|
||||
nativeFramework = "unistyles";
|
||||
}
|
||||
|
||||
const exampleNativeSrc = path.join(
|
||||
exampleBaseDir,
|
||||
`native/${nativeFramework}`,
|
||||
);
|
||||
if (await fs.pathExists(exampleNativeSrc)) {
|
||||
await processAndCopyFiles(
|
||||
"**/*",
|
||||
exampleNativeSrc,
|
||||
nativeAppDir,
|
||||
context,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ export async function setupExamples(config: ProjectConfig): Promise<void> {
|
||||
frontend.includes("react-router") ||
|
||||
frontend.includes("tanstack-router") ||
|
||||
frontend.includes("next") ||
|
||||
frontend.includes("tanstack-start");
|
||||
frontend.includes("tanstack-start") ||
|
||||
frontend.includes("native-nativewind") ||
|
||||
frontend.includes("native-unistyles");
|
||||
|
||||
if (clientDirExists) {
|
||||
const dependencies: AvailableDependencies[] = ["ai"];
|
||||
|
||||
@@ -25,30 +25,9 @@ export async function getExamplesChoice(
|
||||
|
||||
if (database === "none") return [];
|
||||
|
||||
const onlyNative =
|
||||
frontends &&
|
||||
frontends.length === 1 &&
|
||||
(frontends[0] === "native-nativewind" ||
|
||||
frontends[0] === "native-unistyles");
|
||||
if (onlyNative) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const hasWebFrontend =
|
||||
frontends?.some((f) =>
|
||||
[
|
||||
"react-router",
|
||||
"tanstack-router",
|
||||
"tanstack-start",
|
||||
"next",
|
||||
"nuxt",
|
||||
"svelte",
|
||||
"solid",
|
||||
].includes(f),
|
||||
) ?? false;
|
||||
const noFrontendSelected = !frontends || frontends.length === 0;
|
||||
|
||||
if (!hasWebFrontend && !noFrontendSelected) return [];
|
||||
if (noFrontendSelected) return [];
|
||||
|
||||
let response: Examples[] | symbol = [];
|
||||
const options: { value: Examples; label: string; hint: string }[] = [
|
||||
|
||||
@@ -467,24 +467,6 @@ export function validateConfigCompatibility(
|
||||
config.addons = [...new Set(config.addons)];
|
||||
}
|
||||
|
||||
const onlyNativeFrontend =
|
||||
effectiveFrontend &&
|
||||
effectiveFrontend.length === 1 &&
|
||||
(effectiveFrontend[0] === "native-nativewind" ||
|
||||
effectiveFrontend[0] === "native-unistyles");
|
||||
|
||||
if (
|
||||
onlyNativeFrontend &&
|
||||
config.examples &&
|
||||
config.examples.length > 0 &&
|
||||
!config.examples.includes("none")
|
||||
) {
|
||||
consola.fatal(
|
||||
"Examples are not supported when only a native frontend (NativeWind or Unistyles) is selected.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (
|
||||
config.examples &&
|
||||
config.examples.length > 0 &&
|
||||
|
||||
Reference in New Issue
Block a user