@myop/cli 0.1.41 β†’ 0.1.45

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 CHANGED
@@ -2,15 +2,15 @@
2
2
  var ut = Object.defineProperty;
3
3
  var gt = (o, e, t) => e in o ? ut(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
4
4
  var ye = (o, e, t) => gt(o, typeof e != "symbol" ? e + "" : e, t);
5
- import G from "ora";
6
- import { select as Ye, Separator as Fe } from "@inquirer/prompts";
5
+ import V from "ora";
6
+ import { select as Qe, Separator as ke } from "@inquirer/prompts";
7
7
  import { Command as ft, Option as me } from "commander";
8
8
  import { execSync as q, spawn as ht } from "child_process";
9
- import H, { join as Oe } from "path";
10
- import R, { readFileSync as yt } from "fs";
9
+ import D, { join as Oe } from "path";
10
+ import I, { readFileSync as yt } from "fs";
11
11
  import Le from "crypto";
12
12
  import wt from "http";
13
- import { URL as Ke, URLSearchParams as Qe } from "url";
13
+ import { URL as Ze, URLSearchParams as Xe } from "url";
14
14
  import St from "open";
15
15
  import vt from "os";
16
16
  const bt = `
@@ -47,7 +47,7 @@ Examples:
47
47
 
48
48
 
49
49
 
50
- `, y = {
50
+ `, h = {
51
51
  program: null,
52
52
  executionPath: "",
53
53
  options: {
@@ -55,48 +55,48 @@ Examples:
55
55
  verbose: !1
56
56
  },
57
57
  myopConfig: null
58
- }, Ze = {
58
+ }, qe = {
59
59
  name: "πŸ“₯ Install Myop generated dependencies",
60
60
  value: "myopInstall",
61
61
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
62
62
  action: async () => {
63
63
  console.info("installing... ");
64
- for (const o of y.myopConfig.flows) {
65
- const e = H.join(y.executionPath, "/node_modules/@myop/flow-types/");
64
+ for (const o of h.myopConfig.flows) {
65
+ const e = D.join(h.executionPath, "/node_modules/@myop/flow-types/");
66
66
  console.info(`Generate flow at ${e}`), console.info(`Generated flow at ${e}`);
67
67
  }
68
68
  process.exit();
69
69
  }
70
70
  }, xt = (o) => {
71
- const e = H.join(y.executionPath, o);
71
+ const e = D.join(h.executionPath, o);
72
72
  console.info(`reading config file from: ${e}`);
73
- const t = R.readFileSync(e, "utf8"), n = JSON.parse(t);
73
+ const t = I.readFileSync(e, "utf8"), n = JSON.parse(t);
74
74
  return console.info("config file loaded, ", n), n;
75
- }, Ae = (o, e) => {
76
- const t = H.join(y.executionPath, o);
75
+ }, De = (o, e) => {
76
+ const t = D.join(h.executionPath, o);
77
77
  console.info(`writing config file to: ${t}`);
78
78
  try {
79
79
  const n = JSON.stringify(e, null, 2);
80
- R.writeFileSync(t, n), console.info(`config file updated ${n}`);
80
+ I.writeFileSync(t, n), console.info(`config file updated ${n}`);
81
81
  } catch (n) {
82
82
  throw console.info(`error ${n} while writing to ${t}, JSON: ${e}`), console.log(`
83
83
  ⚠️ Failed write config file to ${t}, for more info use verbose flag`), n;
84
84
  }
85
- }, Xe = {
85
+ }, et = {
86
86
  name: "🌟 Add flow definition to your project",
87
87
  value: "addFlow",
88
88
  description: "Adds flow to yours myop.config.json",
89
89
  _action: (o) => {
90
- y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o), Ae(y.options.configPath, y.myopConfig);
90
+ h.myopConfig.flows.includes(o) || h.myopConfig.flows.push(o), De(h.options.configPath, h.myopConfig);
91
91
  },
92
92
  action: async () => {
93
93
  }
94
- }, qe = {
94
+ }, tt = {
95
95
  name: "🚫 Remove flow definition from your project",
96
96
  value: "removeFlow",
97
97
  description: "Removes flow to yours myop.config.json",
98
98
  _action: (o) => {
99
- y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o), Ae(y.options.configPath, y.myopConfig);
99
+ h.myopConfig.flows = h.myopConfig.flows.filter((e) => e !== o), De(h.options.configPath, h.myopConfig);
100
100
  },
101
101
  action: () => {
102
102
  }
@@ -123,13 +123,13 @@ Examples:
123
123
  name: "πŸ”΄ Create new flow",
124
124
  value: "-",
125
125
  disabled: "(not available yet)"
126
- }, Rt = {
126
+ }, It = {
127
127
  name: "πŸ†• Define new custom Myop message",
128
128
  value: "generateMyopMessage",
129
129
  description: "️Help you creates the right structure for a new Myop message, including types and handlers.",
130
130
  disabled: "(not available yet)"
131
- }, Et = [Rt, Ct, Mt, Pt, Tt];
132
- function It(o, e, t, n) {
131
+ }, Et = [It, Ct, Mt, Pt, Tt];
132
+ function Rt(o, e, t, n) {
133
133
  return `<!DOCTYPE html>
134
134
  <html lang="en">
135
135
  <head>
@@ -222,16 +222,16 @@ ${n}
222
222
  function Ot(o) {
223
223
  return o.includes("esbuild") && o.includes("another platform");
224
224
  }
225
- function kt(o) {
225
+ function Ft(o) {
226
226
  return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
227
227
  }
228
- function Ft() {
228
+ function kt() {
229
229
  console.error(`
230
230
  ❌ esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
231
231
  This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows β†’ Mac, or Mac β†’ Linux).
232
232
  `);
233
233
  }
234
- function jt(o) {
234
+ function Nt(o) {
235
235
  return new Promise((e) => {
236
236
  console.log(`πŸ”§ Attempting to fix: removing node_modules and reinstalling...
237
237
  `);
@@ -255,20 +255,20 @@ function jt(o) {
255
255
  });
256
256
  });
257
257
  }
258
- async function et(o, e, t, n, i = {}) {
258
+ async function ot(o, e, t, n, i = {}) {
259
259
  const {
260
260
  hasTriedPlatformFix: s = !1,
261
261
  hasTriedInstall: l = !1,
262
262
  onRetry: w
263
- } = i, v = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
264
- return !s && Ot(v) ? (Ft(), await jt(n) && w ? (console.log(`πŸ”„ Retrying build...
265
- `), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : !l && kt(v) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((m) => {
266
- n("npm install", (d, C, u) => {
267
- if (d) {
268
- console.error("❌ Failed to install dependencies:", d.message), u && console.error(u), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
263
+ } = i, S = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
264
+ return !s && Ot(S) ? (kt(), await Nt(n) && w ? (console.log(`πŸ”„ Retrying build...
265
+ `), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: l }) : !l && Ft(S) ? (console.log("πŸ“¦ Missing dependencies detected, running npm install..."), new Promise((d) => {
266
+ n("npm install", (c, $, u) => {
267
+ if (c) {
268
+ console.error("❌ Failed to install dependencies:", c.message), u && console.error(u), d({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
269
269
  return;
270
270
  }
271
- console.log("βœ… Dependencies installed"), w && w(), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
271
+ console.log("βœ… Dependencies installed"), w && w(), d({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
272
272
  });
273
273
  })) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: l };
274
274
  }
@@ -276,13 +276,13 @@ async function be() {
276
276
  const o = await import("fs"), e = await import("path"), { exec: t } = await import("child_process"), n = await import("http"), { createHash: i } = await import("node:crypto");
277
277
  let s;
278
278
  if (import.meta.url.startsWith("file://")) {
279
- const r = new URL(import.meta.url).pathname, c = process.platform === "win32" && r.startsWith("/") ? r.slice(1) : r;
280
- s = e.default.dirname(c);
279
+ const r = new URL(import.meta.url).pathname, p = process.platform === "win32" && r.startsWith("/") ? r.slice(1) : r;
280
+ s = e.default.dirname(p);
281
281
  } else
282
282
  s = e.default.dirname(import.meta.url);
283
- const l = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(l, "styles.css"), "utf-8"), v = o.default.readFileSync(e.default.join(l, "app.js"), "utf-8"), m = 9292, d = 9293;
284
- let C = "./dist", u = !1, S = !1, M = !1, T = null;
285
- const D = () => {
283
+ const l = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(l, "styles.css"), "utf-8"), S = o.default.readFileSync(e.default.join(l, "app.js"), "utf-8"), d = 9292, c = 9293;
284
+ let $ = "./dist", u = !1, y = !1, C = !1, T = null;
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());
288
288
  if (a.length === 1)
@@ -297,37 +297,37 @@ async function be() {
297
297
  } catch {
298
298
  return !1;
299
299
  }
300
- }, x = (a) => {
300
+ }, b = (a) => {
301
301
  const r = process.platform;
302
- let c;
303
- r === "darwin" ? c = `open "${a}"` : r === "win32" ? c = `start "" "${a}"` : c = `xdg-open "${a}"`, t(c, (p) => {
302
+ let p;
303
+ r === "darwin" ? p = `open "${a}"` : r === "win32" ? p = `start "" "${a}"` : p = `xdg-open "${a}"`, t(p, (m) => {
304
304
  });
305
- }, j = /* @__PURE__ */ new Map(), b = y.program.getOptionValue("config") || "./myop.config.json";
306
- let f, E, _ = !1;
307
- T = D();
305
+ }, F = /* @__PURE__ */ new Map(), x = h.program.getOptionValue("config") || "./myop.config.json";
306
+ let f, E, L = !1;
307
+ T = j();
308
308
  const B = P();
309
309
  try {
310
- const a = o.default.readFileSync(b, "utf-8"), r = JSON.parse(a);
311
- f = r.componentId || "DEV", E = r.componentName || r.name || null, _ = r.HMR === !0, T && !B && (M = !0, _ = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`)), _ && console.log("πŸ”₯ HMR enabled");
310
+ const a = o.default.readFileSync(x, "utf-8"), r = JSON.parse(a);
311
+ f = r.componentId || "DEV", E = r.componentName || r.name || null, L = r.HMR === !0, T && !B && (C = !0, L = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`)), L && console.log("πŸ”₯ HMR enabled");
312
312
  } catch (a) {
313
- T && !B ? (M = !0, f = "DEV", E = e.default.basename(T, ".html"), _ = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", a.message), process.exit(1));
313
+ T && !B ? (C = !0, f = "DEV", E = e.default.basename(T, ".html"), L = !0, console.log(`πŸ“„ Single HTML file mode: ${T}`), console.log("πŸ”₯ HMR enabled")) : (console.error("❌ Error reading myop.config.json:", a.message), process.exit(1));
314
314
  }
315
315
  const U = async () => {
316
316
  if (f !== "DEV" && f !== "NEW")
317
317
  return f;
318
318
  try {
319
- const r = ((await new Promise((g, h) => {
320
- const $ = {
319
+ const r = ((await new Promise((g, v) => {
320
+ const M = {
321
321
  hostname: "localhost",
322
- port: d,
322
+ port: c,
323
323
  path: "/_list",
324
324
  method: "GET",
325
325
  timeout: 1e3
326
- }, O = n.default.request($, (L) => {
327
- let V = "";
328
- L.on("data", (te) => V += te), L.on("end", () => {
326
+ }, O = n.default.request(M, (A) => {
327
+ let G = "";
328
+ A.on("data", (te) => G += te), A.on("end", () => {
329
329
  try {
330
- g(JSON.parse(V));
330
+ g(JSON.parse(G));
331
331
  } catch {
332
332
  g({ components: [] });
333
333
  }
@@ -339,12 +339,12 @@ async function be() {
339
339
  })).components || []).map(([g]) => g).filter((g) => g === "DEV" || g === "NEW" || /^DEV\d+$/.test(g) || /^NEW\d+$/.test(g));
340
340
  if (r.length === 0)
341
341
  return "DEV1";
342
- const c = r.map((g) => {
342
+ const p = r.map((g) => {
343
343
  if (g === "DEV" || g === "NEW") return 1;
344
- const h = g.match(/^DEV(\d+)$/), $ = g.match(/^NEW(\d+)$/);
345
- return h ? parseInt(h[1], 10) : $ ? parseInt($[1], 10) : 0;
344
+ const v = g.match(/^DEV(\d+)$/), M = g.match(/^NEW(\d+)$/);
345
+ return v ? parseInt(v[1], 10) : M ? parseInt(M[1], 10) : 0;
346
346
  }).filter((g) => g > 0);
347
- return `DEV${Math.max(...c, 0) + 1}`;
347
+ return `DEV${Math.max(...p, 0) + 1}`;
348
348
  } catch {
349
349
  return "DEV1";
350
350
  }
@@ -361,67 +361,67 @@ async function be() {
361
361
  ".svg": "image/svg+xml",
362
362
  ".ico": "image/x-icon"
363
363
  }[r] || "application/octet-stream";
364
- }, I = /* @__PURE__ */ new Map(), Z = [], se = 50, Y = [], ie = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), lt = (a, r, c) => {
364
+ }, R = /* @__PURE__ */ new Map(), Z = [], se = 50, Y = [], ie = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), lt = (a, r, p) => {
365
365
  if (a.url.startsWith("/_hmr/")) {
366
- const p = a.url.split("/_hmr/")[1], g = a.headers["sec-websocket-key"], h = i("sha1").update(g + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
366
+ const m = a.url.split("/_hmr/")[1], g = a.headers["sec-websocket-key"], v = i("sha1").update(g + "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: ${h}\r
371
+ Sec-WebSocket-Accept: ${v}\r
372
372
  \r
373
373
  `
374
- ), ee.has(p) || ee.set(p, /* @__PURE__ */ new Set()), ee.get(p).add(r), console.log(`πŸ”Œ HMR client connected: ${p}`), r.on("close", () => {
375
- const $ = ee.get(p);
376
- $ && ($.delete(r), $.size === 0 && ee.delete(p)), console.log(`πŸ”Œ HMR client disconnected: ${p}`);
374
+ ), ee.has(m) || ee.set(m, /* @__PURE__ */ new Set()), ee.get(m).add(r), console.log(`πŸ”Œ HMR client connected: ${m}`), r.on("close", () => {
375
+ const M = ee.get(m);
376
+ M && (M.delete(r), M.size === 0 && ee.delete(m)), console.log(`πŸ”Œ HMR client disconnected: ${m}`);
377
377
  }), r.on("error", () => {
378
- const $ = ee.get(p);
379
- $ && $.delete(r);
378
+ const M = ee.get(m);
379
+ M && M.delete(r);
380
380
  });
381
381
  }
382
382
  }, Ce = n.default.createServer((a, r) => {
383
383
  if (r.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
384
- let c = "";
385
- a.on("data", (p) => c += p), a.on("end", () => {
384
+ let p = "";
385
+ a.on("data", (m) => p += m), a.on("end", () => {
386
386
  try {
387
- const { componentId: p, distPath: g, componentName: h, htmlFile: $ } = JSON.parse(c);
388
- I.set(p, { path: g, name: h || null, htmlFile: $ || null });
389
- const O = h ? ` (${h})` : "";
390
- console.log(`βœ… Registered: ${p}${O} -> ${g}${$ ? "/" + $ : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(I.keys()) }));
391
- const L = Array.from(I.entries()).map(([V, te]) => ({
392
- id: V,
387
+ const { componentId: m, distPath: g, componentName: v, htmlFile: M } = JSON.parse(p);
388
+ R.set(m, { path: g, name: v || null, htmlFile: M || null });
389
+ const O = v ? ` (${v})` : "";
390
+ console.log(`βœ… Registered: ${m}${O} -> ${g}${M ? "/" + M : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(R.keys()) }));
391
+ const A = Array.from(R.entries()).map(([G, te]) => ({
392
+ id: G,
393
393
  path: te.path,
394
394
  name: te.name
395
395
  }));
396
- Y.forEach((V) => {
396
+ Y.forEach((G) => {
397
397
  try {
398
- V.write(`data: ${JSON.stringify({
398
+ G.write(`data: ${JSON.stringify({
399
399
  type: "components",
400
- components: L
400
+ components: A
401
401
  })}
402
402
 
403
403
  `);
404
404
  } catch {
405
405
  }
406
406
  });
407
- } catch (p) {
408
- r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
407
+ } catch (m) {
408
+ r.writeHead(400), r.end(JSON.stringify({ error: m.message }));
409
409
  }
410
410
  });
411
411
  } else if (a.method === "POST" && a.url === "/_unregister") {
412
- let c = "";
413
- a.on("data", (p) => c += p), a.on("end", () => {
412
+ let p = "";
413
+ a.on("data", (m) => p += m), a.on("end", () => {
414
414
  try {
415
- const { componentId: p } = JSON.parse(c);
416
- I.delete(p), console.log(`❌ Unregistered: ${p}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
417
- const g = Array.from(I.entries()).map(([h, $]) => ({
418
- id: h,
419
- path: $.path,
420
- name: $.name
415
+ const { componentId: m } = JSON.parse(p);
416
+ R.delete(m), console.log(`❌ Unregistered: ${m}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
417
+ const g = Array.from(R.entries()).map(([v, M]) => ({
418
+ id: v,
419
+ path: M.path,
420
+ name: M.name
421
421
  }));
422
- Y.forEach((h) => {
422
+ Y.forEach((v) => {
423
423
  try {
424
- h.write(`data: ${JSON.stringify({
424
+ v.write(`data: ${JSON.stringify({
425
425
  type: "components",
426
426
  components: g
427
427
  })}
@@ -430,31 +430,31 @@ Sec-WebSocket-Accept: ${h}\r
430
430
  } catch {
431
431
  }
432
432
  });
433
- } catch (p) {
434
- r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
433
+ } catch (m) {
434
+ r.writeHead(400), r.end(JSON.stringify({ error: m.message }));
435
435
  }
436
436
  });
437
437
  } else if (a.method === "GET" && a.url === "/_list")
438
- r.writeHead(200), r.end(JSON.stringify({ components: Array.from(I.entries()) }));
438
+ r.writeHead(200), r.end(JSON.stringify({ components: Array.from(R.entries()) }));
439
439
  else if (a.method === "POST" && a.url === "/_hmr_notify") {
440
- let c = "";
441
- a.on("data", (p) => c += p), a.on("end", () => {
440
+ let p = "";
441
+ a.on("data", (m) => p += m), a.on("end", () => {
442
442
  try {
443
- const { componentId: p, html: g } = JSON.parse(c), h = ee.get(p);
444
- if (h && h.size > 0) {
445
- console.log(`πŸ”₯ Notifying ${h.size} HMR client(s) for: ${p}`);
446
- const $ = JSON.stringify({ type: "update", html: g }), O = Je($);
447
- h.forEach((L) => {
443
+ const { componentId: m, html: g } = JSON.parse(p), v = ee.get(m);
444
+ if (v && v.size > 0) {
445
+ console.log(`πŸ”₯ Notifying ${v.size} HMR client(s) for: ${m}`);
446
+ const M = JSON.stringify({ type: "update", html: g }), O = ze(M);
447
+ v.forEach((A) => {
448
448
  try {
449
- L.write(O);
449
+ A.write(O);
450
450
  } catch {
451
- h.delete(L);
451
+ v.delete(A);
452
452
  }
453
- }), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: h.size }));
453
+ }), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: v.size }));
454
454
  } else
455
455
  r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
456
- } catch (p) {
457
- r.writeHead(400), r.end(JSON.stringify({ error: p.message }));
456
+ } catch (m) {
457
+ r.writeHead(400), r.end(JSON.stringify({ error: m.message }));
458
458
  }
459
459
  });
460
460
  } else
@@ -464,51 +464,51 @@ Sec-WebSocket-Accept: ${h}\r
464
464
  r.writeHead(403, { "Content-Type": "text/plain" }), r.end("Forbidden");
465
465
  return;
466
466
  }
467
- const c = new URL(a.url, `http://localhost:${m}`), p = c.pathname, g = p.split("/").filter((J) => J);
468
- if (p.startsWith("/consume")) {
469
- const J = c.searchParams.get("id");
467
+ const p = new URL(a.url, `http://localhost:${d}`), m = p.pathname, g = m.split("/").filter((J) => J);
468
+ if (m.startsWith("/consume")) {
469
+ const J = p.searchParams.get("id");
470
470
  if (!J) {
471
471
  r.writeHead(400, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
472
472
  return;
473
473
  }
474
- const W = I.get(J), K = W ? W.path : null, ce = (oe) => {
475
- let N = "Unknown", Q = "Unknown";
474
+ const W = R.get(J), K = W ? W.path : null, ce = (oe) => {
475
+ let _ = "Unknown", Q = "Unknown";
476
476
  if (a.headers.referer || a.headers.referrer) {
477
- const A = a.headers.referer || a.headers.referrer;
477
+ const H = a.headers.referer || a.headers.referrer;
478
478
  try {
479
- const re = new URL(A);
480
- N = re.origin, Q = re.hostname || re.origin;
479
+ const re = new URL(H);
480
+ _ = re.origin, Q = re.hostname || re.origin;
481
481
  } catch {
482
- N = A, Q = A;
482
+ _ = H, Q = H;
483
483
  }
484
484
  } else if (a.headers.origin)
485
485
  try {
486
- const A = new URL(a.headers.origin);
487
- N = A.origin, Q = A.hostname || A.origin;
486
+ const H = new URL(a.headers.origin);
487
+ _ = H.origin, Q = H.hostname || H.origin;
488
488
  } catch {
489
- N = a.headers.origin, Q = a.headers.origin;
489
+ _ = a.headers.origin, Q = a.headers.origin;
490
490
  }
491
491
  else if (a.socket.remoteAddress) {
492
- const A = a.socket.remoteAddress;
493
- A === "::1" || A === "::ffff:127.0.0.1" ? (N = "localhost", Q = "localhost (direct)") : (N = A, Q = A.replace("::ffff:", ""));
492
+ const H = a.socket.remoteAddress;
493
+ H === "::1" || H === "::ffff:127.0.0.1" ? (_ = "localhost", Q = "localhost (direct)") : (_ = H, Q = H.replace("::ffff:", ""));
494
494
  }
495
- const Ee = a.headers.referer || a.headers.referrer || N, he = {
495
+ const Ee = a.headers.referer || a.headers.referrer || _, he = {
496
496
  type: "request",
497
497
  componentId: J,
498
498
  timestamp: Date.now(),
499
499
  servedLocally: oe,
500
500
  referrer: Ee,
501
- origin: N,
501
+ origin: _,
502
502
  originLabel: Q
503
503
  };
504
- ie.has(N) || (ie.set(N, {
505
- url: N,
504
+ ie.has(_) || (ie.set(_, {
505
+ url: _,
506
506
  label: Q,
507
507
  firstSeen: Date.now(),
508
508
  requestCount: 0
509
- }), Y.forEach((A) => {
509
+ }), Y.forEach((H) => {
510
510
  try {
511
- A.write(`data: ${JSON.stringify({
511
+ H.write(`data: ${JSON.stringify({
512
512
  type: "origins",
513
513
  origins: Array.from(ie.values())
514
514
  })}
@@ -517,10 +517,10 @@ Sec-WebSocket-Accept: ${h}\r
517
517
  } catch {
518
518
  }
519
519
  }));
520
- const Ie = ie.get(N);
521
- Ie.requestCount++, Y.forEach((A) => {
520
+ const Re = ie.get(_);
521
+ Re.requestCount++, Y.forEach((H) => {
522
522
  try {
523
- A.write(`data: ${JSON.stringify({
523
+ H.write(`data: ${JSON.stringify({
524
524
  type: "origins",
525
525
  origins: Array.from(ie.values())
526
526
  })}
@@ -528,9 +528,9 @@ Sec-WebSocket-Accept: ${h}\r
528
528
  `);
529
529
  } catch {
530
530
  }
531
- }), Z.push(he), Z.length > se && Z.shift(), Y.forEach((A) => {
531
+ }), Z.push(he), Z.length > se && Z.shift(), Y.forEach((H) => {
532
532
  try {
533
- A.write(`data: ${JSON.stringify(he)}
533
+ H.write(`data: ${JSON.stringify(he)}
534
534
 
535
535
  `);
536
536
  } catch {
@@ -539,12 +539,12 @@ Sec-WebSocket-Accept: ${h}\r
539
539
  };
540
540
  if (K) {
541
541
  const oe = W.htmlFile ? e.default.join(K, W.htmlFile) : e.default.join(K, "index.html");
542
- o.default.readFile(oe, "utf-8", (N, Q) => {
543
- if (N) {
542
+ o.default.readFile(oe, "utf-8", (_, Q) => {
543
+ if (_) {
544
544
  console.log(`❌ File not found: ${oe}`), r.writeHead(404, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "index.html not found" }));
545
545
  return;
546
546
  }
547
- const Ee = Me(Q, J), he = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Ie = {
547
+ const Ee = Me(Q, J), he = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Re = {
548
548
  item: {
549
549
  name: J,
550
550
  id: J,
@@ -564,30 +564,30 @@ Sec-WebSocket-Accept: ${h}\r
564
564
  console.log(`βœ… Serving consume JSON for: ${J}`), ce(!0), r.writeHead(200, {
565
565
  "Content-Type": "application/json",
566
566
  "Access-Control-Allow-Origin": "*"
567
- }), r.end(JSON.stringify(Ie, null, 2));
567
+ }), r.end(JSON.stringify(Re, null, 2));
568
568
  });
569
569
  } else {
570
570
  console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${J}`);
571
- const oe = `https://cloud.myop.dev/consume${c.search}`;
572
- ce(!1), fetch(oe).then((N) => N.text()).then((N) => {
571
+ const oe = `https://cloud.myop.dev/consume${p.search}`;
572
+ ce(!1), fetch(oe).then((_) => _.text()).then((_) => {
573
573
  r.writeHead(200, {
574
574
  "Content-Type": "application/json",
575
575
  "Access-Control-Allow-Origin": "*"
576
- }), r.end(N);
577
- }).catch((N) => {
578
- console.error(`❌ Proxy error: ${N.message}`), r.writeHead(502, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
576
+ }), r.end(_);
577
+ }).catch((_) => {
578
+ console.error(`❌ Proxy error: ${_.message}`), r.writeHead(502, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
579
579
  });
580
580
  }
581
581
  return;
582
582
  }
583
- if (p === "/events") {
583
+ if (m === "/events") {
584
584
  r.writeHead(200, {
585
585
  "Content-Type": "text/event-stream",
586
586
  "Cache-Control": "no-cache",
587
587
  Connection: "keep-alive",
588
588
  "Access-Control-Allow-Origin": "*"
589
589
  }), Y.push(r);
590
- const J = Array.from(I.entries()).map(([W, K]) => ({
590
+ const J = Array.from(R.entries()).map(([W, K]) => ({
591
591
  id: W,
592
592
  path: K.path,
593
593
  name: K.name
@@ -614,7 +614,7 @@ Sec-WebSocket-Accept: ${h}\r
614
614
  return;
615
615
  }
616
616
  if (g.length === 0) {
617
- r.writeHead(200, { "Content-Type": "text/html" }), r.end(It(m, d, w, v));
617
+ r.writeHead(200, { "Content-Type": "text/html" }), r.end(Rt(d, c, w, S));
618
618
  return;
619
619
  }
620
620
  if (g[0] !== "view") {
@@ -625,12 +625,12 @@ Sec-WebSocket-Accept: ${h}\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 h = g[1], $ = I.get(h);
629
- if (!$) {
630
- r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${h}`);
628
+ const v = g[1], M = R.get(v);
629
+ if (!M) {
630
+ r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${v}`);
631
631
  return;
632
632
  }
633
- const O = $.path, L = g.slice(2), V = $.htmlFile || "index.html", te = L.length === 0 ? V : L.join("/"), le = e.default.join(O, te);
633
+ const O = M.path, A = g.slice(2), G = M.htmlFile || "index.html", te = A.length === 0 ? G : A.join("/"), le = e.default.join(O, te);
634
634
  console.log(`πŸ“₯ Request: ${a.url} -> ${le}`), o.default.readFile(le, (J, W) => {
635
635
  if (J) {
636
636
  console.log(`❌ File not found: ${le}`), r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not Found");
@@ -639,57 +639,57 @@ Sec-WebSocket-Accept: ${h}\r
639
639
  const K = z(le);
640
640
  console.log(`βœ… Serving: ${le} (${K})`);
641
641
  let ce = W;
642
- if (K === "text/html" && _) {
642
+ if (K === "text/html" && L) {
643
643
  const oe = W.toString("utf-8");
644
- ce = Me(oe, h);
644
+ ce = Me(oe, v);
645
645
  }
646
646
  r.writeHead(200, {
647
647
  "Content-Type": K,
648
648
  "Access-Control-Allow-Origin": "*"
649
649
  }), r.end(ce);
650
650
  });
651
- }), Ue = () => new Promise((a, r) => {
652
- const c = M ? e.default.resolve(k) : e.default.resolve(k, C), p = JSON.stringify({
651
+ }), Be = () => new Promise((a, r) => {
652
+ const p = C ? e.default.resolve(k) : e.default.resolve(k, $), m = JSON.stringify({
653
653
  componentId: f,
654
- distPath: c,
654
+ distPath: p,
655
655
  componentName: E,
656
- htmlFile: M ? T : null
656
+ htmlFile: C ? T : null
657
657
  }), g = {
658
658
  hostname: "localhost",
659
- port: d,
659
+ port: c,
660
660
  path: "/_register",
661
661
  method: "POST",
662
662
  headers: {
663
663
  "Content-Type": "application/json",
664
- "Content-Length": Buffer.byteLength(p)
664
+ "Content-Length": Buffer.byteLength(m)
665
665
  }
666
- }, h = n.default.request(g, ($) => {
666
+ }, v = n.default.request(g, (M) => {
667
667
  let O = "";
668
- $.on("data", (L) => O += L), $.on("end", () => {
669
- $.statusCode === 200 ? a(JSON.parse(O)) : r(new Error(`Registration failed: ${$.statusCode}`));
668
+ M.on("data", (A) => O += A), M.on("end", () => {
669
+ M.statusCode === 200 ? a(JSON.parse(O)) : r(new Error(`Registration failed: ${M.statusCode}`));
670
670
  });
671
671
  });
672
- h.on("error", r), h.write(p), h.end();
672
+ v.on("error", r), v.write(m), v.end();
673
673
  }), ct = () => new Promise((a, r) => {
674
- const c = JSON.stringify({ componentId: f }), p = {
674
+ const p = JSON.stringify({ componentId: f }), m = {
675
675
  hostname: "localhost",
676
- port: d,
676
+ port: c,
677
677
  path: "/_unregister",
678
678
  method: "POST",
679
679
  headers: {
680
680
  "Content-Type": "application/json",
681
- "Content-Length": Buffer.byteLength(c)
681
+ "Content-Length": Buffer.byteLength(p)
682
682
  }
683
- }, g = n.default.request(p, (h) => {
683
+ }, g = n.default.request(m, (v) => {
684
684
  a();
685
685
  });
686
- g.on("error", () => a()), g.write(c), g.end();
686
+ g.on("error", () => a()), g.write(p), g.end();
687
687
  }), dt = (a) => `
688
688
  <!-- MYOP HMR -->
689
689
  <script>
690
690
  (function() {
691
691
  const componentId = '${a}';
692
- const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
692
+ const wsUrl = 'ws://localhost:${c}/_hmr/' + componentId;
693
693
  let ws;
694
694
  let reconnectAttempts = 0;
695
695
  const maxReconnectAttempts = 10;
@@ -790,75 +790,75 @@ Sec-WebSocket-Accept: ${h}\r
790
790
  })();
791
791
  <\/script>
792
792
  `, Me = (a, r) => {
793
- if (!_) return a;
794
- const c = dt(r);
795
- return a.includes("</body>") ? a.replace("</body>", `${c}</body>`) : a.includes("</html>") ? a.replace("</html>", `${c}</html>`) : a + c;
796
- }, Je = (a) => {
797
- const r = Buffer.from(a), c = r.length;
798
- let p;
799
- return c < 126 ? p = Buffer.concat([
800
- Buffer.from([129, c]),
793
+ if (!L) return a;
794
+ const p = dt(r);
795
+ return a.includes("</body>") ? a.replace("</body>", `${p}</body>`) : a.includes("</html>") ? a.replace("</html>", `${p}</html>`) : a + p;
796
+ }, ze = (a) => {
797
+ const r = Buffer.from(a), p = r.length;
798
+ let m;
799
+ return p < 126 ? m = Buffer.concat([
800
+ Buffer.from([129, p]),
801
801
  // FIN + text frame, length
802
802
  r
803
- ]) : c < 65536 ? p = Buffer.concat([
803
+ ]) : p < 65536 ? m = Buffer.concat([
804
804
  Buffer.from([129, 126]),
805
805
  // FIN + text frame, extended length
806
- Buffer.from([c >> 8, c & 255]),
806
+ Buffer.from([p >> 8, p & 255]),
807
807
  // 16-bit length
808
808
  r
809
- ]) : p = Buffer.concat([
809
+ ]) : m = Buffer.concat([
810
810
  Buffer.from([129, 127]),
811
811
  // FIN + text frame, extended length
812
- Buffer.from([0, 0, 0, 0, c >> 24, c >> 16 & 255, c >> 8 & 255, c & 255]),
812
+ Buffer.from([0, 0, 0, 0, p >> 24, p >> 16 & 255, p >> 8 & 255, p & 255]),
813
813
  // 64-bit length
814
814
  r
815
- ]), p;
816
- }, Be = () => {
817
- if (!_) return;
818
- const a = M ? T : e.default.join(C, "index.html");
815
+ ]), m;
816
+ }, We = () => {
817
+ if (!L) return;
818
+ const a = C ? T : e.default.join($, "index.html");
819
819
  let r;
820
820
  try {
821
- const c = o.default.readFileSync(a, "utf-8");
822
- r = Me(c, f);
823
- } catch (c) {
824
- console.error("❌ Failed to read HTML for HMR:", c.message);
821
+ const p = o.default.readFileSync(a, "utf-8");
822
+ r = Me(p, f);
823
+ } catch (p) {
824
+ console.error("❌ Failed to read HTML for HMR:", p.message);
825
825
  return;
826
826
  }
827
- if (Re) {
828
- const c = ee.get(f);
829
- if (!c || c.size === 0)
827
+ if (Ie) {
828
+ const p = ee.get(f);
829
+ if (!p || p.size === 0)
830
830
  return;
831
- console.log(`πŸ”₯ Notifying ${c.size} HMR client(s)`);
832
- const p = JSON.stringify({
831
+ console.log(`πŸ”₯ Notifying ${p.size} HMR client(s)`);
832
+ const m = JSON.stringify({
833
833
  type: "update",
834
834
  html: r
835
- }), g = Je(p);
836
- c.forEach((h) => {
835
+ }), g = ze(m);
836
+ p.forEach((v) => {
837
837
  try {
838
- h.write(g);
838
+ v.write(g);
839
839
  } catch {
840
- c.delete(h);
840
+ p.delete(v);
841
841
  }
842
842
  });
843
843
  } else {
844
- const c = JSON.stringify({
844
+ const p = JSON.stringify({
845
845
  componentId: f,
846
846
  html: r
847
- }), p = {
847
+ }), m = {
848
848
  hostname: "localhost",
849
- port: d,
849
+ port: c,
850
850
  path: "/_hmr_notify",
851
851
  method: "POST",
852
852
  headers: {
853
853
  "Content-Type": "application/json",
854
- "Content-Length": Buffer.byteLength(c)
854
+ "Content-Length": Buffer.byteLength(p)
855
855
  },
856
856
  timeout: 5e3
857
- }, g = n.default.request(p, (h) => {
858
- let $ = "";
859
- h.on("data", (O) => $ += O), h.on("end", () => {
857
+ }, g = n.default.request(m, (v) => {
858
+ let M = "";
859
+ v.on("data", (O) => M += O), v.on("end", () => {
860
860
  try {
861
- const O = JSON.parse($);
861
+ const O = JSON.parse(M);
862
862
  O.notified > 0 && console.log(`πŸ”₯ Notified ${O.notified} HMR client(s) via server`);
863
863
  } catch {
864
864
  }
@@ -867,173 +867,173 @@ Sec-WebSocket-Accept: ${h}\r
867
867
  g.on("error", () => {
868
868
  }), g.on("timeout", () => {
869
869
  g.destroy();
870
- }), g.write(c), g.end();
870
+ }), g.write(p), g.end();
871
871
  }
872
872
  };
873
873
  let Pe = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
874
874
  const ge = (a) => {
875
875
  if (u) {
876
- S = !0;
876
+ y = !0;
877
877
  return;
878
878
  }
879
879
  u = !0, console.log(`
880
- πŸ”¨ Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, c, p) => {
880
+ πŸ”¨ Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, p, m) => {
881
881
  if (u = !1, r) {
882
- const g = await et(r, c, p, t, {
882
+ const g = await ot(r, p, m, t, {
883
883
  ...Pe,
884
884
  onRetry: () => ge(a)
885
885
  });
886
- Pe = { ...Pe, ...g }, g.handled || (console.error("❌ Build failed:", r.message), p && console.error(p));
886
+ Pe = { ...Pe, ...g }, g.handled || (console.error("❌ Build failed:", r.message), m && console.error(m));
887
887
  } else
888
- console.log("βœ… Build completed"), c && console.log(c), Be(), a && a();
889
- S && (S = !1, ge());
888
+ console.log("βœ… Build completed"), p && console.log(p), We(), a && a();
889
+ y && (y = !1, ge());
890
890
  });
891
- }, ze = /* @__PURE__ */ new Set(), Te = (a) => {
892
- o.default.readdir(a, { withFileTypes: !0 }, (r, c) => {
893
- r || (c.forEach((p) => {
894
- const g = e.default.join(a, p.name);
895
- if (p.isDirectory())
896
- p.name !== "node_modules" && p.name !== "dist" && !p.name.startsWith(".") && Te(g);
897
- else if (p.isFile()) {
898
- const h = e.default.extname(p.name);
899
- if (h === ".js" || h === ".css" || h === ".html")
891
+ }, Ve = /* @__PURE__ */ new Set(), Te = (a) => {
892
+ o.default.readdir(a, { withFileTypes: !0 }, (r, p) => {
893
+ r || (p.forEach((m) => {
894
+ const g = e.default.join(a, m.name);
895
+ if (m.isDirectory())
896
+ m.name !== "node_modules" && m.name !== "dist" && !m.name.startsWith(".") && Te(g);
897
+ else if (m.isFile()) {
898
+ const v = e.default.extname(m.name);
899
+ if (v === ".js" || v === ".css" || v === ".html")
900
900
  try {
901
- const $ = o.default.readFileSync(g, "utf-8");
902
- j.set(g, $);
901
+ const M = o.default.readFileSync(g, "utf-8");
902
+ F.set(g, M);
903
903
  } catch {
904
904
  }
905
905
  }
906
- }), ze.has(a) || (ze.add(a), o.default.watch(a, (p, g) => {
906
+ }), Ve.has(a) || (Ve.add(a), o.default.watch(a, (m, g) => {
907
907
  if (!g) return;
908
- const h = e.default.extname(g);
909
- if (h !== ".js" && h !== ".css" && h !== ".html") return;
910
- const $ = e.default.join(a, g);
908
+ const v = e.default.extname(g);
909
+ if (v !== ".js" && v !== ".css" && v !== ".html") return;
910
+ const M = e.default.join(a, g);
911
911
  setTimeout(() => {
912
912
  try {
913
- const O = o.default.readFileSync($, "utf-8"), L = j.get($);
914
- O !== L && (j.set($, O), console.log(`πŸ“ File changed: ${$}`), M ? Be() : ge());
913
+ const O = o.default.readFileSync(M, "utf-8"), A = F.get(M);
914
+ O !== A && (F.set(M, O), console.log(`πŸ“ File changed: ${M}`), C ? We() : ge());
915
915
  } catch {
916
916
  }
917
917
  }, 50);
918
918
  })));
919
919
  });
920
- }, We = (a) => {
920
+ }, Ge = (a) => {
921
921
  console.log(`
922
- πŸ”¨ Component: ${f}`), M ? (console.log("πŸ“„ No build needed (single HTML file mode)"), Te(k), console.log(`πŸ‘€ Watching ${T} for changes...`), console.log(`Press Ctrl+C to stop
922
+ πŸ”¨ Component: ${f}`), C ? (console.log("πŸ“„ No build needed (single HTML file mode)"), Te(k), console.log(`πŸ‘€ Watching ${T} for changes...`), console.log(`Press Ctrl+C to stop
923
923
  `), a && a()) : (ge(a), Te(k), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
924
924
  `));
925
925
  }, pt = () => new Promise((a) => {
926
926
  const r = {
927
927
  hostname: "localhost",
928
- port: d,
928
+ port: c,
929
929
  path: "/_list",
930
930
  method: "GET",
931
931
  timeout: 1e3
932
- }, c = n.default.request(r, (p) => {
932
+ }, p = n.default.request(r, (m) => {
933
933
  a(!0);
934
934
  });
935
- c.on("error", () => a(!1)), c.on("timeout", () => {
936
- c.destroy(), a(!1);
937
- }), c.end();
935
+ p.on("error", () => a(!1)), p.on("timeout", () => {
936
+ p.destroy(), a(!1);
937
+ }), p.end();
938
938
  }), mt = () => new Promise((a) => {
939
- const r = n.default.createServer((c, p) => {
940
- if (p.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
939
+ const r = n.default.createServer((p, m) => {
940
+ if (m.setHeader("Content-Type", "application/json"), p.method === "POST" && p.url === "/_register") {
941
941
  let g = "";
942
- c.on("data", (h) => g += h), c.on("end", () => {
942
+ p.on("data", (v) => g += v), p.on("end", () => {
943
943
  try {
944
- const { componentId: h, distPath: $, componentName: O, htmlFile: L } = JSON.parse(g);
945
- I.set(h, { path: $, name: O || null, htmlFile: L || null });
946
- const V = O ? ` (${O})` : "";
947
- console.log(`βœ… Registered: ${h}${V} -> ${$}${L ? "/" + L : ""}`), p.writeHead(200), p.end(JSON.stringify({ success: !0, registered: Array.from(I.keys()) }));
948
- } catch (h) {
949
- p.writeHead(400), p.end(JSON.stringify({ error: h.message }));
944
+ const { componentId: v, distPath: M, componentName: O, htmlFile: A } = JSON.parse(g);
945
+ R.set(v, { path: M, name: O || null, htmlFile: A || null });
946
+ const G = O ? ` (${O})` : "";
947
+ console.log(`βœ… Registered: ${v}${G} -> ${M}${A ? "/" + A : ""}`), m.writeHead(200), m.end(JSON.stringify({ success: !0, registered: Array.from(R.keys()) }));
948
+ } catch (v) {
949
+ m.writeHead(400), m.end(JSON.stringify({ error: v.message }));
950
950
  }
951
951
  });
952
- } else if (c.method === "POST" && c.url === "/_unregister") {
952
+ } else if (p.method === "POST" && p.url === "/_unregister") {
953
953
  let g = "";
954
- c.on("data", (h) => g += h), c.on("end", () => {
954
+ p.on("data", (v) => g += v), p.on("end", () => {
955
955
  try {
956
- const { componentId: h } = JSON.parse(g);
957
- I.delete(h), console.log(`❌ Unregistered: ${h}`), p.writeHead(200), p.end(JSON.stringify({ success: !0 }));
958
- } catch (h) {
959
- p.writeHead(400), p.end(JSON.stringify({ error: h.message }));
956
+ const { componentId: v } = JSON.parse(g);
957
+ R.delete(v), console.log(`❌ Unregistered: ${v}`), m.writeHead(200), m.end(JSON.stringify({ success: !0 }));
958
+ } catch (v) {
959
+ m.writeHead(400), m.end(JSON.stringify({ error: v.message }));
960
960
  }
961
961
  });
962
- } else c.method === "GET" && c.url === "/_list" ? (p.writeHead(200), p.end(JSON.stringify({ components: Array.from(I.entries()) }))) : (p.writeHead(404), p.end(JSON.stringify({ error: "Not found" })));
962
+ } else p.method === "GET" && p.url === "/_list" ? (m.writeHead(200), m.end(JSON.stringify({ components: Array.from(R.entries()) }))) : (m.writeHead(404), m.end(JSON.stringify({ error: "Not found" })));
963
963
  });
964
964
  r.on("error", () => {
965
965
  a(!1);
966
- }), r.listen(d, () => {
966
+ }), r.listen(c, () => {
967
967
  console.log(`
968
- πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${d}`), ue.on("error", () => {
968
+ πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${c}`), ue.on("error", () => {
969
969
  r.close(), a(!1);
970
- }), ue.listen(m, () => {
971
- console.log(`πŸ“‘ Main server running at http://localhost:${m}`);
972
- const c = M ? e.default.resolve(k) : e.default.resolve(k, C);
973
- I.set(f, {
974
- path: c,
970
+ }), ue.listen(d, () => {
971
+ console.log(`πŸ“‘ Main server running at http://localhost:${d}`);
972
+ const p = C ? e.default.resolve(k) : e.default.resolve(k, $);
973
+ R.set(f, {
974
+ path: p,
975
975
  name: E,
976
- htmlFile: M ? T : null
976
+ htmlFile: C ? T : null
977
977
  });
978
- const p = E ? ` (${E})` : "";
979
- console.log(`βœ… Registered component: ${f}${p}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), a(!0);
978
+ const m = E ? ` (${E})` : "";
979
+ console.log(`βœ… Registered component: ${f}${m}`), console.log(`πŸ“‘ Access at: http://localhost:${d}/view/${f}/`), a(!0);
980
980
  });
981
981
  });
982
982
  });
983
983
  let fe;
984
- const Ve = () => {
984
+ const Ye = () => {
985
985
  fe = setInterval(async () => {
986
986
  await pt() || (clearInterval(fe), console.log(`
987
- ⚠️ Server appears to be down, attempting to take over...`), await mt() ? (console.log("βœ… Successfully took over as server"), Re = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
987
+ ⚠️ Server appears to be down, attempting to take over...`), await mt() ? (console.log("βœ… Successfully took over as server"), Ie = !0) : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
988
988
  try {
989
- await Ue(), console.log(`βœ… Re-registered component: ${f}`), Ve();
990
- } catch (c) {
991
- console.error("❌ Failed to re-register:", c.message);
989
+ await Be(), console.log(`βœ… Re-registered component: ${f}`), Ye();
990
+ } catch (p) {
991
+ console.error("❌ Failed to re-register:", p.message);
992
992
  }
993
993
  }, 2e3)));
994
994
  }, 3e3);
995
- }, Ge = async () => {
995
+ }, Ke = async () => {
996
996
  console.log(`
997
997
 
998
998
  πŸ›‘ Shutting down...`), fe && clearInterval(fe), await ct(), process.exit(0);
999
999
  };
1000
- process.on("SIGINT", Ge), process.on("SIGTERM", Ge);
1001
- let Re = !1;
1000
+ process.on("SIGINT", Ke), process.on("SIGTERM", Ke);
1001
+ let Ie = !1;
1002
1002
  Ce.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
  f = await U();
1008
- const r = await Ue();
1009
- console.log(`βœ… Registered component: ${f}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), console.log(`πŸ“‹ All registered components: ${r.registered.join(", ")}`), We(() => {
1010
- process.env.MYOP_NO_BROWSER || x(`http://localhost:${m}/view/${f}/`);
1011
- }), Ve();
1008
+ const r = await Be();
1009
+ console.log(`βœ… Registered component: ${f}`), console.log(`πŸ“‘ Access at: http://localhost:${d}/view/${f}/`), console.log(`πŸ“‹ All registered components: ${r.registered.join(", ")}`), Ge(() => {
1010
+ process.env.MYOP_NO_BROWSER || b(`http://localhost:${d}/view/${f}/`);
1011
+ }), Ye();
1012
1012
  } catch (r) {
1013
1013
  console.error("❌ Failed to register component:", r.message), process.exit(1);
1014
1014
  }
1015
1015
  } else
1016
1016
  console.error("❌ Management server error:", a.message), process.exit(1);
1017
- }), Ce.on("upgrade", lt), Ce.listen(d, async () => {
1018
- Re = !0, console.log(`
1019
- πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${d}`), ue.on("error", (a) => {
1017
+ }), Ce.on("upgrade", lt), Ce.listen(c, async () => {
1018
+ Ie = !0, console.log(`
1019
+ πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${c}`), ue.on("error", (a) => {
1020
1020
  console.error("❌ Main server error:", a.message), process.exit(1);
1021
- }), ue.listen(m, async () => {
1022
- console.log(`πŸ“‘ Main server running at http://localhost:${m}`), (f === "DEV" || f === "NEW") && (f = "DEV1");
1023
- const a = M ? e.default.resolve(k) : e.default.resolve(k, C);
1024
- I.set(f, {
1021
+ }), ue.listen(d, async () => {
1022
+ console.log(`πŸ“‘ Main server running at http://localhost:${d}`), (f === "DEV" || f === "NEW") && (f = "DEV1");
1023
+ const a = C ? e.default.resolve(k) : e.default.resolve(k, $);
1024
+ R.set(f, {
1025
1025
  path: a,
1026
1026
  name: E,
1027
- htmlFile: M ? T : null
1027
+ htmlFile: C ? T : null
1028
1028
  });
1029
1029
  const r = E ? ` (${E})` : "";
1030
- console.log(`βœ… Registered component: ${f}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${m}/view/${f}/`), We(() => {
1031
- process.env.MYOP_NO_BROWSER || x(`http://localhost:${m}/view/${f}/`);
1030
+ console.log(`βœ… Registered component: ${f}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${d}/view/${f}/`), Ge(() => {
1031
+ process.env.MYOP_NO_BROWSER || b(`http://localhost:${d}/view/${f}/`);
1032
1032
  });
1033
1033
  });
1034
1034
  });
1035
1035
  }
1036
- const F = class F {
1036
+ const N = class N {
1037
1037
  constructor(e) {
1038
1038
  this.components = e.map(
1039
1039
  (t) => typeof t == "string" ? { name: t, path: "", id: "" } : t
@@ -1042,7 +1042,7 @@ const F = class F {
1042
1042
  this.logs.set(t.name, []), this.scrollPos.set(t.name, 0), this.statuses.set(t.name, "Initializing..."), this.statusKeys.set(t.name, "initializing");
1043
1043
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
1044
1044
  this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, this.needsFullRedraw = !0, this.calculateLayout(), this.render();
1045
- }), this.setupKeyboardInput(), process.stdout.write(F.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1045
+ }), this.setupKeyboardInput(), process.stdout.write(N.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
1046
1046
  }
1047
1047
  setupKeyboardInput() {
1048
1048
  process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (e) => {
@@ -1083,15 +1083,15 @@ const F = class F {
1083
1083
  const e = this.components.length, t = 38;
1084
1084
  let n;
1085
1085
  this.cols >= t * 3 + 4 ? n = Math.min(e, 3) : this.cols >= t * 2 + 2 ? n = Math.min(e, 2) : n = 1;
1086
- const i = Math.ceil(e / n), s = Math.floor(this.cols / n), l = 2, v = this.rows - l - 2, m = Math.floor(v / i);
1087
- this.visibleLogLines = Math.max(2, m - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: i, panelHeight: m }, this.panelPositions.clear();
1088
- for (let d = 0; d < e; d++) {
1089
- const C = this.components[d], u = Math.floor(d / n), S = d % n;
1090
- this.panelPositions.set(C.name, {
1091
- row: l + 1 + u * m,
1092
- col: S * s + 1,
1086
+ const i = Math.ceil(e / n), s = Math.floor(this.cols / n), l = 2, S = this.rows - l - 2, d = Math.floor(S / i);
1087
+ this.visibleLogLines = Math.max(2, d - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: i, panelHeight: d }, this.panelPositions.clear();
1088
+ for (let c = 0; c < e; c++) {
1089
+ const $ = this.components[c], u = Math.floor(c / n), y = c % n;
1090
+ this.panelPositions.set($.name, {
1091
+ row: l + 1 + u * d,
1092
+ col: y * s + 1,
1093
1093
  width: s,
1094
- height: m
1094
+ height: d
1095
1095
  });
1096
1096
  }
1097
1097
  }
@@ -1132,44 +1132,44 @@ const F = class F {
1132
1132
  return `${t}:${n.toString().padStart(2, "0")}`;
1133
1133
  }
1134
1134
  updateHeader() {
1135
- const e = F.C, t = Array.from(this.statusKeys.values()).filter((s) => s === "ready").length, n = this.components.length;
1135
+ const e = N.C, t = Array.from(this.statusKeys.values()).filter((s) => s === "ready").length, n = this.components.length;
1136
1136
  let i = `${e.dim}πŸ“‘${e.reset} http://localhost:9292 ${e.gray}|${e.reset} `;
1137
- i += `${e.green}${t}${e.reset}/${n} ready ${e.gray}|${e.reset} `, i += `⏱ ${this.getUptime()} ${e.gray}|${e.reset} `, i += `Press ${e.yellow}Ctrl+C${e.reset} to stop`, i += F.ESC.clearLine.slice(0, -1), process.stdout.write(F.ESC.moveTo(2, 1) + i);
1137
+ i += `${e.green}${t}${e.reset}/${n} ready ${e.gray}|${e.reset} `, i += `⏱ ${this.getUptime()} ${e.gray}|${e.reset} `, i += `Press ${e.yellow}Ctrl+C${e.reset} to stop`, i += N.ESC.clearLine.slice(0, -1), process.stdout.write(N.ESC.moveTo(2, 1) + i);
1138
1138
  }
1139
1139
  renderPanel(e) {
1140
- const t = F.C, n = F.STATUS, i = this.panelPositions.get(e);
1140
+ const t = N.C, n = N.STATUS, i = this.panelPositions.get(e);
1141
1141
  if (!i) return;
1142
- const s = this.components.findIndex((U) => U.name === e), l = this.components[s], w = s === this.selectedPanel, v = this.statusKeys.get(e) || "initializing", m = n[v], d = t[m.color], C = this.logs.get(e) || [], u = this.scrollPos.get(e) || 0, S = i.width - 1, M = w ? t.cyan : t.gray, T = [], D = l.name.substring(0, S - 20);
1143
- let P = `${M}β”Œβ”€${t.reset} ${d}${m.icon}${t.reset} `;
1144
- P += `${t.bold}${D}${t.reset} ${t.gray}─${t.reset} ${d}${m.label}${t.reset} `;
1145
- const x = 5 + D.length + m.label.length + 3;
1146
- P += `${M}${"─".repeat(Math.max(0, S - x))}┐${t.reset}`, T.push(F.ESC.moveTo(i.row, i.col) + P);
1147
- const j = (l.path || "").substring(0, S - 6);
1148
- let b = `${M}β”‚${t.reset} ${t.dim}${j}${t.reset}`;
1149
- b += " ".repeat(Math.max(0, S - j.length - 3)), b += `${M}β”‚${t.reset}`, T.push(F.ESC.moveTo(i.row + 1, i.col) + b);
1150
- const f = C.length, E = f > this.visibleLogLines ? `${u + 1}-${Math.min(u + this.visibleLogLines, f)}/${f}` : "";
1151
- let _ = `${M}β”œ${"─".repeat(S - E.length - 4)}${t.reset}`;
1152
- E && (_ += `${t.dim}${E}${t.reset}`), _ += `${M}${"─".repeat(2)}─${t.reset}`, T.push(F.ESC.moveTo(i.row + 2, i.col) + _);
1153
- const B = C.slice(u, u + this.visibleLogLines);
1142
+ const s = this.components.findIndex((U) => U.name === e), l = this.components[s], w = s === this.selectedPanel, S = this.statusKeys.get(e) || "initializing", d = n[S], c = t[d.color], $ = this.logs.get(e) || [], u = this.scrollPos.get(e) || 0, y = i.width - 1, C = w ? t.cyan : t.gray, T = [], j = l.name.substring(0, y - 20);
1143
+ let P = `${C}β”Œβ”€${t.reset} ${c}${d.icon}${t.reset} `;
1144
+ P += `${t.bold}${j}${t.reset} ${t.gray}─${t.reset} ${c}${d.label}${t.reset} `;
1145
+ const b = 5 + j.length + d.label.length + 3;
1146
+ P += `${C}${"─".repeat(Math.max(0, y - b))}┐${t.reset}`, T.push(N.ESC.moveTo(i.row, i.col) + P);
1147
+ const F = (l.path || "").substring(0, y - 6);
1148
+ let x = `${C}β”‚${t.reset} ${t.dim}${F}${t.reset}`;
1149
+ x += " ".repeat(Math.max(0, y - F.length - 3)), x += `${C}β”‚${t.reset}`, T.push(N.ESC.moveTo(i.row + 1, i.col) + x);
1150
+ const f = $.length, E = f > this.visibleLogLines ? `${u + 1}-${Math.min(u + this.visibleLogLines, f)}/${f}` : "";
1151
+ let L = `${C}β”œ${"─".repeat(y - E.length - 4)}${t.reset}`;
1152
+ E && (L += `${t.dim}${E}${t.reset}`), L += `${C}${"─".repeat(2)}─${t.reset}`, T.push(N.ESC.moveTo(i.row + 2, i.col) + L);
1153
+ const B = $.slice(u, u + this.visibleLogLines);
1154
1154
  for (let U = 0; U < this.visibleLogLines; U++) {
1155
1155
  const k = B[U];
1156
- let z = `${M}β”‚${t.reset}`;
1156
+ let z = `${C}β”‚${t.reset}`;
1157
1157
  if (k) {
1158
- let I = t.white;
1159
- k.type === "success" ? I = t.green : k.type === "error" ? I = t.red : k.type === "warning" ? I = t.yellow : k.type === "hmr" ? I = t.magenta : k.type === "change" && (I = t.blue);
1160
- const Z = k.message.substring(0, S - 12);
1161
- z += `${t.dim}${k.timestamp}${t.reset} ${I}${Z}${t.reset}`;
1162
- const se = S - k.timestamp.length - Z.length - 2;
1158
+ let R = t.white;
1159
+ k.type === "success" ? R = t.green : k.type === "error" ? R = t.red : k.type === "warning" ? R = t.yellow : k.type === "hmr" ? R = t.magenta : k.type === "change" && (R = t.blue);
1160
+ const Z = k.message.substring(0, y - 12);
1161
+ z += `${t.dim}${k.timestamp}${t.reset} ${R}${Z}${t.reset}`;
1162
+ const se = y - k.timestamp.length - Z.length - 2;
1163
1163
  z += " ".repeat(Math.max(0, se));
1164
1164
  } else
1165
- z += " ".repeat(S - 2);
1166
- z += `${M}β”‚${t.reset}`, T.push(F.ESC.moveTo(i.row + 3 + U, i.col) + z);
1165
+ z += " ".repeat(y - 2);
1166
+ z += `${C}β”‚${t.reset}`, T.push(N.ESC.moveTo(i.row + 3 + U, i.col) + z);
1167
1167
  }
1168
- T.push(F.ESC.moveTo(i.row + 3 + this.visibleLogLines, i.col) + `${M}β””${"─".repeat(S - 2)}β”˜${t.reset}`), process.stdout.write(T.join(""));
1168
+ T.push(N.ESC.moveTo(i.row + 3 + this.visibleLogLines, i.col) + `${C}β””${"─".repeat(y - 2)}β”˜${t.reset}`), process.stdout.write(T.join(""));
1169
1169
  }
1170
1170
  fullRender() {
1171
- const e = F.C;
1172
- process.stdout.write(F.ESC.clearScreen + F.ESC.moveTo(1, 1));
1171
+ const e = N.C;
1172
+ process.stdout.write(N.ESC.clearScreen + N.ESC.moveTo(1, 1));
1173
1173
  const t = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - t.length) / 2);
1174
1174
  process.stdout.write(`${e.cyan}${"━".repeat(n)}${e.bold}${e.bgCyan}${e.black}${t}${e.reset}${e.cyan}${"━".repeat(this.cols - n - t.length)}${e.reset}`), this.updateHeader();
1175
1175
  for (const i of this.components)
@@ -1177,26 +1177,26 @@ const F = class F {
1177
1177
  this.renderFooter();
1178
1178
  }
1179
1179
  renderFooter() {
1180
- const e = F.C, t = this.rows - 1;
1180
+ const e = N.C, t = this.rows - 1;
1181
1181
  let n = `${e.gray}`;
1182
- n += `${e.green}●${e.gray} Ready `, n += `${e.yellow}⟳${e.gray} Building `, n += `${e.magenta}⚑${e.gray} HMR `, n += `${e.red}βœ–${e.gray} Error `, n += `${e.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${e.reset}`, process.stdout.write(F.ESC.moveTo(t, 1) + n);
1182
+ n += `${e.green}●${e.gray} Ready `, n += `${e.yellow}⟳${e.gray} Building `, n += `${e.magenta}⚑${e.gray} HMR `, n += `${e.red}βœ–${e.gray} Error `, n += `${e.dim}| ←→: select panel ↑↓: scroll PgUp/PgDn: page g/G: top/bottom${e.reset}`, process.stdout.write(N.ESC.moveTo(t, 1) + n);
1183
1183
  }
1184
1184
  render() {
1185
1185
  this.needsFullRedraw = !0, this.queueUpdate("__full__");
1186
1186
  }
1187
1187
  clear() {
1188
- this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(F.ESC.clearScreen + F.ESC.moveTo(1, 1) + F.ESC.showCursor);
1188
+ this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(N.ESC.clearScreen + N.ESC.moveTo(1, 1) + N.ESC.showCursor);
1189
1189
  }
1190
1190
  };
1191
1191
  // ANSI escape codes
1192
- ye(F, "ESC", {
1192
+ ye(N, "ESC", {
1193
1193
  moveTo: (e, t) => `\x1B[${e};${t}H`,
1194
1194
  hideCursor: "\x1B[?25l",
1195
1195
  showCursor: "\x1B[?25h",
1196
1196
  clearScreen: "\x1B[2J",
1197
1197
  clearLine: "\x1B[2K"
1198
1198
  }), // Colors
1199
- ye(F, "C", {
1199
+ ye(N, "C", {
1200
1200
  reset: "\x1B[0m",
1201
1201
  bold: "\x1B[1m",
1202
1202
  dim: "\x1B[2m",
@@ -1211,7 +1211,7 @@ ye(F, "C", {
1211
1211
  bgCyan: "\x1B[46m",
1212
1212
  black: "\x1B[30m"
1213
1213
  }), // Status configs
1214
- ye(F, "STATUS", {
1214
+ ye(N, "STATUS", {
1215
1215
  initializing: { icon: "β—”", color: "yellow", label: "Initializing" },
1216
1216
  starting: { icon: "β—‘", color: "yellow", label: "Starting" },
1217
1217
  building: { icon: "⟳", color: "yellow", label: "Building" },
@@ -1224,57 +1224,57 @@ ye(F, "STATUS", {
1224
1224
  warning: { icon: "⚠", color: "yellow", label: "Warning" },
1225
1225
  stopped: { icon: "β– ", color: "gray", label: "Stopped" }
1226
1226
  });
1227
- let je = F;
1228
- async function Nt(o) {
1229
- const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), i = o.map((d) => ({
1230
- name: d.name,
1231
- path: d.path,
1232
- id: d.componentId || ""
1233
- })), s = new je(i), l = [], w = (d) => {
1234
- const C = process.platform;
1227
+ let Ne = N;
1228
+ async function jt(o) {
1229
+ const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), i = o.map((c) => ({
1230
+ name: c.name,
1231
+ path: c.path,
1232
+ id: c.componentId || ""
1233
+ })), s = new Ne(i), l = [], w = (c) => {
1234
+ const $ = process.platform;
1235
1235
  let u;
1236
- C === "darwin" ? u = `open "${d}"` : C === "win32" ? u = `start "" "${d}"` : u = `xdg-open "${d}"`, t(u, () => {
1236
+ $ === "darwin" ? u = `open "${c}"` : $ === "win32" ? u = `start "" "${c}"` : u = `xdg-open "${c}"`, t(u, () => {
1237
1237
  });
1238
- }, v = () => {
1238
+ }, S = () => {
1239
1239
  s.clear(), console.log(`
1240
- πŸ›‘ Shutting down all components...`), l.forEach((d) => {
1240
+ πŸ›‘ Shutting down all components...`), l.forEach((c) => {
1241
1241
  try {
1242
- d.kill("SIGTERM");
1242
+ c.kill("SIGTERM");
1243
1243
  } catch {
1244
1244
  }
1245
1245
  }), setTimeout(() => process.exit(0), 500);
1246
1246
  };
1247
- process.on("SIGINT", v), process.on("SIGTERM", v);
1248
- const m = process.argv[1];
1249
- for (let d = 0; d < o.length; d++) {
1250
- const C = o[d], u = C.name;
1251
- s.setStatus(u, "⏳ Starting..."), s.log(u, `Starting in ${C.path}`);
1252
- const S = e("node", [m, "dev"], {
1253
- cwd: n.default.resolve(C.path),
1247
+ process.on("SIGINT", S), process.on("SIGTERM", S);
1248
+ const d = process.argv[1];
1249
+ for (let c = 0; c < o.length; c++) {
1250
+ const $ = o[c], u = $.name;
1251
+ s.setStatus(u, "⏳ Starting..."), s.log(u, `Starting in ${$.path}`);
1252
+ const y = e("node", [d, "dev"], {
1253
+ cwd: n.default.resolve($.path),
1254
1254
  env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
1255
1255
  stdio: ["ignore", "pipe", "pipe"]
1256
1256
  });
1257
- l.push(S);
1258
- let M = "";
1259
- S.stdout.on("data", (T) => {
1260
- M += T.toString();
1261
- const D = M.split(`
1257
+ l.push(y);
1258
+ let C = "";
1259
+ y.stdout.on("data", (T) => {
1260
+ C += T.toString();
1261
+ const j = C.split(`
1262
1262
  `);
1263
- M = D.pop() || "";
1264
- for (const P of D) {
1265
- const x = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
- x && (x.includes("Registered component") || x.includes("Registered:") ? s.setStatus(u, "βœ… Ready") : x.includes("Building...") || x.includes("Running initial build") ? s.setStatus(u, "πŸ”¨ Building...") : x.includes("Build completed") || x.includes("Build succeeded") ? s.setStatus(u, "βœ… Ready") : x.includes("Build failed") ? s.setStatus(u, "❌ Build Error") : x.includes("File changed") ? (s.setStatus(u, "πŸ“ Changed"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1500)) : x.includes("Notifying") && x.includes("HMR") ? (s.setStatus(u, "πŸ”₯ HMR Update"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)) : x.includes("HMR client connected") && (s.setStatus(u, "πŸ”₯ HMR Connected"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)), !x.includes("Watching") && !x.includes("Press Ctrl+C") && !x.includes("Starting shared") && !x.includes("Management server") && !x.includes("Main server") && !x.includes("Access at:") && !x.includes("No build needed") && s.log(u, x));
1263
+ C = j.pop() || "";
1264
+ for (const P of j) {
1265
+ const b = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1266
+ b && (b.includes("Registered component") || b.includes("Registered:") ? s.setStatus(u, "βœ… Ready") : b.includes("Building...") || b.includes("Running initial build") ? s.setStatus(u, "πŸ”¨ Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? s.setStatus(u, "βœ… Ready") : b.includes("Build failed") ? s.setStatus(u, "❌ Build Error") : b.includes("File changed") ? (s.setStatus(u, "πŸ“ Changed"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (s.setStatus(u, "πŸ”₯ HMR Update"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)) : b.includes("HMR client connected") && (s.setStatus(u, "πŸ”₯ HMR Connected"), setTimeout(() => s.setStatus(u, "βœ… Ready"), 1e3)), !b.includes("Watching") && !b.includes("Press Ctrl+C") && !b.includes("Starting shared") && !b.includes("Management server") && !b.includes("Main server") && !b.includes("Access at:") && !b.includes("No build needed") && s.log(u, b));
1267
1267
  }
1268
- }), S.stderr.on("data", (T) => {
1269
- const D = T.toString().split(`
1268
+ }), y.stderr.on("data", (T) => {
1269
+ const j = T.toString().split(`
1270
1270
  `);
1271
- for (const P of D) {
1272
- const x = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
- x && (s.log(u, `⚠️ ${x}`), s.setStatus(u, "⚠️ Warning"));
1271
+ for (const P of j) {
1272
+ const b = P.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
1273
+ b && (s.log(u, `⚠️ ${b}`), s.setStatus(u, "⚠️ Warning"));
1274
1274
  }
1275
- }), S.on("exit", (T) => {
1275
+ }), y.on("exit", (T) => {
1276
1276
  T !== 0 && T !== null && (s.setStatus(u, `❌ Exited (${T})`), s.log(u, `Process exited with code ${T}`));
1277
- }), d < o.length - 1 && await new Promise((T) => setTimeout(T, 500));
1277
+ }), c < o.length - 1 && await new Promise((T) => setTimeout(T, 500));
1278
1278
  }
1279
1279
  s.render(), setTimeout(() => {
1280
1280
  w("http://localhost:9292");
@@ -1283,53 +1283,53 @@ async function Nt(o) {
1283
1283
  const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1284
1284
  __proto__: null,
1285
1285
  devCommand: be,
1286
- monorepoDevCommand: Nt
1287
- }, Symbol.toStringTag, { value: "Module" })), Ne = H.join(vt.homedir(), ".myop"), pe = H.join(Ne, "credentials.json");
1286
+ monorepoDevCommand: jt
1287
+ }, Symbol.toStringTag, { value: "Module" })), je = D.join(vt.homedir(), ".myop"), pe = D.join(je, "credentials.json");
1288
1288
  function Lt() {
1289
- R.existsSync(Ne) || R.mkdirSync(Ne, { recursive: !0, mode: 448 });
1289
+ I.existsSync(je) || I.mkdirSync(je, { recursive: !0, mode: 448 });
1290
1290
  }
1291
- function De() {
1291
+ function Ae() {
1292
1292
  try {
1293
- if (!R.existsSync(pe))
1293
+ if (!I.existsSync(pe))
1294
1294
  return null;
1295
- const o = R.readFileSync(pe, "utf8");
1295
+ const o = I.readFileSync(pe, "utf8");
1296
1296
  return JSON.parse(o);
1297
1297
  } catch (o) {
1298
1298
  return console.info("Failed to read credentials:", o.message), null;
1299
1299
  }
1300
1300
  }
1301
- function tt(o) {
1301
+ function nt(o) {
1302
1302
  Lt();
1303
1303
  const e = {
1304
1304
  ...o,
1305
1305
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
1306
1306
  };
1307
- R.writeFileSync(pe, JSON.stringify(e, null, 2), {
1307
+ I.writeFileSync(pe, JSON.stringify(e, null, 2), {
1308
1308
  mode: 384
1309
1309
  // Read/write for owner only
1310
1310
  });
1311
1311
  }
1312
- function ot() {
1312
+ function st() {
1313
1313
  try {
1314
- return R.existsSync(pe) && R.unlinkSync(pe), !0;
1314
+ return I.existsSync(pe) && I.unlinkSync(pe), !0;
1315
1315
  } catch (o) {
1316
1316
  return console.error("Failed to clear credentials:", o.message), !1;
1317
1317
  }
1318
1318
  }
1319
- function At(o) {
1319
+ function Dt(o) {
1320
1320
  if (!o || !o.expiresAt)
1321
1321
  return !0;
1322
1322
  const e = 5 * 60 * 1e3, t = new Date(o.expiresAt).getTime();
1323
1323
  return Date.now() > t - e;
1324
1324
  }
1325
1325
  function xe() {
1326
- const o = De();
1326
+ const o = Ae();
1327
1327
  return o ? {
1328
1328
  email: o.userEmail,
1329
1329
  userId: o.userId
1330
1330
  } : null;
1331
1331
  }
1332
- const ae = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, He = `http://localhost:${Se}/callback`, Dt = "myop-cli";
1332
+ const ae = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, He = `http://localhost:${Se}/callback`, At = "myop-cli";
1333
1333
  function Ht() {
1334
1334
  return Le.randomBytes(32).toString("base64url");
1335
1335
  }
@@ -1341,7 +1341,7 @@ async function Jt() {
1341
1341
  method: "POST",
1342
1342
  headers: { "Content-Type": "application/json" },
1343
1343
  body: JSON.stringify({
1344
- client_name: Dt,
1344
+ client_name: At,
1345
1345
  redirect_uris: [He],
1346
1346
  grant_types: ["authorization_code", "refresh_token"],
1347
1347
  response_types: ["code"]
@@ -1522,19 +1522,19 @@ function we(o, e, t, n = null) {
1522
1522
  function Bt(o) {
1523
1523
  return new Promise((e, t) => {
1524
1524
  const n = wt.createServer((i, s) => {
1525
- const l = new Ke(i.url, `http://localhost:${Se}`);
1525
+ const l = new Ze(i.url, `http://localhost:${Se}`);
1526
1526
  if (l.pathname === "/callback") {
1527
- const w = l.searchParams.get("code"), v = l.searchParams.get("state"), m = l.searchParams.get("error");
1528
- if (m) {
1527
+ const w = l.searchParams.get("code"), S = l.searchParams.get("state"), d = l.searchParams.get("error");
1528
+ if (d) {
1529
1529
  s.writeHead(200, { "Content-Type": "text/html" }), s.end(we(
1530
1530
  "error",
1531
1531
  "Authentication Failed",
1532
1532
  "Unable to complete the authentication process.",
1533
- m
1534
- )), n.close(), t(new Error(`OAuth error: ${m}`));
1533
+ d
1534
+ )), n.close(), t(new Error(`OAuth error: ${d}`));
1535
1535
  return;
1536
1536
  }
1537
- if (v !== o) {
1537
+ if (S !== o) {
1538
1538
  s.writeHead(400, { "Content-Type": "text/html" }), s.end(we(
1539
1539
  "warning",
1540
1540
  "Security Error",
@@ -1571,7 +1571,7 @@ async function zt(o, e, t) {
1571
1571
  const n = await fetch(`${ae}/oauth/token`, {
1572
1572
  method: "POST",
1573
1573
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1574
- body: new Qe({
1574
+ body: new Xe({
1575
1575
  grant_type: "authorization_code",
1576
1576
  code: o,
1577
1577
  client_id: e,
@@ -1589,7 +1589,7 @@ async function Wt(o, e) {
1589
1589
  const t = await fetch(`${ae}/oauth/token`, {
1590
1590
  method: "POST",
1591
1591
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1592
- body: new Qe({
1592
+ body: new Xe({
1593
1593
  grant_type: "refresh_token",
1594
1594
  refresh_token: o,
1595
1595
  client_id: e
@@ -1630,49 +1630,49 @@ async function Vt(o) {
1630
1630
  throw new Error("Invalid response from whoami");
1631
1631
  }
1632
1632
  async function de() {
1633
- const o = G("Starting authentication...").start();
1633
+ const o = V("Starting authentication...").start();
1634
1634
  try {
1635
1635
  o.text = "Registering OAuth client...";
1636
1636
  const t = (await Jt()).client_id, n = Ht(), i = Ut(n), s = Le.randomBytes(16).toString("hex");
1637
1637
  o.text = "Waiting for authorization...";
1638
- const l = Bt(s), w = new Ke(`${ae}/oauth/authorize`);
1638
+ const l = Bt(s), w = new Ze(`${ae}/oauth/authorize`);
1639
1639
  w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", t), w.searchParams.set("redirect_uri", He), w.searchParams.set("code_challenge", i), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", s), o.stop(), console.log(`
1640
1640
  🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
1641
1641
  `), await St(w.toString());
1642
- const v = await l;
1642
+ const S = await l;
1643
1643
  o.start("Exchanging authorization code...");
1644
- const m = await zt(v, t, n);
1644
+ const d = await zt(S, t, n);
1645
1645
  o.text = "Getting user info...";
1646
- const d = await Vt(m.access_token), C = {
1647
- accessToken: m.access_token,
1648
- refreshToken: m.refresh_token,
1649
- expiresAt: new Date(Date.now() + m.expires_in * 1e3).toISOString(),
1646
+ const c = await Vt(d.access_token), $ = {
1647
+ accessToken: d.access_token,
1648
+ refreshToken: d.refresh_token,
1649
+ expiresAt: new Date(Date.now() + d.expires_in * 1e3).toISOString(),
1650
1650
  clientId: t,
1651
- userId: d.userId,
1652
- userEmail: d.email
1651
+ userId: c.userId,
1652
+ userEmail: c.email
1653
1653
  };
1654
- return tt(C), o.succeed(`Authenticated as ${d.email}`), C;
1654
+ return nt($), o.succeed(`Authenticated as ${c.email}`), $;
1655
1655
  } catch (e) {
1656
1656
  throw o.fail(`Authentication failed: ${e.message}`), e;
1657
1657
  }
1658
1658
  }
1659
- async function nt() {
1660
- const o = De();
1659
+ async function it() {
1660
+ const o = Ae();
1661
1661
  if (!o) {
1662
1662
  console.log("Not currently logged in.");
1663
1663
  return;
1664
1664
  }
1665
- ot(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1665
+ st(), console.log(`βœ… Logged out (was: ${o.userEmail})`);
1666
1666
  }
1667
- async function st() {
1668
- let o = De();
1667
+ async function Ue() {
1668
+ let o = Ae();
1669
1669
  if (!o)
1670
1670
  return console.log(`Not logged in. Starting authentication...
1671
1671
  `), await de();
1672
- if (!At(o))
1672
+ if (!Dt(o))
1673
1673
  return o;
1674
1674
  if (o.refreshToken) {
1675
- const e = G("Refreshing access token...").start();
1675
+ const e = V("Refreshing access token...").start();
1676
1676
  try {
1677
1677
  const t = await Wt(
1678
1678
  o.refreshToken,
@@ -1683,18 +1683,18 @@ async function st() {
1683
1683
  accessToken: t.access_token,
1684
1684
  refreshToken: t.refresh_token,
1685
1685
  expiresAt: new Date(Date.now() + t.expires_in * 1e3).toISOString()
1686
- }, tt(o), e.succeed("Token refreshed"), o;
1686
+ }, nt(o), e.succeed("Token refreshed"), o;
1687
1687
  } catch {
1688
- return e.warn("Token refresh failed, please log in again"), ot(), await de();
1688
+ return e.warn("Token refresh failed, please log in again"), st(), await de();
1689
1689
  }
1690
1690
  }
1691
1691
  return console.log(`Session expired. Please log in again.
1692
1692
  `), await de();
1693
1693
  }
1694
- function it() {
1694
+ function Je() {
1695
1695
  return ae;
1696
1696
  }
1697
- const X = "@myop/cli", ke = process.platform === "win32";
1697
+ const X = "@myop/cli", Fe = process.platform === "win32";
1698
1698
  function Gt() {
1699
1699
  try {
1700
1700
  return q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
@@ -1727,7 +1727,7 @@ function Qt(o, e) {
1727
1727
  return 0;
1728
1728
  }
1729
1729
  async function Zt(o) {
1730
- const e = G({
1730
+ const e = V({
1731
1731
  text: "Checking for updates...",
1732
1732
  color: "cyan"
1733
1733
  }).start(), t = await Kt();
@@ -1738,7 +1738,7 @@ async function Zt(o) {
1738
1738
  `);
1739
1739
  let n;
1740
1740
  try {
1741
- n = await Ye({
1741
+ n = await Qe({
1742
1742
  message: "Would you like to update now?",
1743
1743
  choices: [
1744
1744
  { name: "Yes, update now", value: !0 },
@@ -1752,7 +1752,7 @@ async function Zt(o) {
1752
1752
  `), process.exit(0)), i;
1753
1753
  }
1754
1754
  if (n) {
1755
- const i = G({
1755
+ const i = V({
1756
1756
  text: `Updating ${X} to v${t}...`,
1757
1757
  color: "green"
1758
1758
  }).start(), s = `npm install -g ${X}@latest`, l = Yt();
@@ -1763,30 +1763,30 @@ async function Zt(o) {
1763
1763
  πŸ” Elevated permissions required.
1764
1764
  `);
1765
1765
  try {
1766
- if (ke) {
1767
- const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${l ? `install -g ${X}@latest --prefix \\"${l}\\"` : `install -g ${X}@latest`}' -Verb RunAs -Wait`;
1768
- q(`powershell -Command "${d}"`, { stdio: "inherit" });
1766
+ if (Fe) {
1767
+ const c = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${l ? `install -g ${X}@latest --prefix \\"${l}\\"` : `install -g ${X}@latest`}' -Verb RunAs -Wait`;
1768
+ q(`powershell -Command "${c}"`, { stdio: "inherit" });
1769
1769
  } else {
1770
- const m = l ? `sudo npm install -g ${X}@latest --prefix "${l}"` : `sudo ${s}`;
1771
- q(m, { stdio: "inherit" });
1770
+ const d = l ? `sudo npm install -g ${X}@latest --prefix "${l}"` : `sudo ${s}`;
1771
+ q(d, { stdio: "inherit" });
1772
1772
  }
1773
1773
  console.log(`
1774
1774
  βœ… Updated to v${t}`);
1775
1775
  } catch {
1776
1776
  console.log(`
1777
1777
  ❌ Update failed`);
1778
- const d = ke ? `npm install -g ${X}@latest (run as Administrator)` : `sudo npm install -g ${X}@latest`;
1778
+ const c = Fe ? `npm install -g ${X}@latest (run as Administrator)` : `sudo npm install -g ${X}@latest`;
1779
1779
  console.log(`
1780
- Please run manually: ${d}
1780
+ Please run manually: ${c}
1781
1781
  `), process.exit(1);
1782
1782
  }
1783
1783
  }
1784
1784
  let w = null;
1785
1785
  try {
1786
- let v;
1787
- l ? v = ke ? Oe(l, "node_modules") : Oe(l, "lib", "node_modules") : v = q("npm root -g", { encoding: "utf-8" }).trim();
1788
- const m = Oe(v, X, "package.json"), d = yt(m, "utf-8");
1789
- w = JSON.parse(d).version;
1786
+ let S;
1787
+ l ? S = Fe ? Oe(l, "node_modules") : Oe(l, "lib", "node_modules") : S = q("npm root -g", { encoding: "utf-8" }).trim();
1788
+ const d = Oe(S, X, "package.json"), c = yt(d, "utf-8");
1789
+ w = JSON.parse(c).version;
1790
1790
  } catch {
1791
1791
  }
1792
1792
  if (w === t)
@@ -1795,8 +1795,8 @@ Please run manually: ${d}
1795
1795
  `), ht(process.argv[0], process.argv.slice(1), {
1796
1796
  stdio: "inherit",
1797
1797
  shell: !0
1798
- }).on("close", (m) => {
1799
- process.exit(m || 0);
1798
+ }).on("close", (d) => {
1799
+ process.exit(d || 0);
1800
1800
  }), !0;
1801
1801
  console.log(`
1802
1802
  Please run myop again to use the new version.
@@ -1807,38 +1807,38 @@ Please run myop again to use the new version.
1807
1807
  const Xt = (o) => new Promise((e) => setTimeout(e, o)), qt = () => {
1808
1808
  let o = new URL(import.meta.url).pathname;
1809
1809
  process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
1810
- const e = H.dirname(o);
1811
- return H.join(e, "skills");
1810
+ const e = D.dirname(o);
1811
+ return D.join(e, "skills");
1812
1812
  }, _e = (o, e) => {
1813
- R.mkdirSync(e, { recursive: !0 });
1814
- const t = R.readdirSync(o, { withFileTypes: !0 });
1813
+ I.mkdirSync(e, { recursive: !0 });
1814
+ const t = I.readdirSync(o, { withFileTypes: !0 });
1815
1815
  for (const n of t) {
1816
- const i = H.join(o, n.name), s = H.join(e, n.name);
1817
- n.isDirectory() ? _e(i, s) : R.copyFileSync(i, s);
1816
+ const i = D.join(o, n.name), s = D.join(e, n.name);
1817
+ n.isDirectory() ? _e(i, s) : I.copyFileSync(i, s);
1818
1818
  }
1819
1819
  }, rt = (o) => {
1820
1820
  const e = qt();
1821
- if (!R.existsSync(e))
1821
+ if (!I.existsSync(e))
1822
1822
  return console.info("Skills source directory not found, skipping skills installation"), !1;
1823
1823
  try {
1824
- const t = H.join(o, ".agents", "skills");
1824
+ const t = D.join(o, ".agents", "skills");
1825
1825
  _e(e, t);
1826
- const n = [".claude", ".cursor", ".gemini", ".junie", ".agent"], i = R.readdirSync(e, { withFileTypes: !0 }).filter((s) => s.isDirectory()).map((s) => s.name);
1826
+ const n = [".claude", ".cursor", ".gemini", ".junie", ".agent"], i = I.readdirSync(e, { withFileTypes: !0 }).filter((s) => s.isDirectory()).map((s) => s.name);
1827
1827
  for (const s of n) {
1828
- const l = H.join(o, s, "skills");
1829
- R.mkdirSync(l, { recursive: !0 });
1828
+ const l = D.join(o, s, "skills");
1829
+ I.mkdirSync(l, { recursive: !0 });
1830
1830
  for (const w of i) {
1831
- const v = H.join(l, w), m = H.join("..", "..", ".agents", "skills", w);
1831
+ const S = D.join(l, w), d = D.join("..", "..", ".agents", "skills", w);
1832
1832
  try {
1833
- R.rmSync(v, { recursive: !0, force: !0 });
1833
+ I.rmSync(S, { recursive: !0, force: !0 });
1834
1834
  } catch {
1835
1835
  }
1836
1836
  try {
1837
- R.symlinkSync(m, v, "dir");
1837
+ I.symlinkSync(d, S, "dir");
1838
1838
  } catch {
1839
1839
  _e(
1840
- H.join(t, w),
1841
- v
1840
+ D.join(t, w),
1841
+ S
1842
1842
  );
1843
1843
  }
1844
1844
  }
@@ -1851,22 +1851,22 @@ const Xt = (o) => new Promise((e) => setTimeout(e, o)), qt = () => {
1851
1851
  const n = [];
1852
1852
  if (t > e) return n;
1853
1853
  try {
1854
- const i = R.readdirSync(o, { withFileTypes: !0 });
1854
+ const i = I.readdirSync(o, { withFileTypes: !0 });
1855
1855
  for (const s of i) {
1856
- const l = H.join(o, s.name);
1856
+ const l = D.join(o, s.name);
1857
1857
  if (s.isDirectory()) {
1858
1858
  if (s.name === "node_modules" || s.name === ".git" || s.name === "dist" || s.name.startsWith("."))
1859
1859
  continue;
1860
1860
  n.push(...at(l, e, t + 1));
1861
1861
  } else if (s.name === "myop.config.json")
1862
1862
  try {
1863
- const w = R.readFileSync(l, "utf-8"), v = JSON.parse(w);
1863
+ const w = I.readFileSync(l, "utf-8"), S = JSON.parse(w);
1864
1864
  n.push({
1865
1865
  path: o,
1866
1866
  configPath: l,
1867
- name: v.name || v.componentName || H.basename(o),
1868
- componentId: v.componentId || null,
1869
- config: v
1867
+ name: S.name || S.componentName || D.basename(o),
1868
+ componentId: S.componentId || null,
1869
+ config: S
1870
1870
  });
1871
1871
  } catch {
1872
1872
  }
@@ -1875,26 +1875,26 @@ const Xt = (o) => new Promise((e) => setTimeout(e, o)), qt = () => {
1875
1875
  }
1876
1876
  return n;
1877
1877
  };
1878
- y.executionPath = process.cwd();
1878
+ h.executionPath = process.cwd();
1879
1879
  const $e = (o = !1) => {
1880
- const e = y.program.getOptionValue("verbose");
1880
+ const e = h.program.getOptionValue("verbose");
1881
1881
  e || (console.info = () => {
1882
- }), console.info("πŸ“ verbose mode on"), y.options = {
1883
- configPath: y.program.getOptionValue("config"),
1882
+ }), console.info("πŸ“ verbose mode on"), h.options = {
1883
+ configPath: h.program.getOptionValue("config"),
1884
1884
  verbose: e
1885
1885
  };
1886
1886
  try {
1887
- return y.myopConfig = xt(y.options.configPath), { configFound: !0 };
1887
+ return h.myopConfig = xt(h.options.configPath), { configFound: !0 };
1888
1888
  } catch (t) {
1889
1889
  if (o) {
1890
1890
  console.info(`
1891
- ⚠️ failed read config file from ${y.options.configPath}, trying to create new one`);
1891
+ ⚠️ failed read config file from ${h.options.configPath}, trying to create new one`);
1892
1892
  try {
1893
1893
  const n = {
1894
1894
  author: "@myop-cli",
1895
1895
  flows: []
1896
1896
  };
1897
- return Ae(y.options.configPath, n), y.myopConfig = n, { configFound: !0 };
1897
+ return De(h.options.configPath, n), h.myopConfig = n, { configFound: !0 };
1898
1898
  } catch {
1899
1899
  return console.info("Error details :", t), { configFound: !1, error: t };
1900
1900
  }
@@ -1903,27 +1903,27 @@ const $e = (o = !1) => {
1903
1903
  }
1904
1904
  };
1905
1905
  [
1906
- new Fe(),
1906
+ new ke(),
1907
1907
  ...Et
1908
1908
  ];
1909
- const eo = "0.1.41";
1910
- y.program = new ft();
1911
- y.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(eo);
1912
- y.program.addOption(new me("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1913
- y.program.addOption(new me("-h, --help", "Show helpful information"));
1914
- y.program.addOption(new me("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1915
- y.program.addOption(new me("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1916
- y.program.addOption(new me("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1917
- y.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, e) => {
1918
- $e(!0), console.info("adding ", o, e, y.options.configPath), o === "flow" && Xe._action(e), process.exit();
1909
+ const eo = "0.1.45";
1910
+ h.program = new ft();
1911
+ h.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(eo);
1912
+ h.program.addOption(new me("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1913
+ h.program.addOption(new me("-h, --help", "Show helpful information"));
1914
+ h.program.addOption(new me("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1915
+ h.program.addOption(new me("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1916
+ h.program.addOption(new me("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
1917
+ h.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, e) => {
1918
+ $e(!0), console.info("adding ", o, e, h.options.configPath), o === "flow" && et._action(e), process.exit();
1919
1919
  });
1920
- y.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, e) => {
1921
- $e(), console.info("removing ", o, e, y.options.configPath), o === "flow" && qe._action(e), process.exit();
1920
+ h.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, e) => {
1921
+ $e(), console.info("removing ", o, e, h.options.configPath), o === "flow" && tt._action(e), process.exit();
1922
1922
  });
1923
- y.program.command("install").description("Install Myop assets").action(async () => {
1924
- $e(), await Ze.action();
1923
+ h.program.command("install").description("Install Myop assets").action(async () => {
1924
+ $e(), await qe.action();
1925
1925
  });
1926
- y.program.command("login").description("Authenticate with Myop platform").action(async () => {
1926
+ h.program.command("login").description("Authenticate with Myop platform").action(async () => {
1927
1927
  try {
1928
1928
  await de();
1929
1929
  } catch (o) {
@@ -1931,54 +1931,54 @@ y.program.command("login").description("Authenticate with Myop platform").action
1931
1931
  }
1932
1932
  process.exit(0);
1933
1933
  });
1934
- y.program.command("logout").description("Clear stored credentials").action(async () => {
1935
- await nt(), process.exit(0);
1934
+ h.program.command("logout").description("Clear stored credentials").action(async () => {
1935
+ await it(), process.exit(0);
1936
1936
  });
1937
- y.program.command("whoami").description("Show current authenticated user").action(async () => {
1937
+ h.program.command("whoami").description("Show current authenticated user").action(async () => {
1938
1938
  const o = xe();
1939
1939
  o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1940
1940
  });
1941
- y.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (o) => {
1942
- var M, T, D, P, x, j;
1943
- const e = y.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), i = await import("path");
1941
+ h.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (o) => {
1942
+ var C, T, j, P, b, F;
1943
+ const e = h.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), i = await import("path");
1944
1944
  let s = {};
1945
1945
  if (t.existsSync(e))
1946
1946
  try {
1947
- const b = t.readFileSync(e, "utf-8");
1948
- s = JSON.parse(b);
1947
+ const x = t.readFileSync(e, "utf-8");
1948
+ s = JSON.parse(x);
1949
1949
  const f = s.name || s.componentName;
1950
1950
  console.log(`πŸ“‹ Found config: ${f || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
1951
- } catch (b) {
1952
- console.error(`⚠️ Failed to parse ${e}:`, b.message);
1951
+ } catch (x) {
1952
+ console.error(`⚠️ Failed to parse ${e}:`, x.message);
1953
1953
  }
1954
1954
  else
1955
1955
  console.log("⚠️ No myop.config.json found. A new component will be created.");
1956
1956
  let l = null, w = !1;
1957
1957
  try {
1958
- const b = JSON.parse(t.readFileSync("package.json", "utf-8"));
1959
- w = !!(b.scripts && b.scripts.build);
1958
+ const x = JSON.parse(t.readFileSync("package.json", "utf-8"));
1959
+ w = !!(x.scripts && x.scripts.build);
1960
1960
  } catch {
1961
1961
  }
1962
1962
  if (!w) {
1963
- const b = t.readdirSync(".").filter(
1963
+ const x = t.readdirSync(".").filter(
1964
1964
  (f) => f.endsWith(".html") && !f.startsWith(".") && t.statSync(f).isFile()
1965
1965
  );
1966
- b.length === 1 && (l = b[0]);
1966
+ x.length === 1 && (l = x[0]);
1967
1967
  }
1968
1968
  if (l)
1969
1969
  console.log(`πŸ“„ Single HTML file mode: ${l} (skipping build)`);
1970
1970
  else if (!o.skipBuild) {
1971
- const { exec: b } = await import("child_process");
1971
+ const { exec: x } = await import("child_process");
1972
1972
  let f = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
1973
1973
  const E = (B = !1) => new Promise((U) => {
1974
- const k = G(B ? "Retrying build..." : "Building project...").start();
1975
- b("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (z, I, Z) => {
1974
+ const k = V(B ? "Retrying build..." : "Building project...").start();
1975
+ x("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (z, R, Z) => {
1976
1976
  if (!z) {
1977
1977
  k.succeed("Build completed"), U(!0);
1978
1978
  return;
1979
1979
  }
1980
1980
  if (k.fail("Build failed"), !f.hasTriedPlatformFix && !f.hasTriedInstall) {
1981
- const se = await et(z, I, Z, b, f);
1981
+ const se = await ot(z, R, Z, x, f);
1982
1982
  if (f = { ...f, ...se }, se.handled) {
1983
1983
  const Y = await E(!0);
1984
1984
  U(Y);
@@ -1990,22 +1990,22 @@ y.program.command("sync").description("Build and upload component to Myop platfo
1990
1990
  });
1991
1991
  await E() || process.exit(1);
1992
1992
  }
1993
- const v = l || "./dist/index.html";
1994
- t.existsSync(v) || (console.error(`❌ Error: ${v} not found`), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1995
- let m;
1993
+ const S = l || "./dist/index.html";
1994
+ t.existsSync(S) || (console.error(`❌ Error: ${S} not found`), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1995
+ let d;
1996
1996
  try {
1997
- m = await st();
1998
- } catch (b) {
1999
- console.error("❌ Authentication failed:", b.message), process.exit(1);
1997
+ d = await Ue();
1998
+ } catch (x) {
1999
+ console.error("❌ Authentication failed:", x.message), process.exit(1);
2000
2000
  }
2001
- const d = it();
2002
- let C = G("Requesting upload URL...").start(), u;
2001
+ const c = Je();
2002
+ let $ = V("Requesting upload URL...").start(), u;
2003
2003
  try {
2004
- const b = await fetch(`${d}/mcp`, {
2004
+ const x = await fetch(`${c}/mcp`, {
2005
2005
  method: "POST",
2006
2006
  headers: {
2007
2007
  "Content-Type": "application/json",
2008
- Authorization: `Bearer ${m.accessToken}`
2008
+ Authorization: `Bearer ${d.accessToken}`
2009
2009
  },
2010
2010
  body: JSON.stringify({
2011
2011
  jsonrpc: "2.0",
@@ -2021,21 +2021,21 @@ y.program.command("sync").description("Build and upload component to Myop platfo
2021
2021
  }
2022
2022
  })
2023
2023
  });
2024
- if (!b.ok)
2025
- throw new Error(`Server returned ${b.status}`);
2026
- const f = await b.json();
2024
+ if (!x.ok)
2025
+ throw new Error(`Server returned ${x.status}`);
2026
+ const f = await x.json();
2027
2027
  if (f.error)
2028
2028
  throw new Error(f.error.message);
2029
- const E = (D = (T = (M = f.result) == null ? void 0 : M.content) == null ? void 0 : T[0]) == null ? void 0 : D.text;
2029
+ const E = (j = (T = (C = f.result) == null ? void 0 : C.content) == null ? void 0 : T[0]) == null ? void 0 : j.text;
2030
2030
  if (u = JSON.parse(E), !u.success)
2031
2031
  throw new Error(u.error);
2032
- C.succeed("Upload URL obtained");
2033
- } catch (b) {
2034
- C.fail("Failed to get upload URL"), console.error(" ", b.message), process.exit(1);
2032
+ $.succeed("Upload URL obtained");
2033
+ } catch (x) {
2034
+ $.fail("Failed to get upload URL"), console.error(" ", x.message), process.exit(1);
2035
2035
  }
2036
- C = G("Uploading component...").start();
2036
+ $ = V("Uploading component...").start();
2037
2037
  try {
2038
- const b = t.readFileSync(v, "utf-8");
2038
+ const x = t.readFileSync(S, "utf-8");
2039
2039
  let f;
2040
2040
  const E = u.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2041
2041
  if (E)
@@ -2048,29 +2048,29 @@ y.program.command("sync").description("Build and upload component to Myop platfo
2048
2048
  throw new Error("Could not parse presigned URL from: " + u.curlCommand);
2049
2049
  }
2050
2050
  console.info("Uploading to:", f.substring(0, 100) + "...");
2051
- const _ = await fetch(f, {
2051
+ const L = await fetch(f, {
2052
2052
  method: "PUT",
2053
2053
  headers: {
2054
2054
  "Content-Type": "text/html"
2055
2055
  },
2056
- body: b
2056
+ body: x
2057
2057
  });
2058
- if (!_.ok) {
2059
- const B = await _.text();
2060
- throw new Error(`Upload failed with status ${_.status}: ${B}`);
2058
+ if (!L.ok) {
2059
+ const B = await L.text();
2060
+ throw new Error(`Upload failed with status ${L.status}: ${B}`);
2061
2061
  }
2062
- C.succeed("Component uploaded");
2063
- } catch (b) {
2064
- C.fail("Upload failed"), console.error(" ", b.message), b.cause && console.error(" Cause:", b.cause), process.exit(1);
2062
+ $.succeed("Component uploaded");
2063
+ } catch (x) {
2064
+ $.fail("Upload failed"), console.error(" ", x.message), x.cause && console.error(" Cause:", x.cause), process.exit(1);
2065
2065
  }
2066
- C = G("Confirming upload...").start();
2067
- let S;
2066
+ $ = V("Confirming upload...").start();
2067
+ let y;
2068
2068
  try {
2069
- const b = await fetch(`${d}/mcp`, {
2069
+ const x = await fetch(`${c}/mcp`, {
2070
2070
  method: "POST",
2071
2071
  headers: {
2072
2072
  "Content-Type": "application/json",
2073
- Authorization: `Bearer ${m.accessToken}`
2073
+ Authorization: `Bearer ${d.accessToken}`
2074
2074
  },
2075
2075
  body: JSON.stringify({
2076
2076
  jsonrpc: "2.0",
@@ -2084,59 +2084,59 @@ y.program.command("sync").description("Build and upload component to Myop platfo
2084
2084
  }
2085
2085
  })
2086
2086
  });
2087
- if (!b.ok)
2088
- throw new Error(`Server returned ${b.status}`);
2089
- const f = await b.json();
2087
+ if (!x.ok)
2088
+ throw new Error(`Server returned ${x.status}`);
2089
+ const f = await x.json();
2090
2090
  if (f.error)
2091
2091
  throw new Error(f.error.message);
2092
- const E = (j = (x = (P = f.result) == null ? void 0 : P.content) == null ? void 0 : x[0]) == null ? void 0 : j.text;
2093
- if (S = JSON.parse(E), !S.success)
2094
- throw new Error(S.error);
2095
- C.succeed("Upload confirmed");
2096
- } catch (b) {
2097
- C.fail("Confirmation failed"), console.error(" ", b.message), process.exit(1);
2098
- }
2099
- if (S.isNewComponent || !s.componentId) {
2100
- s.componentId = S.componentId, s.organization = S.orgId, s.name || (s.name = S.componentName);
2092
+ const E = (F = (b = (P = f.result) == null ? void 0 : P.content) == null ? void 0 : b[0]) == null ? void 0 : F.text;
2093
+ if (y = JSON.parse(E), !y.success)
2094
+ throw new Error(y.error);
2095
+ $.succeed("Upload confirmed");
2096
+ } catch (x) {
2097
+ $.fail("Confirmation failed"), console.error(" ", x.message), process.exit(1);
2098
+ }
2099
+ if (y.isNewComponent || !s.componentId) {
2100
+ s.componentId = y.componentId, s.organization = y.orgId, s.name || (s.name = y.componentName);
2101
2101
  try {
2102
2102
  t.writeFileSync(e, JSON.stringify(s, null, 2)), console.log(`
2103
2103
  πŸ“ Updated ${e} with componentId`);
2104
- } catch (b) {
2104
+ } catch (x) {
2105
2105
  console.log(`
2106
- ⚠️ Could not update ${e}: ${b.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
2106
+ ⚠️ Could not update ${e}: ${x.message}`), console.log(` Please add componentId: "${y.componentId}" manually`);
2107
2107
  }
2108
2108
  }
2109
2109
  console.log(`
2110
- βœ… Sync completed successfully!`), console.log(` Component: ${S.componentName}`), console.log(` Dashboard: ${S.dashboardUrl}`), process.exit(0);
2110
+ βœ… Sync completed successfully!`), console.log(` Component: ${y.componentName}`), console.log(` Dashboard: ${y.dashboardUrl}`), process.exit(0);
2111
2111
  });
2112
- y.program.command("push").description("Upload component to Myop platform").action(async () => {
2113
- var C, u, S, M, T, D;
2114
- const o = y.program.getOptionValue("config") || "./myop.config.json";
2112
+ h.program.command("push").description("Upload component to Myop platform").action(async () => {
2113
+ var $, u, y, C, T, j;
2114
+ const o = h.program.getOptionValue("config") || "./myop.config.json";
2115
2115
  let e = {};
2116
- if (R.existsSync(o))
2116
+ if (I.existsSync(o))
2117
2117
  try {
2118
- e = JSON.parse(R.readFileSync(o, "utf-8"));
2118
+ e = JSON.parse(I.readFileSync(o, "utf-8"));
2119
2119
  } catch (P) {
2120
2120
  console.error(`⚠️ Failed to parse ${o}:`, P.message);
2121
2121
  }
2122
- const t = e.name || e.componentName || H.basename(process.cwd());
2122
+ const t = e.name || e.componentName || D.basename(process.cwd());
2123
2123
  console.log(`
2124
2124
  πŸ“‹ Component: ${t}`);
2125
2125
  let n;
2126
- const i = R.readdirSync(".").filter(
2127
- (P) => P.endsWith(".html") && !P.startsWith(".") && R.statSync(P).isFile()
2126
+ const i = I.readdirSync(".").filter(
2127
+ (P) => P.endsWith(".html") && !P.startsWith(".") && I.statSync(P).isFile()
2128
2128
  );
2129
- i.length === 1 && !R.existsSync("./dist/index.html") ? n = i[0] : R.existsSync("./dist/index.html") ? n = "./dist/index.html" : i.length === 1 ? n = i[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));
2130
- const s = R.readFileSync(n, "utf-8");
2129
+ i.length === 1 && !I.existsSync("./dist/index.html") ? n = i[0] : I.existsSync("./dist/index.html") ? n = "./dist/index.html" : i.length === 1 ? n = i[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));
2130
+ const s = I.readFileSync(n, "utf-8");
2131
2131
  console.log(` File: ${n} (${(s.length / 1024).toFixed(1)} KB)`);
2132
2132
  let l;
2133
2133
  try {
2134
- l = await st();
2134
+ l = await Ue();
2135
2135
  } catch (P) {
2136
2136
  console.error("❌ Authentication failed:", P.message), process.exit(1);
2137
2137
  }
2138
- const w = it();
2139
- let v = G("Uploading...").start(), m;
2138
+ const w = Je();
2139
+ let S = V("Uploading...").start(), d;
2140
2140
  try {
2141
2141
  const P = await fetch(`${w}/mcp`, {
2142
2142
  method: "POST",
@@ -2160,40 +2160,40 @@ y.program.command("push").description("Upload component to Myop platform").actio
2160
2160
  });
2161
2161
  if (!P.ok)
2162
2162
  throw new Error(`Server returned ${P.status}`);
2163
- const x = await P.json();
2164
- if (x.error)
2165
- throw new Error(x.error.message);
2166
- const j = (S = (u = (C = x.result) == null ? void 0 : C.content) == null ? void 0 : u[0]) == null ? void 0 : S.text;
2167
- if (m = JSON.parse(j), !m.success)
2168
- throw new Error(m.error);
2163
+ const b = await P.json();
2164
+ if (b.error)
2165
+ throw new Error(b.error.message);
2166
+ const F = (y = (u = ($ = b.result) == null ? void 0 : $.content) == null ? void 0 : u[0]) == null ? void 0 : y.text;
2167
+ if (d = JSON.parse(F), !d.success)
2168
+ throw new Error(d.error);
2169
2169
  } catch (P) {
2170
- v.fail("Failed to get upload URL"), console.error(" ", P.message), process.exit(1);
2170
+ S.fail("Failed to get upload URL"), console.error(" ", P.message), process.exit(1);
2171
2171
  }
2172
2172
  try {
2173
2173
  let P;
2174
- const x = m.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2175
- if (x)
2176
- P = x[1];
2174
+ const b = d.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
2175
+ if (b)
2176
+ P = b[1];
2177
2177
  else {
2178
- const b = m.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
2179
- if (b)
2180
- P = b[1];
2178
+ const x = d.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
2179
+ if (x)
2180
+ P = x[1];
2181
2181
  else
2182
2182
  throw new Error("Could not parse presigned URL");
2183
2183
  }
2184
- const j = await fetch(P, {
2184
+ const F = await fetch(P, {
2185
2185
  method: "PUT",
2186
2186
  headers: { "Content-Type": "text/html" },
2187
2187
  body: s
2188
2188
  });
2189
- if (!j.ok) {
2190
- const b = await j.text();
2191
- throw new Error(`Upload failed: ${j.status} ${b}`);
2189
+ if (!F.ok) {
2190
+ const x = await F.text();
2191
+ throw new Error(`Upload failed: ${F.status} ${x}`);
2192
2192
  }
2193
2193
  } catch (P) {
2194
- v.fail("Upload failed"), console.error(" ", P.message), process.exit(1);
2194
+ S.fail("Upload failed"), console.error(" ", P.message), process.exit(1);
2195
2195
  }
2196
- let d;
2196
+ let c;
2197
2197
  try {
2198
2198
  const P = await fetch(`${w}/mcp`, {
2199
2199
  method: "POST",
@@ -2208,36 +2208,109 @@ y.program.command("push").description("Upload component to Myop platform").actio
2208
2208
  params: {
2209
2209
  name: "confirm_upload",
2210
2210
  arguments: {
2211
- uploadId: m.uploadId
2211
+ uploadId: d.uploadId
2212
2212
  }
2213
2213
  }
2214
2214
  })
2215
2215
  });
2216
2216
  if (!P.ok)
2217
2217
  throw new Error(`Server returned ${P.status}`);
2218
- const x = await P.json();
2219
- if (x.error)
2220
- throw new Error(x.error.message);
2221
- const j = (D = (T = (M = x.result) == null ? void 0 : M.content) == null ? void 0 : T[0]) == null ? void 0 : D.text;
2222
- if (d = JSON.parse(j), !d.success)
2223
- throw new Error(d.error);
2224
- v.succeed("Pushed successfully");
2218
+ const b = await P.json();
2219
+ if (b.error)
2220
+ throw new Error(b.error.message);
2221
+ const F = (j = (T = (C = b.result) == null ? void 0 : C.content) == null ? void 0 : T[0]) == null ? void 0 : j.text;
2222
+ if (c = JSON.parse(F), !c.success)
2223
+ throw new Error(c.error);
2224
+ S.succeed("Pushed successfully");
2225
2225
  } catch (P) {
2226
- v.fail("Confirmation failed"), console.error(" ", P.message), process.exit(1);
2226
+ S.fail("Confirmation failed"), console.error(" ", P.message), process.exit(1);
2227
2227
  }
2228
- if (d.isNewComponent || !e.componentId || e.componentId === "DEV") {
2229
- e.componentId = d.componentId, e.organization = d.orgId, e.name || (e.name = d.componentName);
2228
+ if (c.isNewComponent || !e.componentId || e.componentId === "DEV") {
2229
+ e.componentId = c.componentId, e.organization = c.orgId, e.name || (e.name = c.componentName);
2230
2230
  try {
2231
- R.writeFileSync(o, JSON.stringify(e, null, 2));
2231
+ I.writeFileSync(o, JSON.stringify(e, null, 2));
2232
2232
  } catch (P) {
2233
- console.log(`⚠️ Could not update ${o}: ${P.message}`), console.log(` Add componentId: "${d.componentId}" manually`);
2233
+ console.log(`⚠️ Could not update ${o}: ${P.message}`), console.log(` Add componentId: "${c.componentId}" manually`);
2234
2234
  }
2235
2235
  }
2236
2236
  console.log(`
2237
- ${d.componentName}`), console.log(` ${d.dashboardUrl}
2237
+ ${c.componentName}`), console.log(` ${c.dashboardUrl}
2238
+ `), process.exit(0);
2239
+ });
2240
+ h.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, e) => {
2241
+ var T, j, P;
2242
+ const t = h.program.getOptionValue("config") || "./myop.config.json";
2243
+ let n = {};
2244
+ if (I.existsSync(t))
2245
+ try {
2246
+ n = JSON.parse(I.readFileSync(t, "utf-8"));
2247
+ } catch {
2248
+ }
2249
+ const i = o || n.componentId;
2250
+ (!i || i === "DEV") && (console.error("❌ No component ID provided."), console.log(" Pass a component ID: myop pull <componentId>"), console.log(" Or ensure myop.config.json has a valid componentId."), process.exit(1));
2251
+ const s = n.name || n.componentName || i;
2252
+ console.log(`
2253
+ πŸ“₯ Pulling: ${s}`), console.log(` ID: ${i}`);
2254
+ let l;
2255
+ try {
2256
+ l = await Ue();
2257
+ } catch (b) {
2258
+ console.error("❌ Authentication failed:", b.message), process.exit(1);
2259
+ }
2260
+ const w = Je(), S = V("Fetching component...").start();
2261
+ let d;
2262
+ try {
2263
+ const b = await fetch(`${w}/mcp`, {
2264
+ method: "POST",
2265
+ headers: {
2266
+ "Content-Type": "application/json",
2267
+ Authorization: `Bearer ${l.accessToken}`
2268
+ },
2269
+ body: JSON.stringify({
2270
+ jsonrpc: "2.0",
2271
+ id: 1,
2272
+ method: "tools/call",
2273
+ params: {
2274
+ name: "get_component",
2275
+ arguments: { componentId: i }
2276
+ }
2277
+ })
2278
+ });
2279
+ if (!b.ok)
2280
+ throw new Error(`Server returned ${b.status}`);
2281
+ const F = await b.json();
2282
+ if (F.error)
2283
+ throw new Error(F.error.message);
2284
+ const x = (P = (j = (T = F.result) == null ? void 0 : T.content) == null ? void 0 : j[0]) == null ? void 0 : P.text;
2285
+ if (d = JSON.parse(x), !d.success && !d.html)
2286
+ throw new Error(d.error || "No HTML content returned");
2287
+ S.succeed("Component fetched");
2288
+ } catch (b) {
2289
+ S.fail("Failed to fetch component"), console.error(" ", b.message), process.exit(1);
2290
+ }
2291
+ let c = e.output;
2292
+ c || (I.existsSync("./dist/index.html") ? c = "./dist/index.html" : c = "./index.html");
2293
+ const $ = d.htmlContent || d.html, u = D.dirname(c);
2294
+ u && !I.existsSync(u) && I.mkdirSync(u, { recursive: !0 }), I.writeFileSync(c, $), console.log(` Saved to: ${c} (${($.length / 1024).toFixed(1)} KB)`);
2295
+ const y = I.existsSync(t);
2296
+ let C = !1;
2297
+ if (y ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = i, C = !0), !n.name && d.name && (n.name = d.name, C = !0)) : (n = {
2298
+ name: d.name || D.basename(process.cwd()),
2299
+ componentId: i,
2300
+ type: "html",
2301
+ author: "@myop-cli",
2302
+ HMR: !0
2303
+ }, C = !0), C)
2304
+ try {
2305
+ I.writeFileSync(t, JSON.stringify(n, null, 2)), console.log(` ${y ? "Updated" : "Created"} ${t}`);
2306
+ } catch (b) {
2307
+ console.log(` ⚠️ Could not write ${t}: ${b.message}`);
2308
+ }
2309
+ console.log(`
2310
+ βœ… Pull completed!
2238
2311
  `), process.exit(0);
2239
2312
  });
2240
- y.program.command("create").description("Create a new Myop HTML component and start dev server").action(async () => {
2313
+ h.program.command("create").description("Create a new Myop HTML component and start dev server").action(async () => {
2241
2314
  const { input: o } = await import("@inquirer/prompts"), e = await import("fs"), n = (await import("path")).default.basename(process.cwd());
2242
2315
  let i;
2243
2316
  try {
@@ -2245,11 +2318,11 @@ y.program.command("create").description("Create a new Myop HTML component and st
2245
2318
  message: "Component name:",
2246
2319
  default: n
2247
2320
  });
2248
- } catch (v) {
2249
- throw v.name === "ExitPromptError" && (console.log(`
2321
+ } catch (S) {
2322
+ throw S.name === "ExitPromptError" && (console.log(`
2250
2323
 
2251
2324
  πŸ‘‹ Goodbye!
2252
- `), process.exit(0)), v;
2325
+ `), process.exit(0)), S;
2253
2326
  }
2254
2327
  (e.existsSync("index.html") || e.existsSync("myop.config.json")) && (console.log(`
2255
2328
  ⚠️ 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));
@@ -2388,7 +2461,7 @@ y.program.command("create").description("Create a new Myop HTML component and st
2388
2461
  console.log(`
2389
2462
  βœ… Created ${i}`), console.log(" index.html"), console.log(" myop.config.json"), w && console.log(" .agents/skills/ (AI agent skills)"), console.log(""), await be();
2390
2463
  });
2391
- y.program.command("dev").description("Start development server with file watching").action(be);
2464
+ h.program.command("dev").description("Start development server with file watching").action(be);
2392
2465
  const to = () => {
2393
2466
  try {
2394
2467
  q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
@@ -2422,12 +2495,12 @@ const to = () => {
2422
2495
  return null;
2423
2496
  }
2424
2497
  }, ne = async (o = !1, e = !1) => {
2425
- var d, C, u;
2426
- const t = xe(), n = !!(t != null && t.email), i = ((d = y.myopConfig) == null ? void 0 : d.name) || ((C = y.myopConfig) == null ? void 0 : C.componentName), s = (u = y.myopConfig) == null ? void 0 : u.componentId, l = to();
2498
+ var c, $, u;
2499
+ const t = xe(), n = !!(t != null && t.email), i = ((c = h.myopConfig) == null ? void 0 : c.name) || (($ = h.myopConfig) == null ? void 0 : $.componentName), s = (u = h.myopConfig) == null ? void 0 : u.componentId, l = to();
2427
2500
  console.log(`
2428
2501
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Welcome to Myop CLI - Remote UI Made Easy β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2429
2502
  `), o && i ? (console.log(` Component: ${i}`), s ? (console.log(` ID: ${s}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${s}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? t.email : "Not logged in"}`), l != null && l.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")) : l != null && l.notARepo ? console.log(" Changes: Not a git repository") : l && (l.insertions > 0 || l.deletions > 0) ? console.log(` Changes: ${l.files} file${l.files !== 1 ? "s" : ""} | \x1B[32m+${l.insertions}\x1B[0m \x1B[31m-${l.deletions}\x1B[0m`) : l && console.log(" Changes: No uncommitted changes"), console.log("");
2430
- const v = [
2503
+ const S = [
2431
2504
  {
2432
2505
  emoji: "πŸš€",
2433
2506
  label: "Initialize new component",
@@ -2449,14 +2522,14 @@ const to = () => {
2449
2522
  help: "Builds project & uploads dist/index.html to Myop",
2450
2523
  disabled: o ? n ? !1 : "(login required)" : "(no config file)"
2451
2524
  }
2452
- ].map((S) => ({
2453
- name: e && !S.disabled ? `${S.emoji} ${S.label}
2454
- ${S.help}` : `${S.emoji} ${S.label}`,
2455
- value: S.value,
2456
- disabled: S.disabled
2525
+ ].map((y) => ({
2526
+ name: e && !y.disabled ? `${y.emoji} ${y.label}
2527
+ ${y.help}` : `${y.emoji} ${y.label}`,
2528
+ value: y.value,
2529
+ disabled: y.disabled
2457
2530
  }));
2458
- v.push(
2459
- new Fe(),
2531
+ S.push(
2532
+ new ke(),
2460
2533
  {
2461
2534
  name: e && n ? `πŸ”“ Logout (${t.email})
2462
2535
  Clears stored credentials from this machine` : e && !n ? `πŸ” Login to Myop
@@ -2467,25 +2540,25 @@ const to = () => {
2467
2540
  name: e ? "πŸ“– Hide help" : "πŸ“– Show help",
2468
2541
  value: "help"
2469
2542
  },
2470
- new Fe(),
2543
+ new ke(),
2471
2544
  {
2472
2545
  name: "πŸ‘‹ Exit",
2473
2546
  value: "exit"
2474
2547
  }
2475
2548
  );
2476
- let m;
2549
+ let d;
2477
2550
  try {
2478
- m = await Ye({
2551
+ d = await Qe({
2479
2552
  message: "What would you like to do?",
2480
- choices: v
2553
+ choices: S
2481
2554
  });
2482
- } catch (S) {
2483
- throw S.name === "ExitPromptError" && (console.log(`
2555
+ } catch (y) {
2556
+ throw y.name === "ExitPromptError" && (console.log(`
2484
2557
 
2485
2558
  πŸ‘‹ Goodbye!
2486
- `), process.exit(0)), S;
2559
+ `), process.exit(0)), y;
2487
2560
  }
2488
- switch (m) {
2561
+ switch (d) {
2489
2562
  case "init":
2490
2563
  await io();
2491
2564
  break;
@@ -2493,9 +2566,9 @@ const to = () => {
2493
2566
  console.log(`
2494
2567
  Running sync...
2495
2568
  `);
2496
- const { execSync: S } = await import("child_process");
2569
+ const { execSync: y } = await import("child_process");
2497
2570
  try {
2498
- S("node " + process.argv[1] + " sync", { stdio: "inherit" });
2571
+ y("node " + process.argv[1] + " sync", { stdio: "inherit" });
2499
2572
  } catch {
2500
2573
  }
2501
2574
  await ne(!0, e);
@@ -2507,12 +2580,12 @@ Running sync...
2507
2580
  try {
2508
2581
  await de(), console.log(`
2509
2582
  `), await ne(o, e);
2510
- } catch (M) {
2511
- console.error("Login failed:", M.message), await ne(o, e);
2583
+ } catch (C) {
2584
+ console.error("Login failed:", C.message), await ne(o, e);
2512
2585
  }
2513
2586
  break;
2514
2587
  case "logout":
2515
- await nt(), console.log(`
2588
+ await it(), console.log(`
2516
2589
  `), await ne(o, e);
2517
2590
  break;
2518
2591
  case "help":
@@ -2523,7 +2596,7 @@ Running sync...
2523
2596
  }
2524
2597
  }, ve = ".myop-monorepo.json", oo = () => {
2525
2598
  try {
2526
- const o = R.readFileSync(ve, "utf-8");
2599
+ const o = I.readFileSync(ve, "utf-8");
2527
2600
  return JSON.parse(o);
2528
2601
  } catch {
2529
2602
  return null;
@@ -2534,7 +2607,7 @@ Running sync...
2534
2607
  selectedComponents: o,
2535
2608
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2536
2609
  };
2537
- R.writeFileSync(ve, JSON.stringify(e, null, 2));
2610
+ I.writeFileSync(ve, JSON.stringify(e, null, 2));
2538
2611
  } catch {
2539
2612
  }
2540
2613
  }, so = async () => {
@@ -2542,25 +2615,25 @@ Running sync...
2542
2615
  console.log(`
2543
2616
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Myop CLI - Monorepo Mode β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
2544
2617
  `);
2545
- const t = G("Scanning for components...").start(), n = at(".");
2618
+ const t = V("Scanning for components...").start(), n = at(".");
2546
2619
  t.stop(), n.length === 0 && (console.log(` ⚠️ No myop.config.json files found in this directory or subdirectories.
2547
2620
  `), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
2548
2621
  const i = oo(), s = (i == null ? void 0 : i.selectedComponents) || [], l = s.length > 0;
2549
2622
  console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
2550
- `), n.forEach((u, S) => {
2551
- const M = u.componentId ? "βœ…" : "βšͺ", T = u.componentId ? u.componentId.substring(0, 8) + "..." : "(not pushed)";
2552
- console.log(` ${M} ${u.name}`), console.log(` Path: ${u.path}`), console.log(` ID: ${T}`), console.log("");
2623
+ `), n.forEach((u, y) => {
2624
+ const C = u.componentId ? "βœ…" : "βšͺ", T = u.componentId ? u.componentId.substring(0, 8) + "..." : "(not pushed)";
2625
+ console.log(` ${C} ${u.name}`), console.log(` Path: ${u.path}`), console.log(` ID: ${T}`), console.log("");
2553
2626
  }), console.log(` User: ${e ? o.email : "Not logged in"}`), l && console.log(` πŸ“‹ Using saved selection from ${ve}`), console.log("");
2554
- const { checkbox: w } = await import("@inquirer/prompts"), v = n.map((u) => ({
2627
+ const { checkbox: w } = await import("@inquirer/prompts"), S = n.map((u) => ({
2555
2628
  name: `${u.name} (${u.path})`,
2556
2629
  value: u.path,
2557
2630
  checked: l ? s.includes(u.path) : !0
2558
2631
  }));
2559
- let m;
2632
+ let d;
2560
2633
  try {
2561
- m = await w({
2634
+ d = await w({
2562
2635
  message: "Select components to start in dev mode:",
2563
- choices: v
2636
+ choices: S
2564
2637
  });
2565
2638
  } catch (u) {
2566
2639
  throw u.name === "ExitPromptError" && (console.log(`
@@ -2568,15 +2641,15 @@ Running sync...
2568
2641
  πŸ‘‹ Goodbye!
2569
2642
  `), process.exit(0)), u;
2570
2643
  }
2571
- m.length === 0 && (console.log(`
2644
+ d.length === 0 && (console.log(`
2572
2645
  ⚠️ No components selected.
2573
- `), process.exit(0)), no(m), console.log(`
2646
+ `), process.exit(0)), no(d), console.log(`
2574
2647
  πŸ’Ύ Selection saved to ${ve}`);
2575
- const d = n.filter((u) => m.includes(u.path));
2576
- console.log(`πŸš€ Starting dev mode for ${d.length} component${d.length > 1 ? "s" : ""}...
2648
+ const c = n.filter((u) => d.includes(u.path));
2649
+ console.log(`πŸš€ Starting dev mode for ${c.length} component${c.length > 1 ? "s" : ""}...
2577
2650
  `);
2578
- const { monorepoDevCommand: C } = await Promise.resolve().then(() => _t);
2579
- await C(d);
2651
+ const { monorepoDevCommand: $ } = await Promise.resolve().then(() => _t);
2652
+ await $(c);
2580
2653
  }, io = async () => {
2581
2654
  const { input: o, select: e } = await import("@inquirer/prompts"), t = await import("fs"), n = await import("path"), i = n.default.basename(process.cwd());
2582
2655
  let s, l;
@@ -2593,22 +2666,22 @@ Running sync...
2593
2666
  { name: "πŸ…°οΈ Angular", value: "angular", disabled: "(coming soon)" }
2594
2667
  ]
2595
2668
  });
2596
- } catch (m) {
2597
- throw m.name === "ExitPromptError" && (console.log(`
2669
+ } catch (d) {
2670
+ throw d.name === "ExitPromptError" && (console.log(`
2598
2671
 
2599
2672
  πŸ‘‹ Goodbye!
2600
- `), process.exit(0)), m;
2673
+ `), process.exit(0)), d;
2601
2674
  }
2602
2675
  const w = {
2603
2676
  name: s,
2604
2677
  type: l,
2605
2678
  author: "@myop-cli",
2606
2679
  HMR: !0
2607
- }, v = y.program.getOptionValue("config") || "./myop.config.json";
2680
+ }, S = h.program.getOptionValue("config") || "./myop.config.json";
2608
2681
  try {
2609
- t.writeFileSync(v, JSON.stringify(w, null, 2)), console.log(`
2610
- βœ… Created ${v}`);
2611
- const m = {
2682
+ t.writeFileSync(S, JSON.stringify(w, null, 2)), console.log(`
2683
+ βœ… Created ${S}`);
2684
+ const d = {
2612
2685
  name: s.toLowerCase().replace(/\s+/g, "-"),
2613
2686
  version: "1.0.0",
2614
2687
  type: "module",
@@ -2620,7 +2693,7 @@ Running sync...
2620
2693
  esbuild: "^0.24.0"
2621
2694
  }
2622
2695
  };
2623
- t.writeFileSync("package.json", JSON.stringify(m, null, 2)), console.log("βœ… Created package.json"), t.mkdirSync("src/modules", { recursive: !0 }), t.mkdirSync("src/styles", { recursive: !0 }), t.writeFileSync("build.js", `import * as esbuild from 'esbuild';
2696
+ t.writeFileSync("package.json", JSON.stringify(d, null, 2)), console.log("βœ… Created package.json"), t.mkdirSync("src/modules", { recursive: !0 }), t.mkdirSync("src/styles", { recursive: !0 }), t.writeFileSync("build.js", `import * as esbuild from 'esbuild';
2624
2697
  import fs from 'fs';
2625
2698
  import path from 'path';
2626
2699
 
@@ -2700,7 +2773,7 @@ fs.writeFileSync('dist/index.html', html);
2700
2773
  console.log('βœ… Built dist/index.html');
2701
2774
  console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
2702
2775
  `), console.log("βœ… Created build.js");
2703
- const C = `<!DOCTYPE html>
2776
+ const $ = `<!DOCTYPE html>
2704
2777
  <html lang="en">
2705
2778
  <head>
2706
2779
  <meta charset="UTF-8">
@@ -2717,7 +2790,7 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
2717
2790
  </body>
2718
2791
  </html>
2719
2792
  `;
2720
- t.writeFileSync("index.html", C), console.log("βœ… Created index.html");
2793
+ t.writeFileSync("index.html", $), console.log("βœ… Created index.html");
2721
2794
  const u = `// ${s} - Entry Point
2722
2795
  import { init } from './modules/app.js';
2723
2796
  import { setupMyopInterface } from './modules/myop.js';
@@ -2728,7 +2801,7 @@ document.addEventListener('DOMContentLoaded', () => {
2728
2801
  });
2729
2802
  `;
2730
2803
  t.writeFileSync("src/index.js", u), console.log("βœ… Created src/index.js");
2731
- const S = `// ${s} - Main Application Logic
2804
+ const y = `// ${s} - Main Application Logic
2732
2805
 
2733
2806
  export function init() {
2734
2807
  console.log('${s} loaded');
@@ -2736,7 +2809,7 @@ export function init() {
2736
2809
  // Your component logic here
2737
2810
  }
2738
2811
  `;
2739
- t.writeFileSync("src/modules/app.js", S), console.log("βœ… Created src/modules/app.js"), t.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
2812
+ t.writeFileSync("src/modules/app.js", y), console.log("βœ… Created src/modules/app.js"), t.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
2740
2813
 
2741
2814
  export function setupMyopInterface() {
2742
2815
  // Called when host app sends data to this component
@@ -2757,7 +2830,7 @@ export function setupMyopInterface() {
2757
2830
  @import './main.css';
2758
2831
  `;
2759
2832
  t.writeFileSync("src/styles/index.css", T), console.log("βœ… Created src/styles/index.css");
2760
- const D = `/* ${s} - Main Styles */
2833
+ const j = `/* ${s} - Main Styles */
2761
2834
 
2762
2835
  * {
2763
2836
  box-sizing: border-box;
@@ -2786,17 +2859,17 @@ p {
2786
2859
  line-height: 1.5;
2787
2860
  }
2788
2861
  `;
2789
- t.writeFileSync("src/styles/main.css", D), console.log("βœ… Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2862
+ t.writeFileSync("src/styles/main.css", j), console.log("βœ… Created src/styles/main.css"), t.writeFileSync(".gitignore", `node_modules/
2790
2863
  dist/
2791
2864
  .temp-entry.js
2792
2865
  .temp-styles.css
2793
2866
  .DS_Store
2794
2867
  `), console.log("βœ… Created .gitignore");
2795
- const x = rt(process.cwd());
2796
- x && console.log("βœ… Installed AI agent skills");
2797
- const j = await import("./index-DuEoKctW.js").then((f) => f.i), b = process.cwd();
2868
+ const b = rt(process.cwd());
2869
+ b && console.log("βœ… Installed AI agent skills");
2870
+ const F = await import("./index-DuEoKctW.js").then((f) => f.i), x = process.cwd();
2798
2871
  try {
2799
- await j.init({ fs: t, dir: b });
2872
+ await F.init({ fs: t, dir: x });
2800
2873
  const f = [
2801
2874
  "myop.config.json",
2802
2875
  "package.json",
@@ -2809,13 +2882,13 @@ dist/
2809
2882
  "src/styles/index.css",
2810
2883
  "src/styles/main.css"
2811
2884
  ];
2812
- if (x) {
2813
- const E = (_, B) => {
2885
+ if (b) {
2886
+ const E = (L, B) => {
2814
2887
  try {
2815
- const U = t.readdirSync(_, { withFileTypes: !0 });
2888
+ const U = t.readdirSync(L, { withFileTypes: !0 });
2816
2889
  for (const k of U) {
2817
- const z = n.join(_, k.name), I = n.join(B, k.name);
2818
- k.isDirectory() ? E(z, I) : f.push(I);
2890
+ const z = n.join(L, k.name), R = n.join(B, k.name);
2891
+ k.isDirectory() ? E(z, R) : f.push(R);
2819
2892
  }
2820
2893
  } catch {
2821
2894
  }
@@ -2823,10 +2896,10 @@ dist/
2823
2896
  E(".agents/skills", ".agents/skills");
2824
2897
  }
2825
2898
  for (const E of f)
2826
- await j.add({ fs: t, dir: b, filepath: E });
2827
- await j.commit({
2899
+ await F.add({ fs: t, dir: x, filepath: E });
2900
+ await F.commit({
2828
2901
  fs: t,
2829
- dir: b,
2902
+ dir: x,
2830
2903
  message: "init",
2831
2904
  author: { name: "myop-cli", email: "cli@myop.dev" }
2832
2905
  }), console.log("βœ… Initialized git repository");
@@ -2835,51 +2908,51 @@ dist/
2835
2908
  }
2836
2909
  console.log(`
2837
2910
  πŸ“¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
2838
- `), y.myopConfig = w, await ne(!0);
2839
- } catch (m) {
2840
- console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
2911
+ `), h.myopConfig = w, await ne(!0);
2912
+ } catch (d) {
2913
+ console.error(`Failed to initialize component: ${d.message}`), process.exit(1);
2841
2914
  }
2842
2915
  };
2843
- y.program.command("default", { isDefault: !0 }).action(async () => {
2844
- if (y.program.getOptionValue("help") && (console.log(bt), process.exit()), y.program.getOptionValue("monorepo")) {
2916
+ h.program.command("default", { isDefault: !0 }).action(async () => {
2917
+ if (h.program.getOptionValue("help") && (console.log(bt), process.exit()), h.program.getOptionValue("monorepo")) {
2845
2918
  await so();
2846
2919
  return;
2847
2920
  }
2848
- if (y.program.getOptionValue("ci")) {
2849
- const w = await import("fs"), v = y.program.getOptionValue("config") || "./myop.config.json", m = y.program.version(), d = xe();
2850
- let C = { found: !1 };
2921
+ if (h.program.getOptionValue("ci")) {
2922
+ const w = await import("fs"), S = h.program.getOptionValue("config") || "./myop.config.json", d = h.program.version(), c = xe();
2923
+ let $ = { found: !1 };
2851
2924
  try {
2852
- if (w.existsSync(v)) {
2853
- const S = w.readFileSync(v, "utf-8"), M = JSON.parse(S);
2854
- C = {
2925
+ if (w.existsSync(S)) {
2926
+ const y = w.readFileSync(S, "utf-8"), C = JSON.parse(y);
2927
+ $ = {
2855
2928
  found: !0,
2856
- path: v,
2857
- name: M.name || M.componentName || null,
2858
- componentId: M.componentId || null,
2859
- organization: M.organization || null
2929
+ path: S,
2930
+ name: C.name || C.componentName || null,
2931
+ componentId: C.componentId || null,
2932
+ organization: C.organization || null
2860
2933
  };
2861
2934
  }
2862
- } catch (S) {
2863
- C = { found: !1, error: S.message };
2935
+ } catch (y) {
2936
+ $ = { found: !1, error: y.message };
2864
2937
  }
2865
2938
  const u = {
2866
- version: m,
2867
- config: C,
2939
+ version: d,
2940
+ config: $,
2868
2941
  auth: {
2869
- loggedIn: !!(d != null && d.email),
2870
- email: (d == null ? void 0 : d.email) || null
2942
+ loggedIn: !!(c != null && c.email),
2943
+ email: (c == null ? void 0 : c.email) || null
2871
2944
  }
2872
2945
  };
2873
2946
  console.log(JSON.stringify(u, null, 2)), process.exit(0);
2874
2947
  }
2875
- let n = G({
2948
+ let n = V({
2876
2949
  text: "Loading Myop CLI...",
2877
2950
  color: "green"
2878
2951
  }).start();
2879
2952
  const i = $e();
2880
2953
  await Xt(500), n.stop();
2881
- const s = y.program.version();
2954
+ const s = h.program.version();
2882
2955
  await Zt(s) || await ne(i.configFound);
2883
2956
  });
2884
- y.program.parse(process.argv);
2885
- y.program.opts();
2957
+ h.program.parse(process.argv);
2958
+ h.program.opts();