@myop/cli 0.1.46 β 0.1.47
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 +760 -733
- package/dist/skills/myop-angular-host/SKILL.md +118 -1
- package/dist/skills/myop-cli/SKILL.md +147 -0
- package/dist/skills/myop-component/SKILL.md +58 -55
- package/dist/skills/myop-component/references/dev-workflow.md +3 -2
- package/dist/skills/myop-react-host/SKILL.md +143 -1
- package/dist/skills/myop-react-native-host/SKILL.md +119 -1
- package/dist/skills/myop-vue-host/SKILL.md +112 -1
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var ye = (o, t, e) =>
|
|
2
|
+
var wt = Object.defineProperty;
|
|
3
|
+
var St = (o, t, e) => t in o ? wt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
4
|
+
var ye = (o, t, e) => St(o, typeof t != "symbol" ? t + "" : t, e);
|
|
5
5
|
import Y from "ora";
|
|
6
|
-
import { select as
|
|
7
|
-
import { Command as
|
|
8
|
-
import { execSync as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { URL as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
const
|
|
6
|
+
import { select as et, Separator as _e } from "@inquirer/prompts";
|
|
7
|
+
import { Command as vt, Option as me } from "commander";
|
|
8
|
+
import { execSync as X, spawn as xt } from "child_process";
|
|
9
|
+
import _, { join as Te } from "path";
|
|
10
|
+
import M, { readFileSync as $t } from "fs";
|
|
11
|
+
import He from "crypto";
|
|
12
|
+
import bt from "http";
|
|
13
|
+
import { URL as tt, URLSearchParams as ot } from "url";
|
|
14
|
+
import Ct from "open";
|
|
15
|
+
import nt from "os";
|
|
16
|
+
const Pt = `
|
|
17
17
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
18
18
|
|
|
19
19
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -55,63 +55,63 @@ Examples:
|
|
|
55
55
|
verbose: !1
|
|
56
56
|
},
|
|
57
57
|
myopConfig: null
|
|
58
|
-
},
|
|
58
|
+
}, st = {
|
|
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
64
|
for (const o of v.myopConfig.flows) {
|
|
65
|
-
const t =
|
|
65
|
+
const t = _.join(v.executionPath, "/node_modules/@myop/flow-types/");
|
|
66
66
|
console.info(`Generate flow at ${t}`), console.info(`Generated flow at ${t}`);
|
|
67
67
|
}
|
|
68
68
|
process.exit();
|
|
69
69
|
}
|
|
70
|
-
},
|
|
71
|
-
const t =
|
|
70
|
+
}, Mt = (o) => {
|
|
71
|
+
const t = _.join(v.executionPath, o);
|
|
72
72
|
console.info(`reading config file from: ${t}`);
|
|
73
|
-
const e =
|
|
73
|
+
const e = M.readFileSync(t, "utf8"), n = JSON.parse(e);
|
|
74
74
|
return console.info("config file loaded, ", n), n;
|
|
75
|
-
},
|
|
76
|
-
const e =
|
|
75
|
+
}, Ue = (o, t) => {
|
|
76
|
+
const e = _.join(v.executionPath, o);
|
|
77
77
|
console.info(`writing config file to: ${e}`);
|
|
78
78
|
try {
|
|
79
79
|
const n = JSON.stringify(t, null, 2);
|
|
80
|
-
|
|
80
|
+
M.writeFileSync(e, n), console.info(`config file updated ${n}`);
|
|
81
81
|
} catch (n) {
|
|
82
82
|
throw console.info(`error ${n} while writing to ${e}, JSON: ${t}`), console.log(`
|
|
83
83
|
β οΈ Failed write config file to ${e}, for more info use verbose flag`), n;
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, it = {
|
|
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
|
-
v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o),
|
|
90
|
+
v.myopConfig.flows.includes(o) || v.myopConfig.flows.push(o), Ue(v.options.configPath, v.myopConfig);
|
|
91
91
|
},
|
|
92
92
|
action: async () => {
|
|
93
93
|
}
|
|
94
|
-
},
|
|
94
|
+
}, rt = {
|
|
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
|
-
v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o),
|
|
99
|
+
v.myopConfig.flows = v.myopConfig.flows.filter((t) => t !== o), Ue(v.options.configPath, v.myopConfig);
|
|
100
100
|
},
|
|
101
101
|
action: () => {
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, Et = {
|
|
104
104
|
name: "π Quit",
|
|
105
105
|
value: "quit",
|
|
106
106
|
description: "Quit and continue coding.",
|
|
107
107
|
action: () => {
|
|
108
108
|
process.exit();
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, It = {
|
|
111
111
|
name: "π’ Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
114
|
-
},
|
|
114
|
+
}, kt = {
|
|
115
115
|
name: "π΅ Create new experience",
|
|
116
116
|
value: "-",
|
|
117
117
|
disabled: "(not available yet)"
|
|
@@ -119,16 +119,16 @@ Examples:
|
|
|
119
119
|
name: "π‘ Create new skin",
|
|
120
120
|
value: "-",
|
|
121
121
|
disabled: "(not available yet)"
|
|
122
|
-
},
|
|
122
|
+
}, Rt = {
|
|
123
123
|
name: "π΄ Create new flow",
|
|
124
124
|
value: "-",
|
|
125
125
|
disabled: "(not available yet)"
|
|
126
|
-
},
|
|
126
|
+
}, Tt = {
|
|
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
|
-
},
|
|
131
|
+
}, jt = [Tt, It, kt, Ot, Rt];
|
|
132
132
|
function Ft(o, t, e, n) {
|
|
133
133
|
return `<!DOCTYPE html>
|
|
134
134
|
<html lang="en">
|
|
@@ -219,19 +219,19 @@ ${n}
|
|
|
219
219
|
</body>
|
|
220
220
|
</html>`;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function _t(o) {
|
|
223
223
|
return o.includes("esbuild") && o.includes("another platform");
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Nt(o) {
|
|
226
226
|
return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function At() {
|
|
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 Lt(o) {
|
|
235
235
|
return new Promise((t) => {
|
|
236
236
|
console.log(`π§ Attempting to fix: removing node_modules and reinstalling...
|
|
237
237
|
`);
|
|
@@ -244,9 +244,9 @@ function At(o) {
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
console.log(" β Removed node_modules"), console.log(` β³ Running npm install...
|
|
247
|
-
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i,
|
|
247
|
+
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, d, h) => {
|
|
248
248
|
if (i) {
|
|
249
|
-
console.error("β npm install failed:", i.message),
|
|
249
|
+
console.error("β npm install failed:", i.message), h && console.error(h), t(!1);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
console.log(` β Dependencies reinstalled successfully!
|
|
@@ -255,22 +255,22 @@ function At(o) {
|
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
async function
|
|
258
|
+
async function at(o, t, e, n, s = {}) {
|
|
259
259
|
const {
|
|
260
260
|
hasTriedPlatformFix: i = !1,
|
|
261
|
-
hasTriedInstall:
|
|
262
|
-
onRetry:
|
|
261
|
+
hasTriedInstall: d = !1,
|
|
262
|
+
onRetry: h
|
|
263
263
|
} = s, y = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
|
|
264
|
-
return !i &&
|
|
265
|
-
`),
|
|
266
|
-
n("npm install", (l,
|
|
264
|
+
return !i && _t(y) ? (At(), await Lt(n) && h ? (console.log(`π Retrying build...
|
|
265
|
+
`), h(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && Nt(y) ? (console.log("π¦ Missing dependencies detected, running npm install..."), new Promise((c) => {
|
|
266
|
+
n("npm install", (l, C, u) => {
|
|
267
267
|
if (l) {
|
|
268
|
-
console.error("β Failed to install dependencies:", l.message),
|
|
268
|
+
console.error("β Failed to install dependencies:", l.message), u && console.error(u), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
console.log("β
Dependencies installed"),
|
|
271
|
+
console.log("β
Dependencies installed"), h && h(), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
272
272
|
});
|
|
273
|
-
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall:
|
|
273
|
+
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: d };
|
|
274
274
|
}
|
|
275
275
|
async function xe() {
|
|
276
276
|
const o = await import("fs"), t = await import("path"), { exec: e } = await import("child_process"), n = await import("http"), { createHash: s } = await import("node:crypto");
|
|
@@ -280,9 +280,9 @@ async function xe() {
|
|
|
280
280
|
i = t.default.dirname(m);
|
|
281
281
|
} else
|
|
282
282
|
i = t.default.dirname(import.meta.url);
|
|
283
|
-
const
|
|
284
|
-
let
|
|
285
|
-
const
|
|
283
|
+
const d = t.default.join(i, "commands", "dev", "management-website"), h = o.default.readFileSync(t.default.join(d, "styles.css"), "utf-8"), y = o.default.readFileSync(t.default.join(d, "app.js"), "utf-8"), c = 9292, l = 9293;
|
|
284
|
+
let C = "./dist", u = !1, P = !1, g = !1, w = 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)
|
|
@@ -290,7 +290,7 @@ async function xe() {
|
|
|
290
290
|
} catch {
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
|
-
},
|
|
293
|
+
}, k = () => {
|
|
294
294
|
try {
|
|
295
295
|
const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
|
|
296
296
|
return !!(a.scripts && a.scripts.build);
|
|
@@ -300,19 +300,19 @@ async function xe() {
|
|
|
300
300
|
}, b = (a) => {
|
|
301
301
|
const r = process.platform;
|
|
302
302
|
let m;
|
|
303
|
-
r === "darwin" ? m = `open "${a}"` : r === "win32" ? m = `start "" "${a}"` : m = `xdg-open "${a}"`, e(m, (
|
|
303
|
+
r === "darwin" ? m = `open "${a}"` : r === "win32" ? m = `start "" "${a}"` : m = `xdg-open "${a}"`, e(m, (f) => {
|
|
304
304
|
});
|
|
305
305
|
}, p = /* @__PURE__ */ new Map(), E = v.program.getOptionValue("config") || "./myop.config.json";
|
|
306
|
-
let x,
|
|
307
|
-
w =
|
|
308
|
-
const
|
|
306
|
+
let x, O, R = !1;
|
|
307
|
+
w = j();
|
|
308
|
+
const D = k();
|
|
309
309
|
try {
|
|
310
310
|
const a = o.default.readFileSync(E, "utf-8"), r = JSON.parse(a);
|
|
311
|
-
x = r.componentId || "DEV",
|
|
311
|
+
x = r.componentId || "DEV", O = r.componentName || r.name || null, R = r.HMR === !0, w && !D && (g = !0, R = !0, console.log(`π Single HTML file mode: ${w}`)), R && console.log("π₯ HMR enabled");
|
|
312
312
|
} catch (a) {
|
|
313
|
-
w && !
|
|
313
|
+
w && !D ? (g = !0, x = "DEV", O = t.default.basename(w, ".html"), R = !0, console.log(`π Single HTML file mode: ${w}`), console.log("π₯ HMR enabled")) : (console.error("β Error reading myop.config.json:", a.message), process.exit(1));
|
|
314
314
|
}
|
|
315
|
-
const
|
|
315
|
+
const L = async () => {
|
|
316
316
|
if (x !== "DEV" && x !== "NEW")
|
|
317
317
|
return x;
|
|
318
318
|
try {
|
|
@@ -348,7 +348,7 @@ async function xe() {
|
|
|
348
348
|
} catch {
|
|
349
349
|
return "DEV1";
|
|
350
350
|
}
|
|
351
|
-
},
|
|
351
|
+
}, T = process.cwd(), J = (a) => {
|
|
352
352
|
const r = t.default.extname(a).toLowerCase();
|
|
353
353
|
return {
|
|
354
354
|
".html": "text/html",
|
|
@@ -361,9 +361,9 @@ async function xe() {
|
|
|
361
361
|
".svg": "image/svg+xml",
|
|
362
362
|
".ico": "image/x-icon"
|
|
363
363
|
}[r] || "application/octet-stream";
|
|
364
|
-
}, F = /* @__PURE__ */ new Map(), V = [], te = 50, z = [], Q = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map(),
|
|
364
|
+
}, F = /* @__PURE__ */ new Map(), V = [], te = 50, z = [], Q = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map(), ut = (a, r, m) => {
|
|
365
365
|
if (a.url.startsWith("/_hmr/")) {
|
|
366
|
-
const
|
|
366
|
+
const f = a.url.split("/_hmr/")[1], S = a.headers["sec-websocket-key"], $ = s("sha1").update(S + "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
|
|
@@ -371,23 +371,23 @@ Connection: Upgrade\r
|
|
|
371
371
|
Sec-WebSocket-Accept: ${$}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
|
-
), oe.has(
|
|
375
|
-
const I = oe.get(
|
|
376
|
-
I && (I.delete(r), I.size === 0 && oe.delete(
|
|
374
|
+
), oe.has(f) || oe.set(f, /* @__PURE__ */ new Set()), oe.get(f).add(r), console.log(`π HMR client connected: ${f}`), r.on("close", () => {
|
|
375
|
+
const I = oe.get(f);
|
|
376
|
+
I && (I.delete(r), I.size === 0 && oe.delete(f)), console.log(`π HMR client disconnected: ${f}`);
|
|
377
377
|
}), r.on("error", () => {
|
|
378
|
-
const I = oe.get(
|
|
378
|
+
const I = oe.get(f);
|
|
379
379
|
I && I.delete(r);
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
382
|
}, Pe = n.default.createServer((a, r) => {
|
|
383
383
|
if (r.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
|
|
384
384
|
let m = "";
|
|
385
|
-
a.on("data", (
|
|
385
|
+
a.on("data", (f) => m += f), a.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId:
|
|
388
|
-
F.set(
|
|
387
|
+
const { componentId: f, distPath: S, componentName: $, htmlFile: I } = JSON.parse(m);
|
|
388
|
+
F.set(f, { path: S, name: $ || null, htmlFile: I || null });
|
|
389
389
|
const N = $ ? ` (${$})` : "";
|
|
390
|
-
console.log(`β
Registered: ${
|
|
390
|
+
console.log(`β
Registered: ${f}${N} -> ${S}${I ? "/" + I : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(F.keys()) }));
|
|
391
391
|
const U = Array.from(F.entries()).map(([K, ne]) => ({
|
|
392
392
|
id: K,
|
|
393
393
|
path: ne.path,
|
|
@@ -404,16 +404,16 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
404
404
|
} catch {
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
|
-
} catch (
|
|
408
|
-
r.writeHead(400), r.end(JSON.stringify({ error:
|
|
407
|
+
} catch (f) {
|
|
408
|
+
r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
|
|
409
409
|
}
|
|
410
410
|
});
|
|
411
411
|
} else if (a.method === "POST" && a.url === "/_unregister") {
|
|
412
412
|
let m = "";
|
|
413
|
-
a.on("data", (
|
|
413
|
+
a.on("data", (f) => m += f), a.on("end", () => {
|
|
414
414
|
try {
|
|
415
|
-
const { componentId:
|
|
416
|
-
F.delete(
|
|
415
|
+
const { componentId: f } = JSON.parse(m);
|
|
416
|
+
F.delete(f), console.log(`β Unregistered: ${f}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
|
|
417
417
|
const S = Array.from(F.entries()).map(([$, I]) => ({
|
|
418
418
|
id: $,
|
|
419
419
|
path: I.path,
|
|
@@ -430,20 +430,20 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
430
430
|
} catch {
|
|
431
431
|
}
|
|
432
432
|
});
|
|
433
|
-
} catch (
|
|
434
|
-
r.writeHead(400), r.end(JSON.stringify({ error:
|
|
433
|
+
} catch (f) {
|
|
434
|
+
r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
} else if (a.method === "GET" && a.url === "/_list")
|
|
438
438
|
r.writeHead(200), r.end(JSON.stringify({ components: Array.from(F.entries()) }));
|
|
439
439
|
else if (a.method === "POST" && a.url === "/_hmr_notify") {
|
|
440
440
|
let m = "";
|
|
441
|
-
a.on("data", (
|
|
441
|
+
a.on("data", (f) => m += f), a.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId:
|
|
443
|
+
const { componentId: f, html: S } = JSON.parse(m), $ = oe.get(f);
|
|
444
444
|
if ($ && $.size > 0) {
|
|
445
|
-
console.log(`π₯ Notifying ${$.size} HMR client(s) for: ${
|
|
446
|
-
const I = JSON.stringify({ type: "update", html: S }), N =
|
|
445
|
+
console.log(`π₯ Notifying ${$.size} HMR client(s) for: ${f}`);
|
|
446
|
+
const I = JSON.stringify({ type: "update", html: S }), N = Ye(I);
|
|
447
447
|
$.forEach((U) => {
|
|
448
448
|
try {
|
|
449
449
|
U.write(N);
|
|
@@ -453,8 +453,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
453
453
|
}), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: $.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 (f) {
|
|
457
|
+
r.writeHead(400), r.end(JSON.stringify({ error: f.message }));
|
|
458
458
|
}
|
|
459
459
|
});
|
|
460
460
|
} else
|
|
@@ -464,45 +464,45 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
464
464
|
r.writeHead(403, { "Content-Type": "text/plain" }), r.end("Forbidden");
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const m = new URL(a.url, `http://localhost:${
|
|
468
|
-
if (
|
|
467
|
+
const m = new URL(a.url, `http://localhost:${c}`), f = m.pathname, S = f.split("/").filter((W) => W);
|
|
468
|
+
if (f.startsWith("/consume")) {
|
|
469
469
|
const W = m.searchParams.get("id");
|
|
470
470
|
if (!W) {
|
|
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
474
|
const G = F.get(W), Z = G ? G.path : null, ce = (se) => {
|
|
475
|
-
let
|
|
475
|
+
let H = "Unknown", q = "Unknown";
|
|
476
476
|
if (a.headers.referer || a.headers.referrer) {
|
|
477
477
|
const B = a.headers.referer || a.headers.referrer;
|
|
478
478
|
try {
|
|
479
479
|
const re = new URL(B);
|
|
480
|
-
|
|
480
|
+
H = re.origin, q = re.hostname || re.origin;
|
|
481
481
|
} catch {
|
|
482
|
-
|
|
482
|
+
H = B, q = B;
|
|
483
483
|
}
|
|
484
484
|
} else if (a.headers.origin)
|
|
485
485
|
try {
|
|
486
486
|
const B = new URL(a.headers.origin);
|
|
487
|
-
|
|
487
|
+
H = B.origin, q = B.hostname || B.origin;
|
|
488
488
|
} catch {
|
|
489
|
-
|
|
489
|
+
H = a.headers.origin, q = a.headers.origin;
|
|
490
490
|
}
|
|
491
491
|
else if (a.socket.remoteAddress) {
|
|
492
492
|
const B = a.socket.remoteAddress;
|
|
493
|
-
B === "::1" || B === "::ffff:127.0.0.1" ? (
|
|
493
|
+
B === "::1" || B === "::ffff:127.0.0.1" ? (H = "localhost", q = "localhost (direct)") : (H = B, q = B.replace("::ffff:", ""));
|
|
494
494
|
}
|
|
495
|
-
const
|
|
495
|
+
const Oe = a.headers.referer || a.headers.referrer || H, he = {
|
|
496
496
|
type: "request",
|
|
497
497
|
componentId: W,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
499
|
servedLocally: se,
|
|
500
|
-
referrer:
|
|
501
|
-
origin:
|
|
500
|
+
referrer: Oe,
|
|
501
|
+
origin: H,
|
|
502
502
|
originLabel: q
|
|
503
503
|
};
|
|
504
|
-
Q.has(
|
|
505
|
-
url:
|
|
504
|
+
Q.has(H) || (Q.set(H, {
|
|
505
|
+
url: H,
|
|
506
506
|
label: q,
|
|
507
507
|
firstSeen: Date.now(),
|
|
508
508
|
requestCount: 0
|
|
@@ -517,8 +517,8 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
const
|
|
521
|
-
|
|
520
|
+
const Re = Q.get(H);
|
|
521
|
+
Re.requestCount++, z.forEach((B) => {
|
|
522
522
|
try {
|
|
523
523
|
B.write(`data: ${JSON.stringify({
|
|
524
524
|
type: "origins",
|
|
@@ -539,12 +539,12 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
539
539
|
};
|
|
540
540
|
if (Z) {
|
|
541
541
|
const se = G.htmlFile ? t.default.join(Z, G.htmlFile) : t.default.join(Z, "index.html");
|
|
542
|
-
o.default.readFile(se, "utf-8", (
|
|
543
|
-
if (
|
|
542
|
+
o.default.readFile(se, "utf-8", (H, q) => {
|
|
543
|
+
if (H) {
|
|
544
544
|
console.log(`β File not found: ${se}`), r.writeHead(404, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "index.html not found" }));
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
const
|
|
547
|
+
const Oe = Me(q, W), he = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Re = {
|
|
548
548
|
item: {
|
|
549
549
|
name: W,
|
|
550
550
|
id: W,
|
|
@@ -555,7 +555,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
557
557
|
shadowRootMode: "localFrame",
|
|
558
|
-
HTML:
|
|
558
|
+
HTML: Oe
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
]
|
|
@@ -564,23 +564,23 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
564
564
|
console.log(`β
Serving consume JSON for: ${W}`), 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: ${W}`);
|
|
571
571
|
const se = `https://cloud.myop.dev/consume${m.search}`;
|
|
572
|
-
ce(!1), fetch(se).then((
|
|
572
|
+
ce(!1), fetch(se).then((H) => H.text()).then((H) => {
|
|
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(H);
|
|
577
|
+
}).catch((H) => {
|
|
578
|
+
console.error(`β Proxy error: ${H.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 (f === "/events") {
|
|
584
584
|
r.writeHead(200, {
|
|
585
585
|
"Content-Type": "text/event-stream",
|
|
586
586
|
"Cache-Control": "no-cache",
|
|
@@ -614,7 +614,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
616
|
if (S.length === 0) {
|
|
617
|
-
r.writeHead(200, { "Content-Type": "text/html" }), r.end(Ft(
|
|
617
|
+
r.writeHead(200, { "Content-Type": "text/html" }), r.end(Ft(c, l, h, y));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
620
|
if (S[0] !== "view") {
|
|
@@ -639,7 +639,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
639
639
|
const Z = J(le);
|
|
640
640
|
console.log(`β
Serving: ${le} (${Z})`);
|
|
641
641
|
let ce = G;
|
|
642
|
-
if (Z === "text/html" &&
|
|
642
|
+
if (Z === "text/html" && R) {
|
|
643
643
|
const se = G.toString("utf-8");
|
|
644
644
|
ce = Me(se, $);
|
|
645
645
|
}
|
|
@@ -648,12 +648,12 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
648
648
|
"Access-Control-Allow-Origin": "*"
|
|
649
649
|
}), r.end(ce);
|
|
650
650
|
});
|
|
651
|
-
}),
|
|
652
|
-
const m =
|
|
651
|
+
}), Ge = () => new Promise((a, r) => {
|
|
652
|
+
const m = g ? t.default.resolve(T) : t.default.resolve(T, C), f = JSON.stringify({
|
|
653
653
|
componentId: x,
|
|
654
654
|
distPath: m,
|
|
655
|
-
componentName:
|
|
656
|
-
htmlFile:
|
|
655
|
+
componentName: O,
|
|
656
|
+
htmlFile: g ? w : null
|
|
657
657
|
}), S = {
|
|
658
658
|
hostname: "localhost",
|
|
659
659
|
port: l,
|
|
@@ -661,7 +661,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
661
661
|
method: "POST",
|
|
662
662
|
headers: {
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
|
-
"Content-Length": Buffer.byteLength(
|
|
664
|
+
"Content-Length": Buffer.byteLength(f)
|
|
665
665
|
}
|
|
666
666
|
}, $ = n.default.request(S, (I) => {
|
|
667
667
|
let N = "";
|
|
@@ -669,9 +669,9 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
669
669
|
I.statusCode === 200 ? a(JSON.parse(N)) : r(new Error(`Registration failed: ${I.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
|
-
$.on("error", r), $.write(
|
|
673
|
-
}),
|
|
674
|
-
const m = JSON.stringify({ componentId: x }),
|
|
672
|
+
$.on("error", r), $.write(f), $.end();
|
|
673
|
+
}), gt = () => new Promise((a, r) => {
|
|
674
|
+
const m = JSON.stringify({ componentId: x }), f = {
|
|
675
675
|
hostname: "localhost",
|
|
676
676
|
port: l,
|
|
677
677
|
path: "/_unregister",
|
|
@@ -680,11 +680,11 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
681
|
"Content-Length": Buffer.byteLength(m)
|
|
682
682
|
}
|
|
683
|
-
}, S = n.default.request(
|
|
683
|
+
}, S = n.default.request(f, ($) => {
|
|
684
684
|
a();
|
|
685
685
|
});
|
|
686
686
|
S.on("error", () => a()), S.write(m), S.end();
|
|
687
|
-
}),
|
|
687
|
+
}), ft = (a) => `
|
|
688
688
|
<!-- MYOP HMR -->
|
|
689
689
|
<script>
|
|
690
690
|
(function() {
|
|
@@ -790,32 +790,32 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
790
790
|
})();
|
|
791
791
|
<\/script>
|
|
792
792
|
`, Me = (a, r) => {
|
|
793
|
-
if (!
|
|
794
|
-
const m =
|
|
793
|
+
if (!R) return a;
|
|
794
|
+
const m = ft(r);
|
|
795
795
|
return a.includes("</body>") ? a.replace("</body>", `${m}</body>`) : a.includes("</html>") ? a.replace("</html>", `${m}</html>`) : a + m;
|
|
796
|
-
},
|
|
796
|
+
}, Ye = (a) => {
|
|
797
797
|
const r = Buffer.from(a), m = r.length;
|
|
798
|
-
let
|
|
799
|
-
return m < 126 ?
|
|
798
|
+
let f;
|
|
799
|
+
return m < 126 ? f = Buffer.concat([
|
|
800
800
|
Buffer.from([129, m]),
|
|
801
801
|
// FIN + text frame, length
|
|
802
802
|
r
|
|
803
|
-
]) : m < 65536 ?
|
|
803
|
+
]) : m < 65536 ? f = Buffer.concat([
|
|
804
804
|
Buffer.from([129, 126]),
|
|
805
805
|
// FIN + text frame, extended length
|
|
806
806
|
Buffer.from([m >> 8, m & 255]),
|
|
807
807
|
// 16-bit length
|
|
808
808
|
r
|
|
809
|
-
]) :
|
|
809
|
+
]) : f = Buffer.concat([
|
|
810
810
|
Buffer.from([129, 127]),
|
|
811
811
|
// FIN + text frame, extended length
|
|
812
812
|
Buffer.from([0, 0, 0, 0, m >> 24, m >> 16 & 255, m >> 8 & 255, m & 255]),
|
|
813
813
|
// 64-bit length
|
|
814
814
|
r
|
|
815
|
-
]),
|
|
816
|
-
},
|
|
817
|
-
if (!
|
|
818
|
-
const a =
|
|
815
|
+
]), f;
|
|
816
|
+
}, Ke = () => {
|
|
817
|
+
if (!R) return;
|
|
818
|
+
const a = g ? w : t.default.join(C, "index.html");
|
|
819
819
|
let r;
|
|
820
820
|
try {
|
|
821
821
|
const m = o.default.readFileSync(a, "utf-8");
|
|
@@ -824,15 +824,15 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
824
824
|
console.error("β Failed to read HTML for HMR:", m.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (
|
|
827
|
+
if (ke) {
|
|
828
828
|
const m = oe.get(x);
|
|
829
829
|
if (!m || m.size === 0)
|
|
830
830
|
return;
|
|
831
831
|
console.log(`π₯ Notifying ${m.size} HMR client(s)`);
|
|
832
|
-
const
|
|
832
|
+
const f = JSON.stringify({
|
|
833
833
|
type: "update",
|
|
834
834
|
html: r
|
|
835
|
-
}), S =
|
|
835
|
+
}), S = Ye(f);
|
|
836
836
|
m.forEach(($) => {
|
|
837
837
|
try {
|
|
838
838
|
$.write(S);
|
|
@@ -844,7 +844,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
844
844
|
const m = JSON.stringify({
|
|
845
845
|
componentId: x,
|
|
846
846
|
html: r
|
|
847
|
-
}),
|
|
847
|
+
}), f = {
|
|
848
848
|
hostname: "localhost",
|
|
849
849
|
port: l,
|
|
850
850
|
path: "/_hmr_notify",
|
|
@@ -854,7 +854,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
854
854
|
"Content-Length": Buffer.byteLength(m)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
}, S = n.default.request(
|
|
857
|
+
}, S = n.default.request(f, ($) => {
|
|
858
858
|
let I = "";
|
|
859
859
|
$.on("data", (N) => I += N), $.on("end", () => {
|
|
860
860
|
try {
|
|
@@ -872,30 +872,30 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
872
872
|
};
|
|
873
873
|
let Ee = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
874
|
const ge = (a) => {
|
|
875
|
-
if (
|
|
876
|
-
|
|
875
|
+
if (u) {
|
|
876
|
+
P = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
|
-
|
|
880
|
-
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, m,
|
|
881
|
-
if (
|
|
882
|
-
const S = await
|
|
879
|
+
u = !0, console.log(`
|
|
880
|
+
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, m, f) => {
|
|
881
|
+
if (u = !1, r) {
|
|
882
|
+
const S = await at(r, m, f, e, {
|
|
883
883
|
...Ee,
|
|
884
884
|
onRetry: () => ge(a)
|
|
885
885
|
});
|
|
886
|
-
Ee = { ...Ee, ...S }, S.handled || (console.error("β Build failed:", r.message),
|
|
886
|
+
Ee = { ...Ee, ...S }, S.handled || (console.error("β Build failed:", r.message), f && console.error(f));
|
|
887
887
|
} else
|
|
888
|
-
console.log("β
Build completed"), m && console.log(m),
|
|
889
|
-
|
|
888
|
+
console.log("β
Build completed"), m && console.log(m), Ke(), a && a();
|
|
889
|
+
P && (P = !1, ge());
|
|
890
890
|
});
|
|
891
|
-
},
|
|
891
|
+
}, Qe = /* @__PURE__ */ new Set(), Ie = (a) => {
|
|
892
892
|
o.default.readdir(a, { withFileTypes: !0 }, (r, m) => {
|
|
893
|
-
r || (m.forEach((
|
|
894
|
-
const S = t.default.join(a,
|
|
895
|
-
if (
|
|
896
|
-
|
|
897
|
-
else if (
|
|
898
|
-
const $ = t.default.extname(
|
|
893
|
+
r || (m.forEach((f) => {
|
|
894
|
+
const S = t.default.join(a, f.name);
|
|
895
|
+
if (f.isDirectory())
|
|
896
|
+
f.name !== "node_modules" && f.name !== "dist" && !f.name.startsWith(".") && Ie(S);
|
|
897
|
+
else if (f.isFile()) {
|
|
898
|
+
const $ = t.default.extname(f.name);
|
|
899
899
|
if ($ === ".js" || $ === ".css" || $ === ".html")
|
|
900
900
|
try {
|
|
901
901
|
const I = o.default.readFileSync(S, "utf-8");
|
|
@@ -903,7 +903,7 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
}),
|
|
906
|
+
}), Qe.has(a) || (Qe.add(a), o.default.watch(a, (f, S) => {
|
|
907
907
|
if (!S) return;
|
|
908
908
|
const $ = t.default.extname(S);
|
|
909
909
|
if ($ !== ".js" && $ !== ".css" && $ !== ".html") return;
|
|
@@ -911,42 +911,42 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
913
913
|
const N = o.default.readFileSync(I, "utf-8"), U = p.get(I);
|
|
914
|
-
N !== U && (p.set(I, N), console.log(`π File changed: ${I}`),
|
|
914
|
+
N !== U && (p.set(I, N), console.log(`π File changed: ${I}`), g ? Ke() : ge());
|
|
915
915
|
} catch {
|
|
916
916
|
}
|
|
917
917
|
}, 50);
|
|
918
918
|
})));
|
|
919
919
|
});
|
|
920
|
-
},
|
|
920
|
+
}, Ze = (a) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
π¨ Component: ${x}`),
|
|
923
|
-
`), a && a()) : (ge(a), Ie(
|
|
922
|
+
π¨ Component: ${x}`), g ? (console.log("π No build needed (single HTML file mode)"), Ie(T), console.log(`π Watching ${w} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
|
+
`), a && a()) : (ge(a), Ie(T), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
|
-
},
|
|
925
|
+
}, ht = () => new Promise((a) => {
|
|
926
926
|
const r = {
|
|
927
927
|
hostname: "localhost",
|
|
928
928
|
port: l,
|
|
929
929
|
path: "/_list",
|
|
930
930
|
method: "GET",
|
|
931
931
|
timeout: 1e3
|
|
932
|
-
}, m = n.default.request(r, (
|
|
932
|
+
}, m = n.default.request(r, (f) => {
|
|
933
933
|
a(!0);
|
|
934
934
|
});
|
|
935
935
|
m.on("error", () => a(!1)), m.on("timeout", () => {
|
|
936
936
|
m.destroy(), a(!1);
|
|
937
937
|
}), m.end();
|
|
938
|
-
}),
|
|
939
|
-
const r = n.default.createServer((m,
|
|
940
|
-
if (
|
|
938
|
+
}), yt = () => new Promise((a) => {
|
|
939
|
+
const r = n.default.createServer((m, f) => {
|
|
940
|
+
if (f.setHeader("Content-Type", "application/json"), m.method === "POST" && m.url === "/_register") {
|
|
941
941
|
let S = "";
|
|
942
942
|
m.on("data", ($) => S += $), m.on("end", () => {
|
|
943
943
|
try {
|
|
944
944
|
const { componentId: $, distPath: I, componentName: N, htmlFile: U } = JSON.parse(S);
|
|
945
945
|
F.set($, { path: I, name: N || null, htmlFile: U || null });
|
|
946
946
|
const K = N ? ` (${N})` : "";
|
|
947
|
-
console.log(`β
Registered: ${$}${K} -> ${I}${U ? "/" + U : ""}`),
|
|
947
|
+
console.log(`β
Registered: ${$}${K} -> ${I}${U ? "/" + U : ""}`), f.writeHead(200), f.end(JSON.stringify({ success: !0, registered: Array.from(F.keys()) }));
|
|
948
948
|
} catch ($) {
|
|
949
|
-
|
|
949
|
+
f.writeHead(400), f.end(JSON.stringify({ error: $.message }));
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
952
|
} else if (m.method === "POST" && m.url === "/_unregister") {
|
|
@@ -954,12 +954,12 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
954
954
|
m.on("data", ($) => S += $), m.on("end", () => {
|
|
955
955
|
try {
|
|
956
956
|
const { componentId: $ } = JSON.parse(S);
|
|
957
|
-
F.delete($), console.log(`β Unregistered: ${$}`),
|
|
957
|
+
F.delete($), console.log(`β Unregistered: ${$}`), f.writeHead(200), f.end(JSON.stringify({ success: !0 }));
|
|
958
958
|
} catch ($) {
|
|
959
|
-
|
|
959
|
+
f.writeHead(400), f.end(JSON.stringify({ error: $.message }));
|
|
960
960
|
}
|
|
961
961
|
});
|
|
962
|
-
} else m.method === "GET" && m.url === "/_list" ? (
|
|
962
|
+
} else m.method === "GET" && m.url === "/_list" ? (f.writeHead(200), f.end(JSON.stringify({ components: Array.from(F.entries()) }))) : (f.writeHead(404), f.end(JSON.stringify({ error: "Not found" })));
|
|
963
963
|
});
|
|
964
964
|
r.on("error", () => {
|
|
965
965
|
a(!1);
|
|
@@ -967,73 +967,73 @@ Sec-WebSocket-Accept: ${$}\r
|
|
|
967
967
|
console.log(`
|
|
968
968
|
π Taking over as server...`), console.log(`π‘ Management server on port ${l}`), ue.on("error", () => {
|
|
969
969
|
r.close(), a(!1);
|
|
970
|
-
}), ue.listen(
|
|
971
|
-
console.log(`π‘ Main server running at http://localhost:${
|
|
972
|
-
const m =
|
|
970
|
+
}), ue.listen(c, () => {
|
|
971
|
+
console.log(`π‘ Main server running at http://localhost:${c}`);
|
|
972
|
+
const m = g ? t.default.resolve(T) : t.default.resolve(T, C);
|
|
973
973
|
F.set(x, {
|
|
974
974
|
path: m,
|
|
975
|
-
name:
|
|
976
|
-
htmlFile:
|
|
975
|
+
name: O,
|
|
976
|
+
htmlFile: g ? w : null
|
|
977
977
|
});
|
|
978
|
-
const
|
|
979
|
-
console.log(`β
Registered component: ${x}${
|
|
978
|
+
const f = O ? ` (${O})` : "";
|
|
979
|
+
console.log(`β
Registered component: ${x}${f}`), console.log(`π‘ Access at: http://localhost:${c}/view/${x}/`), a(!0);
|
|
980
980
|
});
|
|
981
981
|
});
|
|
982
982
|
});
|
|
983
983
|
let fe;
|
|
984
|
-
const
|
|
984
|
+
const qe = () => {
|
|
985
985
|
fe = setInterval(async () => {
|
|
986
|
-
await
|
|
987
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
986
|
+
await ht() || (clearInterval(fe), console.log(`
|
|
987
|
+
β οΈ Server appears to be down, attempting to take over...`), await yt() ? (console.log("β
Successfully took over as server"), ke = !0) : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
988
|
try {
|
|
989
|
-
await
|
|
989
|
+
await Ge(), console.log(`β
Re-registered component: ${x}`), qe();
|
|
990
990
|
} catch (m) {
|
|
991
991
|
console.error("β Failed to re-register:", m.message);
|
|
992
992
|
}
|
|
993
993
|
}, 2e3)));
|
|
994
994
|
}, 3e3);
|
|
995
|
-
},
|
|
995
|
+
}, Xe = async () => {
|
|
996
996
|
console.log(`
|
|
997
997
|
|
|
998
|
-
π Shutting down...`), fe && clearInterval(fe), await
|
|
998
|
+
π Shutting down...`), fe && clearInterval(fe), await gt(), process.exit(0);
|
|
999
999
|
};
|
|
1000
|
-
process.on("SIGINT",
|
|
1001
|
-
let
|
|
1000
|
+
process.on("SIGINT", Xe), process.on("SIGTERM", Xe);
|
|
1001
|
+
let ke = !1;
|
|
1002
1002
|
Pe.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
|
-
x = await
|
|
1008
|
-
const r = await
|
|
1009
|
-
console.log(`β
Registered component: ${x}`), console.log(`π‘ Access at: http://localhost:${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER || b(`http://localhost:${
|
|
1011
|
-
}),
|
|
1007
|
+
x = await L();
|
|
1008
|
+
const r = await Ge();
|
|
1009
|
+
console.log(`β
Registered component: ${x}`), console.log(`π‘ Access at: http://localhost:${c}/view/${x}/`), console.log(`π All registered components: ${r.registered.join(", ")}`), Ze(() => {
|
|
1010
|
+
process.env.MYOP_NO_BROWSER || b(`http://localhost:${c}/view/${x}/`);
|
|
1011
|
+
}), qe();
|
|
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
|
-
}), Pe.on("upgrade",
|
|
1018
|
-
|
|
1017
|
+
}), Pe.on("upgrade", ut), Pe.listen(l, async () => {
|
|
1018
|
+
ke = !0, console.log(`
|
|
1019
1019
|
π Starting shared dev server...`), console.log(`π‘ Management server on port ${l}`), 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 =
|
|
1021
|
+
}), ue.listen(c, async () => {
|
|
1022
|
+
console.log(`π‘ Main server running at http://localhost:${c}`), (x === "DEV" || x === "NEW") && (x = "DEV1");
|
|
1023
|
+
const a = g ? t.default.resolve(T) : t.default.resolve(T, C);
|
|
1024
1024
|
F.set(x, {
|
|
1025
1025
|
path: a,
|
|
1026
|
-
name:
|
|
1027
|
-
htmlFile:
|
|
1026
|
+
name: O,
|
|
1027
|
+
htmlFile: g ? w : null
|
|
1028
1028
|
});
|
|
1029
|
-
const r =
|
|
1030
|
-
console.log(`β
Registered component: ${x}${r}`), console.log(`π‘ Access at: http://localhost:${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER || b(`http://localhost:${
|
|
1029
|
+
const r = O ? ` (${O})` : "";
|
|
1030
|
+
console.log(`β
Registered component: ${x}${r}`), console.log(`π‘ Access at: http://localhost:${c}/view/${x}/`), Ze(() => {
|
|
1031
|
+
process.env.MYOP_NO_BROWSER || b(`http://localhost:${c}/view/${x}/`);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
|
-
const
|
|
1036
|
+
const A = class A {
|
|
1037
1037
|
constructor(t) {
|
|
1038
1038
|
this.components = t.map(
|
|
1039
1039
|
(e) => typeof e == "string" ? { name: e, path: "", id: "" } : e
|
|
@@ -1042,7 +1042,7 @@ const L = class L {
|
|
|
1042
1042
|
this.logs.set(e.name, []), this.scrollPos.set(e.name, 0), this.statuses.set(e.name, "Initializing..."), this.statusKeys.set(e.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(A.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", (t) => {
|
|
@@ -1083,15 +1083,15 @@ const L = class L {
|
|
|
1083
1083
|
const t = this.components.length, e = 38;
|
|
1084
1084
|
let n;
|
|
1085
1085
|
this.cols >= e * 3 + 4 ? n = Math.min(t, 3) : this.cols >= e * 2 + 2 ? n = Math.min(t, 2) : n = 1;
|
|
1086
|
-
const s = Math.ceil(t / n), i = Math.floor(this.cols / n),
|
|
1087
|
-
this.visibleLogLines = Math.max(2,
|
|
1086
|
+
const s = Math.ceil(t / n), i = Math.floor(this.cols / n), d = 2, y = this.rows - d - 2, c = Math.floor(y / s);
|
|
1087
|
+
this.visibleLogLines = Math.max(2, c - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: c }, this.panelPositions.clear();
|
|
1088
1088
|
for (let l = 0; l < t; l++) {
|
|
1089
|
-
const
|
|
1090
|
-
this.panelPositions.set(
|
|
1091
|
-
row:
|
|
1092
|
-
col:
|
|
1089
|
+
const C = this.components[l], u = Math.floor(l / n), P = l % n;
|
|
1090
|
+
this.panelPositions.set(C.name, {
|
|
1091
|
+
row: d + 1 + u * c,
|
|
1092
|
+
col: P * i + 1,
|
|
1093
1093
|
width: i,
|
|
1094
|
-
height:
|
|
1094
|
+
height: c
|
|
1095
1095
|
});
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
@@ -1110,8 +1110,8 @@ const L = class L {
|
|
|
1110
1110
|
s.includes("initializing") || s.includes("β³") ? n = "initializing" : s.includes("starting") ? n = "starting" : s.includes("building") || s.includes("π¨") ? n = "building" : s.includes("ready") || s.includes("β
") ? n = "ready" : s.includes("changed") || s.includes("π") ? n = "changed" : s.includes("hmr") ? n = "hmr_update" : s.includes("π₯") ? n = "hmr" : s.includes("error") || s.includes("β") ? n = "error" : s.includes("warning") || s.includes("β ") ? n = "warning" : (s.includes("stopped") || s.includes("exited")) && (n = "stopped"), this.statuses.set(t, e), this.statusKeys.set(t, n), this.queueUpdate(t);
|
|
1111
1111
|
}
|
|
1112
1112
|
scroll(t, e) {
|
|
1113
|
-
const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines),
|
|
1114
|
-
|
|
1113
|
+
const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), d = Math.max(0, Math.min(i, s + e));
|
|
1114
|
+
d !== s && (this.scrollPos.set(t, d), this.queueUpdate(t));
|
|
1115
1115
|
}
|
|
1116
1116
|
queueUpdate(t) {
|
|
1117
1117
|
this.pendingUpdates.add(t), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
|
|
@@ -1132,44 +1132,44 @@ const L = class L {
|
|
|
1132
1132
|
return `${e}:${n.toString().padStart(2, "0")}`;
|
|
1133
1133
|
}
|
|
1134
1134
|
updateHeader() {
|
|
1135
|
-
const t =
|
|
1135
|
+
const t = A.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
|
|
1136
1136
|
let s = `${t.dim}π‘${t.reset} http://localhost:9292 ${t.gray}|${t.reset} `;
|
|
1137
|
-
s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `β± ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s +=
|
|
1137
|
+
s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `β± ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += A.ESC.clearLine.slice(0, -1), process.stdout.write(A.ESC.moveTo(2, 1) + s);
|
|
1138
1138
|
}
|
|
1139
1139
|
renderPanel(t) {
|
|
1140
|
-
const e =
|
|
1140
|
+
const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
|
|
1141
1141
|
if (!s) return;
|
|
1142
|
-
const i = this.components.findIndex((
|
|
1143
|
-
let
|
|
1144
|
-
|
|
1145
|
-
const b = 5 +
|
|
1146
|
-
|
|
1147
|
-
const p = (
|
|
1148
|
-
let E = `${
|
|
1149
|
-
E += " ".repeat(Math.max(0,
|
|
1150
|
-
const x =
|
|
1151
|
-
let
|
|
1152
|
-
|
|
1153
|
-
const
|
|
1154
|
-
for (let
|
|
1155
|
-
const
|
|
1156
|
-
let J = `${
|
|
1157
|
-
if (
|
|
1142
|
+
const i = this.components.findIndex((L) => L.name === t), d = this.components[i], h = i === this.selectedPanel, y = this.statusKeys.get(t) || "initializing", c = n[y], l = e[c.color], C = this.logs.get(t) || [], u = this.scrollPos.get(t) || 0, P = s.width - 1, g = h ? e.cyan : e.gray, w = [], j = d.name.substring(0, P - 20);
|
|
1143
|
+
let k = `${g}ββ${e.reset} ${l}${c.icon}${e.reset} `;
|
|
1144
|
+
k += `${e.bold}${j}${e.reset} ${e.gray}β${e.reset} ${l}${c.label}${e.reset} `;
|
|
1145
|
+
const b = 5 + j.length + c.label.length + 3;
|
|
1146
|
+
k += `${g}${"β".repeat(Math.max(0, P - b))}β${e.reset}`, w.push(A.ESC.moveTo(s.row, s.col) + k);
|
|
1147
|
+
const p = (d.path || "").substring(0, P - 6);
|
|
1148
|
+
let E = `${g}β${e.reset} ${e.dim}${p}${e.reset}`;
|
|
1149
|
+
E += " ".repeat(Math.max(0, P - p.length - 3)), E += `${g}β${e.reset}`, w.push(A.ESC.moveTo(s.row + 1, s.col) + E);
|
|
1150
|
+
const x = C.length, O = x > this.visibleLogLines ? `${u + 1}-${Math.min(u + this.visibleLogLines, x)}/${x}` : "";
|
|
1151
|
+
let R = `${g}β${"β".repeat(P - O.length - 4)}${e.reset}`;
|
|
1152
|
+
O && (R += `${e.dim}${O}${e.reset}`), R += `${g}${"β".repeat(2)}β€${e.reset}`, w.push(A.ESC.moveTo(s.row + 2, s.col) + R);
|
|
1153
|
+
const D = C.slice(u, u + this.visibleLogLines);
|
|
1154
|
+
for (let L = 0; L < this.visibleLogLines; L++) {
|
|
1155
|
+
const T = D[L];
|
|
1156
|
+
let J = `${g}β${e.reset}`;
|
|
1157
|
+
if (T) {
|
|
1158
1158
|
let F = e.white;
|
|
1159
|
-
|
|
1160
|
-
const V =
|
|
1161
|
-
J += `${e.dim}${
|
|
1162
|
-
const te =
|
|
1159
|
+
T.type === "success" ? F = e.green : T.type === "error" ? F = e.red : T.type === "warning" ? F = e.yellow : T.type === "hmr" ? F = e.magenta : T.type === "change" && (F = e.blue);
|
|
1160
|
+
const V = T.message.substring(0, P - 12);
|
|
1161
|
+
J += `${e.dim}${T.timestamp}${e.reset} ${F}${V}${e.reset}`;
|
|
1162
|
+
const te = P - T.timestamp.length - V.length - 2;
|
|
1163
1163
|
J += " ".repeat(Math.max(0, te));
|
|
1164
1164
|
} else
|
|
1165
|
-
J += " ".repeat(
|
|
1166
|
-
J += `${
|
|
1165
|
+
J += " ".repeat(P - 2);
|
|
1166
|
+
J += `${g}β${e.reset}`, w.push(A.ESC.moveTo(s.row + 3 + L, s.col) + J);
|
|
1167
1167
|
}
|
|
1168
|
-
w.push(
|
|
1168
|
+
w.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}β${"β".repeat(P - 2)}β${e.reset}`), process.stdout.write(w.join(""));
|
|
1169
1169
|
}
|
|
1170
1170
|
fullRender() {
|
|
1171
|
-
const t =
|
|
1172
|
-
process.stdout.write(
|
|
1171
|
+
const t = A.C;
|
|
1172
|
+
process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1));
|
|
1173
1173
|
const e = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - e.length) / 2);
|
|
1174
1174
|
process.stdout.write(`${t.cyan}${"β".repeat(n)}${t.bold}${t.bgCyan}${t.black}${e}${t.reset}${t.cyan}${"β".repeat(this.cols - n - e.length)}${t.reset}`), this.updateHeader();
|
|
1175
1175
|
for (const s of this.components)
|
|
@@ -1177,26 +1177,26 @@ const L = class L {
|
|
|
1177
1177
|
this.renderFooter();
|
|
1178
1178
|
}
|
|
1179
1179
|
renderFooter() {
|
|
1180
|
-
const t =
|
|
1180
|
+
const t = A.C, e = this.rows - 1;
|
|
1181
1181
|
let n = `${t.gray}`;
|
|
1182
|
-
n += `${t.green}β${t.gray} Ready `, n += `${t.yellow}β³${t.gray} Building `, n += `${t.magenta}β‘${t.gray} HMR `, n += `${t.red}β${t.gray} Error `, n += `${t.dim}| ββ: select panel ββ: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(
|
|
1182
|
+
n += `${t.green}β${t.gray} Ready `, n += `${t.yellow}β³${t.gray} Building `, n += `${t.magenta}β‘${t.gray} HMR `, n += `${t.red}β${t.gray} Error `, n += `${t.dim}| ββ: select panel ββ: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(A.ESC.moveTo(e, 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(A.ESC.clearScreen + A.ESC.moveTo(1, 1) + A.ESC.showCursor);
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
// ANSI escape codes
|
|
1192
|
-
ye(
|
|
1192
|
+
ye(A, "ESC", {
|
|
1193
1193
|
moveTo: (t, e) => `\x1B[${t};${e}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(A, "C", {
|
|
1200
1200
|
reset: "\x1B[0m",
|
|
1201
1201
|
bold: "\x1B[1m",
|
|
1202
1202
|
dim: "\x1B[2m",
|
|
@@ -1211,7 +1211,7 @@ ye(L, "C", {
|
|
|
1211
1211
|
bgCyan: "\x1B[46m",
|
|
1212
1212
|
black: "\x1B[30m"
|
|
1213
1213
|
}), // Status configs
|
|
1214
|
-
ye(
|
|
1214
|
+
ye(A, "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,20 +1224,20 @@ ye(L, "STATUS", {
|
|
|
1224
1224
|
warning: { icon: "β ", color: "yellow", label: "Warning" },
|
|
1225
1225
|
stopped: { icon: "β ", color: "gray", label: "Stopped" }
|
|
1226
1226
|
});
|
|
1227
|
-
let Ne =
|
|
1228
|
-
async function
|
|
1227
|
+
let Ne = A;
|
|
1228
|
+
async function Dt(o) {
|
|
1229
1229
|
const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((l) => ({
|
|
1230
1230
|
name: l.name,
|
|
1231
1231
|
path: l.path,
|
|
1232
1232
|
id: l.componentId || ""
|
|
1233
|
-
})), i = new Ne(s),
|
|
1234
|
-
const
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1233
|
+
})), i = new Ne(s), d = [], h = (l) => {
|
|
1234
|
+
const C = process.platform;
|
|
1235
|
+
let u;
|
|
1236
|
+
C === "darwin" ? u = `open "${l}"` : C === "win32" ? u = `start "" "${l}"` : u = `xdg-open "${l}"`, e(u, () => {
|
|
1237
1237
|
});
|
|
1238
1238
|
}, y = () => {
|
|
1239
1239
|
i.clear(), console.log(`
|
|
1240
|
-
π Shutting down all components...`),
|
|
1240
|
+
π Shutting down all components...`), d.forEach((l) => {
|
|
1241
1241
|
try {
|
|
1242
1242
|
l.kill("SIGTERM");
|
|
1243
1243
|
} catch {
|
|
@@ -1245,104 +1245,104 @@ async function Ht(o) {
|
|
|
1245
1245
|
}), setTimeout(() => process.exit(0), 500);
|
|
1246
1246
|
};
|
|
1247
1247
|
process.on("SIGINT", y), process.on("SIGTERM", y);
|
|
1248
|
-
const
|
|
1248
|
+
const c = process.argv[1];
|
|
1249
1249
|
for (let l = 0; l < o.length; l++) {
|
|
1250
|
-
const
|
|
1251
|
-
i.setStatus(
|
|
1252
|
-
const
|
|
1253
|
-
cwd: n.default.resolve(
|
|
1250
|
+
const C = o[l], u = C.name;
|
|
1251
|
+
i.setStatus(u, "β³ Starting..."), i.log(u, `Starting in ${C.path}`);
|
|
1252
|
+
const P = t("node", [c, "dev"], {
|
|
1253
|
+
cwd: n.default.resolve(C.path),
|
|
1254
1254
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1255
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1256
|
});
|
|
1257
|
-
|
|
1258
|
-
let
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1257
|
+
d.push(P);
|
|
1258
|
+
let g = "";
|
|
1259
|
+
P.stdout.on("data", (w) => {
|
|
1260
|
+
g += w.toString();
|
|
1261
|
+
const j = g.split(`
|
|
1262
1262
|
`);
|
|
1263
|
-
|
|
1264
|
-
for (const
|
|
1265
|
-
const b =
|
|
1266
|
-
b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(
|
|
1263
|
+
g = j.pop() || "";
|
|
1264
|
+
for (const k of j) {
|
|
1265
|
+
const b = k.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1266
|
+
b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(u, "β
Ready") : b.includes("Building...") || b.includes("Running initial build") ? i.setStatus(u, "π¨ Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? i.setStatus(u, "β
Ready") : b.includes("Build failed") ? i.setStatus(u, "β Build Error") : b.includes("File changed") ? (i.setStatus(u, "π Changed"), setTimeout(() => i.setStatus(u, "β
Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (i.setStatus(u, "π₯ HMR Update"), setTimeout(() => i.setStatus(u, "β
Ready"), 1e3)) : b.includes("HMR client connected") && (i.setStatus(u, "π₯ HMR Connected"), setTimeout(() => i.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") && i.log(u, b));
|
|
1267
1267
|
}
|
|
1268
|
-
}),
|
|
1269
|
-
const
|
|
1268
|
+
}), P.stderr.on("data", (w) => {
|
|
1269
|
+
const j = w.toString().split(`
|
|
1270
1270
|
`);
|
|
1271
|
-
for (const
|
|
1272
|
-
const b =
|
|
1273
|
-
b && (i.log(
|
|
1271
|
+
for (const k of j) {
|
|
1272
|
+
const b = k.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1273
|
+
b && (i.log(u, `β οΈ ${b}`), i.setStatus(u, "β οΈ Warning"));
|
|
1274
1274
|
}
|
|
1275
|
-
}),
|
|
1276
|
-
w !== 0 && w !== null && (i.setStatus(
|
|
1275
|
+
}), P.on("exit", (w) => {
|
|
1276
|
+
w !== 0 && w !== null && (i.setStatus(u, `β Exited (${w})`), i.log(u, `Process exited with code ${w}`));
|
|
1277
1277
|
}), l < o.length - 1 && await new Promise((w) => setTimeout(w, 500));
|
|
1278
1278
|
}
|
|
1279
1279
|
i.render(), setTimeout(() => {
|
|
1280
|
-
|
|
1280
|
+
h("http://localhost:9292");
|
|
1281
1281
|
}, 2e3);
|
|
1282
1282
|
}
|
|
1283
|
-
const
|
|
1283
|
+
const Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1284
1284
|
__proto__: null,
|
|
1285
1285
|
devCommand: xe,
|
|
1286
|
-
monorepoDevCommand:
|
|
1287
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1288
|
-
function
|
|
1289
|
-
|
|
1286
|
+
monorepoDevCommand: Dt
|
|
1287
|
+
}, Symbol.toStringTag, { value: "Module" })), Ae = _.join(nt.homedir(), ".myop"), pe = _.join(Ae, "credentials.json");
|
|
1288
|
+
function Ut() {
|
|
1289
|
+
M.existsSync(Ae) || M.mkdirSync(Ae, { recursive: !0, mode: 448 });
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function Be() {
|
|
1292
1292
|
try {
|
|
1293
|
-
if (!
|
|
1293
|
+
if (!M.existsSync(pe))
|
|
1294
1294
|
return null;
|
|
1295
|
-
const o =
|
|
1295
|
+
const o = M.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
|
|
1302
|
-
|
|
1301
|
+
function lt(o) {
|
|
1302
|
+
Ut();
|
|
1303
1303
|
const t = {
|
|
1304
1304
|
...o,
|
|
1305
1305
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1306
1306
|
};
|
|
1307
|
-
|
|
1307
|
+
M.writeFileSync(pe, JSON.stringify(t, null, 2), {
|
|
1308
1308
|
mode: 384
|
|
1309
1309
|
// Read/write for owner only
|
|
1310
1310
|
});
|
|
1311
1311
|
}
|
|
1312
|
-
function
|
|
1312
|
+
function ct() {
|
|
1313
1313
|
try {
|
|
1314
|
-
return
|
|
1314
|
+
return M.existsSync(pe) && M.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 Bt(o) {
|
|
1320
1320
|
if (!o || !o.expiresAt)
|
|
1321
1321
|
return !0;
|
|
1322
1322
|
const t = 5 * 60 * 1e3, e = new Date(o.expiresAt).getTime();
|
|
1323
1323
|
return Date.now() > e - t;
|
|
1324
1324
|
}
|
|
1325
1325
|
function $e() {
|
|
1326
|
-
const o =
|
|
1326
|
+
const o = Be();
|
|
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,
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1332
|
+
const ae = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, Je = `http://localhost:${Se}/callback`, Jt = "myop-cli";
|
|
1333
|
+
function zt() {
|
|
1334
|
+
return He.randomBytes(32).toString("base64url");
|
|
1335
1335
|
}
|
|
1336
|
-
function
|
|
1337
|
-
return
|
|
1336
|
+
function Wt(o) {
|
|
1337
|
+
return He.createHash("sha256").update(o).digest("base64url");
|
|
1338
1338
|
}
|
|
1339
|
-
async function
|
|
1339
|
+
async function Vt() {
|
|
1340
1340
|
const o = await fetch(`${ae}/oauth/register`, {
|
|
1341
1341
|
method: "POST",
|
|
1342
1342
|
headers: { "Content-Type": "application/json" },
|
|
1343
1343
|
body: JSON.stringify({
|
|
1344
|
-
client_name:
|
|
1345
|
-
redirect_uris: [
|
|
1344
|
+
client_name: Jt,
|
|
1345
|
+
redirect_uris: [Je],
|
|
1346
1346
|
grant_types: ["authorization_code", "refresh_token"],
|
|
1347
1347
|
response_types: ["code"]
|
|
1348
1348
|
})
|
|
@@ -1371,7 +1371,7 @@ function we(o, t, e, n = null) {
|
|
|
1371
1371
|
success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
|
|
1372
1372
|
error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
|
|
1373
1373
|
warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
|
|
1374
|
-
}, { accent:
|
|
1374
|
+
}, { accent: d, glow: h } = i[o] || i.error;
|
|
1375
1375
|
return `<!DOCTYPE html>
|
|
1376
1376
|
<html lang="en">
|
|
1377
1377
|
<head>
|
|
@@ -1432,7 +1432,7 @@ function we(o, t, e, n = null) {
|
|
|
1432
1432
|
h1 {
|
|
1433
1433
|
font-size: 20px;
|
|
1434
1434
|
font-weight: 500;
|
|
1435
|
-
color: ${
|
|
1435
|
+
color: ${d};
|
|
1436
1436
|
margin-bottom: 12px;
|
|
1437
1437
|
letter-spacing: -0.5px;
|
|
1438
1438
|
}
|
|
@@ -1464,8 +1464,8 @@ function we(o, t, e, n = null) {
|
|
|
1464
1464
|
display: inline-flex;
|
|
1465
1465
|
align-items: center;
|
|
1466
1466
|
gap: 8px;
|
|
1467
|
-
background: ${
|
|
1468
|
-
border: 1px solid ${
|
|
1467
|
+
background: ${h};
|
|
1468
|
+
border: 1px solid ${d}33;
|
|
1469
1469
|
border-radius: 4px;
|
|
1470
1470
|
padding: 10px 16px;
|
|
1471
1471
|
font-size: 12px;
|
|
@@ -1519,19 +1519,19 @@ function we(o, t, e, n = null) {
|
|
|
1519
1519
|
</body>
|
|
1520
1520
|
</html>`;
|
|
1521
1521
|
}
|
|
1522
|
-
function
|
|
1522
|
+
function Gt(o) {
|
|
1523
1523
|
return new Promise((t, e) => {
|
|
1524
|
-
const n =
|
|
1525
|
-
const
|
|
1526
|
-
if (
|
|
1527
|
-
const
|
|
1528
|
-
if (
|
|
1524
|
+
const n = bt.createServer((s, i) => {
|
|
1525
|
+
const d = new tt(s.url, `http://localhost:${Se}`);
|
|
1526
|
+
if (d.pathname === "/callback") {
|
|
1527
|
+
const h = d.searchParams.get("code"), y = d.searchParams.get("state"), c = d.searchParams.get("error");
|
|
1528
|
+
if (c) {
|
|
1529
1529
|
i.writeHead(200, { "Content-Type": "text/html" }), i.end(we(
|
|
1530
1530
|
"error",
|
|
1531
1531
|
"Authentication Failed",
|
|
1532
1532
|
"Unable to complete the authentication process.",
|
|
1533
|
-
|
|
1534
|
-
)), n.close(), e(new Error(`OAuth error: ${
|
|
1533
|
+
c
|
|
1534
|
+
)), n.close(), e(new Error(`OAuth error: ${c}`));
|
|
1535
1535
|
return;
|
|
1536
1536
|
}
|
|
1537
1537
|
if (y !== o) {
|
|
@@ -1543,7 +1543,7 @@ function Yt(o) {
|
|
|
1543
1543
|
)), n.close(), e(new Error("State mismatch"));
|
|
1544
1544
|
return;
|
|
1545
1545
|
}
|
|
1546
|
-
if (!
|
|
1546
|
+
if (!h) {
|
|
1547
1547
|
i.writeHead(400, { "Content-Type": "text/html" }), i.end(we(
|
|
1548
1548
|
"error",
|
|
1549
1549
|
"Missing Authorization Code",
|
|
@@ -1556,7 +1556,7 @@ function Yt(o) {
|
|
|
1556
1556
|
"success",
|
|
1557
1557
|
"Authentication Successful",
|
|
1558
1558
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1559
|
-
)), n.close(), t(
|
|
1559
|
+
)), n.close(), t(h);
|
|
1560
1560
|
} else
|
|
1561
1561
|
i.writeHead(404), i.end("Not found");
|
|
1562
1562
|
});
|
|
@@ -1567,15 +1567,15 @@ function Yt(o) {
|
|
|
1567
1567
|
}, 5 * 60 * 1e3);
|
|
1568
1568
|
});
|
|
1569
1569
|
}
|
|
1570
|
-
async function
|
|
1570
|
+
async function Yt(o, t, e) {
|
|
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 ot({
|
|
1575
1575
|
grant_type: "authorization_code",
|
|
1576
1576
|
code: o,
|
|
1577
1577
|
client_id: t,
|
|
1578
|
-
redirect_uri:
|
|
1578
|
+
redirect_uri: Je,
|
|
1579
1579
|
code_verifier: e
|
|
1580
1580
|
})
|
|
1581
1581
|
});
|
|
@@ -1585,11 +1585,11 @@ async function Kt(o, t, e) {
|
|
|
1585
1585
|
}
|
|
1586
1586
|
return n.json();
|
|
1587
1587
|
}
|
|
1588
|
-
async function
|
|
1588
|
+
async function Kt(o, t) {
|
|
1589
1589
|
const e = 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 ot({
|
|
1593
1593
|
grant_type: "refresh_token",
|
|
1594
1594
|
refresh_token: o,
|
|
1595
1595
|
client_id: t
|
|
@@ -1601,8 +1601,8 @@ async function Qt(o, t) {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
return e.json();
|
|
1603
1603
|
}
|
|
1604
|
-
async function
|
|
1605
|
-
var s, i,
|
|
1604
|
+
async function Qt(o) {
|
|
1605
|
+
var s, i, d;
|
|
1606
1606
|
const t = await fetch(`${ae}/mcp`, {
|
|
1607
1607
|
method: "POST",
|
|
1608
1608
|
headers: {
|
|
@@ -1624,7 +1624,7 @@ async function Zt(o) {
|
|
|
1624
1624
|
const e = await t.json();
|
|
1625
1625
|
if (e.error)
|
|
1626
1626
|
throw new Error(e.error.message);
|
|
1627
|
-
const n = (
|
|
1627
|
+
const n = (d = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : d.text;
|
|
1628
1628
|
if (n)
|
|
1629
1629
|
return JSON.parse(n);
|
|
1630
1630
|
throw new Error("Invalid response from whoami");
|
|
@@ -1633,48 +1633,48 @@ async function de() {
|
|
|
1633
1633
|
const o = Y("Starting authentication...").start();
|
|
1634
1634
|
try {
|
|
1635
1635
|
o.text = "Registering OAuth client...";
|
|
1636
|
-
const e = (await
|
|
1636
|
+
const e = (await Vt()).client_id, n = zt(), s = Wt(n), i = He.randomBytes(16).toString("hex");
|
|
1637
1637
|
o.text = "Waiting for authorization...";
|
|
1638
|
-
const
|
|
1639
|
-
|
|
1640
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1641
|
-
`), await
|
|
1642
|
-
const y = await
|
|
1638
|
+
const d = Gt(i), h = new tt(`${ae}/oauth/authorize`);
|
|
1639
|
+
h.searchParams.set("response_type", "code"), h.searchParams.set("client_id", e), h.searchParams.set("redirect_uri", Je), h.searchParams.set("code_challenge", s), h.searchParams.set("code_challenge_method", "S256"), h.searchParams.set("state", i), o.stop(), console.log(`
|
|
1640
|
+
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${h.toString()}
|
|
1641
|
+
`), await Ct(h.toString());
|
|
1642
|
+
const y = await d;
|
|
1643
1643
|
o.start("Exchanging authorization code...");
|
|
1644
|
-
const
|
|
1644
|
+
const c = await Yt(y, e, n);
|
|
1645
1645
|
o.text = "Getting user info...";
|
|
1646
|
-
const l = await
|
|
1647
|
-
accessToken:
|
|
1648
|
-
refreshToken:
|
|
1649
|
-
expiresAt: new Date(Date.now() +
|
|
1646
|
+
const l = await Qt(c.access_token), C = {
|
|
1647
|
+
accessToken: c.access_token,
|
|
1648
|
+
refreshToken: c.refresh_token,
|
|
1649
|
+
expiresAt: new Date(Date.now() + c.expires_in * 1e3).toISOString(),
|
|
1650
1650
|
clientId: e,
|
|
1651
1651
|
userId: l.userId,
|
|
1652
1652
|
userEmail: l.email
|
|
1653
1653
|
};
|
|
1654
|
-
return
|
|
1654
|
+
return lt(C), o.succeed(`Authenticated as ${l.email}`), C;
|
|
1655
1655
|
} catch (t) {
|
|
1656
1656
|
throw o.fail(`Authentication failed: ${t.message}`), t;
|
|
1657
1657
|
}
|
|
1658
1658
|
}
|
|
1659
|
-
async function
|
|
1660
|
-
const o =
|
|
1659
|
+
async function dt() {
|
|
1660
|
+
const o = Be();
|
|
1661
1661
|
if (!o) {
|
|
1662
1662
|
console.log("Not currently logged in.");
|
|
1663
1663
|
return;
|
|
1664
1664
|
}
|
|
1665
|
-
|
|
1665
|
+
ct(), console.log(`β
Logged out (was: ${o.userEmail})`);
|
|
1666
1666
|
}
|
|
1667
|
-
async function
|
|
1668
|
-
let o =
|
|
1667
|
+
async function ze() {
|
|
1668
|
+
let o = Be();
|
|
1669
1669
|
if (!o)
|
|
1670
1670
|
return console.log(`Not logged in. Starting authentication...
|
|
1671
1671
|
`), await de();
|
|
1672
|
-
if (!
|
|
1672
|
+
if (!Bt(o))
|
|
1673
1673
|
return o;
|
|
1674
1674
|
if (o.refreshToken) {
|
|
1675
1675
|
const t = Y("Refreshing access token...").start();
|
|
1676
1676
|
try {
|
|
1677
|
-
const e = await
|
|
1677
|
+
const e = await Kt(
|
|
1678
1678
|
o.refreshToken,
|
|
1679
1679
|
o.clientId
|
|
1680
1680
|
);
|
|
@@ -1683,9 +1683,9 @@ async function We() {
|
|
|
1683
1683
|
accessToken: e.access_token,
|
|
1684
1684
|
refreshToken: e.refresh_token,
|
|
1685
1685
|
expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
|
|
1686
|
-
},
|
|
1686
|
+
}, lt(o), t.succeed("Token refreshed"), o;
|
|
1687
1687
|
} catch {
|
|
1688
|
-
return t.warn("Token refresh failed, please log in again"),
|
|
1688
|
+
return t.warn("Token refresh failed, please log in again"), ct(), await de();
|
|
1689
1689
|
}
|
|
1690
1690
|
}
|
|
1691
1691
|
return console.log(`Session expired. Please log in again.
|
|
@@ -1694,51 +1694,51 @@ async function We() {
|
|
|
1694
1694
|
function be() {
|
|
1695
1695
|
return ae;
|
|
1696
1696
|
}
|
|
1697
|
-
const
|
|
1698
|
-
function
|
|
1697
|
+
const ee = "@myop/cli", je = process.platform === "win32";
|
|
1698
|
+
function Zt() {
|
|
1699
1699
|
try {
|
|
1700
|
-
return
|
|
1700
|
+
return X("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
|
|
1701
1701
|
} catch {
|
|
1702
1702
|
return "https://registry.npmjs.org/";
|
|
1703
1703
|
}
|
|
1704
1704
|
}
|
|
1705
|
-
function
|
|
1705
|
+
function qt() {
|
|
1706
1706
|
try {
|
|
1707
|
-
return
|
|
1707
|
+
return X("npm config get prefix", { encoding: "utf-8" }).trim();
|
|
1708
1708
|
} catch {
|
|
1709
1709
|
return null;
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
|
-
async function
|
|
1712
|
+
async function Xt() {
|
|
1713
1713
|
try {
|
|
1714
|
-
const o =
|
|
1714
|
+
const o = Zt().replace(/\/$/, ""), t = await fetch(`${o}/${ee}/latest`);
|
|
1715
1715
|
return t.ok ? (await t.json()).version : null;
|
|
1716
1716
|
} catch {
|
|
1717
1717
|
return null;
|
|
1718
1718
|
}
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function eo(o, t) {
|
|
1721
1721
|
const e = o.split(".").map(Number), n = t.split(".").map(Number);
|
|
1722
1722
|
for (let s = 0; s < Math.max(e.length, n.length); s++) {
|
|
1723
|
-
const i = e[s] || 0,
|
|
1724
|
-
if (i >
|
|
1725
|
-
if (i <
|
|
1723
|
+
const i = e[s] || 0, d = n[s] || 0;
|
|
1724
|
+
if (i > d) return 1;
|
|
1725
|
+
if (i < d) return -1;
|
|
1726
1726
|
}
|
|
1727
1727
|
return 0;
|
|
1728
1728
|
}
|
|
1729
|
-
async function
|
|
1729
|
+
async function to(o) {
|
|
1730
1730
|
const t = Y({
|
|
1731
1731
|
text: "Checking for updates...",
|
|
1732
1732
|
color: "cyan"
|
|
1733
|
-
}).start(), e = await
|
|
1734
|
-
if (t.stop(), !e ||
|
|
1733
|
+
}).start(), e = await Xt();
|
|
1734
|
+
if (t.stop(), !e || eo(e, o) <= 0)
|
|
1735
1735
|
return !1;
|
|
1736
1736
|
console.log(`
|
|
1737
1737
|
π¦ New version available: ${o} β ${e}
|
|
1738
1738
|
`);
|
|
1739
1739
|
let n;
|
|
1740
1740
|
try {
|
|
1741
|
-
n = await
|
|
1741
|
+
n = await et({
|
|
1742
1742
|
message: "Would you like to update now?",
|
|
1743
1743
|
choices: [
|
|
1744
1744
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1753,50 +1753,50 @@ async function oo(o) {
|
|
|
1753
1753
|
}
|
|
1754
1754
|
if (n) {
|
|
1755
1755
|
const s = Y({
|
|
1756
|
-
text: `Updating ${
|
|
1756
|
+
text: `Updating ${ee} to v${e}...`,
|
|
1757
1757
|
color: "green"
|
|
1758
|
-
}).start(), i = `npm install -g ${
|
|
1758
|
+
}).start(), i = `npm install -g ${ee}@latest`, d = qt();
|
|
1759
1759
|
try {
|
|
1760
|
-
|
|
1760
|
+
X(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
|
|
1761
1761
|
} catch {
|
|
1762
1762
|
s.stop(), console.log(`
|
|
1763
1763
|
π Elevated permissions required.
|
|
1764
1764
|
`);
|
|
1765
1765
|
try {
|
|
1766
1766
|
if (je) {
|
|
1767
|
-
const l = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${
|
|
1768
|
-
|
|
1767
|
+
const l = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${ee}@latest --prefix \\"${d}\\"` : `install -g ${ee}@latest`}' -Verb RunAs -Wait`;
|
|
1768
|
+
X(`powershell -Command "${l}"`, { stdio: "inherit" });
|
|
1769
1769
|
} else {
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1770
|
+
const c = d ? `sudo npm install -g ${ee}@latest --prefix "${d}"` : `sudo ${i}`;
|
|
1771
|
+
X(c, { stdio: "inherit" });
|
|
1772
1772
|
}
|
|
1773
1773
|
console.log(`
|
|
1774
1774
|
β
Updated to v${e}`);
|
|
1775
1775
|
} catch {
|
|
1776
1776
|
console.log(`
|
|
1777
1777
|
β Update failed`);
|
|
1778
|
-
const l = je ? `npm install -g ${
|
|
1778
|
+
const l = je ? `npm install -g ${ee}@latest (run as Administrator)` : `sudo npm install -g ${ee}@latest`;
|
|
1779
1779
|
console.log(`
|
|
1780
1780
|
Please run manually: ${l}
|
|
1781
1781
|
`), process.exit(1);
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
-
let
|
|
1784
|
+
let h = null;
|
|
1785
1785
|
try {
|
|
1786
1786
|
let y;
|
|
1787
|
-
|
|
1788
|
-
const
|
|
1789
|
-
|
|
1787
|
+
d ? y = je ? Te(d, "node_modules") : Te(d, "lib", "node_modules") : y = X("npm root -g", { encoding: "utf-8" }).trim();
|
|
1788
|
+
const c = Te(y, ee, "package.json"), l = $t(c, "utf-8");
|
|
1789
|
+
h = JSON.parse(l).version;
|
|
1790
1790
|
} catch {
|
|
1791
1791
|
}
|
|
1792
|
-
if (
|
|
1792
|
+
if (h === e)
|
|
1793
1793
|
return console.log(`
|
|
1794
1794
|
π Restarting...
|
|
1795
|
-
`),
|
|
1795
|
+
`), xt(process.argv[0], process.argv.slice(1), {
|
|
1796
1796
|
stdio: "inherit",
|
|
1797
1797
|
shell: !0
|
|
1798
|
-
}).on("close", (
|
|
1799
|
-
process.exit(
|
|
1798
|
+
}).on("close", (c) => {
|
|
1799
|
+
process.exit(c || 0);
|
|
1800
1800
|
}), !0;
|
|
1801
1801
|
console.log(`
|
|
1802
1802
|
Please run myop again to use the new version.
|
|
@@ -1804,35 +1804,35 @@ Please run myop again to use the new version.
|
|
|
1804
1804
|
}
|
|
1805
1805
|
return !1;
|
|
1806
1806
|
}
|
|
1807
|
-
const
|
|
1808
|
-
function
|
|
1809
|
-
|
|
1807
|
+
const Le = _.join(nt.homedir(), ".myop"), De = _.join(Le, "preferences.json");
|
|
1808
|
+
function oo() {
|
|
1809
|
+
M.existsSync(Le) || M.mkdirSync(Le, { recursive: !0, mode: 448 });
|
|
1810
1810
|
}
|
|
1811
|
-
function
|
|
1811
|
+
function pt() {
|
|
1812
1812
|
try {
|
|
1813
|
-
if (!
|
|
1813
|
+
if (!M.existsSync(De))
|
|
1814
1814
|
return {};
|
|
1815
|
-
const o =
|
|
1815
|
+
const o = M.readFileSync(De, "utf8");
|
|
1816
1816
|
return JSON.parse(o);
|
|
1817
1817
|
} catch {
|
|
1818
1818
|
return {};
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
|
-
function
|
|
1822
|
-
|
|
1823
|
-
const e = { ...
|
|
1824
|
-
|
|
1821
|
+
function no(o) {
|
|
1822
|
+
oo();
|
|
1823
|
+
const e = { ...pt(), ...o };
|
|
1824
|
+
M.writeFileSync(De, JSON.stringify(e, null, 2), {
|
|
1825
1825
|
mode: 384
|
|
1826
1826
|
});
|
|
1827
1827
|
}
|
|
1828
|
-
function
|
|
1829
|
-
return
|
|
1828
|
+
function so() {
|
|
1829
|
+
return pt().defaultOrganization || null;
|
|
1830
1830
|
}
|
|
1831
|
-
function
|
|
1832
|
-
|
|
1831
|
+
function Fe({ id: o, name: t }) {
|
|
1832
|
+
no({ defaultOrganization: { id: o, name: t } });
|
|
1833
1833
|
}
|
|
1834
|
-
async function
|
|
1835
|
-
var
|
|
1834
|
+
async function io(o, t, e, n = {}) {
|
|
1835
|
+
var h, y, c;
|
|
1836
1836
|
const s = await fetch(`${o}/mcp`, {
|
|
1837
1837
|
method: "POST",
|
|
1838
1838
|
headers: {
|
|
@@ -1854,72 +1854,60 @@ async function ro(o, t, e, n = {}) {
|
|
|
1854
1854
|
const i = await s.json();
|
|
1855
1855
|
if (i.error)
|
|
1856
1856
|
throw new Error(i.error.message || "MCP error");
|
|
1857
|
-
const
|
|
1858
|
-
if (!
|
|
1857
|
+
const d = (c = (y = (h = i.result) == null ? void 0 : h.content) == null ? void 0 : y[0]) == null ? void 0 : c.text;
|
|
1858
|
+
if (!d)
|
|
1859
1859
|
throw new Error(`No content returned from ${e}`);
|
|
1860
|
-
return JSON.parse(
|
|
1860
|
+
return JSON.parse(d);
|
|
1861
1861
|
}
|
|
1862
|
-
const
|
|
1862
|
+
const ro = (o) => new Promise((t) => setTimeout(t, o)), ao = () => {
|
|
1863
1863
|
let o = new URL(import.meta.url).pathname;
|
|
1864
1864
|
process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
|
|
1865
|
-
const t =
|
|
1866
|
-
return
|
|
1867
|
-
},
|
|
1868
|
-
C.mkdirSync(t, { recursive: !0 });
|
|
1869
|
-
const e = C.readdirSync(o, { withFileTypes: !0 });
|
|
1870
|
-
for (const n of e) {
|
|
1871
|
-
const s = O.join(o, n.name), i = O.join(t, n.name);
|
|
1872
|
-
n.isDirectory() ? He(s, i) : C.copyFileSync(s, i);
|
|
1873
|
-
}
|
|
1874
|
-
}, Ve = (o) => {
|
|
1875
|
-
const t = lo();
|
|
1876
|
-
if (!C.existsSync(t))
|
|
1877
|
-
return console.info("Skills source directory not found, skipping skills installation"), !1;
|
|
1865
|
+
const t = _.dirname(o);
|
|
1866
|
+
return _.join(t, "skills");
|
|
1867
|
+
}, lo = (o) => {
|
|
1878
1868
|
try {
|
|
1879
|
-
const
|
|
1880
|
-
|
|
1881
|
-
const
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
}
|
|
1901
|
-
return !0;
|
|
1869
|
+
const t = _.join(o, "package.json");
|
|
1870
|
+
if (!M.existsSync(t)) return [];
|
|
1871
|
+
const e = JSON.parse(M.readFileSync(t, "utf-8"));
|
|
1872
|
+
return Object.keys({ ...e.dependencies, ...e.devDependencies });
|
|
1873
|
+
} catch {
|
|
1874
|
+
return [];
|
|
1875
|
+
}
|
|
1876
|
+
}, We = async (o) => {
|
|
1877
|
+
const t = ao();
|
|
1878
|
+
if (!M.existsSync(t))
|
|
1879
|
+
return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
|
|
1880
|
+
try {
|
|
1881
|
+
const e = lo(o), n = ["myop-cli", "myop-component"], s = [
|
|
1882
|
+
{ deps: ["@myop/react", "react"], skill: "myop-react-host" },
|
|
1883
|
+
{ deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
|
|
1884
|
+
{ deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
|
|
1885
|
+
{ deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
|
|
1886
|
+
], i = s.filter(({ deps: c }) => c.some((l) => e.includes(l))).map(({ skill: c }) => c), d = s.flatMap(({ deps: c }) => c.filter((l) => e.includes(l)));
|
|
1887
|
+
i.length > 0 ? n.push(...i) : n.push(...s.map((c) => c.skill));
|
|
1888
|
+
const h = n.map((c) => `--skill ${c}`).join(" "), y = `npx -y skills add "${t}" ${h} --agent '*' --copy -y`;
|
|
1889
|
+
return X(y, { cwd: o, stdio: "pipe" }), { success: !0, detected: d, skillNames: n };
|
|
1902
1890
|
} catch (e) {
|
|
1903
|
-
return console.info("Failed to install skills:", e.message), !1;
|
|
1891
|
+
return console.info("Failed to install skills:", e.message), { success: !1 };
|
|
1904
1892
|
}
|
|
1905
|
-
},
|
|
1893
|
+
}, Ve = (o = ".", t = 3, e = 0) => {
|
|
1906
1894
|
const n = [];
|
|
1907
1895
|
if (e > t) return n;
|
|
1908
1896
|
try {
|
|
1909
|
-
const s =
|
|
1897
|
+
const s = M.readdirSync(o, { withFileTypes: !0 });
|
|
1910
1898
|
for (const i of s) {
|
|
1911
|
-
const
|
|
1899
|
+
const d = _.join(o, i.name);
|
|
1912
1900
|
if (i.isDirectory()) {
|
|
1913
1901
|
if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
|
|
1914
1902
|
continue;
|
|
1915
|
-
n.push(...
|
|
1903
|
+
n.push(...Ve(d, t, e + 1));
|
|
1916
1904
|
} else if (i.name === "myop.config.json")
|
|
1917
1905
|
try {
|
|
1918
|
-
const
|
|
1906
|
+
const h = M.readFileSync(d, "utf-8"), y = JSON.parse(h);
|
|
1919
1907
|
n.push({
|
|
1920
1908
|
path: o,
|
|
1921
|
-
configPath:
|
|
1922
|
-
name: y.name || y.componentName ||
|
|
1909
|
+
configPath: d,
|
|
1910
|
+
name: y.name || y.componentName || _.basename(o),
|
|
1923
1911
|
componentId: y.componentId || null,
|
|
1924
1912
|
config: y
|
|
1925
1913
|
});
|
|
@@ -1939,7 +1927,7 @@ const Ce = (o = !1) => {
|
|
|
1939
1927
|
verbose: t
|
|
1940
1928
|
};
|
|
1941
1929
|
try {
|
|
1942
|
-
return v.myopConfig =
|
|
1930
|
+
return v.myopConfig = Mt(v.options.configPath), { configFound: !0 };
|
|
1943
1931
|
} catch (e) {
|
|
1944
1932
|
if (o) {
|
|
1945
1933
|
console.info(`
|
|
@@ -1949,7 +1937,7 @@ const Ce = (o = !1) => {
|
|
|
1949
1937
|
author: "@myop-cli",
|
|
1950
1938
|
flows: []
|
|
1951
1939
|
};
|
|
1952
|
-
return
|
|
1940
|
+
return Ue(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
|
|
1953
1941
|
} catch {
|
|
1954
1942
|
return console.info("Error details :", e), { configFound: !1, error: e };
|
|
1955
1943
|
}
|
|
@@ -1958,11 +1946,11 @@ const Ce = (o = !1) => {
|
|
|
1958
1946
|
}
|
|
1959
1947
|
};
|
|
1960
1948
|
[
|
|
1961
|
-
new
|
|
1962
|
-
...
|
|
1949
|
+
new _e(),
|
|
1950
|
+
...jt
|
|
1963
1951
|
];
|
|
1964
|
-
const co = "0.1.
|
|
1965
|
-
v.program = new
|
|
1952
|
+
const co = "0.1.47";
|
|
1953
|
+
v.program = new vt();
|
|
1966
1954
|
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(co);
|
|
1967
1955
|
v.program.addOption(new me("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
1968
1956
|
v.program.addOption(new me("-h, --help", "Show helpful information"));
|
|
@@ -1970,13 +1958,13 @@ v.program.addOption(new me("-v, --verbose", "Enables verbose output mode for the
|
|
|
1970
1958
|
v.program.addOption(new me("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
|
|
1971
1959
|
v.program.addOption(new me("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
|
|
1972
1960
|
v.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, t) => {
|
|
1973
|
-
Ce(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" &&
|
|
1961
|
+
Ce(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && it._action(t), process.exit();
|
|
1974
1962
|
});
|
|
1975
1963
|
v.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, t) => {
|
|
1976
|
-
Ce(), console.info("removing ", o, t, v.options.configPath), o === "flow" &&
|
|
1964
|
+
Ce(), console.info("removing ", o, t, v.options.configPath), o === "flow" && rt._action(t), process.exit();
|
|
1977
1965
|
});
|
|
1978
1966
|
v.program.command("install").description("Install Myop assets").action(async () => {
|
|
1979
|
-
Ce(), await
|
|
1967
|
+
Ce(), await st.action();
|
|
1980
1968
|
});
|
|
1981
1969
|
v.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1982
1970
|
try {
|
|
@@ -1987,7 +1975,7 @@ v.program.command("login").description("Authenticate with Myop platform").action
|
|
|
1987
1975
|
process.exit(0);
|
|
1988
1976
|
});
|
|
1989
1977
|
v.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1990
|
-
await
|
|
1978
|
+
await dt(), process.exit(0);
|
|
1991
1979
|
});
|
|
1992
1980
|
v.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1993
1981
|
const o = $e();
|
|
@@ -2005,28 +1993,28 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
|
|
|
2005
1993
|
process.exit(0);
|
|
2006
1994
|
});
|
|
2007
1995
|
v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
|
|
2008
|
-
var
|
|
1996
|
+
var P, g, w, j, k, b;
|
|
2009
1997
|
const t = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2010
1998
|
let e = {};
|
|
2011
|
-
if (
|
|
1999
|
+
if (M.existsSync(t))
|
|
2012
2000
|
try {
|
|
2013
|
-
e = JSON.parse(
|
|
2001
|
+
e = JSON.parse(M.readFileSync(t, "utf-8"));
|
|
2014
2002
|
} catch (p) {
|
|
2015
2003
|
console.error(`β οΈ Failed to parse ${t}:`, p.message);
|
|
2016
2004
|
}
|
|
2017
2005
|
o && (e.componentId = o);
|
|
2018
|
-
const n = e.name || e.componentName ||
|
|
2006
|
+
const n = e.name || e.componentName || _.basename(process.cwd());
|
|
2019
2007
|
console.log(`
|
|
2020
2008
|
π Component: ${n}`);
|
|
2021
2009
|
let s = null, i = !1;
|
|
2022
2010
|
try {
|
|
2023
|
-
const p = JSON.parse(
|
|
2011
|
+
const p = JSON.parse(M.readFileSync("package.json", "utf-8"));
|
|
2024
2012
|
i = !!(p.scripts && p.scripts.build);
|
|
2025
2013
|
} catch {
|
|
2026
2014
|
}
|
|
2027
2015
|
if (!i) {
|
|
2028
|
-
const p =
|
|
2029
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2016
|
+
const p = M.readdirSync(".").filter(
|
|
2017
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && M.statSync(E).isFile()
|
|
2030
2018
|
);
|
|
2031
2019
|
p.length === 1 && (s = p[0]);
|
|
2032
2020
|
}
|
|
@@ -2035,49 +2023,49 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2035
2023
|
else if (i) {
|
|
2036
2024
|
const { exec: p } = await import("child_process");
|
|
2037
2025
|
let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
2038
|
-
const x = (
|
|
2039
|
-
const
|
|
2040
|
-
p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (
|
|
2041
|
-
if (!
|
|
2042
|
-
|
|
2026
|
+
const x = (R = !1) => new Promise((D) => {
|
|
2027
|
+
const L = Y(R ? "Retrying build..." : "Building project...").start();
|
|
2028
|
+
p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (T, J, F) => {
|
|
2029
|
+
if (!T) {
|
|
2030
|
+
L.succeed("Build completed"), D(!0);
|
|
2043
2031
|
return;
|
|
2044
2032
|
}
|
|
2045
|
-
if (
|
|
2046
|
-
const V = await
|
|
2033
|
+
if (L.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
|
|
2034
|
+
const V = await at(T, J, F, p, E);
|
|
2047
2035
|
if (E = { ...E, ...V }, V.handled) {
|
|
2048
2036
|
const te = await x(!0);
|
|
2049
|
-
|
|
2037
|
+
D(te);
|
|
2050
2038
|
return;
|
|
2051
2039
|
}
|
|
2052
2040
|
}
|
|
2053
|
-
console.error(
|
|
2041
|
+
console.error(T.message), D(!1);
|
|
2054
2042
|
});
|
|
2055
2043
|
});
|
|
2056
2044
|
await x() || process.exit(1);
|
|
2057
2045
|
}
|
|
2058
|
-
let
|
|
2046
|
+
let d;
|
|
2059
2047
|
if (s)
|
|
2060
|
-
|
|
2061
|
-
else if (
|
|
2062
|
-
|
|
2048
|
+
d = s;
|
|
2049
|
+
else if (M.existsSync("./dist/index.html"))
|
|
2050
|
+
d = "./dist/index.html";
|
|
2063
2051
|
else {
|
|
2064
|
-
const p =
|
|
2065
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2052
|
+
const p = M.readdirSync(".").filter(
|
|
2053
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && M.statSync(E).isFile()
|
|
2066
2054
|
);
|
|
2067
|
-
p.length === 1 ?
|
|
2055
|
+
p.length === 1 ? d = p[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));
|
|
2068
2056
|
}
|
|
2069
|
-
const
|
|
2070
|
-
console.log(` File: ${
|
|
2057
|
+
const h = M.readFileSync(d, "utf-8");
|
|
2058
|
+
console.log(` File: ${d} (${(h.length / 1024).toFixed(1)} KB)`);
|
|
2071
2059
|
let y;
|
|
2072
2060
|
try {
|
|
2073
|
-
y = await
|
|
2061
|
+
y = await ze();
|
|
2074
2062
|
} catch (p) {
|
|
2075
2063
|
console.error("β Authentication failed:", p.message), process.exit(1);
|
|
2076
2064
|
}
|
|
2077
|
-
const
|
|
2078
|
-
let l = Y("Uploading...").start(),
|
|
2065
|
+
const c = be();
|
|
2066
|
+
let l = Y("Uploading...").start(), C;
|
|
2079
2067
|
try {
|
|
2080
|
-
const p = await fetch(`${
|
|
2068
|
+
const p = await fetch(`${c}/mcp`, {
|
|
2081
2069
|
method: "POST",
|
|
2082
2070
|
headers: {
|
|
2083
2071
|
"Content-Type": "application/json",
|
|
@@ -2102,39 +2090,39 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2102
2090
|
const E = await p.json();
|
|
2103
2091
|
if (E.error)
|
|
2104
2092
|
throw new Error(E.error.message);
|
|
2105
|
-
const x = (w = (
|
|
2106
|
-
if (
|
|
2107
|
-
throw new Error(
|
|
2093
|
+
const x = (w = (g = (P = E.result) == null ? void 0 : P.content) == null ? void 0 : g[0]) == null ? void 0 : w.text;
|
|
2094
|
+
if (C = JSON.parse(x), !C.success)
|
|
2095
|
+
throw new Error(C.error);
|
|
2108
2096
|
} catch (p) {
|
|
2109
2097
|
l.fail("Failed to get upload URL"), console.error(" ", p.message), process.exit(1);
|
|
2110
2098
|
}
|
|
2111
2099
|
try {
|
|
2112
2100
|
let p;
|
|
2113
|
-
const E =
|
|
2101
|
+
const E = C.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
2114
2102
|
if (E)
|
|
2115
2103
|
p = E[1];
|
|
2116
2104
|
else {
|
|
2117
|
-
const
|
|
2118
|
-
if (
|
|
2119
|
-
p =
|
|
2105
|
+
const O = C.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
2106
|
+
if (O)
|
|
2107
|
+
p = O[1];
|
|
2120
2108
|
else
|
|
2121
2109
|
throw new Error("Could not parse presigned URL");
|
|
2122
2110
|
}
|
|
2123
2111
|
const x = await fetch(p, {
|
|
2124
2112
|
method: "PUT",
|
|
2125
2113
|
headers: { "Content-Type": "text/html" },
|
|
2126
|
-
body:
|
|
2114
|
+
body: h
|
|
2127
2115
|
});
|
|
2128
2116
|
if (!x.ok) {
|
|
2129
|
-
const
|
|
2130
|
-
throw new Error(`Upload failed: ${x.status} ${
|
|
2117
|
+
const O = await x.text();
|
|
2118
|
+
throw new Error(`Upload failed: ${x.status} ${O}`);
|
|
2131
2119
|
}
|
|
2132
2120
|
} catch (p) {
|
|
2133
2121
|
l.fail("Upload failed"), console.error(" ", p.message), process.exit(1);
|
|
2134
2122
|
}
|
|
2135
|
-
let
|
|
2123
|
+
let u;
|
|
2136
2124
|
try {
|
|
2137
|
-
const p = await fetch(`${
|
|
2125
|
+
const p = await fetch(`${c}/mcp`, {
|
|
2138
2126
|
method: "POST",
|
|
2139
2127
|
headers: {
|
|
2140
2128
|
"Content-Type": "application/json",
|
|
@@ -2147,7 +2135,7 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2147
2135
|
params: {
|
|
2148
2136
|
name: "confirm_upload",
|
|
2149
2137
|
arguments: {
|
|
2150
|
-
uploadId:
|
|
2138
|
+
uploadId: C.uploadId
|
|
2151
2139
|
}
|
|
2152
2140
|
}
|
|
2153
2141
|
})
|
|
@@ -2157,32 +2145,32 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2157
2145
|
const E = await p.json();
|
|
2158
2146
|
if (E.error)
|
|
2159
2147
|
throw new Error(E.error.message);
|
|
2160
|
-
const x = (b = (
|
|
2161
|
-
if (
|
|
2162
|
-
throw new Error(
|
|
2148
|
+
const x = (b = (k = (j = E.result) == null ? void 0 : j.content) == null ? void 0 : k[0]) == null ? void 0 : b.text;
|
|
2149
|
+
if (u = JSON.parse(x), !u.success)
|
|
2150
|
+
throw new Error(u.error);
|
|
2163
2151
|
l.succeed("Pushed successfully");
|
|
2164
2152
|
} catch (p) {
|
|
2165
2153
|
l.fail("Confirmation failed"), console.error(" ", p.message), process.exit(1);
|
|
2166
2154
|
}
|
|
2167
|
-
if (
|
|
2168
|
-
e.componentId =
|
|
2155
|
+
if (u.isNewComponent || !e.componentId || e.componentId === "DEV") {
|
|
2156
|
+
e.componentId = u.componentId, e.organization = u.orgId, e.name || (e.name = u.componentName);
|
|
2169
2157
|
try {
|
|
2170
|
-
|
|
2158
|
+
M.writeFileSync(t, JSON.stringify(e, null, 2));
|
|
2171
2159
|
} catch (p) {
|
|
2172
|
-
console.log(`β οΈ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${
|
|
2160
|
+
console.log(`β οΈ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${u.componentId}" manually`);
|
|
2173
2161
|
}
|
|
2174
2162
|
}
|
|
2175
2163
|
console.log(`
|
|
2176
|
-
${
|
|
2164
|
+
${u.componentName}`), console.log(` ${u.dashboardUrl}
|
|
2177
2165
|
`), process.exit(0);
|
|
2178
2166
|
});
|
|
2179
2167
|
v.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, t) => {
|
|
2180
|
-
var w,
|
|
2168
|
+
var w, j, k;
|
|
2181
2169
|
const e = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2182
2170
|
let n = {};
|
|
2183
|
-
if (
|
|
2171
|
+
if (M.existsSync(e))
|
|
2184
2172
|
try {
|
|
2185
|
-
n = JSON.parse(
|
|
2173
|
+
n = JSON.parse(M.readFileSync(e, "utf-8"));
|
|
2186
2174
|
} catch {
|
|
2187
2175
|
}
|
|
2188
2176
|
const s = o || n.componentId;
|
|
@@ -2190,20 +2178,20 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2190
2178
|
const i = n.name || n.componentName || s;
|
|
2191
2179
|
console.log(`
|
|
2192
2180
|
π₯ Pulling: ${i}`), console.log(` ID: ${s}`);
|
|
2193
|
-
let
|
|
2181
|
+
let d;
|
|
2194
2182
|
try {
|
|
2195
|
-
|
|
2183
|
+
d = await ze();
|
|
2196
2184
|
} catch (b) {
|
|
2197
2185
|
console.error("β Authentication failed:", b.message), process.exit(1);
|
|
2198
2186
|
}
|
|
2199
|
-
const
|
|
2200
|
-
let
|
|
2187
|
+
const h = be(), y = Y("Fetching component...").start();
|
|
2188
|
+
let c;
|
|
2201
2189
|
try {
|
|
2202
|
-
const b = await fetch(`${
|
|
2190
|
+
const b = await fetch(`${h}/mcp`, {
|
|
2203
2191
|
method: "POST",
|
|
2204
2192
|
headers: {
|
|
2205
2193
|
"Content-Type": "application/json",
|
|
2206
|
-
Authorization: `Bearer ${
|
|
2194
|
+
Authorization: `Bearer ${d.accessToken}`
|
|
2207
2195
|
},
|
|
2208
2196
|
body: JSON.stringify({
|
|
2209
2197
|
jsonrpc: "2.0",
|
|
@@ -2220,28 +2208,28 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2220
2208
|
const p = await b.json();
|
|
2221
2209
|
if (p.error)
|
|
2222
2210
|
throw new Error(p.error.message);
|
|
2223
|
-
const E = (
|
|
2224
|
-
if (
|
|
2225
|
-
throw new Error(
|
|
2211
|
+
const E = (k = (j = (w = p.result) == null ? void 0 : w.content) == null ? void 0 : j[0]) == null ? void 0 : k.text;
|
|
2212
|
+
if (c = JSON.parse(E), !c.success && !c.html)
|
|
2213
|
+
throw new Error(c.error || "No HTML content returned");
|
|
2226
2214
|
y.succeed("Component fetched");
|
|
2227
2215
|
} catch (b) {
|
|
2228
2216
|
y.fail("Failed to fetch component"), console.error(" ", b.message), process.exit(1);
|
|
2229
2217
|
}
|
|
2230
2218
|
let l = t.output;
|
|
2231
|
-
l || (
|
|
2232
|
-
const
|
|
2233
|
-
|
|
2234
|
-
const
|
|
2235
|
-
let
|
|
2236
|
-
if (
|
|
2237
|
-
name:
|
|
2219
|
+
l || (M.existsSync("./dist/index.html") ? l = "./dist/index.html" : l = "./index.html");
|
|
2220
|
+
const C = c.htmlContent || c.html, u = _.dirname(l);
|
|
2221
|
+
u && !M.existsSync(u) && M.mkdirSync(u, { recursive: !0 }), M.writeFileSync(l, C), console.log(` Saved to: ${l} (${(C.length / 1024).toFixed(1)} KB)`);
|
|
2222
|
+
const P = M.existsSync(e);
|
|
2223
|
+
let g = !1;
|
|
2224
|
+
if (P ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && c.name && (n.name = c.name, g = !0)) : (n = {
|
|
2225
|
+
name: c.name || _.basename(process.cwd()),
|
|
2238
2226
|
componentId: s,
|
|
2239
2227
|
type: "html",
|
|
2240
2228
|
author: "@myop-cli",
|
|
2241
2229
|
HMR: !0
|
|
2242
|
-
},
|
|
2230
|
+
}, g = !0), g)
|
|
2243
2231
|
try {
|
|
2244
|
-
|
|
2232
|
+
M.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${P ? "Updated" : "Created"} ${e}`);
|
|
2245
2233
|
} catch (b) {
|
|
2246
2234
|
console.log(` β οΈ Could not write ${e}: ${b.message}`);
|
|
2247
2235
|
}
|
|
@@ -2253,40 +2241,40 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2253
2241
|
const { search: t, select: e } = await import("@inquirer/prompts");
|
|
2254
2242
|
let n;
|
|
2255
2243
|
try {
|
|
2256
|
-
n = await
|
|
2257
|
-
} catch (
|
|
2258
|
-
console.error("Authentication failed:",
|
|
2244
|
+
n = await ze();
|
|
2245
|
+
} catch (g) {
|
|
2246
|
+
console.error("Authentication failed:", g.message), process.exit(1);
|
|
2259
2247
|
}
|
|
2260
|
-
const s = be(), i = (
|
|
2261
|
-
let
|
|
2248
|
+
const s = be(), i = (g, w) => io(s, n.accessToken, g, w);
|
|
2249
|
+
let d = Y("Loading organizations...").start(), h;
|
|
2262
2250
|
try {
|
|
2263
|
-
const
|
|
2264
|
-
if (
|
|
2251
|
+
const g = await i("list_organizations");
|
|
2252
|
+
if (h = g.organizations || g, !Array.isArray(h))
|
|
2265
2253
|
throw new Error("Unexpected response from list_organizations");
|
|
2266
|
-
} catch (
|
|
2267
|
-
|
|
2254
|
+
} catch (g) {
|
|
2255
|
+
d.fail("Failed to load organizations"), console.error(" ", g.message), process.exit(1);
|
|
2268
2256
|
}
|
|
2269
|
-
|
|
2270
|
-
let y,
|
|
2257
|
+
h.length === 0 && (d.fail("No organizations found for this account"), process.exit(1)), d.stop();
|
|
2258
|
+
let y, c;
|
|
2271
2259
|
if (o.org) {
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2260
|
+
const g = h.find((w) => w.id === o.org || w._id === o.org);
|
|
2261
|
+
g || (console.error(`Organization "${o.org}" not found. Available:`), h.forEach((w) => console.log(` ${w.id || w._id} ${w.name}`)), process.exit(1)), y = g.id || g._id, c = g.name, Fe({ id: y, name: c });
|
|
2274
2262
|
} else {
|
|
2275
|
-
const
|
|
2276
|
-
if (
|
|
2277
|
-
y =
|
|
2278
|
-
else if (
|
|
2279
|
-
y =
|
|
2263
|
+
const g = so();
|
|
2264
|
+
if (g && h.find((w) => (w.id || w._id) === g.id))
|
|
2265
|
+
y = g.id, c = g.name;
|
|
2266
|
+
else if (h.length === 1)
|
|
2267
|
+
y = h[0].id || h[0]._id, c = h[0].name, Fe({ id: y, name: c });
|
|
2280
2268
|
else
|
|
2281
2269
|
try {
|
|
2282
2270
|
const w = await e({
|
|
2283
2271
|
message: "Select an organization:",
|
|
2284
|
-
choices:
|
|
2285
|
-
name:
|
|
2286
|
-
value: { id:
|
|
2272
|
+
choices: h.map((j) => ({
|
|
2273
|
+
name: j.name,
|
|
2274
|
+
value: { id: j.id || j._id, name: j.name }
|
|
2287
2275
|
}))
|
|
2288
2276
|
});
|
|
2289
|
-
y = w.id,
|
|
2277
|
+
y = w.id, c = w.name, Fe({ id: y, name: c });
|
|
2290
2278
|
} catch (w) {
|
|
2291
2279
|
throw w.name === "ExitPromptError" && (console.log(`
|
|
2292
2280
|
|
|
@@ -2294,40 +2282,40 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2294
2282
|
`), process.exit(0)), w;
|
|
2295
2283
|
}
|
|
2296
2284
|
}
|
|
2297
|
-
console.log(` Using organization: ${
|
|
2285
|
+
console.log(` Using organization: ${c}`), d = Y("Loading components...").start();
|
|
2298
2286
|
let l;
|
|
2299
2287
|
try {
|
|
2300
|
-
const
|
|
2301
|
-
if (l =
|
|
2288
|
+
const g = await i("list_components", { organizationId: y });
|
|
2289
|
+
if (l = g.components || g, !Array.isArray(l))
|
|
2302
2290
|
throw new Error("Unexpected response from list_components");
|
|
2303
|
-
} catch (
|
|
2304
|
-
|
|
2291
|
+
} catch (g) {
|
|
2292
|
+
d.fail("Failed to load components"), console.error(" ", g.message), process.exit(1);
|
|
2305
2293
|
}
|
|
2306
|
-
|
|
2307
|
-
`), process.exit(0)), console.log(` ${
|
|
2294
|
+
d.stop(), l.length === 0 && (console.log(` No components found in this organization.
|
|
2295
|
+
`), process.exit(0)), console.log(` ${c} - ${l.length} component(s)
|
|
2308
2296
|
`);
|
|
2309
|
-
const
|
|
2297
|
+
const C = [];
|
|
2310
2298
|
for (; ; ) {
|
|
2311
|
-
const
|
|
2312
|
-
let
|
|
2299
|
+
const g = `[Done - pull/push ${C.length} selected]`, w = "__done__", j = new Set(C.map((p) => p.id || p._id || p.componentId));
|
|
2300
|
+
let k;
|
|
2313
2301
|
try {
|
|
2314
|
-
|
|
2302
|
+
k = await t({
|
|
2315
2303
|
message: "Search & select components:",
|
|
2316
2304
|
source: (p) => {
|
|
2317
|
-
const E = (p || "").toLowerCase(), x = l.filter((
|
|
2318
|
-
const
|
|
2319
|
-
return
|
|
2320
|
-
}),
|
|
2321
|
-
{ name:
|
|
2305
|
+
const E = (p || "").toLowerCase(), x = l.filter((R) => {
|
|
2306
|
+
const D = R.id || R._id || R.componentId;
|
|
2307
|
+
return j.has(D) ? !1 : E ? (R.name || "").toLowerCase().includes(E) : !0;
|
|
2308
|
+
}), O = [
|
|
2309
|
+
{ name: g, value: w }
|
|
2322
2310
|
];
|
|
2323
|
-
for (const
|
|
2324
|
-
const
|
|
2325
|
-
|
|
2326
|
-
name: `${
|
|
2327
|
-
value:
|
|
2311
|
+
for (const R of x) {
|
|
2312
|
+
const D = R.id || R._id || R.componentId, L = D ? D.substring(0, 8) + "..." : "";
|
|
2313
|
+
O.push({
|
|
2314
|
+
name: `${R.name} (${L})`,
|
|
2315
|
+
value: D
|
|
2328
2316
|
});
|
|
2329
2317
|
}
|
|
2330
|
-
return
|
|
2318
|
+
return O;
|
|
2331
2319
|
}
|
|
2332
2320
|
});
|
|
2333
2321
|
} catch (p) {
|
|
@@ -2336,99 +2324,99 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2336
2324
|
π Goodbye!
|
|
2337
2325
|
`), process.exit(0)), p;
|
|
2338
2326
|
}
|
|
2339
|
-
if (
|
|
2327
|
+
if (k === w)
|
|
2340
2328
|
break;
|
|
2341
|
-
const b = l.find((p) => (p.id || p._id || p.componentId) ===
|
|
2342
|
-
b && (
|
|
2329
|
+
const b = l.find((p) => (p.id || p._id || p.componentId) === k);
|
|
2330
|
+
b && (C.push(b), console.log(` + ${b.name}`));
|
|
2343
2331
|
}
|
|
2344
|
-
|
|
2332
|
+
C.length === 0 && (console.log(` No components selected.
|
|
2345
2333
|
`), process.exit(0));
|
|
2346
|
-
let
|
|
2334
|
+
let u;
|
|
2347
2335
|
try {
|
|
2348
|
-
|
|
2349
|
-
message: `${
|
|
2336
|
+
u = await e({
|
|
2337
|
+
message: `${C.length} component(s) selected:`,
|
|
2350
2338
|
choices: [
|
|
2351
2339
|
{ name: "Pull selected", value: "pull" },
|
|
2352
2340
|
{ name: "Push selected", value: "push" },
|
|
2353
2341
|
{ name: "Cancel", value: "cancel" }
|
|
2354
2342
|
]
|
|
2355
2343
|
});
|
|
2356
|
-
} catch (
|
|
2357
|
-
throw
|
|
2344
|
+
} catch (g) {
|
|
2345
|
+
throw g.name === "ExitPromptError" && (console.log(`
|
|
2358
2346
|
|
|
2359
2347
|
π Goodbye!
|
|
2360
|
-
`), process.exit(0)),
|
|
2348
|
+
`), process.exit(0)), g;
|
|
2361
2349
|
}
|
|
2362
|
-
|
|
2350
|
+
u === "cancel" && (console.log(` Cancelled.
|
|
2363
2351
|
`), process.exit(0));
|
|
2364
|
-
const
|
|
2365
|
-
if (
|
|
2352
|
+
const P = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
2353
|
+
if (u === "pull") {
|
|
2366
2354
|
console.log(`
|
|
2367
|
-
Pulling ${
|
|
2355
|
+
Pulling ${C.length} components...
|
|
2368
2356
|
`);
|
|
2369
|
-
const
|
|
2370
|
-
const b =
|
|
2357
|
+
const g = await Promise.all(C.map(async (k) => {
|
|
2358
|
+
const b = k.id || k._id || k.componentId;
|
|
2371
2359
|
try {
|
|
2372
|
-
const p = await i("get_component", { componentId: b }), E =
|
|
2373
|
-
|
|
2360
|
+
const p = await i("get_component", { componentId: b }), E = P(k.name);
|
|
2361
|
+
M.mkdirSync(E, { recursive: !0 });
|
|
2374
2362
|
const x = p.htmlContent || p.html;
|
|
2375
2363
|
if (!x)
|
|
2376
2364
|
throw new Error("No HTML content returned");
|
|
2377
|
-
return
|
|
2378
|
-
name:
|
|
2365
|
+
return M.writeFileSync(_.join(E, "index.html"), x), M.writeFileSync(_.join(E, "myop.config.json"), JSON.stringify({
|
|
2366
|
+
name: k.name,
|
|
2379
2367
|
componentId: b,
|
|
2380
2368
|
organization: y,
|
|
2381
2369
|
type: "html",
|
|
2382
2370
|
author: "@myop-cli",
|
|
2383
2371
|
HMR: !0
|
|
2384
|
-
}, null, 2)), { name:
|
|
2372
|
+
}, null, 2)), { name: k.name, status: "ok", dir: E };
|
|
2385
2373
|
} catch (p) {
|
|
2386
|
-
return { name:
|
|
2374
|
+
return { name: k.name, status: "failed", error: p.message };
|
|
2387
2375
|
}
|
|
2388
2376
|
}));
|
|
2389
|
-
let w = 0,
|
|
2390
|
-
for (const
|
|
2391
|
-
|
|
2377
|
+
let w = 0, j = 0;
|
|
2378
|
+
for (const k of g)
|
|
2379
|
+
k.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${k.name} -> ./${k.dir}/`), w++) : (console.log(` \x1B[31mβ\x1B[0m ${k.name} - ${k.error}`), j++);
|
|
2392
2380
|
console.log(`
|
|
2393
|
-
Done! Pulled ${w} component${w !== 1 ? "s" : ""}.${
|
|
2381
|
+
Done! Pulled ${w} component${w !== 1 ? "s" : ""}.${j ? ` ${j} failed.` : ""}
|
|
2394
2382
|
`);
|
|
2395
|
-
} else if (
|
|
2383
|
+
} else if (u === "push") {
|
|
2396
2384
|
console.log(`
|
|
2397
|
-
Pushing ${
|
|
2385
|
+
Pushing ${C.length} components...
|
|
2398
2386
|
`);
|
|
2399
|
-
const
|
|
2400
|
-
const E = p.id || p._id || p.componentId, x =
|
|
2387
|
+
const g = Ve(".", 3), w = await Promise.all(C.map(async (p) => {
|
|
2388
|
+
const E = p.id || p._id || p.componentId, x = g.find((O) => O.componentId === E);
|
|
2401
2389
|
if (!x)
|
|
2402
2390
|
return { name: p.name, status: "skipped", reason: "no local match" };
|
|
2403
2391
|
try {
|
|
2404
|
-
let
|
|
2405
|
-
const
|
|
2406
|
-
if (
|
|
2407
|
-
|
|
2392
|
+
let O;
|
|
2393
|
+
const R = x.path;
|
|
2394
|
+
if (M.existsSync(_.join(R, "dist", "index.html")))
|
|
2395
|
+
O = _.join(R, "dist", "index.html");
|
|
2408
2396
|
else {
|
|
2409
|
-
const z =
|
|
2410
|
-
(Q) => Q.endsWith(".html") && !Q.startsWith(".") &&
|
|
2397
|
+
const z = M.readdirSync(R).filter(
|
|
2398
|
+
(Q) => Q.endsWith(".html") && !Q.startsWith(".") && M.statSync(_.join(R, Q)).isFile()
|
|
2411
2399
|
);
|
|
2412
2400
|
if (z.length === 1)
|
|
2413
|
-
|
|
2401
|
+
O = _.join(R, z[0]);
|
|
2414
2402
|
else if (z.includes("index.html"))
|
|
2415
|
-
|
|
2403
|
+
O = _.join(R, "index.html");
|
|
2416
2404
|
else
|
|
2417
2405
|
throw new Error("No HTML file found");
|
|
2418
2406
|
}
|
|
2419
|
-
const
|
|
2420
|
-
name:
|
|
2407
|
+
const D = M.readFileSync(O, "utf-8"), L = x.name || p.name, T = await i("upload_component", {
|
|
2408
|
+
name: L,
|
|
2421
2409
|
componentId: E,
|
|
2422
2410
|
organization: y
|
|
2423
2411
|
});
|
|
2424
|
-
if (!
|
|
2425
|
-
throw new Error(
|
|
2412
|
+
if (!T.success)
|
|
2413
|
+
throw new Error(T.error || "Upload request failed");
|
|
2426
2414
|
let J;
|
|
2427
|
-
const F =
|
|
2415
|
+
const F = T.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
2428
2416
|
if (F)
|
|
2429
2417
|
J = F[1];
|
|
2430
2418
|
else {
|
|
2431
|
-
const z =
|
|
2419
|
+
const z = T.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
2432
2420
|
if (z)
|
|
2433
2421
|
J = z[1];
|
|
2434
2422
|
else
|
|
@@ -2437,25 +2425,25 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2437
2425
|
const V = await fetch(J, {
|
|
2438
2426
|
method: "PUT",
|
|
2439
2427
|
headers: { "Content-Type": "text/html" },
|
|
2440
|
-
body:
|
|
2428
|
+
body: D
|
|
2441
2429
|
});
|
|
2442
2430
|
if (!V.ok)
|
|
2443
2431
|
throw new Error(`Upload failed: ${V.status}`);
|
|
2444
2432
|
const te = await i("confirm_upload", {
|
|
2445
|
-
uploadId:
|
|
2433
|
+
uploadId: T.uploadId
|
|
2446
2434
|
});
|
|
2447
2435
|
if (!te.success)
|
|
2448
2436
|
throw new Error(te.error || "Confirmation failed");
|
|
2449
|
-
return { name:
|
|
2450
|
-
} catch (
|
|
2451
|
-
return { name: p.name, status: "failed", error:
|
|
2437
|
+
return { name: L, status: "ok" };
|
|
2438
|
+
} catch (O) {
|
|
2439
|
+
return { name: p.name, status: "failed", error: O.message };
|
|
2452
2440
|
}
|
|
2453
2441
|
}));
|
|
2454
|
-
let
|
|
2442
|
+
let j = 0, k = 0, b = 0;
|
|
2455
2443
|
for (const p of w)
|
|
2456
|
-
p.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${p.name}`),
|
|
2444
|
+
p.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${p.name}`), j++) : p.status === "skipped" ? (console.log(` \x1B[33mβ\x1B[0m ${p.name} (${p.reason})`), k++) : (console.log(` \x1B[31mβ\x1B[0m ${p.name} - ${p.error}`), b++);
|
|
2457
2445
|
console.log(`
|
|
2458
|
-
Done! Pushed ${
|
|
2446
|
+
Done! Pushed ${j}${k ? `, skipped ${k}` : ""}${b ? `, ${b} failed` : ""}.
|
|
2459
2447
|
`);
|
|
2460
2448
|
}
|
|
2461
2449
|
process.exit(0);
|
|
@@ -2484,7 +2472,7 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2484
2472
|
HMR: !0
|
|
2485
2473
|
};
|
|
2486
2474
|
t.writeFileSync("myop.config.json", JSON.stringify(i, null, 2));
|
|
2487
|
-
const
|
|
2475
|
+
const d = `<!DOCTYPE html>
|
|
2488
2476
|
<html lang="en">
|
|
2489
2477
|
<head>
|
|
2490
2478
|
<meta charset="UTF-8">
|
|
@@ -2606,55 +2594,78 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2606
2594
|
<\/script>
|
|
2607
2595
|
</body>
|
|
2608
2596
|
</html>`;
|
|
2609
|
-
t.writeFileSync("index.html",
|
|
2610
|
-
const
|
|
2597
|
+
t.writeFileSync("index.html", d);
|
|
2598
|
+
const h = await We(process.cwd());
|
|
2611
2599
|
console.log(`
|
|
2612
|
-
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"),
|
|
2600
|
+
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), h.success && console.log(" AI agent skills installed"), console.log(""), await xe();
|
|
2613
2601
|
});
|
|
2614
2602
|
v.program.command("dev").description("Start development server with file watching").action(xe);
|
|
2615
|
-
const
|
|
2616
|
-
const o = process.cwd(), t = Y("Installing AI agent skills...").start(), e =
|
|
2617
|
-
e ? (t.succeed("AI agent skills installed"), console.log(
|
|
2603
|
+
const mt = async () => {
|
|
2604
|
+
const o = process.cwd(), t = Y("Installing AI agent skills...").start(), e = await We(o);
|
|
2605
|
+
e.success ? (t.succeed("AI agent skills installed"), e.detected.length > 0 && console.log(` Detected: ${e.detected.join(", ")}`), console.log(` Skills: ${e.skillNames.join(", ")}`)) : t.fail("Failed to install skills"), process.exit(e.success ? 0 : 1);
|
|
2618
2606
|
};
|
|
2619
|
-
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(
|
|
2620
|
-
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(
|
|
2607
|
+
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(mt);
|
|
2608
|
+
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(mt);
|
|
2621
2609
|
v.program.command("mcp").description("Configure Myop MCP server for your AI coding assistant").action(async () => {
|
|
2622
2610
|
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = be() + "/mcp", i = [
|
|
2623
2611
|
{
|
|
2624
2612
|
name: "Claude Code",
|
|
2625
2613
|
value: "claude",
|
|
2626
|
-
configPath:
|
|
2614
|
+
configPath: _.join(n, ".claude.json"),
|
|
2627
2615
|
getEntry: () => ({ type: "http", url: s }),
|
|
2628
|
-
|
|
2616
|
+
nextSteps: [
|
|
2617
|
+
"Restart Claude Code to pick up the new MCP config.",
|
|
2618
|
+
'Type /mcp to see all MCP servers and verify "myop" is listed.',
|
|
2619
|
+
'Select "Authenticate" next to myop β your browser will open',
|
|
2620
|
+
"to sign in with your Myop account (OAuth)."
|
|
2621
|
+
]
|
|
2629
2622
|
},
|
|
2630
2623
|
{
|
|
2631
2624
|
name: "Cursor",
|
|
2632
2625
|
value: "cursor",
|
|
2633
|
-
configPath:
|
|
2626
|
+
configPath: _.join(n, ".cursor", "mcp.json"),
|
|
2634
2627
|
getEntry: () => ({ url: s }),
|
|
2635
|
-
|
|
2628
|
+
nextSteps: [
|
|
2629
|
+
'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
|
|
2630
|
+
"A green dot means connected. Yellow means auth is needed β",
|
|
2631
|
+
'click "Connect" and your browser will open to sign in',
|
|
2632
|
+
"with your Myop account (OAuth).",
|
|
2633
|
+
"You can also click the refresh icon to reconnect after changes."
|
|
2634
|
+
]
|
|
2636
2635
|
},
|
|
2637
2636
|
{
|
|
2638
2637
|
name: "Windsurf",
|
|
2639
2638
|
value: "windsurf",
|
|
2640
|
-
configPath:
|
|
2639
|
+
configPath: _.join(n, ".codeium", "windsurf", "mcp_config.json"),
|
|
2641
2640
|
getEntry: () => ({ url: s }),
|
|
2642
|
-
|
|
2641
|
+
nextSteps: [
|
|
2642
|
+
"Open Cascade and click the hammer icon (top-right) to see MCP servers.",
|
|
2643
|
+
'Verify "myop" shows a green dot (connected).',
|
|
2644
|
+
'Click "Refresh" if needed. On first use, your browser will open',
|
|
2645
|
+
"to sign in with your Myop account (OAuth)."
|
|
2646
|
+
]
|
|
2643
2647
|
},
|
|
2644
2648
|
{
|
|
2645
2649
|
name: "VS Code (GitHub Copilot)",
|
|
2646
2650
|
value: "vscode",
|
|
2647
|
-
configPath: process.platform === "darwin" ?
|
|
2651
|
+
configPath: process.platform === "darwin" ? _.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? _.join(process.env.APPDATA || _.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : _.join(n, ".config", "Code", "User", "mcp.json"),
|
|
2648
2652
|
getEntry: () => ({ type: "http", url: s }),
|
|
2649
|
-
|
|
2653
|
+
nextSteps: [
|
|
2654
|
+
"Requires VS Code 1.99+ and GitHub Copilot extension.",
|
|
2655
|
+
'Press Cmd+Shift+P / Ctrl+Shift+P > "MCP: List Servers"',
|
|
2656
|
+
'to verify "myop" is running. You can also see MCP tools',
|
|
2657
|
+
"via the Tools button in Copilot Chat (Agent mode).",
|
|
2658
|
+
"On first use, your browser will open to sign in",
|
|
2659
|
+
"with your Myop account (OAuth)."
|
|
2660
|
+
]
|
|
2650
2661
|
}
|
|
2651
2662
|
];
|
|
2652
2663
|
console.log(`
|
|
2653
2664
|
Configure Myop MCP server for your AI coding assistant.
|
|
2654
2665
|
`);
|
|
2655
|
-
let
|
|
2666
|
+
let d;
|
|
2656
2667
|
try {
|
|
2657
|
-
|
|
2668
|
+
d = await o({
|
|
2658
2669
|
message: "Select your AI coding assistant:",
|
|
2659
2670
|
choices: i.map((l) => ({ name: l.name, value: l.value }))
|
|
2660
2671
|
});
|
|
@@ -2664,44 +2675,52 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2664
2675
|
π Goodbye!
|
|
2665
2676
|
`), process.exit(0)), l;
|
|
2666
2677
|
}
|
|
2667
|
-
const
|
|
2678
|
+
const h = i.find((l) => l.value === d);
|
|
2668
2679
|
let y = {};
|
|
2669
2680
|
try {
|
|
2670
|
-
const l =
|
|
2681
|
+
const l = M.readFileSync(h.configPath, "utf-8");
|
|
2671
2682
|
y = JSON.parse(l);
|
|
2672
2683
|
} catch {
|
|
2673
2684
|
}
|
|
2674
2685
|
y.mcpServers || (y.mcpServers = {});
|
|
2675
|
-
const
|
|
2676
|
-
if (
|
|
2677
|
-
|
|
2678
|
-
|
|
2686
|
+
const c = y.mcpServers.myop;
|
|
2687
|
+
if (c && c.url === s) {
|
|
2688
|
+
console.log(`
|
|
2689
|
+
Myop MCP is already configured for ${h.name}.`), console.log(` Config: ${h.configPath}`), console.log(`
|
|
2690
|
+
\x1B[1mNext steps:\x1B[0m`);
|
|
2691
|
+
for (const l of h.nextSteps)
|
|
2692
|
+
console.log(` ${l}`);
|
|
2693
|
+
console.log(""), process.exit(0);
|
|
2694
|
+
}
|
|
2695
|
+
if (c) {
|
|
2679
2696
|
console.log(`
|
|
2680
|
-
Myop MCP is already configured (URL: ${
|
|
2697
|
+
Myop MCP is already configured (URL: ${c.url}).`);
|
|
2681
2698
|
try {
|
|
2682
2699
|
await t({ message: "Update to latest URL?", default: !0 }) || process.exit(0);
|
|
2683
2700
|
} catch (l) {
|
|
2684
2701
|
throw l.name === "ExitPromptError" && process.exit(0), l;
|
|
2685
2702
|
}
|
|
2686
2703
|
}
|
|
2687
|
-
y.mcpServers.myop =
|
|
2688
|
-
\x1B[32mβ\x1B[0m Myop MCP configured for ${
|
|
2689
|
-
|
|
2690
|
-
|
|
2704
|
+
y.mcpServers.myop = h.getEntry(), M.mkdirSync(_.dirname(h.configPath), { recursive: !0 }), M.writeFileSync(h.configPath, JSON.stringify(y, null, 2)), console.log(`
|
|
2705
|
+
\x1B[32mβ\x1B[0m Myop MCP configured for ${h.name}`), console.log(` Config: ${h.configPath}`), console.log(` Server: ${s}`), console.log(`
|
|
2706
|
+
\x1B[1mNext steps:\x1B[0m`);
|
|
2707
|
+
for (const l of h.nextSteps)
|
|
2708
|
+
console.log(` ${l}`);
|
|
2709
|
+
console.log(""), process.exit(0);
|
|
2691
2710
|
});
|
|
2692
2711
|
const po = () => {
|
|
2693
2712
|
try {
|
|
2694
|
-
|
|
2713
|
+
X("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2695
2714
|
} catch {
|
|
2696
2715
|
return { gitNotInstalled: !0 };
|
|
2697
2716
|
}
|
|
2698
2717
|
try {
|
|
2699
|
-
|
|
2718
|
+
X("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2700
2719
|
} catch {
|
|
2701
2720
|
return { notARepo: !0 };
|
|
2702
2721
|
}
|
|
2703
2722
|
try {
|
|
2704
|
-
const o =
|
|
2723
|
+
const o = X("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
|
|
2705
2724
|
encoding: "utf-8",
|
|
2706
2725
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2707
2726
|
}).trim();
|
|
@@ -2722,11 +2741,11 @@ const po = () => {
|
|
|
2722
2741
|
return null;
|
|
2723
2742
|
}
|
|
2724
2743
|
}, ie = async (o = !1, t = !1) => {
|
|
2725
|
-
var l,
|
|
2726
|
-
const e = $e(), n = !!(e != null && e.email), s = ((l = v.myopConfig) == null ? void 0 : l.name) || ((
|
|
2744
|
+
var l, C, u;
|
|
2745
|
+
const e = $e(), n = !!(e != null && e.email), s = ((l = v.myopConfig) == null ? void 0 : l.name) || ((C = v.myopConfig) == null ? void 0 : C.componentName), i = (u = v.myopConfig) == null ? void 0 : u.componentId, d = po();
|
|
2727
2746
|
console.log(`
|
|
2728
2747
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2729
|
-
`), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`),
|
|
2748
|
+
`), o && s ? (console.log(` Component: ${s}`), i ? (console.log(` ID: ${i}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${i}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? e.email : "Not logged in"}`), d != null && d.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")) : d != null && d.notARepo ? console.log(" Changes: Not a git repository") : d && (d.insertions > 0 || d.deletions > 0) ? console.log(` Changes: ${d.files} file${d.files !== 1 ? "s" : ""} | \x1B[32m+${d.insertions}\x1B[0m \x1B[31m-${d.deletions}\x1B[0m`) : d && console.log(" Changes: No uncommitted changes"), console.log("");
|
|
2730
2749
|
const y = [
|
|
2731
2750
|
{
|
|
2732
2751
|
emoji: "π",
|
|
@@ -2749,14 +2768,14 @@ const po = () => {
|
|
|
2749
2768
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
2750
2769
|
disabled: o ? n ? !1 : "(login required)" : "(no config file)"
|
|
2751
2770
|
}
|
|
2752
|
-
].map((
|
|
2753
|
-
name: t && !
|
|
2754
|
-
${
|
|
2755
|
-
value:
|
|
2756
|
-
disabled:
|
|
2771
|
+
].map((P) => ({
|
|
2772
|
+
name: t && !P.disabled ? `${P.emoji} ${P.label}
|
|
2773
|
+
${P.help}` : `${P.emoji} ${P.label}`,
|
|
2774
|
+
value: P.value,
|
|
2775
|
+
disabled: P.disabled
|
|
2757
2776
|
}));
|
|
2758
2777
|
y.push(
|
|
2759
|
-
new
|
|
2778
|
+
new _e(),
|
|
2760
2779
|
{
|
|
2761
2780
|
name: t && n ? `π Logout (${e.email})
|
|
2762
2781
|
Clears stored credentials from this machine` : t && !n ? `π Login to Myop
|
|
@@ -2767,25 +2786,25 @@ const po = () => {
|
|
|
2767
2786
|
name: t ? "π Hide help" : "π Show help",
|
|
2768
2787
|
value: "help"
|
|
2769
2788
|
},
|
|
2770
|
-
new
|
|
2789
|
+
new _e(),
|
|
2771
2790
|
{
|
|
2772
2791
|
name: "π Exit",
|
|
2773
2792
|
value: "exit"
|
|
2774
2793
|
}
|
|
2775
2794
|
);
|
|
2776
|
-
let
|
|
2795
|
+
let c;
|
|
2777
2796
|
try {
|
|
2778
|
-
|
|
2797
|
+
c = await et({
|
|
2779
2798
|
message: "What would you like to do?",
|
|
2780
2799
|
choices: y
|
|
2781
2800
|
});
|
|
2782
|
-
} catch (
|
|
2783
|
-
throw
|
|
2801
|
+
} catch (P) {
|
|
2802
|
+
throw P.name === "ExitPromptError" && (console.log(`
|
|
2784
2803
|
|
|
2785
2804
|
π Goodbye!
|
|
2786
|
-
`), process.exit(0)),
|
|
2805
|
+
`), process.exit(0)), P;
|
|
2787
2806
|
}
|
|
2788
|
-
switch (
|
|
2807
|
+
switch (c) {
|
|
2789
2808
|
case "init":
|
|
2790
2809
|
await fo();
|
|
2791
2810
|
break;
|
|
@@ -2793,9 +2812,9 @@ const po = () => {
|
|
|
2793
2812
|
console.log(`
|
|
2794
2813
|
Pushing component...
|
|
2795
2814
|
`);
|
|
2796
|
-
const { execSync:
|
|
2815
|
+
const { execSync: P } = await import("child_process");
|
|
2797
2816
|
try {
|
|
2798
|
-
|
|
2817
|
+
P("node " + process.argv[1] + " push", { stdio: "inherit" });
|
|
2799
2818
|
} catch {
|
|
2800
2819
|
}
|
|
2801
2820
|
await ie(!0, t);
|
|
@@ -2807,12 +2826,12 @@ Pushing component...
|
|
|
2807
2826
|
try {
|
|
2808
2827
|
await de(), console.log(`
|
|
2809
2828
|
`), await ie(o, t);
|
|
2810
|
-
} catch (
|
|
2811
|
-
console.error("Login failed:",
|
|
2829
|
+
} catch (g) {
|
|
2830
|
+
console.error("Login failed:", g.message), await ie(o, t);
|
|
2812
2831
|
}
|
|
2813
2832
|
break;
|
|
2814
2833
|
case "logout":
|
|
2815
|
-
await
|
|
2834
|
+
await dt(), console.log(`
|
|
2816
2835
|
`), await ie(o, t);
|
|
2817
2836
|
break;
|
|
2818
2837
|
case "help":
|
|
@@ -2823,7 +2842,7 @@ Pushing component...
|
|
|
2823
2842
|
}
|
|
2824
2843
|
}, ve = ".myop-monorepo.json", mo = () => {
|
|
2825
2844
|
try {
|
|
2826
|
-
const o =
|
|
2845
|
+
const o = M.readFileSync(ve, "utf-8");
|
|
2827
2846
|
return JSON.parse(o);
|
|
2828
2847
|
} catch {
|
|
2829
2848
|
return null;
|
|
@@ -2834,7 +2853,7 @@ Pushing component...
|
|
|
2834
2853
|
selectedComponents: o,
|
|
2835
2854
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2836
2855
|
};
|
|
2837
|
-
|
|
2856
|
+
M.writeFileSync(ve, JSON.stringify(t, null, 2));
|
|
2838
2857
|
} catch {
|
|
2839
2858
|
}
|
|
2840
2859
|
}, go = async () => {
|
|
@@ -2842,49 +2861,49 @@ Pushing component...
|
|
|
2842
2861
|
console.log(`
|
|
2843
2862
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Myop CLI - Monorepo Mode β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2844
2863
|
`);
|
|
2845
|
-
const e = Y("Scanning for components...").start(), n =
|
|
2864
|
+
const e = Y("Scanning for components...").start(), n = Ve(".");
|
|
2846
2865
|
e.stop(), n.length === 0 && (console.log(` β οΈ No myop.config.json files found in this directory or subdirectories.
|
|
2847
2866
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2848
|
-
const s = mo(), i = (s == null ? void 0 : s.selectedComponents) || [],
|
|
2867
|
+
const s = mo(), i = (s == null ? void 0 : s.selectedComponents) || [], d = i.length > 0;
|
|
2849
2868
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2850
|
-
`), n.forEach((
|
|
2851
|
-
const
|
|
2852
|
-
console.log(` ${
|
|
2853
|
-
}), console.log(` User: ${t ? o.email : "Not logged in"}`),
|
|
2854
|
-
const { checkbox:
|
|
2855
|
-
name: `${
|
|
2856
|
-
value:
|
|
2857
|
-
checked:
|
|
2869
|
+
`), n.forEach((u, P) => {
|
|
2870
|
+
const g = u.componentId ? "β
" : "βͺ", w = u.componentId ? u.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2871
|
+
console.log(` ${g} ${u.name}`), console.log(` Path: ${u.path}`), console.log(` ID: ${w}`), console.log("");
|
|
2872
|
+
}), console.log(` User: ${t ? o.email : "Not logged in"}`), d && console.log(` π Using saved selection from ${ve}`), console.log("");
|
|
2873
|
+
const { checkbox: h } = await import("@inquirer/prompts"), y = n.map((u) => ({
|
|
2874
|
+
name: `${u.name} (${u.path})`,
|
|
2875
|
+
value: u.path,
|
|
2876
|
+
checked: d ? i.includes(u.path) : !0
|
|
2858
2877
|
}));
|
|
2859
|
-
let
|
|
2878
|
+
let c;
|
|
2860
2879
|
try {
|
|
2861
|
-
|
|
2880
|
+
c = await h({
|
|
2862
2881
|
message: "Select components to start in dev mode:",
|
|
2863
2882
|
choices: y
|
|
2864
2883
|
});
|
|
2865
|
-
} catch (
|
|
2866
|
-
throw
|
|
2884
|
+
} catch (u) {
|
|
2885
|
+
throw u.name === "ExitPromptError" && (console.log(`
|
|
2867
2886
|
|
|
2868
2887
|
π Goodbye!
|
|
2869
|
-
`), process.exit(0)),
|
|
2888
|
+
`), process.exit(0)), u;
|
|
2870
2889
|
}
|
|
2871
|
-
|
|
2890
|
+
c.length === 0 && (console.log(`
|
|
2872
2891
|
β οΈ No components selected.
|
|
2873
|
-
`), process.exit(0)), uo(
|
|
2892
|
+
`), process.exit(0)), uo(c), console.log(`
|
|
2874
2893
|
πΎ Selection saved to ${ve}`);
|
|
2875
|
-
const l = n.filter((
|
|
2894
|
+
const l = n.filter((u) => c.includes(u.path));
|
|
2876
2895
|
console.log(`π Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
|
|
2877
2896
|
`);
|
|
2878
|
-
const { monorepoDevCommand:
|
|
2879
|
-
await
|
|
2897
|
+
const { monorepoDevCommand: C } = await Promise.resolve().then(() => Ht);
|
|
2898
|
+
await C(l);
|
|
2880
2899
|
}, fo = async () => {
|
|
2881
2900
|
const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
|
|
2882
|
-
let i,
|
|
2901
|
+
let i, d;
|
|
2883
2902
|
try {
|
|
2884
2903
|
i = await o({
|
|
2885
2904
|
message: "Component name:",
|
|
2886
2905
|
default: s
|
|
2887
|
-
}),
|
|
2906
|
+
}), d = await t({
|
|
2888
2907
|
message: "Component type:",
|
|
2889
2908
|
choices: [
|
|
2890
2909
|
{ name: "π HTML", value: "html", description: "Plain HTML/JS/CSS component" },
|
|
@@ -2893,22 +2912,22 @@ Pushing component...
|
|
|
2893
2912
|
{ name: "π
°οΈ Angular", value: "angular", disabled: "(coming soon)" }
|
|
2894
2913
|
]
|
|
2895
2914
|
});
|
|
2896
|
-
} catch (
|
|
2897
|
-
throw
|
|
2915
|
+
} catch (c) {
|
|
2916
|
+
throw c.name === "ExitPromptError" && (console.log(`
|
|
2898
2917
|
|
|
2899
2918
|
π Goodbye!
|
|
2900
|
-
`), process.exit(0)),
|
|
2919
|
+
`), process.exit(0)), c;
|
|
2901
2920
|
}
|
|
2902
|
-
const
|
|
2921
|
+
const h = {
|
|
2903
2922
|
name: i,
|
|
2904
|
-
type:
|
|
2923
|
+
type: d,
|
|
2905
2924
|
author: "@myop-cli",
|
|
2906
2925
|
HMR: !0
|
|
2907
2926
|
}, y = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2908
2927
|
try {
|
|
2909
|
-
e.writeFileSync(y, JSON.stringify(
|
|
2928
|
+
e.writeFileSync(y, JSON.stringify(h, null, 2)), console.log(`
|
|
2910
2929
|
β
Created ${y}`);
|
|
2911
|
-
const
|
|
2930
|
+
const c = {
|
|
2912
2931
|
name: i.toLowerCase().replace(/\s+/g, "-"),
|
|
2913
2932
|
version: "1.0.0",
|
|
2914
2933
|
type: "module",
|
|
@@ -2920,7 +2939,7 @@ Pushing component...
|
|
|
2920
2939
|
esbuild: "^0.24.0"
|
|
2921
2940
|
}
|
|
2922
2941
|
};
|
|
2923
|
-
e.writeFileSync("package.json", JSON.stringify(
|
|
2942
|
+
e.writeFileSync("package.json", JSON.stringify(c, null, 2)), console.log("β
Created package.json"), e.mkdirSync("src/modules", { recursive: !0 }), e.mkdirSync("src/styles", { recursive: !0 }), e.writeFileSync("build.js", `import * as esbuild from 'esbuild';
|
|
2924
2943
|
import fs from 'fs';
|
|
2925
2944
|
import path from 'path';
|
|
2926
2945
|
|
|
@@ -3000,7 +3019,7 @@ fs.writeFileSync('dist/index.html', html);
|
|
|
3000
3019
|
console.log('β
Built dist/index.html');
|
|
3001
3020
|
console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
|
|
3002
3021
|
`), console.log("β
Created build.js");
|
|
3003
|
-
const
|
|
3022
|
+
const C = `<!DOCTYPE html>
|
|
3004
3023
|
<html lang="en">
|
|
3005
3024
|
<head>
|
|
3006
3025
|
<meta charset="UTF-8">
|
|
@@ -3017,8 +3036,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
3017
3036
|
</body>
|
|
3018
3037
|
</html>
|
|
3019
3038
|
`;
|
|
3020
|
-
e.writeFileSync("index.html",
|
|
3021
|
-
const
|
|
3039
|
+
e.writeFileSync("index.html", C), console.log("β
Created index.html");
|
|
3040
|
+
const u = `// ${i} - Entry Point
|
|
3022
3041
|
import { init } from './modules/app.js';
|
|
3023
3042
|
import { setupMyopInterface } from './modules/myop.js';
|
|
3024
3043
|
|
|
@@ -3027,8 +3046,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
3027
3046
|
setupMyopInterface();
|
|
3028
3047
|
});
|
|
3029
3048
|
`;
|
|
3030
|
-
e.writeFileSync("src/index.js",
|
|
3031
|
-
const
|
|
3049
|
+
e.writeFileSync("src/index.js", u), console.log("β
Created src/index.js");
|
|
3050
|
+
const P = `// ${i} - Main Application Logic
|
|
3032
3051
|
|
|
3033
3052
|
export function init() {
|
|
3034
3053
|
console.log('${i} loaded');
|
|
@@ -3036,7 +3055,7 @@ export function init() {
|
|
|
3036
3055
|
// Your component logic here
|
|
3037
3056
|
}
|
|
3038
3057
|
`;
|
|
3039
|
-
e.writeFileSync("src/modules/app.js",
|
|
3058
|
+
e.writeFileSync("src/modules/app.js", P), console.log("β
Created src/modules/app.js"), e.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
|
|
3040
3059
|
|
|
3041
3060
|
export function setupMyopInterface() {
|
|
3042
3061
|
// Called when host app sends data to this component
|
|
@@ -3057,7 +3076,7 @@ export function setupMyopInterface() {
|
|
|
3057
3076
|
@import './main.css';
|
|
3058
3077
|
`;
|
|
3059
3078
|
e.writeFileSync("src/styles/index.css", w), console.log("β
Created src/styles/index.css");
|
|
3060
|
-
const
|
|
3079
|
+
const j = `/* ${i} - Main Styles */
|
|
3061
3080
|
|
|
3062
3081
|
* {
|
|
3063
3082
|
box-sizing: border-box;
|
|
@@ -3086,14 +3105,14 @@ p {
|
|
|
3086
3105
|
line-height: 1.5;
|
|
3087
3106
|
}
|
|
3088
3107
|
`;
|
|
3089
|
-
e.writeFileSync("src/styles/main.css",
|
|
3108
|
+
e.writeFileSync("src/styles/main.css", j), console.log("β
Created src/styles/main.css"), e.writeFileSync(".gitignore", `node_modules/
|
|
3090
3109
|
dist/
|
|
3091
3110
|
.temp-entry.js
|
|
3092
3111
|
.temp-styles.css
|
|
3093
3112
|
.DS_Store
|
|
3094
3113
|
`), console.log("β
Created .gitignore");
|
|
3095
|
-
const b =
|
|
3096
|
-
b && console.log("β
Installed AI agent skills");
|
|
3114
|
+
const b = await We(process.cwd());
|
|
3115
|
+
b.success && console.log("β
Installed AI agent skills");
|
|
3097
3116
|
const p = await import("./index-DuEoKctW.js").then((x) => x.i), E = process.cwd();
|
|
3098
3117
|
try {
|
|
3099
3118
|
await p.init({ fs: e, dir: E });
|
|
@@ -3109,21 +3128,29 @@ dist/
|
|
|
3109
3128
|
"src/styles/index.css",
|
|
3110
3129
|
"src/styles/main.css"
|
|
3111
3130
|
];
|
|
3112
|
-
if (b) {
|
|
3113
|
-
const
|
|
3131
|
+
if (b.success) {
|
|
3132
|
+
const O = (R, D) => {
|
|
3114
3133
|
try {
|
|
3115
|
-
const
|
|
3116
|
-
for (const
|
|
3117
|
-
const J = n.join(
|
|
3118
|
-
|
|
3134
|
+
const L = e.readdirSync(R, { withFileTypes: !0 });
|
|
3135
|
+
for (const T of L) {
|
|
3136
|
+
const J = n.join(R, T.name), F = n.join(D, T.name);
|
|
3137
|
+
T.isDirectory() ? O(J, F) : x.push(F);
|
|
3119
3138
|
}
|
|
3120
3139
|
} catch {
|
|
3121
3140
|
}
|
|
3122
3141
|
};
|
|
3123
|
-
|
|
3142
|
+
try {
|
|
3143
|
+
const R = e.readdirSync(".", { withFileTypes: !0 });
|
|
3144
|
+
for (const D of R)
|
|
3145
|
+
if (D.isDirectory() && D.name.startsWith(".")) {
|
|
3146
|
+
const L = n.join(D.name, "skills");
|
|
3147
|
+
e.existsSync(L) && O(L, L);
|
|
3148
|
+
}
|
|
3149
|
+
} catch {
|
|
3150
|
+
}
|
|
3124
3151
|
}
|
|
3125
|
-
for (const
|
|
3126
|
-
await p.add({ fs: e, dir: E, filepath:
|
|
3152
|
+
for (const O of x)
|
|
3153
|
+
await p.add({ fs: e, dir: E, filepath: O });
|
|
3127
3154
|
await p.commit({
|
|
3128
3155
|
fs: e,
|
|
3129
3156
|
dir: E,
|
|
@@ -3135,51 +3162,51 @@ dist/
|
|
|
3135
3162
|
}
|
|
3136
3163
|
console.log(`
|
|
3137
3164
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
3138
|
-
`), v.myopConfig =
|
|
3139
|
-
} catch (
|
|
3140
|
-
console.error(`Failed to initialize component: ${
|
|
3165
|
+
`), v.myopConfig = h, await ie(!0);
|
|
3166
|
+
} catch (c) {
|
|
3167
|
+
console.error(`Failed to initialize component: ${c.message}`), process.exit(1);
|
|
3141
3168
|
}
|
|
3142
3169
|
};
|
|
3143
3170
|
v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
3144
|
-
if (v.program.getOptionValue("help") && (console.log(
|
|
3171
|
+
if (v.program.getOptionValue("help") && (console.log(Pt), process.exit()), v.program.getOptionValue("monorepo")) {
|
|
3145
3172
|
await go();
|
|
3146
3173
|
return;
|
|
3147
3174
|
}
|
|
3148
3175
|
if (v.program.getOptionValue("ci")) {
|
|
3149
|
-
const
|
|
3150
|
-
let
|
|
3176
|
+
const h = await import("fs"), y = v.program.getOptionValue("config") || "./myop.config.json", c = v.program.version(), l = $e();
|
|
3177
|
+
let C = { found: !1 };
|
|
3151
3178
|
try {
|
|
3152
|
-
if (
|
|
3153
|
-
const
|
|
3154
|
-
|
|
3179
|
+
if (h.existsSync(y)) {
|
|
3180
|
+
const P = h.readFileSync(y, "utf-8"), g = JSON.parse(P);
|
|
3181
|
+
C = {
|
|
3155
3182
|
found: !0,
|
|
3156
3183
|
path: y,
|
|
3157
|
-
name:
|
|
3158
|
-
componentId:
|
|
3159
|
-
organization:
|
|
3184
|
+
name: g.name || g.componentName || null,
|
|
3185
|
+
componentId: g.componentId || null,
|
|
3186
|
+
organization: g.organization || null
|
|
3160
3187
|
};
|
|
3161
3188
|
}
|
|
3162
|
-
} catch (
|
|
3163
|
-
|
|
3189
|
+
} catch (P) {
|
|
3190
|
+
C = { found: !1, error: P.message };
|
|
3164
3191
|
}
|
|
3165
|
-
const
|
|
3166
|
-
version:
|
|
3167
|
-
config:
|
|
3192
|
+
const u = {
|
|
3193
|
+
version: c,
|
|
3194
|
+
config: C,
|
|
3168
3195
|
auth: {
|
|
3169
3196
|
loggedIn: !!(l != null && l.email),
|
|
3170
3197
|
email: (l == null ? void 0 : l.email) || null
|
|
3171
3198
|
}
|
|
3172
3199
|
};
|
|
3173
|
-
console.log(JSON.stringify(
|
|
3200
|
+
console.log(JSON.stringify(u, null, 2)), process.exit(0);
|
|
3174
3201
|
}
|
|
3175
3202
|
let n = Y({
|
|
3176
3203
|
text: "Loading Myop CLI...",
|
|
3177
3204
|
color: "green"
|
|
3178
3205
|
}).start();
|
|
3179
3206
|
const s = Ce();
|
|
3180
|
-
await
|
|
3207
|
+
await ro(500), n.stop();
|
|
3181
3208
|
const i = v.program.version();
|
|
3182
|
-
await
|
|
3209
|
+
await to(i) || await ie(s.configFound);
|
|
3183
3210
|
});
|
|
3184
3211
|
v.program.parse(process.argv);
|
|
3185
3212
|
v.program.opts();
|