Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: project prompts #365

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/Helper/humanize/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const HumanizeChoices = {
get: (
choice: string,
projectType?: string,
): { title: string; description: string; value: string } => {
switch (choice) {
case "react":
Expand All @@ -17,28 +18,35 @@ export const HumanizeChoices = {
};
case "refine-vite":
return {
title: "refine(Vite)",
title: projectType === "refine" ? "Vite" : "refine (Vite)",
description:
"Creates a refine React Vite project (Recommended for CRUD applications).",
value: choice,
};
case "refine-nextjs":
return {
title: "refine(Next.js)",
title:
projectType === "refine"
? "Next.js"
: "refine (Next.js)",
description:
"Creates a refine Next.js project with SSR support (Recommended for CRUD applications).",
value: choice,
};
case "refine-remix":
return {
title: "refine(Remix)",
title:
projectType === "refine" ? "Remix" : "refine (Remix)",
description:
"Creates a refine Remix project with SSR support (Recommended for CRUD applications)",
value: choice,
};
case "refine-react":
return {
title: "refine(CRA) [Legacy]",
title:
projectType === "refine"
? "CRA [Legacy]"
: "refine (CRA) [Legacy]",
description:
"Creates a basic refine project (Recommended for CRUD applications)",
value: choice,
Expand Down
14 changes: 7 additions & 7 deletions src/Helper/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ export const sort_project_types = (
projectTypes: { title: string; value: string }[],
): { title: string; value: string }[] => {
const order: Record<string, number> = {
react: 1,
nextjs: 2,
"refine-vite": 3,
"refine-nextjs": 4,
"refine-remix": 5,
"refine-react": 6,
"refine-vite": 1,
"refine-nextjs": 2,
"refine-remix": 3,
"refine-react": 4,
react: 5,
nextjs: 6,
};

const newProjectTypes = [...projectTypes];
Expand Down Expand Up @@ -174,7 +174,7 @@ export const prompt_project_types = async (
? filteredWithContains
: types
)
.map((p) => HumanizeChoices.get(p.title))
.map((p) => HumanizeChoices.get(p.title, typeFromArgs))
.map((p) => ({
type: "select",
name: p.value,
Expand Down
Loading