lapeh 2.2.5 → 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 +76 -7
- package/lib/bootstrap.ts +5 -0
- package/package.json +3 -2
- package/prisma/seed.ts +4 -1
- package/prisma.config.ts +1 -1
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');
|
|
@@ -36,9 +36,14 @@ function runDev() {
|
|
|
36
36
|
try {
|
|
37
37
|
const tsNodePath = require.resolve('ts-node/register');
|
|
38
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
|
+
|
|
39
45
|
// We execute a script that requires ts-node to run lib/bootstrap.ts
|
|
40
|
-
|
|
41
|
-
execSync(`npx nodemon --exec "node -r ${tsNodePath} -r ${tsConfigPathsPath}" -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' });
|
|
42
47
|
} catch (error) {
|
|
43
48
|
// Ignore error
|
|
44
49
|
}
|
|
@@ -77,6 +82,8 @@ async function upgradeProject() {
|
|
|
77
82
|
|
|
78
83
|
// Files/Folders to overwrite/copy
|
|
79
84
|
const filesToSync = [
|
|
85
|
+
'bin', // Ensure CLI script is updated
|
|
86
|
+
'lib', // Ensure core framework files are updated
|
|
80
87
|
'scripts',
|
|
81
88
|
'docker-compose.yml',
|
|
82
89
|
'.env.example',
|
|
@@ -141,7 +148,11 @@ async function upgradeProject() {
|
|
|
141
148
|
// Update scripts
|
|
142
149
|
currentPackageJson.scripts = {
|
|
143
150
|
...currentPackageJson.scripts,
|
|
144
|
-
...templatePackageJson.scripts
|
|
151
|
+
...templatePackageJson.scripts,
|
|
152
|
+
"dev": "lapeh dev",
|
|
153
|
+
"start": "lapeh start",
|
|
154
|
+
"build": "lapeh build",
|
|
155
|
+
"start:prod": "lapeh start"
|
|
145
156
|
};
|
|
146
157
|
|
|
147
158
|
// Update dependencies
|
|
@@ -157,10 +168,32 @@ async function upgradeProject() {
|
|
|
157
168
|
};
|
|
158
169
|
|
|
159
170
|
// Update Lapeh version tag
|
|
160
|
-
|
|
171
|
+
// For local development, we use file reference. For production publish, use version.
|
|
172
|
+
currentPackageJson.dependencies["lapeh"] = "file:../";
|
|
161
173
|
|
|
162
174
|
fs.writeFileSync(packageJsonPath, JSON.stringify(currentPackageJson, null, 2));
|
|
163
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
|
+
|
|
164
197
|
// Run npm install
|
|
165
198
|
console.log('📦 Installing updated dependencies...');
|
|
166
199
|
try {
|
|
@@ -261,7 +294,8 @@ function createProject() {
|
|
|
261
294
|
'dist',
|
|
262
295
|
'.git',
|
|
263
296
|
'.env',
|
|
264
|
-
'bin', //
|
|
297
|
+
'bin', // Exclude bin folder, using dependency instead
|
|
298
|
+
'lib', // Exclude lib folder, using dependency instead
|
|
265
299
|
'package-lock.json',
|
|
266
300
|
'.DS_Store',
|
|
267
301
|
'prisma/migrations', // Exclude existing migrations
|
|
@@ -306,15 +340,50 @@ function createProject() {
|
|
|
306
340
|
packageJson.name = projectName;
|
|
307
341
|
// Add lapeh framework version to dependencies to track it like react-router
|
|
308
342
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
309
|
-
|
|
343
|
+
// For local development, we use file reference. For production publish, use version.
|
|
344
|
+
packageJson.dependencies["lapeh"] = "file:../";
|
|
310
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
|
+
|
|
311
350
|
packageJson.version = '1.0.0';
|
|
312
351
|
packageJson.description = 'Generated by lapeh';
|
|
313
352
|
delete packageJson.bin; // Remove the bin entry from the generated project
|
|
314
353
|
delete packageJson.repository; // Remove repository info if specific to the template
|
|
315
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
|
+
|
|
316
364
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
317
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
|
+
|
|
318
387
|
// Create .env from .env.example with correct DB config
|
|
319
388
|
console.log('⚙️ Configuring environment...');
|
|
320
389
|
const envExamplePath = path.join(projectDir, '.env.example');
|
package/lib/bootstrap.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lapeh",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Framework API Express yang siap pakai (Standardized)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
"uuid": "13.0.0",
|
|
88
88
|
"winston": "^3.19.0",
|
|
89
89
|
"winston-daily-rotate-file": "^5.0.0",
|
|
90
|
-
"zod": "3.23.8"
|
|
90
|
+
"zod": "3.23.8",
|
|
91
|
+
"prisma": "7.2.0"
|
|
91
92
|
},
|
|
92
93
|
"devDependencies": {
|
|
93
94
|
"@eslint/js": "^9.39.2",
|
package/prisma/seed.ts
CHANGED
package/prisma.config.ts
CHANGED