@maravilla-labs/cli 0.1.3 → 0.1.4

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.3",
3
+ "version": "0.1.4",
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",
@@ -150,17 +150,30 @@ async function install() {
150
150
  const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'maravilla-cli-'));
151
151
  const archive = path.join(tmpDir, assetFile);
152
152
 
153
- // Fast path: if installed and matches latest, skip
154
- if (VERSION === 'latest') {
155
- try {
156
- const cur = await currentVersion();
157
- const m = tag.match(/v(\d+\.\d+\.\d+)/);
158
- const latest = m ? m[1] : null;
159
- if (cur && latest && cmpSemver(cur, latest) >= 0) {
160
- log(chalk.green(`Already up to date (v${cur})`));
153
+ // Decide whether to download based on current vs requested version
154
+ const force = process.env.MARAVILLA_FORCE_INSTALL === '1';
155
+ let requested = null;
156
+ const m = tag.match(/v(\d+\.\d+\.\d+)/);
157
+ if (m) requested = m[1];
158
+ let cur = null;
159
+ try { cur = await currentVersion(); } catch {}
160
+
161
+ if (!force) {
162
+ if (process.env.MARAVILLA_OFFLINE === '1') {
163
+ if (cur) {
164
+ if (requested && cmpSemver(cur, requested) < 0) {
165
+ log(chalk.yellow(`Offline mode: cannot update to v${requested}; keeping existing v${cur}`));
166
+ return;
167
+ }
168
+ log(chalk.yellow(`Offline mode: keeping existing v${cur}`));
161
169
  return;
162
170
  }
163
- } catch {}
171
+ throw new Error('Offline mode: no existing binary to keep');
172
+ }
173
+ if (cur && requested && cmpSemver(cur, requested) >= 0) {
174
+ log(chalk.green(`Already up to date (v${cur})`));
175
+ return;
176
+ }
164
177
  }
165
178
 
166
179
  log(chalk.bold(`Installing ${BIN_NAME} ${chalk.cyan(tag)} for ${chalk.cyan(target)}`));
package/scripts/update.js CHANGED
@@ -82,8 +82,9 @@ async function main() {
82
82
  log(`Updating to ${chalk.cyan(tag)}`);
83
83
  }
84
84
 
85
- return await new Promise((resolve) => {
86
- const child = spawn(process.execPath, [postinstall], { stdio: 'inherit' });
85
+ return await new Promise((resolve) => {
86
+ const env = { ...process.env, MARAVILLA_FORCE_INSTALL: '1' };
87
+ const child = spawn(process.execPath, [postinstall], { stdio: 'inherit', env });
87
88
  child.on('exit', (code) => resolve(code ?? 0));
88
89
  });
89
90
  }