mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
several bug fixes
This commit is contained in:
@@ -1,38 +1,52 @@
|
||||
import { cancel, isCancel, multiselect } from "@clack/prompts";
|
||||
import pc from "picocolors";
|
||||
import { DEFAULT_CONFIG } from "../constants";
|
||||
import type { ProjectAddons } from "../types";
|
||||
import type { ProjectAddons, ProjectFrontend } from "../types";
|
||||
|
||||
export async function getAddonsChoice(
|
||||
Addons?: ProjectAddons[],
|
||||
frontends?: ProjectFrontend[],
|
||||
): Promise<ProjectAddons[]> {
|
||||
if (Addons !== undefined) return Addons;
|
||||
|
||||
const hasWeb = frontends?.includes("web");
|
||||
|
||||
const addonOptions = [
|
||||
{
|
||||
value: "biome" as const,
|
||||
label: "Biome",
|
||||
hint: "Add Biome for linting and formatting",
|
||||
},
|
||||
{
|
||||
value: "husky" as const,
|
||||
label: "Husky",
|
||||
hint: "Add Git hooks with Husky, lint-staged (requires Biome)",
|
||||
},
|
||||
];
|
||||
|
||||
const webAddonOptions = [
|
||||
{
|
||||
value: "pwa" as const,
|
||||
label: "PWA (Progressive Web App)",
|
||||
hint: "Make your app installable and work offline",
|
||||
},
|
||||
{
|
||||
value: "tauri" as const,
|
||||
label: "Tauri Desktop App",
|
||||
hint: "Build native desktop apps from your web frontend",
|
||||
},
|
||||
];
|
||||
|
||||
const options = hasWeb ? [...webAddonOptions, ...addonOptions] : addonOptions;
|
||||
|
||||
const initialValues = DEFAULT_CONFIG.addons.filter(
|
||||
(addon) => hasWeb || (addon !== "pwa" && addon !== "tauri"),
|
||||
);
|
||||
|
||||
const response = await multiselect<ProjectAddons>({
|
||||
message: "Which Addons would you like to add?",
|
||||
options: [
|
||||
{
|
||||
value: "pwa",
|
||||
label: "PWA (Progressive Web App)",
|
||||
hint: "Make your app installable and work offline",
|
||||
},
|
||||
{
|
||||
value: "tauri",
|
||||
label: "Tauri Desktop App",
|
||||
hint: "Build native desktop apps from your web frontend",
|
||||
},
|
||||
{
|
||||
value: "biome",
|
||||
label: "Biome",
|
||||
hint: "Add Biome for linting and formatting",
|
||||
},
|
||||
{
|
||||
value: "husky",
|
||||
label: "Husky",
|
||||
hint: "Add Git hooks with Husky, lint-staged (requires Biome)",
|
||||
},
|
||||
],
|
||||
initialValues: DEFAULT_CONFIG.addons,
|
||||
options,
|
||||
initialValues,
|
||||
required: false,
|
||||
});
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ export async function gatherConfig(
|
||||
results.database === "sqlite" && results.orm !== "prisma"
|
||||
? getTursoSetupChoice(flags.turso)
|
||||
: Promise.resolve(false),
|
||||
addons: () => getAddonsChoice(flags.addons),
|
||||
addons: ({ results }) => getAddonsChoice(flags.addons, results.frontend),
|
||||
examples: ({ results }) =>
|
||||
getExamplesChoice(flags.examples, results.database),
|
||||
getExamplesChoice(flags.examples, results.database, results.frontend),
|
||||
git: () => getGitChoice(flags.git),
|
||||
packageManager: () => getPackageManagerChoice(flags.packageManager),
|
||||
noInstall: () => getNoInstallChoice(flags.noInstall),
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
import { cancel, isCancel, multiselect } from "@clack/prompts";
|
||||
import pc from "picocolors";
|
||||
import { DEFAULT_CONFIG } from "../constants";
|
||||
import type { ProjectDatabase, ProjectExamples } from "../types";
|
||||
import type {
|
||||
ProjectDatabase,
|
||||
ProjectExamples,
|
||||
ProjectFrontend,
|
||||
} from "../types";
|
||||
|
||||
export async function getExamplesChoice(
|
||||
examples?: ProjectExamples[],
|
||||
database?: ProjectDatabase,
|
||||
frontends?: ProjectFrontend[],
|
||||
): Promise<ProjectExamples[]> {
|
||||
if (examples !== undefined) return examples;
|
||||
|
||||
if (database === "none") return [];
|
||||
|
||||
const hasWebFrontend = frontends?.includes("web");
|
||||
if (!hasWebFrontend) return [];
|
||||
|
||||
const response = await multiselect<ProjectExamples>({
|
||||
message: "Which examples would you like to include?",
|
||||
options: [
|
||||
|
||||
Reference in New Issue
Block a user