@kuldi/create-nestjs 1.1.1 โ†’ 1.1.3

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
@@ -1,27 +1,39 @@
1
- # @kuldi/create-nestjs
1
+ <div align="center">
2
+ <h1>๐Ÿš€ @kuldi/create-nestjs</h1>
3
+ <p>The official, interactive, and lightning-fast scaffolding tool for <b>Kuli Digital's NestJS Boilerplate</b>.</p>
4
+ </div>
2
5
 
3
- The official interactive scaffolding tool for Kuli Digital's NestJS Boilerplate.
6
+ ---
4
7
 
5
- ## Quick Start
8
+ ## โœจ Features
6
9
 
7
- To generate a new NestJS project using this boilerplate, simply run:
10
+ - **โšก๏ธ Instant Setup**: Scaffold a production-ready NestJS architecture in seconds.
11
+ - **๐Ÿ›  Interactive Prompts**: Easily configure your project name, database name, and package manager.
12
+ - **๐Ÿ” Auto-Configured Environment**: Automatically generates a tailored `.env` file for your database credentials.
13
+ - **๐Ÿ— Production Ready**: Comes pre-configured with Prisma ORM, Swagger Documentation, JWT Auth, and RBAC (Role-Based Access Control) out of the box.
14
+
15
+ ## ๐Ÿš€ Quick Start
16
+
17
+ To generate a new NestJS project, use the `@latest` tag to ensure you get the most recent version of the boilerplate:
8
18
 
9
19
  ```bash
10
- npm create @kuldi/nestjs my-app
20
+ npm create @kuldi/nestjs@latest my-app
11
21
  ```
12
22
 
13
- Or, to create it in the current directory:
23
+ Or, to create the project in your **current directory**:
14
24
 
15
25
  ```bash
16
- npm create @kuldi/nestjs .
26
+ npm create @kuldi/nestjs@latest .
17
27
  ```
18
28
 
19
- ## Features
29
+ ### Note on Global Installations (Optional)
30
+ If you prefer installing the package globally, you can do so, but using `npm create` (or `npx`) is highly recommended to always fetch the latest updates.
20
31
 
21
- - **Interactive Prompts**: Easily configure your project name and database name.
22
- - **Auto-Configured Environment**: Automatically generates a `.env` file tailored to your database credentials.
23
- - **Production Ready**: Scaffolds a full-fledged NestJS architecture with Prisma, Swagger, and JWT Auth out of the box.
32
+ ```bash
33
+ npm install -g @kuldi/create-nestjs
34
+ create-nestjs my-app
35
+ ```
24
36
 
25
- ## License
37
+ ## ๐Ÿ“„ License
26
38
 
27
- MIT - Kuli Digital
39
+ MIT ยฉ Kuli Digital
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@kuldi/create-nestjs",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "description": "Scaffolding tool for Kuli Digital NestJS Boilerplate",
6
6
  "main": "src/cli.js",
7
7
  "bin": {
8
- "create-nestjs": "./src/cli.js"
8
+ "create-nestjs": "src/cli.js"
9
9
  },
10
10
  "files": [
11
11
  "src",
package/src/cli.js CHANGED
@@ -24,20 +24,20 @@ async function run() {
24
24
  {
25
25
  type: 'input',
26
26
  name: 'projectName',
27
- message: 'Nama Project (atau . untuk folder saat ini):',
27
+ message: 'Project Name (or . for current directory):',
28
28
  default: argProjectName || 'my-nestjs-app',
29
29
  when: !argProjectName,
30
30
  },
31
31
  {
32
32
  type: 'input',
33
33
  name: 'database',
34
- message: 'Nama Database PostgreSQL:',
34
+ message: 'PostgreSQL Database Name:',
35
35
  default: 'kulidigital_db',
36
36
  },
37
37
  {
38
38
  type: 'confirm',
39
39
  name: 'skipInstall',
40
- message: 'Lewati instalasi package (npm install)?',
40
+ message: 'Skip package installation (npm install)?',
41
41
  default: false,
42
42
  },
43
43
  ]);
@@ -49,37 +49,37 @@ async function run() {
49
49
  if (projectName === '.') {
50
50
  const files = fs.readdirSync(currentPath).filter(f => !f.startsWith('.git'));
51
51
  if (files.length > 0) {
52
- console.log(chalk.red('\nโŒ Folder saat ini tidak kosong! Harap jalankan di folder kosong.\n'));
52
+ console.log(chalk.red('\nโŒ Current directory is not empty! Please run in an empty directory.\n'));
53
53
  process.exit(1);
54
54
  }
55
55
  }
56
56
 
57
57
  // 2. Salin Template
58
- const copySpinner = ora('Membuat struktur project...').start();
58
+ const copySpinner = ora('Generating project structure...').start();
59
59
  try {
60
60
  const templateDir = path.join(__dirname, '../template');
61
61
 
62
- // Copy seluruh isi folder template ke project tujuan
62
+ // Copy template contents to the target project directory
63
63
  fs.cpSync(templateDir, projectPath, { recursive: true });
64
64
 
65
- // Rename gitignore menjadi .gitignore (krn NPM mengabaikan .gitignore saat publish)
65
+ // Rename gitignore to .gitignore (NPM ignores .gitignore during publish)
66
66
  const gitignorePath = path.join(projectPath, 'gitignore');
67
67
  if (fs.existsSync(gitignorePath)) {
68
68
  fs.renameSync(gitignorePath, path.join(projectPath, '.gitignore'));
69
69
  }
70
70
 
71
- copySpinner.succeed('Struktur project berhasil dibuat.');
71
+ copySpinner.succeed('Project structure generated successfully.');
72
72
  } catch (error) {
73
- copySpinner.fail('Gagal menyalin struktur template.');
73
+ copySpinner.fail('Failed to generate project structure.');
74
74
  console.error(error.message);
75
75
  process.exit(1);
76
76
  }
77
77
 
78
- // Masuk ke folder project
78
+ // Navigate to project directory
79
79
  process.chdir(projectPath);
80
80
 
81
81
  // 3. Setup .env
82
- const envSpinner = ora('Menyiapkan file .env...').start();
82
+ const envSpinner = ora('Configuring environment variables...').start();
83
83
  try {
84
84
  const envExamplePath = path.join(projectPath, '.env.example');
85
85
  const envPath = path.join(projectPath, '.env');
@@ -91,36 +91,36 @@ async function run() {
91
91
  envContent = envContent.replace(/APP_NAME=my-app/g, `APP_NAME=${projectName === '.' ? path.basename(currentPath) : projectName}`);
92
92
 
93
93
  fs.writeFileSync(envPath, envContent);
94
- envSpinner.succeed('File .env berhasil dibuat.');
94
+ envSpinner.succeed('.env file created successfully.');
95
95
  } else {
96
- envSpinner.warn('File .env.example tidak ditemukan, lewati setup .env.');
96
+ envSpinner.warn('.env.example not found, skipping .env setup.');
97
97
  }
98
98
  } catch (error) {
99
- envSpinner.fail('Gagal menyiapkan file .env.');
99
+ envSpinner.fail('Failed to configure .env file.');
100
100
  }
101
101
 
102
- // 4. Inisialisasi Git
102
+ // 4. Initialize Git
103
103
  try {
104
104
  execSync('git init', { stdio: 'ignore' });
105
105
  } catch (e) {
106
- // Abaikan jika user tidak punya git terinstall
106
+ // Ignore if git is not installed
107
107
  }
108
108
 
109
109
  // 5. Install Dependencies
110
110
  if (!answers.skipInstall) {
111
- const installSpinner = ora(`Menginstal dependencies menggunakan npm... (ini butuh waktu beberapa menit)`).start();
111
+ const installSpinner = ora(`Installing dependencies using npm... (this may take a few minutes)`).start();
112
112
  try {
113
113
  execSync(`npm install`, { stdio: 'ignore' });
114
- installSpinner.succeed('Dependencies berhasil diinstal.');
114
+ installSpinner.succeed('Dependencies installed successfully.');
115
115
  } catch (error) {
116
- installSpinner.fail('Gagal menginstal dependencies.');
117
- console.log(chalk.yellow('\nKamu bisa menginstalnya secara manual nanti.'));
116
+ installSpinner.fail('Failed to install dependencies.');
117
+ console.log(chalk.yellow('\nYou can install them manually later.'));
118
118
  }
119
119
  }
120
120
 
121
121
  // 6. Success Message
122
- console.log(chalk.green.bold('\nโœ… Project Berhasil Dibuat!\n'));
123
- console.log(chalk.white('Langkah selanjutnya:'));
122
+ console.log(chalk.green.bold('\nโœ… Project successfully created!\n'));
123
+ console.log(chalk.white('Next steps:'));
124
124
 
125
125
  if (projectName !== '.') {
126
126
  console.log(chalk.cyan(` cd ${projectName}`));
@@ -1,133 +1,137 @@
1
- # Kuli Digital NestJS Backend
2
-
3
- Backend application built with NestJS following Kuli Digital standardization manual.
4
-
5
- ## Features
6
-
7
- - ๐Ÿ” JWT Authentication with RBAC
8
- - ๐Ÿ“ Complete User Management
9
- - ๐ŸŽฏ Permission-based Access Control
10
- - ๐Ÿ“š Auto-generated Swagger Documentation
11
- - โœ… Input Validation
12
- - ๐Ÿ”„ API Versioning
13
- - ๐Ÿ“Š Structured Logging
14
- - ๐Ÿ—ƒ๏ธ Prisma ORM with PostgreSQL
15
- - ๐Ÿงช Testing Setup (Unit & E2E)
16
-
17
- ## Prerequisites
18
-
19
- - Node.js >= 18.x
20
- - PostgreSQL >= 14.x
21
- - npm/yarn/pnpm
22
-
23
- ## Installation
24
- ```bash
25
- # Install dependencies
26
- npm install
27
-
28
- # Setup environment variables
29
- cp .env.example .env
30
- # Edit .env with your database credentials
31
-
32
- # Generate Prisma Client
33
- npm run prisma:generate
34
-
35
- # Run migrations
36
- npm run prisma:migrate
37
-
38
- # Seed database
39
- npm run prisma:seed
40
- ```
41
-
42
- ## Running the Application
43
- ```bash
44
- # Development
45
- npm run start:dev
46
-
47
- # Production build
48
- npm run build
49
- npm run start:prod
50
-
51
- # Debug mode
52
- npm run start:debug
53
- ```
54
-
55
- ## Database Commands
56
- ```bash
57
- # Generate Prisma Client
58
- npm run prisma:generate
59
-
60
- # Create migration
61
- npm run prisma:migrate
62
-
63
- # Seed database
64
- npm run prisma:seed
65
-
66
- # Open Prisma Studio
67
- npm run prisma:studio
68
- ```
69
-
70
- ## Testing
71
- ```bash
72
- # Unit tests
73
- npm run test
74
-
75
- # E2E tests
76
- npm run test:e2e
77
-
78
- # Test coverage
79
- npm run test:cov
80
- ```
81
-
82
- ## API Documentation
83
-
84
- After starting the application, visit:
85
- - Swagger UI: `http://localhost:3000/api-docs`
86
-
87
- ## Default Users
88
-
89
- After seeding the database:
90
-
91
- **Admin User:**
92
- - Email: `admin@kulidigital.com`
93
- - Password: `password123`
94
- - All permissions granted
95
-
96
- **Member User:**
97
- - Email: `member@kulidigital.com`
98
- - Password: `password123`
99
- - Limited permissions (VIEW_USER only)
100
-
101
- ## Project Structure
102
- ```
103
- src/
104
- โ”œโ”€โ”€ common/ # Shared resources
105
- โ”‚ โ”œโ”€โ”€ decorators/ # Custom decorators
106
- โ”‚ โ”œโ”€โ”€ filters/ # Exception filters
107
- โ”‚ โ”œโ”€โ”€ guards/ # Auth & permission guards
108
- โ”‚ โ”œโ”€โ”€ interceptors/ # Logging & transform
109
- โ”‚ โ”œโ”€โ”€ prisma/ # Prisma service
110
- โ”‚ โ””โ”€โ”€ utils/ # Helper functions
111
- โ”œโ”€โ”€ config/ # Configuration files
112
- โ”œโ”€โ”€ modules/ # Feature modules
113
- โ”‚ โ”œโ”€โ”€ auth/ # Authentication
114
- โ”‚ โ”œโ”€โ”€ users/ # User management
115
- โ”‚ โ””โ”€โ”€ health/ # Health checks
116
- โ”œโ”€โ”€ app.module.ts # Root module
117
- โ””โ”€โ”€ main.ts # Application entry point
118
- ```
119
-
120
- ## Environment Variables
121
-
122
- See `.env.example` for all available configuration options.
123
-
124
- ## License
125
-
126
- Proprietary - Kuli Digital
127
- ```
128
-
129
- ### 20.2 .gitkeep for migrations
130
-
131
- **templates/nestjs-app/prisma/migrations/.gitkeep**
132
- ```
133
- # This file keeps the migrations directory in git
1
+ <div align="center">
2
+ <h1>๐Ÿ— Kuli Digital NestJS Backend</h1>
3
+ <p>The standard backend application architecture built with NestJS following the <b>Kuli Digital Standardization Manual</b>.</p>
4
+ </div>
5
+
6
+ ---
7
+
8
+ ## โœจ Features
9
+
10
+ - ๐Ÿ” **JWT Authentication with RBAC**: Secure endpoints using Role-Based Access Control.
11
+ - ๐Ÿ“ **Complete User Management**: Built-in user creation, login, and profile handling.
12
+ - ๐ŸŽฏ **Permission-based Access Control**: Fine-grained authorization controls.
13
+ - ๐Ÿ“š **Auto-generated Swagger Documentation**: Interactive API documentation available out of the box.
14
+ - โœ… **Input Validation**: Strongly typed DTOs and parameter validation.
15
+ - ๐Ÿ”„ **API Versioning**: Scalable route versioning (e.g., `/v1/...`).
16
+ - ๐Ÿ“Š **Structured Logging**: Pre-configured global interceptors for request/response logging.
17
+ - ๐Ÿ—ƒ๏ธ **Prisma ORM with PostgreSQL**: Fully typed database access.
18
+ - ๐Ÿงช **Testing Setup**: Ready-to-go Unit & E2E testing environments.
19
+
20
+ ## โš™๏ธ Prerequisites
21
+
22
+ Before you begin, ensure you have met the following requirements:
23
+ - Node.js `>= 18.x`
24
+ - PostgreSQL `>= 14.x`
25
+ - npm, yarn, or pnpm
26
+
27
+ ## ๐Ÿš€ Installation & Setup
28
+
29
+ 1. **Install dependencies:**
30
+ ```bash
31
+ npm install
32
+ ```
33
+
34
+ 2. **Setup environment variables:**
35
+ Your `.env` file should already be generated if you used the CLI tool. If not, copy it from the example:
36
+ ```bash
37
+ cp .env.example .env
38
+ ```
39
+ *(Ensure `DATABASE_URL` is correctly configured to point to your PostgreSQL database)*
40
+
41
+ 3. **Initialize the Database:**
42
+ ```bash
43
+ # Generate Prisma Client
44
+ npx prisma generate
45
+
46
+ # Run migrations to create tables
47
+ npx prisma migrate dev
48
+
49
+ # Seed the database with default roles and users
50
+ npx prisma db seed
51
+ ```
52
+
53
+ ## ๐Ÿ’ป Running the Application
54
+
55
+ ```bash
56
+ # Development mode (Hot-reload)
57
+ npm run start:dev
58
+
59
+ # Production build
60
+ npm run build
61
+ npm run start:prod
62
+
63
+ # Debug mode
64
+ npm run start:debug
65
+ ```
66
+
67
+ ## ๐Ÿ—„ Database Commands (Prisma)
68
+
69
+ ```bash
70
+ # Generate Prisma Client (after pulling new schema changes)
71
+ npx prisma generate
72
+
73
+ # Create a new migration (after modifying schema.prisma)
74
+ npx prisma migrate dev --name <migration_name>
75
+
76
+ # Open Prisma Studio (GUI to view your database)
77
+ npx prisma studio
78
+ ```
79
+
80
+ ## ๐Ÿงช Testing
81
+
82
+ ```bash
83
+ # Run Unit tests
84
+ npm run test
85
+
86
+ # Run E2E tests
87
+ npm run test:e2e
88
+
89
+ # Run tests with coverage
90
+ npm run test:cov
91
+ ```
92
+
93
+ ## ๐Ÿ“– API Documentation
94
+
95
+ Once the application is running, you can access the Swagger UI documentation at:
96
+ ๐Ÿ‘‰ **[http://localhost:3000/api-docs](http://localhost:3000/api-docs)**
97
+
98
+ ## ๐Ÿ‘ฅ Default Seeded Users
99
+
100
+ If you ran `npx prisma db seed`, you can log in with the following default credentials:
101
+
102
+ **๐Ÿ‘‘ Admin User:**
103
+ - Email: `admin@kulidigital.com`
104
+ - Password: `password123`
105
+ - *Privileges: All permissions granted*
106
+
107
+ **๐Ÿ‘ค Member User:**
108
+ - Email: `member@kulidigital.com`
109
+ - Password: `password123`
110
+ - *Privileges: Limited permissions (VIEW_USER only)*
111
+
112
+ ## ๐Ÿ“‚ Project Structure
113
+
114
+ ```text
115
+ src/
116
+ โ”œโ”€โ”€ common/ # Shared resources across the app
117
+ โ”‚ โ”œโ”€โ”€ constants/ # Global constants (e.g., Permissions)
118
+ โ”‚ โ”œโ”€โ”€ decorators/ # Custom decorators (e.g., @GetUser)
119
+ โ”‚ โ”œโ”€โ”€ dto/ # Shared DTOs (e.g., Pagination)
120
+ โ”‚ โ”œโ”€โ”€ filters/ # Exception filters (e.g., HttpExceptionFilter)
121
+ โ”‚ โ”œโ”€โ”€ guards/ # Auth & permission guards
122
+ โ”‚ โ”œโ”€โ”€ helpers/ # Helper functions
123
+ โ”‚ โ”œโ”€โ”€ interceptors/ # Logging & transform interceptors
124
+ โ”‚ โ”œโ”€โ”€ prisma/ # Prisma module & service
125
+ โ”‚ โ””โ”€โ”€ utils/ # Utility functions (e.g., Password hashing)
126
+ โ”œโ”€โ”€ config/ # Configuration files & Environment validation
127
+ โ”œโ”€โ”€ modules/ # Feature-specific modules
128
+ โ”‚ โ”œโ”€โ”€ auth/ # Authentication logic & endpoints
129
+ โ”‚ โ”œโ”€โ”€ users/ # User management logic & endpoints
130
+ โ”‚ โ””โ”€โ”€ health/ # Health check endpoint
131
+ โ”œโ”€โ”€ app.module.ts # Root module
132
+ โ””โ”€โ”€ main.ts # Application entry point
133
+ ```
134
+
135
+ ## ๐Ÿ“„ License
136
+
137
+ Proprietary - Kuli Digital