@myop/cli 0.1.14 β†’ 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/myop-cli.js +358 -315
  2. package/package.json +1 -1
package/dist/myop-cli.js CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import F from "ora";
3
- import { select as Oe, Separator as me } from "@inquirer/prompts";
4
- import { Command as Ve, Option as ae } from "commander";
5
- import { execSync as se } from "child_process";
3
+ import { select as Ie, Separator as me } from "@inquirer/prompts";
4
+ import { Command as We, Option as ce } from "commander";
5
+ import { execSync as re } from "child_process";
6
6
  import Z from "path";
7
7
  import A from "fs";
8
8
  import fe from "crypto";
9
- import We from "http";
10
- import { URL as Ie, URLSearchParams as je } from "url";
11
- import Ge from "open";
12
- import Ye from "os";
13
- const Ke = `
9
+ import Ge from "http";
10
+ import { URL as je, URLSearchParams as Pe } from "url";
11
+ import Ye from "open";
12
+ import Ke from "os";
13
+ const Xe = `
14
14
  Usage: myop [OPTIONS] COMMAND [ARGS]...
15
15
 
16
16
  A powerful command-line interface for managing your Myop projects.
@@ -52,7 +52,7 @@ Examples:
52
52
  verbose: !1
53
53
  },
54
54
  myopConfig: null
55
- }, ke = {
55
+ }, _e = {
56
56
  name: "πŸ“₯ Install Myop generated dependencies",
57
57
  value: "myopInstall",
58
58
  description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
@@ -64,7 +64,7 @@ Examples:
64
64
  }
65
65
  process.exit();
66
66
  }
67
- }, Xe = (e) => {
67
+ }, Qe = (e) => {
68
68
  const o = Z.join(d.executionPath, e);
69
69
  console.info(`reading config file from: ${o}`);
70
70
  const n = A.readFileSync(o, "utf8"), a = JSON.parse(n);
@@ -79,7 +79,7 @@ Examples:
79
79
  throw console.info(`error ${a} while writing to ${n}, JSON: ${o}`), console.log(`
80
80
  ⚠️ Failed write config file to ${n}, for more info use verbose flag`), a;
81
81
  }
82
- }, Pe = {
82
+ }, Ee = {
83
83
  name: "🌟 Add flow definition to your project",
84
84
  value: "addFlow",
85
85
  description: "Adds flow to yours myop.config.json",
@@ -88,7 +88,7 @@ Examples:
88
88
  },
89
89
  action: async () => {
90
90
  }
91
- }, _e = {
91
+ }, Ne = {
92
92
  name: "🚫 Remove flow definition from your project",
93
93
  value: "removeFlow",
94
94
  description: "Removes flow to yours myop.config.json",
@@ -97,36 +97,36 @@ Examples:
97
97
  },
98
98
  action: () => {
99
99
  }
100
- }, Qe = {
100
+ }, Ze = {
101
101
  name: "πŸ‘‹ Quit",
102
102
  value: "quit",
103
103
  description: "Quit and continue coding.",
104
104
  action: () => {
105
105
  process.exit();
106
106
  }
107
- }, Ze = {
107
+ }, qe = {
108
108
  name: "🟒 Create new component",
109
109
  value: "-",
110
110
  disabled: "(not available yet)"
111
- }, qe = {
111
+ }, et = {
112
112
  name: "πŸ”΅ Create new experience",
113
113
  value: "-",
114
114
  disabled: "(not available yet)"
115
- }, et = {
115
+ }, tt = {
116
116
  name: "🟑 Create new skin",
117
117
  value: "-",
118
118
  disabled: "(not available yet)"
119
- }, tt = {
119
+ }, ot = {
120
120
  name: "πŸ”΄ Create new flow",
121
121
  value: "-",
122
122
  disabled: "(not available yet)"
123
- }, ot = {
123
+ }, nt = {
124
124
  name: "πŸ†• Define new custom Myop message",
125
125
  value: "generateMyopMessage",
126
126
  description: "️Help you creates the right structure for a new Myop message, including types and handlers.",
127
127
  disabled: "(not available yet)"
128
- }, nt = [ot, Ze, qe, et, tt];
129
- function st(e, o, n, a) {
128
+ }, st = [nt, qe, et, tt, ot];
129
+ function rt(e, o, n, a) {
130
130
  return `<!DOCTYPE html>
131
131
  <html lang="en">
132
132
  <head>
@@ -216,7 +216,7 @@ ${a}
216
216
  </body>
217
217
  </html>`;
218
218
  }
219
- async function Ne() {
219
+ async function ke() {
220
220
  const e = await import("fs"), o = await import("path"), { exec: n } = await import("child_process"), a = await import("http"), { createHash: u } = await import("node:crypto");
221
221
  let c;
222
222
  if (import.meta.url.startsWith("file://")) {
@@ -224,13 +224,13 @@ async function Ne() {
224
224
  c = o.default.dirname(s);
225
225
  } else
226
226
  c = o.default.dirname(import.meta.url);
227
- const m = o.default.join(c, "commands", "dev", "management-website"), S = e.default.readFileSync(o.default.join(m, "styles.css"), "utf-8"), x = e.default.readFileSync(o.default.join(m, "app.js"), "utf-8"), g = 9292, y = 9293, w = "./dist";
228
- let j = !1, $ = !1;
229
- const T = /* @__PURE__ */ new Map(), z = d.program.getOptionValue("config") || "./myop.config.json";
230
- let v, _, h = !1;
227
+ const m = o.default.join(c, "commands", "dev", "management-website"), x = e.default.readFileSync(o.default.join(m, "styles.css"), "utf-8"), b = e.default.readFileSync(o.default.join(m, "app.js"), "utf-8"), f = 9292, y = 9293, w = "./dist";
228
+ let j = !1, S = !1;
229
+ const k = /* @__PURE__ */ new Map(), z = d.program.getOptionValue("config") || "./myop.config.json";
230
+ let v, E, h = !1;
231
231
  try {
232
232
  const s = e.default.readFileSync(z, "utf-8"), t = JSON.parse(s);
233
- v = t.componentId || "DEV", _ = t.componentName || t.name || null, h = t.HMR === !0, h && console.log("πŸ”₯ HMR enabled");
233
+ v = t.componentId || "DEV", E = t.componentName || t.name || null, h = t.HMR === !0, h && console.log("πŸ”₯ HMR enabled");
234
234
  } catch (s) {
235
235
  console.error("❌ Error reading myop.config.json:", s.message), process.exit(1);
236
236
  }
@@ -239,15 +239,15 @@ async function Ne() {
239
239
  return v;
240
240
  try {
241
241
  const t = ((await new Promise((l, p) => {
242
- const f = {
242
+ const g = {
243
243
  hostname: "localhost",
244
244
  port: y,
245
245
  path: "/_list",
246
246
  method: "GET",
247
247
  timeout: 1e3
248
- }, O = a.default.request(f, (k) => {
248
+ }, O = a.default.request(g, (P) => {
249
249
  let H = "";
250
- k.on("data", (J) => H += J), k.on("end", () => {
250
+ P.on("data", (L) => H += L), P.on("end", () => {
251
251
  try {
252
252
  l(JSON.parse(H));
253
253
  } catch {
@@ -263,8 +263,8 @@ async function Ne() {
263
263
  return "DEV1";
264
264
  const r = t.map((l) => {
265
265
  if (l === "DEV" || l === "NEW") return 1;
266
- const p = l.match(/^DEV(\d+)$/), f = l.match(/^NEW(\d+)$/);
267
- return p ? parseInt(p[1], 10) : f ? parseInt(f[1], 10) : 0;
266
+ const p = l.match(/^DEV(\d+)$/), g = l.match(/^NEW(\d+)$/);
267
+ return p ? parseInt(p[1], 10) : g ? parseInt(g[1], 10) : 0;
268
268
  }).filter((l) => l > 0);
269
269
  return `DEV${Math.max(...r, 0) + 1}`;
270
270
  } catch {
@@ -283,7 +283,7 @@ async function Ne() {
283
283
  ".svg": "image/svg+xml",
284
284
  ".ico": "image/x-icon"
285
285
  }[t] || "application/octet-stream";
286
- }, b = /* @__PURE__ */ new Map(), q = [], Fe = 50, D = [], V = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), Ae = (s, t, r) => {
286
+ }, C = /* @__PURE__ */ new Map(), q = [], Ae = 50, D = [], V = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), De = (s, t, r) => {
287
287
  if (s.url.startsWith("/_hmr/")) {
288
288
  const i = s.url.split("/_hmr/")[1], l = s.headers["sec-websocket-key"], p = u("sha1").update(l + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
289
289
  t.write(
@@ -294,30 +294,30 @@ Sec-WebSocket-Accept: ${p}\r
294
294
  \r
295
295
  `
296
296
  ), U.has(i) || U.set(i, /* @__PURE__ */ new Set()), U.get(i).add(t), console.log(`πŸ”Œ HMR client connected: ${i}`), t.on("close", () => {
297
- const f = U.get(i);
298
- f && (f.delete(t), f.size === 0 && U.delete(i)), console.log(`πŸ”Œ HMR client disconnected: ${i}`);
297
+ const g = U.get(i);
298
+ g && (g.delete(t), g.size === 0 && U.delete(i)), console.log(`πŸ”Œ HMR client disconnected: ${i}`);
299
299
  }), t.on("error", () => {
300
- const f = U.get(i);
301
- f && f.delete(t);
300
+ const g = U.get(i);
301
+ g && g.delete(t);
302
302
  });
303
303
  }
304
- }, le = a.default.createServer((s, t) => {
304
+ }, de = a.default.createServer((s, t) => {
305
305
  if (t.setHeader("Content-Type", "application/json"), s.method === "POST" && s.url === "/_register") {
306
306
  let r = "";
307
307
  s.on("data", (i) => r += i), s.on("end", () => {
308
308
  try {
309
309
  const { componentId: i, distPath: l, componentName: p } = JSON.parse(r);
310
- b.set(i, { path: l, name: p || null });
311
- const f = p ? ` (${p})` : "";
312
- console.log(`βœ… Registered: ${i}${f} -> ${l}`), t.writeHead(200), t.end(JSON.stringify({ success: !0, registered: Array.from(b.keys()) }));
313
- const O = Array.from(b.entries()).map(([k, H]) => ({
314
- id: k,
310
+ C.set(i, { path: l, name: p || null });
311
+ const g = p ? ` (${p})` : "";
312
+ console.log(`βœ… Registered: ${i}${g} -> ${l}`), t.writeHead(200), t.end(JSON.stringify({ success: !0, registered: Array.from(C.keys()) }));
313
+ const O = Array.from(C.entries()).map(([P, H]) => ({
314
+ id: P,
315
315
  path: H.path,
316
316
  name: H.name
317
317
  }));
318
- D.forEach((k) => {
318
+ D.forEach((P) => {
319
319
  try {
320
- k.write(`data: ${JSON.stringify({
320
+ P.write(`data: ${JSON.stringify({
321
321
  type: "components",
322
322
  components: O
323
323
  })}
@@ -335,11 +335,11 @@ Sec-WebSocket-Accept: ${p}\r
335
335
  s.on("data", (i) => r += i), s.on("end", () => {
336
336
  try {
337
337
  const { componentId: i } = JSON.parse(r);
338
- b.delete(i), console.log(`❌ Unregistered: ${i}`), t.writeHead(200), t.end(JSON.stringify({ success: !0 }));
339
- const l = Array.from(b.entries()).map(([p, f]) => ({
338
+ C.delete(i), console.log(`❌ Unregistered: ${i}`), t.writeHead(200), t.end(JSON.stringify({ success: !0 }));
339
+ const l = Array.from(C.entries()).map(([p, g]) => ({
340
340
  id: p,
341
- path: f.path,
342
- name: f.name
341
+ path: g.path,
342
+ name: g.name
343
343
  }));
344
344
  D.forEach((p) => {
345
345
  try {
@@ -356,52 +356,52 @@ Sec-WebSocket-Accept: ${p}\r
356
356
  t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
357
357
  }
358
358
  });
359
- } else s.method === "GET" && s.url === "/_list" ? (t.writeHead(200), t.end(JSON.stringify({ components: Array.from(b.entries()) }))) : (t.writeHead(404), t.end(JSON.stringify({ error: "Not found" })));
359
+ } else s.method === "GET" && s.url === "/_list" ? (t.writeHead(200), t.end(JSON.stringify({ components: Array.from(C.entries()) }))) : (t.writeHead(404), t.end(JSON.stringify({ error: "Not found" })));
360
360
  }), ee = a.default.createServer((s, t) => {
361
361
  if (s.url.includes("..")) {
362
362
  t.writeHead(403, { "Content-Type": "text/plain" }), t.end("Forbidden");
363
363
  return;
364
364
  }
365
- const r = new URL(s.url, `http://localhost:${g}`), i = r.pathname, l = i.split("/").filter((P) => P);
365
+ const r = new URL(s.url, `http://localhost:${f}`), i = r.pathname, l = i.split("/").filter((_) => _);
366
366
  if (i.startsWith("/consume")) {
367
- const P = r.searchParams.get("id");
368
- if (!P) {
367
+ const _ = r.searchParams.get("id");
368
+ if (!_) {
369
369
  t.writeHead(400, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
370
370
  return;
371
371
  }
372
- const R = b.get(P), L = R ? R.path : null, Me = (W) => {
373
- let C = "Unknown", E = "Unknown";
372
+ const R = C.get(_), J = R ? R.path : null, Oe = (W) => {
373
+ let $ = "Unknown", T = "Unknown";
374
374
  if (s.headers.referer || s.headers.referrer) {
375
375
  const I = s.headers.referer || s.headers.referrer;
376
376
  try {
377
377
  const G = new URL(I);
378
- C = G.origin, E = G.hostname || G.origin;
378
+ $ = G.origin, T = G.hostname || G.origin;
379
379
  } catch {
380
- C = I, E = I;
380
+ $ = I, T = I;
381
381
  }
382
382
  } else if (s.headers.origin)
383
383
  try {
384
384
  const I = new URL(s.headers.origin);
385
- C = I.origin, E = I.hostname || I.origin;
385
+ $ = I.origin, T = I.hostname || I.origin;
386
386
  } catch {
387
- C = s.headers.origin, E = s.headers.origin;
387
+ $ = s.headers.origin, T = s.headers.origin;
388
388
  }
389
389
  else if (s.socket.remoteAddress) {
390
390
  const I = s.socket.remoteAddress;
391
- I === "::1" || I === "::ffff:127.0.0.1" ? (C = "localhost", E = "localhost (direct)") : (C = I, E = I.replace("::ffff:", ""));
391
+ I === "::1" || I === "::ffff:127.0.0.1" ? ($ = "localhost", T = "localhost (direct)") : ($ = I, T = I.replace("::ffff:", ""));
392
392
  }
393
- const pe = s.headers.referer || s.headers.referrer || C, oe = {
393
+ const pe = s.headers.referer || s.headers.referrer || $, ne = {
394
394
  type: "request",
395
- componentId: P,
395
+ componentId: _,
396
396
  timestamp: Date.now(),
397
397
  servedLocally: W,
398
398
  referrer: pe,
399
- origin: C,
400
- originLabel: E
399
+ origin: $,
400
+ originLabel: T
401
401
  };
402
- V.has(C) || (V.set(C, {
403
- url: C,
404
- label: E,
402
+ V.has($) || (V.set($, {
403
+ url: $,
404
+ label: T,
405
405
  firstSeen: Date.now(),
406
406
  requestCount: 0
407
407
  }), D.forEach((I) => {
@@ -415,8 +415,8 @@ Sec-WebSocket-Accept: ${p}\r
415
415
  } catch {
416
416
  }
417
417
  }));
418
- const ze = V.get(C);
419
- ze.requestCount++, D.forEach((I) => {
418
+ const Ve = V.get($);
419
+ Ve.requestCount++, D.forEach((I) => {
420
420
  try {
421
421
  I.write(`data: ${JSON.stringify({
422
422
  type: "origins",
@@ -426,26 +426,26 @@ Sec-WebSocket-Accept: ${p}\r
426
426
  `);
427
427
  } catch {
428
428
  }
429
- }), q.push(oe), q.length > Fe && q.shift(), D.forEach((I) => {
429
+ }), q.push(ne), q.length > Ae && q.shift(), D.forEach((I) => {
430
430
  try {
431
- I.write(`data: ${JSON.stringify(oe)}
431
+ I.write(`data: ${JSON.stringify(ne)}
432
432
 
433
433
  `);
434
434
  } catch {
435
435
  }
436
436
  });
437
437
  };
438
- if (L) {
439
- const W = o.default.join(L, "index.html");
440
- e.default.readFile(W, "utf-8", (C, E) => {
441
- if (C) {
438
+ if (J) {
439
+ const W = o.default.join(J, "index.html");
440
+ e.default.readFile(W, "utf-8", ($, T) => {
441
+ if ($) {
442
442
  console.log(`❌ File not found: ${W}`), t.writeHead(404, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "index.html not found" }));
443
443
  return;
444
444
  }
445
- const pe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, oe = {
445
+ const pe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ne = {
446
446
  item: {
447
- name: P,
448
- id: P,
447
+ name: _,
448
+ id: _,
449
449
  consume_variant: [
450
450
  {
451
451
  id: pe,
@@ -453,27 +453,27 @@ Sec-WebSocket-Accept: ${p}\r
453
453
  loader: {
454
454
  type: "HTMLLoader",
455
455
  shadowRootMode: "localFrame",
456
- HTML: E
456
+ HTML: T
457
457
  }
458
458
  }
459
459
  ]
460
460
  }
461
461
  };
462
- console.log(`βœ… Serving consume JSON for: ${P}`), Me(!0), t.writeHead(200, {
462
+ console.log(`βœ… Serving consume JSON for: ${_}`), Oe(!0), t.writeHead(200, {
463
463
  "Content-Type": "application/json",
464
464
  "Access-Control-Allow-Origin": "*"
465
- }), t.end(JSON.stringify(oe, null, 2));
465
+ }), t.end(JSON.stringify(ne, null, 2));
466
466
  });
467
467
  } else {
468
- console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${P}`);
468
+ console.log(`πŸ“‘ Proxying consume request to cloud.myop.dev for: ${_}`);
469
469
  const W = `https://cloud.myop.dev/consume${r.search}`;
470
- Me(!1), fetch(W).then((C) => C.text()).then((C) => {
470
+ Oe(!1), fetch(W).then(($) => $.text()).then(($) => {
471
471
  t.writeHead(200, {
472
472
  "Content-Type": "application/json",
473
473
  "Access-Control-Allow-Origin": "*"
474
- }), t.end(C);
475
- }).catch((C) => {
476
- console.error(`❌ Proxy error: ${C.message}`), t.writeHead(502, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
474
+ }), t.end($);
475
+ }).catch(($) => {
476
+ console.error(`❌ Proxy error: ${$.message}`), t.writeHead(502, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
477
477
  });
478
478
  }
479
479
  return;
@@ -485,14 +485,14 @@ Sec-WebSocket-Accept: ${p}\r
485
485
  Connection: "keep-alive",
486
486
  "Access-Control-Allow-Origin": "*"
487
487
  }), D.push(t);
488
- const P = Array.from(b.entries()).map(([R, L]) => ({
488
+ const _ = Array.from(C.entries()).map(([R, J]) => ({
489
489
  id: R,
490
- path: L.path,
491
- name: L.name
490
+ path: J.path,
491
+ name: J.name
492
492
  }));
493
493
  t.write(`data: ${JSON.stringify({
494
494
  type: "components",
495
- components: P
495
+ components: _
496
496
  })}
497
497
 
498
498
  `), t.write(`data: ${JSON.stringify({
@@ -512,7 +512,7 @@ Sec-WebSocket-Accept: ${p}\r
512
512
  return;
513
513
  }
514
514
  if (l.length === 0) {
515
- t.writeHead(200, { "Content-Type": "text/html" }), t.end(st(g, y, S, x));
515
+ t.writeHead(200, { "Content-Type": "text/html" }), t.end(rt(f, y, x, b));
516
516
  return;
517
517
  }
518
518
  if (l[0] !== "view") {
@@ -523,20 +523,20 @@ Sec-WebSocket-Accept: ${p}\r
523
523
  t.writeHead(400, { "Content-Type": "text/plain" }), t.end("Component ID required. Use /view/<componentId>/");
524
524
  return;
525
525
  }
526
- const p = l[1], f = b.get(p);
527
- if (!f) {
526
+ const p = l[1], g = C.get(p);
527
+ if (!g) {
528
528
  t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`Component not found: ${p}`);
529
529
  return;
530
530
  }
531
- const O = f.path, k = l.slice(2), H = k.length === 0 ? "index.html" : k.join("/"), J = o.default.join(O, H);
532
- console.log(`πŸ“₯ Request: ${s.url} -> ${J}`), e.default.readFile(J, (P, R) => {
533
- if (P) {
534
- console.log(`❌ File not found: ${J}`), t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not Found");
531
+ const O = g.path, P = l.slice(2), H = P.length === 0 ? "index.html" : P.join("/"), L = o.default.join(O, H);
532
+ console.log(`πŸ“₯ Request: ${s.url} -> ${L}`), e.default.readFile(L, (_, R) => {
533
+ if (_) {
534
+ console.log(`❌ File not found: ${L}`), t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not Found");
535
535
  return;
536
536
  }
537
- const L = K(J);
538
- console.log(`βœ… Serving: ${J} (${L})`), t.writeHead(200, {
539
- "Content-Type": L,
537
+ const J = K(L);
538
+ console.log(`βœ… Serving: ${L} (${J})`), t.writeHead(200, {
539
+ "Content-Type": J,
540
540
  "Access-Control-Allow-Origin": "*"
541
541
  }), t.end(R);
542
542
  });
@@ -544,7 +544,7 @@ Sec-WebSocket-Accept: ${p}\r
544
544
  const r = JSON.stringify({
545
545
  componentId: v,
546
546
  distPath: o.default.resolve(N, w),
547
- componentName: _
547
+ componentName: E
548
548
  }), i = {
549
549
  hostname: "localhost",
550
550
  port: y,
@@ -555,13 +555,13 @@ Sec-WebSocket-Accept: ${p}\r
555
555
  "Content-Length": Buffer.byteLength(r)
556
556
  }
557
557
  }, l = a.default.request(i, (p) => {
558
- let f = "";
559
- p.on("data", (O) => f += O), p.on("end", () => {
560
- p.statusCode === 200 ? s(JSON.parse(f)) : t(new Error(`Registration failed: ${p.statusCode}`));
558
+ let g = "";
559
+ p.on("data", (O) => g += O), p.on("end", () => {
560
+ p.statusCode === 200 ? s(JSON.parse(g)) : t(new Error(`Registration failed: ${p.statusCode}`));
561
561
  });
562
562
  });
563
563
  l.on("error", t), l.write(r), l.end();
564
- }), De = () => new Promise((s, t) => {
564
+ }), He = () => new Promise((s, t) => {
565
565
  const r = JSON.stringify({ componentId: v }), i = {
566
566
  hostname: "localhost",
567
567
  port: y,
@@ -575,7 +575,7 @@ Sec-WebSocket-Accept: ${p}\r
575
575
  s();
576
576
  });
577
577
  l.on("error", () => s()), l.write(r), l.end();
578
- }), He = () => {
578
+ }), Le = () => {
579
579
  if (!h) return;
580
580
  const s = o.default.join(w, "index.html");
581
581
  try {
@@ -714,7 +714,7 @@ Sec-WebSocket-Accept: ${p}\r
714
714
  // 64-bit length
715
715
  t
716
716
  ]), i;
717
- }, Le = () => {
717
+ }, Ue = () => {
718
718
  if (!h) return;
719
719
  const s = U.get(v);
720
720
  if (!s || s.size === 0)
@@ -724,8 +724,8 @@ Sec-WebSocket-Accept: ${p}\r
724
724
  try {
725
725
  let r = e.default.readFileSync(t, "utf-8");
726
726
  if (r.includes("<!-- MYOP HMR -->")) {
727
- const p = r.indexOf("<!-- MYOP HMR -->"), f = r.indexOf("<\/script>", p) + 9;
728
- r = r.slice(0, p) + r.slice(f);
727
+ const p = r.indexOf("<!-- MYOP HMR -->"), g = r.indexOf("<\/script>", p) + 9;
728
+ r = r.slice(0, p) + r.slice(g);
729
729
  }
730
730
  const i = JSON.stringify({
731
731
  type: "update",
@@ -741,27 +741,40 @@ Sec-WebSocket-Accept: ${p}\r
741
741
  } catch (r) {
742
742
  console.error("❌ Failed to read HTML for HMR:", r.message);
743
743
  }
744
- }, de = () => {
744
+ };
745
+ let xe = !1;
746
+ const te = () => {
745
747
  if (j) {
746
- $ = !0;
748
+ S = !0;
747
749
  return;
748
750
  }
749
751
  j = !0, console.log(`
750
752
  πŸ”¨ Building...`), n("npm run build", (s, t, r) => {
751
- j = !1, s ? (console.error("❌ Build failed:", s.message), r && console.error(r)) : (console.log("βœ… Build completed"), t && console.log(t), He(), Le()), $ && ($ = !1, de());
753
+ if (j = !1, s) {
754
+ const i = s.message + (r || "");
755
+ if (!xe && i.includes("ERR_MODULE_NOT_FOUND") && i.includes("esbuild")) {
756
+ xe = !0, console.log("πŸ“¦ Missing dependencies detected, running npm install..."), n("npm install", (l, p, g) => {
757
+ l ? (console.error("❌ Failed to install dependencies:", l.message), g && console.error(g)) : (console.log("βœ… Dependencies installed"), te());
758
+ });
759
+ return;
760
+ }
761
+ console.error("❌ Build failed:", s.message), r && console.error(r);
762
+ } else
763
+ console.log("βœ… Build completed"), t && console.log(t), Le(), Ue();
764
+ S && (S = !1, te());
752
765
  });
753
- }, Se = /* @__PURE__ */ new Set(), xe = (s) => {
766
+ }, Se = /* @__PURE__ */ new Set(), be = (s) => {
754
767
  e.default.readdir(s, { withFileTypes: !0 }, (t, r) => {
755
768
  t || (r.forEach((i) => {
756
769
  const l = o.default.join(s, i.name);
757
770
  if (i.isDirectory())
758
- i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && xe(l);
771
+ i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && be(l);
759
772
  else if (i.isFile()) {
760
773
  const p = o.default.extname(i.name);
761
774
  if (p === ".js" || p === ".css" || p === ".html")
762
775
  try {
763
- const f = e.default.readFileSync(l, "utf-8");
764
- T.set(l, f);
776
+ const g = e.default.readFileSync(l, "utf-8");
777
+ k.set(l, g);
765
778
  } catch {
766
779
  }
767
780
  }
@@ -769,21 +782,21 @@ Sec-WebSocket-Accept: ${p}\r
769
782
  if (!l) return;
770
783
  const p = o.default.extname(l);
771
784
  if (p !== ".js" && p !== ".css" && p !== ".html") return;
772
- const f = o.default.join(s, l);
785
+ const g = o.default.join(s, l);
773
786
  setTimeout(() => {
774
787
  try {
775
- const O = e.default.readFileSync(f, "utf-8"), k = T.get(f);
776
- O !== k && (T.set(f, O), console.log(`πŸ“ File changed: ${f}`), de());
788
+ const O = e.default.readFileSync(g, "utf-8"), P = k.get(g);
789
+ O !== P && (k.set(g, O), console.log(`πŸ“ File changed: ${g}`), te());
777
790
  } catch {
778
791
  }
779
792
  }, 50);
780
793
  })));
781
794
  });
782
- }, be = () => {
795
+ }, Ce = () => {
783
796
  console.log(`
784
- πŸ”¨ Component: ${v}`), de(), xe(N), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
797
+ πŸ”¨ Component: ${v}`), te(), be(N), console.log("πŸ‘€ Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
785
798
  `);
786
- }, Ue = () => new Promise((s) => {
799
+ }, Be = () => new Promise((s) => {
787
800
  const t = {
788
801
  hostname: "localhost",
789
802
  port: y,
@@ -796,16 +809,16 @@ Sec-WebSocket-Accept: ${p}\r
796
809
  r.on("error", () => s(!1)), r.on("timeout", () => {
797
810
  r.destroy(), s(!1);
798
811
  }), r.end();
799
- }), Be = () => new Promise((s) => {
812
+ }), ze = () => new Promise((s) => {
800
813
  const t = a.default.createServer((r, i) => {
801
814
  if (i.setHeader("Content-Type", "application/json"), r.method === "POST" && r.url === "/_register") {
802
815
  let l = "";
803
816
  r.on("data", (p) => l += p), r.on("end", () => {
804
817
  try {
805
- const { componentId: p, distPath: f, componentName: O } = JSON.parse(l);
806
- b.set(p, { path: f, name: O || null });
807
- const k = O ? ` (${O})` : "";
808
- console.log(`βœ… Registered: ${p}${k} -> ${f}`), i.writeHead(200), i.end(JSON.stringify({ success: !0, registered: Array.from(b.keys()) }));
818
+ const { componentId: p, distPath: g, componentName: O } = JSON.parse(l);
819
+ C.set(p, { path: g, name: O || null });
820
+ const P = O ? ` (${O})` : "";
821
+ console.log(`βœ… Registered: ${p}${P} -> ${g}`), i.writeHead(200), i.end(JSON.stringify({ success: !0, registered: Array.from(C.keys()) }));
809
822
  } catch (p) {
810
823
  i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
811
824
  }
@@ -815,12 +828,12 @@ Sec-WebSocket-Accept: ${p}\r
815
828
  r.on("data", (p) => l += p), r.on("end", () => {
816
829
  try {
817
830
  const { componentId: p } = JSON.parse(l);
818
- b.delete(p), console.log(`❌ Unregistered: ${p}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
831
+ C.delete(p), console.log(`❌ Unregistered: ${p}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
819
832
  } catch (p) {
820
833
  i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
821
834
  }
822
835
  });
823
- } else r.method === "GET" && r.url === "/_list" ? (i.writeHead(200), i.end(JSON.stringify({ components: Array.from(b.entries()) }))) : (i.writeHead(404), i.end(JSON.stringify({ error: "Not found" })));
836
+ } else r.method === "GET" && r.url === "/_list" ? (i.writeHead(200), i.end(JSON.stringify({ components: Array.from(C.entries()) }))) : (i.writeHead(404), i.end(JSON.stringify({ error: "Not found" })));
824
837
  });
825
838
  t.on("error", () => {
826
839
  s(!1);
@@ -828,62 +841,62 @@ Sec-WebSocket-Accept: ${p}\r
828
841
  console.log(`
829
842
  πŸ”„ Taking over as server...`), console.log(`πŸ“‘ Management server on port ${y}`), ee.on("error", () => {
830
843
  t.close(), s(!1);
831
- }), ee.listen(g, () => {
832
- console.log(`πŸ“‘ Main server running at http://localhost:${g}`), b.set(v, {
844
+ }), ee.listen(f, () => {
845
+ console.log(`πŸ“‘ Main server running at http://localhost:${f}`), C.set(v, {
833
846
  path: o.default.resolve(N, w),
834
- name: _
847
+ name: E
835
848
  });
836
- const r = _ ? ` (${_})` : "";
837
- console.log(`βœ… Registered component: ${v}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${g}/view/${v}/`), s(!0);
849
+ const r = E ? ` (${E})` : "";
850
+ console.log(`βœ… Registered component: ${v}${r}`), console.log(`πŸ“‘ Access at: http://localhost:${f}/view/${v}/`), s(!0);
838
851
  });
839
852
  });
840
853
  });
841
- let te;
842
- const Ce = () => {
843
- te = setInterval(async () => {
844
- await Ue() || (clearInterval(te), console.log(`
845
- ⚠️ Server appears to be down, attempting to take over...`), await Be() ? console.log("βœ… Successfully took over as server") : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
854
+ let oe;
855
+ const $e = () => {
856
+ oe = setInterval(async () => {
857
+ await Be() || (clearInterval(oe), console.log(`
858
+ ⚠️ Server appears to be down, attempting to take over...`), await ze() ? console.log("βœ… Successfully took over as server") : (console.log("ℹ️ Another instance took over, re-registering..."), setTimeout(async () => {
846
859
  try {
847
- await ve(), console.log(`βœ… Re-registered component: ${v}`), Ce();
860
+ await ve(), console.log(`βœ… Re-registered component: ${v}`), $e();
848
861
  } catch (r) {
849
862
  console.error("❌ Failed to re-register:", r.message);
850
863
  }
851
864
  }, 2e3)));
852
865
  }, 3e3);
853
- }, $e = async () => {
866
+ }, Me = async () => {
854
867
  console.log(`
855
868
 
856
- πŸ›‘ Shutting down...`), te && clearInterval(te), await De(), process.exit(0);
869
+ πŸ›‘ Shutting down...`), oe && clearInterval(oe), await He(), process.exit(0);
857
870
  };
858
- process.on("SIGINT", $e), process.on("SIGTERM", $e), le.on("error", async (s) => {
871
+ process.on("SIGINT", Me), process.on("SIGTERM", Me), de.on("error", async (s) => {
859
872
  if (s.code === "EADDRINUSE") {
860
873
  console.log(`
861
874
  πŸ”— Connecting to existing dev server...`);
862
875
  try {
863
876
  v = await M();
864
877
  const t = await ve();
865
- console.log(`βœ… Registered component: ${v}`), console.log(`πŸ“‘ Access at: http://localhost:${g}/view/${v}/`), console.log(`πŸ“‹ All registered components: ${t.registered.join(", ")}`), be(), Ce();
878
+ console.log(`βœ… Registered component: ${v}`), console.log(`πŸ“‘ Access at: http://localhost:${f}/view/${v}/`), console.log(`πŸ“‹ All registered components: ${t.registered.join(", ")}`), Ce(), $e();
866
879
  } catch (t) {
867
880
  console.error("❌ Failed to register component:", t.message), process.exit(1);
868
881
  }
869
882
  } else
870
883
  console.error("❌ Management server error:", s.message), process.exit(1);
871
- }), le.on("upgrade", Ae), le.listen(y, async () => {
884
+ }), de.on("upgrade", De), de.listen(y, async () => {
872
885
  console.log(`
873
886
  πŸš€ Starting shared dev server...`), console.log(`πŸ“‘ Management server on port ${y}`), ee.on("error", (s) => {
874
887
  console.error("❌ Main server error:", s.message), process.exit(1);
875
- }), ee.listen(g, async () => {
876
- console.log(`πŸ“‘ Main server running at http://localhost:${g}`), (v === "DEV" || v === "NEW") && (v = "DEV1"), b.set(v, {
888
+ }), ee.listen(f, async () => {
889
+ console.log(`πŸ“‘ Main server running at http://localhost:${f}`), (v === "DEV" || v === "NEW") && (v = "DEV1"), C.set(v, {
877
890
  path: o.default.resolve(N, w),
878
- name: _
891
+ name: E
879
892
  });
880
- const s = _ ? ` (${_})` : "";
881
- console.log(`βœ… Registered component: ${v}${s}`), console.log(`πŸ“‘ Access at: http://localhost:${g}/view/${v}/`), be();
893
+ const s = E ? ` (${E})` : "";
894
+ console.log(`βœ… Registered component: ${v}${s}`), console.log(`πŸ“‘ Access at: http://localhost:${f}/view/${v}/`), Ce();
882
895
  });
883
896
  });
884
897
  }
885
- const ue = Z.join(Ye.homedir(), ".myop"), Q = Z.join(ue, "credentials.json");
886
- function rt() {
898
+ const ue = Z.join(Ke.homedir(), ".myop"), Q = Z.join(ue, "credentials.json");
899
+ function it() {
887
900
  A.existsSync(ue) || A.mkdirSync(ue, { recursive: !0, mode: 448 });
888
901
  }
889
902
  function he() {
@@ -897,7 +910,7 @@ function he() {
897
910
  }
898
911
  }
899
912
  function Te(e) {
900
- rt();
913
+ it();
901
914
  const o = {
902
915
  ...e,
903
916
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -907,14 +920,14 @@ function Te(e) {
907
920
  // Read/write for owner only
908
921
  });
909
922
  }
910
- function Ee() {
923
+ function Re() {
911
924
  try {
912
925
  return A.existsSync(Q) && A.unlinkSync(Q), !0;
913
926
  } catch (e) {
914
927
  return console.error("Failed to clear credentials:", e.message), !1;
915
928
  }
916
929
  }
917
- function it(e) {
930
+ function at(e) {
918
931
  if (!e || !e.expiresAt)
919
932
  return !0;
920
933
  const o = 5 * 60 * 1e3, n = new Date(e.expiresAt).getTime();
@@ -927,19 +940,19 @@ function ye() {
927
940
  userId: e.userId
928
941
  } : null;
929
942
  }
930
- const Y = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", re = 19284, we = `http://localhost:${re}/callback`, at = "myop-cli";
931
- function ct() {
943
+ const Y = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", ie = 19284, we = `http://localhost:${ie}/callback`, ct = "myop-cli";
944
+ function lt() {
932
945
  return fe.randomBytes(32).toString("base64url");
933
946
  }
934
- function lt(e) {
947
+ function dt(e) {
935
948
  return fe.createHash("sha256").update(e).digest("base64url");
936
949
  }
937
- async function dt() {
950
+ async function pt() {
938
951
  const e = await fetch(`${Y}/oauth/register`, {
939
952
  method: "POST",
940
953
  headers: { "Content-Type": "application/json" },
941
954
  body: JSON.stringify({
942
- client_name: at,
955
+ client_name: ct,
943
956
  redirect_uris: [we],
944
957
  grant_types: ["authorization_code", "refresh_token"],
945
958
  response_types: ["code"]
@@ -951,7 +964,7 @@ async function dt() {
951
964
  }
952
965
  return e.json();
953
966
  }
954
- function ne(e, o, n, a = null) {
967
+ function se(e, o, n, a = null) {
955
968
  const u = {
956
969
  success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
957
970
  <circle cx="12" cy="12" r="10"/>
@@ -969,7 +982,7 @@ function ne(e, o, n, a = null) {
969
982
  success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
970
983
  error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
971
984
  warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
972
- }, { accent: m, glow: S } = c[e] || c.error;
985
+ }, { accent: m, glow: x } = c[e] || c.error;
973
986
  return `<!DOCTYPE html>
974
987
  <html lang="en">
975
988
  <head>
@@ -1062,7 +1075,7 @@ function ne(e, o, n, a = null) {
1062
1075
  display: inline-flex;
1063
1076
  align-items: center;
1064
1077
  gap: 8px;
1065
- background: ${S};
1078
+ background: ${x};
1066
1079
  border: 1px solid ${m}33;
1067
1080
  border-radius: 4px;
1068
1081
  padding: 10px 16px;
@@ -1117,23 +1130,23 @@ function ne(e, o, n, a = null) {
1117
1130
  </body>
1118
1131
  </html>`;
1119
1132
  }
1120
- function pt(e) {
1133
+ function mt(e) {
1121
1134
  return new Promise((o, n) => {
1122
- const a = We.createServer((u, c) => {
1123
- const m = new Ie(u.url, `http://localhost:${re}`);
1135
+ const a = Ge.createServer((u, c) => {
1136
+ const m = new je(u.url, `http://localhost:${ie}`);
1124
1137
  if (m.pathname === "/callback") {
1125
- const S = m.searchParams.get("code"), x = m.searchParams.get("state"), g = m.searchParams.get("error");
1126
- if (g) {
1127
- c.writeHead(200, { "Content-Type": "text/html" }), c.end(ne(
1138
+ const x = m.searchParams.get("code"), b = m.searchParams.get("state"), f = m.searchParams.get("error");
1139
+ if (f) {
1140
+ c.writeHead(200, { "Content-Type": "text/html" }), c.end(se(
1128
1141
  "error",
1129
1142
  "Authentication Failed",
1130
1143
  "Unable to complete the authentication process.",
1131
- g
1132
- )), a.close(), n(new Error(`OAuth error: ${g}`));
1144
+ f
1145
+ )), a.close(), n(new Error(`OAuth error: ${f}`));
1133
1146
  return;
1134
1147
  }
1135
- if (x !== e) {
1136
- c.writeHead(400, { "Content-Type": "text/html" }), c.end(ne(
1148
+ if (b !== e) {
1149
+ c.writeHead(400, { "Content-Type": "text/html" }), c.end(se(
1137
1150
  "warning",
1138
1151
  "Security Error",
1139
1152
  "State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
@@ -1141,8 +1154,8 @@ function pt(e) {
1141
1154
  )), a.close(), n(new Error("State mismatch"));
1142
1155
  return;
1143
1156
  }
1144
- if (!S) {
1145
- c.writeHead(400, { "Content-Type": "text/html" }), c.end(ne(
1157
+ if (!x) {
1158
+ c.writeHead(400, { "Content-Type": "text/html" }), c.end(se(
1146
1159
  "error",
1147
1160
  "Missing Authorization Code",
1148
1161
  "No authorization code was received from the server.",
@@ -1150,26 +1163,26 @@ function pt(e) {
1150
1163
  )), a.close(), n(new Error("No authorization code"));
1151
1164
  return;
1152
1165
  }
1153
- c.writeHead(200, { "Content-Type": "text/html" }), c.end(ne(
1166
+ c.writeHead(200, { "Content-Type": "text/html" }), c.end(se(
1154
1167
  "success",
1155
1168
  "Authentication Successful",
1156
1169
  "You have been authenticated successfully. Return to the terminal to continue."
1157
- )), a.close(), o(S);
1170
+ )), a.close(), o(x);
1158
1171
  } else
1159
1172
  c.writeHead(404), c.end("Not found");
1160
1173
  });
1161
- a.listen(re, () => {
1162
- console.info(`OAuth callback server listening on port ${re}`);
1174
+ a.listen(ie, () => {
1175
+ console.info(`OAuth callback server listening on port ${ie}`);
1163
1176
  }), setTimeout(() => {
1164
1177
  a.close(), n(new Error("Authentication timed out"));
1165
1178
  }, 5 * 60 * 1e3);
1166
1179
  });
1167
1180
  }
1168
- async function mt(e, o, n) {
1181
+ async function ut(e, o, n) {
1169
1182
  const a = await fetch(`${Y}/oauth/token`, {
1170
1183
  method: "POST",
1171
1184
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1172
- body: new je({
1185
+ body: new Pe({
1173
1186
  grant_type: "authorization_code",
1174
1187
  code: e,
1175
1188
  client_id: o,
@@ -1183,11 +1196,11 @@ async function mt(e, o, n) {
1183
1196
  }
1184
1197
  return a.json();
1185
1198
  }
1186
- async function ut(e, o) {
1199
+ async function ft(e, o) {
1187
1200
  const n = await fetch(`${Y}/oauth/token`, {
1188
1201
  method: "POST",
1189
1202
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
1190
- body: new je({
1203
+ body: new Pe({
1191
1204
  grant_type: "refresh_token",
1192
1205
  refresh_token: e,
1193
1206
  client_id: o
@@ -1199,7 +1212,7 @@ async function ut(e, o) {
1199
1212
  }
1200
1213
  return n.json();
1201
1214
  }
1202
- async function ft(e) {
1215
+ async function gt(e) {
1203
1216
  var u, c, m;
1204
1217
  const o = await fetch(`${Y}/mcp`, {
1205
1218
  method: "POST",
@@ -1231,20 +1244,20 @@ async function X() {
1231
1244
  const e = F("Starting authentication...").start();
1232
1245
  try {
1233
1246
  e.text = "Registering OAuth client...";
1234
- const n = (await dt()).client_id, a = ct(), u = lt(a), c = fe.randomBytes(16).toString("hex");
1247
+ const n = (await pt()).client_id, a = lt(), u = dt(a), c = fe.randomBytes(16).toString("hex");
1235
1248
  e.text = "Waiting for authorization...";
1236
- const m = pt(c), S = new Ie(`${Y}/oauth/authorize`);
1237
- S.searchParams.set("response_type", "code"), S.searchParams.set("client_id", n), S.searchParams.set("redirect_uri", we), S.searchParams.set("code_challenge", u), S.searchParams.set("code_challenge_method", "S256"), S.searchParams.set("state", c), e.stop(), console.log(`
1238
- 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${S.toString()}
1239
- `), await Ge(S.toString());
1240
- const x = await m;
1249
+ const m = mt(c), x = new je(`${Y}/oauth/authorize`);
1250
+ x.searchParams.set("response_type", "code"), x.searchParams.set("client_id", n), x.searchParams.set("redirect_uri", we), x.searchParams.set("code_challenge", u), x.searchParams.set("code_challenge_method", "S256"), x.searchParams.set("state", c), e.stop(), console.log(`
1251
+ 🌐 Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${x.toString()}
1252
+ `), await Ye(x.toString());
1253
+ const b = await m;
1241
1254
  e.start("Exchanging authorization code...");
1242
- const g = await mt(x, n, a);
1255
+ const f = await ut(b, n, a);
1243
1256
  e.text = "Getting user info...";
1244
- const y = await ft(g.access_token), w = {
1245
- accessToken: g.access_token,
1246
- refreshToken: g.refresh_token,
1247
- expiresAt: new Date(Date.now() + g.expires_in * 1e3).toISOString(),
1257
+ const y = await gt(f.access_token), w = {
1258
+ accessToken: f.access_token,
1259
+ refreshToken: f.refresh_token,
1260
+ expiresAt: new Date(Date.now() + f.expires_in * 1e3).toISOString(),
1248
1261
  clientId: n,
1249
1262
  userId: y.userId,
1250
1263
  userEmail: y.email
@@ -1254,25 +1267,25 @@ async function X() {
1254
1267
  throw e.fail(`Authentication failed: ${o.message}`), o;
1255
1268
  }
1256
1269
  }
1257
- async function Re() {
1270
+ async function Fe() {
1258
1271
  const e = he();
1259
1272
  if (!e) {
1260
1273
  console.log("Not currently logged in.");
1261
1274
  return;
1262
1275
  }
1263
- Ee(), console.log(`βœ… Logged out (was: ${e.userEmail})`);
1276
+ Re(), console.log(`βœ… Logged out (was: ${e.userEmail})`);
1264
1277
  }
1265
- async function gt() {
1278
+ async function ht() {
1266
1279
  let e = he();
1267
1280
  if (!e)
1268
1281
  return console.log(`Not logged in. Starting authentication...
1269
1282
  `), await X();
1270
- if (!it(e))
1283
+ if (!at(e))
1271
1284
  return e;
1272
1285
  if (e.refreshToken) {
1273
1286
  const o = F("Refreshing access token...").start();
1274
1287
  try {
1275
- const n = await ut(
1288
+ const n = await ft(
1276
1289
  e.refreshToken,
1277
1290
  e.clientId
1278
1291
  );
@@ -1283,25 +1296,25 @@ async function gt() {
1283
1296
  expiresAt: new Date(Date.now() + n.expires_in * 1e3).toISOString()
1284
1297
  }, Te(e), o.succeed("Token refreshed"), e;
1285
1298
  } catch {
1286
- return o.warn("Token refresh failed, please log in again"), Ee(), await X();
1299
+ return o.warn("Token refresh failed, please log in again"), Re(), await X();
1287
1300
  }
1288
1301
  }
1289
1302
  return console.log(`Session expired. Please log in again.
1290
1303
  `), await X();
1291
1304
  }
1292
- function ht() {
1305
+ function yt() {
1293
1306
  return Y;
1294
1307
  }
1295
- const ie = "@myop/cli";
1296
- async function yt() {
1308
+ const ae = "@myop/cli";
1309
+ async function wt() {
1297
1310
  try {
1298
- const e = await fetch(`https://registry.npmjs.org/${ie}/latest`);
1311
+ const e = await fetch(`https://registry.npmjs.org/${ae}/latest`);
1299
1312
  return e.ok ? (await e.json()).version : null;
1300
1313
  } catch {
1301
1314
  return null;
1302
1315
  }
1303
1316
  }
1304
- function wt(e, o) {
1317
+ function vt(e, o) {
1305
1318
  const n = e.split(".").map(Number), a = o.split(".").map(Number);
1306
1319
  for (let u = 0; u < Math.max(n.length, a.length); u++) {
1307
1320
  const c = n[u] || 0, m = a[u] || 0;
@@ -1310,33 +1323,43 @@ function wt(e, o) {
1310
1323
  }
1311
1324
  return 0;
1312
1325
  }
1313
- async function vt(e) {
1326
+ async function xt(e) {
1314
1327
  const o = F({
1315
1328
  text: "Checking for updates...",
1316
1329
  color: "cyan"
1317
- }).start(), n = await yt();
1318
- if (o.stop(), !n || wt(n, e) <= 0)
1330
+ }).start(), n = await wt();
1331
+ if (o.stop(), !n || vt(n, e) <= 0)
1319
1332
  return !1;
1320
- if (console.log(`
1333
+ console.log(`
1321
1334
  πŸ“¦ New version available: ${e} β†’ ${n}
1322
- `), await Oe({
1323
- message: "Would you like to update now?",
1324
- choices: [
1325
- { name: "Yes, update now", value: !0 },
1326
- { name: "No, continue with current version", value: !1 }
1327
- ]
1328
- })) {
1335
+ `);
1336
+ let a;
1337
+ try {
1338
+ a = await Ie({
1339
+ message: "Would you like to update now?",
1340
+ choices: [
1341
+ { name: "Yes, update now", value: !0 },
1342
+ { name: "No, continue with current version", value: !1 }
1343
+ ]
1344
+ });
1345
+ } catch (u) {
1346
+ throw u.name === "ExitPromptError" && (console.log(`
1347
+
1348
+ πŸ‘‹ Goodbye!
1349
+ `), process.exit(0)), u;
1350
+ }
1351
+ if (a) {
1329
1352
  const u = F({
1330
- text: `Updating ${ie} to v${n}...`,
1353
+ text: `Updating ${ae} to v${n}...`,
1331
1354
  color: "green"
1332
1355
  }).start();
1333
1356
  try {
1334
- se(`npm install -g ${ie}@latest`, { stdio: "pipe" }), u.succeed(`Updated to v${n}`), console.log(`
1357
+ re(`npm install -g ${ae}@latest`, { stdio: "pipe" }), u.succeed(`Updated to v${n}`), console.log(`
1335
1358
  Please restart the CLI to use the new version.
1336
1359
  `), process.exit(0);
1337
1360
  } catch {
1338
1361
  return u.fail("Update failed"), console.log(`
1339
- You can manually update by running: npm install -g ${ie}@latest
1362
+ You can manually update by running: npm install -g ${ae}@latest
1340
1363
  `), !1;
1341
1364
  }
1342
1365
  }
@@ -1344,7 +1367,7 @@ You can manually update by running: npm install -g ${ie}@latest
1344
1367
  }
1345
1368
  const St = (e) => new Promise((o) => setTimeout(o, e));
1346
1369
  d.executionPath = process.cwd();
1347
- const ce = (e = !1) => {
1370
+ const le = (e = !1) => {
1348
1371
  const o = d.program.getOptionValue("verbose");
1349
1372
  o || (console.info = () => {
1350
1373
  }), console.info("πŸ“ verbose mode on"), d.options = {
@@ -1352,7 +1375,7 @@ const ce = (e = !1) => {
1352
1375
  verbose: o
1353
1376
  };
1354
1377
  try {
1355
- return d.myopConfig = Xe(d.options.configPath), { configFound: !0 };
1378
+ return d.myopConfig = Qe(d.options.configPath), { configFound: !0 };
1356
1379
  } catch (n) {
1357
1380
  if (e) {
1358
1381
  console.info(`
@@ -1372,23 +1395,23 @@ const ce = (e = !1) => {
1372
1395
  };
1373
1396
  [
1374
1397
  new me(),
1375
- ...nt
1398
+ ...st
1376
1399
  ];
1377
- const xt = "0.1.14";
1378
- d.program = new Ve();
1379
- d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(xt);
1380
- d.program.addOption(new ae("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1381
- d.program.addOption(new ae("-h, --help", "Show helpful information"));
1382
- d.program.addOption(new ae("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1383
- d.program.addOption(new ae("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1400
+ const bt = "0.1.16";
1401
+ d.program = new We();
1402
+ d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(bt);
1403
+ d.program.addOption(new ce("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
1404
+ d.program.addOption(new ce("-h, --help", "Show helpful information"));
1405
+ d.program.addOption(new ce("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
1406
+ d.program.addOption(new ce("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
1384
1407
  d.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((e, o) => {
1385
- ce(!0), console.info("adding ", e, o, d.options.configPath), e === "flow" && Pe._action(o), process.exit();
1408
+ le(!0), console.info("adding ", e, o, d.options.configPath), e === "flow" && Ee._action(o), process.exit();
1386
1409
  });
1387
1410
  d.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((e, o) => {
1388
- ce(), console.info("removing ", e, o, d.options.configPath), e === "flow" && _e._action(o), process.exit();
1411
+ le(), console.info("removing ", e, o, d.options.configPath), e === "flow" && Ne._action(o), process.exit();
1389
1412
  });
1390
1413
  d.program.command("install").description("Install Myop assets").action(async () => {
1391
- ce(), await ke.action();
1414
+ le(), await _e.action();
1392
1415
  });
1393
1416
  d.program.command("login").description("Authenticate with Myop platform").action(async () => {
1394
1417
  try {
@@ -1399,14 +1422,14 @@ d.program.command("login").description("Authenticate with Myop platform").action
1399
1422
  process.exit(0);
1400
1423
  });
1401
1424
  d.program.command("logout").description("Clear stored credentials").action(async () => {
1402
- await Re(), process.exit(0);
1425
+ await Fe(), process.exit(0);
1403
1426
  });
1404
1427
  d.program.command("whoami").description("Show current authenticated user").action(async () => {
1405
1428
  const e = ye();
1406
1429
  e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
1407
1430
  });
1408
1431
  d.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (e) => {
1409
- var j, $, T, z, v, _;
1432
+ var j, S, k, z, v, E;
1410
1433
  const o = d.program.getOptionValue("config") || "./myop.config.json", n = await import("fs"), { execSync: a } = await import("child_process"), u = await import("path");
1411
1434
  let c = {};
1412
1435
  if (n.existsSync(o))
@@ -1430,20 +1453,20 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1430
1453
  }
1431
1454
  const m = "./dist/index.html";
1432
1455
  n.existsSync(m) || (console.error("❌ Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
1433
- let S;
1456
+ let x;
1434
1457
  try {
1435
- S = await gt();
1458
+ x = await ht();
1436
1459
  } catch (h) {
1437
1460
  console.error("❌ Authentication failed:", h.message), process.exit(1);
1438
1461
  }
1439
- const x = ht();
1440
- let g = F("Requesting upload URL...").start(), y;
1462
+ const b = yt();
1463
+ let f = F("Requesting upload URL...").start(), y;
1441
1464
  try {
1442
- const h = await fetch(`${x}/mcp`, {
1465
+ const h = await fetch(`${b}/mcp`, {
1443
1466
  method: "POST",
1444
1467
  headers: {
1445
1468
  "Content-Type": "application/json",
1446
- Authorization: `Bearer ${S.accessToken}`
1469
+ Authorization: `Bearer ${x.accessToken}`
1447
1470
  },
1448
1471
  body: JSON.stringify({
1449
1472
  jsonrpc: "2.0",
@@ -1464,14 +1487,14 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1464
1487
  const M = await h.json();
1465
1488
  if (M.error)
1466
1489
  throw new Error(M.error.message);
1467
- const N = (T = ($ = (j = M.result) == null ? void 0 : j.content) == null ? void 0 : $[0]) == null ? void 0 : T.text;
1490
+ const N = (k = (S = (j = M.result) == null ? void 0 : j.content) == null ? void 0 : S[0]) == null ? void 0 : k.text;
1468
1491
  if (y = JSON.parse(N), !y.success)
1469
1492
  throw new Error(y.error);
1470
- g.succeed("Upload URL obtained");
1493
+ f.succeed("Upload URL obtained");
1471
1494
  } catch (h) {
1472
- g.fail("Failed to get upload URL"), console.error(" ", h.message), process.exit(1);
1495
+ f.fail("Failed to get upload URL"), console.error(" ", h.message), process.exit(1);
1473
1496
  }
1474
- g = F("Uploading component...").start();
1497
+ f = F("Uploading component...").start();
1475
1498
  try {
1476
1499
  const h = n.readFileSync(m, "utf-8");
1477
1500
  let M;
@@ -1479,9 +1502,9 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1479
1502
  if (N)
1480
1503
  M = N[1];
1481
1504
  else {
1482
- const b = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1483
- if (b)
1484
- M = b[1];
1505
+ const C = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
1506
+ if (C)
1507
+ M = C[1];
1485
1508
  else
1486
1509
  throw new Error("Could not parse presigned URL from: " + y.curlCommand);
1487
1510
  }
@@ -1494,21 +1517,21 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1494
1517
  body: h
1495
1518
  });
1496
1519
  if (!K.ok) {
1497
- const b = await K.text();
1498
- throw new Error(`Upload failed with status ${K.status}: ${b}`);
1520
+ const C = await K.text();
1521
+ throw new Error(`Upload failed with status ${K.status}: ${C}`);
1499
1522
  }
1500
- g.succeed("Component uploaded");
1523
+ f.succeed("Component uploaded");
1501
1524
  } catch (h) {
1502
- g.fail("Upload failed"), console.error(" ", h.message), h.cause && console.error(" Cause:", h.cause), process.exit(1);
1525
+ f.fail("Upload failed"), console.error(" ", h.message), h.cause && console.error(" Cause:", h.cause), process.exit(1);
1503
1526
  }
1504
- g = F("Confirming upload...").start();
1527
+ f = F("Confirming upload...").start();
1505
1528
  let w;
1506
1529
  try {
1507
- const h = await fetch(`${x}/mcp`, {
1530
+ const h = await fetch(`${b}/mcp`, {
1508
1531
  method: "POST",
1509
1532
  headers: {
1510
1533
  "Content-Type": "application/json",
1511
- Authorization: `Bearer ${S.accessToken}`
1534
+ Authorization: `Bearer ${x.accessToken}`
1512
1535
  },
1513
1536
  body: JSON.stringify({
1514
1537
  jsonrpc: "2.0",
@@ -1527,12 +1550,12 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1527
1550
  const M = await h.json();
1528
1551
  if (M.error)
1529
1552
  throw new Error(M.error.message);
1530
- const N = (_ = (v = (z = M.result) == null ? void 0 : z.content) == null ? void 0 : v[0]) == null ? void 0 : _.text;
1553
+ const N = (E = (v = (z = M.result) == null ? void 0 : z.content) == null ? void 0 : v[0]) == null ? void 0 : E.text;
1531
1554
  if (w = JSON.parse(N), !w.success)
1532
1555
  throw new Error(w.error);
1533
- g.succeed("Upload confirmed");
1556
+ f.succeed("Upload confirmed");
1534
1557
  } catch (h) {
1535
- g.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
1558
+ f.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
1536
1559
  }
1537
1560
  if (w.isNewComponent || !c.componentId) {
1538
1561
  c.componentId = w.componentId, c.organization = w.orgId, c.name || (c.name = w.componentName);
@@ -1547,20 +1570,20 @@ d.program.command("sync").description("Build and upload component to Myop platfo
1547
1570
  console.log(`
1548
1571
  βœ… Sync completed successfully!`), console.log(` Component: ${w.componentName}`), console.log(` Dashboard: ${w.dashboardUrl}`), process.exit(0);
1549
1572
  });
1550
- d.program.command("dev").description("Start development server with file watching").action(Ne);
1551
- const bt = () => {
1573
+ d.program.command("dev").description("Start development server with file watching").action(ke);
1574
+ const Ct = () => {
1552
1575
  try {
1553
- se("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1576
+ re("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1554
1577
  } catch {
1555
1578
  return { gitNotInstalled: !0 };
1556
1579
  }
1557
1580
  try {
1558
- se("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1581
+ re("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
1559
1582
  } catch {
1560
1583
  return { notARepo: !0 };
1561
1584
  }
1562
1585
  try {
1563
- const e = se("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
1586
+ const e = re("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
1564
1587
  encoding: "utf-8",
1565
1588
  stdio: ["pipe", "pipe", "pipe"]
1566
1589
  }).trim();
@@ -1582,11 +1605,11 @@ const bt = () => {
1582
1605
  }
1583
1606
  }, B = async (e = !1, o = !1) => {
1584
1607
  var y, w, j;
1585
- const n = ye(), a = !!(n != null && n.email), u = ((y = d.myopConfig) == null ? void 0 : y.name) || ((w = d.myopConfig) == null ? void 0 : w.componentName), c = (j = d.myopConfig) == null ? void 0 : j.componentId, m = bt();
1608
+ const n = ye(), a = !!(n != null && n.email), u = ((y = d.myopConfig) == null ? void 0 : y.name) || ((w = d.myopConfig) == null ? void 0 : w.componentName), c = (j = d.myopConfig) == null ? void 0 : j.componentId, m = Ct();
1586
1609
  console.log(`
1587
1610
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`), console.log("β”‚ β”‚"), console.log("β”‚ Welcome to Myop CLI - Remote UI Made Easy β”‚"), console.log("β”‚ β”‚"), console.log(`β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1588
1611
  `), e && u ? (console.log(` Component: ${u}`), c ? (console.log(` ID: ${c}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${c}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${a ? n.email : "Not logged in"}`), m != null && m.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")) : m != null && m.notARepo ? console.log(" Changes: Not a git repository") : m && (m.insertions > 0 || m.deletions > 0) ? console.log(` Changes: ${m.files} file${m.files !== 1 ? "s" : ""} | \x1B[32m+${m.insertions}\x1B[0m \x1B[31m-${m.deletions}\x1B[0m`) : m && console.log(" Changes: No uncommitted changes"), console.log("");
1589
- const x = [
1612
+ const b = [
1590
1613
  {
1591
1614
  emoji: "πŸš€",
1592
1615
  label: "Initialize new component",
@@ -1608,13 +1631,13 @@ const bt = () => {
1608
1631
  help: "Starts dev server with HMR for instant preview of changes",
1609
1632
  disabled: e ? !1 : "(no config file)"
1610
1633
  }
1611
- ].map(($) => ({
1612
- name: o && !$.disabled ? `${$.emoji} ${$.label}
1613
- ${$.help}` : `${$.emoji} ${$.label}`,
1614
- value: $.value,
1615
- disabled: $.disabled
1634
+ ].map((S) => ({
1635
+ name: o && !S.disabled ? `${S.emoji} ${S.label}
1636
+ ${S.help}` : `${S.emoji} ${S.label}`,
1637
+ value: S.value,
1638
+ disabled: S.disabled
1616
1639
  }));
1617
- switch (x.push(
1640
+ b.push(
1618
1641
  new me(),
1619
1642
  {
1620
1643
  name: o && a ? `πŸ”“ Logout (${n.email})
@@ -1631,37 +1654,47 @@ const bt = () => {
1631
1654
  name: "πŸ‘‹ Exit",
1632
1655
  value: "exit"
1633
1656
  }
1634
- ), await Oe({
1635
- message: "What would you like to do?",
1636
- choices: x
1637
- })) {
1657
+ );
1658
+ let f;
1659
+ try {
1660
+ f = await Ie({
1661
+ message: "What would you like to do?",
1662
+ choices: b
1663
+ });
1664
+ } catch (S) {
1665
+ throw S.name === "ExitPromptError" && (console.log(`
1666
+
1667
+ πŸ‘‹ Goodbye!
1668
+ `), process.exit(0)), S;
1669
+ }
1670
+ switch (f) {
1638
1671
  case "init":
1639
- await Ct();
1672
+ await $t();
1640
1673
  break;
1641
1674
  case "sync":
1642
1675
  console.log(`
1643
1676
  Running sync...
1644
1677
  `);
1645
- const { execSync: $ } = await import("child_process");
1678
+ const { execSync: S } = await import("child_process");
1646
1679
  try {
1647
- $("node " + process.argv[1] + " sync", { stdio: "inherit" });
1680
+ S("node " + process.argv[1] + " sync", { stdio: "inherit" });
1648
1681
  } catch {
1649
1682
  }
1650
1683
  await B(!0, o);
1651
1684
  break;
1652
1685
  case "dev":
1653
- await Ne();
1686
+ await ke();
1654
1687
  break;
1655
1688
  case "login":
1656
1689
  try {
1657
1690
  await X(), console.log(`
1658
1691
  `), await B(e, o);
1659
- } catch (T) {
1660
- console.error("Login failed:", T.message), await B(e, o);
1692
+ } catch (k) {
1693
+ console.error("Login failed:", k.message), await B(e, o);
1661
1694
  }
1662
1695
  break;
1663
1696
  case "logout":
1664
- await Re(), console.log(`
1697
+ await Fe(), console.log(`
1665
1698
  `), await B(e, o);
1666
1699
  break;
1667
1700
  case "help":
@@ -1670,27 +1703,37 @@ Running sync...
1670
1703
  case "exit":
1671
1704
  process.exit(0);
1672
1705
  }
1673
- }, Ct = async () => {
1674
- const { input: e, select: o } = await import("@inquirer/prompts"), n = await import("fs"), u = (await import("path")).default.basename(process.cwd()), c = await e({
1675
- message: "Component name:",
1676
- default: u
1677
- }), m = await o({
1678
- message: "Component type:",
1679
- choices: [
1680
- { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
1681
- { name: "βš›οΈ React", value: "react", disabled: "(coming soon)" },
1682
- { name: "πŸ’š Vue", value: "vue", disabled: "(coming soon)" },
1683
- { name: "πŸ…°οΈ Angular", value: "angular", disabled: "(coming soon)" }
1684
- ]
1685
- }), S = {
1706
+ }, $t = async () => {
1707
+ const { input: e, select: o } = await import("@inquirer/prompts"), n = await import("fs"), u = (await import("path")).default.basename(process.cwd());
1708
+ let c, m;
1709
+ try {
1710
+ c = await e({
1711
+ message: "Component name:",
1712
+ default: u
1713
+ }), m = await o({
1714
+ message: "Component type:",
1715
+ choices: [
1716
+ { name: "πŸ“„ HTML", value: "html", description: "Plain HTML/JS/CSS component" },
1717
+ { name: "βš›οΈ React", value: "react", disabled: "(coming soon)" },
1718
+ { name: "πŸ’š Vue", value: "vue", disabled: "(coming soon)" },
1719
+ { name: "πŸ…°οΈ Angular", value: "angular", disabled: "(coming soon)" }
1720
+ ]
1721
+ });
1722
+ } catch (f) {
1723
+ throw f.name === "ExitPromptError" && (console.log(`
1724
+
1725
+ πŸ‘‹ Goodbye!
1726
+ `), process.exit(0)), f;
1727
+ }
1728
+ const x = {
1686
1729
  name: c,
1687
1730
  type: m,
1688
1731
  author: "@myop-cli"
1689
- }, x = d.program.getOptionValue("config") || "./myop.config.json";
1732
+ }, b = d.program.getOptionValue("config") || "./myop.config.json";
1690
1733
  try {
1691
- n.writeFileSync(x, JSON.stringify(S, null, 2)), console.log(`
1692
- βœ… Created ${x}`);
1693
- const g = {
1734
+ n.writeFileSync(b, JSON.stringify(x, null, 2)), console.log(`
1735
+ βœ… Created ${b}`);
1736
+ const f = {
1694
1737
  name: c.toLowerCase().replace(/\s+/g, "-"),
1695
1738
  version: "1.0.0",
1696
1739
  type: "module",
@@ -1702,7 +1745,7 @@ Running sync...
1702
1745
  esbuild: "^0.24.0"
1703
1746
  }
1704
1747
  };
1705
- n.writeFileSync("package.json", JSON.stringify(g, null, 2)), console.log("βœ… Created package.json"), n.mkdirSync("src/modules", { recursive: !0 }), n.mkdirSync("src/styles", { recursive: !0 }), n.writeFileSync("build.js", `import * as esbuild from 'esbuild';
1748
+ n.writeFileSync("package.json", JSON.stringify(f, null, 2)), console.log("βœ… Created package.json"), n.mkdirSync("src/modules", { recursive: !0 }), n.mkdirSync("src/styles", { recursive: !0 }), n.writeFileSync("build.js", `import * as esbuild from 'esbuild';
1706
1749
  import fs from 'fs';
1707
1750
  import path from 'path';
1708
1751
 
@@ -1810,7 +1853,7 @@ document.addEventListener('DOMContentLoaded', () => {
1810
1853
  });
1811
1854
  `;
1812
1855
  n.writeFileSync("src/index.js", j), console.log("βœ… Created src/index.js");
1813
- const $ = `// ${c} - Main Application Logic
1856
+ const S = `// ${c} - Main Application Logic
1814
1857
 
1815
1858
  export function init() {
1816
1859
  console.log('${c} loaded');
@@ -1818,7 +1861,7 @@ export function init() {
1818
1861
  // Your component logic here
1819
1862
  }
1820
1863
  `;
1821
- n.writeFileSync("src/modules/app.js", $), console.log("βœ… Created src/modules/app.js"), n.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
1864
+ n.writeFileSync("src/modules/app.js", S), console.log("βœ… Created src/modules/app.js"), n.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
1822
1865
 
1823
1866
  export function setupMyopInterface() {
1824
1867
  // Called when host app sends data to this component
@@ -1870,19 +1913,19 @@ p {
1870
1913
  `;
1871
1914
  n.writeFileSync("src/styles/main.css", v), console.log("βœ… Created src/styles/main.css"), console.log(`
1872
1915
  πŸ“¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
1873
- `), d.myopConfig = S, await B(!0);
1874
- } catch (g) {
1875
- console.error(`Failed to initialize component: ${g.message}`), process.exit(1);
1916
+ `), d.myopConfig = x, await B(!0);
1917
+ } catch (f) {
1918
+ console.error(`Failed to initialize component: ${f.message}`), process.exit(1);
1876
1919
  }
1877
1920
  };
1878
1921
  d.program.command("default", { isDefault: !0 }).action(async () => {
1879
- if (d.program.getOptionValue("help") && (console.log(Ke), process.exit()), d.program.getOptionValue("ci")) {
1880
- const c = await import("fs"), m = d.program.getOptionValue("config") || "./myop.config.json", S = d.program.version(), x = ye();
1881
- let g = { found: !1 };
1922
+ if (d.program.getOptionValue("help") && (console.log(Xe), process.exit()), d.program.getOptionValue("ci")) {
1923
+ const c = await import("fs"), m = d.program.getOptionValue("config") || "./myop.config.json", x = d.program.version(), b = ye();
1924
+ let f = { found: !1 };
1882
1925
  try {
1883
1926
  if (c.existsSync(m)) {
1884
1927
  const w = c.readFileSync(m, "utf-8"), j = JSON.parse(w);
1885
- g = {
1928
+ f = {
1886
1929
  found: !0,
1887
1930
  path: m,
1888
1931
  name: j.name || j.componentName || null,
@@ -1891,14 +1934,14 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
1891
1934
  };
1892
1935
  }
1893
1936
  } catch (w) {
1894
- g = { found: !1, error: w.message };
1937
+ f = { found: !1, error: w.message };
1895
1938
  }
1896
1939
  const y = {
1897
- version: S,
1898
- config: g,
1940
+ version: x,
1941
+ config: f,
1899
1942
  auth: {
1900
- loggedIn: !!(x != null && x.email),
1901
- email: (x == null ? void 0 : x.email) || null
1943
+ loggedIn: !!(b != null && b.email),
1944
+ email: (b == null ? void 0 : b.email) || null
1902
1945
  }
1903
1946
  };
1904
1947
  console.log(JSON.stringify(y, null, 2)), process.exit(0);
@@ -1907,10 +1950,10 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
1907
1950
  text: "Loading Myop CLI...",
1908
1951
  color: "green"
1909
1952
  }).start();
1910
- const a = ce();
1953
+ const a = le();
1911
1954
  await St(500), n.stop();
1912
1955
  const u = d.program.version();
1913
- await vt(u), await B(a.configFound);
1956
+ await xt(u), await B(a.configFound);
1914
1957
  });
1915
1958
  d.program.parse(process.argv);
1916
1959
  d.program.opts();