@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 +1 -1
- package/scripts/postinstall.js +22 -9
- package/scripts/update.js +3 -2
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -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
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
}
|