Skip to content

Commit

Permalink
refactor: project prompts (#365)
Browse files Browse the repository at this point in the history
* refactor: project prompts

* fix: specs

* 1.17.6
  • Loading branch information
BatuhanW authored Sep 27, 2023
1 parent 671d16e commit 996db08
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superplate-cli",
"version": "1.17.5",
"version": "1.17.6",
"description": "The frontend boilerplate with superpowers",
"license": "MIT",
"repository": {
Expand Down
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
8 changes: 4 additions & 4 deletions src/Helper/source/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ describe("Source Helper", () => {
{ title: "Refine Remix", value: "refine-remix" },
],
expectedOutput: [
{ title: "React", value: "react" },
{ title: "Next.js", value: "nextjs" },
{ title: "Refine Vite", value: "refine-vite" },
{ title: "Refine Next.js", value: "refine-nextjs" },
{ title: "Refine Remix", value: "refine-remix" },
{ title: "Refine React", value: "refine-react" },
{ title: "React", value: "react" },
{ title: "Next.js", value: "nextjs" },
],
},
{
Expand All @@ -57,12 +57,12 @@ describe("Source Helper", () => {
{ title: "Refine Vite", value: "refine-vite" },
],
expectedOutput: [
{ title: "React", value: "react" },
{ title: "Next.js", value: "nextjs" },
{ title: "Refine Vite", value: "refine-vite" },
{ title: "Refine Next.js", value: "refine-nextjs" },
{ title: "Refine Remix", value: "refine-remix" },
{ title: "Refine React", value: "refine-react" },
{ title: "React", value: "react" },
{ title: "Next.js", value: "nextjs" },
],
},
{
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 996db08

Please sign in to comment.