@myop/cli 0.1.47 β 0.1.48
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 +384 -379
- package/dist/skills/myop-component/SKILL.md +47 -18
- package/dist/skills/myop-component/references/component-api.md +0 -28
- package/dist/skills/myop-component/references/sizing-and-layout.md +41 -71
- package/dist/skills/myop-component/references/type-definitions.md +2 -19
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -111,11 +111,11 @@ Examples:
|
|
|
111
111
|
name: "π’ Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
114
|
-
},
|
|
114
|
+
}, Ot = {
|
|
115
115
|
name: "π΅ Create new experience",
|
|
116
116
|
value: "-",
|
|
117
117
|
disabled: "(not available yet)"
|
|
118
|
-
},
|
|
118
|
+
}, kt = {
|
|
119
119
|
name: "π‘ Create new skin",
|
|
120
120
|
value: "-",
|
|
121
121
|
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
|
-
}, jt = [Tt, It,
|
|
131
|
+
}, jt = [Tt, It, Ot, kt, Rt];
|
|
132
132
|
function Ft(o, t, e, n) {
|
|
133
133
|
return `<!DOCTYPE html>
|
|
134
134
|
<html lang="en">
|
|
@@ -244,9 +244,9 @@ function Lt(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, d,
|
|
247
|
+
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, d, u) => {
|
|
248
248
|
if (i) {
|
|
249
|
-
console.error("β npm install failed:", i.message),
|
|
249
|
+
console.error("β npm install failed:", i.message), u && console.error(u), t(!1);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
console.log(` β Dependencies reinstalled successfully!
|
|
@@ -259,16 +259,16 @@ async function at(o, t, e, n, s = {}) {
|
|
|
259
259
|
const {
|
|
260
260
|
hasTriedPlatformFix: i = !1,
|
|
261
261
|
hasTriedInstall: d = !1,
|
|
262
|
-
onRetry:
|
|
263
|
-
} = s,
|
|
264
|
-
return !i && _t(
|
|
265
|
-
`),
|
|
266
|
-
n("npm install", (l,
|
|
262
|
+
onRetry: u
|
|
263
|
+
} = s, h = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
|
|
264
|
+
return !i && _t(h) ? (At(), await Lt(n) && u ? (console.log(`π Retrying build...
|
|
265
|
+
`), u(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && Nt(h) ? (console.log("π¦ Missing dependencies detected, running npm install..."), new Promise((c) => {
|
|
266
|
+
n("npm install", (l, x, y) => {
|
|
267
267
|
if (l) {
|
|
268
|
-
console.error("β Failed to install dependencies:", l.message),
|
|
268
|
+
console.error("β Failed to install dependencies:", l.message), y && console.error(y), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
console.log("β
Dependencies installed"),
|
|
271
|
+
console.log("β
Dependencies installed"), u && u(), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
272
272
|
});
|
|
273
273
|
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: d };
|
|
274
274
|
}
|
|
@@ -280,8 +280,8 @@ async function xe() {
|
|
|
280
280
|
i = t.default.dirname(m);
|
|
281
281
|
} else
|
|
282
282
|
i = t.default.dirname(import.meta.url);
|
|
283
|
-
const d = t.default.join(i, "commands", "dev", "management-website"),
|
|
284
|
-
let
|
|
283
|
+
const d = t.default.join(i, "commands", "dev", "management-website"), u = o.default.readFileSync(t.default.join(d, "styles.css"), "utf-8"), h = o.default.readFileSync(t.default.join(d, "app.js"), "utf-8"), c = 9292, l = 9293;
|
|
284
|
+
let x = "./dist", y = !1, $ = !1, g = !1, w = null;
|
|
285
285
|
const j = () => {
|
|
286
286
|
try {
|
|
287
287
|
const a = o.default.readdirSync(".").filter((r) => !r.endsWith(".html") || r.startsWith(".") ? !1 : o.default.statSync(r).isFile());
|
|
@@ -290,33 +290,33 @@ async function xe() {
|
|
|
290
290
|
} catch {
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
|
-
},
|
|
293
|
+
}, O = () => {
|
|
294
294
|
try {
|
|
295
295
|
const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
|
|
296
296
|
return !!(a.scripts && a.scripts.build);
|
|
297
297
|
} catch {
|
|
298
298
|
return !1;
|
|
299
299
|
}
|
|
300
|
-
},
|
|
300
|
+
}, P = (a) => {
|
|
301
301
|
const r = process.platform;
|
|
302
302
|
let m;
|
|
303
303
|
r === "darwin" ? m = `open "${a}"` : r === "win32" ? m = `start "" "${a}"` : m = `xdg-open "${a}"`, e(m, (f) => {
|
|
304
304
|
});
|
|
305
305
|
}, p = /* @__PURE__ */ new Map(), E = v.program.getOptionValue("config") || "./myop.config.json";
|
|
306
|
-
let
|
|
306
|
+
let b, k, R = !1;
|
|
307
307
|
w = j();
|
|
308
|
-
const D =
|
|
308
|
+
const D = O();
|
|
309
309
|
try {
|
|
310
310
|
const a = o.default.readFileSync(E, "utf-8"), r = JSON.parse(a);
|
|
311
|
-
|
|
311
|
+
b = r.componentId || "DEV", k = r.componentName || r.name || null, R = r.HMR === !0, w && !D && (g = !0, R = !0, console.log(`π Single HTML file mode: ${w}`)), R && console.log("π₯ HMR enabled");
|
|
312
312
|
} catch (a) {
|
|
313
|
-
w && !D ? (g = !0,
|
|
313
|
+
w && !D ? (g = !0, b = "DEV", k = t.default.basename(w, ".html"), R = !0, console.log(`π Single HTML file mode: ${w}`), console.log("π₯ HMR enabled")) : (console.error("β Error reading myop.config.json:", a.message), process.exit(1));
|
|
314
314
|
}
|
|
315
315
|
const L = async () => {
|
|
316
|
-
if (
|
|
317
|
-
return
|
|
316
|
+
if (b !== "DEV" && b !== "NEW")
|
|
317
|
+
return b;
|
|
318
318
|
try {
|
|
319
|
-
const r = ((await new Promise((S,
|
|
319
|
+
const r = ((await new Promise((S, C) => {
|
|
320
320
|
const I = {
|
|
321
321
|
hostname: "localhost",
|
|
322
322
|
port: l,
|
|
@@ -341,8 +341,8 @@ async function xe() {
|
|
|
341
341
|
return "DEV1";
|
|
342
342
|
const m = r.map((S) => {
|
|
343
343
|
if (S === "DEV" || S === "NEW") return 1;
|
|
344
|
-
const
|
|
345
|
-
return
|
|
344
|
+
const C = S.match(/^DEV(\d+)$/), I = S.match(/^NEW(\d+)$/);
|
|
345
|
+
return C ? parseInt(C[1], 10) : I ? parseInt(I[1], 10) : 0;
|
|
346
346
|
}).filter((S) => S > 0);
|
|
347
347
|
return `DEV${Math.max(...m, 0) + 1}`;
|
|
348
348
|
} catch {
|
|
@@ -363,12 +363,12 @@ async function xe() {
|
|
|
363
363
|
}[r] || "application/octet-stream";
|
|
364
364
|
}, F = /* @__PURE__ */ new Map(), V = [], te = 50, z = [], Q = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map(), ut = (a, r, m) => {
|
|
365
365
|
if (a.url.startsWith("/_hmr/")) {
|
|
366
|
-
const f = a.url.split("/_hmr/")[1], S = a.headers["sec-websocket-key"],
|
|
366
|
+
const f = a.url.split("/_hmr/")[1], S = a.headers["sec-websocket-key"], C = s("sha1").update(S + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
367
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: ${C}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
374
|
), oe.has(f) || oe.set(f, /* @__PURE__ */ new Set()), oe.get(f).add(r), console.log(`π HMR client connected: ${f}`), r.on("close", () => {
|
|
@@ -384,9 +384,9 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
384
384
|
let m = "";
|
|
385
385
|
a.on("data", (f) => m += f), a.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId: f, distPath: S, componentName:
|
|
388
|
-
F.set(f, { path: S, name:
|
|
389
|
-
const N =
|
|
387
|
+
const { componentId: f, distPath: S, componentName: C, htmlFile: I } = JSON.parse(m);
|
|
388
|
+
F.set(f, { path: S, name: C || null, htmlFile: I || null });
|
|
389
|
+
const N = C ? ` (${C})` : "";
|
|
390
390
|
console.log(`β
Registered: ${f}${N} -> ${S}${I ? "/" + I : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(F.keys()) }));
|
|
391
391
|
const U = Array.from(F.entries()).map(([K, ne]) => ({
|
|
392
392
|
id: K,
|
|
@@ -414,14 +414,14 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
414
414
|
try {
|
|
415
415
|
const { componentId: f } = JSON.parse(m);
|
|
416
416
|
F.delete(f), console.log(`β Unregistered: ${f}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
|
|
417
|
-
const S = Array.from(F.entries()).map(([
|
|
418
|
-
id:
|
|
417
|
+
const S = Array.from(F.entries()).map(([C, I]) => ({
|
|
418
|
+
id: C,
|
|
419
419
|
path: I.path,
|
|
420
420
|
name: I.name
|
|
421
421
|
}));
|
|
422
|
-
z.forEach((
|
|
422
|
+
z.forEach((C) => {
|
|
423
423
|
try {
|
|
424
|
-
|
|
424
|
+
C.write(`data: ${JSON.stringify({
|
|
425
425
|
type: "components",
|
|
426
426
|
components: S
|
|
427
427
|
})}
|
|
@@ -440,17 +440,17 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
440
440
|
let m = "";
|
|
441
441
|
a.on("data", (f) => m += f), a.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId: f, html: S } = JSON.parse(m),
|
|
444
|
-
if (
|
|
445
|
-
console.log(`π₯ Notifying ${
|
|
443
|
+
const { componentId: f, html: S } = JSON.parse(m), C = oe.get(f);
|
|
444
|
+
if (C && C.size > 0) {
|
|
445
|
+
console.log(`π₯ Notifying ${C.size} HMR client(s) for: ${f}`);
|
|
446
446
|
const I = JSON.stringify({ type: "update", html: S }), N = Ye(I);
|
|
447
|
-
|
|
447
|
+
C.forEach((U) => {
|
|
448
448
|
try {
|
|
449
449
|
U.write(N);
|
|
450
450
|
} catch {
|
|
451
|
-
|
|
451
|
+
C.delete(U);
|
|
452
452
|
}
|
|
453
|
-
}), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified:
|
|
453
|
+
}), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: C.size }));
|
|
454
454
|
} else
|
|
455
455
|
r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
|
|
456
456
|
} catch (f) {
|
|
@@ -492,12 +492,12 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
492
492
|
const B = a.socket.remoteAddress;
|
|
493
493
|
B === "::1" || B === "::ffff:127.0.0.1" ? (H = "localhost", q = "localhost (direct)") : (H = B, q = B.replace("::ffff:", ""));
|
|
494
494
|
}
|
|
495
|
-
const
|
|
495
|
+
const ke = a.headers.referer || a.headers.referrer || H, he = {
|
|
496
496
|
type: "request",
|
|
497
497
|
componentId: W,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
499
|
servedLocally: se,
|
|
500
|
-
referrer:
|
|
500
|
+
referrer: ke,
|
|
501
501
|
origin: H,
|
|
502
502
|
originLabel: q
|
|
503
503
|
};
|
|
@@ -544,7 +544,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
544
544
|
console.log(`β File not found: ${se}`), 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 ke = Me(q, W), he = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Re = {
|
|
548
548
|
item: {
|
|
549
549
|
name: W,
|
|
550
550
|
id: W,
|
|
@@ -555,7 +555,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
557
557
|
shadowRootMode: "localFrame",
|
|
558
|
-
HTML:
|
|
558
|
+
HTML: ke
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
]
|
|
@@ -614,7 +614,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
616
|
if (S.length === 0) {
|
|
617
|
-
r.writeHead(200, { "Content-Type": "text/html" }), r.end(Ft(c, l,
|
|
617
|
+
r.writeHead(200, { "Content-Type": "text/html" }), r.end(Ft(c, l, u, h));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
620
|
if (S[0] !== "view") {
|
|
@@ -625,9 +625,9 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
625
625
|
r.writeHead(400, { "Content-Type": "text/plain" }), r.end("Component ID required. Use /view/<componentId>/");
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
const
|
|
628
|
+
const C = S[1], I = F.get(C);
|
|
629
629
|
if (!I) {
|
|
630
|
-
r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${
|
|
630
|
+
r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${C}`);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
633
|
const N = I.path, U = S.slice(2), K = I.htmlFile || "index.html", ne = U.length === 0 ? K : U.join("/"), le = t.default.join(N, ne);
|
|
@@ -641,7 +641,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
641
641
|
let ce = G;
|
|
642
642
|
if (Z === "text/html" && R) {
|
|
643
643
|
const se = G.toString("utf-8");
|
|
644
|
-
ce = Me(se,
|
|
644
|
+
ce = Me(se, C);
|
|
645
645
|
}
|
|
646
646
|
r.writeHead(200, {
|
|
647
647
|
"Content-Type": Z,
|
|
@@ -649,10 +649,10 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
649
649
|
}), r.end(ce);
|
|
650
650
|
});
|
|
651
651
|
}), Ge = () => new Promise((a, r) => {
|
|
652
|
-
const m = g ? t.default.resolve(T) : t.default.resolve(T,
|
|
653
|
-
componentId:
|
|
652
|
+
const m = g ? t.default.resolve(T) : t.default.resolve(T, x), f = JSON.stringify({
|
|
653
|
+
componentId: b,
|
|
654
654
|
distPath: m,
|
|
655
|
-
componentName:
|
|
655
|
+
componentName: k,
|
|
656
656
|
htmlFile: g ? w : null
|
|
657
657
|
}), S = {
|
|
658
658
|
hostname: "localhost",
|
|
@@ -663,15 +663,15 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
664
|
"Content-Length": Buffer.byteLength(f)
|
|
665
665
|
}
|
|
666
|
-
},
|
|
666
|
+
}, C = n.default.request(S, (I) => {
|
|
667
667
|
let N = "";
|
|
668
668
|
I.on("data", (U) => N += U), I.on("end", () => {
|
|
669
669
|
I.statusCode === 200 ? a(JSON.parse(N)) : r(new Error(`Registration failed: ${I.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
|
-
|
|
672
|
+
C.on("error", r), C.write(f), C.end();
|
|
673
673
|
}), gt = () => new Promise((a, r) => {
|
|
674
|
-
const m = JSON.stringify({ componentId:
|
|
674
|
+
const m = JSON.stringify({ componentId: b }), f = {
|
|
675
675
|
hostname: "localhost",
|
|
676
676
|
port: l,
|
|
677
677
|
path: "/_unregister",
|
|
@@ -680,7 +680,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
681
|
"Content-Length": Buffer.byteLength(m)
|
|
682
682
|
}
|
|
683
|
-
}, S = n.default.request(f, (
|
|
683
|
+
}, S = n.default.request(f, (C) => {
|
|
684
684
|
a();
|
|
685
685
|
});
|
|
686
686
|
S.on("error", () => a()), S.write(m), S.end();
|
|
@@ -815,17 +815,17 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
815
815
|
]), f;
|
|
816
816
|
}, Ke = () => {
|
|
817
817
|
if (!R) return;
|
|
818
|
-
const a = g ? w : t.default.join(
|
|
818
|
+
const a = g ? w : t.default.join(x, "index.html");
|
|
819
819
|
let r;
|
|
820
820
|
try {
|
|
821
821
|
const m = o.default.readFileSync(a, "utf-8");
|
|
822
|
-
r = Me(m,
|
|
822
|
+
r = Me(m, b);
|
|
823
823
|
} catch (m) {
|
|
824
824
|
console.error("β Failed to read HTML for HMR:", m.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (
|
|
828
|
-
const m = oe.get(
|
|
827
|
+
if (Oe) {
|
|
828
|
+
const m = oe.get(b);
|
|
829
829
|
if (!m || m.size === 0)
|
|
830
830
|
return;
|
|
831
831
|
console.log(`π₯ Notifying ${m.size} HMR client(s)`);
|
|
@@ -833,16 +833,16 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
833
833
|
type: "update",
|
|
834
834
|
html: r
|
|
835
835
|
}), S = Ye(f);
|
|
836
|
-
m.forEach((
|
|
836
|
+
m.forEach((C) => {
|
|
837
837
|
try {
|
|
838
|
-
|
|
838
|
+
C.write(S);
|
|
839
839
|
} catch {
|
|
840
|
-
m.delete(
|
|
840
|
+
m.delete(C);
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
} else {
|
|
844
844
|
const m = JSON.stringify({
|
|
845
|
-
componentId:
|
|
845
|
+
componentId: b,
|
|
846
846
|
html: r
|
|
847
847
|
}), f = {
|
|
848
848
|
hostname: "localhost",
|
|
@@ -854,9 +854,9 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
854
854
|
"Content-Length": Buffer.byteLength(m)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
}, S = n.default.request(f, (
|
|
857
|
+
}, S = n.default.request(f, (C) => {
|
|
858
858
|
let I = "";
|
|
859
|
-
|
|
859
|
+
C.on("data", (N) => I += N), C.on("end", () => {
|
|
860
860
|
try {
|
|
861
861
|
const N = JSON.parse(I);
|
|
862
862
|
N.notified > 0 && console.log(`π₯ Notified ${N.notified} HMR client(s) via server`);
|
|
@@ -872,13 +872,13 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
872
872
|
};
|
|
873
873
|
let Ee = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
874
|
const ge = (a) => {
|
|
875
|
-
if (
|
|
876
|
-
|
|
875
|
+
if (y) {
|
|
876
|
+
$ = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
|
-
|
|
879
|
+
y = !0, console.log(`
|
|
880
880
|
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, m, f) => {
|
|
881
|
-
if (
|
|
881
|
+
if (y = !1, r) {
|
|
882
882
|
const S = await at(r, m, f, e, {
|
|
883
883
|
...Ee,
|
|
884
884
|
onRetry: () => ge(a)
|
|
@@ -886,7 +886,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
886
886
|
Ee = { ...Ee, ...S }, S.handled || (console.error("β Build failed:", r.message), f && console.error(f));
|
|
887
887
|
} else
|
|
888
888
|
console.log("β
Build completed"), m && console.log(m), Ke(), a && a();
|
|
889
|
-
|
|
889
|
+
$ && ($ = !1, ge());
|
|
890
890
|
});
|
|
891
891
|
}, Qe = /* @__PURE__ */ new Set(), Ie = (a) => {
|
|
892
892
|
o.default.readdir(a, { withFileTypes: !0 }, (r, m) => {
|
|
@@ -895,8 +895,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
895
895
|
if (f.isDirectory())
|
|
896
896
|
f.name !== "node_modules" && f.name !== "dist" && !f.name.startsWith(".") && Ie(S);
|
|
897
897
|
else if (f.isFile()) {
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
898
|
+
const C = t.default.extname(f.name);
|
|
899
|
+
if (C === ".js" || C === ".css" || C === ".html")
|
|
900
900
|
try {
|
|
901
901
|
const I = o.default.readFileSync(S, "utf-8");
|
|
902
902
|
p.set(S, I);
|
|
@@ -905,8 +905,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
905
905
|
}
|
|
906
906
|
}), Qe.has(a) || (Qe.add(a), o.default.watch(a, (f, S) => {
|
|
907
907
|
if (!S) return;
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
908
|
+
const C = t.default.extname(S);
|
|
909
|
+
if (C !== ".js" && C !== ".css" && C !== ".html") return;
|
|
910
910
|
const I = t.default.join(a, S);
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
@@ -919,7 +919,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
919
919
|
});
|
|
920
920
|
}, Ze = (a) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
π¨ Component: ${
|
|
922
|
+
π¨ Component: ${b}`), g ? (console.log("π No build needed (single HTML file mode)"), Ie(T), console.log(`π Watching ${w} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
923
|
`), a && a()) : (ge(a), Ie(T), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
925
|
}, ht = () => new Promise((a) => {
|
|
@@ -939,24 +939,24 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
939
939
|
const r = n.default.createServer((m, f) => {
|
|
940
940
|
if (f.setHeader("Content-Type", "application/json"), m.method === "POST" && m.url === "/_register") {
|
|
941
941
|
let S = "";
|
|
942
|
-
m.on("data", (
|
|
942
|
+
m.on("data", (C) => S += C), m.on("end", () => {
|
|
943
943
|
try {
|
|
944
|
-
const { componentId:
|
|
945
|
-
F.set(
|
|
944
|
+
const { componentId: C, distPath: I, componentName: N, htmlFile: U } = JSON.parse(S);
|
|
945
|
+
F.set(C, { path: I, name: N || null, htmlFile: U || null });
|
|
946
946
|
const K = N ? ` (${N})` : "";
|
|
947
|
-
console.log(`β
Registered: ${
|
|
948
|
-
} catch (
|
|
949
|
-
f.writeHead(400), f.end(JSON.stringify({ error:
|
|
947
|
+
console.log(`β
Registered: ${C}${K} -> ${I}${U ? "/" + U : ""}`), f.writeHead(200), f.end(JSON.stringify({ success: !0, registered: Array.from(F.keys()) }));
|
|
948
|
+
} catch (C) {
|
|
949
|
+
f.writeHead(400), f.end(JSON.stringify({ error: C.message }));
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
952
|
} else if (m.method === "POST" && m.url === "/_unregister") {
|
|
953
953
|
let S = "";
|
|
954
|
-
m.on("data", (
|
|
954
|
+
m.on("data", (C) => S += C), m.on("end", () => {
|
|
955
955
|
try {
|
|
956
|
-
const { componentId:
|
|
957
|
-
F.delete(
|
|
958
|
-
} catch (
|
|
959
|
-
f.writeHead(400), f.end(JSON.stringify({ error:
|
|
956
|
+
const { componentId: C } = JSON.parse(S);
|
|
957
|
+
F.delete(C), console.log(`β Unregistered: ${C}`), f.writeHead(200), f.end(JSON.stringify({ success: !0 }));
|
|
958
|
+
} catch (C) {
|
|
959
|
+
f.writeHead(400), f.end(JSON.stringify({ error: C.message }));
|
|
960
960
|
}
|
|
961
961
|
});
|
|
962
962
|
} else m.method === "GET" && m.url === "/_list" ? (f.writeHead(200), f.end(JSON.stringify({ components: Array.from(F.entries()) }))) : (f.writeHead(404), f.end(JSON.stringify({ error: "Not found" })));
|
|
@@ -969,14 +969,14 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
969
969
|
r.close(), a(!1);
|
|
970
970
|
}), ue.listen(c, () => {
|
|
971
971
|
console.log(`π‘ Main server running at http://localhost:${c}`);
|
|
972
|
-
const m = g ? t.default.resolve(T) : t.default.resolve(T,
|
|
973
|
-
F.set(
|
|
972
|
+
const m = g ? t.default.resolve(T) : t.default.resolve(T, x);
|
|
973
|
+
F.set(b, {
|
|
974
974
|
path: m,
|
|
975
|
-
name:
|
|
975
|
+
name: k,
|
|
976
976
|
htmlFile: g ? w : null
|
|
977
977
|
});
|
|
978
|
-
const f =
|
|
979
|
-
console.log(`β
Registered component: ${
|
|
978
|
+
const f = k ? ` (${k})` : "";
|
|
979
|
+
console.log(`β
Registered component: ${b}${f}`), console.log(`π‘ Access at: http://localhost:${c}/view/${b}/`), a(!0);
|
|
980
980
|
});
|
|
981
981
|
});
|
|
982
982
|
});
|
|
@@ -984,9 +984,9 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
984
984
|
const qe = () => {
|
|
985
985
|
fe = setInterval(async () => {
|
|
986
986
|
await ht() || (clearInterval(fe), console.log(`
|
|
987
|
-
β οΈ Server appears to be down, attempting to take over...`), await yt() ? (console.log("β
Successfully took over as server"),
|
|
987
|
+
β οΈ Server appears to be down, attempting to take over...`), await yt() ? (console.log("β
Successfully took over as server"), Oe = !0) : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
988
|
try {
|
|
989
|
-
await Ge(), console.log(`β
Re-registered component: ${
|
|
989
|
+
await Ge(), console.log(`β
Re-registered component: ${b}`), qe();
|
|
990
990
|
} catch (m) {
|
|
991
991
|
console.error("β Failed to re-register:", m.message);
|
|
992
992
|
}
|
|
@@ -998,16 +998,16 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
998
998
|
π Shutting down...`), fe && clearInterval(fe), await gt(), process.exit(0);
|
|
999
999
|
};
|
|
1000
1000
|
process.on("SIGINT", Xe), process.on("SIGTERM", Xe);
|
|
1001
|
-
let
|
|
1001
|
+
let Oe = !1;
|
|
1002
1002
|
Pe.on("error", async (a) => {
|
|
1003
1003
|
if (a.code === "EADDRINUSE") {
|
|
1004
1004
|
console.log(`
|
|
1005
1005
|
π Connecting to existing dev server...`);
|
|
1006
1006
|
try {
|
|
1007
|
-
|
|
1007
|
+
b = await L();
|
|
1008
1008
|
const r = await Ge();
|
|
1009
|
-
console.log(`β
Registered component: ${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1009
|
+
console.log(`β
Registered component: ${b}`), console.log(`π‘ Access at: http://localhost:${c}/view/${b}/`), console.log(`π All registered components: ${r.registered.join(", ")}`), Ze(() => {
|
|
1010
|
+
process.env.MYOP_NO_BROWSER || P(`http://localhost:${c}/view/${b}/`);
|
|
1011
1011
|
}), qe();
|
|
1012
1012
|
} catch (r) {
|
|
1013
1013
|
console.error("β Failed to register component:", r.message), process.exit(1);
|
|
@@ -1015,20 +1015,20 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
1015
1015
|
} else
|
|
1016
1016
|
console.error("β Management server error:", a.message), process.exit(1);
|
|
1017
1017
|
}), Pe.on("upgrade", ut), Pe.listen(l, async () => {
|
|
1018
|
-
|
|
1018
|
+
Oe = !0, console.log(`
|
|
1019
1019
|
π Starting shared dev server...`), console.log(`π‘ Management server on port ${l}`), ue.on("error", (a) => {
|
|
1020
1020
|
console.error("β Main server error:", a.message), process.exit(1);
|
|
1021
1021
|
}), ue.listen(c, async () => {
|
|
1022
|
-
console.log(`π‘ Main server running at http://localhost:${c}`), (
|
|
1023
|
-
const a = g ? t.default.resolve(T) : t.default.resolve(T,
|
|
1024
|
-
F.set(
|
|
1022
|
+
console.log(`π‘ Main server running at http://localhost:${c}`), (b === "DEV" || b === "NEW") && (b = "DEV1");
|
|
1023
|
+
const a = g ? t.default.resolve(T) : t.default.resolve(T, x);
|
|
1024
|
+
F.set(b, {
|
|
1025
1025
|
path: a,
|
|
1026
|
-
name:
|
|
1026
|
+
name: k,
|
|
1027
1027
|
htmlFile: g ? w : null
|
|
1028
1028
|
});
|
|
1029
|
-
const r =
|
|
1030
|
-
console.log(`β
Registered component: ${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1029
|
+
const r = k ? ` (${k})` : "";
|
|
1030
|
+
console.log(`β
Registered component: ${b}${r}`), console.log(`π‘ Access at: http://localhost:${c}/view/${b}/`), Ze(() => {
|
|
1031
|
+
process.env.MYOP_NO_BROWSER || P(`http://localhost:${c}/view/${b}/`);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
});
|
|
@@ -1083,13 +1083,13 @@ 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), d = 2,
|
|
1086
|
+
const s = Math.ceil(t / n), i = Math.floor(this.cols / n), d = 2, h = this.rows - d - 2, c = Math.floor(h / s);
|
|
1087
1087
|
this.visibleLogLines = Math.max(2, c - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: c }, this.panelPositions.clear();
|
|
1088
1088
|
for (let l = 0; l < t; l++) {
|
|
1089
|
-
const
|
|
1090
|
-
this.panelPositions.set(
|
|
1091
|
-
row: d + 1 +
|
|
1092
|
-
col:
|
|
1089
|
+
const x = this.components[l], y = Math.floor(l / n), $ = l % n;
|
|
1090
|
+
this.panelPositions.set(x.name, {
|
|
1091
|
+
row: d + 1 + y * c,
|
|
1092
|
+
col: $ * i + 1,
|
|
1093
1093
|
width: i,
|
|
1094
1094
|
height: c
|
|
1095
1095
|
});
|
|
@@ -1139,33 +1139,33 @@ const A = class A {
|
|
|
1139
1139
|
renderPanel(t) {
|
|
1140
1140
|
const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
|
|
1141
1141
|
if (!s) return;
|
|
1142
|
-
const i = this.components.findIndex((L) => L.name === t), d = this.components[i],
|
|
1143
|
-
let
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
const p = (d.path || "").substring(0,
|
|
1142
|
+
const i = this.components.findIndex((L) => L.name === t), d = this.components[i], u = i === this.selectedPanel, h = this.statusKeys.get(t) || "initializing", c = n[h], l = e[c.color], x = this.logs.get(t) || [], y = this.scrollPos.get(t) || 0, $ = s.width - 1, g = u ? e.cyan : e.gray, w = [], j = d.name.substring(0, $ - 20);
|
|
1143
|
+
let O = `${g}ββ${e.reset} ${l}${c.icon}${e.reset} `;
|
|
1144
|
+
O += `${e.bold}${j}${e.reset} ${e.gray}β${e.reset} ${l}${c.label}${e.reset} `;
|
|
1145
|
+
const P = 5 + j.length + c.label.length + 3;
|
|
1146
|
+
O += `${g}${"β".repeat(Math.max(0, $ - P))}β${e.reset}`, w.push(A.ESC.moveTo(s.row, s.col) + O);
|
|
1147
|
+
const p = (d.path || "").substring(0, $ - 6);
|
|
1148
1148
|
let E = `${g}β${e.reset} ${e.dim}${p}${e.reset}`;
|
|
1149
|
-
E += " ".repeat(Math.max(0,
|
|
1150
|
-
const
|
|
1151
|
-
let R = `${g}β${"β".repeat(
|
|
1152
|
-
|
|
1153
|
-
const D =
|
|
1149
|
+
E += " ".repeat(Math.max(0, $ - p.length - 3)), E += `${g}β${e.reset}`, w.push(A.ESC.moveTo(s.row + 1, s.col) + E);
|
|
1150
|
+
const b = x.length, k = b > this.visibleLogLines ? `${y + 1}-${Math.min(y + this.visibleLogLines, b)}/${b}` : "";
|
|
1151
|
+
let R = `${g}β${"β".repeat($ - k.length - 4)}${e.reset}`;
|
|
1152
|
+
k && (R += `${e.dim}${k}${e.reset}`), R += `${g}${"β".repeat(2)}β€${e.reset}`, w.push(A.ESC.moveTo(s.row + 2, s.col) + R);
|
|
1153
|
+
const D = x.slice(y, y + this.visibleLogLines);
|
|
1154
1154
|
for (let L = 0; L < this.visibleLogLines; L++) {
|
|
1155
1155
|
const T = D[L];
|
|
1156
1156
|
let J = `${g}β${e.reset}`;
|
|
1157
1157
|
if (T) {
|
|
1158
1158
|
let F = e.white;
|
|
1159
1159
|
T.type === "success" ? F = e.green : T.type === "error" ? F = e.red : T.type === "warning" ? F = e.yellow : T.type === "hmr" ? F = e.magenta : T.type === "change" && (F = e.blue);
|
|
1160
|
-
const V = T.message.substring(0,
|
|
1160
|
+
const V = T.message.substring(0, $ - 12);
|
|
1161
1161
|
J += `${e.dim}${T.timestamp}${e.reset} ${F}${V}${e.reset}`;
|
|
1162
|
-
const te =
|
|
1162
|
+
const te = $ - T.timestamp.length - V.length - 2;
|
|
1163
1163
|
J += " ".repeat(Math.max(0, te));
|
|
1164
1164
|
} else
|
|
1165
|
-
J += " ".repeat(
|
|
1165
|
+
J += " ".repeat($ - 2);
|
|
1166
1166
|
J += `${g}β${e.reset}`, w.push(A.ESC.moveTo(s.row + 3 + L, s.col) + J);
|
|
1167
1167
|
}
|
|
1168
|
-
w.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}β${"β".repeat(
|
|
1168
|
+
w.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}β${"β".repeat($ - 2)}β${e.reset}`), process.stdout.write(w.join(""));
|
|
1169
1169
|
}
|
|
1170
1170
|
fullRender() {
|
|
1171
1171
|
const t = A.C;
|
|
@@ -1230,12 +1230,12 @@ async function Dt(o) {
|
|
|
1230
1230
|
name: l.name,
|
|
1231
1231
|
path: l.path,
|
|
1232
1232
|
id: l.componentId || ""
|
|
1233
|
-
})), i = new Ne(s), d = [],
|
|
1234
|
-
const
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1233
|
+
})), i = new Ne(s), d = [], u = (l) => {
|
|
1234
|
+
const x = process.platform;
|
|
1235
|
+
let y;
|
|
1236
|
+
x === "darwin" ? y = `open "${l}"` : x === "win32" ? y = `start "" "${l}"` : y = `xdg-open "${l}"`, e(y, () => {
|
|
1237
1237
|
});
|
|
1238
|
-
},
|
|
1238
|
+
}, h = () => {
|
|
1239
1239
|
i.clear(), console.log(`
|
|
1240
1240
|
π Shutting down all components...`), d.forEach((l) => {
|
|
1241
1241
|
try {
|
|
@@ -1244,40 +1244,40 @@ async function Dt(o) {
|
|
|
1244
1244
|
}
|
|
1245
1245
|
}), setTimeout(() => process.exit(0), 500);
|
|
1246
1246
|
};
|
|
1247
|
-
process.on("SIGINT",
|
|
1247
|
+
process.on("SIGINT", h), process.on("SIGTERM", h);
|
|
1248
1248
|
const c = process.argv[1];
|
|
1249
1249
|
for (let l = 0; l < o.length; l++) {
|
|
1250
|
-
const
|
|
1251
|
-
i.setStatus(
|
|
1252
|
-
const
|
|
1253
|
-
cwd: n.default.resolve(
|
|
1250
|
+
const x = o[l], y = x.name;
|
|
1251
|
+
i.setStatus(y, "β³ Starting..."), i.log(y, `Starting in ${x.path}`);
|
|
1252
|
+
const $ = t("node", [c, "dev"], {
|
|
1253
|
+
cwd: n.default.resolve(x.path),
|
|
1254
1254
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1255
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1256
|
});
|
|
1257
|
-
d.push(
|
|
1257
|
+
d.push($);
|
|
1258
1258
|
let g = "";
|
|
1259
|
-
|
|
1259
|
+
$.stdout.on("data", (w) => {
|
|
1260
1260
|
g += w.toString();
|
|
1261
1261
|
const j = g.split(`
|
|
1262
1262
|
`);
|
|
1263
1263
|
g = j.pop() || "";
|
|
1264
|
-
for (const
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1264
|
+
for (const O of j) {
|
|
1265
|
+
const P = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1266
|
+
P && (P.includes("Registered component") || P.includes("Registered:") ? i.setStatus(y, "β
Ready") : P.includes("Building...") || P.includes("Running initial build") ? i.setStatus(y, "π¨ Building...") : P.includes("Build completed") || P.includes("Build succeeded") ? i.setStatus(y, "β
Ready") : P.includes("Build failed") ? i.setStatus(y, "β Build Error") : P.includes("File changed") ? (i.setStatus(y, "π Changed"), setTimeout(() => i.setStatus(y, "β
Ready"), 1500)) : P.includes("Notifying") && P.includes("HMR") ? (i.setStatus(y, "π₯ HMR Update"), setTimeout(() => i.setStatus(y, "β
Ready"), 1e3)) : P.includes("HMR client connected") && (i.setStatus(y, "π₯ HMR Connected"), setTimeout(() => i.setStatus(y, "β
Ready"), 1e3)), !P.includes("Watching") && !P.includes("Press Ctrl+C") && !P.includes("Starting shared") && !P.includes("Management server") && !P.includes("Main server") && !P.includes("Access at:") && !P.includes("No build needed") && i.log(y, P));
|
|
1267
1267
|
}
|
|
1268
|
-
}),
|
|
1268
|
+
}), $.stderr.on("data", (w) => {
|
|
1269
1269
|
const j = w.toString().split(`
|
|
1270
1270
|
`);
|
|
1271
|
-
for (const
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1271
|
+
for (const O of j) {
|
|
1272
|
+
const P = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1273
|
+
P && (i.log(y, `β οΈ ${P}`), i.setStatus(y, "β οΈ Warning"));
|
|
1274
1274
|
}
|
|
1275
|
-
}),
|
|
1276
|
-
w !== 0 && w !== null && (i.setStatus(
|
|
1275
|
+
}), $.on("exit", (w) => {
|
|
1276
|
+
w !== 0 && w !== null && (i.setStatus(y, `β Exited (${w})`), i.log(y, `Process exited with code ${w}`));
|
|
1277
1277
|
}), l < o.length - 1 && await new Promise((w) => setTimeout(w, 500));
|
|
1278
1278
|
}
|
|
1279
1279
|
i.render(), setTimeout(() => {
|
|
1280
|
-
|
|
1280
|
+
u("http://localhost:9292");
|
|
1281
1281
|
}, 2e3);
|
|
1282
1282
|
}
|
|
1283
1283
|
const Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -1371,7 +1371,7 @@ function we(o, t, e, n = null) {
|
|
|
1371
1371
|
success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
|
|
1372
1372
|
error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
|
|
1373
1373
|
warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
|
|
1374
|
-
}, { accent: d, glow:
|
|
1374
|
+
}, { accent: d, glow: u } = i[o] || i.error;
|
|
1375
1375
|
return `<!DOCTYPE html>
|
|
1376
1376
|
<html lang="en">
|
|
1377
1377
|
<head>
|
|
@@ -1464,7 +1464,7 @@ function we(o, t, e, n = null) {
|
|
|
1464
1464
|
display: inline-flex;
|
|
1465
1465
|
align-items: center;
|
|
1466
1466
|
gap: 8px;
|
|
1467
|
-
background: ${
|
|
1467
|
+
background: ${u};
|
|
1468
1468
|
border: 1px solid ${d}33;
|
|
1469
1469
|
border-radius: 4px;
|
|
1470
1470
|
padding: 10px 16px;
|
|
@@ -1524,7 +1524,7 @@ function Gt(o) {
|
|
|
1524
1524
|
const n = bt.createServer((s, i) => {
|
|
1525
1525
|
const d = new tt(s.url, `http://localhost:${Se}`);
|
|
1526
1526
|
if (d.pathname === "/callback") {
|
|
1527
|
-
const
|
|
1527
|
+
const u = d.searchParams.get("code"), h = d.searchParams.get("state"), c = d.searchParams.get("error");
|
|
1528
1528
|
if (c) {
|
|
1529
1529
|
i.writeHead(200, { "Content-Type": "text/html" }), i.end(we(
|
|
1530
1530
|
"error",
|
|
@@ -1534,7 +1534,7 @@ function Gt(o) {
|
|
|
1534
1534
|
)), n.close(), e(new Error(`OAuth error: ${c}`));
|
|
1535
1535
|
return;
|
|
1536
1536
|
}
|
|
1537
|
-
if (
|
|
1537
|
+
if (h !== o) {
|
|
1538
1538
|
i.writeHead(400, { "Content-Type": "text/html" }), i.end(we(
|
|
1539
1539
|
"warning",
|
|
1540
1540
|
"Security Error",
|
|
@@ -1543,7 +1543,7 @@ function Gt(o) {
|
|
|
1543
1543
|
)), n.close(), e(new Error("State mismatch"));
|
|
1544
1544
|
return;
|
|
1545
1545
|
}
|
|
1546
|
-
if (!
|
|
1546
|
+
if (!u) {
|
|
1547
1547
|
i.writeHead(400, { "Content-Type": "text/html" }), i.end(we(
|
|
1548
1548
|
"error",
|
|
1549
1549
|
"Missing Authorization Code",
|
|
@@ -1556,7 +1556,7 @@ function Gt(o) {
|
|
|
1556
1556
|
"success",
|
|
1557
1557
|
"Authentication Successful",
|
|
1558
1558
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1559
|
-
)), n.close(), t(
|
|
1559
|
+
)), n.close(), t(u);
|
|
1560
1560
|
} else
|
|
1561
1561
|
i.writeHead(404), i.end("Not found");
|
|
1562
1562
|
});
|
|
@@ -1635,15 +1635,15 @@ async function de() {
|
|
|
1635
1635
|
o.text = "Registering OAuth client...";
|
|
1636
1636
|
const e = (await Vt()).client_id, n = zt(), s = Wt(n), i = He.randomBytes(16).toString("hex");
|
|
1637
1637
|
o.text = "Waiting for authorization...";
|
|
1638
|
-
const d = Gt(i),
|
|
1639
|
-
|
|
1640
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1641
|
-
`), await Ct(
|
|
1642
|
-
const
|
|
1638
|
+
const d = Gt(i), u = new tt(`${ae}/oauth/authorize`);
|
|
1639
|
+
u.searchParams.set("response_type", "code"), u.searchParams.set("client_id", e), u.searchParams.set("redirect_uri", Je), u.searchParams.set("code_challenge", s), u.searchParams.set("code_challenge_method", "S256"), u.searchParams.set("state", i), o.stop(), console.log(`
|
|
1640
|
+
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${u.toString()}
|
|
1641
|
+
`), await Ct(u.toString());
|
|
1642
|
+
const h = await d;
|
|
1643
1643
|
o.start("Exchanging authorization code...");
|
|
1644
|
-
const c = await Yt(
|
|
1644
|
+
const c = await Yt(h, e, n);
|
|
1645
1645
|
o.text = "Getting user info...";
|
|
1646
|
-
const l = await Qt(c.access_token),
|
|
1646
|
+
const l = await Qt(c.access_token), x = {
|
|
1647
1647
|
accessToken: c.access_token,
|
|
1648
1648
|
refreshToken: c.refresh_token,
|
|
1649
1649
|
expiresAt: new Date(Date.now() + c.expires_in * 1e3).toISOString(),
|
|
@@ -1651,7 +1651,7 @@ async function de() {
|
|
|
1651
1651
|
userId: l.userId,
|
|
1652
1652
|
userEmail: l.email
|
|
1653
1653
|
};
|
|
1654
|
-
return lt(
|
|
1654
|
+
return lt(x), o.succeed(`Authenticated as ${l.email}`), x;
|
|
1655
1655
|
} catch (t) {
|
|
1656
1656
|
throw o.fail(`Authentication failed: ${t.message}`), t;
|
|
1657
1657
|
}
|
|
@@ -1781,15 +1781,15 @@ Please run manually: ${l}
|
|
|
1781
1781
|
`), process.exit(1);
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
-
let
|
|
1784
|
+
let u = null;
|
|
1785
1785
|
try {
|
|
1786
|
-
let
|
|
1787
|
-
d ?
|
|
1788
|
-
const c = Te(
|
|
1789
|
-
|
|
1786
|
+
let h;
|
|
1787
|
+
d ? h = je ? Te(d, "node_modules") : Te(d, "lib", "node_modules") : h = X("npm root -g", { encoding: "utf-8" }).trim();
|
|
1788
|
+
const c = Te(h, ee, "package.json"), l = $t(c, "utf-8");
|
|
1789
|
+
u = JSON.parse(l).version;
|
|
1790
1790
|
} catch {
|
|
1791
1791
|
}
|
|
1792
|
-
if (
|
|
1792
|
+
if (u === e)
|
|
1793
1793
|
return console.log(`
|
|
1794
1794
|
π Restarting...
|
|
1795
1795
|
`), xt(process.argv[0], process.argv.slice(1), {
|
|
@@ -1832,7 +1832,7 @@ function Fe({ id: o, name: t }) {
|
|
|
1832
1832
|
no({ defaultOrganization: { id: o, name: t } });
|
|
1833
1833
|
}
|
|
1834
1834
|
async function io(o, t, e, n = {}) {
|
|
1835
|
-
var
|
|
1835
|
+
var u, h, c;
|
|
1836
1836
|
const s = await fetch(`${o}/mcp`, {
|
|
1837
1837
|
method: "POST",
|
|
1838
1838
|
headers: {
|
|
@@ -1854,7 +1854,7 @@ async function io(o, t, e, n = {}) {
|
|
|
1854
1854
|
const i = await s.json();
|
|
1855
1855
|
if (i.error)
|
|
1856
1856
|
throw new Error(i.error.message || "MCP error");
|
|
1857
|
-
const d = (c = (
|
|
1857
|
+
const d = (c = (h = (u = i.result) == null ? void 0 : u.content) == null ? void 0 : h[0]) == null ? void 0 : c.text;
|
|
1858
1858
|
if (!d)
|
|
1859
1859
|
throw new Error(`No content returned from ${e}`);
|
|
1860
1860
|
return JSON.parse(d);
|
|
@@ -1885,8 +1885,8 @@ const ro = (o) => new Promise((t) => setTimeout(t, o)), ao = () => {
|
|
|
1885
1885
|
{ deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
|
|
1886
1886
|
], i = s.filter(({ deps: c }) => c.some((l) => e.includes(l))).map(({ skill: c }) => c), d = s.flatMap(({ deps: c }) => c.filter((l) => e.includes(l)));
|
|
1887
1887
|
i.length > 0 ? n.push(...i) : n.push(...s.map((c) => c.skill));
|
|
1888
|
-
const
|
|
1889
|
-
return X(
|
|
1888
|
+
const u = n.map((c) => `--skill ${c}`).join(" "), h = `npx -y skills add "${t}" ${u} --agent '*' --copy -y`;
|
|
1889
|
+
return X(h, { cwd: o, stdio: "pipe" }), { success: !0, detected: d, skillNames: n };
|
|
1890
1890
|
} catch (e) {
|
|
1891
1891
|
return console.info("Failed to install skills:", e.message), { success: !1 };
|
|
1892
1892
|
}
|
|
@@ -1903,13 +1903,13 @@ const ro = (o) => new Promise((t) => setTimeout(t, o)), ao = () => {
|
|
|
1903
1903
|
n.push(...Ve(d, t, e + 1));
|
|
1904
1904
|
} else if (i.name === "myop.config.json")
|
|
1905
1905
|
try {
|
|
1906
|
-
const
|
|
1906
|
+
const u = M.readFileSync(d, "utf-8"), h = JSON.parse(u);
|
|
1907
1907
|
n.push({
|
|
1908
1908
|
path: o,
|
|
1909
1909
|
configPath: d,
|
|
1910
|
-
name:
|
|
1911
|
-
componentId:
|
|
1912
|
-
config:
|
|
1910
|
+
name: h.name || h.componentName || _.basename(o),
|
|
1911
|
+
componentId: h.componentId || null,
|
|
1912
|
+
config: h
|
|
1913
1913
|
});
|
|
1914
1914
|
} catch {
|
|
1915
1915
|
}
|
|
@@ -1949,7 +1949,7 @@ const Ce = (o = !1) => {
|
|
|
1949
1949
|
new _e(),
|
|
1950
1950
|
...jt
|
|
1951
1951
|
];
|
|
1952
|
-
const co = "0.1.
|
|
1952
|
+
const co = "0.1.48";
|
|
1953
1953
|
v.program = new vt();
|
|
1954
1954
|
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(co);
|
|
1955
1955
|
v.program.addOption(new me("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
@@ -1993,7 +1993,7 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
|
|
|
1993
1993
|
process.exit(0);
|
|
1994
1994
|
});
|
|
1995
1995
|
v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
|
|
1996
|
-
var
|
|
1996
|
+
var $, g, w, j, O, P;
|
|
1997
1997
|
const t = v.program.getOptionValue("config") || "./myop.config.json";
|
|
1998
1998
|
let e = {};
|
|
1999
1999
|
if (M.existsSync(t))
|
|
@@ -2023,7 +2023,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2023
2023
|
else if (i) {
|
|
2024
2024
|
const { exec: p } = await import("child_process");
|
|
2025
2025
|
let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
2026
|
-
const
|
|
2026
|
+
const b = (R = !1) => new Promise((D) => {
|
|
2027
2027
|
const L = Y(R ? "Retrying build..." : "Building project...").start();
|
|
2028
2028
|
p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (T, J, F) => {
|
|
2029
2029
|
if (!T) {
|
|
@@ -2033,7 +2033,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2033
2033
|
if (L.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
|
|
2034
2034
|
const V = await at(T, J, F, p, E);
|
|
2035
2035
|
if (E = { ...E, ...V }, V.handled) {
|
|
2036
|
-
const te = await
|
|
2036
|
+
const te = await b(!0);
|
|
2037
2037
|
D(te);
|
|
2038
2038
|
return;
|
|
2039
2039
|
}
|
|
@@ -2041,7 +2041,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2041
2041
|
console.error(T.message), D(!1);
|
|
2042
2042
|
});
|
|
2043
2043
|
});
|
|
2044
|
-
await
|
|
2044
|
+
await b() || process.exit(1);
|
|
2045
2045
|
}
|
|
2046
2046
|
let d;
|
|
2047
2047
|
if (s)
|
|
@@ -2054,22 +2054,22 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2054
2054
|
);
|
|
2055
2055
|
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));
|
|
2056
2056
|
}
|
|
2057
|
-
const
|
|
2058
|
-
console.log(` File: ${d} (${(
|
|
2059
|
-
let
|
|
2057
|
+
const u = M.readFileSync(d, "utf-8");
|
|
2058
|
+
console.log(` File: ${d} (${(u.length / 1024).toFixed(1)} KB)`);
|
|
2059
|
+
let h;
|
|
2060
2060
|
try {
|
|
2061
|
-
|
|
2061
|
+
h = await ze();
|
|
2062
2062
|
} catch (p) {
|
|
2063
2063
|
console.error("β Authentication failed:", p.message), process.exit(1);
|
|
2064
2064
|
}
|
|
2065
2065
|
const c = be();
|
|
2066
|
-
let l = Y("Uploading...").start(),
|
|
2066
|
+
let l = Y("Uploading...").start(), x;
|
|
2067
2067
|
try {
|
|
2068
2068
|
const p = await fetch(`${c}/mcp`, {
|
|
2069
2069
|
method: "POST",
|
|
2070
2070
|
headers: {
|
|
2071
2071
|
"Content-Type": "application/json",
|
|
2072
|
-
Authorization: `Bearer ${
|
|
2072
|
+
Authorization: `Bearer ${h.accessToken}`
|
|
2073
2073
|
},
|
|
2074
2074
|
body: JSON.stringify({
|
|
2075
2075
|
jsonrpc: "2.0",
|
|
@@ -2090,43 +2090,43 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2090
2090
|
const E = await p.json();
|
|
2091
2091
|
if (E.error)
|
|
2092
2092
|
throw new Error(E.error.message);
|
|
2093
|
-
const
|
|
2094
|
-
if (
|
|
2095
|
-
throw new Error(
|
|
2093
|
+
const b = (w = (g = ($ = E.result) == null ? void 0 : $.content) == null ? void 0 : g[0]) == null ? void 0 : w.text;
|
|
2094
|
+
if (x = JSON.parse(b), !x.success)
|
|
2095
|
+
throw new Error(x.error);
|
|
2096
2096
|
} catch (p) {
|
|
2097
2097
|
l.fail("Failed to get upload URL"), console.error(" ", p.message), process.exit(1);
|
|
2098
2098
|
}
|
|
2099
2099
|
try {
|
|
2100
2100
|
let p;
|
|
2101
|
-
const E =
|
|
2101
|
+
const E = x.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
2102
2102
|
if (E)
|
|
2103
2103
|
p = E[1];
|
|
2104
2104
|
else {
|
|
2105
|
-
const
|
|
2106
|
-
if (
|
|
2107
|
-
p =
|
|
2105
|
+
const k = x.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
2106
|
+
if (k)
|
|
2107
|
+
p = k[1];
|
|
2108
2108
|
else
|
|
2109
2109
|
throw new Error("Could not parse presigned URL");
|
|
2110
2110
|
}
|
|
2111
|
-
const
|
|
2111
|
+
const b = await fetch(p, {
|
|
2112
2112
|
method: "PUT",
|
|
2113
2113
|
headers: { "Content-Type": "text/html" },
|
|
2114
|
-
body:
|
|
2114
|
+
body: u
|
|
2115
2115
|
});
|
|
2116
|
-
if (!
|
|
2117
|
-
const
|
|
2118
|
-
throw new Error(`Upload failed: ${
|
|
2116
|
+
if (!b.ok) {
|
|
2117
|
+
const k = await b.text();
|
|
2118
|
+
throw new Error(`Upload failed: ${b.status} ${k}`);
|
|
2119
2119
|
}
|
|
2120
2120
|
} catch (p) {
|
|
2121
2121
|
l.fail("Upload failed"), console.error(" ", p.message), process.exit(1);
|
|
2122
2122
|
}
|
|
2123
|
-
let
|
|
2123
|
+
let y;
|
|
2124
2124
|
try {
|
|
2125
2125
|
const p = await fetch(`${c}/mcp`, {
|
|
2126
2126
|
method: "POST",
|
|
2127
2127
|
headers: {
|
|
2128
2128
|
"Content-Type": "application/json",
|
|
2129
|
-
Authorization: `Bearer ${
|
|
2129
|
+
Authorization: `Bearer ${h.accessToken}`
|
|
2130
2130
|
},
|
|
2131
2131
|
body: JSON.stringify({
|
|
2132
2132
|
jsonrpc: "2.0",
|
|
@@ -2135,7 +2135,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2135
2135
|
params: {
|
|
2136
2136
|
name: "confirm_upload",
|
|
2137
2137
|
arguments: {
|
|
2138
|
-
uploadId:
|
|
2138
|
+
uploadId: x.uploadId
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
2141
|
})
|
|
@@ -2145,27 +2145,27 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2145
2145
|
const E = await p.json();
|
|
2146
2146
|
if (E.error)
|
|
2147
2147
|
throw new Error(E.error.message);
|
|
2148
|
-
const
|
|
2149
|
-
if (
|
|
2150
|
-
throw new Error(
|
|
2148
|
+
const b = (P = (O = (j = E.result) == null ? void 0 : j.content) == null ? void 0 : O[0]) == null ? void 0 : P.text;
|
|
2149
|
+
if (y = JSON.parse(b), !y.success)
|
|
2150
|
+
throw new Error(y.error);
|
|
2151
2151
|
l.succeed("Pushed successfully");
|
|
2152
2152
|
} catch (p) {
|
|
2153
2153
|
l.fail("Confirmation failed"), console.error(" ", p.message), process.exit(1);
|
|
2154
2154
|
}
|
|
2155
|
-
if (
|
|
2156
|
-
e.componentId =
|
|
2155
|
+
if (y.isNewComponent || !e.componentId || e.componentId === "DEV") {
|
|
2156
|
+
e.componentId = y.componentId, e.organization = y.orgId, e.name || (e.name = y.componentName);
|
|
2157
2157
|
try {
|
|
2158
2158
|
M.writeFileSync(t, JSON.stringify(e, null, 2));
|
|
2159
2159
|
} catch (p) {
|
|
2160
|
-
console.log(`β οΈ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${
|
|
2160
|
+
console.log(`β οΈ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
2163
|
console.log(`
|
|
2164
|
-
${
|
|
2164
|
+
${y.componentName}`), console.log(` ${y.dashboardUrl}
|
|
2165
2165
|
`), process.exit(0);
|
|
2166
2166
|
});
|
|
2167
2167
|
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)").action(async (o, t) => {
|
|
2168
|
-
var w, j,
|
|
2168
|
+
var w, j, O;
|
|
2169
2169
|
const e = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2170
2170
|
let n = {};
|
|
2171
2171
|
if (M.existsSync(e))
|
|
@@ -2181,13 +2181,13 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2181
2181
|
let d;
|
|
2182
2182
|
try {
|
|
2183
2183
|
d = await ze();
|
|
2184
|
-
} catch (
|
|
2185
|
-
console.error("β Authentication failed:",
|
|
2184
|
+
} catch (P) {
|
|
2185
|
+
console.error("β Authentication failed:", P.message), process.exit(1);
|
|
2186
2186
|
}
|
|
2187
|
-
const
|
|
2187
|
+
const u = be(), h = Y("Fetching component...").start();
|
|
2188
2188
|
let c;
|
|
2189
2189
|
try {
|
|
2190
|
-
const
|
|
2190
|
+
const P = await fetch(`${u}/mcp`, {
|
|
2191
2191
|
method: "POST",
|
|
2192
2192
|
headers: {
|
|
2193
2193
|
"Content-Type": "application/json",
|
|
@@ -2203,25 +2203,25 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2203
2203
|
}
|
|
2204
2204
|
})
|
|
2205
2205
|
});
|
|
2206
|
-
if (!
|
|
2207
|
-
throw new Error(`Server returned ${
|
|
2208
|
-
const p = await
|
|
2206
|
+
if (!P.ok)
|
|
2207
|
+
throw new Error(`Server returned ${P.status}`);
|
|
2208
|
+
const p = await P.json();
|
|
2209
2209
|
if (p.error)
|
|
2210
2210
|
throw new Error(p.error.message);
|
|
2211
|
-
const E = (
|
|
2211
|
+
const E = (O = (j = (w = p.result) == null ? void 0 : w.content) == null ? void 0 : j[0]) == null ? void 0 : O.text;
|
|
2212
2212
|
if (c = JSON.parse(E), !c.success && !c.html)
|
|
2213
2213
|
throw new Error(c.error || "No HTML content returned");
|
|
2214
|
-
|
|
2215
|
-
} catch (
|
|
2216
|
-
|
|
2214
|
+
h.succeed("Component fetched");
|
|
2215
|
+
} catch (P) {
|
|
2216
|
+
h.fail("Failed to fetch component"), console.error(" ", P.message), process.exit(1);
|
|
2217
2217
|
}
|
|
2218
2218
|
let l = t.output;
|
|
2219
2219
|
l || (M.existsSync("./dist/index.html") ? l = "./dist/index.html" : l = "./index.html");
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
const
|
|
2220
|
+
const x = c.htmlContent || c.html, y = _.dirname(l);
|
|
2221
|
+
y && !M.existsSync(y) && M.mkdirSync(y, { recursive: !0 }), M.writeFileSync(l, x), console.log(` Saved to: ${l} (${(x.length / 1024).toFixed(1)} KB)`);
|
|
2222
|
+
const $ = M.existsSync(e);
|
|
2223
2223
|
let g = !1;
|
|
2224
|
-
if (
|
|
2224
|
+
if ($ ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && c.name && (n.name = c.name, g = !0)) : (n = {
|
|
2225
2225
|
name: c.name || _.basename(process.cwd()),
|
|
2226
2226
|
componentId: s,
|
|
2227
2227
|
type: "html",
|
|
@@ -2229,9 +2229,9 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2229
2229
|
HMR: !0
|
|
2230
2230
|
}, g = !0), g)
|
|
2231
2231
|
try {
|
|
2232
|
-
M.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${
|
|
2233
|
-
} catch (
|
|
2234
|
-
console.log(` β οΈ Could not write ${e}: ${
|
|
2232
|
+
M.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${$ ? "Updated" : "Created"} ${e}`);
|
|
2233
|
+
} catch (P) {
|
|
2234
|
+
console.log(` β οΈ Could not write ${e}: ${P.message}`);
|
|
2235
2235
|
}
|
|
2236
2236
|
console.log(`
|
|
2237
2237
|
β
Pull completed!
|
|
@@ -2246,35 +2246,35 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2246
2246
|
console.error("Authentication failed:", g.message), process.exit(1);
|
|
2247
2247
|
}
|
|
2248
2248
|
const s = be(), i = (g, w) => io(s, n.accessToken, g, w);
|
|
2249
|
-
let d = Y("Loading organizations...").start(),
|
|
2249
|
+
let d = Y("Loading organizations...").start(), u;
|
|
2250
2250
|
try {
|
|
2251
2251
|
const g = await i("list_organizations");
|
|
2252
|
-
if (
|
|
2252
|
+
if (u = g.organizations || g, !Array.isArray(u))
|
|
2253
2253
|
throw new Error("Unexpected response from list_organizations");
|
|
2254
2254
|
} catch (g) {
|
|
2255
2255
|
d.fail("Failed to load organizations"), console.error(" ", g.message), process.exit(1);
|
|
2256
2256
|
}
|
|
2257
|
-
|
|
2258
|
-
let
|
|
2257
|
+
u.length === 0 && (d.fail("No organizations found for this account"), process.exit(1)), d.stop();
|
|
2258
|
+
let h, c;
|
|
2259
2259
|
if (o.org) {
|
|
2260
|
-
const g =
|
|
2261
|
-
g || (console.error(`Organization "${o.org}" not found. Available:`),
|
|
2260
|
+
const g = u.find((w) => w.id === o.org || w._id === o.org);
|
|
2261
|
+
g || (console.error(`Organization "${o.org}" not found. Available:`), u.forEach((w) => console.log(` ${w.id || w._id} ${w.name}`)), process.exit(1)), h = g.id || g._id, c = g.name, Fe({ id: h, name: c });
|
|
2262
2262
|
} else {
|
|
2263
2263
|
const g = so();
|
|
2264
|
-
if (g &&
|
|
2265
|
-
|
|
2266
|
-
else if (
|
|
2267
|
-
|
|
2264
|
+
if (g && u.find((w) => (w.id || w._id) === g.id))
|
|
2265
|
+
h = g.id, c = g.name;
|
|
2266
|
+
else if (u.length === 1)
|
|
2267
|
+
h = u[0].id || u[0]._id, c = u[0].name, Fe({ id: h, name: c });
|
|
2268
2268
|
else
|
|
2269
2269
|
try {
|
|
2270
2270
|
const w = await e({
|
|
2271
2271
|
message: "Select an organization:",
|
|
2272
|
-
choices:
|
|
2272
|
+
choices: u.map((j) => ({
|
|
2273
2273
|
name: j.name,
|
|
2274
2274
|
value: { id: j.id || j._id, name: j.name }
|
|
2275
2275
|
}))
|
|
2276
2276
|
});
|
|
2277
|
-
|
|
2277
|
+
h = w.id, c = w.name, Fe({ id: h, name: c });
|
|
2278
2278
|
} catch (w) {
|
|
2279
2279
|
throw w.name === "ExitPromptError" && (console.log(`
|
|
2280
2280
|
|
|
@@ -2285,7 +2285,7 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2285
2285
|
console.log(` Using organization: ${c}`), d = Y("Loading components...").start();
|
|
2286
2286
|
let l;
|
|
2287
2287
|
try {
|
|
2288
|
-
const g = await i("list_components", { organizationId:
|
|
2288
|
+
const g = await i("list_components", { organizationId: h });
|
|
2289
2289
|
if (l = g.components || g, !Array.isArray(l))
|
|
2290
2290
|
throw new Error("Unexpected response from list_components");
|
|
2291
2291
|
} catch (g) {
|
|
@@ -2294,28 +2294,28 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2294
2294
|
d.stop(), l.length === 0 && (console.log(` No components found in this organization.
|
|
2295
2295
|
`), process.exit(0)), console.log(` ${c} - ${l.length} component(s)
|
|
2296
2296
|
`);
|
|
2297
|
-
const
|
|
2297
|
+
const x = [];
|
|
2298
2298
|
for (; ; ) {
|
|
2299
|
-
const g = `[Done - pull/push ${
|
|
2300
|
-
let
|
|
2299
|
+
const g = `[Done - pull/push ${x.length} selected]`, w = "__done__", j = new Set(x.map((p) => p.id || p._id || p.componentId));
|
|
2300
|
+
let O;
|
|
2301
2301
|
try {
|
|
2302
|
-
|
|
2302
|
+
O = await t({
|
|
2303
2303
|
message: "Search & select components:",
|
|
2304
2304
|
source: (p) => {
|
|
2305
|
-
const E = (p || "").toLowerCase(),
|
|
2305
|
+
const E = (p || "").toLowerCase(), b = l.filter((R) => {
|
|
2306
2306
|
const D = R.id || R._id || R.componentId;
|
|
2307
2307
|
return j.has(D) ? !1 : E ? (R.name || "").toLowerCase().includes(E) : !0;
|
|
2308
|
-
}),
|
|
2308
|
+
}), k = [
|
|
2309
2309
|
{ name: g, value: w }
|
|
2310
2310
|
];
|
|
2311
|
-
for (const R of
|
|
2311
|
+
for (const R of b) {
|
|
2312
2312
|
const D = R.id || R._id || R.componentId, L = D ? D.substring(0, 8) + "..." : "";
|
|
2313
|
-
|
|
2313
|
+
k.push({
|
|
2314
2314
|
name: `${R.name} (${L})`,
|
|
2315
2315
|
value: D
|
|
2316
2316
|
});
|
|
2317
2317
|
}
|
|
2318
|
-
return
|
|
2318
|
+
return k;
|
|
2319
2319
|
}
|
|
2320
2320
|
});
|
|
2321
2321
|
} catch (p) {
|
|
@@ -2324,17 +2324,17 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2324
2324
|
π Goodbye!
|
|
2325
2325
|
`), process.exit(0)), p;
|
|
2326
2326
|
}
|
|
2327
|
-
if (
|
|
2327
|
+
if (O === w)
|
|
2328
2328
|
break;
|
|
2329
|
-
const
|
|
2330
|
-
|
|
2329
|
+
const P = l.find((p) => (p.id || p._id || p.componentId) === O);
|
|
2330
|
+
P && (x.push(P), console.log(` + ${P.name}`));
|
|
2331
2331
|
}
|
|
2332
|
-
|
|
2332
|
+
x.length === 0 && (console.log(` No components selected.
|
|
2333
2333
|
`), process.exit(0));
|
|
2334
|
-
let
|
|
2334
|
+
let y;
|
|
2335
2335
|
try {
|
|
2336
|
-
|
|
2337
|
-
message: `${
|
|
2336
|
+
y = await e({
|
|
2337
|
+
message: `${x.length} component(s) selected:`,
|
|
2338
2338
|
choices: [
|
|
2339
2339
|
{ name: "Pull selected", value: "pull" },
|
|
2340
2340
|
{ name: "Push selected", value: "push" },
|
|
@@ -2347,67 +2347,67 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2347
2347
|
π Goodbye!
|
|
2348
2348
|
`), process.exit(0)), g;
|
|
2349
2349
|
}
|
|
2350
|
-
|
|
2350
|
+
y === "cancel" && (console.log(` Cancelled.
|
|
2351
2351
|
`), process.exit(0));
|
|
2352
|
-
const
|
|
2353
|
-
if (
|
|
2352
|
+
const $ = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
2353
|
+
if (y === "pull") {
|
|
2354
2354
|
console.log(`
|
|
2355
|
-
Pulling ${
|
|
2355
|
+
Pulling ${x.length} components...
|
|
2356
2356
|
`);
|
|
2357
|
-
const g = await Promise.all(
|
|
2358
|
-
const
|
|
2357
|
+
const g = await Promise.all(x.map(async (O) => {
|
|
2358
|
+
const P = O.id || O._id || O.componentId;
|
|
2359
2359
|
try {
|
|
2360
|
-
const p = await i("get_component", { componentId:
|
|
2360
|
+
const p = await i("get_component", { componentId: P }), E = $(O.name);
|
|
2361
2361
|
M.mkdirSync(E, { recursive: !0 });
|
|
2362
|
-
const
|
|
2363
|
-
if (!
|
|
2362
|
+
const b = p.htmlContent || p.html;
|
|
2363
|
+
if (!b)
|
|
2364
2364
|
throw new Error("No HTML content returned");
|
|
2365
|
-
return M.writeFileSync(_.join(E, "index.html"),
|
|
2366
|
-
name:
|
|
2367
|
-
componentId:
|
|
2368
|
-
organization:
|
|
2365
|
+
return M.writeFileSync(_.join(E, "index.html"), b), M.writeFileSync(_.join(E, "myop.config.json"), JSON.stringify({
|
|
2366
|
+
name: O.name,
|
|
2367
|
+
componentId: P,
|
|
2368
|
+
organization: h,
|
|
2369
2369
|
type: "html",
|
|
2370
2370
|
author: "@myop-cli",
|
|
2371
2371
|
HMR: !0
|
|
2372
|
-
}, null, 2)), { name:
|
|
2372
|
+
}, null, 2)), { name: O.name, status: "ok", dir: E };
|
|
2373
2373
|
} catch (p) {
|
|
2374
|
-
return { name:
|
|
2374
|
+
return { name: O.name, status: "failed", error: p.message };
|
|
2375
2375
|
}
|
|
2376
2376
|
}));
|
|
2377
2377
|
let w = 0, j = 0;
|
|
2378
|
-
for (const
|
|
2379
|
-
|
|
2378
|
+
for (const O of g)
|
|
2379
|
+
O.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${O.name} -> ./${O.dir}/`), w++) : (console.log(` \x1B[31mβ\x1B[0m ${O.name} - ${O.error}`), j++);
|
|
2380
2380
|
console.log(`
|
|
2381
2381
|
Done! Pulled ${w} component${w !== 1 ? "s" : ""}.${j ? ` ${j} failed.` : ""}
|
|
2382
2382
|
`);
|
|
2383
|
-
} else if (
|
|
2383
|
+
} else if (y === "push") {
|
|
2384
2384
|
console.log(`
|
|
2385
|
-
Pushing ${
|
|
2385
|
+
Pushing ${x.length} components...
|
|
2386
2386
|
`);
|
|
2387
|
-
const g = Ve(".", 3), w = await Promise.all(
|
|
2388
|
-
const E = p.id || p._id || p.componentId,
|
|
2389
|
-
if (!
|
|
2387
|
+
const g = Ve(".", 3), w = await Promise.all(x.map(async (p) => {
|
|
2388
|
+
const E = p.id || p._id || p.componentId, b = g.find((k) => k.componentId === E);
|
|
2389
|
+
if (!b)
|
|
2390
2390
|
return { name: p.name, status: "skipped", reason: "no local match" };
|
|
2391
2391
|
try {
|
|
2392
|
-
let
|
|
2393
|
-
const R =
|
|
2392
|
+
let k;
|
|
2393
|
+
const R = b.path;
|
|
2394
2394
|
if (M.existsSync(_.join(R, "dist", "index.html")))
|
|
2395
|
-
|
|
2395
|
+
k = _.join(R, "dist", "index.html");
|
|
2396
2396
|
else {
|
|
2397
2397
|
const z = M.readdirSync(R).filter(
|
|
2398
2398
|
(Q) => Q.endsWith(".html") && !Q.startsWith(".") && M.statSync(_.join(R, Q)).isFile()
|
|
2399
2399
|
);
|
|
2400
2400
|
if (z.length === 1)
|
|
2401
|
-
|
|
2401
|
+
k = _.join(R, z[0]);
|
|
2402
2402
|
else if (z.includes("index.html"))
|
|
2403
|
-
|
|
2403
|
+
k = _.join(R, "index.html");
|
|
2404
2404
|
else
|
|
2405
2405
|
throw new Error("No HTML file found");
|
|
2406
2406
|
}
|
|
2407
|
-
const D = M.readFileSync(
|
|
2407
|
+
const D = M.readFileSync(k, "utf-8"), L = b.name || p.name, T = await i("upload_component", {
|
|
2408
2408
|
name: L,
|
|
2409
2409
|
componentId: E,
|
|
2410
|
-
organization:
|
|
2410
|
+
organization: h
|
|
2411
2411
|
});
|
|
2412
2412
|
if (!T.success)
|
|
2413
2413
|
throw new Error(T.error || "Upload request failed");
|
|
@@ -2435,15 +2435,15 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2435
2435
|
if (!te.success)
|
|
2436
2436
|
throw new Error(te.error || "Confirmation failed");
|
|
2437
2437
|
return { name: L, status: "ok" };
|
|
2438
|
-
} catch (
|
|
2439
|
-
return { name: p.name, status: "failed", error:
|
|
2438
|
+
} catch (k) {
|
|
2439
|
+
return { name: p.name, status: "failed", error: k.message };
|
|
2440
2440
|
}
|
|
2441
2441
|
}));
|
|
2442
|
-
let j = 0,
|
|
2442
|
+
let j = 0, O = 0, P = 0;
|
|
2443
2443
|
for (const p of w)
|
|
2444
|
-
p.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${p.name}`), j++) : p.status === "skipped" ? (console.log(` \x1B[33mβ\x1B[0m ${p.name} (${p.reason})`),
|
|
2444
|
+
p.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${p.name}`), j++) : p.status === "skipped" ? (console.log(` \x1B[33mβ\x1B[0m ${p.name} (${p.reason})`), O++) : (console.log(` \x1B[31mβ\x1B[0m ${p.name} - ${p.error}`), P++);
|
|
2445
2445
|
console.log(`
|
|
2446
|
-
Done! Pushed ${j}${
|
|
2446
|
+
Done! Pushed ${j}${O ? `, skipped ${O}` : ""}${P ? `, ${P} failed` : ""}.
|
|
2447
2447
|
`);
|
|
2448
2448
|
}
|
|
2449
2449
|
process.exit(0);
|
|
@@ -2456,11 +2456,11 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2456
2456
|
message: "Component name:",
|
|
2457
2457
|
default: n
|
|
2458
2458
|
});
|
|
2459
|
-
} catch (
|
|
2460
|
-
throw
|
|
2459
|
+
} catch (h) {
|
|
2460
|
+
throw h.name === "ExitPromptError" && (console.log(`
|
|
2461
2461
|
|
|
2462
2462
|
π Goodbye!
|
|
2463
|
-
`), process.exit(0)),
|
|
2463
|
+
`), process.exit(0)), h;
|
|
2464
2464
|
}
|
|
2465
2465
|
(t.existsSync("index.html") || t.existsSync("myop.config.json")) && (console.log(`
|
|
2466
2466
|
β οΈ 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));
|
|
@@ -2595,9 +2595,9 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2595
2595
|
</body>
|
|
2596
2596
|
</html>`;
|
|
2597
2597
|
t.writeFileSync("index.html", d);
|
|
2598
|
-
const
|
|
2598
|
+
const u = await We(process.cwd());
|
|
2599
2599
|
console.log(`
|
|
2600
|
-
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"),
|
|
2600
|
+
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), u.success && console.log(" AI agent skills installed"), console.log(""), await xe();
|
|
2601
2601
|
});
|
|
2602
2602
|
v.program.command("dev").description("Start development server with file watching").action(xe);
|
|
2603
2603
|
const mt = async () => {
|
|
@@ -2675,20 +2675,20 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2675
2675
|
π Goodbye!
|
|
2676
2676
|
`), process.exit(0)), l;
|
|
2677
2677
|
}
|
|
2678
|
-
const
|
|
2679
|
-
let
|
|
2678
|
+
const u = i.find((l) => l.value === d);
|
|
2679
|
+
let h = {};
|
|
2680
2680
|
try {
|
|
2681
|
-
const l = M.readFileSync(
|
|
2682
|
-
|
|
2681
|
+
const l = M.readFileSync(u.configPath, "utf-8");
|
|
2682
|
+
h = JSON.parse(l);
|
|
2683
2683
|
} catch {
|
|
2684
2684
|
}
|
|
2685
|
-
|
|
2686
|
-
const c =
|
|
2685
|
+
h.mcpServers || (h.mcpServers = {});
|
|
2686
|
+
const c = h.mcpServers.myop;
|
|
2687
2687
|
if (c && c.url === s) {
|
|
2688
2688
|
console.log(`
|
|
2689
|
-
Myop MCP is already configured for ${
|
|
2689
|
+
Myop MCP is already configured for ${u.name}.`), console.log(` Config: ${u.configPath}`), console.log(`
|
|
2690
2690
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2691
|
-
for (const l of
|
|
2691
|
+
for (const l of u.nextSteps)
|
|
2692
2692
|
console.log(` ${l}`);
|
|
2693
2693
|
console.log(""), process.exit(0);
|
|
2694
2694
|
}
|
|
@@ -2701,10 +2701,10 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2701
2701
|
throw l.name === "ExitPromptError" && process.exit(0), l;
|
|
2702
2702
|
}
|
|
2703
2703
|
}
|
|
2704
|
-
|
|
2705
|
-
\x1B[32mβ\x1B[0m Myop MCP configured for ${
|
|
2704
|
+
h.mcpServers.myop = u.getEntry(), M.mkdirSync(_.dirname(u.configPath), { recursive: !0 }), M.writeFileSync(u.configPath, JSON.stringify(h, null, 2)), console.log(`
|
|
2705
|
+
\x1B[32mβ\x1B[0m Myop MCP configured for ${u.name}`), console.log(` Config: ${u.configPath}`), console.log(` Server: ${s}`), console.log(`
|
|
2706
2706
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2707
|
-
for (const l of
|
|
2707
|
+
for (const l of u.nextSteps)
|
|
2708
2708
|
console.log(` ${l}`);
|
|
2709
2709
|
console.log(""), process.exit(0);
|
|
2710
2710
|
});
|
|
@@ -2741,12 +2741,12 @@ const po = () => {
|
|
|
2741
2741
|
return null;
|
|
2742
2742
|
}
|
|
2743
2743
|
}, ie = async (o = !1, t = !1) => {
|
|
2744
|
-
var l,
|
|
2745
|
-
const e = $e(), n = !!(e != null && e.email), s = ((l = v.myopConfig) == null ? void 0 : l.name) || ((
|
|
2744
|
+
var l, x, y;
|
|
2745
|
+
const e = $e(), n = !!(e != null && e.email), s = ((l = v.myopConfig) == null ? void 0 : l.name) || ((x = v.myopConfig) == null ? void 0 : x.componentName), i = (y = v.myopConfig) == null ? void 0 : y.componentId, d = po();
|
|
2746
2746
|
console.log(`
|
|
2747
2747
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2748
2748
|
`), 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("");
|
|
2749
|
-
const
|
|
2749
|
+
const h = [
|
|
2750
2750
|
{
|
|
2751
2751
|
emoji: "π",
|
|
2752
2752
|
label: "Initialize new component",
|
|
@@ -2768,13 +2768,13 @@ const po = () => {
|
|
|
2768
2768
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
2769
2769
|
disabled: o ? n ? !1 : "(login required)" : "(no config file)"
|
|
2770
2770
|
}
|
|
2771
|
-
].map((
|
|
2772
|
-
name: t &&
|
|
2773
|
-
${
|
|
2774
|
-
value:
|
|
2775
|
-
disabled:
|
|
2771
|
+
].map(($) => ({
|
|
2772
|
+
name: t && !$.disabled ? `${$.emoji} ${$.label}
|
|
2773
|
+
${$.help}` : `${$.emoji} ${$.label}`,
|
|
2774
|
+
value: $.value,
|
|
2775
|
+
disabled: $.disabled
|
|
2776
2776
|
}));
|
|
2777
|
-
|
|
2777
|
+
h.push(
|
|
2778
2778
|
new _e(),
|
|
2779
2779
|
{
|
|
2780
2780
|
name: t && n ? `π Logout (${e.email})
|
|
@@ -2796,13 +2796,13 @@ const po = () => {
|
|
|
2796
2796
|
try {
|
|
2797
2797
|
c = await et({
|
|
2798
2798
|
message: "What would you like to do?",
|
|
2799
|
-
choices:
|
|
2799
|
+
choices: h
|
|
2800
2800
|
});
|
|
2801
|
-
} catch (
|
|
2802
|
-
throw
|
|
2801
|
+
} catch ($) {
|
|
2802
|
+
throw $.name === "ExitPromptError" && (console.log(`
|
|
2803
2803
|
|
|
2804
2804
|
π Goodbye!
|
|
2805
|
-
`), process.exit(0)),
|
|
2805
|
+
`), process.exit(0)), $;
|
|
2806
2806
|
}
|
|
2807
2807
|
switch (c) {
|
|
2808
2808
|
case "init":
|
|
@@ -2812,9 +2812,9 @@ const po = () => {
|
|
|
2812
2812
|
console.log(`
|
|
2813
2813
|
Pushing component...
|
|
2814
2814
|
`);
|
|
2815
|
-
const { execSync:
|
|
2815
|
+
const { execSync: $ } = await import("child_process");
|
|
2816
2816
|
try {
|
|
2817
|
-
|
|
2817
|
+
$("node " + process.argv[1] + " push", { stdio: "inherit" });
|
|
2818
2818
|
} catch {
|
|
2819
2819
|
}
|
|
2820
2820
|
await ie(!0, t);
|
|
@@ -2866,36 +2866,41 @@ Pushing component...
|
|
|
2866
2866
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2867
2867
|
const s = mo(), i = (s == null ? void 0 : s.selectedComponents) || [], d = i.length > 0;
|
|
2868
2868
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2869
|
-
`), n.forEach((
|
|
2870
|
-
const
|
|
2871
|
-
console.log(` ${
|
|
2869
|
+
`), n.forEach((x, y) => {
|
|
2870
|
+
const $ = x.componentId ? "β
" : "βͺ", g = x.componentId ? x.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2871
|
+
console.log(` ${$} ${x.name}`), console.log(` Path: ${x.path}`), console.log(` ID: ${g}`), console.log("");
|
|
2872
2872
|
}), console.log(` User: ${t ? o.email : "Not logged in"}`), d && console.log(` π Using saved selection from ${ve}`), console.log("");
|
|
2873
|
-
const
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2873
|
+
const u = v.program.getOptionValue("ci");
|
|
2874
|
+
let h;
|
|
2875
|
+
if (u)
|
|
2876
|
+
d ? (h = i, console.log(` π€ CI mode: using saved selection (${h.length} components)`)) : (h = n.map((x) => x.path), console.log(` π€ CI mode: no saved selection, using all ${h.length} components`));
|
|
2877
|
+
else {
|
|
2878
|
+
const { checkbox: x } = await import("@inquirer/prompts"), y = n.map(($) => ({
|
|
2879
|
+
name: `${$.name} (${$.path})`,
|
|
2880
|
+
value: $.path,
|
|
2881
|
+
checked: d ? i.includes($.path) : !0
|
|
2882
|
+
}));
|
|
2883
|
+
try {
|
|
2884
|
+
h = await x({
|
|
2885
|
+
message: "Select components to start in dev mode:",
|
|
2886
|
+
choices: y
|
|
2887
|
+
});
|
|
2888
|
+
} catch ($) {
|
|
2889
|
+
throw $.name === "ExitPromptError" && (console.log(`
|
|
2886
2890
|
|
|
2887
2891
|
π Goodbye!
|
|
2888
|
-
`), process.exit(0)),
|
|
2892
|
+
`), process.exit(0)), $;
|
|
2893
|
+
}
|
|
2889
2894
|
}
|
|
2890
|
-
|
|
2895
|
+
h.length === 0 && (console.log(`
|
|
2891
2896
|
β οΈ No components selected.
|
|
2892
|
-
`), process.exit(0)), uo(
|
|
2893
|
-
πΎ Selection saved to ${ve}`);
|
|
2894
|
-
const
|
|
2895
|
-
console.log(`π Starting dev mode for ${
|
|
2897
|
+
`), process.exit(0)), u || (uo(h), console.log(`
|
|
2898
|
+
πΎ Selection saved to ${ve}`));
|
|
2899
|
+
const c = n.filter((x) => h.includes(x.path));
|
|
2900
|
+
console.log(`π Starting dev mode for ${c.length} component${c.length > 1 ? "s" : ""}...
|
|
2896
2901
|
`);
|
|
2897
|
-
const { monorepoDevCommand:
|
|
2898
|
-
await
|
|
2902
|
+
const { monorepoDevCommand: l } = await Promise.resolve().then(() => Ht);
|
|
2903
|
+
await l(c);
|
|
2899
2904
|
}, fo = async () => {
|
|
2900
2905
|
const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
|
|
2901
2906
|
let i, d;
|
|
@@ -2918,15 +2923,15 @@ Pushing component...
|
|
|
2918
2923
|
π Goodbye!
|
|
2919
2924
|
`), process.exit(0)), c;
|
|
2920
2925
|
}
|
|
2921
|
-
const
|
|
2926
|
+
const u = {
|
|
2922
2927
|
name: i,
|
|
2923
2928
|
type: d,
|
|
2924
2929
|
author: "@myop-cli",
|
|
2925
2930
|
HMR: !0
|
|
2926
|
-
},
|
|
2931
|
+
}, h = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2927
2932
|
try {
|
|
2928
|
-
e.writeFileSync(
|
|
2929
|
-
β
Created ${
|
|
2933
|
+
e.writeFileSync(h, JSON.stringify(u, null, 2)), console.log(`
|
|
2934
|
+
β
Created ${h}`);
|
|
2930
2935
|
const c = {
|
|
2931
2936
|
name: i.toLowerCase().replace(/\s+/g, "-"),
|
|
2932
2937
|
version: "1.0.0",
|
|
@@ -3019,7 +3024,7 @@ fs.writeFileSync('dist/index.html', html);
|
|
|
3019
3024
|
console.log('β
Built dist/index.html');
|
|
3020
3025
|
console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
|
|
3021
3026
|
`), console.log("β
Created build.js");
|
|
3022
|
-
const
|
|
3027
|
+
const x = `<!DOCTYPE html>
|
|
3023
3028
|
<html lang="en">
|
|
3024
3029
|
<head>
|
|
3025
3030
|
<meta charset="UTF-8">
|
|
@@ -3036,8 +3041,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
3036
3041
|
</body>
|
|
3037
3042
|
</html>
|
|
3038
3043
|
`;
|
|
3039
|
-
e.writeFileSync("index.html",
|
|
3040
|
-
const
|
|
3044
|
+
e.writeFileSync("index.html", x), console.log("β
Created index.html");
|
|
3045
|
+
const y = `// ${i} - Entry Point
|
|
3041
3046
|
import { init } from './modules/app.js';
|
|
3042
3047
|
import { setupMyopInterface } from './modules/myop.js';
|
|
3043
3048
|
|
|
@@ -3046,8 +3051,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
3046
3051
|
setupMyopInterface();
|
|
3047
3052
|
});
|
|
3048
3053
|
`;
|
|
3049
|
-
e.writeFileSync("src/index.js",
|
|
3050
|
-
const
|
|
3054
|
+
e.writeFileSync("src/index.js", y), console.log("β
Created src/index.js");
|
|
3055
|
+
const $ = `// ${i} - Main Application Logic
|
|
3051
3056
|
|
|
3052
3057
|
export function init() {
|
|
3053
3058
|
console.log('${i} loaded');
|
|
@@ -3055,7 +3060,7 @@ export function init() {
|
|
|
3055
3060
|
// Your component logic here
|
|
3056
3061
|
}
|
|
3057
3062
|
`;
|
|
3058
|
-
e.writeFileSync("src/modules/app.js",
|
|
3063
|
+
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
|
|
3059
3064
|
|
|
3060
3065
|
export function setupMyopInterface() {
|
|
3061
3066
|
// Called when host app sends data to this component
|
|
@@ -3111,12 +3116,12 @@ dist/
|
|
|
3111
3116
|
.temp-styles.css
|
|
3112
3117
|
.DS_Store
|
|
3113
3118
|
`), console.log("β
Created .gitignore");
|
|
3114
|
-
const
|
|
3115
|
-
|
|
3116
|
-
const p = await import("./index-DuEoKctW.js").then((
|
|
3119
|
+
const P = await We(process.cwd());
|
|
3120
|
+
P.success && console.log("β
Installed AI agent skills");
|
|
3121
|
+
const p = await import("./index-DuEoKctW.js").then((b) => b.i), E = process.cwd();
|
|
3117
3122
|
try {
|
|
3118
3123
|
await p.init({ fs: e, dir: E });
|
|
3119
|
-
const
|
|
3124
|
+
const b = [
|
|
3120
3125
|
"myop.config.json",
|
|
3121
3126
|
"package.json",
|
|
3122
3127
|
"build.js",
|
|
@@ -3128,13 +3133,13 @@ dist/
|
|
|
3128
3133
|
"src/styles/index.css",
|
|
3129
3134
|
"src/styles/main.css"
|
|
3130
3135
|
];
|
|
3131
|
-
if (
|
|
3132
|
-
const
|
|
3136
|
+
if (P.success) {
|
|
3137
|
+
const k = (R, D) => {
|
|
3133
3138
|
try {
|
|
3134
3139
|
const L = e.readdirSync(R, { withFileTypes: !0 });
|
|
3135
3140
|
for (const T of L) {
|
|
3136
3141
|
const J = n.join(R, T.name), F = n.join(D, T.name);
|
|
3137
|
-
T.isDirectory() ?
|
|
3142
|
+
T.isDirectory() ? k(J, F) : b.push(F);
|
|
3138
3143
|
}
|
|
3139
3144
|
} catch {
|
|
3140
3145
|
}
|
|
@@ -3144,25 +3149,25 @@ dist/
|
|
|
3144
3149
|
for (const D of R)
|
|
3145
3150
|
if (D.isDirectory() && D.name.startsWith(".")) {
|
|
3146
3151
|
const L = n.join(D.name, "skills");
|
|
3147
|
-
e.existsSync(L) &&
|
|
3152
|
+
e.existsSync(L) && k(L, L);
|
|
3148
3153
|
}
|
|
3149
3154
|
} catch {
|
|
3150
3155
|
}
|
|
3151
3156
|
}
|
|
3152
|
-
for (const
|
|
3153
|
-
await p.add({ fs: e, dir: E, filepath:
|
|
3157
|
+
for (const k of b)
|
|
3158
|
+
await p.add({ fs: e, dir: E, filepath: k });
|
|
3154
3159
|
await p.commit({
|
|
3155
3160
|
fs: e,
|
|
3156
3161
|
dir: E,
|
|
3157
3162
|
message: "init",
|
|
3158
3163
|
author: { name: "myop-cli", email: "cli@myop.dev" }
|
|
3159
3164
|
}), console.log("β
Initialized git repository");
|
|
3160
|
-
} catch (
|
|
3161
|
-
console.log("β οΈ Failed to initialize git repository:",
|
|
3165
|
+
} catch (b) {
|
|
3166
|
+
console.log("β οΈ Failed to initialize git repository:", b.message);
|
|
3162
3167
|
}
|
|
3163
3168
|
console.log(`
|
|
3164
3169
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
3165
|
-
`), v.myopConfig =
|
|
3170
|
+
`), v.myopConfig = u, await ie(!0);
|
|
3166
3171
|
} catch (c) {
|
|
3167
3172
|
console.error(`Failed to initialize component: ${c.message}`), process.exit(1);
|
|
3168
3173
|
}
|
|
@@ -3173,31 +3178,31 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
3173
3178
|
return;
|
|
3174
3179
|
}
|
|
3175
3180
|
if (v.program.getOptionValue("ci")) {
|
|
3176
|
-
const
|
|
3177
|
-
let
|
|
3181
|
+
const u = await import("fs"), h = v.program.getOptionValue("config") || "./myop.config.json", c = v.program.version(), l = $e();
|
|
3182
|
+
let x = { found: !1 };
|
|
3178
3183
|
try {
|
|
3179
|
-
if (
|
|
3180
|
-
const
|
|
3181
|
-
|
|
3184
|
+
if (u.existsSync(h)) {
|
|
3185
|
+
const $ = u.readFileSync(h, "utf-8"), g = JSON.parse($);
|
|
3186
|
+
x = {
|
|
3182
3187
|
found: !0,
|
|
3183
|
-
path:
|
|
3188
|
+
path: h,
|
|
3184
3189
|
name: g.name || g.componentName || null,
|
|
3185
3190
|
componentId: g.componentId || null,
|
|
3186
3191
|
organization: g.organization || null
|
|
3187
3192
|
};
|
|
3188
3193
|
}
|
|
3189
|
-
} catch (
|
|
3190
|
-
|
|
3194
|
+
} catch ($) {
|
|
3195
|
+
x = { found: !1, error: $.message };
|
|
3191
3196
|
}
|
|
3192
|
-
const
|
|
3197
|
+
const y = {
|
|
3193
3198
|
version: c,
|
|
3194
|
-
config:
|
|
3199
|
+
config: x,
|
|
3195
3200
|
auth: {
|
|
3196
3201
|
loggedIn: !!(l != null && l.email),
|
|
3197
3202
|
email: (l == null ? void 0 : l.email) || null
|
|
3198
3203
|
}
|
|
3199
3204
|
};
|
|
3200
|
-
console.log(JSON.stringify(
|
|
3205
|
+
console.log(JSON.stringify(y, null, 2)), process.exit(0);
|
|
3201
3206
|
}
|
|
3202
3207
|
let n = Y({
|
|
3203
3208
|
text: "Loading Myop CLI...",
|