@usercli/clideveloper 1.0.9 → 2.0.1

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
@@ -14,6 +14,10 @@ Think of it as your **personal npm butler** šŸ•“ļø, setting up your tools while
14
14
 
15
15
  ---
16
16
 
17
+ **Bug Resolved āœ…**
18
+ The issue has been fixed! Please download the latest version using command: npx @usercli/clideveloper@latest
19
+
20
+
17
21
  ## 🚧 Current Status
18
22
 
19
23
  . āœ… Backend frameworks fully supported
@@ -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
 
@@ -12,6 +12,8 @@ async function commonNextReactSetup(userPath,setupName){
12
12
  let userInstallPath=path.join(process.cwd(),userPath);
13
13
 
14
14
  switch(setupName){
15
+
16
+ // next js installing process
15
17
  case "nextjs":
16
18
 
17
19
  let jsTsChoice=await inquire.prompt([
@@ -38,6 +40,9 @@ async function commonNextReactSetup(userPath,setupName){
38
40
 
39
41
  break;
40
42
 
43
+
44
+
45
+ // react js installing process
41
46
  case "reactjs":
42
47
  let tsjs=await inquire.prompt([
43
48
  {
@@ -50,6 +55,18 @@ async function commonNextReactSetup(userPath,setupName){
50
55
  }
51
56
  return "Only write y or n in small";
52
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
+ }
53
70
  }
54
71
  ])
55
72
 
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usercli/clideveloper",
3
- "version": "1.0.9",
3
+ "version": "2.0.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {