lapeh 2.4.0 → 2.4.2

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 (2) hide show
  1. package/bin/index.js +58 -3
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -34,6 +34,23 @@ switch (command) {
34
34
  function runDev() {
35
35
  console.log('🚀 Starting Lapeh in development mode...');
36
36
  try {
37
+ // Generate Prisma Client before starting
38
+ console.log('🔄 Generating Prisma Client...');
39
+ const compileSchemaPath = path.join(process.cwd(), 'scripts/compile-schema.js');
40
+ if (fs.existsSync(compileSchemaPath)) {
41
+ try {
42
+ execSync('node scripts/compile-schema.js', { stdio: 'inherit' });
43
+ } catch (e) {
44
+ console.warn('⚠️ Failed to run compile-schema.js', e.message);
45
+ }
46
+ }
47
+
48
+ try {
49
+ execSync('npx prisma generate', { stdio: 'inherit' });
50
+ } catch (e) {
51
+ console.warn('⚠️ Failed to run prisma generate. Continuing...', e.message);
52
+ }
53
+
37
54
  const tsNodePath = require.resolve('ts-node/register');
38
55
  const tsConfigPathsPath = require.resolve('tsconfig-paths/register');
39
56
 
@@ -48,7 +65,19 @@ function runDev() {
48
65
 
49
66
  // We execute a script that requires ts-node to run lib/bootstrap.ts
50
67
  // Use JSON.stringify to properly escape paths for the shell command
51
- const cmd = `npx nodemon --watch src --watch lib --ext ts,json --exec "node -r ${JSON.stringify(tsNodePath)} -r ${JSON.stringify(tsConfigPathsPath)} ${JSON.stringify(bootstrapPath)}"`;
68
+ const nodeArgs = `-r ${JSON.stringify(tsNodePath)} -r ${JSON.stringify(tsConfigPathsPath)} ${JSON.stringify(bootstrapPath)}`;
69
+ const isWin = process.platform === 'win32';
70
+
71
+ let cmd;
72
+ if (isWin) {
73
+ // On Windows, escape inner quotes
74
+ const escapedArgs = nodeArgs.replace(/"/g, '\\"');
75
+ cmd = `npx nodemon --watch src --watch lib --ext ts,json --exec "node ${escapedArgs}"`;
76
+ } else {
77
+ // On Linux/Mac, use single quotes for the outer wrapper
78
+ cmd = `npx nodemon --watch src --watch lib --ext ts,json --exec 'node ${nodeArgs}'`;
79
+ }
80
+
52
81
  execSync(cmd, { stdio: 'inherit' });
53
82
  } catch (error) {
54
83
  // Ignore error
@@ -180,8 +209,34 @@ function runStart() {
180
209
 
181
210
  function runBuild() {
182
211
  console.log('🛠️ Building Lapeh project...');
183
- execSync('npm run prisma:generate', { stdio: 'inherit' });
184
- execSync('npx tsc && npx tsc-alias', { stdio: 'inherit' });
212
+
213
+ // Compile schema if script exists
214
+ const compileSchemaPath = path.join(process.cwd(), 'scripts/compile-schema.js');
215
+ if (fs.existsSync(compileSchemaPath)) {
216
+ try {
217
+ execSync('node scripts/compile-schema.js', { stdio: 'inherit' });
218
+ } catch (e) {
219
+ console.error('❌ Failed to compile schema.');
220
+ process.exit(1);
221
+ }
222
+ }
223
+
224
+ // Generate prisma client
225
+ try {
226
+ execSync('npx prisma generate', { stdio: 'inherit' });
227
+ } catch (e) {
228
+ console.error('❌ Failed to generate prisma client.');
229
+ process.exit(1);
230
+ }
231
+
232
+ // Compile TS
233
+ try {
234
+ execSync('npx tsc && npx tsc-alias', { stdio: 'inherit' });
235
+ } catch (e) {
236
+ console.error('❌ Build failed.');
237
+ process.exit(1);
238
+ }
239
+
185
240
  console.log('✅ Build complete.');
186
241
  }
187
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapeh",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Framework API Express yang siap pakai (Standardized)",
5
5
  "main": "dist/lib/bootstrap.js",
6
6
  "bin": {