@usercli/clideveloper 2.1.5 β 2.2.7
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 +131 -1
- 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
|
|
@@ -190,6 +204,118 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
|
190
204
|
console.log("Prisma installed completely with prisma setup");
|
|
191
205
|
}
|
|
192
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
|
+
|
|
213
|
+
await execPromise("npm i ioredis",{cwd:`${path}/backend`})
|
|
214
|
+
await execPromise("npm i cors",{cwd:`${path}/backend`})
|
|
215
|
+
await execPromise("npm i dotenv",{cwd:`${path}/backend`});
|
|
216
|
+
|
|
217
|
+
spinner.success({text:"All requirements are installed successfully"});
|
|
218
|
+
spinner.stop();
|
|
219
|
+
|
|
220
|
+
console.log("To fully setup redis answer below question to run the redis");
|
|
221
|
+
// env redis file setup
|
|
222
|
+
|
|
223
|
+
const envRedis=await inquire.prompt([
|
|
224
|
+
{
|
|
225
|
+
name:"envHost",
|
|
226
|
+
type:"editor",
|
|
227
|
+
message:"Write your host name which is required to run redis editor will open copy and past your host name and with ctrl+s save it and close the editor fully?:"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name:"envPass",
|
|
231
|
+
type:"editor",
|
|
232
|
+
message:"Write your password which is required to run redis editor will open copy and past your password and with ctrl+s save it and close the editor fully?:"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name:"envPort",
|
|
236
|
+
type:"input",
|
|
237
|
+
message:"Write your port which is required to run redis?:"
|
|
238
|
+
}
|
|
239
|
+
])
|
|
240
|
+
|
|
241
|
+
let spinner1=createSpinner("Doing setup for redies...").start();
|
|
242
|
+
await fs.mkdir(`${path}/backend/redisFileForConnection`,{recursive:true});
|
|
243
|
+
|
|
244
|
+
let redisCode=`
|
|
245
|
+
const Redis=require("ioredis");
|
|
246
|
+
require("dotenv").config();
|
|
247
|
+
|
|
248
|
+
const redis=new Redis({
|
|
249
|
+
|
|
250
|
+
host:process.env.REDIS_HOST,
|
|
251
|
+
password:process.env.REDIS_PASS,
|
|
252
|
+
port:process.env.REDIS_PORT
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
module.exports={redis}
|
|
257
|
+
|
|
258
|
+
`
|
|
259
|
+
|
|
260
|
+
let cleanRedis=redisCode.trim();
|
|
261
|
+
|
|
262
|
+
await fs.writeFile(`${path}/backend/redisFileForConnection/redisConnection.js`,cleanRedis);
|
|
263
|
+
|
|
264
|
+
// env file is made
|
|
265
|
+
let envData=`
|
|
266
|
+
# string
|
|
267
|
+
REDIS_HOST=${envRedis.envHost}
|
|
268
|
+
|
|
269
|
+
#string
|
|
270
|
+
REDIS_PASS=${envRedis.envPass}
|
|
271
|
+
|
|
272
|
+
#number
|
|
273
|
+
REDIS_PORT=${parseInt(envRedis.envPort)}
|
|
274
|
+
`;
|
|
275
|
+
let cleanEnvFile=envData.trim();
|
|
276
|
+
await fs.writeFile(`${path}/backend/.env`,cleanEnvFile);
|
|
277
|
+
console.log("Env file is made succefully");
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
let expressCode=`
|
|
283
|
+
const express=require("express");
|
|
284
|
+
const cors=require("cors");
|
|
285
|
+
const {redis}=require("./redisFileForConnection/redisConnection");
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
const app=express();
|
|
289
|
+
|
|
290
|
+
redis.on("connect",()=>{
|
|
291
|
+
console.log("redis is connected succesfully");
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
app.use(cors());
|
|
295
|
+
|
|
296
|
+
app.get("/",(_,res)=>{
|
|
297
|
+
|
|
298
|
+
res.status(200).json({success:"hello developer"});
|
|
299
|
+
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
303
|
+
|
|
304
|
+
`
|
|
305
|
+
|
|
306
|
+
let clean=expressCode.trim();
|
|
307
|
+
let readFile=await fs.readFile(`${path}/backend/index.js`,"utf8");
|
|
308
|
+
|
|
309
|
+
readFile=readFile=clean;
|
|
310
|
+
|
|
311
|
+
await fs.writeFile(`${path}/backend/index.js`,readFile);
|
|
312
|
+
spinner1.success({text:"redis setup is done enjoy!"});
|
|
313
|
+
|
|
314
|
+
}catch(err){
|
|
315
|
+
console.log("ioredis is not install for some reason");
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
193
319
|
|
|
194
320
|
else{
|
|
195
321
|
if(mongooseInstall=="No"){
|
|
@@ -202,6 +328,10 @@ app.listen(7000,()=> console.log("Server is on and running on port 7000"))
|
|
|
202
328
|
console.log("You do not installed prisma");
|
|
203
329
|
}
|
|
204
330
|
|
|
331
|
+
if(redis=="No"){
|
|
332
|
+
console.log("You do not install redis");
|
|
333
|
+
}
|
|
334
|
+
|
|
205
335
|
else{
|
|
206
336
|
console.log("There is no option like this");
|
|
207
337
|
}
|