@usercli/clideveloper 1.0.8 β†’ 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,8 +16,11 @@ Think of it as your **personal npm butler** πŸ•΄οΈ, setting up your tools while
16
16
 
17
17
  ## 🚧 Current Status
18
18
 
19
- > **React.js and Next.js installation is not available yet.**
20
- > Support for React.js and Next.js will be added in a future update.
19
+ . βœ… Backend frameworks fully supported
20
+
21
+ . βœ… React.js and Next.js installation is now available
22
+
23
+ . ⚠️ Other frontend frameworks will be added in future updates
21
24
 
22
25
  ---
23
26
 
@@ -9,8 +9,8 @@ const execPromise = util.promisify(exec);
9
9
  async function expressjs(path) {
10
10
  try {
11
11
  let spinner = createSpinner("Installing Express...").start();
12
- await execPromise("npm i express", { cwd: path }); // installing express
13
- await execPromise("npm i nodemon --save-dev",{cwd:path}) // installing nodemon
12
+ await execPromise("npm i express", { cwd: `${path}/backend` }); // installing express
13
+ await execPromise("npm i nodemon --save-dev",{cwd:`${path}/backend`}) // installing nodemon
14
14
 
15
15
 
16
16
 
@@ -34,12 +34,12 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
34
34
  try{
35
35
 
36
36
  // we create a file index.js and that all code expresscode after triming we put inside it
37
- await fs.writeFile(`${path}/index.js`,clean,(err)=>{
37
+ await fs.writeFile(`${path}/backend/index.js`,clean,(err)=>{
38
38
  if(err) console.log(err);
39
39
  })
40
40
 
41
41
  //we are reading package file
42
- let packageFile=await fs.readFile(`${path}/package.json`,"utf8");
42
+ let packageFile=await fs.readFile(`${path}/backend/package.json`,"utf8");
43
43
 
44
44
  //this package file is json that is why we use JSON.parse method
45
45
  let pkg=JSON.parse(packageFile);
@@ -51,7 +51,7 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
51
51
  }
52
52
 
53
53
 
54
- await fs.writeFile(`${path}/package.json`,JSON.stringify(pkg,null,4));
54
+ await fs.writeFile(`${path}/backend/package.json`,JSON.stringify(pkg,null,4));
55
55
 
56
56
  spinner.success({ text: "Express installed successfully! πŸŽ‰" });
57
57
 
@@ -122,7 +122,7 @@ async function userNpmInstall({mongooseInstall,cors,prisma},path){
122
122
  // mongoose installing process
123
123
  if(mongooseInstall=="Yes"){
124
124
  let spinner=createSpinner("Installing mongoose...").start();
125
- await execPromise("npm i mongoose",{cwd:path});
125
+ await execPromise("npm i mongoose",{cwd:`${path}/backend`});
126
126
 
127
127
  spinner.success({text:"mongoose installed sucessfully enjoy!"});
128
128
  }
@@ -132,7 +132,7 @@ async function userNpmInstall({mongooseInstall,cors,prisma},path){
132
132
  // cors intall and update a index.js file and put cors code or express code in it
133
133
  if(cors=="Yes"){
134
134
  let spinner=createSpinner("Installing cors...").start();
135
- await execPromise("npm i cors",{cwd:path});
135
+ await execPromise("npm i cors",{cwd:`${path}/backend`});
136
136
 
137
137
  let expressCode=`
138
138
  const express=require("express");
@@ -153,11 +153,11 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
153
153
  `
154
154
 
155
155
  let clean=expressCode.trim();
156
- let readFile=await fs.readFile(`${path}/index.js`,"utf8");
156
+ let readFile=await fs.readFile(`${path}/backend/index.js`,"utf8");
157
157
 
158
158
  readFile=readFile=clean;
159
159
 
160
- await fs.writeFile(`${path}/index.js`,readFile);
160
+ await fs.writeFile(`${path}/backend/index.js`,readFile);
161
161
 
162
162
  spinner.success({text:"cors installed sucessfully enjoy!"});
163
163
  }
@@ -168,7 +168,7 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
168
168
 
169
169
  let spinner1 = createSpinner("Installing prisma...").start();
170
170
 
171
- await execPromise("npm i prisma",{cwd:path});
171
+ await execPromise("npm i prisma",{cwd:`${path}/backend`});
172
172
 
173
173
  spinner1.success({text:"prisma install suceessfully!"})
174
174
 
@@ -176,7 +176,7 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
176
176
 
177
177
  let spinner2=createSpinner("Setup prisma...").start();
178
178
 
179
- await execPromise("npx prisma init",{cwd:path});
179
+ await execPromise("npx prisma init",{cwd:`${path}/backend`});
180
180
 
181
181
  spinner2.success({text:"Prisma setup done enjoy!"});
182
182
 
@@ -2,16 +2,21 @@ const { exec } = require("child_process");
2
2
  const util = require("util");
3
3
  const path = require("path");
4
4
  const { createSpinner } = require("nanospinner");
5
+ const fs = require("fs").promises;
5
6
 
6
7
  const execPromise = util.promisify(exec);
7
8
 
8
9
  async function createNestJs(folderName) {
9
10
  try {
10
11
  const userPath = path.join(process.cwd(), folderName);
12
+ const backendPath = path.join(userPath, "backend");
11
13
 
12
- console.log(`Creating NestJS project in: ${userPath}`);
14
+ console.log(`Creating NestJS project in: ${backendPath}`);
15
+
16
+ // Create the main project folder and backend subfolder
17
+ await fs.mkdir(backendPath, { recursive: true });
13
18
 
14
- // Start spinner
19
+ // Start spinner for CLI installation
15
20
  const spinner = createSpinner("Installing NestJS CLI globally...").start();
16
21
 
17
22
  try {
@@ -25,18 +30,18 @@ async function createNestJs(folderName) {
25
30
  // Create new spinner for project creation
26
31
  const spinner2 = createSpinner("Creating NestJS project...").start();
27
32
 
28
- // Create NestJS project
29
- // Note: nest new will create a new folder, so we need to be careful with paths
30
- await execPromise(`nest new ${folderName} --skip-git`, {
31
- cwd: process.cwd() // Run from current directory, not inside the folder
33
+ // Create NestJS project directly in the backend folder
34
+ // The key change: use `--directory .` to create in current directory
35
+ await execPromise(`nest new . --skip-git --package-manager npm`, {
36
+ cwd: backendPath
32
37
  });
33
38
 
34
39
  spinner2.success({ text: "NestJS project created successfully!" });
35
40
 
36
41
  console.log("\nβœ… NestJS project created successfully!");
37
- console.log(`πŸ“ Location: ${userPath}`);
42
+ console.log(`πŸ“ Location: ${backendPath}`);
38
43
  console.log("\nπŸš€ To start your NestJS app:");
39
- console.log(` cd ${folderName}`);
44
+ console.log(` cd ${backendPath}`);
40
45
  console.log(" npm run start");
41
46
  console.log(" npm run start:dev # for development with watch mode");
42
47
 
@@ -0,0 +1,90 @@
1
+ const {exec}=require("child_process");
2
+ const util=require("util");
3
+ const { createSpinner } = require("nanospinner");
4
+ const path = require("path");
5
+ const inquire=require("inquirer").default;
6
+
7
+ let execPromise=util.promisify(exec);
8
+
9
+ async function commonNextReactSetup(userPath,setupName){
10
+ try{
11
+
12
+ let userInstallPath=path.join(process.cwd(),userPath);
13
+
14
+ switch(setupName){
15
+
16
+ // next js installing process
17
+ case "nextjs":
18
+
19
+ let jsTsChoice=await inquire.prompt([
20
+ {
21
+ name:"jsTs",
22
+ type:"input",
23
+ message:"You want to use typescript then write y or if you want to use normal js write n?",
24
+ validate:(check)=>{
25
+ if(check.trim()=="y" || check.trim()=="n"){
26
+ return true;
27
+ }
28
+
29
+ return "Write y or n in small";
30
+ }
31
+ }
32
+ ])
33
+
34
+
35
+ let spinner=createSpinner("Installing Next.js… greatness takes a moment πŸš€").start();
36
+
37
+ await execPromise(`npx create-next-app@latest . ${(jsTsChoice.jsTs=="y")?"--typescript":"--javascript"} --tailwind --app --no-eslint --import-alias "@/*" --yes --no-git`,{cwd:userInstallPath, shell: true});
38
+
39
+ spinner.success({text:"Successfully installed next js enjoy coding!"});
40
+
41
+ break;
42
+
43
+
44
+
45
+ // react js installing process
46
+ case "reactjs":
47
+ let tsjs=await inquire.prompt([
48
+ {
49
+ name:"jsts",
50
+ type:"input",
51
+ message:"If you want to install react with typescript write y and if you want to install react with normal js write n?",
52
+ validate:(check)=>{
53
+ if(check.trim()=="y" || check.trim()=="n"){
54
+ return true;
55
+ }
56
+ return "Only write y or n in small";
57
+ }
58
+ },
59
+ {
60
+ name:"backend",
61
+ type:"input",
62
+ message:"You want backend type y otherwise n?",
63
+ validate:(check)=>{
64
+ if(check.trim()=="y" || check.trim()=="n"){
65
+ return true;
66
+ }
67
+
68
+ return "Write y and n in small no other options are available";
69
+ }
70
+ }
71
+ ])
72
+
73
+ let spinner1=createSpinner("Downloading React… grabbing virtual DOM snacks πŸͺ").start();
74
+
75
+ await execPromise(`npm create vite@latest . --template ${(tsjs=="y")?"react-ts":"react"} --yes`,{cwd:userInstallPath,shell:true})
76
+
77
+ spinner1.success({text:"Successfully install react enjoy!"});
78
+
79
+ break;
80
+
81
+ default:
82
+ console.log("There no this type option are available");
83
+
84
+ }
85
+ }catch(err){
86
+ console.log(err);
87
+ }
88
+ }
89
+
90
+ module.exports={commonNextReactSetup};
@@ -4,16 +4,19 @@ const { createSpinner } = require("nanospinner");
4
4
  const util = require("util");
5
5
  const inquire = require("inquirer").default;
6
6
  const { expressjs } = require("./expressjs");
7
+ const fs = require("fs").promises;
7
8
 
8
9
  const execPromise = util.promisify(exec);
9
10
 
10
11
  async function nodejs(fileName) {
11
12
  try {
12
13
  const folderPath = path.join(process.cwd(), fileName);
14
+ await fs.mkdir(`${folderPath}/backend`,{recursive:true});
15
+ console.log("Folder backend is created sucessfully");
13
16
 
14
17
  let spinner = createSpinner("Initializing npm project...").start();
15
18
 
16
- await execPromise("npm init -y", { cwd: folderPath });
19
+ await execPromise("npm init -y", { cwd: `${folderPath}/backend` });
17
20
  spinner.success({ text: "Project initialized successfully!" });
18
21
  console.log("βœ… Node.js project setup completed!");
19
22
 
package/index.js CHANGED
@@ -7,6 +7,7 @@ let {createFoldder}=require("./components/folderCreate");
7
7
  let {nodejs}=require("./components/nodejs");
8
8
  const {heading} =require("./components/welcomeHeading");
9
9
  const {createNestJs}=require("./components/nestjs");
10
+ const {commonNextReactSetup}=require("./components/nextjsReactjsSetup");
10
11
 
11
12
 
12
13
  async function main() {
@@ -34,9 +35,9 @@ async function main() {
34
35
  }else if(answer.framework=="nestjs"){
35
36
  await createNestJs(answer.folderName)
36
37
  }else if(answer.framework=="reactjs"){
37
- console.log("This react js is not come yet coming soon developer");
38
+ await commonNextReactSetup(answer.folderName,"reactjs");
38
39
  }else if(answer.framework=="nextjs"){
39
- console.log("This react js is not come yet coming soon developer");
40
+ await commonNextReactSetup(answer.folderName,"nextjs");
40
41
  }
41
42
 
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usercli/clideveloper",
3
- "version": "1.0.8",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {