Skip to content

Commit 8e38670

Browse files
committed
cleaning the code little bit :D
1 parent ac3556e commit 8e38670

File tree

6 files changed

+33
-45
lines changed

6 files changed

+33
-45
lines changed

bin/app.js

+3-39
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const path = process.cwd();
1111
import chalk from 'chalk';
1212
import * as qs from '../utils/questions.js';
1313
import { links } from '../utils/links.js';
14+
import { frontEndInstall } from '../utils/fGitHandler.js';
1415

1516
console.log(chalk.green("Hello, I'm a CLI for creating a new project"));
1617
inquirer
@@ -70,30 +71,8 @@ inquirer
7071
console.log(chalk.red('🚧 This feature is not available yet'));
7172
}
7273
inquirer.prompt(qs.questionsRestApiF).then((answers) => {
73-
74-
if (answers['frontend'] === 'VueJs') {
75-
frontEndInstall(answers, 'VueJs');
76-
// inquirer.prompt(qs.questionsRun).then((answers) => {
77-
// if (answers['Run Project']) {
78-
// shell.exec(`npm run dev`);
79-
// } else {
80-
// console.log(chalk.green('👋 Bye'));
81-
// }
82-
// });
83-
} else if (answers['frontend'] === 'NuxtJs') {
84-
frontEndInstall(answers, 'NuxtJs');
85-
} else if (answers['frontend'] === 'Svelte') {
86-
frontEndInstall(answers, 'Svelte');
87-
} else if (answers['frontend'] === 'React') {
88-
frontEndInstall(answers, 'ReactJs');
89-
} else if (answers['frontend'] === 'NextJs') {
90-
frontEndInstall(answers, 'NextJs');
91-
} else if (answers['frontend'] === 'Angular') {
92-
frontEndInstall(answers, 'Angular');
93-
}
94-
else {
95-
console.log(chalk.red('🚧 Something Wrong You Should Not See This'));
96-
}
74+
console.log(chalk.green('📁 Created a folder for the frontend project'));
75+
frontEndInstall(answers['frontend']);
9776
});
9877

9978
// This Part is still just idea and not implemented yet
@@ -138,18 +117,3 @@ inquirer
138117
}
139118
});
140119

141-
function frontEndInstall(answers, fmName) {
142-
shell.exec(`mkdir ${answers['frontend']}`);
143-
console.log(chalk.green('📁 Created a folder for the backend project'));
144-
console.log(chalk.green('cloning the backend project from GitHub 🚀'));
145-
shell.exec(`git clone ${links.get(fmName)} ${answers['frontend']}`);
146-
shell.cd(`${path}/${answers['frontend']}`);
147-
console.log(chalk.green('🚀 Installing dependencies'));
148-
shell.exec(`npm i`);
149-
console.log(chalk.green('📦 Successfully installed all the required dependencies\nHappy hacking 🚀'));
150-
console.log(chalk.green('\nMade with ❤️ by @ru44'));
151-
shell.rm('-rf', '.git');
152-
shell.rm('-rf', '.github');
153-
shell.cd(`..`);
154-
}
155-

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utils/bGitHandler.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import shell from 'shelljs';
2+
const path = process.cwd();
3+
import chalk from 'chalk';
4+
import { links } from '../utils/links.js';

utils/fGitHandler.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import shell from 'shelljs';
2+
const path = process.cwd();
3+
import chalk from 'chalk';
4+
import { links } from '../utils/links.js';
5+
6+
7+
8+
export function frontEndInstall(fmName) {
9+
shell.exec(`mkdir ${fmName}`);
10+
console.log(chalk.green('cloning the backend project from GitHub 🚀'));
11+
shell.exec(`git clone ${links.get(fmName)} ${fmName}`);
12+
shell.cd(`${path}/${fmName}`);
13+
console.log(chalk.green('🚀 Installing dependencies'));
14+
shell.exec(`npm i`);
15+
console.log(chalk.green('📦 Successfully installed all the required dependencies\nHappy hacking 🚀'));
16+
console.log(chalk.green('\nMade with ❤️ by @ru44'));
17+
shell.rm('-rf', '.git');
18+
shell.rm('-rf', '.github');
19+
shell.cd(`..`);
20+
}

utils/links.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let links = new Map([
1313
['AdonisJs', 'https://github.com/ru44/backendAdonis.git'],
1414
['TallStack', 'https://github.com/ru44/tallStack.git'],
1515
['DotNet', 'https://dotnet.microsoft.com/'],
16-
['Spring', 'https://spring.io/'],
16+
['Spring Boot', 'https://spring.io/'],
1717
]);
1818

1919
const _links = links;

utils/questions.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const questionsMVC = [
1919
type: 'list',
2020
name: 'MVC',
2121
message: 'Choose the MVC framework which you want to use:',
22-
choices: ['TallStack', 'DjangoMTV (coming soon)'],
22+
choices: ['TallStack', 'DjangoMTV'],
2323
}
2424
];
2525

@@ -28,7 +28,7 @@ const questionsRestApiF = [
2828
type: 'list',
2929
name: 'frontend',
3030
message: 'Choose the front framework which you want to use:',
31-
choices: ['VueJs', 'NuxtJs', 'React', 'NextJs', 'Angular', 'Svelte'],
31+
choices: ['VueJs', 'NuxtJs', 'ReactJs', 'NextJs', 'Angular', 'Svelte'],
3232
},
3333
];
3434

@@ -37,7 +37,7 @@ const questionsRestApiB = [
3737
type: 'list',
3838
name: 'backend',
3939
message: 'Choose the backend framework which you want to use:',
40-
choices: ['Express', 'NestJs', 'AdonisJs', 'Fastify', 'Django', 'Laravel', 'Spring Boot', 'Dotnet Core',],
40+
choices: ['ExpressJs', 'NestJs', 'AdonisJs', 'Fastify', 'Django', 'Laravel', 'Spring Boot', 'DotNet',],
4141
}
4242
];
4343

0 commit comments

Comments
 (0)