Skip to content

Commit

Permalink
refactor: project prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
BatuhanW committed Sep 27, 2023
1 parent 671d16e commit 2321c59
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
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

0 comments on commit 2321c59

Please sign in to comment.