Skip to content

Commit

Permalink
Merge pull request #108 from giuseppesciacca/fix/106_issue_create_ano…
Browse files Browse the repository at this point in the history
…ther_component_question_moment

Fix/ #106 issue create another component question moment
  • Loading branch information
Giuliano1993 authored Apr 25, 2024
2 parents f6d2589 + fa1e9ad commit bb3796c
Show file tree
Hide file tree
Showing 16 changed files with 479 additions and 411 deletions.
16 changes: 8 additions & 8 deletions src/utils/frameworks/angular/angular.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const framework = "angular";
export default function (componentName, folder, anotherComponent) {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: "component.component.ts",
folder: folder,
anotherComponent: anotherComponent,
};

export default function (componentName, folder) {
return {
componentName,
framework: framework.toLowerCase(),
template: "component.component.ts",
folder: folder,
};
}
7 changes: 2 additions & 5 deletions src/utils/frameworks/angular/angular.mts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { Answers } from "../../wizard.mjs";

const framework = "angular";

export default function (componentName: string, folder: string, anotherComponent: boolean): Answers {
export default function (componentName: string, folder: string) {
return {
componentName: componentName,
componentName,
framework: framework.toLowerCase(),
template: "component.component.ts",
folder: folder,
anotherComponent: anotherComponent,
};
}
15 changes: 7 additions & 8 deletions src/utils/frameworks/astro/astro.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const framework = "astro";
export default function (componentName, folder, anotherComponent) {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: "component.astro",
folder: folder,
anotherComponent: anotherComponent,
};
export default function (componentName, folder) {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: "component.astro",
folder: folder,
};
}
3 changes: 1 addition & 2 deletions src/utils/frameworks/astro/astro.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const framework = "astro";

export default function (componentName: string, folder: string, anotherComponent: boolean) {
export default function (componentName: string, folder: string) {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: "component.astro",
folder: folder,
anotherComponent: anotherComponent,
};
}
46 changes: 23 additions & 23 deletions src/utils/frameworks/qwik/qwik.mjs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import inquirer from "inquirer";
const framework = "qwik";
export default function (componentName, folder, anotherComponent) {
return inquirer
.prompt([
{
type: "list",
name: "type",
message: "Choose wich type of component to create",
choices: ["Hello World", "useStore", "useStyles"],
},
export default function (componentName, folder) {
return inquirer
.prompt([
{
type: "list",
name: "type",
message: "Choose wich type of component to create",
choices: ["Hello World", "useStore", "useStyles"],
},
])
.then(answers => {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: answers.type === "Hello World"
? "hello-world-component.tsx"
: answers.type === "useStore"
? "usestore-component.tsx"
: answers.type === "useStyles"
? "usestyles-component.tsx"
: "hello-world-component.tsx",
folder: folder,
anotherComponent: anotherComponent,
};
.then((answers) => {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template:
answers.type === "Hello World"
? "hello-world-component.tsx"
: answers.type === "useStore"
? "usestore-component.tsx"
: answers.type === "useStyles"
? "usestyles-component.tsx"
: "hello-world-component.tsx",
folder: folder,
};
});
}
5 changes: 2 additions & 3 deletions src/utils/frameworks/qwik/qwik.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inquirer from "inquirer";

const framework = "qwik";
export default function (componentName: string, folder: string, anotherComponent: boolean) {
export default function (componentName: string, folder: string) {
return inquirer
.prompt([
{
Expand All @@ -11,7 +11,7 @@ export default function (componentName: string, folder: string, anotherComponent
choices: ["Hello World", "useStore", "useStyles"],
},
])
.then(answers => {
.then((answers: { type: string }) => {
return {
componentName: componentName,
framework: framework.toLowerCase(),
Expand All @@ -24,7 +24,6 @@ export default function (componentName: string, folder: string, anotherComponent
? "usestyles-component.tsx"
: "hello-world-component.tsx",
folder: folder,
anotherComponent: anotherComponent,
};
});
}
90 changes: 43 additions & 47 deletions src/utils/frameworks/react/react.mjs
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
import inquirer from "inquirer";
const framework = "react";
export default function (componentName, folder, anotherComponent) {
return inquirer
.prompt([
{
type: "confirm",
name: "typescript",
message: "Do you want to use Typescript?",
default: true,
},
export default function (componentName, folder) {
return inquirer
.prompt([
{
type: "confirm",
name: "typescript",
message: "Do you want to use Typescript?",
default: true,
},
{
type: "list",
name: "css",
message: "Do you want to use any CSS framework?",
choices: ["Tailwind", "Styled Components", "CSS Module", "No"],
default: "No",
},
])
.then((answers) => {
const { typescript } = answers;
return inquirer
.prompt([
{
type: "list",
name: "css",
message: "Do you want to use any CSS framework?",
choices: ["Tailwind", "Styled Components", "CSS Module", "No"],
default: "No",
},
])
.then((answers) => {
const { css } = answers;
const extension = typescript ? "tsx" : "jsx";
let templateBase = "function-component";
switch (css) {
case "Tailwind":
templateBase += "-tailwind";
break;
case "Styled Components":
templateBase += "-styled-components";
break;
case "CSS Module":
templateBase += "-css-module";
break;
default:
break;
}
const template = `${templateBase}.${extension}`;
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: template,
folder: folder,
anotherComponent: anotherComponent,
};
});
.then((answers) => {
const { typescript } = answers;
const { css } = answers;
const extension = typescript ? "tsx" : "jsx";
let templateBase = "function-component";

switch (css) {
case "Tailwind":
templateBase += "-tailwind";
break;
case "Styled Components":
templateBase += "-styled-components";
break;
case "CSS Module":
templateBase += "-css-module";
break;
default:
break;
}
const template = `${templateBase}.${extension}`;

return {
componentName: componentName,
framework: framework.toLowerCase(),
template: template,
folder: folder,
};
});
}
70 changes: 32 additions & 38 deletions src/utils/frameworks/react/react.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import inquirer from "inquirer";

const framework = "react";

export default function (componentName: string, folder: string, anotherComponent: boolean) {
export default function (componentName: string, folder: string) {
return inquirer
.prompt([
{
Expand All @@ -11,46 +11,40 @@ export default function (componentName: string, folder: string, anotherComponent
message: "Do you want to use Typescript?",
default: true,
},
{
type: "list",
name: "css",
message: "Do you want to use any CSS framework?",
choices: ["Tailwind", "Styled Components", "CSS Module", "No"],
default: "No",
},
])
.then((answers: { typescript: boolean }) => {
.then((answers: { typescript: boolean; css: string }) => {
const { typescript } = answers;
const { css } = answers;
const extension = typescript ? "tsx" : "jsx";
let templateBase = "function-component";

return inquirer
.prompt([
{
type: "list",
name: "css",
message: "Do you want to use any CSS framework?",
choices: ["Tailwind", "Styled Components", "CSS Module", "No"],
default: "No",
},
])
.then((answers: { css: string }) => {
const { css } = answers;
const extension = typescript ? "tsx" : "jsx";
let templateBase = "function-component";
switch (css) {
case "Tailwind":
templateBase += "-tailwind";
break;
case "Styled Components":
templateBase += "-styled-components";
break;
case "CSS Module":
templateBase += "-css-module";
break;
default:
break;
}
const template = `${templateBase}.${extension}`;
switch (css) {
case "Tailwind":
templateBase += "-tailwind";
break;
case "Styled Components":
templateBase += "-styled-components";
break;
case "CSS Module":
templateBase += "-css-module";
break;
default:
break;
}
const template = `${templateBase}.${extension}`;

return {
componentName: componentName,
framework: framework.toLowerCase(),
template: template,
folder: folder,
anotherComponent: anotherComponent,
};
});
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: template,
folder: folder,
};
});
}
35 changes: 18 additions & 17 deletions src/utils/frameworks/svelte/svelte.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import inquirer from "inquirer";
const framework = "svelte";
export default function (componentName, folder, anotherComponent) {
return inquirer
.prompt([
{
type: "confirm",
name: "typescript",
message: "Do you want to use Typescript?",
default: true,
},
export default function (componentName, folder) {
return inquirer
.prompt([
{
type: "confirm",
name: "typescript",
message: "Do you want to use Typescript?",
default: true,
},
])
.then((answers) => {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: answers.typescript ? "component-ts.svelte" : "component-js.svelte",
folder: folder,
anotherComponent: anotherComponent,
};
.then((answers) => {
return {
componentName: componentName,
framework: framework.toLowerCase(),
template: answers.typescript
? "component-ts.svelte"
: "component-js.svelte",
folder: folder,
};
});
}
3 changes: 1 addition & 2 deletions src/utils/frameworks/svelte/svelte.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inquirer from "inquirer";

const framework = "svelte";
export default function (componentName: string, folder: string, anotherComponent: boolean) {
export default function (componentName: string, folder: string) {
return inquirer
.prompt([
{
Expand All @@ -17,7 +17,6 @@ export default function (componentName: string, folder: string, anotherComponent
framework: framework.toLowerCase(),
template: answers.typescript ? "component-ts.svelte" : "component-js.svelte",
folder: folder,
anotherComponent: anotherComponent,
};
});
}
Loading

0 comments on commit bb3796c

Please sign in to comment.