@myop/cli 0.1.52 β 0.1.53
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/myop-cli.js +935 -1032
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
import
|
|
6
|
-
import { select as
|
|
7
|
-
import { Command as
|
|
8
|
-
import { execSync as Q, spawn as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { URL as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
const
|
|
2
|
+
var St = Object.defineProperty;
|
|
3
|
+
var xt = (o, t, e) => t in o ? St(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
4
|
+
var we = (o, t, e) => xt(o, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
+
import V from "ora";
|
|
6
|
+
import { select as ot, Separator as De } from "@inquirer/prompts";
|
|
7
|
+
import { Command as bt, Option as ue } from "commander";
|
|
8
|
+
import { execSync as Q, spawn as $t } from "child_process";
|
|
9
|
+
import N, { join as _e } from "path";
|
|
10
|
+
import P, { readFileSync as Ct } from "fs";
|
|
11
|
+
import Be from "crypto";
|
|
12
|
+
import Mt from "http";
|
|
13
|
+
import { URL as nt, URLSearchParams as st } from "url";
|
|
14
|
+
import Pt from "open";
|
|
15
|
+
import it from "os";
|
|
16
|
+
const Et = `
|
|
17
17
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
18
18
|
|
|
19
19
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -55,81 +55,81 @@ Examples:
|
|
|
55
55
|
verbose: !1
|
|
56
56
|
},
|
|
57
57
|
myopConfig: null
|
|
58
|
-
},
|
|
58
|
+
}, rt = {
|
|
59
59
|
name: "π₯ Install Myop generated dependencies",
|
|
60
60
|
value: "myopInstall",
|
|
61
61
|
description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
|
|
62
62
|
action: async () => {
|
|
63
63
|
console.info("installing... ");
|
|
64
64
|
for (const o of v.myopConfig.flows) {
|
|
65
|
-
const t =
|
|
65
|
+
const t = N.join(v.executionPath, "/node_modules/@myop/flow-types/");
|
|
66
66
|
console.info(`Generate flow at ${t}`), console.info(`Generated flow at ${t}`);
|
|
67
67
|
}
|
|
68
68
|
process.exit();
|
|
69
69
|
}
|
|
70
|
-
},
|
|
71
|
-
const t =
|
|
70
|
+
}, Ot = (o) => {
|
|
71
|
+
const t = N.join(v.executionPath, o);
|
|
72
72
|
console.info(`reading config file from: ${t}`);
|
|
73
|
-
const e =
|
|
73
|
+
const e = P.readFileSync(t, "utf8"), n = JSON.parse(e);
|
|
74
74
|
return console.info("config file loaded, ", n), n;
|
|
75
|
-
},
|
|
76
|
-
const e =
|
|
75
|
+
}, Je = (o, t) => {
|
|
76
|
+
const e = N.join(v.executionPath, o);
|
|
77
77
|
console.info(`writing config file to: ${e}`);
|
|
78
78
|
try {
|
|
79
79
|
const n = JSON.stringify(t, null, 2);
|
|
80
|
-
|
|
80
|
+
P.writeFileSync(e, n), console.info(`config file updated ${n}`);
|
|
81
81
|
} catch (n) {
|
|
82
82
|
throw console.info(`error ${n} while writing to ${e}, JSON: ${t}`), console.log(`
|
|
83
83
|
β οΈ Failed write config file to ${e}, for more info use verbose flag`), n;
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, at = {
|
|
86
86
|
name: "π Add flow definition to your project",
|
|
87
87
|
value: "addFlow",
|
|
88
88
|
description: "Adds flow to yours myop.config.json",
|
|
89
89
|
_action: (o) => {
|
|
90
|
-
v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o),
|
|
90
|
+
v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), Je(v.options.configPath, v.myopConfig);
|
|
91
91
|
},
|
|
92
92
|
action: async () => {
|
|
93
93
|
}
|
|
94
|
-
},
|
|
94
|
+
}, lt = {
|
|
95
95
|
name: "π« Remove flow definition from your project",
|
|
96
96
|
value: "removeFlow",
|
|
97
97
|
description: "Removes flow to yours myop.config.json",
|
|
98
98
|
_action: (o) => {
|
|
99
|
-
v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o),
|
|
99
|
+
v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), Je(v.options.configPath, v.myopConfig);
|
|
100
100
|
},
|
|
101
101
|
action: () => {
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, It = {
|
|
104
104
|
name: "π Quit",
|
|
105
105
|
value: "quit",
|
|
106
106
|
description: "Quit and continue coding.",
|
|
107
107
|
action: () => {
|
|
108
108
|
process.exit();
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, kt = {
|
|
111
111
|
name: "π’ Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
114
|
-
},
|
|
114
|
+
}, Rt = {
|
|
115
115
|
name: "π΅ Create new experience",
|
|
116
116
|
value: "-",
|
|
117
117
|
disabled: "(not available yet)"
|
|
118
|
-
},
|
|
118
|
+
}, Nt = {
|
|
119
119
|
name: "π‘ Create new skin",
|
|
120
120
|
value: "-",
|
|
121
121
|
disabled: "(not available yet)"
|
|
122
|
-
},
|
|
122
|
+
}, Tt = {
|
|
123
123
|
name: "π΄ Create new flow",
|
|
124
124
|
value: "-",
|
|
125
125
|
disabled: "(not available yet)"
|
|
126
|
-
},
|
|
126
|
+
}, _t = {
|
|
127
127
|
name: "π Define new custom Myop message",
|
|
128
128
|
value: "generateMyopMessage",
|
|
129
129
|
description: "οΈHelp you creates the right structure for a new Myop message, including types and handlers.",
|
|
130
130
|
disabled: "(not available yet)"
|
|
131
|
-
},
|
|
132
|
-
function
|
|
131
|
+
}, Ft = [_t, kt, Rt, Nt, Tt];
|
|
132
|
+
function jt(o, t, e, n) {
|
|
133
133
|
return `<!DOCTYPE html>
|
|
134
134
|
<html lang="en">
|
|
135
135
|
<head>
|
|
@@ -219,19 +219,19 @@ ${n}
|
|
|
219
219
|
</body>
|
|
220
220
|
</html>`;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function Dt(o) {
|
|
223
223
|
return o.includes("esbuild") && o.includes("another platform");
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function At(o) {
|
|
226
226
|
return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Lt() {
|
|
229
229
|
console.error(`
|
|
230
230
|
β esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
|
|
231
231
|
This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows β Mac, or Mac β Linux).
|
|
232
232
|
`);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function Ut(o) {
|
|
235
235
|
return new Promise((t) => {
|
|
236
236
|
console.log(`π§ Attempting to fix: removing node_modules and reinstalling...
|
|
237
237
|
`);
|
|
@@ -244,9 +244,9 @@ function Jt(o) {
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
console.log(" β Removed node_modules"), console.log(` β³ Running npm install...
|
|
247
|
-
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i,
|
|
247
|
+
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, d, g) => {
|
|
248
248
|
if (i) {
|
|
249
|
-
console.error("β npm install failed:", i.message),
|
|
249
|
+
console.error("β npm install failed:", i.message), g && console.error(g), t(!1);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
console.log(` β Dependencies reinstalled successfully!
|
|
@@ -255,79 +255,79 @@ function Jt(o) {
|
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
async function
|
|
258
|
+
async function ct(o, t, e, n, s = {}) {
|
|
259
259
|
const {
|
|
260
260
|
hasTriedPlatformFix: i = !1,
|
|
261
|
-
hasTriedInstall:
|
|
262
|
-
onRetry:
|
|
263
|
-
} = s,
|
|
264
|
-
return !i &&
|
|
265
|
-
`),
|
|
266
|
-
n("npm install", (
|
|
267
|
-
if (
|
|
268
|
-
console.error("β Failed to install dependencies:",
|
|
261
|
+
hasTriedInstall: d = !1,
|
|
262
|
+
onRetry: g
|
|
263
|
+
} = s, h = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
|
|
264
|
+
return !i && Dt(h) ? (Lt(), await Ut(n) && g ? (console.log(`π Retrying build...
|
|
265
|
+
`), g(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && At(h) ? (console.log("π¦ Missing dependencies detected, running npm install..."), new Promise((l) => {
|
|
266
|
+
n("npm install", (c, y, S) => {
|
|
267
|
+
if (c) {
|
|
268
|
+
console.error("β Failed to install dependencies:", c.message), S && console.error(S), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
console.log("β
Dependencies installed"),
|
|
271
|
+
console.log("β
Dependencies installed"), g && g(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
272
272
|
});
|
|
273
|
-
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall:
|
|
273
|
+
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: d };
|
|
274
274
|
}
|
|
275
|
-
async function
|
|
275
|
+
async function be() {
|
|
276
276
|
const o = await import("fs"), t = await import("path"), { exec: e } = await import("child_process"), n = await import("http"), { createHash: s } = await import("node:crypto");
|
|
277
277
|
let i;
|
|
278
278
|
if (import.meta.url.startsWith("file://")) {
|
|
279
|
-
const
|
|
280
|
-
i = t.default.dirname(
|
|
279
|
+
const r = new URL(import.meta.url).pathname, m = process.platform === "win32" && r.startsWith("/") ? r.slice(1) : r;
|
|
280
|
+
i = t.default.dirname(m);
|
|
281
281
|
} else
|
|
282
282
|
i = t.default.dirname(import.meta.url);
|
|
283
|
-
const
|
|
284
|
-
let y = "./dist", S = !1, x = !1,
|
|
283
|
+
const d = t.default.join(i, "commands", "dev", "management-website"), g = o.default.readFileSync(t.default.join(d, "styles.css"), "utf-8"), h = o.default.readFileSync(t.default.join(d, "app.js"), "utf-8"), l = 9292, c = 9293;
|
|
284
|
+
let y = "./dist", S = !1, x = !1, u = !1, p = null;
|
|
285
285
|
const E = () => {
|
|
286
286
|
try {
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
return
|
|
287
|
+
const a = o.default.readdirSync(".").filter((r) => !r.endsWith(".html") || r.startsWith(".") ? !1 : o.default.statSync(r).isFile());
|
|
288
|
+
if (a.length === 1)
|
|
289
|
+
return a[0];
|
|
290
290
|
} catch {
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
|
-
},
|
|
293
|
+
}, I = () => {
|
|
294
294
|
try {
|
|
295
|
-
const
|
|
296
|
-
return !!(
|
|
295
|
+
const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
|
|
296
|
+
return !!(a.scripts && a.scripts.build);
|
|
297
297
|
} catch {
|
|
298
298
|
return !1;
|
|
299
299
|
}
|
|
300
|
-
},
|
|
301
|
-
const
|
|
302
|
-
let
|
|
303
|
-
|
|
300
|
+
}, $ = (a) => {
|
|
301
|
+
const r = process.platform;
|
|
302
|
+
let m;
|
|
303
|
+
r === "darwin" ? m = `open "${a}"` : r === "win32" ? m = `start "" "${a}"` : m = `xdg-open "${a}"`, e(m, (f) => {
|
|
304
304
|
});
|
|
305
|
-
},
|
|
305
|
+
}, C = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
|
|
306
306
|
let M, R, k = !1;
|
|
307
|
-
|
|
308
|
-
const L =
|
|
307
|
+
p = E();
|
|
308
|
+
const L = I();
|
|
309
309
|
try {
|
|
310
|
-
const
|
|
311
|
-
M =
|
|
312
|
-
} catch (
|
|
313
|
-
|
|
310
|
+
const a = o.default.readFileSync(j, "utf-8"), r = JSON.parse(a);
|
|
311
|
+
M = r.componentId || "DEV", R = r.componentName || r.name || null, k = r.HMR === !0, p && !L && (u = !0, k = !0, console.log(`π Single HTML file mode: ${p}`)), k && console.log("π₯ HMR enabled");
|
|
312
|
+
} catch (a) {
|
|
313
|
+
p && !L ? (u = !0, M = "DEV", R = t.default.basename(p, ".html"), k = !0, console.log(`π Single HTML file mode: ${p}`), console.log("π₯ HMR enabled")) : (console.error("β Error reading myop.config.json:", a.message), process.exit(1));
|
|
314
314
|
}
|
|
315
|
-
const
|
|
315
|
+
const A = async () => {
|
|
316
316
|
if (M !== "DEV" && M !== "NEW")
|
|
317
317
|
return M;
|
|
318
318
|
try {
|
|
319
|
-
const
|
|
320
|
-
const
|
|
319
|
+
const r = ((await new Promise((w, b) => {
|
|
320
|
+
const O = {
|
|
321
321
|
hostname: "localhost",
|
|
322
|
-
port:
|
|
322
|
+
port: c,
|
|
323
323
|
path: "/_list",
|
|
324
324
|
method: "GET",
|
|
325
325
|
timeout: 1e3
|
|
326
|
-
}, F = n.default.request(
|
|
327
|
-
let
|
|
328
|
-
H.on("data", (ee) =>
|
|
326
|
+
}, F = n.default.request(O, (H) => {
|
|
327
|
+
let G = "";
|
|
328
|
+
H.on("data", (ee) => G += ee), H.on("end", () => {
|
|
329
329
|
try {
|
|
330
|
-
w(JSON.parse(
|
|
330
|
+
w(JSON.parse(G));
|
|
331
331
|
} catch {
|
|
332
332
|
w({ components: [] });
|
|
333
333
|
}
|
|
@@ -337,19 +337,19 @@ async function Ce() {
|
|
|
337
337
|
F.destroy(), w({ components: [] });
|
|
338
338
|
}), F.end();
|
|
339
339
|
})).components || []).map(([w]) => w).filter((w) => w === "DEV" || w === "NEW" || /^DEV\d+$/.test(w) || /^NEW\d+$/.test(w));
|
|
340
|
-
if (
|
|
340
|
+
if (r.length === 0)
|
|
341
341
|
return "DEV1";
|
|
342
|
-
const
|
|
342
|
+
const m = r.map((w) => {
|
|
343
343
|
if (w === "DEV" || w === "NEW") return 1;
|
|
344
|
-
const
|
|
345
|
-
return
|
|
344
|
+
const b = w.match(/^DEV(\d+)$/), O = w.match(/^NEW(\d+)$/);
|
|
345
|
+
return b ? parseInt(b[1], 10) : O ? parseInt(O[1], 10) : 0;
|
|
346
346
|
}).filter((w) => w > 0);
|
|
347
|
-
return `DEV${Math.max(...
|
|
347
|
+
return `DEV${Math.max(...m, 0) + 1}`;
|
|
348
348
|
} catch {
|
|
349
349
|
return "DEV1";
|
|
350
350
|
}
|
|
351
|
-
},
|
|
352
|
-
const
|
|
351
|
+
}, _ = process.cwd(), z = (a) => {
|
|
352
|
+
const r = t.default.extname(a).toLowerCase();
|
|
353
353
|
return {
|
|
354
354
|
".html": "text/html",
|
|
355
355
|
".js": "text/javascript",
|
|
@@ -360,42 +360,42 @@ async function Ce() {
|
|
|
360
360
|
".gif": "image/gif",
|
|
361
361
|
".svg": "image/svg+xml",
|
|
362
362
|
".ico": "image/x-icon"
|
|
363
|
-
}[
|
|
364
|
-
},
|
|
365
|
-
if (
|
|
366
|
-
const
|
|
367
|
-
|
|
363
|
+
}[r] || "application/octet-stream";
|
|
364
|
+
}, T = /* @__PURE__ */ new Map(), oe = [], Pe = 50, X = [], se = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), ft = (a, r, m) => {
|
|
365
|
+
if (a.url.startsWith("/_hmr/")) {
|
|
366
|
+
const f = a.url.split("/_hmr/")[1], w = a.headers["sec-websocket-key"], b = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
367
|
+
r.write(
|
|
368
368
|
`HTTP/1.1 101 Switching Protocols\r
|
|
369
369
|
Upgrade: websocket\r
|
|
370
370
|
Connection: Upgrade\r
|
|
371
|
-
Sec-WebSocket-Accept: ${
|
|
371
|
+
Sec-WebSocket-Accept: ${b}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
|
-
),
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
}),
|
|
378
|
-
const
|
|
379
|
-
|
|
374
|
+
), q.has(f) || q.set(f, /* @__PURE__ */ new Set()), q.get(f).add(r), console.log(`π HMR client connected: ${f}`), r.on("close", () => {
|
|
375
|
+
const O = q.get(f);
|
|
376
|
+
O && (O.delete(r), O.size === 0 && q.delete(f)), console.log(`π HMR client disconnected: ${f}`);
|
|
377
|
+
}), r.on("error", () => {
|
|
378
|
+
const O = q.get(f);
|
|
379
|
+
O && O.delete(r);
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
|
-
},
|
|
383
|
-
if (
|
|
384
|
-
let
|
|
385
|
-
|
|
382
|
+
}, Ee = n.default.createServer((a, r) => {
|
|
383
|
+
if (r.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
|
|
384
|
+
let m = "";
|
|
385
|
+
a.on("data", (f) => m += f), a.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId:
|
|
388
|
-
|
|
389
|
-
const F =
|
|
390
|
-
console.log(`β
Registered: ${
|
|
391
|
-
const H = Array.from(
|
|
392
|
-
id:
|
|
387
|
+
const { componentId: f, distPath: w, componentName: b, htmlFile: O } = JSON.parse(m);
|
|
388
|
+
T.set(f, { path: w, name: b || null, htmlFile: O || null });
|
|
389
|
+
const F = b ? ` (${b})` : "";
|
|
390
|
+
console.log(`β
Registered: ${f}${F} -> ${w}${O ? "/" + O : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
|
|
391
|
+
const H = Array.from(T.entries()).map(([G, ee]) => ({
|
|
392
|
+
id: G,
|
|
393
393
|
path: ee.path,
|
|
394
394
|
name: ee.name
|
|
395
395
|
}));
|
|
396
|
-
|
|
396
|
+
X.forEach((G) => {
|
|
397
397
|
try {
|
|
398
|
-
|
|
398
|
+
G.write(`data: ${JSON.stringify({
|
|
399
399
|
type: "components",
|
|
400
400
|
components: H
|
|
401
401
|
})}
|
|
@@ -404,24 +404,24 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
404
404
|
} catch {
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
|
-
} catch (
|
|
408
|
-
|
|
407
|
+
} catch (f) {
|
|
408
|
+
r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
|
|
409
409
|
}
|
|
410
410
|
});
|
|
411
|
-
} else if (
|
|
412
|
-
let
|
|
413
|
-
|
|
411
|
+
} else if (a.method === "POST" && a.url === "/_unregister") {
|
|
412
|
+
let m = "";
|
|
413
|
+
a.on("data", (f) => m += f), a.on("end", () => {
|
|
414
414
|
try {
|
|
415
|
-
const { componentId:
|
|
416
|
-
|
|
417
|
-
const w = Array.from(
|
|
418
|
-
id:
|
|
419
|
-
path:
|
|
420
|
-
name:
|
|
415
|
+
const { componentId: f } = JSON.parse(m);
|
|
416
|
+
T.delete(f), console.log(`β Unregistered: ${f}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
|
|
417
|
+
const w = Array.from(T.entries()).map(([b, O]) => ({
|
|
418
|
+
id: b,
|
|
419
|
+
path: O.path,
|
|
420
|
+
name: O.name
|
|
421
421
|
}));
|
|
422
|
-
|
|
422
|
+
X.forEach((b) => {
|
|
423
423
|
try {
|
|
424
|
-
|
|
424
|
+
b.write(`data: ${JSON.stringify({
|
|
425
425
|
type: "components",
|
|
426
426
|
components: w
|
|
427
427
|
})}
|
|
@@ -430,74 +430,74 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
430
430
|
} catch {
|
|
431
431
|
}
|
|
432
432
|
});
|
|
433
|
-
} catch (
|
|
434
|
-
|
|
433
|
+
} catch (f) {
|
|
434
|
+
r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
|
-
} else if (
|
|
438
|
-
|
|
439
|
-
else if (
|
|
440
|
-
let
|
|
441
|
-
|
|
437
|
+
} else if (a.method === "GET" && a.url === "/_list")
|
|
438
|
+
r.writeHead(200), r.end(JSON.stringify({ components: Array.from(T.entries()) }));
|
|
439
|
+
else if (a.method === "POST" && a.url === "/_hmr_notify") {
|
|
440
|
+
let m = "";
|
|
441
|
+
a.on("data", (f) => m += f), a.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId:
|
|
444
|
-
if (
|
|
445
|
-
console.log(`π₯ Notifying ${
|
|
446
|
-
const
|
|
447
|
-
|
|
443
|
+
const { componentId: f, html: w } = JSON.parse(m), b = q.get(f);
|
|
444
|
+
if (b && b.size > 0) {
|
|
445
|
+
console.log(`π₯ Notifying ${b.size} HMR client(s) for: ${f}`);
|
|
446
|
+
const O = JSON.stringify({ type: "update", html: w }), F = Qe(O);
|
|
447
|
+
b.forEach((H) => {
|
|
448
448
|
try {
|
|
449
449
|
H.write(F);
|
|
450
450
|
} catch {
|
|
451
|
-
|
|
451
|
+
b.delete(H);
|
|
452
452
|
}
|
|
453
|
-
}),
|
|
453
|
+
}), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: b.size }));
|
|
454
454
|
} else
|
|
455
|
-
|
|
456
|
-
} catch (
|
|
457
|
-
|
|
455
|
+
r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
|
|
456
|
+
} catch (f) {
|
|
457
|
+
r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
|
|
458
458
|
}
|
|
459
459
|
});
|
|
460
460
|
} else
|
|
461
|
-
|
|
462
|
-
}), ge = n.default.createServer((
|
|
463
|
-
if (
|
|
464
|
-
|
|
461
|
+
r.writeHead(404), r.end(JSON.stringify({ error: "Not found" }));
|
|
462
|
+
}), ge = n.default.createServer((a, r) => {
|
|
463
|
+
if (a.url.includes("..")) {
|
|
464
|
+
r.writeHead(403, { "Content-Type": "text/plain" }), r.end("Forbidden");
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
469
|
-
const J =
|
|
467
|
+
const m = new URL(a.url, `http://localhost:${l}`), f = m.pathname, w = f.split("/").filter((J) => J);
|
|
468
|
+
if (f.startsWith("/consume")) {
|
|
469
|
+
const J = m.searchParams.get("id");
|
|
470
470
|
if (!J) {
|
|
471
|
-
|
|
471
|
+
r.writeHead(400, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
const
|
|
474
|
+
const W = T.get(J), Y = W ? W.path : null, de = (te) => {
|
|
475
475
|
let U = "Unknown", K = "Unknown";
|
|
476
|
-
if (
|
|
477
|
-
const B =
|
|
476
|
+
if (a.headers.referer || a.headers.referrer) {
|
|
477
|
+
const B = a.headers.referer || a.headers.referrer;
|
|
478
478
|
try {
|
|
479
479
|
const ie = new URL(B);
|
|
480
480
|
U = ie.origin, K = ie.hostname || ie.origin;
|
|
481
481
|
} catch {
|
|
482
482
|
U = B, K = B;
|
|
483
483
|
}
|
|
484
|
-
} else if (
|
|
484
|
+
} else if (a.headers.origin)
|
|
485
485
|
try {
|
|
486
|
-
const B = new URL(
|
|
486
|
+
const B = new URL(a.headers.origin);
|
|
487
487
|
U = B.origin, K = B.hostname || B.origin;
|
|
488
488
|
} catch {
|
|
489
|
-
U =
|
|
489
|
+
U = a.headers.origin, K = a.headers.origin;
|
|
490
490
|
}
|
|
491
|
-
else if (
|
|
492
|
-
const B =
|
|
491
|
+
else if (a.socket.remoteAddress) {
|
|
492
|
+
const B = a.socket.remoteAddress;
|
|
493
493
|
B === "::1" || B === "::ffff:127.0.0.1" ? (U = "localhost", K = "localhost (direct)") : (U = B, K = B.replace("::ffff:", ""));
|
|
494
494
|
}
|
|
495
|
-
const
|
|
495
|
+
const Ne = a.headers.referer || a.headers.referrer || U, ye = {
|
|
496
496
|
type: "request",
|
|
497
497
|
componentId: J,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
499
|
servedLocally: te,
|
|
500
|
-
referrer:
|
|
500
|
+
referrer: Ne,
|
|
501
501
|
origin: U,
|
|
502
502
|
originLabel: K
|
|
503
503
|
};
|
|
@@ -506,7 +506,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
506
506
|
label: K,
|
|
507
507
|
firstSeen: Date.now(),
|
|
508
508
|
requestCount: 0
|
|
509
|
-
}),
|
|
509
|
+
}), X.forEach((B) => {
|
|
510
510
|
try {
|
|
511
511
|
B.write(`data: ${JSON.stringify({
|
|
512
512
|
type: "origins",
|
|
@@ -517,8 +517,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
const
|
|
521
|
-
|
|
520
|
+
const Te = se.get(U);
|
|
521
|
+
Te.requestCount++, X.forEach((B) => {
|
|
522
522
|
try {
|
|
523
523
|
B.write(`data: ${JSON.stringify({
|
|
524
524
|
type: "origins",
|
|
@@ -528,168 +528,168 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
528
528
|
`);
|
|
529
529
|
} catch {
|
|
530
530
|
}
|
|
531
|
-
}), oe.push(
|
|
531
|
+
}), oe.push(ye), oe.length > Pe && oe.shift(), X.forEach((B) => {
|
|
532
532
|
try {
|
|
533
|
-
B.write(`data: ${JSON.stringify(
|
|
533
|
+
B.write(`data: ${JSON.stringify(ye)}
|
|
534
534
|
|
|
535
535
|
`);
|
|
536
536
|
} catch {
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
};
|
|
540
|
-
if (
|
|
541
|
-
const te =
|
|
540
|
+
if (Y) {
|
|
541
|
+
const te = W.htmlFile ? t.default.join(Y, W.htmlFile) : t.default.join(Y, "index.html");
|
|
542
542
|
o.default.readFile(te, "utf-8", (U, K) => {
|
|
543
543
|
if (U) {
|
|
544
|
-
console.log(`β File not found: ${te}`),
|
|
544
|
+
console.log(`β File not found: ${te}`), r.writeHead(404, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "index.html not found" }));
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
const
|
|
547
|
+
const Ne = Oe(K, J), ye = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Te = {
|
|
548
548
|
item: {
|
|
549
549
|
name: J,
|
|
550
550
|
id: J,
|
|
551
551
|
consume_variant: [
|
|
552
552
|
{
|
|
553
|
-
id:
|
|
553
|
+
id: ye,
|
|
554
554
|
name: "dev version",
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
557
557
|
shadowRootMode: "localFrame",
|
|
558
|
-
HTML:
|
|
558
|
+
HTML: Ne
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
]
|
|
562
562
|
}
|
|
563
563
|
};
|
|
564
|
-
console.log(`β
Serving consume JSON for: ${J}`), de(!0),
|
|
564
|
+
console.log(`β
Serving consume JSON for: ${J}`), de(!0), r.writeHead(200, {
|
|
565
565
|
"Content-Type": "application/json",
|
|
566
566
|
"Access-Control-Allow-Origin": "*"
|
|
567
|
-
}),
|
|
567
|
+
}), r.end(JSON.stringify(Te, null, 2));
|
|
568
568
|
});
|
|
569
569
|
} else {
|
|
570
570
|
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${J}`);
|
|
571
|
-
const te = `https://cloud.myop.dev/consume${
|
|
571
|
+
const te = `https://cloud.myop.dev/consume${m.search}`;
|
|
572
572
|
de(!1), fetch(te).then((U) => U.text()).then((U) => {
|
|
573
|
-
|
|
573
|
+
r.writeHead(200, {
|
|
574
574
|
"Content-Type": "application/json",
|
|
575
575
|
"Access-Control-Allow-Origin": "*"
|
|
576
|
-
}),
|
|
576
|
+
}), r.end(U);
|
|
577
577
|
}).catch((U) => {
|
|
578
|
-
console.error(`β Proxy error: ${U.message}`),
|
|
578
|
+
console.error(`β Proxy error: ${U.message}`), r.writeHead(502, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
|
-
if (
|
|
584
|
-
|
|
583
|
+
if (f === "/events") {
|
|
584
|
+
r.writeHead(200, {
|
|
585
585
|
"Content-Type": "text/event-stream",
|
|
586
586
|
"Cache-Control": "no-cache",
|
|
587
587
|
Connection: "keep-alive",
|
|
588
588
|
"Access-Control-Allow-Origin": "*"
|
|
589
|
-
}),
|
|
590
|
-
const J = Array.from(
|
|
591
|
-
id:
|
|
592
|
-
path:
|
|
593
|
-
name:
|
|
589
|
+
}), X.push(r);
|
|
590
|
+
const J = Array.from(T.entries()).map(([W, Y]) => ({
|
|
591
|
+
id: W,
|
|
592
|
+
path: Y.path,
|
|
593
|
+
name: Y.name
|
|
594
594
|
}));
|
|
595
|
-
|
|
595
|
+
r.write(`data: ${JSON.stringify({
|
|
596
596
|
type: "components",
|
|
597
597
|
components: J
|
|
598
598
|
})}
|
|
599
599
|
|
|
600
|
-
`),
|
|
600
|
+
`), r.write(`data: ${JSON.stringify({
|
|
601
601
|
type: "origins",
|
|
602
602
|
origins: Array.from(se.values())
|
|
603
603
|
})}
|
|
604
604
|
|
|
605
|
-
`),
|
|
605
|
+
`), r.write(`data: ${JSON.stringify({
|
|
606
606
|
type: "requestLog",
|
|
607
607
|
log: oe
|
|
608
608
|
})}
|
|
609
609
|
|
|
610
|
-
`),
|
|
611
|
-
const
|
|
612
|
-
|
|
610
|
+
`), a.on("close", () => {
|
|
611
|
+
const W = X.indexOf(r);
|
|
612
|
+
W !== -1 && X.splice(W, 1);
|
|
613
613
|
});
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
616
|
if (w.length === 0) {
|
|
617
|
-
|
|
617
|
+
r.writeHead(200, { "Content-Type": "text/html" }), r.end(jt(l, c, g, h));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
620
|
if (w[0] !== "view") {
|
|
621
|
-
|
|
621
|
+
r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not found. Use /view/<componentId>/ to access components.");
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
624
|
if (w.length < 2) {
|
|
625
|
-
|
|
625
|
+
r.writeHead(400, { "Content-Type": "text/plain" }), r.end("Component ID required. Use /view/<componentId>/");
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
const
|
|
629
|
-
if (!
|
|
630
|
-
|
|
628
|
+
const b = w[1], O = T.get(b);
|
|
629
|
+
if (!O) {
|
|
630
|
+
r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${b}`);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const F =
|
|
634
|
-
console.log(`π₯ Request: ${
|
|
633
|
+
const F = O.path, H = w.slice(2), G = O.htmlFile || "index.html", ee = H.length === 0 ? G : H.join("/"), ce = t.default.join(F, ee);
|
|
634
|
+
console.log(`π₯ Request: ${a.url} -> ${ce}`), o.default.readFile(ce, (J, W) => {
|
|
635
635
|
if (J) {
|
|
636
|
-
console.log(`β File not found: ${ce}`),
|
|
636
|
+
console.log(`β File not found: ${ce}`), r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not Found");
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
639
|
-
const
|
|
640
|
-
console.log(`β
Serving: ${ce} (${
|
|
641
|
-
let de =
|
|
642
|
-
if (
|
|
643
|
-
const te =
|
|
644
|
-
de =
|
|
639
|
+
const Y = z(ce);
|
|
640
|
+
console.log(`β
Serving: ${ce} (${Y})`);
|
|
641
|
+
let de = W;
|
|
642
|
+
if (Y === "text/html" && k) {
|
|
643
|
+
const te = W.toString("utf-8");
|
|
644
|
+
de = Oe(te, b);
|
|
645
645
|
}
|
|
646
|
-
|
|
647
|
-
"Content-Type":
|
|
646
|
+
r.writeHead(200, {
|
|
647
|
+
"Content-Type": Y,
|
|
648
648
|
"Access-Control-Allow-Origin": "*"
|
|
649
|
-
}),
|
|
649
|
+
}), r.end(de);
|
|
650
650
|
});
|
|
651
|
-
}),
|
|
652
|
-
const
|
|
651
|
+
}), Ke = () => new Promise((a, r) => {
|
|
652
|
+
const m = u ? t.default.resolve(_) : t.default.resolve(_, y), f = JSON.stringify({
|
|
653
653
|
componentId: M,
|
|
654
|
-
distPath:
|
|
654
|
+
distPath: m,
|
|
655
655
|
componentName: R,
|
|
656
|
-
htmlFile:
|
|
656
|
+
htmlFile: u ? p : null
|
|
657
657
|
}), w = {
|
|
658
658
|
hostname: "localhost",
|
|
659
|
-
port:
|
|
659
|
+
port: c,
|
|
660
660
|
path: "/_register",
|
|
661
661
|
method: "POST",
|
|
662
662
|
headers: {
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
|
-
"Content-Length": Buffer.byteLength(
|
|
664
|
+
"Content-Length": Buffer.byteLength(f)
|
|
665
665
|
}
|
|
666
|
-
},
|
|
666
|
+
}, b = n.default.request(w, (O) => {
|
|
667
667
|
let F = "";
|
|
668
|
-
|
|
669
|
-
|
|
668
|
+
O.on("data", (H) => F += H), O.on("end", () => {
|
|
669
|
+
O.statusCode === 200 ? a(JSON.parse(F)) : r(new Error(`Registration failed: ${O.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
|
-
|
|
673
|
-
}),
|
|
674
|
-
const
|
|
672
|
+
b.on("error", r), b.write(f), b.end();
|
|
673
|
+
}), ht = () => new Promise((a, r) => {
|
|
674
|
+
const m = JSON.stringify({ componentId: M }), f = {
|
|
675
675
|
hostname: "localhost",
|
|
676
|
-
port:
|
|
676
|
+
port: c,
|
|
677
677
|
path: "/_unregister",
|
|
678
678
|
method: "POST",
|
|
679
679
|
headers: {
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
|
-
"Content-Length": Buffer.byteLength(
|
|
681
|
+
"Content-Length": Buffer.byteLength(m)
|
|
682
682
|
}
|
|
683
|
-
}, w = n.default.request(
|
|
684
|
-
|
|
683
|
+
}, w = n.default.request(f, (b) => {
|
|
684
|
+
a();
|
|
685
685
|
});
|
|
686
|
-
w.on("error", () =>
|
|
687
|
-
}),
|
|
686
|
+
w.on("error", () => a()), w.write(m), w.end();
|
|
687
|
+
}), yt = (a) => `
|
|
688
688
|
<!-- MYOP HMR -->
|
|
689
689
|
<script>
|
|
690
690
|
(function() {
|
|
691
|
-
const componentId = '${
|
|
692
|
-
const wsUrl = 'ws://localhost:${
|
|
691
|
+
const componentId = '${a}';
|
|
692
|
+
const wsUrl = 'ws://localhost:${c}/_hmr/' + componentId;
|
|
693
693
|
let ws;
|
|
694
694
|
let reconnectAttempts = 0;
|
|
695
695
|
const maxReconnectAttempts = 10;
|
|
@@ -789,76 +789,76 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
789
789
|
connect();
|
|
790
790
|
})();
|
|
791
791
|
<\/script>
|
|
792
|
-
`,
|
|
793
|
-
if (!k) return
|
|
794
|
-
const
|
|
795
|
-
return
|
|
796
|
-
},
|
|
797
|
-
const
|
|
798
|
-
let
|
|
799
|
-
return
|
|
800
|
-
Buffer.from([129,
|
|
792
|
+
`, Oe = (a, r) => {
|
|
793
|
+
if (!k) return a;
|
|
794
|
+
const m = yt(r);
|
|
795
|
+
return a.includes("</body>") ? a.replace("</body>", `${m}</body>`) : a.includes("</html>") ? a.replace("</html>", `${m}</html>`) : a + m;
|
|
796
|
+
}, Qe = (a) => {
|
|
797
|
+
const r = Buffer.from(a), m = r.length;
|
|
798
|
+
let f;
|
|
799
|
+
return m < 126 ? f = Buffer.concat([
|
|
800
|
+
Buffer.from([129, m]),
|
|
801
801
|
// FIN + text frame, length
|
|
802
|
-
|
|
803
|
-
]) :
|
|
802
|
+
r
|
|
803
|
+
]) : m < 65536 ? f = Buffer.concat([
|
|
804
804
|
Buffer.from([129, 126]),
|
|
805
805
|
// FIN + text frame, extended length
|
|
806
|
-
Buffer.from([
|
|
806
|
+
Buffer.from([m >> 8, m & 255]),
|
|
807
807
|
// 16-bit length
|
|
808
|
-
|
|
809
|
-
]) :
|
|
808
|
+
r
|
|
809
|
+
]) : f = Buffer.concat([
|
|
810
810
|
Buffer.from([129, 127]),
|
|
811
811
|
// FIN + text frame, extended length
|
|
812
|
-
Buffer.from([0, 0, 0, 0,
|
|
812
|
+
Buffer.from([0, 0, 0, 0, m >> 24, m >> 16 & 255, m >> 8 & 255, m & 255]),
|
|
813
813
|
// 64-bit length
|
|
814
|
-
|
|
815
|
-
]),
|
|
816
|
-
},
|
|
814
|
+
r
|
|
815
|
+
]), f;
|
|
816
|
+
}, Ze = () => {
|
|
817
817
|
if (!k) return;
|
|
818
|
-
const
|
|
819
|
-
let
|
|
818
|
+
const a = u ? p : t.default.join(y, "index.html");
|
|
819
|
+
let r;
|
|
820
820
|
try {
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
} catch (
|
|
824
|
-
console.error("β Failed to read HTML for HMR:",
|
|
821
|
+
const m = o.default.readFileSync(a, "utf-8");
|
|
822
|
+
r = Oe(m, M);
|
|
823
|
+
} catch (m) {
|
|
824
|
+
console.error("β Failed to read HTML for HMR:", m.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (
|
|
828
|
-
const
|
|
829
|
-
if (!
|
|
827
|
+
if (Re) {
|
|
828
|
+
const m = q.get(M);
|
|
829
|
+
if (!m || m.size === 0)
|
|
830
830
|
return;
|
|
831
|
-
console.log(`π₯ Notifying ${
|
|
832
|
-
const
|
|
831
|
+
console.log(`π₯ Notifying ${m.size} HMR client(s)`);
|
|
832
|
+
const f = JSON.stringify({
|
|
833
833
|
type: "update",
|
|
834
|
-
html:
|
|
835
|
-
}), w =
|
|
836
|
-
|
|
834
|
+
html: r
|
|
835
|
+
}), w = Qe(f);
|
|
836
|
+
m.forEach((b) => {
|
|
837
837
|
try {
|
|
838
|
-
|
|
838
|
+
b.write(w);
|
|
839
839
|
} catch {
|
|
840
|
-
|
|
840
|
+
m.delete(b);
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
} else {
|
|
844
|
-
const
|
|
844
|
+
const m = JSON.stringify({
|
|
845
845
|
componentId: M,
|
|
846
|
-
html:
|
|
847
|
-
}),
|
|
846
|
+
html: r
|
|
847
|
+
}), f = {
|
|
848
848
|
hostname: "localhost",
|
|
849
|
-
port:
|
|
849
|
+
port: c,
|
|
850
850
|
path: "/_hmr_notify",
|
|
851
851
|
method: "POST",
|
|
852
852
|
headers: {
|
|
853
853
|
"Content-Type": "application/json",
|
|
854
|
-
"Content-Length": Buffer.byteLength(
|
|
854
|
+
"Content-Length": Buffer.byteLength(m)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
}, w = n.default.request(
|
|
858
|
-
let
|
|
859
|
-
|
|
857
|
+
}, w = n.default.request(f, (b) => {
|
|
858
|
+
let O = "";
|
|
859
|
+
b.on("data", (F) => O += F), b.on("end", () => {
|
|
860
860
|
try {
|
|
861
|
-
const F = JSON.parse(
|
|
861
|
+
const F = JSON.parse(O);
|
|
862
862
|
F.notified > 0 && console.log(`π₯ Notified ${F.notified} HMR client(s) via server`);
|
|
863
863
|
} catch {
|
|
864
864
|
}
|
|
@@ -867,173 +867,173 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
867
867
|
w.on("error", () => {
|
|
868
868
|
}), w.on("timeout", () => {
|
|
869
869
|
w.destroy();
|
|
870
|
-
}), w.write(
|
|
870
|
+
}), w.write(m), w.end();
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
|
-
let
|
|
874
|
-
const
|
|
873
|
+
let Ie = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
|
+
const fe = (a) => {
|
|
875
875
|
if (S) {
|
|
876
876
|
x = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
879
|
S = !0, console.log(`
|
|
880
|
-
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (
|
|
881
|
-
if (S = !1,
|
|
882
|
-
const w = await
|
|
883
|
-
...
|
|
884
|
-
onRetry: () =>
|
|
880
|
+
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, m, f) => {
|
|
881
|
+
if (S = !1, r) {
|
|
882
|
+
const w = await ct(r, m, f, e, {
|
|
883
|
+
...Ie,
|
|
884
|
+
onRetry: () => fe(a)
|
|
885
885
|
});
|
|
886
|
-
|
|
886
|
+
Ie = { ...Ie, ...w }, w.handled || (console.error("β Build failed:", r.message), f && console.error(f));
|
|
887
887
|
} else
|
|
888
|
-
console.log("β
Build completed"),
|
|
889
|
-
x && (x = !1,
|
|
888
|
+
console.log("β
Build completed"), m && console.log(m), Ze(), a && a();
|
|
889
|
+
x && (x = !1, fe());
|
|
890
890
|
});
|
|
891
|
-
},
|
|
892
|
-
o.default.readdir(
|
|
893
|
-
|
|
894
|
-
const w = t.default.join(
|
|
895
|
-
if (
|
|
896
|
-
|
|
897
|
-
else if (
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
891
|
+
}, Xe = /* @__PURE__ */ new Set(), ke = (a) => {
|
|
892
|
+
o.default.readdir(a, { withFileTypes: !0 }, (r, m) => {
|
|
893
|
+
r || (m.forEach((f) => {
|
|
894
|
+
const w = t.default.join(a, f.name);
|
|
895
|
+
if (f.isDirectory())
|
|
896
|
+
f.name !== "node_modules" && f.name !== "dist" && !f.name.startsWith(".") && ke(w);
|
|
897
|
+
else if (f.isFile()) {
|
|
898
|
+
const b = t.default.extname(f.name);
|
|
899
|
+
if (b === ".js" || b === ".css" || b === ".html")
|
|
900
900
|
try {
|
|
901
|
-
const
|
|
902
|
-
|
|
901
|
+
const O = o.default.readFileSync(w, "utf-8");
|
|
902
|
+
C.set(w, O);
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
}),
|
|
906
|
+
}), Xe.has(a) || (Xe.add(a), o.default.watch(a, (f, w) => {
|
|
907
907
|
if (!w) return;
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
const
|
|
908
|
+
const b = t.default.extname(w);
|
|
909
|
+
if (b !== ".js" && b !== ".css" && b !== ".html") return;
|
|
910
|
+
const O = t.default.join(a, w);
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
913
|
-
const F = o.default.readFileSync(
|
|
914
|
-
F !== H && (
|
|
913
|
+
const F = o.default.readFileSync(O, "utf-8"), H = C.get(O);
|
|
914
|
+
F !== H && (C.set(O, F), console.log(`π File changed: ${O}`), u ? Ze() : fe());
|
|
915
915
|
} catch {
|
|
916
916
|
}
|
|
917
917
|
}, 50);
|
|
918
918
|
})));
|
|
919
919
|
});
|
|
920
|
-
},
|
|
920
|
+
}, qe = (a) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
π¨ Component: ${M}`),
|
|
923
|
-
`),
|
|
922
|
+
π¨ Component: ${M}`), u ? (console.log("π No build needed (single HTML file mode)"), ke(_), console.log(`π Watching ${p} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
|
+
`), a && a()) : (fe(a), ke(_), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
|
-
},
|
|
926
|
-
const
|
|
925
|
+
}, wt = () => new Promise((a) => {
|
|
926
|
+
const r = {
|
|
927
927
|
hostname: "localhost",
|
|
928
|
-
port:
|
|
928
|
+
port: c,
|
|
929
929
|
path: "/_list",
|
|
930
930
|
method: "GET",
|
|
931
931
|
timeout: 1e3
|
|
932
|
-
},
|
|
933
|
-
|
|
932
|
+
}, m = n.default.request(r, (f) => {
|
|
933
|
+
a(!0);
|
|
934
934
|
});
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}),
|
|
938
|
-
}),
|
|
939
|
-
const
|
|
940
|
-
if (
|
|
935
|
+
m.on("error", () => a(!1)), m.on("timeout", () => {
|
|
936
|
+
m.destroy(), a(!1);
|
|
937
|
+
}), m.end();
|
|
938
|
+
}), vt = () => new Promise((a) => {
|
|
939
|
+
const r = n.default.createServer((m, f) => {
|
|
940
|
+
if (f.setHeader("Content-Type", "application/json"), m.method === "POST" && m.url === "/_register") {
|
|
941
941
|
let w = "";
|
|
942
|
-
|
|
942
|
+
m.on("data", (b) => w += b), m.on("end", () => {
|
|
943
943
|
try {
|
|
944
|
-
const { componentId:
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
console.log(`β
Registered: ${
|
|
948
|
-
} catch (
|
|
949
|
-
|
|
944
|
+
const { componentId: b, distPath: O, componentName: F, htmlFile: H } = JSON.parse(w);
|
|
945
|
+
T.set(b, { path: O, name: F || null, htmlFile: H || null });
|
|
946
|
+
const G = F ? ` (${F})` : "";
|
|
947
|
+
console.log(`β
Registered: ${b}${G} -> ${O}${H ? "/" + H : ""}`), f.writeHead(200), f.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
|
|
948
|
+
} catch (b) {
|
|
949
|
+
f.writeHead(400), f.end(JSON.stringify({ error: b.message }));
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
|
-
} else if (
|
|
952
|
+
} else if (m.method === "POST" && m.url === "/_unregister") {
|
|
953
953
|
let w = "";
|
|
954
|
-
|
|
954
|
+
m.on("data", (b) => w += b), m.on("end", () => {
|
|
955
955
|
try {
|
|
956
|
-
const { componentId:
|
|
957
|
-
|
|
958
|
-
} catch (
|
|
959
|
-
|
|
956
|
+
const { componentId: b } = JSON.parse(w);
|
|
957
|
+
T.delete(b), console.log(`β Unregistered: ${b}`), f.writeHead(200), f.end(JSON.stringify({ success: !0 }));
|
|
958
|
+
} catch (b) {
|
|
959
|
+
f.writeHead(400), f.end(JSON.stringify({ error: b.message }));
|
|
960
960
|
}
|
|
961
961
|
});
|
|
962
|
-
} else
|
|
962
|
+
} else m.method === "GET" && m.url === "/_list" ? (f.writeHead(200), f.end(JSON.stringify({ components: Array.from(T.entries()) }))) : (f.writeHead(404), f.end(JSON.stringify({ error: "Not found" })));
|
|
963
963
|
});
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}),
|
|
964
|
+
r.on("error", () => {
|
|
965
|
+
a(!1);
|
|
966
|
+
}), r.listen(c, () => {
|
|
967
967
|
console.log(`
|
|
968
|
-
π Taking over as server...`), console.log(`π‘ Management server on port ${
|
|
969
|
-
|
|
970
|
-
}), ge.listen(
|
|
971
|
-
console.log(`π‘ Main server running at http://localhost:${
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
path:
|
|
968
|
+
π Taking over as server...`), console.log(`π‘ Management server on port ${c}`), ge.on("error", () => {
|
|
969
|
+
r.close(), a(!1);
|
|
970
|
+
}), ge.listen(l, () => {
|
|
971
|
+
console.log(`π‘ Main server running at http://localhost:${l}`);
|
|
972
|
+
const m = u ? t.default.resolve(_) : t.default.resolve(_, y);
|
|
973
|
+
T.set(M, {
|
|
974
|
+
path: m,
|
|
975
975
|
name: R,
|
|
976
|
-
htmlFile:
|
|
976
|
+
htmlFile: u ? p : null
|
|
977
977
|
});
|
|
978
|
-
const
|
|
979
|
-
console.log(`β
Registered component: ${M}${
|
|
978
|
+
const f = R ? ` (${R})` : "";
|
|
979
|
+
console.log(`β
Registered component: ${M}${f}`), console.log(`π‘ Access at: http://localhost:${l}/view/${M}/`), a(!0);
|
|
980
980
|
});
|
|
981
981
|
});
|
|
982
982
|
});
|
|
983
|
-
let
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
await
|
|
987
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
983
|
+
let he;
|
|
984
|
+
const et = () => {
|
|
985
|
+
he = setInterval(async () => {
|
|
986
|
+
await wt() || (clearInterval(he), console.log(`
|
|
987
|
+
β οΈ Server appears to be down, attempting to take over...`), await vt() ? (console.log("β
Successfully took over as server"), Re = !0) : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
988
|
try {
|
|
989
|
-
await
|
|
990
|
-
} catch (
|
|
991
|
-
console.error("β Failed to re-register:",
|
|
989
|
+
await Ke(), console.log(`β
Re-registered component: ${M}`), et();
|
|
990
|
+
} catch (m) {
|
|
991
|
+
console.error("β Failed to re-register:", m.message);
|
|
992
992
|
}
|
|
993
993
|
}, 2e3)));
|
|
994
994
|
}, 3e3);
|
|
995
|
-
},
|
|
995
|
+
}, tt = async () => {
|
|
996
996
|
console.log(`
|
|
997
997
|
|
|
998
|
-
π Shutting down...`),
|
|
998
|
+
π Shutting down...`), he && clearInterval(he), await ht(), process.exit(0);
|
|
999
999
|
};
|
|
1000
|
-
process.on("SIGINT",
|
|
1001
|
-
let
|
|
1002
|
-
|
|
1003
|
-
if (
|
|
1000
|
+
process.on("SIGINT", tt), process.on("SIGTERM", tt);
|
|
1001
|
+
let Re = !1;
|
|
1002
|
+
Ee.on("error", async (a) => {
|
|
1003
|
+
if (a.code === "EADDRINUSE") {
|
|
1004
1004
|
console.log(`
|
|
1005
1005
|
π Connecting to existing dev server...`);
|
|
1006
1006
|
try {
|
|
1007
|
-
M = await
|
|
1008
|
-
const
|
|
1009
|
-
console.log(`β
Registered component: ${M}`), console.log(`π‘ Access at: http://localhost:${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1011
|
-
}),
|
|
1012
|
-
} catch (
|
|
1013
|
-
console.error("β Failed to register component:",
|
|
1007
|
+
M = await A();
|
|
1008
|
+
const r = await Ke();
|
|
1009
|
+
console.log(`β
Registered component: ${M}`), console.log(`π‘ Access at: http://localhost:${l}/view/${M}/`), console.log(`π All registered components: ${r.registered.join(", ")}`), qe(() => {
|
|
1010
|
+
process.env.MYOP_NO_BROWSER || $(`http://localhost:${l}/view/${M}/`);
|
|
1011
|
+
}), et();
|
|
1012
|
+
} catch (r) {
|
|
1013
|
+
console.error("β Failed to register component:", r.message), process.exit(1);
|
|
1014
1014
|
}
|
|
1015
1015
|
} else
|
|
1016
|
-
console.error("β Management server error:",
|
|
1017
|
-
}),
|
|
1018
|
-
|
|
1019
|
-
π Starting shared dev server...`), console.log(`π‘ Management server on port ${
|
|
1020
|
-
console.error("β Main server error:",
|
|
1021
|
-
}), ge.listen(
|
|
1022
|
-
console.log(`π‘ Main server running at http://localhost:${
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
path:
|
|
1016
|
+
console.error("β Management server error:", a.message), process.exit(1);
|
|
1017
|
+
}), Ee.on("upgrade", ft), Ee.listen(c, async () => {
|
|
1018
|
+
Re = !0, console.log(`
|
|
1019
|
+
π Starting shared dev server...`), console.log(`π‘ Management server on port ${c}`), ge.on("error", (a) => {
|
|
1020
|
+
console.error("β Main server error:", a.message), process.exit(1);
|
|
1021
|
+
}), ge.listen(l, async () => {
|
|
1022
|
+
console.log(`π‘ Main server running at http://localhost:${l}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
|
|
1023
|
+
const a = u ? t.default.resolve(_) : t.default.resolve(_, y);
|
|
1024
|
+
T.set(M, {
|
|
1025
|
+
path: a,
|
|
1026
1026
|
name: R,
|
|
1027
|
-
htmlFile:
|
|
1027
|
+
htmlFile: u ? p : null
|
|
1028
1028
|
});
|
|
1029
|
-
const
|
|
1030
|
-
console.log(`β
Registered component: ${M}${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1029
|
+
const r = R ? ` (${R})` : "";
|
|
1030
|
+
console.log(`β
Registered component: ${M}${r}`), console.log(`π‘ Access at: http://localhost:${l}/view/${M}/`), qe(() => {
|
|
1031
|
+
process.env.MYOP_NO_BROWSER || $(`http://localhost:${l}/view/${M}/`);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
|
-
const
|
|
1036
|
+
const D = class D {
|
|
1037
1037
|
constructor(t) {
|
|
1038
1038
|
this.components = t.map(
|
|
1039
1039
|
(e) => typeof e == "string" ? { name: e, path: "", id: "" } : e
|
|
@@ -1042,7 +1042,7 @@ const A = class A {
|
|
|
1042
1042
|
this.logs.set(e.name, []), this.scrollPos.set(e.name, 0), this.statuses.set(e.name, "Initializing..."), this.statusKeys.set(e.name, "initializing");
|
|
1043
1043
|
this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
|
|
1044
1044
|
this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
|
|
1045
|
-
}), this.setupKeyboardInput(), process.stdout.write(
|
|
1045
|
+
}), this.setupKeyboardInput(), process.stdout.write(D.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
|
|
1046
1046
|
}
|
|
1047
1047
|
setupKeyboardInput() {
|
|
1048
1048
|
process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (t) => {
|
|
@@ -1083,15 +1083,15 @@ const A = class A {
|
|
|
1083
1083
|
const t = this.components.length, e = 38;
|
|
1084
1084
|
let n;
|
|
1085
1085
|
this.cols >= e * 3 + 4 ? n = Math.min(t, 3) : this.cols >= e * 2 + 2 ? n = Math.min(t, 2) : n = 1;
|
|
1086
|
-
const s = Math.ceil(t / n), i = Math.floor(this.cols / n),
|
|
1087
|
-
this.visibleLogLines = Math.max(2,
|
|
1088
|
-
for (let
|
|
1089
|
-
const y = this.components[
|
|
1086
|
+
const s = Math.ceil(t / n), i = Math.floor(this.cols / n), d = 2, h = this.rows - d - 2, l = Math.floor(h / s);
|
|
1087
|
+
this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
|
|
1088
|
+
for (let c = 0; c < t; c++) {
|
|
1089
|
+
const y = this.components[c], S = Math.floor(c / n), x = c % n;
|
|
1090
1090
|
this.panelPositions.set(y.name, {
|
|
1091
|
-
row:
|
|
1091
|
+
row: d + 1 + S * l,
|
|
1092
1092
|
col: x * i + 1,
|
|
1093
1093
|
width: i,
|
|
1094
|
-
height:
|
|
1094
|
+
height: l
|
|
1095
1095
|
});
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
@@ -1110,8 +1110,8 @@ const A = class A {
|
|
|
1110
1110
|
s.includes("initializing") || s.includes("β³") ? n = "initializing" : s.includes("starting") ? n = "starting" : s.includes("building") || s.includes("π¨") ? n = "building" : s.includes("ready") || s.includes("β
") ? n = "ready" : s.includes("changed") || s.includes("π") ? n = "changed" : s.includes("hmr") ? n = "hmr_update" : s.includes("π₯") ? n = "hmr" : s.includes("error") || s.includes("β") ? n = "error" : s.includes("warning") || s.includes("β ") ? n = "warning" : (s.includes("stopped") || s.includes("exited")) && (n = "stopped"), this.statuses.set(t, e), this.statusKeys.set(t, n), this.queueUpdate(t);
|
|
1111
1111
|
}
|
|
1112
1112
|
scroll(t, e) {
|
|
1113
|
-
const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines),
|
|
1114
|
-
|
|
1113
|
+
const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), d = Math.max(0, Math.min(i, s + e));
|
|
1114
|
+
d !== s && (this.scrollPos.set(t, d), this.queueUpdate(t));
|
|
1115
1115
|
}
|
|
1116
1116
|
queueUpdate(t) {
|
|
1117
1117
|
this.pendingUpdates.add(t), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
|
|
@@ -1132,44 +1132,44 @@ const A = class A {
|
|
|
1132
1132
|
return `${e}:${n.toString().padStart(2, "0")}`;
|
|
1133
1133
|
}
|
|
1134
1134
|
updateHeader() {
|
|
1135
|
-
const t =
|
|
1135
|
+
const t = D.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
|
|
1136
1136
|
let s = `${t.dim}π‘${t.reset} http://localhost:9292 ${t.gray}|${t.reset} `;
|
|
1137
|
-
s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `β± ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s +=
|
|
1137
|
+
s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `β± ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += D.ESC.clearLine.slice(0, -1), process.stdout.write(D.ESC.moveTo(2, 1) + s);
|
|
1138
1138
|
}
|
|
1139
1139
|
renderPanel(t) {
|
|
1140
|
-
const e =
|
|
1140
|
+
const e = D.C, n = D.STATUS, s = this.panelPositions.get(t);
|
|
1141
1141
|
if (!s) return;
|
|
1142
|
-
const i = this.components.findIndex((
|
|
1143
|
-
let
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
const
|
|
1148
|
-
let j = `${
|
|
1149
|
-
j += " ".repeat(Math.max(0, x -
|
|
1142
|
+
const i = this.components.findIndex((A) => A.name === t), d = this.components[i], g = i === this.selectedPanel, h = this.statusKeys.get(t) || "initializing", l = n[h], c = e[l.color], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, u = g ? e.cyan : e.gray, p = [], E = d.name.substring(0, x - 20);
|
|
1143
|
+
let I = `${u}ββ${e.reset} ${c}${l.icon}${e.reset} `;
|
|
1144
|
+
I += `${e.bold}${E}${e.reset} ${e.gray}β${e.reset} ${c}${l.label}${e.reset} `;
|
|
1145
|
+
const $ = 5 + E.length + l.label.length + 3;
|
|
1146
|
+
I += `${u}${"β".repeat(Math.max(0, x - $))}β${e.reset}`, p.push(D.ESC.moveTo(s.row, s.col) + I);
|
|
1147
|
+
const C = (d.path || "").substring(0, x - 6);
|
|
1148
|
+
let j = `${u}β${e.reset} ${e.dim}${C}${e.reset}`;
|
|
1149
|
+
j += " ".repeat(Math.max(0, x - C.length - 3)), j += `${u}β${e.reset}`, p.push(D.ESC.moveTo(s.row + 1, s.col) + j);
|
|
1150
1150
|
const M = y.length, R = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
|
|
1151
|
-
let k = `${
|
|
1152
|
-
R && (k += `${e.dim}${R}${e.reset}`), k += `${
|
|
1151
|
+
let k = `${u}β${"β".repeat(x - R.length - 4)}${e.reset}`;
|
|
1152
|
+
R && (k += `${e.dim}${R}${e.reset}`), k += `${u}${"β".repeat(2)}β€${e.reset}`, p.push(D.ESC.moveTo(s.row + 2, s.col) + k);
|
|
1153
1153
|
const L = y.slice(S, S + this.visibleLogLines);
|
|
1154
|
-
for (let
|
|
1155
|
-
const
|
|
1156
|
-
let
|
|
1157
|
-
if (
|
|
1158
|
-
let
|
|
1159
|
-
|
|
1160
|
-
const oe =
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1154
|
+
for (let A = 0; A < this.visibleLogLines; A++) {
|
|
1155
|
+
const _ = L[A];
|
|
1156
|
+
let z = `${u}β${e.reset}`;
|
|
1157
|
+
if (_) {
|
|
1158
|
+
let T = e.white;
|
|
1159
|
+
_.type === "success" ? T = e.green : _.type === "error" ? T = e.red : _.type === "warning" ? T = e.yellow : _.type === "hmr" ? T = e.magenta : _.type === "change" && (T = e.blue);
|
|
1160
|
+
const oe = _.message.substring(0, x - 12);
|
|
1161
|
+
z += `${e.dim}${_.timestamp}${e.reset} ${T}${oe}${e.reset}`;
|
|
1162
|
+
const Pe = x - _.timestamp.length - oe.length - 2;
|
|
1163
|
+
z += " ".repeat(Math.max(0, Pe));
|
|
1164
1164
|
} else
|
|
1165
|
-
|
|
1166
|
-
|
|
1165
|
+
z += " ".repeat(x - 2);
|
|
1166
|
+
z += `${u}β${e.reset}`, p.push(D.ESC.moveTo(s.row + 3 + A, s.col) + z);
|
|
1167
1167
|
}
|
|
1168
|
-
|
|
1168
|
+
p.push(D.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${u}β${"β".repeat(x - 2)}β${e.reset}`), process.stdout.write(p.join(""));
|
|
1169
1169
|
}
|
|
1170
1170
|
fullRender() {
|
|
1171
|
-
const t =
|
|
1172
|
-
process.stdout.write(
|
|
1171
|
+
const t = D.C;
|
|
1172
|
+
process.stdout.write(D.ESC.clearScreen + D.ESC.moveTo(1, 1));
|
|
1173
1173
|
const e = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - e.length) / 2);
|
|
1174
1174
|
process.stdout.write(`${t.cyan}${"β".repeat(n)}${t.bold}${t.bgCyan}${t.black}${e}${t.reset}${t.cyan}${"β".repeat(this.cols - n - e.length)}${t.reset}`), this.updateHeader();
|
|
1175
1175
|
for (const s of this.components)
|
|
@@ -1177,26 +1177,26 @@ const A = class A {
|
|
|
1177
1177
|
this.renderFooter();
|
|
1178
1178
|
}
|
|
1179
1179
|
renderFooter() {
|
|
1180
|
-
const t =
|
|
1180
|
+
const t = D.C, e = this.rows - 1;
|
|
1181
1181
|
let n = `${t.gray}`;
|
|
1182
|
-
n += `${t.green}β${t.gray} Ready `, n += `${t.yellow}β³${t.gray} Building `, n += `${t.magenta}β‘${t.gray} HMR `, n += `${t.red}β${t.gray} Error `, n += `${t.dim}| ββ: select panel ββ: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(
|
|
1182
|
+
n += `${t.green}β${t.gray} Ready `, n += `${t.yellow}β³${t.gray} Building `, n += `${t.magenta}β‘${t.gray} HMR `, n += `${t.red}β${t.gray} Error `, n += `${t.dim}| ββ: select panel ββ: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(D.ESC.moveTo(e, 1) + n);
|
|
1183
1183
|
}
|
|
1184
1184
|
render() {
|
|
1185
1185
|
this.needsFullRedraw = !0, this.queueUpdate("__full__");
|
|
1186
1186
|
}
|
|
1187
1187
|
clear() {
|
|
1188
|
-
this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(
|
|
1188
|
+
this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(D.ESC.clearScreen + D.ESC.moveTo(1, 1) + D.ESC.showCursor);
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
// ANSI escape codes
|
|
1192
|
-
|
|
1192
|
+
we(D, "ESC", {
|
|
1193
1193
|
moveTo: (t, e) => `\x1B[${t};${e}H`,
|
|
1194
1194
|
hideCursor: "\x1B[?25l",
|
|
1195
1195
|
showCursor: "\x1B[?25h",
|
|
1196
1196
|
clearScreen: "\x1B[2J",
|
|
1197
1197
|
clearLine: "\x1B[2K"
|
|
1198
1198
|
}), // Colors
|
|
1199
|
-
|
|
1199
|
+
we(D, "C", {
|
|
1200
1200
|
reset: "\x1B[0m",
|
|
1201
1201
|
bold: "\x1B[1m",
|
|
1202
1202
|
dim: "\x1B[2m",
|
|
@@ -1211,7 +1211,7 @@ ve(A, "C", {
|
|
|
1211
1211
|
bgCyan: "\x1B[46m",
|
|
1212
1212
|
black: "\x1B[30m"
|
|
1213
1213
|
}), // Status configs
|
|
1214
|
-
|
|
1214
|
+
we(D, "STATUS", {
|
|
1215
1215
|
initializing: { icon: "β", color: "yellow", label: "Initializing" },
|
|
1216
1216
|
starting: { icon: "β", color: "yellow", label: "Starting" },
|
|
1217
1217
|
building: { icon: "β³", color: "yellow", label: "Building" },
|
|
@@ -1224,221 +1224,125 @@ ve(A, "STATUS", {
|
|
|
1224
1224
|
warning: { icon: "β ", color: "yellow", label: "Warning" },
|
|
1225
1225
|
stopped: { icon: "β ", color: "gray", label: "Stopped" }
|
|
1226
1226
|
});
|
|
1227
|
-
let
|
|
1228
|
-
async function
|
|
1229
|
-
const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((
|
|
1230
|
-
name:
|
|
1231
|
-
path:
|
|
1232
|
-
id:
|
|
1233
|
-
})), i = new
|
|
1227
|
+
let Ae = D;
|
|
1228
|
+
async function Ht(o) {
|
|
1229
|
+
const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((c) => ({
|
|
1230
|
+
name: c.name,
|
|
1231
|
+
path: c.path,
|
|
1232
|
+
id: c.componentId || ""
|
|
1233
|
+
})), i = new Ae(s), d = [], g = (c) => {
|
|
1234
1234
|
const y = process.platform;
|
|
1235
1235
|
let S;
|
|
1236
|
-
y === "darwin" ? S = `open "${
|
|
1236
|
+
y === "darwin" ? S = `open "${c}"` : y === "win32" ? S = `start "" "${c}"` : S = `xdg-open "${c}"`, e(S, () => {
|
|
1237
1237
|
});
|
|
1238
|
-
},
|
|
1238
|
+
}, h = () => {
|
|
1239
1239
|
i.clear(), console.log(`
|
|
1240
|
-
π Shutting down all components...`),
|
|
1240
|
+
π Shutting down all components...`), d.forEach((c) => {
|
|
1241
1241
|
try {
|
|
1242
|
-
|
|
1242
|
+
c.kill("SIGTERM");
|
|
1243
1243
|
} catch {
|
|
1244
1244
|
}
|
|
1245
1245
|
}), setTimeout(() => process.exit(0), 500);
|
|
1246
1246
|
};
|
|
1247
|
-
process.on("SIGINT",
|
|
1248
|
-
const
|
|
1249
|
-
for (let
|
|
1250
|
-
const y = o[
|
|
1247
|
+
process.on("SIGINT", h), process.on("SIGTERM", h);
|
|
1248
|
+
const l = process.argv[1];
|
|
1249
|
+
for (let c = 0; c < o.length; c++) {
|
|
1250
|
+
const y = o[c], S = y.name;
|
|
1251
1251
|
i.setStatus(S, "β³ Starting..."), i.log(S, `Starting in ${y.path}`);
|
|
1252
|
-
const x = t("node", [
|
|
1252
|
+
const x = t("node", [l, "dev"], {
|
|
1253
1253
|
cwd: n.default.resolve(y.path),
|
|
1254
1254
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1255
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1256
|
});
|
|
1257
|
-
|
|
1258
|
-
let
|
|
1259
|
-
x.stdout.on("data", (
|
|
1260
|
-
|
|
1261
|
-
const E =
|
|
1257
|
+
d.push(x);
|
|
1258
|
+
let u = "";
|
|
1259
|
+
x.stdout.on("data", (p) => {
|
|
1260
|
+
u += p.toString();
|
|
1261
|
+
const E = u.split(`
|
|
1262
1262
|
`);
|
|
1263
|
-
|
|
1264
|
-
for (const
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1263
|
+
u = E.pop() || "";
|
|
1264
|
+
for (const I of E) {
|
|
1265
|
+
const $ = I.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1266
|
+
$ && ($.includes("Registered component") || $.includes("Registered:") ? i.setStatus(S, "β
Ready") : $.includes("Building...") || $.includes("Running initial build") ? i.setStatus(S, "π¨ Building...") : $.includes("Build completed") || $.includes("Build succeeded") ? i.setStatus(S, "β
Ready") : $.includes("Build failed") ? i.setStatus(S, "β Build Error") : $.includes("File changed") ? (i.setStatus(S, "π Changed"), setTimeout(() => i.setStatus(S, "β
Ready"), 1500)) : $.includes("Notifying") && $.includes("HMR") ? (i.setStatus(S, "π₯ HMR Update"), setTimeout(() => i.setStatus(S, "β
Ready"), 1e3)) : $.includes("HMR client connected") && (i.setStatus(S, "π₯ HMR Connected"), setTimeout(() => i.setStatus(S, "β
Ready"), 1e3)), !$.includes("Watching") && !$.includes("Press Ctrl+C") && !$.includes("Starting shared") && !$.includes("Management server") && !$.includes("Main server") && !$.includes("Access at:") && !$.includes("No build needed") && i.log(S, $));
|
|
1267
1267
|
}
|
|
1268
|
-
}), x.stderr.on("data", (
|
|
1269
|
-
const E =
|
|
1268
|
+
}), x.stderr.on("data", (p) => {
|
|
1269
|
+
const E = p.toString().split(`
|
|
1270
1270
|
`);
|
|
1271
|
-
for (const
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1271
|
+
for (const I of E) {
|
|
1272
|
+
const $ = I.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1273
|
+
$ && (i.log(S, `β οΈ ${$}`), i.setStatus(S, "β οΈ Warning"));
|
|
1274
1274
|
}
|
|
1275
|
-
}), x.on("exit", (
|
|
1276
|
-
|
|
1277
|
-
}),
|
|
1275
|
+
}), x.on("exit", (p) => {
|
|
1276
|
+
p !== 0 && p !== null && (i.setStatus(S, `β Exited (${p})`), i.log(S, `Process exited with code ${p}`));
|
|
1277
|
+
}), c < o.length - 1 && await new Promise((p) => setTimeout(p, 500));
|
|
1278
1278
|
}
|
|
1279
1279
|
i.render(), setTimeout(() => {
|
|
1280
|
-
|
|
1280
|
+
g("http://localhost:9292");
|
|
1281
1281
|
}, 2e3);
|
|
1282
1282
|
}
|
|
1283
|
-
const
|
|
1283
|
+
const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1284
1284
|
__proto__: null,
|
|
1285
|
-
devCommand:
|
|
1286
|
-
monorepoDevCommand:
|
|
1287
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
headers: { Authorization: `Bearer ${t}` }
|
|
1291
|
-
});
|
|
1292
|
-
if (!e.ok) {
|
|
1293
|
-
const n = await e.text();
|
|
1294
|
-
throw new Error(`${e.status}: ${n}`);
|
|
1295
|
-
}
|
|
1296
|
-
return e.json();
|
|
1297
|
-
}
|
|
1298
|
-
function pe(o, t, e) {
|
|
1299
|
-
const n = _.join(o, t);
|
|
1300
|
-
C.mkdirSync(_.dirname(n), { recursive: !0 }), C.writeFileSync(n, JSON.stringify(e, null, 2));
|
|
1301
|
-
}
|
|
1302
|
-
async function $e(o, t, e, n) {
|
|
1303
|
-
return mt(
|
|
1304
|
-
`${o}/export?componentId=${encodeURIComponent(e)}&env=${encodeURIComponent(n)}`,
|
|
1305
|
-
t
|
|
1306
|
-
);
|
|
1307
|
-
}
|
|
1308
|
-
async function Yt(o, t, e, n) {
|
|
1309
|
-
let s = 0;
|
|
1310
|
-
for (const i of n) {
|
|
1311
|
-
const { componentId: r, environment: p } = i;
|
|
1312
|
-
if (!(!r || !p)) {
|
|
1313
|
-
try {
|
|
1314
|
-
const m = await $e(o, t, r, p);
|
|
1315
|
-
pe(e, `components/${r}/${p}.json`, m), s++;
|
|
1316
|
-
} catch (m) {
|
|
1317
|
-
console.warn(` Warning: ${r}/${p}: ${m.message}`);
|
|
1318
|
-
}
|
|
1319
|
-
try {
|
|
1320
|
-
const m = await $e(o, t, r, "preview");
|
|
1321
|
-
pe(e, `components/${r}/preview.json`, m), s++;
|
|
1322
|
-
} catch {
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
return s;
|
|
1327
|
-
}
|
|
1328
|
-
async function Gt(o, t, e) {
|
|
1329
|
-
const n = await mt(`${o}/export`, t);
|
|
1330
|
-
pe(e, "manifest.json", n);
|
|
1331
|
-
let s = 0, i = 0;
|
|
1332
|
-
for (const r of n.components || []) {
|
|
1333
|
-
for (const p of r.environments || [])
|
|
1334
|
-
try {
|
|
1335
|
-
const m = await $e(o, t, r.id, p);
|
|
1336
|
-
pe(e, `components/${r.id}/${p}.json`, m), s++;
|
|
1337
|
-
} catch (m) {
|
|
1338
|
-
console.warn(` Warning: ${r.id}/${p}: ${m.message}`), i++;
|
|
1339
|
-
}
|
|
1340
|
-
try {
|
|
1341
|
-
const p = await $e(o, t, r.id, "preview");
|
|
1342
|
-
pe(e, `components/${r.id}/preview.json`, p), s++;
|
|
1343
|
-
} catch {
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return { manifest: n, fileCount: s, errorCount: i };
|
|
1347
|
-
}
|
|
1348
|
-
function Kt() {
|
|
1349
|
-
v.program.command("export").description("Export components as static JSON for self-hosting").option("-k, --api-key <key>", "Myop API key (or set MYOP_API_KEY env var)").option("-o, --output <dir>", "Output directory", "./myop-static").option("-u, --url <url>", "Myop API URL (or set MYOP_API_URL env var)").option("--releases <json>", "JSON array of releases for incremental sync (from webhook payload)").option("--component <id>", "Single component ID for incremental sync").option("--env <env>", "Environment for single component sync (used with --component)").action(async (o) => {
|
|
1350
|
-
var i;
|
|
1351
|
-
const t = o.apiKey || process.env.MYOP_API_KEY, e = o.url || process.env.MYOP_API_URL || Vt, n = o.output || process.env.OUTPUT_DIR || "./myop-static";
|
|
1352
|
-
t || (console.error("Error: API key required. Use --api-key or set MYOP_API_KEY env var."), console.error("Create one at: Dashboard > Rollout Settings > Self-Hosting > API Keys"), process.exit(1));
|
|
1353
|
-
let s = null;
|
|
1354
|
-
if (o.releases)
|
|
1355
|
-
try {
|
|
1356
|
-
s = JSON.parse(o.releases), Array.isArray(s) || (s = s.releases || [s]);
|
|
1357
|
-
} catch {
|
|
1358
|
-
console.error("Error: --releases must be valid JSON"), process.exit(1);
|
|
1359
|
-
}
|
|
1360
|
-
else o.component && o.env && (s = [{ componentId: o.component, environment: o.env }]);
|
|
1361
|
-
if (s) {
|
|
1362
|
-
const r = z(`Incremental export: ${s.length} component(s)...`).start();
|
|
1363
|
-
try {
|
|
1364
|
-
const p = await Yt(e, t, n, s);
|
|
1365
|
-
r.succeed(`Incremental export done. ${p} file(s) written to ${n}/`);
|
|
1366
|
-
} catch (p) {
|
|
1367
|
-
r.fail(`Export failed: ${p.message}`), process.exit(1);
|
|
1368
|
-
}
|
|
1369
|
-
} else {
|
|
1370
|
-
const r = z(`Full export from ${e}...`).start();
|
|
1371
|
-
try {
|
|
1372
|
-
const { manifest: p, fileCount: m, errorCount: c } = await Gt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
|
|
1373
|
-
r.succeed(
|
|
1374
|
-
`Full export done. ${m} file(s) from ${d} component(s) written to ${n}/`
|
|
1375
|
-
), c > 0 && console.warn(` ${c} file(s) failed.`);
|
|
1376
|
-
} catch (p) {
|
|
1377
|
-
r.fail(`Export failed: ${p.message}`), process.exit(1);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
process.exit(0);
|
|
1381
|
-
});
|
|
1285
|
+
devCommand: be,
|
|
1286
|
+
monorepoDevCommand: Ht
|
|
1287
|
+
}, Symbol.toStringTag, { value: "Module" })), Le = N.join(it.homedir(), ".myop"), me = N.join(Le, "credentials.json");
|
|
1288
|
+
function Jt() {
|
|
1289
|
+
P.existsSync(Le) || P.mkdirSync(Le, { recursive: !0, mode: 448 });
|
|
1382
1290
|
}
|
|
1383
|
-
|
|
1384
|
-
function Qt() {
|
|
1385
|
-
C.existsSync(He) || C.mkdirSync(He, { recursive: !0, mode: 448 });
|
|
1386
|
-
}
|
|
1387
|
-
function Ve() {
|
|
1291
|
+
function ze() {
|
|
1388
1292
|
try {
|
|
1389
|
-
if (!
|
|
1293
|
+
if (!P.existsSync(me))
|
|
1390
1294
|
return null;
|
|
1391
|
-
const o =
|
|
1295
|
+
const o = P.readFileSync(me, "utf8");
|
|
1392
1296
|
return JSON.parse(o);
|
|
1393
1297
|
} catch (o) {
|
|
1394
1298
|
return console.info("Failed to read credentials:", o.message), null;
|
|
1395
1299
|
}
|
|
1396
1300
|
}
|
|
1397
|
-
function
|
|
1398
|
-
|
|
1301
|
+
function dt(o) {
|
|
1302
|
+
Jt();
|
|
1399
1303
|
const t = {
|
|
1400
1304
|
...o,
|
|
1401
1305
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1402
1306
|
};
|
|
1403
|
-
|
|
1307
|
+
P.writeFileSync(me, JSON.stringify(t, null, 2), {
|
|
1404
1308
|
mode: 384
|
|
1405
1309
|
// Read/write for owner only
|
|
1406
1310
|
});
|
|
1407
1311
|
}
|
|
1408
|
-
function
|
|
1312
|
+
function pt() {
|
|
1409
1313
|
try {
|
|
1410
|
-
return
|
|
1314
|
+
return P.existsSync(me) && P.unlinkSync(me), !0;
|
|
1411
1315
|
} catch (o) {
|
|
1412
1316
|
return console.error("Failed to clear credentials:", o.message), !1;
|
|
1413
1317
|
}
|
|
1414
1318
|
}
|
|
1415
|
-
function
|
|
1319
|
+
function zt(o) {
|
|
1416
1320
|
if (!o || !o.expiresAt)
|
|
1417
1321
|
return !0;
|
|
1418
1322
|
const t = 5 * 60 * 1e3, e = new Date(o.expiresAt).getTime();
|
|
1419
1323
|
return Date.now() > e - t;
|
|
1420
1324
|
}
|
|
1421
|
-
function
|
|
1422
|
-
const o =
|
|
1325
|
+
function $e() {
|
|
1326
|
+
const o = ze();
|
|
1423
1327
|
return o ? {
|
|
1424
1328
|
email: o.userEmail,
|
|
1425
1329
|
userId: o.userId
|
|
1426
1330
|
} : null;
|
|
1427
1331
|
}
|
|
1428
|
-
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev",
|
|
1429
|
-
function
|
|
1430
|
-
return
|
|
1332
|
+
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, We = `http://localhost:${Se}/callback`, Wt = "myop-cli";
|
|
1333
|
+
function Vt() {
|
|
1334
|
+
return Be.randomBytes(32).toString("base64url");
|
|
1431
1335
|
}
|
|
1432
|
-
function
|
|
1433
|
-
return
|
|
1336
|
+
function Gt(o) {
|
|
1337
|
+
return Be.createHash("sha256").update(o).digest("base64url");
|
|
1434
1338
|
}
|
|
1435
|
-
async function
|
|
1339
|
+
async function Yt() {
|
|
1436
1340
|
const o = await fetch(`${le}/oauth/register`, {
|
|
1437
1341
|
method: "POST",
|
|
1438
1342
|
headers: { "Content-Type": "application/json" },
|
|
1439
1343
|
body: JSON.stringify({
|
|
1440
|
-
client_name:
|
|
1441
|
-
redirect_uris: [
|
|
1344
|
+
client_name: Wt,
|
|
1345
|
+
redirect_uris: [We],
|
|
1442
1346
|
grant_types: ["authorization_code", "refresh_token"],
|
|
1443
1347
|
response_types: ["code"]
|
|
1444
1348
|
})
|
|
@@ -1449,7 +1353,7 @@ async function to() {
|
|
|
1449
1353
|
}
|
|
1450
1354
|
return o.json();
|
|
1451
1355
|
}
|
|
1452
|
-
function
|
|
1356
|
+
function ve(o, t, e, n = null) {
|
|
1453
1357
|
const s = {
|
|
1454
1358
|
success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
|
|
1455
1359
|
<circle cx="12" cy="12" r="10"/>
|
|
@@ -1467,7 +1371,7 @@ function Se(o, t, e, n = null) {
|
|
|
1467
1371
|
success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
|
|
1468
1372
|
error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
|
|
1469
1373
|
warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
|
|
1470
|
-
}, { accent:
|
|
1374
|
+
}, { accent: d, glow: g } = i[o] || i.error;
|
|
1471
1375
|
return `<!DOCTYPE html>
|
|
1472
1376
|
<html lang="en">
|
|
1473
1377
|
<head>
|
|
@@ -1528,7 +1432,7 @@ function Se(o, t, e, n = null) {
|
|
|
1528
1432
|
h1 {
|
|
1529
1433
|
font-size: 20px;
|
|
1530
1434
|
font-weight: 500;
|
|
1531
|
-
color: ${
|
|
1435
|
+
color: ${d};
|
|
1532
1436
|
margin-bottom: 12px;
|
|
1533
1437
|
letter-spacing: -0.5px;
|
|
1534
1438
|
}
|
|
@@ -1560,8 +1464,8 @@ function Se(o, t, e, n = null) {
|
|
|
1560
1464
|
display: inline-flex;
|
|
1561
1465
|
align-items: center;
|
|
1562
1466
|
gap: 8px;
|
|
1563
|
-
background: ${
|
|
1564
|
-
border: 1px solid ${
|
|
1467
|
+
background: ${g};
|
|
1468
|
+
border: 1px solid ${d}33;
|
|
1565
1469
|
border-radius: 4px;
|
|
1566
1470
|
padding: 10px 16px;
|
|
1567
1471
|
font-size: 12px;
|
|
@@ -1615,23 +1519,23 @@ function Se(o, t, e, n = null) {
|
|
|
1615
1519
|
</body>
|
|
1616
1520
|
</html>`;
|
|
1617
1521
|
}
|
|
1618
|
-
function
|
|
1522
|
+
function Kt(o) {
|
|
1619
1523
|
return new Promise((t, e) => {
|
|
1620
|
-
const n =
|
|
1621
|
-
const
|
|
1622
|
-
if (
|
|
1623
|
-
const
|
|
1624
|
-
if (
|
|
1625
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
1524
|
+
const n = Mt.createServer((s, i) => {
|
|
1525
|
+
const d = new nt(s.url, `http://localhost:${Se}`);
|
|
1526
|
+
if (d.pathname === "/callback") {
|
|
1527
|
+
const g = d.searchParams.get("code"), h = d.searchParams.get("state"), l = d.searchParams.get("error");
|
|
1528
|
+
if (l) {
|
|
1529
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(ve(
|
|
1626
1530
|
"error",
|
|
1627
1531
|
"Authentication Failed",
|
|
1628
1532
|
"Unable to complete the authentication process.",
|
|
1629
|
-
|
|
1630
|
-
)), n.close(), e(new Error(`OAuth error: ${
|
|
1533
|
+
l
|
|
1534
|
+
)), n.close(), e(new Error(`OAuth error: ${l}`));
|
|
1631
1535
|
return;
|
|
1632
1536
|
}
|
|
1633
|
-
if (
|
|
1634
|
-
i.writeHead(400, { "Content-Type": "text/html" }), i.end(
|
|
1537
|
+
if (h !== o) {
|
|
1538
|
+
i.writeHead(400, { "Content-Type": "text/html" }), i.end(ve(
|
|
1635
1539
|
"warning",
|
|
1636
1540
|
"Security Error",
|
|
1637
1541
|
"State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
|
|
@@ -1639,8 +1543,8 @@ function oo(o) {
|
|
|
1639
1543
|
)), n.close(), e(new Error("State mismatch"));
|
|
1640
1544
|
return;
|
|
1641
1545
|
}
|
|
1642
|
-
if (!
|
|
1643
|
-
i.writeHead(400, { "Content-Type": "text/html" }), i.end(
|
|
1546
|
+
if (!g) {
|
|
1547
|
+
i.writeHead(400, { "Content-Type": "text/html" }), i.end(ve(
|
|
1644
1548
|
"error",
|
|
1645
1549
|
"Missing Authorization Code",
|
|
1646
1550
|
"No authorization code was received from the server.",
|
|
@@ -1648,30 +1552,30 @@ function oo(o) {
|
|
|
1648
1552
|
)), n.close(), e(new Error("No authorization code"));
|
|
1649
1553
|
return;
|
|
1650
1554
|
}
|
|
1651
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
1555
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(ve(
|
|
1652
1556
|
"success",
|
|
1653
1557
|
"Authentication Successful",
|
|
1654
1558
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1655
|
-
)), n.close(), t(
|
|
1559
|
+
)), n.close(), t(g);
|
|
1656
1560
|
} else
|
|
1657
1561
|
i.writeHead(404), i.end("Not found");
|
|
1658
1562
|
});
|
|
1659
|
-
n.listen(
|
|
1660
|
-
console.info(`OAuth callback server listening on port ${
|
|
1563
|
+
n.listen(Se, () => {
|
|
1564
|
+
console.info(`OAuth callback server listening on port ${Se}`);
|
|
1661
1565
|
}), setTimeout(() => {
|
|
1662
1566
|
n.close(), e(new Error("Authentication timed out"));
|
|
1663
1567
|
}, 5 * 60 * 1e3);
|
|
1664
1568
|
});
|
|
1665
1569
|
}
|
|
1666
|
-
async function
|
|
1570
|
+
async function Qt(o, t, e) {
|
|
1667
1571
|
const n = await fetch(`${le}/oauth/token`, {
|
|
1668
1572
|
method: "POST",
|
|
1669
1573
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1670
|
-
body: new
|
|
1574
|
+
body: new st({
|
|
1671
1575
|
grant_type: "authorization_code",
|
|
1672
1576
|
code: o,
|
|
1673
1577
|
client_id: t,
|
|
1674
|
-
redirect_uri:
|
|
1578
|
+
redirect_uri: We,
|
|
1675
1579
|
code_verifier: e
|
|
1676
1580
|
})
|
|
1677
1581
|
});
|
|
@@ -1681,11 +1585,11 @@ async function no(o, t, e) {
|
|
|
1681
1585
|
}
|
|
1682
1586
|
return n.json();
|
|
1683
1587
|
}
|
|
1684
|
-
async function
|
|
1588
|
+
async function Zt(o, t) {
|
|
1685
1589
|
const e = await fetch(`${le}/oauth/token`, {
|
|
1686
1590
|
method: "POST",
|
|
1687
1591
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1688
|
-
body: new
|
|
1592
|
+
body: new st({
|
|
1689
1593
|
grant_type: "refresh_token",
|
|
1690
1594
|
refresh_token: o,
|
|
1691
1595
|
client_id: t
|
|
@@ -1697,8 +1601,8 @@ async function so(o, t) {
|
|
|
1697
1601
|
}
|
|
1698
1602
|
return e.json();
|
|
1699
1603
|
}
|
|
1700
|
-
async function
|
|
1701
|
-
var s, i,
|
|
1604
|
+
async function Xt(o) {
|
|
1605
|
+
var s, i, d;
|
|
1702
1606
|
const t = await fetch(`${le}/mcp`, {
|
|
1703
1607
|
method: "POST",
|
|
1704
1608
|
headers: {
|
|
@@ -1720,62 +1624,62 @@ async function io(o) {
|
|
|
1720
1624
|
const e = await t.json();
|
|
1721
1625
|
if (e.error)
|
|
1722
1626
|
throw new Error(e.error.message);
|
|
1723
|
-
const n = (
|
|
1627
|
+
const n = (d = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : d.text;
|
|
1724
1628
|
if (n)
|
|
1725
1629
|
return JSON.parse(n);
|
|
1726
1630
|
throw new Error("Invalid response from whoami");
|
|
1727
1631
|
}
|
|
1728
|
-
async function
|
|
1729
|
-
const o =
|
|
1632
|
+
async function pe() {
|
|
1633
|
+
const o = V("Starting authentication...").start();
|
|
1730
1634
|
try {
|
|
1731
1635
|
o.text = "Registering OAuth client...";
|
|
1732
|
-
const e = (await
|
|
1636
|
+
const e = (await Yt()).client_id, n = Vt(), s = Gt(n), i = Be.randomBytes(16).toString("hex");
|
|
1733
1637
|
o.text = "Waiting for authorization...";
|
|
1734
|
-
const
|
|
1735
|
-
|
|
1736
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1737
|
-
`), await
|
|
1738
|
-
const
|
|
1638
|
+
const d = Kt(i), g = new nt(`${le}/oauth/authorize`);
|
|
1639
|
+
g.searchParams.set("response_type", "code"), g.searchParams.set("client_id", e), g.searchParams.set("redirect_uri", We), g.searchParams.set("code_challenge", s), g.searchParams.set("code_challenge_method", "S256"), g.searchParams.set("state", i), o.stop(), console.log(`
|
|
1640
|
+
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${g.toString()}
|
|
1641
|
+
`), await Pt(g.toString());
|
|
1642
|
+
const h = await d;
|
|
1739
1643
|
o.start("Exchanging authorization code...");
|
|
1740
|
-
const
|
|
1644
|
+
const l = await Qt(h, e, n);
|
|
1741
1645
|
o.text = "Getting user info...";
|
|
1742
|
-
const
|
|
1743
|
-
accessToken:
|
|
1744
|
-
refreshToken:
|
|
1745
|
-
expiresAt: new Date(Date.now() +
|
|
1646
|
+
const c = await Xt(l.access_token), y = {
|
|
1647
|
+
accessToken: l.access_token,
|
|
1648
|
+
refreshToken: l.refresh_token,
|
|
1649
|
+
expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
|
|
1746
1650
|
clientId: e,
|
|
1747
|
-
userId:
|
|
1748
|
-
userEmail:
|
|
1651
|
+
userId: c.userId,
|
|
1652
|
+
userEmail: c.email
|
|
1749
1653
|
};
|
|
1750
|
-
return
|
|
1654
|
+
return dt(y), o.succeed(`Authenticated as ${c.email}`), y;
|
|
1751
1655
|
} catch (t) {
|
|
1752
1656
|
throw o.fail(`Authentication failed: ${t.message}`), t;
|
|
1753
1657
|
}
|
|
1754
1658
|
}
|
|
1755
|
-
async function
|
|
1756
|
-
const o =
|
|
1659
|
+
async function mt() {
|
|
1660
|
+
const o = ze();
|
|
1757
1661
|
if (!o) {
|
|
1758
1662
|
console.log("Not currently logged in.");
|
|
1759
1663
|
return;
|
|
1760
1664
|
}
|
|
1761
|
-
|
|
1665
|
+
pt(), console.log(`β
Logged out (was: ${o.userEmail})`);
|
|
1762
1666
|
}
|
|
1763
|
-
function
|
|
1667
|
+
function qt(o) {
|
|
1764
1668
|
var e, n;
|
|
1765
1669
|
const t = (o == null ? void 0 : o.message) || "";
|
|
1766
1670
|
return t.includes("ECONNREFUSED") || t.includes("ENOTFOUND") || t.includes("ETIMEDOUT") || t.includes("fetch failed") || t.includes("network") || (o == null ? void 0 : o.code) === "ECONNREFUSED" || ((e = o == null ? void 0 : o.cause) == null ? void 0 : e.code) === "ECONNREFUSED" || ((n = o == null ? void 0 : o.cause) == null ? void 0 : n.code) === "ENOTFOUND";
|
|
1767
1671
|
}
|
|
1768
|
-
async function
|
|
1769
|
-
let o =
|
|
1672
|
+
async function Ve() {
|
|
1673
|
+
let o = ze();
|
|
1770
1674
|
if (!o)
|
|
1771
1675
|
return console.log(`Not logged in. Starting authentication...
|
|
1772
|
-
`), await
|
|
1773
|
-
if (!
|
|
1676
|
+
`), await pe();
|
|
1677
|
+
if (!zt(o))
|
|
1774
1678
|
return o;
|
|
1775
1679
|
if (o.refreshToken) {
|
|
1776
|
-
const t =
|
|
1680
|
+
const t = V("Refreshing access token...").start();
|
|
1777
1681
|
try {
|
|
1778
|
-
const e = await
|
|
1682
|
+
const e = await Zt(
|
|
1779
1683
|
o.refreshToken,
|
|
1780
1684
|
o.clientId
|
|
1781
1685
|
);
|
|
@@ -1784,64 +1688,64 @@ async function Ge() {
|
|
|
1784
1688
|
accessToken: e.access_token,
|
|
1785
1689
|
refreshToken: e.refresh_token,
|
|
1786
1690
|
expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
|
|
1787
|
-
},
|
|
1691
|
+
}, dt(o), t.succeed("Token refreshed"), o;
|
|
1788
1692
|
} catch (e) {
|
|
1789
|
-
if (
|
|
1693
|
+
if (qt(e))
|
|
1790
1694
|
throw t.fail("Network error during token refresh"), e;
|
|
1791
|
-
return t.warn("Token refresh failed, please log in again"),
|
|
1695
|
+
return t.warn("Token refresh failed, please log in again"), pt(), await pe();
|
|
1792
1696
|
}
|
|
1793
1697
|
}
|
|
1794
1698
|
return console.log(`Session expired. Please log in again.
|
|
1795
|
-
`), await
|
|
1699
|
+
`), await pe();
|
|
1796
1700
|
}
|
|
1797
|
-
function
|
|
1701
|
+
function Ce() {
|
|
1798
1702
|
return le;
|
|
1799
1703
|
}
|
|
1800
|
-
const Z = "@myop/cli",
|
|
1801
|
-
function
|
|
1704
|
+
const Z = "@myop/cli", Fe = process.platform === "win32";
|
|
1705
|
+
function eo() {
|
|
1802
1706
|
try {
|
|
1803
1707
|
return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
|
|
1804
1708
|
} catch {
|
|
1805
1709
|
return "https://registry.npmjs.org/";
|
|
1806
1710
|
}
|
|
1807
1711
|
}
|
|
1808
|
-
function
|
|
1712
|
+
function to() {
|
|
1809
1713
|
try {
|
|
1810
1714
|
return Q("npm config get prefix", { encoding: "utf-8" }).trim();
|
|
1811
1715
|
} catch {
|
|
1812
1716
|
return null;
|
|
1813
1717
|
}
|
|
1814
1718
|
}
|
|
1815
|
-
async function
|
|
1719
|
+
async function oo() {
|
|
1816
1720
|
try {
|
|
1817
|
-
const o =
|
|
1721
|
+
const o = eo().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
|
|
1818
1722
|
return t.ok ? (await t.json()).version : null;
|
|
1819
1723
|
} catch {
|
|
1820
1724
|
return null;
|
|
1821
1725
|
}
|
|
1822
1726
|
}
|
|
1823
|
-
function
|
|
1727
|
+
function no(o, t) {
|
|
1824
1728
|
const e = o.split(".").map(Number), n = t.split(".").map(Number);
|
|
1825
1729
|
for (let s = 0; s < Math.max(e.length, n.length); s++) {
|
|
1826
|
-
const i = e[s] || 0,
|
|
1827
|
-
if (i >
|
|
1828
|
-
if (i <
|
|
1730
|
+
const i = e[s] || 0, d = n[s] || 0;
|
|
1731
|
+
if (i > d) return 1;
|
|
1732
|
+
if (i < d) return -1;
|
|
1829
1733
|
}
|
|
1830
1734
|
return 0;
|
|
1831
1735
|
}
|
|
1832
|
-
async function
|
|
1833
|
-
const t =
|
|
1736
|
+
async function so(o) {
|
|
1737
|
+
const t = V({
|
|
1834
1738
|
text: "Checking for updates...",
|
|
1835
1739
|
color: "cyan"
|
|
1836
|
-
}).start(), e = await
|
|
1837
|
-
if (t.stop(), !e ||
|
|
1740
|
+
}).start(), e = await oo();
|
|
1741
|
+
if (t.stop(), !e || no(e, o) <= 0)
|
|
1838
1742
|
return !1;
|
|
1839
1743
|
console.log(`
|
|
1840
1744
|
π¦ New version available: ${o} β ${e}
|
|
1841
1745
|
`);
|
|
1842
1746
|
let n;
|
|
1843
1747
|
try {
|
|
1844
|
-
n = await
|
|
1748
|
+
n = await ot({
|
|
1845
1749
|
message: "Would you like to update now?",
|
|
1846
1750
|
choices: [
|
|
1847
1751
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1855,10 +1759,10 @@ async function mo(o) {
|
|
|
1855
1759
|
`), process.exit(0)), s;
|
|
1856
1760
|
}
|
|
1857
1761
|
if (n) {
|
|
1858
|
-
const s =
|
|
1762
|
+
const s = V({
|
|
1859
1763
|
text: `Updating ${Z} to v${e}...`,
|
|
1860
1764
|
color: "green"
|
|
1861
|
-
}).start(), i = `npm install -g ${Z}@latest`,
|
|
1765
|
+
}).start(), i = `npm install -g ${Z}@latest`, d = to();
|
|
1862
1766
|
try {
|
|
1863
1767
|
Q(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
|
|
1864
1768
|
} catch {
|
|
@@ -1866,40 +1770,40 @@ async function mo(o) {
|
|
|
1866
1770
|
π Elevated permissions required.
|
|
1867
1771
|
`);
|
|
1868
1772
|
try {
|
|
1869
|
-
if (
|
|
1870
|
-
const
|
|
1871
|
-
Q(`powershell -Command "${
|
|
1773
|
+
if (Fe) {
|
|
1774
|
+
const c = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${Z}@latest --prefix \\"${d}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
|
|
1775
|
+
Q(`powershell -Command "${c}"`, { stdio: "inherit" });
|
|
1872
1776
|
} else {
|
|
1873
|
-
const
|
|
1874
|
-
Q(
|
|
1777
|
+
const l = d ? `sudo npm install -g ${Z}@latest --prefix "${d}"` : `sudo ${i}`;
|
|
1778
|
+
Q(l, { stdio: "inherit" });
|
|
1875
1779
|
}
|
|
1876
1780
|
console.log(`
|
|
1877
1781
|
β
Updated to v${e}`);
|
|
1878
1782
|
} catch {
|
|
1879
1783
|
console.log(`
|
|
1880
1784
|
β Update failed`);
|
|
1881
|
-
const
|
|
1785
|
+
const c = Fe ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
|
|
1882
1786
|
console.log(`
|
|
1883
|
-
Please run manually: ${
|
|
1787
|
+
Please run manually: ${c}
|
|
1884
1788
|
`), process.exit(1);
|
|
1885
1789
|
}
|
|
1886
1790
|
}
|
|
1887
|
-
let
|
|
1791
|
+
let g = null;
|
|
1888
1792
|
try {
|
|
1889
|
-
let
|
|
1890
|
-
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1793
|
+
let h;
|
|
1794
|
+
d ? h = Fe ? _e(d, "node_modules") : _e(d, "lib", "node_modules") : h = Q("npm root -g", { encoding: "utf-8" }).trim();
|
|
1795
|
+
const l = _e(h, Z, "package.json"), c = Ct(l, "utf-8");
|
|
1796
|
+
g = JSON.parse(c).version;
|
|
1893
1797
|
} catch {
|
|
1894
1798
|
}
|
|
1895
|
-
if (
|
|
1799
|
+
if (g === e)
|
|
1896
1800
|
return console.log(`
|
|
1897
1801
|
π Restarting...
|
|
1898
|
-
`),
|
|
1802
|
+
`), $t(process.argv[0], process.argv.slice(1), {
|
|
1899
1803
|
stdio: "inherit",
|
|
1900
1804
|
shell: !0
|
|
1901
|
-
}).on("close", (
|
|
1902
|
-
process.exit(
|
|
1805
|
+
}).on("close", (l) => {
|
|
1806
|
+
process.exit(l || 0);
|
|
1903
1807
|
}), !0;
|
|
1904
1808
|
console.log(`
|
|
1905
1809
|
Please run myop again to use the new version.
|
|
@@ -1907,35 +1811,35 @@ Please run myop again to use the new version.
|
|
|
1907
1811
|
}
|
|
1908
1812
|
return !1;
|
|
1909
1813
|
}
|
|
1910
|
-
const
|
|
1911
|
-
function
|
|
1912
|
-
|
|
1814
|
+
const Ue = N.join(it.homedir(), ".myop"), He = N.join(Ue, "preferences.json");
|
|
1815
|
+
function io() {
|
|
1816
|
+
P.existsSync(Ue) || P.mkdirSync(Ue, { recursive: !0, mode: 448 });
|
|
1913
1817
|
}
|
|
1914
|
-
function
|
|
1818
|
+
function ut() {
|
|
1915
1819
|
try {
|
|
1916
|
-
if (!
|
|
1820
|
+
if (!P.existsSync(He))
|
|
1917
1821
|
return {};
|
|
1918
|
-
const o =
|
|
1822
|
+
const o = P.readFileSync(He, "utf8");
|
|
1919
1823
|
return JSON.parse(o);
|
|
1920
1824
|
} catch {
|
|
1921
1825
|
return {};
|
|
1922
1826
|
}
|
|
1923
1827
|
}
|
|
1924
|
-
function
|
|
1925
|
-
|
|
1926
|
-
const e = { ...
|
|
1927
|
-
|
|
1828
|
+
function ro(o) {
|
|
1829
|
+
io();
|
|
1830
|
+
const e = { ...ut(), ...o };
|
|
1831
|
+
P.writeFileSync(He, JSON.stringify(e, null, 2), {
|
|
1928
1832
|
mode: 384
|
|
1929
1833
|
});
|
|
1930
1834
|
}
|
|
1931
|
-
function
|
|
1932
|
-
return
|
|
1835
|
+
function ao() {
|
|
1836
|
+
return ut().defaultOrganization || null;
|
|
1933
1837
|
}
|
|
1934
|
-
function
|
|
1935
|
-
|
|
1838
|
+
function je({ id: o, name: t }) {
|
|
1839
|
+
ro({ defaultOrganization: { id: o, name: t } });
|
|
1936
1840
|
}
|
|
1937
|
-
async function
|
|
1938
|
-
var
|
|
1841
|
+
async function lo(o, t, e, n = {}) {
|
|
1842
|
+
var g, h, l;
|
|
1939
1843
|
const s = await fetch(`${o}/mcp`, {
|
|
1940
1844
|
method: "POST",
|
|
1941
1845
|
headers: {
|
|
@@ -1957,12 +1861,12 @@ async function ho(o, t, e, n = {}) {
|
|
|
1957
1861
|
const i = await s.json();
|
|
1958
1862
|
if (i.error)
|
|
1959
1863
|
throw new Error(i.error.message || "MCP error");
|
|
1960
|
-
const
|
|
1961
|
-
if (!
|
|
1864
|
+
const d = (l = (h = (g = i.result) == null ? void 0 : g.content) == null ? void 0 : h[0]) == null ? void 0 : l.text;
|
|
1865
|
+
if (!d)
|
|
1962
1866
|
throw new Error(`No content returned from ${e}`);
|
|
1963
|
-
return JSON.parse(
|
|
1867
|
+
return JSON.parse(d);
|
|
1964
1868
|
}
|
|
1965
|
-
const
|
|
1869
|
+
const co = (o) => new Promise((t) => setTimeout(t, o));
|
|
1966
1870
|
function re(o) {
|
|
1967
1871
|
var e, n;
|
|
1968
1872
|
const t = (o == null ? void 0 : o.message) || "";
|
|
@@ -1973,57 +1877,57 @@ function ae(o) {
|
|
|
1973
1877
|
This usually happens in sandboxed environments (Claude Web, containers)`), console.error(` where outbound HTTP is restricted.
|
|
1974
1878
|
`), console.error(" [MYOP_MCP_FALLBACK] Use Myop MCP tools instead:"), console.error(o === "push" ? " - Use the upload_component MCP tool with htmlContent parameter" : o === "pull" ? " - Use the get_component MCP tool" : " - Use list_organizations + list_components MCP tools"), console.error(" - Do NOT use presigned URL / curl flow β same network restrictions apply"), console.error("");
|
|
1975
1879
|
}
|
|
1976
|
-
const
|
|
1880
|
+
const po = () => {
|
|
1977
1881
|
let o = new URL(import.meta.url).pathname;
|
|
1978
1882
|
process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
|
|
1979
|
-
const t =
|
|
1980
|
-
return
|
|
1981
|
-
},
|
|
1883
|
+
const t = N.dirname(o);
|
|
1884
|
+
return N.join(t, "skills");
|
|
1885
|
+
}, mo = (o) => {
|
|
1982
1886
|
try {
|
|
1983
|
-
const t =
|
|
1984
|
-
if (!
|
|
1985
|
-
const e = JSON.parse(
|
|
1887
|
+
const t = N.join(o, "package.json");
|
|
1888
|
+
if (!P.existsSync(t)) return [];
|
|
1889
|
+
const e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
1986
1890
|
return Object.keys({ ...e.dependencies, ...e.devDependencies });
|
|
1987
1891
|
} catch {
|
|
1988
1892
|
return [];
|
|
1989
1893
|
}
|
|
1990
|
-
},
|
|
1991
|
-
const t =
|
|
1992
|
-
if (!
|
|
1894
|
+
}, Ge = async (o) => {
|
|
1895
|
+
const t = po();
|
|
1896
|
+
if (!P.existsSync(t))
|
|
1993
1897
|
return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
|
|
1994
1898
|
try {
|
|
1995
|
-
const e =
|
|
1899
|
+
const e = mo(o), n = ["myop-cli", "myop-component"], s = [
|
|
1996
1900
|
{ deps: ["@myop/react", "react"], skill: "myop-react-host" },
|
|
1997
1901
|
{ deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
|
|
1998
1902
|
{ deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
|
|
1999
1903
|
{ deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
|
|
2000
|
-
], i = s.filter(({ deps:
|
|
2001
|
-
i.length > 0 ? n.push(...i) : n.push(...s.map((
|
|
2002
|
-
const
|
|
2003
|
-
return Q(
|
|
1904
|
+
], i = s.filter(({ deps: l }) => l.some((c) => e.includes(c))).map(({ skill: l }) => l), d = s.flatMap(({ deps: l }) => l.filter((c) => e.includes(c)));
|
|
1905
|
+
i.length > 0 ? n.push(...i) : n.push(...s.map((l) => l.skill));
|
|
1906
|
+
const g = n.map((l) => `--skill ${l}`).join(" "), h = `npx -y skills add "${t}" ${g} --agent '*' --copy -y`;
|
|
1907
|
+
return Q(h, { cwd: o, stdio: "pipe" }), { success: !0, detected: d, skillNames: n };
|
|
2004
1908
|
} catch (e) {
|
|
2005
1909
|
return console.info("Failed to install skills:", e.message), { success: !1 };
|
|
2006
1910
|
}
|
|
2007
|
-
},
|
|
1911
|
+
}, Ye = (o = ".", t = 3, e = 0) => {
|
|
2008
1912
|
const n = [];
|
|
2009
1913
|
if (e > t) return n;
|
|
2010
1914
|
try {
|
|
2011
|
-
const s =
|
|
1915
|
+
const s = P.readdirSync(o, { withFileTypes: !0 });
|
|
2012
1916
|
for (const i of s) {
|
|
2013
|
-
const
|
|
1917
|
+
const d = N.join(o, i.name);
|
|
2014
1918
|
if (i.isDirectory()) {
|
|
2015
1919
|
if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
|
|
2016
1920
|
continue;
|
|
2017
|
-
n.push(...
|
|
1921
|
+
n.push(...Ye(d, t, e + 1));
|
|
2018
1922
|
} else if (i.name === "myop.config.json")
|
|
2019
1923
|
try {
|
|
2020
|
-
const
|
|
1924
|
+
const g = P.readFileSync(d, "utf-8"), h = JSON.parse(g);
|
|
2021
1925
|
n.push({
|
|
2022
1926
|
path: o,
|
|
2023
|
-
configPath:
|
|
2024
|
-
name:
|
|
2025
|
-
componentId:
|
|
2026
|
-
config:
|
|
1927
|
+
configPath: d,
|
|
1928
|
+
name: h.name || h.componentName || N.basename(o),
|
|
1929
|
+
componentId: h.componentId || null,
|
|
1930
|
+
config: h
|
|
2027
1931
|
});
|
|
2028
1932
|
} catch {
|
|
2029
1933
|
}
|
|
@@ -2033,7 +1937,7 @@ const wo = () => {
|
|
|
2033
1937
|
return n;
|
|
2034
1938
|
};
|
|
2035
1939
|
v.executionPath = process.cwd();
|
|
2036
|
-
const
|
|
1940
|
+
const Me = (o = !1) => {
|
|
2037
1941
|
const t = v.program.getOptionValue("verbose");
|
|
2038
1942
|
t || (console.info = () => {
|
|
2039
1943
|
}), console.info("π verbose mode on"), v.options = {
|
|
@@ -2041,7 +1945,7 @@ const Ee = (o = !1) => {
|
|
|
2041
1945
|
verbose: t
|
|
2042
1946
|
};
|
|
2043
1947
|
try {
|
|
2044
|
-
return v.myopConfig =
|
|
1948
|
+
return v.myopConfig = Ot(v.options.configPath), { configFound: !0 };
|
|
2045
1949
|
} catch (e) {
|
|
2046
1950
|
if (o) {
|
|
2047
1951
|
console.info(`
|
|
@@ -2051,7 +1955,7 @@ const Ee = (o = !1) => {
|
|
|
2051
1955
|
author: "@myop-cli",
|
|
2052
1956
|
flows: []
|
|
2053
1957
|
};
|
|
2054
|
-
return
|
|
1958
|
+
return Je(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
|
|
2055
1959
|
} catch {
|
|
2056
1960
|
return console.info("Error details :", e), { configFound: !1, error: e };
|
|
2057
1961
|
}
|
|
@@ -2060,39 +1964,39 @@ const Ee = (o = !1) => {
|
|
|
2060
1964
|
}
|
|
2061
1965
|
};
|
|
2062
1966
|
[
|
|
2063
|
-
new
|
|
2064
|
-
...
|
|
1967
|
+
new De(),
|
|
1968
|
+
...Ft
|
|
2065
1969
|
];
|
|
2066
|
-
const
|
|
2067
|
-
v.program = new
|
|
2068
|
-
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(
|
|
2069
|
-
v.program.addOption(new
|
|
2070
|
-
v.program.addOption(new
|
|
2071
|
-
v.program.addOption(new
|
|
2072
|
-
v.program.addOption(new
|
|
2073
|
-
v.program.addOption(new
|
|
1970
|
+
const uo = "0.1.53";
|
|
1971
|
+
v.program = new bt();
|
|
1972
|
+
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(uo);
|
|
1973
|
+
v.program.addOption(new ue("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
1974
|
+
v.program.addOption(new ue("-h, --help", "Show helpful information"));
|
|
1975
|
+
v.program.addOption(new ue("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
|
|
1976
|
+
v.program.addOption(new ue("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
|
|
1977
|
+
v.program.addOption(new ue("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
|
|
2074
1978
|
v.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, t) => {
|
|
2075
|
-
|
|
1979
|
+
Me(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && at._action(t), process.exit();
|
|
2076
1980
|
});
|
|
2077
1981
|
v.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, t) => {
|
|
2078
|
-
|
|
1982
|
+
Me(), console.info("removing ", o, t, v.options.configPath), o === "flow" && lt._action(t), process.exit();
|
|
2079
1983
|
});
|
|
2080
1984
|
v.program.command("install").description("Install Myop assets").action(async () => {
|
|
2081
|
-
|
|
1985
|
+
Me(), await rt.action();
|
|
2082
1986
|
});
|
|
2083
1987
|
v.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
2084
1988
|
try {
|
|
2085
|
-
await
|
|
1989
|
+
await pe();
|
|
2086
1990
|
} catch (o) {
|
|
2087
1991
|
console.error("Login failed:", o.message), process.exit(1);
|
|
2088
1992
|
}
|
|
2089
1993
|
process.exit(0);
|
|
2090
1994
|
});
|
|
2091
1995
|
v.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
2092
|
-
await
|
|
1996
|
+
await mt(), process.exit(0);
|
|
2093
1997
|
});
|
|
2094
1998
|
v.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
2095
|
-
const o =
|
|
1999
|
+
const o = $e();
|
|
2096
2000
|
o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
|
|
2097
2001
|
});
|
|
2098
2002
|
v.program.command("sync").description('[deprecated] Use "myop push" instead').option("--skip-build", "Skip the build step").action(async () => {
|
|
@@ -2107,85 +2011,85 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
|
|
|
2107
2011
|
process.exit(0);
|
|
2108
2012
|
});
|
|
2109
2013
|
v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
|
|
2110
|
-
var S, x,
|
|
2014
|
+
var S, x, u;
|
|
2111
2015
|
const t = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2112
2016
|
let e = {};
|
|
2113
|
-
if (
|
|
2017
|
+
if (P.existsSync(t))
|
|
2114
2018
|
try {
|
|
2115
|
-
e = JSON.parse(
|
|
2116
|
-
} catch (
|
|
2117
|
-
console.error(`β οΈ Failed to parse ${t}:`,
|
|
2019
|
+
e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
2020
|
+
} catch (p) {
|
|
2021
|
+
console.error(`β οΈ Failed to parse ${t}:`, p.message);
|
|
2118
2022
|
}
|
|
2119
2023
|
o && (e.componentId = o);
|
|
2120
|
-
const n = e.name || e.componentName ||
|
|
2024
|
+
const n = e.name || e.componentName || N.basename(process.cwd());
|
|
2121
2025
|
console.log(`
|
|
2122
2026
|
π Component: ${n}`);
|
|
2123
2027
|
let s = null, i = !1;
|
|
2124
2028
|
try {
|
|
2125
|
-
const
|
|
2126
|
-
i = !!(
|
|
2029
|
+
const p = JSON.parse(P.readFileSync("package.json", "utf-8"));
|
|
2030
|
+
i = !!(p.scripts && p.scripts.build);
|
|
2127
2031
|
} catch {
|
|
2128
2032
|
}
|
|
2129
2033
|
if (!i) {
|
|
2130
|
-
const
|
|
2131
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2034
|
+
const p = P.readdirSync(".").filter(
|
|
2035
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2132
2036
|
);
|
|
2133
|
-
|
|
2037
|
+
p.length === 1 && (s = p[0]);
|
|
2134
2038
|
}
|
|
2135
2039
|
if (s)
|
|
2136
2040
|
console.log(` Single file: ${s} (skipping build)`);
|
|
2137
2041
|
else if (i) {
|
|
2138
|
-
const { exec:
|
|
2042
|
+
const { exec: p } = await import("child_process");
|
|
2139
2043
|
let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
2140
|
-
const
|
|
2141
|
-
const M =
|
|
2142
|
-
|
|
2044
|
+
const I = (C = !1) => new Promise((j) => {
|
|
2045
|
+
const M = V(C ? "Retrying build..." : "Building project...").start();
|
|
2046
|
+
p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (R, k, L) => {
|
|
2143
2047
|
if (!R) {
|
|
2144
2048
|
M.succeed("Build completed"), j(!0);
|
|
2145
2049
|
return;
|
|
2146
2050
|
}
|
|
2147
2051
|
if (M.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
|
|
2148
|
-
const
|
|
2149
|
-
if (E = { ...E, ...
|
|
2150
|
-
const
|
|
2151
|
-
j(
|
|
2052
|
+
const A = await ct(R, k, L, p, E);
|
|
2053
|
+
if (E = { ...E, ...A }, A.handled) {
|
|
2054
|
+
const _ = await I(!0);
|
|
2055
|
+
j(_);
|
|
2152
2056
|
return;
|
|
2153
2057
|
}
|
|
2154
2058
|
}
|
|
2155
2059
|
console.error(R.message), j(!1);
|
|
2156
2060
|
});
|
|
2157
2061
|
});
|
|
2158
|
-
await
|
|
2062
|
+
await I() || process.exit(1);
|
|
2159
2063
|
}
|
|
2160
|
-
let
|
|
2064
|
+
let d;
|
|
2161
2065
|
if (s)
|
|
2162
|
-
|
|
2163
|
-
else if (
|
|
2164
|
-
|
|
2066
|
+
d = s;
|
|
2067
|
+
else if (P.existsSync("./dist/index.html"))
|
|
2068
|
+
d = "./dist/index.html";
|
|
2165
2069
|
else {
|
|
2166
|
-
const
|
|
2167
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2070
|
+
const p = P.readdirSync(".").filter(
|
|
2071
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2168
2072
|
);
|
|
2169
|
-
|
|
2073
|
+
p.length === 1 ? d = p[0] : (console.error("β No HTML file found to upload."), console.log(" Expected: a single .html file in root or ./dist/index.html"), process.exit(1));
|
|
2170
2074
|
}
|
|
2171
|
-
const
|
|
2172
|
-
console.log(` File: ${
|
|
2173
|
-
let
|
|
2075
|
+
const g = P.readFileSync(d, "utf-8");
|
|
2076
|
+
console.log(` File: ${d} (${(g.length / 1024).toFixed(1)} KB)`);
|
|
2077
|
+
let h;
|
|
2174
2078
|
try {
|
|
2175
|
-
|
|
2176
|
-
} catch (
|
|
2177
|
-
re(
|
|
2079
|
+
h = await Ve();
|
|
2080
|
+
} catch (p) {
|
|
2081
|
+
re(p) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("β Authentication failed:", p.message), console.error(`
|
|
2178
2082
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2179
2083
|
`)), process.exit(1);
|
|
2180
2084
|
}
|
|
2181
|
-
const
|
|
2182
|
-
let
|
|
2085
|
+
const l = Ce();
|
|
2086
|
+
let c = V("Uploading...").start(), y;
|
|
2183
2087
|
try {
|
|
2184
|
-
const
|
|
2088
|
+
const p = await fetch(`${l}/mcp`, {
|
|
2185
2089
|
method: "POST",
|
|
2186
2090
|
headers: {
|
|
2187
2091
|
"Content-Type": "application/json",
|
|
2188
|
-
Authorization: `Bearer ${
|
|
2092
|
+
Authorization: `Bearer ${h.accessToken}`
|
|
2189
2093
|
},
|
|
2190
2094
|
body: JSON.stringify({
|
|
2191
2095
|
jsonrpc: "2.0",
|
|
@@ -2197,29 +2101,29 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2197
2101
|
name: n,
|
|
2198
2102
|
componentId: e.componentId && e.componentId !== "DEV" ? e.componentId : void 0,
|
|
2199
2103
|
organization: e.organization || void 0,
|
|
2200
|
-
htmlContent:
|
|
2104
|
+
htmlContent: g
|
|
2201
2105
|
}
|
|
2202
2106
|
}
|
|
2203
2107
|
})
|
|
2204
2108
|
});
|
|
2205
|
-
if (!
|
|
2206
|
-
throw new Error(`Server returned ${
|
|
2207
|
-
const E = await
|
|
2109
|
+
if (!p.ok)
|
|
2110
|
+
throw new Error(`Server returned ${p.status}`);
|
|
2111
|
+
const E = await p.json();
|
|
2208
2112
|
if (E.error)
|
|
2209
2113
|
throw new Error(E.error.message);
|
|
2210
|
-
const
|
|
2211
|
-
if (y = JSON.parse(
|
|
2114
|
+
const I = (u = (x = (S = E.result) == null ? void 0 : S.content) == null ? void 0 : x[0]) == null ? void 0 : u.text;
|
|
2115
|
+
if (y = JSON.parse(I), !y.success)
|
|
2212
2116
|
throw new Error(y.error);
|
|
2213
|
-
|
|
2214
|
-
} catch (
|
|
2215
|
-
|
|
2117
|
+
c.succeed("Pushed successfully");
|
|
2118
|
+
} catch (p) {
|
|
2119
|
+
c.fail("Upload failed"), re(p) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", p.message), process.exit(1);
|
|
2216
2120
|
}
|
|
2217
2121
|
if (y.isNewComponent || !e.componentId || e.componentId === "DEV") {
|
|
2218
2122
|
e.componentId = y.componentId, e.organization = y.orgId, e.name || (e.name = y.componentName);
|
|
2219
2123
|
try {
|
|
2220
|
-
|
|
2221
|
-
} catch (
|
|
2222
|
-
console.log(`β οΈ Could not update ${t}: ${
|
|
2124
|
+
P.writeFileSync(t, JSON.stringify(e, null, 2));
|
|
2125
|
+
} catch (p) {
|
|
2126
|
+
console.log(`β οΈ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
|
|
2223
2127
|
}
|
|
2224
2128
|
}
|
|
2225
2129
|
console.log(`
|
|
@@ -2227,12 +2131,12 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2227
2131
|
`), process.exit(0);
|
|
2228
2132
|
});
|
|
2229
2133
|
v.program.command("pull").description("Download component HTML from Myop platform").argument("[componentId]", "Component ID to pull (overrides myop.config.json)").option("-o, --output <path>", "Output file path (default: index.html or dist/index.html)").option("-e, --env <environment>", "Pull the variant released to this environment (e.g., staging, production)").action(async (o, t) => {
|
|
2230
|
-
var
|
|
2134
|
+
var p, E, I;
|
|
2231
2135
|
const e = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2232
2136
|
let n = {};
|
|
2233
|
-
if (
|
|
2137
|
+
if (P.existsSync(e))
|
|
2234
2138
|
try {
|
|
2235
|
-
n = JSON.parse(
|
|
2139
|
+
n = JSON.parse(P.readFileSync(e, "utf-8"));
|
|
2236
2140
|
} catch {
|
|
2237
2141
|
}
|
|
2238
2142
|
const s = o || n.componentId;
|
|
@@ -2240,22 +2144,22 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2240
2144
|
const i = n.name || n.componentName || s;
|
|
2241
2145
|
console.log(`
|
|
2242
2146
|
π₯ Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
|
|
2243
|
-
let
|
|
2147
|
+
let d;
|
|
2244
2148
|
try {
|
|
2245
|
-
|
|
2246
|
-
} catch (
|
|
2247
|
-
re(
|
|
2149
|
+
d = await Ve();
|
|
2150
|
+
} catch ($) {
|
|
2151
|
+
re($) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("β Authentication failed:", $.message), console.error(`
|
|
2248
2152
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2249
2153
|
`)), process.exit(1);
|
|
2250
2154
|
}
|
|
2251
|
-
const
|
|
2252
|
-
let
|
|
2155
|
+
const g = Ce(), h = V("Fetching component...").start();
|
|
2156
|
+
let l;
|
|
2253
2157
|
try {
|
|
2254
|
-
const
|
|
2158
|
+
const $ = await fetch(`${g}/mcp`, {
|
|
2255
2159
|
method: "POST",
|
|
2256
2160
|
headers: {
|
|
2257
2161
|
"Content-Type": "application/json",
|
|
2258
|
-
Authorization: `Bearer ${
|
|
2162
|
+
Authorization: `Bearer ${d.accessToken}`
|
|
2259
2163
|
},
|
|
2260
2164
|
body: JSON.stringify({
|
|
2261
2165
|
jsonrpc: "2.0",
|
|
@@ -2267,33 +2171,33 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2267
2171
|
}
|
|
2268
2172
|
})
|
|
2269
2173
|
});
|
|
2270
|
-
if (
|
|
2271
|
-
throw new Error(`Server returned ${
|
|
2272
|
-
const
|
|
2273
|
-
if (
|
|
2274
|
-
throw new Error(
|
|
2275
|
-
const j = (
|
|
2276
|
-
|
|
2277
|
-
} catch (
|
|
2278
|
-
|
|
2279
|
-
}
|
|
2280
|
-
let
|
|
2281
|
-
|
|
2282
|
-
const y =
|
|
2283
|
-
S && !
|
|
2284
|
-
const x =
|
|
2285
|
-
let
|
|
2286
|
-
if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s,
|
|
2287
|
-
name:
|
|
2174
|
+
if (!$.ok)
|
|
2175
|
+
throw new Error(`Server returned ${$.status}`);
|
|
2176
|
+
const C = await $.json();
|
|
2177
|
+
if (C.error)
|
|
2178
|
+
throw new Error(C.error.message);
|
|
2179
|
+
const j = (I = (E = (p = C.result) == null ? void 0 : p.content) == null ? void 0 : E[0]) == null ? void 0 : I.text;
|
|
2180
|
+
l = JSON.parse(j), !l.success && !l.html && (h.fail("Failed to fetch component"), console.error(" ", l.error || "No HTML content returned"), l.message && console.error(" ", l.message), process.exit(1)), h.succeed("Component fetched");
|
|
2181
|
+
} catch ($) {
|
|
2182
|
+
h.fail("Failed to fetch component"), re($) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", $.message), process.exit(1);
|
|
2183
|
+
}
|
|
2184
|
+
let c = t.output;
|
|
2185
|
+
c || (P.existsSync("./dist/index.html") ? c = "./dist/index.html" : c = "./index.html");
|
|
2186
|
+
const y = l.htmlContent || l.html, S = N.dirname(c);
|
|
2187
|
+
S && !P.existsSync(S) && P.mkdirSync(S, { recursive: !0 }), P.writeFileSync(c, y), console.log(` Saved to: ${c} (${(y.length / 1024).toFixed(1)} KB)`);
|
|
2188
|
+
const x = P.existsSync(e);
|
|
2189
|
+
let u = !1;
|
|
2190
|
+
if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, u = !0), !n.name && l.name && (n.name = l.name, u = !0)) : (n = {
|
|
2191
|
+
name: l.name || N.basename(process.cwd()),
|
|
2288
2192
|
componentId: s,
|
|
2289
2193
|
type: "html",
|
|
2290
2194
|
author: "@myop-cli",
|
|
2291
2195
|
HMR: !0
|
|
2292
|
-
},
|
|
2196
|
+
}, u = !0), u)
|
|
2293
2197
|
try {
|
|
2294
|
-
|
|
2295
|
-
} catch (
|
|
2296
|
-
console.log(` β οΈ Could not write ${e}: ${
|
|
2198
|
+
P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${x ? "Updated" : "Created"} ${e}`);
|
|
2199
|
+
} catch ($) {
|
|
2200
|
+
console.log(` β οΈ Could not write ${e}: ${$.message}`);
|
|
2297
2201
|
}
|
|
2298
2202
|
console.log(`
|
|
2299
2203
|
β
Pull completed!
|
|
@@ -2303,95 +2207,95 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2303
2207
|
const { search: t, select: e } = await import("@inquirer/prompts");
|
|
2304
2208
|
let n;
|
|
2305
2209
|
try {
|
|
2306
|
-
n = await
|
|
2307
|
-
} catch (
|
|
2308
|
-
re(
|
|
2210
|
+
n = await Ve();
|
|
2211
|
+
} catch (u) {
|
|
2212
|
+
re(u) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("β Authentication failed:", u.message), console.error(`
|
|
2309
2213
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2310
2214
|
`)), process.exit(1);
|
|
2311
2215
|
}
|
|
2312
|
-
const s =
|
|
2313
|
-
let
|
|
2216
|
+
const s = Ce(), i = (u, p) => lo(s, n.accessToken, u, p);
|
|
2217
|
+
let d = V("Loading organizations...").start(), g;
|
|
2314
2218
|
try {
|
|
2315
|
-
const
|
|
2316
|
-
if (
|
|
2219
|
+
const u = await i("list_organizations");
|
|
2220
|
+
if (g = u.organizations || u, !Array.isArray(g))
|
|
2317
2221
|
throw new Error("Unexpected response from list_organizations");
|
|
2318
|
-
} catch (
|
|
2319
|
-
|
|
2222
|
+
} catch (u) {
|
|
2223
|
+
d.fail("Failed to load organizations"), re(u) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", u.message), process.exit(1);
|
|
2320
2224
|
}
|
|
2321
|
-
|
|
2322
|
-
let
|
|
2225
|
+
g.length === 0 && (d.fail("No organizations found for this account"), process.exit(1)), d.stop();
|
|
2226
|
+
let h, l;
|
|
2323
2227
|
if (o.org) {
|
|
2324
|
-
const
|
|
2325
|
-
|
|
2228
|
+
const u = g.find((p) => p.id === o.org || p._id === o.org);
|
|
2229
|
+
u || (console.error(`Organization "${o.org}" not found. Available:`), g.forEach((p) => console.log(` ${p.id || p._id} ${p.name}`)), process.exit(1)), h = u.id || u._id, l = u.name, je({ id: h, name: l });
|
|
2326
2230
|
} else {
|
|
2327
|
-
const
|
|
2328
|
-
if (
|
|
2329
|
-
|
|
2330
|
-
else if (
|
|
2331
|
-
|
|
2231
|
+
const u = ao();
|
|
2232
|
+
if (u && g.find((p) => (p.id || p._id) === u.id))
|
|
2233
|
+
h = u.id, l = u.name;
|
|
2234
|
+
else if (g.length === 1)
|
|
2235
|
+
h = g[0].id || g[0]._id, l = g[0].name, je({ id: h, name: l });
|
|
2332
2236
|
else
|
|
2333
2237
|
try {
|
|
2334
|
-
const
|
|
2238
|
+
const p = await e({
|
|
2335
2239
|
message: "Select an organization:",
|
|
2336
|
-
choices:
|
|
2240
|
+
choices: g.map((E) => ({
|
|
2337
2241
|
name: E.name,
|
|
2338
2242
|
value: { id: E.id || E._id, name: E.name }
|
|
2339
2243
|
}))
|
|
2340
2244
|
});
|
|
2341
|
-
|
|
2342
|
-
} catch (
|
|
2343
|
-
throw
|
|
2245
|
+
h = p.id, l = p.name, je({ id: h, name: l });
|
|
2246
|
+
} catch (p) {
|
|
2247
|
+
throw p.name === "ExitPromptError" && (console.log(`
|
|
2344
2248
|
|
|
2345
2249
|
π Goodbye!
|
|
2346
|
-
`), process.exit(0)),
|
|
2250
|
+
`), process.exit(0)), p;
|
|
2347
2251
|
}
|
|
2348
2252
|
}
|
|
2349
|
-
console.log(` Using organization: ${
|
|
2350
|
-
let
|
|
2253
|
+
console.log(` Using organization: ${l}`), d = V("Loading components...").start();
|
|
2254
|
+
let c;
|
|
2351
2255
|
try {
|
|
2352
|
-
const
|
|
2353
|
-
if (
|
|
2256
|
+
const u = await i("list_components", { organizationId: h });
|
|
2257
|
+
if (c = u.components || u, !Array.isArray(c))
|
|
2354
2258
|
throw new Error("Unexpected response from list_components");
|
|
2355
|
-
} catch (
|
|
2356
|
-
|
|
2259
|
+
} catch (u) {
|
|
2260
|
+
d.fail("Failed to load components"), console.error(" ", u.message), process.exit(1);
|
|
2357
2261
|
}
|
|
2358
|
-
|
|
2359
|
-
`), process.exit(0)), console.log(` ${
|
|
2262
|
+
d.stop(), c.length === 0 && (console.log(` No components found in this organization.
|
|
2263
|
+
`), process.exit(0)), console.log(` ${l} - ${c.length} component(s)
|
|
2360
2264
|
`);
|
|
2361
2265
|
const y = [];
|
|
2362
2266
|
for (; ; ) {
|
|
2363
|
-
const
|
|
2364
|
-
let
|
|
2267
|
+
const u = `[Done - pull/push ${y.length} selected]`, p = "__done__", E = new Set(y.map((C) => C.id || C._id || C.componentId));
|
|
2268
|
+
let I;
|
|
2365
2269
|
try {
|
|
2366
|
-
|
|
2270
|
+
I = await t({
|
|
2367
2271
|
message: "Search & select components:",
|
|
2368
|
-
source: (
|
|
2369
|
-
const j = (
|
|
2272
|
+
source: (C) => {
|
|
2273
|
+
const j = (C || "").toLowerCase(), M = c.filter((k) => {
|
|
2370
2274
|
const L = k.id || k._id || k.componentId;
|
|
2371
2275
|
return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
|
|
2372
2276
|
}), R = [
|
|
2373
|
-
{ name:
|
|
2277
|
+
{ name: u, value: p }
|
|
2374
2278
|
];
|
|
2375
2279
|
for (const k of M) {
|
|
2376
|
-
const L = k.id || k._id || k.componentId,
|
|
2280
|
+
const L = k.id || k._id || k.componentId, A = L ? L.substring(0, 8) + "..." : "";
|
|
2377
2281
|
R.push({
|
|
2378
|
-
name: `${k.name} (${
|
|
2282
|
+
name: `${k.name} (${A})`,
|
|
2379
2283
|
value: L
|
|
2380
2284
|
});
|
|
2381
2285
|
}
|
|
2382
2286
|
return R;
|
|
2383
2287
|
}
|
|
2384
2288
|
});
|
|
2385
|
-
} catch (
|
|
2386
|
-
throw
|
|
2289
|
+
} catch (C) {
|
|
2290
|
+
throw C.name === "ExitPromptError" && (console.log(`
|
|
2387
2291
|
|
|
2388
2292
|
π Goodbye!
|
|
2389
|
-
`), process.exit(0)),
|
|
2293
|
+
`), process.exit(0)), C;
|
|
2390
2294
|
}
|
|
2391
|
-
if (
|
|
2295
|
+
if (I === p)
|
|
2392
2296
|
break;
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2297
|
+
const $ = c.find((C) => (C.id || C._id || C.componentId) === I);
|
|
2298
|
+
$ && (y.push($), console.log(` + ${$.name}`));
|
|
2395
2299
|
}
|
|
2396
2300
|
y.length === 0 && (console.log(` No components selected.
|
|
2397
2301
|
`), process.exit(0));
|
|
@@ -2405,87 +2309,87 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2405
2309
|
{ name: "Cancel", value: "cancel" }
|
|
2406
2310
|
]
|
|
2407
2311
|
});
|
|
2408
|
-
} catch (
|
|
2409
|
-
throw
|
|
2312
|
+
} catch (u) {
|
|
2313
|
+
throw u.name === "ExitPromptError" && (console.log(`
|
|
2410
2314
|
|
|
2411
2315
|
π Goodbye!
|
|
2412
|
-
`), process.exit(0)),
|
|
2316
|
+
`), process.exit(0)), u;
|
|
2413
2317
|
}
|
|
2414
2318
|
S === "cancel" && (console.log(` Cancelled.
|
|
2415
2319
|
`), process.exit(0));
|
|
2416
|
-
const x = (
|
|
2320
|
+
const x = (u) => u.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
2417
2321
|
if (S === "pull") {
|
|
2418
2322
|
console.log(`
|
|
2419
2323
|
Pulling ${y.length} components...
|
|
2420
2324
|
`);
|
|
2421
|
-
const
|
|
2422
|
-
const
|
|
2325
|
+
const u = await Promise.all(y.map(async (I) => {
|
|
2326
|
+
const $ = I.id || I._id || I.componentId;
|
|
2423
2327
|
try {
|
|
2424
|
-
const
|
|
2425
|
-
|
|
2426
|
-
const M =
|
|
2328
|
+
const C = await i("get_component", { componentId: $ }), j = x(I.name);
|
|
2329
|
+
P.mkdirSync(j, { recursive: !0 });
|
|
2330
|
+
const M = C.htmlContent || C.html;
|
|
2427
2331
|
if (!M)
|
|
2428
2332
|
throw new Error("No HTML content returned");
|
|
2429
|
-
return
|
|
2430
|
-
name:
|
|
2431
|
-
componentId:
|
|
2432
|
-
organization:
|
|
2333
|
+
return P.writeFileSync(N.join(j, "index.html"), M), P.writeFileSync(N.join(j, "myop.config.json"), JSON.stringify({
|
|
2334
|
+
name: I.name,
|
|
2335
|
+
componentId: $,
|
|
2336
|
+
organization: h,
|
|
2433
2337
|
type: "html",
|
|
2434
2338
|
author: "@myop-cli",
|
|
2435
2339
|
HMR: !0
|
|
2436
|
-
}, null, 2)), { name:
|
|
2437
|
-
} catch (
|
|
2438
|
-
return { name:
|
|
2340
|
+
}, null, 2)), { name: I.name, status: "ok", dir: j };
|
|
2341
|
+
} catch (C) {
|
|
2342
|
+
return { name: I.name, status: "failed", error: C.message };
|
|
2439
2343
|
}
|
|
2440
2344
|
}));
|
|
2441
|
-
let
|
|
2442
|
-
for (const
|
|
2443
|
-
|
|
2345
|
+
let p = 0, E = 0;
|
|
2346
|
+
for (const I of u)
|
|
2347
|
+
I.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${I.name} -> ./${I.dir}/`), p++) : (console.log(` \x1B[31mβ\x1B[0m ${I.name} - ${I.error}`), E++);
|
|
2444
2348
|
console.log(`
|
|
2445
|
-
Done! Pulled ${
|
|
2349
|
+
Done! Pulled ${p} component${p !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
|
|
2446
2350
|
`);
|
|
2447
2351
|
} else if (S === "push") {
|
|
2448
2352
|
console.log(`
|
|
2449
2353
|
Pushing ${y.length} components...
|
|
2450
2354
|
`);
|
|
2451
|
-
const
|
|
2452
|
-
const j =
|
|
2355
|
+
const u = Ye(".", 3), p = await Promise.all(y.map(async (C) => {
|
|
2356
|
+
const j = C.id || C._id || C.componentId, M = u.find((R) => R.componentId === j);
|
|
2453
2357
|
if (!M)
|
|
2454
|
-
return { name:
|
|
2358
|
+
return { name: C.name, status: "skipped", reason: "no local match" };
|
|
2455
2359
|
try {
|
|
2456
2360
|
let R;
|
|
2457
2361
|
const k = M.path;
|
|
2458
|
-
if (
|
|
2459
|
-
R =
|
|
2362
|
+
if (P.existsSync(N.join(k, "dist", "index.html")))
|
|
2363
|
+
R = N.join(k, "dist", "index.html");
|
|
2460
2364
|
else {
|
|
2461
|
-
const
|
|
2462
|
-
(
|
|
2365
|
+
const z = P.readdirSync(k).filter(
|
|
2366
|
+
(T) => T.endsWith(".html") && !T.startsWith(".") && P.statSync(N.join(k, T)).isFile()
|
|
2463
2367
|
);
|
|
2464
|
-
if (
|
|
2465
|
-
R =
|
|
2466
|
-
else if (
|
|
2467
|
-
R =
|
|
2368
|
+
if (z.length === 1)
|
|
2369
|
+
R = N.join(k, z[0]);
|
|
2370
|
+
else if (z.includes("index.html"))
|
|
2371
|
+
R = N.join(k, "index.html");
|
|
2468
2372
|
else
|
|
2469
2373
|
throw new Error("No HTML file found");
|
|
2470
2374
|
}
|
|
2471
|
-
const L =
|
|
2472
|
-
name:
|
|
2375
|
+
const L = P.readFileSync(R, "utf-8"), A = M.name || C.name, _ = await i("upload_component", {
|
|
2376
|
+
name: A,
|
|
2473
2377
|
componentId: j,
|
|
2474
|
-
organization:
|
|
2378
|
+
organization: h,
|
|
2475
2379
|
htmlContent: L
|
|
2476
2380
|
});
|
|
2477
|
-
if (!
|
|
2478
|
-
throw new Error(
|
|
2479
|
-
return { name:
|
|
2381
|
+
if (!_.success)
|
|
2382
|
+
throw new Error(_.error || "Upload failed");
|
|
2383
|
+
return { name: A, status: "ok" };
|
|
2480
2384
|
} catch (R) {
|
|
2481
|
-
return { name:
|
|
2385
|
+
return { name: C.name, status: "failed", error: R.message };
|
|
2482
2386
|
}
|
|
2483
2387
|
}));
|
|
2484
|
-
let E = 0,
|
|
2485
|
-
for (const
|
|
2486
|
-
|
|
2388
|
+
let E = 0, I = 0, $ = 0;
|
|
2389
|
+
for (const C of p)
|
|
2390
|
+
C.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${C.name}`), E++) : C.status === "skipped" ? (console.log(` \x1B[33mβ\x1B[0m ${C.name} (${C.reason})`), I++) : (console.log(` \x1B[31mβ\x1B[0m ${C.name} - ${C.error}`), $++);
|
|
2487
2391
|
console.log(`
|
|
2488
|
-
Done! Pushed ${E}${
|
|
2392
|
+
Done! Pushed ${E}${I ? `, skipped ${I}` : ""}${$ ? `, ${$} failed` : ""}.
|
|
2489
2393
|
`);
|
|
2490
2394
|
}
|
|
2491
2395
|
process.exit(0);
|
|
@@ -2498,11 +2402,11 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2498
2402
|
message: "Component name:",
|
|
2499
2403
|
default: n
|
|
2500
2404
|
});
|
|
2501
|
-
} catch (
|
|
2502
|
-
throw
|
|
2405
|
+
} catch (h) {
|
|
2406
|
+
throw h.name === "ExitPromptError" && (console.log(`
|
|
2503
2407
|
|
|
2504
2408
|
π Goodbye!
|
|
2505
|
-
`), process.exit(0)),
|
|
2409
|
+
`), process.exit(0)), h;
|
|
2506
2410
|
}
|
|
2507
2411
|
(t.existsSync("index.html") || t.existsSync("myop.config.json")) && (console.log(`
|
|
2508
2412
|
β οΈ index.html or myop.config.json already exists in this directory.`), console.log(" Use `myop dev` to start the dev server for an existing component.\n"), process.exit(1));
|
|
@@ -2514,7 +2418,7 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2514
2418
|
HMR: !0
|
|
2515
2419
|
};
|
|
2516
2420
|
t.writeFileSync("myop.config.json", JSON.stringify(i, null, 2));
|
|
2517
|
-
const
|
|
2421
|
+
const d = `<!DOCTYPE html>
|
|
2518
2422
|
<html lang="en">
|
|
2519
2423
|
<head>
|
|
2520
2424
|
<meta charset="UTF-8">
|
|
@@ -2636,25 +2540,24 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2636
2540
|
<\/script>
|
|
2637
2541
|
</body>
|
|
2638
2542
|
</html>`;
|
|
2639
|
-
t.writeFileSync("index.html",
|
|
2640
|
-
const
|
|
2543
|
+
t.writeFileSync("index.html", d);
|
|
2544
|
+
const g = await Ge(process.cwd());
|
|
2641
2545
|
console.log(`
|
|
2642
|
-
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"),
|
|
2546
|
+
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), g.success && console.log(" AI agent skills installed"), console.log(""), await be();
|
|
2643
2547
|
});
|
|
2644
|
-
v.program.command("dev").description("Start development server with file watching").action(
|
|
2645
|
-
|
|
2646
|
-
const
|
|
2647
|
-
const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Ke(o);
|
|
2548
|
+
v.program.command("dev").description("Start development server with file watching").action(be);
|
|
2549
|
+
const gt = async () => {
|
|
2550
|
+
const o = process.cwd(), t = V("Installing AI agent skills...").start(), e = await Ge(o);
|
|
2648
2551
|
e.success ? (t.succeed("AI agent skills installed"), e.detected.length > 0 && console.log(` Detected: ${e.detected.join(", ")}`), console.log(` Skills: ${e.skillNames.join(", ")}`)) : t.fail("Failed to install skills"), process.exit(e.success ? 0 : 1);
|
|
2649
2552
|
};
|
|
2650
|
-
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(
|
|
2651
|
-
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(
|
|
2553
|
+
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(gt);
|
|
2554
|
+
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(gt);
|
|
2652
2555
|
v.program.command("mcp").description("Configure Myop MCP server for your AI coding assistant").action(async () => {
|
|
2653
|
-
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s =
|
|
2556
|
+
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Ce() + "/mcp", i = [
|
|
2654
2557
|
{
|
|
2655
2558
|
name: "Claude Code",
|
|
2656
2559
|
value: "claude",
|
|
2657
|
-
configPath:
|
|
2560
|
+
configPath: N.join(n, ".claude.json"),
|
|
2658
2561
|
getEntry: () => ({ type: "http", url: s }),
|
|
2659
2562
|
nextSteps: [
|
|
2660
2563
|
"Restart Claude Code to pick up the new MCP config.",
|
|
@@ -2666,7 +2569,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2666
2569
|
{
|
|
2667
2570
|
name: "Cursor",
|
|
2668
2571
|
value: "cursor",
|
|
2669
|
-
configPath:
|
|
2572
|
+
configPath: N.join(n, ".cursor", "mcp.json"),
|
|
2670
2573
|
getEntry: () => ({ url: s }),
|
|
2671
2574
|
nextSteps: [
|
|
2672
2575
|
'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
|
|
@@ -2679,7 +2582,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2679
2582
|
{
|
|
2680
2583
|
name: "Windsurf",
|
|
2681
2584
|
value: "windsurf",
|
|
2682
|
-
configPath:
|
|
2585
|
+
configPath: N.join(n, ".codeium", "windsurf", "mcp_config.json"),
|
|
2683
2586
|
getEntry: () => ({ url: s }),
|
|
2684
2587
|
nextSteps: [
|
|
2685
2588
|
"Open Cascade and click the hammer icon (top-right) to see MCP servers.",
|
|
@@ -2691,7 +2594,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2691
2594
|
{
|
|
2692
2595
|
name: "VS Code (GitHub Copilot)",
|
|
2693
2596
|
value: "vscode",
|
|
2694
|
-
configPath: process.platform === "darwin" ?
|
|
2597
|
+
configPath: process.platform === "darwin" ? N.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? N.join(process.env.APPDATA || N.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : N.join(n, ".config", "Code", "User", "mcp.json"),
|
|
2695
2598
|
getEntry: () => ({ type: "http", url: s }),
|
|
2696
2599
|
nextSteps: [
|
|
2697
2600
|
"Requires VS Code 1.99+ and GitHub Copilot extension.",
|
|
@@ -2706,52 +2609,52 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2706
2609
|
console.log(`
|
|
2707
2610
|
Configure Myop MCP server for your AI coding assistant.
|
|
2708
2611
|
`);
|
|
2709
|
-
let
|
|
2612
|
+
let d;
|
|
2710
2613
|
try {
|
|
2711
|
-
|
|
2614
|
+
d = await o({
|
|
2712
2615
|
message: "Select your AI coding assistant:",
|
|
2713
|
-
choices: i.map((
|
|
2616
|
+
choices: i.map((c) => ({ name: c.name, value: c.value }))
|
|
2714
2617
|
});
|
|
2715
|
-
} catch (
|
|
2716
|
-
throw
|
|
2618
|
+
} catch (c) {
|
|
2619
|
+
throw c.name === "ExitPromptError" && (console.log(`
|
|
2717
2620
|
|
|
2718
2621
|
π Goodbye!
|
|
2719
|
-
`), process.exit(0)),
|
|
2622
|
+
`), process.exit(0)), c;
|
|
2720
2623
|
}
|
|
2721
|
-
const
|
|
2722
|
-
let
|
|
2624
|
+
const g = i.find((c) => c.value === d);
|
|
2625
|
+
let h = {};
|
|
2723
2626
|
try {
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2627
|
+
const c = P.readFileSync(g.configPath, "utf-8");
|
|
2628
|
+
h = JSON.parse(c);
|
|
2726
2629
|
} catch {
|
|
2727
2630
|
}
|
|
2728
|
-
|
|
2729
|
-
const
|
|
2730
|
-
if (
|
|
2631
|
+
h.mcpServers || (h.mcpServers = {});
|
|
2632
|
+
const l = h.mcpServers.myop;
|
|
2633
|
+
if (l && l.url === s) {
|
|
2731
2634
|
console.log(`
|
|
2732
|
-
Myop MCP is already configured for ${
|
|
2635
|
+
Myop MCP is already configured for ${g.name}.`), console.log(` Config: ${g.configPath}`), console.log(`
|
|
2733
2636
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2734
|
-
for (const
|
|
2735
|
-
console.log(` ${
|
|
2637
|
+
for (const c of g.nextSteps)
|
|
2638
|
+
console.log(` ${c}`);
|
|
2736
2639
|
console.log(""), process.exit(0);
|
|
2737
2640
|
}
|
|
2738
|
-
if (
|
|
2641
|
+
if (l) {
|
|
2739
2642
|
console.log(`
|
|
2740
|
-
Myop MCP is already configured (URL: ${
|
|
2643
|
+
Myop MCP is already configured (URL: ${l.url}).`);
|
|
2741
2644
|
try {
|
|
2742
2645
|
await t({ message: "Update to latest URL?", default: !0 }) || process.exit(0);
|
|
2743
|
-
} catch (
|
|
2744
|
-
throw
|
|
2646
|
+
} catch (c) {
|
|
2647
|
+
throw c.name === "ExitPromptError" && process.exit(0), c;
|
|
2745
2648
|
}
|
|
2746
2649
|
}
|
|
2747
|
-
|
|
2748
|
-
\x1B[32mβ\x1B[0m Myop MCP configured for ${
|
|
2650
|
+
h.mcpServers.myop = g.getEntry(), P.mkdirSync(N.dirname(g.configPath), { recursive: !0 }), P.writeFileSync(g.configPath, JSON.stringify(h, null, 2)), console.log(`
|
|
2651
|
+
\x1B[32mβ\x1B[0m Myop MCP configured for ${g.name}`), console.log(` Config: ${g.configPath}`), console.log(` Server: ${s}`), console.log(`
|
|
2749
2652
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2750
|
-
for (const
|
|
2751
|
-
console.log(` ${
|
|
2653
|
+
for (const c of g.nextSteps)
|
|
2654
|
+
console.log(` ${c}`);
|
|
2752
2655
|
console.log(""), process.exit(0);
|
|
2753
2656
|
});
|
|
2754
|
-
const
|
|
2657
|
+
const go = () => {
|
|
2755
2658
|
try {
|
|
2756
2659
|
Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2757
2660
|
} catch {
|
|
@@ -2784,12 +2687,12 @@ const xo = () => {
|
|
|
2784
2687
|
return null;
|
|
2785
2688
|
}
|
|
2786
2689
|
}, ne = async (o = !1, t = !1) => {
|
|
2787
|
-
var
|
|
2788
|
-
const e =
|
|
2690
|
+
var c, y, S;
|
|
2691
|
+
const e = $e(), n = !!(e != null && e.email), s = ((c = v.myopConfig) == null ? void 0 : c.name) || ((y = v.myopConfig) == null ? void 0 : y.componentName), i = (S = v.myopConfig) == null ? void 0 : S.componentId, d = go();
|
|
2789
2692
|
console.log(`
|
|
2790
2693
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2791
|
-
`), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`),
|
|
2792
|
-
const
|
|
2694
|
+
`), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`), d != null && d.gitNotInstalled ? (console.log(" Changes: Git not installed"), console.log(" Install: https://git-scm.com/downloads"), console.log(" Mac: brew install git | Windows: https://gitforwindows.org")) : d != null && d.notARepo ? console.log(" Changes: Not a git repository") : d && (d.insertions > 0 || d.deletions > 0) ? console.log(` Changes: ${d.files} file${d.files !== 1 ? "s" : ""} | \x1B[32m+${d.insertions}\x1B[0m \x1B[31m-${d.deletions}\x1B[0m`) : d && console.log(" Changes: No uncommitted changes"), console.log("");
|
|
2695
|
+
const h = [
|
|
2793
2696
|
{
|
|
2794
2697
|
emoji: "π",
|
|
2795
2698
|
label: "Initialize new component",
|
|
@@ -2817,8 +2720,8 @@ const xo = () => {
|
|
|
2817
2720
|
value: x.value,
|
|
2818
2721
|
disabled: x.disabled
|
|
2819
2722
|
}));
|
|
2820
|
-
|
|
2821
|
-
new
|
|
2723
|
+
h.push(
|
|
2724
|
+
new De(),
|
|
2822
2725
|
{
|
|
2823
2726
|
name: t && n ? `π Logout (${e.email})
|
|
2824
2727
|
Clears stored credentials from this machine` : t && !n ? `π Login to Myop
|
|
@@ -2829,17 +2732,17 @@ const xo = () => {
|
|
|
2829
2732
|
name: t ? "π Hide help" : "π Show help",
|
|
2830
2733
|
value: "help"
|
|
2831
2734
|
},
|
|
2832
|
-
new
|
|
2735
|
+
new De(),
|
|
2833
2736
|
{
|
|
2834
2737
|
name: "π Exit",
|
|
2835
2738
|
value: "exit"
|
|
2836
2739
|
}
|
|
2837
2740
|
);
|
|
2838
|
-
let
|
|
2741
|
+
let l;
|
|
2839
2742
|
try {
|
|
2840
|
-
|
|
2743
|
+
l = await ot({
|
|
2841
2744
|
message: "What would you like to do?",
|
|
2842
|
-
choices:
|
|
2745
|
+
choices: h
|
|
2843
2746
|
});
|
|
2844
2747
|
} catch (x) {
|
|
2845
2748
|
throw x.name === "ExitPromptError" && (console.log(`
|
|
@@ -2847,9 +2750,9 @@ const xo = () => {
|
|
|
2847
2750
|
π Goodbye!
|
|
2848
2751
|
`), process.exit(0)), x;
|
|
2849
2752
|
}
|
|
2850
|
-
switch (
|
|
2753
|
+
switch (l) {
|
|
2851
2754
|
case "init":
|
|
2852
|
-
await
|
|
2755
|
+
await wo();
|
|
2853
2756
|
break;
|
|
2854
2757
|
case "sync":
|
|
2855
2758
|
console.log(`
|
|
@@ -2863,18 +2766,18 @@ Pushing component...
|
|
|
2863
2766
|
await ne(!0, t);
|
|
2864
2767
|
break;
|
|
2865
2768
|
case "dev":
|
|
2866
|
-
await
|
|
2769
|
+
await be();
|
|
2867
2770
|
break;
|
|
2868
2771
|
case "login":
|
|
2869
2772
|
try {
|
|
2870
|
-
await
|
|
2773
|
+
await pe(), console.log(`
|
|
2871
2774
|
`), await ne(o, t);
|
|
2872
|
-
} catch (
|
|
2873
|
-
console.error("Login failed:",
|
|
2775
|
+
} catch (u) {
|
|
2776
|
+
console.error("Login failed:", u.message), await ne(o, t);
|
|
2874
2777
|
}
|
|
2875
2778
|
break;
|
|
2876
2779
|
case "logout":
|
|
2877
|
-
await
|
|
2780
|
+
await mt(), console.log(`
|
|
2878
2781
|
`), await ne(o, t);
|
|
2879
2782
|
break;
|
|
2880
2783
|
case "help":
|
|
@@ -2883,48 +2786,48 @@ Pushing component...
|
|
|
2883
2786
|
case "exit":
|
|
2884
2787
|
process.exit(0);
|
|
2885
2788
|
}
|
|
2886
|
-
},
|
|
2789
|
+
}, xe = ".myop-monorepo.json", fo = () => {
|
|
2887
2790
|
try {
|
|
2888
|
-
const o =
|
|
2791
|
+
const o = P.readFileSync(xe, "utf-8");
|
|
2889
2792
|
return JSON.parse(o);
|
|
2890
2793
|
} catch {
|
|
2891
2794
|
return null;
|
|
2892
2795
|
}
|
|
2893
|
-
},
|
|
2796
|
+
}, ho = (o) => {
|
|
2894
2797
|
try {
|
|
2895
2798
|
const t = {
|
|
2896
2799
|
selectedComponents: o,
|
|
2897
2800
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2898
2801
|
};
|
|
2899
|
-
|
|
2802
|
+
P.writeFileSync(xe, JSON.stringify(t, null, 2));
|
|
2900
2803
|
} catch {
|
|
2901
2804
|
}
|
|
2902
|
-
},
|
|
2903
|
-
const o =
|
|
2805
|
+
}, yo = async () => {
|
|
2806
|
+
const o = $e(), t = !!(o != null && o.email);
|
|
2904
2807
|
console.log(`
|
|
2905
2808
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Myop CLI - Monorepo Mode β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2906
2809
|
`);
|
|
2907
|
-
const e =
|
|
2810
|
+
const e = V("Scanning for components...").start(), n = Ye(".");
|
|
2908
2811
|
e.stop(), n.length === 0 && (console.log(` β οΈ No myop.config.json files found in this directory or subdirectories.
|
|
2909
2812
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2910
|
-
const s =
|
|
2813
|
+
const s = fo(), i = (s == null ? void 0 : s.selectedComponents) || [], d = i.length > 0;
|
|
2911
2814
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2912
2815
|
`), n.forEach((y, S) => {
|
|
2913
|
-
const x = y.componentId ? "β
" : "βͺ",
|
|
2914
|
-
console.log(` ${x} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${
|
|
2915
|
-
}), console.log(` User: ${t ? o.email : "Not logged in"}`),
|
|
2916
|
-
const
|
|
2917
|
-
let
|
|
2918
|
-
if (
|
|
2919
|
-
|
|
2816
|
+
const x = y.componentId ? "β
" : "βͺ", u = y.componentId ? y.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2817
|
+
console.log(` ${x} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${u}`), console.log("");
|
|
2818
|
+
}), console.log(` User: ${t ? o.email : "Not logged in"}`), d && console.log(` π Using saved selection from ${xe}`), console.log("");
|
|
2819
|
+
const g = v.program.getOptionValue("ci");
|
|
2820
|
+
let h;
|
|
2821
|
+
if (g)
|
|
2822
|
+
d ? (h = i, console.log(` π€ CI mode: using saved selection (${h.length} components)`)) : (h = n.map((y) => y.path), console.log(` π€ CI mode: no saved selection, using all ${h.length} components`));
|
|
2920
2823
|
else {
|
|
2921
2824
|
const { checkbox: y } = await import("@inquirer/prompts"), S = n.map((x) => ({
|
|
2922
2825
|
name: `${x.name} (${x.path})`,
|
|
2923
2826
|
value: x.path,
|
|
2924
|
-
checked:
|
|
2827
|
+
checked: d ? i.includes(x.path) : !0
|
|
2925
2828
|
}));
|
|
2926
2829
|
try {
|
|
2927
|
-
|
|
2830
|
+
h = await y({
|
|
2928
2831
|
message: "Select components to start in dev mode:",
|
|
2929
2832
|
choices: S
|
|
2930
2833
|
});
|
|
@@ -2935,23 +2838,23 @@ Pushing component...
|
|
|
2935
2838
|
`), process.exit(0)), x;
|
|
2936
2839
|
}
|
|
2937
2840
|
}
|
|
2938
|
-
|
|
2841
|
+
h.length === 0 && (console.log(`
|
|
2939
2842
|
β οΈ No components selected.
|
|
2940
|
-
`), process.exit(0)),
|
|
2941
|
-
πΎ Selection saved to ${
|
|
2942
|
-
const
|
|
2943
|
-
console.log(`π Starting dev mode for ${
|
|
2843
|
+
`), process.exit(0)), g || (ho(h), console.log(`
|
|
2844
|
+
πΎ Selection saved to ${xe}`));
|
|
2845
|
+
const l = n.filter((y) => h.includes(y.path));
|
|
2846
|
+
console.log(`π Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
|
|
2944
2847
|
`);
|
|
2945
|
-
const { monorepoDevCommand:
|
|
2946
|
-
await
|
|
2947
|
-
},
|
|
2848
|
+
const { monorepoDevCommand: c } = await Promise.resolve().then(() => Bt);
|
|
2849
|
+
await c(l);
|
|
2850
|
+
}, wo = async () => {
|
|
2948
2851
|
const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
|
|
2949
|
-
let i,
|
|
2852
|
+
let i, d;
|
|
2950
2853
|
try {
|
|
2951
2854
|
i = await o({
|
|
2952
2855
|
message: "Component name:",
|
|
2953
2856
|
default: s
|
|
2954
|
-
}),
|
|
2857
|
+
}), d = await t({
|
|
2955
2858
|
message: "Component type:",
|
|
2956
2859
|
choices: [
|
|
2957
2860
|
{ name: "π HTML", value: "html", description: "Plain HTML/JS/CSS component" },
|
|
@@ -2960,22 +2863,22 @@ Pushing component...
|
|
|
2960
2863
|
{ name: "π
°οΈ Angular", value: "angular", disabled: "(coming soon)" }
|
|
2961
2864
|
]
|
|
2962
2865
|
});
|
|
2963
|
-
} catch (
|
|
2964
|
-
throw
|
|
2866
|
+
} catch (l) {
|
|
2867
|
+
throw l.name === "ExitPromptError" && (console.log(`
|
|
2965
2868
|
|
|
2966
2869
|
π Goodbye!
|
|
2967
|
-
`), process.exit(0)),
|
|
2870
|
+
`), process.exit(0)), l;
|
|
2968
2871
|
}
|
|
2969
|
-
const
|
|
2872
|
+
const g = {
|
|
2970
2873
|
name: i,
|
|
2971
|
-
type:
|
|
2874
|
+
type: d,
|
|
2972
2875
|
author: "@myop-cli",
|
|
2973
2876
|
HMR: !0
|
|
2974
|
-
},
|
|
2877
|
+
}, h = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2975
2878
|
try {
|
|
2976
|
-
e.writeFileSync(
|
|
2977
|
-
β
Created ${
|
|
2978
|
-
const
|
|
2879
|
+
e.writeFileSync(h, JSON.stringify(g, null, 2)), console.log(`
|
|
2880
|
+
β
Created ${h}`);
|
|
2881
|
+
const l = {
|
|
2979
2882
|
name: i.toLowerCase().replace(/\s+/g, "-"),
|
|
2980
2883
|
version: "1.0.0",
|
|
2981
2884
|
type: "module",
|
|
@@ -2987,7 +2890,7 @@ Pushing component...
|
|
|
2987
2890
|
esbuild: "^0.24.0"
|
|
2988
2891
|
}
|
|
2989
2892
|
};
|
|
2990
|
-
e.writeFileSync("package.json", JSON.stringify(
|
|
2893
|
+
e.writeFileSync("package.json", JSON.stringify(l, null, 2)), console.log("β
Created package.json"), e.mkdirSync("src/modules", { recursive: !0 }), e.mkdirSync("src/styles", { recursive: !0 }), e.writeFileSync("build.js", `import * as esbuild from 'esbuild';
|
|
2991
2894
|
import fs from 'fs';
|
|
2992
2895
|
import path from 'path';
|
|
2993
2896
|
|
|
@@ -3119,11 +3022,11 @@ export function setupMyopInterface() {
|
|
|
3119
3022
|
};
|
|
3120
3023
|
}
|
|
3121
3024
|
`), console.log("β
Created src/modules/myop.js");
|
|
3122
|
-
const
|
|
3025
|
+
const p = `/* ${i} - Styles Entry Point */
|
|
3123
3026
|
/* Add your CSS imports here - they will be auto-bundled */
|
|
3124
3027
|
@import './main.css';
|
|
3125
3028
|
`;
|
|
3126
|
-
e.writeFileSync("src/styles/index.css",
|
|
3029
|
+
e.writeFileSync("src/styles/index.css", p), console.log("β
Created src/styles/index.css");
|
|
3127
3030
|
const E = `/* ${i} - Main Styles */
|
|
3128
3031
|
|
|
3129
3032
|
* {
|
|
@@ -3159,11 +3062,11 @@ dist/
|
|
|
3159
3062
|
.temp-styles.css
|
|
3160
3063
|
.DS_Store
|
|
3161
3064
|
`), console.log("β
Created .gitignore");
|
|
3162
|
-
const
|
|
3163
|
-
|
|
3164
|
-
const
|
|
3065
|
+
const $ = await Ge(process.cwd());
|
|
3066
|
+
$.success && console.log("β
Installed AI agent skills");
|
|
3067
|
+
const C = await import("./index-DuEoKctW.js").then((M) => M.i), j = process.cwd();
|
|
3165
3068
|
try {
|
|
3166
|
-
await
|
|
3069
|
+
await C.init({ fs: e, dir: j });
|
|
3167
3070
|
const M = [
|
|
3168
3071
|
"myop.config.json",
|
|
3169
3072
|
"package.json",
|
|
@@ -3176,13 +3079,13 @@ dist/
|
|
|
3176
3079
|
"src/styles/index.css",
|
|
3177
3080
|
"src/styles/main.css"
|
|
3178
3081
|
];
|
|
3179
|
-
if (
|
|
3082
|
+
if ($.success) {
|
|
3180
3083
|
const R = (k, L) => {
|
|
3181
3084
|
try {
|
|
3182
|
-
const
|
|
3183
|
-
for (const
|
|
3184
|
-
const
|
|
3185
|
-
|
|
3085
|
+
const A = e.readdirSync(k, { withFileTypes: !0 });
|
|
3086
|
+
for (const _ of A) {
|
|
3087
|
+
const z = n.join(k, _.name), T = n.join(L, _.name);
|
|
3088
|
+
_.isDirectory() ? R(z, T) : M.push(T);
|
|
3186
3089
|
}
|
|
3187
3090
|
} catch {
|
|
3188
3091
|
}
|
|
@@ -3191,15 +3094,15 @@ dist/
|
|
|
3191
3094
|
const k = e.readdirSync(".", { withFileTypes: !0 });
|
|
3192
3095
|
for (const L of k)
|
|
3193
3096
|
if (L.isDirectory() && L.name.startsWith(".")) {
|
|
3194
|
-
const
|
|
3195
|
-
e.existsSync(
|
|
3097
|
+
const A = n.join(L.name, "skills");
|
|
3098
|
+
e.existsSync(A) && R(A, A);
|
|
3196
3099
|
}
|
|
3197
3100
|
} catch {
|
|
3198
3101
|
}
|
|
3199
3102
|
}
|
|
3200
3103
|
for (const R of M)
|
|
3201
|
-
await
|
|
3202
|
-
await
|
|
3104
|
+
await C.add({ fs: e, dir: j, filepath: R });
|
|
3105
|
+
await C.commit({
|
|
3203
3106
|
fs: e,
|
|
3204
3107
|
dir: j,
|
|
3205
3108
|
message: "init",
|
|
@@ -3210,51 +3113,51 @@ dist/
|
|
|
3210
3113
|
}
|
|
3211
3114
|
console.log(`
|
|
3212
3115
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
3213
|
-
`), v.myopConfig =
|
|
3214
|
-
} catch (
|
|
3215
|
-
console.error(`Failed to initialize component: ${
|
|
3116
|
+
`), v.myopConfig = g, await ne(!0);
|
|
3117
|
+
} catch (l) {
|
|
3118
|
+
console.error(`Failed to initialize component: ${l.message}`), process.exit(1);
|
|
3216
3119
|
}
|
|
3217
3120
|
};
|
|
3218
3121
|
v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
3219
|
-
if (v.program.getOptionValue("help") && (console.log(
|
|
3220
|
-
await
|
|
3122
|
+
if (v.program.getOptionValue("help") && (console.log(Et), process.exit()), v.program.getOptionValue("monorepo")) {
|
|
3123
|
+
await yo();
|
|
3221
3124
|
return;
|
|
3222
3125
|
}
|
|
3223
3126
|
if (v.program.getOptionValue("ci")) {
|
|
3224
|
-
const
|
|
3127
|
+
const g = await import("fs"), h = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), c = $e();
|
|
3225
3128
|
let y = { found: !1 };
|
|
3226
3129
|
try {
|
|
3227
|
-
if (
|
|
3228
|
-
const x =
|
|
3130
|
+
if (g.existsSync(h)) {
|
|
3131
|
+
const x = g.readFileSync(h, "utf-8"), u = JSON.parse(x);
|
|
3229
3132
|
y = {
|
|
3230
3133
|
found: !0,
|
|
3231
|
-
path:
|
|
3232
|
-
name:
|
|
3233
|
-
componentId:
|
|
3234
|
-
organization:
|
|
3134
|
+
path: h,
|
|
3135
|
+
name: u.name || u.componentName || null,
|
|
3136
|
+
componentId: u.componentId || null,
|
|
3137
|
+
organization: u.organization || null
|
|
3235
3138
|
};
|
|
3236
3139
|
}
|
|
3237
3140
|
} catch (x) {
|
|
3238
3141
|
y = { found: !1, error: x.message };
|
|
3239
3142
|
}
|
|
3240
3143
|
const S = {
|
|
3241
|
-
version:
|
|
3144
|
+
version: l,
|
|
3242
3145
|
config: y,
|
|
3243
3146
|
auth: {
|
|
3244
|
-
loggedIn: !!(
|
|
3245
|
-
email: (
|
|
3147
|
+
loggedIn: !!(c != null && c.email),
|
|
3148
|
+
email: (c == null ? void 0 : c.email) || null
|
|
3246
3149
|
}
|
|
3247
3150
|
};
|
|
3248
3151
|
console.log(JSON.stringify(S, null, 2)), process.exit(0);
|
|
3249
3152
|
}
|
|
3250
|
-
let n =
|
|
3153
|
+
let n = V({
|
|
3251
3154
|
text: "Loading Myop CLI...",
|
|
3252
3155
|
color: "green"
|
|
3253
3156
|
}).start();
|
|
3254
|
-
const s =
|
|
3255
|
-
await
|
|
3157
|
+
const s = Me();
|
|
3158
|
+
await co(500), n.stop();
|
|
3256
3159
|
const i = v.program.version();
|
|
3257
|
-
await
|
|
3160
|
+
await so(i) || await ne(s.configFound);
|
|
3258
3161
|
});
|
|
3259
3162
|
v.program.parse(process.argv);
|
|
3260
3163
|
v.program.opts();
|