nestjs-prisma-cli 1.0.5 → 1.0.6

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.
Files changed (50) hide show
  1. package/bin/index.js +49 -19
  2. package/package.json +1 -1
  3. package/template/Dockerfile +30 -0
  4. /package/{bin/template → template}/.github/workflows/deploy-to-ecr.yml +0 -0
  5. /package/{bin/template → template}/prisma/schema.prisma +0 -0
  6. /package/{bin/template → template}/prisma/seed.ts +0 -0
  7. /package/{bin/template → template}/src/app.controller.spec.ts +0 -0
  8. /package/{bin/template → template}/src/app.controller.ts +0 -0
  9. /package/{bin/template → template}/src/app.module.ts +0 -0
  10. /package/{bin/template → template}/src/app.service.ts +0 -0
  11. /package/{bin/template → template}/src/common/classes/base64.ts +0 -0
  12. /package/{bin/template → template}/src/common/decorator/public.decorator.ts +0 -0
  13. /package/{bin/template → template}/src/common/dto/index.ts +0 -0
  14. /package/{bin/template → template}/src/common/dto/paginated-response.dto.ts +0 -0
  15. /package/{bin/template → template}/src/common/dto/pagination.dto.ts +0 -0
  16. /package/{bin/template → template}/src/common/enums/db-error-code.enum.ts +0 -0
  17. /package/{bin/template → template}/src/common/enums/index.ts +0 -0
  18. /package/{bin/template → template}/src/common/enums/message-code.enum.ts +0 -0
  19. /package/{bin/template → template}/src/common/http-interceptor/http-error-type.ts +0 -0
  20. /package/{bin/template → template}/src/common/http-interceptor/http-exception.filter.ts +0 -0
  21. /package/{bin/template → template}/src/common/http-interceptor/index.ts +0 -0
  22. /package/{bin/template → template}/src/common/http-interceptor/logging.interceptor.ts +0 -0
  23. /package/{bin/template → template}/src/common/http-interceptor/response.interceptor.ts +0 -0
  24. /package/{bin/template → template}/src/common/logger/winston.logger.ts +0 -0
  25. /package/{bin/template → template}/src/common/s3/s3.module.ts +0 -0
  26. /package/{bin/template → template}/src/common/s3/s3.service.spec.ts +0 -0
  27. /package/{bin/template → template}/src/common/s3/s3.service.ts +0 -0
  28. /package/{bin/template → template}/src/common/utils/pagination.util.ts +0 -0
  29. /package/{bin/template → template}/src/main.ts +0 -0
  30. /package/{bin/template → template}/src/modules/auth/auth.controller.spec.ts +0 -0
  31. /package/{bin/template → template}/src/modules/auth/auth.controller.ts +0 -0
  32. /package/{bin/template → template}/src/modules/auth/auth.module.ts +0 -0
  33. /package/{bin/template → template}/src/modules/auth/auth.service.spec.ts +0 -0
  34. /package/{bin/template → template}/src/modules/auth/auth.service.ts +0 -0
  35. /package/{bin/template → template}/src/modules/auth/dto/login.dto.ts +0 -0
  36. /package/{bin/template → template}/src/modules/auth/jwt/jwt.guard.spec.ts +0 -0
  37. /package/{bin/template → template}/src/modules/auth/jwt/jwt.guard.ts +0 -0
  38. /package/{bin/template → template}/src/modules/auth/jwt/jwt.strategy.ts +0 -0
  39. /package/{bin/template → template}/src/modules/user/dto/create-user.dto.ts +0 -0
  40. /package/{bin/template → template}/src/modules/user/dto/update-user.dto.ts +0 -0
  41. /package/{bin/template → template}/src/modules/user/user.controller.spec.ts +0 -0
  42. /package/{bin/template → template}/src/modules/user/user.controller.ts +0 -0
  43. /package/{bin/template → template}/src/modules/user/user.module.ts +0 -0
  44. /package/{bin/template → template}/src/modules/user/user.service.spec.ts +0 -0
  45. /package/{bin/template → template}/src/modules/user/user.service.ts +0 -0
  46. /package/{bin/template → template}/src/prisma/prisma.module.ts +0 -0
  47. /package/{bin/template → template}/src/prisma/prisma.service.spec.ts +0 -0
  48. /package/{bin/template → template}/src/prisma/prisma.service.ts +0 -0
  49. /package/{bin/template → template}/test/app.e2e-spec.ts +0 -0
  50. /package/{bin/template → template}/test/jest-e2e.json +0 -0
package/bin/index.js CHANGED
@@ -4,8 +4,8 @@ import chalk from "chalk";
4
4
  import fs from "fs-extra";
5
5
  import path from "path";
6
6
  import { execa } from "execa";
7
- import { readFileSync } from "fs";
8
- import { fileURLToPath } from "url";
7
+ import { readFileSync } from "fs";
8
+ import { fileURLToPath } from "url";
9
9
 
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = path.dirname(__filename);
@@ -64,9 +64,12 @@ async function main() {
64
64
  ]);
65
65
 
66
66
  console.log(chalk.green(`📦 Creating NestJS project "${projectName}"...`));
67
- await execa("npx", ["@nestjs/cli", "new", projectName, "--skip-install"], { stdio: "inherit" });
67
+ await execa("npx", ["@nestjs/cli", "new", projectName, "--skip-install"], {
68
+ stdio: "inherit",
69
+ });
68
70
 
69
71
  const pkgManager = detectPackageManager();
72
+
70
73
  const coreDeps = [
71
74
  "argon2",
72
75
  "@nestjs/config",
@@ -83,15 +86,46 @@ async function main() {
83
86
  "moment",
84
87
  ];
85
88
  await execa(pkgManager, ["install", ...coreDeps], { cwd: projectPath, stdio: "inherit" });
86
- console.log(chalk.green("✅ Core dependencies installed!"));
87
89
 
88
90
  await execa(pkgManager, ["install", "@prisma/client"], { cwd: projectPath, stdio: "inherit" });
89
91
  await execa(pkgManager, ["install", "-D", "prisma"], { cwd: projectPath, stdio: "inherit" });
90
- console.log(chalk.green("✅ Prisma and @prisma/client installed!"));
91
92
 
92
- const templatePath = path.resolve("./template");
93
+ console.log(chalk.green("✅ Dependencies installed!"));
94
+
95
+ const templatePath = path.resolve(__dirname, "../template");
93
96
  const projectPrismaPath = path.join(projectPath, "prisma/schema.prisma");
94
97
 
98
+ const extraItems = [
99
+ { src: path.resolve(__dirname, "../.github"), dest: path.join(projectPath, ".github") },
100
+ { src: path.resolve(__dirname, "../Dockerfile"), dest: path.join(projectPath, "Dockerfile") },
101
+ ];
102
+
103
+ async function safeCopy(src, dest, label) {
104
+ try {
105
+ if (await fs.pathExists(src)) {
106
+ await fs.copy(src, dest, { overwrite: true });
107
+ console.log(chalk.green(`✅ ${label} copied!`));
108
+ } else {
109
+ console.log(chalk.yellow(`⚠️ ${label} not found, skipped.`));
110
+ }
111
+ } catch (err) {
112
+ console.log(chalk.red(`❌ Failed to copy ${label}:`), err.message);
113
+ }
114
+ }
115
+
116
+ for (const item of extraItems) {
117
+ const label = path.basename(item.dest);
118
+ await safeCopy(item.src, item.dest, label);
119
+ }
120
+
121
+ if (await fs.pathExists(templatePath)) {
122
+ console.log(chalk.blue("📄 Copying template files..."));
123
+ await fs.copy(templatePath, projectPath, { overwrite: true });
124
+ console.log(chalk.green("✅ Template files copied!"));
125
+ } else {
126
+ console.log(chalk.yellow("⚠️ Template folder not found. Skipping copy."));
127
+ }
128
+
95
129
  const providerMap = {
96
130
  postgresql: "postgresql",
97
131
  mysql: "mysql",
@@ -103,19 +137,14 @@ async function main() {
103
137
  const selectedProvider = providerMap[database.toLowerCase()] || "mysql";
104
138
 
105
139
  let prismaContent = "";
106
- if (fs.existsSync(templatePath)) {
107
- await fs.copy(templatePath, projectPath, { overwrite: true });
108
- const templatePrismaPath = path.join(templatePath, "prisma/schema.prisma");
109
- if (fs.existsSync(templatePrismaPath)) {
110
- prismaContent = await fs.readFile(templatePrismaPath, "utf-8");
111
- prismaContent = prismaContent.replace(
112
- /datasource\s+db\s*{[^}]*provider\s*=\s*".*"/,
113
- `datasource db {\n provider = "${selectedProvider}"`
114
- );
115
- }
116
- }
117
-
118
- if (!prismaContent) {
140
+ const templatePrismaPath = path.join(templatePath, "prisma/schema.prisma");
141
+ if (fs.existsSync(templatePrismaPath)) {
142
+ prismaContent = await fs.readFile(templatePrismaPath, "utf-8");
143
+ prismaContent = prismaContent.replace(
144
+ /datasource\s+db\s*{[^}]*provider\s*=\s*".*"/,
145
+ `datasource db {\n provider = "${selectedProvider}"`
146
+ );
147
+ } else {
119
148
  prismaContent = `generator client {
120
149
  provider = "prisma-client-js"
121
150
  }
@@ -172,6 +201,7 @@ PORT=3000
172
201
  console.log(chalk.yellow("🎉 Project ready!"));
173
202
  console.log(chalk.green("✅ .env created! Please update DATABASE_URL if necessary before running Prisma commands."));
174
203
  console.log(chalk.cyan(`cd ${projectName}`));
204
+
175
205
  console.log(chalk.yellow("🔧 Next steps (run manually):"));
176
206
  console.log(chalk.cyan(`1. Generate Prisma Client:`));
177
207
  console.log(chalk.cyan(` npx prisma generate`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-prisma-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A CLI to generate NestJS + Prisma project boilerplate with Swagger, Auth, and AWS S3 setup",
5
5
  "type": "module",
6
6
  "main": "bin/index.js",
@@ -0,0 +1,30 @@
1
+ # Use an official Node.js runtime as the base image
2
+ FROM node:22-alpine
3
+
4
+ # Set the working directory inside the container
5
+ WORKDIR /app
6
+
7
+ # Copy Prisma schema first (needed for prisma generate)
8
+ COPY prisma ./prisma/
9
+
10
+ # Copy package.json and package-lock.json
11
+ COPY package*.json ./
12
+
13
+ # Install dependencies (this will trigger prisma generate)
14
+ RUN npm install
15
+
16
+ # Manually run prisma generate again (optional but safe)
17
+ RUN npx prisma generate
18
+
19
+ # Copy the rest of the app
20
+ COPY src ./src/
21
+ COPY tsconfig*.json ./
22
+
23
+ # Build the app
24
+ RUN npm run build
25
+
26
+ # Expose the app port
27
+ EXPOSE 8080
28
+
29
+ # Run Prisma migration and start server
30
+ CMD ["sh", "-c", "npx prisma migrate deploy && node dist/src/main.js"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes