@myop/cli 0.1.11 β 0.1.13
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 +531 -466
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { select as
|
|
4
|
-
import { Command as
|
|
5
|
-
import { execSync as
|
|
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";
|
|
6
6
|
import Z from "path";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import A from "fs";
|
|
8
|
+
import fe from "crypto";
|
|
9
9
|
import We from "http";
|
|
10
|
-
import { URL as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
const
|
|
10
|
+
import { URL as Ie, URLSearchParams as je } from "url";
|
|
11
|
+
import Ge from "open";
|
|
12
|
+
import Ye from "os";
|
|
13
|
+
const Ke = `
|
|
14
14
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
15
15
|
|
|
16
16
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -44,7 +44,7 @@ Examples:
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
`,
|
|
47
|
+
`, d = {
|
|
48
48
|
program: null,
|
|
49
49
|
executionPath: "",
|
|
50
50
|
options: {
|
|
@@ -52,81 +52,81 @@ Examples:
|
|
|
52
52
|
verbose: !1
|
|
53
53
|
},
|
|
54
54
|
myopConfig: null
|
|
55
|
-
},
|
|
55
|
+
}, ke = {
|
|
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.",
|
|
59
59
|
action: async () => {
|
|
60
60
|
console.info("installing... ");
|
|
61
|
-
for (const e of
|
|
62
|
-
const o = Z.join(
|
|
61
|
+
for (const e of d.myopConfig.flows) {
|
|
62
|
+
const o = Z.join(d.executionPath, "/node_modules/@myop/flow-types/");
|
|
63
63
|
console.info(`Generate flow at ${o}`), console.info(`Generated flow at ${o}`);
|
|
64
64
|
}
|
|
65
65
|
process.exit();
|
|
66
66
|
}
|
|
67
|
-
},
|
|
68
|
-
const o = Z.join(
|
|
67
|
+
}, Xe = (e) => {
|
|
68
|
+
const o = Z.join(d.executionPath, e);
|
|
69
69
|
console.info(`reading config file from: ${o}`);
|
|
70
|
-
const n =
|
|
70
|
+
const n = A.readFileSync(o, "utf8"), a = JSON.parse(n);
|
|
71
71
|
return console.info("config file loaded, ", a), a;
|
|
72
|
-
},
|
|
73
|
-
const n = Z.join(
|
|
72
|
+
}, ge = (e, o) => {
|
|
73
|
+
const n = Z.join(d.executionPath, e);
|
|
74
74
|
console.info(`writing config file to: ${n}`);
|
|
75
75
|
try {
|
|
76
76
|
const a = JSON.stringify(o, null, 2);
|
|
77
|
-
|
|
77
|
+
A.writeFileSync(n, a), console.info(`config file updated ${a}`);
|
|
78
78
|
} catch (a) {
|
|
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
|
-
},
|
|
82
|
+
}, Pe = {
|
|
83
83
|
name: "π Add flow definition to your project",
|
|
84
84
|
value: "addFlow",
|
|
85
85
|
description: "Adds flow to yours myop.config.json",
|
|
86
86
|
_action: (e) => {
|
|
87
|
-
|
|
87
|
+
d.myopConfig.flows.includes(e) || d.myopConfig.flows.push(e), ge(d.options.configPath, d.myopConfig);
|
|
88
88
|
},
|
|
89
89
|
action: async () => {
|
|
90
90
|
}
|
|
91
|
-
},
|
|
91
|
+
}, _e = {
|
|
92
92
|
name: "π« Remove flow definition from your project",
|
|
93
93
|
value: "removeFlow",
|
|
94
94
|
description: "Removes flow to yours myop.config.json",
|
|
95
95
|
_action: (e) => {
|
|
96
|
-
|
|
96
|
+
d.myopConfig.flows = d.myopConfig.flows.filter((o) => o !== e), ge(d.options.configPath, d.myopConfig);
|
|
97
97
|
},
|
|
98
98
|
action: () => {
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, Qe = {
|
|
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
|
-
},
|
|
107
|
+
}, Ze = {
|
|
108
108
|
name: "π’ Create new component",
|
|
109
109
|
value: "-",
|
|
110
110
|
disabled: "(not available yet)"
|
|
111
|
-
},
|
|
111
|
+
}, qe = {
|
|
112
112
|
name: "π΅ Create new experience",
|
|
113
113
|
value: "-",
|
|
114
114
|
disabled: "(not available yet)"
|
|
115
|
-
},
|
|
115
|
+
}, et = {
|
|
116
116
|
name: "π‘ Create new skin",
|
|
117
117
|
value: "-",
|
|
118
118
|
disabled: "(not available yet)"
|
|
119
|
-
},
|
|
119
|
+
}, tt = {
|
|
120
120
|
name: "π΄ Create new flow",
|
|
121
121
|
value: "-",
|
|
122
122
|
disabled: "(not available yet)"
|
|
123
|
-
},
|
|
123
|
+
}, ot = {
|
|
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
|
-
},
|
|
129
|
-
function
|
|
128
|
+
}, nt = [ot, Ze, qe, et, tt];
|
|
129
|
+
function st(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
|
|
219
|
+
async function Ne() {
|
|
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,17 +224,53 @@ async function Pe() {
|
|
|
224
224
|
c = o.default.dirname(s);
|
|
225
225
|
} else
|
|
226
226
|
c = o.default.dirname(import.meta.url);
|
|
227
|
-
const
|
|
228
|
-
let
|
|
229
|
-
const
|
|
230
|
-
let
|
|
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;
|
|
231
231
|
try {
|
|
232
|
-
const s = e.default.readFileSync(
|
|
233
|
-
|
|
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");
|
|
234
234
|
} catch (s) {
|
|
235
235
|
console.error("β Error reading myop.config.json:", s.message), process.exit(1);
|
|
236
236
|
}
|
|
237
|
-
const
|
|
237
|
+
const M = async () => {
|
|
238
|
+
if (v !== "DEV" && v !== "NEW")
|
|
239
|
+
return v;
|
|
240
|
+
try {
|
|
241
|
+
const t = ((await new Promise((l, p) => {
|
|
242
|
+
const f = {
|
|
243
|
+
hostname: "localhost",
|
|
244
|
+
port: y,
|
|
245
|
+
path: "/_list",
|
|
246
|
+
method: "GET",
|
|
247
|
+
timeout: 1e3
|
|
248
|
+
}, O = a.default.request(f, (k) => {
|
|
249
|
+
let H = "";
|
|
250
|
+
k.on("data", (J) => H += J), k.on("end", () => {
|
|
251
|
+
try {
|
|
252
|
+
l(JSON.parse(H));
|
|
253
|
+
} catch {
|
|
254
|
+
l({ components: [] });
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
O.on("error", () => l({ components: [] })), O.on("timeout", () => {
|
|
259
|
+
O.destroy(), l({ components: [] });
|
|
260
|
+
}), O.end();
|
|
261
|
+
})).components || []).map(([l]) => l).filter((l) => l === "DEV" || l === "NEW" || /^DEV\d+$/.test(l) || /^NEW\d+$/.test(l));
|
|
262
|
+
if (t.length === 0)
|
|
263
|
+
return "DEV1";
|
|
264
|
+
const r = t.map((l) => {
|
|
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;
|
|
268
|
+
}).filter((l) => l > 0);
|
|
269
|
+
return `DEV${Math.max(...r, 0) + 1}`;
|
|
270
|
+
} catch {
|
|
271
|
+
return "DEV1";
|
|
272
|
+
}
|
|
273
|
+
}, N = process.cwd(), K = (s) => {
|
|
238
274
|
const t = o.default.extname(s).toLowerCase();
|
|
239
275
|
return {
|
|
240
276
|
".html": "text/html",
|
|
@@ -247,41 +283,41 @@ async function Pe() {
|
|
|
247
283
|
".svg": "image/svg+xml",
|
|
248
284
|
".ico": "image/x-icon"
|
|
249
285
|
}[t] || "application/octet-stream";
|
|
250
|
-
},
|
|
286
|
+
}, b = /* @__PURE__ */ new Map(), q = [], Fe = 50, D = [], V = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), Ae = (s, t, r) => {
|
|
251
287
|
if (s.url.startsWith("/_hmr/")) {
|
|
252
|
-
const i = s.url.split("/_hmr/")[1],
|
|
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");
|
|
253
289
|
t.write(
|
|
254
290
|
`HTTP/1.1 101 Switching Protocols\r
|
|
255
291
|
Upgrade: websocket\r
|
|
256
292
|
Connection: Upgrade\r
|
|
257
|
-
Sec-WebSocket-Accept: ${
|
|
293
|
+
Sec-WebSocket-Accept: ${p}\r
|
|
258
294
|
\r
|
|
259
295
|
`
|
|
260
|
-
),
|
|
261
|
-
const
|
|
262
|
-
|
|
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}`);
|
|
263
299
|
}), t.on("error", () => {
|
|
264
|
-
const
|
|
265
|
-
|
|
300
|
+
const f = U.get(i);
|
|
301
|
+
f && f.delete(t);
|
|
266
302
|
});
|
|
267
303
|
}
|
|
268
|
-
},
|
|
304
|
+
}, le = a.default.createServer((s, t) => {
|
|
269
305
|
if (t.setHeader("Content-Type", "application/json"), s.method === "POST" && s.url === "/_register") {
|
|
270
306
|
let r = "";
|
|
271
307
|
s.on("data", (i) => r += i), s.on("end", () => {
|
|
272
308
|
try {
|
|
273
|
-
const { componentId: i, distPath:
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
console.log(`β
Registered: ${i}${
|
|
277
|
-
const O = Array.from(
|
|
278
|
-
id:
|
|
279
|
-
path:
|
|
280
|
-
name:
|
|
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,
|
|
315
|
+
path: H.path,
|
|
316
|
+
name: H.name
|
|
281
317
|
}));
|
|
282
|
-
|
|
318
|
+
D.forEach((k) => {
|
|
283
319
|
try {
|
|
284
|
-
|
|
320
|
+
k.write(`data: ${JSON.stringify({
|
|
285
321
|
type: "components",
|
|
286
322
|
components: O
|
|
287
323
|
})}
|
|
@@ -299,17 +335,17 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
299
335
|
s.on("data", (i) => r += i), s.on("end", () => {
|
|
300
336
|
try {
|
|
301
337
|
const { componentId: i } = JSON.parse(r);
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
id:
|
|
305
|
-
path:
|
|
306
|
-
name:
|
|
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]) => ({
|
|
340
|
+
id: p,
|
|
341
|
+
path: f.path,
|
|
342
|
+
name: f.name
|
|
307
343
|
}));
|
|
308
|
-
|
|
344
|
+
D.forEach((p) => {
|
|
309
345
|
try {
|
|
310
|
-
|
|
346
|
+
p.write(`data: ${JSON.stringify({
|
|
311
347
|
type: "components",
|
|
312
|
-
components:
|
|
348
|
+
components: l
|
|
313
349
|
})}
|
|
314
350
|
|
|
315
351
|
`);
|
|
@@ -320,124 +356,124 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
320
356
|
t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
|
|
321
357
|
}
|
|
322
358
|
});
|
|
323
|
-
} else s.method === "GET" && s.url === "/_list" ? (t.writeHead(200), t.end(JSON.stringify({ components: Array.from(
|
|
324
|
-
}),
|
|
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" })));
|
|
360
|
+
}), ee = a.default.createServer((s, t) => {
|
|
325
361
|
if (s.url.includes("..")) {
|
|
326
362
|
t.writeHead(403, { "Content-Type": "text/plain" }), t.end("Forbidden");
|
|
327
363
|
return;
|
|
328
364
|
}
|
|
329
|
-
const r = new URL(s.url, `http://localhost:${g}`), i = r.pathname,
|
|
365
|
+
const r = new URL(s.url, `http://localhost:${g}`), i = r.pathname, l = i.split("/").filter((P) => P);
|
|
330
366
|
if (i.startsWith("/consume")) {
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
367
|
+
const P = r.searchParams.get("id");
|
|
368
|
+
if (!P) {
|
|
333
369
|
t.writeHead(400, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
334
370
|
return;
|
|
335
371
|
}
|
|
336
|
-
const
|
|
337
|
-
let
|
|
372
|
+
const R = b.get(P), L = R ? R.path : null, Me = (W) => {
|
|
373
|
+
let C = "Unknown", E = "Unknown";
|
|
338
374
|
if (s.headers.referer || s.headers.referrer) {
|
|
339
|
-
const
|
|
375
|
+
const I = s.headers.referer || s.headers.referrer;
|
|
340
376
|
try {
|
|
341
|
-
const
|
|
342
|
-
|
|
377
|
+
const G = new URL(I);
|
|
378
|
+
C = G.origin, E = G.hostname || G.origin;
|
|
343
379
|
} catch {
|
|
344
|
-
|
|
380
|
+
C = I, E = I;
|
|
345
381
|
}
|
|
346
382
|
} else if (s.headers.origin)
|
|
347
383
|
try {
|
|
348
|
-
const
|
|
349
|
-
|
|
384
|
+
const I = new URL(s.headers.origin);
|
|
385
|
+
C = I.origin, E = I.hostname || I.origin;
|
|
350
386
|
} catch {
|
|
351
|
-
|
|
387
|
+
C = s.headers.origin, E = s.headers.origin;
|
|
352
388
|
}
|
|
353
389
|
else if (s.socket.remoteAddress) {
|
|
354
|
-
const
|
|
355
|
-
|
|
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:", ""));
|
|
356
392
|
}
|
|
357
|
-
const
|
|
393
|
+
const pe = s.headers.referer || s.headers.referrer || C, oe = {
|
|
358
394
|
type: "request",
|
|
359
|
-
componentId:
|
|
395
|
+
componentId: P,
|
|
360
396
|
timestamp: Date.now(),
|
|
361
397
|
servedLocally: W,
|
|
362
|
-
referrer:
|
|
363
|
-
origin:
|
|
364
|
-
originLabel:
|
|
398
|
+
referrer: pe,
|
|
399
|
+
origin: C,
|
|
400
|
+
originLabel: E
|
|
365
401
|
};
|
|
366
|
-
|
|
367
|
-
url:
|
|
368
|
-
label:
|
|
402
|
+
V.has(C) || (V.set(C, {
|
|
403
|
+
url: C,
|
|
404
|
+
label: E,
|
|
369
405
|
firstSeen: Date.now(),
|
|
370
406
|
requestCount: 0
|
|
371
|
-
}),
|
|
407
|
+
}), D.forEach((I) => {
|
|
372
408
|
try {
|
|
373
|
-
|
|
409
|
+
I.write(`data: ${JSON.stringify({
|
|
374
410
|
type: "origins",
|
|
375
|
-
origins: Array.from(
|
|
411
|
+
origins: Array.from(V.values())
|
|
376
412
|
})}
|
|
377
413
|
|
|
378
414
|
`);
|
|
379
415
|
} catch {
|
|
380
416
|
}
|
|
381
417
|
}));
|
|
382
|
-
const
|
|
383
|
-
|
|
418
|
+
const ze = V.get(C);
|
|
419
|
+
ze.requestCount++, D.forEach((I) => {
|
|
384
420
|
try {
|
|
385
|
-
|
|
421
|
+
I.write(`data: ${JSON.stringify({
|
|
386
422
|
type: "origins",
|
|
387
|
-
origins: Array.from(
|
|
423
|
+
origins: Array.from(V.values())
|
|
388
424
|
})}
|
|
389
425
|
|
|
390
426
|
`);
|
|
391
427
|
} catch {
|
|
392
428
|
}
|
|
393
|
-
}),
|
|
429
|
+
}), q.push(oe), q.length > Fe && q.shift(), D.forEach((I) => {
|
|
394
430
|
try {
|
|
395
|
-
|
|
431
|
+
I.write(`data: ${JSON.stringify(oe)}
|
|
396
432
|
|
|
397
433
|
`);
|
|
398
434
|
} catch {
|
|
399
435
|
}
|
|
400
436
|
});
|
|
401
437
|
};
|
|
402
|
-
if (
|
|
403
|
-
const W = o.default.join(
|
|
404
|
-
e.default.readFile(W, "utf-8", (
|
|
405
|
-
if (
|
|
438
|
+
if (L) {
|
|
439
|
+
const W = o.default.join(L, "index.html");
|
|
440
|
+
e.default.readFile(W, "utf-8", (C, E) => {
|
|
441
|
+
if (C) {
|
|
406
442
|
console.log(`β File not found: ${W}`), t.writeHead(404, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "index.html not found" }));
|
|
407
443
|
return;
|
|
408
444
|
}
|
|
409
|
-
const
|
|
445
|
+
const pe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, oe = {
|
|
410
446
|
item: {
|
|
411
|
-
name:
|
|
412
|
-
id:
|
|
447
|
+
name: P,
|
|
448
|
+
id: P,
|
|
413
449
|
consume_variant: [
|
|
414
450
|
{
|
|
415
|
-
id:
|
|
451
|
+
id: pe,
|
|
416
452
|
name: "dev version",
|
|
417
453
|
loader: {
|
|
418
454
|
type: "HTMLLoader",
|
|
419
455
|
shadowRootMode: "localFrame",
|
|
420
|
-
HTML:
|
|
456
|
+
HTML: E
|
|
421
457
|
}
|
|
422
458
|
}
|
|
423
459
|
]
|
|
424
460
|
}
|
|
425
461
|
};
|
|
426
|
-
console.log(`β
Serving consume JSON for: ${
|
|
462
|
+
console.log(`β
Serving consume JSON for: ${P}`), Me(!0), t.writeHead(200, {
|
|
427
463
|
"Content-Type": "application/json",
|
|
428
464
|
"Access-Control-Allow-Origin": "*"
|
|
429
|
-
}), t.end(JSON.stringify(
|
|
465
|
+
}), t.end(JSON.stringify(oe, null, 2));
|
|
430
466
|
});
|
|
431
467
|
} else {
|
|
432
|
-
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${
|
|
468
|
+
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${P}`);
|
|
433
469
|
const W = `https://cloud.myop.dev/consume${r.search}`;
|
|
434
|
-
|
|
470
|
+
Me(!1), fetch(W).then((C) => C.text()).then((C) => {
|
|
435
471
|
t.writeHead(200, {
|
|
436
472
|
"Content-Type": "application/json",
|
|
437
473
|
"Access-Control-Allow-Origin": "*"
|
|
438
|
-
}), t.end(
|
|
439
|
-
}).catch((
|
|
440
|
-
console.error(`β Proxy error: ${
|
|
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" }));
|
|
441
477
|
});
|
|
442
478
|
}
|
|
443
479
|
return;
|
|
@@ -448,67 +484,67 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
448
484
|
"Cache-Control": "no-cache",
|
|
449
485
|
Connection: "keep-alive",
|
|
450
486
|
"Access-Control-Allow-Origin": "*"
|
|
451
|
-
}),
|
|
452
|
-
const
|
|
453
|
-
id:
|
|
454
|
-
path:
|
|
455
|
-
name:
|
|
487
|
+
}), D.push(t);
|
|
488
|
+
const P = Array.from(b.entries()).map(([R, L]) => ({
|
|
489
|
+
id: R,
|
|
490
|
+
path: L.path,
|
|
491
|
+
name: L.name
|
|
456
492
|
}));
|
|
457
493
|
t.write(`data: ${JSON.stringify({
|
|
458
494
|
type: "components",
|
|
459
|
-
components:
|
|
495
|
+
components: P
|
|
460
496
|
})}
|
|
461
497
|
|
|
462
498
|
`), t.write(`data: ${JSON.stringify({
|
|
463
499
|
type: "origins",
|
|
464
|
-
origins: Array.from(
|
|
500
|
+
origins: Array.from(V.values())
|
|
465
501
|
})}
|
|
466
502
|
|
|
467
503
|
`), t.write(`data: ${JSON.stringify({
|
|
468
504
|
type: "requestLog",
|
|
469
|
-
log:
|
|
505
|
+
log: q
|
|
470
506
|
})}
|
|
471
507
|
|
|
472
508
|
`), s.on("close", () => {
|
|
473
|
-
const
|
|
474
|
-
|
|
509
|
+
const R = D.indexOf(t);
|
|
510
|
+
R !== -1 && D.splice(R, 1);
|
|
475
511
|
});
|
|
476
512
|
return;
|
|
477
513
|
}
|
|
478
|
-
if (
|
|
479
|
-
t.writeHead(200, { "Content-Type": "text/html" }), t.end(
|
|
514
|
+
if (l.length === 0) {
|
|
515
|
+
t.writeHead(200, { "Content-Type": "text/html" }), t.end(st(g, y, S, x));
|
|
480
516
|
return;
|
|
481
517
|
}
|
|
482
|
-
if (
|
|
518
|
+
if (l[0] !== "view") {
|
|
483
519
|
t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not found. Use /view/<componentId>/ to access components.");
|
|
484
520
|
return;
|
|
485
521
|
}
|
|
486
|
-
if (
|
|
522
|
+
if (l.length < 2) {
|
|
487
523
|
t.writeHead(400, { "Content-Type": "text/plain" }), t.end("Component ID required. Use /view/<componentId>/");
|
|
488
524
|
return;
|
|
489
525
|
}
|
|
490
|
-
const
|
|
491
|
-
if (!
|
|
492
|
-
t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`Component not found: ${
|
|
526
|
+
const p = l[1], f = b.get(p);
|
|
527
|
+
if (!f) {
|
|
528
|
+
t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`Component not found: ${p}`);
|
|
493
529
|
return;
|
|
494
530
|
}
|
|
495
|
-
const O =
|
|
496
|
-
console.log(`π₯ Request: ${s.url} -> ${
|
|
497
|
-
if (
|
|
498
|
-
console.log(`β File not found: ${
|
|
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");
|
|
499
535
|
return;
|
|
500
536
|
}
|
|
501
|
-
const
|
|
502
|
-
console.log(`β
Serving: ${
|
|
503
|
-
"Content-Type":
|
|
537
|
+
const L = K(J);
|
|
538
|
+
console.log(`β
Serving: ${J} (${L})`), t.writeHead(200, {
|
|
539
|
+
"Content-Type": L,
|
|
504
540
|
"Access-Control-Allow-Origin": "*"
|
|
505
|
-
}), t.end(
|
|
541
|
+
}), t.end(R);
|
|
506
542
|
});
|
|
507
|
-
}),
|
|
543
|
+
}), ve = () => new Promise((s, t) => {
|
|
508
544
|
const r = JSON.stringify({
|
|
509
|
-
componentId:
|
|
510
|
-
distPath: o.default.resolve(
|
|
511
|
-
componentName:
|
|
545
|
+
componentId: v,
|
|
546
|
+
distPath: o.default.resolve(N, w),
|
|
547
|
+
componentName: _
|
|
512
548
|
}), i = {
|
|
513
549
|
hostname: "localhost",
|
|
514
550
|
port: y,
|
|
@@ -518,15 +554,15 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
518
554
|
"Content-Type": "application/json",
|
|
519
555
|
"Content-Length": Buffer.byteLength(r)
|
|
520
556
|
}
|
|
521
|
-
},
|
|
522
|
-
let
|
|
523
|
-
|
|
524
|
-
|
|
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}`));
|
|
525
561
|
});
|
|
526
562
|
});
|
|
527
|
-
|
|
528
|
-
}),
|
|
529
|
-
const r = JSON.stringify({ componentId:
|
|
563
|
+
l.on("error", t), l.write(r), l.end();
|
|
564
|
+
}), De = () => new Promise((s, t) => {
|
|
565
|
+
const r = JSON.stringify({ componentId: v }), i = {
|
|
530
566
|
hostname: "localhost",
|
|
531
567
|
port: y,
|
|
532
568
|
path: "/_unregister",
|
|
@@ -535,24 +571,24 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
535
571
|
"Content-Type": "application/json",
|
|
536
572
|
"Content-Length": Buffer.byteLength(r)
|
|
537
573
|
}
|
|
538
|
-
},
|
|
574
|
+
}, l = a.default.request(i, (p) => {
|
|
539
575
|
s();
|
|
540
576
|
});
|
|
541
|
-
|
|
577
|
+
l.on("error", () => s()), l.write(r), l.end();
|
|
542
578
|
}), He = () => {
|
|
543
|
-
if (!
|
|
579
|
+
if (!h) return;
|
|
544
580
|
const s = o.default.join(w, "index.html");
|
|
545
581
|
try {
|
|
546
582
|
let t = e.default.readFileSync(s, "utf-8");
|
|
547
583
|
if (t.includes("<!-- MYOP HMR -->")) {
|
|
548
|
-
const i = t.indexOf("<!-- MYOP HMR -->"),
|
|
549
|
-
t = t.slice(0, i) + t.slice(
|
|
584
|
+
const i = t.indexOf("<!-- MYOP HMR -->"), l = t.indexOf("<\/script>", i) + 9;
|
|
585
|
+
t = t.slice(0, i) + t.slice(l);
|
|
550
586
|
}
|
|
551
587
|
const r = `
|
|
552
588
|
<!-- MYOP HMR -->
|
|
553
589
|
<script>
|
|
554
590
|
(function() {
|
|
555
|
-
const componentId = '${
|
|
591
|
+
const componentId = '${v}';
|
|
556
592
|
const wsUrl = 'ws://localhost:${y}/_hmr/' + componentId;
|
|
557
593
|
let ws;
|
|
558
594
|
let reconnectAttempts = 0;
|
|
@@ -658,7 +694,7 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
658
694
|
} catch (t) {
|
|
659
695
|
console.error("β Failed to inject HMR script:", t.message);
|
|
660
696
|
}
|
|
661
|
-
},
|
|
697
|
+
}, Je = (s) => {
|
|
662
698
|
const t = Buffer.from(s), r = t.length;
|
|
663
699
|
let i;
|
|
664
700
|
return r < 126 ? i = Buffer.concat([
|
|
@@ -678,9 +714,9 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
678
714
|
// 64-bit length
|
|
679
715
|
t
|
|
680
716
|
]), i;
|
|
681
|
-
},
|
|
682
|
-
if (!
|
|
683
|
-
const s =
|
|
717
|
+
}, Le = () => {
|
|
718
|
+
if (!h) return;
|
|
719
|
+
const s = U.get(v);
|
|
684
720
|
if (!s || s.size === 0)
|
|
685
721
|
return;
|
|
686
722
|
console.log(`π₯ Notifying ${s.size} HMR client(s)`);
|
|
@@ -688,66 +724,66 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
688
724
|
try {
|
|
689
725
|
let r = e.default.readFileSync(t, "utf-8");
|
|
690
726
|
if (r.includes("<!-- MYOP HMR -->")) {
|
|
691
|
-
const
|
|
692
|
-
r = r.slice(0,
|
|
727
|
+
const p = r.indexOf("<!-- MYOP HMR -->"), f = r.indexOf("<\/script>", p) + 9;
|
|
728
|
+
r = r.slice(0, p) + r.slice(f);
|
|
693
729
|
}
|
|
694
730
|
const i = JSON.stringify({
|
|
695
731
|
type: "update",
|
|
696
732
|
html: r
|
|
697
|
-
}),
|
|
698
|
-
s.forEach((
|
|
733
|
+
}), l = Je(i);
|
|
734
|
+
s.forEach((p) => {
|
|
699
735
|
try {
|
|
700
|
-
|
|
736
|
+
p.write(l);
|
|
701
737
|
} catch {
|
|
702
|
-
s.delete(
|
|
738
|
+
s.delete(p);
|
|
703
739
|
}
|
|
704
740
|
});
|
|
705
741
|
} catch (r) {
|
|
706
742
|
console.error("β Failed to read HTML for HMR:", r.message);
|
|
707
743
|
}
|
|
708
|
-
},
|
|
709
|
-
if (
|
|
710
|
-
|
|
744
|
+
}, de = () => {
|
|
745
|
+
if (j) {
|
|
746
|
+
$ = !0;
|
|
711
747
|
return;
|
|
712
748
|
}
|
|
713
|
-
|
|
749
|
+
j = !0, console.log(`
|
|
714
750
|
π¨ Building...`), n("npm run build", (s, t, r) => {
|
|
715
|
-
|
|
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());
|
|
716
752
|
});
|
|
717
|
-
},
|
|
753
|
+
}, Se = /* @__PURE__ */ new Set(), xe = (s) => {
|
|
718
754
|
e.default.readdir(s, { withFileTypes: !0 }, (t, r) => {
|
|
719
755
|
t || (r.forEach((i) => {
|
|
720
|
-
const
|
|
756
|
+
const l = o.default.join(s, i.name);
|
|
721
757
|
if (i.isDirectory())
|
|
722
|
-
i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") &&
|
|
758
|
+
i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && xe(l);
|
|
723
759
|
else if (i.isFile()) {
|
|
724
|
-
const
|
|
725
|
-
if (
|
|
760
|
+
const p = o.default.extname(i.name);
|
|
761
|
+
if (p === ".js" || p === ".css" || p === ".html")
|
|
726
762
|
try {
|
|
727
|
-
const
|
|
728
|
-
|
|
763
|
+
const f = e.default.readFileSync(l, "utf-8");
|
|
764
|
+
T.set(l, f);
|
|
729
765
|
} catch {
|
|
730
766
|
}
|
|
731
767
|
}
|
|
732
|
-
}),
|
|
733
|
-
if (!
|
|
734
|
-
const
|
|
735
|
-
if (
|
|
736
|
-
const
|
|
768
|
+
}), Se.has(s) || (Se.add(s), e.default.watch(s, (i, l) => {
|
|
769
|
+
if (!l) return;
|
|
770
|
+
const p = o.default.extname(l);
|
|
771
|
+
if (p !== ".js" && p !== ".css" && p !== ".html") return;
|
|
772
|
+
const f = o.default.join(s, l);
|
|
737
773
|
setTimeout(() => {
|
|
738
774
|
try {
|
|
739
|
-
const O = e.default.readFileSync(
|
|
740
|
-
O !==
|
|
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());
|
|
741
777
|
} catch {
|
|
742
778
|
}
|
|
743
779
|
}, 50);
|
|
744
780
|
})));
|
|
745
781
|
});
|
|
746
|
-
},
|
|
782
|
+
}, be = () => {
|
|
747
783
|
console.log(`
|
|
748
|
-
π¨ Component: ${
|
|
784
|
+
π¨ Component: ${v}`), de(), xe(N), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
749
785
|
`);
|
|
750
|
-
},
|
|
786
|
+
}, Ue = () => new Promise((s) => {
|
|
751
787
|
const t = {
|
|
752
788
|
hostname: "localhost",
|
|
753
789
|
port: y,
|
|
@@ -760,150 +796,151 @@ Sec-WebSocket-Accept: ${d}\r
|
|
|
760
796
|
r.on("error", () => s(!1)), r.on("timeout", () => {
|
|
761
797
|
r.destroy(), s(!1);
|
|
762
798
|
}), r.end();
|
|
763
|
-
}),
|
|
799
|
+
}), Be = () => new Promise((s) => {
|
|
764
800
|
const t = a.default.createServer((r, i) => {
|
|
765
801
|
if (i.setHeader("Content-Type", "application/json"), r.method === "POST" && r.url === "/_register") {
|
|
766
|
-
let
|
|
767
|
-
r.on("data", (
|
|
802
|
+
let l = "";
|
|
803
|
+
r.on("data", (p) => l += p), r.on("end", () => {
|
|
768
804
|
try {
|
|
769
|
-
const { componentId:
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
console.log(`β
Registered: ${
|
|
773
|
-
} catch (
|
|
774
|
-
i.writeHead(400), i.end(JSON.stringify({ error:
|
|
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()) }));
|
|
809
|
+
} catch (p) {
|
|
810
|
+
i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
|
|
775
811
|
}
|
|
776
812
|
});
|
|
777
813
|
} else if (r.method === "POST" && r.url === "/_unregister") {
|
|
778
|
-
let
|
|
779
|
-
r.on("data", (
|
|
814
|
+
let l = "";
|
|
815
|
+
r.on("data", (p) => l += p), r.on("end", () => {
|
|
780
816
|
try {
|
|
781
|
-
const { componentId:
|
|
782
|
-
|
|
783
|
-
} catch (
|
|
784
|
-
i.writeHead(400), i.end(JSON.stringify({ error:
|
|
817
|
+
const { componentId: p } = JSON.parse(l);
|
|
818
|
+
b.delete(p), console.log(`β Unregistered: ${p}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
|
|
819
|
+
} catch (p) {
|
|
820
|
+
i.writeHead(400), i.end(JSON.stringify({ error: p.message }));
|
|
785
821
|
}
|
|
786
822
|
});
|
|
787
|
-
} else r.method === "GET" && r.url === "/_list" ? (i.writeHead(200), i.end(JSON.stringify({ components: Array.from(
|
|
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" })));
|
|
788
824
|
});
|
|
789
825
|
t.on("error", () => {
|
|
790
826
|
s(!1);
|
|
791
827
|
}), t.listen(y, () => {
|
|
792
828
|
console.log(`
|
|
793
|
-
π Taking over as server...`), console.log(`π‘ Management server on port ${y}`),
|
|
829
|
+
π Taking over as server...`), console.log(`π‘ Management server on port ${y}`), ee.on("error", () => {
|
|
794
830
|
t.close(), s(!1);
|
|
795
|
-
}),
|
|
796
|
-
console.log(`π‘ Main server running at http://localhost:${g}`),
|
|
797
|
-
path: o.default.resolve(
|
|
798
|
-
name:
|
|
831
|
+
}), ee.listen(g, () => {
|
|
832
|
+
console.log(`π‘ Main server running at http://localhost:${g}`), b.set(v, {
|
|
833
|
+
path: o.default.resolve(N, w),
|
|
834
|
+
name: _
|
|
799
835
|
});
|
|
800
|
-
const r =
|
|
801
|
-
console.log(`β
Registered component: ${
|
|
836
|
+
const r = _ ? ` (${_})` : "";
|
|
837
|
+
console.log(`β
Registered component: ${v}${r}`), console.log(`π‘ Access at: http://localhost:${g}/view/${v}/`), s(!0);
|
|
802
838
|
});
|
|
803
839
|
});
|
|
804
840
|
});
|
|
805
|
-
let
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
await
|
|
809
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
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 () => {
|
|
810
846
|
try {
|
|
811
|
-
await
|
|
847
|
+
await ve(), console.log(`β
Re-registered component: ${v}`), Ce();
|
|
812
848
|
} catch (r) {
|
|
813
849
|
console.error("β Failed to re-register:", r.message);
|
|
814
850
|
}
|
|
815
851
|
}, 2e3)));
|
|
816
852
|
}, 3e3);
|
|
817
|
-
},
|
|
853
|
+
}, $e = async () => {
|
|
818
854
|
console.log(`
|
|
819
855
|
|
|
820
|
-
π Shutting down...`),
|
|
856
|
+
π Shutting down...`), te && clearInterval(te), await De(), process.exit(0);
|
|
821
857
|
};
|
|
822
|
-
process.on("SIGINT",
|
|
858
|
+
process.on("SIGINT", $e), process.on("SIGTERM", $e), le.on("error", async (s) => {
|
|
823
859
|
if (s.code === "EADDRINUSE") {
|
|
824
860
|
console.log(`
|
|
825
861
|
π Connecting to existing dev server...`);
|
|
826
862
|
try {
|
|
827
|
-
|
|
828
|
-
|
|
863
|
+
v = await M();
|
|
864
|
+
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();
|
|
829
866
|
} catch (t) {
|
|
830
867
|
console.error("β Failed to register component:", t.message), process.exit(1);
|
|
831
868
|
}
|
|
832
869
|
} else
|
|
833
870
|
console.error("β Management server error:", s.message), process.exit(1);
|
|
834
|
-
}),
|
|
871
|
+
}), le.on("upgrade", Ae), le.listen(y, async () => {
|
|
835
872
|
console.log(`
|
|
836
|
-
π Starting shared dev server...`), console.log(`π‘ Management server on port ${y}`),
|
|
873
|
+
π Starting shared dev server...`), console.log(`π‘ Management server on port ${y}`), ee.on("error", (s) => {
|
|
837
874
|
console.error("β Main server error:", s.message), process.exit(1);
|
|
838
|
-
}),
|
|
839
|
-
console.log(`π‘ Main server running at http://localhost:${g}`),
|
|
840
|
-
path: o.default.resolve(
|
|
841
|
-
name:
|
|
875
|
+
}), ee.listen(g, async () => {
|
|
876
|
+
console.log(`π‘ Main server running at http://localhost:${g}`), (v === "DEV" || v === "NEW") && (v = "DEV1"), b.set(v, {
|
|
877
|
+
path: o.default.resolve(N, w),
|
|
878
|
+
name: _
|
|
842
879
|
});
|
|
843
|
-
const s =
|
|
844
|
-
console.log(`β
Registered component: ${
|
|
880
|
+
const s = _ ? ` (${_})` : "";
|
|
881
|
+
console.log(`β
Registered component: ${v}${s}`), console.log(`π‘ Access at: http://localhost:${g}/view/${v}/`), be();
|
|
845
882
|
});
|
|
846
883
|
});
|
|
847
884
|
}
|
|
848
|
-
const
|
|
849
|
-
function
|
|
850
|
-
|
|
885
|
+
const ue = Z.join(Ye.homedir(), ".myop"), Q = Z.join(ue, "credentials.json");
|
|
886
|
+
function rt() {
|
|
887
|
+
A.existsSync(ue) || A.mkdirSync(ue, { recursive: !0, mode: 448 });
|
|
851
888
|
}
|
|
852
|
-
function
|
|
889
|
+
function he() {
|
|
853
890
|
try {
|
|
854
|
-
if (!
|
|
891
|
+
if (!A.existsSync(Q))
|
|
855
892
|
return null;
|
|
856
|
-
const e =
|
|
893
|
+
const e = A.readFileSync(Q, "utf8");
|
|
857
894
|
return JSON.parse(e);
|
|
858
895
|
} catch (e) {
|
|
859
896
|
return console.info("Failed to read credentials:", e.message), null;
|
|
860
897
|
}
|
|
861
898
|
}
|
|
862
|
-
function
|
|
863
|
-
|
|
899
|
+
function Te(e) {
|
|
900
|
+
rt();
|
|
864
901
|
const o = {
|
|
865
902
|
...e,
|
|
866
903
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
867
904
|
};
|
|
868
|
-
|
|
905
|
+
A.writeFileSync(Q, JSON.stringify(o, null, 2), {
|
|
869
906
|
mode: 384
|
|
870
907
|
// Read/write for owner only
|
|
871
908
|
});
|
|
872
909
|
}
|
|
873
|
-
function
|
|
910
|
+
function Ee() {
|
|
874
911
|
try {
|
|
875
|
-
return
|
|
912
|
+
return A.existsSync(Q) && A.unlinkSync(Q), !0;
|
|
876
913
|
} catch (e) {
|
|
877
914
|
return console.error("Failed to clear credentials:", e.message), !1;
|
|
878
915
|
}
|
|
879
916
|
}
|
|
880
|
-
function
|
|
917
|
+
function it(e) {
|
|
881
918
|
if (!e || !e.expiresAt)
|
|
882
919
|
return !0;
|
|
883
920
|
const o = 5 * 60 * 1e3, n = new Date(e.expiresAt).getTime();
|
|
884
921
|
return Date.now() > n - o;
|
|
885
922
|
}
|
|
886
|
-
function
|
|
887
|
-
const e =
|
|
923
|
+
function ye() {
|
|
924
|
+
const e = he();
|
|
888
925
|
return e ? {
|
|
889
926
|
email: e.userEmail,
|
|
890
927
|
userId: e.userId
|
|
891
928
|
} : null;
|
|
892
929
|
}
|
|
893
|
-
const
|
|
894
|
-
function
|
|
895
|
-
return
|
|
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() {
|
|
932
|
+
return fe.randomBytes(32).toString("base64url");
|
|
896
933
|
}
|
|
897
|
-
function
|
|
898
|
-
return
|
|
934
|
+
function lt(e) {
|
|
935
|
+
return fe.createHash("sha256").update(e).digest("base64url");
|
|
899
936
|
}
|
|
900
|
-
async function
|
|
901
|
-
const e = await fetch(`${
|
|
937
|
+
async function dt() {
|
|
938
|
+
const e = await fetch(`${Y}/oauth/register`, {
|
|
902
939
|
method: "POST",
|
|
903
940
|
headers: { "Content-Type": "application/json" },
|
|
904
941
|
body: JSON.stringify({
|
|
905
|
-
client_name:
|
|
906
|
-
redirect_uris: [
|
|
942
|
+
client_name: at,
|
|
943
|
+
redirect_uris: [we],
|
|
907
944
|
grant_types: ["authorization_code", "refresh_token"],
|
|
908
945
|
response_types: ["code"]
|
|
909
946
|
})
|
|
@@ -914,7 +951,7 @@ async function lt() {
|
|
|
914
951
|
}
|
|
915
952
|
return e.json();
|
|
916
953
|
}
|
|
917
|
-
function
|
|
954
|
+
function ne(e, o, n, a = null) {
|
|
918
955
|
const u = {
|
|
919
956
|
success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
|
|
920
957
|
<circle cx="12" cy="12" r="10"/>
|
|
@@ -932,7 +969,7 @@ function oe(e, o, n, a = null) {
|
|
|
932
969
|
success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
|
|
933
970
|
error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
|
|
934
971
|
warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
|
|
935
|
-
}, { accent:
|
|
972
|
+
}, { accent: m, glow: S } = c[e] || c.error;
|
|
936
973
|
return `<!DOCTYPE html>
|
|
937
974
|
<html lang="en">
|
|
938
975
|
<head>
|
|
@@ -993,7 +1030,7 @@ function oe(e, o, n, a = null) {
|
|
|
993
1030
|
h1 {
|
|
994
1031
|
font-size: 20px;
|
|
995
1032
|
font-weight: 500;
|
|
996
|
-
color: ${
|
|
1033
|
+
color: ${m};
|
|
997
1034
|
margin-bottom: 12px;
|
|
998
1035
|
letter-spacing: -0.5px;
|
|
999
1036
|
}
|
|
@@ -1025,8 +1062,8 @@ function oe(e, o, n, a = null) {
|
|
|
1025
1062
|
display: inline-flex;
|
|
1026
1063
|
align-items: center;
|
|
1027
1064
|
gap: 8px;
|
|
1028
|
-
background: ${
|
|
1029
|
-
border: 1px solid ${
|
|
1065
|
+
background: ${S};
|
|
1066
|
+
border: 1px solid ${m}33;
|
|
1030
1067
|
border-radius: 4px;
|
|
1031
1068
|
padding: 10px 16px;
|
|
1032
1069
|
font-size: 12px;
|
|
@@ -1080,14 +1117,14 @@ function oe(e, o, n, a = null) {
|
|
|
1080
1117
|
</body>
|
|
1081
1118
|
</html>`;
|
|
1082
1119
|
}
|
|
1083
|
-
function
|
|
1120
|
+
function pt(e) {
|
|
1084
1121
|
return new Promise((o, n) => {
|
|
1085
1122
|
const a = We.createServer((u, c) => {
|
|
1086
|
-
const
|
|
1087
|
-
if (
|
|
1088
|
-
const
|
|
1123
|
+
const m = new Ie(u.url, `http://localhost:${re}`);
|
|
1124
|
+
if (m.pathname === "/callback") {
|
|
1125
|
+
const S = m.searchParams.get("code"), x = m.searchParams.get("state"), g = m.searchParams.get("error");
|
|
1089
1126
|
if (g) {
|
|
1090
|
-
c.writeHead(200, { "Content-Type": "text/html" }), c.end(
|
|
1127
|
+
c.writeHead(200, { "Content-Type": "text/html" }), c.end(ne(
|
|
1091
1128
|
"error",
|
|
1092
1129
|
"Authentication Failed",
|
|
1093
1130
|
"Unable to complete the authentication process.",
|
|
@@ -1095,8 +1132,8 @@ function dt(e) {
|
|
|
1095
1132
|
)), a.close(), n(new Error(`OAuth error: ${g}`));
|
|
1096
1133
|
return;
|
|
1097
1134
|
}
|
|
1098
|
-
if (
|
|
1099
|
-
c.writeHead(400, { "Content-Type": "text/html" }), c.end(
|
|
1135
|
+
if (x !== e) {
|
|
1136
|
+
c.writeHead(400, { "Content-Type": "text/html" }), c.end(ne(
|
|
1100
1137
|
"warning",
|
|
1101
1138
|
"Security Error",
|
|
1102
1139
|
"State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
|
|
@@ -1104,8 +1141,8 @@ function dt(e) {
|
|
|
1104
1141
|
)), a.close(), n(new Error("State mismatch"));
|
|
1105
1142
|
return;
|
|
1106
1143
|
}
|
|
1107
|
-
if (!
|
|
1108
|
-
c.writeHead(400, { "Content-Type": "text/html" }), c.end(
|
|
1144
|
+
if (!S) {
|
|
1145
|
+
c.writeHead(400, { "Content-Type": "text/html" }), c.end(ne(
|
|
1109
1146
|
"error",
|
|
1110
1147
|
"Missing Authorization Code",
|
|
1111
1148
|
"No authorization code was received from the server.",
|
|
@@ -1113,30 +1150,30 @@ function dt(e) {
|
|
|
1113
1150
|
)), a.close(), n(new Error("No authorization code"));
|
|
1114
1151
|
return;
|
|
1115
1152
|
}
|
|
1116
|
-
c.writeHead(200, { "Content-Type": "text/html" }), c.end(
|
|
1153
|
+
c.writeHead(200, { "Content-Type": "text/html" }), c.end(ne(
|
|
1117
1154
|
"success",
|
|
1118
1155
|
"Authentication Successful",
|
|
1119
1156
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1120
|
-
)), a.close(), o(
|
|
1157
|
+
)), a.close(), o(S);
|
|
1121
1158
|
} else
|
|
1122
1159
|
c.writeHead(404), c.end("Not found");
|
|
1123
1160
|
});
|
|
1124
|
-
a.listen(
|
|
1125
|
-
console.info(`OAuth callback server listening on port ${
|
|
1161
|
+
a.listen(re, () => {
|
|
1162
|
+
console.info(`OAuth callback server listening on port ${re}`);
|
|
1126
1163
|
}), setTimeout(() => {
|
|
1127
1164
|
a.close(), n(new Error("Authentication timed out"));
|
|
1128
1165
|
}, 5 * 60 * 1e3);
|
|
1129
1166
|
});
|
|
1130
1167
|
}
|
|
1131
|
-
async function
|
|
1132
|
-
const a = await fetch(`${
|
|
1168
|
+
async function mt(e, o, n) {
|
|
1169
|
+
const a = await fetch(`${Y}/oauth/token`, {
|
|
1133
1170
|
method: "POST",
|
|
1134
1171
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1135
1172
|
body: new je({
|
|
1136
1173
|
grant_type: "authorization_code",
|
|
1137
1174
|
code: e,
|
|
1138
1175
|
client_id: o,
|
|
1139
|
-
redirect_uri:
|
|
1176
|
+
redirect_uri: we,
|
|
1140
1177
|
code_verifier: n
|
|
1141
1178
|
})
|
|
1142
1179
|
});
|
|
@@ -1146,8 +1183,8 @@ async function pt(e, o, n) {
|
|
|
1146
1183
|
}
|
|
1147
1184
|
return a.json();
|
|
1148
1185
|
}
|
|
1149
|
-
async function
|
|
1150
|
-
const n = await fetch(`${
|
|
1186
|
+
async function ut(e, o) {
|
|
1187
|
+
const n = await fetch(`${Y}/oauth/token`, {
|
|
1151
1188
|
method: "POST",
|
|
1152
1189
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1153
1190
|
body: new je({
|
|
@@ -1162,9 +1199,9 @@ async function mt(e, o) {
|
|
|
1162
1199
|
}
|
|
1163
1200
|
return n.json();
|
|
1164
1201
|
}
|
|
1165
|
-
async function
|
|
1166
|
-
var u, c,
|
|
1167
|
-
const o = await fetch(`${
|
|
1202
|
+
async function ft(e) {
|
|
1203
|
+
var u, c, m;
|
|
1204
|
+
const o = await fetch(`${Y}/mcp`, {
|
|
1168
1205
|
method: "POST",
|
|
1169
1206
|
headers: {
|
|
1170
1207
|
"Content-Type": "application/json",
|
|
@@ -1185,26 +1222,26 @@ async function ut(e) {
|
|
|
1185
1222
|
const n = await o.json();
|
|
1186
1223
|
if (n.error)
|
|
1187
1224
|
throw new Error(n.error.message);
|
|
1188
|
-
const a = (
|
|
1225
|
+
const a = (m = (c = (u = n.result) == null ? void 0 : u.content) == null ? void 0 : c[0]) == null ? void 0 : m.text;
|
|
1189
1226
|
if (a)
|
|
1190
1227
|
return JSON.parse(a);
|
|
1191
1228
|
throw new Error("Invalid response from whoami");
|
|
1192
1229
|
}
|
|
1193
1230
|
async function X() {
|
|
1194
|
-
const e =
|
|
1231
|
+
const e = F("Starting authentication...").start();
|
|
1195
1232
|
try {
|
|
1196
1233
|
e.text = "Registering OAuth client...";
|
|
1197
|
-
const n = (await
|
|
1234
|
+
const n = (await dt()).client_id, a = ct(), u = lt(a), c = fe.randomBytes(16).toString("hex");
|
|
1198
1235
|
e.text = "Waiting for authorization...";
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1202
|
-
`), await
|
|
1203
|
-
const
|
|
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;
|
|
1204
1241
|
e.start("Exchanging authorization code...");
|
|
1205
|
-
const g = await
|
|
1242
|
+
const g = await mt(x, n, a);
|
|
1206
1243
|
e.text = "Getting user info...";
|
|
1207
|
-
const y = await
|
|
1244
|
+
const y = await ft(g.access_token), w = {
|
|
1208
1245
|
accessToken: g.access_token,
|
|
1209
1246
|
refreshToken: g.refresh_token,
|
|
1210
1247
|
expiresAt: new Date(Date.now() + g.expires_in * 1e3).toISOString(),
|
|
@@ -1212,30 +1249,30 @@ async function X() {
|
|
|
1212
1249
|
userId: y.userId,
|
|
1213
1250
|
userEmail: y.email
|
|
1214
1251
|
};
|
|
1215
|
-
return
|
|
1252
|
+
return Te(w), e.succeed(`Authenticated as ${y.email}`), w;
|
|
1216
1253
|
} catch (o) {
|
|
1217
1254
|
throw e.fail(`Authentication failed: ${o.message}`), o;
|
|
1218
1255
|
}
|
|
1219
1256
|
}
|
|
1220
|
-
async function
|
|
1221
|
-
const e =
|
|
1257
|
+
async function Re() {
|
|
1258
|
+
const e = he();
|
|
1222
1259
|
if (!e) {
|
|
1223
1260
|
console.log("Not currently logged in.");
|
|
1224
1261
|
return;
|
|
1225
1262
|
}
|
|
1226
|
-
|
|
1263
|
+
Ee(), console.log(`β
Logged out (was: ${e.userEmail})`);
|
|
1227
1264
|
}
|
|
1228
|
-
async function
|
|
1229
|
-
let e =
|
|
1265
|
+
async function gt() {
|
|
1266
|
+
let e = he();
|
|
1230
1267
|
if (!e)
|
|
1231
1268
|
return console.log(`Not logged in. Starting authentication...
|
|
1232
1269
|
`), await X();
|
|
1233
|
-
if (!
|
|
1270
|
+
if (!it(e))
|
|
1234
1271
|
return e;
|
|
1235
1272
|
if (e.refreshToken) {
|
|
1236
|
-
const o =
|
|
1273
|
+
const o = F("Refreshing access token...").start();
|
|
1237
1274
|
try {
|
|
1238
|
-
const n = await
|
|
1275
|
+
const n = await ut(
|
|
1239
1276
|
e.refreshToken,
|
|
1240
1277
|
e.clientId
|
|
1241
1278
|
);
|
|
@@ -1244,88 +1281,88 @@ async function ft() {
|
|
|
1244
1281
|
accessToken: n.access_token,
|
|
1245
1282
|
refreshToken: n.refresh_token,
|
|
1246
1283
|
expiresAt: new Date(Date.now() + n.expires_in * 1e3).toISOString()
|
|
1247
|
-
},
|
|
1284
|
+
}, Te(e), o.succeed("Token refreshed"), e;
|
|
1248
1285
|
} catch {
|
|
1249
|
-
return o.warn("Token refresh failed, please log in again"),
|
|
1286
|
+
return o.warn("Token refresh failed, please log in again"), Ee(), await X();
|
|
1250
1287
|
}
|
|
1251
1288
|
}
|
|
1252
1289
|
return console.log(`Session expired. Please log in again.
|
|
1253
1290
|
`), await X();
|
|
1254
1291
|
}
|
|
1255
|
-
function
|
|
1256
|
-
return
|
|
1292
|
+
function ht() {
|
|
1293
|
+
return Y;
|
|
1257
1294
|
}
|
|
1258
|
-
const
|
|
1259
|
-
async function
|
|
1295
|
+
const ie = "@myop/cli";
|
|
1296
|
+
async function yt() {
|
|
1260
1297
|
try {
|
|
1261
|
-
const e = await fetch(`https://registry.npmjs.org/${
|
|
1298
|
+
const e = await fetch(`https://registry.npmjs.org/${ie}/latest`);
|
|
1262
1299
|
return e.ok ? (await e.json()).version : null;
|
|
1263
1300
|
} catch {
|
|
1264
1301
|
return null;
|
|
1265
1302
|
}
|
|
1266
1303
|
}
|
|
1267
|
-
function
|
|
1304
|
+
function wt(e, o) {
|
|
1268
1305
|
const n = e.split(".").map(Number), a = o.split(".").map(Number);
|
|
1269
1306
|
for (let u = 0; u < Math.max(n.length, a.length); u++) {
|
|
1270
|
-
const c = n[u] || 0,
|
|
1271
|
-
if (c >
|
|
1272
|
-
if (c <
|
|
1307
|
+
const c = n[u] || 0, m = a[u] || 0;
|
|
1308
|
+
if (c > m) return 1;
|
|
1309
|
+
if (c < m) return -1;
|
|
1273
1310
|
}
|
|
1274
1311
|
return 0;
|
|
1275
1312
|
}
|
|
1276
|
-
async function
|
|
1277
|
-
const o =
|
|
1313
|
+
async function vt(e) {
|
|
1314
|
+
const o = F({
|
|
1278
1315
|
text: "Checking for updates...",
|
|
1279
1316
|
color: "cyan"
|
|
1280
|
-
}).start(), n = await
|
|
1281
|
-
if (o.stop(), !n ||
|
|
1317
|
+
}).start(), n = await yt();
|
|
1318
|
+
if (o.stop(), !n || wt(n, e) <= 0)
|
|
1282
1319
|
return !1;
|
|
1283
1320
|
if (console.log(`
|
|
1284
1321
|
π¦ New version available: ${e} β ${n}
|
|
1285
|
-
`), await
|
|
1322
|
+
`), await Oe({
|
|
1286
1323
|
message: "Would you like to update now?",
|
|
1287
1324
|
choices: [
|
|
1288
1325
|
{ name: "Yes, update now", value: !0 },
|
|
1289
1326
|
{ name: "No, continue with current version", value: !1 }
|
|
1290
1327
|
]
|
|
1291
1328
|
})) {
|
|
1292
|
-
const u =
|
|
1293
|
-
text: `Updating ${
|
|
1329
|
+
const u = F({
|
|
1330
|
+
text: `Updating ${ie} to v${n}...`,
|
|
1294
1331
|
color: "green"
|
|
1295
1332
|
}).start();
|
|
1296
1333
|
try {
|
|
1297
|
-
|
|
1334
|
+
se(`npm install -g ${ie}@latest`, { stdio: "pipe" }), u.succeed(`Updated to v${n}`), console.log(`
|
|
1298
1335
|
Please restart the CLI to use the new version.
|
|
1299
1336
|
`), process.exit(0);
|
|
1300
1337
|
} catch {
|
|
1301
1338
|
return u.fail("Update failed"), console.log(`
|
|
1302
|
-
You can manually update by running: npm install -g ${
|
|
1339
|
+
You can manually update by running: npm install -g ${ie}@latest
|
|
1303
1340
|
`), !1;
|
|
1304
1341
|
}
|
|
1305
1342
|
}
|
|
1306
1343
|
return !1;
|
|
1307
1344
|
}
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1310
|
-
const
|
|
1311
|
-
const o =
|
|
1345
|
+
const St = (e) => new Promise((o) => setTimeout(o, e));
|
|
1346
|
+
d.executionPath = process.cwd();
|
|
1347
|
+
const ce = (e = !1) => {
|
|
1348
|
+
const o = d.program.getOptionValue("verbose");
|
|
1312
1349
|
o || (console.info = () => {
|
|
1313
|
-
}), console.info("π verbose mode on"),
|
|
1314
|
-
configPath:
|
|
1350
|
+
}), console.info("π verbose mode on"), d.options = {
|
|
1351
|
+
configPath: d.program.getOptionValue("config"),
|
|
1315
1352
|
verbose: o
|
|
1316
1353
|
};
|
|
1317
1354
|
try {
|
|
1318
|
-
return
|
|
1355
|
+
return d.myopConfig = Xe(d.options.configPath), { configFound: !0 };
|
|
1319
1356
|
} catch (n) {
|
|
1320
1357
|
if (e) {
|
|
1321
1358
|
console.info(`
|
|
1322
|
-
β οΈ failed read config file from ${
|
|
1359
|
+
β οΈ failed read config file from ${d.options.configPath}, trying to create new one`);
|
|
1323
1360
|
try {
|
|
1324
1361
|
const a = {
|
|
1325
1362
|
author: "@myop-cli",
|
|
1326
1363
|
flows: []
|
|
1327
1364
|
};
|
|
1328
|
-
return
|
|
1365
|
+
return ge(d.options.configPath, a), d.myopConfig = a, { configFound: !0 };
|
|
1329
1366
|
} catch {
|
|
1330
1367
|
return console.info("Error details :", n), { configFound: !1, error: n };
|
|
1331
1368
|
}
|
|
@@ -1334,24 +1371,26 @@ const ie = (e = !1) => {
|
|
|
1334
1371
|
}
|
|
1335
1372
|
};
|
|
1336
1373
|
[
|
|
1337
|
-
new
|
|
1338
|
-
...
|
|
1374
|
+
new me(),
|
|
1375
|
+
...nt
|
|
1339
1376
|
];
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1377
|
+
const xt = "0.1.13";
|
|
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"));
|
|
1384
|
+
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();
|
|
1347
1386
|
});
|
|
1348
|
-
|
|
1349
|
-
|
|
1387
|
+
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();
|
|
1350
1389
|
});
|
|
1351
|
-
|
|
1352
|
-
|
|
1390
|
+
d.program.command("install").description("Install Myop assets").action(async () => {
|
|
1391
|
+
ce(), await ke.action();
|
|
1353
1392
|
});
|
|
1354
|
-
|
|
1393
|
+
d.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1355
1394
|
try {
|
|
1356
1395
|
await X();
|
|
1357
1396
|
} catch (e) {
|
|
@@ -1359,52 +1398,52 @@ l.program.command("login").description("Authenticate with Myop platform").action
|
|
|
1359
1398
|
}
|
|
1360
1399
|
process.exit(0);
|
|
1361
1400
|
});
|
|
1362
|
-
|
|
1363
|
-
await
|
|
1401
|
+
d.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1402
|
+
await Re(), process.exit(0);
|
|
1364
1403
|
});
|
|
1365
|
-
|
|
1366
|
-
const e =
|
|
1404
|
+
d.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1405
|
+
const e = ye();
|
|
1367
1406
|
e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
|
|
1368
1407
|
});
|
|
1369
|
-
|
|
1370
|
-
var
|
|
1371
|
-
const o =
|
|
1408
|
+
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, _;
|
|
1410
|
+
const o = d.program.getOptionValue("config") || "./myop.config.json", n = await import("fs"), { execSync: a } = await import("child_process"), u = await import("path");
|
|
1372
1411
|
let c = {};
|
|
1373
1412
|
if (n.existsSync(o))
|
|
1374
1413
|
try {
|
|
1375
|
-
const
|
|
1376
|
-
c = JSON.parse(
|
|
1377
|
-
const
|
|
1378
|
-
console.log(`π Found config: ${
|
|
1379
|
-
} catch (
|
|
1380
|
-
console.error(`β οΈ Failed to parse ${o}:`,
|
|
1414
|
+
const h = n.readFileSync(o, "utf-8");
|
|
1415
|
+
c = JSON.parse(h);
|
|
1416
|
+
const M = c.name || c.componentName;
|
|
1417
|
+
console.log(`π Found config: ${M || "Unnamed component"}`), c.componentId && console.log(` Component ID: ${c.componentId}`);
|
|
1418
|
+
} catch (h) {
|
|
1419
|
+
console.error(`β οΈ Failed to parse ${o}:`, h.message);
|
|
1381
1420
|
}
|
|
1382
1421
|
else
|
|
1383
1422
|
console.log("β οΈ No myop.config.json found. A new component will be created.");
|
|
1384
1423
|
if (!e.skipBuild) {
|
|
1385
|
-
const
|
|
1424
|
+
const h = F("Building project...").start();
|
|
1386
1425
|
try {
|
|
1387
|
-
a("npm run build", { stdio: "pipe" }),
|
|
1388
|
-
} catch (
|
|
1389
|
-
|
|
1426
|
+
a("npm run build", { stdio: "pipe" }), h.succeed("Build completed");
|
|
1427
|
+
} catch (M) {
|
|
1428
|
+
h.fail("Build failed"), console.error(M.message), process.exit(1);
|
|
1390
1429
|
}
|
|
1391
1430
|
}
|
|
1392
|
-
const
|
|
1393
|
-
n.existsSync(
|
|
1394
|
-
let
|
|
1431
|
+
const m = "./dist/index.html";
|
|
1432
|
+
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;
|
|
1395
1434
|
try {
|
|
1396
|
-
|
|
1397
|
-
} catch (
|
|
1398
|
-
console.error("β Authentication failed:",
|
|
1435
|
+
S = await gt();
|
|
1436
|
+
} catch (h) {
|
|
1437
|
+
console.error("β Authentication failed:", h.message), process.exit(1);
|
|
1399
1438
|
}
|
|
1400
|
-
const
|
|
1401
|
-
let g =
|
|
1439
|
+
const x = ht();
|
|
1440
|
+
let g = F("Requesting upload URL...").start(), y;
|
|
1402
1441
|
try {
|
|
1403
|
-
const
|
|
1442
|
+
const h = await fetch(`${x}/mcp`, {
|
|
1404
1443
|
method: "POST",
|
|
1405
1444
|
headers: {
|
|
1406
1445
|
"Content-Type": "application/json",
|
|
1407
|
-
Authorization: `Bearer ${
|
|
1446
|
+
Authorization: `Bearer ${S.accessToken}`
|
|
1408
1447
|
},
|
|
1409
1448
|
body: JSON.stringify({
|
|
1410
1449
|
jsonrpc: "2.0",
|
|
@@ -1420,56 +1459,56 @@ l.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1420
1459
|
}
|
|
1421
1460
|
})
|
|
1422
1461
|
});
|
|
1423
|
-
if (!
|
|
1424
|
-
throw new Error(`Server returned ${
|
|
1425
|
-
const
|
|
1426
|
-
if (
|
|
1427
|
-
throw new Error(
|
|
1428
|
-
const
|
|
1429
|
-
if (y = JSON.parse(
|
|
1462
|
+
if (!h.ok)
|
|
1463
|
+
throw new Error(`Server returned ${h.status}`);
|
|
1464
|
+
const M = await h.json();
|
|
1465
|
+
if (M.error)
|
|
1466
|
+
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;
|
|
1468
|
+
if (y = JSON.parse(N), !y.success)
|
|
1430
1469
|
throw new Error(y.error);
|
|
1431
1470
|
g.succeed("Upload URL obtained");
|
|
1432
|
-
} catch (
|
|
1433
|
-
g.fail("Failed to get upload URL"), console.error(" ",
|
|
1471
|
+
} catch (h) {
|
|
1472
|
+
g.fail("Failed to get upload URL"), console.error(" ", h.message), process.exit(1);
|
|
1434
1473
|
}
|
|
1435
|
-
g =
|
|
1474
|
+
g = F("Uploading component...").start();
|
|
1436
1475
|
try {
|
|
1437
|
-
const
|
|
1438
|
-
let
|
|
1439
|
-
const
|
|
1440
|
-
if (
|
|
1441
|
-
|
|
1476
|
+
const h = n.readFileSync(m, "utf-8");
|
|
1477
|
+
let M;
|
|
1478
|
+
const N = y.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
1479
|
+
if (N)
|
|
1480
|
+
M = N[1];
|
|
1442
1481
|
else {
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1445
|
-
|
|
1482
|
+
const b = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
1483
|
+
if (b)
|
|
1484
|
+
M = b[1];
|
|
1446
1485
|
else
|
|
1447
1486
|
throw new Error("Could not parse presigned URL from: " + y.curlCommand);
|
|
1448
1487
|
}
|
|
1449
|
-
console.info("Uploading to:",
|
|
1450
|
-
const
|
|
1488
|
+
console.info("Uploading to:", M.substring(0, 100) + "...");
|
|
1489
|
+
const K = await fetch(M, {
|
|
1451
1490
|
method: "PUT",
|
|
1452
1491
|
headers: {
|
|
1453
1492
|
"Content-Type": "text/html"
|
|
1454
1493
|
},
|
|
1455
|
-
body:
|
|
1494
|
+
body: h
|
|
1456
1495
|
});
|
|
1457
|
-
if (
|
|
1458
|
-
const
|
|
1459
|
-
throw new Error(`Upload failed with status ${
|
|
1496
|
+
if (!K.ok) {
|
|
1497
|
+
const b = await K.text();
|
|
1498
|
+
throw new Error(`Upload failed with status ${K.status}: ${b}`);
|
|
1460
1499
|
}
|
|
1461
1500
|
g.succeed("Component uploaded");
|
|
1462
|
-
} catch (
|
|
1463
|
-
g.fail("Upload failed"), console.error(" ",
|
|
1501
|
+
} catch (h) {
|
|
1502
|
+
g.fail("Upload failed"), console.error(" ", h.message), h.cause && console.error(" Cause:", h.cause), process.exit(1);
|
|
1464
1503
|
}
|
|
1465
|
-
g =
|
|
1504
|
+
g = F("Confirming upload...").start();
|
|
1466
1505
|
let w;
|
|
1467
1506
|
try {
|
|
1468
|
-
const
|
|
1507
|
+
const h = await fetch(`${x}/mcp`, {
|
|
1469
1508
|
method: "POST",
|
|
1470
1509
|
headers: {
|
|
1471
1510
|
"Content-Type": "application/json",
|
|
1472
|
-
Authorization: `Bearer ${
|
|
1511
|
+
Authorization: `Bearer ${S.accessToken}`
|
|
1473
1512
|
},
|
|
1474
1513
|
body: JSON.stringify({
|
|
1475
1514
|
jsonrpc: "2.0",
|
|
@@ -1483,45 +1522,45 @@ l.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1483
1522
|
}
|
|
1484
1523
|
})
|
|
1485
1524
|
});
|
|
1486
|
-
if (!
|
|
1487
|
-
throw new Error(`Server returned ${
|
|
1488
|
-
const
|
|
1489
|
-
if (
|
|
1490
|
-
throw new Error(
|
|
1491
|
-
const
|
|
1492
|
-
if (w = JSON.parse(
|
|
1525
|
+
if (!h.ok)
|
|
1526
|
+
throw new Error(`Server returned ${h.status}`);
|
|
1527
|
+
const M = await h.json();
|
|
1528
|
+
if (M.error)
|
|
1529
|
+
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;
|
|
1531
|
+
if (w = JSON.parse(N), !w.success)
|
|
1493
1532
|
throw new Error(w.error);
|
|
1494
1533
|
g.succeed("Upload confirmed");
|
|
1495
|
-
} catch (
|
|
1496
|
-
g.fail("Confirmation failed"), console.error(" ",
|
|
1534
|
+
} catch (h) {
|
|
1535
|
+
g.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
|
|
1497
1536
|
}
|
|
1498
1537
|
if (w.isNewComponent || !c.componentId) {
|
|
1499
1538
|
c.componentId = w.componentId, c.organization = w.orgId, c.name || (c.name = w.componentName);
|
|
1500
1539
|
try {
|
|
1501
1540
|
n.writeFileSync(o, JSON.stringify(c, null, 2)), console.log(`
|
|
1502
1541
|
π Updated ${o} with componentId`);
|
|
1503
|
-
} catch (
|
|
1542
|
+
} catch (h) {
|
|
1504
1543
|
console.log(`
|
|
1505
|
-
β οΈ Could not update ${o}: ${
|
|
1544
|
+
β οΈ Could not update ${o}: ${h.message}`), console.log(` Please add componentId: "${w.componentId}" manually`);
|
|
1506
1545
|
}
|
|
1507
1546
|
}
|
|
1508
1547
|
console.log(`
|
|
1509
1548
|
β
Sync completed successfully!`), console.log(` Component: ${w.componentName}`), console.log(` Dashboard: ${w.dashboardUrl}`), process.exit(0);
|
|
1510
1549
|
});
|
|
1511
|
-
|
|
1512
|
-
const
|
|
1550
|
+
d.program.command("dev").description("Start development server with file watching").action(Ne);
|
|
1551
|
+
const bt = () => {
|
|
1513
1552
|
try {
|
|
1514
|
-
|
|
1553
|
+
se("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
1515
1554
|
} catch {
|
|
1516
1555
|
return { gitNotInstalled: !0 };
|
|
1517
1556
|
}
|
|
1518
1557
|
try {
|
|
1519
|
-
|
|
1558
|
+
se("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
1520
1559
|
} catch {
|
|
1521
1560
|
return { notARepo: !0 };
|
|
1522
1561
|
}
|
|
1523
1562
|
try {
|
|
1524
|
-
const e =
|
|
1563
|
+
const e = se("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
|
|
1525
1564
|
encoding: "utf-8",
|
|
1526
1565
|
stdio: ["pipe", "pipe", "pipe"]
|
|
1527
1566
|
}).trim();
|
|
@@ -1541,13 +1580,13 @@ const St = () => {
|
|
|
1541
1580
|
} catch {
|
|
1542
1581
|
return null;
|
|
1543
1582
|
}
|
|
1544
|
-
},
|
|
1545
|
-
var y, w,
|
|
1546
|
-
const n =
|
|
1583
|
+
}, B = async (e = !1, o = !1) => {
|
|
1584
|
+
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();
|
|
1547
1586
|
console.log(`
|
|
1548
1587
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
1549
|
-
`), 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"}`),
|
|
1550
|
-
const
|
|
1588
|
+
`), 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 = [
|
|
1551
1590
|
{
|
|
1552
1591
|
emoji: "π",
|
|
1553
1592
|
label: "Initialize new component",
|
|
@@ -1569,14 +1608,14 @@ const St = () => {
|
|
|
1569
1608
|
help: "Starts dev server with HMR for instant preview of changes",
|
|
1570
1609
|
disabled: e ? !1 : "(no config file)"
|
|
1571
1610
|
}
|
|
1572
|
-
].map((
|
|
1573
|
-
name: o &&
|
|
1574
|
-
${
|
|
1575
|
-
value:
|
|
1576
|
-
disabled:
|
|
1611
|
+
].map(($) => ({
|
|
1612
|
+
name: o && !$.disabled ? `${$.emoji} ${$.label}
|
|
1613
|
+
${$.help}` : `${$.emoji} ${$.label}`,
|
|
1614
|
+
value: $.value,
|
|
1615
|
+
disabled: $.disabled
|
|
1577
1616
|
}));
|
|
1578
|
-
switch (
|
|
1579
|
-
new
|
|
1617
|
+
switch (x.push(
|
|
1618
|
+
new me(),
|
|
1580
1619
|
{
|
|
1581
1620
|
name: o && a ? `π Logout (${n.email})
|
|
1582
1621
|
Clears stored credentials from this machine` : o && !a ? `π Login to Myop
|
|
@@ -1587,55 +1626,55 @@ const St = () => {
|
|
|
1587
1626
|
name: o ? "π Hide help" : "π Show help",
|
|
1588
1627
|
value: "help"
|
|
1589
1628
|
},
|
|
1590
|
-
new
|
|
1629
|
+
new me(),
|
|
1591
1630
|
{
|
|
1592
1631
|
name: "π Exit",
|
|
1593
1632
|
value: "exit"
|
|
1594
1633
|
}
|
|
1595
|
-
), await
|
|
1634
|
+
), await Oe({
|
|
1596
1635
|
message: "What would you like to do?",
|
|
1597
|
-
choices:
|
|
1636
|
+
choices: x
|
|
1598
1637
|
})) {
|
|
1599
1638
|
case "init":
|
|
1600
|
-
await
|
|
1639
|
+
await Ct();
|
|
1601
1640
|
break;
|
|
1602
1641
|
case "sync":
|
|
1603
1642
|
console.log(`
|
|
1604
1643
|
Running sync...
|
|
1605
1644
|
`);
|
|
1606
|
-
const { execSync:
|
|
1645
|
+
const { execSync: $ } = await import("child_process");
|
|
1607
1646
|
try {
|
|
1608
|
-
|
|
1647
|
+
$("node " + process.argv[1] + " sync", { stdio: "inherit" });
|
|
1609
1648
|
} catch {
|
|
1610
1649
|
}
|
|
1611
|
-
await
|
|
1650
|
+
await B(!0, o);
|
|
1612
1651
|
break;
|
|
1613
1652
|
case "dev":
|
|
1614
|
-
await
|
|
1653
|
+
await Ne();
|
|
1615
1654
|
break;
|
|
1616
1655
|
case "login":
|
|
1617
1656
|
try {
|
|
1618
1657
|
await X(), console.log(`
|
|
1619
|
-
`), await
|
|
1620
|
-
} catch (
|
|
1621
|
-
console.error("Login failed:",
|
|
1658
|
+
`), await B(e, o);
|
|
1659
|
+
} catch (T) {
|
|
1660
|
+
console.error("Login failed:", T.message), await B(e, o);
|
|
1622
1661
|
}
|
|
1623
1662
|
break;
|
|
1624
1663
|
case "logout":
|
|
1625
|
-
await
|
|
1626
|
-
`), await
|
|
1664
|
+
await Re(), console.log(`
|
|
1665
|
+
`), await B(e, o);
|
|
1627
1666
|
break;
|
|
1628
1667
|
case "help":
|
|
1629
|
-
await
|
|
1668
|
+
await B(e, !o);
|
|
1630
1669
|
break;
|
|
1631
1670
|
case "exit":
|
|
1632
1671
|
process.exit(0);
|
|
1633
1672
|
}
|
|
1634
|
-
},
|
|
1673
|
+
}, Ct = async () => {
|
|
1635
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({
|
|
1636
1675
|
message: "Component name:",
|
|
1637
1676
|
default: u
|
|
1638
|
-
}),
|
|
1677
|
+
}), m = await o({
|
|
1639
1678
|
message: "Component type:",
|
|
1640
1679
|
choices: [
|
|
1641
1680
|
{ name: "π HTML", value: "html", description: "Plain HTML/JS/CSS component" },
|
|
@@ -1643,14 +1682,14 @@ Running sync...
|
|
|
1643
1682
|
{ name: "π Vue", value: "vue", disabled: "(coming soon)" },
|
|
1644
1683
|
{ name: "π
°οΈ Angular", value: "angular", disabled: "(coming soon)" }
|
|
1645
1684
|
]
|
|
1646
|
-
}),
|
|
1685
|
+
}), S = {
|
|
1647
1686
|
name: c,
|
|
1648
|
-
type:
|
|
1687
|
+
type: m,
|
|
1649
1688
|
author: "@myop-cli"
|
|
1650
|
-
},
|
|
1689
|
+
}, x = d.program.getOptionValue("config") || "./myop.config.json";
|
|
1651
1690
|
try {
|
|
1652
|
-
n.writeFileSync(
|
|
1653
|
-
β
Created ${
|
|
1691
|
+
n.writeFileSync(x, JSON.stringify(S, null, 2)), console.log(`
|
|
1692
|
+
β
Created ${x}`);
|
|
1654
1693
|
const g = {
|
|
1655
1694
|
name: c.toLowerCase().replace(/\s+/g, "-"),
|
|
1656
1695
|
version: "1.0.0",
|
|
@@ -1761,7 +1800,7 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
1761
1800
|
</html>
|
|
1762
1801
|
`;
|
|
1763
1802
|
n.writeFileSync("index.html", w), console.log("β
Created index.html");
|
|
1764
|
-
const
|
|
1803
|
+
const j = `// ${c} - Entry Point
|
|
1765
1804
|
import { init } from './modules/app.js';
|
|
1766
1805
|
import { setupMyopInterface } from './modules/myop.js';
|
|
1767
1806
|
|
|
@@ -1770,8 +1809,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1770
1809
|
setupMyopInterface();
|
|
1771
1810
|
});
|
|
1772
1811
|
`;
|
|
1773
|
-
n.writeFileSync("src/index.js",
|
|
1774
|
-
const
|
|
1812
|
+
n.writeFileSync("src/index.js", j), console.log("β
Created src/index.js");
|
|
1813
|
+
const $ = `// ${c} - Main Application Logic
|
|
1775
1814
|
|
|
1776
1815
|
export function init() {
|
|
1777
1816
|
console.log('${c} loaded');
|
|
@@ -1779,7 +1818,7 @@ export function init() {
|
|
|
1779
1818
|
// Your component logic here
|
|
1780
1819
|
}
|
|
1781
1820
|
`;
|
|
1782
|
-
n.writeFileSync("src/modules/app.js",
|
|
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
|
|
1783
1822
|
|
|
1784
1823
|
export function setupMyopInterface() {
|
|
1785
1824
|
// Called when host app sends data to this component
|
|
@@ -1795,12 +1834,12 @@ export function setupMyopInterface() {
|
|
|
1795
1834
|
};
|
|
1796
1835
|
}
|
|
1797
1836
|
`), console.log("β
Created src/modules/myop.js");
|
|
1798
|
-
const
|
|
1837
|
+
const z = `/* ${c} - Styles Entry Point */
|
|
1799
1838
|
/* Add your CSS imports here - they will be auto-bundled */
|
|
1800
1839
|
@import './main.css';
|
|
1801
1840
|
`;
|
|
1802
|
-
n.writeFileSync("src/styles/index.css",
|
|
1803
|
-
const
|
|
1841
|
+
n.writeFileSync("src/styles/index.css", z), console.log("β
Created src/styles/index.css");
|
|
1842
|
+
const v = `/* ${c} - Main Styles */
|
|
1804
1843
|
|
|
1805
1844
|
* {
|
|
1806
1845
|
box-sizing: border-box;
|
|
@@ -1829,23 +1868,49 @@ p {
|
|
|
1829
1868
|
line-height: 1.5;
|
|
1830
1869
|
}
|
|
1831
1870
|
`;
|
|
1832
|
-
n.writeFileSync("src/styles/main.css",
|
|
1871
|
+
n.writeFileSync("src/styles/main.css", v), console.log("β
Created src/styles/main.css"), console.log(`
|
|
1833
1872
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
1834
|
-
`),
|
|
1873
|
+
`), d.myopConfig = S, await B(!0);
|
|
1835
1874
|
} catch (g) {
|
|
1836
1875
|
console.error(`Failed to initialize component: ${g.message}`), process.exit(1);
|
|
1837
1876
|
}
|
|
1838
1877
|
};
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1878
|
+
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 };
|
|
1882
|
+
try {
|
|
1883
|
+
if (c.existsSync(m)) {
|
|
1884
|
+
const w = c.readFileSync(m, "utf-8"), j = JSON.parse(w);
|
|
1885
|
+
g = {
|
|
1886
|
+
found: !0,
|
|
1887
|
+
path: m,
|
|
1888
|
+
name: j.name || j.componentName || null,
|
|
1889
|
+
componentId: j.componentId || null,
|
|
1890
|
+
organization: j.organization || null
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
} catch (w) {
|
|
1894
|
+
g = { found: !1, error: w.message };
|
|
1895
|
+
}
|
|
1896
|
+
const y = {
|
|
1897
|
+
version: S,
|
|
1898
|
+
config: g,
|
|
1899
|
+
auth: {
|
|
1900
|
+
loggedIn: !!(x != null && x.email),
|
|
1901
|
+
email: (x == null ? void 0 : x.email) || null
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
console.log(JSON.stringify(y, null, 2)), process.exit(0);
|
|
1905
|
+
}
|
|
1906
|
+
let n = F({
|
|
1842
1907
|
text: "Loading Myop CLI...",
|
|
1843
1908
|
color: "green"
|
|
1844
1909
|
}).start();
|
|
1845
|
-
const
|
|
1846
|
-
await
|
|
1847
|
-
const
|
|
1848
|
-
await
|
|
1910
|
+
const a = ce();
|
|
1911
|
+
await St(500), n.stop();
|
|
1912
|
+
const u = d.program.version();
|
|
1913
|
+
await vt(u), await B(a.configFound);
|
|
1849
1914
|
});
|
|
1850
|
-
|
|
1851
|
-
|
|
1915
|
+
d.program.parse(process.argv);
|
|
1916
|
+
d.program.opts();
|