@myop/cli 0.1.15 β 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.
- package/dist/myop-cli.js +280 -267
- 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
|
|
4
|
-
import { Command as
|
|
5
|
-
import { execSync as
|
|
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
|
|
10
|
-
import { URL as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
const
|
|
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
|
-
},
|
|
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,22 +64,22 @@ Examples:
|
|
|
64
64
|
}
|
|
65
65
|
process.exit();
|
|
66
66
|
}
|
|
67
|
-
},
|
|
67
|
+
}, Qe = (e) => {
|
|
68
68
|
const o = Z.join(d.executionPath, e);
|
|
69
69
|
console.info(`reading config file from: ${o}`);
|
|
70
|
-
const n = A.readFileSync(o, "utf8"),
|
|
71
|
-
return console.info("config file loaded, ",
|
|
70
|
+
const n = A.readFileSync(o, "utf8"), a = JSON.parse(n);
|
|
71
|
+
return console.info("config file loaded, ", a), a;
|
|
72
72
|
}, ge = (e, o) => {
|
|
73
73
|
const n = Z.join(d.executionPath, e);
|
|
74
74
|
console.info(`writing config file to: ${n}`);
|
|
75
75
|
try {
|
|
76
|
-
const
|
|
77
|
-
A.writeFileSync(n,
|
|
78
|
-
} catch (
|
|
79
|
-
throw console.info(`error ${
|
|
80
|
-
β οΈ Failed write config file to ${n}, for more info use verbose flag`),
|
|
76
|
+
const a = JSON.stringify(o, null, 2);
|
|
77
|
+
A.writeFileSync(n, a), console.info(`config file updated ${a}`);
|
|
78
|
+
} catch (a) {
|
|
79
|
+
throw console.info(`error ${a} while writing to ${n}, JSON: ${o}`), console.log(`
|
|
80
|
+
β οΈ Failed write config file to ${n}, for more info use verbose flag`), a;
|
|
81
81
|
}
|
|
82
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
107
|
+
}, qe = {
|
|
108
108
|
name: "π’ Create new component",
|
|
109
109
|
value: "-",
|
|
110
110
|
disabled: "(not available yet)"
|
|
111
|
-
},
|
|
111
|
+
}, et = {
|
|
112
112
|
name: "π΅ Create new experience",
|
|
113
113
|
value: "-",
|
|
114
114
|
disabled: "(not available yet)"
|
|
115
|
-
},
|
|
115
|
+
}, tt = {
|
|
116
116
|
name: "π‘ Create new skin",
|
|
117
117
|
value: "-",
|
|
118
118
|
disabled: "(not available yet)"
|
|
119
|
-
},
|
|
119
|
+
}, ot = {
|
|
120
120
|
name: "π΄ Create new flow",
|
|
121
121
|
value: "-",
|
|
122
122
|
disabled: "(not available yet)"
|
|
123
|
-
},
|
|
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
|
-
},
|
|
129
|
-
function
|
|
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>
|
|
@@ -211,13 +211,13 @@ ${n}
|
|
|
211
211
|
// Inject PORT as a global variable for the app to use
|
|
212
212
|
window.PORT = ${e};
|
|
213
213
|
|
|
214
|
-
${
|
|
214
|
+
${a}
|
|
215
215
|
<\/script>
|
|
216
216
|
</body>
|
|
217
217
|
</html>`;
|
|
218
218
|
}
|
|
219
|
-
async function
|
|
220
|
-
const e = await import("fs"), o = await import("path"), { exec: n } = await import("child_process"),
|
|
219
|
+
async function ke() {
|
|
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://")) {
|
|
223
223
|
const s = import.meta.url.slice(7);
|
|
@@ -226,7 +226,7 @@ async function _e() {
|
|
|
226
226
|
c = o.default.dirname(import.meta.url);
|
|
227
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
228
|
let j = !1, S = !1;
|
|
229
|
-
const
|
|
229
|
+
const k = /* @__PURE__ */ new Map(), z = d.program.getOptionValue("config") || "./myop.config.json";
|
|
230
230
|
let v, E, h = !1;
|
|
231
231
|
try {
|
|
232
232
|
const s = e.default.readFileSync(z, "utf-8"), t = JSON.parse(s);
|
|
@@ -245,9 +245,9 @@ async function _e() {
|
|
|
245
245
|
path: "/_list",
|
|
246
246
|
method: "GET",
|
|
247
247
|
timeout: 1e3
|
|
248
|
-
}, O =
|
|
248
|
+
}, O = a.default.request(g, (P) => {
|
|
249
249
|
let H = "";
|
|
250
|
-
P.on("data", (
|
|
250
|
+
P.on("data", (L) => H += L), P.on("end", () => {
|
|
251
251
|
try {
|
|
252
252
|
l(JSON.parse(H));
|
|
253
253
|
} catch {
|
|
@@ -270,7 +270,7 @@ async function _e() {
|
|
|
270
270
|
} catch {
|
|
271
271
|
return "DEV1";
|
|
272
272
|
}
|
|
273
|
-
},
|
|
273
|
+
}, N = process.cwd(), K = (s) => {
|
|
274
274
|
const t = o.default.extname(s).toLowerCase();
|
|
275
275
|
return {
|
|
276
276
|
".html": "text/html",
|
|
@@ -283,9 +283,9 @@ async function _e() {
|
|
|
283
283
|
".svg": "image/svg+xml",
|
|
284
284
|
".ico": "image/x-icon"
|
|
285
285
|
}[t] || "application/octet-stream";
|
|
286
|
-
}, C = /* @__PURE__ */ new Map(), q = [],
|
|
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
|
-
const
|
|
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(
|
|
290
290
|
`HTTP/1.1 101 Switching Protocols\r
|
|
291
291
|
Upgrade: websocket\r
|
|
@@ -293,23 +293,23 @@ Connection: Upgrade\r
|
|
|
293
293
|
Sec-WebSocket-Accept: ${p}\r
|
|
294
294
|
\r
|
|
295
295
|
`
|
|
296
|
-
), U.has(
|
|
297
|
-
const g = U.get(
|
|
298
|
-
g && (g.delete(t), g.size === 0 && U.delete(
|
|
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 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 g = U.get(
|
|
300
|
+
const g = U.get(i);
|
|
301
301
|
g && g.delete(t);
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
-
},
|
|
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
|
-
s.on("data", (
|
|
307
|
+
s.on("data", (i) => r += i), s.on("end", () => {
|
|
308
308
|
try {
|
|
309
|
-
const { componentId:
|
|
310
|
-
C.set(
|
|
309
|
+
const { componentId: i, distPath: l, componentName: p } = JSON.parse(r);
|
|
310
|
+
C.set(i, { path: l, name: p || null });
|
|
311
311
|
const g = p ? ` (${p})` : "";
|
|
312
|
-
console.log(`β
Registered: ${
|
|
312
|
+
console.log(`β
Registered: ${i}${g} -> ${l}`), t.writeHead(200), t.end(JSON.stringify({ success: !0, registered: Array.from(C.keys()) }));
|
|
313
313
|
const O = Array.from(C.entries()).map(([P, H]) => ({
|
|
314
314
|
id: P,
|
|
315
315
|
path: H.path,
|
|
@@ -326,16 +326,16 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
326
326
|
} catch {
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
|
-
} catch (
|
|
330
|
-
t.writeHead(400), t.end(JSON.stringify({ error:
|
|
329
|
+
} catch (i) {
|
|
330
|
+
t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
} else if (s.method === "POST" && s.url === "/_unregister") {
|
|
334
334
|
let r = "";
|
|
335
|
-
s.on("data", (
|
|
335
|
+
s.on("data", (i) => r += i), s.on("end", () => {
|
|
336
336
|
try {
|
|
337
|
-
const { componentId:
|
|
338
|
-
C.delete(
|
|
337
|
+
const { componentId: i } = JSON.parse(r);
|
|
338
|
+
C.delete(i), console.log(`β Unregistered: ${i}`), t.writeHead(200), t.end(JSON.stringify({ success: !0 }));
|
|
339
339
|
const l = Array.from(C.entries()).map(([p, g]) => ({
|
|
340
340
|
id: p,
|
|
341
341
|
path: g.path,
|
|
@@ -352,24 +352,24 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
352
352
|
} catch {
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
|
-
} catch (
|
|
356
|
-
t.writeHead(400), t.end(JSON.stringify({ error:
|
|
355
|
+
} catch (i) {
|
|
356
|
+
t.writeHead(400), t.end(JSON.stringify({ error: i.message }));
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
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
|
-
}), ee =
|
|
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:${f}`),
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
368
|
-
if (!
|
|
365
|
+
const r = new URL(s.url, `http://localhost:${f}`), i = r.pathname, l = i.split("/").filter((_) => _);
|
|
366
|
+
if (i.startsWith("/consume")) {
|
|
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 = C.get(
|
|
372
|
+
const R = C.get(_), J = R ? R.path : null, Oe = (W) => {
|
|
373
373
|
let $ = "Unknown", T = "Unknown";
|
|
374
374
|
if (s.headers.referer || s.headers.referrer) {
|
|
375
375
|
const I = s.headers.referer || s.headers.referrer;
|
|
@@ -390,9 +390,9 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
390
390
|
const I = s.socket.remoteAddress;
|
|
391
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 || $,
|
|
393
|
+
const pe = s.headers.referer || s.headers.referrer || $, ne = {
|
|
394
394
|
type: "request",
|
|
395
|
-
componentId:
|
|
395
|
+
componentId: _,
|
|
396
396
|
timestamp: Date.now(),
|
|
397
397
|
servedLocally: W,
|
|
398
398
|
referrer: pe,
|
|
@@ -415,8 +415,8 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
415
415
|
} catch {
|
|
416
416
|
}
|
|
417
417
|
}));
|
|
418
|
-
const
|
|
419
|
-
|
|
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(
|
|
429
|
+
}), q.push(ne), q.length > Ae && q.shift(), D.forEach((I) => {
|
|
430
430
|
try {
|
|
431
|
-
I.write(`data: ${JSON.stringify(
|
|
431
|
+
I.write(`data: ${JSON.stringify(ne)}
|
|
432
432
|
|
|
433
433
|
`);
|
|
434
434
|
} catch {
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
};
|
|
438
|
-
if (
|
|
439
|
-
const W = o.default.join(
|
|
438
|
+
if (J) {
|
|
439
|
+
const W = o.default.join(J, "index.html");
|
|
440
440
|
e.default.readFile(W, "utf-8", ($, T) => {
|
|
441
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)}`,
|
|
445
|
+
const pe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ne = {
|
|
446
446
|
item: {
|
|
447
|
-
name:
|
|
448
|
-
id:
|
|
447
|
+
name: _,
|
|
448
|
+
id: _,
|
|
449
449
|
consume_variant: [
|
|
450
450
|
{
|
|
451
451
|
id: pe,
|
|
@@ -459,15 +459,15 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
459
459
|
]
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
|
-
console.log(`β
Serving consume JSON for: ${
|
|
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(
|
|
465
|
+
}), t.end(JSON.stringify(ne, null, 2));
|
|
466
466
|
});
|
|
467
467
|
} else {
|
|
468
|
-
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${
|
|
468
|
+
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${_}`);
|
|
469
469
|
const W = `https://cloud.myop.dev/consume${r.search}`;
|
|
470
|
-
|
|
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": "*"
|
|
@@ -478,21 +478,21 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
478
478
|
}
|
|
479
479
|
return;
|
|
480
480
|
}
|
|
481
|
-
if (
|
|
481
|
+
if (i === "/events") {
|
|
482
482
|
t.writeHead(200, {
|
|
483
483
|
"Content-Type": "text/event-stream",
|
|
484
484
|
"Cache-Control": "no-cache",
|
|
485
485
|
Connection: "keep-alive",
|
|
486
486
|
"Access-Control-Allow-Origin": "*"
|
|
487
487
|
}), D.push(t);
|
|
488
|
-
const
|
|
488
|
+
const _ = Array.from(C.entries()).map(([R, J]) => ({
|
|
489
489
|
id: R,
|
|
490
|
-
path:
|
|
491
|
-
name:
|
|
490
|
+
path: J.path,
|
|
491
|
+
name: J.name
|
|
492
492
|
}));
|
|
493
493
|
t.write(`data: ${JSON.stringify({
|
|
494
494
|
type: "components",
|
|
495
|
-
components:
|
|
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(
|
|
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") {
|
|
@@ -528,24 +528,24 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
528
528
|
t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`Component not found: ${p}`);
|
|
529
529
|
return;
|
|
530
530
|
}
|
|
531
|
-
const O = g.path, P = l.slice(2), H = P.length === 0 ? "index.html" : P.join("/"),
|
|
532
|
-
console.log(`π₯ Request: ${s.url} -> ${
|
|
533
|
-
if (
|
|
534
|
-
console.log(`β File 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
|
|
538
|
-
console.log(`β
Serving: ${
|
|
539
|
-
"Content-Type":
|
|
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
|
});
|
|
543
543
|
}), ve = () => new Promise((s, t) => {
|
|
544
544
|
const r = JSON.stringify({
|
|
545
545
|
componentId: v,
|
|
546
|
-
distPath: o.default.resolve(
|
|
546
|
+
distPath: o.default.resolve(N, w),
|
|
547
547
|
componentName: E
|
|
548
|
-
}),
|
|
548
|
+
}), i = {
|
|
549
549
|
hostname: "localhost",
|
|
550
550
|
port: y,
|
|
551
551
|
path: "/_register",
|
|
@@ -554,15 +554,15 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
554
554
|
"Content-Type": "application/json",
|
|
555
555
|
"Content-Length": Buffer.byteLength(r)
|
|
556
556
|
}
|
|
557
|
-
}, l =
|
|
557
|
+
}, l = a.default.request(i, (p) => {
|
|
558
558
|
let g = "";
|
|
559
559
|
p.on("data", (O) => g += O), p.on("end", () => {
|
|
560
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
|
-
}),
|
|
565
|
-
const r = JSON.stringify({ componentId: v }),
|
|
564
|
+
}), He = () => new Promise((s, t) => {
|
|
565
|
+
const r = JSON.stringify({ componentId: v }), i = {
|
|
566
566
|
hostname: "localhost",
|
|
567
567
|
port: y,
|
|
568
568
|
path: "/_unregister",
|
|
@@ -571,18 +571,18 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
571
571
|
"Content-Type": "application/json",
|
|
572
572
|
"Content-Length": Buffer.byteLength(r)
|
|
573
573
|
}
|
|
574
|
-
}, l =
|
|
574
|
+
}, l = a.default.request(i, (p) => {
|
|
575
575
|
s();
|
|
576
576
|
});
|
|
577
577
|
l.on("error", () => s()), l.write(r), l.end();
|
|
578
|
-
}),
|
|
578
|
+
}), Le = () => {
|
|
579
579
|
if (!h) return;
|
|
580
580
|
const s = o.default.join(w, "index.html");
|
|
581
581
|
try {
|
|
582
582
|
let t = e.default.readFileSync(s, "utf-8");
|
|
583
583
|
if (t.includes("<!-- MYOP HMR -->")) {
|
|
584
|
-
const
|
|
585
|
-
t = t.slice(0,
|
|
584
|
+
const i = t.indexOf("<!-- MYOP HMR -->"), l = t.indexOf("<\/script>", i) + 9;
|
|
585
|
+
t = t.slice(0, i) + t.slice(l);
|
|
586
586
|
}
|
|
587
587
|
const r = `
|
|
588
588
|
<!-- MYOP HMR -->
|
|
@@ -696,25 +696,25 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
696
696
|
}
|
|
697
697
|
}, Je = (s) => {
|
|
698
698
|
const t = Buffer.from(s), r = t.length;
|
|
699
|
-
let
|
|
700
|
-
return r < 126 ?
|
|
699
|
+
let i;
|
|
700
|
+
return r < 126 ? i = Buffer.concat([
|
|
701
701
|
Buffer.from([129, r]),
|
|
702
702
|
// FIN + text frame, length
|
|
703
703
|
t
|
|
704
|
-
]) : r < 65536 ?
|
|
704
|
+
]) : r < 65536 ? i = Buffer.concat([
|
|
705
705
|
Buffer.from([129, 126]),
|
|
706
706
|
// FIN + text frame, extended length
|
|
707
707
|
Buffer.from([r >> 8, r & 255]),
|
|
708
708
|
// 16-bit length
|
|
709
709
|
t
|
|
710
|
-
]) :
|
|
710
|
+
]) : i = Buffer.concat([
|
|
711
711
|
Buffer.from([129, 127]),
|
|
712
712
|
// FIN + text frame, extended length
|
|
713
713
|
Buffer.from([0, 0, 0, 0, r >> 24, r >> 16 & 255, r >> 8 & 255, r & 255]),
|
|
714
714
|
// 64-bit length
|
|
715
715
|
t
|
|
716
|
-
]),
|
|
717
|
-
},
|
|
716
|
+
]), i;
|
|
717
|
+
}, Ue = () => {
|
|
718
718
|
if (!h) return;
|
|
719
719
|
const s = U.get(v);
|
|
720
720
|
if (!s || s.size === 0)
|
|
@@ -727,10 +727,10 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
727
727
|
const p = r.indexOf("<!-- MYOP HMR -->"), g = r.indexOf("<\/script>", p) + 9;
|
|
728
728
|
r = r.slice(0, p) + r.slice(g);
|
|
729
729
|
}
|
|
730
|
-
const
|
|
730
|
+
const i = JSON.stringify({
|
|
731
731
|
type: "update",
|
|
732
732
|
html: r
|
|
733
|
-
}), l = Je(
|
|
733
|
+
}), l = Je(i);
|
|
734
734
|
s.forEach((p) => {
|
|
735
735
|
try {
|
|
736
736
|
p.write(l);
|
|
@@ -741,73 +741,86 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
741
741
|
} catch (r) {
|
|
742
742
|
console.error("β Failed to read HTML for HMR:", r.message);
|
|
743
743
|
}
|
|
744
|
-
}
|
|
744
|
+
};
|
|
745
|
+
let xe = !1;
|
|
746
|
+
const te = () => {
|
|
745
747
|
if (j) {
|
|
746
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
|
|
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
|
-
},
|
|
766
|
+
}, Se = /* @__PURE__ */ new Set(), be = (s) => {
|
|
754
767
|
e.default.readdir(s, { withFileTypes: !0 }, (t, r) => {
|
|
755
|
-
t || (r.forEach((
|
|
756
|
-
const l = o.default.join(s,
|
|
757
|
-
if (
|
|
758
|
-
|
|
759
|
-
else if (
|
|
760
|
-
const p = o.default.extname(
|
|
768
|
+
t || (r.forEach((i) => {
|
|
769
|
+
const l = o.default.join(s, i.name);
|
|
770
|
+
if (i.isDirectory())
|
|
771
|
+
i.name !== "node_modules" && i.name !== "dist" && !i.name.startsWith(".") && be(l);
|
|
772
|
+
else if (i.isFile()) {
|
|
773
|
+
const p = o.default.extname(i.name);
|
|
761
774
|
if (p === ".js" || p === ".css" || p === ".html")
|
|
762
775
|
try {
|
|
763
776
|
const g = e.default.readFileSync(l, "utf-8");
|
|
764
|
-
|
|
777
|
+
k.set(l, g);
|
|
765
778
|
} catch {
|
|
766
779
|
}
|
|
767
780
|
}
|
|
768
|
-
}),
|
|
781
|
+
}), Se.has(s) || (Se.add(s), e.default.watch(s, (i, l) => {
|
|
769
782
|
if (!l) return;
|
|
770
783
|
const p = o.default.extname(l);
|
|
771
784
|
if (p !== ".js" && p !== ".css" && p !== ".html") return;
|
|
772
785
|
const g = o.default.join(s, l);
|
|
773
786
|
setTimeout(() => {
|
|
774
787
|
try {
|
|
775
|
-
const O = e.default.readFileSync(g, "utf-8"), P =
|
|
776
|
-
O !== P && (
|
|
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
|
-
},
|
|
795
|
+
}, Ce = () => {
|
|
783
796
|
console.log(`
|
|
784
|
-
π¨ Component: ${v}`),
|
|
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
|
-
},
|
|
799
|
+
}, Be = () => new Promise((s) => {
|
|
787
800
|
const t = {
|
|
788
801
|
hostname: "localhost",
|
|
789
802
|
port: y,
|
|
790
803
|
path: "/_list",
|
|
791
804
|
method: "GET",
|
|
792
805
|
timeout: 1e3
|
|
793
|
-
}, r =
|
|
806
|
+
}, r = a.default.request(t, (i) => {
|
|
794
807
|
s(!0);
|
|
795
808
|
});
|
|
796
809
|
r.on("error", () => s(!1)), r.on("timeout", () => {
|
|
797
810
|
r.destroy(), s(!1);
|
|
798
811
|
}), r.end();
|
|
799
|
-
}),
|
|
800
|
-
const t =
|
|
801
|
-
if (
|
|
812
|
+
}), ze = () => new Promise((s) => {
|
|
813
|
+
const t = a.default.createServer((r, i) => {
|
|
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
818
|
const { componentId: p, distPath: g, componentName: O } = JSON.parse(l);
|
|
806
819
|
C.set(p, { path: g, name: O || null });
|
|
807
820
|
const P = O ? ` (${O})` : "";
|
|
808
|
-
console.log(`β
Registered: ${p}${P} -> ${g}`),
|
|
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
|
}
|
|
812
825
|
});
|
|
813
826
|
} else if (r.method === "POST" && r.url === "/_unregister") {
|
|
@@ -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
|
-
C.delete(p), console.log(`β Unregistered: ${p}`),
|
|
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" ? (
|
|
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);
|
|
@@ -830,7 +843,7 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
830
843
|
t.close(), s(!1);
|
|
831
844
|
}), ee.listen(f, () => {
|
|
832
845
|
console.log(`π‘ Main server running at http://localhost:${f}`), C.set(v, {
|
|
833
|
-
path: o.default.resolve(
|
|
846
|
+
path: o.default.resolve(N, w),
|
|
834
847
|
name: E
|
|
835
848
|
});
|
|
836
849
|
const r = E ? ` (${E})` : "";
|
|
@@ -838,52 +851,52 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
838
851
|
});
|
|
839
852
|
});
|
|
840
853
|
});
|
|
841
|
-
let
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
await
|
|
845
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
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}`),
|
|
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
|
-
},
|
|
866
|
+
}, Me = async () => {
|
|
854
867
|
console.log(`
|
|
855
868
|
|
|
856
|
-
π Shutting down...`),
|
|
869
|
+
π Shutting down...`), oe && clearInterval(oe), await He(), process.exit(0);
|
|
857
870
|
};
|
|
858
|
-
process.on("SIGINT",
|
|
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:${f}/view/${v}/`), console.log(`π All registered components: ${t.registered.join(", ")}`),
|
|
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
|
-
}),
|
|
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
888
|
}), ee.listen(f, async () => {
|
|
876
889
|
console.log(`π‘ Main server running at http://localhost:${f}`), (v === "DEV" || v === "NEW") && (v = "DEV1"), C.set(v, {
|
|
877
|
-
path: o.default.resolve(
|
|
890
|
+
path: o.default.resolve(N, w),
|
|
878
891
|
name: E
|
|
879
892
|
});
|
|
880
893
|
const s = E ? ` (${E})` : "";
|
|
881
|
-
console.log(`β
Registered component: ${v}${s}`), console.log(`π‘ Access at: http://localhost:${f}/view/${v}/`),
|
|
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(
|
|
886
|
-
function
|
|
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() {
|
|
@@ -896,8 +909,8 @@ function he() {
|
|
|
896
909
|
return console.info("Failed to read credentials:", e.message), null;
|
|
897
910
|
}
|
|
898
911
|
}
|
|
899
|
-
function
|
|
900
|
-
|
|
912
|
+
function Te(e) {
|
|
913
|
+
it();
|
|
901
914
|
const o = {
|
|
902
915
|
...e,
|
|
903
916
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -907,14 +920,14 @@ function Ne(e) {
|
|
|
907
920
|
// Read/write for owner only
|
|
908
921
|
});
|
|
909
922
|
}
|
|
910
|
-
function
|
|
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
|
|
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",
|
|
931
|
-
function
|
|
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
|
|
947
|
+
function dt(e) {
|
|
935
948
|
return fe.createHash("sha256").update(e).digest("base64url");
|
|
936
949
|
}
|
|
937
|
-
async function
|
|
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:
|
|
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
|
|
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"/>
|
|
@@ -1104,7 +1117,7 @@ function ne(e, o, n, i = null) {
|
|
|
1104
1117
|
</div>
|
|
1105
1118
|
<h1>${o}</h1>
|
|
1106
1119
|
<p class="message">${n}</p>
|
|
1107
|
-
${
|
|
1120
|
+
${a ? `<div class="details"><code>Error:</code> ${a}</div>` : ""}
|
|
1108
1121
|
<div class="hint">
|
|
1109
1122
|
<span>Press</span>
|
|
1110
1123
|
<kbd>β</kbd><kbd>W</kbd>
|
|
@@ -1117,59 +1130,59 @@ function ne(e, o, n, i = null) {
|
|
|
1117
1130
|
</body>
|
|
1118
1131
|
</html>`;
|
|
1119
1132
|
}
|
|
1120
|
-
function
|
|
1133
|
+
function mt(e) {
|
|
1121
1134
|
return new Promise((o, n) => {
|
|
1122
|
-
const
|
|
1123
|
-
const m = new
|
|
1135
|
+
const a = Ge.createServer((u, c) => {
|
|
1136
|
+
const m = new je(u.url, `http://localhost:${ie}`);
|
|
1124
1137
|
if (m.pathname === "/callback") {
|
|
1125
1138
|
const x = m.searchParams.get("code"), b = m.searchParams.get("state"), f = m.searchParams.get("error");
|
|
1126
1139
|
if (f) {
|
|
1127
|
-
c.writeHead(200, { "Content-Type": "text/html" }), c.end(
|
|
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
1144
|
f
|
|
1132
|
-
)),
|
|
1145
|
+
)), a.close(), n(new Error(`OAuth error: ${f}`));
|
|
1133
1146
|
return;
|
|
1134
1147
|
}
|
|
1135
1148
|
if (b !== e) {
|
|
1136
|
-
c.writeHead(400, { "Content-Type": "text/html" }), c.end(
|
|
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.",
|
|
1140
1153
|
"state_mismatch"
|
|
1141
|
-
)),
|
|
1154
|
+
)), a.close(), n(new Error("State mismatch"));
|
|
1142
1155
|
return;
|
|
1143
1156
|
}
|
|
1144
1157
|
if (!x) {
|
|
1145
|
-
c.writeHead(400, { "Content-Type": "text/html" }), c.end(
|
|
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.",
|
|
1149
1162
|
"missing_code"
|
|
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(
|
|
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
|
-
)),
|
|
1170
|
+
)), a.close(), o(x);
|
|
1158
1171
|
} else
|
|
1159
1172
|
c.writeHead(404), c.end("Not found");
|
|
1160
1173
|
});
|
|
1161
|
-
|
|
1162
|
-
console.info(`OAuth callback server listening on port ${
|
|
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
|
|
1169
|
-
const
|
|
1181
|
+
async function ut(e, o, n) {
|
|
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
|
|
1185
|
+
body: new Pe({
|
|
1173
1186
|
grant_type: "authorization_code",
|
|
1174
1187
|
code: e,
|
|
1175
1188
|
client_id: o,
|
|
@@ -1177,29 +1190,29 @@ async function mt(e, o, n) {
|
|
|
1177
1190
|
code_verifier: n
|
|
1178
1191
|
})
|
|
1179
1192
|
});
|
|
1180
|
-
if (!
|
|
1181
|
-
const u = await
|
|
1193
|
+
if (!a.ok) {
|
|
1194
|
+
const u = await a.json();
|
|
1182
1195
|
throw new Error(u.error_description || u.error || "Token exchange failed");
|
|
1183
1196
|
}
|
|
1184
|
-
return
|
|
1197
|
+
return a.json();
|
|
1185
1198
|
}
|
|
1186
|
-
async function
|
|
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
|
|
1203
|
+
body: new Pe({
|
|
1191
1204
|
grant_type: "refresh_token",
|
|
1192
1205
|
refresh_token: e,
|
|
1193
1206
|
client_id: o
|
|
1194
1207
|
})
|
|
1195
1208
|
});
|
|
1196
1209
|
if (!n.ok) {
|
|
1197
|
-
const
|
|
1198
|
-
throw new Error(
|
|
1210
|
+
const a = await n.json();
|
|
1211
|
+
throw new Error(a.error_description || a.error || "Token refresh failed");
|
|
1199
1212
|
}
|
|
1200
1213
|
return n.json();
|
|
1201
1214
|
}
|
|
1202
|
-
async function
|
|
1215
|
+
async function gt(e) {
|
|
1203
1216
|
var u, c, m;
|
|
1204
1217
|
const o = await fetch(`${Y}/mcp`, {
|
|
1205
1218
|
method: "POST",
|
|
@@ -1222,26 +1235,26 @@ async function ft(e) {
|
|
|
1222
1235
|
const n = await o.json();
|
|
1223
1236
|
if (n.error)
|
|
1224
1237
|
throw new Error(n.error.message);
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
return JSON.parse(
|
|
1238
|
+
const a = (m = (c = (u = n.result) == null ? void 0 : u.content) == null ? void 0 : c[0]) == null ? void 0 : m.text;
|
|
1239
|
+
if (a)
|
|
1240
|
+
return JSON.parse(a);
|
|
1228
1241
|
throw new Error("Invalid response from whoami");
|
|
1229
1242
|
}
|
|
1230
1243
|
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
|
|
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 =
|
|
1249
|
+
const m = mt(c), x = new je(`${Y}/oauth/authorize`);
|
|
1237
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(`
|
|
1238
1251
|
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${x.toString()}
|
|
1239
|
-
`), await
|
|
1252
|
+
`), await Ye(x.toString());
|
|
1240
1253
|
const b = await m;
|
|
1241
1254
|
e.start("Exchanging authorization code...");
|
|
1242
|
-
const f = await
|
|
1255
|
+
const f = await ut(b, n, a);
|
|
1243
1256
|
e.text = "Getting user info...";
|
|
1244
|
-
const y = await
|
|
1257
|
+
const y = await gt(f.access_token), w = {
|
|
1245
1258
|
accessToken: f.access_token,
|
|
1246
1259
|
refreshToken: f.refresh_token,
|
|
1247
1260
|
expiresAt: new Date(Date.now() + f.expires_in * 1e3).toISOString(),
|
|
@@ -1249,30 +1262,30 @@ async function X() {
|
|
|
1249
1262
|
userId: y.userId,
|
|
1250
1263
|
userEmail: y.email
|
|
1251
1264
|
};
|
|
1252
|
-
return
|
|
1265
|
+
return Te(w), e.succeed(`Authenticated as ${y.email}`), w;
|
|
1253
1266
|
} catch (o) {
|
|
1254
1267
|
throw e.fail(`Authentication failed: ${o.message}`), o;
|
|
1255
1268
|
}
|
|
1256
1269
|
}
|
|
1257
|
-
async function
|
|
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
|
-
|
|
1276
|
+
Re(), console.log(`β
Logged out (was: ${e.userEmail})`);
|
|
1264
1277
|
}
|
|
1265
|
-
async function
|
|
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 (!
|
|
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
|
|
1288
|
+
const n = await ft(
|
|
1276
1289
|
e.refreshToken,
|
|
1277
1290
|
e.clientId
|
|
1278
1291
|
);
|
|
@@ -1281,48 +1294,48 @@ async function gt() {
|
|
|
1281
1294
|
accessToken: n.access_token,
|
|
1282
1295
|
refreshToken: n.refresh_token,
|
|
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"),
|
|
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
|
|
1305
|
+
function yt() {
|
|
1293
1306
|
return Y;
|
|
1294
1307
|
}
|
|
1295
|
-
const
|
|
1296
|
-
async function
|
|
1308
|
+
const ae = "@myop/cli";
|
|
1309
|
+
async function wt() {
|
|
1297
1310
|
try {
|
|
1298
|
-
const e = await fetch(`https://registry.npmjs.org/${
|
|
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
|
|
1305
|
-
const n = e.split(".").map(Number),
|
|
1306
|
-
for (let u = 0; u < Math.max(n.length,
|
|
1307
|
-
const c = n[u] || 0, m =
|
|
1317
|
+
function vt(e, o) {
|
|
1318
|
+
const n = e.split(".").map(Number), a = o.split(".").map(Number);
|
|
1319
|
+
for (let u = 0; u < Math.max(n.length, a.length); u++) {
|
|
1320
|
+
const c = n[u] || 0, m = a[u] || 0;
|
|
1308
1321
|
if (c > m) return 1;
|
|
1309
1322
|
if (c < m) return -1;
|
|
1310
1323
|
}
|
|
1311
1324
|
return 0;
|
|
1312
1325
|
}
|
|
1313
|
-
async function
|
|
1326
|
+
async function xt(e) {
|
|
1314
1327
|
const o = F({
|
|
1315
1328
|
text: "Checking for updates...",
|
|
1316
1329
|
color: "cyan"
|
|
1317
|
-
}).start(), n = await
|
|
1318
|
-
if (o.stop(), !n ||
|
|
1330
|
+
}).start(), n = await wt();
|
|
1331
|
+
if (o.stop(), !n || vt(n, e) <= 0)
|
|
1319
1332
|
return !1;
|
|
1320
1333
|
console.log(`
|
|
1321
1334
|
π¦ New version available: ${e} β ${n}
|
|
1322
1335
|
`);
|
|
1323
|
-
let
|
|
1336
|
+
let a;
|
|
1324
1337
|
try {
|
|
1325
|
-
|
|
1338
|
+
a = await Ie({
|
|
1326
1339
|
message: "Would you like to update now?",
|
|
1327
1340
|
choices: [
|
|
1328
1341
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1335,26 +1348,26 @@ async function vt(e) {
|
|
|
1335
1348
|
π Goodbye!
|
|
1336
1349
|
`), process.exit(0)), u;
|
|
1337
1350
|
}
|
|
1338
|
-
if (
|
|
1351
|
+
if (a) {
|
|
1339
1352
|
const u = F({
|
|
1340
|
-
text: `Updating ${
|
|
1353
|
+
text: `Updating ${ae} to v${n}...`,
|
|
1341
1354
|
color: "green"
|
|
1342
1355
|
}).start();
|
|
1343
1356
|
try {
|
|
1344
|
-
|
|
1357
|
+
re(`npm install -g ${ae}@latest`, { stdio: "pipe" }), u.succeed(`Updated to v${n}`), console.log(`
|
|
1345
1358
|
Please restart the CLI to use the new version.
|
|
1346
1359
|
`), process.exit(0);
|
|
1347
1360
|
} catch {
|
|
1348
1361
|
return u.fail("Update failed"), console.log(`
|
|
1349
|
-
You can manually update by running: npm install -g ${
|
|
1362
|
+
You can manually update by running: npm install -g ${ae}@latest
|
|
1350
1363
|
`), !1;
|
|
1351
1364
|
}
|
|
1352
1365
|
}
|
|
1353
1366
|
return !1;
|
|
1354
1367
|
}
|
|
1355
|
-
const
|
|
1368
|
+
const St = (e) => new Promise((o) => setTimeout(o, e));
|
|
1356
1369
|
d.executionPath = process.cwd();
|
|
1357
|
-
const
|
|
1370
|
+
const le = (e = !1) => {
|
|
1358
1371
|
const o = d.program.getOptionValue("verbose");
|
|
1359
1372
|
o || (console.info = () => {
|
|
1360
1373
|
}), console.info("π verbose mode on"), d.options = {
|
|
@@ -1362,17 +1375,17 @@ const ce = (e = !1) => {
|
|
|
1362
1375
|
verbose: o
|
|
1363
1376
|
};
|
|
1364
1377
|
try {
|
|
1365
|
-
return d.myopConfig =
|
|
1378
|
+
return d.myopConfig = Qe(d.options.configPath), { configFound: !0 };
|
|
1366
1379
|
} catch (n) {
|
|
1367
1380
|
if (e) {
|
|
1368
1381
|
console.info(`
|
|
1369
1382
|
β οΈ failed read config file from ${d.options.configPath}, trying to create new one`);
|
|
1370
1383
|
try {
|
|
1371
|
-
const
|
|
1384
|
+
const a = {
|
|
1372
1385
|
author: "@myop-cli",
|
|
1373
1386
|
flows: []
|
|
1374
1387
|
};
|
|
1375
|
-
return ge(d.options.configPath,
|
|
1388
|
+
return ge(d.options.configPath, a), d.myopConfig = a, { configFound: !0 };
|
|
1376
1389
|
} catch {
|
|
1377
1390
|
return console.info("Error details :", n), { configFound: !1, error: n };
|
|
1378
1391
|
}
|
|
@@ -1382,23 +1395,23 @@ const ce = (e = !1) => {
|
|
|
1382
1395
|
};
|
|
1383
1396
|
[
|
|
1384
1397
|
new me(),
|
|
1385
|
-
...
|
|
1398
|
+
...st
|
|
1386
1399
|
];
|
|
1387
|
-
const
|
|
1388
|
-
d.program = new
|
|
1389
|
-
d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(
|
|
1390
|
-
d.program.addOption(new
|
|
1391
|
-
d.program.addOption(new
|
|
1392
|
-
d.program.addOption(new
|
|
1393
|
-
d.program.addOption(new
|
|
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"));
|
|
1394
1407
|
d.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((e, o) => {
|
|
1395
|
-
|
|
1408
|
+
le(!0), console.info("adding ", e, o, d.options.configPath), e === "flow" && Ee._action(o), process.exit();
|
|
1396
1409
|
});
|
|
1397
1410
|
d.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((e, o) => {
|
|
1398
|
-
|
|
1411
|
+
le(), console.info("removing ", e, o, d.options.configPath), e === "flow" && Ne._action(o), process.exit();
|
|
1399
1412
|
});
|
|
1400
1413
|
d.program.command("install").description("Install Myop assets").action(async () => {
|
|
1401
|
-
|
|
1414
|
+
le(), await _e.action();
|
|
1402
1415
|
});
|
|
1403
1416
|
d.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1404
1417
|
try {
|
|
@@ -1409,15 +1422,15 @@ d.program.command("login").description("Authenticate with Myop platform").action
|
|
|
1409
1422
|
process.exit(0);
|
|
1410
1423
|
});
|
|
1411
1424
|
d.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1412
|
-
await
|
|
1425
|
+
await Fe(), process.exit(0);
|
|
1413
1426
|
});
|
|
1414
1427
|
d.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1415
1428
|
const e = ye();
|
|
1416
1429
|
e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
|
|
1417
1430
|
});
|
|
1418
1431
|
d.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (e) => {
|
|
1419
|
-
var j, S,
|
|
1420
|
-
const o = d.program.getOptionValue("config") || "./myop.config.json", n = await import("fs"), { execSync:
|
|
1432
|
+
var j, S, k, z, v, E;
|
|
1433
|
+
const o = d.program.getOptionValue("config") || "./myop.config.json", n = await import("fs"), { execSync: a } = await import("child_process"), u = await import("path");
|
|
1421
1434
|
let c = {};
|
|
1422
1435
|
if (n.existsSync(o))
|
|
1423
1436
|
try {
|
|
@@ -1433,7 +1446,7 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1433
1446
|
if (!e.skipBuild) {
|
|
1434
1447
|
const h = F("Building project...").start();
|
|
1435
1448
|
try {
|
|
1436
|
-
|
|
1449
|
+
a("npm run build", { stdio: "pipe" }), h.succeed("Build completed");
|
|
1437
1450
|
} catch (M) {
|
|
1438
1451
|
h.fail("Build failed"), console.error(M.message), process.exit(1);
|
|
1439
1452
|
}
|
|
@@ -1442,11 +1455,11 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1442
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));
|
|
1443
1456
|
let x;
|
|
1444
1457
|
try {
|
|
1445
|
-
x = await
|
|
1458
|
+
x = await ht();
|
|
1446
1459
|
} catch (h) {
|
|
1447
1460
|
console.error("β Authentication failed:", h.message), process.exit(1);
|
|
1448
1461
|
}
|
|
1449
|
-
const b =
|
|
1462
|
+
const b = yt();
|
|
1450
1463
|
let f = F("Requesting upload URL...").start(), y;
|
|
1451
1464
|
try {
|
|
1452
1465
|
const h = await fetch(`${b}/mcp`, {
|
|
@@ -1474,8 +1487,8 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1474
1487
|
const M = await h.json();
|
|
1475
1488
|
if (M.error)
|
|
1476
1489
|
throw new Error(M.error.message);
|
|
1477
|
-
const
|
|
1478
|
-
if (y = JSON.parse(
|
|
1490
|
+
const N = (k = (S = (j = M.result) == null ? void 0 : j.content) == null ? void 0 : S[0]) == null ? void 0 : k.text;
|
|
1491
|
+
if (y = JSON.parse(N), !y.success)
|
|
1479
1492
|
throw new Error(y.error);
|
|
1480
1493
|
f.succeed("Upload URL obtained");
|
|
1481
1494
|
} catch (h) {
|
|
@@ -1485,9 +1498,9 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1485
1498
|
try {
|
|
1486
1499
|
const h = n.readFileSync(m, "utf-8");
|
|
1487
1500
|
let M;
|
|
1488
|
-
const
|
|
1489
|
-
if (
|
|
1490
|
-
M =
|
|
1501
|
+
const N = y.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
1502
|
+
if (N)
|
|
1503
|
+
M = N[1];
|
|
1491
1504
|
else {
|
|
1492
1505
|
const C = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
1493
1506
|
if (C)
|
|
@@ -1537,8 +1550,8 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1537
1550
|
const M = await h.json();
|
|
1538
1551
|
if (M.error)
|
|
1539
1552
|
throw new Error(M.error.message);
|
|
1540
|
-
const
|
|
1541
|
-
if (w = JSON.parse(
|
|
1553
|
+
const N = (E = (v = (z = M.result) == null ? void 0 : z.content) == null ? void 0 : v[0]) == null ? void 0 : E.text;
|
|
1554
|
+
if (w = JSON.parse(N), !w.success)
|
|
1542
1555
|
throw new Error(w.error);
|
|
1543
1556
|
f.succeed("Upload confirmed");
|
|
1544
1557
|
} catch (h) {
|
|
@@ -1557,20 +1570,20 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1557
1570
|
console.log(`
|
|
1558
1571
|
β
Sync completed successfully!`), console.log(` Component: ${w.componentName}`), console.log(` Dashboard: ${w.dashboardUrl}`), process.exit(0);
|
|
1559
1572
|
});
|
|
1560
|
-
d.program.command("dev").description("Start development server with file watching").action(
|
|
1561
|
-
const
|
|
1573
|
+
d.program.command("dev").description("Start development server with file watching").action(ke);
|
|
1574
|
+
const Ct = () => {
|
|
1562
1575
|
try {
|
|
1563
|
-
|
|
1576
|
+
re("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
1564
1577
|
} catch {
|
|
1565
1578
|
return { gitNotInstalled: !0 };
|
|
1566
1579
|
}
|
|
1567
1580
|
try {
|
|
1568
|
-
|
|
1581
|
+
re("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
1569
1582
|
} catch {
|
|
1570
1583
|
return { notARepo: !0 };
|
|
1571
1584
|
}
|
|
1572
1585
|
try {
|
|
1573
|
-
const e =
|
|
1586
|
+
const e = re("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
|
|
1574
1587
|
encoding: "utf-8",
|
|
1575
1588
|
stdio: ["pipe", "pipe", "pipe"]
|
|
1576
1589
|
}).trim();
|
|
@@ -1581,10 +1594,10 @@ const bt = () => {
|
|
|
1581
1594
|
deletions: 0
|
|
1582
1595
|
};
|
|
1583
1596
|
const o = e.split(`
|
|
1584
|
-
`), n = o[o.length - 1],
|
|
1597
|
+
`), n = o[o.length - 1], a = n.match(/(\d+) insertion/), u = n.match(/(\d+) deletion/), c = n.match(/(\d+) file/);
|
|
1585
1598
|
return {
|
|
1586
1599
|
files: c ? parseInt(c[1]) : 0,
|
|
1587
|
-
insertions:
|
|
1600
|
+
insertions: a ? parseInt(a[1]) : 0,
|
|
1588
1601
|
deletions: u ? parseInt(u[1]) : 0
|
|
1589
1602
|
};
|
|
1590
1603
|
} catch {
|
|
@@ -1592,10 +1605,10 @@ const bt = () => {
|
|
|
1592
1605
|
}
|
|
1593
1606
|
}, B = async (e = !1, o = !1) => {
|
|
1594
1607
|
var y, w, j;
|
|
1595
|
-
const n = ye(),
|
|
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();
|
|
1596
1609
|
console.log(`
|
|
1597
1610
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
1598
|
-
`), 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: ${
|
|
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("");
|
|
1599
1612
|
const b = [
|
|
1600
1613
|
{
|
|
1601
1614
|
emoji: "π",
|
|
@@ -1609,7 +1622,7 @@ const bt = () => {
|
|
|
1609
1622
|
label: u ? `Push "${u}"` : "Push component",
|
|
1610
1623
|
value: "sync",
|
|
1611
1624
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
1612
|
-
disabled: e ?
|
|
1625
|
+
disabled: e ? a ? !1 : "(login required)" : "(no config file)"
|
|
1613
1626
|
},
|
|
1614
1627
|
{
|
|
1615
1628
|
emoji: "π οΈ ",
|
|
@@ -1627,10 +1640,10 @@ const bt = () => {
|
|
|
1627
1640
|
b.push(
|
|
1628
1641
|
new me(),
|
|
1629
1642
|
{
|
|
1630
|
-
name: o &&
|
|
1631
|
-
Clears stored credentials from this machine` : o && !
|
|
1632
|
-
Opens browser to authenticate with Myop` :
|
|
1633
|
-
value:
|
|
1643
|
+
name: o && a ? `π Logout (${n.email})
|
|
1644
|
+
Clears stored credentials from this machine` : o && !a ? `π Login to Myop
|
|
1645
|
+
Opens browser to authenticate with Myop` : a ? `π Logout (${n.email})` : "π Login to Myop",
|
|
1646
|
+
value: a ? "logout" : "login"
|
|
1634
1647
|
},
|
|
1635
1648
|
{
|
|
1636
1649
|
name: o ? "π Hide help" : "π Show help",
|
|
@@ -1644,7 +1657,7 @@ const bt = () => {
|
|
|
1644
1657
|
);
|
|
1645
1658
|
let f;
|
|
1646
1659
|
try {
|
|
1647
|
-
f = await
|
|
1660
|
+
f = await Ie({
|
|
1648
1661
|
message: "What would you like to do?",
|
|
1649
1662
|
choices: b
|
|
1650
1663
|
});
|
|
@@ -1656,7 +1669,7 @@ const bt = () => {
|
|
|
1656
1669
|
}
|
|
1657
1670
|
switch (f) {
|
|
1658
1671
|
case "init":
|
|
1659
|
-
await
|
|
1672
|
+
await $t();
|
|
1660
1673
|
break;
|
|
1661
1674
|
case "sync":
|
|
1662
1675
|
console.log(`
|
|
@@ -1670,18 +1683,18 @@ Running sync...
|
|
|
1670
1683
|
await B(!0, o);
|
|
1671
1684
|
break;
|
|
1672
1685
|
case "dev":
|
|
1673
|
-
await
|
|
1686
|
+
await ke();
|
|
1674
1687
|
break;
|
|
1675
1688
|
case "login":
|
|
1676
1689
|
try {
|
|
1677
1690
|
await X(), console.log(`
|
|
1678
1691
|
`), await B(e, o);
|
|
1679
|
-
} catch (
|
|
1680
|
-
console.error("Login failed:",
|
|
1692
|
+
} catch (k) {
|
|
1693
|
+
console.error("Login failed:", k.message), await B(e, o);
|
|
1681
1694
|
}
|
|
1682
1695
|
break;
|
|
1683
1696
|
case "logout":
|
|
1684
|
-
await
|
|
1697
|
+
await Fe(), console.log(`
|
|
1685
1698
|
`), await B(e, o);
|
|
1686
1699
|
break;
|
|
1687
1700
|
case "help":
|
|
@@ -1690,7 +1703,7 @@ Running sync...
|
|
|
1690
1703
|
case "exit":
|
|
1691
1704
|
process.exit(0);
|
|
1692
1705
|
}
|
|
1693
|
-
},
|
|
1706
|
+
}, $t = async () => {
|
|
1694
1707
|
const { input: e, select: o } = await import("@inquirer/prompts"), n = await import("fs"), u = (await import("path")).default.basename(process.cwd());
|
|
1695
1708
|
let c, m;
|
|
1696
1709
|
try {
|
|
@@ -1906,7 +1919,7 @@ p {
|
|
|
1906
1919
|
}
|
|
1907
1920
|
};
|
|
1908
1921
|
d.program.command("default", { isDefault: !0 }).action(async () => {
|
|
1909
|
-
if (d.program.getOptionValue("help") && (console.log(
|
|
1922
|
+
if (d.program.getOptionValue("help") && (console.log(Xe), process.exit()), d.program.getOptionValue("ci")) {
|
|
1910
1923
|
const c = await import("fs"), m = d.program.getOptionValue("config") || "./myop.config.json", x = d.program.version(), b = ye();
|
|
1911
1924
|
let f = { found: !1 };
|
|
1912
1925
|
try {
|
|
@@ -1937,10 +1950,10 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
1937
1950
|
text: "Loading Myop CLI...",
|
|
1938
1951
|
color: "green"
|
|
1939
1952
|
}).start();
|
|
1940
|
-
const
|
|
1941
|
-
await
|
|
1953
|
+
const a = le();
|
|
1954
|
+
await St(500), n.stop();
|
|
1942
1955
|
const u = d.program.version();
|
|
1943
|
-
await
|
|
1956
|
+
await xt(u), await B(a.configFound);
|
|
1944
1957
|
});
|
|
1945
1958
|
d.program.parse(process.argv);
|
|
1946
1959
|
d.program.opts();
|