@usercli/clideveloper 2.0.4 → 2.2.6
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 +1 -0
- package/components/expressjs.js +112 -1
- package/components/nextjsReactjsSetup.js +55 -46
- package/package.json +1 -1
package/README.md
CHANGED
package/components/expressjs.js
CHANGED
|
@@ -97,6 +97,20 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
|
97
97
|
return "Yes or No only";
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
+
|
|
101
|
+
{
|
|
102
|
+
name:"redis",
|
|
103
|
+
type:"rawlist",
|
|
104
|
+
message:"Yes or No to install ioredis in express?",
|
|
105
|
+
choices:["Yes","No"],
|
|
106
|
+
validate:(check)=>{
|
|
107
|
+
if(check.trim()=="Yes" || check.trim()=="No"){
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return "Yes or No only";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
100
114
|
])
|
|
101
115
|
|
|
102
116
|
|
|
@@ -116,7 +130,7 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
|
116
130
|
|
|
117
131
|
|
|
118
132
|
|
|
119
|
-
async function userNpmInstall({mongooseInstall,cors,prisma},path){
|
|
133
|
+
async function userNpmInstall({mongooseInstall,cors,prisma,redis},path){
|
|
120
134
|
try{
|
|
121
135
|
|
|
122
136
|
// mongoose installing process
|
|
@@ -180,9 +194,102 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
|
180
194
|
|
|
181
195
|
spinner2.success({text:"Prisma setup done enjoy!"});
|
|
182
196
|
|
|
197
|
+
let spinner3=createSpinner("Prisma client is installing...").start();
|
|
198
|
+
|
|
199
|
+
// install @prisma/client
|
|
200
|
+
await execPromise("npm install @prisma/client",{cwd:`${path}/backend`});
|
|
201
|
+
|
|
202
|
+
spinner3.success({text:"Prisma client install successfully!"});
|
|
203
|
+
|
|
183
204
|
console.log("Prisma installed completely with prisma setup");
|
|
184
205
|
}
|
|
185
206
|
|
|
207
|
+
if(redis=="Yes"){
|
|
208
|
+
try{
|
|
209
|
+
// write redis file or create folder
|
|
210
|
+
|
|
211
|
+
let spinner=createSpinner("Downloading all the things which are required to run redies...").start();
|
|
212
|
+
await execPromise("npm i ioredis",{cwd:`${path}/backend`})
|
|
213
|
+
await execPromise("npm i cors",{cwd:`${path}/backend`})
|
|
214
|
+
await execPromise("npm i dotenv",{cwd:`${path}/backend`});
|
|
215
|
+
|
|
216
|
+
await fs.mkdir(`${path}/backend/redisFileForConnection`,{recursive:true});
|
|
217
|
+
|
|
218
|
+
let redisCode=`
|
|
219
|
+
const Redis=require("ioredis");
|
|
220
|
+
require("dotenv").config();
|
|
221
|
+
|
|
222
|
+
const redis=new Redis({
|
|
223
|
+
|
|
224
|
+
host:process.env.REDIS_HOST,
|
|
225
|
+
password:process.env.REDIS_PASS,
|
|
226
|
+
port:process.env.REDIS_PORT
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
module.exports={redis}
|
|
231
|
+
|
|
232
|
+
`
|
|
233
|
+
|
|
234
|
+
let cleanRedis=redisCode.trim();
|
|
235
|
+
|
|
236
|
+
await fs.writeFile(`${path}/backend/redisFileForConnection/redisConnection.js`,cleanRedis);
|
|
237
|
+
|
|
238
|
+
// env file is made
|
|
239
|
+
let envData=`
|
|
240
|
+
# string
|
|
241
|
+
REDIS_HOST=""
|
|
242
|
+
|
|
243
|
+
#string
|
|
244
|
+
REDIS_PASS=""
|
|
245
|
+
|
|
246
|
+
#number
|
|
247
|
+
REDIS_PORT=
|
|
248
|
+
`;
|
|
249
|
+
let cleanEnvFile=envData.trim();
|
|
250
|
+
await fs.writeFile(`${path}/backend/.env`,cleanEnvFile);
|
|
251
|
+
console.log("Env file is made succefully");
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
let expressCode=`
|
|
257
|
+
const express=require("express");
|
|
258
|
+
const cors=require("cors");
|
|
259
|
+
const {redis}=require("./redisFileForConnection/redisConnection");
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
const app=express();
|
|
263
|
+
|
|
264
|
+
redis.on("connect",()=>{
|
|
265
|
+
console.log("redis is connected succesfully");
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
app.use(cors());
|
|
269
|
+
|
|
270
|
+
app.get("/",(_,res)=>{
|
|
271
|
+
|
|
272
|
+
res.status(200).json({success:"hello developer"});
|
|
273
|
+
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
277
|
+
|
|
278
|
+
`
|
|
279
|
+
|
|
280
|
+
let clean=expressCode.trim();
|
|
281
|
+
let readFile=await fs.readFile(`${path}/backend/index.js`,"utf8");
|
|
282
|
+
|
|
283
|
+
readFile=readFile=clean;
|
|
284
|
+
|
|
285
|
+
await fs.writeFile(`${path}/backend/index.js`,readFile);
|
|
286
|
+
spinner.success({text:"redis setup is done enjoy!"});
|
|
287
|
+
|
|
288
|
+
}catch(err){
|
|
289
|
+
console.log("ioredis is not install for some reason");
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
186
293
|
|
|
187
294
|
else{
|
|
188
295
|
if(mongooseInstall=="No"){
|
|
@@ -195,6 +302,10 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
|
195
302
|
console.log("You do not installed prisma");
|
|
196
303
|
}
|
|
197
304
|
|
|
305
|
+
if(redis=="No"){
|
|
306
|
+
console.log("You do not install redis");
|
|
307
|
+
}
|
|
308
|
+
|
|
198
309
|
else{
|
|
199
310
|
console.log("There is no option like this");
|
|
200
311
|
}
|
|
@@ -1,90 +1,99 @@
|
|
|
1
|
-
const {exec}=require("child_process");
|
|
2
|
-
const util=require("util");
|
|
1
|
+
const { exec } = require("child_process");
|
|
2
|
+
const util = require("util");
|
|
3
3
|
const { createSpinner } = require("nanospinner");
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const inquire=require("inquirer").default;
|
|
5
|
+
const inquire = require("inquirer").default;
|
|
6
|
+
const fs = require("fs").promises;
|
|
6
7
|
|
|
7
|
-
let execPromise=util.promisify(exec);
|
|
8
|
+
let execPromise = util.promisify(exec);
|
|
8
9
|
|
|
9
|
-
async function commonNextReactSetup(userPath,setupName){
|
|
10
|
-
try{
|
|
11
|
-
|
|
12
|
-
let userInstallPath=path.join(process.cwd(),userPath);
|
|
10
|
+
async function commonNextReactSetup(userPath, setupName) {
|
|
11
|
+
try {
|
|
12
|
+
const frontendPath = path.join(process.cwd(), userPath, "frontend");
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
await fs.mkdir(frontendPath, { recursive: true });
|
|
15
15
|
|
|
16
|
+
switch (setupName) {
|
|
16
17
|
// next js installing process
|
|
17
18
|
case "nextjs":
|
|
18
|
-
|
|
19
|
-
let jsTsChoice=await inquire.prompt([
|
|
19
|
+
let jsTsChoice = await inquire.prompt([
|
|
20
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"){
|
|
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
26
|
return true;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
return "Write y or n in small";
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
|
-
])
|
|
33
|
-
|
|
31
|
+
]);
|
|
34
32
|
|
|
35
|
-
let spinner=createSpinner("Installing Next.js… greatness takes a moment 🚀").start();
|
|
33
|
+
let spinner = createSpinner("Installing Next.js… greatness takes a moment 🚀").start();
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
|
|
36
|
+
await execPromise(
|
|
37
|
+
`npx create-next-app@latest . ${(jsTsChoice.jsTs == "y") ? "--typescript" : "--javascript"} --tailwind --app --no-eslint --import-alias "@/*" --yes --no-git`,
|
|
38
|
+
{
|
|
39
|
+
cwd: frontendPath,
|
|
40
|
+
shell: true,
|
|
41
|
+
windowsHide: true
|
|
42
|
+
}
|
|
43
|
+
);
|
|
40
44
|
|
|
45
|
+
spinner.success({ text: "Successfully installed next js enjoy coding!" });
|
|
41
46
|
break;
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
48
|
// react js installing process
|
|
46
49
|
case "reactjs":
|
|
47
|
-
let tsjs=await inquire.prompt([
|
|
50
|
+
let tsjs = await inquire.prompt([
|
|
48
51
|
{
|
|
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"){
|
|
52
|
+
name: "jsts",
|
|
53
|
+
type: "input",
|
|
54
|
+
message: "If you want to install react with typescript write y and if you want to install react with normal js write n?",
|
|
55
|
+
validate: (check) => {
|
|
56
|
+
if (check.trim() == "y" || check.trim() == "n") {
|
|
54
57
|
return true;
|
|
55
58
|
}
|
|
56
59
|
return "Only write y or n in small";
|
|
57
60
|
}
|
|
58
61
|
},
|
|
59
62
|
{
|
|
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"){
|
|
63
|
+
name: "backend",
|
|
64
|
+
type: "input",
|
|
65
|
+
message: "You want backend type y otherwise n?",
|
|
66
|
+
validate: (check) => {
|
|
67
|
+
if (check.trim() == "y" || check.trim() == "n") {
|
|
65
68
|
return true;
|
|
66
69
|
}
|
|
67
|
-
|
|
68
70
|
return "Write y and n in small no other options are available";
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
|
-
])
|
|
73
|
+
]);
|
|
72
74
|
|
|
73
|
-
let spinner1=createSpinner("Downloading React… grabbing virtual DOM snacks 🍪").start();
|
|
75
|
+
let spinner1 = createSpinner("Downloading React… grabbing virtual DOM snacks 🍪").start();
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
await execPromise(
|
|
79
|
+
`npm create vite@latest . --template ${(tsjs.jsts == "y") ? "react-ts" : "react"} --yes`,
|
|
80
|
+
{
|
|
81
|
+
cwd: frontendPath,
|
|
82
|
+
shell: true,
|
|
83
|
+
windowsHide: true
|
|
84
|
+
}
|
|
85
|
+
);
|
|
78
86
|
|
|
87
|
+
spinner1.success({ text: "Successfully install react enjoy!" });
|
|
79
88
|
break;
|
|
80
89
|
|
|
81
90
|
default:
|
|
82
91
|
console.log("There no this type option are available");
|
|
83
|
-
|
|
84
92
|
}
|
|
85
|
-
}catch(err){
|
|
86
|
-
console.
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.error("Error in setup:", err);
|
|
95
|
+
throw err;
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
module.exports={commonNextReactSetup};
|
|
99
|
+
module.exports = { commonNextReactSetup };
|