@kuldi/create-nestjs 1.1.5 → 1.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kuldi/create-nestjs",
3
- "version": "1.1.5",
3
+ "version": "1.1.9",
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
@@ -18,18 +18,22 @@ async function run() {
18
18
  console.log(chalk.cyan.bold('\nšŸš€ Kuli Digital NestJS Boilerplate Generator\n'));
19
19
 
20
20
  const argProjectName = process.argv[2];
21
+ const isCurrentDirArg = argProjectName === '.';
22
+ const defaultName = isCurrentDirArg ? path.basename(currentPath) : (argProjectName || 'my-nestjs-app');
21
23
 
22
24
  // 1. Tanya Project Name
23
25
  const { projectName } = await inquirer.prompt([
24
26
  {
25
27
  type: 'input',
26
28
  name: 'projectName',
27
- message: 'Project Name (or . for current directory):',
28
- default: argProjectName === '.' ? '.' : (argProjectName || 'my-nestjs-app'),
29
+ message: 'Project Name:',
30
+ default: defaultName,
29
31
  }
30
32
  ]);
31
33
 
32
- const projectPath = projectName === '.' ? currentPath : path.join(currentPath, projectName);
34
+ const isCurrentDir = isCurrentDirArg || projectName === '.';
35
+ const projectPath = isCurrentDir ? currentPath : path.join(currentPath, projectName);
36
+ const finalProjectName = projectName === '.' ? path.basename(currentPath) : projectName;
33
37
 
34
38
  // 2. Cek apakah folder kosong (Overwrite Check)
35
39
  if (fs.existsSync(projectPath)) {
@@ -57,7 +61,7 @@ async function run() {
57
61
  type: 'input',
58
62
  name: 'database',
59
63
  message: 'PostgreSQL Database Name:',
60
- default: projectName === '.' || !projectName ? 'kulidigital_db' : `${projectName}_db`,
64
+ default: `${finalProjectName}_db`,
61
65
  },
62
66
  {
63
67
  type: 'confirm',
@@ -112,14 +116,49 @@ async function run() {
112
116
  envSpinner.fail('Failed to configure .env file.');
113
117
  }
114
118
 
115
- // 4. Initialize Git
119
+ // 4. Update package.json & README.md
120
+ const configSpinner = ora('Configuring project details...').start();
121
+ try {
122
+ // Update package.json
123
+ const pkgPath = path.join(projectPath, 'package.json');
124
+ if (fs.existsSync(pkgPath)) {
125
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
126
+ pkg.name = finalProjectName;
127
+ pkg.description = `${finalProjectName} Application`;
128
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
129
+ }
130
+
131
+ // Update README.md
132
+ const readmePath = path.join(projectPath, 'README.md');
133
+ if (fs.existsSync(readmePath)) {
134
+ let readmeContent = fs.readFileSync(readmePath, 'utf-8');
135
+ readmeContent = readmeContent.replace(/<h1>šŸ— Kuli Digital NestJS Backend<\/h1>/g, `<h1>šŸ— ${finalProjectName} Backend</h1>`);
136
+ readmeContent = readmeContent.replace(/<p>The standard backend application architecture built with NestJS following the <b>Kuli Digital Standardization Manual<\/b>\.<\/p>/g, `<p>Backend application for ${finalProjectName}.</p>`);
137
+ fs.writeFileSync(readmePath, readmeContent);
138
+ }
139
+
140
+ // Update Swagger config in main.ts
141
+ const mainTsPath = path.join(projectPath, 'src', 'main.ts');
142
+ if (fs.existsSync(mainTsPath)) {
143
+ let mainTsContent = fs.readFileSync(mainTsPath, 'utf-8');
144
+ mainTsContent = mainTsContent.replace(/\.setTitle\('Kuli Digital Standard API'\)/g, `.setTitle('${finalProjectName} API')`);
145
+ mainTsContent = mainTsContent.replace(/\.setDescription\('Kuli Digital NestJS Backend API Documentation'\)/g, `.setDescription('${finalProjectName} Backend API Documentation')`);
146
+ fs.writeFileSync(mainTsPath, mainTsContent);
147
+ }
148
+
149
+ configSpinner.succeed('Project details configured successfully.');
150
+ } catch (error) {
151
+ configSpinner.fail('Failed to configure project details.');
152
+ }
153
+
154
+ // 5. Initialize Git
116
155
  try {
117
156
  execSync('git init', { stdio: 'ignore' });
118
157
  } catch (e) {
119
158
  // Ignore if git is not installed
120
159
  }
121
160
 
122
- // 5. Install Dependencies
161
+ // 6. Install Dependencies
123
162
  if (!answers.skipInstall) {
124
163
  const installSpinner = ora(`Installing dependencies using npm... (this may take a few minutes)`).start();
125
164
  try {
@@ -131,7 +170,7 @@ async function run() {
131
170
  }
132
171
  }
133
172
 
134
- // 6. Success Message
173
+ // 7. Success Message
135
174
  console.log(chalk.green.bold('\nāœ… Project successfully created!\n'));
136
175
  console.log(chalk.white('Next steps:'));
137
176
 
@@ -144,7 +183,7 @@ async function run() {
144
183
  }
145
184
 
146
185
  console.log(chalk.cyan(` npx prisma migrate dev`));
147
- console.log(chalk.cyan(` npx prisma db seed`));
186
+ console.log(chalk.cyan(` npm run prisma:seed`));
148
187
  console.log(chalk.cyan(` npm run start:dev\n`));
149
188
  console.log(chalk.gray(`Happy Coding! - Kuli Digital\n`));
150
189
  }
@@ -47,7 +47,7 @@ npx prisma generate
47
47
  npx prisma migrate dev
48
48
 
49
49
  # Seed the database with default roles and users
50
- npx prisma db seed
50
+ npm run prisma:seed
51
51
  ```
52
52
 
53
53
  ## šŸ’» Running the Application
@@ -97,7 +97,7 @@ Once the application is running, you can access the Swagger UI documentation at:
97
97
 
98
98
  ## šŸ‘„ Default Seeded Users
99
99
 
100
- If you ran `npx prisma db seed`, you can log in with the following default credentials:
100
+ If you ran `npm run prisma:seed`, you can log in with the following default credentials:
101
101
 
102
102
  **šŸ‘‘ Admin User:**
103
103
  - Email: `admin@kulidigital.com`
@@ -5,4 +5,7 @@ export default defineConfig({
5
5
  datasource: {
6
6
  url: env('DATABASE_URL'),
7
7
  },
8
+ migrations: {
9
+ seed: 'ts-node prisma/seeder/index.ts',
10
+ },
8
11
  });