@maravilla-labs/cli 0.1.8 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maravilla-labs/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "NPM wrapper for the Maravilla CLI binary; downloads the right release for your platform.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Maravilla Labs",
@@ -204,6 +204,7 @@ async function install() {
204
204
  // Decide whether to download based on current vs requested version
205
205
  const force = process.env.MARAVILLA_FORCE_INSTALL === '1';
206
206
  let requested = null;
207
+ // Handle both "cli-v0.1.9" and "v0.1.9" formats
207
208
  const m = tag.match(/v(\d+\.\d+\.\d+)/);
208
209
  if (m) requested = m[1];
209
210
 
@@ -248,22 +249,63 @@ async function install() {
248
249
  log('Extracting archive');
249
250
  await extractArchive(archive, tmpDir, ext);
250
251
 
252
+ // Find the actual binary - it might be directly in tmpDir or in a subdirectory
251
253
  const innerDir = path.join(tmpDir, art);
252
- const srcPath = path.join(innerDir, EXECUTABLE);
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
+ }
270
+
271
+ // Remove existing binary first to ensure clean replacement
272
+ try {
273
+ await fs.promises.unlink(INSTALL_PATH);
274
+ log('Removed existing binary');
275
+ } catch (e) {
276
+ // File might not exist, that's okay
277
+ }
278
+
279
+ // Copy new binary
253
280
  await fs.promises.copyFile(srcPath, INSTALL_PATH);
254
281
  await fs.promises.chmod(INSTALL_PATH, 0o755);
255
- log(chalk.green(`Installed to ${INSTALL_PATH}`));
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)`));
256
286
 
257
287
  // Self-check: run --version
288
+ // Use absolute path and clear environment to avoid caching issues
258
289
  await new Promise((resolve, reject) => {
259
290
  log('Verifying install by running --version');
260
- const child = spawn(INSTALL_PATH, ['--version'], { stdio: ['ignore', 'pipe', 'pipe'] });
291
+ const child = spawn(INSTALL_PATH, ['--version'], {
292
+ stdio: ['ignore', 'pipe', 'pipe'],
293
+ env: { ...process.env, NODE_DISABLE_COLORS: '1' },
294
+ shell: false
295
+ });
261
296
  let out = '';
262
297
  child.stdout.on('data', (d) => (out += d.toString()))
263
298
  child.on('error', reject);
264
299
  child.on('exit', (code) => {
265
300
  if (code === 0) {
266
- log(chalk.green(`Version: ${out.trim()}`));
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
+ }
267
309
  resolve();
268
310
  } else {
269
311
  reject(new Error(`Version check failed with code ${code}`));
package/scripts/update.js CHANGED
@@ -111,11 +111,27 @@ async function main() {
111
111
  log(`Updating to ${chalk.cyan(tag)}`);
112
112
  }
113
113
 
114
- return await new Promise((resolve) => {
115
- const env = { ...process.env, MARAVILLA_FORCE_INSTALL: '1' };
116
- const child = spawn(process.execPath, [postinstall], { stdio: 'inherit', env });
114
+ // Force the specific version we want
115
+ const env = {
116
+ ...process.env,
117
+ MARAVILLA_FORCE_INSTALL: '1',
118
+ MARAVILLA_VERSION: tag // Pass the tag to ensure we get the right version
119
+ };
120
+
121
+ const result = await new Promise((resolve) => {
122
+ const child = spawn(process.execPath, [postinstall], { stdio: 'inherit', env });
117
123
  child.on('exit', (code) => resolve(code ?? 0));
118
124
  });
125
+
126
+ // Verify the update worked
127
+ if (result === 0) {
128
+ const newVersion = await currentVersion();
129
+ if (newVersion) {
130
+ log(chalk.green(`✅ Successfully updated to v${newVersion}`));
131
+ }
132
+ }
133
+
134
+ return result;
119
135
  }
120
136
 
121
137
  main().then((code) => process.exit(code)).catch((e) => {