@myop/cli 0.1.52 → 0.1.54

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.
Files changed (2) hide show
  1. package/dist/myop-cli.js +223 -217
  2. package/package.json +1 -1
package/dist/myop-cli.js CHANGED
@@ -6,7 +6,7 @@ import z from "ora";
6
6
  import { select as st, Separator as Le } 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 _, { join as je } from "path";
9
+ import R, { join as je } from "path";
10
10
  import C, { readFileSync as Et } from "fs";
11
11
  import ze from "crypto";
12
12
  import It from "http";
@@ -62,18 +62,18 @@ Examples:
62
62
  action: async () => {
63
63
  console.info("installing... ");
64
64
  for (const o of v.myopConfig.flows) {
65
- const t = _.join(v.executionPath, "/node_modules/@myop/flow-types/");
65
+ const t = R.join(v.executionPath, "/node_modules/@myop/flow-types/");
66
66
  console.info(`Generate flow at ${t}`), console.info(`Generated flow at ${t}`);
67
67
  }
68
68
  process.exit();
69
69
  }
70
70
  }, Rt = (o) => {
71
- const t = _.join(v.executionPath, o);
71
+ const t = R.join(v.executionPath, o);
72
72
  console.info(`reading config file from: ${t}`);
73
73
  const e = C.readFileSync(t, "utf8"), n = JSON.parse(e);
74
74
  return console.info("config file loaded, ", n), n;
75
75
  }, We = (o, t) => {
76
- const e = _.join(v.executionPath, o);
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);
@@ -262,13 +262,13 @@ async function pt(o, t, e, n, s = {}) {
262
262
  onRetry: p
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
- `), 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((c) => {
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
266
  n("npm install", (d, y, S) => {
267
267
  if (d) {
268
- console.error("❌ Failed to install dependencies:", d.message), S && console.error(S), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
268
+ console.error("❌ Failed to install dependencies:", d.message), S && console.error(S), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
269
269
  return;
270
270
  }
271
- console.log("✅ Dependencies installed"), p && p(), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
271
+ console.log("✅ Dependencies installed"), p && p(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
272
272
  });
273
273
  })) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: r };
274
274
  }
@@ -280,37 +280,37 @@ async function Ce() {
280
280
  i = t.default.dirname(f);
281
281
  } else
282
282
  i = t.default.dirname(import.meta.url);
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"), c = 9292, d = 9293;
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
284
  let y = "./dist", S = !1, x = !1, g = !1, u = null;
285
285
  const E = () => {
286
286
  try {
287
- const l = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
288
- if (l.length === 1)
289
- return l[0];
287
+ const c = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
288
+ if (c.length === 1)
289
+ return c[0];
290
290
  } catch {
291
291
  }
292
292
  return null;
293
293
  }, O = () => {
294
294
  try {
295
- const l = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
- return !!(l.scripts && l.scripts.build);
295
+ const c = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
296
+ return !!(c.scripts && c.scripts.build);
297
297
  } catch {
298
298
  return !1;
299
299
  }
300
- }, b = (l) => {
300
+ }, b = (c) => {
301
301
  const a = process.platform;
302
302
  let f;
303
- a === "darwin" ? f = `open "${l}"` : a === "win32" ? f = `start "" "${l}"` : f = `xdg-open "${l}"`, e(f, (h) => {
303
+ a === "darwin" ? f = `open "${c}"` : a === "win32" ? f = `start "" "${c}"` : f = `xdg-open "${c}"`, e(f, (h) => {
304
304
  });
305
305
  }, P = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
306
- let M, R, k = !1;
306
+ let M, _, k = !1;
307
307
  u = E();
308
308
  const L = O();
309
309
  try {
310
- const l = o.default.readFileSync(j, "utf-8"), a = JSON.parse(l);
311
- M = a.componentId || "DEV", R = 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
- } catch (l) {
313
- u && !L ? (g = !0, M = "DEV", R = 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:", l.message), process.exit(1));
310
+ const c = o.default.readFileSync(j, "utf-8"), a = JSON.parse(c);
311
+ M = a.componentId || "DEV", _ = 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
+ } catch (c) {
313
+ u && !L ? (g = !0, M = "DEV", _ = 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
316
  if (M !== "DEV" && M !== "NEW")
@@ -348,8 +348,8 @@ async function Ce() {
348
348
  } catch {
349
349
  return "DEV1";
350
350
  }
351
- }, T = process.cwd(), W = (l) => {
352
- const a = t.default.extname(l).toLowerCase();
351
+ }, T = process.cwd(), W = (c) => {
352
+ const a = t.default.extname(c).toLowerCase();
353
353
  return {
354
354
  ".html": "text/html",
355
355
  ".js": "text/javascript",
@@ -361,9 +361,9 @@ async function Ce() {
361
361
  ".svg": "image/svg+xml",
362
362
  ".ico": "image/x-icon"
363
363
  }[a] || "application/octet-stream";
364
- }, N = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (l, a, f) => {
365
- if (l.url.startsWith("/_hmr/")) {
366
- const h = l.url.split("/_hmr/")[1], w = l.headers["sec-websocket-key"], $ = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
364
+ }, N = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
365
+ if (c.url.startsWith("/_hmr/")) {
366
+ const h = c.url.split("/_hmr/")[1], w = c.headers["sec-websocket-key"], $ = s("sha1").update(w + "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
@@ -379,10 +379,10 @@ Sec-WebSocket-Accept: ${$}\r
379
379
  I && I.delete(a);
380
380
  });
381
381
  }
382
- }, Oe = n.default.createServer((l, a) => {
383
- if (a.setHeader("Content-Type", "application/json"), l.method === "POST" && l.url === "/_register") {
382
+ }, Oe = n.default.createServer((c, a) => {
383
+ if (a.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
384
384
  let f = "";
385
- l.on("data", (h) => f += h), l.on("end", () => {
385
+ c.on("data", (h) => f += h), c.on("end", () => {
386
386
  try {
387
387
  const { componentId: h, distPath: w, componentName: $, htmlFile: I } = JSON.parse(f);
388
388
  N.set(h, { path: w, name: $ || null, htmlFile: I || null });
@@ -408,9 +408,9 @@ Sec-WebSocket-Accept: ${$}\r
408
408
  a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
409
409
  }
410
410
  });
411
- } else if (l.method === "POST" && l.url === "/_unregister") {
411
+ } else if (c.method === "POST" && c.url === "/_unregister") {
412
412
  let f = "";
413
- l.on("data", (h) => f += h), l.on("end", () => {
413
+ c.on("data", (h) => f += h), c.on("end", () => {
414
414
  try {
415
415
  const { componentId: h } = JSON.parse(f);
416
416
  N.delete(h), console.log(`❌ Unregistered: ${h}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
@@ -434,11 +434,11 @@ Sec-WebSocket-Accept: ${$}\r
434
434
  a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
435
435
  }
436
436
  });
437
- } else if (l.method === "GET" && l.url === "/_list")
437
+ } else if (c.method === "GET" && c.url === "/_list")
438
438
  a.writeHead(200), a.end(JSON.stringify({ components: Array.from(N.entries()) }));
439
- else if (l.method === "POST" && l.url === "/_hmr_notify") {
439
+ else if (c.method === "POST" && c.url === "/_hmr_notify") {
440
440
  let f = "";
441
- l.on("data", (h) => f += h), l.on("end", () => {
441
+ c.on("data", (h) => f += h), c.on("end", () => {
442
442
  try {
443
443
  const { componentId: h, html: w } = JSON.parse(f), $ = X.get(h);
444
444
  if ($ && $.size > 0) {
@@ -459,12 +459,12 @@ Sec-WebSocket-Accept: ${$}\r
459
459
  });
460
460
  } else
461
461
  a.writeHead(404), a.end(JSON.stringify({ error: "Not found" }));
462
- }), ge = n.default.createServer((l, a) => {
463
- if (l.url.includes("..")) {
462
+ }), ge = n.default.createServer((c, a) => {
463
+ if (c.url.includes("..")) {
464
464
  a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
465
465
  return;
466
466
  }
467
- const f = new URL(l.url, `http://localhost:${c}`), h = f.pathname, w = h.split("/").filter((J) => J);
467
+ const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, w = h.split("/").filter((J) => J);
468
468
  if (h.startsWith("/consume")) {
469
469
  const J = f.searchParams.get("id");
470
470
  if (!J) {
@@ -473,26 +473,26 @@ Sec-WebSocket-Accept: ${$}\r
473
473
  }
474
474
  const V = N.get(J), G = V ? V.path : null, de = (te) => {
475
475
  let U = "Unknown", K = "Unknown";
476
- if (l.headers.referer || l.headers.referrer) {
477
- const B = l.headers.referer || l.headers.referrer;
476
+ if (c.headers.referer || c.headers.referrer) {
477
+ const B = c.headers.referer || c.headers.referrer;
478
478
  try {
479
479
  const ie = new URL(B);
480
480
  U = ie.origin, K = ie.hostname || ie.origin;
481
481
  } catch {
482
482
  U = B, K = B;
483
483
  }
484
- } else if (l.headers.origin)
484
+ } else if (c.headers.origin)
485
485
  try {
486
- const B = new URL(l.headers.origin);
486
+ const B = new URL(c.headers.origin);
487
487
  U = B.origin, K = B.hostname || B.origin;
488
488
  } catch {
489
- U = l.headers.origin, K = l.headers.origin;
489
+ U = c.headers.origin, K = c.headers.origin;
490
490
  }
491
- else if (l.socket.remoteAddress) {
492
- const B = l.socket.remoteAddress;
491
+ else if (c.socket.remoteAddress) {
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 Te = l.headers.referer || l.headers.referrer || U, we = {
495
+ const Te = c.headers.referer || c.headers.referrer || U, we = {
496
496
  type: "request",
497
497
  componentId: J,
498
498
  timestamp: Date.now(),
@@ -607,14 +607,14 @@ Sec-WebSocket-Accept: ${$}\r
607
607
  log: oe
608
608
  })}
609
609
 
610
- `), l.on("close", () => {
610
+ `), c.on("close", () => {
611
611
  const V = q.indexOf(a);
612
612
  V !== -1 && q.splice(V, 1);
613
613
  });
614
614
  return;
615
615
  }
616
616
  if (w.length === 0) {
617
- a.writeHead(200, { "Content-Type": "text/html" }), a.end(Lt(c, d, p, m));
617
+ a.writeHead(200, { "Content-Type": "text/html" }), a.end(Lt(l, d, p, m));
618
618
  return;
619
619
  }
620
620
  if (w[0] !== "view") {
@@ -631,7 +631,7 @@ Sec-WebSocket-Accept: ${$}\r
631
631
  return;
632
632
  }
633
633
  const F = I.path, H = w.slice(2), Y = I.htmlFile || "index.html", ee = H.length === 0 ? Y : H.join("/"), ce = t.default.join(F, ee);
634
- console.log(`📥 Request: ${l.url} -> ${ce}`), o.default.readFile(ce, (J, V) => {
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");
637
637
  return;
@@ -648,11 +648,11 @@ Sec-WebSocket-Accept: ${$}\r
648
648
  "Access-Control-Allow-Origin": "*"
649
649
  }), a.end(de);
650
650
  });
651
- }), Ze = () => new Promise((l, a) => {
651
+ }), Ze = () => new Promise((c, a) => {
652
652
  const f = g ? t.default.resolve(T) : t.default.resolve(T, y), h = JSON.stringify({
653
653
  componentId: M,
654
654
  distPath: f,
655
- componentName: R,
655
+ componentName: _,
656
656
  htmlFile: g ? u : null
657
657
  }), w = {
658
658
  hostname: "localhost",
@@ -666,11 +666,11 @@ Sec-WebSocket-Accept: ${$}\r
666
666
  }, $ = n.default.request(w, (I) => {
667
667
  let F = "";
668
668
  I.on("data", (H) => F += H), I.on("end", () => {
669
- I.statusCode === 200 ? l(JSON.parse(F)) : a(new Error(`Registration failed: ${I.statusCode}`));
669
+ I.statusCode === 200 ? c(JSON.parse(F)) : a(new Error(`Registration failed: ${I.statusCode}`));
670
670
  });
671
671
  });
672
672
  $.on("error", a), $.write(h), $.end();
673
- }), vt = () => new Promise((l, a) => {
673
+ }), vt = () => new Promise((c, a) => {
674
674
  const f = JSON.stringify({ componentId: M }), h = {
675
675
  hostname: "localhost",
676
676
  port: d,
@@ -681,14 +681,14 @@ Sec-WebSocket-Accept: ${$}\r
681
681
  "Content-Length": Buffer.byteLength(f)
682
682
  }
683
683
  }, w = n.default.request(h, ($) => {
684
- l();
684
+ c();
685
685
  });
686
- w.on("error", () => l()), w.write(f), w.end();
687
- }), St = (l) => `
686
+ w.on("error", () => c()), w.write(f), w.end();
687
+ }), St = (c) => `
688
688
  <!-- MYOP HMR -->
689
689
  <script>
690
690
  (function() {
691
- const componentId = '${l}';
691
+ const componentId = '${c}';
692
692
  const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
693
693
  let ws;
694
694
  let reconnectAttempts = 0;
@@ -789,12 +789,12 @@ Sec-WebSocket-Accept: ${$}\r
789
789
  connect();
790
790
  })();
791
791
  <\/script>
792
- `, ke = (l, a) => {
793
- if (!k) return l;
792
+ `, ke = (c, a) => {
793
+ if (!k) return c;
794
794
  const f = St(a);
795
- return l.includes("</body>") ? l.replace("</body>", `${f}</body>`) : l.includes("</html>") ? l.replace("</html>", `${f}</html>`) : l + f;
796
- }, qe = (l) => {
797
- const a = Buffer.from(l), f = a.length;
795
+ return c.includes("</body>") ? c.replace("</body>", `${f}</body>`) : c.includes("</html>") ? c.replace("</html>", `${f}</html>`) : c + f;
796
+ }, qe = (c) => {
797
+ const a = Buffer.from(c), f = a.length;
798
798
  let h;
799
799
  return f < 126 ? h = Buffer.concat([
800
800
  Buffer.from([129, f]),
@@ -815,10 +815,10 @@ Sec-WebSocket-Accept: ${$}\r
815
815
  ]), h;
816
816
  }, Xe = () => {
817
817
  if (!k) return;
818
- const l = g ? u : t.default.join(y, "index.html");
818
+ const c = g ? u : t.default.join(y, "index.html");
819
819
  let a;
820
820
  try {
821
- const f = o.default.readFileSync(l, "utf-8");
821
+ const f = o.default.readFileSync(c, "utf-8");
822
822
  a = ke(f, M);
823
823
  } catch (f) {
824
824
  console.error("❌ Failed to read HTML for HMR:", f.message);
@@ -871,7 +871,7 @@ Sec-WebSocket-Accept: ${$}\r
871
871
  }
872
872
  };
873
873
  let Re = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
- const he = (l) => {
874
+ const he = (c) => {
875
875
  if (S) {
876
876
  x = !0;
877
877
  return;
@@ -881,17 +881,17 @@ Sec-WebSocket-Accept: ${$}\r
881
881
  if (S = !1, a) {
882
882
  const w = await pt(a, f, h, e, {
883
883
  ...Re,
884
- onRetry: () => he(l)
884
+ onRetry: () => he(c)
885
885
  });
886
886
  Re = { ...Re, ...w }, w.handled || (console.error("❌ Build failed:", a.message), h && console.error(h));
887
887
  } else
888
- console.log("✅ Build completed"), f && console.log(f), Xe(), l && l();
888
+ console.log("✅ Build completed"), f && console.log(f), Xe(), c && c();
889
889
  x && (x = !1, he());
890
890
  });
891
- }, et = /* @__PURE__ */ new Set(), _e = (l) => {
892
- o.default.readdir(l, { withFileTypes: !0 }, (a, f) => {
891
+ }, et = /* @__PURE__ */ new Set(), _e = (c) => {
892
+ o.default.readdir(c, { withFileTypes: !0 }, (a, f) => {
893
893
  a || (f.forEach((h) => {
894
- const w = t.default.join(l, h.name);
894
+ const w = t.default.join(c, h.name);
895
895
  if (h.isDirectory())
896
896
  h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(w);
897
897
  else if (h.isFile()) {
@@ -903,11 +903,11 @@ Sec-WebSocket-Accept: ${$}\r
903
903
  } catch {
904
904
  }
905
905
  }
906
- }), et.has(l) || (et.add(l), o.default.watch(l, (h, w) => {
906
+ }), et.has(c) || (et.add(c), o.default.watch(c, (h, w) => {
907
907
  if (!w) return;
908
908
  const $ = t.default.extname(w);
909
909
  if ($ !== ".js" && $ !== ".css" && $ !== ".html") return;
910
- const I = t.default.join(l, w);
910
+ const I = t.default.join(c, w);
911
911
  setTimeout(() => {
912
912
  try {
913
913
  const F = o.default.readFileSync(I, "utf-8"), H = P.get(I);
@@ -917,12 +917,12 @@ Sec-WebSocket-Accept: ${$}\r
917
917
  }, 50);
918
918
  })));
919
919
  });
920
- }, tt = (l) => {
920
+ }, tt = (c) => {
921
921
  console.log(`
922
922
  🔨 Component: ${M}`), g ? (console.log("📄 No build needed (single HTML file mode)"), _e(T), console.log(`👀 Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
923
- `), l && l()) : (he(l), _e(T), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
923
+ `), c && c()) : (he(c), _e(T), console.log("👀 Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
924
924
  `));
925
- }, xt = () => new Promise((l) => {
925
+ }, xt = () => new Promise((c) => {
926
926
  const a = {
927
927
  hostname: "localhost",
928
928
  port: d,
@@ -930,12 +930,12 @@ Sec-WebSocket-Accept: ${$}\r
930
930
  method: "GET",
931
931
  timeout: 1e3
932
932
  }, f = n.default.request(a, (h) => {
933
- l(!0);
933
+ c(!0);
934
934
  });
935
- f.on("error", () => l(!1)), f.on("timeout", () => {
936
- f.destroy(), l(!1);
935
+ f.on("error", () => c(!1)), f.on("timeout", () => {
936
+ f.destroy(), c(!1);
937
937
  }), f.end();
938
- }), $t = () => new Promise((l) => {
938
+ }), $t = () => new Promise((c) => {
939
939
  const a = n.default.createServer((f, h) => {
940
940
  if (h.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
941
941
  let w = "";
@@ -962,21 +962,21 @@ Sec-WebSocket-Accept: ${$}\r
962
962
  } else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(N.entries()) }))) : (h.writeHead(404), h.end(JSON.stringify({ error: "Not found" })));
963
963
  });
964
964
  a.on("error", () => {
965
- l(!1);
965
+ c(!1);
966
966
  }), a.listen(d, () => {
967
967
  console.log(`
968
968
  🔄 Taking over as server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", () => {
969
- a.close(), l(!1);
970
- }), ge.listen(c, () => {
971
- console.log(`📡 Main server running at http://localhost:${c}`);
969
+ a.close(), c(!1);
970
+ }), ge.listen(l, () => {
971
+ console.log(`📡 Main server running at http://localhost:${l}`);
972
972
  const f = g ? t.default.resolve(T) : t.default.resolve(T, y);
973
973
  N.set(M, {
974
974
  path: f,
975
- name: R,
975
+ name: _,
976
976
  htmlFile: g ? u : null
977
977
  });
978
- const h = R ? ` (${R})` : "";
979
- console.log(`✅ Registered component: ${M}${h}`), console.log(`📡 Access at: http://localhost:${c}/view/${M}/`), l(!0);
978
+ const h = _ ? ` (${_})` : "";
979
+ console.log(`✅ Registered component: ${M}${h}`), console.log(`📡 Access at: http://localhost:${l}/view/${M}/`), c(!0);
980
980
  });
981
981
  });
982
982
  });
@@ -999,36 +999,36 @@ Sec-WebSocket-Accept: ${$}\r
999
999
  };
1000
1000
  process.on("SIGINT", nt), process.on("SIGTERM", nt);
1001
1001
  let Ne = !1;
1002
- Oe.on("error", async (l) => {
1003
- if (l.code === "EADDRINUSE") {
1002
+ Oe.on("error", async (c) => {
1003
+ if (c.code === "EADDRINUSE") {
1004
1004
  console.log(`
1005
1005
  🔗 Connecting to existing dev server...`);
1006
1006
  try {
1007
1007
  M = await D();
1008
1008
  const a = await Ze();
1009
- console.log(`✅ Registered component: ${M}`), console.log(`📡 Access at: http://localhost:${c}/view/${M}/`), console.log(`📋 All registered components: ${a.registered.join(", ")}`), tt(() => {
1010
- process.env.MYOP_NO_BROWSER || b(`http://localhost:${c}/view/${M}/`);
1009
+ console.log(`✅ Registered component: ${M}`), console.log(`📡 Access at: http://localhost:${l}/view/${M}/`), console.log(`📋 All registered components: ${a.registered.join(", ")}`), tt(() => {
1010
+ process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${M}/`);
1011
1011
  }), ot();
1012
1012
  } catch (a) {
1013
1013
  console.error("❌ Failed to register component:", a.message), process.exit(1);
1014
1014
  }
1015
1015
  } else
1016
- console.error("❌ Management server error:", l.message), process.exit(1);
1016
+ console.error("❌ Management server error:", c.message), process.exit(1);
1017
1017
  }), Oe.on("upgrade", wt), Oe.listen(d, async () => {
1018
1018
  Ne = !0, console.log(`
1019
- 🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", (l) => {
1020
- console.error("❌ Main server error:", l.message), process.exit(1);
1021
- }), ge.listen(c, async () => {
1022
- console.log(`📡 Main server running at http://localhost:${c}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
1023
- const l = g ? t.default.resolve(T) : t.default.resolve(T, y);
1019
+ 🚀 Starting shared dev server...`), console.log(`📡 Management server on port ${d}`), ge.on("error", (c) => {
1020
+ console.error("❌ Main server error:", c.message), process.exit(1);
1021
+ }), ge.listen(l, async () => {
1022
+ console.log(`📡 Main server running at http://localhost:${l}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
1023
+ const c = g ? t.default.resolve(T) : t.default.resolve(T, y);
1024
1024
  N.set(M, {
1025
- path: l,
1026
- name: R,
1025
+ path: c,
1026
+ name: _,
1027
1027
  htmlFile: g ? u : null
1028
1028
  });
1029
- const a = R ? ` (${R})` : "";
1030
- console.log(`✅ Registered component: ${M}${a}`), console.log(`📡 Access at: http://localhost:${c}/view/${M}/`), tt(() => {
1031
- process.env.MYOP_NO_BROWSER || b(`http://localhost:${c}/view/${M}/`);
1029
+ const a = _ ? ` (${_})` : "";
1030
+ console.log(`✅ Registered component: ${M}${a}`), console.log(`📡 Access at: http://localhost:${l}/view/${M}/`), tt(() => {
1031
+ process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${M}/`);
1032
1032
  });
1033
1033
  });
1034
1034
  });
@@ -1083,15 +1083,15 @@ const A = class A {
1083
1083
  const t = this.components.length, e = 38;
1084
1084
  let n;
1085
1085
  this.cols >= e * 3 + 4 ? n = Math.min(t, 3) : this.cols >= e * 2 + 2 ? n = Math.min(t, 2) : n = 1;
1086
- const s = Math.ceil(t / n), i = Math.floor(this.cols / n), r = 2, m = this.rows - r - 2, c = Math.floor(m / s);
1087
- this.visibleLogLines = Math.max(2, c - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: c }, this.panelPositions.clear();
1086
+ 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
+ this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
1088
1088
  for (let d = 0; d < t; d++) {
1089
1089
  const y = this.components[d], S = Math.floor(d / n), x = d % n;
1090
1090
  this.panelPositions.set(y.name, {
1091
- row: r + 1 + S * c,
1091
+ row: r + 1 + S * l,
1092
1092
  col: x * i + 1,
1093
1093
  width: i,
1094
- height: c
1094
+ height: l
1095
1095
  });
1096
1096
  }
1097
1097
  }
@@ -1139,17 +1139,17 @@ 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((D) => D.name === t), r = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", c = n[m], d = e[c.color], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, x - 20);
1143
- let O = `${g}┌─${e.reset} ${d}${c.icon}${e.reset} `;
1144
- O += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${d}${c.label}${e.reset} `;
1145
- const b = 5 + E.length + c.label.length + 3;
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], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, x - 20);
1143
+ let O = `${g}┌─${e.reset} ${d}${l.icon}${e.reset} `;
1144
+ O += `${e.bold}${E}${e.reset} ${e.gray}─${e.reset} ${d}${l.label}${e.reset} `;
1145
+ const b = 5 + E.length + l.label.length + 3;
1146
1146
  O += `${g}${"─".repeat(Math.max(0, x - b))}┐${e.reset}`, u.push(A.ESC.moveTo(s.row, s.col) + O);
1147
1147
  const P = (r.path || "").substring(0, x - 6);
1148
1148
  let j = `${g}│${e.reset} ${e.dim}${P}${e.reset}`;
1149
1149
  j += " ".repeat(Math.max(0, x - P.length - 3)), j += `${g}│${e.reset}`, u.push(A.ESC.moveTo(s.row + 1, s.col) + j);
1150
- const M = y.length, R = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
1151
- let k = `${g}├${"─".repeat(x - R.length - 4)}${e.reset}`;
1152
- R && (k += `${e.dim}${R}${e.reset}`), k += `${g}${"─".repeat(2)}┤${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
1150
+ const M = y.length, _ = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
1151
+ let k = `${g}├${"─".repeat(x - _.length - 4)}${e.reset}`;
1152
+ _ && (k += `${e.dim}${_}${e.reset}`), k += `${g}${"─".repeat(2)}┤${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
1153
1153
  const L = y.slice(S, S + this.visibleLogLines);
1154
1154
  for (let D = 0; D < this.visibleLogLines; D++) {
1155
1155
  const T = L[D];
@@ -1245,11 +1245,11 @@ async function zt(o) {
1245
1245
  }), setTimeout(() => process.exit(0), 500);
1246
1246
  };
1247
1247
  process.on("SIGINT", m), process.on("SIGTERM", m);
1248
- const c = process.argv[1];
1248
+ const l = process.argv[1];
1249
1249
  for (let d = 0; d < o.length; d++) {
1250
1250
  const y = o[d], S = y.name;
1251
1251
  i.setStatus(S, "⏳ Starting..."), i.log(S, `Starting in ${y.path}`);
1252
- const x = t("node", [c, "dev"], {
1252
+ const x = t("node", [l, "dev"], {
1253
1253
  cwd: n.default.resolve(y.path),
1254
1254
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1255
1255
  stdio: ["ignore", "pipe", "pipe"]
@@ -1296,8 +1296,10 @@ async function mt(o, t) {
1296
1296
  return e.json();
1297
1297
  }
1298
1298
  function pe(o, t, e) {
1299
- const n = _.join(o, t);
1300
- C.mkdirSync(_.dirname(n), { recursive: !0 }), C.writeFileSync(n, JSON.stringify(e, null, 2));
1299
+ const n = R.resolve(R.join(o, t)), s = R.resolve(o);
1300
+ if (!n.startsWith(s + R.sep))
1301
+ throw new Error(`Invalid path: "${t}" escapes output directory`);
1302
+ C.mkdirSync(R.dirname(n), { recursive: !0 }), C.writeFileSync(n, JSON.stringify(e, null, 2));
1301
1303
  }
1302
1304
  async function $e(o, t, e, n) {
1303
1305
  return mt(
@@ -1307,19 +1309,23 @@ async function $e(o, t, e, n) {
1307
1309
  }
1308
1310
  async function Yt(o, t, e, n) {
1309
1311
  let s = 0;
1310
- for (const i of n) {
1311
- const { componentId: r, environment: p } = i;
1312
- if (!(!r || !p)) {
1312
+ const i = /* @__PURE__ */ new Set();
1313
+ for (const r of n) {
1314
+ const { componentId: p, environment: m } = r;
1315
+ if (!(!p || !m)) {
1313
1316
  try {
1314
- const m = await $e(o, t, r, p);
1315
- pe(e, `components/${r}/${p}.json`, m), s++;
1316
- } catch (m) {
1317
- console.warn(` Warning: ${r}/${p}: ${m.message}`);
1317
+ const l = await $e(o, t, p, m);
1318
+ pe(e, `components/${p}/${m}.json`, l), s++;
1319
+ } catch (l) {
1320
+ console.warn(` Warning: ${p}/${m}: ${l.message}`);
1318
1321
  }
1319
- try {
1320
- const m = await $e(o, t, r, "preview");
1321
- pe(e, `components/${r}/preview.json`, m), s++;
1322
- } catch {
1322
+ if (!i.has(p)) {
1323
+ i.add(p);
1324
+ try {
1325
+ const l = await $e(o, t, p, "preview");
1326
+ pe(e, `components/${p}/preview.json`, l), s++;
1327
+ } catch {
1328
+ }
1323
1329
  }
1324
1330
  }
1325
1331
  }
@@ -1369,10 +1375,10 @@ function Kt() {
1369
1375
  } else {
1370
1376
  const r = z(`Full export from ${e}...`).start();
1371
1377
  try {
1372
- const { manifest: p, fileCount: m, errorCount: c } = await Gt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
1378
+ const { manifest: p, fileCount: m, errorCount: l } = await Gt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
1373
1379
  r.succeed(
1374
1380
  `Full export done. ${m} file(s) from ${d} component(s) written to ${n}/`
1375
- ), c > 0 && console.warn(` ${c} file(s) failed.`);
1381
+ ), l > 0 && console.warn(` ${l} file(s) failed.`);
1376
1382
  } catch (p) {
1377
1383
  r.fail(`Export failed: ${p.message}`), process.exit(1);
1378
1384
  }
@@ -1380,7 +1386,7 @@ function Kt() {
1380
1386
  process.exit(0);
1381
1387
  });
1382
1388
  }
1383
- const He = _.join(at.homedir(), ".myop"), ue = _.join(He, "credentials.json");
1389
+ const He = R.join(at.homedir(), ".myop"), ue = R.join(He, "credentials.json");
1384
1390
  function Qt() {
1385
1391
  C.existsSync(He) || C.mkdirSync(He, { recursive: !0, mode: 448 });
1386
1392
  }
@@ -1620,14 +1626,14 @@ function oo(o) {
1620
1626
  const n = It.createServer((s, i) => {
1621
1627
  const r = new it(s.url, `http://localhost:${xe}`);
1622
1628
  if (r.pathname === "/callback") {
1623
- const p = r.searchParams.get("code"), m = r.searchParams.get("state"), c = r.searchParams.get("error");
1624
- if (c) {
1629
+ const p = r.searchParams.get("code"), m = r.searchParams.get("state"), l = r.searchParams.get("error");
1630
+ if (l) {
1625
1631
  i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
1626
1632
  "error",
1627
1633
  "Authentication Failed",
1628
1634
  "Unable to complete the authentication process.",
1629
- c
1630
- )), n.close(), e(new Error(`OAuth error: ${c}`));
1635
+ l
1636
+ )), n.close(), e(new Error(`OAuth error: ${l}`));
1631
1637
  return;
1632
1638
  }
1633
1639
  if (m !== o) {
@@ -1737,12 +1743,12 @@ async function me() {
1737
1743
  `), await Ot(p.toString());
1738
1744
  const m = await r;
1739
1745
  o.start("Exchanging authorization code...");
1740
- const c = await no(m, e, n);
1746
+ const l = await no(m, e, n);
1741
1747
  o.text = "Getting user info...";
1742
- const d = await io(c.access_token), y = {
1743
- accessToken: c.access_token,
1744
- refreshToken: c.refresh_token,
1745
- expiresAt: new Date(Date.now() + c.expires_in * 1e3).toISOString(),
1748
+ const d = await io(l.access_token), y = {
1749
+ accessToken: l.access_token,
1750
+ refreshToken: l.refresh_token,
1751
+ expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
1746
1752
  clientId: e,
1747
1753
  userId: d.userId,
1748
1754
  userEmail: d.email
@@ -1870,8 +1876,8 @@ async function mo(o) {
1870
1876
  const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${r ? `install -g ${Z}@latest --prefix \\"${r}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
1871
1877
  Q(`powershell -Command "${d}"`, { stdio: "inherit" });
1872
1878
  } else {
1873
- const c = r ? `sudo npm install -g ${Z}@latest --prefix "${r}"` : `sudo ${i}`;
1874
- Q(c, { stdio: "inherit" });
1879
+ const l = r ? `sudo npm install -g ${Z}@latest --prefix "${r}"` : `sudo ${i}`;
1880
+ Q(l, { stdio: "inherit" });
1875
1881
  }
1876
1882
  console.log(`
1877
1883
  ✅ Updated to v${e}`);
@@ -1888,7 +1894,7 @@ Please run manually: ${d}
1888
1894
  try {
1889
1895
  let m;
1890
1896
  r ? m = Ae ? je(r, "node_modules") : je(r, "lib", "node_modules") : m = Q("npm root -g", { encoding: "utf-8" }).trim();
1891
- const c = je(m, Z, "package.json"), d = Et(c, "utf-8");
1897
+ const l = je(m, Z, "package.json"), d = Et(l, "utf-8");
1892
1898
  p = JSON.parse(d).version;
1893
1899
  } catch {
1894
1900
  }
@@ -1898,8 +1904,8 @@ Please run manually: ${d}
1898
1904
  `), Mt(process.argv[0], process.argv.slice(1), {
1899
1905
  stdio: "inherit",
1900
1906
  shell: !0
1901
- }).on("close", (c) => {
1902
- process.exit(c || 0);
1907
+ }).on("close", (l) => {
1908
+ process.exit(l || 0);
1903
1909
  }), !0;
1904
1910
  console.log(`
1905
1911
  Please run myop again to use the new version.
@@ -1907,7 +1913,7 @@ Please run myop again to use the new version.
1907
1913
  }
1908
1914
  return !1;
1909
1915
  }
1910
- const Be = _.join(at.homedir(), ".myop"), Je = _.join(Be, "preferences.json");
1916
+ const Be = R.join(at.homedir(), ".myop"), Je = R.join(Be, "preferences.json");
1911
1917
  function uo() {
1912
1918
  C.existsSync(Be) || C.mkdirSync(Be, { recursive: !0, mode: 448 });
1913
1919
  }
@@ -1935,7 +1941,7 @@ function De({ id: o, name: t }) {
1935
1941
  fo({ defaultOrganization: { id: o, name: t } });
1936
1942
  }
1937
1943
  async function ho(o, t, e, n = {}) {
1938
- var p, m, c;
1944
+ var p, m, l;
1939
1945
  const s = await fetch(`${o}/mcp`, {
1940
1946
  method: "POST",
1941
1947
  headers: {
@@ -1957,7 +1963,7 @@ async function ho(o, t, e, n = {}) {
1957
1963
  const i = await s.json();
1958
1964
  if (i.error)
1959
1965
  throw new Error(i.error.message || "MCP error");
1960
- const r = (c = (m = (p = i.result) == null ? void 0 : p.content) == null ? void 0 : m[0]) == null ? void 0 : c.text;
1966
+ const r = (l = (m = (p = i.result) == null ? void 0 : p.content) == null ? void 0 : m[0]) == null ? void 0 : l.text;
1961
1967
  if (!r)
1962
1968
  throw new Error(`No content returned from ${e}`);
1963
1969
  return JSON.parse(r);
@@ -1976,11 +1982,11 @@ function ae(o) {
1976
1982
  const wo = () => {
1977
1983
  let o = new URL(import.meta.url).pathname;
1978
1984
  process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1979
- const t = _.dirname(o);
1980
- return _.join(t, "skills");
1985
+ const t = R.dirname(o);
1986
+ return R.join(t, "skills");
1981
1987
  }, vo = (o) => {
1982
1988
  try {
1983
- const t = _.join(o, "package.json");
1989
+ const t = R.join(o, "package.json");
1984
1990
  if (!C.existsSync(t)) return [];
1985
1991
  const e = JSON.parse(C.readFileSync(t, "utf-8"));
1986
1992
  return Object.keys({ ...e.dependencies, ...e.devDependencies });
@@ -1997,9 +2003,9 @@ const wo = () => {
1997
2003
  { deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
1998
2004
  { deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
1999
2005
  { deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
2000
- ], i = s.filter(({ deps: c }) => c.some((d) => e.includes(d))).map(({ skill: c }) => c), r = s.flatMap(({ deps: c }) => c.filter((d) => e.includes(d)));
2001
- i.length > 0 ? n.push(...i) : n.push(...s.map((c) => c.skill));
2002
- const p = n.map((c) => `--skill ${c}`).join(" "), m = `npx -y skills add "${t}" ${p} --agent '*' --copy -y`;
2006
+ ], i = s.filter(({ deps: l }) => l.some((d) => e.includes(d))).map(({ skill: l }) => l), r = s.flatMap(({ deps: l }) => l.filter((d) => e.includes(d)));
2007
+ i.length > 0 ? n.push(...i) : n.push(...s.map((l) => l.skill));
2008
+ const p = n.map((l) => `--skill ${l}`).join(" "), m = `npx -y skills add "${t}" ${p} --agent '*' --copy -y`;
2003
2009
  return Q(m, { cwd: o, stdio: "pipe" }), { success: !0, detected: r, skillNames: n };
2004
2010
  } catch (e) {
2005
2011
  return console.info("Failed to install skills:", e.message), { success: !1 };
@@ -2010,7 +2016,7 @@ const wo = () => {
2010
2016
  try {
2011
2017
  const s = C.readdirSync(o, { withFileTypes: !0 });
2012
2018
  for (const i of s) {
2013
- const r = _.join(o, i.name);
2019
+ const r = R.join(o, i.name);
2014
2020
  if (i.isDirectory()) {
2015
2021
  if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
2016
2022
  continue;
@@ -2021,7 +2027,7 @@ const wo = () => {
2021
2027
  n.push({
2022
2028
  path: o,
2023
2029
  configPath: r,
2024
- name: m.name || m.componentName || _.basename(o),
2030
+ name: m.name || m.componentName || R.basename(o),
2025
2031
  componentId: m.componentId || null,
2026
2032
  config: m
2027
2033
  });
@@ -2063,7 +2069,7 @@ const Ee = (o = !1) => {
2063
2069
  new Le(),
2064
2070
  ...Dt
2065
2071
  ];
2066
- const So = "0.1.52";
2072
+ const So = "0.1.54";
2067
2073
  v.program = new Pt();
2068
2074
  v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(So);
2069
2075
  v.program.addOption(new fe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
@@ -2117,7 +2123,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
2117
2123
  console.error(`⚠️ Failed to parse ${t}:`, u.message);
2118
2124
  }
2119
2125
  o && (e.componentId = o);
2120
- const n = e.name || e.componentName || _.basename(process.cwd());
2126
+ const n = e.name || e.componentName || R.basename(process.cwd());
2121
2127
  console.log(`
2122
2128
  📋 Component: ${n}`);
2123
2129
  let s = null, i = !1;
@@ -2139,20 +2145,20 @@ v.program.command("push").description("Upload component to Myop platform").argum
2139
2145
  let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
2140
2146
  const O = (P = !1) => new Promise((j) => {
2141
2147
  const M = z(P ? "Retrying build..." : "Building project...").start();
2142
- u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (R, k, L) => {
2143
- if (!R) {
2148
+ u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (_, k, L) => {
2149
+ if (!_) {
2144
2150
  M.succeed("Build completed"), j(!0);
2145
2151
  return;
2146
2152
  }
2147
2153
  if (M.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
2148
- const D = await pt(R, k, L, u, E);
2154
+ const D = await pt(_, k, L, u, E);
2149
2155
  if (E = { ...E, ...D }, D.handled) {
2150
2156
  const T = await O(!0);
2151
2157
  j(T);
2152
2158
  return;
2153
2159
  }
2154
2160
  }
2155
- console.error(R.message), j(!1);
2161
+ console.error(_.message), j(!1);
2156
2162
  });
2157
2163
  });
2158
2164
  await O() || process.exit(1);
@@ -2178,10 +2184,10 @@ v.program.command("push").description("Upload component to Myop platform").argum
2178
2184
  [MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
2179
2185
  `)), process.exit(1);
2180
2186
  }
2181
- const c = Me();
2187
+ const l = Me();
2182
2188
  let d = z("Uploading...").start(), y;
2183
2189
  try {
2184
- const u = await fetch(`${c}/mcp`, {
2190
+ const u = await fetch(`${l}/mcp`, {
2185
2191
  method: "POST",
2186
2192
  headers: {
2187
2193
  "Content-Type": "application/json",
@@ -2249,7 +2255,7 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2249
2255
  `)), process.exit(1);
2250
2256
  }
2251
2257
  const p = Me(), m = z("Fetching component...").start();
2252
- let c;
2258
+ let l;
2253
2259
  try {
2254
2260
  const b = await fetch(`${p}/mcp`, {
2255
2261
  method: "POST",
@@ -2273,18 +2279,18 @@ v.program.command("pull").description("Download component HTML from Myop platfor
2273
2279
  if (P.error)
2274
2280
  throw new Error(P.error.message);
2275
2281
  const j = (O = (E = (u = P.result) == null ? void 0 : u.content) == null ? void 0 : E[0]) == null ? void 0 : O.text;
2276
- c = JSON.parse(j), !c.success && !c.html && (m.fail("Failed to fetch component"), console.error(" ", c.error || "No HTML content returned"), c.message && console.error(" ", c.message), process.exit(1)), m.succeed("Component fetched");
2282
+ 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");
2277
2283
  } catch (b) {
2278
2284
  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);
2279
2285
  }
2280
2286
  let d = t.output;
2281
2287
  d || (C.existsSync("./dist/index.html") ? d = "./dist/index.html" : d = "./index.html");
2282
- const y = c.htmlContent || c.html, S = _.dirname(d);
2288
+ const y = l.htmlContent || l.html, S = R.dirname(d);
2283
2289
  S && !C.existsSync(S) && C.mkdirSync(S, { recursive: !0 }), C.writeFileSync(d, y), console.log(` Saved to: ${d} (${(y.length / 1024).toFixed(1)} KB)`);
2284
2290
  const x = C.existsSync(e);
2285
2291
  let g = !1;
2286
- if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && c.name && (n.name = c.name, g = !0)) : (n = {
2287
- name: c.name || _.basename(process.cwd()),
2292
+ if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
2293
+ name: l.name || R.basename(process.cwd()),
2288
2294
  componentId: s,
2289
2295
  type: "html",
2290
2296
  author: "@myop-cli",
@@ -2319,16 +2325,16 @@ v.program.command("list").description("Browse and pull/push remote components").
2319
2325
  r.fail("Failed to load organizations"), re(g) ? (console.error("❌ Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", g.message), process.exit(1);
2320
2326
  }
2321
2327
  p.length === 0 && (r.fail("No organizations found for this account"), process.exit(1)), r.stop();
2322
- let m, c;
2328
+ let m, l;
2323
2329
  if (o.org) {
2324
2330
  const g = p.find((u) => u.id === o.org || u._id === o.org);
2325
- 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, c = g.name, De({ id: m, name: c });
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, De({ id: m, name: l });
2326
2332
  } else {
2327
2333
  const g = go();
2328
2334
  if (g && p.find((u) => (u.id || u._id) === g.id))
2329
- m = g.id, c = g.name;
2335
+ m = g.id, l = g.name;
2330
2336
  else if (p.length === 1)
2331
- m = p[0].id || p[0]._id, c = p[0].name, De({ id: m, name: c });
2337
+ m = p[0].id || p[0]._id, l = p[0].name, De({ id: m, name: l });
2332
2338
  else
2333
2339
  try {
2334
2340
  const u = await e({
@@ -2338,7 +2344,7 @@ v.program.command("list").description("Browse and pull/push remote components").
2338
2344
  value: { id: E.id || E._id, name: E.name }
2339
2345
  }))
2340
2346
  });
2341
- m = u.id, c = u.name, De({ id: m, name: c });
2347
+ m = u.id, l = u.name, De({ id: m, name: l });
2342
2348
  } catch (u) {
2343
2349
  throw u.name === "ExitPromptError" && (console.log(`
2344
2350
 
@@ -2346,7 +2352,7 @@ v.program.command("list").description("Browse and pull/push remote components").
2346
2352
  `), process.exit(0)), u;
2347
2353
  }
2348
2354
  }
2349
- console.log(` Using organization: ${c}`), r = z("Loading components...").start();
2355
+ console.log(` Using organization: ${l}`), r = z("Loading components...").start();
2350
2356
  let d;
2351
2357
  try {
2352
2358
  const g = await i("list_components", { organizationId: m });
@@ -2356,7 +2362,7 @@ v.program.command("list").description("Browse and pull/push remote components").
2356
2362
  r.fail("Failed to load components"), console.error(" ", g.message), process.exit(1);
2357
2363
  }
2358
2364
  r.stop(), d.length === 0 && (console.log(` No components found in this organization.
2359
- `), process.exit(0)), console.log(` ${c} - ${d.length} component(s)
2365
+ `), process.exit(0)), console.log(` ${l} - ${d.length} component(s)
2360
2366
  `);
2361
2367
  const y = [];
2362
2368
  for (; ; ) {
@@ -2369,17 +2375,17 @@ v.program.command("list").description("Browse and pull/push remote components").
2369
2375
  const j = (P || "").toLowerCase(), M = d.filter((k) => {
2370
2376
  const L = k.id || k._id || k.componentId;
2371
2377
  return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
2372
- }), R = [
2378
+ }), _ = [
2373
2379
  { name: g, value: u }
2374
2380
  ];
2375
2381
  for (const k of M) {
2376
2382
  const L = k.id || k._id || k.componentId, D = L ? L.substring(0, 8) + "..." : "";
2377
- R.push({
2383
+ _.push({
2378
2384
  name: `${k.name} (${D})`,
2379
2385
  value: L
2380
2386
  });
2381
2387
  }
2382
- return R;
2388
+ return _;
2383
2389
  }
2384
2390
  });
2385
2391
  } catch (P) {
@@ -2426,7 +2432,7 @@ v.program.command("list").description("Browse and pull/push remote components").
2426
2432
  const M = P.htmlContent || P.html;
2427
2433
  if (!M)
2428
2434
  throw new Error("No HTML content returned");
2429
- return C.writeFileSync(_.join(j, "index.html"), M), C.writeFileSync(_.join(j, "myop.config.json"), JSON.stringify({
2435
+ return C.writeFileSync(R.join(j, "index.html"), M), C.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
2430
2436
  name: O.name,
2431
2437
  componentId: b,
2432
2438
  organization: m,
@@ -2449,26 +2455,26 @@ v.program.command("list").description("Browse and pull/push remote components").
2449
2455
  Pushing ${y.length} components...
2450
2456
  `);
2451
2457
  const g = Qe(".", 3), u = await Promise.all(y.map(async (P) => {
2452
- const j = P.id || P._id || P.componentId, M = g.find((R) => R.componentId === j);
2458
+ const j = P.id || P._id || P.componentId, M = g.find((_) => _.componentId === j);
2453
2459
  if (!M)
2454
2460
  return { name: P.name, status: "skipped", reason: "no local match" };
2455
2461
  try {
2456
- let R;
2462
+ let _;
2457
2463
  const k = M.path;
2458
- if (C.existsSync(_.join(k, "dist", "index.html")))
2459
- R = _.join(k, "dist", "index.html");
2464
+ if (C.existsSync(R.join(k, "dist", "index.html")))
2465
+ _ = R.join(k, "dist", "index.html");
2460
2466
  else {
2461
2467
  const W = C.readdirSync(k).filter(
2462
- (N) => N.endsWith(".html") && !N.startsWith(".") && C.statSync(_.join(k, N)).isFile()
2468
+ (N) => N.endsWith(".html") && !N.startsWith(".") && C.statSync(R.join(k, N)).isFile()
2463
2469
  );
2464
2470
  if (W.length === 1)
2465
- R = _.join(k, W[0]);
2471
+ _ = R.join(k, W[0]);
2466
2472
  else if (W.includes("index.html"))
2467
- R = _.join(k, "index.html");
2473
+ _ = R.join(k, "index.html");
2468
2474
  else
2469
2475
  throw new Error("No HTML file found");
2470
2476
  }
2471
- const L = C.readFileSync(R, "utf-8"), D = M.name || P.name, T = await i("upload_component", {
2477
+ const L = C.readFileSync(_, "utf-8"), D = M.name || P.name, T = await i("upload_component", {
2472
2478
  name: D,
2473
2479
  componentId: j,
2474
2480
  organization: m,
@@ -2477,8 +2483,8 @@ v.program.command("list").description("Browse and pull/push remote components").
2477
2483
  if (!T.success)
2478
2484
  throw new Error(T.error || "Upload failed");
2479
2485
  return { name: D, status: "ok" };
2480
- } catch (R) {
2481
- return { name: P.name, status: "failed", error: R.message };
2486
+ } catch (_) {
2487
+ return { name: P.name, status: "failed", error: _.message };
2482
2488
  }
2483
2489
  }));
2484
2490
  let E = 0, O = 0, b = 0;
@@ -2642,7 +2648,6 @@ v.program.command("create").description("Create a new Myop HTML component and st
2642
2648
  ✅ Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Ce();
2643
2649
  });
2644
2650
  v.program.command("dev").description("Start development server with file watching").action(Ce);
2645
- Kt();
2646
2651
  const yt = async () => {
2647
2652
  const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Ke(o);
2648
2653
  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,7 +2659,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2654
2659
  {
2655
2660
  name: "Claude Code",
2656
2661
  value: "claude",
2657
- configPath: _.join(n, ".claude.json"),
2662
+ configPath: R.join(n, ".claude.json"),
2658
2663
  getEntry: () => ({ type: "http", url: s }),
2659
2664
  nextSteps: [
2660
2665
  "Restart Claude Code to pick up the new MCP config.",
@@ -2666,7 +2671,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2666
2671
  {
2667
2672
  name: "Cursor",
2668
2673
  value: "cursor",
2669
- configPath: _.join(n, ".cursor", "mcp.json"),
2674
+ configPath: R.join(n, ".cursor", "mcp.json"),
2670
2675
  getEntry: () => ({ url: s }),
2671
2676
  nextSteps: [
2672
2677
  'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
@@ -2679,7 +2684,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2679
2684
  {
2680
2685
  name: "Windsurf",
2681
2686
  value: "windsurf",
2682
- configPath: _.join(n, ".codeium", "windsurf", "mcp_config.json"),
2687
+ configPath: R.join(n, ".codeium", "windsurf", "mcp_config.json"),
2683
2688
  getEntry: () => ({ url: s }),
2684
2689
  nextSteps: [
2685
2690
  "Open Cascade and click the hammer icon (top-right) to see MCP servers.",
@@ -2691,7 +2696,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2691
2696
  {
2692
2697
  name: "VS Code (GitHub Copilot)",
2693
2698
  value: "vscode",
2694
- configPath: process.platform === "darwin" ? _.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? _.join(process.env.APPDATA || _.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : _.join(n, ".config", "Code", "User", "mcp.json"),
2699
+ configPath: process.platform === "darwin" ? R.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? R.join(process.env.APPDATA || R.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : R.join(n, ".config", "Code", "User", "mcp.json"),
2695
2700
  getEntry: () => ({ type: "http", url: s }),
2696
2701
  nextSteps: [
2697
2702
  "Requires VS Code 1.99+ and GitHub Copilot extension.",
@@ -2726,8 +2731,8 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2726
2731
  } catch {
2727
2732
  }
2728
2733
  m.mcpServers || (m.mcpServers = {});
2729
- const c = m.mcpServers.myop;
2730
- if (c && c.url === s) {
2734
+ const l = m.mcpServers.myop;
2735
+ if (l && l.url === s) {
2731
2736
  console.log(`
2732
2737
  Myop MCP is already configured for ${p.name}.`), console.log(` Config: ${p.configPath}`), console.log(`
2733
2738
  \x1B[1mNext steps:\x1B[0m`);
@@ -2735,16 +2740,16 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
2735
2740
  console.log(` ${d}`);
2736
2741
  console.log(""), process.exit(0);
2737
2742
  }
2738
- if (c) {
2743
+ if (l) {
2739
2744
  console.log(`
2740
- Myop MCP is already configured (URL: ${c.url}).`);
2745
+ Myop MCP is already configured (URL: ${l.url}).`);
2741
2746
  try {
2742
2747
  await t({ message: "Update to latest URL?", default: !0 }) || process.exit(0);
2743
2748
  } catch (d) {
2744
2749
  throw d.name === "ExitPromptError" && process.exit(0), d;
2745
2750
  }
2746
2751
  }
2747
- m.mcpServers.myop = p.getEntry(), C.mkdirSync(_.dirname(p.configPath), { recursive: !0 }), C.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
2752
+ m.mcpServers.myop = p.getEntry(), C.mkdirSync(R.dirname(p.configPath), { recursive: !0 }), C.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
2748
2753
  \x1B[32m✔\x1B[0m Myop MCP configured for ${p.name}`), console.log(` Config: ${p.configPath}`), console.log(` Server: ${s}`), console.log(`
2749
2754
  \x1B[1mNext steps:\x1B[0m`);
2750
2755
  for (const d of p.nextSteps)
@@ -2835,9 +2840,9 @@ const xo = () => {
2835
2840
  value: "exit"
2836
2841
  }
2837
2842
  );
2838
- let c;
2843
+ let l;
2839
2844
  try {
2840
- c = await st({
2845
+ l = await st({
2841
2846
  message: "What would you like to do?",
2842
2847
  choices: m
2843
2848
  });
@@ -2847,7 +2852,7 @@ const xo = () => {
2847
2852
  👋 Goodbye!
2848
2853
  `), process.exit(0)), x;
2849
2854
  }
2850
- switch (c) {
2855
+ switch (l) {
2851
2856
  case "init":
2852
2857
  await Po();
2853
2858
  break;
@@ -2939,11 +2944,11 @@ Pushing component...
2939
2944
  ⚠️ No components selected.
2940
2945
  `), process.exit(0)), p || (bo(m), console.log(`
2941
2946
  💾 Selection saved to ${be}`));
2942
- const c = n.filter((y) => m.includes(y.path));
2943
- console.log(`🚀 Starting dev mode for ${c.length} component${c.length > 1 ? "s" : ""}...
2947
+ const l = n.filter((y) => m.includes(y.path));
2948
+ console.log(`🚀 Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
2944
2949
  `);
2945
2950
  const { monorepoDevCommand: d } = await Promise.resolve().then(() => Wt);
2946
- await d(c);
2951
+ await d(l);
2947
2952
  }, Po = async () => {
2948
2953
  const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
2949
2954
  let i, r;
@@ -2960,11 +2965,11 @@ Pushing component...
2960
2965
  { name: "🅰️ Angular", value: "angular", disabled: "(coming soon)" }
2961
2966
  ]
2962
2967
  });
2963
- } catch (c) {
2964
- throw c.name === "ExitPromptError" && (console.log(`
2968
+ } catch (l) {
2969
+ throw l.name === "ExitPromptError" && (console.log(`
2965
2970
 
2966
2971
  👋 Goodbye!
2967
- `), process.exit(0)), c;
2972
+ `), process.exit(0)), l;
2968
2973
  }
2969
2974
  const p = {
2970
2975
  name: i,
@@ -2975,7 +2980,7 @@ Pushing component...
2975
2980
  try {
2976
2981
  e.writeFileSync(m, JSON.stringify(p, null, 2)), console.log(`
2977
2982
  ✅ Created ${m}`);
2978
- const c = {
2983
+ const l = {
2979
2984
  name: i.toLowerCase().replace(/\s+/g, "-"),
2980
2985
  version: "1.0.0",
2981
2986
  type: "module",
@@ -2987,7 +2992,7 @@ Pushing component...
2987
2992
  esbuild: "^0.24.0"
2988
2993
  }
2989
2994
  };
2990
- e.writeFileSync("package.json", JSON.stringify(c, null, 2)), console.log("✅ Created package.json"), e.mkdirSync("src/modules", { recursive: !0 }), e.mkdirSync("src/styles", { recursive: !0 }), e.writeFileSync("build.js", `import * as esbuild from 'esbuild';
2995
+ e.writeFileSync("package.json", JSON.stringify(l, null, 2)), console.log("✅ Created package.json"), e.mkdirSync("src/modules", { recursive: !0 }), e.mkdirSync("src/styles", { recursive: !0 }), e.writeFileSync("build.js", `import * as esbuild from 'esbuild';
2991
2996
  import fs from 'fs';
2992
2997
  import path from 'path';
2993
2998
 
@@ -3177,12 +3182,12 @@ dist/
3177
3182
  "src/styles/main.css"
3178
3183
  ];
3179
3184
  if (b.success) {
3180
- const R = (k, L) => {
3185
+ const _ = (k, L) => {
3181
3186
  try {
3182
3187
  const D = e.readdirSync(k, { withFileTypes: !0 });
3183
3188
  for (const T of D) {
3184
3189
  const W = n.join(k, T.name), N = n.join(L, T.name);
3185
- T.isDirectory() ? R(W, N) : M.push(N);
3190
+ T.isDirectory() ? _(W, N) : M.push(N);
3186
3191
  }
3187
3192
  } catch {
3188
3193
  }
@@ -3192,13 +3197,13 @@ dist/
3192
3197
  for (const L of k)
3193
3198
  if (L.isDirectory() && L.name.startsWith(".")) {
3194
3199
  const D = n.join(L.name, "skills");
3195
- e.existsSync(D) && R(D, D);
3200
+ e.existsSync(D) && _(D, D);
3196
3201
  }
3197
3202
  } catch {
3198
3203
  }
3199
3204
  }
3200
- for (const R of M)
3201
- await P.add({ fs: e, dir: j, filepath: R });
3205
+ for (const _ of M)
3206
+ await P.add({ fs: e, dir: j, filepath: _ });
3202
3207
  await P.commit({
3203
3208
  fs: e,
3204
3209
  dir: j,
@@ -3211,8 +3216,8 @@ dist/
3211
3216
  console.log(`
3212
3217
  📦 Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
3213
3218
  `), v.myopConfig = p, await ne(!0);
3214
- } catch (c) {
3215
- console.error(`Failed to initialize component: ${c.message}`), process.exit(1);
3219
+ } catch (l) {
3220
+ console.error(`Failed to initialize component: ${l.message}`), process.exit(1);
3216
3221
  }
3217
3222
  };
3218
3223
  v.program.command("default", { isDefault: !0 }).action(async () => {
@@ -3221,7 +3226,7 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
3221
3226
  return;
3222
3227
  }
3223
3228
  if (v.program.getOptionValue("ci")) {
3224
- const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", c = v.program.version(), d = Pe();
3229
+ const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), d = Pe();
3225
3230
  let y = { found: !1 };
3226
3231
  try {
3227
3232
  if (p.existsSync(m)) {
@@ -3238,7 +3243,7 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
3238
3243
  y = { found: !1, error: x.message };
3239
3244
  }
3240
3245
  const S = {
3241
- version: c,
3246
+ version: l,
3242
3247
  config: y,
3243
3248
  auth: {
3244
3249
  loggedIn: !!(d != null && d.email),
@@ -3256,5 +3261,6 @@ v.program.command("default", { isDefault: !0 }).action(async () => {
3256
3261
  const i = v.program.version();
3257
3262
  await mo(i) || await ne(s.configFound);
3258
3263
  });
3264
+ Kt();
3259
3265
  v.program.parse(process.argv);
3260
3266
  v.program.opts();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myop/cli",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "description": "Myop cli",
5
5
  "type": "module",
6
6
  "repository": {