lapeh 2.0.3 โ†’ 2.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/bin/index.js CHANGED
@@ -37,6 +37,9 @@ async function upgradeProject() {
37
37
  '.env.example',
38
38
  '.vscode',
39
39
  'tsconfig.json',
40
+ 'README.md',
41
+ 'src/redis.ts', // Core framework file
42
+ 'src/prisma.ts', // Core framework file
40
43
  ];
41
44
 
42
45
  // Helper to copy recursive
@@ -44,15 +47,37 @@ async function upgradeProject() {
44
47
  if (!fs.existsSync(src)) return;
45
48
  const stats = fs.statSync(src);
46
49
  if (stats.isDirectory()) {
47
- if (!fs.existsSync(dest)) fs.mkdirSync(dest);
50
+ if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
48
51
  fs.readdirSync(src).forEach(childItemName => {
49
52
  copyRecursive(path.join(src, childItemName), path.join(dest, childItemName));
50
53
  });
51
54
  } else {
55
+ // Ensure destination directory exists
56
+ const destDir = path.dirname(dest);
57
+ if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true });
52
58
  fs.copyFileSync(src, dest);
53
59
  }
54
60
  }
55
61
 
62
+ // 1. Migration: Rename .model -> .prisma
63
+ const modelsDir = path.join(currentDir, 'src', 'models');
64
+ if (fs.existsSync(modelsDir)) {
65
+ console.log('๐Ÿ”„ Checking for legacy .model files...');
66
+ const files = fs.readdirSync(modelsDir);
67
+ let renamedCount = 0;
68
+ files.forEach(file => {
69
+ if (file.endsWith('.model')) {
70
+ const oldPath = path.join(modelsDir, file);
71
+ const newPath = path.join(modelsDir, file.replace('.model', '.prisma'));
72
+ fs.renameSync(oldPath, newPath);
73
+ renamedCount++;
74
+ }
75
+ });
76
+ if (renamedCount > 0) {
77
+ console.log(`โœ… Migrated ${renamedCount} files from .model to .prisma`);
78
+ }
79
+ }
80
+
56
81
  for (const item of filesToSync) {
57
82
  const srcPath = path.join(templateDir, item);
58
83
  const destPath = path.join(currentDir, item);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapeh",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Framework API Express yang siap pakai (Standardized)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -23,7 +23,8 @@
23
23
  "generate:jwt": "node scripts/generate-jwt-secret.js",
24
24
  "make:module": "node scripts/make-module.js",
25
25
  "make:model": "node scripts/make-model.js",
26
- "make:controller": "node scripts/make-controller.js"
26
+ "make:controller": "node scripts/make-controller.js",
27
+ "config:clear": "node scripts/config-clear.js"
27
28
  },
28
29
  "keywords": [
29
30
  "express",
package/readme.md CHANGED
@@ -162,7 +162,19 @@ npm run make:model NamaModel
162
162
 
163
163
  Ini akan membuat file `src/models/User.prisma`.
164
164
 
165
- ### 3. Workflow Database (Prisma)
165
+ ### 3. Membuat Controller
166
+
167
+ Membuat file Controller baru. Gunakan flag `-r` untuk membuat controller lengkap dengan method CRUD (index, show, store, update, destroy).
168
+
169
+ ```bash
170
+ npm run make:controller NamaController
171
+ # Contoh Basic: npm run make:controller PaymentController
172
+
173
+ # Contoh Resource (CRUD Lengkap):
174
+ npm run make:controller PaymentController -r
175
+ ```
176
+
177
+ ### 4. Workflow Database (Prisma)
166
178
 
167
179
  Karena framework ini menggunakan **Schema Terpisah** (split schema), Anda **TIDAK BOLEH** mengedit `prisma/schema.prisma` secara manual.
168
180
 
@@ -188,7 +200,7 @@ npm run prisma:deploy
188
200
 
189
201
  > **Catatan:** Script `compile-schema.js` akan otomatis berjalan sebelum perintah prisma di atas dieksekusi.
190
202
 
191
- ### 4. Generate JWT Secret
203
+ ### 5. Generate JWT Secret
192
204
 
193
205
  Jika Anda perlu me-refresh secret key JWT:
194
206
 
@@ -196,6 +208,19 @@ Jika Anda perlu me-refresh secret key JWT:
196
208
  npm run generate:jwt
197
209
  ```
198
210
 
211
+ ### 6. Maintenance (Clear Config)
212
+
213
+ Membersihkan cache framework, NPM, build artifacts, dan temporary files (sangat berguna jika mengalami isu cache aneh atau ingin reset environment development).
214
+
215
+ ```bash
216
+ npm run config:clear
217
+ ```
218
+
219
+ - Menghapus `node_modules/.cache`
220
+ - Menghapus `dist/`
221
+ - Menghapus `dump.rdb` (Redis Persistence)
222
+ - Membersihkan `npm cache`
223
+
199
224
  ---
200
225
 
201
226
  ## ๐Ÿ“‚ Struktur Folder
@@ -0,0 +1,45 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { execSync } = require('child_process');
4
+
5
+ const rootDir = path.join(__dirname, '..');
6
+
7
+ console.log('๐Ÿงน Starting cleanup process...');
8
+
9
+ // 1. Remove dist folder (Build artifacts)
10
+ const distDir = path.join(rootDir, 'dist');
11
+ if (fs.existsSync(distDir)) {
12
+ console.log('๐Ÿ—‘๏ธ Removing dist/ folder...');
13
+ fs.rmSync(distDir, { recursive: true, force: true });
14
+ }
15
+
16
+ // 2. Remove node_modules/.cache (Framework caches: ts-node, eslint, etc)
17
+ const nmCacheDir = path.join(rootDir, 'node_modules', '.cache');
18
+ if (fs.existsSync(nmCacheDir)) {
19
+ console.log('๐Ÿ—‘๏ธ Removing node_modules/.cache...');
20
+ fs.rmSync(nmCacheDir, { recursive: true, force: true });
21
+ }
22
+
23
+ // 3. Remove Redis local persistence file (dump.rdb)
24
+ const dumpRdb = path.join(rootDir, 'dump.rdb');
25
+ if (fs.existsSync(dumpRdb)) {
26
+ console.log('๐Ÿ—‘๏ธ Removing dump.rdb (Redis persistence)...');
27
+ fs.unlinkSync(dumpRdb);
28
+ }
29
+
30
+ // 4. Remove Coverage folder (if exists)
31
+ const coverageDir = path.join(rootDir, 'coverage');
32
+ if (fs.existsSync(coverageDir)) {
33
+ console.log('๐Ÿ—‘๏ธ Removing coverage/ folder...');
34
+ fs.rmSync(coverageDir, { recursive: true, force: true });
35
+ }
36
+
37
+ // 5. Clear NPM Cache
38
+ try {
39
+ console.log('๐Ÿ“ฆ Clearing NPM cache...');
40
+ execSync('npm cache clean --force', { stdio: 'inherit' });
41
+ } catch (error) {
42
+ console.warn('โš ๏ธ Warning: Could not clear NPM cache. You might need admin privileges.');
43
+ }
44
+
45
+ console.log('โœจ Cleanup complete! Project is fresh.');