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