jru-express 1.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/index.js ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { execSync } = require("child_process");
6
+ const { Command } = require("commander");
7
+
8
+ const program = new Command();
9
+
10
+ program
11
+ .name("jru-express")
12
+ .description("Generate a basic Express.js backend")
13
+ .argument("<project-name>", "Name of the project")
14
+ .action((projectName) => {
15
+
16
+ const projectPath = path.join(process.cwd(), projectName);
17
+ const templatePath = path.join(__dirname, "templates");
18
+
19
+ // Check if project already exists
20
+ if (fs.existsSync(projectPath)) {
21
+ console.error(`Project "${projectName}" already exists.`);
22
+ process.exit(1);
23
+ }
24
+
25
+ console.log("\nCreating JruExpress project...\n");
26
+
27
+ // Create project directory
28
+ fs.mkdirSync(projectPath, { recursive: true });
29
+
30
+ // Copy template structure
31
+ fs.cpSync(templatePath, projectPath, {
32
+ recursive: true
33
+ });
34
+
35
+ console.log("✔ Folder structure created");
36
+
37
+ // Move into project directory
38
+ process.chdir(projectPath);
39
+
40
+ // Initialize npm
41
+ console.log("✔ Initializing npm...");
42
+ execSync("npm init -y", { stdio: "inherit" });
43
+
44
+ // Install Express
45
+ console.log("\n✔ Installing Express...");
46
+ execSync("npm install express", { stdio: "inherit" });
47
+
48
+ // Install Nodemon
49
+ console.log("\n✔ Installing Nodemon...");
50
+ execSync("npm install --save-dev nodemon", {
51
+ stdio: "inherit"
52
+ });
53
+
54
+ // Update package.json scripts
55
+ const packageJsonPath = path.join(projectPath, "package.json");
56
+
57
+ const packageJson = JSON.parse(
58
+ fs.readFileSync(packageJsonPath, "utf8")
59
+ );
60
+
61
+ packageJson.scripts = {
62
+ start: "node server.js",
63
+ dev: "nodemon server.js"
64
+ };
65
+
66
+ fs.writeFileSync(
67
+ packageJsonPath,
68
+ JSON.stringify(packageJson, null, 2)
69
+ );
70
+
71
+ console.log("\n✔ Scripts configured");
72
+
73
+ console.log(`
74
+ ╔══════════════════════════════════════╗
75
+ ║ JruExpress Project Ready ║
76
+ ╚══════════════════════════════════════╝
77
+
78
+ Project: ${projectName}
79
+
80
+ Run:
81
+
82
+ cd ${projectName}
83
+
84
+ Development:
85
+ npm run dev
86
+
87
+ Production:
88
+ npm start
89
+
90
+ `);
91
+ });
92
+
93
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "jru-express",
3
+ "version": "1.0.0",
4
+ "description": "My basic Express backend generator",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "jru-express": "index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"No tests yet\""
11
+ },
12
+ "keywords": [
13
+ "express",
14
+ "backend",
15
+ "generator",
16
+ "scaffold"
17
+ ],
18
+ "author": "The Great RAR",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "commander": "^14.0.0"
22
+ }
23
+ }
@@ -0,0 +1,11 @@
1
+ # JruExpress Backend
2
+
3
+ Backend generated using JruExpress.
4
+
5
+ ## Install
6
+
7
+ npm install
8
+
9
+ ## Run
10
+
11
+ node server.js
@@ -0,0 +1,7 @@
1
+ const app = require("./src/app");
2
+
3
+ const PORT = process.env.PORT || 3000;
4
+
5
+ app.listen(PORT, () => {
6
+ console.log(`Server running on port https://localhost:${PORT}`);
7
+ });
@@ -0,0 +1,13 @@
1
+ const express = require("express");
2
+
3
+ const app = express();
4
+
5
+ app.use(express.json());
6
+
7
+ app.get("/", (req, res) => {
8
+ res.json({
9
+ message: "JruExpress API is running"
10
+ });
11
+ });
12
+
13
+ module.exports = app;
File without changes
File without changes