@myop/cli 0.1.54 → 0.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/myop-cli.js +417 -407
- package/dist/skills/myop-cli/SKILL.md +65 -0
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -3,12 +3,12 @@ var bt = Object.defineProperty;
|
|
|
3
3
|
var Ct = (o, t, e) => t in o ? bt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
4
4
|
var ve = (o, t, e) => Ct(o, typeof t != "symbol" ? t + "" : t, e);
|
|
5
5
|
import z from "ora";
|
|
6
|
-
import { select as st, Separator as
|
|
6
|
+
import { select as st, Separator as Ue } from "@inquirer/prompts";
|
|
7
7
|
import { Command as Pt, Option as fe } from "commander";
|
|
8
8
|
import { execSync as Q, spawn as Mt } from "child_process";
|
|
9
|
-
import R, { join as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import R, { join as Ae } from "path";
|
|
10
|
+
import P, { readFileSync as Et } from "fs";
|
|
11
|
+
import We from "crypto";
|
|
12
12
|
import It from "http";
|
|
13
13
|
import { URL as it, URLSearchParams as rt } from "url";
|
|
14
14
|
import Ot from "open";
|
|
@@ -70,14 +70,14 @@ Examples:
|
|
|
70
70
|
}, Rt = (o) => {
|
|
71
71
|
const t = R.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
|
-
},
|
|
75
|
+
}, Ve = (o, t) => {
|
|
76
76
|
const e = R.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;
|
|
@@ -87,7 +87,7 @@ Examples:
|
|
|
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), Ve(v.options.configPath, v.myopConfig);
|
|
91
91
|
},
|
|
92
92
|
action: async () => {
|
|
93
93
|
}
|
|
@@ -96,18 +96,18 @@ Examples:
|
|
|
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), Ve(v.options.configPath, v.myopConfig);
|
|
100
100
|
},
|
|
101
101
|
action: () => {
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, Nt = {
|
|
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
|
+
}, _t = {
|
|
111
111
|
name: "🟢 Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
@@ -128,7 +128,7 @@ Examples:
|
|
|
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
|
-
}, Dt = [At,
|
|
131
|
+
}, Dt = [At, _t, Tt, Ft, jt];
|
|
132
132
|
function Lt(o, t, e, n) {
|
|
133
133
|
return `<!DOCTYPE html>
|
|
134
134
|
<html lang="en">
|
|
@@ -263,9 +263,9 @@ async function pt(o, t, e, n, s = {}) {
|
|
|
263
263
|
} = s, m = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
|
|
264
264
|
return !i && Ut(m) ? (Bt(), await Jt(n) && p ? (console.log(`🔄 Retrying build...
|
|
265
265
|
`), p(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : !r && Ht(m) ? (console.log("📦 Missing dependencies detected, running npm install..."), new Promise((l) => {
|
|
266
|
-
n("npm install", (d,
|
|
266
|
+
n("npm install", (d, w, x) => {
|
|
267
267
|
if (d) {
|
|
268
|
-
console.error("❌ Failed to install dependencies:", d.message),
|
|
268
|
+
console.error("❌ Failed to install dependencies:", d.message), x && console.error(x), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
console.log("✅ Dependencies installed"), p && p(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
@@ -281,7 +281,7 @@ async function Ce() {
|
|
|
281
281
|
} else
|
|
282
282
|
i = t.default.dirname(import.meta.url);
|
|
283
283
|
const r = t.default.join(i, "commands", "dev", "management-website"), p = o.default.readFileSync(t.default.join(r, "styles.css"), "utf-8"), m = o.default.readFileSync(t.default.join(r, "app.js"), "utf-8"), l = 9292, d = 9293;
|
|
284
|
-
let
|
|
284
|
+
let w = "./dist", x = !1, $ = !1, g = !1, u = null;
|
|
285
285
|
const E = () => {
|
|
286
286
|
try {
|
|
287
287
|
const c = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
|
|
@@ -302,53 +302,53 @@ async function Ce() {
|
|
|
302
302
|
let f;
|
|
303
303
|
a === "darwin" ? f = `open "${c}"` : a === "win32" ? f = `start "" "${c}"` : f = `xdg-open "${c}"`, e(f, (h) => {
|
|
304
304
|
});
|
|
305
|
-
},
|
|
306
|
-
let
|
|
305
|
+
}, M = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
|
|
306
|
+
let C, N, k = !1;
|
|
307
307
|
u = E();
|
|
308
308
|
const L = O();
|
|
309
309
|
try {
|
|
310
310
|
const c = o.default.readFileSync(j, "utf-8"), a = JSON.parse(c);
|
|
311
|
-
|
|
311
|
+
C = a.componentId || "DEV", N = a.componentName || a.name || null, k = a.HMR === !0, u && !L && (g = !0, k = !0, console.log(`📄 Single HTML file mode: ${u}`)), k && console.log("🔥 HMR enabled");
|
|
312
312
|
} catch (c) {
|
|
313
|
-
u && !L ? (g = !0,
|
|
313
|
+
u && !L ? (g = !0, C = "DEV", N = t.default.basename(u, ".html"), k = !0, console.log(`📄 Single HTML file mode: ${u}`), console.log("🔥 HMR enabled")) : (console.error("❌ Error reading myop.config.json:", c.message), process.exit(1));
|
|
314
314
|
}
|
|
315
315
|
const D = async () => {
|
|
316
|
-
if (
|
|
317
|
-
return
|
|
316
|
+
if (C !== "DEV" && C !== "NEW")
|
|
317
|
+
return C;
|
|
318
318
|
try {
|
|
319
|
-
const a = ((await new Promise((
|
|
319
|
+
const a = ((await new Promise((y, S) => {
|
|
320
320
|
const I = {
|
|
321
321
|
hostname: "localhost",
|
|
322
322
|
port: d,
|
|
323
323
|
path: "/_list",
|
|
324
324
|
method: "GET",
|
|
325
325
|
timeout: 1e3
|
|
326
|
-
},
|
|
326
|
+
}, T = n.default.request(I, (H) => {
|
|
327
327
|
let Y = "";
|
|
328
328
|
H.on("data", (ee) => Y += ee), H.on("end", () => {
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
y(JSON.parse(Y));
|
|
331
331
|
} catch {
|
|
332
|
-
|
|
332
|
+
y({ components: [] });
|
|
333
333
|
}
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}),
|
|
339
|
-
})).components || []).map(([
|
|
336
|
+
T.on("error", () => y({ components: [] })), T.on("timeout", () => {
|
|
337
|
+
T.destroy(), y({ components: [] });
|
|
338
|
+
}), T.end();
|
|
339
|
+
})).components || []).map(([y]) => y).filter((y) => y === "DEV" || y === "NEW" || /^DEV\d+$/.test(y) || /^NEW\d+$/.test(y));
|
|
340
340
|
if (a.length === 0)
|
|
341
341
|
return "DEV1";
|
|
342
|
-
const f = a.map((
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
return
|
|
346
|
-
}).filter((
|
|
342
|
+
const f = a.map((y) => {
|
|
343
|
+
if (y === "DEV" || y === "NEW") return 1;
|
|
344
|
+
const S = y.match(/^DEV(\d+)$/), I = y.match(/^NEW(\d+)$/);
|
|
345
|
+
return S ? parseInt(S[1], 10) : I ? parseInt(I[1], 10) : 0;
|
|
346
|
+
}).filter((y) => y > 0);
|
|
347
347
|
return `DEV${Math.max(...f, 0) + 1}`;
|
|
348
348
|
} catch {
|
|
349
349
|
return "DEV1";
|
|
350
350
|
}
|
|
351
|
-
},
|
|
351
|
+
}, F = process.cwd(), W = (c) => {
|
|
352
352
|
const a = t.default.extname(c).toLowerCase();
|
|
353
353
|
return {
|
|
354
354
|
".html": "text/html",
|
|
@@ -361,14 +361,14 @@ async function Ce() {
|
|
|
361
361
|
".svg": "image/svg+xml",
|
|
362
362
|
".ico": "image/x-icon"
|
|
363
363
|
}[a] || "application/octet-stream";
|
|
364
|
-
},
|
|
364
|
+
}, _ = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
|
|
365
365
|
if (c.url.startsWith("/_hmr/")) {
|
|
366
|
-
const h = c.url.split("/_hmr/")[1],
|
|
366
|
+
const h = c.url.split("/_hmr/")[1], y = c.headers["sec-websocket-key"], S = s("sha1").update(y + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
367
367
|
a.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: ${S}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
374
|
), X.has(h) || X.set(h, /* @__PURE__ */ new Set()), X.get(h).add(a), console.log(`🔌 HMR client connected: ${h}`), a.on("close", () => {
|
|
@@ -384,11 +384,11 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
384
384
|
let f = "";
|
|
385
385
|
c.on("data", (h) => f += h), c.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId: h, distPath:
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
console.log(`✅ Registered: ${h}${
|
|
391
|
-
const H = Array.from(
|
|
387
|
+
const { componentId: h, distPath: y, componentName: S, htmlFile: I } = JSON.parse(f);
|
|
388
|
+
_.set(h, { path: y, name: S || null, htmlFile: I || null });
|
|
389
|
+
const T = S ? ` (${S})` : "";
|
|
390
|
+
console.log(`✅ Registered: ${h}${T} -> ${y}${I ? "/" + I : ""}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(_.keys()) }));
|
|
391
|
+
const H = Array.from(_.entries()).map(([Y, ee]) => ({
|
|
392
392
|
id: Y,
|
|
393
393
|
path: ee.path,
|
|
394
394
|
name: ee.name
|
|
@@ -413,17 +413,17 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
413
413
|
c.on("data", (h) => f += h), c.on("end", () => {
|
|
414
414
|
try {
|
|
415
415
|
const { componentId: h } = JSON.parse(f);
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
id:
|
|
416
|
+
_.delete(h), console.log(`❌ Unregistered: ${h}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
|
|
417
|
+
const y = Array.from(_.entries()).map(([S, I]) => ({
|
|
418
|
+
id: S,
|
|
419
419
|
path: I.path,
|
|
420
420
|
name: I.name
|
|
421
421
|
}));
|
|
422
|
-
q.forEach((
|
|
422
|
+
q.forEach((S) => {
|
|
423
423
|
try {
|
|
424
|
-
|
|
424
|
+
S.write(`data: ${JSON.stringify({
|
|
425
425
|
type: "components",
|
|
426
|
-
components:
|
|
426
|
+
components: y
|
|
427
427
|
})}
|
|
428
428
|
|
|
429
429
|
`);
|
|
@@ -435,22 +435,22 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
} else if (c.method === "GET" && c.url === "/_list")
|
|
438
|
-
a.writeHead(200), a.end(JSON.stringify({ components: Array.from(
|
|
438
|
+
a.writeHead(200), a.end(JSON.stringify({ components: Array.from(_.entries()) }));
|
|
439
439
|
else if (c.method === "POST" && c.url === "/_hmr_notify") {
|
|
440
440
|
let f = "";
|
|
441
441
|
c.on("data", (h) => f += h), c.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId: h, html:
|
|
444
|
-
if (
|
|
445
|
-
console.log(`🔥 Notifying ${
|
|
446
|
-
const I = JSON.stringify({ type: "update", html:
|
|
447
|
-
|
|
443
|
+
const { componentId: h, html: y } = JSON.parse(f), S = X.get(h);
|
|
444
|
+
if (S && S.size > 0) {
|
|
445
|
+
console.log(`🔥 Notifying ${S.size} HMR client(s) for: ${h}`);
|
|
446
|
+
const I = JSON.stringify({ type: "update", html: y }), T = qe(I);
|
|
447
|
+
S.forEach((H) => {
|
|
448
448
|
try {
|
|
449
|
-
H.write(
|
|
449
|
+
H.write(T);
|
|
450
450
|
} catch {
|
|
451
|
-
|
|
451
|
+
S.delete(H);
|
|
452
452
|
}
|
|
453
|
-
}), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified:
|
|
453
|
+
}), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: S.size }));
|
|
454
454
|
} else
|
|
455
455
|
a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: 0 }));
|
|
456
456
|
} catch (h) {
|
|
@@ -464,14 +464,14 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
464
464
|
a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname,
|
|
467
|
+
const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, y = h.split("/").filter((J) => J);
|
|
468
468
|
if (h.startsWith("/consume")) {
|
|
469
469
|
const J = f.searchParams.get("id");
|
|
470
470
|
if (!J) {
|
|
471
471
|
a.writeHead(400, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
const V =
|
|
474
|
+
const V = _.get(J), G = V ? V.path : null, de = (te) => {
|
|
475
475
|
let U = "Unknown", K = "Unknown";
|
|
476
476
|
if (c.headers.referer || c.headers.referrer) {
|
|
477
477
|
const B = c.headers.referer || c.headers.referrer;
|
|
@@ -492,12 +492,12 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
492
492
|
const B = c.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 Fe = c.headers.referer || c.headers.referrer || U, we = {
|
|
496
496
|
type: "request",
|
|
497
497
|
componentId: J,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
499
|
servedLocally: te,
|
|
500
|
-
referrer:
|
|
500
|
+
referrer: Fe,
|
|
501
501
|
origin: U,
|
|
502
502
|
originLabel: K
|
|
503
503
|
};
|
|
@@ -517,8 +517,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
const
|
|
521
|
-
|
|
520
|
+
const je = se.get(U);
|
|
521
|
+
je.requestCount++, q.forEach((B) => {
|
|
522
522
|
try {
|
|
523
523
|
B.write(`data: ${JSON.stringify({
|
|
524
524
|
type: "origins",
|
|
@@ -544,7 +544,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
544
544
|
console.log(`❌ File not found: ${te}`), a.writeHead(404, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "index.html not found" }));
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
const
|
|
547
|
+
const Fe = Re(K, J), we = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, je = {
|
|
548
548
|
item: {
|
|
549
549
|
name: J,
|
|
550
550
|
id: J,
|
|
@@ -555,7 +555,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
557
557
|
shadowRootMode: "localFrame",
|
|
558
|
-
HTML:
|
|
558
|
+
HTML: Fe
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
]
|
|
@@ -564,7 +564,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
564
564
|
console.log(`✅ Serving consume JSON for: ${J}`), de(!0), a.writeHead(200, {
|
|
565
565
|
"Content-Type": "application/json",
|
|
566
566
|
"Access-Control-Allow-Origin": "*"
|
|
567
|
-
}), a.end(JSON.stringify(
|
|
567
|
+
}), a.end(JSON.stringify(je, null, 2));
|
|
568
568
|
});
|
|
569
569
|
} else {
|
|
570
570
|
console.log(`📡 Proxying consume request to cloud.myop.dev for: ${J}`);
|
|
@@ -587,7 +587,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
587
587
|
Connection: "keep-alive",
|
|
588
588
|
"Access-Control-Allow-Origin": "*"
|
|
589
589
|
}), q.push(a);
|
|
590
|
-
const J = Array.from(
|
|
590
|
+
const J = Array.from(_.entries()).map(([V, G]) => ({
|
|
591
591
|
id: V,
|
|
592
592
|
path: G.path,
|
|
593
593
|
name: G.name
|
|
@@ -613,24 +613,24 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
613
613
|
});
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
|
-
if (
|
|
616
|
+
if (y.length === 0) {
|
|
617
617
|
a.writeHead(200, { "Content-Type": "text/html" }), a.end(Lt(l, d, p, m));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
|
-
if (
|
|
620
|
+
if (y[0] !== "view") {
|
|
621
621
|
a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not found. Use /view/<componentId>/ to access components.");
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
|
-
if (
|
|
624
|
+
if (y.length < 2) {
|
|
625
625
|
a.writeHead(400, { "Content-Type": "text/plain" }), a.end("Component ID required. Use /view/<componentId>/");
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
const
|
|
628
|
+
const S = y[1], I = _.get(S);
|
|
629
629
|
if (!I) {
|
|
630
|
-
a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${
|
|
630
|
+
a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${S}`);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const
|
|
633
|
+
const T = I.path, H = y.slice(2), Y = I.htmlFile || "index.html", ee = H.length === 0 ? Y : H.join("/"), ce = t.default.join(T, ee);
|
|
634
634
|
console.log(`📥 Request: ${c.url} -> ${ce}`), o.default.readFile(ce, (J, V) => {
|
|
635
635
|
if (J) {
|
|
636
636
|
console.log(`❌ File not found: ${ce}`), a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not Found");
|
|
@@ -641,20 +641,20 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
641
641
|
let de = V;
|
|
642
642
|
if (G === "text/html" && k) {
|
|
643
643
|
const te = V.toString("utf-8");
|
|
644
|
-
de =
|
|
644
|
+
de = Re(te, S);
|
|
645
645
|
}
|
|
646
646
|
a.writeHead(200, {
|
|
647
647
|
"Content-Type": G,
|
|
648
648
|
"Access-Control-Allow-Origin": "*"
|
|
649
649
|
}), a.end(de);
|
|
650
650
|
});
|
|
651
|
-
}),
|
|
652
|
-
const f = g ? t.default.resolve(
|
|
653
|
-
componentId:
|
|
651
|
+
}), ke = () => new Promise((c, a) => {
|
|
652
|
+
const f = g ? t.default.resolve(F) : t.default.resolve(F, w), h = JSON.stringify({
|
|
653
|
+
componentId: C,
|
|
654
654
|
distPath: f,
|
|
655
|
-
componentName:
|
|
655
|
+
componentName: N,
|
|
656
656
|
htmlFile: g ? u : null
|
|
657
|
-
}),
|
|
657
|
+
}), y = {
|
|
658
658
|
hostname: "localhost",
|
|
659
659
|
port: d,
|
|
660
660
|
path: "/_register",
|
|
@@ -663,15 +663,15 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
664
|
"Content-Length": Buffer.byteLength(h)
|
|
665
665
|
}
|
|
666
|
-
},
|
|
667
|
-
let
|
|
668
|
-
I.on("data", (H) =>
|
|
669
|
-
I.statusCode === 200 ? c(JSON.parse(
|
|
666
|
+
}, S = n.default.request(y, (I) => {
|
|
667
|
+
let T = "";
|
|
668
|
+
I.on("data", (H) => T += H), I.on("end", () => {
|
|
669
|
+
I.statusCode === 200 ? c(JSON.parse(T)) : a(new Error(`Registration failed: ${I.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
|
-
|
|
672
|
+
S.on("error", a), S.write(h), S.end();
|
|
673
673
|
}), vt = () => new Promise((c, a) => {
|
|
674
|
-
const f = JSON.stringify({ componentId:
|
|
674
|
+
const f = JSON.stringify({ componentId: C }), h = {
|
|
675
675
|
hostname: "localhost",
|
|
676
676
|
port: d,
|
|
677
677
|
path: "/_unregister",
|
|
@@ -680,10 +680,10 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
681
|
"Content-Length": Buffer.byteLength(f)
|
|
682
682
|
}
|
|
683
|
-
},
|
|
683
|
+
}, y = n.default.request(h, (S) => {
|
|
684
684
|
c();
|
|
685
685
|
});
|
|
686
|
-
|
|
686
|
+
y.on("error", () => c()), y.write(f), y.end();
|
|
687
687
|
}), St = (c) => `
|
|
688
688
|
<!-- MYOP HMR -->
|
|
689
689
|
<script>
|
|
@@ -789,7 +789,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
789
789
|
connect();
|
|
790
790
|
})();
|
|
791
791
|
<\/script>
|
|
792
|
-
`,
|
|
792
|
+
`, Re = (c, a) => {
|
|
793
793
|
if (!k) return c;
|
|
794
794
|
const f = St(a);
|
|
795
795
|
return c.includes("</body>") ? c.replace("</body>", `${f}</body>`) : c.includes("</html>") ? c.replace("</html>", `${f}</html>`) : c + f;
|
|
@@ -815,34 +815,34 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
815
815
|
]), h;
|
|
816
816
|
}, Xe = () => {
|
|
817
817
|
if (!k) return;
|
|
818
|
-
const c = g ? u : t.default.join(
|
|
818
|
+
const c = g ? u : t.default.join(w, "index.html");
|
|
819
819
|
let a;
|
|
820
820
|
try {
|
|
821
821
|
const f = o.default.readFileSync(c, "utf-8");
|
|
822
|
-
a =
|
|
822
|
+
a = Re(f, C);
|
|
823
823
|
} catch (f) {
|
|
824
824
|
console.error("❌ Failed to read HTML for HMR:", f.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (
|
|
828
|
-
const f = X.get(
|
|
827
|
+
if (Te) {
|
|
828
|
+
const f = X.get(C);
|
|
829
829
|
if (!f || f.size === 0)
|
|
830
830
|
return;
|
|
831
831
|
console.log(`🔥 Notifying ${f.size} HMR client(s)`);
|
|
832
832
|
const h = JSON.stringify({
|
|
833
833
|
type: "update",
|
|
834
834
|
html: a
|
|
835
|
-
}),
|
|
836
|
-
f.forEach((
|
|
835
|
+
}), y = qe(h);
|
|
836
|
+
f.forEach((S) => {
|
|
837
837
|
try {
|
|
838
|
-
|
|
838
|
+
S.write(y);
|
|
839
839
|
} catch {
|
|
840
|
-
f.delete(
|
|
840
|
+
f.delete(S);
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
} else {
|
|
844
844
|
const f = JSON.stringify({
|
|
845
|
-
componentId:
|
|
845
|
+
componentId: C,
|
|
846
846
|
html: a
|
|
847
847
|
}), h = {
|
|
848
848
|
hostname: "localhost",
|
|
@@ -854,64 +854,64 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
854
854
|
"Content-Length": Buffer.byteLength(f)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
},
|
|
857
|
+
}, y = n.default.request(h, (S) => {
|
|
858
858
|
let I = "";
|
|
859
|
-
|
|
859
|
+
S.on("data", (T) => I += T), S.on("end", () => {
|
|
860
860
|
try {
|
|
861
|
-
const
|
|
862
|
-
|
|
861
|
+
const T = JSON.parse(I);
|
|
862
|
+
T.notified > 0 && console.log(`🔥 Notified ${T.notified} HMR client(s) via server`);
|
|
863
863
|
} catch {
|
|
864
864
|
}
|
|
865
865
|
});
|
|
866
866
|
});
|
|
867
|
-
|
|
868
|
-
}),
|
|
869
|
-
|
|
870
|
-
}),
|
|
867
|
+
y.on("error", () => {
|
|
868
|
+
}), y.on("timeout", () => {
|
|
869
|
+
y.destroy();
|
|
870
|
+
}), y.write(f), y.end();
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
|
-
let
|
|
873
|
+
let Ne = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
874
|
const he = (c) => {
|
|
875
|
-
if (
|
|
876
|
-
|
|
875
|
+
if (x) {
|
|
876
|
+
$ = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
|
-
|
|
879
|
+
x = !0, console.log(`
|
|
880
880
|
🔨 Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (a, f, h) => {
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
883
|
-
...
|
|
881
|
+
if (x = !1, a) {
|
|
882
|
+
const y = await pt(a, f, h, e, {
|
|
883
|
+
...Ne,
|
|
884
884
|
onRetry: () => he(c)
|
|
885
885
|
});
|
|
886
|
-
|
|
886
|
+
Ne = { ...Ne, ...y }, y.handled || (console.error("❌ Build failed:", a.message), h && console.error(h));
|
|
887
887
|
} else
|
|
888
888
|
console.log("✅ Build completed"), f && console.log(f), Xe(), c && c();
|
|
889
|
-
|
|
889
|
+
$ && ($ = !1, he());
|
|
890
890
|
});
|
|
891
891
|
}, et = /* @__PURE__ */ new Set(), _e = (c) => {
|
|
892
892
|
o.default.readdir(c, { withFileTypes: !0 }, (a, f) => {
|
|
893
893
|
a || (f.forEach((h) => {
|
|
894
|
-
const
|
|
894
|
+
const y = t.default.join(c, h.name);
|
|
895
895
|
if (h.isDirectory())
|
|
896
|
-
h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(
|
|
896
|
+
h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(y);
|
|
897
897
|
else if (h.isFile()) {
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
898
|
+
const S = t.default.extname(h.name);
|
|
899
|
+
if (S === ".js" || S === ".css" || S === ".html")
|
|
900
900
|
try {
|
|
901
|
-
const I = o.default.readFileSync(
|
|
902
|
-
|
|
901
|
+
const I = o.default.readFileSync(y, "utf-8");
|
|
902
|
+
M.set(y, I);
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
}), et.has(c) || (et.add(c), o.default.watch(c, (h,
|
|
907
|
-
if (!
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
const I = t.default.join(c,
|
|
906
|
+
}), et.has(c) || (et.add(c), o.default.watch(c, (h, y) => {
|
|
907
|
+
if (!y) return;
|
|
908
|
+
const S = t.default.extname(y);
|
|
909
|
+
if (S !== ".js" && S !== ".css" && S !== ".html") return;
|
|
910
|
+
const I = t.default.join(c, y);
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
913
|
-
const
|
|
914
|
-
|
|
913
|
+
const T = o.default.readFileSync(I, "utf-8"), H = M.get(I);
|
|
914
|
+
T !== H && (M.set(I, T), console.log(`📝 File changed: ${I}`), g ? Xe() : he());
|
|
915
915
|
} catch {
|
|
916
916
|
}
|
|
917
917
|
}, 50);
|
|
@@ -919,8 +919,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
919
919
|
});
|
|
920
920
|
}, tt = (c) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
🔨 Component: ${
|
|
923
|
-
`), c && c()) : (he(c), _e(
|
|
922
|
+
🔨 Component: ${C}`), g ? (console.log("📄 No build needed (single HTML file mode)"), _e(F), console.log(`👀 Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
|
+
`), c && c()) : (he(c), _e(F), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
925
|
}, xt = () => new Promise((c) => {
|
|
926
926
|
const a = {
|
|
@@ -930,7 +930,17 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
930
930
|
method: "GET",
|
|
931
931
|
timeout: 1e3
|
|
932
932
|
}, f = n.default.request(a, (h) => {
|
|
933
|
-
|
|
933
|
+
let y = "";
|
|
934
|
+
h.on("data", (S) => y += S), h.on("end", () => {
|
|
935
|
+
try {
|
|
936
|
+
(JSON.parse(y).components || []).map((T) => T[0]).includes(C) || ke().then(() => {
|
|
937
|
+
console.log(`🔄 Re-registered component: ${C}`);
|
|
938
|
+
}).catch(() => {
|
|
939
|
+
});
|
|
940
|
+
} catch {
|
|
941
|
+
}
|
|
942
|
+
c(!0);
|
|
943
|
+
});
|
|
934
944
|
});
|
|
935
945
|
f.on("error", () => c(!1)), f.on("timeout", () => {
|
|
936
946
|
f.destroy(), c(!1);
|
|
@@ -938,28 +948,28 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
938
948
|
}), $t = () => new Promise((c) => {
|
|
939
949
|
const a = n.default.createServer((f, h) => {
|
|
940
950
|
if (h.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
|
|
941
|
-
let
|
|
942
|
-
f.on("data", (
|
|
951
|
+
let y = "";
|
|
952
|
+
f.on("data", (S) => y += S), f.on("end", () => {
|
|
943
953
|
try {
|
|
944
|
-
const { componentId:
|
|
945
|
-
|
|
946
|
-
const Y =
|
|
947
|
-
console.log(`✅ Registered: ${
|
|
948
|
-
} catch (
|
|
949
|
-
h.writeHead(400), h.end(JSON.stringify({ error:
|
|
954
|
+
const { componentId: S, distPath: I, componentName: T, htmlFile: H } = JSON.parse(y);
|
|
955
|
+
_.set(S, { path: I, name: T || null, htmlFile: H || null });
|
|
956
|
+
const Y = T ? ` (${T})` : "";
|
|
957
|
+
console.log(`✅ Registered: ${S}${Y} -> ${I}${H ? "/" + H : ""}`), h.writeHead(200), h.end(JSON.stringify({ success: !0, registered: Array.from(_.keys()) }));
|
|
958
|
+
} catch (S) {
|
|
959
|
+
h.writeHead(400), h.end(JSON.stringify({ error: S.message }));
|
|
950
960
|
}
|
|
951
961
|
});
|
|
952
962
|
} else if (f.method === "POST" && f.url === "/_unregister") {
|
|
953
|
-
let
|
|
954
|
-
f.on("data", (
|
|
963
|
+
let y = "";
|
|
964
|
+
f.on("data", (S) => y += S), f.on("end", () => {
|
|
955
965
|
try {
|
|
956
|
-
const { componentId:
|
|
957
|
-
|
|
958
|
-
} catch (
|
|
959
|
-
h.writeHead(400), h.end(JSON.stringify({ error:
|
|
966
|
+
const { componentId: S } = JSON.parse(y);
|
|
967
|
+
_.delete(S), console.log(`❌ Unregistered: ${S}`), h.writeHead(200), h.end(JSON.stringify({ success: !0 }));
|
|
968
|
+
} catch (S) {
|
|
969
|
+
h.writeHead(400), h.end(JSON.stringify({ error: S.message }));
|
|
960
970
|
}
|
|
961
971
|
});
|
|
962
|
-
} else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(
|
|
972
|
+
} else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(_.entries()) }))) : (h.writeHead(404), h.end(JSON.stringify({ error: "Not found" })));
|
|
963
973
|
});
|
|
964
974
|
a.on("error", () => {
|
|
965
975
|
c(!1);
|
|
@@ -969,14 +979,14 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
969
979
|
a.close(), c(!1);
|
|
970
980
|
}), ge.listen(l, () => {
|
|
971
981
|
console.log(`📡 Main server running at http://localhost:${l}`);
|
|
972
|
-
const f = g ? t.default.resolve(
|
|
973
|
-
|
|
982
|
+
const f = g ? t.default.resolve(F) : t.default.resolve(F, w);
|
|
983
|
+
_.set(C, {
|
|
974
984
|
path: f,
|
|
975
|
-
name:
|
|
985
|
+
name: N,
|
|
976
986
|
htmlFile: g ? u : null
|
|
977
987
|
});
|
|
978
|
-
const h =
|
|
979
|
-
console.log(`✅ Registered component: ${
|
|
988
|
+
const h = N ? ` (${N})` : "";
|
|
989
|
+
console.log(`✅ Registered component: ${C}${h}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), c(!0);
|
|
980
990
|
});
|
|
981
991
|
});
|
|
982
992
|
});
|
|
@@ -984,9 +994,9 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
984
994
|
const ot = () => {
|
|
985
995
|
ye = setInterval(async () => {
|
|
986
996
|
await xt() || (clearInterval(ye), console.log(`
|
|
987
|
-
⚠️ Server appears to be down, attempting to take over...`), await $t() ? (console.log("✅ Successfully took over as server"),
|
|
997
|
+
⚠️ Server appears to be down, attempting to take over...`), await $t() ? (console.log("✅ Successfully took over as server"), Te = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
998
|
try {
|
|
989
|
-
await
|
|
999
|
+
await ke(), console.log(`✅ Re-registered component: ${C}`), ot();
|
|
990
1000
|
} catch (f) {
|
|
991
1001
|
console.error("❌ Failed to re-register:", f.message);
|
|
992
1002
|
}
|
|
@@ -998,16 +1008,16 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
998
1008
|
🛑 Shutting down...`), ye && clearInterval(ye), await vt(), process.exit(0);
|
|
999
1009
|
};
|
|
1000
1010
|
process.on("SIGINT", nt), process.on("SIGTERM", nt);
|
|
1001
|
-
let
|
|
1011
|
+
let Te = !1;
|
|
1002
1012
|
Oe.on("error", async (c) => {
|
|
1003
1013
|
if (c.code === "EADDRINUSE") {
|
|
1004
1014
|
console.log(`
|
|
1005
1015
|
🔗 Connecting to existing dev server...`);
|
|
1006
1016
|
try {
|
|
1007
|
-
|
|
1008
|
-
const a = await
|
|
1009
|
-
console.log(`✅ Registered component: ${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${
|
|
1017
|
+
C = await D();
|
|
1018
|
+
const a = await ke();
|
|
1019
|
+
console.log(`✅ Registered component: ${C}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), console.log(`📋 All registered components: ${a.registered.join(", ")}`), tt(() => {
|
|
1020
|
+
process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${C}/`);
|
|
1011
1021
|
}), ot();
|
|
1012
1022
|
} catch (a) {
|
|
1013
1023
|
console.error("❌ Failed to register component:", a.message), process.exit(1);
|
|
@@ -1015,20 +1025,20 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
1015
1025
|
} else
|
|
1016
1026
|
console.error("❌ Management server error:", c.message), process.exit(1);
|
|
1017
1027
|
}), Oe.on("upgrade", wt), Oe.listen(d, async () => {
|
|
1018
|
-
|
|
1028
|
+
Te = !0, console.log(`
|
|
1019
1029
|
🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", (c) => {
|
|
1020
1030
|
console.error("❌ Main server error:", c.message), process.exit(1);
|
|
1021
1031
|
}), ge.listen(l, async () => {
|
|
1022
|
-
console.log(`📡 Main server running at http://localhost:${l}`), (
|
|
1023
|
-
const c = g ? t.default.resolve(
|
|
1024
|
-
|
|
1032
|
+
console.log(`📡 Main server running at http://localhost:${l}`), (C === "DEV" || C === "NEW") && (C = "DEV1");
|
|
1033
|
+
const c = g ? t.default.resolve(F) : t.default.resolve(F, w);
|
|
1034
|
+
_.set(C, {
|
|
1025
1035
|
path: c,
|
|
1026
|
-
name:
|
|
1036
|
+
name: N,
|
|
1027
1037
|
htmlFile: g ? u : null
|
|
1028
1038
|
});
|
|
1029
|
-
const a =
|
|
1030
|
-
console.log(`✅ Registered component: ${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${
|
|
1039
|
+
const a = N ? ` (${N})` : "";
|
|
1040
|
+
console.log(`✅ Registered component: ${C}${a}`), console.log(`📡 Access at: http://localhost:${l}/view/${C}/`), tt(() => {
|
|
1041
|
+
process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${C}/`);
|
|
1032
1042
|
});
|
|
1033
1043
|
});
|
|
1034
1044
|
});
|
|
@@ -1086,10 +1096,10 @@ const A = class A {
|
|
|
1086
1096
|
const s = Math.ceil(t / n), i = Math.floor(this.cols / n), r = 2, m = this.rows - r - 2, l = Math.floor(m / s);
|
|
1087
1097
|
this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
|
|
1088
1098
|
for (let d = 0; d < t; d++) {
|
|
1089
|
-
const
|
|
1090
|
-
this.panelPositions.set(
|
|
1091
|
-
row: r + 1 +
|
|
1092
|
-
col:
|
|
1099
|
+
const w = this.components[d], x = Math.floor(d / n), $ = d % n;
|
|
1100
|
+
this.panelPositions.set(w.name, {
|
|
1101
|
+
row: r + 1 + x * l,
|
|
1102
|
+
col: $ * i + 1,
|
|
1093
1103
|
width: i,
|
|
1094
1104
|
height: l
|
|
1095
1105
|
});
|
|
@@ -1139,33 +1149,33 @@ const A = class A {
|
|
|
1139
1149
|
renderPanel(t) {
|
|
1140
1150
|
const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
|
|
1141
1151
|
if (!s) return;
|
|
1142
|
-
const i = this.components.findIndex((D) => D.name === t), r = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", l = n[m], d = e[l.color],
|
|
1152
|
+
const i = this.components.findIndex((D) => D.name === t), r = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", l = n[m], d = e[l.color], w = this.logs.get(t) || [], x = this.scrollPos.get(t) || 0, $ = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, $ - 20);
|
|
1143
1153
|
let O = `${g}┌─${e.reset} ${d}${l.icon}${e.reset} `;
|
|
1144
1154
|
O += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${d}${l.label}${e.reset} `;
|
|
1145
1155
|
const b = 5 + E.length + l.label.length + 3;
|
|
1146
|
-
O += `${g}${"─".repeat(Math.max(0,
|
|
1147
|
-
const
|
|
1148
|
-
let j = `${g}│${e.reset} ${e.dim}${
|
|
1149
|
-
j += " ".repeat(Math.max(0,
|
|
1150
|
-
const
|
|
1151
|
-
let k = `${g}├${"─".repeat(
|
|
1152
|
-
|
|
1153
|
-
const L =
|
|
1156
|
+
O += `${g}${"─".repeat(Math.max(0, $ - b))}┐${e.reset}`, u.push(A.ESC.moveTo(s.row, s.col) + O);
|
|
1157
|
+
const M = (r.path || "").substring(0, $ - 6);
|
|
1158
|
+
let j = `${g}│${e.reset} ${e.dim}${M}${e.reset}`;
|
|
1159
|
+
j += " ".repeat(Math.max(0, $ - M.length - 3)), j += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 1, s.col) + j);
|
|
1160
|
+
const C = w.length, N = C > this.visibleLogLines ? `${x + 1}-${Math.min(x + this.visibleLogLines, C)}/${C}` : "";
|
|
1161
|
+
let k = `${g}├${"─".repeat($ - N.length - 4)}${e.reset}`;
|
|
1162
|
+
N && (k += `${e.dim}${N}${e.reset}`), k += `${g}${"─".repeat(2)}┤${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
|
|
1163
|
+
const L = w.slice(x, x + this.visibleLogLines);
|
|
1154
1164
|
for (let D = 0; D < this.visibleLogLines; D++) {
|
|
1155
|
-
const
|
|
1165
|
+
const F = L[D];
|
|
1156
1166
|
let W = `${g}│${e.reset}`;
|
|
1157
|
-
if (
|
|
1158
|
-
let
|
|
1159
|
-
|
|
1160
|
-
const oe =
|
|
1161
|
-
W += `${e.dim}${
|
|
1162
|
-
const Ie =
|
|
1167
|
+
if (F) {
|
|
1168
|
+
let _ = e.white;
|
|
1169
|
+
F.type === "success" ? _ = e.green : F.type === "error" ? _ = e.red : F.type === "warning" ? _ = e.yellow : F.type === "hmr" ? _ = e.magenta : F.type === "change" && (_ = e.blue);
|
|
1170
|
+
const oe = F.message.substring(0, $ - 12);
|
|
1171
|
+
W += `${e.dim}${F.timestamp}${e.reset} ${_}${oe}${e.reset}`;
|
|
1172
|
+
const Ie = $ - F.timestamp.length - oe.length - 2;
|
|
1163
1173
|
W += " ".repeat(Math.max(0, Ie));
|
|
1164
1174
|
} else
|
|
1165
|
-
W += " ".repeat(
|
|
1175
|
+
W += " ".repeat($ - 2);
|
|
1166
1176
|
W += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 3 + D, s.col) + W);
|
|
1167
1177
|
}
|
|
1168
|
-
u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}└${"─".repeat(
|
|
1178
|
+
u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}└${"─".repeat($ - 2)}┘${e.reset}`), process.stdout.write(u.join(""));
|
|
1169
1179
|
}
|
|
1170
1180
|
fullRender() {
|
|
1171
1181
|
const t = A.C;
|
|
@@ -1224,16 +1234,16 @@ ve(A, "STATUS", {
|
|
|
1224
1234
|
warning: { icon: "⚠", color: "yellow", label: "Warning" },
|
|
1225
1235
|
stopped: { icon: "■", color: "gray", label: "Stopped" }
|
|
1226
1236
|
});
|
|
1227
|
-
let
|
|
1237
|
+
let He = A;
|
|
1228
1238
|
async function zt(o) {
|
|
1229
1239
|
const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((d) => ({
|
|
1230
1240
|
name: d.name,
|
|
1231
1241
|
path: d.path,
|
|
1232
1242
|
id: d.componentId || ""
|
|
1233
|
-
})), i = new
|
|
1234
|
-
const
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1243
|
+
})), i = new He(s), r = [], p = (d) => {
|
|
1244
|
+
const w = process.platform;
|
|
1245
|
+
let x;
|
|
1246
|
+
w === "darwin" ? x = `open "${d}"` : w === "win32" ? x = `start "" "${d}"` : x = `xdg-open "${d}"`, e(x, () => {
|
|
1237
1247
|
});
|
|
1238
1248
|
}, m = () => {
|
|
1239
1249
|
i.clear(), console.log(`
|
|
@@ -1247,33 +1257,33 @@ async function zt(o) {
|
|
|
1247
1257
|
process.on("SIGINT", m), process.on("SIGTERM", m);
|
|
1248
1258
|
const l = process.argv[1];
|
|
1249
1259
|
for (let d = 0; d < o.length; d++) {
|
|
1250
|
-
const
|
|
1251
|
-
i.setStatus(
|
|
1252
|
-
const
|
|
1253
|
-
cwd: n.default.resolve(
|
|
1260
|
+
const w = o[d], x = w.name;
|
|
1261
|
+
i.setStatus(x, "⏳ Starting..."), i.log(x, `Starting in ${w.path}`);
|
|
1262
|
+
const $ = t("node", [l, "dev"], {
|
|
1263
|
+
cwd: n.default.resolve(w.path),
|
|
1254
1264
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1265
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1266
|
});
|
|
1257
|
-
r.push(
|
|
1267
|
+
r.push($);
|
|
1258
1268
|
let g = "";
|
|
1259
|
-
|
|
1269
|
+
$.stdout.on("data", (u) => {
|
|
1260
1270
|
g += u.toString();
|
|
1261
1271
|
const E = g.split(`
|
|
1262
1272
|
`);
|
|
1263
1273
|
g = E.pop() || "";
|
|
1264
1274
|
for (const O of E) {
|
|
1265
1275
|
const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1266
|
-
b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(
|
|
1276
|
+
b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(x, "✅ Ready") : b.includes("Building...") || b.includes("Running initial build") ? i.setStatus(x, "🔨 Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? i.setStatus(x, "✅ Ready") : b.includes("Build failed") ? i.setStatus(x, "❌ Build Error") : b.includes("File changed") ? (i.setStatus(x, "📝 Changed"), setTimeout(() => i.setStatus(x, "✅ Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (i.setStatus(x, "🔥 HMR Update"), setTimeout(() => i.setStatus(x, "✅ Ready"), 1e3)) : b.includes("HMR client connected") && (i.setStatus(x, "🔥 HMR Connected"), setTimeout(() => i.setStatus(x, "✅ Ready"), 1e3)), !b.includes("Watching") && !b.includes("Press Ctrl+C") && !b.includes("Starting shared") && !b.includes("Management server") && !b.includes("Main server") && !b.includes("Access at:") && !b.includes("No build needed") && i.log(x, b));
|
|
1267
1277
|
}
|
|
1268
|
-
}),
|
|
1278
|
+
}), $.stderr.on("data", (u) => {
|
|
1269
1279
|
const E = u.toString().split(`
|
|
1270
1280
|
`);
|
|
1271
1281
|
for (const O of E) {
|
|
1272
1282
|
const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1273
|
-
b && (i.log(
|
|
1283
|
+
b && (i.log(x, `⚠️ ${b}`), i.setStatus(x, "⚠️ Warning"));
|
|
1274
1284
|
}
|
|
1275
|
-
}),
|
|
1276
|
-
u !== 0 && u !== null && (i.setStatus(
|
|
1285
|
+
}), $.on("exit", (u) => {
|
|
1286
|
+
u !== 0 && u !== null && (i.setStatus(x, `❌ Exited (${u})`), i.log(x, `Process exited with code ${u}`));
|
|
1277
1287
|
}), d < o.length - 1 && await new Promise((u) => setTimeout(u, 500));
|
|
1278
1288
|
}
|
|
1279
1289
|
i.render(), setTimeout(() => {
|
|
@@ -1299,7 +1309,7 @@ function pe(o, t, e) {
|
|
|
1299
1309
|
const n = R.resolve(R.join(o, t)), s = R.resolve(o);
|
|
1300
1310
|
if (!n.startsWith(s + R.sep))
|
|
1301
1311
|
throw new Error(`Invalid path: "${t}" escapes output directory`);
|
|
1302
|
-
|
|
1312
|
+
P.mkdirSync(R.dirname(n), { recursive: !0 }), P.writeFileSync(n, JSON.stringify(e, null, 2));
|
|
1303
1313
|
}
|
|
1304
1314
|
async function $e(o, t, e, n) {
|
|
1305
1315
|
return mt(
|
|
@@ -1386,15 +1396,15 @@ function Kt() {
|
|
|
1386
1396
|
process.exit(0);
|
|
1387
1397
|
});
|
|
1388
1398
|
}
|
|
1389
|
-
const
|
|
1399
|
+
const Be = R.join(at.homedir(), ".myop"), ue = R.join(Be, "credentials.json");
|
|
1390
1400
|
function Qt() {
|
|
1391
|
-
|
|
1401
|
+
P.existsSync(Be) || P.mkdirSync(Be, { recursive: !0, mode: 448 });
|
|
1392
1402
|
}
|
|
1393
|
-
function
|
|
1403
|
+
function Ye() {
|
|
1394
1404
|
try {
|
|
1395
|
-
if (!
|
|
1405
|
+
if (!P.existsSync(ue))
|
|
1396
1406
|
return null;
|
|
1397
|
-
const o =
|
|
1407
|
+
const o = P.readFileSync(ue, "utf8");
|
|
1398
1408
|
return JSON.parse(o);
|
|
1399
1409
|
} catch (o) {
|
|
1400
1410
|
return console.info("Failed to read credentials:", o.message), null;
|
|
@@ -1406,14 +1416,14 @@ function ut(o) {
|
|
|
1406
1416
|
...o,
|
|
1407
1417
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1408
1418
|
};
|
|
1409
|
-
|
|
1419
|
+
P.writeFileSync(ue, JSON.stringify(t, null, 2), {
|
|
1410
1420
|
mode: 384
|
|
1411
1421
|
// Read/write for owner only
|
|
1412
1422
|
});
|
|
1413
1423
|
}
|
|
1414
1424
|
function ft() {
|
|
1415
1425
|
try {
|
|
1416
|
-
return
|
|
1426
|
+
return P.existsSync(ue) && P.unlinkSync(ue), !0;
|
|
1417
1427
|
} catch (o) {
|
|
1418
1428
|
return console.error("Failed to clear credentials:", o.message), !1;
|
|
1419
1429
|
}
|
|
@@ -1425,18 +1435,18 @@ function Zt(o) {
|
|
|
1425
1435
|
return Date.now() > e - t;
|
|
1426
1436
|
}
|
|
1427
1437
|
function Pe() {
|
|
1428
|
-
const o =
|
|
1438
|
+
const o = Ye();
|
|
1429
1439
|
return o ? {
|
|
1430
1440
|
email: o.userEmail,
|
|
1431
1441
|
userId: o.userId
|
|
1432
1442
|
} : null;
|
|
1433
1443
|
}
|
|
1434
|
-
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284,
|
|
1444
|
+
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284, Ge = `http://localhost:${xe}/callback`, qt = "myop-cli";
|
|
1435
1445
|
function Xt() {
|
|
1436
|
-
return
|
|
1446
|
+
return We.randomBytes(32).toString("base64url");
|
|
1437
1447
|
}
|
|
1438
1448
|
function eo(o) {
|
|
1439
|
-
return
|
|
1449
|
+
return We.createHash("sha256").update(o).digest("base64url");
|
|
1440
1450
|
}
|
|
1441
1451
|
async function to() {
|
|
1442
1452
|
const o = await fetch(`${le}/oauth/register`, {
|
|
@@ -1444,7 +1454,7 @@ async function to() {
|
|
|
1444
1454
|
headers: { "Content-Type": "application/json" },
|
|
1445
1455
|
body: JSON.stringify({
|
|
1446
1456
|
client_name: qt,
|
|
1447
|
-
redirect_uris: [
|
|
1457
|
+
redirect_uris: [Ge],
|
|
1448
1458
|
grant_types: ["authorization_code", "refresh_token"],
|
|
1449
1459
|
response_types: ["code"]
|
|
1450
1460
|
})
|
|
@@ -1677,7 +1687,7 @@ async function no(o, t, e) {
|
|
|
1677
1687
|
grant_type: "authorization_code",
|
|
1678
1688
|
code: o,
|
|
1679
1689
|
client_id: t,
|
|
1680
|
-
redirect_uri:
|
|
1690
|
+
redirect_uri: Ge,
|
|
1681
1691
|
code_verifier: e
|
|
1682
1692
|
})
|
|
1683
1693
|
});
|
|
@@ -1735,17 +1745,17 @@ async function me() {
|
|
|
1735
1745
|
const o = z("Starting authentication...").start();
|
|
1736
1746
|
try {
|
|
1737
1747
|
o.text = "Registering OAuth client...";
|
|
1738
|
-
const e = (await to()).client_id, n = Xt(), s = eo(n), i =
|
|
1748
|
+
const e = (await to()).client_id, n = Xt(), s = eo(n), i = We.randomBytes(16).toString("hex");
|
|
1739
1749
|
o.text = "Waiting for authorization...";
|
|
1740
1750
|
const r = oo(i), p = new it(`${le}/oauth/authorize`);
|
|
1741
|
-
p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri",
|
|
1751
|
+
p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri", Ge), p.searchParams.set("code_challenge", s), p.searchParams.set("code_challenge_method", "S256"), p.searchParams.set("state", i), o.stop(), console.log(`
|
|
1742
1752
|
🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${p.toString()}
|
|
1743
1753
|
`), await Ot(p.toString());
|
|
1744
1754
|
const m = await r;
|
|
1745
1755
|
o.start("Exchanging authorization code...");
|
|
1746
1756
|
const l = await no(m, e, n);
|
|
1747
1757
|
o.text = "Getting user info...";
|
|
1748
|
-
const d = await io(l.access_token),
|
|
1758
|
+
const d = await io(l.access_token), w = {
|
|
1749
1759
|
accessToken: l.access_token,
|
|
1750
1760
|
refreshToken: l.refresh_token,
|
|
1751
1761
|
expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
|
|
@@ -1753,13 +1763,13 @@ async function me() {
|
|
|
1753
1763
|
userId: d.userId,
|
|
1754
1764
|
userEmail: d.email
|
|
1755
1765
|
};
|
|
1756
|
-
return ut(
|
|
1766
|
+
return ut(w), o.succeed(`Authenticated as ${d.email}`), w;
|
|
1757
1767
|
} catch (t) {
|
|
1758
1768
|
throw o.fail(`Authentication failed: ${t.message}`), t;
|
|
1759
1769
|
}
|
|
1760
1770
|
}
|
|
1761
1771
|
async function gt() {
|
|
1762
|
-
const o =
|
|
1772
|
+
const o = Ye();
|
|
1763
1773
|
if (!o) {
|
|
1764
1774
|
console.log("Not currently logged in.");
|
|
1765
1775
|
return;
|
|
@@ -1771,8 +1781,8 @@ function ro(o) {
|
|
|
1771
1781
|
const t = (o == null ? void 0 : o.message) || "";
|
|
1772
1782
|
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";
|
|
1773
1783
|
}
|
|
1774
|
-
async function
|
|
1775
|
-
let o =
|
|
1784
|
+
async function Ke() {
|
|
1785
|
+
let o = Ye();
|
|
1776
1786
|
if (!o)
|
|
1777
1787
|
return console.log(`Not logged in. Starting authentication...
|
|
1778
1788
|
`), await me();
|
|
@@ -1803,7 +1813,7 @@ async function Ge() {
|
|
|
1803
1813
|
function Me() {
|
|
1804
1814
|
return le;
|
|
1805
1815
|
}
|
|
1806
|
-
const Z = "@myop/cli",
|
|
1816
|
+
const Z = "@myop/cli", De = process.platform === "win32";
|
|
1807
1817
|
function ao() {
|
|
1808
1818
|
try {
|
|
1809
1819
|
return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
|
|
@@ -1872,7 +1882,7 @@ async function mo(o) {
|
|
|
1872
1882
|
🔐 Elevated permissions required.
|
|
1873
1883
|
`);
|
|
1874
1884
|
try {
|
|
1875
|
-
if (
|
|
1885
|
+
if (De) {
|
|
1876
1886
|
const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${r ? `install -g ${Z}@latest --prefix \\"${r}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
|
|
1877
1887
|
Q(`powershell -Command "${d}"`, { stdio: "inherit" });
|
|
1878
1888
|
} else {
|
|
@@ -1884,7 +1894,7 @@ async function mo(o) {
|
|
|
1884
1894
|
} catch {
|
|
1885
1895
|
console.log(`
|
|
1886
1896
|
❌ Update failed`);
|
|
1887
|
-
const d =
|
|
1897
|
+
const d = De ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
|
|
1888
1898
|
console.log(`
|
|
1889
1899
|
Please run manually: ${d}
|
|
1890
1900
|
`), process.exit(1);
|
|
@@ -1893,8 +1903,8 @@ Please run manually: ${d}
|
|
|
1893
1903
|
let p = null;
|
|
1894
1904
|
try {
|
|
1895
1905
|
let m;
|
|
1896
|
-
r ? m =
|
|
1897
|
-
const l =
|
|
1906
|
+
r ? m = De ? Ae(r, "node_modules") : Ae(r, "lib", "node_modules") : m = Q("npm root -g", { encoding: "utf-8" }).trim();
|
|
1907
|
+
const l = Ae(m, Z, "package.json"), d = Et(l, "utf-8");
|
|
1898
1908
|
p = JSON.parse(d).version;
|
|
1899
1909
|
} catch {
|
|
1900
1910
|
}
|
|
@@ -1913,15 +1923,15 @@ Please run myop again to use the new version.
|
|
|
1913
1923
|
}
|
|
1914
1924
|
return !1;
|
|
1915
1925
|
}
|
|
1916
|
-
const
|
|
1926
|
+
const Je = R.join(at.homedir(), ".myop"), ze = R.join(Je, "preferences.json");
|
|
1917
1927
|
function uo() {
|
|
1918
|
-
|
|
1928
|
+
P.existsSync(Je) || P.mkdirSync(Je, { recursive: !0, mode: 448 });
|
|
1919
1929
|
}
|
|
1920
1930
|
function ht() {
|
|
1921
1931
|
try {
|
|
1922
|
-
if (!
|
|
1932
|
+
if (!P.existsSync(ze))
|
|
1923
1933
|
return {};
|
|
1924
|
-
const o =
|
|
1934
|
+
const o = P.readFileSync(ze, "utf8");
|
|
1925
1935
|
return JSON.parse(o);
|
|
1926
1936
|
} catch {
|
|
1927
1937
|
return {};
|
|
@@ -1930,14 +1940,14 @@ function ht() {
|
|
|
1930
1940
|
function fo(o) {
|
|
1931
1941
|
uo();
|
|
1932
1942
|
const e = { ...ht(), ...o };
|
|
1933
|
-
|
|
1943
|
+
P.writeFileSync(ze, JSON.stringify(e, null, 2), {
|
|
1934
1944
|
mode: 384
|
|
1935
1945
|
});
|
|
1936
1946
|
}
|
|
1937
1947
|
function go() {
|
|
1938
1948
|
return ht().defaultOrganization || null;
|
|
1939
1949
|
}
|
|
1940
|
-
function
|
|
1950
|
+
function Le({ id: o, name: t }) {
|
|
1941
1951
|
fo({ defaultOrganization: { id: o, name: t } });
|
|
1942
1952
|
}
|
|
1943
1953
|
async function ho(o, t, e, n = {}) {
|
|
@@ -1987,15 +1997,15 @@ const wo = () => {
|
|
|
1987
1997
|
}, vo = (o) => {
|
|
1988
1998
|
try {
|
|
1989
1999
|
const t = R.join(o, "package.json");
|
|
1990
|
-
if (!
|
|
1991
|
-
const e = JSON.parse(
|
|
2000
|
+
if (!P.existsSync(t)) return [];
|
|
2001
|
+
const e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
1992
2002
|
return Object.keys({ ...e.dependencies, ...e.devDependencies });
|
|
1993
2003
|
} catch {
|
|
1994
2004
|
return [];
|
|
1995
2005
|
}
|
|
1996
|
-
},
|
|
2006
|
+
}, Qe = async (o) => {
|
|
1997
2007
|
const t = wo();
|
|
1998
|
-
if (!
|
|
2008
|
+
if (!P.existsSync(t))
|
|
1999
2009
|
return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
|
|
2000
2010
|
try {
|
|
2001
2011
|
const e = vo(o), n = ["myop-cli", "myop-component"], s = [
|
|
@@ -2010,20 +2020,20 @@ const wo = () => {
|
|
|
2010
2020
|
} catch (e) {
|
|
2011
2021
|
return console.info("Failed to install skills:", e.message), { success: !1 };
|
|
2012
2022
|
}
|
|
2013
|
-
},
|
|
2023
|
+
}, Ze = (o = ".", t = 3, e = 0) => {
|
|
2014
2024
|
const n = [];
|
|
2015
2025
|
if (e > t) return n;
|
|
2016
2026
|
try {
|
|
2017
|
-
const s =
|
|
2027
|
+
const s = P.readdirSync(o, { withFileTypes: !0 });
|
|
2018
2028
|
for (const i of s) {
|
|
2019
2029
|
const r = R.join(o, i.name);
|
|
2020
2030
|
if (i.isDirectory()) {
|
|
2021
2031
|
if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
|
|
2022
2032
|
continue;
|
|
2023
|
-
n.push(...
|
|
2033
|
+
n.push(...Ze(r, t, e + 1));
|
|
2024
2034
|
} else if (i.name === "myop.config.json")
|
|
2025
2035
|
try {
|
|
2026
|
-
const p =
|
|
2036
|
+
const p = P.readFileSync(r, "utf-8"), m = JSON.parse(p);
|
|
2027
2037
|
n.push({
|
|
2028
2038
|
path: o,
|
|
2029
2039
|
configPath: r,
|
|
@@ -2057,7 +2067,7 @@ const Ee = (o = !1) => {
|
|
|
2057
2067
|
author: "@myop-cli",
|
|
2058
2068
|
flows: []
|
|
2059
2069
|
};
|
|
2060
|
-
return
|
|
2070
|
+
return Ve(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
|
|
2061
2071
|
} catch {
|
|
2062
2072
|
return console.info("Error details :", e), { configFound: !1, error: e };
|
|
2063
2073
|
}
|
|
@@ -2066,10 +2076,10 @@ const Ee = (o = !1) => {
|
|
|
2066
2076
|
}
|
|
2067
2077
|
};
|
|
2068
2078
|
[
|
|
2069
|
-
new
|
|
2079
|
+
new Ue(),
|
|
2070
2080
|
...Dt
|
|
2071
2081
|
];
|
|
2072
|
-
const So = "0.1.
|
|
2082
|
+
const So = "0.1.55";
|
|
2073
2083
|
v.program = new Pt();
|
|
2074
2084
|
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(So);
|
|
2075
2085
|
v.program.addOption(new fe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
@@ -2113,12 +2123,12 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
|
|
|
2113
2123
|
process.exit(0);
|
|
2114
2124
|
});
|
|
2115
2125
|
v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
|
|
2116
|
-
var
|
|
2126
|
+
var x, $, g;
|
|
2117
2127
|
const t = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2118
2128
|
let e = {};
|
|
2119
|
-
if (
|
|
2129
|
+
if (P.existsSync(t))
|
|
2120
2130
|
try {
|
|
2121
|
-
e = JSON.parse(
|
|
2131
|
+
e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
2122
2132
|
} catch (u) {
|
|
2123
2133
|
console.error(`⚠️ Failed to parse ${t}:`, u.message);
|
|
2124
2134
|
}
|
|
@@ -2128,13 +2138,13 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2128
2138
|
📋 Component: ${n}`);
|
|
2129
2139
|
let s = null, i = !1;
|
|
2130
2140
|
try {
|
|
2131
|
-
const u = JSON.parse(
|
|
2141
|
+
const u = JSON.parse(P.readFileSync("package.json", "utf-8"));
|
|
2132
2142
|
i = !!(u.scripts && u.scripts.build);
|
|
2133
2143
|
} catch {
|
|
2134
2144
|
}
|
|
2135
2145
|
if (!i) {
|
|
2136
|
-
const u =
|
|
2137
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2146
|
+
const u = P.readdirSync(".").filter(
|
|
2147
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2138
2148
|
);
|
|
2139
2149
|
u.length === 1 && (s = u[0]);
|
|
2140
2150
|
}
|
|
@@ -2143,22 +2153,22 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2143
2153
|
else if (i) {
|
|
2144
2154
|
const { exec: u } = await import("child_process");
|
|
2145
2155
|
let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
2146
|
-
const O = (
|
|
2147
|
-
const
|
|
2148
|
-
u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (
|
|
2149
|
-
if (!
|
|
2150
|
-
|
|
2156
|
+
const O = (M = !1) => new Promise((j) => {
|
|
2157
|
+
const C = z(M ? "Retrying build..." : "Building project...").start();
|
|
2158
|
+
u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (N, k, L) => {
|
|
2159
|
+
if (!N) {
|
|
2160
|
+
C.succeed("Build completed"), j(!0);
|
|
2151
2161
|
return;
|
|
2152
2162
|
}
|
|
2153
|
-
if (
|
|
2154
|
-
const D = await pt(
|
|
2163
|
+
if (C.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
|
|
2164
|
+
const D = await pt(N, k, L, u, E);
|
|
2155
2165
|
if (E = { ...E, ...D }, D.handled) {
|
|
2156
|
-
const
|
|
2157
|
-
j(
|
|
2166
|
+
const F = await O(!0);
|
|
2167
|
+
j(F);
|
|
2158
2168
|
return;
|
|
2159
2169
|
}
|
|
2160
2170
|
}
|
|
2161
|
-
console.error(
|
|
2171
|
+
console.error(N.message), j(!1);
|
|
2162
2172
|
});
|
|
2163
2173
|
});
|
|
2164
2174
|
await O() || process.exit(1);
|
|
@@ -2166,26 +2176,26 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2166
2176
|
let r;
|
|
2167
2177
|
if (s)
|
|
2168
2178
|
r = s;
|
|
2169
|
-
else if (
|
|
2179
|
+
else if (P.existsSync("./dist/index.html"))
|
|
2170
2180
|
r = "./dist/index.html";
|
|
2171
2181
|
else {
|
|
2172
|
-
const u =
|
|
2173
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2182
|
+
const u = P.readdirSync(".").filter(
|
|
2183
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2174
2184
|
);
|
|
2175
2185
|
u.length === 1 ? r = u[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));
|
|
2176
2186
|
}
|
|
2177
|
-
const p =
|
|
2187
|
+
const p = P.readFileSync(r, "utf-8");
|
|
2178
2188
|
console.log(` File: ${r} (${(p.length / 1024).toFixed(1)} KB)`);
|
|
2179
2189
|
let m;
|
|
2180
2190
|
try {
|
|
2181
|
-
m = await
|
|
2191
|
+
m = await Ke();
|
|
2182
2192
|
} catch (u) {
|
|
2183
2193
|
re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("❌ Authentication failed:", u.message), console.error(`
|
|
2184
2194
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2185
2195
|
`)), process.exit(1);
|
|
2186
2196
|
}
|
|
2187
2197
|
const l = Me();
|
|
2188
|
-
let d = z("Uploading...").start(),
|
|
2198
|
+
let d = z("Uploading...").start(), w;
|
|
2189
2199
|
try {
|
|
2190
2200
|
const u = await fetch(`${l}/mcp`, {
|
|
2191
2201
|
method: "POST",
|
|
@@ -2213,32 +2223,32 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2213
2223
|
const E = await u.json();
|
|
2214
2224
|
if (E.error)
|
|
2215
2225
|
throw new Error(E.error.message);
|
|
2216
|
-
const O = (g = (
|
|
2217
|
-
if (
|
|
2218
|
-
throw new Error(
|
|
2226
|
+
const O = (g = ($ = (x = E.result) == null ? void 0 : x.content) == null ? void 0 : $[0]) == null ? void 0 : g.text;
|
|
2227
|
+
if (w = JSON.parse(O), !w.success)
|
|
2228
|
+
throw new Error(w.error);
|
|
2219
2229
|
d.succeed("Pushed successfully");
|
|
2220
2230
|
} catch (u) {
|
|
2221
2231
|
d.fail("Upload failed"), re(u) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", u.message), process.exit(1);
|
|
2222
2232
|
}
|
|
2223
|
-
if (
|
|
2224
|
-
e.componentId =
|
|
2233
|
+
if (w.isNewComponent || !e.componentId || e.componentId === "DEV") {
|
|
2234
|
+
e.componentId = w.componentId, e.organization = w.orgId, e.name || (e.name = w.componentName);
|
|
2225
2235
|
try {
|
|
2226
|
-
|
|
2236
|
+
P.writeFileSync(t, JSON.stringify(e, null, 2));
|
|
2227
2237
|
} catch (u) {
|
|
2228
|
-
console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${
|
|
2238
|
+
console.log(`⚠️ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${w.componentId}" manually`);
|
|
2229
2239
|
}
|
|
2230
2240
|
}
|
|
2231
2241
|
console.log(`
|
|
2232
|
-
${
|
|
2242
|
+
${w.componentName}`), console.log(` ${w.dashboardUrl}
|
|
2233
2243
|
`), process.exit(0);
|
|
2234
2244
|
});
|
|
2235
2245
|
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) => {
|
|
2236
2246
|
var u, E, O;
|
|
2237
2247
|
const e = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2238
2248
|
let n = {};
|
|
2239
|
-
if (
|
|
2249
|
+
if (P.existsSync(e))
|
|
2240
2250
|
try {
|
|
2241
|
-
n = JSON.parse(
|
|
2251
|
+
n = JSON.parse(P.readFileSync(e, "utf-8"));
|
|
2242
2252
|
} catch {
|
|
2243
2253
|
}
|
|
2244
2254
|
const s = o || n.componentId;
|
|
@@ -2248,7 +2258,7 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2248
2258
|
📥 Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
|
|
2249
2259
|
let r;
|
|
2250
2260
|
try {
|
|
2251
|
-
r = await
|
|
2261
|
+
r = await Ke();
|
|
2252
2262
|
} catch (b) {
|
|
2253
2263
|
re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("❌ Authentication failed:", b.message), console.error(`
|
|
2254
2264
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
@@ -2275,21 +2285,21 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2275
2285
|
});
|
|
2276
2286
|
if (!b.ok)
|
|
2277
2287
|
throw new Error(`Server returned ${b.status}`);
|
|
2278
|
-
const
|
|
2279
|
-
if (
|
|
2280
|
-
throw new Error(
|
|
2281
|
-
const j = (O = (E = (u =
|
|
2288
|
+
const M = await b.json();
|
|
2289
|
+
if (M.error)
|
|
2290
|
+
throw new Error(M.error.message);
|
|
2291
|
+
const j = (O = (E = (u = M.result) == null ? void 0 : u.content) == null ? void 0 : E[0]) == null ? void 0 : O.text;
|
|
2282
2292
|
l = JSON.parse(j), !l.success && !l.html && (m.fail("Failed to fetch component"), console.error(" ", l.error || "No HTML content returned"), l.message && console.error(" ", l.message), process.exit(1)), m.succeed("Component fetched");
|
|
2283
2293
|
} catch (b) {
|
|
2284
2294
|
m.fail("Failed to fetch component"), re(b) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", b.message), process.exit(1);
|
|
2285
2295
|
}
|
|
2286
2296
|
let d = t.output;
|
|
2287
|
-
d || (
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2290
|
-
const
|
|
2297
|
+
d || (P.existsSync("./dist/index.html") ? d = "./dist/index.html" : d = "./index.html");
|
|
2298
|
+
const w = l.htmlContent || l.html, x = R.dirname(d);
|
|
2299
|
+
x && !P.existsSync(x) && P.mkdirSync(x, { recursive: !0 }), P.writeFileSync(d, w), console.log(` Saved to: ${d} (${(w.length / 1024).toFixed(1)} KB)`);
|
|
2300
|
+
const $ = P.existsSync(e);
|
|
2291
2301
|
let g = !1;
|
|
2292
|
-
if (
|
|
2302
|
+
if ($ ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
|
|
2293
2303
|
name: l.name || R.basename(process.cwd()),
|
|
2294
2304
|
componentId: s,
|
|
2295
2305
|
type: "html",
|
|
@@ -2297,7 +2307,7 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2297
2307
|
HMR: !0
|
|
2298
2308
|
}, g = !0), g)
|
|
2299
2309
|
try {
|
|
2300
|
-
|
|
2310
|
+
P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${$ ? "Updated" : "Created"} ${e}`);
|
|
2301
2311
|
} catch (b) {
|
|
2302
2312
|
console.log(` ⚠️ Could not write ${e}: ${b.message}`);
|
|
2303
2313
|
}
|
|
@@ -2309,7 +2319,7 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2309
2319
|
const { search: t, select: e } = await import("@inquirer/prompts");
|
|
2310
2320
|
let n;
|
|
2311
2321
|
try {
|
|
2312
|
-
n = await
|
|
2322
|
+
n = await Ke();
|
|
2313
2323
|
} catch (g) {
|
|
2314
2324
|
re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("❌ Authentication failed:", g.message), console.error(`
|
|
2315
2325
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
@@ -2328,13 +2338,13 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2328
2338
|
let m, l;
|
|
2329
2339
|
if (o.org) {
|
|
2330
2340
|
const g = p.find((u) => u.id === o.org || u._id === o.org);
|
|
2331
|
-
g || (console.error(`Organization "${o.org}" not found. Available:`), p.forEach((u) => console.log(` ${u.id || u._id} ${u.name}`)), process.exit(1)), m = g.id || g._id, l = g.name,
|
|
2341
|
+
g || (console.error(`Organization "${o.org}" not found. Available:`), p.forEach((u) => console.log(` ${u.id || u._id} ${u.name}`)), process.exit(1)), m = g.id || g._id, l = g.name, Le({ id: m, name: l });
|
|
2332
2342
|
} else {
|
|
2333
2343
|
const g = go();
|
|
2334
2344
|
if (g && p.find((u) => (u.id || u._id) === g.id))
|
|
2335
2345
|
m = g.id, l = g.name;
|
|
2336
2346
|
else if (p.length === 1)
|
|
2337
|
-
m = p[0].id || p[0]._id, l = p[0].name,
|
|
2347
|
+
m = p[0].id || p[0]._id, l = p[0].name, Le({ id: m, name: l });
|
|
2338
2348
|
else
|
|
2339
2349
|
try {
|
|
2340
2350
|
const u = await e({
|
|
@@ -2344,7 +2354,7 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2344
2354
|
value: { id: E.id || E._id, name: E.name }
|
|
2345
2355
|
}))
|
|
2346
2356
|
});
|
|
2347
|
-
m = u.id, l = u.name,
|
|
2357
|
+
m = u.id, l = u.name, Le({ id: m, name: l });
|
|
2348
2358
|
} catch (u) {
|
|
2349
2359
|
throw u.name === "ExitPromptError" && (console.log(`
|
|
2350
2360
|
|
|
@@ -2364,47 +2374,47 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2364
2374
|
r.stop(), d.length === 0 && (console.log(` No components found in this organization.
|
|
2365
2375
|
`), process.exit(0)), console.log(` ${l} - ${d.length} component(s)
|
|
2366
2376
|
`);
|
|
2367
|
-
const
|
|
2377
|
+
const w = [];
|
|
2368
2378
|
for (; ; ) {
|
|
2369
|
-
const g = `[Done - pull/push ${
|
|
2379
|
+
const g = `[Done - pull/push ${w.length} selected]`, u = "__done__", E = new Set(w.map((M) => M.id || M._id || M.componentId));
|
|
2370
2380
|
let O;
|
|
2371
2381
|
try {
|
|
2372
2382
|
O = await t({
|
|
2373
2383
|
message: "Search & select components:",
|
|
2374
|
-
source: (
|
|
2375
|
-
const j = (
|
|
2384
|
+
source: (M) => {
|
|
2385
|
+
const j = (M || "").toLowerCase(), C = d.filter((k) => {
|
|
2376
2386
|
const L = k.id || k._id || k.componentId;
|
|
2377
2387
|
return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
|
|
2378
|
-
}),
|
|
2388
|
+
}), N = [
|
|
2379
2389
|
{ name: g, value: u }
|
|
2380
2390
|
];
|
|
2381
|
-
for (const k of
|
|
2391
|
+
for (const k of C) {
|
|
2382
2392
|
const L = k.id || k._id || k.componentId, D = L ? L.substring(0, 8) + "..." : "";
|
|
2383
|
-
|
|
2393
|
+
N.push({
|
|
2384
2394
|
name: `${k.name} (${D})`,
|
|
2385
2395
|
value: L
|
|
2386
2396
|
});
|
|
2387
2397
|
}
|
|
2388
|
-
return
|
|
2398
|
+
return N;
|
|
2389
2399
|
}
|
|
2390
2400
|
});
|
|
2391
|
-
} catch (
|
|
2392
|
-
throw
|
|
2401
|
+
} catch (M) {
|
|
2402
|
+
throw M.name === "ExitPromptError" && (console.log(`
|
|
2393
2403
|
|
|
2394
2404
|
👋 Goodbye!
|
|
2395
|
-
`), process.exit(0)),
|
|
2405
|
+
`), process.exit(0)), M;
|
|
2396
2406
|
}
|
|
2397
2407
|
if (O === u)
|
|
2398
2408
|
break;
|
|
2399
|
-
const b = d.find((
|
|
2400
|
-
b && (
|
|
2409
|
+
const b = d.find((M) => (M.id || M._id || M.componentId) === O);
|
|
2410
|
+
b && (w.push(b), console.log(` + ${b.name}`));
|
|
2401
2411
|
}
|
|
2402
|
-
|
|
2412
|
+
w.length === 0 && (console.log(` No components selected.
|
|
2403
2413
|
`), process.exit(0));
|
|
2404
|
-
let
|
|
2414
|
+
let x;
|
|
2405
2415
|
try {
|
|
2406
|
-
|
|
2407
|
-
message: `${
|
|
2416
|
+
x = await e({
|
|
2417
|
+
message: `${w.length} component(s) selected:`,
|
|
2408
2418
|
choices: [
|
|
2409
2419
|
{ name: "Pull selected", value: "pull" },
|
|
2410
2420
|
{ name: "Push selected", value: "push" },
|
|
@@ -2417,22 +2427,22 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2417
2427
|
👋 Goodbye!
|
|
2418
2428
|
`), process.exit(0)), g;
|
|
2419
2429
|
}
|
|
2420
|
-
|
|
2430
|
+
x === "cancel" && (console.log(` Cancelled.
|
|
2421
2431
|
`), process.exit(0));
|
|
2422
|
-
const
|
|
2423
|
-
if (
|
|
2432
|
+
const $ = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
2433
|
+
if (x === "pull") {
|
|
2424
2434
|
console.log(`
|
|
2425
|
-
Pulling ${
|
|
2435
|
+
Pulling ${w.length} components...
|
|
2426
2436
|
`);
|
|
2427
|
-
const g = await Promise.all(
|
|
2437
|
+
const g = await Promise.all(w.map(async (O) => {
|
|
2428
2438
|
const b = O.id || O._id || O.componentId;
|
|
2429
2439
|
try {
|
|
2430
|
-
const
|
|
2431
|
-
|
|
2432
|
-
const
|
|
2433
|
-
if (!
|
|
2440
|
+
const M = await i("get_component", { componentId: b }), j = $(O.name);
|
|
2441
|
+
P.mkdirSync(j, { recursive: !0 });
|
|
2442
|
+
const C = M.htmlContent || M.html;
|
|
2443
|
+
if (!C)
|
|
2434
2444
|
throw new Error("No HTML content returned");
|
|
2435
|
-
return
|
|
2445
|
+
return P.writeFileSync(R.join(j, "index.html"), C), P.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
|
|
2436
2446
|
name: O.name,
|
|
2437
2447
|
componentId: b,
|
|
2438
2448
|
organization: m,
|
|
@@ -2440,8 +2450,8 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2440
2450
|
author: "@myop-cli",
|
|
2441
2451
|
HMR: !0
|
|
2442
2452
|
}, null, 2)), { name: O.name, status: "ok", dir: j };
|
|
2443
|
-
} catch (
|
|
2444
|
-
return { name: O.name, status: "failed", error:
|
|
2453
|
+
} catch (M) {
|
|
2454
|
+
return { name: O.name, status: "failed", error: M.message };
|
|
2445
2455
|
}
|
|
2446
2456
|
}));
|
|
2447
2457
|
let u = 0, E = 0;
|
|
@@ -2450,46 +2460,46 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2450
2460
|
console.log(`
|
|
2451
2461
|
Done! Pulled ${u} component${u !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
|
|
2452
2462
|
`);
|
|
2453
|
-
} else if (
|
|
2463
|
+
} else if (x === "push") {
|
|
2454
2464
|
console.log(`
|
|
2455
|
-
Pushing ${
|
|
2465
|
+
Pushing ${w.length} components...
|
|
2456
2466
|
`);
|
|
2457
|
-
const g =
|
|
2458
|
-
const j =
|
|
2459
|
-
if (!
|
|
2460
|
-
return { name:
|
|
2467
|
+
const g = Ze(".", 3), u = await Promise.all(w.map(async (M) => {
|
|
2468
|
+
const j = M.id || M._id || M.componentId, C = g.find((N) => N.componentId === j);
|
|
2469
|
+
if (!C)
|
|
2470
|
+
return { name: M.name, status: "skipped", reason: "no local match" };
|
|
2461
2471
|
try {
|
|
2462
|
-
let
|
|
2463
|
-
const k =
|
|
2464
|
-
if (
|
|
2465
|
-
|
|
2472
|
+
let N;
|
|
2473
|
+
const k = C.path;
|
|
2474
|
+
if (P.existsSync(R.join(k, "dist", "index.html")))
|
|
2475
|
+
N = R.join(k, "dist", "index.html");
|
|
2466
2476
|
else {
|
|
2467
|
-
const W =
|
|
2468
|
-
(
|
|
2477
|
+
const W = P.readdirSync(k).filter(
|
|
2478
|
+
(_) => _.endsWith(".html") && !_.startsWith(".") && P.statSync(R.join(k, _)).isFile()
|
|
2469
2479
|
);
|
|
2470
2480
|
if (W.length === 1)
|
|
2471
|
-
|
|
2481
|
+
N = R.join(k, W[0]);
|
|
2472
2482
|
else if (W.includes("index.html"))
|
|
2473
|
-
|
|
2483
|
+
N = R.join(k, "index.html");
|
|
2474
2484
|
else
|
|
2475
2485
|
throw new Error("No HTML file found");
|
|
2476
2486
|
}
|
|
2477
|
-
const L =
|
|
2487
|
+
const L = P.readFileSync(N, "utf-8"), D = C.name || M.name, F = await i("upload_component", {
|
|
2478
2488
|
name: D,
|
|
2479
2489
|
componentId: j,
|
|
2480
2490
|
organization: m,
|
|
2481
2491
|
htmlContent: L
|
|
2482
2492
|
});
|
|
2483
|
-
if (!
|
|
2484
|
-
throw new Error(
|
|
2493
|
+
if (!F.success)
|
|
2494
|
+
throw new Error(F.error || "Upload failed");
|
|
2485
2495
|
return { name: D, status: "ok" };
|
|
2486
|
-
} catch (
|
|
2487
|
-
return { name:
|
|
2496
|
+
} catch (N) {
|
|
2497
|
+
return { name: M.name, status: "failed", error: N.message };
|
|
2488
2498
|
}
|
|
2489
2499
|
}));
|
|
2490
2500
|
let E = 0, O = 0, b = 0;
|
|
2491
|
-
for (const
|
|
2492
|
-
|
|
2501
|
+
for (const M of u)
|
|
2502
|
+
M.status === "ok" ? (console.log(` \x1B[32m✔\x1B[0m ${M.name}`), E++) : M.status === "skipped" ? (console.log(` \x1B[33m⊘\x1B[0m ${M.name} (${M.reason})`), O++) : (console.log(` \x1B[31m✖\x1B[0m ${M.name} - ${M.error}`), b++);
|
|
2493
2503
|
console.log(`
|
|
2494
2504
|
Done! Pushed ${E}${O ? `, skipped ${O}` : ""}${b ? `, ${b} failed` : ""}.
|
|
2495
2505
|
`);
|
|
@@ -2643,13 +2653,13 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2643
2653
|
</body>
|
|
2644
2654
|
</html>`;
|
|
2645
2655
|
t.writeFileSync("index.html", r);
|
|
2646
|
-
const p = await
|
|
2656
|
+
const p = await Qe(process.cwd());
|
|
2647
2657
|
console.log(`
|
|
2648
2658
|
✅ Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Ce();
|
|
2649
2659
|
});
|
|
2650
2660
|
v.program.command("dev").description("Start development server with file watching").action(Ce);
|
|
2651
2661
|
const yt = async () => {
|
|
2652
|
-
const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await
|
|
2662
|
+
const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Qe(o);
|
|
2653
2663
|
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);
|
|
2654
2664
|
};
|
|
2655
2665
|
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(yt);
|
|
@@ -2726,7 +2736,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2726
2736
|
const p = i.find((d) => d.value === r);
|
|
2727
2737
|
let m = {};
|
|
2728
2738
|
try {
|
|
2729
|
-
const d =
|
|
2739
|
+
const d = P.readFileSync(p.configPath, "utf-8");
|
|
2730
2740
|
m = JSON.parse(d);
|
|
2731
2741
|
} catch {
|
|
2732
2742
|
}
|
|
@@ -2749,7 +2759,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2749
2759
|
throw d.name === "ExitPromptError" && process.exit(0), d;
|
|
2750
2760
|
}
|
|
2751
2761
|
}
|
|
2752
|
-
m.mcpServers.myop = p.getEntry(),
|
|
2762
|
+
m.mcpServers.myop = p.getEntry(), P.mkdirSync(R.dirname(p.configPath), { recursive: !0 }), P.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
|
|
2753
2763
|
\x1B[32m✔\x1B[0m Myop MCP configured for ${p.name}`), console.log(` Config: ${p.configPath}`), console.log(` Server: ${s}`), console.log(`
|
|
2754
2764
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2755
2765
|
for (const d of p.nextSteps)
|
|
@@ -2789,8 +2799,8 @@ const xo = () => {
|
|
|
2789
2799
|
return null;
|
|
2790
2800
|
}
|
|
2791
2801
|
}, ne = async (o = !1, t = !1) => {
|
|
2792
|
-
var d,
|
|
2793
|
-
const e = Pe(), n = !!(e != null && e.email), s = ((d = v.myopConfig) == null ? void 0 : d.name) || ((
|
|
2802
|
+
var d, w, x;
|
|
2803
|
+
const e = Pe(), n = !!(e != null && e.email), s = ((d = v.myopConfig) == null ? void 0 : d.name) || ((w = v.myopConfig) == null ? void 0 : w.componentName), i = (x = v.myopConfig) == null ? void 0 : x.componentId, r = xo();
|
|
2794
2804
|
console.log(`
|
|
2795
2805
|
┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Welcome to Myop CLI - Remote UI Made Easy │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
|
|
2796
2806
|
`), 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"}`), r != null && r.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")) : r != null && r.notARepo ? console.log(" Changes: Not a git repository") : r && (r.insertions > 0 || r.deletions > 0) ? console.log(` Changes: ${r.files} file${r.files !== 1 ? "s" : ""} | \x1B[32m+${r.insertions}\x1B[0m \x1B[31m-${r.deletions}\x1B[0m`) : r && console.log(" Changes: No uncommitted changes"), console.log("");
|
|
@@ -2816,14 +2826,14 @@ const xo = () => {
|
|
|
2816
2826
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
2817
2827
|
disabled: o ? n ? !1 : "(login required)" : "(no config file)"
|
|
2818
2828
|
}
|
|
2819
|
-
].map((
|
|
2820
|
-
name: t &&
|
|
2821
|
-
${
|
|
2822
|
-
value:
|
|
2823
|
-
disabled:
|
|
2829
|
+
].map(($) => ({
|
|
2830
|
+
name: t && !$.disabled ? `${$.emoji} ${$.label}
|
|
2831
|
+
${$.help}` : `${$.emoji} ${$.label}`,
|
|
2832
|
+
value: $.value,
|
|
2833
|
+
disabled: $.disabled
|
|
2824
2834
|
}));
|
|
2825
2835
|
m.push(
|
|
2826
|
-
new
|
|
2836
|
+
new Ue(),
|
|
2827
2837
|
{
|
|
2828
2838
|
name: t && n ? `🔓 Logout (${e.email})
|
|
2829
2839
|
Clears stored credentials from this machine` : t && !n ? `🔐 Login to Myop
|
|
@@ -2834,7 +2844,7 @@ const xo = () => {
|
|
|
2834
2844
|
name: t ? "📖 Hide help" : "📖 Show help",
|
|
2835
2845
|
value: "help"
|
|
2836
2846
|
},
|
|
2837
|
-
new
|
|
2847
|
+
new Ue(),
|
|
2838
2848
|
{
|
|
2839
2849
|
name: "👋 Exit",
|
|
2840
2850
|
value: "exit"
|
|
@@ -2846,11 +2856,11 @@ const xo = () => {
|
|
|
2846
2856
|
message: "What would you like to do?",
|
|
2847
2857
|
choices: m
|
|
2848
2858
|
});
|
|
2849
|
-
} catch (
|
|
2850
|
-
throw
|
|
2859
|
+
} catch ($) {
|
|
2860
|
+
throw $.name === "ExitPromptError" && (console.log(`
|
|
2851
2861
|
|
|
2852
2862
|
👋 Goodbye!
|
|
2853
|
-
`), process.exit(0)),
|
|
2863
|
+
`), process.exit(0)), $;
|
|
2854
2864
|
}
|
|
2855
2865
|
switch (l) {
|
|
2856
2866
|
case "init":
|
|
@@ -2860,9 +2870,9 @@ const xo = () => {
|
|
|
2860
2870
|
console.log(`
|
|
2861
2871
|
Pushing component...
|
|
2862
2872
|
`);
|
|
2863
|
-
const { execSync:
|
|
2873
|
+
const { execSync: $ } = await import("child_process");
|
|
2864
2874
|
try {
|
|
2865
|
-
|
|
2875
|
+
$("node " + process.argv[1] + " push", { stdio: "inherit" });
|
|
2866
2876
|
} catch {
|
|
2867
2877
|
}
|
|
2868
2878
|
await ne(!0, t);
|
|
@@ -2890,7 +2900,7 @@ Pushing component...
|
|
|
2890
2900
|
}
|
|
2891
2901
|
}, be = ".myop-monorepo.json", $o = () => {
|
|
2892
2902
|
try {
|
|
2893
|
-
const o =
|
|
2903
|
+
const o = P.readFileSync(be, "utf-8");
|
|
2894
2904
|
return JSON.parse(o);
|
|
2895
2905
|
} catch {
|
|
2896
2906
|
return null;
|
|
@@ -2901,7 +2911,7 @@ Pushing component...
|
|
|
2901
2911
|
selectedComponents: o,
|
|
2902
2912
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2903
2913
|
};
|
|
2904
|
-
|
|
2914
|
+
P.writeFileSync(be, JSON.stringify(t, null, 2));
|
|
2905
2915
|
} catch {
|
|
2906
2916
|
}
|
|
2907
2917
|
}, Co = async () => {
|
|
@@ -2909,42 +2919,42 @@ Pushing component...
|
|
|
2909
2919
|
console.log(`
|
|
2910
2920
|
┌─────────────────────────────────────────────────┐`), console.log("│ │"), console.log("│ Myop CLI - Monorepo Mode │"), console.log("│ │"), console.log(`└─────────────────────────────────────────────────┘
|
|
2911
2921
|
`);
|
|
2912
|
-
const e = z("Scanning for components...").start(), n =
|
|
2922
|
+
const e = z("Scanning for components...").start(), n = Ze(".");
|
|
2913
2923
|
e.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
|
|
2914
2924
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2915
2925
|
const s = $o(), i = (s == null ? void 0 : s.selectedComponents) || [], r = i.length > 0;
|
|
2916
2926
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2917
|
-
`), n.forEach((
|
|
2918
|
-
const
|
|
2919
|
-
console.log(` ${
|
|
2927
|
+
`), n.forEach((w, x) => {
|
|
2928
|
+
const $ = w.componentId ? "✅" : "⚪", g = w.componentId ? w.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2929
|
+
console.log(` ${$} ${w.name}`), console.log(` Path: ${w.path}`), console.log(` ID: ${g}`), console.log("");
|
|
2920
2930
|
}), console.log(` User: ${t ? o.email : "Not logged in"}`), r && console.log(` 📋 Using saved selection from ${be}`), console.log("");
|
|
2921
2931
|
const p = v.program.getOptionValue("ci");
|
|
2922
2932
|
let m;
|
|
2923
2933
|
if (p)
|
|
2924
|
-
r ? (m = i, console.log(` 🤖 CI mode: using saved selection (${m.length} components)`)) : (m = n.map((
|
|
2934
|
+
r ? (m = i, console.log(` 🤖 CI mode: using saved selection (${m.length} components)`)) : (m = n.map((w) => w.path), console.log(` 🤖 CI mode: no saved selection, using all ${m.length} components`));
|
|
2925
2935
|
else {
|
|
2926
|
-
const { checkbox:
|
|
2927
|
-
name: `${
|
|
2928
|
-
value:
|
|
2929
|
-
checked: r ? i.includes(
|
|
2936
|
+
const { checkbox: w } = await import("@inquirer/prompts"), x = n.map(($) => ({
|
|
2937
|
+
name: `${$.name} (${$.path})`,
|
|
2938
|
+
value: $.path,
|
|
2939
|
+
checked: r ? i.includes($.path) : !0
|
|
2930
2940
|
}));
|
|
2931
2941
|
try {
|
|
2932
|
-
m = await
|
|
2942
|
+
m = await w({
|
|
2933
2943
|
message: "Select components to start in dev mode:",
|
|
2934
|
-
choices:
|
|
2944
|
+
choices: x
|
|
2935
2945
|
});
|
|
2936
|
-
} catch (
|
|
2937
|
-
throw
|
|
2946
|
+
} catch ($) {
|
|
2947
|
+
throw $.name === "ExitPromptError" && (console.log(`
|
|
2938
2948
|
|
|
2939
2949
|
👋 Goodbye!
|
|
2940
|
-
`), process.exit(0)),
|
|
2950
|
+
`), process.exit(0)), $;
|
|
2941
2951
|
}
|
|
2942
2952
|
}
|
|
2943
2953
|
m.length === 0 && (console.log(`
|
|
2944
2954
|
⚠️ No components selected.
|
|
2945
2955
|
`), process.exit(0)), p || (bo(m), console.log(`
|
|
2946
2956
|
💾 Selection saved to ${be}`));
|
|
2947
|
-
const l = n.filter((
|
|
2957
|
+
const l = n.filter((w) => m.includes(w.path));
|
|
2948
2958
|
console.log(`🚀 Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
|
|
2949
2959
|
`);
|
|
2950
2960
|
const { monorepoDevCommand: d } = await Promise.resolve().then(() => Wt);
|
|
@@ -3072,7 +3082,7 @@ fs.writeFileSync('dist/index.html', html);
|
|
|
3072
3082
|
console.log('✅ Built dist/index.html');
|
|
3073
3083
|
console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
|
|
3074
3084
|
`), console.log("✅ Created build.js");
|
|
3075
|
-
const
|
|
3085
|
+
const w = `<!DOCTYPE html>
|
|
3076
3086
|
<html lang="en">
|
|
3077
3087
|
<head>
|
|
3078
3088
|
<meta charset="UTF-8">
|
|
@@ -3089,8 +3099,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
3089
3099
|
</body>
|
|
3090
3100
|
</html>
|
|
3091
3101
|
`;
|
|
3092
|
-
e.writeFileSync("index.html",
|
|
3093
|
-
const
|
|
3102
|
+
e.writeFileSync("index.html", w), console.log("✅ Created index.html");
|
|
3103
|
+
const x = `// ${i} - Entry Point
|
|
3094
3104
|
import { init } from './modules/app.js';
|
|
3095
3105
|
import { setupMyopInterface } from './modules/myop.js';
|
|
3096
3106
|
|
|
@@ -3099,8 +3109,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
3099
3109
|
setupMyopInterface();
|
|
3100
3110
|
});
|
|
3101
3111
|
`;
|
|
3102
|
-
e.writeFileSync("src/index.js",
|
|
3103
|
-
const
|
|
3112
|
+
e.writeFileSync("src/index.js", x), console.log("✅ Created src/index.js");
|
|
3113
|
+
const $ = `// ${i} - Main Application Logic
|
|
3104
3114
|
|
|
3105
3115
|
export function init() {
|
|
3106
3116
|
console.log('${i} loaded');
|
|
@@ -3108,7 +3118,7 @@ export function init() {
|
|
|
3108
3118
|
// Your component logic here
|
|
3109
3119
|
}
|
|
3110
3120
|
`;
|
|
3111
|
-
e.writeFileSync("src/modules/app.js",
|
|
3121
|
+
e.writeFileSync("src/modules/app.js", $), console.log("✅ Created src/modules/app.js"), e.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
|
|
3112
3122
|
|
|
3113
3123
|
export function setupMyopInterface() {
|
|
3114
3124
|
// Called when host app sends data to this component
|
|
@@ -3164,12 +3174,12 @@ dist/
|
|
|
3164
3174
|
.temp-styles.css
|
|
3165
3175
|
.DS_Store
|
|
3166
3176
|
`), console.log("✅ Created .gitignore");
|
|
3167
|
-
const b = await
|
|
3177
|
+
const b = await Qe(process.cwd());
|
|
3168
3178
|
b.success && console.log("✅ Installed AI agent skills");
|
|
3169
|
-
const
|
|
3179
|
+
const M = await import("./index-DuEoKctW.js").then((C) => C.i), j = process.cwd();
|
|
3170
3180
|
try {
|
|
3171
|
-
await
|
|
3172
|
-
const
|
|
3181
|
+
await M.init({ fs: e, dir: j });
|
|
3182
|
+
const C = [
|
|
3173
3183
|
"myop.config.json",
|
|
3174
3184
|
"package.json",
|
|
3175
3185
|
"build.js",
|
|
@@ -3182,12 +3192,12 @@ dist/
|
|
|
3182
3192
|
"src/styles/main.css"
|
|
3183
3193
|
];
|
|
3184
3194
|
if (b.success) {
|
|
3185
|
-
const
|
|
3195
|
+
const N = (k, L) => {
|
|
3186
3196
|
try {
|
|
3187
3197
|
const D = e.readdirSync(k, { withFileTypes: !0 });
|
|
3188
|
-
for (const
|
|
3189
|
-
const W = n.join(k,
|
|
3190
|
-
|
|
3198
|
+
for (const F of D) {
|
|
3199
|
+
const W = n.join(k, F.name), _ = n.join(L, F.name);
|
|
3200
|
+
F.isDirectory() ? N(W, _) : C.push(_);
|
|
3191
3201
|
}
|
|
3192
3202
|
} catch {
|
|
3193
3203
|
}
|
|
@@ -3197,21 +3207,21 @@ dist/
|
|
|
3197
3207
|
for (const L of k)
|
|
3198
3208
|
if (L.isDirectory() && L.name.startsWith(".")) {
|
|
3199
3209
|
const D = n.join(L.name, "skills");
|
|
3200
|
-
e.existsSync(D) &&
|
|
3210
|
+
e.existsSync(D) && N(D, D);
|
|
3201
3211
|
}
|
|
3202
3212
|
} catch {
|
|
3203
3213
|
}
|
|
3204
3214
|
}
|
|
3205
|
-
for (const
|
|
3206
|
-
await
|
|
3207
|
-
await
|
|
3215
|
+
for (const N of C)
|
|
3216
|
+
await M.add({ fs: e, dir: j, filepath: N });
|
|
3217
|
+
await M.commit({
|
|
3208
3218
|
fs: e,
|
|
3209
3219
|
dir: j,
|
|
3210
3220
|
message: "init",
|
|
3211
3221
|
author: { name: "myop-cli", email: "cli@myop.dev" }
|
|
3212
3222
|
}), console.log("✅ Initialized git repository");
|
|
3213
|
-
} catch (
|
|
3214
|
-
console.log("⚠️ Failed to initialize git repository:",
|
|
3223
|
+
} catch (C) {
|
|
3224
|
+
console.log("⚠️ Failed to initialize git repository:", C.message);
|
|
3215
3225
|
}
|
|
3216
3226
|
console.log(`
|
|
3217
3227
|
📦 Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
@@ -3227,11 +3237,11 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
3227
3237
|
}
|
|
3228
3238
|
if (v.program.getOptionValue("ci")) {
|
|
3229
3239
|
const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), d = Pe();
|
|
3230
|
-
let
|
|
3240
|
+
let w = { found: !1 };
|
|
3231
3241
|
try {
|
|
3232
3242
|
if (p.existsSync(m)) {
|
|
3233
|
-
const
|
|
3234
|
-
|
|
3243
|
+
const $ = p.readFileSync(m, "utf-8"), g = JSON.parse($);
|
|
3244
|
+
w = {
|
|
3235
3245
|
found: !0,
|
|
3236
3246
|
path: m,
|
|
3237
3247
|
name: g.name || g.componentName || null,
|
|
@@ -3239,18 +3249,18 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
3239
3249
|
organization: g.organization || null
|
|
3240
3250
|
};
|
|
3241
3251
|
}
|
|
3242
|
-
} catch (
|
|
3243
|
-
|
|
3252
|
+
} catch ($) {
|
|
3253
|
+
w = { found: !1, error: $.message };
|
|
3244
3254
|
}
|
|
3245
|
-
const
|
|
3255
|
+
const x = {
|
|
3246
3256
|
version: l,
|
|
3247
|
-
config:
|
|
3257
|
+
config: w,
|
|
3248
3258
|
auth: {
|
|
3249
3259
|
loggedIn: !!(d != null && d.email),
|
|
3250
3260
|
email: (d == null ? void 0 : d.email) || null
|
|
3251
3261
|
}
|
|
3252
3262
|
};
|
|
3253
|
-
console.log(JSON.stringify(
|
|
3263
|
+
console.log(JSON.stringify(x, null, 2)), process.exit(0);
|
|
3254
3264
|
}
|
|
3255
3265
|
let n = z({
|
|
3256
3266
|
text: "Loading Myop CLI...",
|