@myop/cli 0.1.53 β 0.1.55
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/README.md +28 -0
- package/dist/myop-cli.js +1107 -994
- package/dist/skills/myop-cli/SKILL.md +65 -0
- 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 Q, spawn as
|
|
9
|
-
import
|
|
10
|
-
import P, { readFileSync as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { URL as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
const
|
|
2
|
+
var bt = Object.defineProperty;
|
|
3
|
+
var Ct = (o, t, e) => t in o ? bt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
4
|
+
var ve = (o, t, e) => Ct(o, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
+
import z from "ora";
|
|
6
|
+
import { select as st, Separator as Ue } from "@inquirer/prompts";
|
|
7
|
+
import { Command as Pt, Option as fe } from "commander";
|
|
8
|
+
import { execSync as Q, spawn as Mt } from "child_process";
|
|
9
|
+
import R, { join as Ae } from "path";
|
|
10
|
+
import P, { readFileSync as Et } from "fs";
|
|
11
|
+
import We from "crypto";
|
|
12
|
+
import It from "http";
|
|
13
|
+
import { URL as it, URLSearchParams as rt } from "url";
|
|
14
|
+
import Ot from "open";
|
|
15
|
+
import at from "os";
|
|
16
|
+
const kt = `
|
|
17
17
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
18
18
|
|
|
19
19
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -55,25 +55,25 @@ Examples:
|
|
|
55
55
|
verbose: !1
|
|
56
56
|
},
|
|
57
57
|
myopConfig: null
|
|
58
|
-
},
|
|
58
|
+
}, lt = {
|
|
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 = R.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
|
+
}, Rt = (o) => {
|
|
71
|
+
const t = R.join(v.executionPath, o);
|
|
72
72
|
console.info(`reading config file from: ${t}`);
|
|
73
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
|
+
}, Ve = (o, t) => {
|
|
76
|
+
const e = R.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);
|
|
@@ -82,54 +82,54 @@ Examples:
|
|
|
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
|
+
}, ct = {
|
|
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), Ve(v.options.configPath, v.myopConfig);
|
|
91
91
|
},
|
|
92
92
|
action: async () => {
|
|
93
93
|
}
|
|
94
|
-
},
|
|
94
|
+
}, dt = {
|
|
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), Ve(v.options.configPath, v.myopConfig);
|
|
100
100
|
},
|
|
101
101
|
action: () => {
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, Nt = {
|
|
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
|
+
}, _t = {
|
|
111
111
|
name: "π’ Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
114
|
-
},
|
|
114
|
+
}, Tt = {
|
|
115
115
|
name: "π΅ Create new experience",
|
|
116
116
|
value: "-",
|
|
117
117
|
disabled: "(not available yet)"
|
|
118
|
-
},
|
|
118
|
+
}, Ft = {
|
|
119
119
|
name: "π‘ Create new skin",
|
|
120
120
|
value: "-",
|
|
121
121
|
disabled: "(not available yet)"
|
|
122
|
-
},
|
|
122
|
+
}, jt = {
|
|
123
123
|
name: "π΄ Create new flow",
|
|
124
124
|
value: "-",
|
|
125
125
|
disabled: "(not available yet)"
|
|
126
|
-
},
|
|
126
|
+
}, At = {
|
|
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
|
+
}, Dt = [At, _t, Tt, Ft, jt];
|
|
132
|
+
function Lt(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 Ut(o) {
|
|
223
223
|
return o.includes("esbuild") && o.includes("another platform");
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Ht(o) {
|
|
226
226
|
return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Bt() {
|
|
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 Jt(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 Ut(o) {
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
console.log(" β Removed node_modules"), console.log(` β³ Running npm install...
|
|
247
|
-
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i,
|
|
247
|
+
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (i, r, p) => {
|
|
248
248
|
if (i) {
|
|
249
|
-
console.error("β npm install failed:", i.message),
|
|
249
|
+
console.error("β npm install failed:", i.message), p && console.error(p), t(!1);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
console.log(` β Dependencies reinstalled successfully!
|
|
@@ -255,101 +255,101 @@ function Ut(o) {
|
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
async function
|
|
258
|
+
async function pt(o, t, e, n, s = {}) {
|
|
259
259
|
const {
|
|
260
260
|
hasTriedPlatformFix: i = !1,
|
|
261
|
-
hasTriedInstall:
|
|
262
|
-
onRetry:
|
|
263
|
-
} = s,
|
|
264
|
-
return !i &&
|
|
265
|
-
`),
|
|
266
|
-
n("npm install", (
|
|
267
|
-
if (
|
|
268
|
-
console.error("β Failed to install dependencies:",
|
|
261
|
+
hasTriedInstall: r = !1,
|
|
262
|
+
onRetry: p
|
|
263
|
+
} = s, m = ((o == null ? void 0 : o.message) || "") + (t || "") + (e || "");
|
|
264
|
+
return !i && Ut(m) ? (Bt(), await Jt(n) && p ? (console.log(`π Retrying build...
|
|
265
|
+
`), p(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: r }) : !r && Ht(m) ? (console.log("π¦ Missing dependencies detected, running npm install..."), new Promise((l) => {
|
|
266
|
+
n("npm install", (d, w, x) => {
|
|
267
|
+
if (d) {
|
|
268
|
+
console.error("β Failed to install dependencies:", d.message), x && console.error(x), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
console.log("β
Dependencies installed"),
|
|
271
|
+
console.log("β
Dependencies installed"), p && p(), l({ handled: !0, hasTriedPlatformFix: i, hasTriedInstall: !0 });
|
|
272
272
|
});
|
|
273
|
-
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall:
|
|
273
|
+
})) : { handled: !1, hasTriedPlatformFix: i, hasTriedInstall: r };
|
|
274
274
|
}
|
|
275
|
-
async function
|
|
275
|
+
async function Ce() {
|
|
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://")) {
|
|
279
|
-
const
|
|
280
|
-
i = t.default.dirname(
|
|
279
|
+
const a = new URL(import.meta.url).pathname, f = process.platform === "win32" && a.startsWith("/") ? a.slice(1) : a;
|
|
280
|
+
i = t.default.dirname(f);
|
|
281
281
|
} else
|
|
282
282
|
i = t.default.dirname(import.meta.url);
|
|
283
|
-
const
|
|
284
|
-
let
|
|
283
|
+
const r = t.default.join(i, "commands", "dev", "management-website"), p = o.default.readFileSync(t.default.join(r, "styles.css"), "utf-8"), m = o.default.readFileSync(t.default.join(r, "app.js"), "utf-8"), l = 9292, d = 9293;
|
|
284
|
+
let w = "./dist", x = !1, $ = !1, g = !1, u = null;
|
|
285
285
|
const E = () => {
|
|
286
286
|
try {
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
return
|
|
287
|
+
const c = o.default.readdirSync(".").filter((a) => !a.endsWith(".html") || a.startsWith(".") ? !1 : o.default.statSync(a).isFile());
|
|
288
|
+
if (c.length === 1)
|
|
289
|
+
return c[0];
|
|
290
290
|
} catch {
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
|
-
},
|
|
293
|
+
}, O = () => {
|
|
294
294
|
try {
|
|
295
|
-
const
|
|
296
|
-
return !!(
|
|
295
|
+
const c = JSON.parse(o.default.readFileSync("package.json", "utf-8"));
|
|
296
|
+
return !!(c.scripts && c.scripts.build);
|
|
297
297
|
} catch {
|
|
298
298
|
return !1;
|
|
299
299
|
}
|
|
300
|
-
},
|
|
301
|
-
const
|
|
302
|
-
let
|
|
303
|
-
|
|
300
|
+
}, b = (c) => {
|
|
301
|
+
const a = process.platform;
|
|
302
|
+
let f;
|
|
303
|
+
a === "darwin" ? f = `open "${c}"` : a === "win32" ? f = `start "" "${c}"` : f = `xdg-open "${c}"`, e(f, (h) => {
|
|
304
304
|
});
|
|
305
|
-
},
|
|
306
|
-
let
|
|
307
|
-
|
|
308
|
-
const L =
|
|
305
|
+
}, M = /* @__PURE__ */ new Map(), j = v.program.getOptionValue("config") || "./myop.config.json";
|
|
306
|
+
let C, N, k = !1;
|
|
307
|
+
u = E();
|
|
308
|
+
const L = O();
|
|
309
309
|
try {
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
} catch (
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
317
|
-
return
|
|
310
|
+
const c = o.default.readFileSync(j, "utf-8"), a = JSON.parse(c);
|
|
311
|
+
C = a.componentId || "DEV", N = a.componentName || a.name || null, k = a.HMR === !0, u && !L && (g = !0, k = !0, console.log(`π Single HTML file mode: ${u}`)), k && console.log("π₯ HMR enabled");
|
|
312
|
+
} catch (c) {
|
|
313
|
+
u && !L ? (g = !0, C = "DEV", N = t.default.basename(u, ".html"), k = !0, console.log(`π Single HTML file mode: ${u}`), console.log("π₯ HMR enabled")) : (console.error("β Error reading myop.config.json:", c.message), process.exit(1));
|
|
314
|
+
}
|
|
315
|
+
const D = async () => {
|
|
316
|
+
if (C !== "DEV" && C !== "NEW")
|
|
317
|
+
return C;
|
|
318
318
|
try {
|
|
319
|
-
const
|
|
320
|
-
const
|
|
319
|
+
const a = ((await new Promise((y, S) => {
|
|
320
|
+
const I = {
|
|
321
321
|
hostname: "localhost",
|
|
322
|
-
port:
|
|
322
|
+
port: d,
|
|
323
323
|
path: "/_list",
|
|
324
324
|
method: "GET",
|
|
325
325
|
timeout: 1e3
|
|
326
|
-
},
|
|
327
|
-
let
|
|
328
|
-
H.on("data", (ee) =>
|
|
326
|
+
}, T = n.default.request(I, (H) => {
|
|
327
|
+
let Y = "";
|
|
328
|
+
H.on("data", (ee) => Y += ee), H.on("end", () => {
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
y(JSON.parse(Y));
|
|
331
331
|
} catch {
|
|
332
|
-
|
|
332
|
+
y({ components: [] });
|
|
333
333
|
}
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}),
|
|
339
|
-
})).components || []).map(([
|
|
340
|
-
if (
|
|
336
|
+
T.on("error", () => y({ components: [] })), T.on("timeout", () => {
|
|
337
|
+
T.destroy(), y({ components: [] });
|
|
338
|
+
}), T.end();
|
|
339
|
+
})).components || []).map(([y]) => y).filter((y) => y === "DEV" || y === "NEW" || /^DEV\d+$/.test(y) || /^NEW\d+$/.test(y));
|
|
340
|
+
if (a.length === 0)
|
|
341
341
|
return "DEV1";
|
|
342
|
-
const
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
return
|
|
346
|
-
}).filter((
|
|
347
|
-
return `DEV${Math.max(...
|
|
342
|
+
const f = a.map((y) => {
|
|
343
|
+
if (y === "DEV" || y === "NEW") return 1;
|
|
344
|
+
const S = y.match(/^DEV(\d+)$/), I = y.match(/^NEW(\d+)$/);
|
|
345
|
+
return S ? parseInt(S[1], 10) : I ? parseInt(I[1], 10) : 0;
|
|
346
|
+
}).filter((y) => y > 0);
|
|
347
|
+
return `DEV${Math.max(...f, 0) + 1}`;
|
|
348
348
|
} catch {
|
|
349
349
|
return "DEV1";
|
|
350
350
|
}
|
|
351
|
-
},
|
|
352
|
-
const
|
|
351
|
+
}, F = process.cwd(), W = (c) => {
|
|
352
|
+
const a = t.default.extname(c).toLowerCase();
|
|
353
353
|
return {
|
|
354
354
|
".html": "text/html",
|
|
355
355
|
".js": "text/javascript",
|
|
@@ -360,42 +360,42 @@ async function be() {
|
|
|
360
360
|
".gif": "image/gif",
|
|
361
361
|
".svg": "image/svg+xml",
|
|
362
362
|
".ico": "image/x-icon"
|
|
363
|
-
}[
|
|
364
|
-
},
|
|
365
|
-
if (
|
|
366
|
-
const
|
|
367
|
-
|
|
363
|
+
}[a] || "application/octet-stream";
|
|
364
|
+
}, _ = /* @__PURE__ */ new Map(), oe = [], Ie = 50, q = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), wt = (c, a, f) => {
|
|
365
|
+
if (c.url.startsWith("/_hmr/")) {
|
|
366
|
+
const h = c.url.split("/_hmr/")[1], y = c.headers["sec-websocket-key"], S = s("sha1").update(y + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
367
|
+
a.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: ${S}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
|
-
),
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
}),
|
|
378
|
-
const
|
|
379
|
-
|
|
374
|
+
), X.has(h) || X.set(h, /* @__PURE__ */ new Set()), X.get(h).add(a), console.log(`π HMR client connected: ${h}`), a.on("close", () => {
|
|
375
|
+
const I = X.get(h);
|
|
376
|
+
I && (I.delete(a), I.size === 0 && X.delete(h)), console.log(`π HMR client disconnected: ${h}`);
|
|
377
|
+
}), a.on("error", () => {
|
|
378
|
+
const I = X.get(h);
|
|
379
|
+
I && I.delete(a);
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
|
-
},
|
|
383
|
-
if (
|
|
384
|
-
let
|
|
385
|
-
|
|
382
|
+
}, Oe = n.default.createServer((c, a) => {
|
|
383
|
+
if (a.setHeader("Content-Type", "application/json"), c.method === "POST" && c.url === "/_register") {
|
|
384
|
+
let f = "";
|
|
385
|
+
c.on("data", (h) => f += h), c.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId:
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
console.log(`β
Registered: ${
|
|
391
|
-
const H = Array.from(
|
|
392
|
-
id:
|
|
387
|
+
const { componentId: h, distPath: y, componentName: S, htmlFile: I } = JSON.parse(f);
|
|
388
|
+
_.set(h, { path: y, name: S || null, htmlFile: I || null });
|
|
389
|
+
const T = S ? ` (${S})` : "";
|
|
390
|
+
console.log(`β
Registered: ${h}${T} -> ${y}${I ? "/" + I : ""}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(_.keys()) }));
|
|
391
|
+
const H = Array.from(_.entries()).map(([Y, ee]) => ({
|
|
392
|
+
id: Y,
|
|
393
393
|
path: ee.path,
|
|
394
394
|
name: ee.name
|
|
395
395
|
}));
|
|
396
|
-
|
|
396
|
+
q.forEach((Y) => {
|
|
397
397
|
try {
|
|
398
|
-
|
|
398
|
+
Y.write(`data: ${JSON.stringify({
|
|
399
399
|
type: "components",
|
|
400
400
|
components: H
|
|
401
401
|
})}
|
|
@@ -404,100 +404,100 @@ Sec-WebSocket-Accept: ${b}\r
|
|
|
404
404
|
} catch {
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
|
-
} catch (
|
|
408
|
-
|
|
407
|
+
} catch (h) {
|
|
408
|
+
a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
|
|
409
409
|
}
|
|
410
410
|
});
|
|
411
|
-
} else if (
|
|
412
|
-
let
|
|
413
|
-
|
|
411
|
+
} else if (c.method === "POST" && c.url === "/_unregister") {
|
|
412
|
+
let f = "";
|
|
413
|
+
c.on("data", (h) => f += h), c.on("end", () => {
|
|
414
414
|
try {
|
|
415
|
-
const { componentId:
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
id:
|
|
419
|
-
path:
|
|
420
|
-
name:
|
|
415
|
+
const { componentId: h } = JSON.parse(f);
|
|
416
|
+
_.delete(h), console.log(`β Unregistered: ${h}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
|
|
417
|
+
const y = Array.from(_.entries()).map(([S, I]) => ({
|
|
418
|
+
id: S,
|
|
419
|
+
path: I.path,
|
|
420
|
+
name: I.name
|
|
421
421
|
}));
|
|
422
|
-
|
|
422
|
+
q.forEach((S) => {
|
|
423
423
|
try {
|
|
424
|
-
|
|
424
|
+
S.write(`data: ${JSON.stringify({
|
|
425
425
|
type: "components",
|
|
426
|
-
components:
|
|
426
|
+
components: y
|
|
427
427
|
})}
|
|
428
428
|
|
|
429
429
|
`);
|
|
430
430
|
} catch {
|
|
431
431
|
}
|
|
432
432
|
});
|
|
433
|
-
} catch (
|
|
434
|
-
|
|
433
|
+
} catch (h) {
|
|
434
|
+
a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
|
-
} else if (
|
|
438
|
-
|
|
439
|
-
else if (
|
|
440
|
-
let
|
|
441
|
-
|
|
437
|
+
} else if (c.method === "GET" && c.url === "/_list")
|
|
438
|
+
a.writeHead(200), a.end(JSON.stringify({ components: Array.from(_.entries()) }));
|
|
439
|
+
else if (c.method === "POST" && c.url === "/_hmr_notify") {
|
|
440
|
+
let f = "";
|
|
441
|
+
c.on("data", (h) => f += h), c.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId:
|
|
444
|
-
if (
|
|
445
|
-
console.log(`π₯ Notifying ${
|
|
446
|
-
const
|
|
447
|
-
|
|
443
|
+
const { componentId: h, html: y } = JSON.parse(f), S = X.get(h);
|
|
444
|
+
if (S && S.size > 0) {
|
|
445
|
+
console.log(`π₯ Notifying ${S.size} HMR client(s) for: ${h}`);
|
|
446
|
+
const I = JSON.stringify({ type: "update", html: y }), T = qe(I);
|
|
447
|
+
S.forEach((H) => {
|
|
448
448
|
try {
|
|
449
|
-
H.write(
|
|
449
|
+
H.write(T);
|
|
450
450
|
} catch {
|
|
451
|
-
|
|
451
|
+
S.delete(H);
|
|
452
452
|
}
|
|
453
|
-
}),
|
|
453
|
+
}), a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: S.size }));
|
|
454
454
|
} else
|
|
455
|
-
|
|
456
|
-
} catch (
|
|
457
|
-
|
|
455
|
+
a.writeHead(200), a.end(JSON.stringify({ success: !0, notified: 0 }));
|
|
456
|
+
} catch (h) {
|
|
457
|
+
a.writeHead(400), a.end(JSON.stringify({ error: h.message }));
|
|
458
458
|
}
|
|
459
459
|
});
|
|
460
460
|
} else
|
|
461
|
-
|
|
462
|
-
}), ge = n.default.createServer((
|
|
463
|
-
if (
|
|
464
|
-
|
|
461
|
+
a.writeHead(404), a.end(JSON.stringify({ error: "Not found" }));
|
|
462
|
+
}), ge = n.default.createServer((c, a) => {
|
|
463
|
+
if (c.url.includes("..")) {
|
|
464
|
+
a.writeHead(403, { "Content-Type": "text/plain" }), a.end("Forbidden");
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
469
|
-
const J =
|
|
467
|
+
const f = new URL(c.url, `http://localhost:${l}`), h = f.pathname, y = h.split("/").filter((J) => J);
|
|
468
|
+
if (h.startsWith("/consume")) {
|
|
469
|
+
const J = f.searchParams.get("id");
|
|
470
470
|
if (!J) {
|
|
471
|
-
|
|
471
|
+
a.writeHead(400, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
const
|
|
474
|
+
const V = _.get(J), G = V ? V.path : null, de = (te) => {
|
|
475
475
|
let U = "Unknown", K = "Unknown";
|
|
476
|
-
if (
|
|
477
|
-
const B =
|
|
476
|
+
if (c.headers.referer || c.headers.referrer) {
|
|
477
|
+
const B = c.headers.referer || c.headers.referrer;
|
|
478
478
|
try {
|
|
479
479
|
const ie = new URL(B);
|
|
480
480
|
U = ie.origin, K = ie.hostname || ie.origin;
|
|
481
481
|
} catch {
|
|
482
482
|
U = B, K = B;
|
|
483
483
|
}
|
|
484
|
-
} else if (
|
|
484
|
+
} else if (c.headers.origin)
|
|
485
485
|
try {
|
|
486
|
-
const B = new URL(
|
|
486
|
+
const B = new URL(c.headers.origin);
|
|
487
487
|
U = B.origin, K = B.hostname || B.origin;
|
|
488
488
|
} catch {
|
|
489
|
-
U =
|
|
489
|
+
U = c.headers.origin, K = c.headers.origin;
|
|
490
490
|
}
|
|
491
|
-
else if (
|
|
492
|
-
const B =
|
|
491
|
+
else if (c.socket.remoteAddress) {
|
|
492
|
+
const B = c.socket.remoteAddress;
|
|
493
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 Fe = c.headers.referer || c.headers.referrer || U, we = {
|
|
496
496
|
type: "request",
|
|
497
497
|
componentId: J,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
499
|
servedLocally: te,
|
|
500
|
-
referrer:
|
|
500
|
+
referrer: Fe,
|
|
501
501
|
origin: U,
|
|
502
502
|
originLabel: K
|
|
503
503
|
};
|
|
@@ -506,7 +506,7 @@ Sec-WebSocket-Accept: ${b}\r
|
|
|
506
506
|
label: K,
|
|
507
507
|
firstSeen: Date.now(),
|
|
508
508
|
requestCount: 0
|
|
509
|
-
}),
|
|
509
|
+
}), q.forEach((B) => {
|
|
510
510
|
try {
|
|
511
511
|
B.write(`data: ${JSON.stringify({
|
|
512
512
|
type: "origins",
|
|
@@ -517,8 +517,8 @@ Sec-WebSocket-Accept: ${b}\r
|
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
const
|
|
521
|
-
|
|
520
|
+
const je = se.get(U);
|
|
521
|
+
je.requestCount++, q.forEach((B) => {
|
|
522
522
|
try {
|
|
523
523
|
B.write(`data: ${JSON.stringify({
|
|
524
524
|
type: "origins",
|
|
@@ -528,168 +528,168 @@ Sec-WebSocket-Accept: ${b}\r
|
|
|
528
528
|
`);
|
|
529
529
|
} catch {
|
|
530
530
|
}
|
|
531
|
-
}), oe.push(
|
|
531
|
+
}), oe.push(we), oe.length > Ie && oe.shift(), q.forEach((B) => {
|
|
532
532
|
try {
|
|
533
|
-
B.write(`data: ${JSON.stringify(
|
|
533
|
+
B.write(`data: ${JSON.stringify(we)}
|
|
534
534
|
|
|
535
535
|
`);
|
|
536
536
|
} catch {
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
};
|
|
540
|
-
if (
|
|
541
|
-
const te =
|
|
540
|
+
if (G) {
|
|
541
|
+
const te = V.htmlFile ? t.default.join(G, V.htmlFile) : t.default.join(G, "index.html");
|
|
542
542
|
o.default.readFile(te, "utf-8", (U, K) => {
|
|
543
543
|
if (U) {
|
|
544
|
-
console.log(`β File not found: ${te}`),
|
|
544
|
+
console.log(`β File not found: ${te}`), a.writeHead(404, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "index.html not found" }));
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
const
|
|
547
|
+
const Fe = Re(K, J), we = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, je = {
|
|
548
548
|
item: {
|
|
549
549
|
name: J,
|
|
550
550
|
id: J,
|
|
551
551
|
consume_variant: [
|
|
552
552
|
{
|
|
553
|
-
id:
|
|
553
|
+
id: we,
|
|
554
554
|
name: "dev version",
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
557
557
|
shadowRootMode: "localFrame",
|
|
558
|
-
HTML:
|
|
558
|
+
HTML: Fe
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
]
|
|
562
562
|
}
|
|
563
563
|
};
|
|
564
|
-
console.log(`β
Serving consume JSON for: ${J}`), de(!0),
|
|
564
|
+
console.log(`β
Serving consume JSON for: ${J}`), de(!0), a.writeHead(200, {
|
|
565
565
|
"Content-Type": "application/json",
|
|
566
566
|
"Access-Control-Allow-Origin": "*"
|
|
567
|
-
}),
|
|
567
|
+
}), a.end(JSON.stringify(je, null, 2));
|
|
568
568
|
});
|
|
569
569
|
} else {
|
|
570
570
|
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${J}`);
|
|
571
|
-
const te = `https://cloud.myop.dev/consume${
|
|
571
|
+
const te = `https://cloud.myop.dev/consume${f.search}`;
|
|
572
572
|
de(!1), fetch(te).then((U) => U.text()).then((U) => {
|
|
573
|
-
|
|
573
|
+
a.writeHead(200, {
|
|
574
574
|
"Content-Type": "application/json",
|
|
575
575
|
"Access-Control-Allow-Origin": "*"
|
|
576
|
-
}),
|
|
576
|
+
}), a.end(U);
|
|
577
577
|
}).catch((U) => {
|
|
578
|
-
console.error(`β Proxy error: ${U.message}`),
|
|
578
|
+
console.error(`β Proxy error: ${U.message}`), a.writeHead(502, { "Content-Type": "application/json" }), a.end(JSON.stringify({ error: "Failed to fetch from cloud.myop.dev" }));
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
|
-
if (
|
|
584
|
-
|
|
583
|
+
if (h === "/events") {
|
|
584
|
+
a.writeHead(200, {
|
|
585
585
|
"Content-Type": "text/event-stream",
|
|
586
586
|
"Cache-Control": "no-cache",
|
|
587
587
|
Connection: "keep-alive",
|
|
588
588
|
"Access-Control-Allow-Origin": "*"
|
|
589
|
-
}),
|
|
590
|
-
const J = Array.from(
|
|
591
|
-
id:
|
|
592
|
-
path:
|
|
593
|
-
name:
|
|
589
|
+
}), q.push(a);
|
|
590
|
+
const J = Array.from(_.entries()).map(([V, G]) => ({
|
|
591
|
+
id: V,
|
|
592
|
+
path: G.path,
|
|
593
|
+
name: G.name
|
|
594
594
|
}));
|
|
595
|
-
|
|
595
|
+
a.write(`data: ${JSON.stringify({
|
|
596
596
|
type: "components",
|
|
597
597
|
components: J
|
|
598
598
|
})}
|
|
599
599
|
|
|
600
|
-
`),
|
|
600
|
+
`), a.write(`data: ${JSON.stringify({
|
|
601
601
|
type: "origins",
|
|
602
602
|
origins: Array.from(se.values())
|
|
603
603
|
})}
|
|
604
604
|
|
|
605
|
-
`),
|
|
605
|
+
`), a.write(`data: ${JSON.stringify({
|
|
606
606
|
type: "requestLog",
|
|
607
607
|
log: oe
|
|
608
608
|
})}
|
|
609
609
|
|
|
610
|
-
`),
|
|
611
|
-
const
|
|
612
|
-
|
|
610
|
+
`), c.on("close", () => {
|
|
611
|
+
const V = q.indexOf(a);
|
|
612
|
+
V !== -1 && q.splice(V, 1);
|
|
613
613
|
});
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
|
-
if (
|
|
617
|
-
|
|
616
|
+
if (y.length === 0) {
|
|
617
|
+
a.writeHead(200, { "Content-Type": "text/html" }), a.end(Lt(l, d, p, m));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
|
-
if (
|
|
621
|
-
|
|
620
|
+
if (y[0] !== "view") {
|
|
621
|
+
a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not found. Use /view/<componentId>/ to access components.");
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
|
-
if (
|
|
625
|
-
|
|
624
|
+
if (y.length < 2) {
|
|
625
|
+
a.writeHead(400, { "Content-Type": "text/plain" }), a.end("Component ID required. Use /view/<componentId>/");
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
const
|
|
629
|
-
if (!
|
|
630
|
-
|
|
628
|
+
const S = y[1], I = _.get(S);
|
|
629
|
+
if (!I) {
|
|
630
|
+
a.writeHead(404, { "Content-Type": "text/plain" }), a.end(`Component not found: ${S}`);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const
|
|
634
|
-
console.log(`π₯ Request: ${
|
|
633
|
+
const T = I.path, H = y.slice(2), Y = I.htmlFile || "index.html", ee = H.length === 0 ? Y : H.join("/"), ce = t.default.join(T, ee);
|
|
634
|
+
console.log(`π₯ Request: ${c.url} -> ${ce}`), o.default.readFile(ce, (J, V) => {
|
|
635
635
|
if (J) {
|
|
636
|
-
console.log(`β File not found: ${ce}`),
|
|
636
|
+
console.log(`β File not found: ${ce}`), a.writeHead(404, { "Content-Type": "text/plain" }), a.end("Not Found");
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
639
|
-
const
|
|
640
|
-
console.log(`β
Serving: ${ce} (${
|
|
641
|
-
let de =
|
|
642
|
-
if (
|
|
643
|
-
const te =
|
|
644
|
-
de =
|
|
639
|
+
const G = W(ce);
|
|
640
|
+
console.log(`β
Serving: ${ce} (${G})`);
|
|
641
|
+
let de = V;
|
|
642
|
+
if (G === "text/html" && k) {
|
|
643
|
+
const te = V.toString("utf-8");
|
|
644
|
+
de = Re(te, S);
|
|
645
645
|
}
|
|
646
|
-
|
|
647
|
-
"Content-Type":
|
|
646
|
+
a.writeHead(200, {
|
|
647
|
+
"Content-Type": G,
|
|
648
648
|
"Access-Control-Allow-Origin": "*"
|
|
649
|
-
}),
|
|
649
|
+
}), a.end(de);
|
|
650
650
|
});
|
|
651
|
-
}),
|
|
652
|
-
const
|
|
653
|
-
componentId:
|
|
654
|
-
distPath:
|
|
655
|
-
componentName:
|
|
656
|
-
htmlFile:
|
|
657
|
-
}),
|
|
651
|
+
}), ke = () => new Promise((c, a) => {
|
|
652
|
+
const f = g ? t.default.resolve(F) : t.default.resolve(F, w), h = JSON.stringify({
|
|
653
|
+
componentId: C,
|
|
654
|
+
distPath: f,
|
|
655
|
+
componentName: N,
|
|
656
|
+
htmlFile: g ? u : null
|
|
657
|
+
}), y = {
|
|
658
658
|
hostname: "localhost",
|
|
659
|
-
port:
|
|
659
|
+
port: d,
|
|
660
660
|
path: "/_register",
|
|
661
661
|
method: "POST",
|
|
662
662
|
headers: {
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
|
-
"Content-Length": Buffer.byteLength(
|
|
664
|
+
"Content-Length": Buffer.byteLength(h)
|
|
665
665
|
}
|
|
666
|
-
},
|
|
667
|
-
let
|
|
668
|
-
|
|
669
|
-
|
|
666
|
+
}, S = n.default.request(y, (I) => {
|
|
667
|
+
let T = "";
|
|
668
|
+
I.on("data", (H) => T += H), I.on("end", () => {
|
|
669
|
+
I.statusCode === 200 ? c(JSON.parse(T)) : a(new Error(`Registration failed: ${I.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
|
-
|
|
673
|
-
}),
|
|
674
|
-
const
|
|
672
|
+
S.on("error", a), S.write(h), S.end();
|
|
673
|
+
}), vt = () => new Promise((c, a) => {
|
|
674
|
+
const f = JSON.stringify({ componentId: C }), h = {
|
|
675
675
|
hostname: "localhost",
|
|
676
|
-
port:
|
|
676
|
+
port: d,
|
|
677
677
|
path: "/_unregister",
|
|
678
678
|
method: "POST",
|
|
679
679
|
headers: {
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
|
-
"Content-Length": Buffer.byteLength(
|
|
681
|
+
"Content-Length": Buffer.byteLength(f)
|
|
682
682
|
}
|
|
683
|
-
},
|
|
684
|
-
|
|
683
|
+
}, y = n.default.request(h, (S) => {
|
|
684
|
+
c();
|
|
685
685
|
});
|
|
686
|
-
|
|
687
|
-
}),
|
|
686
|
+
y.on("error", () => c()), y.write(f), y.end();
|
|
687
|
+
}), St = (c) => `
|
|
688
688
|
<!-- MYOP HMR -->
|
|
689
689
|
<script>
|
|
690
690
|
(function() {
|
|
691
|
-
const componentId = '${
|
|
692
|
-
const wsUrl = 'ws://localhost:${
|
|
691
|
+
const componentId = '${c}';
|
|
692
|
+
const wsUrl = 'ws://localhost:${d}/_hmr/' + componentId;
|
|
693
693
|
let ws;
|
|
694
694
|
let reconnectAttempts = 0;
|
|
695
695
|
const maxReconnectAttempts = 10;
|
|
@@ -789,251 +789,261 @@ Sec-WebSocket-Accept: ${b}\r
|
|
|
789
789
|
connect();
|
|
790
790
|
})();
|
|
791
791
|
<\/script>
|
|
792
|
-
`,
|
|
793
|
-
if (!k) return
|
|
794
|
-
const
|
|
795
|
-
return
|
|
796
|
-
},
|
|
797
|
-
const
|
|
798
|
-
let
|
|
799
|
-
return
|
|
800
|
-
Buffer.from([129,
|
|
792
|
+
`, Re = (c, a) => {
|
|
793
|
+
if (!k) return c;
|
|
794
|
+
const f = St(a);
|
|
795
|
+
return c.includes("</body>") ? c.replace("</body>", `${f}</body>`) : c.includes("</html>") ? c.replace("</html>", `${f}</html>`) : c + f;
|
|
796
|
+
}, qe = (c) => {
|
|
797
|
+
const a = Buffer.from(c), f = a.length;
|
|
798
|
+
let h;
|
|
799
|
+
return f < 126 ? h = Buffer.concat([
|
|
800
|
+
Buffer.from([129, f]),
|
|
801
801
|
// FIN + text frame, length
|
|
802
|
-
|
|
803
|
-
]) :
|
|
802
|
+
a
|
|
803
|
+
]) : f < 65536 ? h = Buffer.concat([
|
|
804
804
|
Buffer.from([129, 126]),
|
|
805
805
|
// FIN + text frame, extended length
|
|
806
|
-
Buffer.from([
|
|
806
|
+
Buffer.from([f >> 8, f & 255]),
|
|
807
807
|
// 16-bit length
|
|
808
|
-
|
|
809
|
-
]) :
|
|
808
|
+
a
|
|
809
|
+
]) : h = Buffer.concat([
|
|
810
810
|
Buffer.from([129, 127]),
|
|
811
811
|
// FIN + text frame, extended length
|
|
812
|
-
Buffer.from([0, 0, 0, 0,
|
|
812
|
+
Buffer.from([0, 0, 0, 0, f >> 24, f >> 16 & 255, f >> 8 & 255, f & 255]),
|
|
813
813
|
// 64-bit length
|
|
814
|
-
|
|
815
|
-
]),
|
|
816
|
-
},
|
|
814
|
+
a
|
|
815
|
+
]), h;
|
|
816
|
+
}, Xe = () => {
|
|
817
817
|
if (!k) return;
|
|
818
|
-
const
|
|
819
|
-
let
|
|
818
|
+
const c = g ? u : t.default.join(w, "index.html");
|
|
819
|
+
let a;
|
|
820
820
|
try {
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
} catch (
|
|
824
|
-
console.error("β Failed to read HTML for HMR:",
|
|
821
|
+
const f = o.default.readFileSync(c, "utf-8");
|
|
822
|
+
a = Re(f, C);
|
|
823
|
+
} catch (f) {
|
|
824
|
+
console.error("β Failed to read HTML for HMR:", f.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (
|
|
828
|
-
const
|
|
829
|
-
if (!
|
|
827
|
+
if (Te) {
|
|
828
|
+
const f = X.get(C);
|
|
829
|
+
if (!f || f.size === 0)
|
|
830
830
|
return;
|
|
831
|
-
console.log(`π₯ Notifying ${
|
|
832
|
-
const
|
|
831
|
+
console.log(`π₯ Notifying ${f.size} HMR client(s)`);
|
|
832
|
+
const h = JSON.stringify({
|
|
833
833
|
type: "update",
|
|
834
|
-
html:
|
|
835
|
-
}),
|
|
836
|
-
|
|
834
|
+
html: a
|
|
835
|
+
}), y = qe(h);
|
|
836
|
+
f.forEach((S) => {
|
|
837
837
|
try {
|
|
838
|
-
|
|
838
|
+
S.write(y);
|
|
839
839
|
} catch {
|
|
840
|
-
|
|
840
|
+
f.delete(S);
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
} else {
|
|
844
|
-
const
|
|
845
|
-
componentId:
|
|
846
|
-
html:
|
|
847
|
-
}),
|
|
844
|
+
const f = JSON.stringify({
|
|
845
|
+
componentId: C,
|
|
846
|
+
html: a
|
|
847
|
+
}), h = {
|
|
848
848
|
hostname: "localhost",
|
|
849
|
-
port:
|
|
849
|
+
port: d,
|
|
850
850
|
path: "/_hmr_notify",
|
|
851
851
|
method: "POST",
|
|
852
852
|
headers: {
|
|
853
853
|
"Content-Type": "application/json",
|
|
854
|
-
"Content-Length": Buffer.byteLength(
|
|
854
|
+
"Content-Length": Buffer.byteLength(f)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
},
|
|
858
|
-
let
|
|
859
|
-
|
|
857
|
+
}, y = n.default.request(h, (S) => {
|
|
858
|
+
let I = "";
|
|
859
|
+
S.on("data", (T) => I += T), S.on("end", () => {
|
|
860
860
|
try {
|
|
861
|
-
const
|
|
862
|
-
|
|
861
|
+
const T = JSON.parse(I);
|
|
862
|
+
T.notified > 0 && console.log(`π₯ Notified ${T.notified} HMR client(s) via server`);
|
|
863
863
|
} catch {
|
|
864
864
|
}
|
|
865
865
|
});
|
|
866
866
|
});
|
|
867
|
-
|
|
868
|
-
}),
|
|
869
|
-
|
|
870
|
-
}),
|
|
867
|
+
y.on("error", () => {
|
|
868
|
+
}), y.on("timeout", () => {
|
|
869
|
+
y.destroy();
|
|
870
|
+
}), y.write(f), y.end();
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
|
-
let
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
876
|
-
|
|
873
|
+
let Ne = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
|
+
const he = (c) => {
|
|
875
|
+
if (x) {
|
|
876
|
+
$ = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
|
-
|
|
880
|
-
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
883
|
-
...
|
|
884
|
-
onRetry: () =>
|
|
879
|
+
x = !0, console.log(`
|
|
880
|
+
π¨ Building...`), e("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (a, f, h) => {
|
|
881
|
+
if (x = !1, a) {
|
|
882
|
+
const y = await pt(a, f, h, e, {
|
|
883
|
+
...Ne,
|
|
884
|
+
onRetry: () => he(c)
|
|
885
885
|
});
|
|
886
|
-
|
|
886
|
+
Ne = { ...Ne, ...y }, y.handled || (console.error("β Build failed:", a.message), h && console.error(h));
|
|
887
887
|
} else
|
|
888
|
-
console.log("β
Build completed"),
|
|
889
|
-
|
|
888
|
+
console.log("β
Build completed"), f && console.log(f), Xe(), c && c();
|
|
889
|
+
$ && ($ = !1, he());
|
|
890
890
|
});
|
|
891
|
-
},
|
|
892
|
-
o.default.readdir(
|
|
893
|
-
|
|
894
|
-
const
|
|
895
|
-
if (
|
|
896
|
-
|
|
897
|
-
else if (
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
891
|
+
}, et = /* @__PURE__ */ new Set(), _e = (c) => {
|
|
892
|
+
o.default.readdir(c, { withFileTypes: !0 }, (a, f) => {
|
|
893
|
+
a || (f.forEach((h) => {
|
|
894
|
+
const y = t.default.join(c, h.name);
|
|
895
|
+
if (h.isDirectory())
|
|
896
|
+
h.name !== "node_modules" && h.name !== "dist" && !h.name.startsWith(".") && _e(y);
|
|
897
|
+
else if (h.isFile()) {
|
|
898
|
+
const S = t.default.extname(h.name);
|
|
899
|
+
if (S === ".js" || S === ".css" || S === ".html")
|
|
900
900
|
try {
|
|
901
|
-
const
|
|
902
|
-
|
|
901
|
+
const I = o.default.readFileSync(y, "utf-8");
|
|
902
|
+
M.set(y, I);
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
}),
|
|
907
|
-
if (!
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
const
|
|
906
|
+
}), et.has(c) || (et.add(c), o.default.watch(c, (h, y) => {
|
|
907
|
+
if (!y) return;
|
|
908
|
+
const S = t.default.extname(y);
|
|
909
|
+
if (S !== ".js" && S !== ".css" && S !== ".html") return;
|
|
910
|
+
const I = t.default.join(c, y);
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
913
|
-
const
|
|
914
|
-
|
|
913
|
+
const T = o.default.readFileSync(I, "utf-8"), H = M.get(I);
|
|
914
|
+
T !== H && (M.set(I, T), console.log(`π File changed: ${I}`), g ? Xe() : he());
|
|
915
915
|
} catch {
|
|
916
916
|
}
|
|
917
917
|
}, 50);
|
|
918
918
|
})));
|
|
919
919
|
});
|
|
920
|
-
},
|
|
920
|
+
}, tt = (c) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
π¨ Component: ${
|
|
923
|
-
`),
|
|
922
|
+
π¨ Component: ${C}`), g ? (console.log("π No build needed (single HTML file mode)"), _e(F), console.log(`π Watching ${u} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
|
+
`), c && c()) : (he(c), _e(F), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
|
-
},
|
|
926
|
-
const
|
|
925
|
+
}, xt = () => new Promise((c) => {
|
|
926
|
+
const a = {
|
|
927
927
|
hostname: "localhost",
|
|
928
|
-
port:
|
|
928
|
+
port: d,
|
|
929
929
|
path: "/_list",
|
|
930
930
|
method: "GET",
|
|
931
931
|
timeout: 1e3
|
|
932
|
-
},
|
|
933
|
-
|
|
932
|
+
}, f = n.default.request(a, (h) => {
|
|
933
|
+
let y = "";
|
|
934
|
+
h.on("data", (S) => y += S), h.on("end", () => {
|
|
935
|
+
try {
|
|
936
|
+
(JSON.parse(y).components || []).map((T) => T[0]).includes(C) || ke().then(() => {
|
|
937
|
+
console.log(`π Re-registered component: ${C}`);
|
|
938
|
+
}).catch(() => {
|
|
939
|
+
});
|
|
940
|
+
} catch {
|
|
941
|
+
}
|
|
942
|
+
c(!0);
|
|
943
|
+
});
|
|
934
944
|
});
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}),
|
|
938
|
-
}),
|
|
939
|
-
const
|
|
940
|
-
if (
|
|
941
|
-
let
|
|
942
|
-
|
|
945
|
+
f.on("error", () => c(!1)), f.on("timeout", () => {
|
|
946
|
+
f.destroy(), c(!1);
|
|
947
|
+
}), f.end();
|
|
948
|
+
}), $t = () => new Promise((c) => {
|
|
949
|
+
const a = n.default.createServer((f, h) => {
|
|
950
|
+
if (h.setHeader("Content-Type", "application/json"), f.method === "POST" && f.url === "/_register") {
|
|
951
|
+
let y = "";
|
|
952
|
+
f.on("data", (S) => y += S), f.on("end", () => {
|
|
943
953
|
try {
|
|
944
|
-
const { componentId:
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
console.log(`β
Registered: ${
|
|
948
|
-
} catch (
|
|
949
|
-
|
|
954
|
+
const { componentId: S, distPath: I, componentName: T, htmlFile: H } = JSON.parse(y);
|
|
955
|
+
_.set(S, { path: I, name: T || null, htmlFile: H || null });
|
|
956
|
+
const Y = T ? ` (${T})` : "";
|
|
957
|
+
console.log(`β
Registered: ${S}${Y} -> ${I}${H ? "/" + H : ""}`), h.writeHead(200), h.end(JSON.stringify({ success: !0, registered: Array.from(_.keys()) }));
|
|
958
|
+
} catch (S) {
|
|
959
|
+
h.writeHead(400), h.end(JSON.stringify({ error: S.message }));
|
|
950
960
|
}
|
|
951
961
|
});
|
|
952
|
-
} else if (
|
|
953
|
-
let
|
|
954
|
-
|
|
962
|
+
} else if (f.method === "POST" && f.url === "/_unregister") {
|
|
963
|
+
let y = "";
|
|
964
|
+
f.on("data", (S) => y += S), f.on("end", () => {
|
|
955
965
|
try {
|
|
956
|
-
const { componentId:
|
|
957
|
-
|
|
958
|
-
} catch (
|
|
959
|
-
|
|
966
|
+
const { componentId: S } = JSON.parse(y);
|
|
967
|
+
_.delete(S), console.log(`β Unregistered: ${S}`), h.writeHead(200), h.end(JSON.stringify({ success: !0 }));
|
|
968
|
+
} catch (S) {
|
|
969
|
+
h.writeHead(400), h.end(JSON.stringify({ error: S.message }));
|
|
960
970
|
}
|
|
961
971
|
});
|
|
962
|
-
} else
|
|
972
|
+
} else f.method === "GET" && f.url === "/_list" ? (h.writeHead(200), h.end(JSON.stringify({ components: Array.from(_.entries()) }))) : (h.writeHead(404), h.end(JSON.stringify({ error: "Not found" })));
|
|
963
973
|
});
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}),
|
|
974
|
+
a.on("error", () => {
|
|
975
|
+
c(!1);
|
|
976
|
+
}), a.listen(d, () => {
|
|
967
977
|
console.log(`
|
|
968
|
-
π Taking over as server...`), console.log(`π‘ Management server on port ${
|
|
969
|
-
|
|
978
|
+
π Taking over as server...`), console.log(`π‘ Management server on port ${d}`), ge.on("error", () => {
|
|
979
|
+
a.close(), c(!1);
|
|
970
980
|
}), ge.listen(l, () => {
|
|
971
981
|
console.log(`π‘ Main server running at http://localhost:${l}`);
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
path:
|
|
975
|
-
name:
|
|
976
|
-
htmlFile:
|
|
982
|
+
const f = g ? t.default.resolve(F) : t.default.resolve(F, w);
|
|
983
|
+
_.set(C, {
|
|
984
|
+
path: f,
|
|
985
|
+
name: N,
|
|
986
|
+
htmlFile: g ? u : null
|
|
977
987
|
});
|
|
978
|
-
const
|
|
979
|
-
console.log(`β
Registered component: ${
|
|
988
|
+
const h = N ? ` (${N})` : "";
|
|
989
|
+
console.log(`β
Registered component: ${C}${h}`), console.log(`π‘ Access at: http://localhost:${l}/view/${C}/`), c(!0);
|
|
980
990
|
});
|
|
981
991
|
});
|
|
982
992
|
});
|
|
983
|
-
let
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
await
|
|
987
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
993
|
+
let ye;
|
|
994
|
+
const ot = () => {
|
|
995
|
+
ye = setInterval(async () => {
|
|
996
|
+
await xt() || (clearInterval(ye), console.log(`
|
|
997
|
+
β οΈ Server appears to be down, attempting to take over...`), await $t() ? (console.log("β
Successfully took over as server"), Te = !0) : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
998
|
try {
|
|
989
|
-
await
|
|
990
|
-
} catch (
|
|
991
|
-
console.error("β Failed to re-register:",
|
|
999
|
+
await ke(), console.log(`β
Re-registered component: ${C}`), ot();
|
|
1000
|
+
} catch (f) {
|
|
1001
|
+
console.error("β Failed to re-register:", f.message);
|
|
992
1002
|
}
|
|
993
1003
|
}, 2e3)));
|
|
994
1004
|
}, 3e3);
|
|
995
|
-
},
|
|
1005
|
+
}, nt = async () => {
|
|
996
1006
|
console.log(`
|
|
997
1007
|
|
|
998
|
-
π Shutting down...`),
|
|
1008
|
+
π Shutting down...`), ye && clearInterval(ye), await vt(), process.exit(0);
|
|
999
1009
|
};
|
|
1000
|
-
process.on("SIGINT",
|
|
1001
|
-
let
|
|
1002
|
-
|
|
1003
|
-
if (
|
|
1010
|
+
process.on("SIGINT", nt), process.on("SIGTERM", nt);
|
|
1011
|
+
let Te = !1;
|
|
1012
|
+
Oe.on("error", async (c) => {
|
|
1013
|
+
if (c.code === "EADDRINUSE") {
|
|
1004
1014
|
console.log(`
|
|
1005
1015
|
π Connecting to existing dev server...`);
|
|
1006
1016
|
try {
|
|
1007
|
-
|
|
1008
|
-
const
|
|
1009
|
-
console.log(`β
Registered component: ${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1011
|
-
}),
|
|
1012
|
-
} catch (
|
|
1013
|
-
console.error("β Failed to register component:",
|
|
1017
|
+
C = await D();
|
|
1018
|
+
const a = await ke();
|
|
1019
|
+
console.log(`β
Registered component: ${C}`), console.log(`π‘ Access at: http://localhost:${l}/view/${C}/`), console.log(`π All registered components: ${a.registered.join(", ")}`), tt(() => {
|
|
1020
|
+
process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${C}/`);
|
|
1021
|
+
}), ot();
|
|
1022
|
+
} catch (a) {
|
|
1023
|
+
console.error("β Failed to register component:", a.message), process.exit(1);
|
|
1014
1024
|
}
|
|
1015
1025
|
} else
|
|
1016
|
-
console.error("β Management server error:",
|
|
1017
|
-
}),
|
|
1018
|
-
|
|
1019
|
-
π Starting shared dev server...`), console.log(`π‘ Management server on port ${
|
|
1020
|
-
console.error("β Main server error:",
|
|
1026
|
+
console.error("β Management server error:", c.message), process.exit(1);
|
|
1027
|
+
}), Oe.on("upgrade", wt), Oe.listen(d, async () => {
|
|
1028
|
+
Te = !0, console.log(`
|
|
1029
|
+
π Starting shared dev server...`), console.log(`π‘ Management server on port ${d}`), ge.on("error", (c) => {
|
|
1030
|
+
console.error("β Main server error:", c.message), process.exit(1);
|
|
1021
1031
|
}), ge.listen(l, async () => {
|
|
1022
|
-
console.log(`π‘ Main server running at http://localhost:${l}`), (
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
path:
|
|
1026
|
-
name:
|
|
1027
|
-
htmlFile:
|
|
1032
|
+
console.log(`π‘ Main server running at http://localhost:${l}`), (C === "DEV" || C === "NEW") && (C = "DEV1");
|
|
1033
|
+
const c = g ? t.default.resolve(F) : t.default.resolve(F, w);
|
|
1034
|
+
_.set(C, {
|
|
1035
|
+
path: c,
|
|
1036
|
+
name: N,
|
|
1037
|
+
htmlFile: g ? u : null
|
|
1028
1038
|
});
|
|
1029
|
-
const
|
|
1030
|
-
console.log(`β
Registered component: ${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1039
|
+
const a = N ? ` (${N})` : "";
|
|
1040
|
+
console.log(`β
Registered component: ${C}${a}`), console.log(`π‘ Access at: http://localhost:${l}/view/${C}/`), tt(() => {
|
|
1041
|
+
process.env.MYOP_NO_BROWSER || b(`http://localhost:${l}/view/${C}/`);
|
|
1032
1042
|
});
|
|
1033
1043
|
});
|
|
1034
1044
|
});
|
|
1035
1045
|
}
|
|
1036
|
-
const
|
|
1046
|
+
const A = class A {
|
|
1037
1047
|
constructor(t) {
|
|
1038
1048
|
this.components = t.map(
|
|
1039
1049
|
(e) => typeof e == "string" ? { name: e, path: "", id: "" } : e
|
|
@@ -1042,7 +1052,7 @@ const D = class D {
|
|
|
1042
1052
|
this.logs.set(e.name, []), this.scrollPos.set(e.name, 0), this.statuses.set(e.name, "Initializing..."), this.statusKeys.set(e.name, "initializing");
|
|
1043
1053
|
this.cols = process.stdout.columns || 120, this.rows = process.stdout.rows || 30, process.stdout.on("resize", () => {
|
|
1044
1054
|
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(
|
|
1055
|
+
}), this.setupKeyboardInput(), process.stdout.write(A.ESC.hideCursor), this.calculateLayout(), this.render(), this.uptimeInterval = setInterval(() => this.updateHeader(), 1e3);
|
|
1046
1056
|
}
|
|
1047
1057
|
setupKeyboardInput() {
|
|
1048
1058
|
process.stdin.isTTY && (process.stdin.setRawMode(!0), process.stdin.resume(), process.stdin.setEncoding("utf8"), process.stdin.on("data", (t) => {
|
|
@@ -1083,13 +1093,13 @@ const D = class D {
|
|
|
1083
1093
|
const t = this.components.length, e = 38;
|
|
1084
1094
|
let n;
|
|
1085
1095
|
this.cols >= e * 3 + 4 ? n = Math.min(t, 3) : this.cols >= e * 2 + 2 ? n = Math.min(t, 2) : n = 1;
|
|
1086
|
-
const s = Math.ceil(t / n), i = Math.floor(this.cols / n),
|
|
1096
|
+
const s = Math.ceil(t / n), i = Math.floor(this.cols / n), r = 2, m = this.rows - r - 2, l = Math.floor(m / s);
|
|
1087
1097
|
this.visibleLogLines = Math.max(2, l - 4), this.layout = { panelsPerRow: n, panelWidth: i, numRows: s, panelHeight: l }, this.panelPositions.clear();
|
|
1088
|
-
for (let
|
|
1089
|
-
const
|
|
1090
|
-
this.panelPositions.set(
|
|
1091
|
-
row:
|
|
1092
|
-
col:
|
|
1098
|
+
for (let d = 0; d < t; d++) {
|
|
1099
|
+
const w = this.components[d], x = Math.floor(d / n), $ = d % n;
|
|
1100
|
+
this.panelPositions.set(w.name, {
|
|
1101
|
+
row: r + 1 + x * l,
|
|
1102
|
+
col: $ * i + 1,
|
|
1093
1103
|
width: i,
|
|
1094
1104
|
height: l
|
|
1095
1105
|
});
|
|
@@ -1110,8 +1120,8 @@ const D = class D {
|
|
|
1110
1120
|
s.includes("initializing") || s.includes("β³") ? n = "initializing" : s.includes("starting") ? n = "starting" : s.includes("building") || s.includes("π¨") ? n = "building" : s.includes("ready") || s.includes("β
") ? n = "ready" : s.includes("changed") || s.includes("π") ? n = "changed" : s.includes("hmr") ? n = "hmr_update" : s.includes("π₯") ? n = "hmr" : s.includes("error") || s.includes("β") ? n = "error" : s.includes("warning") || s.includes("β ") ? n = "warning" : (s.includes("stopped") || s.includes("exited")) && (n = "stopped"), this.statuses.set(t, e), this.statusKeys.set(t, n), this.queueUpdate(t);
|
|
1111
1121
|
}
|
|
1112
1122
|
scroll(t, e) {
|
|
1113
|
-
const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines),
|
|
1114
|
-
|
|
1123
|
+
const n = this.logs.get(t) || [], s = this.scrollPos.get(t) || 0, i = Math.max(0, n.length - this.visibleLogLines), r = Math.max(0, Math.min(i, s + e));
|
|
1124
|
+
r !== s && (this.scrollPos.set(t, r), this.queueUpdate(t));
|
|
1115
1125
|
}
|
|
1116
1126
|
queueUpdate(t) {
|
|
1117
1127
|
this.pendingUpdates.add(t), this.renderQueued || (this.renderQueued = !0, setImmediate(() => {
|
|
@@ -1132,44 +1142,44 @@ const D = class D {
|
|
|
1132
1142
|
return `${e}:${n.toString().padStart(2, "0")}`;
|
|
1133
1143
|
}
|
|
1134
1144
|
updateHeader() {
|
|
1135
|
-
const t =
|
|
1145
|
+
const t = A.C, e = Array.from(this.statusKeys.values()).filter((i) => i === "ready").length, n = this.components.length;
|
|
1136
1146
|
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 +=
|
|
1147
|
+
s += `${t.green}${e}${t.reset}/${n} ready ${t.gray}|${t.reset} `, s += `β± ${this.getUptime()} ${t.gray}|${t.reset} `, s += `Press ${t.yellow}Ctrl+C${t.reset} to stop`, s += A.ESC.clearLine.slice(0, -1), process.stdout.write(A.ESC.moveTo(2, 1) + s);
|
|
1138
1148
|
}
|
|
1139
1149
|
renderPanel(t) {
|
|
1140
|
-
const e =
|
|
1150
|
+
const e = A.C, n = A.STATUS, s = this.panelPositions.get(t);
|
|
1141
1151
|
if (!s) return;
|
|
1142
|
-
const i = this.components.findIndex((
|
|
1143
|
-
let
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
const
|
|
1148
|
-
let j = `${
|
|
1149
|
-
j += " ".repeat(Math.max(0,
|
|
1150
|
-
const
|
|
1151
|
-
let k = `${
|
|
1152
|
-
|
|
1153
|
-
const L =
|
|
1154
|
-
for (let
|
|
1155
|
-
const
|
|
1156
|
-
let
|
|
1157
|
-
if (
|
|
1158
|
-
let
|
|
1159
|
-
|
|
1160
|
-
const oe =
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1152
|
+
const i = this.components.findIndex((D) => D.name === t), r = this.components[i], p = i === this.selectedPanel, m = this.statusKeys.get(t) || "initializing", l = n[m], d = e[l.color], w = this.logs.get(t) || [], x = this.scrollPos.get(t) || 0, $ = s.width - 1, g = p ? e.cyan : e.gray, u = [], E = r.name.substring(0, $ - 20);
|
|
1153
|
+
let O = `${g}ββ${e.reset} ${d}${l.icon}${e.reset} `;
|
|
1154
|
+
O += `${e.bold}${E}${e.reset} ${e.gray}β${e.reset} ${d}${l.label}${e.reset} `;
|
|
1155
|
+
const b = 5 + E.length + l.label.length + 3;
|
|
1156
|
+
O += `${g}${"β".repeat(Math.max(0, $ - b))}β${e.reset}`, u.push(A.ESC.moveTo(s.row, s.col) + O);
|
|
1157
|
+
const M = (r.path || "").substring(0, $ - 6);
|
|
1158
|
+
let j = `${g}β${e.reset} ${e.dim}${M}${e.reset}`;
|
|
1159
|
+
j += " ".repeat(Math.max(0, $ - M.length - 3)), j += `${g}β${e.reset}`, u.push(A.ESC.moveTo(s.row + 1, s.col) + j);
|
|
1160
|
+
const C = w.length, N = C > this.visibleLogLines ? `${x + 1}-${Math.min(x + this.visibleLogLines, C)}/${C}` : "";
|
|
1161
|
+
let k = `${g}β${"β".repeat($ - N.length - 4)}${e.reset}`;
|
|
1162
|
+
N && (k += `${e.dim}${N}${e.reset}`), k += `${g}${"β".repeat(2)}β€${e.reset}`, u.push(A.ESC.moveTo(s.row + 2, s.col) + k);
|
|
1163
|
+
const L = w.slice(x, x + this.visibleLogLines);
|
|
1164
|
+
for (let D = 0; D < this.visibleLogLines; D++) {
|
|
1165
|
+
const F = L[D];
|
|
1166
|
+
let W = `${g}β${e.reset}`;
|
|
1167
|
+
if (F) {
|
|
1168
|
+
let _ = e.white;
|
|
1169
|
+
F.type === "success" ? _ = e.green : F.type === "error" ? _ = e.red : F.type === "warning" ? _ = e.yellow : F.type === "hmr" ? _ = e.magenta : F.type === "change" && (_ = e.blue);
|
|
1170
|
+
const oe = F.message.substring(0, $ - 12);
|
|
1171
|
+
W += `${e.dim}${F.timestamp}${e.reset} ${_}${oe}${e.reset}`;
|
|
1172
|
+
const Ie = $ - F.timestamp.length - oe.length - 2;
|
|
1173
|
+
W += " ".repeat(Math.max(0, Ie));
|
|
1164
1174
|
} else
|
|
1165
|
-
|
|
1166
|
-
|
|
1175
|
+
W += " ".repeat($ - 2);
|
|
1176
|
+
W += `${g}β${e.reset}`, u.push(A.ESC.moveTo(s.row + 3 + D, s.col) + W);
|
|
1167
1177
|
}
|
|
1168
|
-
|
|
1178
|
+
u.push(A.ESC.moveTo(s.row + 3 + this.visibleLogLines, s.col) + `${g}β${"β".repeat($ - 2)}β${e.reset}`), process.stdout.write(u.join(""));
|
|
1169
1179
|
}
|
|
1170
1180
|
fullRender() {
|
|
1171
|
-
const t =
|
|
1172
|
-
process.stdout.write(
|
|
1181
|
+
const t = A.C;
|
|
1182
|
+
process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1));
|
|
1173
1183
|
const e = " MYOP MONOREPO DEV ", n = Math.floor((this.cols - e.length) / 2);
|
|
1174
1184
|
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
1185
|
for (const s of this.components)
|
|
@@ -1177,26 +1187,26 @@ const D = class D {
|
|
|
1177
1187
|
this.renderFooter();
|
|
1178
1188
|
}
|
|
1179
1189
|
renderFooter() {
|
|
1180
|
-
const t =
|
|
1190
|
+
const t = A.C, e = this.rows - 1;
|
|
1181
1191
|
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(
|
|
1192
|
+
n += `${t.green}β${t.gray} Ready `, n += `${t.yellow}β³${t.gray} Building `, n += `${t.magenta}β‘${t.gray} HMR `, n += `${t.red}β${t.gray} Error `, n += `${t.dim}| ββ: select panel ββ: scroll PgUp/PgDn: page g/G: top/bottom${t.reset}`, process.stdout.write(A.ESC.moveTo(e, 1) + n);
|
|
1183
1193
|
}
|
|
1184
1194
|
render() {
|
|
1185
1195
|
this.needsFullRedraw = !0, this.queueUpdate("__full__");
|
|
1186
1196
|
}
|
|
1187
1197
|
clear() {
|
|
1188
|
-
this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(
|
|
1198
|
+
this.uptimeInterval && clearInterval(this.uptimeInterval), process.stdin.isTTY && process.stdin.setRawMode(!1), process.stdout.write(A.ESC.clearScreen + A.ESC.moveTo(1, 1) + A.ESC.showCursor);
|
|
1189
1199
|
}
|
|
1190
1200
|
};
|
|
1191
1201
|
// ANSI escape codes
|
|
1192
|
-
|
|
1202
|
+
ve(A, "ESC", {
|
|
1193
1203
|
moveTo: (t, e) => `\x1B[${t};${e}H`,
|
|
1194
1204
|
hideCursor: "\x1B[?25l",
|
|
1195
1205
|
showCursor: "\x1B[?25h",
|
|
1196
1206
|
clearScreen: "\x1B[2J",
|
|
1197
1207
|
clearLine: "\x1B[2K"
|
|
1198
1208
|
}), // Colors
|
|
1199
|
-
|
|
1209
|
+
ve(A, "C", {
|
|
1200
1210
|
reset: "\x1B[0m",
|
|
1201
1211
|
bold: "\x1B[1m",
|
|
1202
1212
|
dim: "\x1B[2m",
|
|
@@ -1211,7 +1221,7 @@ we(D, "C", {
|
|
|
1211
1221
|
bgCyan: "\x1B[46m",
|
|
1212
1222
|
black: "\x1B[30m"
|
|
1213
1223
|
}), // Status configs
|
|
1214
|
-
|
|
1224
|
+
ve(A, "STATUS", {
|
|
1215
1225
|
initializing: { icon: "β", color: "yellow", label: "Initializing" },
|
|
1216
1226
|
starting: { icon: "β", color: "yellow", label: "Starting" },
|
|
1217
1227
|
building: { icon: "β³", color: "yellow", label: "Building" },
|
|
@@ -1224,125 +1234,227 @@ we(D, "STATUS", {
|
|
|
1224
1234
|
warning: { icon: "β ", color: "yellow", label: "Warning" },
|
|
1225
1235
|
stopped: { icon: "β ", color: "gray", label: "Stopped" }
|
|
1226
1236
|
});
|
|
1227
|
-
let
|
|
1228
|
-
async function
|
|
1229
|
-
const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((
|
|
1230
|
-
name:
|
|
1231
|
-
path:
|
|
1232
|
-
id:
|
|
1233
|
-
})), i = new
|
|
1234
|
-
const
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1237
|
+
let He = A;
|
|
1238
|
+
async function zt(o) {
|
|
1239
|
+
const { spawn: t, exec: e } = await import("child_process"), n = await import("path"), s = o.map((d) => ({
|
|
1240
|
+
name: d.name,
|
|
1241
|
+
path: d.path,
|
|
1242
|
+
id: d.componentId || ""
|
|
1243
|
+
})), i = new He(s), r = [], p = (d) => {
|
|
1244
|
+
const w = process.platform;
|
|
1245
|
+
let x;
|
|
1246
|
+
w === "darwin" ? x = `open "${d}"` : w === "win32" ? x = `start "" "${d}"` : x = `xdg-open "${d}"`, e(x, () => {
|
|
1237
1247
|
});
|
|
1238
|
-
},
|
|
1248
|
+
}, m = () => {
|
|
1239
1249
|
i.clear(), console.log(`
|
|
1240
|
-
π Shutting down all components...`),
|
|
1250
|
+
π Shutting down all components...`), r.forEach((d) => {
|
|
1241
1251
|
try {
|
|
1242
|
-
|
|
1252
|
+
d.kill("SIGTERM");
|
|
1243
1253
|
} catch {
|
|
1244
1254
|
}
|
|
1245
1255
|
}), setTimeout(() => process.exit(0), 500);
|
|
1246
1256
|
};
|
|
1247
|
-
process.on("SIGINT",
|
|
1257
|
+
process.on("SIGINT", m), process.on("SIGTERM", m);
|
|
1248
1258
|
const l = process.argv[1];
|
|
1249
|
-
for (let
|
|
1250
|
-
const
|
|
1251
|
-
i.setStatus(
|
|
1252
|
-
const
|
|
1253
|
-
cwd: n.default.resolve(
|
|
1259
|
+
for (let d = 0; d < o.length; d++) {
|
|
1260
|
+
const w = o[d], x = w.name;
|
|
1261
|
+
i.setStatus(x, "β³ Starting..."), i.log(x, `Starting in ${w.path}`);
|
|
1262
|
+
const $ = t("node", [l, "dev"], {
|
|
1263
|
+
cwd: n.default.resolve(w.path),
|
|
1254
1264
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1265
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1266
|
});
|
|
1257
|
-
|
|
1258
|
-
let
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const E =
|
|
1267
|
+
r.push($);
|
|
1268
|
+
let g = "";
|
|
1269
|
+
$.stdout.on("data", (u) => {
|
|
1270
|
+
g += u.toString();
|
|
1271
|
+
const E = g.split(`
|
|
1262
1272
|
`);
|
|
1263
|
-
|
|
1264
|
-
for (const
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1273
|
+
g = E.pop() || "";
|
|
1274
|
+
for (const O of E) {
|
|
1275
|
+
const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1276
|
+
b && (b.includes("Registered component") || b.includes("Registered:") ? i.setStatus(x, "β
Ready") : b.includes("Building...") || b.includes("Running initial build") ? i.setStatus(x, "π¨ Building...") : b.includes("Build completed") || b.includes("Build succeeded") ? i.setStatus(x, "β
Ready") : b.includes("Build failed") ? i.setStatus(x, "β Build Error") : b.includes("File changed") ? (i.setStatus(x, "π Changed"), setTimeout(() => i.setStatus(x, "β
Ready"), 1500)) : b.includes("Notifying") && b.includes("HMR") ? (i.setStatus(x, "π₯ HMR Update"), setTimeout(() => i.setStatus(x, "β
Ready"), 1e3)) : b.includes("HMR client connected") && (i.setStatus(x, "π₯ HMR Connected"), setTimeout(() => i.setStatus(x, "β
Ready"), 1e3)), !b.includes("Watching") && !b.includes("Press Ctrl+C") && !b.includes("Starting shared") && !b.includes("Management server") && !b.includes("Main server") && !b.includes("Access at:") && !b.includes("No build needed") && i.log(x, b));
|
|
1267
1277
|
}
|
|
1268
|
-
}),
|
|
1269
|
-
const E =
|
|
1278
|
+
}), $.stderr.on("data", (u) => {
|
|
1279
|
+
const E = u.toString().split(`
|
|
1270
1280
|
`);
|
|
1271
|
-
for (const
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1281
|
+
for (const O of E) {
|
|
1282
|
+
const b = O.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1283
|
+
b && (i.log(x, `β οΈ ${b}`), i.setStatus(x, "β οΈ Warning"));
|
|
1274
1284
|
}
|
|
1275
|
-
}),
|
|
1276
|
-
|
|
1277
|
-
}),
|
|
1285
|
+
}), $.on("exit", (u) => {
|
|
1286
|
+
u !== 0 && u !== null && (i.setStatus(x, `β Exited (${u})`), i.log(x, `Process exited with code ${u}`));
|
|
1287
|
+
}), d < o.length - 1 && await new Promise((u) => setTimeout(u, 500));
|
|
1278
1288
|
}
|
|
1279
1289
|
i.render(), setTimeout(() => {
|
|
1280
|
-
|
|
1290
|
+
p("http://localhost:9292");
|
|
1281
1291
|
}, 2e3);
|
|
1282
1292
|
}
|
|
1283
|
-
const
|
|
1293
|
+
const Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1284
1294
|
__proto__: null,
|
|
1285
|
-
devCommand:
|
|
1286
|
-
monorepoDevCommand:
|
|
1287
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1288
|
-
function
|
|
1289
|
-
|
|
1295
|
+
devCommand: Ce,
|
|
1296
|
+
monorepoDevCommand: zt
|
|
1297
|
+
}, Symbol.toStringTag, { value: "Module" })), Vt = "https://cloud.myop.dev";
|
|
1298
|
+
async function mt(o, t) {
|
|
1299
|
+
const e = await fetch(o, {
|
|
1300
|
+
headers: { Authorization: `Bearer ${t}` }
|
|
1301
|
+
});
|
|
1302
|
+
if (!e.ok) {
|
|
1303
|
+
const n = await e.text();
|
|
1304
|
+
throw new Error(`${e.status}: ${n}`);
|
|
1305
|
+
}
|
|
1306
|
+
return e.json();
|
|
1307
|
+
}
|
|
1308
|
+
function pe(o, t, e) {
|
|
1309
|
+
const n = R.resolve(R.join(o, t)), s = R.resolve(o);
|
|
1310
|
+
if (!n.startsWith(s + R.sep))
|
|
1311
|
+
throw new Error(`Invalid path: "${t}" escapes output directory`);
|
|
1312
|
+
P.mkdirSync(R.dirname(n), { recursive: !0 }), P.writeFileSync(n, JSON.stringify(e, null, 2));
|
|
1313
|
+
}
|
|
1314
|
+
async function $e(o, t, e, n) {
|
|
1315
|
+
return mt(
|
|
1316
|
+
`${o}/export?componentId=${encodeURIComponent(e)}&env=${encodeURIComponent(n)}`,
|
|
1317
|
+
t
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
async function Yt(o, t, e, n) {
|
|
1321
|
+
let s = 0;
|
|
1322
|
+
const i = /* @__PURE__ */ new Set();
|
|
1323
|
+
for (const r of n) {
|
|
1324
|
+
const { componentId: p, environment: m } = r;
|
|
1325
|
+
if (!(!p || !m)) {
|
|
1326
|
+
try {
|
|
1327
|
+
const l = await $e(o, t, p, m);
|
|
1328
|
+
pe(e, `components/${p}/${m}.json`, l), s++;
|
|
1329
|
+
} catch (l) {
|
|
1330
|
+
console.warn(` Warning: ${p}/${m}: ${l.message}`);
|
|
1331
|
+
}
|
|
1332
|
+
if (!i.has(p)) {
|
|
1333
|
+
i.add(p);
|
|
1334
|
+
try {
|
|
1335
|
+
const l = await $e(o, t, p, "preview");
|
|
1336
|
+
pe(e, `components/${p}/preview.json`, l), s++;
|
|
1337
|
+
} catch {
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
return s;
|
|
1290
1343
|
}
|
|
1291
|
-
function
|
|
1344
|
+
async function Gt(o, t, e) {
|
|
1345
|
+
const n = await mt(`${o}/export`, t);
|
|
1346
|
+
pe(e, "manifest.json", n);
|
|
1347
|
+
let s = 0, i = 0;
|
|
1348
|
+
for (const r of n.components || []) {
|
|
1349
|
+
for (const p of r.environments || [])
|
|
1350
|
+
try {
|
|
1351
|
+
const m = await $e(o, t, r.id, p);
|
|
1352
|
+
pe(e, `components/${r.id}/${p}.json`, m), s++;
|
|
1353
|
+
} catch (m) {
|
|
1354
|
+
console.warn(` Warning: ${r.id}/${p}: ${m.message}`), i++;
|
|
1355
|
+
}
|
|
1356
|
+
try {
|
|
1357
|
+
const p = await $e(o, t, r.id, "preview");
|
|
1358
|
+
pe(e, `components/${r.id}/preview.json`, p), s++;
|
|
1359
|
+
} catch {
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
return { manifest: n, fileCount: s, errorCount: i };
|
|
1363
|
+
}
|
|
1364
|
+
function Kt() {
|
|
1365
|
+
v.program.command("export").description("Export components as static JSON for self-hosting").option("-k, --api-key <key>", "Myop API key (or set MYOP_API_KEY env var)").option("-o, --output <dir>", "Output directory", "./myop-static").option("-u, --url <url>", "Myop API URL (or set MYOP_API_URL env var)").option("--releases <json>", "JSON array of releases for incremental sync (from webhook payload)").option("--component <id>", "Single component ID for incremental sync").option("--env <env>", "Environment for single component sync (used with --component)").action(async (o) => {
|
|
1366
|
+
var i;
|
|
1367
|
+
const t = o.apiKey || process.env.MYOP_API_KEY, e = o.url || process.env.MYOP_API_URL || Vt, n = o.output || process.env.OUTPUT_DIR || "./myop-static";
|
|
1368
|
+
t || (console.error("Error: API key required. Use --api-key or set MYOP_API_KEY env var."), console.error("Create one at: Dashboard > Rollout Settings > Self-Hosting > API Keys"), process.exit(1));
|
|
1369
|
+
let s = null;
|
|
1370
|
+
if (o.releases)
|
|
1371
|
+
try {
|
|
1372
|
+
s = JSON.parse(o.releases), Array.isArray(s) || (s = s.releases || [s]);
|
|
1373
|
+
} catch {
|
|
1374
|
+
console.error("Error: --releases must be valid JSON"), process.exit(1);
|
|
1375
|
+
}
|
|
1376
|
+
else o.component && o.env && (s = [{ componentId: o.component, environment: o.env }]);
|
|
1377
|
+
if (s) {
|
|
1378
|
+
const r = z(`Incremental export: ${s.length} component(s)...`).start();
|
|
1379
|
+
try {
|
|
1380
|
+
const p = await Yt(e, t, n, s);
|
|
1381
|
+
r.succeed(`Incremental export done. ${p} file(s) written to ${n}/`);
|
|
1382
|
+
} catch (p) {
|
|
1383
|
+
r.fail(`Export failed: ${p.message}`), process.exit(1);
|
|
1384
|
+
}
|
|
1385
|
+
} else {
|
|
1386
|
+
const r = z(`Full export from ${e}...`).start();
|
|
1387
|
+
try {
|
|
1388
|
+
const { manifest: p, fileCount: m, errorCount: l } = await Gt(e, t, n), d = ((i = p.components) == null ? void 0 : i.length) || 0;
|
|
1389
|
+
r.succeed(
|
|
1390
|
+
`Full export done. ${m} file(s) from ${d} component(s) written to ${n}/`
|
|
1391
|
+
), l > 0 && console.warn(` ${l} file(s) failed.`);
|
|
1392
|
+
} catch (p) {
|
|
1393
|
+
r.fail(`Export failed: ${p.message}`), process.exit(1);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
process.exit(0);
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
const Be = R.join(at.homedir(), ".myop"), ue = R.join(Be, "credentials.json");
|
|
1400
|
+
function Qt() {
|
|
1401
|
+
P.existsSync(Be) || P.mkdirSync(Be, { recursive: !0, mode: 448 });
|
|
1402
|
+
}
|
|
1403
|
+
function Ye() {
|
|
1292
1404
|
try {
|
|
1293
|
-
if (!P.existsSync(
|
|
1405
|
+
if (!P.existsSync(ue))
|
|
1294
1406
|
return null;
|
|
1295
|
-
const o = P.readFileSync(
|
|
1407
|
+
const o = P.readFileSync(ue, "utf8");
|
|
1296
1408
|
return JSON.parse(o);
|
|
1297
1409
|
} catch (o) {
|
|
1298
1410
|
return console.info("Failed to read credentials:", o.message), null;
|
|
1299
1411
|
}
|
|
1300
1412
|
}
|
|
1301
|
-
function
|
|
1302
|
-
|
|
1413
|
+
function ut(o) {
|
|
1414
|
+
Qt();
|
|
1303
1415
|
const t = {
|
|
1304
1416
|
...o,
|
|
1305
1417
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1306
1418
|
};
|
|
1307
|
-
P.writeFileSync(
|
|
1419
|
+
P.writeFileSync(ue, JSON.stringify(t, null, 2), {
|
|
1308
1420
|
mode: 384
|
|
1309
1421
|
// Read/write for owner only
|
|
1310
1422
|
});
|
|
1311
1423
|
}
|
|
1312
|
-
function
|
|
1424
|
+
function ft() {
|
|
1313
1425
|
try {
|
|
1314
|
-
return P.existsSync(
|
|
1426
|
+
return P.existsSync(ue) && P.unlinkSync(ue), !0;
|
|
1315
1427
|
} catch (o) {
|
|
1316
1428
|
return console.error("Failed to clear credentials:", o.message), !1;
|
|
1317
1429
|
}
|
|
1318
1430
|
}
|
|
1319
|
-
function
|
|
1431
|
+
function Zt(o) {
|
|
1320
1432
|
if (!o || !o.expiresAt)
|
|
1321
1433
|
return !0;
|
|
1322
1434
|
const t = 5 * 60 * 1e3, e = new Date(o.expiresAt).getTime();
|
|
1323
1435
|
return Date.now() > e - t;
|
|
1324
1436
|
}
|
|
1325
|
-
function
|
|
1326
|
-
const o =
|
|
1437
|
+
function Pe() {
|
|
1438
|
+
const o = Ye();
|
|
1327
1439
|
return o ? {
|
|
1328
1440
|
email: o.userEmail,
|
|
1329
1441
|
userId: o.userId
|
|
1330
1442
|
} : null;
|
|
1331
1443
|
}
|
|
1332
|
-
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev",
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1444
|
+
const le = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", xe = 19284, Ge = `http://localhost:${xe}/callback`, qt = "myop-cli";
|
|
1445
|
+
function Xt() {
|
|
1446
|
+
return We.randomBytes(32).toString("base64url");
|
|
1335
1447
|
}
|
|
1336
|
-
function
|
|
1337
|
-
return
|
|
1448
|
+
function eo(o) {
|
|
1449
|
+
return We.createHash("sha256").update(o).digest("base64url");
|
|
1338
1450
|
}
|
|
1339
|
-
async function
|
|
1451
|
+
async function to() {
|
|
1340
1452
|
const o = await fetch(`${le}/oauth/register`, {
|
|
1341
1453
|
method: "POST",
|
|
1342
1454
|
headers: { "Content-Type": "application/json" },
|
|
1343
1455
|
body: JSON.stringify({
|
|
1344
|
-
client_name:
|
|
1345
|
-
redirect_uris: [
|
|
1456
|
+
client_name: qt,
|
|
1457
|
+
redirect_uris: [Ge],
|
|
1346
1458
|
grant_types: ["authorization_code", "refresh_token"],
|
|
1347
1459
|
response_types: ["code"]
|
|
1348
1460
|
})
|
|
@@ -1353,7 +1465,7 @@ async function Yt() {
|
|
|
1353
1465
|
}
|
|
1354
1466
|
return o.json();
|
|
1355
1467
|
}
|
|
1356
|
-
function
|
|
1468
|
+
function Se(o, t, e, n = null) {
|
|
1357
1469
|
const s = {
|
|
1358
1470
|
success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
|
|
1359
1471
|
<circle cx="12" cy="12" r="10"/>
|
|
@@ -1371,7 +1483,7 @@ function ve(o, t, e, n = null) {
|
|
|
1371
1483
|
success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
|
|
1372
1484
|
error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
|
|
1373
1485
|
warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
|
|
1374
|
-
}, { accent:
|
|
1486
|
+
}, { accent: r, glow: p } = i[o] || i.error;
|
|
1375
1487
|
return `<!DOCTYPE html>
|
|
1376
1488
|
<html lang="en">
|
|
1377
1489
|
<head>
|
|
@@ -1432,7 +1544,7 @@ function ve(o, t, e, n = null) {
|
|
|
1432
1544
|
h1 {
|
|
1433
1545
|
font-size: 20px;
|
|
1434
1546
|
font-weight: 500;
|
|
1435
|
-
color: ${
|
|
1547
|
+
color: ${r};
|
|
1436
1548
|
margin-bottom: 12px;
|
|
1437
1549
|
letter-spacing: -0.5px;
|
|
1438
1550
|
}
|
|
@@ -1464,8 +1576,8 @@ function ve(o, t, e, n = null) {
|
|
|
1464
1576
|
display: inline-flex;
|
|
1465
1577
|
align-items: center;
|
|
1466
1578
|
gap: 8px;
|
|
1467
|
-
background: ${
|
|
1468
|
-
border: 1px solid ${
|
|
1579
|
+
background: ${p};
|
|
1580
|
+
border: 1px solid ${r}33;
|
|
1469
1581
|
border-radius: 4px;
|
|
1470
1582
|
padding: 10px 16px;
|
|
1471
1583
|
font-size: 12px;
|
|
@@ -1519,14 +1631,14 @@ function ve(o, t, e, n = null) {
|
|
|
1519
1631
|
</body>
|
|
1520
1632
|
</html>`;
|
|
1521
1633
|
}
|
|
1522
|
-
function
|
|
1634
|
+
function oo(o) {
|
|
1523
1635
|
return new Promise((t, e) => {
|
|
1524
|
-
const n =
|
|
1525
|
-
const
|
|
1526
|
-
if (
|
|
1527
|
-
const
|
|
1636
|
+
const n = It.createServer((s, i) => {
|
|
1637
|
+
const r = new it(s.url, `http://localhost:${xe}`);
|
|
1638
|
+
if (r.pathname === "/callback") {
|
|
1639
|
+
const p = r.searchParams.get("code"), m = r.searchParams.get("state"), l = r.searchParams.get("error");
|
|
1528
1640
|
if (l) {
|
|
1529
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
1641
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
|
|
1530
1642
|
"error",
|
|
1531
1643
|
"Authentication Failed",
|
|
1532
1644
|
"Unable to complete the authentication process.",
|
|
@@ -1534,8 +1646,8 @@ function Kt(o) {
|
|
|
1534
1646
|
)), n.close(), e(new Error(`OAuth error: ${l}`));
|
|
1535
1647
|
return;
|
|
1536
1648
|
}
|
|
1537
|
-
if (
|
|
1538
|
-
i.writeHead(400, { "Content-Type": "text/html" }), i.end(
|
|
1649
|
+
if (m !== o) {
|
|
1650
|
+
i.writeHead(400, { "Content-Type": "text/html" }), i.end(Se(
|
|
1539
1651
|
"warning",
|
|
1540
1652
|
"Security Error",
|
|
1541
1653
|
"State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
|
|
@@ -1543,8 +1655,8 @@ function Kt(o) {
|
|
|
1543
1655
|
)), n.close(), e(new Error("State mismatch"));
|
|
1544
1656
|
return;
|
|
1545
1657
|
}
|
|
1546
|
-
if (!
|
|
1547
|
-
i.writeHead(400, { "Content-Type": "text/html" }), i.end(
|
|
1658
|
+
if (!p) {
|
|
1659
|
+
i.writeHead(400, { "Content-Type": "text/html" }), i.end(Se(
|
|
1548
1660
|
"error",
|
|
1549
1661
|
"Missing Authorization Code",
|
|
1550
1662
|
"No authorization code was received from the server.",
|
|
@@ -1552,30 +1664,30 @@ function Kt(o) {
|
|
|
1552
1664
|
)), n.close(), e(new Error("No authorization code"));
|
|
1553
1665
|
return;
|
|
1554
1666
|
}
|
|
1555
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
1667
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(Se(
|
|
1556
1668
|
"success",
|
|
1557
1669
|
"Authentication Successful",
|
|
1558
1670
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1559
|
-
)), n.close(), t(
|
|
1671
|
+
)), n.close(), t(p);
|
|
1560
1672
|
} else
|
|
1561
1673
|
i.writeHead(404), i.end("Not found");
|
|
1562
1674
|
});
|
|
1563
|
-
n.listen(
|
|
1564
|
-
console.info(`OAuth callback server listening on port ${
|
|
1675
|
+
n.listen(xe, () => {
|
|
1676
|
+
console.info(`OAuth callback server listening on port ${xe}`);
|
|
1565
1677
|
}), setTimeout(() => {
|
|
1566
1678
|
n.close(), e(new Error("Authentication timed out"));
|
|
1567
1679
|
}, 5 * 60 * 1e3);
|
|
1568
1680
|
});
|
|
1569
1681
|
}
|
|
1570
|
-
async function
|
|
1682
|
+
async function no(o, t, e) {
|
|
1571
1683
|
const n = await fetch(`${le}/oauth/token`, {
|
|
1572
1684
|
method: "POST",
|
|
1573
1685
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1574
|
-
body: new
|
|
1686
|
+
body: new rt({
|
|
1575
1687
|
grant_type: "authorization_code",
|
|
1576
1688
|
code: o,
|
|
1577
1689
|
client_id: t,
|
|
1578
|
-
redirect_uri:
|
|
1690
|
+
redirect_uri: Ge,
|
|
1579
1691
|
code_verifier: e
|
|
1580
1692
|
})
|
|
1581
1693
|
});
|
|
@@ -1585,11 +1697,11 @@ async function Qt(o, t, e) {
|
|
|
1585
1697
|
}
|
|
1586
1698
|
return n.json();
|
|
1587
1699
|
}
|
|
1588
|
-
async function
|
|
1700
|
+
async function so(o, t) {
|
|
1589
1701
|
const e = await fetch(`${le}/oauth/token`, {
|
|
1590
1702
|
method: "POST",
|
|
1591
1703
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1592
|
-
body: new
|
|
1704
|
+
body: new rt({
|
|
1593
1705
|
grant_type: "refresh_token",
|
|
1594
1706
|
refresh_token: o,
|
|
1595
1707
|
client_id: t
|
|
@@ -1601,8 +1713,8 @@ async function Zt(o, t) {
|
|
|
1601
1713
|
}
|
|
1602
1714
|
return e.json();
|
|
1603
1715
|
}
|
|
1604
|
-
async function
|
|
1605
|
-
var s, i,
|
|
1716
|
+
async function io(o) {
|
|
1717
|
+
var s, i, r;
|
|
1606
1718
|
const t = await fetch(`${le}/mcp`, {
|
|
1607
1719
|
method: "POST",
|
|
1608
1720
|
headers: {
|
|
@@ -1624,62 +1736,62 @@ async function Xt(o) {
|
|
|
1624
1736
|
const e = await t.json();
|
|
1625
1737
|
if (e.error)
|
|
1626
1738
|
throw new Error(e.error.message);
|
|
1627
|
-
const n = (
|
|
1739
|
+
const n = (r = (i = (s = e.result) == null ? void 0 : s.content) == null ? void 0 : i[0]) == null ? void 0 : r.text;
|
|
1628
1740
|
if (n)
|
|
1629
1741
|
return JSON.parse(n);
|
|
1630
1742
|
throw new Error("Invalid response from whoami");
|
|
1631
1743
|
}
|
|
1632
|
-
async function
|
|
1633
|
-
const o =
|
|
1744
|
+
async function me() {
|
|
1745
|
+
const o = z("Starting authentication...").start();
|
|
1634
1746
|
try {
|
|
1635
1747
|
o.text = "Registering OAuth client...";
|
|
1636
|
-
const e = (await
|
|
1748
|
+
const e = (await to()).client_id, n = Xt(), s = eo(n), i = We.randomBytes(16).toString("hex");
|
|
1637
1749
|
o.text = "Waiting for authorization...";
|
|
1638
|
-
const
|
|
1639
|
-
|
|
1640
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1641
|
-
`), await
|
|
1642
|
-
const
|
|
1750
|
+
const r = oo(i), p = new it(`${le}/oauth/authorize`);
|
|
1751
|
+
p.searchParams.set("response_type", "code"), p.searchParams.set("client_id", e), p.searchParams.set("redirect_uri", Ge), p.searchParams.set("code_challenge", s), p.searchParams.set("code_challenge_method", "S256"), p.searchParams.set("state", i), o.stop(), console.log(`
|
|
1752
|
+
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${p.toString()}
|
|
1753
|
+
`), await Ot(p.toString());
|
|
1754
|
+
const m = await r;
|
|
1643
1755
|
o.start("Exchanging authorization code...");
|
|
1644
|
-
const l = await
|
|
1756
|
+
const l = await no(m, e, n);
|
|
1645
1757
|
o.text = "Getting user info...";
|
|
1646
|
-
const
|
|
1758
|
+
const d = await io(l.access_token), w = {
|
|
1647
1759
|
accessToken: l.access_token,
|
|
1648
1760
|
refreshToken: l.refresh_token,
|
|
1649
1761
|
expiresAt: new Date(Date.now() + l.expires_in * 1e3).toISOString(),
|
|
1650
1762
|
clientId: e,
|
|
1651
|
-
userId:
|
|
1652
|
-
userEmail:
|
|
1763
|
+
userId: d.userId,
|
|
1764
|
+
userEmail: d.email
|
|
1653
1765
|
};
|
|
1654
|
-
return
|
|
1766
|
+
return ut(w), o.succeed(`Authenticated as ${d.email}`), w;
|
|
1655
1767
|
} catch (t) {
|
|
1656
1768
|
throw o.fail(`Authentication failed: ${t.message}`), t;
|
|
1657
1769
|
}
|
|
1658
1770
|
}
|
|
1659
|
-
async function
|
|
1660
|
-
const o =
|
|
1771
|
+
async function gt() {
|
|
1772
|
+
const o = Ye();
|
|
1661
1773
|
if (!o) {
|
|
1662
1774
|
console.log("Not currently logged in.");
|
|
1663
1775
|
return;
|
|
1664
1776
|
}
|
|
1665
|
-
|
|
1777
|
+
ft(), console.log(`β
Logged out (was: ${o.userEmail})`);
|
|
1666
1778
|
}
|
|
1667
|
-
function
|
|
1779
|
+
function ro(o) {
|
|
1668
1780
|
var e, n;
|
|
1669
1781
|
const t = (o == null ? void 0 : o.message) || "";
|
|
1670
1782
|
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
1783
|
}
|
|
1672
|
-
async function
|
|
1673
|
-
let o =
|
|
1784
|
+
async function Ke() {
|
|
1785
|
+
let o = Ye();
|
|
1674
1786
|
if (!o)
|
|
1675
1787
|
return console.log(`Not logged in. Starting authentication...
|
|
1676
|
-
`), await
|
|
1677
|
-
if (!
|
|
1788
|
+
`), await me();
|
|
1789
|
+
if (!Zt(o))
|
|
1678
1790
|
return o;
|
|
1679
1791
|
if (o.refreshToken) {
|
|
1680
|
-
const t =
|
|
1792
|
+
const t = z("Refreshing access token...").start();
|
|
1681
1793
|
try {
|
|
1682
|
-
const e = await
|
|
1794
|
+
const e = await so(
|
|
1683
1795
|
o.refreshToken,
|
|
1684
1796
|
o.clientId
|
|
1685
1797
|
);
|
|
@@ -1688,64 +1800,64 @@ async function Ve() {
|
|
|
1688
1800
|
accessToken: e.access_token,
|
|
1689
1801
|
refreshToken: e.refresh_token,
|
|
1690
1802
|
expiresAt: new Date(Date.now() + e.expires_in * 1e3).toISOString()
|
|
1691
|
-
},
|
|
1803
|
+
}, ut(o), t.succeed("Token refreshed"), o;
|
|
1692
1804
|
} catch (e) {
|
|
1693
|
-
if (
|
|
1805
|
+
if (ro(e))
|
|
1694
1806
|
throw t.fail("Network error during token refresh"), e;
|
|
1695
|
-
return t.warn("Token refresh failed, please log in again"),
|
|
1807
|
+
return t.warn("Token refresh failed, please log in again"), ft(), await me();
|
|
1696
1808
|
}
|
|
1697
1809
|
}
|
|
1698
1810
|
return console.log(`Session expired. Please log in again.
|
|
1699
|
-
`), await
|
|
1811
|
+
`), await me();
|
|
1700
1812
|
}
|
|
1701
|
-
function
|
|
1813
|
+
function Me() {
|
|
1702
1814
|
return le;
|
|
1703
1815
|
}
|
|
1704
|
-
const Z = "@myop/cli",
|
|
1705
|
-
function
|
|
1816
|
+
const Z = "@myop/cli", De = process.platform === "win32";
|
|
1817
|
+
function ao() {
|
|
1706
1818
|
try {
|
|
1707
1819
|
return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
|
|
1708
1820
|
} catch {
|
|
1709
1821
|
return "https://registry.npmjs.org/";
|
|
1710
1822
|
}
|
|
1711
1823
|
}
|
|
1712
|
-
function
|
|
1824
|
+
function lo() {
|
|
1713
1825
|
try {
|
|
1714
1826
|
return Q("npm config get prefix", { encoding: "utf-8" }).trim();
|
|
1715
1827
|
} catch {
|
|
1716
1828
|
return null;
|
|
1717
1829
|
}
|
|
1718
1830
|
}
|
|
1719
|
-
async function
|
|
1831
|
+
async function co() {
|
|
1720
1832
|
try {
|
|
1721
|
-
const o =
|
|
1833
|
+
const o = ao().replace(/\/$/, ""), t = await fetch(`${o}/${Z}/latest`);
|
|
1722
1834
|
return t.ok ? (await t.json()).version : null;
|
|
1723
1835
|
} catch {
|
|
1724
1836
|
return null;
|
|
1725
1837
|
}
|
|
1726
1838
|
}
|
|
1727
|
-
function
|
|
1839
|
+
function po(o, t) {
|
|
1728
1840
|
const e = o.split(".").map(Number), n = t.split(".").map(Number);
|
|
1729
1841
|
for (let s = 0; s < Math.max(e.length, n.length); s++) {
|
|
1730
|
-
const i = e[s] || 0,
|
|
1731
|
-
if (i >
|
|
1732
|
-
if (i <
|
|
1842
|
+
const i = e[s] || 0, r = n[s] || 0;
|
|
1843
|
+
if (i > r) return 1;
|
|
1844
|
+
if (i < r) return -1;
|
|
1733
1845
|
}
|
|
1734
1846
|
return 0;
|
|
1735
1847
|
}
|
|
1736
|
-
async function
|
|
1737
|
-
const t =
|
|
1848
|
+
async function mo(o) {
|
|
1849
|
+
const t = z({
|
|
1738
1850
|
text: "Checking for updates...",
|
|
1739
1851
|
color: "cyan"
|
|
1740
|
-
}).start(), e = await
|
|
1741
|
-
if (t.stop(), !e ||
|
|
1852
|
+
}).start(), e = await co();
|
|
1853
|
+
if (t.stop(), !e || po(e, o) <= 0)
|
|
1742
1854
|
return !1;
|
|
1743
1855
|
console.log(`
|
|
1744
1856
|
π¦ New version available: ${o} β ${e}
|
|
1745
1857
|
`);
|
|
1746
1858
|
let n;
|
|
1747
1859
|
try {
|
|
1748
|
-
n = await
|
|
1860
|
+
n = await st({
|
|
1749
1861
|
message: "Would you like to update now?",
|
|
1750
1862
|
choices: [
|
|
1751
1863
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1759,10 +1871,10 @@ async function so(o) {
|
|
|
1759
1871
|
`), process.exit(0)), s;
|
|
1760
1872
|
}
|
|
1761
1873
|
if (n) {
|
|
1762
|
-
const s =
|
|
1874
|
+
const s = z({
|
|
1763
1875
|
text: `Updating ${Z} to v${e}...`,
|
|
1764
1876
|
color: "green"
|
|
1765
|
-
}).start(), i = `npm install -g ${Z}@latest`,
|
|
1877
|
+
}).start(), i = `npm install -g ${Z}@latest`, r = lo();
|
|
1766
1878
|
try {
|
|
1767
1879
|
Q(i, { stdio: "pipe" }), s.succeed(`Updated to v${e}`);
|
|
1768
1880
|
} catch {
|
|
@@ -1770,11 +1882,11 @@ async function so(o) {
|
|
|
1770
1882
|
π Elevated permissions required.
|
|
1771
1883
|
`);
|
|
1772
1884
|
try {
|
|
1773
|
-
if (
|
|
1774
|
-
const
|
|
1775
|
-
Q(`powershell -Command "${
|
|
1885
|
+
if (De) {
|
|
1886
|
+
const d = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${r ? `install -g ${Z}@latest --prefix \\"${r}\\"` : `install -g ${Z}@latest`}' -Verb RunAs -Wait`;
|
|
1887
|
+
Q(`powershell -Command "${d}"`, { stdio: "inherit" });
|
|
1776
1888
|
} else {
|
|
1777
|
-
const l =
|
|
1889
|
+
const l = r ? `sudo npm install -g ${Z}@latest --prefix "${r}"` : `sudo ${i}`;
|
|
1778
1890
|
Q(l, { stdio: "inherit" });
|
|
1779
1891
|
}
|
|
1780
1892
|
console.log(`
|
|
@@ -1782,24 +1894,24 @@ async function so(o) {
|
|
|
1782
1894
|
} catch {
|
|
1783
1895
|
console.log(`
|
|
1784
1896
|
β Update failed`);
|
|
1785
|
-
const
|
|
1897
|
+
const d = De ? `npm install -g ${Z}@latest (run as Administrator)` : `sudo npm install -g ${Z}@latest`;
|
|
1786
1898
|
console.log(`
|
|
1787
|
-
Please run manually: ${
|
|
1899
|
+
Please run manually: ${d}
|
|
1788
1900
|
`), process.exit(1);
|
|
1789
1901
|
}
|
|
1790
1902
|
}
|
|
1791
|
-
let
|
|
1903
|
+
let p = null;
|
|
1792
1904
|
try {
|
|
1793
|
-
let
|
|
1794
|
-
|
|
1795
|
-
const l =
|
|
1796
|
-
|
|
1905
|
+
let m;
|
|
1906
|
+
r ? m = De ? Ae(r, "node_modules") : Ae(r, "lib", "node_modules") : m = Q("npm root -g", { encoding: "utf-8" }).trim();
|
|
1907
|
+
const l = Ae(m, Z, "package.json"), d = Et(l, "utf-8");
|
|
1908
|
+
p = JSON.parse(d).version;
|
|
1797
1909
|
} catch {
|
|
1798
1910
|
}
|
|
1799
|
-
if (
|
|
1911
|
+
if (p === e)
|
|
1800
1912
|
return console.log(`
|
|
1801
1913
|
π Restarting...
|
|
1802
|
-
`),
|
|
1914
|
+
`), Mt(process.argv[0], process.argv.slice(1), {
|
|
1803
1915
|
stdio: "inherit",
|
|
1804
1916
|
shell: !0
|
|
1805
1917
|
}).on("close", (l) => {
|
|
@@ -1811,35 +1923,35 @@ Please run myop again to use the new version.
|
|
|
1811
1923
|
}
|
|
1812
1924
|
return !1;
|
|
1813
1925
|
}
|
|
1814
|
-
const
|
|
1815
|
-
function
|
|
1816
|
-
P.existsSync(
|
|
1926
|
+
const Je = R.join(at.homedir(), ".myop"), ze = R.join(Je, "preferences.json");
|
|
1927
|
+
function uo() {
|
|
1928
|
+
P.existsSync(Je) || P.mkdirSync(Je, { recursive: !0, mode: 448 });
|
|
1817
1929
|
}
|
|
1818
|
-
function
|
|
1930
|
+
function ht() {
|
|
1819
1931
|
try {
|
|
1820
|
-
if (!P.existsSync(
|
|
1932
|
+
if (!P.existsSync(ze))
|
|
1821
1933
|
return {};
|
|
1822
|
-
const o = P.readFileSync(
|
|
1934
|
+
const o = P.readFileSync(ze, "utf8");
|
|
1823
1935
|
return JSON.parse(o);
|
|
1824
1936
|
} catch {
|
|
1825
1937
|
return {};
|
|
1826
1938
|
}
|
|
1827
1939
|
}
|
|
1828
|
-
function
|
|
1829
|
-
|
|
1830
|
-
const e = { ...
|
|
1831
|
-
P.writeFileSync(
|
|
1940
|
+
function fo(o) {
|
|
1941
|
+
uo();
|
|
1942
|
+
const e = { ...ht(), ...o };
|
|
1943
|
+
P.writeFileSync(ze, JSON.stringify(e, null, 2), {
|
|
1832
1944
|
mode: 384
|
|
1833
1945
|
});
|
|
1834
1946
|
}
|
|
1835
|
-
function
|
|
1836
|
-
return
|
|
1947
|
+
function go() {
|
|
1948
|
+
return ht().defaultOrganization || null;
|
|
1837
1949
|
}
|
|
1838
|
-
function
|
|
1839
|
-
|
|
1950
|
+
function Le({ id: o, name: t }) {
|
|
1951
|
+
fo({ defaultOrganization: { id: o, name: t } });
|
|
1840
1952
|
}
|
|
1841
|
-
async function
|
|
1842
|
-
var
|
|
1953
|
+
async function ho(o, t, e, n = {}) {
|
|
1954
|
+
var p, m, l;
|
|
1843
1955
|
const s = await fetch(`${o}/mcp`, {
|
|
1844
1956
|
method: "POST",
|
|
1845
1957
|
headers: {
|
|
@@ -1861,12 +1973,12 @@ async function lo(o, t, e, n = {}) {
|
|
|
1861
1973
|
const i = await s.json();
|
|
1862
1974
|
if (i.error)
|
|
1863
1975
|
throw new Error(i.error.message || "MCP error");
|
|
1864
|
-
const
|
|
1865
|
-
if (!
|
|
1976
|
+
const r = (l = (m = (p = i.result) == null ? void 0 : p.content) == null ? void 0 : m[0]) == null ? void 0 : l.text;
|
|
1977
|
+
if (!r)
|
|
1866
1978
|
throw new Error(`No content returned from ${e}`);
|
|
1867
|
-
return JSON.parse(
|
|
1979
|
+
return JSON.parse(r);
|
|
1868
1980
|
}
|
|
1869
|
-
const
|
|
1981
|
+
const yo = (o) => new Promise((t) => setTimeout(t, o));
|
|
1870
1982
|
function re(o) {
|
|
1871
1983
|
var e, n;
|
|
1872
1984
|
const t = (o == null ? void 0 : o.message) || "";
|
|
@@ -1877,57 +1989,57 @@ function ae(o) {
|
|
|
1877
1989
|
This usually happens in sandboxed environments (Claude Web, containers)`), console.error(` where outbound HTTP is restricted.
|
|
1878
1990
|
`), 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
1991
|
}
|
|
1880
|
-
const
|
|
1992
|
+
const wo = () => {
|
|
1881
1993
|
let o = new URL(import.meta.url).pathname;
|
|
1882
1994
|
process.platform === "win32" && o.startsWith("/") && (o = o.slice(1));
|
|
1883
|
-
const t =
|
|
1884
|
-
return
|
|
1885
|
-
},
|
|
1995
|
+
const t = R.dirname(o);
|
|
1996
|
+
return R.join(t, "skills");
|
|
1997
|
+
}, vo = (o) => {
|
|
1886
1998
|
try {
|
|
1887
|
-
const t =
|
|
1999
|
+
const t = R.join(o, "package.json");
|
|
1888
2000
|
if (!P.existsSync(t)) return [];
|
|
1889
2001
|
const e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
1890
2002
|
return Object.keys({ ...e.dependencies, ...e.devDependencies });
|
|
1891
2003
|
} catch {
|
|
1892
2004
|
return [];
|
|
1893
2005
|
}
|
|
1894
|
-
},
|
|
1895
|
-
const t =
|
|
2006
|
+
}, Qe = async (o) => {
|
|
2007
|
+
const t = wo();
|
|
1896
2008
|
if (!P.existsSync(t))
|
|
1897
2009
|
return console.info("Skills source directory not found, skipping skills installation"), { success: !1 };
|
|
1898
2010
|
try {
|
|
1899
|
-
const e =
|
|
2011
|
+
const e = vo(o), n = ["myop-cli", "myop-component"], s = [
|
|
1900
2012
|
{ deps: ["@myop/react", "react"], skill: "myop-react-host" },
|
|
1901
2013
|
{ deps: ["@myop/vue", "vue"], skill: "myop-vue-host" },
|
|
1902
2014
|
{ deps: ["@myop/angular", "@angular/core"], skill: "myop-angular-host" },
|
|
1903
2015
|
{ deps: ["@myop/react-native", "react-native"], skill: "myop-react-native-host" }
|
|
1904
|
-
], i = s.filter(({ deps: l }) => l.some((
|
|
2016
|
+
], i = s.filter(({ deps: l }) => l.some((d) => e.includes(d))).map(({ skill: l }) => l), r = s.flatMap(({ deps: l }) => l.filter((d) => e.includes(d)));
|
|
1905
2017
|
i.length > 0 ? n.push(...i) : n.push(...s.map((l) => l.skill));
|
|
1906
|
-
const
|
|
1907
|
-
return Q(
|
|
2018
|
+
const p = n.map((l) => `--skill ${l}`).join(" "), m = `npx -y skills add "${t}" ${p} --agent '*' --copy -y`;
|
|
2019
|
+
return Q(m, { cwd: o, stdio: "pipe" }), { success: !0, detected: r, skillNames: n };
|
|
1908
2020
|
} catch (e) {
|
|
1909
2021
|
return console.info("Failed to install skills:", e.message), { success: !1 };
|
|
1910
2022
|
}
|
|
1911
|
-
},
|
|
2023
|
+
}, Ze = (o = ".", t = 3, e = 0) => {
|
|
1912
2024
|
const n = [];
|
|
1913
2025
|
if (e > t) return n;
|
|
1914
2026
|
try {
|
|
1915
2027
|
const s = P.readdirSync(o, { withFileTypes: !0 });
|
|
1916
2028
|
for (const i of s) {
|
|
1917
|
-
const
|
|
2029
|
+
const r = R.join(o, i.name);
|
|
1918
2030
|
if (i.isDirectory()) {
|
|
1919
2031
|
if (i.name === "node_modules" || i.name === ".git" || i.name === "dist" || i.name.startsWith("."))
|
|
1920
2032
|
continue;
|
|
1921
|
-
n.push(...
|
|
2033
|
+
n.push(...Ze(r, t, e + 1));
|
|
1922
2034
|
} else if (i.name === "myop.config.json")
|
|
1923
2035
|
try {
|
|
1924
|
-
const
|
|
2036
|
+
const p = P.readFileSync(r, "utf-8"), m = JSON.parse(p);
|
|
1925
2037
|
n.push({
|
|
1926
2038
|
path: o,
|
|
1927
|
-
configPath:
|
|
1928
|
-
name:
|
|
1929
|
-
componentId:
|
|
1930
|
-
config:
|
|
2039
|
+
configPath: r,
|
|
2040
|
+
name: m.name || m.componentName || R.basename(o),
|
|
2041
|
+
componentId: m.componentId || null,
|
|
2042
|
+
config: m
|
|
1931
2043
|
});
|
|
1932
2044
|
} catch {
|
|
1933
2045
|
}
|
|
@@ -1937,7 +2049,7 @@ const po = () => {
|
|
|
1937
2049
|
return n;
|
|
1938
2050
|
};
|
|
1939
2051
|
v.executionPath = process.cwd();
|
|
1940
|
-
const
|
|
2052
|
+
const Ee = (o = !1) => {
|
|
1941
2053
|
const t = v.program.getOptionValue("verbose");
|
|
1942
2054
|
t || (console.info = () => {
|
|
1943
2055
|
}), console.info("π verbose mode on"), v.options = {
|
|
@@ -1945,7 +2057,7 @@ const Me = (o = !1) => {
|
|
|
1945
2057
|
verbose: t
|
|
1946
2058
|
};
|
|
1947
2059
|
try {
|
|
1948
|
-
return v.myopConfig =
|
|
2060
|
+
return v.myopConfig = Rt(v.options.configPath), { configFound: !0 };
|
|
1949
2061
|
} catch (e) {
|
|
1950
2062
|
if (o) {
|
|
1951
2063
|
console.info(`
|
|
@@ -1955,7 +2067,7 @@ const Me = (o = !1) => {
|
|
|
1955
2067
|
author: "@myop-cli",
|
|
1956
2068
|
flows: []
|
|
1957
2069
|
};
|
|
1958
|
-
return
|
|
2070
|
+
return Ve(v.options.configPath, n), v.myopConfig = n, { configFound: !0 };
|
|
1959
2071
|
} catch {
|
|
1960
2072
|
return console.info("Error details :", e), { configFound: !1, error: e };
|
|
1961
2073
|
}
|
|
@@ -1964,39 +2076,39 @@ const Me = (o = !1) => {
|
|
|
1964
2076
|
}
|
|
1965
2077
|
};
|
|
1966
2078
|
[
|
|
1967
|
-
new
|
|
1968
|
-
...
|
|
2079
|
+
new Ue(),
|
|
2080
|
+
...Dt
|
|
1969
2081
|
];
|
|
1970
|
-
const
|
|
1971
|
-
v.program = new
|
|
1972
|
-
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(
|
|
1973
|
-
v.program.addOption(new
|
|
1974
|
-
v.program.addOption(new
|
|
1975
|
-
v.program.addOption(new
|
|
1976
|
-
v.program.addOption(new
|
|
1977
|
-
v.program.addOption(new
|
|
2082
|
+
const So = "0.1.55";
|
|
2083
|
+
v.program = new Pt();
|
|
2084
|
+
v.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(So);
|
|
2085
|
+
v.program.addOption(new fe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
2086
|
+
v.program.addOption(new fe("-h, --help", "Show helpful information"));
|
|
2087
|
+
v.program.addOption(new fe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
|
|
2088
|
+
v.program.addOption(new fe("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
|
|
2089
|
+
v.program.addOption(new fe("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
|
|
1978
2090
|
v.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, t) => {
|
|
1979
|
-
|
|
2091
|
+
Ee(!0), console.info("adding ", o, t, v.options.configPath), o === "flow" && ct._action(t), process.exit();
|
|
1980
2092
|
});
|
|
1981
2093
|
v.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, t) => {
|
|
1982
|
-
|
|
2094
|
+
Ee(), console.info("removing ", o, t, v.options.configPath), o === "flow" && dt._action(t), process.exit();
|
|
1983
2095
|
});
|
|
1984
2096
|
v.program.command("install").description("Install Myop assets").action(async () => {
|
|
1985
|
-
|
|
2097
|
+
Ee(), await lt.action();
|
|
1986
2098
|
});
|
|
1987
2099
|
v.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1988
2100
|
try {
|
|
1989
|
-
await
|
|
2101
|
+
await me();
|
|
1990
2102
|
} catch (o) {
|
|
1991
2103
|
console.error("Login failed:", o.message), process.exit(1);
|
|
1992
2104
|
}
|
|
1993
2105
|
process.exit(0);
|
|
1994
2106
|
});
|
|
1995
2107
|
v.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1996
|
-
await
|
|
2108
|
+
await gt(), process.exit(0);
|
|
1997
2109
|
});
|
|
1998
2110
|
v.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1999
|
-
const o =
|
|
2111
|
+
const o = Pe();
|
|
2000
2112
|
o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
|
|
2001
2113
|
});
|
|
2002
2114
|
v.program.command("sync").description('[deprecated] Use "myop push" instead').option("--skip-build", "Skip the build step").action(async () => {
|
|
@@ -2011,85 +2123,85 @@ v.program.command("sync").description('[deprecated] Use "myop push" instead').op
|
|
|
2011
2123
|
process.exit(0);
|
|
2012
2124
|
});
|
|
2013
2125
|
v.program.command("push").description("Upload component to Myop platform").argument("[componentId]", "Component ID to push to (overrides myop.config.json)").action(async (o) => {
|
|
2014
|
-
var
|
|
2126
|
+
var x, $, g;
|
|
2015
2127
|
const t = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2016
2128
|
let e = {};
|
|
2017
2129
|
if (P.existsSync(t))
|
|
2018
2130
|
try {
|
|
2019
2131
|
e = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
2020
|
-
} catch (
|
|
2021
|
-
console.error(`β οΈ Failed to parse ${t}:`,
|
|
2132
|
+
} catch (u) {
|
|
2133
|
+
console.error(`β οΈ Failed to parse ${t}:`, u.message);
|
|
2022
2134
|
}
|
|
2023
2135
|
o && (e.componentId = o);
|
|
2024
|
-
const n = e.name || e.componentName ||
|
|
2136
|
+
const n = e.name || e.componentName || R.basename(process.cwd());
|
|
2025
2137
|
console.log(`
|
|
2026
2138
|
π Component: ${n}`);
|
|
2027
2139
|
let s = null, i = !1;
|
|
2028
2140
|
try {
|
|
2029
|
-
const
|
|
2030
|
-
i = !!(
|
|
2141
|
+
const u = JSON.parse(P.readFileSync("package.json", "utf-8"));
|
|
2142
|
+
i = !!(u.scripts && u.scripts.build);
|
|
2031
2143
|
} catch {
|
|
2032
2144
|
}
|
|
2033
2145
|
if (!i) {
|
|
2034
|
-
const
|
|
2146
|
+
const u = P.readdirSync(".").filter(
|
|
2035
2147
|
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2036
2148
|
);
|
|
2037
|
-
|
|
2149
|
+
u.length === 1 && (s = u[0]);
|
|
2038
2150
|
}
|
|
2039
2151
|
if (s)
|
|
2040
2152
|
console.log(` Single file: ${s} (skipping build)`);
|
|
2041
2153
|
else if (i) {
|
|
2042
|
-
const { exec:
|
|
2154
|
+
const { exec: u } = await import("child_process");
|
|
2043
2155
|
let E = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
2044
|
-
const
|
|
2045
|
-
const
|
|
2046
|
-
|
|
2047
|
-
if (!
|
|
2048
|
-
|
|
2156
|
+
const O = (M = !1) => new Promise((j) => {
|
|
2157
|
+
const C = z(M ? "Retrying build..." : "Building project...").start();
|
|
2158
|
+
u("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (N, k, L) => {
|
|
2159
|
+
if (!N) {
|
|
2160
|
+
C.succeed("Build completed"), j(!0);
|
|
2049
2161
|
return;
|
|
2050
2162
|
}
|
|
2051
|
-
if (
|
|
2052
|
-
const
|
|
2053
|
-
if (E = { ...E, ...
|
|
2054
|
-
const
|
|
2055
|
-
j(
|
|
2163
|
+
if (C.fail("Build failed"), !E.hasTriedPlatformFix && !E.hasTriedInstall) {
|
|
2164
|
+
const D = await pt(N, k, L, u, E);
|
|
2165
|
+
if (E = { ...E, ...D }, D.handled) {
|
|
2166
|
+
const F = await O(!0);
|
|
2167
|
+
j(F);
|
|
2056
2168
|
return;
|
|
2057
2169
|
}
|
|
2058
2170
|
}
|
|
2059
|
-
console.error(
|
|
2171
|
+
console.error(N.message), j(!1);
|
|
2060
2172
|
});
|
|
2061
2173
|
});
|
|
2062
|
-
await
|
|
2174
|
+
await O() || process.exit(1);
|
|
2063
2175
|
}
|
|
2064
|
-
let
|
|
2176
|
+
let r;
|
|
2065
2177
|
if (s)
|
|
2066
|
-
|
|
2178
|
+
r = s;
|
|
2067
2179
|
else if (P.existsSync("./dist/index.html"))
|
|
2068
|
-
|
|
2180
|
+
r = "./dist/index.html";
|
|
2069
2181
|
else {
|
|
2070
|
-
const
|
|
2182
|
+
const u = P.readdirSync(".").filter(
|
|
2071
2183
|
(E) => E.endsWith(".html") && !E.startsWith(".") && P.statSync(E).isFile()
|
|
2072
2184
|
);
|
|
2073
|
-
|
|
2185
|
+
u.length === 1 ? r = u[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));
|
|
2074
2186
|
}
|
|
2075
|
-
const
|
|
2076
|
-
console.log(` File: ${
|
|
2077
|
-
let
|
|
2187
|
+
const p = P.readFileSync(r, "utf-8");
|
|
2188
|
+
console.log(` File: ${r} (${(p.length / 1024).toFixed(1)} KB)`);
|
|
2189
|
+
let m;
|
|
2078
2190
|
try {
|
|
2079
|
-
|
|
2080
|
-
} catch (
|
|
2081
|
-
re(
|
|
2191
|
+
m = await Ke();
|
|
2192
|
+
} catch (u) {
|
|
2193
|
+
re(u) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("push")) : (console.error("β Authentication failed:", u.message), console.error(`
|
|
2082
2194
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2083
2195
|
`)), process.exit(1);
|
|
2084
2196
|
}
|
|
2085
|
-
const l =
|
|
2086
|
-
let
|
|
2197
|
+
const l = Me();
|
|
2198
|
+
let d = z("Uploading...").start(), w;
|
|
2087
2199
|
try {
|
|
2088
|
-
const
|
|
2200
|
+
const u = await fetch(`${l}/mcp`, {
|
|
2089
2201
|
method: "POST",
|
|
2090
2202
|
headers: {
|
|
2091
2203
|
"Content-Type": "application/json",
|
|
2092
|
-
Authorization: `Bearer ${
|
|
2204
|
+
Authorization: `Bearer ${m.accessToken}`
|
|
2093
2205
|
},
|
|
2094
2206
|
body: JSON.stringify({
|
|
2095
2207
|
jsonrpc: "2.0",
|
|
@@ -2101,37 +2213,37 @@ v.program.command("push").description("Upload component to Myop platform").argum
|
|
|
2101
2213
|
name: n,
|
|
2102
2214
|
componentId: e.componentId && e.componentId !== "DEV" ? e.componentId : void 0,
|
|
2103
2215
|
organization: e.organization || void 0,
|
|
2104
|
-
htmlContent:
|
|
2216
|
+
htmlContent: p
|
|
2105
2217
|
}
|
|
2106
2218
|
}
|
|
2107
2219
|
})
|
|
2108
2220
|
});
|
|
2109
|
-
if (!
|
|
2110
|
-
throw new Error(`Server returned ${
|
|
2111
|
-
const E = await
|
|
2221
|
+
if (!u.ok)
|
|
2222
|
+
throw new Error(`Server returned ${u.status}`);
|
|
2223
|
+
const E = await u.json();
|
|
2112
2224
|
if (E.error)
|
|
2113
2225
|
throw new Error(E.error.message);
|
|
2114
|
-
const
|
|
2115
|
-
if (
|
|
2116
|
-
throw new Error(
|
|
2117
|
-
|
|
2118
|
-
} catch (
|
|
2119
|
-
|
|
2120
|
-
}
|
|
2121
|
-
if (
|
|
2122
|
-
e.componentId =
|
|
2226
|
+
const O = (g = ($ = (x = E.result) == null ? void 0 : x.content) == null ? void 0 : $[0]) == null ? void 0 : g.text;
|
|
2227
|
+
if (w = JSON.parse(O), !w.success)
|
|
2228
|
+
throw new Error(w.error);
|
|
2229
|
+
d.succeed("Pushed successfully");
|
|
2230
|
+
} catch (u) {
|
|
2231
|
+
d.fail("Upload failed"), re(u) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("push")) : console.error(" ", u.message), process.exit(1);
|
|
2232
|
+
}
|
|
2233
|
+
if (w.isNewComponent || !e.componentId || e.componentId === "DEV") {
|
|
2234
|
+
e.componentId = w.componentId, e.organization = w.orgId, e.name || (e.name = w.componentName);
|
|
2123
2235
|
try {
|
|
2124
2236
|
P.writeFileSync(t, JSON.stringify(e, null, 2));
|
|
2125
|
-
} catch (
|
|
2126
|
-
console.log(`β οΈ Could not update ${t}: ${
|
|
2237
|
+
} catch (u) {
|
|
2238
|
+
console.log(`β οΈ Could not update ${t}: ${u.message}`), console.log(` Add componentId: "${w.componentId}" manually`);
|
|
2127
2239
|
}
|
|
2128
2240
|
}
|
|
2129
2241
|
console.log(`
|
|
2130
|
-
${
|
|
2242
|
+
${w.componentName}`), console.log(` ${w.dashboardUrl}
|
|
2131
2243
|
`), process.exit(0);
|
|
2132
2244
|
});
|
|
2133
2245
|
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
|
|
2246
|
+
var u, E, O;
|
|
2135
2247
|
const e = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2136
2248
|
let n = {};
|
|
2137
2249
|
if (P.existsSync(e))
|
|
@@ -2144,22 +2256,22 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2144
2256
|
const i = n.name || n.componentName || s;
|
|
2145
2257
|
console.log(`
|
|
2146
2258
|
π₯ Pulling: ${i}`), console.log(` ID: ${s}`), t.env && console.log(` Environment: ${t.env}`);
|
|
2147
|
-
let
|
|
2259
|
+
let r;
|
|
2148
2260
|
try {
|
|
2149
|
-
|
|
2150
|
-
} catch (
|
|
2151
|
-
re(
|
|
2261
|
+
r = await Ke();
|
|
2262
|
+
} catch (b) {
|
|
2263
|
+
re(b) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("pull")) : (console.error("β Authentication failed:", b.message), console.error(`
|
|
2152
2264
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2153
2265
|
`)), process.exit(1);
|
|
2154
2266
|
}
|
|
2155
|
-
const
|
|
2267
|
+
const p = Me(), m = z("Fetching component...").start();
|
|
2156
2268
|
let l;
|
|
2157
2269
|
try {
|
|
2158
|
-
const
|
|
2270
|
+
const b = await fetch(`${p}/mcp`, {
|
|
2159
2271
|
method: "POST",
|
|
2160
2272
|
headers: {
|
|
2161
2273
|
"Content-Type": "application/json",
|
|
2162
|
-
Authorization: `Bearer ${
|
|
2274
|
+
Authorization: `Bearer ${r.accessToken}`
|
|
2163
2275
|
},
|
|
2164
2276
|
body: JSON.stringify({
|
|
2165
2277
|
jsonrpc: "2.0",
|
|
@@ -2171,33 +2283,33 @@ v.program.command("pull").description("Download component HTML from Myop platfor
|
|
|
2171
2283
|
}
|
|
2172
2284
|
})
|
|
2173
2285
|
});
|
|
2174
|
-
if (
|
|
2175
|
-
throw new Error(`Server returned ${
|
|
2176
|
-
const
|
|
2177
|
-
if (
|
|
2178
|
-
throw new Error(
|
|
2179
|
-
const j = (
|
|
2180
|
-
l = JSON.parse(j), !l.success && !l.html && (
|
|
2181
|
-
} catch (
|
|
2182
|
-
|
|
2183
|
-
}
|
|
2184
|
-
let
|
|
2185
|
-
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2188
|
-
const
|
|
2189
|
-
let
|
|
2190
|
-
if (
|
|
2191
|
-
name: l.name ||
|
|
2286
|
+
if (!b.ok)
|
|
2287
|
+
throw new Error(`Server returned ${b.status}`);
|
|
2288
|
+
const M = await b.json();
|
|
2289
|
+
if (M.error)
|
|
2290
|
+
throw new Error(M.error.message);
|
|
2291
|
+
const j = (O = (E = (u = M.result) == null ? void 0 : u.content) == null ? void 0 : E[0]) == null ? void 0 : O.text;
|
|
2292
|
+
l = JSON.parse(j), !l.success && !l.html && (m.fail("Failed to fetch component"), console.error(" ", l.error || "No HTML content returned"), l.message && console.error(" ", l.message), process.exit(1)), m.succeed("Component fetched");
|
|
2293
|
+
} catch (b) {
|
|
2294
|
+
m.fail("Failed to fetch component"), re(b) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("pull")) : console.error(" ", b.message), process.exit(1);
|
|
2295
|
+
}
|
|
2296
|
+
let d = t.output;
|
|
2297
|
+
d || (P.existsSync("./dist/index.html") ? d = "./dist/index.html" : d = "./index.html");
|
|
2298
|
+
const w = l.htmlContent || l.html, x = R.dirname(d);
|
|
2299
|
+
x && !P.existsSync(x) && P.mkdirSync(x, { recursive: !0 }), P.writeFileSync(d, w), console.log(` Saved to: ${d} (${(w.length / 1024).toFixed(1)} KB)`);
|
|
2300
|
+
const $ = P.existsSync(e);
|
|
2301
|
+
let g = !1;
|
|
2302
|
+
if ($ ? ((!n.componentId || n.componentId === "DEV") && (n.componentId = s, g = !0), !n.name && l.name && (n.name = l.name, g = !0)) : (n = {
|
|
2303
|
+
name: l.name || R.basename(process.cwd()),
|
|
2192
2304
|
componentId: s,
|
|
2193
2305
|
type: "html",
|
|
2194
2306
|
author: "@myop-cli",
|
|
2195
2307
|
HMR: !0
|
|
2196
|
-
},
|
|
2308
|
+
}, g = !0), g)
|
|
2197
2309
|
try {
|
|
2198
|
-
P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${
|
|
2199
|
-
} catch (
|
|
2200
|
-
console.log(` β οΈ Could not write ${e}: ${
|
|
2310
|
+
P.writeFileSync(e, JSON.stringify(n, null, 2)), console.log(` ${$ ? "Updated" : "Created"} ${e}`);
|
|
2311
|
+
} catch (b) {
|
|
2312
|
+
console.log(` β οΈ Could not write ${e}: ${b.message}`);
|
|
2201
2313
|
}
|
|
2202
2314
|
console.log(`
|
|
2203
2315
|
β
Pull completed!
|
|
@@ -2207,189 +2319,189 @@ v.program.command("list").description("Browse and pull/push remote components").
|
|
|
2207
2319
|
const { search: t, select: e } = await import("@inquirer/prompts");
|
|
2208
2320
|
let n;
|
|
2209
2321
|
try {
|
|
2210
|
-
n = await
|
|
2211
|
-
} catch (
|
|
2212
|
-
re(
|
|
2322
|
+
n = await Ke();
|
|
2323
|
+
} catch (g) {
|
|
2324
|
+
re(g) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("list")) : (console.error("β Authentication failed:", g.message), console.error(`
|
|
2213
2325
|
[MYOP_AUTH_REQUIRED] Run 'myop login' to authenticate,`), console.error(` or use the setup_cli_auth MCP tool to set up credentials automatically.
|
|
2214
2326
|
`)), process.exit(1);
|
|
2215
2327
|
}
|
|
2216
|
-
const s =
|
|
2217
|
-
let
|
|
2328
|
+
const s = Me(), i = (g, u) => ho(s, n.accessToken, g, u);
|
|
2329
|
+
let r = z("Loading organizations...").start(), p;
|
|
2218
2330
|
try {
|
|
2219
|
-
const
|
|
2220
|
-
if (
|
|
2331
|
+
const g = await i("list_organizations");
|
|
2332
|
+
if (p = g.organizations || g, !Array.isArray(p))
|
|
2221
2333
|
throw new Error("Unexpected response from list_organizations");
|
|
2222
|
-
} catch (
|
|
2223
|
-
|
|
2334
|
+
} catch (g) {
|
|
2335
|
+
r.fail("Failed to load organizations"), re(g) ? (console.error("β Network error: Unable to reach mcp.myop.dev"), ae("list")) : console.error(" ", g.message), process.exit(1);
|
|
2224
2336
|
}
|
|
2225
|
-
|
|
2226
|
-
let
|
|
2337
|
+
p.length === 0 && (r.fail("No organizations found for this account"), process.exit(1)), r.stop();
|
|
2338
|
+
let m, l;
|
|
2227
2339
|
if (o.org) {
|
|
2228
|
-
const
|
|
2229
|
-
|
|
2340
|
+
const g = p.find((u) => u.id === o.org || u._id === o.org);
|
|
2341
|
+
g || (console.error(`Organization "${o.org}" not found. Available:`), p.forEach((u) => console.log(` ${u.id || u._id} ${u.name}`)), process.exit(1)), m = g.id || g._id, l = g.name, Le({ id: m, name: l });
|
|
2230
2342
|
} else {
|
|
2231
|
-
const
|
|
2232
|
-
if (
|
|
2233
|
-
|
|
2234
|
-
else if (
|
|
2235
|
-
|
|
2343
|
+
const g = go();
|
|
2344
|
+
if (g && p.find((u) => (u.id || u._id) === g.id))
|
|
2345
|
+
m = g.id, l = g.name;
|
|
2346
|
+
else if (p.length === 1)
|
|
2347
|
+
m = p[0].id || p[0]._id, l = p[0].name, Le({ id: m, name: l });
|
|
2236
2348
|
else
|
|
2237
2349
|
try {
|
|
2238
|
-
const
|
|
2350
|
+
const u = await e({
|
|
2239
2351
|
message: "Select an organization:",
|
|
2240
|
-
choices:
|
|
2352
|
+
choices: p.map((E) => ({
|
|
2241
2353
|
name: E.name,
|
|
2242
2354
|
value: { id: E.id || E._id, name: E.name }
|
|
2243
2355
|
}))
|
|
2244
2356
|
});
|
|
2245
|
-
|
|
2246
|
-
} catch (
|
|
2247
|
-
throw
|
|
2357
|
+
m = u.id, l = u.name, Le({ id: m, name: l });
|
|
2358
|
+
} catch (u) {
|
|
2359
|
+
throw u.name === "ExitPromptError" && (console.log(`
|
|
2248
2360
|
|
|
2249
2361
|
π Goodbye!
|
|
2250
|
-
`), process.exit(0)),
|
|
2362
|
+
`), process.exit(0)), u;
|
|
2251
2363
|
}
|
|
2252
2364
|
}
|
|
2253
|
-
console.log(` Using organization: ${l}`),
|
|
2254
|
-
let
|
|
2365
|
+
console.log(` Using organization: ${l}`), r = z("Loading components...").start();
|
|
2366
|
+
let d;
|
|
2255
2367
|
try {
|
|
2256
|
-
const
|
|
2257
|
-
if (
|
|
2368
|
+
const g = await i("list_components", { organizationId: m });
|
|
2369
|
+
if (d = g.components || g, !Array.isArray(d))
|
|
2258
2370
|
throw new Error("Unexpected response from list_components");
|
|
2259
|
-
} catch (
|
|
2260
|
-
|
|
2371
|
+
} catch (g) {
|
|
2372
|
+
r.fail("Failed to load components"), console.error(" ", g.message), process.exit(1);
|
|
2261
2373
|
}
|
|
2262
|
-
|
|
2263
|
-
`), process.exit(0)), console.log(` ${l} - ${
|
|
2374
|
+
r.stop(), d.length === 0 && (console.log(` No components found in this organization.
|
|
2375
|
+
`), process.exit(0)), console.log(` ${l} - ${d.length} component(s)
|
|
2264
2376
|
`);
|
|
2265
|
-
const
|
|
2377
|
+
const w = [];
|
|
2266
2378
|
for (; ; ) {
|
|
2267
|
-
const
|
|
2268
|
-
let
|
|
2379
|
+
const g = `[Done - pull/push ${w.length} selected]`, u = "__done__", E = new Set(w.map((M) => M.id || M._id || M.componentId));
|
|
2380
|
+
let O;
|
|
2269
2381
|
try {
|
|
2270
|
-
|
|
2382
|
+
O = await t({
|
|
2271
2383
|
message: "Search & select components:",
|
|
2272
|
-
source: (
|
|
2273
|
-
const j = (
|
|
2384
|
+
source: (M) => {
|
|
2385
|
+
const j = (M || "").toLowerCase(), C = d.filter((k) => {
|
|
2274
2386
|
const L = k.id || k._id || k.componentId;
|
|
2275
2387
|
return E.has(L) ? !1 : j ? (k.name || "").toLowerCase().includes(j) : !0;
|
|
2276
|
-
}),
|
|
2277
|
-
{ name:
|
|
2388
|
+
}), N = [
|
|
2389
|
+
{ name: g, value: u }
|
|
2278
2390
|
];
|
|
2279
|
-
for (const k of
|
|
2280
|
-
const L = k.id || k._id || k.componentId,
|
|
2281
|
-
|
|
2282
|
-
name: `${k.name} (${
|
|
2391
|
+
for (const k of C) {
|
|
2392
|
+
const L = k.id || k._id || k.componentId, D = L ? L.substring(0, 8) + "..." : "";
|
|
2393
|
+
N.push({
|
|
2394
|
+
name: `${k.name} (${D})`,
|
|
2283
2395
|
value: L
|
|
2284
2396
|
});
|
|
2285
2397
|
}
|
|
2286
|
-
return
|
|
2398
|
+
return N;
|
|
2287
2399
|
}
|
|
2288
2400
|
});
|
|
2289
|
-
} catch (
|
|
2290
|
-
throw
|
|
2401
|
+
} catch (M) {
|
|
2402
|
+
throw M.name === "ExitPromptError" && (console.log(`
|
|
2291
2403
|
|
|
2292
2404
|
π Goodbye!
|
|
2293
|
-
`), process.exit(0)),
|
|
2405
|
+
`), process.exit(0)), M;
|
|
2294
2406
|
}
|
|
2295
|
-
if (
|
|
2407
|
+
if (O === u)
|
|
2296
2408
|
break;
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2409
|
+
const b = d.find((M) => (M.id || M._id || M.componentId) === O);
|
|
2410
|
+
b && (w.push(b), console.log(` + ${b.name}`));
|
|
2299
2411
|
}
|
|
2300
|
-
|
|
2412
|
+
w.length === 0 && (console.log(` No components selected.
|
|
2301
2413
|
`), process.exit(0));
|
|
2302
|
-
let
|
|
2414
|
+
let x;
|
|
2303
2415
|
try {
|
|
2304
|
-
|
|
2305
|
-
message: `${
|
|
2416
|
+
x = await e({
|
|
2417
|
+
message: `${w.length} component(s) selected:`,
|
|
2306
2418
|
choices: [
|
|
2307
2419
|
{ name: "Pull selected", value: "pull" },
|
|
2308
2420
|
{ name: "Push selected", value: "push" },
|
|
2309
2421
|
{ name: "Cancel", value: "cancel" }
|
|
2310
2422
|
]
|
|
2311
2423
|
});
|
|
2312
|
-
} catch (
|
|
2313
|
-
throw
|
|
2424
|
+
} catch (g) {
|
|
2425
|
+
throw g.name === "ExitPromptError" && (console.log(`
|
|
2314
2426
|
|
|
2315
2427
|
π Goodbye!
|
|
2316
|
-
`), process.exit(0)),
|
|
2428
|
+
`), process.exit(0)), g;
|
|
2317
2429
|
}
|
|
2318
|
-
|
|
2430
|
+
x === "cancel" && (console.log(` Cancelled.
|
|
2319
2431
|
`), process.exit(0));
|
|
2320
|
-
const
|
|
2321
|
-
if (
|
|
2432
|
+
const $ = (g) => g.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
2433
|
+
if (x === "pull") {
|
|
2322
2434
|
console.log(`
|
|
2323
|
-
Pulling ${
|
|
2435
|
+
Pulling ${w.length} components...
|
|
2324
2436
|
`);
|
|
2325
|
-
const
|
|
2326
|
-
const
|
|
2437
|
+
const g = await Promise.all(w.map(async (O) => {
|
|
2438
|
+
const b = O.id || O._id || O.componentId;
|
|
2327
2439
|
try {
|
|
2328
|
-
const
|
|
2440
|
+
const M = await i("get_component", { componentId: b }), j = $(O.name);
|
|
2329
2441
|
P.mkdirSync(j, { recursive: !0 });
|
|
2330
|
-
const
|
|
2331
|
-
if (!
|
|
2442
|
+
const C = M.htmlContent || M.html;
|
|
2443
|
+
if (!C)
|
|
2332
2444
|
throw new Error("No HTML content returned");
|
|
2333
|
-
return P.writeFileSync(
|
|
2334
|
-
name:
|
|
2335
|
-
componentId:
|
|
2336
|
-
organization:
|
|
2445
|
+
return P.writeFileSync(R.join(j, "index.html"), C), P.writeFileSync(R.join(j, "myop.config.json"), JSON.stringify({
|
|
2446
|
+
name: O.name,
|
|
2447
|
+
componentId: b,
|
|
2448
|
+
organization: m,
|
|
2337
2449
|
type: "html",
|
|
2338
2450
|
author: "@myop-cli",
|
|
2339
2451
|
HMR: !0
|
|
2340
|
-
}, null, 2)), { name:
|
|
2341
|
-
} catch (
|
|
2342
|
-
return { name:
|
|
2452
|
+
}, null, 2)), { name: O.name, status: "ok", dir: j };
|
|
2453
|
+
} catch (M) {
|
|
2454
|
+
return { name: O.name, status: "failed", error: M.message };
|
|
2343
2455
|
}
|
|
2344
2456
|
}));
|
|
2345
|
-
let
|
|
2346
|
-
for (const
|
|
2347
|
-
|
|
2457
|
+
let u = 0, E = 0;
|
|
2458
|
+
for (const O of g)
|
|
2459
|
+
O.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${O.name} -> ./${O.dir}/`), u++) : (console.log(` \x1B[31mβ\x1B[0m ${O.name} - ${O.error}`), E++);
|
|
2348
2460
|
console.log(`
|
|
2349
|
-
Done! Pulled ${
|
|
2461
|
+
Done! Pulled ${u} component${u !== 1 ? "s" : ""}.${E ? ` ${E} failed.` : ""}
|
|
2350
2462
|
`);
|
|
2351
|
-
} else if (
|
|
2463
|
+
} else if (x === "push") {
|
|
2352
2464
|
console.log(`
|
|
2353
|
-
Pushing ${
|
|
2465
|
+
Pushing ${w.length} components...
|
|
2354
2466
|
`);
|
|
2355
|
-
const
|
|
2356
|
-
const j =
|
|
2357
|
-
if (!
|
|
2358
|
-
return { name:
|
|
2467
|
+
const g = Ze(".", 3), u = await Promise.all(w.map(async (M) => {
|
|
2468
|
+
const j = M.id || M._id || M.componentId, C = g.find((N) => N.componentId === j);
|
|
2469
|
+
if (!C)
|
|
2470
|
+
return { name: M.name, status: "skipped", reason: "no local match" };
|
|
2359
2471
|
try {
|
|
2360
|
-
let
|
|
2361
|
-
const k =
|
|
2362
|
-
if (P.existsSync(
|
|
2363
|
-
|
|
2472
|
+
let N;
|
|
2473
|
+
const k = C.path;
|
|
2474
|
+
if (P.existsSync(R.join(k, "dist", "index.html")))
|
|
2475
|
+
N = R.join(k, "dist", "index.html");
|
|
2364
2476
|
else {
|
|
2365
|
-
const
|
|
2366
|
-
(
|
|
2477
|
+
const W = P.readdirSync(k).filter(
|
|
2478
|
+
(_) => _.endsWith(".html") && !_.startsWith(".") && P.statSync(R.join(k, _)).isFile()
|
|
2367
2479
|
);
|
|
2368
|
-
if (
|
|
2369
|
-
|
|
2370
|
-
else if (
|
|
2371
|
-
|
|
2480
|
+
if (W.length === 1)
|
|
2481
|
+
N = R.join(k, W[0]);
|
|
2482
|
+
else if (W.includes("index.html"))
|
|
2483
|
+
N = R.join(k, "index.html");
|
|
2372
2484
|
else
|
|
2373
2485
|
throw new Error("No HTML file found");
|
|
2374
2486
|
}
|
|
2375
|
-
const L = P.readFileSync(
|
|
2376
|
-
name:
|
|
2487
|
+
const L = P.readFileSync(N, "utf-8"), D = C.name || M.name, F = await i("upload_component", {
|
|
2488
|
+
name: D,
|
|
2377
2489
|
componentId: j,
|
|
2378
|
-
organization:
|
|
2490
|
+
organization: m,
|
|
2379
2491
|
htmlContent: L
|
|
2380
2492
|
});
|
|
2381
|
-
if (!
|
|
2382
|
-
throw new Error(
|
|
2383
|
-
return { name:
|
|
2384
|
-
} catch (
|
|
2385
|
-
return { name:
|
|
2493
|
+
if (!F.success)
|
|
2494
|
+
throw new Error(F.error || "Upload failed");
|
|
2495
|
+
return { name: D, status: "ok" };
|
|
2496
|
+
} catch (N) {
|
|
2497
|
+
return { name: M.name, status: "failed", error: N.message };
|
|
2386
2498
|
}
|
|
2387
2499
|
}));
|
|
2388
|
-
let E = 0,
|
|
2389
|
-
for (const
|
|
2390
|
-
|
|
2500
|
+
let E = 0, O = 0, b = 0;
|
|
2501
|
+
for (const M of u)
|
|
2502
|
+
M.status === "ok" ? (console.log(` \x1B[32mβ\x1B[0m ${M.name}`), E++) : M.status === "skipped" ? (console.log(` \x1B[33mβ\x1B[0m ${M.name} (${M.reason})`), O++) : (console.log(` \x1B[31mβ\x1B[0m ${M.name} - ${M.error}`), b++);
|
|
2391
2503
|
console.log(`
|
|
2392
|
-
Done! Pushed ${E}${
|
|
2504
|
+
Done! Pushed ${E}${O ? `, skipped ${O}` : ""}${b ? `, ${b} failed` : ""}.
|
|
2393
2505
|
`);
|
|
2394
2506
|
}
|
|
2395
2507
|
process.exit(0);
|
|
@@ -2402,11 +2514,11 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2402
2514
|
message: "Component name:",
|
|
2403
2515
|
default: n
|
|
2404
2516
|
});
|
|
2405
|
-
} catch (
|
|
2406
|
-
throw
|
|
2517
|
+
} catch (m) {
|
|
2518
|
+
throw m.name === "ExitPromptError" && (console.log(`
|
|
2407
2519
|
|
|
2408
2520
|
π Goodbye!
|
|
2409
|
-
`), process.exit(0)),
|
|
2521
|
+
`), process.exit(0)), m;
|
|
2410
2522
|
}
|
|
2411
2523
|
(t.existsSync("index.html") || t.existsSync("myop.config.json")) && (console.log(`
|
|
2412
2524
|
β οΈ index.html or myop.config.json already exists in this directory.`), console.log(" Use `myop dev` to start the dev server for an existing component.\n"), process.exit(1));
|
|
@@ -2418,7 +2530,7 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2418
2530
|
HMR: !0
|
|
2419
2531
|
};
|
|
2420
2532
|
t.writeFileSync("myop.config.json", JSON.stringify(i, null, 2));
|
|
2421
|
-
const
|
|
2533
|
+
const r = `<!DOCTYPE html>
|
|
2422
2534
|
<html lang="en">
|
|
2423
2535
|
<head>
|
|
2424
2536
|
<meta charset="UTF-8">
|
|
@@ -2540,24 +2652,24 @@ v.program.command("create").description("Create a new Myop HTML component and st
|
|
|
2540
2652
|
<\/script>
|
|
2541
2653
|
</body>
|
|
2542
2654
|
</html>`;
|
|
2543
|
-
t.writeFileSync("index.html",
|
|
2544
|
-
const
|
|
2655
|
+
t.writeFileSync("index.html", r);
|
|
2656
|
+
const p = await Qe(process.cwd());
|
|
2545
2657
|
console.log(`
|
|
2546
|
-
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"),
|
|
2658
|
+
β
Created ${s}`), console.log(" index.html"), console.log(" myop.config.json"), p.success && console.log(" AI agent skills installed"), console.log(""), await Ce();
|
|
2547
2659
|
});
|
|
2548
|
-
v.program.command("dev").description("Start development server with file watching").action(
|
|
2549
|
-
const
|
|
2550
|
-
const o = process.cwd(), t =
|
|
2660
|
+
v.program.command("dev").description("Start development server with file watching").action(Ce);
|
|
2661
|
+
const yt = async () => {
|
|
2662
|
+
const o = process.cwd(), t = z("Installing AI agent skills...").start(), e = await Qe(o);
|
|
2551
2663
|
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);
|
|
2552
2664
|
};
|
|
2553
|
-
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(
|
|
2554
|
-
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(
|
|
2665
|
+
v.program.command("skill").description("Install or update AI agent skills in the current directory").action(yt);
|
|
2666
|
+
v.program.command("train").description("Install or update AI agent skills in the current directory (alias for skill)").action(yt);
|
|
2555
2667
|
v.program.command("mcp").description("Configure Myop MCP server for your AI coding assistant").action(async () => {
|
|
2556
|
-
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s =
|
|
2668
|
+
const { select: o, confirm: t } = await import("@inquirer/prompts"), n = (await import("os")).homedir(), s = Me() + "/mcp", i = [
|
|
2557
2669
|
{
|
|
2558
2670
|
name: "Claude Code",
|
|
2559
2671
|
value: "claude",
|
|
2560
|
-
configPath:
|
|
2672
|
+
configPath: R.join(n, ".claude.json"),
|
|
2561
2673
|
getEntry: () => ({ type: "http", url: s }),
|
|
2562
2674
|
nextSteps: [
|
|
2563
2675
|
"Restart Claude Code to pick up the new MCP config.",
|
|
@@ -2569,7 +2681,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2569
2681
|
{
|
|
2570
2682
|
name: "Cursor",
|
|
2571
2683
|
value: "cursor",
|
|
2572
|
-
configPath:
|
|
2684
|
+
configPath: R.join(n, ".cursor", "mcp.json"),
|
|
2573
2685
|
getEntry: () => ({ url: s }),
|
|
2574
2686
|
nextSteps: [
|
|
2575
2687
|
'Go to Cursor Settings > Tools & MCP to verify "myop" appears.',
|
|
@@ -2582,7 +2694,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2582
2694
|
{
|
|
2583
2695
|
name: "Windsurf",
|
|
2584
2696
|
value: "windsurf",
|
|
2585
|
-
configPath:
|
|
2697
|
+
configPath: R.join(n, ".codeium", "windsurf", "mcp_config.json"),
|
|
2586
2698
|
getEntry: () => ({ url: s }),
|
|
2587
2699
|
nextSteps: [
|
|
2588
2700
|
"Open Cascade and click the hammer icon (top-right) to see MCP servers.",
|
|
@@ -2594,7 +2706,7 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2594
2706
|
{
|
|
2595
2707
|
name: "VS Code (GitHub Copilot)",
|
|
2596
2708
|
value: "vscode",
|
|
2597
|
-
configPath: process.platform === "darwin" ?
|
|
2709
|
+
configPath: process.platform === "darwin" ? R.join(n, "Library", "Application Support", "Code", "User", "mcp.json") : process.platform === "win32" ? R.join(process.env.APPDATA || R.join(n, "AppData", "Roaming"), "Code", "User", "mcp.json") : R.join(n, ".config", "Code", "User", "mcp.json"),
|
|
2598
2710
|
getEntry: () => ({ type: "http", url: s }),
|
|
2599
2711
|
nextSteps: [
|
|
2600
2712
|
"Requires VS Code 1.99+ and GitHub Copilot extension.",
|
|
@@ -2609,33 +2721,33 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2609
2721
|
console.log(`
|
|
2610
2722
|
Configure Myop MCP server for your AI coding assistant.
|
|
2611
2723
|
`);
|
|
2612
|
-
let
|
|
2724
|
+
let r;
|
|
2613
2725
|
try {
|
|
2614
|
-
|
|
2726
|
+
r = await o({
|
|
2615
2727
|
message: "Select your AI coding assistant:",
|
|
2616
|
-
choices: i.map((
|
|
2728
|
+
choices: i.map((d) => ({ name: d.name, value: d.value }))
|
|
2617
2729
|
});
|
|
2618
|
-
} catch (
|
|
2619
|
-
throw
|
|
2730
|
+
} catch (d) {
|
|
2731
|
+
throw d.name === "ExitPromptError" && (console.log(`
|
|
2620
2732
|
|
|
2621
2733
|
π Goodbye!
|
|
2622
|
-
`), process.exit(0)),
|
|
2734
|
+
`), process.exit(0)), d;
|
|
2623
2735
|
}
|
|
2624
|
-
const
|
|
2625
|
-
let
|
|
2736
|
+
const p = i.find((d) => d.value === r);
|
|
2737
|
+
let m = {};
|
|
2626
2738
|
try {
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2739
|
+
const d = P.readFileSync(p.configPath, "utf-8");
|
|
2740
|
+
m = JSON.parse(d);
|
|
2629
2741
|
} catch {
|
|
2630
2742
|
}
|
|
2631
|
-
|
|
2632
|
-
const l =
|
|
2743
|
+
m.mcpServers || (m.mcpServers = {});
|
|
2744
|
+
const l = m.mcpServers.myop;
|
|
2633
2745
|
if (l && l.url === s) {
|
|
2634
2746
|
console.log(`
|
|
2635
|
-
Myop MCP is already configured for ${
|
|
2747
|
+
Myop MCP is already configured for ${p.name}.`), console.log(` Config: ${p.configPath}`), console.log(`
|
|
2636
2748
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2637
|
-
for (const
|
|
2638
|
-
console.log(` ${
|
|
2749
|
+
for (const d of p.nextSteps)
|
|
2750
|
+
console.log(` ${d}`);
|
|
2639
2751
|
console.log(""), process.exit(0);
|
|
2640
2752
|
}
|
|
2641
2753
|
if (l) {
|
|
@@ -2643,18 +2755,18 @@ v.program.command("mcp").description("Configure Myop MCP server for your AI codi
|
|
|
2643
2755
|
Myop MCP is already configured (URL: ${l.url}).`);
|
|
2644
2756
|
try {
|
|
2645
2757
|
await t({ message: "Update to latest URL?", default: !0 }) || process.exit(0);
|
|
2646
|
-
} catch (
|
|
2647
|
-
throw
|
|
2758
|
+
} catch (d) {
|
|
2759
|
+
throw d.name === "ExitPromptError" && process.exit(0), d;
|
|
2648
2760
|
}
|
|
2649
2761
|
}
|
|
2650
|
-
|
|
2651
|
-
\x1B[32mβ\x1B[0m Myop MCP configured for ${
|
|
2762
|
+
m.mcpServers.myop = p.getEntry(), P.mkdirSync(R.dirname(p.configPath), { recursive: !0 }), P.writeFileSync(p.configPath, JSON.stringify(m, null, 2)), console.log(`
|
|
2763
|
+
\x1B[32mβ\x1B[0m Myop MCP configured for ${p.name}`), console.log(` Config: ${p.configPath}`), console.log(` Server: ${s}`), console.log(`
|
|
2652
2764
|
\x1B[1mNext steps:\x1B[0m`);
|
|
2653
|
-
for (const
|
|
2654
|
-
console.log(` ${
|
|
2765
|
+
for (const d of p.nextSteps)
|
|
2766
|
+
console.log(` ${d}`);
|
|
2655
2767
|
console.log(""), process.exit(0);
|
|
2656
2768
|
});
|
|
2657
|
-
const
|
|
2769
|
+
const xo = () => {
|
|
2658
2770
|
try {
|
|
2659
2771
|
Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2660
2772
|
} catch {
|
|
@@ -2687,12 +2799,12 @@ const go = () => {
|
|
|
2687
2799
|
return null;
|
|
2688
2800
|
}
|
|
2689
2801
|
}, ne = async (o = !1, t = !1) => {
|
|
2690
|
-
var
|
|
2691
|
-
const e =
|
|
2802
|
+
var d, w, x;
|
|
2803
|
+
const e = Pe(), n = !!(e != null && e.email), s = ((d = v.myopConfig) == null ? void 0 : d.name) || ((w = v.myopConfig) == null ? void 0 : w.componentName), i = (x = v.myopConfig) == null ? void 0 : x.componentId, r = xo();
|
|
2692
2804
|
console.log(`
|
|
2693
2805
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2694
|
-
`), 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"}`),
|
|
2695
|
-
const
|
|
2806
|
+
`), 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"}`), r != null && r.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")) : r != null && r.notARepo ? console.log(" Changes: Not a git repository") : r && (r.insertions > 0 || r.deletions > 0) ? console.log(` Changes: ${r.files} file${r.files !== 1 ? "s" : ""} | \x1B[32m+${r.insertions}\x1B[0m \x1B[31m-${r.deletions}\x1B[0m`) : r && console.log(" Changes: No uncommitted changes"), console.log("");
|
|
2807
|
+
const m = [
|
|
2696
2808
|
{
|
|
2697
2809
|
emoji: "π",
|
|
2698
2810
|
label: "Initialize new component",
|
|
@@ -2714,14 +2826,14 @@ const go = () => {
|
|
|
2714
2826
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
2715
2827
|
disabled: o ? n ? !1 : "(login required)" : "(no config file)"
|
|
2716
2828
|
}
|
|
2717
|
-
].map((
|
|
2718
|
-
name: t &&
|
|
2719
|
-
${
|
|
2720
|
-
value:
|
|
2721
|
-
disabled:
|
|
2829
|
+
].map(($) => ({
|
|
2830
|
+
name: t && !$.disabled ? `${$.emoji} ${$.label}
|
|
2831
|
+
${$.help}` : `${$.emoji} ${$.label}`,
|
|
2832
|
+
value: $.value,
|
|
2833
|
+
disabled: $.disabled
|
|
2722
2834
|
}));
|
|
2723
|
-
|
|
2724
|
-
new
|
|
2835
|
+
m.push(
|
|
2836
|
+
new Ue(),
|
|
2725
2837
|
{
|
|
2726
2838
|
name: t && n ? `π Logout (${e.email})
|
|
2727
2839
|
Clears stored credentials from this machine` : t && !n ? `π Login to Myop
|
|
@@ -2732,7 +2844,7 @@ const go = () => {
|
|
|
2732
2844
|
name: t ? "π Hide help" : "π Show help",
|
|
2733
2845
|
value: "help"
|
|
2734
2846
|
},
|
|
2735
|
-
new
|
|
2847
|
+
new Ue(),
|
|
2736
2848
|
{
|
|
2737
2849
|
name: "π Exit",
|
|
2738
2850
|
value: "exit"
|
|
@@ -2740,44 +2852,44 @@ const go = () => {
|
|
|
2740
2852
|
);
|
|
2741
2853
|
let l;
|
|
2742
2854
|
try {
|
|
2743
|
-
l = await
|
|
2855
|
+
l = await st({
|
|
2744
2856
|
message: "What would you like to do?",
|
|
2745
|
-
choices:
|
|
2857
|
+
choices: m
|
|
2746
2858
|
});
|
|
2747
|
-
} catch (
|
|
2748
|
-
throw
|
|
2859
|
+
} catch ($) {
|
|
2860
|
+
throw $.name === "ExitPromptError" && (console.log(`
|
|
2749
2861
|
|
|
2750
2862
|
π Goodbye!
|
|
2751
|
-
`), process.exit(0)),
|
|
2863
|
+
`), process.exit(0)), $;
|
|
2752
2864
|
}
|
|
2753
2865
|
switch (l) {
|
|
2754
2866
|
case "init":
|
|
2755
|
-
await
|
|
2867
|
+
await Po();
|
|
2756
2868
|
break;
|
|
2757
2869
|
case "sync":
|
|
2758
2870
|
console.log(`
|
|
2759
2871
|
Pushing component...
|
|
2760
2872
|
`);
|
|
2761
|
-
const { execSync:
|
|
2873
|
+
const { execSync: $ } = await import("child_process");
|
|
2762
2874
|
try {
|
|
2763
|
-
|
|
2875
|
+
$("node " + process.argv[1] + " push", { stdio: "inherit" });
|
|
2764
2876
|
} catch {
|
|
2765
2877
|
}
|
|
2766
2878
|
await ne(!0, t);
|
|
2767
2879
|
break;
|
|
2768
2880
|
case "dev":
|
|
2769
|
-
await
|
|
2881
|
+
await Ce();
|
|
2770
2882
|
break;
|
|
2771
2883
|
case "login":
|
|
2772
2884
|
try {
|
|
2773
|
-
await
|
|
2885
|
+
await me(), console.log(`
|
|
2774
2886
|
`), await ne(o, t);
|
|
2775
|
-
} catch (
|
|
2776
|
-
console.error("Login failed:",
|
|
2887
|
+
} catch (g) {
|
|
2888
|
+
console.error("Login failed:", g.message), await ne(o, t);
|
|
2777
2889
|
}
|
|
2778
2890
|
break;
|
|
2779
2891
|
case "logout":
|
|
2780
|
-
await
|
|
2892
|
+
await gt(), console.log(`
|
|
2781
2893
|
`), await ne(o, t);
|
|
2782
2894
|
break;
|
|
2783
2895
|
case "help":
|
|
@@ -2786,75 +2898,75 @@ Pushing component...
|
|
|
2786
2898
|
case "exit":
|
|
2787
2899
|
process.exit(0);
|
|
2788
2900
|
}
|
|
2789
|
-
},
|
|
2901
|
+
}, be = ".myop-monorepo.json", $o = () => {
|
|
2790
2902
|
try {
|
|
2791
|
-
const o = P.readFileSync(
|
|
2903
|
+
const o = P.readFileSync(be, "utf-8");
|
|
2792
2904
|
return JSON.parse(o);
|
|
2793
2905
|
} catch {
|
|
2794
2906
|
return null;
|
|
2795
2907
|
}
|
|
2796
|
-
},
|
|
2908
|
+
}, bo = (o) => {
|
|
2797
2909
|
try {
|
|
2798
2910
|
const t = {
|
|
2799
2911
|
selectedComponents: o,
|
|
2800
2912
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2801
2913
|
};
|
|
2802
|
-
P.writeFileSync(
|
|
2914
|
+
P.writeFileSync(be, JSON.stringify(t, null, 2));
|
|
2803
2915
|
} catch {
|
|
2804
2916
|
}
|
|
2805
|
-
},
|
|
2806
|
-
const o =
|
|
2917
|
+
}, Co = async () => {
|
|
2918
|
+
const o = Pe(), t = !!(o != null && o.email);
|
|
2807
2919
|
console.log(`
|
|
2808
2920
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Myop CLI - Monorepo Mode β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2809
2921
|
`);
|
|
2810
|
-
const e =
|
|
2922
|
+
const e = z("Scanning for components...").start(), n = Ze(".");
|
|
2811
2923
|
e.stop(), n.length === 0 && (console.log(` β οΈ No myop.config.json files found in this directory or subdirectories.
|
|
2812
2924
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2813
|
-
const s =
|
|
2925
|
+
const s = $o(), i = (s == null ? void 0 : s.selectedComponents) || [], r = i.length > 0;
|
|
2814
2926
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2815
|
-
`), n.forEach((
|
|
2816
|
-
const
|
|
2817
|
-
console.log(` ${
|
|
2818
|
-
}), console.log(` User: ${t ? o.email : "Not logged in"}`),
|
|
2819
|
-
const
|
|
2820
|
-
let
|
|
2821
|
-
if (
|
|
2822
|
-
|
|
2927
|
+
`), n.forEach((w, x) => {
|
|
2928
|
+
const $ = w.componentId ? "β
" : "βͺ", g = w.componentId ? w.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2929
|
+
console.log(` ${$} ${w.name}`), console.log(` Path: ${w.path}`), console.log(` ID: ${g}`), console.log("");
|
|
2930
|
+
}), console.log(` User: ${t ? o.email : "Not logged in"}`), r && console.log(` π Using saved selection from ${be}`), console.log("");
|
|
2931
|
+
const p = v.program.getOptionValue("ci");
|
|
2932
|
+
let m;
|
|
2933
|
+
if (p)
|
|
2934
|
+
r ? (m = i, console.log(` π€ CI mode: using saved selection (${m.length} components)`)) : (m = n.map((w) => w.path), console.log(` π€ CI mode: no saved selection, using all ${m.length} components`));
|
|
2823
2935
|
else {
|
|
2824
|
-
const { checkbox:
|
|
2825
|
-
name: `${
|
|
2826
|
-
value:
|
|
2827
|
-
checked:
|
|
2936
|
+
const { checkbox: w } = await import("@inquirer/prompts"), x = n.map(($) => ({
|
|
2937
|
+
name: `${$.name} (${$.path})`,
|
|
2938
|
+
value: $.path,
|
|
2939
|
+
checked: r ? i.includes($.path) : !0
|
|
2828
2940
|
}));
|
|
2829
2941
|
try {
|
|
2830
|
-
|
|
2942
|
+
m = await w({
|
|
2831
2943
|
message: "Select components to start in dev mode:",
|
|
2832
|
-
choices:
|
|
2944
|
+
choices: x
|
|
2833
2945
|
});
|
|
2834
|
-
} catch (
|
|
2835
|
-
throw
|
|
2946
|
+
} catch ($) {
|
|
2947
|
+
throw $.name === "ExitPromptError" && (console.log(`
|
|
2836
2948
|
|
|
2837
2949
|
π Goodbye!
|
|
2838
|
-
`), process.exit(0)),
|
|
2950
|
+
`), process.exit(0)), $;
|
|
2839
2951
|
}
|
|
2840
2952
|
}
|
|
2841
|
-
|
|
2953
|
+
m.length === 0 && (console.log(`
|
|
2842
2954
|
β οΈ No components selected.
|
|
2843
|
-
`), process.exit(0)),
|
|
2844
|
-
πΎ Selection saved to ${
|
|
2845
|
-
const l = n.filter((
|
|
2955
|
+
`), process.exit(0)), p || (bo(m), console.log(`
|
|
2956
|
+
πΎ Selection saved to ${be}`));
|
|
2957
|
+
const l = n.filter((w) => m.includes(w.path));
|
|
2846
2958
|
console.log(`π Starting dev mode for ${l.length} component${l.length > 1 ? "s" : ""}...
|
|
2847
2959
|
`);
|
|
2848
|
-
const { monorepoDevCommand:
|
|
2849
|
-
await
|
|
2850
|
-
},
|
|
2960
|
+
const { monorepoDevCommand: d } = await Promise.resolve().then(() => Wt);
|
|
2961
|
+
await d(l);
|
|
2962
|
+
}, Po = async () => {
|
|
2851
2963
|
const { input: o, select: t } = await import("@inquirer/prompts"), e = await import("fs"), n = await import("path"), s = n.default.basename(process.cwd());
|
|
2852
|
-
let i,
|
|
2964
|
+
let i, r;
|
|
2853
2965
|
try {
|
|
2854
2966
|
i = await o({
|
|
2855
2967
|
message: "Component name:",
|
|
2856
2968
|
default: s
|
|
2857
|
-
}),
|
|
2969
|
+
}), r = await t({
|
|
2858
2970
|
message: "Component type:",
|
|
2859
2971
|
choices: [
|
|
2860
2972
|
{ name: "π HTML", value: "html", description: "Plain HTML/JS/CSS component" },
|
|
@@ -2869,15 +2981,15 @@ Pushing component...
|
|
|
2869
2981
|
π Goodbye!
|
|
2870
2982
|
`), process.exit(0)), l;
|
|
2871
2983
|
}
|
|
2872
|
-
const
|
|
2984
|
+
const p = {
|
|
2873
2985
|
name: i,
|
|
2874
|
-
type:
|
|
2986
|
+
type: r,
|
|
2875
2987
|
author: "@myop-cli",
|
|
2876
2988
|
HMR: !0
|
|
2877
|
-
},
|
|
2989
|
+
}, m = v.program.getOptionValue("config") || "./myop.config.json";
|
|
2878
2990
|
try {
|
|
2879
|
-
e.writeFileSync(
|
|
2880
|
-
β
Created ${
|
|
2991
|
+
e.writeFileSync(m, JSON.stringify(p, null, 2)), console.log(`
|
|
2992
|
+
β
Created ${m}`);
|
|
2881
2993
|
const l = {
|
|
2882
2994
|
name: i.toLowerCase().replace(/\s+/g, "-"),
|
|
2883
2995
|
version: "1.0.0",
|
|
@@ -2970,7 +3082,7 @@ fs.writeFileSync('dist/index.html', html);
|
|
|
2970
3082
|
console.log('β
Built dist/index.html');
|
|
2971
3083
|
console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
|
|
2972
3084
|
`), console.log("β
Created build.js");
|
|
2973
|
-
const
|
|
3085
|
+
const w = `<!DOCTYPE html>
|
|
2974
3086
|
<html lang="en">
|
|
2975
3087
|
<head>
|
|
2976
3088
|
<meta charset="UTF-8">
|
|
@@ -2987,8 +3099,8 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
2987
3099
|
</body>
|
|
2988
3100
|
</html>
|
|
2989
3101
|
`;
|
|
2990
|
-
e.writeFileSync("index.html",
|
|
2991
|
-
const
|
|
3102
|
+
e.writeFileSync("index.html", w), console.log("β
Created index.html");
|
|
3103
|
+
const x = `// ${i} - Entry Point
|
|
2992
3104
|
import { init } from './modules/app.js';
|
|
2993
3105
|
import { setupMyopInterface } from './modules/myop.js';
|
|
2994
3106
|
|
|
@@ -2997,8 +3109,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
2997
3109
|
setupMyopInterface();
|
|
2998
3110
|
});
|
|
2999
3111
|
`;
|
|
3000
|
-
e.writeFileSync("src/index.js",
|
|
3001
|
-
const
|
|
3112
|
+
e.writeFileSync("src/index.js", x), console.log("β
Created src/index.js");
|
|
3113
|
+
const $ = `// ${i} - Main Application Logic
|
|
3002
3114
|
|
|
3003
3115
|
export function init() {
|
|
3004
3116
|
console.log('${i} loaded');
|
|
@@ -3006,7 +3118,7 @@ export function init() {
|
|
|
3006
3118
|
// Your component logic here
|
|
3007
3119
|
}
|
|
3008
3120
|
`;
|
|
3009
|
-
e.writeFileSync("src/modules/app.js",
|
|
3121
|
+
e.writeFileSync("src/modules/app.js", $), console.log("β
Created src/modules/app.js"), e.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
|
|
3010
3122
|
|
|
3011
3123
|
export function setupMyopInterface() {
|
|
3012
3124
|
// Called when host app sends data to this component
|
|
@@ -3022,11 +3134,11 @@ export function setupMyopInterface() {
|
|
|
3022
3134
|
};
|
|
3023
3135
|
}
|
|
3024
3136
|
`), console.log("β
Created src/modules/myop.js");
|
|
3025
|
-
const
|
|
3137
|
+
const u = `/* ${i} - Styles Entry Point */
|
|
3026
3138
|
/* Add your CSS imports here - they will be auto-bundled */
|
|
3027
3139
|
@import './main.css';
|
|
3028
3140
|
`;
|
|
3029
|
-
e.writeFileSync("src/styles/index.css",
|
|
3141
|
+
e.writeFileSync("src/styles/index.css", u), console.log("β
Created src/styles/index.css");
|
|
3030
3142
|
const E = `/* ${i} - Main Styles */
|
|
3031
3143
|
|
|
3032
3144
|
* {
|
|
@@ -3062,12 +3174,12 @@ dist/
|
|
|
3062
3174
|
.temp-styles.css
|
|
3063
3175
|
.DS_Store
|
|
3064
3176
|
`), console.log("β
Created .gitignore");
|
|
3065
|
-
const
|
|
3066
|
-
|
|
3067
|
-
const
|
|
3177
|
+
const b = await Qe(process.cwd());
|
|
3178
|
+
b.success && console.log("β
Installed AI agent skills");
|
|
3179
|
+
const M = await import("./index-DuEoKctW.js").then((C) => C.i), j = process.cwd();
|
|
3068
3180
|
try {
|
|
3069
|
-
await
|
|
3070
|
-
const
|
|
3181
|
+
await M.init({ fs: e, dir: j });
|
|
3182
|
+
const C = [
|
|
3071
3183
|
"myop.config.json",
|
|
3072
3184
|
"package.json",
|
|
3073
3185
|
"build.js",
|
|
@@ -3079,13 +3191,13 @@ dist/
|
|
|
3079
3191
|
"src/styles/index.css",
|
|
3080
3192
|
"src/styles/main.css"
|
|
3081
3193
|
];
|
|
3082
|
-
if (
|
|
3083
|
-
const
|
|
3194
|
+
if (b.success) {
|
|
3195
|
+
const N = (k, L) => {
|
|
3084
3196
|
try {
|
|
3085
|
-
const
|
|
3086
|
-
for (const
|
|
3087
|
-
const
|
|
3088
|
-
|
|
3197
|
+
const D = e.readdirSync(k, { withFileTypes: !0 });
|
|
3198
|
+
for (const F of D) {
|
|
3199
|
+
const W = n.join(k, F.name), _ = n.join(L, F.name);
|
|
3200
|
+
F.isDirectory() ? N(W, _) : C.push(_);
|
|
3089
3201
|
}
|
|
3090
3202
|
} catch {
|
|
3091
3203
|
}
|
|
@@ -3094,70 +3206,71 @@ dist/
|
|
|
3094
3206
|
const k = e.readdirSync(".", { withFileTypes: !0 });
|
|
3095
3207
|
for (const L of k)
|
|
3096
3208
|
if (L.isDirectory() && L.name.startsWith(".")) {
|
|
3097
|
-
const
|
|
3098
|
-
e.existsSync(
|
|
3209
|
+
const D = n.join(L.name, "skills");
|
|
3210
|
+
e.existsSync(D) && N(D, D);
|
|
3099
3211
|
}
|
|
3100
3212
|
} catch {
|
|
3101
3213
|
}
|
|
3102
3214
|
}
|
|
3103
|
-
for (const
|
|
3104
|
-
await
|
|
3105
|
-
await
|
|
3215
|
+
for (const N of C)
|
|
3216
|
+
await M.add({ fs: e, dir: j, filepath: N });
|
|
3217
|
+
await M.commit({
|
|
3106
3218
|
fs: e,
|
|
3107
3219
|
dir: j,
|
|
3108
3220
|
message: "init",
|
|
3109
3221
|
author: { name: "myop-cli", email: "cli@myop.dev" }
|
|
3110
3222
|
}), console.log("β
Initialized git repository");
|
|
3111
|
-
} catch (
|
|
3112
|
-
console.log("β οΈ Failed to initialize git repository:",
|
|
3223
|
+
} catch (C) {
|
|
3224
|
+
console.log("β οΈ Failed to initialize git repository:", C.message);
|
|
3113
3225
|
}
|
|
3114
3226
|
console.log(`
|
|
3115
3227
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
3116
|
-
`), v.myopConfig =
|
|
3228
|
+
`), v.myopConfig = p, await ne(!0);
|
|
3117
3229
|
} catch (l) {
|
|
3118
3230
|
console.error(`Failed to initialize component: ${l.message}`), process.exit(1);
|
|
3119
3231
|
}
|
|
3120
3232
|
};
|
|
3121
3233
|
v.program.command("default", { isDefault: !0 }).action(async () => {
|
|
3122
|
-
if (v.program.getOptionValue("help") && (console.log(
|
|
3123
|
-
await
|
|
3234
|
+
if (v.program.getOptionValue("help") && (console.log(kt), process.exit()), v.program.getOptionValue("monorepo")) {
|
|
3235
|
+
await Co();
|
|
3124
3236
|
return;
|
|
3125
3237
|
}
|
|
3126
3238
|
if (v.program.getOptionValue("ci")) {
|
|
3127
|
-
const
|
|
3128
|
-
let
|
|
3239
|
+
const p = await import("fs"), m = v.program.getOptionValue("config") || "./myop.config.json", l = v.program.version(), d = Pe();
|
|
3240
|
+
let w = { found: !1 };
|
|
3129
3241
|
try {
|
|
3130
|
-
if (
|
|
3131
|
-
const
|
|
3132
|
-
|
|
3242
|
+
if (p.existsSync(m)) {
|
|
3243
|
+
const $ = p.readFileSync(m, "utf-8"), g = JSON.parse($);
|
|
3244
|
+
w = {
|
|
3133
3245
|
found: !0,
|
|
3134
|
-
path:
|
|
3135
|
-
name:
|
|
3136
|
-
componentId:
|
|
3137
|
-
organization:
|
|
3246
|
+
path: m,
|
|
3247
|
+
name: g.name || g.componentName || null,
|
|
3248
|
+
componentId: g.componentId || null,
|
|
3249
|
+
organization: g.organization || null
|
|
3138
3250
|
};
|
|
3139
3251
|
}
|
|
3140
|
-
} catch (
|
|
3141
|
-
|
|
3252
|
+
} catch ($) {
|
|
3253
|
+
w = { found: !1, error: $.message };
|
|
3142
3254
|
}
|
|
3143
|
-
const
|
|
3255
|
+
const x = {
|
|
3144
3256
|
version: l,
|
|
3145
|
-
config:
|
|
3257
|
+
config: w,
|
|
3146
3258
|
auth: {
|
|
3147
|
-
loggedIn: !!(
|
|
3148
|
-
email: (
|
|
3259
|
+
loggedIn: !!(d != null && d.email),
|
|
3260
|
+
email: (d == null ? void 0 : d.email) || null
|
|
3149
3261
|
}
|
|
3150
3262
|
};
|
|
3151
|
-
console.log(JSON.stringify(
|
|
3263
|
+
console.log(JSON.stringify(x, null, 2)), process.exit(0);
|
|
3152
3264
|
}
|
|
3153
|
-
let n =
|
|
3265
|
+
let n = z({
|
|
3154
3266
|
text: "Loading Myop CLI...",
|
|
3155
3267
|
color: "green"
|
|
3156
3268
|
}).start();
|
|
3157
|
-
const s =
|
|
3158
|
-
await
|
|
3269
|
+
const s = Ee();
|
|
3270
|
+
await yo(500), n.stop();
|
|
3159
3271
|
const i = v.program.version();
|
|
3160
|
-
await
|
|
3272
|
+
await mo(i) || await ne(s.configFound);
|
|
3161
3273
|
});
|
|
3274
|
+
Kt();
|
|
3162
3275
|
v.program.parse(process.argv);
|
|
3163
3276
|
v.program.opts();
|