lapeh 2.3.5 → 2.3.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 +33 -5
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -122,9 +122,34 @@ function runStart() {
|
|
|
122
122
|
// But `runStart` is inside `bin/index.js` which is likely a JS file.
|
|
123
123
|
// We can require('../lib/bootstrap') or '../dist/lib/bootstrap'.
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
// IMPORTANT: When running from a user's project, the 'lapeh' package is inside node_modules.
|
|
126
|
+
// So `__dirname` is `.../node_modules/lapeh/bin`.
|
|
127
|
+
// We want `.../node_modules/lapeh/lib/bootstrap.js`.
|
|
128
|
+
|
|
129
|
+
let frameworkBootstrap;
|
|
130
|
+
try {
|
|
131
|
+
frameworkBootstrap = require('../lib/bootstrap');
|
|
132
|
+
} catch (e) {
|
|
133
|
+
try {
|
|
134
|
+
frameworkBootstrap = require('../dist/lib/bootstrap');
|
|
135
|
+
} catch (e2) {
|
|
136
|
+
// Try absolute path resolution from CWD if relative require fails
|
|
137
|
+
// This handles cases where CLI might be symlinked or global
|
|
138
|
+
const cwdNodeModules = path.join(process.cwd(), 'node_modules', 'lapeh');
|
|
139
|
+
if (fs.existsSync(path.join(cwdNodeModules, 'lib/bootstrap.js'))) {
|
|
140
|
+
frameworkBootstrap = require(path.join(cwdNodeModules, 'lib/bootstrap.js'));
|
|
141
|
+
} else if (fs.existsSync(path.join(cwdNodeModules, 'dist/lib/bootstrap.js'))) {
|
|
142
|
+
frameworkBootstrap = require(path.join(cwdNodeModules, 'dist/lib/bootstrap.js'));
|
|
143
|
+
} else {
|
|
144
|
+
throw e;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (frameworkBootstrap) {
|
|
150
|
+
frameworkBootstrap.bootstrap();
|
|
151
|
+
return; // Exit this function, let the bootstrap take over
|
|
152
|
+
}
|
|
128
153
|
|
|
129
154
|
} catch (e) {
|
|
130
155
|
// If direct require fails (maybe because of ESM/CJS mix or path issues), fallback to child process
|
|
@@ -144,7 +169,8 @@ function runStart() {
|
|
|
144
169
|
const possiblePaths = [
|
|
145
170
|
path.join(__dirname, '../lib/bootstrap.js'),
|
|
146
171
|
path.join(__dirname, '../dist/lib/bootstrap.js'),
|
|
147
|
-
path.join(process.cwd(), 'node_modules/lapeh/lib/bootstrap.js')
|
|
172
|
+
path.join(process.cwd(), 'node_modules/lapeh/lib/bootstrap.js'),
|
|
173
|
+
path.join(process.cwd(), 'node_modules/lapeh/dist/lib/bootstrap.js')
|
|
148
174
|
];
|
|
149
175
|
|
|
150
176
|
bootstrapPath = possiblePaths.find(p => fs.existsSync(p));
|
|
@@ -155,7 +181,9 @@ function runStart() {
|
|
|
155
181
|
process.exit(1);
|
|
156
182
|
}
|
|
157
183
|
|
|
158
|
-
|
|
184
|
+
// Escape backslashes for Windows paths in the require string
|
|
185
|
+
const safeBootstrapPath = bootstrapPath.replace(/\\/g, '/'); // node require uses forward slashes or escaped backslashes
|
|
186
|
+
const cmd = `node -e "require('${safeBootstrapPath}').bootstrap()"`;
|
|
159
187
|
execSync(cmd, {
|
|
160
188
|
stdio: 'inherit',
|
|
161
189
|
env: { ...process.env, NODE_ENV: 'production' }
|