@magneticjs/cli 0.1.0 → 0.1.2

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 CHANGED
@@ -1,11 +1,11 @@
1
- # @magnetic/cli
1
+ # @magneticjs/cli
2
2
 
3
- Build, develop, and deploy Magnetic server-driven UI apps.
3
+ Build, develop, and deploy [Magnetic](https://github.com/inventhq/magnetic) server-driven UI apps.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install -g @magnetic/cli
8
+ npm install -g @magneticjs/cli
9
9
  ```
10
10
 
11
11
  This also downloads the `magnetic-v8-server` binary for your platform via postinstall.
package/dist/cli.js CHANGED
@@ -228,8 +228,23 @@ async function startDev(opts) {
228
228
  const outDir = join3(appDir, "dist");
229
229
  const serverBin = opts.serverBin || findServerBinary(monorepoRoot || appDir);
230
230
  if (!serverBin) {
231
- console.error("[magnetic] Cannot find magnetic-v8-server binary.");
232
- console.error(" Build it with: cargo build --release -p magnetic-v8-server");
231
+ console.error("");
232
+ console.error(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
233
+ console.error(" \u2551 MAGNETIC: Server binary not found \u2551");
234
+ console.error(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
235
+ console.error("");
236
+ console.error(" `magnetic dev` requires the magnetic-v8-server binary.");
237
+ console.error(" It should have been downloaded during `npm install @magneticjs/cli`.");
238
+ console.error("");
239
+ console.error(" To fix:");
240
+ console.error(" npm rebuild @magneticjs/cli");
241
+ console.error("");
242
+ console.error(" Or build from source:");
243
+ console.error(" git clone https://github.com/inventhq/magnetic.git");
244
+ console.error(" cd magnetic/rs/crates/magnetic-v8-server");
245
+ console.error(" cargo build --release");
246
+ console.error(" cp target/release/magnetic-v8-server $(npm root -g)/@magneticjs/cli/bin/");
247
+ console.error("");
233
248
  process.exit(1);
234
249
  }
235
250
  let serverProcess = null;
@@ -375,7 +390,7 @@ function getArg(flag) {
375
390
  }
376
391
  function usage() {
377
392
  console.log(`
378
- @magnetic/cli \u2014 Build and deploy server-driven UI apps
393
+ @magneticjs/cli \u2014 Build and deploy server-driven UI apps
379
394
 
380
395
  Usage:
381
396
  magnetic dev Start dev mode (watch + rebuild + serve)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magneticjs/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Magnetic CLI — build, dev, and deploy server-driven UI apps",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * install-server.js — Downloads the prebuilt magnetic-v8-server binary
4
- * for the current platform during `npm install @magnetic/cli`.
4
+ * for the current platform during `npm install @magneticjs/cli`.
5
5
  *
6
6
  * Update strategy:
7
- * - Version is read from ../package.json (matches @magnetic/cli version)
8
- * - When user runs `npm update @magnetic/cli`, this script re-runs
7
+ * - Version is read from ../package.json (matches @magneticjs/cli version)
8
+ * - When user runs `npm update @magneticjs/cli`, this script re-runs
9
9
  * - Binary version is tracked in bin/.version
10
10
  * - If version mismatch → re-download; if match → skip
11
11
  *
@@ -69,24 +69,52 @@ console.log(`[magnetic] ${url}`);
69
69
 
70
70
  try {
71
71
  mkdirSync(binDir, { recursive: true });
72
- // Use curl or wget — available on all platforms
72
+
73
+ // Download — curl with -L follows GitHub's 302 redirect
74
+ let downloaded = false;
73
75
  try {
74
- execSync(`curl -fsSL "${url}" | tar xz -C "${binDir}"`, { stdio: 'pipe' });
75
- } catch {
76
- execSync(`wget -qO- "${url}" | tar xz -C "${binDir}"`, { stdio: 'pipe' });
76
+ execSync(`curl -fsSL "${url}" -o "${join(binDir, filename)}"`, { stdio: 'pipe' });
77
+ execSync(`tar xzf "${join(binDir, filename)}" -C "${binDir}"`, { stdio: 'pipe' });
78
+ downloaded = true;
79
+ } catch (e1) {
80
+ try {
81
+ execSync(`wget -q "${url}" -O "${join(binDir, filename)}"`, { stdio: 'pipe' });
82
+ execSync(`tar xzf "${join(binDir, filename)}" -C "${binDir}"`, { stdio: 'pipe' });
83
+ downloaded = true;
84
+ } catch (e2) {
85
+ // Both failed
86
+ }
77
87
  }
78
88
 
79
- if (existsSync(binPath)) {
89
+ // Clean up tarball
90
+ try { execSync(`rm -f "${join(binDir, filename)}"`, { stdio: 'pipe' }); } catch {}
91
+
92
+ if (downloaded && existsSync(binPath)) {
80
93
  chmodSync(binPath, 0o755);
81
94
  writeFileSync(versionFile, version);
82
95
  console.log(`[magnetic] ✓ Server binary v${version} installed: ${binPath}`);
83
96
  } else {
84
- throw new Error('Binary not found after extraction');
97
+ throw new Error(`Download failed or binary not found after extraction`);
85
98
  }
86
99
  } catch (err) {
87
- console.warn(`[magnetic] Could not download prebuilt binary: ${err.message}`);
88
- console.warn('[magnetic] The CLI will still work, but you need the server binary for `magnetic dev`.');
89
- console.warn('[magnetic] Build from source: cargo build --release -p magnetic-v8-server');
90
- // Don't fail the install — just warn
100
+ console.error('');
101
+ console.error(' ╔══════════════════════════════════════════════════════════════╗');
102
+ console.error(' ║ MAGNETIC: Server binary download failed ║');
103
+ console.error(' ╚══════════════════════════════════════════════════════════════╝');
104
+ console.error('');
105
+ console.error(` URL: ${url}`);
106
+ console.error(` Error: ${err.message}`);
107
+ console.error('');
108
+ console.error(' `magnetic dev` will NOT work without the server binary.');
109
+ console.error('');
110
+ console.error(' To fix, either:');
111
+ console.error(' 1. Re-run: npm rebuild @magneticjs/cli');
112
+ console.error(' 2. Build from source:');
113
+ console.error(' git clone https://github.com/inventhq/magnetic.git');
114
+ console.error(' cd magnetic/rs/crates/magnetic-v8-server');
115
+ console.error(' cargo build --release');
116
+ console.error(' cp target/release/magnetic-v8-server $(npm root -g)/@magneticjs/cli/bin/');
117
+ console.error('');
118
+ // Don't fail npm install — but make the error impossible to miss
91
119
  process.exit(0);
92
120
  }
package/src/cli.ts CHANGED
@@ -37,7 +37,7 @@ function getArg(flag: string): string | undefined {
37
37
 
38
38
  function usage() {
39
39
  console.log(`
40
- @magnetic/cli — Build and deploy server-driven UI apps
40
+ @magneticjs/cli — Build and deploy server-driven UI apps
41
41
 
42
42
  Usage:
43
43
  magnetic dev Start dev mode (watch + rebuild + serve)
package/src/dev.ts CHANGED
@@ -39,8 +39,23 @@ export async function startDev(opts: DevOptions): Promise<void> {
39
39
  // Find the V8 server binary
40
40
  const serverBin = opts.serverBin || findServerBinary(monorepoRoot || appDir);
41
41
  if (!serverBin) {
42
- console.error('[magnetic] Cannot find magnetic-v8-server binary.');
43
- console.error(' Build it with: cargo build --release -p magnetic-v8-server');
42
+ console.error('');
43
+ console.error(' ╔══════════════════════════════════════════════════════════════╗');
44
+ console.error(' ║ MAGNETIC: Server binary not found ║');
45
+ console.error(' ╚══════════════════════════════════════════════════════════════╝');
46
+ console.error('');
47
+ console.error(' `magnetic dev` requires the magnetic-v8-server binary.');
48
+ console.error(' It should have been downloaded during `npm install @magneticjs/cli`.');
49
+ console.error('');
50
+ console.error(' To fix:');
51
+ console.error(' npm rebuild @magneticjs/cli');
52
+ console.error('');
53
+ console.error(' Or build from source:');
54
+ console.error(' git clone https://github.com/inventhq/magnetic.git');
55
+ console.error(' cd magnetic/rs/crates/magnetic-v8-server');
56
+ console.error(' cargo build --release');
57
+ console.error(' cp target/release/magnetic-v8-server $(npm root -g)/@magneticjs/cli/bin/');
58
+ console.error('');
44
59
  process.exit(1);
45
60
  }
46
61