nestjs-prisma-cli 1.0.4 → 1.0.5

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 CHANGED
@@ -33,7 +33,8 @@ npm install -g nestjs-prisma-cli
33
33
 
34
34
  ```
35
35
 
36
- ### 2️⃣ Check CLI version
36
+ ### 2️⃣ Check CLI version
37
+
37
38
  ```bash
38
39
 
39
40
  nestgen -v
@@ -43,6 +44,7 @@ nestgen --version
43
44
  ```
44
45
 
45
46
  ### 3️⃣ Generate a new project
47
+
46
48
  ```bash
47
49
 
48
50
  nestgen
@@ -50,8 +52,8 @@ nestgen
50
52
  Step 1 : ? Enter your project name: my-app
51
53
 
52
54
  Step 2 : ? Select your database: (Use arrow keys)
53
- PostgreSQL
54
55
  MySQL
56
+ PostgreSQL
55
57
  SQLite
56
58
  MongoDB
57
59
  CockroachDB
@@ -59,8 +61,9 @@ Step 2 : ? Select your database: (Use arrow keys)
59
61
  Step 3 : 🎉 Project ready! Next steps:
60
62
  cd my-app
61
63
  Check .env
64
+ npx prisma generate
65
+ npx prisma migrate dev --name init
66
+ npx ts-node prisma/seed.ts
62
67
  npm run start:dev
63
- npm run prisma:migrate
64
- npm run seed
65
68
 
66
69
  ```
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env node
2
- const inquirer = require("inquirer");
3
- const chalk = require("chalk");
4
- const fs = require("fs-extra");
5
- const path = require("path");
6
- const { execa } = require("execa");
7
- const { readFileSync } = require("fs");
2
+ import inquirer from "inquirer";
3
+ import chalk from "chalk";
4
+ import fs from "fs-extra";
5
+ import path from "path";
6
+ import { execa } from "execa";
7
+ import { readFileSync } from "fs";
8
+ import { fileURLToPath } from "url";
8
9
 
9
- const packageJson = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf-8"));
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ const packageJson = JSON.parse(
14
+ readFileSync(path.join(__dirname, "../package.json"), "utf-8")
15
+ );
10
16
 
11
17
  if (process.argv.includes("-v") || process.argv.includes("--version")) {
12
18
  console.log(`nestgen ${packageJson.version}`);
@@ -37,8 +43,9 @@ async function main() {
37
43
  console.log(chalk.blue("🚀 Welcome to NestJS + Prisma Project Generator!"));
38
44
 
39
45
  const { projectName } = await inquirer.prompt([
40
- { type: "input", name: "projectName", message: "Enter your project name:" }
46
+ { type: "input", name: "projectName", message: "Enter your project name:" },
41
47
  ]);
48
+
42
49
  const dbSafeName = projectName.replace(/-/g, "_") + "_db";
43
50
  const projectPath = path.join(process.cwd(), projectName);
44
51
 
@@ -52,8 +59,8 @@ async function main() {
52
59
  type: "list",
53
60
  name: "database",
54
61
  message: "Select your database:",
55
- choices: ["MySQL", "PostgreSQL", "SQLite", "MongoDB", "CockroachDB", "SQLServer"]
56
- }
62
+ choices: ["PostgreSQL", "MySQL", "SQLite", "MongoDB", "CockroachDB", "SQLServer"],
63
+ },
57
64
  ]);
58
65
 
59
66
  console.log(chalk.green(`📦 Creating NestJS project "${projectName}"...`));
@@ -73,7 +80,7 @@ async function main() {
73
80
  "@nestjs/passport",
74
81
  "@aws-sdk/client-s3",
75
82
  "@aws-sdk/s3-request-presigner",
76
- "moment"
83
+ "moment",
77
84
  ];
78
85
  await execa(pkgManager, ["install", ...coreDeps], { cwd: projectPath, stdio: "inherit" });
79
86
  console.log(chalk.green("✅ Core dependencies installed!"));
@@ -82,7 +89,7 @@ async function main() {
82
89
  await execa(pkgManager, ["install", "-D", "prisma"], { cwd: projectPath, stdio: "inherit" });
83
90
  console.log(chalk.green("✅ Prisma and @prisma/client installed!"));
84
91
 
85
- const templatePath = path.resolve(__dirname, "./template");
92
+ const templatePath = path.resolve("./template");
86
93
  const projectPrismaPath = path.join(projectPath, "prisma/schema.prisma");
87
94
 
88
95
  const providerMap = {
@@ -91,7 +98,7 @@ async function main() {
91
98
  sqlite: "sqlite",
92
99
  mongodb: "mongodb",
93
100
  cockroachdb: "postgresql",
94
- sqlserver: "sqlserver"
101
+ sqlserver: "sqlserver",
95
102
  };
96
103
  const selectedProvider = providerMap[database.toLowerCase()] || "mysql";
97
104
 
@@ -140,7 +147,7 @@ model User {
140
147
  sqlite: `file:./dev.db`,
141
148
  mongodb: `mongodb://localhost:27017/${dbSafeName}`,
142
149
  cockroachdb: `postgresql://root:password@localhost:26257/${dbSafeName}?sslmode=disable`,
143
- sqlserver: `sqlserver://localhost:1433;database=${dbSafeName};user=sa;password=your_password;encrypt=false`
150
+ sqlserver: `sqlserver://localhost:1433;database=${dbSafeName};user=sa;password=your_password;encrypt=false`,
144
151
  };
145
152
 
146
153
  const envContent = `DATABASE_URL="${defaultUrlMap[database.toLowerCase()]}"
@@ -161,29 +168,24 @@ PORT=3000
161
168
  `;
162
169
 
163
170
  await fs.outputFile(path.join(projectPath, ".env"), envContent);
164
- console.log(chalk.yellow("🎉 Project ready! Next steps:"));
165
- console.log(chalk.cyan(`cd ${projectName}`));
166
-
167
- console.log(chalk.green("✅ .env created! Please update DATABASE_URL if necessary before running seed."));
168
-
169
- console.log(chalk.green("📦 Prisma installed!"));
170
171
 
172
+ console.log(chalk.yellow("🎉 Project ready!"));
173
+ console.log(chalk.green("✅ .env created! Please update DATABASE_URL if necessary before running Prisma commands."));
174
+ console.log(chalk.cyan(`cd ${projectName}`));
171
175
  console.log(chalk.yellow("🔧 Next steps (run manually):"));
172
176
  console.log(chalk.cyan(`1. Generate Prisma Client:`));
173
177
  console.log(chalk.cyan(` npx prisma generate`));
174
-
175
178
  console.log(chalk.cyan(`2. Apply Prisma Migrations:`));
176
179
  console.log(chalk.cyan(` npx prisma migrate dev --name init`));
177
-
178
180
  console.log(chalk.cyan(`3. Run Seed Script:`));
179
181
  console.log(chalk.cyan(` npx ts-node prisma/seed.ts`));
180
182
 
181
183
  console.log(chalk.yellow("⚠️ Make sure your .env DATABASE_URL is correct before running the above commands!"));
182
-
184
+ console.log(chalk.cyan(`\nStart the development server:`));
183
185
  console.log(chalk.cyan(`${pkgManager} run start:dev`));
184
186
  }
185
187
 
186
- main().catch(err => {
188
+ main().catch((err) => {
187
189
  console.error(chalk.red("❌ Error:"), err);
188
190
  process.exit(1);
189
191
  });
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "nestjs-prisma-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A CLI to generate NestJS + Prisma project boilerplate with Swagger, Auth, and AWS S3 setup",
5
- "main": "bin/index.js",
6
5
  "type": "module",
6
+ "main": "bin/index.js",
7
7
  "files": [
8
8
  "bin/",
9
9
  "template/"
10
10
  ],
11
11
  "bin": {
12
- "nestgen": "./bin/index.cjs"
12
+ "nestgen": "./bin/index.js"
13
13
  },
14
14
  "scripts": {
15
15
  "start": "node ./bin/index.js",
@@ -28,8 +28,7 @@
28
28
  "chalk": "^4.1.2",
29
29
  "execa": "^9.6.0",
30
30
  "fs-extra": "^11.3.1",
31
- "inquirer": "^8.2.7",
32
- "path": "^0.12.7"
31
+ "inquirer": "^9.2.7"
33
32
  },
34
33
  "engines": {
35
34
  "node": ">=18"