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