@kuldi/create-nestjs 1.1.2 โ†’ 1.1.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kuli Digital
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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
26
  npm create @kuldi/nestjs .
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@kuldi/create-nestjs",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "Scaffolding tool for Kuli Digital NestJS Boilerplate",
6
6
  "main": "src/cli.js",
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
  ]);
@@ -45,41 +45,52 @@ async function run() {
45
45
  const projectName = argProjectName || answers.projectName;
46
46
  const projectPath = projectName === '.' ? currentPath : path.join(currentPath, projectName);
47
47
 
48
- // Mengecek apakah target directory kosong
49
- if (projectName === '.') {
50
- const files = fs.readdirSync(currentPath).filter(f => !f.startsWith('.git'));
48
+ // Check if target directory is empty
49
+ if (fs.existsSync(projectPath)) {
50
+ const files = fs.readdirSync(projectPath).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'));
53
- process.exit(1);
52
+ const { overwrite } = await inquirer.prompt([
53
+ {
54
+ type: 'confirm',
55
+ name: 'overwrite',
56
+ message: 'Directory is not empty. Do you want to continue? (This will overwrite existing files)',
57
+ default: false,
58
+ }
59
+ ]);
60
+
61
+ if (!overwrite) {
62
+ console.log(chalk.yellow('\nโš ๏ธ Setup cancelled.\n'));
63
+ process.exit(0);
64
+ }
54
65
  }
55
66
  }
56
67
 
57
68
  // 2. Salin Template
58
- const copySpinner = ora('Membuat struktur project...').start();
69
+ const copySpinner = ora('Generating project structure...').start();
59
70
  try {
60
71
  const templateDir = path.join(__dirname, '../template');
61
72
 
62
- // Copy seluruh isi folder template ke project tujuan
73
+ // Copy template contents to the target project directory
63
74
  fs.cpSync(templateDir, projectPath, { recursive: true });
64
75
 
65
- // Rename gitignore menjadi .gitignore (krn NPM mengabaikan .gitignore saat publish)
76
+ // Rename gitignore to .gitignore (NPM ignores .gitignore during publish)
66
77
  const gitignorePath = path.join(projectPath, 'gitignore');
67
78
  if (fs.existsSync(gitignorePath)) {
68
79
  fs.renameSync(gitignorePath, path.join(projectPath, '.gitignore'));
69
80
  }
70
81
 
71
- copySpinner.succeed('Struktur project berhasil dibuat.');
82
+ copySpinner.succeed('Project structure generated successfully.');
72
83
  } catch (error) {
73
- copySpinner.fail('Gagal menyalin struktur template.');
84
+ copySpinner.fail('Failed to generate project structure.');
74
85
  console.error(error.message);
75
86
  process.exit(1);
76
87
  }
77
88
 
78
- // Masuk ke folder project
89
+ // Navigate to project directory
79
90
  process.chdir(projectPath);
80
91
 
81
92
  // 3. Setup .env
82
- const envSpinner = ora('Menyiapkan file .env...').start();
93
+ const envSpinner = ora('Configuring environment variables...').start();
83
94
  try {
84
95
  const envExamplePath = path.join(projectPath, '.env.example');
85
96
  const envPath = path.join(projectPath, '.env');
@@ -91,36 +102,36 @@ async function run() {
91
102
  envContent = envContent.replace(/APP_NAME=my-app/g, `APP_NAME=${projectName === '.' ? path.basename(currentPath) : projectName}`);
92
103
 
93
104
  fs.writeFileSync(envPath, envContent);
94
- envSpinner.succeed('File .env berhasil dibuat.');
105
+ envSpinner.succeed('.env file created successfully.');
95
106
  } else {
96
- envSpinner.warn('File .env.example tidak ditemukan, lewati setup .env.');
107
+ envSpinner.warn('.env.example not found, skipping .env setup.');
97
108
  }
98
109
  } catch (error) {
99
- envSpinner.fail('Gagal menyiapkan file .env.');
110
+ envSpinner.fail('Failed to configure .env file.');
100
111
  }
101
112
 
102
- // 4. Inisialisasi Git
113
+ // 4. Initialize Git
103
114
  try {
104
115
  execSync('git init', { stdio: 'ignore' });
105
116
  } catch (e) {
106
- // Abaikan jika user tidak punya git terinstall
117
+ // Ignore if git is not installed
107
118
  }
108
119
 
109
120
  // 5. Install Dependencies
110
121
  if (!answers.skipInstall) {
111
- const installSpinner = ora(`Menginstal dependencies menggunakan npm... (ini butuh waktu beberapa menit)`).start();
122
+ const installSpinner = ora(`Installing dependencies using npm... (this may take a few minutes)`).start();
112
123
  try {
113
124
  execSync(`npm install`, { stdio: 'ignore' });
114
- installSpinner.succeed('Dependencies berhasil diinstal.');
125
+ installSpinner.succeed('Dependencies installed successfully.');
115
126
  } catch (error) {
116
- installSpinner.fail('Gagal menginstal dependencies.');
117
- console.log(chalk.yellow('\nKamu bisa menginstalnya secara manual nanti.'));
127
+ installSpinner.fail('Failed to install dependencies.');
128
+ console.log(chalk.yellow('\nYou can install them manually later.'));
118
129
  }
119
130
  }
120
131
 
121
132
  // 6. Success Message
122
- console.log(chalk.green.bold('\nโœ… Project Berhasil Dibuat!\n'));
123
- console.log(chalk.white('Langkah selanjutnya:'));
133
+ console.log(chalk.green.bold('\nโœ… Project successfully created!\n'));
134
+ console.log(chalk.white('Next steps:'));
124
135
 
125
136
  if (projectName !== '.') {
126
137
  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