add svelte

This commit is contained in:
Aman Varshney
2025-04-26 08:12:01 +05:30
parent 0e8af094da
commit 8adf020c2a
45 changed files with 1212 additions and 97 deletions

View File

@@ -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,
});