@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 +3 -3
- package/dist/cli.js +18 -3
- package/package.json +1 -1
- package/scripts/install-server.js +41 -13
- package/src/cli.ts +1 -1
- package/src/dev.ts +17 -2
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# @
|
|
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 @
|
|
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("
|
|
232
|
-
console.error("
|
|
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
|
-
@
|
|
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,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 @
|
|
4
|
+
* for the current platform during `npm install @magneticjs/cli`.
|
|
5
5
|
*
|
|
6
6
|
* Update strategy:
|
|
7
|
-
* - Version is read from ../package.json (matches @
|
|
8
|
-
* - When user runs `npm update @
|
|
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
|
-
|
|
72
|
+
|
|
73
|
+
// Download — curl with -L follows GitHub's 302 redirect
|
|
74
|
+
let downloaded = false;
|
|
73
75
|
try {
|
|
74
|
-
execSync(`curl -fsSL "${url}"
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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(
|
|
97
|
+
throw new Error(`Download failed or binary not found after extraction`);
|
|
85
98
|
}
|
|
86
99
|
} catch (err) {
|
|
87
|
-
console.
|
|
88
|
-
console.
|
|
89
|
-
console.
|
|
90
|
-
|
|
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
|
-
@
|
|
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('
|
|
43
|
-
console.error('
|
|
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
|
|