@maravilla-labs/cli 0.1.7 → 0.1.9
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/README.md +5 -0
- package/package.json +1 -1
- package/scripts/postinstall.js +28 -4
- package/scripts/update.js +19 -3
package/README.md
CHANGED
|
@@ -16,6 +16,11 @@ pnpm add -g @maravilla-labs/cli
|
|
|
16
16
|
yarn global add @maravilla-labs/cli
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
**Note:** To see installation progress with npm 7+, use the `--foreground-scripts` flag:
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @maravilla-labs/cli --foreground-scripts
|
|
22
|
+
```
|
|
23
|
+
|
|
19
24
|
Verify:
|
|
20
25
|
|
|
21
26
|
```bash
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -18,8 +18,17 @@ if (process.env.MARAVILLA_CLI_SKIP_INSTALL === '1' || process.env.CI) {
|
|
|
18
18
|
console.log('✿ Skipping Maravilla CLI binary install (CI or skip flag set)');
|
|
19
19
|
process.exit(0);
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
import { spawn } from 'child_process';
|
|
22
23
|
|
|
24
|
+
// Detect if output is being suppressed (npm 7+ behavior)
|
|
25
|
+
// Write to stderr as a fallback since it's more likely to be shown
|
|
26
|
+
const isOutputSuppressed = !process.stdout.isTTY && !process.env.npm_config_foreground_scripts;
|
|
27
|
+
if (isOutputSuppressed) {
|
|
28
|
+
console.error('✿ Installing Maravilla CLI binary...');
|
|
29
|
+
console.error('✿ To see detailed progress, run: npm install --foreground-scripts');
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
const __filename = fileURLToPath(import.meta.url);
|
|
24
33
|
const __dirname = path.dirname(__filename);
|
|
25
34
|
|
|
@@ -195,6 +204,7 @@ async function install() {
|
|
|
195
204
|
// Decide whether to download based on current vs requested version
|
|
196
205
|
const force = process.env.MARAVILLA_FORCE_INSTALL === '1';
|
|
197
206
|
let requested = null;
|
|
207
|
+
// Handle both "cli-v0.1.9" and "v0.1.9" formats
|
|
198
208
|
const m = tag.match(/v(\d+\.\d+\.\d+)/);
|
|
199
209
|
if (m) requested = m[1];
|
|
200
210
|
|
|
@@ -241,6 +251,14 @@ async function install() {
|
|
|
241
251
|
|
|
242
252
|
const innerDir = path.join(tmpDir, art);
|
|
243
253
|
const srcPath = path.join(innerDir, EXECUTABLE);
|
|
254
|
+
|
|
255
|
+
// Remove existing binary first to ensure clean replacement
|
|
256
|
+
try {
|
|
257
|
+
await fs.promises.unlink(INSTALL_PATH);
|
|
258
|
+
} catch (e) {
|
|
259
|
+
// File might not exist, that's okay
|
|
260
|
+
}
|
|
261
|
+
|
|
244
262
|
await fs.promises.copyFile(srcPath, INSTALL_PATH);
|
|
245
263
|
await fs.promises.chmod(INSTALL_PATH, 0o755);
|
|
246
264
|
log(chalk.green(`Installed to ${INSTALL_PATH}`));
|
|
@@ -273,7 +291,13 @@ async function sha256File(filePath) {
|
|
|
273
291
|
});
|
|
274
292
|
}
|
|
275
293
|
|
|
276
|
-
install()
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
294
|
+
install()
|
|
295
|
+
.then(() => {
|
|
296
|
+
if (isOutputSuppressed) {
|
|
297
|
+
console.error('✿ Maravilla CLI binary installed successfully!');
|
|
298
|
+
}
|
|
299
|
+
})
|
|
300
|
+
.catch(err => {
|
|
301
|
+
console.error(chalk.red(`${flower()} install failed: ${err.message}`));
|
|
302
|
+
process.exitCode = 1;
|
|
303
|
+
});
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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) => {
|