@maravilla-labs/cli 0.1.9 → 0.1.10
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/package.json +1 -1
- package/scripts/postinstall.js +37 -4
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -249,30 +249,63 @@ async function install() {
|
|
|
249
249
|
log('Extracting archive');
|
|
250
250
|
await extractArchive(archive, tmpDir, ext);
|
|
251
251
|
|
|
252
|
+
// Find the actual binary - it might be directly in tmpDir or in a subdirectory
|
|
252
253
|
const innerDir = path.join(tmpDir, art);
|
|
253
|
-
|
|
254
|
+
let srcPath = path.join(innerDir, EXECUTABLE);
|
|
255
|
+
|
|
256
|
+
// Check if binary exists in expected location
|
|
257
|
+
if (!fs.existsSync(srcPath)) {
|
|
258
|
+
// Try direct path in tmpDir
|
|
259
|
+
const directPath = path.join(tmpDir, EXECUTABLE);
|
|
260
|
+
if (fs.existsSync(directPath)) {
|
|
261
|
+
srcPath = directPath;
|
|
262
|
+
log(chalk.yellow('Binary found in root of archive'));
|
|
263
|
+
} else {
|
|
264
|
+
// List directory contents to debug
|
|
265
|
+
const files = await fs.promises.readdir(tmpDir, { recursive: true });
|
|
266
|
+
console.error('Archive contents:', files);
|
|
267
|
+
throw new Error(`Binary not found at expected paths. Looking for: ${EXECUTABLE}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
254
270
|
|
|
255
271
|
// Remove existing binary first to ensure clean replacement
|
|
256
272
|
try {
|
|
257
273
|
await fs.promises.unlink(INSTALL_PATH);
|
|
274
|
+
log('Removed existing binary');
|
|
258
275
|
} catch (e) {
|
|
259
276
|
// File might not exist, that's okay
|
|
260
277
|
}
|
|
261
278
|
|
|
279
|
+
// Copy new binary
|
|
262
280
|
await fs.promises.copyFile(srcPath, INSTALL_PATH);
|
|
263
281
|
await fs.promises.chmod(INSTALL_PATH, 0o755);
|
|
264
|
-
|
|
282
|
+
|
|
283
|
+
// Verify the file was actually copied
|
|
284
|
+
const stats = await fs.promises.stat(INSTALL_PATH);
|
|
285
|
+
log(chalk.green(`Installed to ${INSTALL_PATH} (${stats.size} bytes)`));
|
|
265
286
|
|
|
266
287
|
// Self-check: run --version
|
|
288
|
+
// Use absolute path and clear environment to avoid caching issues
|
|
267
289
|
await new Promise((resolve, reject) => {
|
|
268
290
|
log('Verifying install by running --version');
|
|
269
|
-
const child = spawn(INSTALL_PATH, ['--version'], {
|
|
291
|
+
const child = spawn(INSTALL_PATH, ['--version'], {
|
|
292
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
293
|
+
env: { ...process.env, NODE_DISABLE_COLORS: '1' },
|
|
294
|
+
shell: false
|
|
295
|
+
});
|
|
270
296
|
let out = '';
|
|
271
297
|
child.stdout.on('data', (d) => (out += d.toString()))
|
|
272
298
|
child.on('error', reject);
|
|
273
299
|
child.on('exit', (code) => {
|
|
274
300
|
if (code === 0) {
|
|
275
|
-
|
|
301
|
+
const version = out.trim();
|
|
302
|
+
log(chalk.green(`Version: ${version}`));
|
|
303
|
+
|
|
304
|
+
// Extra check: if we expected a specific version, verify it
|
|
305
|
+
if (requested && !version.includes(requested)) {
|
|
306
|
+
log(chalk.yellow(`Warning: Expected version ${requested} but got ${version}`));
|
|
307
|
+
log(chalk.yellow('The binary might be cached. Try running the command directly.'));
|
|
308
|
+
}
|
|
276
309
|
resolve();
|
|
277
310
|
} else {
|
|
278
311
|
reject(new Error(`Version check failed with code ${code}`));
|