@magneticjs/cli 0.1.1 → 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/dist/cli.js +17 -2
- package/package.json +1 -1
- package/scripts/install-server.js +38 -10
- package/src/dev.ts +17 -2
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;
|
package/package.json
CHANGED
|
@@ -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/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
|
|