mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add svelte
This commit is contained in:
@@ -3,65 +3,75 @@ import pc from "picocolors";
|
||||
import { DEFAULT_CONFIG } from "../constants";
|
||||
import type { ProjectAddons, ProjectFrontend } from "../types";
|
||||
|
||||
type AddonOption = {
|
||||
value: ProjectAddons;
|
||||
label: string;
|
||||
hint: string;
|
||||
};
|
||||
|
||||
export async function getAddonsChoice(
|
||||
addons?: ProjectAddons[],
|
||||
frontends?: ProjectFrontend[],
|
||||
): Promise<ProjectAddons[]> {
|
||||
if (addons !== undefined) return addons;
|
||||
|
||||
const hasCompatibleWebFrontend =
|
||||
const hasCompatiblePwaFrontend =
|
||||
frontends?.includes("react-router") ||
|
||||
frontends?.includes("tanstack-router");
|
||||
|
||||
const addonOptions = [
|
||||
const hasCompatibleTauriFrontend =
|
||||
frontends?.includes("react-router") ||
|
||||
frontends?.includes("tanstack-router") ||
|
||||
frontends?.includes("nuxt") ||
|
||||
frontends?.includes("svelte");
|
||||
|
||||
const allPossibleOptions: AddonOption[] = [
|
||||
{
|
||||
value: "turborepo" as const,
|
||||
value: "turborepo",
|
||||
label: "Turborepo (Recommended)",
|
||||
hint: "Optimize builds for monorepos",
|
||||
},
|
||||
{
|
||||
value: "starlight" as const,
|
||||
value: "starlight",
|
||||
label: "Starlight",
|
||||
hint: "Add Astro Starlight documentation site",
|
||||
},
|
||||
{
|
||||
value: "biome" as const,
|
||||
value: "biome",
|
||||
label: "Biome",
|
||||
hint: "Add Biome for linting and formatting",
|
||||
},
|
||||
{
|
||||
value: "husky" as const,
|
||||
value: "husky",
|
||||
label: "Husky",
|
||||
hint: "Add Git hooks with Husky, lint-staged (requires Biome)",
|
||||
},
|
||||
];
|
||||
|
||||
const webAddonOptions = [
|
||||
{
|
||||
value: "pwa" as const,
|
||||
value: "pwa",
|
||||
label: "PWA (Progressive Web App)",
|
||||
hint: "Make your app installable and work offline",
|
||||
},
|
||||
{
|
||||
value: "tauri" as const,
|
||||
value: "tauri",
|
||||
label: "Tauri Desktop App",
|
||||
hint: "Build native desktop apps from your web frontend",
|
||||
},
|
||||
];
|
||||
|
||||
const options = hasCompatibleWebFrontend
|
||||
? [...addonOptions, ...webAddonOptions]
|
||||
: addonOptions;
|
||||
const options = allPossibleOptions.filter((option) => {
|
||||
if (option.value === "pwa") return hasCompatiblePwaFrontend;
|
||||
if (option.value === "tauri") return hasCompatibleTauriFrontend;
|
||||
return true;
|
||||
});
|
||||
|
||||
const initialValues = DEFAULT_CONFIG.addons.filter(
|
||||
(addon) =>
|
||||
hasCompatibleWebFrontend || (addon !== "pwa" && addon !== "tauri"),
|
||||
const initialValues = DEFAULT_CONFIG.addons.filter((addonValue) =>
|
||||
options.some((opt) => opt.value === addonValue),
|
||||
);
|
||||
|
||||
const response = await multiselect<ProjectAddons>({
|
||||
const response = await multiselect({
|
||||
message: "Select addons",
|
||||
options,
|
||||
initialValues,
|
||||
options: options,
|
||||
initialValues: initialValues,
|
||||
required: false,
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ export async function getApiChoice(
|
||||
if (Api) return Api;
|
||||
|
||||
const includesNuxt = frontend?.includes("nuxt");
|
||||
const includesSvelte = frontend?.includes("svelte");
|
||||
|
||||
let apiOptions = [
|
||||
{
|
||||
@@ -24,12 +25,14 @@ export async function getApiChoice(
|
||||
},
|
||||
];
|
||||
|
||||
if (includesNuxt) {
|
||||
if (includesNuxt || includesSvelte) {
|
||||
apiOptions = [
|
||||
{
|
||||
value: "orpc" as const,
|
||||
label: "oRPC",
|
||||
hint: "End-to-end type-safe APIs (Required for Nuxt frontend)",
|
||||
hint: `End-to-end type-safe APIs (Required for ${
|
||||
includesNuxt ? "Nuxt" : "Svelte"
|
||||
} frontend)`,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -37,7 +40,7 @@ export async function getApiChoice(
|
||||
const apiType = await select<ProjectApi>({
|
||||
message: "Select API type",
|
||||
options: apiOptions,
|
||||
initialValue: includesNuxt ? "orpc" : DEFAULT_CONFIG.api,
|
||||
initialValue: includesNuxt || includesSvelte ? "orpc" : DEFAULT_CONFIG.api,
|
||||
});
|
||||
|
||||
if (isCancel(apiType)) {
|
||||
@@ -45,7 +48,7 @@ export async function getApiChoice(
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (includesNuxt && apiType !== "orpc") {
|
||||
if ((includesNuxt || includesSvelte) && apiType !== "orpc") {
|
||||
return "orpc";
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@ export async function getExamplesChoice(
|
||||
frontends?.includes("react-router") ||
|
||||
frontends?.includes("tanstack-router") ||
|
||||
frontends?.includes("tanstack-start") ||
|
||||
frontends?.includes("next") || // Added next
|
||||
frontends?.includes("nuxt"); // Added nuxt
|
||||
frontends?.includes("next") ||
|
||||
frontends?.includes("nuxt") ||
|
||||
frontends?.includes("svelte");
|
||||
|
||||
if (!hasWebFrontend) return [];
|
||||
|
||||
@@ -36,7 +37,6 @@ export async function getExamplesChoice(
|
||||
},
|
||||
];
|
||||
|
||||
// AI example is available for hono, express, next backends, and Nuxt (if backend is not elysia)
|
||||
if (backend !== "elysia") {
|
||||
options.push({
|
||||
value: "ai" as const,
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function getFrontendChoice(
|
||||
{
|
||||
value: "web",
|
||||
label: "Web",
|
||||
hint: "React or Vue Web Application",
|
||||
hint: "React, Vue or Svelte Web Application",
|
||||
},
|
||||
{
|
||||
value: "native",
|
||||
@@ -29,7 +29,8 @@ export async function getFrontendChoice(
|
||||
f === "react-router" ||
|
||||
f === "tanstack-start" ||
|
||||
f === "next" ||
|
||||
f === "nuxt",
|
||||
f === "nuxt" ||
|
||||
f === "svelte",
|
||||
)
|
||||
? ["web"]
|
||||
: [],
|
||||
@@ -66,6 +67,11 @@ export async function getFrontendChoice(
|
||||
label: "Nuxt",
|
||||
hint: "The Progressive Web Framework for Vue.js",
|
||||
},
|
||||
{
|
||||
value: "svelte",
|
||||
label: "Svelte",
|
||||
hint: "web development for the rest of us",
|
||||
},
|
||||
{
|
||||
value: "tanstack-start",
|
||||
label: "TanStack Start (beta)",
|
||||
@@ -78,7 +84,9 @@ export async function getFrontendChoice(
|
||||
f === "tanstack-router" ||
|
||||
f === "react-router" ||
|
||||
f === "tanstack-start" ||
|
||||
f === "next",
|
||||
f === "next" ||
|
||||
f === "nuxt" ||
|
||||
f === "svelte",
|
||||
) || "tanstack-router",
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user