@myop/cli 0.1.48 β 0.1.49
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 +868 -920
- package/dist/skills/myop-cli/SKILL.md +24 -3
- 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
|
|
5
|
-
import
|
|
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
|
|
2
|
+
var St = Object.defineProperty;
|
|
3
|
+
var xt = (o, t, e) => t in o ? St(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
4
|
+
var we = (o, t, e) => xt(o, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
+
import V from "ora";
|
|
6
|
+
import { select as ot, Separator as De } from "@inquirer/prompts";
|
|
7
|
+
import { Command as bt, Option as ue } from "commander";
|
|
8
|
+
import { execSync as Q, spawn as $t } from "child_process";
|
|
9
|
+
import N, { join as _e } from "path";
|
|
10
|
+
import P, { readFileSync as Ct } from "fs";
|
|
11
|
+
import Be from "crypto";
|
|
12
|
+
import Mt from "http";
|
|
13
|
+
import { URL as nt, URLSearchParams as st } from "url";
|
|
14
|
+
import Pt from "open";
|
|
15
|
+
import it from "os";
|
|
16
|
+
const Et = `
|
|
17
17
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
18
18
|
|
|
19
19
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -55,81 +55,81 @@ Examples:
|
|
|
55
55
|
verbose: !1
|
|
56
56
|
},
|
|
57
57
|
myopConfig: null
|
|
58
|
-
},
|
|
58
|
+
}, rt = {
|
|
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 = N.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
|
+
}, Ot = (o) => {
|
|
71
|
+
const t = N.join(v.executionPath, o);
|
|
72
72
|
console.info(`reading config file from: ${t}`);
|
|
73
|
-
const e =
|
|
73
|
+
const e = P.readFileSync(t, "utf8"), n = JSON.parse(e);
|
|
74
74
|
return console.info("config file loaded, ", n), n;
|
|
75
|
-
},
|
|
76
|
-
const e =
|
|
75
|
+
}, Je = (o, t) => {
|
|
76
|
+
const e = N.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
|
+
P.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
|
+
}, at = {
|
|
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), Je(v.options.configPath, v.myopConfig);
|
|
91
91
|
},
|
|
92
92
|
action: async () => {
|
|
93
93
|
}
|
|
94
|
-
},
|
|
94
|
+
}, lt = {
|
|
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), Je(v.options.configPath, v.myopConfig);
|
|
100
100
|
},
|
|
101
101
|
action: () => {
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, It = {
|
|
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
|
+
}, kt = {
|
|
111
111
|
name: "π’ Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
114
|
-
},
|
|
114
|
+
}, Rt = {
|
|
115
115
|
name: "π΅ Create new experience",
|
|
116
116
|
value: "-",
|
|
117
117
|
disabled: "(not available yet)"
|
|
118
|
-
},
|
|
118
|
+
}, Nt = {
|
|
119
119
|
name: "π‘ Create new skin",
|
|
120
120
|
value: "-",
|
|
121
121
|
disabled: "(not available yet)"
|
|
122
|
-
},
|
|
122
|
+
}, Tt = {
|
|
123
123
|
name: "π΄ Create new flow",
|
|
124
124
|
value: "-",
|
|
125
125
|
disabled: "(not available yet)"
|
|
126
|
-
},
|
|
126
|
+
}, _t = {
|
|
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
|
-
},
|
|
132
|
-
function
|
|
131
|
+
}, Ft = [_t, kt, Rt, Nt, Tt];
|
|
132
|
+
function jt(o, t, e, n) {
|
|
133
133
|
return `<!DOCTYPE html>
|
|
134
134
|
<html lang="en">
|
|
135
135
|
<head>
|
|
@@ -219,19 +219,19 @@ ${n}
|
|
|
219
219
|
</body>
|
|
220
220
|
</html>`;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function Dt(o) {
|
|
223
223
|
return o.includes("esbuild") && o.includes("another platform");
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function At(o) {
|
|
226
226
|
return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Lt() {
|
|
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 Ut(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 Lt(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, d,
|
|
247
|
+
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, d, g) => {
|
|
248
248
|
if (i) {
|
|
249
|
-
console.error("β npm install failed:", i.message),
|
|
249
|
+
console.error("β npm install failed:", i.message), g && console.error(g), t(!1);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
console.log(` β Dependencies reinstalled successfully!
|
|
@@ -255,24 +255,24 @@ function Lt(o) {
|
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
async function
|
|
258
|
+
async function ct(o, t, e, n, s = {}) {
|
|
259
259
|
const {
|
|
260
260
|
hasTriedPlatformFix: i = !1,
|
|
261
261
|
hasTriedInstall: d = !1,
|
|
262
|
-
onRetry:
|
|
262
|
+
onRetry: g
|
|
263
263
|
} = s, h = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
|
|
264
|
-
return !i &&
|
|
265
|
-
`),
|
|
266
|
-
n("npm install", (l,
|
|
264
|
+
return !i && Dt(h) ? (Lt(), await Ut(n) && g ? (console.log(`π Retrying build...
|
|
265
|
+
`), g(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && At(h) ? (console.log("π¦ Missing dependencies detected, running npm install..."), new Promise((c) => {
|
|
266
|
+
n("npm install", (l, y, S) => {
|
|
267
267
|
if (l) {
|
|
268
|
-
console.error("β Failed to install dependencies:", l.message),
|
|
268
|
+
console.error("β Failed to install dependencies:", l.message), S && console.error(S), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
console.log("β
Dependencies installed"),
|
|
271
|
+
console.log("β
Dependencies installed"), g && g(), c({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
272
272
|
});
|
|
273
273
|
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: d };
|
|
274
274
|
}
|
|
275
|
-
async function
|
|
275
|
+
async function be() {
|
|
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");
|
|
277
277
|
let i;
|
|
278
278
|
if (import.meta.url.startsWith("file://")) {
|
|
@@ -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 d = t.default.join(i, "commands", "dev", "management-website"),
|
|
284
|
-
let
|
|
285
|
-
const
|
|
283
|
+
const d = t.default.join(i, "commands", "dev", "management-website"), g = o.default.readFileSync(t.default.join(d, "styles.css"), "utf-8"), h = o.default.readFileSync(t.default.join(d, "app.js"), "utf-8"), c = 9292, l = 9293;
|
|
284
|
+
let y = "./dist", S = !1, x = !1, u = !1, p = null;
|
|
285
|
+
const E = () => {
|
|
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,65 +290,65 @@ async function xe() {
|
|
|
290
290
|
} catch {
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
|
-
},
|
|
293
|
+
}, I = () => {
|
|
294
294
|
try {
|
|
295
295
|
const a = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
|
|
296
296
|
return !!(a.scripts && a.scripts.build);
|
|
297
297
|
} catch {
|
|
298
298
|
return !1;
|
|
299
299
|
}
|
|
300
|
-
},
|
|
300
|
+
}, $ = (a) => {
|
|
301
301
|
const r = process.platform;
|
|
302
302
|
let m;
|
|
303
303
|
r === "darwin" ? m = `open "${a}"` : r === "win32" ? m = `start "" "${a}"` : m = `xdg-open "${a}"`, e(m, (f) => {
|
|
304
304
|
});
|
|
305
|
-
},
|
|
306
|
-
let
|
|
307
|
-
|
|
308
|
-
const
|
|
305
|
+
}, C = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
|
|
306
|
+
let M, R, k = !1;
|
|
307
|
+
p = E();
|
|
308
|
+
const L = I();
|
|
309
309
|
try {
|
|
310
|
-
const a = o.default.readFileSync(
|
|
311
|
-
|
|
310
|
+
const a = o.default.readFileSync(j, "utf-8"), r = JSON.parse(a);
|
|
311
|
+
M = r.componentId || "DEV", R = r.componentName || r.name || null, k = r.HMR === !0, p && !L && (u = !0, k = !0, console.log(`π Single HTML file mode: ${p}`)), k && console.log("π₯ HMR enabled");
|
|
312
312
|
} catch (a) {
|
|
313
|
-
|
|
313
|
+
p && !L ? (u = !0, M = "DEV", R = t.default.basename(p, ".html"), k = !0, console.log(`π Single HTML file mode: ${p}`), console.log("π₯ HMR enabled")) : (console.error("β Error reading myop.config.json:", a.message), process.exit(1));
|
|
314
314
|
}
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
317
|
-
return
|
|
315
|
+
const A = async () => {
|
|
316
|
+
if (M !== "DEV" && M !== "NEW")
|
|
317
|
+
return M;
|
|
318
318
|
try {
|
|
319
|
-
const r = ((await new Promise((
|
|
320
|
-
const
|
|
319
|
+
const r = ((await new Promise((w, b) => {
|
|
320
|
+
const O = {
|
|
321
321
|
hostname: "localhost",
|
|
322
322
|
port: l,
|
|
323
323
|
path: "/_list",
|
|
324
324
|
method: "GET",
|
|
325
325
|
timeout: 1e3
|
|
326
|
-
},
|
|
327
|
-
let
|
|
328
|
-
|
|
326
|
+
}, F = n.default.request(O, (H) => {
|
|
327
|
+
let G = "";
|
|
328
|
+
H.on("data", (ee) => G += ee), H.on("end", () => {
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
w(JSON.parse(G));
|
|
331
331
|
} catch {
|
|
332
|
-
|
|
332
|
+
w({ components: [] });
|
|
333
333
|
}
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}),
|
|
339
|
-
})).components || []).map(([
|
|
336
|
+
F.on("error", () => w({ components: [] })), F.on("timeout", () => {
|
|
337
|
+
F.destroy(), w({ components: [] });
|
|
338
|
+
}), F.end();
|
|
339
|
+
})).components || []).map(([w]) => w).filter((w) => w === "DEV" || w === "NEW" || /^DEV\d+$/.test(w) || /^NEW\d+$/.test(w));
|
|
340
340
|
if (r.length === 0)
|
|
341
341
|
return "DEV1";
|
|
342
|
-
const m = r.map((
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
return
|
|
346
|
-
}).filter((
|
|
342
|
+
const m = r.map((w) => {
|
|
343
|
+
if (w === "DEV" || w === "NEW") return 1;
|
|
344
|
+
const b = w.match(/^DEV(\d+)$/), O = w.match(/^NEW(\d+)$/);
|
|
345
|
+
return b ? parseInt(b[1], 10) : O ? parseInt(O[1], 10) : 0;
|
|
346
|
+
}).filter((w) => w > 0);
|
|
347
347
|
return `DEV${Math.max(...m, 0) + 1}`;
|
|
348
348
|
} catch {
|
|
349
349
|
return "DEV1";
|
|
350
350
|
}
|
|
351
|
-
},
|
|
351
|
+
}, _ = process.cwd(), z = (a) => {
|
|
352
352
|
const r = t.default.extname(a).toLowerCase();
|
|
353
353
|
return {
|
|
354
354
|
".html": "text/html",
|
|
@@ -361,43 +361,43 @@ async function xe() {
|
|
|
361
361
|
".svg": "image/svg+xml",
|
|
362
362
|
".ico": "image/x-icon"
|
|
363
363
|
}[r] || "application/octet-stream";
|
|
364
|
-
},
|
|
364
|
+
}, T = /* @__PURE__ */ new Map(), oe = [], Pe = 50, X = [], se = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), ft = (a, r, m) => {
|
|
365
365
|
if (a.url.startsWith("/_hmr/")) {
|
|
366
|
-
const f = a.url.split("/_hmr/")[1],
|
|
366
|
+
const f = a.url.split("/_hmr/")[1], w = a.headers["sec-websocket-key"], b = s("sha1").update(w + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
367
367
|
r.write(
|
|
368
368
|
`HTTP/1.1 101 Switching Protocols\r
|
|
369
369
|
Upgrade: websocket\r
|
|
370
370
|
Connection: Upgrade\r
|
|
371
|
-
Sec-WebSocket-Accept: ${
|
|
371
|
+
Sec-WebSocket-Accept: ${b}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
|
-
),
|
|
375
|
-
const
|
|
376
|
-
|
|
374
|
+
), q.has(f) || q.set(f, /* @__PURE__ */ new Set()), q.get(f).add(r), console.log(`π HMR client connected: ${f}`), r.on("close", () => {
|
|
375
|
+
const O = q.get(f);
|
|
376
|
+
O && (O.delete(r), O.size === 0 && q.delete(f)), console.log(`π HMR client disconnected: ${f}`);
|
|
377
377
|
}), r.on("error", () => {
|
|
378
|
-
const
|
|
379
|
-
|
|
378
|
+
const O = q.get(f);
|
|
379
|
+
O && O.delete(r);
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
|
-
},
|
|
382
|
+
}, Ee = 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
385
|
a.on("data", (f) => m += f), a.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId: f, distPath:
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
console.log(`β
Registered: ${f}${
|
|
391
|
-
const
|
|
392
|
-
id:
|
|
393
|
-
path:
|
|
394
|
-
name:
|
|
387
|
+
const { componentId: f, distPath: w, componentName: b, htmlFile: O } = JSON.parse(m);
|
|
388
|
+
T.set(f, { path: w, name: b || null, htmlFile: O || null });
|
|
389
|
+
const F = b ? ` (${b})` : "";
|
|
390
|
+
console.log(`β
Registered: ${f}${F} -> ${w}${O ? "/" + O : ""}`), r.writeHead(200), r.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
|
|
391
|
+
const H = Array.from(T.entries()).map(([G, ee]) => ({
|
|
392
|
+
id: G,
|
|
393
|
+
path: ee.path,
|
|
394
|
+
name: ee.name
|
|
395
395
|
}));
|
|
396
|
-
|
|
396
|
+
X.forEach((G) => {
|
|
397
397
|
try {
|
|
398
|
-
|
|
398
|
+
G.write(`data: ${JSON.stringify({
|
|
399
399
|
type: "components",
|
|
400
|
-
components:
|
|
400
|
+
components: H
|
|
401
401
|
})}
|
|
402
402
|
|
|
403
403
|
`);
|
|
@@ -413,17 +413,17 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
413
413
|
a.on("data", (f) => m += f), a.on("end", () => {
|
|
414
414
|
try {
|
|
415
415
|
const { componentId: f } = JSON.parse(m);
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
id:
|
|
419
|
-
path:
|
|
420
|
-
name:
|
|
416
|
+
T.delete(f), console.log(`β Unregistered: ${f}`), r.writeHead(200), r.end(JSON.stringify({ success: !0 }));
|
|
417
|
+
const w = Array.from(T.entries()).map(([b, O]) => ({
|
|
418
|
+
id: b,
|
|
419
|
+
path: O.path,
|
|
420
|
+
name: O.name
|
|
421
421
|
}));
|
|
422
|
-
|
|
422
|
+
X.forEach((b) => {
|
|
423
423
|
try {
|
|
424
|
-
|
|
424
|
+
b.write(`data: ${JSON.stringify({
|
|
425
425
|
type: "components",
|
|
426
|
-
components:
|
|
426
|
+
components: w
|
|
427
427
|
})}
|
|
428
428
|
|
|
429
429
|
`);
|
|
@@ -435,22 +435,22 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
} else if (a.method === "GET" && a.url === "/_list")
|
|
438
|
-
r.writeHead(200), r.end(JSON.stringify({ components: Array.from(
|
|
438
|
+
r.writeHead(200), r.end(JSON.stringify({ components: Array.from(T.entries()) }));
|
|
439
439
|
else if (a.method === "POST" && a.url === "/_hmr_notify") {
|
|
440
440
|
let m = "";
|
|
441
441
|
a.on("data", (f) => m += f), a.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId: f, html:
|
|
444
|
-
if (
|
|
445
|
-
console.log(`π₯ Notifying ${
|
|
446
|
-
const
|
|
447
|
-
|
|
443
|
+
const { componentId: f, html: w } = JSON.parse(m), b = q.get(f);
|
|
444
|
+
if (b && b.size > 0) {
|
|
445
|
+
console.log(`π₯ Notifying ${b.size} HMR client(s) for: ${f}`);
|
|
446
|
+
const O = JSON.stringify({ type: "update", html: w }), F = Qe(O);
|
|
447
|
+
b.forEach((H) => {
|
|
448
448
|
try {
|
|
449
|
-
|
|
449
|
+
H.write(F);
|
|
450
450
|
} catch {
|
|
451
|
-
|
|
451
|
+
b.delete(H);
|
|
452
452
|
}
|
|
453
|
-
}), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified:
|
|
453
|
+
}), r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: b.size }));
|
|
454
454
|
} else
|
|
455
455
|
r.writeHead(200), r.end(JSON.stringify({ success: !0, notified: 0 }));
|
|
456
456
|
} catch (f) {
|
|
@@ -459,123 +459,123 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
459
459
|
});
|
|
460
460
|
} else
|
|
461
461
|
r.writeHead(404), r.end(JSON.stringify({ error: "Not found" }));
|
|
462
|
-
}),
|
|
462
|
+
}), ge = n.default.createServer((a, r) => {
|
|
463
463
|
if (a.url.includes("..")) {
|
|
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:${c}`), f = m.pathname,
|
|
467
|
+
const m = new URL(a.url, `http://localhost:${c}`), f = m.pathname, w = f.split("/").filter((J) => J);
|
|
468
468
|
if (f.startsWith("/consume")) {
|
|
469
|
-
const
|
|
470
|
-
if (!
|
|
469
|
+
const J = m.searchParams.get("id");
|
|
470
|
+
if (!J) {
|
|
471
471
|
r.writeHead(400, { "Content-Type": "application/json" }), r.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
const
|
|
475
|
-
let
|
|
474
|
+
const W = T.get(J), Y = W ? W.path : null, de = (te) => {
|
|
475
|
+
let U = "Unknown", K = "Unknown";
|
|
476
476
|
if (a.headers.referer || a.headers.referrer) {
|
|
477
477
|
const B = a.headers.referer || a.headers.referrer;
|
|
478
478
|
try {
|
|
479
|
-
const
|
|
480
|
-
|
|
479
|
+
const ie = new URL(B);
|
|
480
|
+
U = ie.origin, K = ie.hostname || ie.origin;
|
|
481
481
|
} catch {
|
|
482
|
-
|
|
482
|
+
U = B, K = B;
|
|
483
483
|
}
|
|
484
484
|
} else if (a.headers.origin)
|
|
485
485
|
try {
|
|
486
486
|
const B = new URL(a.headers.origin);
|
|
487
|
-
|
|
487
|
+
U = B.origin, K = B.hostname || B.origin;
|
|
488
488
|
} catch {
|
|
489
|
-
|
|
489
|
+
U = a.headers.origin, K = 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" ? (U = "localhost", K = "localhost (direct)") : (U = B, K = B.replace("::ffff:", ""));
|
|
494
494
|
}
|
|
495
|
-
const
|
|
495
|
+
const Ne = a.headers.referer || a.headers.referrer || U, ye = {
|
|
496
496
|
type: "request",
|
|
497
|
-
componentId:
|
|
497
|
+
componentId: J,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
|
-
servedLocally:
|
|
500
|
-
referrer:
|
|
501
|
-
origin:
|
|
502
|
-
originLabel:
|
|
499
|
+
servedLocally: te,
|
|
500
|
+
referrer: Ne,
|
|
501
|
+
origin: U,
|
|
502
|
+
originLabel: K
|
|
503
503
|
};
|
|
504
|
-
|
|
505
|
-
url:
|
|
506
|
-
label:
|
|
504
|
+
se.has(U) || (se.set(U, {
|
|
505
|
+
url: U,
|
|
506
|
+
label: K,
|
|
507
507
|
firstSeen: Date.now(),
|
|
508
508
|
requestCount: 0
|
|
509
|
-
}),
|
|
509
|
+
}), X.forEach((B) => {
|
|
510
510
|
try {
|
|
511
511
|
B.write(`data: ${JSON.stringify({
|
|
512
512
|
type: "origins",
|
|
513
|
-
origins: Array.from(
|
|
513
|
+
origins: Array.from(se.values())
|
|
514
514
|
})}
|
|
515
515
|
|
|
516
516
|
`);
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
const
|
|
521
|
-
|
|
520
|
+
const Te = se.get(U);
|
|
521
|
+
Te.requestCount++, X.forEach((B) => {
|
|
522
522
|
try {
|
|
523
523
|
B.write(`data: ${JSON.stringify({
|
|
524
524
|
type: "origins",
|
|
525
|
-
origins: Array.from(
|
|
525
|
+
origins: Array.from(se.values())
|
|
526
526
|
})}
|
|
527
527
|
|
|
528
528
|
`);
|
|
529
529
|
} catch {
|
|
530
530
|
}
|
|
531
|
-
}),
|
|
531
|
+
}), oe.push(ye), oe.length > Pe && oe.shift(), X.forEach((B) => {
|
|
532
532
|
try {
|
|
533
|
-
B.write(`data: ${JSON.stringify(
|
|
533
|
+
B.write(`data: ${JSON.stringify(ye)}
|
|
534
534
|
|
|
535
535
|
`);
|
|
536
536
|
} catch {
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
};
|
|
540
|
-
if (
|
|
541
|
-
const
|
|
542
|
-
o.default.readFile(
|
|
543
|
-
if (
|
|
544
|
-
console.log(`β File not found: ${
|
|
540
|
+
if (Y) {
|
|
541
|
+
const te = W.htmlFile ? t.default.join(Y, W.htmlFile) : t.default.join(Y, "index.html");
|
|
542
|
+
o.default.readFile(te, "utf-8", (U, K) => {
|
|
543
|
+
if (U) {
|
|
544
|
+
console.log(`β File not found: ${te}`), 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 Ne = Oe(K, J), ye = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Te = {
|
|
548
548
|
item: {
|
|
549
|
-
name:
|
|
550
|
-
id:
|
|
549
|
+
name: J,
|
|
550
|
+
id: J,
|
|
551
551
|
consume_variant: [
|
|
552
552
|
{
|
|
553
|
-
id:
|
|
553
|
+
id: ye,
|
|
554
554
|
name: "dev version",
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
557
557
|
shadowRootMode: "localFrame",
|
|
558
|
-
HTML:
|
|
558
|
+
HTML: Ne
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
]
|
|
562
562
|
}
|
|
563
563
|
};
|
|
564
|
-
console.log(`β
Serving consume JSON for: ${
|
|
564
|
+
console.log(`β
Serving consume JSON for: ${J}`), de(!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(Te, null, 2));
|
|
568
568
|
});
|
|
569
569
|
} else {
|
|
570
|
-
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${
|
|
571
|
-
const
|
|
572
|
-
|
|
570
|
+
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${J}`);
|
|
571
|
+
const te = `https://cloud.myop.dev/consume${m.search}`;
|
|
572
|
+
de(!1), fetch(te).then((U) => U.text()).then((U) => {
|
|
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(U);
|
|
577
|
+
}).catch((U) => {
|
|
578
|
+
console.error(`β Proxy error: ${U.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;
|
|
@@ -586,75 +586,75 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
586
586
|
"Cache-Control": "no-cache",
|
|
587
587
|
Connection: "keep-alive",
|
|
588
588
|
"Access-Control-Allow-Origin": "*"
|
|
589
|
-
}),
|
|
590
|
-
const
|
|
591
|
-
id:
|
|
592
|
-
path:
|
|
593
|
-
name:
|
|
589
|
+
}), X.push(r);
|
|
590
|
+
const J = Array.from(T.entries()).map(([W, Y]) => ({
|
|
591
|
+
id: W,
|
|
592
|
+
path: Y.path,
|
|
593
|
+
name: Y.name
|
|
594
594
|
}));
|
|
595
595
|
r.write(`data: ${JSON.stringify({
|
|
596
596
|
type: "components",
|
|
597
|
-
components:
|
|
597
|
+
components: J
|
|
598
598
|
})}
|
|
599
599
|
|
|
600
600
|
`), r.write(`data: ${JSON.stringify({
|
|
601
601
|
type: "origins",
|
|
602
|
-
origins: Array.from(
|
|
602
|
+
origins: Array.from(se.values())
|
|
603
603
|
})}
|
|
604
604
|
|
|
605
605
|
`), r.write(`data: ${JSON.stringify({
|
|
606
606
|
type: "requestLog",
|
|
607
|
-
log:
|
|
607
|
+
log: oe
|
|
608
608
|
})}
|
|
609
609
|
|
|
610
610
|
`), a.on("close", () => {
|
|
611
|
-
const
|
|
612
|
-
|
|
611
|
+
const W = X.indexOf(r);
|
|
612
|
+
W !== -1 && X.splice(W, 1);
|
|
613
613
|
});
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
|
-
if (
|
|
617
|
-
r.writeHead(200, { "Content-Type": "text/html" }), r.end(
|
|
616
|
+
if (w.length === 0) {
|
|
617
|
+
r.writeHead(200, { "Content-Type": "text/html" }), r.end(jt(c, l, g, h));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
|
-
if (
|
|
620
|
+
if (w[0] !== "view") {
|
|
621
621
|
r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not found. Use /view/<componentId>/ to access components.");
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
|
-
if (
|
|
624
|
+
if (w.length < 2) {
|
|
625
625
|
r.writeHead(400, { "Content-Type": "text/plain" }), r.end("Component ID required. Use /view/<componentId>/");
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
const
|
|
629
|
-
if (!
|
|
630
|
-
r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${
|
|
628
|
+
const b = w[1], O = T.get(b);
|
|
629
|
+
if (!O) {
|
|
630
|
+
r.writeHead(404, { "Content-Type": "text/plain" }), r.end(`Component not found: ${b}`);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const
|
|
634
|
-
console.log(`π₯ Request: ${a.url} -> ${
|
|
635
|
-
if (
|
|
636
|
-
console.log(`β File not found: ${
|
|
633
|
+
const F = O.path, H = w.slice(2), G = O.htmlFile || "index.html", ee = H.length === 0 ? G : H.join("/"), ce = t.default.join(F, ee);
|
|
634
|
+
console.log(`π₯ Request: ${a.url} -> ${ce}`), o.default.readFile(ce, (J, W) => {
|
|
635
|
+
if (J) {
|
|
636
|
+
console.log(`β File not found: ${ce}`), r.writeHead(404, { "Content-Type": "text/plain" }), r.end("Not Found");
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
639
|
-
const
|
|
640
|
-
console.log(`β
Serving: ${
|
|
641
|
-
let
|
|
642
|
-
if (
|
|
643
|
-
const
|
|
644
|
-
|
|
639
|
+
const Y = z(ce);
|
|
640
|
+
console.log(`β
Serving: ${ce} (${Y})`);
|
|
641
|
+
let de = W;
|
|
642
|
+
if (Y === "text/html" && k) {
|
|
643
|
+
const te = W.toString("utf-8");
|
|
644
|
+
de = Oe(te, b);
|
|
645
645
|
}
|
|
646
646
|
r.writeHead(200, {
|
|
647
|
-
"Content-Type":
|
|
647
|
+
"Content-Type": Y,
|
|
648
648
|
"Access-Control-Allow-Origin": "*"
|
|
649
|
-
}), r.end(
|
|
649
|
+
}), r.end(de);
|
|
650
650
|
});
|
|
651
|
-
}),
|
|
652
|
-
const m =
|
|
653
|
-
componentId:
|
|
651
|
+
}), Ke = () => new Promise((a, r) => {
|
|
652
|
+
const m = u ? t.default.resolve(_) : t.default.resolve(_, y), f = JSON.stringify({
|
|
653
|
+
componentId: M,
|
|
654
654
|
distPath: m,
|
|
655
|
-
componentName:
|
|
656
|
-
htmlFile:
|
|
657
|
-
}),
|
|
655
|
+
componentName: R,
|
|
656
|
+
htmlFile: u ? p : null
|
|
657
|
+
}), w = {
|
|
658
658
|
hostname: "localhost",
|
|
659
659
|
port: l,
|
|
660
660
|
path: "/_register",
|
|
@@ -663,15 +663,15 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
664
|
"Content-Length": Buffer.byteLength(f)
|
|
665
665
|
}
|
|
666
|
-
},
|
|
667
|
-
let
|
|
668
|
-
|
|
669
|
-
|
|
666
|
+
}, b = n.default.request(w, (O) => {
|
|
667
|
+
let F = "";
|
|
668
|
+
O.on("data", (H) => F += H), O.on("end", () => {
|
|
669
|
+
O.statusCode === 200 ? a(JSON.parse(F)) : r(new Error(`Registration failed: ${O.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
|
-
|
|
673
|
-
}),
|
|
674
|
-
const m = JSON.stringify({ componentId:
|
|
672
|
+
b.on("error", r), b.write(f), b.end();
|
|
673
|
+
}), ht = () => new Promise((a, r) => {
|
|
674
|
+
const m = JSON.stringify({ componentId: M }), f = {
|
|
675
675
|
hostname: "localhost",
|
|
676
676
|
port: l,
|
|
677
677
|
path: "/_unregister",
|
|
@@ -680,11 +680,11 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
681
|
"Content-Length": Buffer.byteLength(m)
|
|
682
682
|
}
|
|
683
|
-
},
|
|
683
|
+
}, w = n.default.request(f, (b) => {
|
|
684
684
|
a();
|
|
685
685
|
});
|
|
686
|
-
|
|
687
|
-
}),
|
|
686
|
+
w.on("error", () => a()), w.write(m), w.end();
|
|
687
|
+
}), yt = (a) => `
|
|
688
688
|
<!-- MYOP HMR -->
|
|
689
689
|
<script>
|
|
690
690
|
(function() {
|
|
@@ -789,11 +789,11 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
789
789
|
connect();
|
|
790
790
|
})();
|
|
791
791
|
<\/script>
|
|
792
|
-
`,
|
|
793
|
-
if (!
|
|
794
|
-
const m =
|
|
792
|
+
`, Oe = (a, r) => {
|
|
793
|
+
if (!k) return a;
|
|
794
|
+
const m = yt(r);
|
|
795
795
|
return a.includes("</body>") ? a.replace("</body>", `${m}</body>`) : a.includes("</html>") ? a.replace("</html>", `${m}</html>`) : a + m;
|
|
796
|
-
},
|
|
796
|
+
}, Qe = (a) => {
|
|
797
797
|
const r = Buffer.from(a), m = r.length;
|
|
798
798
|
let f;
|
|
799
799
|
return m < 126 ? f = Buffer.concat([
|
|
@@ -813,36 +813,36 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
813
813
|
// 64-bit length
|
|
814
814
|
r
|
|
815
815
|
]), f;
|
|
816
|
-
},
|
|
817
|
-
if (!
|
|
818
|
-
const a =
|
|
816
|
+
}, Ze = () => {
|
|
817
|
+
if (!k) return;
|
|
818
|
+
const a = u ? p : t.default.join(y, "index.html");
|
|
819
819
|
let r;
|
|
820
820
|
try {
|
|
821
821
|
const m = o.default.readFileSync(a, "utf-8");
|
|
822
|
-
r =
|
|
822
|
+
r = Oe(m, M);
|
|
823
823
|
} catch (m) {
|
|
824
824
|
console.error("β Failed to read HTML for HMR:", m.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (
|
|
828
|
-
const m =
|
|
827
|
+
if (Re) {
|
|
828
|
+
const m = q.get(M);
|
|
829
829
|
if (!m || m.size === 0)
|
|
830
830
|
return;
|
|
831
831
|
console.log(`π₯ Notifying ${m.size} HMR client(s)`);
|
|
832
832
|
const f = JSON.stringify({
|
|
833
833
|
type: "update",
|
|
834
834
|
html: r
|
|
835
|
-
}),
|
|
836
|
-
m.forEach((
|
|
835
|
+
}), w = Qe(f);
|
|
836
|
+
m.forEach((b) => {
|
|
837
837
|
try {
|
|
838
|
-
|
|
838
|
+
b.write(w);
|
|
839
839
|
} catch {
|
|
840
|
-
m.delete(
|
|
840
|
+
m.delete(b);
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
} else {
|
|
844
844
|
const m = JSON.stringify({
|
|
845
|
-
componentId:
|
|
845
|
+
componentId: M,
|
|
846
846
|
html: r
|
|
847
847
|
}), f = {
|
|
848
848
|
hostname: "localhost",
|
|
@@ -854,75 +854,75 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
854
854
|
"Content-Length": Buffer.byteLength(m)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
},
|
|
858
|
-
let
|
|
859
|
-
|
|
857
|
+
}, w = n.default.request(f, (b) => {
|
|
858
|
+
let O = "";
|
|
859
|
+
b.on("data", (F) => O += F), b.on("end", () => {
|
|
860
860
|
try {
|
|
861
|
-
const
|
|
862
|
-
|
|
861
|
+
const F = JSON.parse(O);
|
|
862
|
+
F.notified > 0 && console.log(`π₯ Notified ${F.notified} HMR client(s) via server`);
|
|
863
863
|
} catch {
|
|
864
864
|
}
|
|
865
865
|
});
|
|
866
866
|
});
|
|
867
|
-
|
|
868
|
-
}),
|
|
869
|
-
|
|
870
|
-
}),
|
|
867
|
+
w.on("error", () => {
|
|
868
|
+
}), w.on("timeout", () => {
|
|
869
|
+
w.destroy();
|
|
870
|
+
}), w.write(m), w.end();
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
|
-
let
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
876
|
-
|
|
873
|
+
let Ie = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
|
+
const fe = (a) => {
|
|
875
|
+
if (S) {
|
|
876
|
+
x = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
|
-
|
|
879
|
+
S = !0, console.log(`
|
|
880
880
|
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (r, m, f) => {
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
883
|
-
...
|
|
884
|
-
onRetry: () =>
|
|
881
|
+
if (S = !1, r) {
|
|
882
|
+
const w = await ct(r, m, f, e, {
|
|
883
|
+
...Ie,
|
|
884
|
+
onRetry: () => fe(a)
|
|
885
885
|
});
|
|
886
|
-
|
|
886
|
+
Ie = { ...Ie, ...w }, w.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), Ze(), a && a();
|
|
889
|
+
x && (x = !1, fe());
|
|
890
890
|
});
|
|
891
|
-
},
|
|
891
|
+
}, Xe = /* @__PURE__ */ new Set(), ke = (a) => {
|
|
892
892
|
o.default.readdir(a, { withFileTypes: !0 }, (r, m) => {
|
|
893
893
|
r || (m.forEach((f) => {
|
|
894
|
-
const
|
|
894
|
+
const w = t.default.join(a, f.name);
|
|
895
895
|
if (f.isDirectory())
|
|
896
|
-
f.name !== "node_modules" && f.name !== "dist" && !f.name.startsWith(".") &&
|
|
896
|
+
f.name !== "node_modules" && f.name !== "dist" && !f.name.startsWith(".") && ke(w);
|
|
897
897
|
else if (f.isFile()) {
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
898
|
+
const b = t.default.extname(f.name);
|
|
899
|
+
if (b === ".js" || b === ".css" || b === ".html")
|
|
900
900
|
try {
|
|
901
|
-
const
|
|
902
|
-
|
|
901
|
+
const O = o.default.readFileSync(w, "utf-8");
|
|
902
|
+
C.set(w, O);
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
}),
|
|
907
|
-
if (!
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
const
|
|
906
|
+
}), Xe.has(a) || (Xe.add(a), o.default.watch(a, (f, w) => {
|
|
907
|
+
if (!w) return;
|
|
908
|
+
const b = t.default.extname(w);
|
|
909
|
+
if (b !== ".js" && b !== ".css" && b !== ".html") return;
|
|
910
|
+
const O = t.default.join(a, w);
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
913
|
-
const
|
|
914
|
-
|
|
913
|
+
const F = o.default.readFileSync(O, "utf-8"), H = C.get(O);
|
|
914
|
+
F !== H && (C.set(O, F), console.log(`π File changed: ${O}`), u ? Ze() : fe());
|
|
915
915
|
} catch {
|
|
916
916
|
}
|
|
917
917
|
}, 50);
|
|
918
918
|
})));
|
|
919
919
|
});
|
|
920
|
-
},
|
|
920
|
+
}, qe = (a) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
π¨ Component: ${
|
|
923
|
-
`), a && a()) : (
|
|
922
|
+
π¨ Component: ${M}`), u ? (console.log("π No build needed (single HTML file mode)"), ke(_), console.log(`π Watching ${p} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
|
+
`), a && a()) : (fe(a), ke(_), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
|
-
},
|
|
925
|
+
}, wt = () => new Promise((a) => {
|
|
926
926
|
const r = {
|
|
927
927
|
hostname: "localhost",
|
|
928
928
|
port: l,
|
|
@@ -935,105 +935,105 @@ Sec-WebSocket-Accept: ${C}\r
|
|
|
935
935
|
m.on("error", () => a(!1)), m.on("timeout", () => {
|
|
936
936
|
m.destroy(), a(!1);
|
|
937
937
|
}), m.end();
|
|
938
|
-
}),
|
|
938
|
+
}), vt = () => new Promise((a) => {
|
|
939
939
|
const r = n.default.createServer((m, f) => {
|
|
940
940
|
if (f.setHeader("Content-Type", "application/json"), m.method === "POST" && m.url === "/_register") {
|
|
941
|
-
let
|
|
942
|
-
m.on("data", (
|
|
941
|
+
let w = "";
|
|
942
|
+
m.on("data", (b) => w += b), m.on("end", () => {
|
|
943
943
|
try {
|
|
944
|
-
const { componentId:
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
console.log(`β
Registered: ${
|
|
948
|
-
} catch (
|
|
949
|
-
f.writeHead(400), f.end(JSON.stringify({ error:
|
|
944
|
+
const { componentId: b, distPath: O, componentName: F, htmlFile: H } = JSON.parse(w);
|
|
945
|
+
T.set(b, { path: O, name: F || null, htmlFile: H || null });
|
|
946
|
+
const G = F ? ` (${F})` : "";
|
|
947
|
+
console.log(`β
Registered: ${b}${G} -> ${O}${H ? "/" + H : ""}`), f.writeHead(200), f.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
|
|
948
|
+
} catch (b) {
|
|
949
|
+
f.writeHead(400), f.end(JSON.stringify({ error: b.message }));
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
952
|
} else if (m.method === "POST" && m.url === "/_unregister") {
|
|
953
|
-
let
|
|
954
|
-
m.on("data", (
|
|
953
|
+
let w = "";
|
|
954
|
+
m.on("data", (b) => w += b), m.on("end", () => {
|
|
955
955
|
try {
|
|
956
|
-
const { componentId:
|
|
957
|
-
|
|
958
|
-
} catch (
|
|
959
|
-
f.writeHead(400), f.end(JSON.stringify({ error:
|
|
956
|
+
const { componentId: b } = JSON.parse(w);
|
|
957
|
+
T.delete(b), console.log(`β Unregistered: ${b}`), f.writeHead(200), f.end(JSON.stringify({ success: !0 }));
|
|
958
|
+
} catch (b) {
|
|
959
|
+
f.writeHead(400), f.end(JSON.stringify({ error: b.message }));
|
|
960
960
|
}
|
|
961
961
|
});
|
|
962
|
-
} else m.method === "GET" && m.url === "/_list" ? (f.writeHead(200), f.end(JSON.stringify({ components: Array.from(
|
|
962
|
+
} else m.method === "GET" && m.url === "/_list" ? (f.writeHead(200), f.end(JSON.stringify({ components: Array.from(T.entries()) }))) : (f.writeHead(404), f.end(JSON.stringify({ error: "Not found" })));
|
|
963
963
|
});
|
|
964
964
|
r.on("error", () => {
|
|
965
965
|
a(!1);
|
|
966
966
|
}), r.listen(l, () => {
|
|
967
967
|
console.log(`
|
|
968
|
-
π Taking over as server...`), console.log(`π‘ Management server on port ${l}`),
|
|
968
|
+
π Taking over as server...`), console.log(`π‘ Management server on port ${l}`), ge.on("error", () => {
|
|
969
969
|
r.close(), a(!1);
|
|
970
|
-
}),
|
|
970
|
+
}), ge.listen(c, () => {
|
|
971
971
|
console.log(`π‘ Main server running at http://localhost:${c}`);
|
|
972
|
-
const m =
|
|
973
|
-
|
|
972
|
+
const m = u ? t.default.resolve(_) : t.default.resolve(_, y);
|
|
973
|
+
T.set(M, {
|
|
974
974
|
path: m,
|
|
975
|
-
name:
|
|
976
|
-
htmlFile:
|
|
975
|
+
name: R,
|
|
976
|
+
htmlFile: u ? p : null
|
|
977
977
|
});
|
|
978
|
-
const f =
|
|
979
|
-
console.log(`β
Registered component: ${
|
|
978
|
+
const f = R ? ` (${R})` : "";
|
|
979
|
+
console.log(`β
Registered component: ${M}${f}`), console.log(`π‘ Access at: http://localhost:${c}/view/${M}/`), a(!0);
|
|
980
980
|
});
|
|
981
981
|
});
|
|
982
982
|
});
|
|
983
|
-
let
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
await
|
|
987
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
983
|
+
let he;
|
|
984
|
+
const et = () => {
|
|
985
|
+
he = setInterval(async () => {
|
|
986
|
+
await wt() || (clearInterval(he), console.log(`
|
|
987
|
+
β οΈ Server appears to be down, attempting to take over...`), await vt() ? (console.log("β
Successfully took over as server"), Re = !0) : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
988
|
try {
|
|
989
|
-
await
|
|
989
|
+
await Ke(), console.log(`β
Re-registered component: ${M}`), et();
|
|
990
990
|
} catch (m) {
|
|
991
991
|
console.error("β Failed to re-register:", m.message);
|
|
992
992
|
}
|
|
993
993
|
}, 2e3)));
|
|
994
994
|
}, 3e3);
|
|
995
|
-
},
|
|
995
|
+
}, tt = async () => {
|
|
996
996
|
console.log(`
|
|
997
997
|
|
|
998
|
-
π Shutting down...`),
|
|
998
|
+
π Shutting down...`), he && clearInterval(he), await ht(), process.exit(0);
|
|
999
999
|
};
|
|
1000
|
-
process.on("SIGINT",
|
|
1001
|
-
let
|
|
1002
|
-
|
|
1000
|
+
process.on("SIGINT", tt), process.on("SIGTERM", tt);
|
|
1001
|
+
let Re = !1;
|
|
1002
|
+
Ee.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
|
-
|
|
1008
|
-
const r = await
|
|
1009
|
-
console.log(`β
Registered component: ${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1011
|
-
}),
|
|
1007
|
+
M = await A();
|
|
1008
|
+
const r = await Ke();
|
|
1009
|
+
console.log(`β
Registered component: ${M}`), console.log(`π‘ Access at: http://localhost:${c}/view/${M}/`), console.log(`π All registered components: ${r.registered.join(", ")}`), qe(() => {
|
|
1010
|
+
process.env.MYOP_NO_BROWSER || $(`http://localhost:${c}/view/${M}/`);
|
|
1011
|
+
}), et();
|
|
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
|
-
}),
|
|
1018
|
-
|
|
1019
|
-
π Starting shared dev server...`), console.log(`π‘ Management server on port ${l}`),
|
|
1017
|
+
}), Ee.on("upgrade", ft), Ee.listen(l, async () => {
|
|
1018
|
+
Re = !0, console.log(`
|
|
1019
|
+
π Starting shared dev server...`), console.log(`π‘ Management server on port ${l}`), ge.on("error", (a) => {
|
|
1020
1020
|
console.error("β Main server error:", a.message), process.exit(1);
|
|
1021
|
-
}),
|
|
1022
|
-
console.log(`π‘ Main server running at http://localhost:${c}`), (
|
|
1023
|
-
const a =
|
|
1024
|
-
|
|
1021
|
+
}), ge.listen(c, async () => {
|
|
1022
|
+
console.log(`π‘ Main server running at http://localhost:${c}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
|
|
1023
|
+
const a = u ? t.default.resolve(_) : t.default.resolve(_, y);
|
|
1024
|
+
T.set(M, {
|
|
1025
1025
|
path: a,
|
|
1026
|
-
name:
|
|
1027
|
-
htmlFile:
|
|
1026
|
+
name: R,
|
|
1027
|
+
htmlFile: u ? p : null
|
|
1028
1028
|
});
|
|
1029
|
-
const r =
|
|
1030
|
-
console.log(`β
Registered component: ${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1029
|
+
const r = R ? ` (${R})` : "";
|
|
1030
|
+
console.log(`β
Registered component: ${M}${r}`), console.log(`π‘ Access at: http://localhost:${c}/view/${M}/`), qe(() => {
|
|
1031
|
+
process.env.MYOP_NO_BROWSER || $(`http://localhost:${c}/view/${M}/`);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
|
-
const
|
|
1036
|
+
const D = class D {
|
|
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 A = class A {
|
|
|
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(D.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) => {
|
|
@@ -1086,10 +1086,10 @@ const A = class A {
|
|
|
1086
1086
|
const s = Math.ceil(t / n), i = Math.floor(this.cols / n), d = 2, h = this.rows - d - 2, c = Math.floor(h / s);
|
|
1087
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: d + 1 +
|
|
1092
|
-
col:
|
|
1089
|
+
const y = this.components[l], S = Math.floor(l / n), x = l % n;
|
|
1090
|
+
this.panelPositions.set(y.name, {
|
|
1091
|
+
row: d + 1 + S * c,
|
|
1092
|
+
col: x * i + 1,
|
|
1093
1093
|
width: i,
|
|
1094
1094
|
height: c
|
|
1095
1095
|
});
|
|
@@ -1132,44 +1132,44 @@ const A = class A {
|
|
|
1132
1132
|
return `${e}:${n.toString().padStart(2, "0")}`;
|
|
1133
1133
|
}
|
|
1134
1134
|
updateHeader() {
|
|
1135
|
-
const t =
|
|
1135
|
+
const t = D.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 += D.ESC.clearLine.slice(0, -1), process.stdout.write(D.ESC.moveTo(2, 1) + s);
|
|
1138
1138
|
}
|
|
1139
1139
|
renderPanel(t) {
|
|
1140
|
-
const e =
|
|
1140
|
+
const e = D.C, n = D.STATUS, s = this.panelPositions.get(t);
|
|
1141
1141
|
if (!s) return;
|
|
1142
|
-
const i = this.components.findIndex((
|
|
1143
|
-
let
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
const
|
|
1148
|
-
let
|
|
1149
|
-
|
|
1150
|
-
const
|
|
1151
|
-
let
|
|
1152
|
-
|
|
1153
|
-
const
|
|
1154
|
-
for (let
|
|
1155
|
-
const
|
|
1156
|
-
let
|
|
1157
|
-
if (
|
|
1158
|
-
let
|
|
1159
|
-
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1142
|
+
const i = this.components.findIndex((A) => A.name === t), d = this.components[i], g = i === this.selectedPanel, h = this.statusKeys.get(t) || "initializing", c = n[h], l = e[c.color], y = this.logs.get(t) || [], S = this.scrollPos.get(t) || 0, x = s.width - 1, u = g ? e.cyan : e.gray, p = [], E = d.name.substring(0, x - 20);
|
|
1143
|
+
let I = `${u}ββ${e.reset} ${l}${c.icon}${e.reset} `;
|
|
1144
|
+
I += `${e.bold}${E}${e.reset} ${e.gray}β${e.reset} ${l}${c.label}${e.reset} `;
|
|
1145
|
+
const $ = 5 + E.length + c.label.length + 3;
|
|
1146
|
+
I += `${u}${"β".repeat(Math.max(0, x - $))}β${e.reset}`, p.push(D.ESC.moveTo(s.row, s.col) + I);
|
|
1147
|
+
const C = (d.path || "").substring(0, x - 6);
|
|
1148
|
+
let j = `${u}β${e.reset} ${e.dim}${C}${e.reset}`;
|
|
1149
|
+
j += " ".repeat(Math.max(0, x - C.length - 3)), j += `${u}β${e.reset}`, p.push(D.ESC.moveTo(s.row + 1, s.col) + j);
|
|
1150
|
+
const M = y.length, R = M > this.visibleLogLines ? `${S + 1}-${Math.min(S + this.visibleLogLines, M)}/${M}` : "";
|
|
1151
|
+
let k = `${u}β${"β".repeat(x - R.length - 4)}${e.reset}`;
|
|
1152
|
+
R && (k += `${e.dim}${R}${e.reset}`), k += `${u}${"β".repeat(2)}β€${e.reset}`, p.push(D.ESC.moveTo(s.row + 2, s.col) + k);
|
|
1153
|
+
const L = y.slice(S, S + this.visibleLogLines);
|
|
1154
|
+
for (let A = 0; A < this.visibleLogLines; A++) {
|
|
1155
|
+
const _ = L[A];
|
|
1156
|
+
let z = `${u}β${e.reset}`;
|
|
1157
|
+
if (_) {
|
|
1158
|
+
let T = e.white;
|
|
1159
|
+
_.type === "success" ? T = e.green : _.type === "error" ? T = e.red : _.type === "warning" ? T = e.yellow : _.type === "hmr" ? T = e.magenta : _.type === "change" && (T = e.blue);
|
|
1160
|
+
const oe = _.message.substring(0, x - 12);
|
|
1161
|
+
z += `${e.dim}${_.timestamp}${e.reset} ${T}${oe}${e.reset}`;
|
|
1162
|
+
const Pe = x - _.timestamp.length - oe.length - 2;
|
|
1163
|
+
z += " ".repeat(Math.max(0, Pe));
|
|
1164
1164
|
} else
|
|
1165
|
-
|
|
1166
|
-
|
|
1165
|
+
z += " ".repeat(x - 2);
|
|
1166
|
+
z += `${u}β${e.reset}`, p.push(D.ESC.moveTo(s.row + 3 + A, s.col) + z);
|
|
1167
1167
|
}
|
|
1168
|
-
|
|
1168
|
+
p.push(D.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${u}β${"β".repeat(x - 2)}β${e.reset}`), process.stdout.write(p.join(""));
|
|
1169
1169
|
}
|
|
1170
1170
|
fullRender() {
|
|
1171
|
-
const t =
|
|
1172
|
-
process.stdout.write(
|
|
1171
|
+
const t = D.C;
|
|
1172
|
+
process.stdout.write(D.ESC.clearScreen + D.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 A = class A {
|
|
|
1177
1177
|
this.renderFooter();
|
|
1178
1178
|
}
|
|
1179
1179
|
renderFooter() {
|
|
1180
|
-
const t =
|
|
1180
|
+
const t = D.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(D.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(D.ESC.clearScreen + D.ESC.moveTo(1, 1) + D.ESC.showCursor);
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
// ANSI escape codes
|
|
1192
|
-
|
|
1192
|
+
we(D, "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
|
-
|
|
1199
|
+
we(D, "C", {
|
|
1200
1200
|
reset: "\x1B[0m",
|
|
1201
1201
|
bold: "\x1B[1m",
|
|
1202
1202
|
dim: "\x1B[2m",
|
|
@@ -1211,7 +1211,7 @@ ye(A, "C", {
|
|
|
1211
1211
|
bgCyan: "\x1B[46m",
|
|
1212
1212
|
black: "\x1B[30m"
|
|
1213
1213
|
}), // Status configs
|
|
1214
|
-
|
|
1214
|
+
we(D, "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,16 +1224,16 @@ ye(A, "STATUS", {
|
|
|
1224
1224
|
warning: { icon: "β ", color: "yellow", label: "Warning" },
|
|
1225
1225
|
stopped: { icon: "β ", color: "gray", label: "Stopped" }
|
|
1226
1226
|
});
|
|
1227
|
-
let
|
|
1228
|
-
async function
|
|
1227
|
+
let Ae = D;
|
|
1228
|
+
async function Ht(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
|
|
1234
|
-
const
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1233
|
+
})), i = new Ae(s), d = [], g = (l) => {
|
|
1234
|
+
const y = process.platform;
|
|
1235
|
+
let S;
|
|
1236
|
+
y === "darwin" ? S = `open "${l}"` : y === "win32" ? S = `start "" "${l}"` : S = `xdg-open "${l}"`, e(S, () => {
|
|
1237
1237
|
});
|
|
1238
1238
|
}, h = () => {
|
|
1239
1239
|
i.clear(), console.log(`
|
|
@@ -1247,102 +1247,102 @@ async function Dt(o) {
|
|
|
1247
1247
|
process.on("SIGINT", h), process.on("SIGTERM", h);
|
|
1248
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 y = o[l], S = y.name;
|
|
1251
|
+
i.setStatus(S, "β³ Starting..."), i.log(S, `Starting in ${y.path}`);
|
|
1252
|
+
const x = t("node", [c, "dev"], {
|
|
1253
|
+
cwd: n.default.resolve(y.path),
|
|
1254
1254
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1255
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1256
|
});
|
|
1257
|
-
d.push(
|
|
1258
|
-
let
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1257
|
+
d.push(x);
|
|
1258
|
+
let u = "";
|
|
1259
|
+
x.stdout.on("data", (p) => {
|
|
1260
|
+
u += p.toString();
|
|
1261
|
+
const E = u.split(`
|
|
1262
1262
|
`);
|
|
1263
|
-
|
|
1264
|
-
for (const
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1263
|
+
u = E.pop() || "";
|
|
1264
|
+
for (const I of E) {
|
|
1265
|
+
const $ = I.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1266
|
+
$ && ($.includes("Registered component") || $.includes("Registered:") ? i.setStatus(S, "β
Ready") : $.includes("Building...") || $.includes("Running initial build") ? i.setStatus(S, "π¨ Building...") : $.includes("Build completed") || $.includes("Build succeeded") ? i.setStatus(S, "β
Ready") : $.includes("Build failed") ? i.setStatus(S, "β Build Error") : $.includes("File changed") ? (i.setStatus(S, "π Changed"), setTimeout(() => i.setStatus(S, "β
Ready"), 1500)) : $.includes("Notifying") && $.includes("HMR") ? (i.setStatus(S, "π₯ HMR Update"), setTimeout(() => i.setStatus(S, "β
Ready"), 1e3)) : $.includes("HMR client connected") && (i.setStatus(S, "π₯ HMR Connected"), setTimeout(() => i.setStatus(S, "β
Ready"), 1e3)), !$.includes("Watching") && !$.includes("Press Ctrl+C") && !$.includes("Starting shared") && !$.includes("Management server") && !$.includes("Main server") && !$.includes("Access at:") && !$.includes("No build needed") && i.log(S, $));
|
|
1267
1267
|
}
|
|
1268
|
-
}),
|
|
1269
|
-
const
|
|
1268
|
+
}), x.stderr.on("data", (p) => {
|
|
1269
|
+
const E = p.toString().split(`
|
|
1270
1270
|
`);
|
|
1271
|
-
for (const
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1271
|
+
for (const I of E) {
|
|
1272
|
+
const $ = I.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1273
|
+
$ && (i.log(S, `β οΈ ${$}`), i.setStatus(S, "β οΈ Warning"));
|
|
1274
1274
|
}
|
|
1275
|
-
}),
|
|
1276
|
-
|
|
1277
|
-
}), l < o.length - 1 && await new Promise((
|
|
1275
|
+
}), x.on("exit", (p) => {
|
|
1276
|
+
p !== 0 && p !== null && (i.setStatus(S, `β Exited (${p})`), i.log(S, `Process exited with code ${p}`));
|
|
1277
|
+
}), l < o.length - 1 && await new Promise((p) => setTimeout(p, 500));
|
|
1278
1278
|
}
|
|
1279
1279
|
i.render(), setTimeout(() => {
|
|
1280
|
-
|
|
1280
|
+
g("http://localhost:9292");
|
|
1281
1281
|
}, 2e3);
|
|
1282
1282
|
}
|
|
1283
|
-
const
|
|
1283
|
+
const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1284
1284
|
__proto__: null,
|
|
1285
|
-
devCommand:
|
|
1286
|
-
monorepoDevCommand:
|
|
1287
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1288
|
-
function
|
|
1289
|
-
|
|
1285
|
+
devCommand: be,
|
|
1286
|
+
monorepoDevCommand: Ht
|
|
1287
|
+
}, Symbol.toStringTag, { value: "Module" })), Le = N.join(it.homedir(), ".myop"), me = N.join(Le, "credentials.json");
|
|
1288
|
+
function Jt() {
|
|
1289
|
+
P.existsSync(Le) || P.mkdirSync(Le, { recursive: !0, mode: 448 });
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function ze() {
|
|
1292
1292
|
try {
|
|
1293
|
-
if (!
|
|
1293
|
+
if (!P.existsSync(me))
|
|
1294
1294
|
return null;
|
|
1295
|
-
const o =
|
|
1295
|
+
const o = P.readFileSync(me, "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 dt(o) {
|
|
1302
|
+
Jt();
|
|
1303
1303
|
const t = {
|
|
1304
1304
|
...o,
|
|
1305
1305
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1306
1306
|
};
|
|
1307
|
-
|
|
1307
|
+
P.writeFileSync(me, JSON.stringify(t, null, 2), {
|
|
1308
1308
|
mode: 384
|
|
1309
1309
|
// Read/write for owner only
|
|
1310
1310
|
});
|
|
1311
1311
|
}
|
|
1312
|
-
function
|
|
1312
|
+
function pt() {
|
|
1313
1313
|
try {
|
|
1314
|
-
return
|
|
1314
|
+
return P.existsSync(me) && P.unlinkSync(me), !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 zt(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 = ze();
|
|
1327
1327
|
return o ? {
|
|
1328
1328
|
email: o.userEmail,
|
|
1329
1329
|
userId: o.userId
|
|
1330
1330
|
} : null;
|
|
1331
1331
|
}
|
|
1332
|
-
const
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1332
|
+
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", Se = 19284, We = `http://localhost:${Se}/callback`, Wt = "myop-cli";
|
|
1333
|
+
function Vt() {
|
|
1334
|
+
return Be.randomBytes(32).toString("base64url");
|
|
1335
1335
|
}
|
|
1336
|
-
function
|
|
1337
|
-
return
|
|
1336
|
+
function Gt(o) {
|
|
1337
|
+
return Be.createHash("sha256").update(o).digest("base64url");
|
|
1338
1338
|
}
|
|
1339
|
-
async function
|
|
1340
|
-
const o = await fetch(`${
|
|
1339
|
+
async function Yt() {
|
|
1340
|
+
const o = await fetch(`${le}/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: Wt,
|
|
1345
|
+
redirect_uris: [We],
|
|
1346
1346
|
grant_types: ["authorization_code", "refresh_token"],
|
|
1347
1347
|
response_types: ["code"]
|
|
1348
1348
|
})
|
|
@@ -1353,7 +1353,7 @@ async function Vt() {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
return o.json();
|
|
1355
1355
|
}
|
|
1356
|
-
function
|
|
1356
|
+
function ve(o, t, e, n = null) {
|
|
1357
1357
|
const s = {
|
|
1358
1358
|
success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
|
|
1359
1359
|
<circle cx="12" cy="12" r="10"/>
|
|
@@ -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: d, glow:
|
|
1374
|
+
}, { accent: d, glow: g } = i[o] || i.error;
|
|
1375
1375
|
return `<!DOCTYPE html>
|
|
1376
1376
|
<html lang="en">
|
|
1377
1377
|
<head>
|
|
@@ -1464,7 +1464,7 @@ function we(o, t, e, n = null) {
|
|
|
1464
1464
|
display: inline-flex;
|
|
1465
1465
|
align-items: center;
|
|
1466
1466
|
gap: 8px;
|
|
1467
|
-
background: ${
|
|
1467
|
+
background: ${g};
|
|
1468
1468
|
border: 1px solid ${d}33;
|
|
1469
1469
|
border-radius: 4px;
|
|
1470
1470
|
padding: 10px 16px;
|
|
@@ -1519,14 +1519,14 @@ function we(o, t, e, n = null) {
|
|
|
1519
1519
|
</body>
|
|
1520
1520
|
</html>`;
|
|
1521
1521
|
}
|
|
1522
|
-
function
|
|
1522
|
+
function Kt(o) {
|
|
1523
1523
|
return new Promise((t, e) => {
|
|
1524
|
-
const n =
|
|
1525
|
-
const d = new
|
|
1524
|
+
const n = Mt.createServer((s, i) => {
|
|
1525
|
+
const d = new nt(s.url, `http://localhost:${Se}`);
|
|
1526
1526
|
if (d.pathname === "/callback") {
|
|
1527
|
-
const
|
|
1527
|
+
const g = d.searchParams.get("code"), h = d.searchParams.get("state"), c = d.searchParams.get("error");
|
|
1528
1528
|
if (c) {
|
|
1529
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
1529
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(ve(
|
|
1530
1530
|
"error",
|
|
1531
1531
|
"Authentication Failed",
|
|
1532
1532
|
"Unable to complete the authentication process.",
|
|
@@ -1535,7 +1535,7 @@ function Gt(o) {
|
|
|
1535
1535
|
return;
|
|
1536
1536
|
}
|
|
1537
1537
|
if (h !== o) {
|
|
1538
|
-
i.writeHead(400, { "Content-Type": "text/html" }), i.end(
|
|
1538
|
+
i.writeHead(400, { "Content-Type": "text/html" }), i.end(ve(
|
|
1539
1539
|
"warning",
|
|
1540
1540
|
"Security Error",
|
|
1541
1541
|
"State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
|
|
@@ -1543,8 +1543,8 @@ function Gt(o) {
|
|
|
1543
1543
|
)), n.close(), e(new Error("State mismatch"));
|
|
1544
1544
|
return;
|
|
1545
1545
|
}
|
|
1546
|
-
if (!
|
|
1547
|
-
i.writeHead(400, { "Content-Type": "text/html" }), i.end(
|
|
1546
|
+
if (!g) {
|
|
1547
|
+
i.writeHead(400, { "Content-Type": "text/html" }), i.end(ve(
|
|
1548
1548
|
"error",
|
|
1549
1549
|
"Missing Authorization Code",
|
|
1550
1550
|
"No authorization code was received from the server.",
|
|
@@ -1552,11 +1552,11 @@ function Gt(o) {
|
|
|
1552
1552
|
)), n.close(), e(new Error("No authorization code"));
|
|
1553
1553
|
return;
|
|
1554
1554
|
}
|
|
1555
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
1555
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(ve(
|
|
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(g);
|
|
1560
1560
|
} else
|
|
1561
1561
|
i.writeHead(404), i.end("Not found");
|
|
1562
1562
|
});
|
|
@@ -1567,15 +1567,15 @@ function Gt(o) {
|
|
|
1567
1567
|
}, 5 * 60 * 1e3);
|
|
1568
1568
|
});
|
|
1569
1569
|
}
|
|
1570
|
-
async function
|
|
1571
|
-
const n = await fetch(`${
|
|
1570
|
+
async function Qt(o, t, e) {
|
|
1571
|
+
const n = await fetch(`${le}/oauth/token`, {
|
|
1572
1572
|
method: "POST",
|
|
1573
1573
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1574
|
-
body: new
|
|
1574
|
+
body: new st({
|
|
1575
1575
|
grant_type: "authorization_code",
|
|
1576
1576
|
code: o,
|
|
1577
1577
|
client_id: t,
|
|
1578
|
-
redirect_uri:
|
|
1578
|
+
redirect_uri: We,
|
|
1579
1579
|
code_verifier: e
|
|
1580
1580
|
})
|
|
1581
1581
|
});
|
|
@@ -1585,11 +1585,11 @@ async function Yt(o, t, e) {
|
|
|
1585
1585
|
}
|
|
1586
1586
|
return n.json();
|
|
1587
1587
|
}
|
|
1588
|
-
async function
|
|
1589
|
-
const e = await fetch(`${
|
|
1588
|
+
async function Zt(o, t) {
|
|
1589
|
+
const e = await fetch(`${le}/oauth/token`, {
|
|
1590
1590
|
method: "POST",
|
|
1591
1591
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1592
|
-
body: new
|
|
1592
|
+
body: new st({
|
|
1593
1593
|
grant_type: "refresh_token",
|
|
1594
1594
|
refresh_token: o,
|
|
1595
1595
|
client_id: t
|
|
@@ -1601,9 +1601,9 @@ async function Kt(o, t) {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
return e.json();
|
|
1603
1603
|
}
|
|
1604
|
-
async function
|
|
1604
|
+
async function Xt(o) {
|
|
1605
1605
|
var s, i, d;
|
|
1606
|
-
const t = await fetch(`${
|
|
1606
|
+
const t = await fetch(`${le}/mcp`, {
|
|
1607
1607
|
method: "POST",
|
|
1608
1608
|
headers: {
|
|
1609
1609
|
"Content-Type": "application/json",
|
|
@@ -1629,21 +1629,21 @@ async function Qt(o) {
|
|
|
1629
1629
|
return JSON.parse(n);
|
|
1630
1630
|
throw new Error("Invalid response from whoami");
|
|
1631
1631
|
}
|
|
1632
|
-
async function
|
|
1633
|
-
const o =
|
|
1632
|
+
async function pe() {
|
|
1633
|
+
const o = V("Starting authentication...").start();
|
|
1634
1634
|
try {
|
|
1635
1635
|
o.text = "Registering OAuth client...";
|
|
1636
|
-
const e = (await
|
|
1636
|
+
const e = (await Yt()).client_id, n = Vt(), s = Gt(n), i = Be.randomBytes(16).toString("hex");
|
|
1637
1637
|
o.text = "Waiting for authorization...";
|
|
1638
|
-
const d =
|
|
1639
|
-
|
|
1640
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1641
|
-
`), await
|
|
1638
|
+
const d = Kt(i), g = new nt(`${le}/oauth/authorize`);
|
|
1639
|
+
g.searchParams.set("response_type", "code"), g.searchParams.set("client_id", e), g.searchParams.set("redirect_uri", We), g.searchParams.set("code_challenge", s), g.searchParams.set("code_challenge_method", "S256"), g.searchParams.set("state", i), o.stop(), console.log(`
|
|
1640
|
+
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${g.toString()}
|
|
1641
|
+
`), await Pt(g.toString());
|
|
1642
1642
|
const h = await d;
|
|
1643
1643
|
o.start("Exchanging authorization code...");
|
|
1644
|
-
const c = await
|
|
1644
|
+
const c = await Qt(h, e, n);
|
|
1645
1645
|
o.text = "Getting user info...";
|
|
1646
|
-
const l = await
|
|
1646
|
+
const l = await Xt(c.access_token), y = {
|
|
1647
1647
|
accessToken: c.access_token,
|
|
1648
1648
|
refreshToken: c.refresh_token,
|
|
1649
1649
|
expiresAt: new Date(Date.now() + c.expires_in * 1e3).toISOString(),
|
|
@@ -1651,30 +1651,35 @@ async function de() {
|
|
|
1651
1651
|
userId: l.userId,
|
|
1652
1652
|
userEmail: l.email
|
|
1653
1653
|
};
|
|
1654
|
-
return
|
|
1654
|
+
return dt(y), o.succeed(`Authenticated as ${l.email}`), y;
|
|
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 mt() {
|
|
1660
|
+
const o = ze();
|
|
1661
1661
|
if (!o) {
|
|
1662
1662
|
console.log("Not currently logged in.");
|
|
1663
1663
|
return;
|
|
1664
1664
|
}
|
|
1665
|
-
|
|
1665
|
+
pt(), console.log(`β
Logged out (was: ${o.userEmail})`);
|
|
1666
1666
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1667
|
+
function qt(o) {
|
|
1668
|
+
var e, n;
|
|
1669
|
+
const t = (o == null ? void 0 : o.message) || "";
|
|
1670
|
+
return t.includes("ECONNREFUSED") || t.includes("ENOTFOUND") || t.includes("ETIMEDOUT") || t.includes("fetch failed") || t.includes("network") || (o == null ? void 0 : o.code) === "ECONNREFUSED" || ((e = o == null ? void 0 : o.cause) == null ? void 0 : e.code) === "ECONNREFUSED" || ((n = o == null ? void 0 : o.cause) == null ? void 0 : n.code) === "ENOTFOUND";
|
|
1671
|
+
}
|
|
1672
|
+
async function Ve() {
|
|
1673
|
+
let o = ze();
|
|
1669
1674
|
if (!o)
|
|
1670
1675
|
return console.log(`Not logged in. Starting authentication...
|
|
1671
|
-
`), await
|
|
1672
|
-
if (!
|
|
1676
|
+
`), await pe();
|
|
1677
|
+
if (!zt(o))
|
|
1673
1678
|
return o;
|
|
1674
1679
|
if (o.refreshToken) {
|
|
1675
|
-
const t =
|
|
1680
|
+
const t = V("Refreshing access token...").start();
|
|
1676
1681
|
try {
|
|
1677
|
-
const e = await
|
|
1682
|
+
const e = await Zt(
|
|
1678
1683
|
o.refreshToken,
|
|
1679
1684
|
o.clientId
|
|
1680
1685
|
);
|
|
@@ -1683,41 +1688,43 @@ async function ze() {
|
|
|
1683
1688
|
accessToken: e.access_token,
|
|
1684
1689
|
refreshToken: e.refresh_token,
|
|
1685
1690
|
expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
|
|
1686
|
-
},
|
|
1687
|
-
} catch {
|
|
1688
|
-
|
|
1691
|
+
}, dt(o), t.succeed("Token refreshed"), o;
|
|
1692
|
+
} catch (e) {
|
|
1693
|
+
if (qt(e))
|
|
1694
|
+
throw t.fail("Network error during token refresh"), e;
|
|
1695
|
+
return t.warn("Token refresh failed, please log in again"), pt(), await pe();
|
|
1689
1696
|
}
|
|
1690
1697
|
}
|
|
1691
1698
|
return console.log(`Session expired. Please log in again.
|
|
1692
|
-
`), await
|
|
1699
|
+
`), await pe();
|
|
1693
1700
|
}
|
|
1694
|
-
function
|
|
1695
|
-
return
|
|
1701
|
+
function Ce() {
|
|
1702
|
+
return le;
|
|
1696
1703
|
}
|
|
1697
|
-
const
|
|
1698
|
-
function
|
|
1704
|
+
const Z = "@myop/cli", Fe = process.platform === "win32";
|
|
1705
|
+
function eo() {
|
|
1699
1706
|
try {
|
|
1700
|
-
return
|
|
1707
|
+
return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
|
|
1701
1708
|
} catch {
|
|
1702
1709
|
return "https://registry.npmjs.org/";
|
|
1703
1710
|
}
|
|
1704
1711
|
}
|
|
1705
|
-
function
|
|
1712
|
+
function to() {
|
|
1706
1713
|
try {
|
|
1707
|
-
return
|
|
1714
|
+
return Q("npm config get prefix", { encoding: "utf-8" }).trim();
|
|
1708
1715
|
} catch {
|
|
1709
1716
|
return null;
|
|
1710
1717
|
}
|
|
1711
1718
|
}
|
|
1712
|
-
async function
|
|
1719
|
+
async function oo() {
|
|
1713
1720
|
try {
|
|
1714
|
-
const o =
|
|
1721
|
+
const o = eo().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
|
|
1715
1722
|
return t.ok ? (await t.json()).version : null;
|
|
1716
1723
|
} catch {
|
|
1717
1724
|
return null;
|
|
1718
1725
|
}
|
|
1719
1726
|
}
|
|
1720
|
-
function
|
|
1727
|
+
function no(o, t) {
|
|
1721
1728
|
const e = o.split(".").map(Number), n = t.split(".").map(Number);
|
|
1722
1729
|
for (let s = 0; s < Math.max(e.length, n.length); s++) {
|
|
1723
1730
|
const i = e[s] || 0, d = n[s] || 0;
|
|
@@ -1726,19 +1733,19 @@ function eo(o, t) {
|
|
|
1726
1733
|
}
|
|
1727
1734
|
return 0;
|
|
1728
1735
|
}
|
|
1729
|
-
async function
|
|
1730
|
-
const t =
|
|
1736
|
+
async function so(o) {
|
|
1737
|
+
const t = V({
|
|
1731
1738
|
text: "Checking for updates...",
|
|
1732
1739
|
color: "cyan"
|
|
1733
|
-
}).start(), e = await
|
|
1734
|
-
if (t.stop(), !e ||
|
|
1740
|
+
}).start(), e = await oo();
|
|
1741
|
+
if (t.stop(), !e || no(e, o) <= 0)
|
|
1735
1742
|
return !1;
|
|
1736
1743
|
console.log(`
|
|
1737
1744
|
π¦ New version available: ${o} β ${e}
|
|
1738
1745
|
`);
|
|
1739
1746
|
let n;
|
|
1740
1747
|
try {
|
|
1741
|
-
n = await
|
|
1748
|
+
n = await ot({
|
|
1742
1749
|
message: "Would you like to update now?",
|
|
1743
1750
|
choices: [
|
|
1744
1751
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1752,47 +1759,47 @@ async function to(o) {
|
|
|
1752
1759
|
`), process.exit(0)), s;
|
|
1753
1760
|
}
|
|
1754
1761
|
if (n) {
|
|
1755
|
-
const s =
|
|
1756
|
-
text: `Updating ${
|
|
1762
|
+
const s = V({
|
|
1763
|
+
text: `Updating ${Z} to v${e}...`,
|
|
1757
1764
|
color: "green"
|
|
1758
|
-
}).start(), i = `npm install -g ${
|
|
1765
|
+
}).start(), i = `npm install -g ${Z}@latest`, d = to();
|
|
1759
1766
|
try {
|
|
1760
|
-
|
|
1767
|
+
Q(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
|
|
1761
1768
|
} catch {
|
|
1762
1769
|
s.stop(), console.log(`
|
|
1763
1770
|
π Elevated permissions required.
|
|
1764
1771
|
`);
|
|
1765
1772
|
try {
|
|
1766
|
-
if (
|
|
1767
|
-
const l = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${
|
|
1768
|
-
|
|
1773
|
+
if (Fe) {
|
|
1774
|
+
const l = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${Z}@latest --prefix \\"${d}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
|
|
1775
|
+
Q(`powershell -Command "${l}"`, { stdio: "inherit" });
|
|
1769
1776
|
} else {
|
|
1770
|
-
const c = d ? `sudo npm install -g ${
|
|
1771
|
-
|
|
1777
|
+
const c = d ? `sudo npm install -g ${Z}@latest --prefix "${d}"` : `sudo ${i}`;
|
|
1778
|
+
Q(c, { stdio: "inherit" });
|
|
1772
1779
|
}
|
|
1773
1780
|
console.log(`
|
|
1774
1781
|
β
Updated to v${e}`);
|
|
1775
1782
|
} catch {
|
|
1776
1783
|
console.log(`
|
|
1777
1784
|
β Update failed`);
|
|
1778
|
-
const l =
|
|
1785
|
+
const l = Fe ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
|
|
1779
1786
|
console.log(`
|
|
1780
1787
|
Please run manually: ${l}
|
|
1781
1788
|
`), process.exit(1);
|
|
1782
1789
|
}
|
|
1783
1790
|
}
|
|
1784
|
-
let
|
|
1791
|
+
let g = null;
|
|
1785
1792
|
try {
|
|
1786
1793
|
let h;
|
|
1787
|
-
d ? h =
|
|
1788
|
-
const c =
|
|
1789
|
-
|
|
1794
|
+
d ? h = Fe ? _e(d, "node_modules") : _e(d, "lib", "node_modules") : h = Q("npm root -g", { encoding: "utf-8" }).trim();
|
|
1795
|
+
const c = _e(h, Z, "package.json"), l = Ct(c, "utf-8");
|
|
1796
|
+
g = JSON.parse(l).version;
|
|
1790
1797
|
} catch {
|
|
1791
1798
|
}
|
|
1792
|
-
if (
|
|
1799
|
+
if (g === e)
|
|
1793
1800
|
return console.log(`
|
|
1794
1801
|
π Restarting...
|
|
1795
|
-
`),
|
|
1802
|
+
`), $t(process.argv[0], process.argv.slice(1), {
|
|
1796
1803
|
stdio: "inherit",
|
|
1797
1804
|
shell: !0
|
|
1798
1805
|
}).on("close", (c) => {
|
|
@@ -1804,35 +1811,35 @@ Please run myop again to use the new version.
|
|
|
1804
1811
|
}
|
|
1805
1812
|
return !1;
|
|
1806
1813
|
}
|
|
1807
|
-
const
|
|
1808
|
-
function
|
|
1809
|
-
|
|
1814
|
+
const Ue = N.join(it.homedir(), ".myop"), He = N.join(Ue, "preferences.json");
|
|
1815
|
+
function io() {
|
|
1816
|
+
P.existsSync(Ue) || P.mkdirSync(Ue, { recursive: !0, mode: 448 });
|
|
1810
1817
|
}
|
|
1811
|
-
function
|
|
1818
|
+
function ut() {
|
|
1812
1819
|
try {
|
|
1813
|
-
if (!
|
|
1820
|
+
if (!P.existsSync(He))
|
|
1814
1821
|
return {};
|
|
1815
|
-
const o =
|
|
1822
|
+
const o = P.readFileSync(He, "utf8");
|
|
1816
1823
|
return JSON.parse(o);
|
|
1817
1824
|
} catch {
|
|
1818
1825
|
return {};
|
|
1819
1826
|
}
|
|
1820
1827
|
}
|
|
1821
|
-
function
|
|
1822
|
-
|
|
1823
|
-
const e = { ...
|
|
1824
|
-
|
|
1828
|
+
function ro(o) {
|
|
1829
|
+
io();
|
|
1830
|
+
const e = { ...ut(), ...o };
|
|
1831
|
+
P.writeFileSync(He, JSON.stringify(e, null, 2), {
|
|
1825
1832
|
mode: 384
|
|
1826
1833
|
});
|
|
1827
1834
|
}
|
|
1828
|
-
function
|
|
1829
|
-
return
|
|
1835
|
+
function ao() {
|
|
1836
|
+
return ut().defaultOrganization || null;
|
|
1830
1837
|
}
|
|
1831
|
-
function
|
|
1832
|
-
|
|
1838
|
+
function je({ id: o, name: t }) {
|
|
1839
|
+
ro({ defaultOrganization: { id: o, name: t } });
|
|
1833
1840
|
}
|
|
1834
|
-
async function
|
|
1835
|
-
var
|
|
1841
|
+
async function lo(o, t, e, n = {}) {
|
|
1842
|
+
var g, h, c;
|
|
1836
1843
|
const s = await fetch(`${o}/mcp`, {
|
|
1837
1844
|
method: "POST",
|
|
1838
1845
|
headers: {
|
|
@@ -1854,60 +1861,71 @@ async function io(o, t, e, n = {}) {
|
|
|
1854
1861
|
const i = await s.json();
|
|
1855
1862
|
if (i.error)
|
|
1856
1863
|
throw new Error(i.error.message || "MCP error");
|
|
1857
|
-
const d = (c = (h = (
|
|
1864
|
+
const d = (c = (h = (g = i.result) == null ? void 0 : g.content) == null ? void 0 : h[0]) == null ? void 0 : c.text;
|
|
1858
1865
|
if (!d)
|
|
1859
1866
|
throw new Error(`No content returned from ${e}`);
|
|
1860
1867
|
return JSON.parse(d);
|
|
1861
1868
|
}
|
|
1862
|
-
const
|
|
1869
|
+
const co = (o) => new Promise((t) => setTimeout(t, o));
|
|
1870
|
+
function re(o) {
|
|
1871
|
+
var e, n;
|
|
1872
|
+
const t = (o == null ? void 0 : o.message) || "";
|
|
1873
|
+
return t.includes("ECONNREFUSED") || t.includes("ENOTFOUND") || t.includes("ETIMEDOUT") || t.includes("fetch failed") || t.includes("network") || (o == null ? void 0 : o.code) === "ECONNREFUSED" || ((e = o == null ? void 0 : o.cause) == null ? void 0 : e.code) === "ECONNREFUSED" || ((n = o == null ? void 0 : o.cause) == null ? void 0 : n.code) === "ENOTFOUND";
|
|
1874
|
+
}
|
|
1875
|
+
function ae(o) {
|
|
1876
|
+
console.error(`
|
|
1877
|
+
This usually happens in sandboxed environments (Claude Web, containers)`), console.error(` where outbound HTTP is restricted.
|
|
1878
|
+
`), console.error(" [MYOP_MCP_FALLBACK] Use Myop MCP tools instead:"), console.error(o === "push" ? " - Use the upload_component MCP tool with htmlContent parameter" : o === "pull" ? " - Use the get_component MCP tool" : " - Use list_organizations + list_components MCP tools"), console.error(" - Do NOT use presigned URL / curl flow β same network restrictions apply"), console.error("");
|
|
1879
|
+
}
|
|
1880
|
+
const po = () => {
|
|
1863
1881
|
let o = new URL(import.meta.url).pathname;
|
|
1864
1882
|
process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
|
|
1865
|
-
const t =
|
|
1866
|
-
return
|
|
1867
|
-
},
|
|
1883
|
+
const t = N.dirname(o);
|
|
1884
|
+
return N.join(t, "skills");
|
|
1885
|
+
}, mo = (o) => {
|
|
1868
1886
|
try {
|
|
1869
|
-
const t =
|
|
1870
|
-
if (!
|
|
1871
|
-
const e = JSON.parse(
|
|
1887
|
+
const t = N.join(o, "package.json");
|
|
1888
|
+
if (!P.existsSync(t)) return [];
|
|
1889
|
+
const e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
1872
1890
|
return Object.keys({ ...e.dependencies, ...e.devDependencies });
|
|
1873
1891
|
} catch {
|
|
1874
1892
|
return [];
|
|
1875
1893
|
}
|
|
1876
|
-
},
|
|
1877
|
-
const t =
|
|
1878
|
-
if (!
|
|
1894
|
+
}, Ge = async (o) => {
|
|
1895
|
+
const t = po();
|
|
1896
|
+
if (!P.existsSync(t))
|
|
1879
1897
|
return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
|
|
1880
1898
|
try {
|
|
1881
|
-
const e =
|
|
1899
|
+
const e = mo(o), n = ["myop-cli", "myop-component"], s = [
|
|
1882
1900
|
{ deps: ["@myop/react", "react"], skill: "myop-react-host" },
|
|
1883
1901
|
{ deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
|
|
1884
1902
|
{ deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
|
|
1885
1903
|
{ deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
|
|
1886
1904
|
], 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
1905
|
i.length > 0 ? n.push(...i) : n.push(...s.map((c) => c.skill));
|
|
1888
|
-
const
|
|
1889
|
-
return
|
|
1906
|
+
const g = n.map((c) => `--skill ${c}`).join(" "), h = `npx -y skills add "${t}" ${g} --agent '*' --copy -y`;
|
|
1907
|
+
return Q(h, { cwd: o, stdio: "pipe" }), { success: !0, detected: d, skillNames: n };
|
|
1890
1908
|
} catch (e) {
|
|
1891
1909
|
return console.info("Failed to install skills:", e.message), { success: !1 };
|
|
1892
1910
|
}
|
|
1893
|
-
},
|
|
1911
|
+
}, Ye = (o = ".", t = 3, e = 0) => {
|
|
1894
1912
|
const n = [];
|
|
1895
1913
|
if (e > t) return n;
|
|
1896
1914
|
try {
|
|
1897
|
-
const s =
|
|
1915
|
+
const s = P.readdirSync(o, { withFileTypes: !0 });
|
|
1898
1916
|
for (const i of s) {
|
|
1899
|
-
const d =
|
|
1917
|
+
const d = N.join(o, i.name);
|
|
1900
1918
|
if (i.isDirectory()) {
|
|
1901
1919
|
if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
|
|
1902
1920
|
continue;
|
|
1903
|
-
n.push(...
|
|
1921
|
+
n.push(...Ye(d, t, e + 1));
|
|
1904
1922
|
} else if (i.name === "myop.config.json")
|
|
1905
1923
|
try {
|
|
1906
|
-
const
|
|
1924
|
+
const g = P.readFileSync(d, "utf-8"), h = JSON.parse(g);
|
|
1907
1925
|
n.push({
|
|
1908
1926
|
path: o,
|
|
1909
1927
|
configPath: d,
|
|
1910
|
-
name: h.name || h.componentName ||
|
|
1928
|
+
name: h.name || h.componentName || N.basename(o),
|
|
1911
1929
|
componentId: h.componentId || null,
|
|
1912
1930
|
config: h
|
|
1913
1931
|
});
|
|
@@ -1919,7 +1937,7 @@ const ro = (o) => new Promise((t) => setTimeout(t, o)), ao = () => {
|
|
|
1919
1937
|
return n;
|
|
1920
1938
|
};
|
|
1921
1939
|
v.executionPath = process.cwd();
|
|
1922
|
-
const
|
|
1940
|
+
const Me = (o = !1) => {
|
|
1923
1941
|
const t = v.program.getOptionValue("verbose");
|
|
1924
1942
|
t || (console.info = () => {
|
|
1925
1943
|
}), console.info("π verbose mode on"), v.options = {
|
|
@@ -1927,7 +1945,7 @@ const Ce = (o = !1) => {
|
|
|
1927
1945
|
verbose: t
|
|
1928
1946
|
};
|
|
1929
1947
|
try {
|
|
1930
|
-
return v.myopConfig =
|
|
1948
|
+
return v.myopConfig = Ot(v.options.configPath), { configFound: !0 };
|
|
1931
1949
|
} catch (e) {
|
|
1932
1950
|
if (o) {
|
|
1933
1951
|
console.info(`
|
|
@@ -1937,7 +1955,7 @@ const Ce = (o = !1) => {
|
|
|
1937
1955
|
author: "@myop-cli",
|
|
1938
1956
|
flows: []
|
|
1939
1957
|
};
|
|
1940
|
-
return
|
|
1958
|
+
return Je(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
|
|
1941
1959
|
} catch {
|
|
1942
1960
|
return console.info("Error details :", e), { configFound: !1, error: e };
|
|
1943
1961
|
}
|
|
@@ -1946,36 +1964,36 @@ const Ce = (o = !1) => {
|
|
|
1946
1964
|
}
|
|
1947
1965
|
};
|
|
1948
1966
|
[
|
|
1949
|
-
new
|
|
1950
|
-
...
|
|
1967
|
+
new De(),
|
|
1968
|
+
...Ft
|
|
1951
1969
|
];
|
|
1952
|
-
const
|
|
1953
|
-
v.program = new
|
|
1954
|
-
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(
|
|
1955
|
-
v.program.addOption(new
|
|
1956
|
-
v.program.addOption(new
|
|
1957
|
-
v.program.addOption(new
|
|
1958
|
-
v.program.addOption(new
|
|
1959
|
-
v.program.addOption(new
|
|
1970
|
+
const uo = "0.1.49";
|
|
1971
|
+
v.program = new bt();
|
|
1972
|
+
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(uo);
|
|
1973
|
+
v.program.addOption(new ue("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
1974
|
+
v.program.addOption(new ue("-h, --help", "Show helpful information"));
|
|
1975
|
+
v.program.addOption(new ue("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
|
|
1976
|
+
v.program.addOption(new ue("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
|
|
1977
|
+
v.program.addOption(new ue("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
|
|
1960
1978
|
v.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, t) => {
|
|
1961
|
-
|
|
1979
|
+
Me(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && at._action(t), process.exit();
|
|
1962
1980
|
});
|
|
1963
1981
|
v.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, t) => {
|
|
1964
|
-
|
|
1982
|
+
Me(), console.info("removing ", o, t, v.options.configPath), o === "flow" && lt._action(t), process.exit();
|
|
1965
1983
|
});
|
|
1966
1984
|
v.program.command("install").description("Install Myop assets").action(async () => {
|
|
1967
|
-
|
|
1985
|
+
Me(), await rt.action();
|
|
1968
1986
|
});
|
|
1969
1987
|
v.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1970
1988
|
try {
|
|
1971
|
-
await
|
|
1989
|
+
await pe();
|
|
1972
1990
|
} catch (o) {
|
|
1973
1991
|
console.error("Login failed:", o.message), process.exit(1);
|
|
1974
1992
|
}
|
|
1975
1993
|
process.exit(0);
|
|
1976
1994
|
});
|
|
1977
1995
|
v.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1978
|
-
await
|
|
1996
|
+
await mt(), process.exit(0);
|
|
1979
1997
|
});
|
|
1980
1998
|
v.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1981
1999
|
const o = $e();
|
|
@@ -1993,28 +2011,28 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
|
|
|
1993
2011
|
process.exit(0);
|
|
1994
2012
|
});
|
|
1995
2013
|
v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
|
|
1996
|
-
var
|
|
2014
|
+
var S, x, u;
|
|
1997
2015
|
const t = v.program.getOptionValue("config") || "./myop.config.json";
|
|
1998
2016
|
let e = {};
|
|
1999
|
-
if (
|
|
2017
|
+
if (P.existsSync(t))
|
|
2000
2018
|
try {
|
|
2001
|
-
e = JSON.parse(
|
|
2019
|
+
e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
2002
2020
|
} catch (p) {
|
|
2003
2021
|
console.error(`β οΈ Failed to parse ${t}:`, p.message);
|
|
2004
2022
|
}
|
|
2005
2023
|
o && (e.componentId = o);
|
|
2006
|
-
const n = e.name || e.componentName ||
|
|
2024
|
+
const n = e.name || e.componentName || N.basename(process.cwd());
|
|
2007
2025
|
console.log(`
|
|
2008
2026
|
π Component: ${n}`);
|
|
2009
2027
|
let s = null, i = !1;
|
|
2010
2028
|
try {
|
|
2011
|
-
const p = JSON.parse(
|
|
2029
|
+
const p = JSON.parse(P.readFileSync("package.json", "utf-8"));
|
|
2012
2030
|
i = !!(p.scripts && p.scripts.build);
|
|
2013
2031
|
} catch {
|
|
2014
2032
|
}
|
|
2015
2033
|
if (!i) {
|
|
2016
|
-
const p =
|
|
2017
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2034
|
+
const p = P.readdirSync(".").filter(
|
|
2035
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2018
2036
|
);
|
|
2019
2037
|
p.length === 1 && (s = p[0]);
|
|
2020
2038
|
}
|
|
@@ -2023,47 +2041,49 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2023
2041
|
else if (i) {
|
|
2024
2042
|
const { exec: p } = await import("child_process");
|
|
2025
2043
|
let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
2026
|
-
const
|
|
2027
|
-
const
|
|
2028
|
-
p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (
|
|
2029
|
-
if (!
|
|
2030
|
-
|
|
2044
|
+
const I = (C = !1) => new Promise((j) => {
|
|
2045
|
+
const M = V(C ? "Retrying build..." : "Building project...").start();
|
|
2046
|
+
p("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (R, k, L) => {
|
|
2047
|
+
if (!R) {
|
|
2048
|
+
M.succeed("Build completed"), j(!0);
|
|
2031
2049
|
return;
|
|
2032
2050
|
}
|
|
2033
|
-
if (
|
|
2034
|
-
const
|
|
2035
|
-
if (E = { ...E, ...
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2051
|
+
if (M.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
|
|
2052
|
+
const A = await ct(R, k, L, p, E);
|
|
2053
|
+
if (E = { ...E, ...A }, A.handled) {
|
|
2054
|
+
const _ = await I(!0);
|
|
2055
|
+
j(_);
|
|
2038
2056
|
return;
|
|
2039
2057
|
}
|
|
2040
2058
|
}
|
|
2041
|
-
console.error(
|
|
2059
|
+
console.error(R.message), j(!1);
|
|
2042
2060
|
});
|
|
2043
2061
|
});
|
|
2044
|
-
await
|
|
2062
|
+
await I() || process.exit(1);
|
|
2045
2063
|
}
|
|
2046
2064
|
let d;
|
|
2047
2065
|
if (s)
|
|
2048
2066
|
d = s;
|
|
2049
|
-
else if (
|
|
2067
|
+
else if (P.existsSync("./dist/index.html"))
|
|
2050
2068
|
d = "./dist/index.html";
|
|
2051
2069
|
else {
|
|
2052
|
-
const p =
|
|
2053
|
-
(E) => E.endsWith(".html") && !E.startsWith(".") &&
|
|
2070
|
+
const p = P.readdirSync(".").filter(
|
|
2071
|
+
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2054
2072
|
);
|
|
2055
2073
|
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));
|
|
2056
2074
|
}
|
|
2057
|
-
const
|
|
2058
|
-
console.log(` File: ${d} (${(
|
|
2075
|
+
const g = P.readFileSync(d, "utf-8");
|
|
2076
|
+
console.log(` File: ${d} (${(g.length / 1024).toFixed(1)} KB)`);
|
|
2059
2077
|
let h;
|
|
2060
2078
|
try {
|
|
2061
|
-
h = await
|
|
2079
|
+
h = await Ve();
|
|
2062
2080
|
} catch (p) {
|
|
2063
|
-
console.error("β Authentication failed:", p.message),
|
|
2081
|
+
re(p) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("β Authentication failed:", p.message), console.error(`
|
|
2082
|
+
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2083
|
+
`)), process.exit(1);
|
|
2064
2084
|
}
|
|
2065
|
-
const c =
|
|
2066
|
-
let l =
|
|
2085
|
+
const c = Ce();
|
|
2086
|
+
let l = V("Uploading...").start(), y;
|
|
2067
2087
|
try {
|
|
2068
2088
|
const p = await fetch(`${c}/mcp`, {
|
|
2069
2089
|
method: "POST",
|
|
@@ -2080,62 +2100,8 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2080
2100
|
arguments: {
|
|
2081
2101
|
name: n,
|
|
2082
2102
|
componentId: e.componentId && e.componentId !== "DEV" ? e.componentId : void 0,
|
|
2083
|
-
organization: e.organization || void 0
|
|
2084
|
-
|
|
2085
|
-
}
|
|
2086
|
-
})
|
|
2087
|
-
});
|
|
2088
|
-
if (!p.ok)
|
|
2089
|
-
throw new Error(`Server returned ${p.status}`);
|
|
2090
|
-
const E = await p.json();
|
|
2091
|
-
if (E.error)
|
|
2092
|
-
throw new Error(E.error.message);
|
|
2093
|
-
const b = (w = (g = ($ = E.result) == null ? void 0 : $.content) == null ? void 0 : g[0]) == null ? void 0 : w.text;
|
|
2094
|
-
if (x = JSON.parse(b), !x.success)
|
|
2095
|
-
throw new Error(x.error);
|
|
2096
|
-
} catch (p) {
|
|
2097
|
-
l.fail("Failed to get upload URL"), console.error(" ", p.message), process.exit(1);
|
|
2098
|
-
}
|
|
2099
|
-
try {
|
|
2100
|
-
let p;
|
|
2101
|
-
const E = x.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
2102
|
-
if (E)
|
|
2103
|
-
p = E[1];
|
|
2104
|
-
else {
|
|
2105
|
-
const k = x.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
2106
|
-
if (k)
|
|
2107
|
-
p = k[1];
|
|
2108
|
-
else
|
|
2109
|
-
throw new Error("Could not parse presigned URL");
|
|
2110
|
-
}
|
|
2111
|
-
const b = await fetch(p, {
|
|
2112
|
-
method: "PUT",
|
|
2113
|
-
headers: { "Content-Type": "text/html" },
|
|
2114
|
-
body: u
|
|
2115
|
-
});
|
|
2116
|
-
if (!b.ok) {
|
|
2117
|
-
const k = await b.text();
|
|
2118
|
-
throw new Error(`Upload failed: ${b.status} ${k}`);
|
|
2119
|
-
}
|
|
2120
|
-
} catch (p) {
|
|
2121
|
-
l.fail("Upload failed"), console.error(" ", p.message), process.exit(1);
|
|
2122
|
-
}
|
|
2123
|
-
let y;
|
|
2124
|
-
try {
|
|
2125
|
-
const p = await fetch(`${c}/mcp`, {
|
|
2126
|
-
method: "POST",
|
|
2127
|
-
headers: {
|
|
2128
|
-
"Content-Type": "application/json",
|
|
2129
|
-
Authorization: `Bearer ${h.accessToken}`
|
|
2130
|
-
},
|
|
2131
|
-
body: JSON.stringify({
|
|
2132
|
-
jsonrpc: "2.0",
|
|
2133
|
-
id: 2,
|
|
2134
|
-
method: "tools/call",
|
|
2135
|
-
params: {
|
|
2136
|
-
name: "confirm_upload",
|
|
2137
|
-
arguments: {
|
|
2138
|
-
uploadId: x.uploadId
|
|
2103
|
+
organization: e.organization || void 0,
|
|
2104
|
+
htmlContent: g
|
|
2139
2105
|
}
|
|
2140
2106
|
}
|
|
2141
2107
|
})
|
|
@@ -2145,17 +2111,17 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2145
2111
|
const E = await p.json();
|
|
2146
2112
|
if (E.error)
|
|
2147
2113
|
throw new Error(E.error.message);
|
|
2148
|
-
const
|
|
2149
|
-
if (y = JSON.parse(
|
|
2114
|
+
const I = (u = (x = (S = E.result) == null ? void 0 : S.content) == null ? void 0 : x[0]) == null ? void 0 : u.text;
|
|
2115
|
+
if (y = JSON.parse(I), !y.success)
|
|
2150
2116
|
throw new Error(y.error);
|
|
2151
2117
|
l.succeed("Pushed successfully");
|
|
2152
2118
|
} catch (p) {
|
|
2153
|
-
l.fail("
|
|
2119
|
+
l.fail("Upload failed"), re(p) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", p.message), process.exit(1);
|
|
2154
2120
|
}
|
|
2155
2121
|
if (y.isNewComponent || !e.componentId || e.componentId === "DEV") {
|
|
2156
2122
|
e.componentId = y.componentId, e.organization = y.orgId, e.name || (e.name = y.componentName);
|
|
2157
2123
|
try {
|
|
2158
|
-
|
|
2124
|
+
P.writeFileSync(t, JSON.stringify(e, null, 2));
|
|
2159
2125
|
} catch (p) {
|
|
2160
2126
|
console.log(`β οΈ Could not update ${t}: ${p.message}`), console.log(` Add componentId: "${y.componentId}" manually`);
|
|
2161
2127
|
}
|
|
@@ -2164,30 +2130,32 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2164
2130
|
${y.componentName}`), console.log(` ${y.dashboardUrl}
|
|
2165
2131
|
`), process.exit(0);
|
|
2166
2132
|
});
|
|
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) => {
|
|
2168
|
-
var
|
|
2133
|
+
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)").option("-e, --env <environment>", "Pull the variant released to this environment (e.g., staging, production)").action(async (o, t) => {
|
|
2134
|
+
var p, E, I;
|
|
2169
2135
|
const e = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2170
2136
|
let n = {};
|
|
2171
|
-
if (
|
|
2137
|
+
if (P.existsSync(e))
|
|
2172
2138
|
try {
|
|
2173
|
-
n = JSON.parse(
|
|
2139
|
+
n = JSON.parse(P.readFileSync(e, "utf-8"));
|
|
2174
2140
|
} catch {
|
|
2175
2141
|
}
|
|
2176
2142
|
const s = o || n.componentId;
|
|
2177
2143
|
(!s || s === "DEV") && (console.error("β No component ID provided."), console.log(" Pass a component ID: myop pull <componentId>"), console.log(" Or ensure myop.config.json has a valid componentId."), process.exit(1));
|
|
2178
2144
|
const i = n.name || n.componentName || s;
|
|
2179
2145
|
console.log(`
|
|
2180
|
-
π₯ Pulling: ${i}`), console.log(` ID: ${s}`);
|
|
2146
|
+
π₯ Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
|
|
2181
2147
|
let d;
|
|
2182
2148
|
try {
|
|
2183
|
-
d = await
|
|
2184
|
-
} catch (
|
|
2185
|
-
console.error("β Authentication failed:",
|
|
2149
|
+
d = await Ve();
|
|
2150
|
+
} catch ($) {
|
|
2151
|
+
re($) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("β Authentication failed:", $.message), console.error(`
|
|
2152
|
+
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2153
|
+
`)), process.exit(1);
|
|
2186
2154
|
}
|
|
2187
|
-
const
|
|
2155
|
+
const g = Ce(), h = V("Fetching component...").start();
|
|
2188
2156
|
let c;
|
|
2189
2157
|
try {
|
|
2190
|
-
const
|
|
2158
|
+
const $ = await fetch(`${g}/mcp`, {
|
|
2191
2159
|
method: "POST",
|
|
2192
2160
|
headers: {
|
|
2193
2161
|
"Content-Type": "application/json",
|
|
@@ -2199,39 +2167,39 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2199
2167
|
method: "tools/call",
|
|
2200
2168
|
params: {
|
|
2201
2169
|
name: "get_component",
|
|
2202
|
-
arguments: { componentId: s }
|
|
2170
|
+
arguments: { componentId: s, ...t.env && { environment: t.env } }
|
|
2203
2171
|
}
|
|
2204
2172
|
})
|
|
2205
2173
|
});
|
|
2206
|
-
if (
|
|
2207
|
-
throw new Error(`Server returned ${
|
|
2208
|
-
const
|
|
2209
|
-
if (
|
|
2210
|
-
throw new Error(
|
|
2211
|
-
const
|
|
2212
|
-
if (c = JSON.parse(
|
|
2174
|
+
if (!$.ok)
|
|
2175
|
+
throw new Error(`Server returned ${$.status}`);
|
|
2176
|
+
const C = await $.json();
|
|
2177
|
+
if (C.error)
|
|
2178
|
+
throw new Error(C.error.message);
|
|
2179
|
+
const j = (I = (E = (p = C.result) == null ? void 0 : p.content) == null ? void 0 : E[0]) == null ? void 0 : I.text;
|
|
2180
|
+
if (c = JSON.parse(j), !c.success && !c.html)
|
|
2213
2181
|
throw new Error(c.error || "No HTML content returned");
|
|
2214
2182
|
h.succeed("Component fetched");
|
|
2215
|
-
} catch (
|
|
2216
|
-
h.fail("Failed to fetch component"), console.error(" ",
|
|
2183
|
+
} catch ($) {
|
|
2184
|
+
h.fail("Failed to fetch component"), re($) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", $.message), process.exit(1);
|
|
2217
2185
|
}
|
|
2218
2186
|
let l = t.output;
|
|
2219
|
-
l || (
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
const
|
|
2223
|
-
let
|
|
2224
|
-
if (
|
|
2225
|
-
name: c.name ||
|
|
2187
|
+
l || (P.existsSync("./dist/index.html") ? l = "./dist/index.html" : l = "./index.html");
|
|
2188
|
+
const y = c.htmlContent || c.html, S = N.dirname(l);
|
|
2189
|
+
S && !P.existsSync(S) && P.mkdirSync(S, { recursive: !0 }), P.writeFileSync(l, y), console.log(` Saved to: ${l} (${(y.length / 1024).toFixed(1)} KB)`);
|
|
2190
|
+
const x = P.existsSync(e);
|
|
2191
|
+
let u = !1;
|
|
2192
|
+
if (x ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, u = !0), !n.name && c.name && (n.name = c.name, u = !0)) : (n = {
|
|
2193
|
+
name: c.name || N.basename(process.cwd()),
|
|
2226
2194
|
componentId: s,
|
|
2227
2195
|
type: "html",
|
|
2228
2196
|
author: "@myop-cli",
|
|
2229
2197
|
HMR: !0
|
|
2230
|
-
},
|
|
2198
|
+
}, u = !0), u)
|
|
2231
2199
|
try {
|
|
2232
|
-
|
|
2233
|
-
} catch (
|
|
2234
|
-
console.log(` β οΈ Could not write ${e}: ${
|
|
2200
|
+
P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${x ? "Updated" : "Created"} ${e}`);
|
|
2201
|
+
} catch ($) {
|
|
2202
|
+
console.log(` β οΈ Could not write ${e}: ${$.message}`);
|
|
2235
2203
|
}
|
|
2236
2204
|
console.log(`
|
|
2237
2205
|
β
Pull completed!
|
|
@@ -2241,209 +2209,189 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2241
2209
|
const { search: t, select: e } = await import("@inquirer/prompts");
|
|
2242
2210
|
let n;
|
|
2243
2211
|
try {
|
|
2244
|
-
n = await
|
|
2245
|
-
} catch (
|
|
2246
|
-
console.error("Authentication failed:",
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2212
|
+
n = await Ve();
|
|
2213
|
+
} catch (u) {
|
|
2214
|
+
re(u) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("β Authentication failed:", u.message), console.error(`
|
|
2215
|
+
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2216
|
+
`)), process.exit(1);
|
|
2217
|
+
}
|
|
2218
|
+
const s = Ce(), i = (u, p) => lo(s, n.accessToken, u, p);
|
|
2219
|
+
let d = V("Loading organizations...").start(), g;
|
|
2250
2220
|
try {
|
|
2251
|
-
const
|
|
2252
|
-
if (
|
|
2221
|
+
const u = await i("list_organizations");
|
|
2222
|
+
if (g = u.organizations || u, !Array.isArray(g))
|
|
2253
2223
|
throw new Error("Unexpected response from list_organizations");
|
|
2254
|
-
} catch (
|
|
2255
|
-
d.fail("Failed to load organizations"), console.error(" ",
|
|
2224
|
+
} catch (u) {
|
|
2225
|
+
d.fail("Failed to load organizations"), re(u) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", u.message), process.exit(1);
|
|
2256
2226
|
}
|
|
2257
|
-
|
|
2227
|
+
g.length === 0 && (d.fail("No organizations found for this account"), process.exit(1)), d.stop();
|
|
2258
2228
|
let h, c;
|
|
2259
2229
|
if (o.org) {
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2230
|
+
const u = g.find((p) => p.id === o.org || p._id === o.org);
|
|
2231
|
+
u || (console.error(`Organization "${o.org}" not found. Available:`), g.forEach((p) => console.log(` ${p.id || p._id} ${p.name}`)), process.exit(1)), h = u.id || u._id, c = u.name, je({ id: h, name: c });
|
|
2262
2232
|
} else {
|
|
2263
|
-
const
|
|
2264
|
-
if (
|
|
2265
|
-
h =
|
|
2266
|
-
else if (
|
|
2267
|
-
h =
|
|
2233
|
+
const u = ao();
|
|
2234
|
+
if (u && g.find((p) => (p.id || p._id) === u.id))
|
|
2235
|
+
h = u.id, c = u.name;
|
|
2236
|
+
else if (g.length === 1)
|
|
2237
|
+
h = g[0].id || g[0]._id, c = g[0].name, je({ id: h, name: c });
|
|
2268
2238
|
else
|
|
2269
2239
|
try {
|
|
2270
|
-
const
|
|
2240
|
+
const p = await e({
|
|
2271
2241
|
message: "Select an organization:",
|
|
2272
|
-
choices:
|
|
2273
|
-
name:
|
|
2274
|
-
value: { id:
|
|
2242
|
+
choices: g.map((E) => ({
|
|
2243
|
+
name: E.name,
|
|
2244
|
+
value: { id: E.id || E._id, name: E.name }
|
|
2275
2245
|
}))
|
|
2276
2246
|
});
|
|
2277
|
-
h =
|
|
2278
|
-
} catch (
|
|
2279
|
-
throw
|
|
2247
|
+
h = p.id, c = p.name, je({ id: h, name: c });
|
|
2248
|
+
} catch (p) {
|
|
2249
|
+
throw p.name === "ExitPromptError" && (console.log(`
|
|
2280
2250
|
|
|
2281
2251
|
π Goodbye!
|
|
2282
|
-
`), process.exit(0)),
|
|
2252
|
+
`), process.exit(0)), p;
|
|
2283
2253
|
}
|
|
2284
2254
|
}
|
|
2285
|
-
console.log(` Using organization: ${c}`), d =
|
|
2255
|
+
console.log(` Using organization: ${c}`), d = V("Loading components...").start();
|
|
2286
2256
|
let l;
|
|
2287
2257
|
try {
|
|
2288
|
-
const
|
|
2289
|
-
if (l =
|
|
2258
|
+
const u = await i("list_components", { organizationId: h });
|
|
2259
|
+
if (l = u.components || u, !Array.isArray(l))
|
|
2290
2260
|
throw new Error("Unexpected response from list_components");
|
|
2291
|
-
} catch (
|
|
2292
|
-
d.fail("Failed to load components"), console.error(" ",
|
|
2261
|
+
} catch (u) {
|
|
2262
|
+
d.fail("Failed to load components"), console.error(" ", u.message), process.exit(1);
|
|
2293
2263
|
}
|
|
2294
2264
|
d.stop(), l.length === 0 && (console.log(` No components found in this organization.
|
|
2295
2265
|
`), process.exit(0)), console.log(` ${c} - ${l.length} component(s)
|
|
2296
2266
|
`);
|
|
2297
|
-
const
|
|
2267
|
+
const y = [];
|
|
2298
2268
|
for (; ; ) {
|
|
2299
|
-
const
|
|
2300
|
-
let
|
|
2269
|
+
const u = `[Done - pull/push ${y.length} selected]`, p = "__done__", E = new Set(y.map((C) => C.id || C._id || C.componentId));
|
|
2270
|
+
let I;
|
|
2301
2271
|
try {
|
|
2302
|
-
|
|
2272
|
+
I = await t({
|
|
2303
2273
|
message: "Search & select components:",
|
|
2304
|
-
source: (
|
|
2305
|
-
const
|
|
2306
|
-
const
|
|
2307
|
-
return
|
|
2308
|
-
}),
|
|
2309
|
-
{ name:
|
|
2274
|
+
source: (C) => {
|
|
2275
|
+
const j = (C || "").toLowerCase(), M = l.filter((k) => {
|
|
2276
|
+
const L = k.id || k._id || k.componentId;
|
|
2277
|
+
return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
|
|
2278
|
+
}), R = [
|
|
2279
|
+
{ name: u, value: p }
|
|
2310
2280
|
];
|
|
2311
|
-
for (const
|
|
2312
|
-
const
|
|
2313
|
-
|
|
2314
|
-
name: `${
|
|
2315
|
-
value:
|
|
2281
|
+
for (const k of M) {
|
|
2282
|
+
const L = k.id || k._id || k.componentId, A = L ? L.substring(0, 8) + "..." : "";
|
|
2283
|
+
R.push({
|
|
2284
|
+
name: `${k.name} (${A})`,
|
|
2285
|
+
value: L
|
|
2316
2286
|
});
|
|
2317
2287
|
}
|
|
2318
|
-
return
|
|
2288
|
+
return R;
|
|
2319
2289
|
}
|
|
2320
2290
|
});
|
|
2321
|
-
} catch (
|
|
2322
|
-
throw
|
|
2291
|
+
} catch (C) {
|
|
2292
|
+
throw C.name === "ExitPromptError" && (console.log(`
|
|
2323
2293
|
|
|
2324
2294
|
π Goodbye!
|
|
2325
|
-
`), process.exit(0)),
|
|
2295
|
+
`), process.exit(0)), C;
|
|
2326
2296
|
}
|
|
2327
|
-
if (
|
|
2297
|
+
if (I === p)
|
|
2328
2298
|
break;
|
|
2329
|
-
const
|
|
2330
|
-
|
|
2299
|
+
const $ = l.find((C) => (C.id || C._id || C.componentId) === I);
|
|
2300
|
+
$ && (y.push($), console.log(` + ${$.name}`));
|
|
2331
2301
|
}
|
|
2332
|
-
|
|
2302
|
+
y.length === 0 && (console.log(` No components selected.
|
|
2333
2303
|
`), process.exit(0));
|
|
2334
|
-
let
|
|
2304
|
+
let S;
|
|
2335
2305
|
try {
|
|
2336
|
-
|
|
2337
|
-
message: `${
|
|
2306
|
+
S = await e({
|
|
2307
|
+
message: `${y.length} component(s) selected:`,
|
|
2338
2308
|
choices: [
|
|
2339
2309
|
{ name: "Pull selected", value: "pull" },
|
|
2340
2310
|
{ name: "Push selected", value: "push" },
|
|
2341
2311
|
{ name: "Cancel", value: "cancel" }
|
|
2342
2312
|
]
|
|
2343
2313
|
});
|
|
2344
|
-
} catch (
|
|
2345
|
-
throw
|
|
2314
|
+
} catch (u) {
|
|
2315
|
+
throw u.name === "ExitPromptError" && (console.log(`
|
|
2346
2316
|
|
|
2347
2317
|
π Goodbye!
|
|
2348
|
-
`), process.exit(0)),
|
|
2318
|
+
`), process.exit(0)), u;
|
|
2349
2319
|
}
|
|
2350
|
-
|
|
2320
|
+
S === "cancel" && (console.log(` Cancelled.
|
|
2351
2321
|
`), process.exit(0));
|
|
2352
|
-
const
|
|
2353
|
-
if (
|
|
2322
|
+
const x = (u) => u.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
2323
|
+
if (S === "pull") {
|
|
2354
2324
|
console.log(`
|
|
2355
|
-
Pulling ${
|
|
2325
|
+
Pulling ${y.length} components...
|
|
2356
2326
|
`);
|
|
2357
|
-
const
|
|
2358
|
-
const
|
|
2327
|
+
const u = await Promise.all(y.map(async (I) => {
|
|
2328
|
+
const $ = I.id || I._id || I.componentId;
|
|
2359
2329
|
try {
|
|
2360
|
-
const
|
|
2361
|
-
|
|
2362
|
-
const
|
|
2363
|
-
if (!
|
|
2330
|
+
const C = await i("get_component", { componentId: $ }), j = x(I.name);
|
|
2331
|
+
P.mkdirSync(j, { recursive: !0 });
|
|
2332
|
+
const M = C.htmlContent || C.html;
|
|
2333
|
+
if (!M)
|
|
2364
2334
|
throw new Error("No HTML content returned");
|
|
2365
|
-
return
|
|
2366
|
-
name:
|
|
2367
|
-
componentId:
|
|
2335
|
+
return P.writeFileSync(N.join(j, "index.html"), M), P.writeFileSync(N.join(j, "myop.config.json"), JSON.stringify({
|
|
2336
|
+
name: I.name,
|
|
2337
|
+
componentId: $,
|
|
2368
2338
|
organization: h,
|
|
2369
2339
|
type: "html",
|
|
2370
2340
|
author: "@myop-cli",
|
|
2371
2341
|
HMR: !0
|
|
2372
|
-
}, null, 2)), { name:
|
|
2373
|
-
} catch (
|
|
2374
|
-
return { name:
|
|
2342
|
+
}, null, 2)), { name: I.name, status: "ok", dir: j };
|
|
2343
|
+
} catch (C) {
|
|
2344
|
+
return { name: I.name, status: "failed", error: C.message };
|
|
2375
2345
|
}
|
|
2376
2346
|
}));
|
|
2377
|
-
let
|
|
2378
|
-
for (const
|
|
2379
|
-
|
|
2347
|
+
let p = 0, E = 0;
|
|
2348
|
+
for (const I of u)
|
|
2349
|
+
I.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${I.name} -> ./${I.dir}/`), p++) : (console.log(` \x1B[31mβ\x1B[0m ${I.name} - ${I.error}`), E++);
|
|
2380
2350
|
console.log(`
|
|
2381
|
-
Done! Pulled ${
|
|
2351
|
+
Done! Pulled ${p} component${p !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
|
|
2382
2352
|
`);
|
|
2383
|
-
} else if (
|
|
2353
|
+
} else if (S === "push") {
|
|
2384
2354
|
console.log(`
|
|
2385
|
-
Pushing ${
|
|
2355
|
+
Pushing ${y.length} components...
|
|
2386
2356
|
`);
|
|
2387
|
-
const
|
|
2388
|
-
const
|
|
2389
|
-
if (!
|
|
2390
|
-
return { name:
|
|
2357
|
+
const u = Ye(".", 3), p = await Promise.all(y.map(async (C) => {
|
|
2358
|
+
const j = C.id || C._id || C.componentId, M = u.find((R) => R.componentId === j);
|
|
2359
|
+
if (!M)
|
|
2360
|
+
return { name: C.name, status: "skipped", reason: "no local match" };
|
|
2391
2361
|
try {
|
|
2392
|
-
let
|
|
2393
|
-
const
|
|
2394
|
-
if (
|
|
2395
|
-
|
|
2362
|
+
let R;
|
|
2363
|
+
const k = M.path;
|
|
2364
|
+
if (P.existsSync(N.join(k, "dist", "index.html")))
|
|
2365
|
+
R = N.join(k, "dist", "index.html");
|
|
2396
2366
|
else {
|
|
2397
|
-
const z =
|
|
2398
|
-
(
|
|
2367
|
+
const z = P.readdirSync(k).filter(
|
|
2368
|
+
(T) => T.endsWith(".html") && !T.startsWith(".") && P.statSync(N.join(k, T)).isFile()
|
|
2399
2369
|
);
|
|
2400
2370
|
if (z.length === 1)
|
|
2401
|
-
|
|
2371
|
+
R = N.join(k, z[0]);
|
|
2402
2372
|
else if (z.includes("index.html"))
|
|
2403
|
-
|
|
2373
|
+
R = N.join(k, "index.html");
|
|
2404
2374
|
else
|
|
2405
2375
|
throw new Error("No HTML file found");
|
|
2406
2376
|
}
|
|
2407
|
-
const
|
|
2408
|
-
name:
|
|
2409
|
-
componentId:
|
|
2410
|
-
organization: h
|
|
2411
|
-
|
|
2412
|
-
if (!T.success)
|
|
2413
|
-
throw new Error(T.error || "Upload request failed");
|
|
2414
|
-
let J;
|
|
2415
|
-
const F = T.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
2416
|
-
if (F)
|
|
2417
|
-
J = F[1];
|
|
2418
|
-
else {
|
|
2419
|
-
const z = T.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
2420
|
-
if (z)
|
|
2421
|
-
J = z[1];
|
|
2422
|
-
else
|
|
2423
|
-
throw new Error("Could not parse presigned URL");
|
|
2424
|
-
}
|
|
2425
|
-
const V = await fetch(J, {
|
|
2426
|
-
method: "PUT",
|
|
2427
|
-
headers: { "Content-Type": "text/html" },
|
|
2428
|
-
body: D
|
|
2429
|
-
});
|
|
2430
|
-
if (!V.ok)
|
|
2431
|
-
throw new Error(`Upload failed: ${V.status}`);
|
|
2432
|
-
const te = await i("confirm_upload", {
|
|
2433
|
-
uploadId: T.uploadId
|
|
2377
|
+
const L = P.readFileSync(R, "utf-8"), A = M.name || C.name, _ = await i("upload_component", {
|
|
2378
|
+
name: A,
|
|
2379
|
+
componentId: j,
|
|
2380
|
+
organization: h,
|
|
2381
|
+
htmlContent: L
|
|
2434
2382
|
});
|
|
2435
|
-
if (!
|
|
2436
|
-
throw new Error(
|
|
2437
|
-
return { name:
|
|
2438
|
-
} catch (
|
|
2439
|
-
return { name:
|
|
2383
|
+
if (!_.success)
|
|
2384
|
+
throw new Error(_.error || "Upload failed");
|
|
2385
|
+
return { name: A, status: "ok" };
|
|
2386
|
+
} catch (R) {
|
|
2387
|
+
return { name: C.name, status: "failed", error: R.message };
|
|
2440
2388
|
}
|
|
2441
2389
|
}));
|
|
2442
|
-
let
|
|
2443
|
-
for (const
|
|
2444
|
-
|
|
2390
|
+
let E = 0, I = 0, $ = 0;
|
|
2391
|
+
for (const C of p)
|
|
2392
|
+
C.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${C.name}`), E++) : C.status === "skipped" ? (console.log(` \x1B[33mβ\x1B[0m ${C.name} (${C.reason})`), I++) : (console.log(` \x1B[31mβ\x1B[0m ${C.name} - ${C.error}`), $++);
|
|
2445
2393
|
console.log(`
|
|
2446
|
-
Done! Pushed ${
|
|
2394
|
+
Done! Pushed ${E}${I ? `, skipped ${I}` : ""}${$ ? `, ${$} failed` : ""}.
|
|
2447
2395
|
`);
|
|
2448
2396
|
}
|
|
2449
2397
|
process.exit(0);
|
|
@@ -2595,23 +2543,23 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2595
2543
|
</body>
|
|
2596
2544
|
</html>`;
|
|
2597
2545
|
t.writeFileSync("index.html", d);
|
|
2598
|
-
const
|
|
2546
|
+
const g = await Ge(process.cwd());
|
|
2599
2547
|
console.log(`
|
|
2600
|
-
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"),
|
|
2548
|
+
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), g.success && console.log(" AI agent skills installed"), console.log(""), await be();
|
|
2601
2549
|
});
|
|
2602
|
-
v.program.command("dev").description("Start development server with file watching").action(
|
|
2603
|
-
const
|
|
2604
|
-
const o = process.cwd(), t =
|
|
2550
|
+
v.program.command("dev").description("Start development server with file watching").action(be);
|
|
2551
|
+
const gt = async () => {
|
|
2552
|
+
const o = process.cwd(), t = V("Installing AI agent skills...").start(), e = await Ge(o);
|
|
2605
2553
|
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);
|
|
2606
2554
|
};
|
|
2607
|
-
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(
|
|
2608
|
-
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(
|
|
2555
|
+
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(gt);
|
|
2556
|
+
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(gt);
|
|
2609
2557
|
v.program.command("mcp").description("Configure Myop MCP server for your AI coding assistant").action(async () => {
|
|
2610
|
-
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s =
|
|
2558
|
+
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Ce() + "/mcp", i = [
|
|
2611
2559
|
{
|
|
2612
2560
|
name: "Claude Code",
|
|
2613
2561
|
value: "claude",
|
|
2614
|
-
configPath:
|
|
2562
|
+
configPath: N.join(n, ".claude.json"),
|
|
2615
2563
|
getEntry: () => ({ type: "http", url: s }),
|
|
2616
2564
|
nextSteps: [
|
|
2617
2565
|
"Restart Claude Code to pick up the new MCP config.",
|
|
@@ -2623,7 +2571,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2623
2571
|
{
|
|
2624
2572
|
name: "Cursor",
|
|
2625
2573
|
value: "cursor",
|
|
2626
|
-
configPath:
|
|
2574
|
+
configPath: N.join(n, ".cursor", "mcp.json"),
|
|
2627
2575
|
getEntry: () => ({ url: s }),
|
|
2628
2576
|
nextSteps: [
|
|
2629
2577
|
'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
|
|
@@ -2636,7 +2584,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2636
2584
|
{
|
|
2637
2585
|
name: "Windsurf",
|
|
2638
2586
|
value: "windsurf",
|
|
2639
|
-
configPath:
|
|
2587
|
+
configPath: N.join(n, ".codeium", "windsurf", "mcp_config.json"),
|
|
2640
2588
|
getEntry: () => ({ url: s }),
|
|
2641
2589
|
nextSteps: [
|
|
2642
2590
|
"Open Cascade and click the hammer icon (top-right) to see MCP servers.",
|
|
@@ -2648,7 +2596,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2648
2596
|
{
|
|
2649
2597
|
name: "VS Code (GitHub Copilot)",
|
|
2650
2598
|
value: "vscode",
|
|
2651
|
-
configPath: process.platform === "darwin" ?
|
|
2599
|
+
configPath: process.platform === "darwin" ? N.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? N.join(process.env.APPDATA || N.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : N.join(n, ".config", "Code", "User", "mcp.json"),
|
|
2652
2600
|
getEntry: () => ({ type: "http", url: s }),
|
|
2653
2601
|
nextSteps: [
|
|
2654
2602
|
"Requires VS Code 1.99+ and GitHub Copilot extension.",
|
|
@@ -2675,10 +2623,10 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2675
2623
|
π Goodbye!
|
|
2676
2624
|
`), process.exit(0)), l;
|
|
2677
2625
|
}
|
|
2678
|
-
const
|
|
2626
|
+
const g = i.find((l) => l.value === d);
|
|
2679
2627
|
let h = {};
|
|
2680
2628
|
try {
|
|
2681
|
-
const l =
|
|
2629
|
+
const l = P.readFileSync(g.configPath, "utf-8");
|
|
2682
2630
|
h = JSON.parse(l);
|
|
2683
2631
|
} catch {
|
|
2684
2632
|
}
|
|
@@ -2686,9 +2634,9 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2686
2634
|
const c = h.mcpServers.myop;
|
|
2687
2635
|
if (c && c.url === s) {
|
|
2688
2636
|
console.log(`
|
|
2689
|
-
Myop MCP is already configured for ${
|
|
2637
|
+
Myop MCP is already configured for ${g.name}.`), console.log(` Config: ${g.configPath}`), console.log(`
|
|
2690
2638
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2691
|
-
for (const l of
|
|
2639
|
+
for (const l of g.nextSteps)
|
|
2692
2640
|
console.log(` ${l}`);
|
|
2693
2641
|
console.log(""), process.exit(0);
|
|
2694
2642
|
}
|
|
@@ -2701,26 +2649,26 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2701
2649
|
throw l.name === "ExitPromptError" && process.exit(0), l;
|
|
2702
2650
|
}
|
|
2703
2651
|
}
|
|
2704
|
-
h.mcpServers.myop =
|
|
2705
|
-
\x1B[32mβ\x1B[0m Myop MCP configured for ${
|
|
2652
|
+
h.mcpServers.myop = g.getEntry(), P.mkdirSync(N.dirname(g.configPath), { recursive: !0 }), P.writeFileSync(g.configPath, JSON.stringify(h, null, 2)), console.log(`
|
|
2653
|
+
\x1B[32mβ\x1B[0m Myop MCP configured for ${g.name}`), console.log(` Config: ${g.configPath}`), console.log(` Server: ${s}`), console.log(`
|
|
2706
2654
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2707
|
-
for (const l of
|
|
2655
|
+
for (const l of g.nextSteps)
|
|
2708
2656
|
console.log(` ${l}`);
|
|
2709
2657
|
console.log(""), process.exit(0);
|
|
2710
2658
|
});
|
|
2711
|
-
const
|
|
2659
|
+
const go = () => {
|
|
2712
2660
|
try {
|
|
2713
|
-
|
|
2661
|
+
Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2714
2662
|
} catch {
|
|
2715
2663
|
return { gitNotInstalled: !0 };
|
|
2716
2664
|
}
|
|
2717
2665
|
try {
|
|
2718
|
-
|
|
2666
|
+
Q("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2719
2667
|
} catch {
|
|
2720
2668
|
return { notARepo: !0 };
|
|
2721
2669
|
}
|
|
2722
2670
|
try {
|
|
2723
|
-
const o =
|
|
2671
|
+
const o = Q("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
|
|
2724
2672
|
encoding: "utf-8",
|
|
2725
2673
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2726
2674
|
}).trim();
|
|
@@ -2740,9 +2688,9 @@ const po = () => {
|
|
|
2740
2688
|
} catch {
|
|
2741
2689
|
return null;
|
|
2742
2690
|
}
|
|
2743
|
-
},
|
|
2744
|
-
var l,
|
|
2745
|
-
const e = $e(), n = !!(e != null && e.email), s = ((l = v.myopConfig) == null ? void 0 : l.name) || ((
|
|
2691
|
+
}, ne = async (o = !1, t = !1) => {
|
|
2692
|
+
var l, y, S;
|
|
2693
|
+
const e = $e(), n = !!(e != null && e.email), s = ((l = v.myopConfig) == null ? void 0 : l.name) || ((y = v.myopConfig) == null ? void 0 : y.componentName), i = (S = v.myopConfig) == null ? void 0 : S.componentId, d = go();
|
|
2746
2694
|
console.log(`
|
|
2747
2695
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2748
2696
|
`), 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("");
|
|
@@ -2768,14 +2716,14 @@ const po = () => {
|
|
|
2768
2716
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
2769
2717
|
disabled: o ? n ? !1 : "(login required)" : "(no config file)"
|
|
2770
2718
|
}
|
|
2771
|
-
].map((
|
|
2772
|
-
name: t &&
|
|
2773
|
-
${
|
|
2774
|
-
value:
|
|
2775
|
-
disabled:
|
|
2719
|
+
].map((x) => ({
|
|
2720
|
+
name: t && !x.disabled ? `${x.emoji} ${x.label}
|
|
2721
|
+
${x.help}` : `${x.emoji} ${x.label}`,
|
|
2722
|
+
value: x.value,
|
|
2723
|
+
disabled: x.disabled
|
|
2776
2724
|
}));
|
|
2777
2725
|
h.push(
|
|
2778
|
-
new
|
|
2726
|
+
new De(),
|
|
2779
2727
|
{
|
|
2780
2728
|
name: t && n ? `π Logout (${e.email})
|
|
2781
2729
|
Clears stored credentials from this machine` : t && !n ? `π Login to Myop
|
|
@@ -2786,7 +2734,7 @@ const po = () => {
|
|
|
2786
2734
|
name: t ? "π Hide help" : "π Show help",
|
|
2787
2735
|
value: "help"
|
|
2788
2736
|
},
|
|
2789
|
-
new
|
|
2737
|
+
new De(),
|
|
2790
2738
|
{
|
|
2791
2739
|
name: "π Exit",
|
|
2792
2740
|
value: "exit"
|
|
@@ -2794,114 +2742,114 @@ const po = () => {
|
|
|
2794
2742
|
);
|
|
2795
2743
|
let c;
|
|
2796
2744
|
try {
|
|
2797
|
-
c = await
|
|
2745
|
+
c = await ot({
|
|
2798
2746
|
message: "What would you like to do?",
|
|
2799
2747
|
choices: h
|
|
2800
2748
|
});
|
|
2801
|
-
} catch (
|
|
2802
|
-
throw
|
|
2749
|
+
} catch (x) {
|
|
2750
|
+
throw x.name === "ExitPromptError" && (console.log(`
|
|
2803
2751
|
|
|
2804
2752
|
π Goodbye!
|
|
2805
|
-
`), process.exit(0)),
|
|
2753
|
+
`), process.exit(0)), x;
|
|
2806
2754
|
}
|
|
2807
2755
|
switch (c) {
|
|
2808
2756
|
case "init":
|
|
2809
|
-
await
|
|
2757
|
+
await wo();
|
|
2810
2758
|
break;
|
|
2811
2759
|
case "sync":
|
|
2812
2760
|
console.log(`
|
|
2813
2761
|
Pushing component...
|
|
2814
2762
|
`);
|
|
2815
|
-
const { execSync:
|
|
2763
|
+
const { execSync: x } = await import("child_process");
|
|
2816
2764
|
try {
|
|
2817
|
-
|
|
2765
|
+
x("node " + process.argv[1] + " push", { stdio: "inherit" });
|
|
2818
2766
|
} catch {
|
|
2819
2767
|
}
|
|
2820
|
-
await
|
|
2768
|
+
await ne(!0, t);
|
|
2821
2769
|
break;
|
|
2822
2770
|
case "dev":
|
|
2823
|
-
await
|
|
2771
|
+
await be();
|
|
2824
2772
|
break;
|
|
2825
2773
|
case "login":
|
|
2826
2774
|
try {
|
|
2827
|
-
await
|
|
2828
|
-
`), await
|
|
2829
|
-
} catch (
|
|
2830
|
-
console.error("Login failed:",
|
|
2775
|
+
await pe(), console.log(`
|
|
2776
|
+
`), await ne(o, t);
|
|
2777
|
+
} catch (u) {
|
|
2778
|
+
console.error("Login failed:", u.message), await ne(o, t);
|
|
2831
2779
|
}
|
|
2832
2780
|
break;
|
|
2833
2781
|
case "logout":
|
|
2834
|
-
await
|
|
2835
|
-
`), await
|
|
2782
|
+
await mt(), console.log(`
|
|
2783
|
+
`), await ne(o, t);
|
|
2836
2784
|
break;
|
|
2837
2785
|
case "help":
|
|
2838
|
-
await
|
|
2786
|
+
await ne(o, !t);
|
|
2839
2787
|
break;
|
|
2840
2788
|
case "exit":
|
|
2841
2789
|
process.exit(0);
|
|
2842
2790
|
}
|
|
2843
|
-
},
|
|
2791
|
+
}, xe = ".myop-monorepo.json", fo = () => {
|
|
2844
2792
|
try {
|
|
2845
|
-
const o =
|
|
2793
|
+
const o = P.readFileSync(xe, "utf-8");
|
|
2846
2794
|
return JSON.parse(o);
|
|
2847
2795
|
} catch {
|
|
2848
2796
|
return null;
|
|
2849
2797
|
}
|
|
2850
|
-
},
|
|
2798
|
+
}, ho = (o) => {
|
|
2851
2799
|
try {
|
|
2852
2800
|
const t = {
|
|
2853
2801
|
selectedComponents: o,
|
|
2854
2802
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2855
2803
|
};
|
|
2856
|
-
|
|
2804
|
+
P.writeFileSync(xe, JSON.stringify(t, null, 2));
|
|
2857
2805
|
} catch {
|
|
2858
2806
|
}
|
|
2859
|
-
},
|
|
2807
|
+
}, yo = async () => {
|
|
2860
2808
|
const o = $e(), t = !!(o != null && o.email);
|
|
2861
2809
|
console.log(`
|
|
2862
2810
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Myop CLI - Monorepo Mode β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2863
2811
|
`);
|
|
2864
|
-
const e =
|
|
2812
|
+
const e = V("Scanning for components...").start(), n = Ye(".");
|
|
2865
2813
|
e.stop(), n.length === 0 && (console.log(` β οΈ No myop.config.json files found in this directory or subdirectories.
|
|
2866
2814
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2867
|
-
const s =
|
|
2815
|
+
const s = fo(), i = (s == null ? void 0 : s.selectedComponents) || [], d = i.length > 0;
|
|
2868
2816
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2869
|
-
`), n.forEach((
|
|
2870
|
-
const
|
|
2871
|
-
console.log(` ${
|
|
2872
|
-
}), console.log(` User: ${t ? o.email : "Not logged in"}`), d && console.log(` π Using saved selection from ${
|
|
2873
|
-
const
|
|
2817
|
+
`), n.forEach((y, S) => {
|
|
2818
|
+
const x = y.componentId ? "β
" : "βͺ", u = y.componentId ? y.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2819
|
+
console.log(` ${x} ${y.name}`), console.log(` Path: ${y.path}`), console.log(` ID: ${u}`), console.log("");
|
|
2820
|
+
}), console.log(` User: ${t ? o.email : "Not logged in"}`), d && console.log(` π Using saved selection from ${xe}`), console.log("");
|
|
2821
|
+
const g = v.program.getOptionValue("ci");
|
|
2874
2822
|
let h;
|
|
2875
|
-
if (
|
|
2876
|
-
d ? (h = i, console.log(` π€ CI mode: using saved selection (${h.length} components)`)) : (h = n.map((
|
|
2823
|
+
if (g)
|
|
2824
|
+
d ? (h = i, console.log(` π€ CI mode: using saved selection (${h.length} components)`)) : (h = n.map((y) => y.path), console.log(` π€ CI mode: no saved selection, using all ${h.length} components`));
|
|
2877
2825
|
else {
|
|
2878
|
-
const { checkbox:
|
|
2879
|
-
name: `${
|
|
2880
|
-
value:
|
|
2881
|
-
checked: d ? i.includes(
|
|
2826
|
+
const { checkbox: y } = await import("@inquirer/prompts"), S = n.map((x) => ({
|
|
2827
|
+
name: `${x.name} (${x.path})`,
|
|
2828
|
+
value: x.path,
|
|
2829
|
+
checked: d ? i.includes(x.path) : !0
|
|
2882
2830
|
}));
|
|
2883
2831
|
try {
|
|
2884
|
-
h = await
|
|
2832
|
+
h = await y({
|
|
2885
2833
|
message: "Select components to start in dev mode:",
|
|
2886
|
-
choices:
|
|
2834
|
+
choices: S
|
|
2887
2835
|
});
|
|
2888
|
-
} catch (
|
|
2889
|
-
throw
|
|
2836
|
+
} catch (x) {
|
|
2837
|
+
throw x.name === "ExitPromptError" && (console.log(`
|
|
2890
2838
|
|
|
2891
2839
|
π Goodbye!
|
|
2892
|
-
`), process.exit(0)),
|
|
2840
|
+
`), process.exit(0)), x;
|
|
2893
2841
|
}
|
|
2894
2842
|
}
|
|
2895
2843
|
h.length === 0 && (console.log(`
|
|
2896
2844
|
β οΈ No components selected.
|
|
2897
|
-
`), process.exit(0)),
|
|
2898
|
-
πΎ Selection saved to ${
|
|
2899
|
-
const c = n.filter((
|
|
2845
|
+
`), process.exit(0)), g || (ho(h), console.log(`
|
|
2846
|
+
πΎ Selection saved to ${xe}`));
|
|
2847
|
+
const c = n.filter((y) => h.includes(y.path));
|
|
2900
2848
|
console.log(`π Starting dev mode for ${c.length} component${c.length > 1 ? "s" : ""}...
|
|
2901
2849
|
`);
|
|
2902
|
-
const { monorepoDevCommand: l } = await Promise.resolve().then(() =>
|
|
2850
|
+
const { monorepoDevCommand: l } = await Promise.resolve().then(() => Bt);
|
|
2903
2851
|
await l(c);
|
|
2904
|
-
},
|
|
2852
|
+
}, wo = async () => {
|
|
2905
2853
|
const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
|
|
2906
2854
|
let i, d;
|
|
2907
2855
|
try {
|
|
@@ -2923,14 +2871,14 @@ Pushing component...
|
|
|
2923
2871
|
π Goodbye!
|
|
2924
2872
|
`), process.exit(0)), c;
|
|
2925
2873
|
}
|
|
2926
|
-
const
|
|
2874
|
+
const g = {
|
|
2927
2875
|
name: i,
|
|
2928
2876
|
type: d,
|
|
2929
2877
|
author: "@myop-cli",
|
|
2930
2878
|
HMR: !0
|
|
2931
2879
|
}, h = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2932
2880
|
try {
|
|
2933
|
-
e.writeFileSync(h, JSON.stringify(
|
|
2881
|
+
e.writeFileSync(h, JSON.stringify(g, null, 2)), console.log(`
|
|
2934
2882
|
β
Created ${h}`);
|
|
2935
2883
|
const c = {
|
|
2936
2884
|
name: i.toLowerCase().replace(/\s+/g, "-"),
|
|
@@ -3024,7 +2972,7 @@ fs.writeFileSync('dist/index.html', html);
|
|
|
3024
2972
|
console.log('β
Built dist/index.html');
|
|
3025
2973
|
console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
|
|
3026
2974
|
`), console.log("β
Created build.js");
|
|
3027
|
-
const
|
|
2975
|
+
const y = `<!DOCTYPE html>
|
|
3028
2976
|
<html lang="en">
|
|
3029
2977
|
<head>
|
|
3030
2978
|
<meta charset="UTF-8">
|
|
@@ -3041,8 +2989,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
3041
2989
|
</body>
|
|
3042
2990
|
</html>
|
|
3043
2991
|
`;
|
|
3044
|
-
e.writeFileSync("index.html",
|
|
3045
|
-
const
|
|
2992
|
+
e.writeFileSync("index.html", y), console.log("β
Created index.html");
|
|
2993
|
+
const S = `// ${i} - Entry Point
|
|
3046
2994
|
import { init } from './modules/app.js';
|
|
3047
2995
|
import { setupMyopInterface } from './modules/myop.js';
|
|
3048
2996
|
|
|
@@ -3051,8 +2999,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
3051
2999
|
setupMyopInterface();
|
|
3052
3000
|
});
|
|
3053
3001
|
`;
|
|
3054
|
-
e.writeFileSync("src/index.js",
|
|
3055
|
-
const
|
|
3002
|
+
e.writeFileSync("src/index.js", S), console.log("β
Created src/index.js");
|
|
3003
|
+
const x = `// ${i} - Main Application Logic
|
|
3056
3004
|
|
|
3057
3005
|
export function init() {
|
|
3058
3006
|
console.log('${i} loaded');
|
|
@@ -3060,7 +3008,7 @@ export function init() {
|
|
|
3060
3008
|
// Your component logic here
|
|
3061
3009
|
}
|
|
3062
3010
|
`;
|
|
3063
|
-
e.writeFileSync("src/modules/app.js",
|
|
3011
|
+
e.writeFileSync("src/modules/app.js", x), console.log("β
Created src/modules/app.js"), e.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
|
|
3064
3012
|
|
|
3065
3013
|
export function setupMyopInterface() {
|
|
3066
3014
|
// Called when host app sends data to this component
|
|
@@ -3076,12 +3024,12 @@ export function setupMyopInterface() {
|
|
|
3076
3024
|
};
|
|
3077
3025
|
}
|
|
3078
3026
|
`), console.log("β
Created src/modules/myop.js");
|
|
3079
|
-
const
|
|
3027
|
+
const p = `/* ${i} - Styles Entry Point */
|
|
3080
3028
|
/* Add your CSS imports here - they will be auto-bundled */
|
|
3081
3029
|
@import './main.css';
|
|
3082
3030
|
`;
|
|
3083
|
-
e.writeFileSync("src/styles/index.css",
|
|
3084
|
-
const
|
|
3031
|
+
e.writeFileSync("src/styles/index.css", p), console.log("β
Created src/styles/index.css");
|
|
3032
|
+
const E = `/* ${i} - Main Styles */
|
|
3085
3033
|
|
|
3086
3034
|
* {
|
|
3087
3035
|
box-sizing: border-box;
|
|
@@ -3110,18 +3058,18 @@ p {
|
|
|
3110
3058
|
line-height: 1.5;
|
|
3111
3059
|
}
|
|
3112
3060
|
`;
|
|
3113
|
-
e.writeFileSync("src/styles/main.css",
|
|
3061
|
+
e.writeFileSync("src/styles/main.css", E), console.log("β
Created src/styles/main.css"), e.writeFileSync(".gitignore", `node_modules/
|
|
3114
3062
|
dist/
|
|
3115
3063
|
.temp-entry.js
|
|
3116
3064
|
.temp-styles.css
|
|
3117
3065
|
.DS_Store
|
|
3118
3066
|
`), console.log("β
Created .gitignore");
|
|
3119
|
-
const
|
|
3120
|
-
|
|
3121
|
-
const
|
|
3067
|
+
const $ = await Ge(process.cwd());
|
|
3068
|
+
$.success && console.log("β
Installed AI agent skills");
|
|
3069
|
+
const C = await import("./index-DuEoKctW.js").then((M) => M.i), j = process.cwd();
|
|
3122
3070
|
try {
|
|
3123
|
-
await
|
|
3124
|
-
const
|
|
3071
|
+
await C.init({ fs: e, dir: j });
|
|
3072
|
+
const M = [
|
|
3125
3073
|
"myop.config.json",
|
|
3126
3074
|
"package.json",
|
|
3127
3075
|
"build.js",
|
|
@@ -3133,85 +3081,85 @@ dist/
|
|
|
3133
3081
|
"src/styles/index.css",
|
|
3134
3082
|
"src/styles/main.css"
|
|
3135
3083
|
];
|
|
3136
|
-
if (
|
|
3137
|
-
const
|
|
3084
|
+
if ($.success) {
|
|
3085
|
+
const R = (k, L) => {
|
|
3138
3086
|
try {
|
|
3139
|
-
const
|
|
3140
|
-
for (const
|
|
3141
|
-
const
|
|
3142
|
-
|
|
3087
|
+
const A = e.readdirSync(k, { withFileTypes: !0 });
|
|
3088
|
+
for (const _ of A) {
|
|
3089
|
+
const z = n.join(k, _.name), T = n.join(L, _.name);
|
|
3090
|
+
_.isDirectory() ? R(z, T) : M.push(T);
|
|
3143
3091
|
}
|
|
3144
3092
|
} catch {
|
|
3145
3093
|
}
|
|
3146
3094
|
};
|
|
3147
3095
|
try {
|
|
3148
|
-
const
|
|
3149
|
-
for (const
|
|
3150
|
-
if (
|
|
3151
|
-
const
|
|
3152
|
-
e.existsSync(
|
|
3096
|
+
const k = e.readdirSync(".", { withFileTypes: !0 });
|
|
3097
|
+
for (const L of k)
|
|
3098
|
+
if (L.isDirectory() && L.name.startsWith(".")) {
|
|
3099
|
+
const A = n.join(L.name, "skills");
|
|
3100
|
+
e.existsSync(A) && R(A, A);
|
|
3153
3101
|
}
|
|
3154
3102
|
} catch {
|
|
3155
3103
|
}
|
|
3156
3104
|
}
|
|
3157
|
-
for (const
|
|
3158
|
-
await
|
|
3159
|
-
await
|
|
3105
|
+
for (const R of M)
|
|
3106
|
+
await C.add({ fs: e, dir: j, filepath: R });
|
|
3107
|
+
await C.commit({
|
|
3160
3108
|
fs: e,
|
|
3161
|
-
dir:
|
|
3109
|
+
dir: j,
|
|
3162
3110
|
message: "init",
|
|
3163
3111
|
author: { name: "myop-cli", email: "cli@myop.dev" }
|
|
3164
3112
|
}), console.log("β
Initialized git repository");
|
|
3165
|
-
} catch (
|
|
3166
|
-
console.log("β οΈ Failed to initialize git repository:",
|
|
3113
|
+
} catch (M) {
|
|
3114
|
+
console.log("β οΈ Failed to initialize git repository:", M.message);
|
|
3167
3115
|
}
|
|
3168
3116
|
console.log(`
|
|
3169
3117
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
3170
|
-
`), v.myopConfig =
|
|
3118
|
+
`), v.myopConfig = g, await ne(!0);
|
|
3171
3119
|
} catch (c) {
|
|
3172
3120
|
console.error(`Failed to initialize component: ${c.message}`), process.exit(1);
|
|
3173
3121
|
}
|
|
3174
3122
|
};
|
|
3175
3123
|
v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
3176
|
-
if (v.program.getOptionValue("help") && (console.log(
|
|
3177
|
-
await
|
|
3124
|
+
if (v.program.getOptionValue("help") && (console.log(Et), process.exit()), v.program.getOptionValue("monorepo")) {
|
|
3125
|
+
await yo();
|
|
3178
3126
|
return;
|
|
3179
3127
|
}
|
|
3180
3128
|
if (v.program.getOptionValue("ci")) {
|
|
3181
|
-
const
|
|
3182
|
-
let
|
|
3129
|
+
const g = await import("fs"), h = v.program.getOptionValue("config") || "./myop.config.json", c = v.program.version(), l = $e();
|
|
3130
|
+
let y = { found: !1 };
|
|
3183
3131
|
try {
|
|
3184
|
-
if (
|
|
3185
|
-
const
|
|
3186
|
-
|
|
3132
|
+
if (g.existsSync(h)) {
|
|
3133
|
+
const x = g.readFileSync(h, "utf-8"), u = JSON.parse(x);
|
|
3134
|
+
y = {
|
|
3187
3135
|
found: !0,
|
|
3188
3136
|
path: h,
|
|
3189
|
-
name:
|
|
3190
|
-
componentId:
|
|
3191
|
-
organization:
|
|
3137
|
+
name: u.name || u.componentName || null,
|
|
3138
|
+
componentId: u.componentId || null,
|
|
3139
|
+
organization: u.organization || null
|
|
3192
3140
|
};
|
|
3193
3141
|
}
|
|
3194
|
-
} catch (
|
|
3195
|
-
|
|
3142
|
+
} catch (x) {
|
|
3143
|
+
y = { found: !1, error: x.message };
|
|
3196
3144
|
}
|
|
3197
|
-
const
|
|
3145
|
+
const S = {
|
|
3198
3146
|
version: c,
|
|
3199
|
-
config:
|
|
3147
|
+
config: y,
|
|
3200
3148
|
auth: {
|
|
3201
3149
|
loggedIn: !!(l != null && l.email),
|
|
3202
3150
|
email: (l == null ? void 0 : l.email) || null
|
|
3203
3151
|
}
|
|
3204
3152
|
};
|
|
3205
|
-
console.log(JSON.stringify(
|
|
3153
|
+
console.log(JSON.stringify(S, null, 2)), process.exit(0);
|
|
3206
3154
|
}
|
|
3207
|
-
let n =
|
|
3155
|
+
let n = V({
|
|
3208
3156
|
text: "Loading Myop CLI...",
|
|
3209
3157
|
color: "green"
|
|
3210
3158
|
}).start();
|
|
3211
|
-
const s =
|
|
3212
|
-
await
|
|
3159
|
+
const s = Me();
|
|
3160
|
+
await co(500), n.stop();
|
|
3213
3161
|
const i = v.program.version();
|
|
3214
|
-
await
|
|
3162
|
+
await so(i) || await ne(s.configFound);
|
|
3215
3163
|
});
|
|
3216
3164
|
v.program.parse(process.argv);
|
|
3217
3165
|
v.program.opts();
|