neatnode 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/bin/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import("../src/cli.js");
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "neatnode",
3
+ "version": "1.0.0",
4
+ "description": "Plug & Play Node.js backend starter template",
5
+ "bin": {
6
+ "neatnode": "./bin/index.js"
7
+ },
8
+ "keywords": [
9
+ "nodejs",
10
+ "express",
11
+ "mongodb",
12
+ "rest api"
13
+ ],
14
+ "author": "Aakash Gupta",
15
+ "license": "ISC",
16
+ "type": "module",
17
+ "dependencies": {
18
+ "fs-extra": "^11.3.2",
19
+ "inquirer": "^12.10.0"
20
+ }
21
+ }
@@ -0,0 +1,32 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { copyTemplate } from "../utils/copyTemplate.js";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ export async function createProject({ projectName, templatePath }) {
10
+ try {
11
+ const targetPath = path.join(process.cwd(), projectName);
12
+
13
+ // Prevent overwriting existing folder
14
+ if (fs.existsSync(targetPath)) {
15
+ console.error(`❌ Folder "${projectName}" already exists.`);
16
+ process.exit(1);
17
+ }
18
+
19
+ // Copy template
20
+ console.log("📁 Creating project folder...");
21
+ fs.mkdirSync(targetPath);
22
+ await copyTemplate(templatePath, targetPath);
23
+
24
+ console.log(`✅ Project "${projectName}" created successfully!`);
25
+ console.log(`\ncd ${projectName}`);
26
+ console.log("npm install");
27
+ console.log("npm run dev (or npm start)\n");
28
+ } catch (err) {
29
+ console.error("Failed to create project:", err);
30
+ process.exit(1);
31
+ }
32
+ }
package/src/cli.js ADDED
@@ -0,0 +1,34 @@
1
+ import inquirer from "inquirer";
2
+ import { createProject } from "./actions/createProject.js";
3
+ import templates from "./config/templates.js";
4
+
5
+ async function main() {
6
+ console.log("Welcome to NodeNeat CLI!");
7
+
8
+ const { projectName } = await inquirer.prompt([
9
+ {
10
+ name: "projectName",
11
+ type: "input",
12
+ message: "Enter your project folder name:",
13
+ default: "my-app"
14
+ }
15
+ ]);
16
+
17
+
18
+ const { template } = await inquirer.prompt([
19
+ {
20
+ name: "template",
21
+ type: "list",
22
+ message: "Choose a template:",
23
+ choices: templates.map(t => t.name)
24
+ }
25
+ ]);
26
+
27
+ const chosen = templates.find(t => t.name === template);
28
+ await createProject({
29
+ projectName,
30
+ templatePath: chosen.path
31
+ });
32
+ }
33
+
34
+ main();
@@ -0,0 +1,20 @@
1
+ import path from "path";
2
+ import { fileURLToPath } from "url";
3
+
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+
7
+ export default [
8
+ {
9
+ name: "Basic Express",
10
+ path: path.join(__dirname, "../../templates/express-basic")
11
+ },
12
+ {
13
+ name: "REST API",
14
+ path: path.join(__dirname, "../../templates/express-rest-api")
15
+ },
16
+ {
17
+ name: "Socket.IO Setup",
18
+ path: path.join(__dirname, "../../templates/express-socket")
19
+ }
20
+ ];
@@ -0,0 +1,31 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ export async function copyTemplate(srcDir, destDir) {
5
+
6
+ const ignoreList = ["node_modules", ".git", ".env"];
7
+
8
+ // make sure destination exists
9
+ if (!fs.existsSync(destDir)) {
10
+ fs.mkdirSync(destDir, { recursive: true });
11
+ }
12
+
13
+ // read all files/folders in template
14
+ const items = fs.readdirSync(srcDir, { withFileTypes: true });
15
+
16
+ for (const item of items) {
17
+ // skip ignored ones
18
+ if (ignoreList.includes(item.name)) continue;
19
+
20
+ const srcPath = path.join(srcDir, item.name);
21
+ const destPath = path.join(destDir, item.name);
22
+
23
+ if (item.isDirectory()) {
24
+ // recurse for folders
25
+ await copyTemplate(srcPath, destPath);
26
+ } else {
27
+ // copy individual files
28
+ fs.copyFileSync(srcPath, destPath);
29
+ }
30
+ }
31
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ import express from "express";
2
+ const app = express();
3
+
4
+ app.get("/", (req, res) => res.send("🚀 Express Basic Template Ready!"));
5
+ app.listen(3000, () => console.log("Server running on port 3000"));
@@ -0,0 +1,5 @@
1
+ import express from "express";
2
+ const app = express();
3
+
4
+ app.get("/", (req, res) => res.send("🚀 Express express-rest-api Template Ready!"));
5
+ app.listen(3000, () => console.log("Server running on port 3000"));
@@ -0,0 +1,5 @@
1
+ import express from "express";
2
+ const app = express();
3
+
4
+ app.get("/", (req, res) => res.send("🚀 Express Socket.IO Template Ready!"));
5
+ app.listen(3000, () => console.log("Server running on port 3000"));