lapeh 2.2.4 → 2.2.6

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
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
@@ -9,7 +9,7 @@ const args = process.argv.slice(2);
9
9
  const command = args[0];
10
10
 
11
11
  // Register tsconfig paths for development
12
- require('tsconfig-paths/register');
12
+ // require('tsconfig-paths/register');
13
13
 
14
14
  switch (command) {
15
15
  case 'dev':
@@ -34,9 +34,16 @@ switch (command) {
34
34
  function runDev() {
35
35
  console.log('🚀 Starting Lapeh in development mode...');
36
36
  try {
37
+ const tsNodePath = require.resolve('ts-node/register');
38
+ const tsConfigPathsPath = require.resolve('tsconfig-paths/register');
39
+
40
+ // Resolve bootstrap file relative to this script
41
+ // If run from node_modules, it will find ../lib/bootstrap.ts
42
+ // If run from source, it will find ../lib/bootstrap.ts
43
+ const bootstrapPath = path.resolve(__dirname, '../lib/bootstrap.ts');
44
+
37
45
  // We execute a script that requires ts-node to run lib/bootstrap.ts
38
- // In a real package, this would be `node dist/lib/bootstrap.js`
39
- execSync('npx nodemon --exec ts-node -r tsconfig-paths/register -e "require(\'./lib/bootstrap\').bootstrap()"', { stdio: 'inherit' });
46
+ execSync(`npx nodemon --watch src --watch lib --ext ts,json --exec "node -r ${tsNodePath} -r ${tsConfigPathsPath} ${bootstrapPath}"`, { stdio: 'inherit' });
40
47
  } catch (error) {
41
48
  // Ignore error
42
49
  }
@@ -75,6 +82,8 @@ async function upgradeProject() {
75
82
 
76
83
  // Files/Folders to overwrite/copy
77
84
  const filesToSync = [
85
+ 'bin', // Ensure CLI script is updated
86
+ 'lib', // Ensure core framework files are updated
78
87
  'scripts',
79
88
  'docker-compose.yml',
80
89
  '.env.example',
@@ -139,7 +148,11 @@ async function upgradeProject() {
139
148
  // Update scripts
140
149
  currentPackageJson.scripts = {
141
150
  ...currentPackageJson.scripts,
142
- ...templatePackageJson.scripts
151
+ ...templatePackageJson.scripts,
152
+ "dev": "lapeh dev",
153
+ "start": "lapeh start",
154
+ "build": "lapeh build",
155
+ "start:prod": "lapeh start"
143
156
  };
144
157
 
145
158
  // Update dependencies
@@ -155,10 +168,32 @@ async function upgradeProject() {
155
168
  };
156
169
 
157
170
  // Update Lapeh version tag
158
- currentPackageJson.dependencies["lapeh"] = templatePackageJson.version;
171
+ // For local development, we use file reference. For production publish, use version.
172
+ currentPackageJson.dependencies["lapeh"] = "file:../";
159
173
 
160
174
  fs.writeFileSync(packageJsonPath, JSON.stringify(currentPackageJson, null, 2));
161
175
 
176
+ // Update tsconfig.json to support framework-as-dependency
177
+ console.log('🔧 Configuring tsconfig.json...');
178
+ const tsconfigPath = path.join(currentDir, 'tsconfig.json');
179
+ if (fs.existsSync(tsconfigPath)) {
180
+ // Use comment-json or just basic parsing if no comments (standard JSON)
181
+ // Since our template tsconfig is standard JSON, require is fine or JSON.parse
182
+ const tsconfig = require(tsconfigPath);
183
+
184
+ // Update paths
185
+ if (tsconfig.compilerOptions && tsconfig.compilerOptions.paths) {
186
+ tsconfig.compilerOptions.paths["@lapeh/*"] = ["node_modules/lapeh/lib/*"];
187
+ }
188
+
189
+ // Add ts-node ignore configuration
190
+ tsconfig["ts-node"] = {
191
+ "ignore": ["node_modules/(?!lapeh)"]
192
+ };
193
+
194
+ fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
195
+ }
196
+
162
197
  // Run npm install
163
198
  console.log('📦 Installing updated dependencies...');
164
199
  try {
@@ -259,7 +294,8 @@ function createProject() {
259
294
  'dist',
260
295
  '.git',
261
296
  '.env',
262
- 'bin', // Don't copy the CLI script itself
297
+ 'bin', // Exclude bin folder, using dependency instead
298
+ 'lib', // Exclude lib folder, using dependency instead
263
299
  'package-lock.json',
264
300
  '.DS_Store',
265
301
  'prisma/migrations', // Exclude existing migrations
@@ -304,15 +340,50 @@ function createProject() {
304
340
  packageJson.name = projectName;
305
341
  // Add lapeh framework version to dependencies to track it like react-router
306
342
  packageJson.dependencies = packageJson.dependencies || {};
307
- packageJson.dependencies["lapeh"] = packageJson.version;
343
+ // For local development, we use file reference. For production publish, use version.
344
+ packageJson.dependencies["lapeh"] = "file:../";
308
345
 
346
+ // Ensure prisma CLI is available in devDependencies for the new project
347
+ packageJson.devDependencies = packageJson.devDependencies || {};
348
+ packageJson.devDependencies["prisma"] = "7.2.0";
349
+
309
350
  packageJson.version = '1.0.0';
310
351
  packageJson.description = 'Generated by lapeh';
311
352
  delete packageJson.bin; // Remove the bin entry from the generated project
312
353
  delete packageJson.repository; // Remove repository info if specific to the template
313
354
 
355
+ // Update scripts to use lapeh binary
356
+ packageJson.scripts = {
357
+ ...packageJson.scripts,
358
+ "dev": "lapeh dev",
359
+ "start": "lapeh start",
360
+ "build": "lapeh build",
361
+ "start:prod": "lapeh start"
362
+ };
363
+
314
364
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
315
365
 
366
+ // Update tsconfig.json to support framework-as-dependency
367
+ console.log('🔧 Configuring tsconfig.json...');
368
+ const tsconfigPath = path.join(projectDir, 'tsconfig.json');
369
+ if (fs.existsSync(tsconfigPath)) {
370
+ // Use comment-json or just basic parsing if no comments (standard JSON)
371
+ // Since our template tsconfig is standard JSON, require is fine or JSON.parse
372
+ const tsconfig = require(tsconfigPath);
373
+
374
+ // Update paths
375
+ if (tsconfig.compilerOptions && tsconfig.compilerOptions.paths) {
376
+ tsconfig.compilerOptions.paths["@lapeh/*"] = ["node_modules/lapeh/lib/*"];
377
+ }
378
+
379
+ // Add ts-node ignore configuration
380
+ tsconfig["ts-node"] = {
381
+ "ignore": ["node_modules/(?!lapeh)"]
382
+ };
383
+
384
+ fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
385
+ }
386
+
316
387
  // Create .env from .env.example with correct DB config
317
388
  console.log('⚙️ Configuring environment...');
318
389
  const envExamplePath = path.join(projectDir, '.env.example');
package/lib/bootstrap.ts CHANGED
@@ -143,3 +143,8 @@ export async function bootstrap() {
143
143
  shutdown("uncaughtException");
144
144
  });
145
145
  }
146
+
147
+ // Self-executing if run directly
148
+ if (require.main === module) {
149
+ bootstrap();
150
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapeh",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "Framework API Express yang siap pakai (Standardized)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -81,10 +81,14 @@
81
81
  "pg": "8.16.3",
82
82
  "slugify": "1.6.6",
83
83
  "socket.io": "4.8.3",
84
+ "ts-node": "^10.9.2",
85
+ "tsconfig-paths": "^4.2.0",
86
+ "typescript": "^5.9.3",
84
87
  "uuid": "13.0.0",
85
88
  "winston": "^3.19.0",
86
89
  "winston-daily-rotate-file": "^5.0.0",
87
- "zod": "3.23.8"
90
+ "zod": "3.23.8",
91
+ "prisma": "7.2.0"
88
92
  },
89
93
  "devDependencies": {
90
94
  "@eslint/js": "^9.39.2",
@@ -99,12 +103,6 @@
99
103
  "@types/uuid": "10.0.0",
100
104
  "eslint": "^9.39.2",
101
105
  "globals": "^16.5.0",
102
- "nodemon": "3.1.11",
103
- "prisma": "7.2.0",
104
- "ts-node": "10.9.2",
105
- "tsc-alias": "^1.8.16",
106
- "tsconfig-paths": "^4.2.0",
107
- "typescript": "5.9.3",
108
106
  "typescript-eslint": "^8.50.1"
109
107
  }
110
108
  }
package/prisma/seed.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { prisma } from "../lib/core/database";
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
3
+
4
+ import { prisma } from "@lapeh/core/database";
2
5
  import bcrypt from "bcryptjs";
3
6
  import { v4 as uuidv4 } from "uuid";
4
7
 
package/prisma.config.ts CHANGED
@@ -7,7 +7,7 @@ export default defineConfig({
7
7
  schema: "prisma/schema.prisma",
8
8
  migrations: {
9
9
  path: "prisma/migrations",
10
- seed: "ts-node prisma/seed.ts",
10
+ seed: "ts-node -r tsconfig-paths/register prisma/seed.ts",
11
11
  },
12
12
  datasource: {
13
13
  url: env("DATABASE_URL"),