create-enterprise-backend 0.1.0 → 0.1.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 ADDED
@@ -0,0 +1,89 @@
1
+ # Create Enterprise Backend
2
+
3
+ A CLI tool for scaffolding enterprise-ready backend applications with Express or Fastify, integrated with MongoDB or Supabase.
4
+
5
+ ## Features
6
+
7
+ - **Frameworks**: Choose between Express.js or Fastify
8
+ - **Databases**: Support for MongoDB or Supabase
9
+ - **Authentication**: Pre-configured JWT authentication modules
10
+ - **Middleware**: Built-in error handling, database guards, and JWT guards
11
+ - **Project Structure**: Organized modular architecture for scalability
12
+
13
+ ## Installation
14
+
15
+ Install globally using npm:
16
+
17
+ ```bash
18
+ npm install -g create-enterprise-backend
19
+ ```
20
+
21
+ Or use with npx without installing:
22
+
23
+ ```bash
24
+ npx create-enterprise-backend
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Run the CLI and follow the interactive prompts:
30
+
31
+ ```bash
32
+ create-enterprise-backend [project-name]
33
+ ```
34
+
35
+ ### Options
36
+
37
+ - **Project Name**: Optional. If not provided, you'll be prompted to enter it.
38
+ - **Framework**: Select Express or Fastify
39
+ - **Database**: Choose MongoDB or Supabase
40
+ - **Install Dependencies**: Option to install npm packages immediately
41
+
42
+ ### Example
43
+
44
+ ```bash
45
+ npx create-enterprise-backend my-backend-app
46
+ ```
47
+
48
+ This will create a new directory `my-backend-app` with the scaffolded backend.
49
+
50
+ ## Project Structure
51
+
52
+ The generated project includes:
53
+
54
+ - **src/app.js**: Main application setup
55
+ - **src/server.js**: Server initialization
56
+ - **src/routes.js**: Route definitions
57
+ - **src/config/**: Configuration files (database, environment)
58
+ - **src/middlewares/**: Custom middleware (guards, error handling)
59
+ - **src/modules/**: Modular components (e.g., auth module)
60
+ - **src/services/**: Business logic services
61
+ - **src/utils/**: Utility functions
62
+
63
+ ## Getting Started
64
+
65
+ After generating the project:
66
+
67
+ 1. Navigate to the project directory:
68
+ ```bash
69
+ cd my-backend-app
70
+ ```
71
+
72
+ 2. Start the development server:
73
+ ```bash
74
+ npm run dev
75
+ ```
76
+
77
+ 3. The server will run on the configured port (check `src/config/env.js`).
78
+
79
+ ## Requirements
80
+
81
+ - Node.js >= 18
82
+
83
+ ## Contributing
84
+
85
+ Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/ImaadDev/create-enterprise-backend).
86
+
87
+ ## License
88
+
89
+ MIT# create-enterprise-backend
package/core/run.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import path from "path";
2
- import fs from "fs";
3
2
  import prompts from "prompts";
4
3
  import chalk from "chalk";
5
4
  import { generateProject } from "./scaffold.js";
@@ -34,7 +33,7 @@ export async function run() {
34
33
  message: "Select database",
35
34
  choices: [
36
35
  { title: "MongoDB", value: "mongo" },
37
- { title: "Supabase", value: "supabase" },
36
+ { title: "Supabase", value: "supabase" }
38
37
  ]
39
38
  },
40
39
  {
@@ -57,25 +56,13 @@ export async function run() {
57
56
  const projectName = (projectNameArg || answers.projectName).trim();
58
57
  const { framework, database } = answers;
59
58
 
60
- const templatePath = path.resolve(
61
- "templates",
62
- framework,
63
- database
64
- );
65
-
66
- // ✅ Validate template exists
67
- if (!fs.existsSync(templatePath)) {
68
- console.log(
69
- chalk.red(
70
- `\n❌ Template not found for: ${framework} + ${database}\n`
71
- )
72
- );
73
- process.exit(1);
74
- }
75
-
76
- const targetDir = path.join(process.cwd(), projectName);
59
+ const targetDir =
60
+ projectName === "." || projectName === "./"
61
+ ? process.cwd()
62
+ : path.join(process.cwd(), projectName);
77
63
 
78
64
  console.log(chalk.gray("\n📦 Generating project..."));
65
+
79
66
  await generateProject({
80
67
  framework,
81
68
  database,
@@ -89,7 +76,10 @@ export async function run() {
89
76
  }
90
77
 
91
78
  console.log(chalk.green.bold("\n✅ Done!\n"));
92
- console.log(
93
- `Next steps:\n cd ${projectName}\n npm run dev\n`
94
- );
79
+
80
+ if (projectName !== "." && projectName !== "./") {
81
+ console.log(`Next steps:\n cd ${projectName}\n npm run dev\n`);
82
+ } else {
83
+ console.log(`Next steps:\n npm run dev\n`);
84
+ }
95
85
  }
package/core/scaffold.js CHANGED
@@ -7,29 +7,47 @@ function getPackageRoot() {
7
7
  return path.resolve(path.dirname(__filename), "..");
8
8
  }
9
9
 
10
- export async function generateProject({ framework, database, targetDir, projectName }) {
10
+ const DB_MAP = {
11
+ mongo: "mongo",
12
+ supabase: "supabase"
13
+ };
14
+
15
+ export async function generateProject({
16
+ framework,
17
+ database,
18
+ targetDir,
19
+ projectName
20
+ }) {
11
21
  const root = getPackageRoot();
12
22
 
13
- const templateDir = path.join(root, "templates", framework, database);
23
+ const dbFolder = DB_MAP[database];
24
+ if (!dbFolder) {
25
+ throw new Error(`Unsupported database: ${database}`);
26
+ }
27
+
28
+ const templateDir = path.join(root, "templates", framework, dbFolder);
14
29
 
15
- const exists = await fs.pathExists(templateDir);
16
- if (!exists) {
17
- throw new Error(`Template not found: ${framework}/${database}`);
30
+ if (!(await fs.pathExists(templateDir))) {
31
+ throw new Error(`Template not found: ${framework}/${dbFolder}`);
18
32
  }
19
33
 
20
- if (await fs.pathExists(targetDir)) {
34
+ const isCurrentDir =
35
+ projectName === "." || projectName === "./";
36
+
37
+ if (!isCurrentDir && (await fs.pathExists(targetDir))) {
21
38
  throw new Error(`Target folder already exists: ${projectName}`);
22
39
  }
23
40
 
24
41
  await fs.ensureDir(targetDir);
42
+
25
43
  await fs.copy(templateDir, targetDir, {
26
44
  overwrite: false,
27
45
  errorOnExist: true
28
46
  });
29
47
 
30
- // Rename package name inside generated package.json (if template has one)
48
+ // Rename package.json only when not using "."
31
49
  const pkgPath = path.join(targetDir, "package.json");
32
- if (await fs.pathExists(pkgPath)) {
50
+ if (!isCurrentDir && (await fs.pathExists(pkgPath))) {
33
51
  const pkg = await fs.readJson(pkgPath);
34
52
  pkg.name = projectName;
35
53
  await fs.writeJson(pkgPath, pkg, { spaces: 2 });
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "create-enterprise-backend",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Enterprise backend scaffolder (Express/Fastify + Mongo/Supabase)",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-enterprise-backend": "./bin/cli.js"
8
8
  },
9
- "files": ["bin", "core", "templates", "README.md"],
9
+ "files": [
10
+ "bin",
11
+ "core",
12
+ "templates",
13
+ "README.md"
14
+ ],
10
15
  "keywords": [
11
16
  "cli",
12
17
  "scaffold",
@@ -24,5 +29,13 @@
24
29
  "chalk": "^5.3.0",
25
30
  "fs-extra": "^11.2.0",
26
31
  "prompts": "^2.4.2"
27
- }
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/ImaadDev/create-enterprise-backend"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/ImaadDev/create-enterprise-backend/issues"
39
+ },
40
+ "homepage": "https://github.com/ImaadDev/create-enterprise-backend#README"
28
41
  }