@myop/cli 0.1.38 β 0.1.40
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 +583 -538
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
2
|
+
var ct = Object.defineProperty;
|
|
3
|
+
var dt = (o, e, t) => e in o ? ct(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
4
|
+
var he = (o, e, t) => dt(o, typeof e != "symbol" ? e + "" : e, t);
|
|
5
5
|
import V from "ora";
|
|
6
|
-
import { select as
|
|
7
|
-
import { Command as
|
|
8
|
-
import { execSync as
|
|
9
|
-
import
|
|
10
|
-
import D from "fs";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { URL as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
const
|
|
6
|
+
import { select as Ge, Separator as Fe } from "@inquirer/prompts";
|
|
7
|
+
import { Command as pt, Option as pe } from "commander";
|
|
8
|
+
import { execSync as Q, spawn as mt } from "child_process";
|
|
9
|
+
import ne, { join as Ee } from "path";
|
|
10
|
+
import D, { readFileSync as ut } from "fs";
|
|
11
|
+
import ke from "crypto";
|
|
12
|
+
import gt from "http";
|
|
13
|
+
import { URL as Ye, URLSearchParams as Ke } from "url";
|
|
14
|
+
import ft from "open";
|
|
15
|
+
import ht from "os";
|
|
16
|
+
const yt = `
|
|
17
17
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
18
18
|
|
|
19
19
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -55,25 +55,25 @@ Examples:
|
|
|
55
55
|
verbose: !1
|
|
56
56
|
},
|
|
57
57
|
myopConfig: null
|
|
58
|
-
},
|
|
58
|
+
}, Qe = {
|
|
59
59
|
name: "π₯ Install Myop generated dependencies",
|
|
60
60
|
value: "myopInstall",
|
|
61
61
|
description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
|
|
62
62
|
action: async () => {
|
|
63
63
|
console.info("installing... ");
|
|
64
64
|
for (const o of y.myopConfig.flows) {
|
|
65
|
-
const e =
|
|
65
|
+
const e = ne.join(y.executionPath, "/node_modules/@myop/flow-types/");
|
|
66
66
|
console.info(`Generate flow at ${e}`), console.info(`Generated flow at ${e}`);
|
|
67
67
|
}
|
|
68
68
|
process.exit();
|
|
69
69
|
}
|
|
70
|
-
},
|
|
71
|
-
const e =
|
|
70
|
+
}, wt = (o) => {
|
|
71
|
+
const e = ne.join(y.executionPath, o);
|
|
72
72
|
console.info(`reading config file from: ${e}`);
|
|
73
73
|
const t = D.readFileSync(e, "utf8"), n = JSON.parse(t);
|
|
74
74
|
return console.info("config file loaded, ", n), n;
|
|
75
|
-
},
|
|
76
|
-
const t =
|
|
75
|
+
}, _e = (o, e) => {
|
|
76
|
+
const t = ne.join(y.executionPath, o);
|
|
77
77
|
console.info(`writing config file to: ${t}`);
|
|
78
78
|
try {
|
|
79
79
|
const n = JSON.stringify(e, null, 2);
|
|
@@ -82,54 +82,54 @@ Examples:
|
|
|
82
82
|
throw console.info(`error ${n} while writing to ${t}, JSON: ${e}`), console.log(`
|
|
83
83
|
β οΈ Failed write config file to ${t}, for more info use verbose flag`), n;
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, Ze = {
|
|
86
86
|
name: "π Add flow definition to your project",
|
|
87
87
|
value: "addFlow",
|
|
88
88
|
description: "Adds flow to yours myop.config.json",
|
|
89
89
|
_action: (o) => {
|
|
90
|
-
y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o),
|
|
90
|
+
y.myopConfig.flows.includes(o) || y.myopConfig.flows.push(o), _e(y.options.configPath, y.myopConfig);
|
|
91
91
|
},
|
|
92
92
|
action: async () => {
|
|
93
93
|
}
|
|
94
|
-
},
|
|
94
|
+
}, Xe = {
|
|
95
95
|
name: "π« Remove flow definition from your project",
|
|
96
96
|
value: "removeFlow",
|
|
97
97
|
description: "Removes flow to yours myop.config.json",
|
|
98
98
|
_action: (o) => {
|
|
99
|
-
y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o),
|
|
99
|
+
y.myopConfig.flows = y.myopConfig.flows.filter((e) => e !== o), _e(y.options.configPath, y.myopConfig);
|
|
100
100
|
},
|
|
101
101
|
action: () => {
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, vt = {
|
|
104
104
|
name: "π Quit",
|
|
105
105
|
value: "quit",
|
|
106
106
|
description: "Quit and continue coding.",
|
|
107
107
|
action: () => {
|
|
108
108
|
process.exit();
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, bt = {
|
|
111
111
|
name: "π’ Create new component",
|
|
112
112
|
value: "-",
|
|
113
113
|
disabled: "(not available yet)"
|
|
114
|
-
},
|
|
114
|
+
}, St = {
|
|
115
115
|
name: "π΅ Create new experience",
|
|
116
116
|
value: "-",
|
|
117
117
|
disabled: "(not available yet)"
|
|
118
|
-
},
|
|
118
|
+
}, $t = {
|
|
119
119
|
name: "π‘ Create new skin",
|
|
120
120
|
value: "-",
|
|
121
121
|
disabled: "(not available yet)"
|
|
122
|
-
},
|
|
122
|
+
}, xt = {
|
|
123
123
|
name: "π΄ Create new flow",
|
|
124
124
|
value: "-",
|
|
125
125
|
disabled: "(not available yet)"
|
|
126
|
-
},
|
|
126
|
+
}, Ct = {
|
|
127
127
|
name: "π Define new custom Myop message",
|
|
128
128
|
value: "generateMyopMessage",
|
|
129
129
|
description: "οΈHelp you creates the right structure for a new Myop message, including types and handlers.",
|
|
130
130
|
disabled: "(not available yet)"
|
|
131
|
-
},
|
|
132
|
-
function
|
|
131
|
+
}, Mt = [Ct, bt, St, $t, xt];
|
|
132
|
+
function Pt(o, e, t, n) {
|
|
133
133
|
return `<!DOCTYPE html>
|
|
134
134
|
<html lang="en">
|
|
135
135
|
<head>
|
|
@@ -219,19 +219,19 @@ ${n}
|
|
|
219
219
|
</body>
|
|
220
220
|
</html>`;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function Rt(o) {
|
|
223
223
|
return o.includes("esbuild") && o.includes("another platform");
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Tt(o) {
|
|
226
226
|
return o.includes("ERR_MODULE_NOT_FOUND") && o.includes("esbuild");
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Ot() {
|
|
229
229
|
console.error(`
|
|
230
230
|
β esbuild platform mismatch detected!`), console.error(" Your node_modules contains esbuild binaries for a different OS."), console.error(`
|
|
231
231
|
This usually happens when node_modules is copied between different`), console.error(` operating systems (e.g., Windows β Mac, or Mac β Linux).
|
|
232
232
|
`);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function Et(o) {
|
|
235
235
|
return new Promise((e) => {
|
|
236
236
|
console.log(`π§ Attempting to fix: removing node_modules and reinstalling...
|
|
237
237
|
`);
|
|
@@ -244,9 +244,9 @@ function Rt(o) {
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
console.log(" β Removed node_modules"), console.log(` β³ Running npm install...
|
|
247
|
-
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (s, d,
|
|
247
|
+
`), o("npm install", { maxBuffer: 10 * 1024 * 1024 }, (s, d, w) => {
|
|
248
248
|
if (s) {
|
|
249
|
-
console.error("β npm install failed:", s.message),
|
|
249
|
+
console.error("β npm install failed:", s.message), w && console.error(w), e(!1);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
console.log(` β Dependencies reinstalled successfully!
|
|
@@ -255,24 +255,24 @@ function Rt(o) {
|
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
async function
|
|
258
|
+
async function qe(o, e, t, n, r = {}) {
|
|
259
259
|
const {
|
|
260
260
|
hasTriedPlatformFix: s = !1,
|
|
261
261
|
hasTriedInstall: d = !1,
|
|
262
|
-
onRetry:
|
|
263
|
-
} = r,
|
|
264
|
-
return !s &&
|
|
265
|
-
`),
|
|
266
|
-
n("npm install", (p, S,
|
|
262
|
+
onRetry: w
|
|
263
|
+
} = r, $ = ((o == null ? void 0 : o.message) || "") + (e || "") + (t || "");
|
|
264
|
+
return !s && Rt($) ? (Ot(), await Et(n) && w ? (console.log(`π Retrying build...
|
|
265
|
+
`), w(), { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : { handled: !0, hasTriedPlatformFix: !0, hasTriedInstall: d }) : !d && Tt($) ? (console.log("π¦ Missing dependencies detected, running npm install..."), new Promise((m) => {
|
|
266
|
+
n("npm install", (p, S, g) => {
|
|
267
267
|
if (p) {
|
|
268
|
-
console.error("β Failed to install dependencies:", p.message),
|
|
268
|
+
console.error("β Failed to install dependencies:", p.message), g && console.error(g), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
console.log("β
Dependencies installed"),
|
|
271
|
+
console.log("β
Dependencies installed"), w && w(), m({ handled: !0, hasTriedPlatformFix: s, hasTriedInstall: !0 });
|
|
272
272
|
});
|
|
273
273
|
})) : { handled: !1, hasTriedPlatformFix: s, hasTriedInstall: d };
|
|
274
274
|
}
|
|
275
|
-
async function
|
|
275
|
+
async function Le() {
|
|
276
276
|
const o = await import("fs"), e = await import("path"), { exec: t } = await import("child_process"), n = await import("http"), { createHash: r } = await import("node:crypto");
|
|
277
277
|
let s;
|
|
278
278
|
if (import.meta.url.startsWith("file://")) {
|
|
@@ -280,8 +280,8 @@ async function _e() {
|
|
|
280
280
|
s = e.default.dirname(l);
|
|
281
281
|
} else
|
|
282
282
|
s = e.default.dirname(import.meta.url);
|
|
283
|
-
const d = e.default.join(s, "commands", "dev", "management-website"),
|
|
284
|
-
let S = "./dist",
|
|
283
|
+
const d = e.default.join(s, "commands", "dev", "management-website"), w = o.default.readFileSync(e.default.join(d, "styles.css"), "utf-8"), $ = o.default.readFileSync(e.default.join(d, "app.js"), "utf-8"), m = 9292, p = 9293;
|
|
284
|
+
let S = "./dist", g = !1, b = !1, x = !1, C = null;
|
|
285
285
|
const L = () => {
|
|
286
286
|
try {
|
|
287
287
|
const a = o.default.readdirSync(".").filter((i) => !i.endsWith(".html") || i.startsWith(".") ? !1 : o.default.statSync(i).isFile());
|
|
@@ -297,53 +297,53 @@ async function _e() {
|
|
|
297
297
|
} catch {
|
|
298
298
|
return !1;
|
|
299
299
|
}
|
|
300
|
-
},
|
|
300
|
+
}, f = (a) => {
|
|
301
301
|
const i = process.platform;
|
|
302
302
|
let l;
|
|
303
303
|
i === "darwin" ? l = `open "${a}"` : i === "win32" ? l = `start "" "${a}"` : l = `xdg-open "${a}"`, t(l, (c) => {
|
|
304
304
|
});
|
|
305
305
|
}, P = /* @__PURE__ */ new Map(), E = y.program.getOptionValue("config") || "./myop.config.json";
|
|
306
|
-
let
|
|
307
|
-
|
|
308
|
-
const
|
|
306
|
+
let M, I, _ = !1;
|
|
307
|
+
C = L();
|
|
308
|
+
const te = H();
|
|
309
309
|
try {
|
|
310
310
|
const a = o.default.readFileSync(E, "utf-8"), i = JSON.parse(a);
|
|
311
|
-
|
|
311
|
+
M = i.componentId || "DEV", I = i.componentName || i.name || null, _ = i.HMR === !0, C && !te && (x = !0, _ = !0, console.log(`π Single HTML file mode: ${C}`)), _ && console.log("π₯ HMR enabled");
|
|
312
312
|
} catch (a) {
|
|
313
|
-
|
|
313
|
+
C && !te ? (x = !0, M = "DEV", I = e.default.basename(C, ".html"), _ = !0, console.log(`π Single HTML file mode: ${C}`), console.log("π₯ HMR enabled")) : (console.error("β Error reading myop.config.json:", a.message), process.exit(1));
|
|
314
314
|
}
|
|
315
315
|
const U = async () => {
|
|
316
|
-
if (
|
|
317
|
-
return
|
|
316
|
+
if (M !== "DEV" && M !== "NEW")
|
|
317
|
+
return M;
|
|
318
318
|
try {
|
|
319
|
-
const i = ((await new Promise((
|
|
320
|
-
const
|
|
319
|
+
const i = ((await new Promise((u, h) => {
|
|
320
|
+
const v = {
|
|
321
321
|
hostname: "localhost",
|
|
322
322
|
port: p,
|
|
323
323
|
path: "/_list",
|
|
324
324
|
method: "GET",
|
|
325
325
|
timeout: 1e3
|
|
326
|
-
}, R = n.default.request(
|
|
326
|
+
}, R = n.default.request(v, (N) => {
|
|
327
327
|
let J = "";
|
|
328
|
-
N.on("data", (
|
|
328
|
+
N.on("data", (q) => J += q), N.on("end", () => {
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
u(JSON.parse(J));
|
|
331
331
|
} catch {
|
|
332
|
-
|
|
332
|
+
u({ components: [] });
|
|
333
333
|
}
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
|
-
R.on("error", () =>
|
|
337
|
-
R.destroy(),
|
|
336
|
+
R.on("error", () => u({ components: [] })), R.on("timeout", () => {
|
|
337
|
+
R.destroy(), u({ components: [] });
|
|
338
338
|
}), R.end();
|
|
339
|
-
})).components || []).map(([
|
|
339
|
+
})).components || []).map(([u]) => u).filter((u) => u === "DEV" || u === "NEW" || /^DEV\d+$/.test(u) || /^NEW\d+$/.test(u));
|
|
340
340
|
if (i.length === 0)
|
|
341
341
|
return "DEV1";
|
|
342
|
-
const l = i.map((
|
|
343
|
-
if (
|
|
344
|
-
const h =
|
|
345
|
-
return h ? parseInt(h[1], 10) :
|
|
346
|
-
}).filter((
|
|
342
|
+
const l = i.map((u) => {
|
|
343
|
+
if (u === "DEV" || u === "NEW") return 1;
|
|
344
|
+
const h = u.match(/^DEV(\d+)$/), v = u.match(/^NEW(\d+)$/);
|
|
345
|
+
return h ? parseInt(h[1], 10) : v ? parseInt(v[1], 10) : 0;
|
|
346
|
+
}).filter((u) => u > 0);
|
|
347
347
|
return `DEV${Math.max(...l, 0) + 1}`;
|
|
348
348
|
} catch {
|
|
349
349
|
return "DEV1";
|
|
@@ -361,9 +361,9 @@ async function _e() {
|
|
|
361
361
|
".svg": "image/svg+xml",
|
|
362
362
|
".ico": "image/x-icon"
|
|
363
363
|
}[i] || "application/octet-stream";
|
|
364
|
-
}, T = /* @__PURE__ */ new Map(), Y = [],
|
|
364
|
+
}, T = /* @__PURE__ */ new Map(), Y = [], $e = 50, Z = [], se = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), st = (a, i, l) => {
|
|
365
365
|
if (a.url.startsWith("/_hmr/")) {
|
|
366
|
-
const c = a.url.split("/_hmr/")[1],
|
|
366
|
+
const c = a.url.split("/_hmr/")[1], u = a.headers["sec-websocket-key"], h = r("sha1").update(u + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
367
367
|
i.write(
|
|
368
368
|
`HTTP/1.1 101 Switching Protocols\r
|
|
369
369
|
Upgrade: websocket\r
|
|
@@ -371,29 +371,29 @@ Connection: Upgrade\r
|
|
|
371
371
|
Sec-WebSocket-Accept: ${h}\r
|
|
372
372
|
\r
|
|
373
373
|
`
|
|
374
|
-
),
|
|
375
|
-
const
|
|
376
|
-
|
|
374
|
+
), X.has(c) || X.set(c, /* @__PURE__ */ new Set()), X.get(c).add(i), console.log(`π HMR client connected: ${c}`), i.on("close", () => {
|
|
375
|
+
const v = X.get(c);
|
|
376
|
+
v && (v.delete(i), v.size === 0 && X.delete(c)), console.log(`π HMR client disconnected: ${c}`);
|
|
377
377
|
}), i.on("error", () => {
|
|
378
|
-
const
|
|
379
|
-
|
|
378
|
+
const v = X.get(c);
|
|
379
|
+
v && v.delete(i);
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
|
-
},
|
|
382
|
+
}, xe = n.default.createServer((a, i) => {
|
|
383
383
|
if (i.setHeader("Content-Type", "application/json"), a.method === "POST" && a.url === "/_register") {
|
|
384
384
|
let l = "";
|
|
385
385
|
a.on("data", (c) => l += c), a.on("end", () => {
|
|
386
386
|
try {
|
|
387
|
-
const { componentId: c, distPath:
|
|
388
|
-
T.set(c, { path:
|
|
387
|
+
const { componentId: c, distPath: u, componentName: h, htmlFile: v } = JSON.parse(l);
|
|
388
|
+
T.set(c, { path: u, name: h || null, htmlFile: v || null });
|
|
389
389
|
const R = h ? ` (${h})` : "";
|
|
390
|
-
console.log(`β
Registered: ${c}${R} -> ${
|
|
391
|
-
const N = Array.from(T.entries()).map(([J,
|
|
390
|
+
console.log(`β
Registered: ${c}${R} -> ${u}${v ? "/" + v : ""}`), i.writeHead(200), i.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
|
|
391
|
+
const N = Array.from(T.entries()).map(([J, q]) => ({
|
|
392
392
|
id: J,
|
|
393
|
-
path:
|
|
394
|
-
name:
|
|
393
|
+
path: q.path,
|
|
394
|
+
name: q.name
|
|
395
395
|
}));
|
|
396
|
-
|
|
396
|
+
Z.forEach((J) => {
|
|
397
397
|
try {
|
|
398
398
|
J.write(`data: ${JSON.stringify({
|
|
399
399
|
type: "components",
|
|
@@ -414,16 +414,16 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
414
414
|
try {
|
|
415
415
|
const { componentId: c } = JSON.parse(l);
|
|
416
416
|
T.delete(c), console.log(`β Unregistered: ${c}`), i.writeHead(200), i.end(JSON.stringify({ success: !0 }));
|
|
417
|
-
const
|
|
417
|
+
const u = Array.from(T.entries()).map(([h, v]) => ({
|
|
418
418
|
id: h,
|
|
419
|
-
path:
|
|
420
|
-
name:
|
|
419
|
+
path: v.path,
|
|
420
|
+
name: v.name
|
|
421
421
|
}));
|
|
422
|
-
|
|
422
|
+
Z.forEach((h) => {
|
|
423
423
|
try {
|
|
424
424
|
h.write(`data: ${JSON.stringify({
|
|
425
425
|
type: "components",
|
|
426
|
-
components:
|
|
426
|
+
components: u
|
|
427
427
|
})}
|
|
428
428
|
|
|
429
429
|
`);
|
|
@@ -440,10 +440,10 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
440
440
|
let l = "";
|
|
441
441
|
a.on("data", (c) => l += c), a.on("end", () => {
|
|
442
442
|
try {
|
|
443
|
-
const { componentId: c, html:
|
|
443
|
+
const { componentId: c, html: u } = JSON.parse(l), h = X.get(c);
|
|
444
444
|
if (h && h.size > 0) {
|
|
445
445
|
console.log(`π₯ Notifying ${h.size} HMR client(s) for: ${c}`);
|
|
446
|
-
const
|
|
446
|
+
const v = JSON.stringify({ type: "update", html: u }), R = Ue(v);
|
|
447
447
|
h.forEach((N) => {
|
|
448
448
|
try {
|
|
449
449
|
N.write(R);
|
|
@@ -459,78 +459,78 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
459
459
|
});
|
|
460
460
|
} else
|
|
461
461
|
i.writeHead(404), i.end(JSON.stringify({ error: "Not found" }));
|
|
462
|
-
}),
|
|
462
|
+
}), me = n.default.createServer((a, i) => {
|
|
463
463
|
if (a.url.includes("..")) {
|
|
464
464
|
i.writeHead(403, { "Content-Type": "text/plain" }), i.end("Forbidden");
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const l = new URL(a.url, `http://localhost:${
|
|
467
|
+
const l = new URL(a.url, `http://localhost:${m}`), c = l.pathname, u = c.split("/").filter((A) => A);
|
|
468
468
|
if (c.startsWith("/consume")) {
|
|
469
469
|
const A = l.searchParams.get("id");
|
|
470
470
|
if (!A) {
|
|
471
471
|
i.writeHead(400, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
const B = T.get(A), z = B ? B.path : null,
|
|
474
|
+
const B = T.get(A), z = B ? B.path : null, le = (ee) => {
|
|
475
475
|
let j = "Unknown", W = "Unknown";
|
|
476
476
|
if (a.headers.referer || a.headers.referrer) {
|
|
477
|
-
const
|
|
477
|
+
const k = a.headers.referer || a.headers.referrer;
|
|
478
478
|
try {
|
|
479
|
-
const
|
|
480
|
-
j =
|
|
479
|
+
const ie = new URL(k);
|
|
480
|
+
j = ie.origin, W = ie.hostname || ie.origin;
|
|
481
481
|
} catch {
|
|
482
|
-
j =
|
|
482
|
+
j = k, W = k;
|
|
483
483
|
}
|
|
484
484
|
} else if (a.headers.origin)
|
|
485
485
|
try {
|
|
486
|
-
const
|
|
487
|
-
j =
|
|
486
|
+
const k = new URL(a.headers.origin);
|
|
487
|
+
j = k.origin, W = k.hostname || k.origin;
|
|
488
488
|
} catch {
|
|
489
489
|
j = a.headers.origin, W = a.headers.origin;
|
|
490
490
|
}
|
|
491
491
|
else if (a.socket.remoteAddress) {
|
|
492
|
-
const
|
|
493
|
-
|
|
492
|
+
const k = a.socket.remoteAddress;
|
|
493
|
+
k === "::1" || k === "::ffff:127.0.0.1" ? (j = "localhost", W = "localhost (direct)") : (j = k, W = k.replace("::ffff:", ""));
|
|
494
494
|
}
|
|
495
|
-
const Te = a.headers.referer || a.headers.referrer || j,
|
|
495
|
+
const Te = a.headers.referer || a.headers.referrer || j, fe = {
|
|
496
496
|
type: "request",
|
|
497
497
|
componentId: A,
|
|
498
498
|
timestamp: Date.now(),
|
|
499
|
-
servedLocally:
|
|
499
|
+
servedLocally: ee,
|
|
500
500
|
referrer: Te,
|
|
501
501
|
origin: j,
|
|
502
502
|
originLabel: W
|
|
503
503
|
};
|
|
504
|
-
|
|
504
|
+
se.has(j) || (se.set(j, {
|
|
505
505
|
url: j,
|
|
506
506
|
label: W,
|
|
507
507
|
firstSeen: Date.now(),
|
|
508
508
|
requestCount: 0
|
|
509
|
-
}),
|
|
509
|
+
}), Z.forEach((k) => {
|
|
510
510
|
try {
|
|
511
|
-
|
|
511
|
+
k.write(`data: ${JSON.stringify({
|
|
512
512
|
type: "origins",
|
|
513
|
-
origins: Array.from(
|
|
513
|
+
origins: Array.from(se.values())
|
|
514
514
|
})}
|
|
515
515
|
|
|
516
516
|
`);
|
|
517
517
|
} catch {
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
const Oe =
|
|
521
|
-
Oe.requestCount++,
|
|
520
|
+
const Oe = se.get(j);
|
|
521
|
+
Oe.requestCount++, Z.forEach((k) => {
|
|
522
522
|
try {
|
|
523
|
-
|
|
523
|
+
k.write(`data: ${JSON.stringify({
|
|
524
524
|
type: "origins",
|
|
525
|
-
origins: Array.from(
|
|
525
|
+
origins: Array.from(se.values())
|
|
526
526
|
})}
|
|
527
527
|
|
|
528
528
|
`);
|
|
529
529
|
} catch {
|
|
530
530
|
}
|
|
531
|
-
}), Y.push(
|
|
531
|
+
}), Y.push(fe), Y.length > $e && Y.shift(), Z.forEach((k) => {
|
|
532
532
|
try {
|
|
533
|
-
|
|
533
|
+
k.write(`data: ${JSON.stringify(fe)}
|
|
534
534
|
|
|
535
535
|
`);
|
|
536
536
|
} catch {
|
|
@@ -538,19 +538,19 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
538
538
|
});
|
|
539
539
|
};
|
|
540
540
|
if (z) {
|
|
541
|
-
const
|
|
542
|
-
o.default.readFile(
|
|
541
|
+
const ee = B.htmlFile ? e.default.join(z, B.htmlFile) : e.default.join(z, "index.html");
|
|
542
|
+
o.default.readFile(ee, "utf-8", (j, W) => {
|
|
543
543
|
if (j) {
|
|
544
|
-
console.log(`β File not found: ${
|
|
544
|
+
console.log(`β File not found: ${ee}`), i.writeHead(404, { "Content-Type": "application/json" }), i.end(JSON.stringify({ error: "index.html not found" }));
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
const Te = Ce(W, A),
|
|
547
|
+
const Te = Ce(W, A), fe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Oe = {
|
|
548
548
|
item: {
|
|
549
549
|
name: A,
|
|
550
550
|
id: A,
|
|
551
551
|
consume_variant: [
|
|
552
552
|
{
|
|
553
|
-
id:
|
|
553
|
+
id: fe,
|
|
554
554
|
name: "dev version",
|
|
555
555
|
loader: {
|
|
556
556
|
type: "HTMLLoader",
|
|
@@ -561,15 +561,15 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
561
561
|
]
|
|
562
562
|
}
|
|
563
563
|
};
|
|
564
|
-
console.log(`β
Serving consume JSON for: ${A}`),
|
|
564
|
+
console.log(`β
Serving consume JSON for: ${A}`), le(!0), i.writeHead(200, {
|
|
565
565
|
"Content-Type": "application/json",
|
|
566
566
|
"Access-Control-Allow-Origin": "*"
|
|
567
567
|
}), i.end(JSON.stringify(Oe, null, 2));
|
|
568
568
|
});
|
|
569
569
|
} else {
|
|
570
570
|
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${A}`);
|
|
571
|
-
const
|
|
572
|
-
|
|
571
|
+
const ee = `https://cloud.myop.dev/consume${l.search}`;
|
|
572
|
+
le(!1), fetch(ee).then((j) => j.text()).then((j) => {
|
|
573
573
|
i.writeHead(200, {
|
|
574
574
|
"Content-Type": "application/json",
|
|
575
575
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -586,7 +586,7 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
586
586
|
"Cache-Control": "no-cache",
|
|
587
587
|
Connection: "keep-alive",
|
|
588
588
|
"Access-Control-Allow-Origin": "*"
|
|
589
|
-
}),
|
|
589
|
+
}), Z.push(i);
|
|
590
590
|
const A = Array.from(T.entries()).map(([B, z]) => ({
|
|
591
591
|
id: B,
|
|
592
592
|
path: z.path,
|
|
@@ -599,7 +599,7 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
599
599
|
|
|
600
600
|
`), i.write(`data: ${JSON.stringify({
|
|
601
601
|
type: "origins",
|
|
602
|
-
origins: Array.from(
|
|
602
|
+
origins: Array.from(se.values())
|
|
603
603
|
})}
|
|
604
604
|
|
|
605
605
|
`), i.write(`data: ${JSON.stringify({
|
|
@@ -608,53 +608,53 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
608
608
|
})}
|
|
609
609
|
|
|
610
610
|
`), a.on("close", () => {
|
|
611
|
-
const B =
|
|
612
|
-
B !== -1 &&
|
|
611
|
+
const B = Z.indexOf(i);
|
|
612
|
+
B !== -1 && Z.splice(B, 1);
|
|
613
613
|
});
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
|
-
if (
|
|
617
|
-
i.writeHead(200, { "Content-Type": "text/html" }), i.end(
|
|
616
|
+
if (u.length === 0) {
|
|
617
|
+
i.writeHead(200, { "Content-Type": "text/html" }), i.end(Pt(m, p, w, $));
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
|
-
if (
|
|
620
|
+
if (u[0] !== "view") {
|
|
621
621
|
i.writeHead(404, { "Content-Type": "text/plain" }), i.end("Not found. Use /view/<componentId>/ to access components.");
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
|
-
if (
|
|
624
|
+
if (u.length < 2) {
|
|
625
625
|
i.writeHead(400, { "Content-Type": "text/plain" }), i.end("Component ID required. Use /view/<componentId>/");
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
const h =
|
|
629
|
-
if (!
|
|
628
|
+
const h = u[1], v = T.get(h);
|
|
629
|
+
if (!v) {
|
|
630
630
|
i.writeHead(404, { "Content-Type": "text/plain" }), i.end(`Component not found: ${h}`);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const R =
|
|
634
|
-
console.log(`π₯ Request: ${a.url} -> ${
|
|
633
|
+
const R = v.path, N = u.slice(2), J = v.htmlFile || "index.html", q = N.length === 0 ? J : N.join("/"), ae = e.default.join(R, q);
|
|
634
|
+
console.log(`π₯ Request: ${a.url} -> ${ae}`), o.default.readFile(ae, (A, B) => {
|
|
635
635
|
if (A) {
|
|
636
|
-
console.log(`β File not found: ${
|
|
636
|
+
console.log(`β File not found: ${ae}`), i.writeHead(404, { "Content-Type": "text/plain" }), i.end("Not Found");
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
639
|
-
const z = G(
|
|
640
|
-
console.log(`β
Serving: ${
|
|
641
|
-
let
|
|
642
|
-
if (z === "text/html" &&
|
|
643
|
-
const
|
|
644
|
-
|
|
639
|
+
const z = G(ae);
|
|
640
|
+
console.log(`β
Serving: ${ae} (${z})`);
|
|
641
|
+
let le = B;
|
|
642
|
+
if (z === "text/html" && _) {
|
|
643
|
+
const ee = B.toString("utf-8");
|
|
644
|
+
le = Ce(ee, h);
|
|
645
645
|
}
|
|
646
646
|
i.writeHead(200, {
|
|
647
647
|
"Content-Type": z,
|
|
648
648
|
"Access-Control-Allow-Origin": "*"
|
|
649
|
-
}), i.end(
|
|
649
|
+
}), i.end(le);
|
|
650
650
|
});
|
|
651
|
-
}),
|
|
651
|
+
}), De = () => new Promise((a, i) => {
|
|
652
652
|
const l = x ? e.default.resolve(F) : e.default.resolve(F, S), c = JSON.stringify({
|
|
653
|
-
componentId:
|
|
653
|
+
componentId: M,
|
|
654
654
|
distPath: l,
|
|
655
655
|
componentName: I,
|
|
656
|
-
htmlFile: x ?
|
|
657
|
-
}),
|
|
656
|
+
htmlFile: x ? C : null
|
|
657
|
+
}), u = {
|
|
658
658
|
hostname: "localhost",
|
|
659
659
|
port: p,
|
|
660
660
|
path: "/_register",
|
|
@@ -663,15 +663,15 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
663
663
|
"Content-Type": "application/json",
|
|
664
664
|
"Content-Length": Buffer.byteLength(c)
|
|
665
665
|
}
|
|
666
|
-
}, h = n.default.request(
|
|
666
|
+
}, h = n.default.request(u, (v) => {
|
|
667
667
|
let R = "";
|
|
668
|
-
|
|
669
|
-
|
|
668
|
+
v.on("data", (N) => R += N), v.on("end", () => {
|
|
669
|
+
v.statusCode === 200 ? a(JSON.parse(R)) : i(new Error(`Registration failed: ${v.statusCode}`));
|
|
670
670
|
});
|
|
671
671
|
});
|
|
672
672
|
h.on("error", i), h.write(c), h.end();
|
|
673
|
-
}),
|
|
674
|
-
const l = JSON.stringify({ componentId:
|
|
673
|
+
}), it = () => new Promise((a, i) => {
|
|
674
|
+
const l = JSON.stringify({ componentId: M }), c = {
|
|
675
675
|
hostname: "localhost",
|
|
676
676
|
port: p,
|
|
677
677
|
path: "/_unregister",
|
|
@@ -680,11 +680,11 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
680
680
|
"Content-Type": "application/json",
|
|
681
681
|
"Content-Length": Buffer.byteLength(l)
|
|
682
682
|
}
|
|
683
|
-
},
|
|
683
|
+
}, u = n.default.request(c, (h) => {
|
|
684
684
|
a();
|
|
685
685
|
});
|
|
686
|
-
|
|
687
|
-
}),
|
|
686
|
+
u.on("error", () => a()), u.write(l), u.end();
|
|
687
|
+
}), rt = (a) => `
|
|
688
688
|
<!-- MYOP HMR -->
|
|
689
689
|
<script>
|
|
690
690
|
(function() {
|
|
@@ -790,10 +790,10 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
790
790
|
})();
|
|
791
791
|
<\/script>
|
|
792
792
|
`, Ce = (a, i) => {
|
|
793
|
-
if (!
|
|
794
|
-
const l =
|
|
793
|
+
if (!_) return a;
|
|
794
|
+
const l = rt(i);
|
|
795
795
|
return a.includes("</body>") ? a.replace("</body>", `${l}</body>`) : a.includes("</html>") ? a.replace("</html>", `${l}</html>`) : a + l;
|
|
796
|
-
},
|
|
796
|
+
}, Ue = (a) => {
|
|
797
797
|
const i = Buffer.from(a), l = i.length;
|
|
798
798
|
let c;
|
|
799
799
|
return l < 126 ? c = Buffer.concat([
|
|
@@ -813,36 +813,36 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
813
813
|
// 64-bit length
|
|
814
814
|
i
|
|
815
815
|
]), c;
|
|
816
|
-
},
|
|
817
|
-
if (!
|
|
818
|
-
const a = x ?
|
|
816
|
+
}, Be = () => {
|
|
817
|
+
if (!_) return;
|
|
818
|
+
const a = x ? C : e.default.join(S, "index.html");
|
|
819
819
|
let i;
|
|
820
820
|
try {
|
|
821
821
|
const l = o.default.readFileSync(a, "utf-8");
|
|
822
|
-
i = Ce(l,
|
|
822
|
+
i = Ce(l, M);
|
|
823
823
|
} catch (l) {
|
|
824
824
|
console.error("β Failed to read HTML for HMR:", l.message);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
827
|
if (Re) {
|
|
828
|
-
const l =
|
|
828
|
+
const l = X.get(M);
|
|
829
829
|
if (!l || l.size === 0)
|
|
830
830
|
return;
|
|
831
831
|
console.log(`π₯ Notifying ${l.size} HMR client(s)`);
|
|
832
832
|
const c = JSON.stringify({
|
|
833
833
|
type: "update",
|
|
834
834
|
html: i
|
|
835
|
-
}),
|
|
835
|
+
}), u = Ue(c);
|
|
836
836
|
l.forEach((h) => {
|
|
837
837
|
try {
|
|
838
|
-
h.write(
|
|
838
|
+
h.write(u);
|
|
839
839
|
} catch {
|
|
840
840
|
l.delete(h);
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
} else {
|
|
844
844
|
const l = JSON.stringify({
|
|
845
|
-
componentId:
|
|
845
|
+
componentId: M,
|
|
846
846
|
html: i
|
|
847
847
|
}), c = {
|
|
848
848
|
hostname: "localhost",
|
|
@@ -854,75 +854,75 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
854
854
|
"Content-Length": Buffer.byteLength(l)
|
|
855
855
|
},
|
|
856
856
|
timeout: 5e3
|
|
857
|
-
},
|
|
858
|
-
let
|
|
859
|
-
h.on("data", (R) =>
|
|
857
|
+
}, u = n.default.request(c, (h) => {
|
|
858
|
+
let v = "";
|
|
859
|
+
h.on("data", (R) => v += R), h.on("end", () => {
|
|
860
860
|
try {
|
|
861
|
-
const R = JSON.parse(
|
|
861
|
+
const R = JSON.parse(v);
|
|
862
862
|
R.notified > 0 && console.log(`π₯ Notified ${R.notified} HMR client(s) via server`);
|
|
863
863
|
} catch {
|
|
864
864
|
}
|
|
865
865
|
});
|
|
866
866
|
});
|
|
867
|
-
|
|
868
|
-
}),
|
|
869
|
-
|
|
870
|
-
}),
|
|
867
|
+
u.on("error", () => {
|
|
868
|
+
}), u.on("timeout", () => {
|
|
869
|
+
u.destroy();
|
|
870
|
+
}), u.write(l), u.end();
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
873
|
let Me = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
874
|
+
const ue = (a) => {
|
|
875
|
+
if (g) {
|
|
876
876
|
b = !0;
|
|
877
877
|
return;
|
|
878
878
|
}
|
|
879
|
-
|
|
879
|
+
g = !0, console.log(`
|
|
880
880
|
π¨ Building...`), t("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (i, l, c) => {
|
|
881
|
-
if (
|
|
882
|
-
const
|
|
881
|
+
if (g = !1, i) {
|
|
882
|
+
const u = await qe(i, l, c, t, {
|
|
883
883
|
...Me,
|
|
884
|
-
onRetry: () =>
|
|
884
|
+
onRetry: () => ue(a)
|
|
885
885
|
});
|
|
886
|
-
Me = { ...Me, ...
|
|
886
|
+
Me = { ...Me, ...u }, u.handled || (console.error("β Build failed:", i.message), c && console.error(c));
|
|
887
887
|
} else
|
|
888
|
-
console.log("β
Build completed"), l && console.log(l),
|
|
889
|
-
b && (b = !1,
|
|
888
|
+
console.log("β
Build completed"), l && console.log(l), Be(), a && a();
|
|
889
|
+
b && (b = !1, ue());
|
|
890
890
|
});
|
|
891
|
-
},
|
|
891
|
+
}, Je = /* @__PURE__ */ new Set(), Pe = (a) => {
|
|
892
892
|
o.default.readdir(a, { withFileTypes: !0 }, (i, l) => {
|
|
893
893
|
i || (l.forEach((c) => {
|
|
894
|
-
const
|
|
894
|
+
const u = e.default.join(a, c.name);
|
|
895
895
|
if (c.isDirectory())
|
|
896
|
-
c.name !== "node_modules" && c.name !== "dist" && !c.name.startsWith(".") && Pe(
|
|
896
|
+
c.name !== "node_modules" && c.name !== "dist" && !c.name.startsWith(".") && Pe(u);
|
|
897
897
|
else if (c.isFile()) {
|
|
898
898
|
const h = e.default.extname(c.name);
|
|
899
899
|
if (h === ".js" || h === ".css" || h === ".html")
|
|
900
900
|
try {
|
|
901
|
-
const
|
|
902
|
-
P.set(
|
|
901
|
+
const v = o.default.readFileSync(u, "utf-8");
|
|
902
|
+
P.set(u, v);
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
}),
|
|
907
|
-
if (!
|
|
908
|
-
const h = e.default.extname(
|
|
906
|
+
}), Je.has(a) || (Je.add(a), o.default.watch(a, (c, u) => {
|
|
907
|
+
if (!u) return;
|
|
908
|
+
const h = e.default.extname(u);
|
|
909
909
|
if (h !== ".js" && h !== ".css" && h !== ".html") return;
|
|
910
|
-
const
|
|
910
|
+
const v = e.default.join(a, u);
|
|
911
911
|
setTimeout(() => {
|
|
912
912
|
try {
|
|
913
|
-
const R = o.default.readFileSync(
|
|
914
|
-
R !== N && (P.set(
|
|
913
|
+
const R = o.default.readFileSync(v, "utf-8"), N = P.get(v);
|
|
914
|
+
R !== N && (P.set(v, R), console.log(`π File changed: ${v}`), x ? Be() : ue());
|
|
915
915
|
} catch {
|
|
916
916
|
}
|
|
917
917
|
}, 50);
|
|
918
918
|
})));
|
|
919
919
|
});
|
|
920
|
-
},
|
|
920
|
+
}, ze = (a) => {
|
|
921
921
|
console.log(`
|
|
922
|
-
π¨ Component: ${
|
|
923
|
-
`), a && a()) : (
|
|
922
|
+
π¨ Component: ${M}`), x ? (console.log("π No build needed (single HTML file mode)"), Pe(F), console.log(`π Watching ${C} for changes...`), console.log(`Press Ctrl+C to stop
|
|
923
|
+
`), a && a()) : (ue(a), Pe(F), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
924
924
|
`));
|
|
925
|
-
},
|
|
925
|
+
}, at = () => new Promise((a) => {
|
|
926
926
|
const i = {
|
|
927
927
|
hostname: "localhost",
|
|
928
928
|
port: p,
|
|
@@ -935,25 +935,25 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
935
935
|
l.on("error", () => a(!1)), l.on("timeout", () => {
|
|
936
936
|
l.destroy(), a(!1);
|
|
937
937
|
}), l.end();
|
|
938
|
-
}),
|
|
938
|
+
}), lt = () => new Promise((a) => {
|
|
939
939
|
const i = n.default.createServer((l, c) => {
|
|
940
940
|
if (c.setHeader("Content-Type", "application/json"), l.method === "POST" && l.url === "/_register") {
|
|
941
|
-
let
|
|
942
|
-
l.on("data", (h) =>
|
|
941
|
+
let u = "";
|
|
942
|
+
l.on("data", (h) => u += h), l.on("end", () => {
|
|
943
943
|
try {
|
|
944
|
-
const { componentId: h, distPath:
|
|
945
|
-
T.set(h, { path:
|
|
944
|
+
const { componentId: h, distPath: v, componentName: R, htmlFile: N } = JSON.parse(u);
|
|
945
|
+
T.set(h, { path: v, name: R || null, htmlFile: N || null });
|
|
946
946
|
const J = R ? ` (${R})` : "";
|
|
947
|
-
console.log(`β
Registered: ${h}${J} -> ${
|
|
947
|
+
console.log(`β
Registered: ${h}${J} -> ${v}${N ? "/" + N : ""}`), c.writeHead(200), c.end(JSON.stringify({ success: !0, registered: Array.from(T.keys()) }));
|
|
948
948
|
} catch (h) {
|
|
949
949
|
c.writeHead(400), c.end(JSON.stringify({ error: h.message }));
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
952
|
} else if (l.method === "POST" && l.url === "/_unregister") {
|
|
953
|
-
let
|
|
954
|
-
l.on("data", (h) =>
|
|
953
|
+
let u = "";
|
|
954
|
+
l.on("data", (h) => u += h), l.on("end", () => {
|
|
955
955
|
try {
|
|
956
|
-
const { componentId: h } = JSON.parse(
|
|
956
|
+
const { componentId: h } = JSON.parse(u);
|
|
957
957
|
T.delete(h), console.log(`β Unregistered: ${h}`), c.writeHead(200), c.end(JSON.stringify({ success: !0 }));
|
|
958
958
|
} catch (h) {
|
|
959
959
|
c.writeHead(400), c.end(JSON.stringify({ error: h.message }));
|
|
@@ -965,70 +965,70 @@ Sec-WebSocket-Accept: ${h}\r
|
|
|
965
965
|
a(!1);
|
|
966
966
|
}), i.listen(p, () => {
|
|
967
967
|
console.log(`
|
|
968
|
-
π Taking over as server...`), console.log(`π‘ Management server on port ${p}`),
|
|
968
|
+
π Taking over as server...`), console.log(`π‘ Management server on port ${p}`), me.on("error", () => {
|
|
969
969
|
i.close(), a(!1);
|
|
970
|
-
}),
|
|
971
|
-
console.log(`π‘ Main server running at http://localhost:${
|
|
970
|
+
}), me.listen(m, () => {
|
|
971
|
+
console.log(`π‘ Main server running at http://localhost:${m}`);
|
|
972
972
|
const l = x ? e.default.resolve(F) : e.default.resolve(F, S);
|
|
973
|
-
T.set(
|
|
973
|
+
T.set(M, {
|
|
974
974
|
path: l,
|
|
975
975
|
name: I,
|
|
976
|
-
htmlFile: x ?
|
|
976
|
+
htmlFile: x ? C : null
|
|
977
977
|
});
|
|
978
978
|
const c = I ? ` (${I})` : "";
|
|
979
|
-
console.log(`β
Registered component: ${
|
|
979
|
+
console.log(`β
Registered component: ${M}${c}`), console.log(`π‘ Access at: http://localhost:${m}/view/${M}/`), a(!0);
|
|
980
980
|
});
|
|
981
981
|
});
|
|
982
982
|
});
|
|
983
|
-
let
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
await
|
|
987
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
983
|
+
let ge;
|
|
984
|
+
const We = () => {
|
|
985
|
+
ge = setInterval(async () => {
|
|
986
|
+
await at() || (clearInterval(ge), console.log(`
|
|
987
|
+
β οΈ Server appears to be down, attempting to take over...`), await lt() ? (console.log("β
Successfully took over as server"), Re = !0) : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
988
988
|
try {
|
|
989
|
-
await
|
|
989
|
+
await De(), console.log(`β
Re-registered component: ${M}`), We();
|
|
990
990
|
} catch (l) {
|
|
991
991
|
console.error("β Failed to re-register:", l.message);
|
|
992
992
|
}
|
|
993
993
|
}, 2e3)));
|
|
994
994
|
}, 3e3);
|
|
995
|
-
},
|
|
995
|
+
}, Ve = async () => {
|
|
996
996
|
console.log(`
|
|
997
997
|
|
|
998
|
-
π Shutting down...`),
|
|
998
|
+
π Shutting down...`), ge && clearInterval(ge), await it(), process.exit(0);
|
|
999
999
|
};
|
|
1000
|
-
process.on("SIGINT",
|
|
1000
|
+
process.on("SIGINT", Ve), process.on("SIGTERM", Ve);
|
|
1001
1001
|
let Re = !1;
|
|
1002
|
-
|
|
1002
|
+
xe.on("error", async (a) => {
|
|
1003
1003
|
if (a.code === "EADDRINUSE") {
|
|
1004
1004
|
console.log(`
|
|
1005
1005
|
π Connecting to existing dev server...`);
|
|
1006
1006
|
try {
|
|
1007
|
-
|
|
1008
|
-
const i = await
|
|
1009
|
-
console.log(`β
Registered component: ${
|
|
1010
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1011
|
-
}),
|
|
1007
|
+
M = await U();
|
|
1008
|
+
const i = await De();
|
|
1009
|
+
console.log(`β
Registered component: ${M}`), console.log(`π‘ Access at: http://localhost:${m}/view/${M}/`), console.log(`π All registered components: ${i.registered.join(", ")}`), ze(() => {
|
|
1010
|
+
process.env.MYOP_NO_BROWSER || f(`http://localhost:${m}/view/${M}/`);
|
|
1011
|
+
}), We();
|
|
1012
1012
|
} catch (i) {
|
|
1013
1013
|
console.error("β Failed to register component:", i.message), process.exit(1);
|
|
1014
1014
|
}
|
|
1015
1015
|
} else
|
|
1016
1016
|
console.error("β Management server error:", a.message), process.exit(1);
|
|
1017
|
-
}),
|
|
1017
|
+
}), xe.on("upgrade", st), xe.listen(p, async () => {
|
|
1018
1018
|
Re = !0, console.log(`
|
|
1019
|
-
π Starting shared dev server...`), console.log(`π‘ Management server on port ${p}`),
|
|
1019
|
+
π Starting shared dev server...`), console.log(`π‘ Management server on port ${p}`), me.on("error", (a) => {
|
|
1020
1020
|
console.error("β Main server error:", a.message), process.exit(1);
|
|
1021
|
-
}),
|
|
1022
|
-
console.log(`π‘ Main server running at http://localhost:${
|
|
1021
|
+
}), me.listen(m, async () => {
|
|
1022
|
+
console.log(`π‘ Main server running at http://localhost:${m}`), (M === "DEV" || M === "NEW") && (M = "DEV1");
|
|
1023
1023
|
const a = x ? e.default.resolve(F) : e.default.resolve(F, S);
|
|
1024
|
-
T.set(
|
|
1024
|
+
T.set(M, {
|
|
1025
1025
|
path: a,
|
|
1026
1026
|
name: I,
|
|
1027
|
-
htmlFile: x ?
|
|
1027
|
+
htmlFile: x ? C : null
|
|
1028
1028
|
});
|
|
1029
1029
|
const i = I ? ` (${I})` : "";
|
|
1030
|
-
console.log(`β
Registered component: ${
|
|
1031
|
-
process.env.MYOP_NO_BROWSER ||
|
|
1030
|
+
console.log(`β
Registered component: ${M}${i}`), console.log(`π‘ Access at: http://localhost:${m}/view/${M}/`), ze(() => {
|
|
1031
|
+
process.env.MYOP_NO_BROWSER || f(`http://localhost:${m}/view/${M}/`);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
});
|
|
@@ -1083,15 +1083,15 @@ const O = class O {
|
|
|
1083
1083
|
const e = this.components.length, t = 38;
|
|
1084
1084
|
let n;
|
|
1085
1085
|
this.cols >= t * 3 + 4 ? n = Math.min(e, 3) : this.cols >= t * 2 + 2 ? n = Math.min(e, 2) : n = 1;
|
|
1086
|
-
const r = Math.ceil(e / n), s = Math.floor(this.cols / n), d = 2,
|
|
1087
|
-
this.visibleLogLines = Math.max(2,
|
|
1086
|
+
const r = Math.ceil(e / n), s = Math.floor(this.cols / n), d = 2, $ = this.rows - d - 2, m = Math.floor($ / r);
|
|
1087
|
+
this.visibleLogLines = Math.max(2, m - 4), this.layout = { panelsPerRow: n, panelWidth: s, numRows: r, panelHeight: m }, this.panelPositions.clear();
|
|
1088
1088
|
for (let p = 0; p < e; p++) {
|
|
1089
|
-
const S = this.components[p],
|
|
1089
|
+
const S = this.components[p], g = Math.floor(p / n), b = p % n;
|
|
1090
1090
|
this.panelPositions.set(S.name, {
|
|
1091
|
-
row: d + 1 +
|
|
1091
|
+
row: d + 1 + g * m,
|
|
1092
1092
|
col: b * s + 1,
|
|
1093
1093
|
width: s,
|
|
1094
|
-
height:
|
|
1094
|
+
height: m
|
|
1095
1095
|
});
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
@@ -1139,33 +1139,33 @@ const O = class O {
|
|
|
1139
1139
|
renderPanel(e) {
|
|
1140
1140
|
const t = O.C, n = O.STATUS, r = this.panelPositions.get(e);
|
|
1141
1141
|
if (!r) return;
|
|
1142
|
-
const s = this.components.findIndex((U) => U.name === e), d = this.components[s],
|
|
1143
|
-
let H = `${x}ββ${t.reset} ${p}${
|
|
1144
|
-
H += `${t.bold}${L}${t.reset} ${t.gray}β${t.reset} ${p}${
|
|
1145
|
-
const
|
|
1146
|
-
H += `${x}${"β".repeat(Math.max(0, b -
|
|
1142
|
+
const s = this.components.findIndex((U) => U.name === e), d = this.components[s], w = s === this.selectedPanel, $ = this.statusKeys.get(e) || "initializing", m = n[$], p = t[m.color], S = this.logs.get(e) || [], g = this.scrollPos.get(e) || 0, b = r.width - 1, x = w ? t.cyan : t.gray, C = [], L = d.name.substring(0, b - 20);
|
|
1143
|
+
let H = `${x}ββ${t.reset} ${p}${m.icon}${t.reset} `;
|
|
1144
|
+
H += `${t.bold}${L}${t.reset} ${t.gray}β${t.reset} ${p}${m.label}${t.reset} `;
|
|
1145
|
+
const f = 5 + L.length + m.label.length + 3;
|
|
1146
|
+
H += `${x}${"β".repeat(Math.max(0, b - f))}β${t.reset}`, C.push(O.ESC.moveTo(r.row, r.col) + H);
|
|
1147
1147
|
const P = (d.path || "").substring(0, b - 6);
|
|
1148
1148
|
let E = `${x}β${t.reset} ${t.dim}${P}${t.reset}`;
|
|
1149
|
-
E += " ".repeat(Math.max(0, b - P.length - 3)), E += `${x}β${t.reset}`,
|
|
1150
|
-
const
|
|
1151
|
-
let
|
|
1152
|
-
I && (
|
|
1153
|
-
const
|
|
1149
|
+
E += " ".repeat(Math.max(0, b - P.length - 3)), E += `${x}β${t.reset}`, C.push(O.ESC.moveTo(r.row + 1, r.col) + E);
|
|
1150
|
+
const M = S.length, I = M > this.visibleLogLines ? `${g + 1}-${Math.min(g + this.visibleLogLines, M)}/${M}` : "";
|
|
1151
|
+
let _ = `${x}β${"β".repeat(b - I.length - 4)}${t.reset}`;
|
|
1152
|
+
I && (_ += `${t.dim}${I}${t.reset}`), _ += `${x}${"β".repeat(2)}β€${t.reset}`, C.push(O.ESC.moveTo(r.row + 2, r.col) + _);
|
|
1153
|
+
const te = S.slice(g, g + this.visibleLogLines);
|
|
1154
1154
|
for (let U = 0; U < this.visibleLogLines; U++) {
|
|
1155
|
-
const F =
|
|
1155
|
+
const F = te[U];
|
|
1156
1156
|
let G = `${x}β${t.reset}`;
|
|
1157
1157
|
if (F) {
|
|
1158
1158
|
let T = t.white;
|
|
1159
1159
|
F.type === "success" ? T = t.green : F.type === "error" ? T = t.red : F.type === "warning" ? T = t.yellow : F.type === "hmr" ? T = t.magenta : F.type === "change" && (T = t.blue);
|
|
1160
1160
|
const Y = F.message.substring(0, b - 12);
|
|
1161
1161
|
G += `${t.dim}${F.timestamp}${t.reset} ${T}${Y}${t.reset}`;
|
|
1162
|
-
const
|
|
1163
|
-
G += " ".repeat(Math.max(0,
|
|
1162
|
+
const $e = b - F.timestamp.length - Y.length - 2;
|
|
1163
|
+
G += " ".repeat(Math.max(0, $e));
|
|
1164
1164
|
} else
|
|
1165
1165
|
G += " ".repeat(b - 2);
|
|
1166
|
-
G += `${x}β${t.reset}`,
|
|
1166
|
+
G += `${x}β${t.reset}`, C.push(O.ESC.moveTo(r.row + 3 + U, r.col) + G);
|
|
1167
1167
|
}
|
|
1168
|
-
|
|
1168
|
+
C.push(O.ESC.moveTo(r.row + 3 + this.visibleLogLines, r.col) + `${x}β${"β".repeat(b - 2)}β${t.reset}`), process.stdout.write(C.join(""));
|
|
1169
1169
|
}
|
|
1170
1170
|
fullRender() {
|
|
1171
1171
|
const e = O.C;
|
|
@@ -1189,14 +1189,14 @@ const O = class O {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
// ANSI escape codes
|
|
1192
|
-
|
|
1192
|
+
he(O, "ESC", {
|
|
1193
1193
|
moveTo: (e, t) => `\x1B[${e};${t}H`,
|
|
1194
1194
|
hideCursor: "\x1B[?25l",
|
|
1195
1195
|
showCursor: "\x1B[?25h",
|
|
1196
1196
|
clearScreen: "\x1B[2J",
|
|
1197
1197
|
clearLine: "\x1B[2K"
|
|
1198
1198
|
}), // Colors
|
|
1199
|
-
|
|
1199
|
+
he(O, "C", {
|
|
1200
1200
|
reset: "\x1B[0m",
|
|
1201
1201
|
bold: "\x1B[1m",
|
|
1202
1202
|
dim: "\x1B[2m",
|
|
@@ -1211,7 +1211,7 @@ fe(O, "C", {
|
|
|
1211
1211
|
bgCyan: "\x1B[46m",
|
|
1212
1212
|
black: "\x1B[30m"
|
|
1213
1213
|
}), // Status configs
|
|
1214
|
-
|
|
1214
|
+
he(O, "STATUS", {
|
|
1215
1215
|
initializing: { icon: "β", color: "yellow", label: "Initializing" },
|
|
1216
1216
|
starting: { icon: "β", color: "yellow", label: "Starting" },
|
|
1217
1217
|
building: { icon: "β³", color: "yellow", label: "Building" },
|
|
@@ -1224,18 +1224,18 @@ fe(O, "STATUS", {
|
|
|
1224
1224
|
warning: { icon: "β ", color: "yellow", label: "Warning" },
|
|
1225
1225
|
stopped: { icon: "β ", color: "gray", label: "Stopped" }
|
|
1226
1226
|
});
|
|
1227
|
-
let
|
|
1228
|
-
async function
|
|
1227
|
+
let je = O;
|
|
1228
|
+
async function It(o) {
|
|
1229
1229
|
const { spawn: e, exec: t } = await import("child_process"), n = await import("path"), r = o.map((p) => ({
|
|
1230
1230
|
name: p.name,
|
|
1231
1231
|
path: p.path,
|
|
1232
1232
|
id: p.componentId || ""
|
|
1233
|
-
})), s = new
|
|
1233
|
+
})), s = new je(r), d = [], w = (p) => {
|
|
1234
1234
|
const S = process.platform;
|
|
1235
|
-
let
|
|
1236
|
-
S === "darwin" ?
|
|
1235
|
+
let g;
|
|
1236
|
+
S === "darwin" ? g = `open "${p}"` : S === "win32" ? g = `start "" "${p}"` : g = `xdg-open "${p}"`, t(g, () => {
|
|
1237
1237
|
});
|
|
1238
|
-
},
|
|
1238
|
+
}, $ = () => {
|
|
1239
1239
|
s.clear(), console.log(`
|
|
1240
1240
|
π Shutting down all components...`), d.forEach((p) => {
|
|
1241
1241
|
try {
|
|
@@ -1244,105 +1244,105 @@ async function Tt(o) {
|
|
|
1244
1244
|
}
|
|
1245
1245
|
}), setTimeout(() => process.exit(0), 500);
|
|
1246
1246
|
};
|
|
1247
|
-
process.on("SIGINT",
|
|
1248
|
-
const
|
|
1247
|
+
process.on("SIGINT", $), process.on("SIGTERM", $);
|
|
1248
|
+
const m = process.argv[1];
|
|
1249
1249
|
for (let p = 0; p < o.length; p++) {
|
|
1250
|
-
const S = o[p],
|
|
1251
|
-
s.setStatus(
|
|
1252
|
-
const b = e("node", [
|
|
1250
|
+
const S = o[p], g = S.name;
|
|
1251
|
+
s.setStatus(g, "β³ Starting..."), s.log(g, `Starting in ${S.path}`);
|
|
1252
|
+
const b = e("node", [m, "dev"], {
|
|
1253
1253
|
cwd: n.default.resolve(S.path),
|
|
1254
1254
|
env: { ...process.env, FORCE_COLOR: "1", MYOP_NO_BROWSER: "1" },
|
|
1255
1255
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1256
1256
|
});
|
|
1257
1257
|
d.push(b);
|
|
1258
1258
|
let x = "";
|
|
1259
|
-
b.stdout.on("data", (
|
|
1260
|
-
x +=
|
|
1259
|
+
b.stdout.on("data", (C) => {
|
|
1260
|
+
x += C.toString();
|
|
1261
1261
|
const L = x.split(`
|
|
1262
1262
|
`);
|
|
1263
1263
|
x = L.pop() || "";
|
|
1264
1264
|
for (const H of L) {
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1265
|
+
const f = H.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1266
|
+
f && (f.includes("Registered component") || f.includes("Registered:") ? s.setStatus(g, "β
Ready") : f.includes("Building...") || f.includes("Running initial build") ? s.setStatus(g, "π¨ Building...") : f.includes("Build completed") || f.includes("Build succeeded") ? s.setStatus(g, "β
Ready") : f.includes("Build failed") ? s.setStatus(g, "β Build Error") : f.includes("File changed") ? (s.setStatus(g, "π Changed"), setTimeout(() => s.setStatus(g, "β
Ready"), 1500)) : f.includes("Notifying") && f.includes("HMR") ? (s.setStatus(g, "π₯ HMR Update"), setTimeout(() => s.setStatus(g, "β
Ready"), 1e3)) : f.includes("HMR client connected") && (s.setStatus(g, "π₯ HMR Connected"), setTimeout(() => s.setStatus(g, "β
Ready"), 1e3)), !f.includes("Watching") && !f.includes("Press Ctrl+C") && !f.includes("Starting shared") && !f.includes("Management server") && !f.includes("Main server") && !f.includes("Access at:") && !f.includes("No build needed") && s.log(g, f));
|
|
1267
1267
|
}
|
|
1268
|
-
}), b.stderr.on("data", (
|
|
1269
|
-
const L =
|
|
1268
|
+
}), b.stderr.on("data", (C) => {
|
|
1269
|
+
const L = C.toString().split(`
|
|
1270
1270
|
`);
|
|
1271
1271
|
for (const H of L) {
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1272
|
+
const f = H.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").trim();
|
|
1273
|
+
f && (s.log(g, `β οΈ ${f}`), s.setStatus(g, "β οΈ Warning"));
|
|
1274
1274
|
}
|
|
1275
|
-
}), b.on("exit", (
|
|
1276
|
-
|
|
1277
|
-
}), p < o.length - 1 && await new Promise((
|
|
1275
|
+
}), b.on("exit", (C) => {
|
|
1276
|
+
C !== 0 && C !== null && (s.setStatus(g, `β Exited (${C})`), s.log(g, `Process exited with code ${C}`));
|
|
1277
|
+
}), p < o.length - 1 && await new Promise((C) => setTimeout(C, 500));
|
|
1278
1278
|
}
|
|
1279
1279
|
s.render(), setTimeout(() => {
|
|
1280
|
-
|
|
1280
|
+
w("http://localhost:9292");
|
|
1281
1281
|
}, 2e3);
|
|
1282
1282
|
}
|
|
1283
|
-
const
|
|
1283
|
+
const Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1284
1284
|
__proto__: null,
|
|
1285
|
-
devCommand:
|
|
1286
|
-
monorepoDevCommand:
|
|
1287
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1288
|
-
function
|
|
1289
|
-
D.existsSync(
|
|
1285
|
+
devCommand: Le,
|
|
1286
|
+
monorepoDevCommand: It
|
|
1287
|
+
}, Symbol.toStringTag, { value: "Module" })), Ne = ne.join(ht.homedir(), ".myop"), de = ne.join(Ne, "credentials.json");
|
|
1288
|
+
function jt() {
|
|
1289
|
+
D.existsSync(Ne) || D.mkdirSync(Ne, { recursive: !0, mode: 448 });
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function Ae() {
|
|
1292
1292
|
try {
|
|
1293
|
-
if (!D.existsSync(
|
|
1293
|
+
if (!D.existsSync(de))
|
|
1294
1294
|
return null;
|
|
1295
|
-
const o = D.readFileSync(
|
|
1295
|
+
const o = D.readFileSync(de, "utf8");
|
|
1296
1296
|
return JSON.parse(o);
|
|
1297
1297
|
} catch (o) {
|
|
1298
1298
|
return console.info("Failed to read credentials:", o.message), null;
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1302
|
-
|
|
1301
|
+
function et(o) {
|
|
1302
|
+
jt();
|
|
1303
1303
|
const e = {
|
|
1304
1304
|
...o,
|
|
1305
1305
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1306
1306
|
};
|
|
1307
|
-
D.writeFileSync(
|
|
1307
|
+
D.writeFileSync(de, JSON.stringify(e, null, 2), {
|
|
1308
1308
|
mode: 384
|
|
1309
1309
|
// Read/write for owner only
|
|
1310
1310
|
});
|
|
1311
1311
|
}
|
|
1312
|
-
function
|
|
1312
|
+
function tt() {
|
|
1313
1313
|
try {
|
|
1314
|
-
return D.existsSync(
|
|
1314
|
+
return D.existsSync(de) && D.unlinkSync(de), !0;
|
|
1315
1315
|
} catch (o) {
|
|
1316
1316
|
return console.error("Failed to clear credentials:", o.message), !1;
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
|
-
function
|
|
1319
|
+
function Nt(o) {
|
|
1320
1320
|
if (!o || !o.expiresAt)
|
|
1321
1321
|
return !0;
|
|
1322
1322
|
const e = 5 * 60 * 1e3, t = new Date(o.expiresAt).getTime();
|
|
1323
1323
|
return Date.now() > t - e;
|
|
1324
1324
|
}
|
|
1325
1325
|
function be() {
|
|
1326
|
-
const o =
|
|
1326
|
+
const o = Ae();
|
|
1327
1327
|
return o ? {
|
|
1328
1328
|
email: o.userEmail,
|
|
1329
1329
|
userId: o.userId
|
|
1330
1330
|
} : null;
|
|
1331
1331
|
}
|
|
1332
|
-
const
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1332
|
+
const re = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", we = 19284, He = `http://localhost:${we}/callback`, kt = "myop-cli";
|
|
1333
|
+
function _t() {
|
|
1334
|
+
return ke.randomBytes(32).toString("base64url");
|
|
1335
1335
|
}
|
|
1336
|
-
function
|
|
1337
|
-
return
|
|
1336
|
+
function Lt(o) {
|
|
1337
|
+
return ke.createHash("sha256").update(o).digest("base64url");
|
|
1338
1338
|
}
|
|
1339
|
-
async function
|
|
1340
|
-
const o = await fetch(`${
|
|
1339
|
+
async function At() {
|
|
1340
|
+
const o = await fetch(`${re}/oauth/register`, {
|
|
1341
1341
|
method: "POST",
|
|
1342
1342
|
headers: { "Content-Type": "application/json" },
|
|
1343
1343
|
body: JSON.stringify({
|
|
1344
|
-
client_name:
|
|
1345
|
-
redirect_uris: [
|
|
1344
|
+
client_name: kt,
|
|
1345
|
+
redirect_uris: [He],
|
|
1346
1346
|
grant_types: ["authorization_code", "refresh_token"],
|
|
1347
1347
|
response_types: ["code"]
|
|
1348
1348
|
})
|
|
@@ -1353,7 +1353,7 @@ async function _t() {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
return o.json();
|
|
1355
1355
|
}
|
|
1356
|
-
function
|
|
1356
|
+
function ye(o, e, t, n = null) {
|
|
1357
1357
|
const r = {
|
|
1358
1358
|
success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
|
|
1359
1359
|
<circle cx="12" cy="12" r="10"/>
|
|
@@ -1371,7 +1371,7 @@ function ge(o, e, t, n = null) {
|
|
|
1371
1371
|
success: { accent: "#4ade80", glow: "rgba(74, 222, 128, 0.1)" },
|
|
1372
1372
|
error: { accent: "#f87171", glow: "rgba(248, 113, 113, 0.1)" },
|
|
1373
1373
|
warning: { accent: "#fbbf24", glow: "rgba(251, 191, 36, 0.1)" }
|
|
1374
|
-
}, { accent: d, glow:
|
|
1374
|
+
}, { accent: d, glow: w } = s[o] || s.error;
|
|
1375
1375
|
return `<!DOCTYPE html>
|
|
1376
1376
|
<html lang="en">
|
|
1377
1377
|
<head>
|
|
@@ -1464,7 +1464,7 @@ function ge(o, e, t, n = null) {
|
|
|
1464
1464
|
display: inline-flex;
|
|
1465
1465
|
align-items: center;
|
|
1466
1466
|
gap: 8px;
|
|
1467
|
-
background: ${
|
|
1467
|
+
background: ${w};
|
|
1468
1468
|
border: 1px solid ${d}33;
|
|
1469
1469
|
border-radius: 4px;
|
|
1470
1470
|
padding: 10px 16px;
|
|
@@ -1519,23 +1519,23 @@ function ge(o, e, t, n = null) {
|
|
|
1519
1519
|
</body>
|
|
1520
1520
|
</html>`;
|
|
1521
1521
|
}
|
|
1522
|
-
function
|
|
1522
|
+
function Ht(o) {
|
|
1523
1523
|
return new Promise((e, t) => {
|
|
1524
|
-
const n =
|
|
1525
|
-
const d = new
|
|
1524
|
+
const n = gt.createServer((r, s) => {
|
|
1525
|
+
const d = new Ye(r.url, `http://localhost:${we}`);
|
|
1526
1526
|
if (d.pathname === "/callback") {
|
|
1527
|
-
const
|
|
1528
|
-
if (
|
|
1529
|
-
s.writeHead(200, { "Content-Type": "text/html" }), s.end(
|
|
1527
|
+
const w = d.searchParams.get("code"), $ = d.searchParams.get("state"), m = d.searchParams.get("error");
|
|
1528
|
+
if (m) {
|
|
1529
|
+
s.writeHead(200, { "Content-Type": "text/html" }), s.end(ye(
|
|
1530
1530
|
"error",
|
|
1531
1531
|
"Authentication Failed",
|
|
1532
1532
|
"Unable to complete the authentication process.",
|
|
1533
|
-
|
|
1534
|
-
)), n.close(), t(new Error(`OAuth error: ${
|
|
1533
|
+
m
|
|
1534
|
+
)), n.close(), t(new Error(`OAuth error: ${m}`));
|
|
1535
1535
|
return;
|
|
1536
1536
|
}
|
|
1537
|
-
if (
|
|
1538
|
-
s.writeHead(400, { "Content-Type": "text/html" }), s.end(
|
|
1537
|
+
if ($ !== o) {
|
|
1538
|
+
s.writeHead(400, { "Content-Type": "text/html" }), s.end(ye(
|
|
1539
1539
|
"warning",
|
|
1540
1540
|
"Security Error",
|
|
1541
1541
|
"State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
|
|
@@ -1543,8 +1543,8 @@ function kt(o) {
|
|
|
1543
1543
|
)), n.close(), t(new Error("State mismatch"));
|
|
1544
1544
|
return;
|
|
1545
1545
|
}
|
|
1546
|
-
if (!
|
|
1547
|
-
s.writeHead(400, { "Content-Type": "text/html" }), s.end(
|
|
1546
|
+
if (!w) {
|
|
1547
|
+
s.writeHead(400, { "Content-Type": "text/html" }), s.end(ye(
|
|
1548
1548
|
"error",
|
|
1549
1549
|
"Missing Authorization Code",
|
|
1550
1550
|
"No authorization code was received from the server.",
|
|
@@ -1552,30 +1552,30 @@ function kt(o) {
|
|
|
1552
1552
|
)), n.close(), t(new Error("No authorization code"));
|
|
1553
1553
|
return;
|
|
1554
1554
|
}
|
|
1555
|
-
s.writeHead(200, { "Content-Type": "text/html" }), s.end(
|
|
1555
|
+
s.writeHead(200, { "Content-Type": "text/html" }), s.end(ye(
|
|
1556
1556
|
"success",
|
|
1557
1557
|
"Authentication Successful",
|
|
1558
1558
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1559
|
-
)), n.close(), e(
|
|
1559
|
+
)), n.close(), e(w);
|
|
1560
1560
|
} else
|
|
1561
1561
|
s.writeHead(404), s.end("Not found");
|
|
1562
1562
|
});
|
|
1563
|
-
n.listen(
|
|
1564
|
-
console.info(`OAuth callback server listening on port ${
|
|
1563
|
+
n.listen(we, () => {
|
|
1564
|
+
console.info(`OAuth callback server listening on port ${we}`);
|
|
1565
1565
|
}), setTimeout(() => {
|
|
1566
1566
|
n.close(), t(new Error("Authentication timed out"));
|
|
1567
1567
|
}, 5 * 60 * 1e3);
|
|
1568
1568
|
});
|
|
1569
1569
|
}
|
|
1570
|
-
async function
|
|
1571
|
-
const n = await fetch(`${
|
|
1570
|
+
async function Dt(o, e, t) {
|
|
1571
|
+
const n = await fetch(`${re}/oauth/token`, {
|
|
1572
1572
|
method: "POST",
|
|
1573
1573
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1574
|
-
body: new
|
|
1574
|
+
body: new Ke({
|
|
1575
1575
|
grant_type: "authorization_code",
|
|
1576
1576
|
code: o,
|
|
1577
1577
|
client_id: e,
|
|
1578
|
-
redirect_uri:
|
|
1578
|
+
redirect_uri: He,
|
|
1579
1579
|
code_verifier: t
|
|
1580
1580
|
})
|
|
1581
1581
|
});
|
|
@@ -1585,11 +1585,11 @@ async function Lt(o, e, t) {
|
|
|
1585
1585
|
}
|
|
1586
1586
|
return n.json();
|
|
1587
1587
|
}
|
|
1588
|
-
async function
|
|
1589
|
-
const t = await fetch(`${
|
|
1588
|
+
async function Ut(o, e) {
|
|
1589
|
+
const t = await fetch(`${re}/oauth/token`, {
|
|
1590
1590
|
method: "POST",
|
|
1591
1591
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1592
|
-
body: new
|
|
1592
|
+
body: new Ke({
|
|
1593
1593
|
grant_type: "refresh_token",
|
|
1594
1594
|
refresh_token: o,
|
|
1595
1595
|
client_id: e
|
|
@@ -1601,9 +1601,9 @@ async function At(o, e) {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
return t.json();
|
|
1603
1603
|
}
|
|
1604
|
-
async function
|
|
1604
|
+
async function Bt(o) {
|
|
1605
1605
|
var r, s, d;
|
|
1606
|
-
const e = await fetch(`${
|
|
1606
|
+
const e = await fetch(`${re}/mcp`, {
|
|
1607
1607
|
method: "POST",
|
|
1608
1608
|
headers: {
|
|
1609
1609
|
"Content-Type": "application/json",
|
|
@@ -1629,52 +1629,52 @@ async function Ht(o) {
|
|
|
1629
1629
|
return JSON.parse(n);
|
|
1630
1630
|
throw new Error("Invalid response from whoami");
|
|
1631
1631
|
}
|
|
1632
|
-
async function
|
|
1632
|
+
async function ce() {
|
|
1633
1633
|
const o = V("Starting authentication...").start();
|
|
1634
1634
|
try {
|
|
1635
1635
|
o.text = "Registering OAuth client...";
|
|
1636
|
-
const t = (await
|
|
1636
|
+
const t = (await At()).client_id, n = _t(), r = Lt(n), s = ke.randomBytes(16).toString("hex");
|
|
1637
1637
|
o.text = "Waiting for authorization...";
|
|
1638
|
-
const d =
|
|
1639
|
-
|
|
1640
|
-
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${
|
|
1641
|
-
`), await
|
|
1642
|
-
const
|
|
1638
|
+
const d = Ht(s), w = new Ye(`${re}/oauth/authorize`);
|
|
1639
|
+
w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", t), w.searchParams.set("redirect_uri", He), w.searchParams.set("code_challenge", r), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", s), o.stop(), console.log(`
|
|
1640
|
+
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
|
|
1641
|
+
`), await ft(w.toString());
|
|
1642
|
+
const $ = await d;
|
|
1643
1643
|
o.start("Exchanging authorization code...");
|
|
1644
|
-
const
|
|
1644
|
+
const m = await Dt($, t, n);
|
|
1645
1645
|
o.text = "Getting user info...";
|
|
1646
|
-
const p = await
|
|
1647
|
-
accessToken:
|
|
1648
|
-
refreshToken:
|
|
1649
|
-
expiresAt: new Date(Date.now() +
|
|
1646
|
+
const p = await Bt(m.access_token), S = {
|
|
1647
|
+
accessToken: m.access_token,
|
|
1648
|
+
refreshToken: m.refresh_token,
|
|
1649
|
+
expiresAt: new Date(Date.now() + m.expires_in * 1e3).toISOString(),
|
|
1650
1650
|
clientId: t,
|
|
1651
1651
|
userId: p.userId,
|
|
1652
1652
|
userEmail: p.email
|
|
1653
1653
|
};
|
|
1654
|
-
return
|
|
1654
|
+
return et(S), o.succeed(`Authenticated as ${p.email}`), S;
|
|
1655
1655
|
} catch (e) {
|
|
1656
1656
|
throw o.fail(`Authentication failed: ${e.message}`), e;
|
|
1657
1657
|
}
|
|
1658
1658
|
}
|
|
1659
|
-
async function
|
|
1660
|
-
const o =
|
|
1659
|
+
async function ot() {
|
|
1660
|
+
const o = Ae();
|
|
1661
1661
|
if (!o) {
|
|
1662
1662
|
console.log("Not currently logged in.");
|
|
1663
1663
|
return;
|
|
1664
1664
|
}
|
|
1665
|
-
|
|
1665
|
+
tt(), console.log(`β
Logged out (was: ${o.userEmail})`);
|
|
1666
1666
|
}
|
|
1667
|
-
async function
|
|
1668
|
-
let o =
|
|
1667
|
+
async function Jt() {
|
|
1668
|
+
let o = Ae();
|
|
1669
1669
|
if (!o)
|
|
1670
1670
|
return console.log(`Not logged in. Starting authentication...
|
|
1671
|
-
`), await
|
|
1672
|
-
if (!
|
|
1671
|
+
`), await ce();
|
|
1672
|
+
if (!Nt(o))
|
|
1673
1673
|
return o;
|
|
1674
1674
|
if (o.refreshToken) {
|
|
1675
1675
|
const e = V("Refreshing access token...").start();
|
|
1676
1676
|
try {
|
|
1677
|
-
const t = await
|
|
1677
|
+
const t = await Ut(
|
|
1678
1678
|
o.refreshToken,
|
|
1679
1679
|
o.clientId
|
|
1680
1680
|
);
|
|
@@ -1683,27 +1683,41 @@ async function Dt() {
|
|
|
1683
1683
|
accessToken: t.access_token,
|
|
1684
1684
|
refreshToken: t.refresh_token,
|
|
1685
1685
|
expiresAt: new Date(Date.now() + t.expires_in * 1e3).toISOString()
|
|
1686
|
-
},
|
|
1686
|
+
}, et(o), e.succeed("Token refreshed"), o;
|
|
1687
1687
|
} catch {
|
|
1688
|
-
return e.warn("Token refresh failed, please log in again"),
|
|
1688
|
+
return e.warn("Token refresh failed, please log in again"), tt(), await ce();
|
|
1689
1689
|
}
|
|
1690
1690
|
}
|
|
1691
1691
|
return console.log(`Session expired. Please log in again.
|
|
1692
|
-
`), await
|
|
1692
|
+
`), await ce();
|
|
1693
|
+
}
|
|
1694
|
+
function zt() {
|
|
1695
|
+
return re;
|
|
1693
1696
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1697
|
+
const K = "@myop/cli", Ie = process.platform === "win32";
|
|
1698
|
+
function Wt() {
|
|
1699
|
+
try {
|
|
1700
|
+
return Q("npm config get registry", { encoding: "utf-8" }).trim() || "https://registry.npmjs.org/";
|
|
1701
|
+
} catch {
|
|
1702
|
+
return "https://registry.npmjs.org/";
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
function Vt() {
|
|
1706
|
+
try {
|
|
1707
|
+
return Q("npm config get prefix", { encoding: "utf-8" }).trim();
|
|
1708
|
+
} catch {
|
|
1709
|
+
return null;
|
|
1710
|
+
}
|
|
1696
1711
|
}
|
|
1697
|
-
|
|
1698
|
-
async function Bt() {
|
|
1712
|
+
async function Gt() {
|
|
1699
1713
|
try {
|
|
1700
|
-
const o = await fetch(
|
|
1701
|
-
return
|
|
1714
|
+
const o = Wt().replace(/\/$/, ""), e = await fetch(`${o}/${K}/latest`);
|
|
1715
|
+
return e.ok ? (await e.json()).version : null;
|
|
1702
1716
|
} catch {
|
|
1703
1717
|
return null;
|
|
1704
1718
|
}
|
|
1705
1719
|
}
|
|
1706
|
-
function
|
|
1720
|
+
function Yt(o, e) {
|
|
1707
1721
|
const t = o.split(".").map(Number), n = e.split(".").map(Number);
|
|
1708
1722
|
for (let r = 0; r < Math.max(t.length, n.length); r++) {
|
|
1709
1723
|
const s = t[r] || 0, d = n[r] || 0;
|
|
@@ -1712,19 +1726,19 @@ function Jt(o, e) {
|
|
|
1712
1726
|
}
|
|
1713
1727
|
return 0;
|
|
1714
1728
|
}
|
|
1715
|
-
async function
|
|
1729
|
+
async function Kt(o) {
|
|
1716
1730
|
const e = V({
|
|
1717
1731
|
text: "Checking for updates...",
|
|
1718
1732
|
color: "cyan"
|
|
1719
|
-
}).start(), t = await
|
|
1720
|
-
if (e.stop(), !t ||
|
|
1733
|
+
}).start(), t = await Gt();
|
|
1734
|
+
if (e.stop(), !t || Yt(t, o) <= 0)
|
|
1721
1735
|
return !1;
|
|
1722
1736
|
console.log(`
|
|
1723
1737
|
π¦ New version available: ${o} β ${t}
|
|
1724
1738
|
`);
|
|
1725
1739
|
let n;
|
|
1726
1740
|
try {
|
|
1727
|
-
n = await
|
|
1741
|
+
n = await Ge({
|
|
1728
1742
|
message: "Would you like to update now?",
|
|
1729
1743
|
choices: [
|
|
1730
1744
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1739,46 +1753,77 @@ async function zt(o) {
|
|
|
1739
1753
|
}
|
|
1740
1754
|
if (n) {
|
|
1741
1755
|
const r = V({
|
|
1742
|
-
text: `Updating ${
|
|
1756
|
+
text: `Updating ${K} to v${t}...`,
|
|
1743
1757
|
color: "green"
|
|
1744
|
-
}).start();
|
|
1758
|
+
}).start(), s = `npm install -g ${K}@latest`, d = Vt();
|
|
1745
1759
|
try {
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1760
|
+
Q(s, { stdio: "pipe" }), r.succeed(`Updated to v${t}`);
|
|
1761
|
+
} catch {
|
|
1762
|
+
r.stop(), console.log(`
|
|
1763
|
+
π Elevated permissions required.
|
|
1764
|
+
`);
|
|
1765
|
+
try {
|
|
1766
|
+
if (Ie) {
|
|
1767
|
+
const p = `Start-Process -FilePath 'cmd' -ArgumentList '/c npm ${d ? `install -g ${K}@latest --prefix \\"${d}\\"` : `install -g ${K}@latest`}' -Verb RunAs -Wait`;
|
|
1768
|
+
Q(`powershell -Command "${p}"`, { stdio: "inherit" });
|
|
1769
|
+
} else {
|
|
1770
|
+
const m = d ? `sudo npm install -g ${K}@latest --prefix "${d}"` : `sudo ${s}`;
|
|
1771
|
+
Q(m, { stdio: "inherit" });
|
|
1772
|
+
}
|
|
1773
|
+
console.log(`
|
|
1774
|
+
β
Updated to v${t}`);
|
|
1775
|
+
} catch {
|
|
1776
|
+
console.log(`
|
|
1777
|
+
β Update failed`);
|
|
1778
|
+
const p = Ie ? `npm install -g ${K}@latest (run as Administrator)` : `sudo npm install -g ${K}@latest`;
|
|
1779
|
+
console.log(`
|
|
1780
|
+
Please run manually: ${p}
|
|
1781
|
+
`), process.exit(1);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
let w = null;
|
|
1785
|
+
try {
|
|
1786
|
+
let $;
|
|
1787
|
+
d ? $ = Ie ? Ee(d, "node_modules") : Ee(d, "lib", "node_modules") : $ = Q("npm root -g", { encoding: "utf-8" }).trim();
|
|
1788
|
+
const m = Ee($, K, "package.json"), p = ut(m, "utf-8");
|
|
1789
|
+
w = JSON.parse(p).version;
|
|
1790
|
+
} catch {
|
|
1791
|
+
}
|
|
1792
|
+
if (w === t)
|
|
1793
|
+
return console.log(`
|
|
1794
|
+
π Restarting...
|
|
1795
|
+
`), mt(process.argv[0], process.argv.slice(1), {
|
|
1749
1796
|
stdio: "inherit",
|
|
1750
1797
|
shell: !0
|
|
1751
|
-
}).on("close", (
|
|
1752
|
-
process.exit(
|
|
1798
|
+
}).on("close", (m) => {
|
|
1799
|
+
process.exit(m || 0);
|
|
1753
1800
|
}), !0;
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
`), !1;
|
|
1758
|
-
}
|
|
1801
|
+
console.log(`
|
|
1802
|
+
Please run myop again to use the new version.
|
|
1803
|
+
`), process.exit(0);
|
|
1759
1804
|
}
|
|
1760
1805
|
return !1;
|
|
1761
1806
|
}
|
|
1762
|
-
const
|
|
1807
|
+
const Qt = (o) => new Promise((e) => setTimeout(e, o)), nt = (o = ".", e = 3, t = 0) => {
|
|
1763
1808
|
const n = [];
|
|
1764
1809
|
if (t > e) return n;
|
|
1765
1810
|
try {
|
|
1766
1811
|
const r = D.readdirSync(o, { withFileTypes: !0 });
|
|
1767
1812
|
for (const s of r) {
|
|
1768
|
-
const d =
|
|
1813
|
+
const d = ne.join(o, s.name);
|
|
1769
1814
|
if (s.isDirectory()) {
|
|
1770
1815
|
if (s.name === "node_modules" || s.name === ".git" || s.name === "dist" || s.name.startsWith("."))
|
|
1771
1816
|
continue;
|
|
1772
|
-
n.push(...
|
|
1817
|
+
n.push(...nt(d, e, t + 1));
|
|
1773
1818
|
} else if (s.name === "myop.config.json")
|
|
1774
1819
|
try {
|
|
1775
|
-
const
|
|
1820
|
+
const w = D.readFileSync(d, "utf-8"), $ = JSON.parse(w);
|
|
1776
1821
|
n.push({
|
|
1777
1822
|
path: o,
|
|
1778
1823
|
configPath: d,
|
|
1779
|
-
name:
|
|
1780
|
-
componentId:
|
|
1781
|
-
config:
|
|
1824
|
+
name: $.name || $.componentName || ne.basename(o),
|
|
1825
|
+
componentId: $.componentId || null,
|
|
1826
|
+
config: $
|
|
1782
1827
|
});
|
|
1783
1828
|
} catch {
|
|
1784
1829
|
}
|
|
@@ -1796,7 +1841,7 @@ const Se = (o = !1) => {
|
|
|
1796
1841
|
verbose: e
|
|
1797
1842
|
};
|
|
1798
1843
|
try {
|
|
1799
|
-
return y.myopConfig =
|
|
1844
|
+
return y.myopConfig = wt(y.options.configPath), { configFound: !0 };
|
|
1800
1845
|
} catch (t) {
|
|
1801
1846
|
if (o) {
|
|
1802
1847
|
console.info(`
|
|
@@ -1806,7 +1851,7 @@ const Se = (o = !1) => {
|
|
|
1806
1851
|
author: "@myop-cli",
|
|
1807
1852
|
flows: []
|
|
1808
1853
|
};
|
|
1809
|
-
return
|
|
1854
|
+
return _e(y.options.configPath, n), y.myopConfig = n, { configFound: !0 };
|
|
1810
1855
|
} catch {
|
|
1811
1856
|
return console.info("Error details :", t), { configFound: !1, error: t };
|
|
1812
1857
|
}
|
|
@@ -1815,95 +1860,95 @@ const Se = (o = !1) => {
|
|
|
1815
1860
|
}
|
|
1816
1861
|
};
|
|
1817
1862
|
[
|
|
1818
|
-
new
|
|
1819
|
-
...
|
|
1863
|
+
new Fe(),
|
|
1864
|
+
...Mt
|
|
1820
1865
|
];
|
|
1821
|
-
const
|
|
1822
|
-
y.program = new
|
|
1823
|
-
y.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(
|
|
1824
|
-
y.program.addOption(new
|
|
1825
|
-
y.program.addOption(new
|
|
1826
|
-
y.program.addOption(new
|
|
1827
|
-
y.program.addOption(new
|
|
1828
|
-
y.program.addOption(new
|
|
1866
|
+
const Zt = "0.1.40";
|
|
1867
|
+
y.program = new pt();
|
|
1868
|
+
y.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(Zt);
|
|
1869
|
+
y.program.addOption(new pe("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
1870
|
+
y.program.addOption(new pe("-h, --help", "Show helpful information"));
|
|
1871
|
+
y.program.addOption(new pe("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
|
|
1872
|
+
y.program.addOption(new pe("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
|
|
1873
|
+
y.program.addOption(new pe("-m, --monorepo", "Monorepo mode: scan for all myop.config.json files in nested directories"));
|
|
1829
1874
|
y.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((o, e) => {
|
|
1830
|
-
Se(!0), console.info("adding ", o, e, y.options.configPath), o === "flow" &&
|
|
1875
|
+
Se(!0), console.info("adding ", o, e, y.options.configPath), o === "flow" && Ze._action(e), process.exit();
|
|
1831
1876
|
});
|
|
1832
1877
|
y.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((o, e) => {
|
|
1833
|
-
Se(), console.info("removing ", o, e, y.options.configPath), o === "flow" &&
|
|
1878
|
+
Se(), console.info("removing ", o, e, y.options.configPath), o === "flow" && Xe._action(e), process.exit();
|
|
1834
1879
|
});
|
|
1835
1880
|
y.program.command("install").description("Install Myop assets").action(async () => {
|
|
1836
|
-
Se(), await
|
|
1881
|
+
Se(), await Qe.action();
|
|
1837
1882
|
});
|
|
1838
1883
|
y.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1839
1884
|
try {
|
|
1840
|
-
await
|
|
1885
|
+
await ce();
|
|
1841
1886
|
} catch (o) {
|
|
1842
1887
|
console.error("Login failed:", o.message), process.exit(1);
|
|
1843
1888
|
}
|
|
1844
1889
|
process.exit(0);
|
|
1845
1890
|
});
|
|
1846
1891
|
y.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1847
|
-
await
|
|
1892
|
+
await ot(), process.exit(0);
|
|
1848
1893
|
});
|
|
1849
1894
|
y.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1850
1895
|
const o = be();
|
|
1851
1896
|
o && o.email ? console.log(`Logged in as: ${o.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
|
|
1852
1897
|
});
|
|
1853
1898
|
y.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (o) => {
|
|
1854
|
-
var
|
|
1899
|
+
var g, b, x, C, L, H;
|
|
1855
1900
|
const e = y.program.getOptionValue("config") || "./myop.config.json", t = await import("fs"), { execSync: n } = await import("child_process"), r = await import("path");
|
|
1856
1901
|
let s = {};
|
|
1857
1902
|
if (t.existsSync(e))
|
|
1858
1903
|
try {
|
|
1859
|
-
const
|
|
1860
|
-
s = JSON.parse(
|
|
1904
|
+
const f = t.readFileSync(e, "utf-8");
|
|
1905
|
+
s = JSON.parse(f);
|
|
1861
1906
|
const P = s.name || s.componentName;
|
|
1862
1907
|
console.log(`π Found config: ${P || "Unnamed component"}`), s.componentId && console.log(` Component ID: ${s.componentId}`);
|
|
1863
|
-
} catch (
|
|
1864
|
-
console.error(`β οΈ Failed to parse ${e}:`,
|
|
1908
|
+
} catch (f) {
|
|
1909
|
+
console.error(`β οΈ Failed to parse ${e}:`, f.message);
|
|
1865
1910
|
}
|
|
1866
1911
|
else
|
|
1867
1912
|
console.log("β οΈ No myop.config.json found. A new component will be created.");
|
|
1868
1913
|
if (!o.skipBuild) {
|
|
1869
|
-
const { exec:
|
|
1914
|
+
const { exec: f } = await import("child_process");
|
|
1870
1915
|
let P = { hasTriedPlatformFix: !1, hasTriedInstall: !1 };
|
|
1871
|
-
const E = (I = !1) => new Promise((
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1916
|
+
const E = (I = !1) => new Promise((_) => {
|
|
1917
|
+
const te = V(I ? "Retrying build..." : "Building project...").start();
|
|
1918
|
+
f("npm run build", { maxBuffer: 10 * 1024 * 1024 }, async (U, F, G) => {
|
|
1874
1919
|
if (!U) {
|
|
1875
|
-
|
|
1920
|
+
te.succeed("Build completed"), _(!0);
|
|
1876
1921
|
return;
|
|
1877
1922
|
}
|
|
1878
|
-
if (
|
|
1879
|
-
const T = await
|
|
1923
|
+
if (te.fail("Build failed"), !P.hasTriedPlatformFix && !P.hasTriedInstall) {
|
|
1924
|
+
const T = await qe(U, F, G, f, P);
|
|
1880
1925
|
if (P = { ...P, ...T }, T.handled) {
|
|
1881
1926
|
const Y = await E(!0);
|
|
1882
|
-
|
|
1927
|
+
_(Y);
|
|
1883
1928
|
return;
|
|
1884
1929
|
}
|
|
1885
1930
|
}
|
|
1886
|
-
console.error(U.message),
|
|
1931
|
+
console.error(U.message), _(!1);
|
|
1887
1932
|
});
|
|
1888
1933
|
});
|
|
1889
1934
|
await E() || process.exit(1);
|
|
1890
1935
|
}
|
|
1891
1936
|
const d = "./dist/index.html";
|
|
1892
1937
|
t.existsSync(d) || (console.error("β Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
|
|
1893
|
-
let
|
|
1938
|
+
let w;
|
|
1894
1939
|
try {
|
|
1895
|
-
|
|
1896
|
-
} catch (
|
|
1897
|
-
console.error("β Authentication failed:",
|
|
1940
|
+
w = await Jt();
|
|
1941
|
+
} catch (f) {
|
|
1942
|
+
console.error("β Authentication failed:", f.message), process.exit(1);
|
|
1898
1943
|
}
|
|
1899
|
-
const
|
|
1900
|
-
let
|
|
1944
|
+
const $ = zt();
|
|
1945
|
+
let m = V("Requesting upload URL...").start(), p;
|
|
1901
1946
|
try {
|
|
1902
|
-
const
|
|
1947
|
+
const f = await fetch(`${$}/mcp`, {
|
|
1903
1948
|
method: "POST",
|
|
1904
1949
|
headers: {
|
|
1905
1950
|
"Content-Type": "application/json",
|
|
1906
|
-
Authorization: `Bearer ${
|
|
1951
|
+
Authorization: `Bearer ${w.accessToken}`
|
|
1907
1952
|
},
|
|
1908
1953
|
body: JSON.stringify({
|
|
1909
1954
|
jsonrpc: "2.0",
|
|
@@ -1919,21 +1964,21 @@ y.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1919
1964
|
}
|
|
1920
1965
|
})
|
|
1921
1966
|
});
|
|
1922
|
-
if (!
|
|
1923
|
-
throw new Error(`Server returned ${
|
|
1924
|
-
const P = await
|
|
1967
|
+
if (!f.ok)
|
|
1968
|
+
throw new Error(`Server returned ${f.status}`);
|
|
1969
|
+
const P = await f.json();
|
|
1925
1970
|
if (P.error)
|
|
1926
1971
|
throw new Error(P.error.message);
|
|
1927
|
-
const E = (x = (b = (
|
|
1972
|
+
const E = (x = (b = (g = P.result) == null ? void 0 : g.content) == null ? void 0 : b[0]) == null ? void 0 : x.text;
|
|
1928
1973
|
if (p = JSON.parse(E), !p.success)
|
|
1929
1974
|
throw new Error(p.error);
|
|
1930
|
-
|
|
1931
|
-
} catch (
|
|
1932
|
-
|
|
1975
|
+
m.succeed("Upload URL obtained");
|
|
1976
|
+
} catch (f) {
|
|
1977
|
+
m.fail("Failed to get upload URL"), console.error(" ", f.message), process.exit(1);
|
|
1933
1978
|
}
|
|
1934
|
-
|
|
1979
|
+
m = V("Uploading component...").start();
|
|
1935
1980
|
try {
|
|
1936
|
-
const
|
|
1981
|
+
const f = t.readFileSync(d, "utf-8");
|
|
1937
1982
|
let P;
|
|
1938
1983
|
const E = p.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
1939
1984
|
if (E)
|
|
@@ -1946,29 +1991,29 @@ y.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1946
1991
|
throw new Error("Could not parse presigned URL from: " + p.curlCommand);
|
|
1947
1992
|
}
|
|
1948
1993
|
console.info("Uploading to:", P.substring(0, 100) + "...");
|
|
1949
|
-
const
|
|
1994
|
+
const M = await fetch(P, {
|
|
1950
1995
|
method: "PUT",
|
|
1951
1996
|
headers: {
|
|
1952
1997
|
"Content-Type": "text/html"
|
|
1953
1998
|
},
|
|
1954
|
-
body:
|
|
1999
|
+
body: f
|
|
1955
2000
|
});
|
|
1956
|
-
if (!
|
|
1957
|
-
const I = await
|
|
1958
|
-
throw new Error(`Upload failed with status ${
|
|
2001
|
+
if (!M.ok) {
|
|
2002
|
+
const I = await M.text();
|
|
2003
|
+
throw new Error(`Upload failed with status ${M.status}: ${I}`);
|
|
1959
2004
|
}
|
|
1960
|
-
|
|
1961
|
-
} catch (
|
|
1962
|
-
|
|
2005
|
+
m.succeed("Component uploaded");
|
|
2006
|
+
} catch (f) {
|
|
2007
|
+
m.fail("Upload failed"), console.error(" ", f.message), f.cause && console.error(" Cause:", f.cause), process.exit(1);
|
|
1963
2008
|
}
|
|
1964
|
-
|
|
2009
|
+
m = V("Confirming upload...").start();
|
|
1965
2010
|
let S;
|
|
1966
2011
|
try {
|
|
1967
|
-
const
|
|
2012
|
+
const f = await fetch(`${$}/mcp`, {
|
|
1968
2013
|
method: "POST",
|
|
1969
2014
|
headers: {
|
|
1970
2015
|
"Content-Type": "application/json",
|
|
1971
|
-
Authorization: `Bearer ${
|
|
2016
|
+
Authorization: `Bearer ${w.accessToken}`
|
|
1972
2017
|
},
|
|
1973
2018
|
body: JSON.stringify({
|
|
1974
2019
|
jsonrpc: "2.0",
|
|
@@ -1982,45 +2027,45 @@ y.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1982
2027
|
}
|
|
1983
2028
|
})
|
|
1984
2029
|
});
|
|
1985
|
-
if (!
|
|
1986
|
-
throw new Error(`Server returned ${
|
|
1987
|
-
const P = await
|
|
2030
|
+
if (!f.ok)
|
|
2031
|
+
throw new Error(`Server returned ${f.status}`);
|
|
2032
|
+
const P = await f.json();
|
|
1988
2033
|
if (P.error)
|
|
1989
2034
|
throw new Error(P.error.message);
|
|
1990
|
-
const E = (H = (L = (
|
|
2035
|
+
const E = (H = (L = (C = P.result) == null ? void 0 : C.content) == null ? void 0 : L[0]) == null ? void 0 : H.text;
|
|
1991
2036
|
if (S = JSON.parse(E), !S.success)
|
|
1992
2037
|
throw new Error(S.error);
|
|
1993
|
-
|
|
1994
|
-
} catch (
|
|
1995
|
-
|
|
2038
|
+
m.succeed("Upload confirmed");
|
|
2039
|
+
} catch (f) {
|
|
2040
|
+
m.fail("Confirmation failed"), console.error(" ", f.message), process.exit(1);
|
|
1996
2041
|
}
|
|
1997
2042
|
if (S.isNewComponent || !s.componentId) {
|
|
1998
2043
|
s.componentId = S.componentId, s.organization = S.orgId, s.name || (s.name = S.componentName);
|
|
1999
2044
|
try {
|
|
2000
2045
|
t.writeFileSync(e, JSON.stringify(s, null, 2)), console.log(`
|
|
2001
2046
|
π Updated ${e} with componentId`);
|
|
2002
|
-
} catch (
|
|
2047
|
+
} catch (f) {
|
|
2003
2048
|
console.log(`
|
|
2004
|
-
β οΈ Could not update ${e}: ${
|
|
2049
|
+
β οΈ Could not update ${e}: ${f.message}`), console.log(` Please add componentId: "${S.componentId}" manually`);
|
|
2005
2050
|
}
|
|
2006
2051
|
}
|
|
2007
2052
|
console.log(`
|
|
2008
2053
|
β
Sync completed successfully!`), console.log(` Component: ${S.componentName}`), console.log(` Dashboard: ${S.dashboardUrl}`), process.exit(0);
|
|
2009
2054
|
});
|
|
2010
|
-
y.program.command("dev").description("Start development server with file watching").action(
|
|
2011
|
-
const
|
|
2055
|
+
y.program.command("dev").description("Start development server with file watching").action(Le);
|
|
2056
|
+
const Xt = () => {
|
|
2012
2057
|
try {
|
|
2013
|
-
|
|
2058
|
+
Q("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2014
2059
|
} catch {
|
|
2015
2060
|
return { gitNotInstalled: !0 };
|
|
2016
2061
|
}
|
|
2017
2062
|
try {
|
|
2018
|
-
|
|
2063
|
+
Q("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
2019
2064
|
} catch {
|
|
2020
2065
|
return { notARepo: !0 };
|
|
2021
2066
|
}
|
|
2022
2067
|
try {
|
|
2023
|
-
const o =
|
|
2068
|
+
const o = Q("git diff --stat HEAD -- . 2>/dev/null || git diff --stat -- . 2>/dev/null", {
|
|
2024
2069
|
encoding: "utf-8",
|
|
2025
2070
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2026
2071
|
}).trim();
|
|
@@ -2040,13 +2085,13 @@ const Gt = () => {
|
|
|
2040
2085
|
} catch {
|
|
2041
2086
|
return null;
|
|
2042
2087
|
}
|
|
2043
|
-
},
|
|
2044
|
-
var p, S,
|
|
2045
|
-
const t = be(), n = !!(t != null && t.email), r = ((p = y.myopConfig) == null ? void 0 : p.name) || ((S = y.myopConfig) == null ? void 0 : S.componentName), s = (
|
|
2088
|
+
}, oe = async (o = !1, e = !1) => {
|
|
2089
|
+
var p, S, g;
|
|
2090
|
+
const t = be(), n = !!(t != null && t.email), r = ((p = y.myopConfig) == null ? void 0 : p.name) || ((S = y.myopConfig) == null ? void 0 : S.componentName), s = (g = y.myopConfig) == null ? void 0 : g.componentId, d = Xt();
|
|
2046
2091
|
console.log(`
|
|
2047
2092
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2048
2093
|
`), o && r ? (console.log(` Component: ${r}`), s ? (console.log(` ID: ${s}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${s}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${n ? t.email : "Not logged in"}`), d != null && d.gitNotInstalled ? (console.log(" Changes: Git not installed"), console.log(" Install: https://git-scm.com/downloads"), console.log(" Mac: brew install git | Windows: https://gitforwindows.org")) : d != null && d.notARepo ? console.log(" Changes: Not a git repository") : d && (d.insertions > 0 || d.deletions > 0) ? console.log(` Changes: ${d.files} file${d.files !== 1 ? "s" : ""} | \x1B[32m+${d.insertions}\x1B[0m \x1B[31m-${d.deletions}\x1B[0m`) : d && console.log(" Changes: No uncommitted changes"), console.log("");
|
|
2049
|
-
const
|
|
2094
|
+
const $ = [
|
|
2050
2095
|
{
|
|
2051
2096
|
emoji: "π",
|
|
2052
2097
|
label: "Initialize new component",
|
|
@@ -2074,8 +2119,8 @@ const Gt = () => {
|
|
|
2074
2119
|
value: b.value,
|
|
2075
2120
|
disabled: b.disabled
|
|
2076
2121
|
}));
|
|
2077
|
-
|
|
2078
|
-
new
|
|
2122
|
+
$.push(
|
|
2123
|
+
new Fe(),
|
|
2079
2124
|
{
|
|
2080
2125
|
name: e && n ? `π Logout (${t.email})
|
|
2081
2126
|
Clears stored credentials from this machine` : e && !n ? `π Login to Myop
|
|
@@ -2086,17 +2131,17 @@ const Gt = () => {
|
|
|
2086
2131
|
name: e ? "π Hide help" : "π Show help",
|
|
2087
2132
|
value: "help"
|
|
2088
2133
|
},
|
|
2089
|
-
new
|
|
2134
|
+
new Fe(),
|
|
2090
2135
|
{
|
|
2091
2136
|
name: "π Exit",
|
|
2092
2137
|
value: "exit"
|
|
2093
2138
|
}
|
|
2094
2139
|
);
|
|
2095
|
-
let
|
|
2140
|
+
let m;
|
|
2096
2141
|
try {
|
|
2097
|
-
|
|
2142
|
+
m = await Ge({
|
|
2098
2143
|
message: "What would you like to do?",
|
|
2099
|
-
choices:
|
|
2144
|
+
choices: $
|
|
2100
2145
|
});
|
|
2101
2146
|
} catch (b) {
|
|
2102
2147
|
throw b.name === "ExitPromptError" && (console.log(`
|
|
@@ -2104,9 +2149,9 @@ const Gt = () => {
|
|
|
2104
2149
|
π Goodbye!
|
|
2105
2150
|
`), process.exit(0)), b;
|
|
2106
2151
|
}
|
|
2107
|
-
switch (
|
|
2152
|
+
switch (m) {
|
|
2108
2153
|
case "init":
|
|
2109
|
-
await
|
|
2154
|
+
await oo();
|
|
2110
2155
|
break;
|
|
2111
2156
|
case "sync":
|
|
2112
2157
|
console.log(`
|
|
@@ -2117,37 +2162,37 @@ Running sync...
|
|
|
2117
2162
|
b("node " + process.argv[1] + " sync", { stdio: "inherit" });
|
|
2118
2163
|
} catch {
|
|
2119
2164
|
}
|
|
2120
|
-
await
|
|
2165
|
+
await oe(!0, e);
|
|
2121
2166
|
break;
|
|
2122
2167
|
case "dev":
|
|
2123
|
-
await
|
|
2168
|
+
await Le();
|
|
2124
2169
|
break;
|
|
2125
2170
|
case "login":
|
|
2126
2171
|
try {
|
|
2127
|
-
await
|
|
2128
|
-
`), await
|
|
2172
|
+
await ce(), console.log(`
|
|
2173
|
+
`), await oe(o, e);
|
|
2129
2174
|
} catch (x) {
|
|
2130
|
-
console.error("Login failed:", x.message), await
|
|
2175
|
+
console.error("Login failed:", x.message), await oe(o, e);
|
|
2131
2176
|
}
|
|
2132
2177
|
break;
|
|
2133
2178
|
case "logout":
|
|
2134
|
-
await
|
|
2135
|
-
`), await
|
|
2179
|
+
await ot(), console.log(`
|
|
2180
|
+
`), await oe(o, e);
|
|
2136
2181
|
break;
|
|
2137
2182
|
case "help":
|
|
2138
|
-
await
|
|
2183
|
+
await oe(o, !e);
|
|
2139
2184
|
break;
|
|
2140
2185
|
case "exit":
|
|
2141
2186
|
process.exit(0);
|
|
2142
2187
|
}
|
|
2143
|
-
}, ve = ".myop-monorepo.json",
|
|
2188
|
+
}, ve = ".myop-monorepo.json", qt = () => {
|
|
2144
2189
|
try {
|
|
2145
2190
|
const o = D.readFileSync(ve, "utf-8");
|
|
2146
2191
|
return JSON.parse(o);
|
|
2147
2192
|
} catch {
|
|
2148
2193
|
return null;
|
|
2149
2194
|
}
|
|
2150
|
-
},
|
|
2195
|
+
}, eo = (o) => {
|
|
2151
2196
|
try {
|
|
2152
2197
|
const e = {
|
|
2153
2198
|
selectedComponents: o,
|
|
@@ -2156,47 +2201,47 @@ Running sync...
|
|
|
2156
2201
|
D.writeFileSync(ve, JSON.stringify(e, null, 2));
|
|
2157
2202
|
} catch {
|
|
2158
2203
|
}
|
|
2159
|
-
},
|
|
2204
|
+
}, to = async () => {
|
|
2160
2205
|
const o = be(), e = !!(o != null && o.email);
|
|
2161
2206
|
console.log(`
|
|
2162
2207
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Myop CLI - Monorepo Mode β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2163
2208
|
`);
|
|
2164
|
-
const t = V("Scanning for components...").start(), n =
|
|
2209
|
+
const t = V("Scanning for components...").start(), n = nt(".");
|
|
2165
2210
|
t.stop(), n.length === 0 && (console.log(` β οΈ No myop.config.json files found in this directory or subdirectories.
|
|
2166
2211
|
`), console.log(" Run `myop` without -m flag to initialize a single component.\n"), process.exit(0));
|
|
2167
|
-
const r =
|
|
2212
|
+
const r = qt(), s = (r == null ? void 0 : r.selectedComponents) || [], d = s.length > 0;
|
|
2168
2213
|
console.log(` Found ${n.length} component${n.length > 1 ? "s" : ""}:
|
|
2169
|
-
`), n.forEach((
|
|
2170
|
-
const x =
|
|
2171
|
-
console.log(` ${x} ${
|
|
2214
|
+
`), n.forEach((g, b) => {
|
|
2215
|
+
const x = g.componentId ? "β
" : "βͺ", C = g.componentId ? g.componentId.substring(0, 8) + "..." : "(not pushed)";
|
|
2216
|
+
console.log(` ${x} ${g.name}`), console.log(` Path: ${g.path}`), console.log(` ID: ${C}`), console.log("");
|
|
2172
2217
|
}), console.log(` User: ${e ? o.email : "Not logged in"}`), d && console.log(` π Using saved selection from ${ve}`), console.log("");
|
|
2173
|
-
const { checkbox:
|
|
2174
|
-
name: `${
|
|
2175
|
-
value:
|
|
2176
|
-
checked: d ? s.includes(
|
|
2218
|
+
const { checkbox: w } = await import("@inquirer/prompts"), $ = n.map((g) => ({
|
|
2219
|
+
name: `${g.name} (${g.path})`,
|
|
2220
|
+
value: g.path,
|
|
2221
|
+
checked: d ? s.includes(g.path) : !0
|
|
2177
2222
|
}));
|
|
2178
|
-
let
|
|
2223
|
+
let m;
|
|
2179
2224
|
try {
|
|
2180
|
-
|
|
2225
|
+
m = await w({
|
|
2181
2226
|
message: "Select components to start in dev mode:",
|
|
2182
|
-
choices:
|
|
2227
|
+
choices: $
|
|
2183
2228
|
});
|
|
2184
|
-
} catch (
|
|
2185
|
-
throw
|
|
2229
|
+
} catch (g) {
|
|
2230
|
+
throw g.name === "ExitPromptError" && (console.log(`
|
|
2186
2231
|
|
|
2187
2232
|
π Goodbye!
|
|
2188
|
-
`), process.exit(0)),
|
|
2233
|
+
`), process.exit(0)), g;
|
|
2189
2234
|
}
|
|
2190
|
-
|
|
2235
|
+
m.length === 0 && (console.log(`
|
|
2191
2236
|
β οΈ No components selected.
|
|
2192
|
-
`), process.exit(0)),
|
|
2237
|
+
`), process.exit(0)), eo(m), console.log(`
|
|
2193
2238
|
πΎ Selection saved to ${ve}`);
|
|
2194
|
-
const p = n.filter((
|
|
2239
|
+
const p = n.filter((g) => m.includes(g.path));
|
|
2195
2240
|
console.log(`π Starting dev mode for ${p.length} component${p.length > 1 ? "s" : ""}...
|
|
2196
2241
|
`);
|
|
2197
|
-
const { monorepoDevCommand: S } = await Promise.resolve().then(() =>
|
|
2242
|
+
const { monorepoDevCommand: S } = await Promise.resolve().then(() => Ft);
|
|
2198
2243
|
await S(p);
|
|
2199
|
-
},
|
|
2244
|
+
}, oo = async () => {
|
|
2200
2245
|
const { input: o, select: e } = await import("@inquirer/prompts"), t = await import("fs"), r = (await import("path")).default.basename(process.cwd());
|
|
2201
2246
|
let s, d;
|
|
2202
2247
|
try {
|
|
@@ -2212,22 +2257,22 @@ Running sync...
|
|
|
2212
2257
|
{ name: "π
°οΈ Angular", value: "angular", disabled: "(coming soon)" }
|
|
2213
2258
|
]
|
|
2214
2259
|
});
|
|
2215
|
-
} catch (
|
|
2216
|
-
throw
|
|
2260
|
+
} catch (m) {
|
|
2261
|
+
throw m.name === "ExitPromptError" && (console.log(`
|
|
2217
2262
|
|
|
2218
2263
|
π Goodbye!
|
|
2219
|
-
`), process.exit(0)),
|
|
2264
|
+
`), process.exit(0)), m;
|
|
2220
2265
|
}
|
|
2221
|
-
const
|
|
2266
|
+
const w = {
|
|
2222
2267
|
name: s,
|
|
2223
2268
|
type: d,
|
|
2224
2269
|
author: "@myop-cli",
|
|
2225
2270
|
HMR: !0
|
|
2226
|
-
},
|
|
2271
|
+
}, $ = y.program.getOptionValue("config") || "./myop.config.json";
|
|
2227
2272
|
try {
|
|
2228
|
-
t.writeFileSync(
|
|
2229
|
-
β
Created ${
|
|
2230
|
-
const
|
|
2273
|
+
t.writeFileSync($, JSON.stringify(w, null, 2)), console.log(`
|
|
2274
|
+
β
Created ${$}`);
|
|
2275
|
+
const m = {
|
|
2231
2276
|
name: s.toLowerCase().replace(/\s+/g, "-"),
|
|
2232
2277
|
version: "1.0.0",
|
|
2233
2278
|
type: "module",
|
|
@@ -2239,7 +2284,7 @@ Running sync...
|
|
|
2239
2284
|
esbuild: "^0.24.0"
|
|
2240
2285
|
}
|
|
2241
2286
|
};
|
|
2242
|
-
t.writeFileSync("package.json", JSON.stringify(
|
|
2287
|
+
t.writeFileSync("package.json", JSON.stringify(m, null, 2)), console.log("β
Created package.json"), t.mkdirSync("src/modules", { recursive: !0 }), t.mkdirSync("src/styles", { recursive: !0 }), t.writeFileSync("build.js", `import * as esbuild from 'esbuild';
|
|
2243
2288
|
import fs from 'fs';
|
|
2244
2289
|
import path from 'path';
|
|
2245
2290
|
|
|
@@ -2337,7 +2382,7 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
2337
2382
|
</html>
|
|
2338
2383
|
`;
|
|
2339
2384
|
t.writeFileSync("index.html", S), console.log("β
Created index.html");
|
|
2340
|
-
const
|
|
2385
|
+
const g = `// ${s} - Entry Point
|
|
2341
2386
|
import { init } from './modules/app.js';
|
|
2342
2387
|
import { setupMyopInterface } from './modules/myop.js';
|
|
2343
2388
|
|
|
@@ -2346,7 +2391,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
2346
2391
|
setupMyopInterface();
|
|
2347
2392
|
});
|
|
2348
2393
|
`;
|
|
2349
|
-
t.writeFileSync("src/index.js",
|
|
2394
|
+
t.writeFileSync("src/index.js", g), console.log("β
Created src/index.js");
|
|
2350
2395
|
const b = `// ${s} - Main Application Logic
|
|
2351
2396
|
|
|
2352
2397
|
export function init() {
|
|
@@ -2371,11 +2416,11 @@ export function setupMyopInterface() {
|
|
|
2371
2416
|
};
|
|
2372
2417
|
}
|
|
2373
2418
|
`), console.log("β
Created src/modules/myop.js");
|
|
2374
|
-
const
|
|
2419
|
+
const C = `/* ${s} - Styles Entry Point */
|
|
2375
2420
|
/* Add your CSS imports here - they will be auto-bundled */
|
|
2376
2421
|
@import './main.css';
|
|
2377
2422
|
`;
|
|
2378
|
-
t.writeFileSync("src/styles/index.css",
|
|
2423
|
+
t.writeFileSync("src/styles/index.css", C), console.log("β
Created src/styles/index.css");
|
|
2379
2424
|
const L = `/* ${s} - Main Styles */
|
|
2380
2425
|
|
|
2381
2426
|
* {
|
|
@@ -2411,9 +2456,9 @@ dist/
|
|
|
2411
2456
|
.temp-styles.css
|
|
2412
2457
|
.DS_Store
|
|
2413
2458
|
`), console.log("β
Created .gitignore");
|
|
2414
|
-
const
|
|
2459
|
+
const f = await import("./index-DuEoKctW.js").then((E) => E.i), P = process.cwd();
|
|
2415
2460
|
try {
|
|
2416
|
-
await
|
|
2461
|
+
await f.init({ fs: t, dir: P });
|
|
2417
2462
|
const E = [
|
|
2418
2463
|
"myop.config.json",
|
|
2419
2464
|
"package.json",
|
|
@@ -2426,9 +2471,9 @@ dist/
|
|
|
2426
2471
|
"src/styles/index.css",
|
|
2427
2472
|
"src/styles/main.css"
|
|
2428
2473
|
];
|
|
2429
|
-
for (const
|
|
2430
|
-
await
|
|
2431
|
-
await
|
|
2474
|
+
for (const M of E)
|
|
2475
|
+
await f.add({ fs: t, dir: P, filepath: M });
|
|
2476
|
+
await f.commit({
|
|
2432
2477
|
fs: t,
|
|
2433
2478
|
dir: P,
|
|
2434
2479
|
message: "init",
|
|
@@ -2439,25 +2484,25 @@ dist/
|
|
|
2439
2484
|
}
|
|
2440
2485
|
console.log(`
|
|
2441
2486
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
2442
|
-
`), y.myopConfig =
|
|
2443
|
-
} catch (
|
|
2444
|
-
console.error(`Failed to initialize component: ${
|
|
2487
|
+
`), y.myopConfig = w, await oe(!0);
|
|
2488
|
+
} catch (m) {
|
|
2489
|
+
console.error(`Failed to initialize component: ${m.message}`), process.exit(1);
|
|
2445
2490
|
}
|
|
2446
2491
|
};
|
|
2447
2492
|
y.program.command("default", { isDefault: !0 }).action(async () => {
|
|
2448
|
-
if (y.program.getOptionValue("help") && (console.log(
|
|
2449
|
-
await
|
|
2493
|
+
if (y.program.getOptionValue("help") && (console.log(yt), process.exit()), y.program.getOptionValue("monorepo")) {
|
|
2494
|
+
await to();
|
|
2450
2495
|
return;
|
|
2451
2496
|
}
|
|
2452
2497
|
if (y.program.getOptionValue("ci")) {
|
|
2453
|
-
const
|
|
2498
|
+
const w = await import("fs"), $ = y.program.getOptionValue("config") || "./myop.config.json", m = y.program.version(), p = be();
|
|
2454
2499
|
let S = { found: !1 };
|
|
2455
2500
|
try {
|
|
2456
|
-
if (
|
|
2457
|
-
const b =
|
|
2501
|
+
if (w.existsSync($)) {
|
|
2502
|
+
const b = w.readFileSync($, "utf-8"), x = JSON.parse(b);
|
|
2458
2503
|
S = {
|
|
2459
2504
|
found: !0,
|
|
2460
|
-
path:
|
|
2505
|
+
path: $,
|
|
2461
2506
|
name: x.name || x.componentName || null,
|
|
2462
2507
|
componentId: x.componentId || null,
|
|
2463
2508
|
organization: x.organization || null
|
|
@@ -2466,24 +2511,24 @@ y.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
2466
2511
|
} catch (b) {
|
|
2467
2512
|
S = { found: !1, error: b.message };
|
|
2468
2513
|
}
|
|
2469
|
-
const
|
|
2470
|
-
version:
|
|
2514
|
+
const g = {
|
|
2515
|
+
version: m,
|
|
2471
2516
|
config: S,
|
|
2472
2517
|
auth: {
|
|
2473
2518
|
loggedIn: !!(p != null && p.email),
|
|
2474
2519
|
email: (p == null ? void 0 : p.email) || null
|
|
2475
2520
|
}
|
|
2476
2521
|
};
|
|
2477
|
-
console.log(JSON.stringify(
|
|
2522
|
+
console.log(JSON.stringify(g, null, 2)), process.exit(0);
|
|
2478
2523
|
}
|
|
2479
2524
|
let n = V({
|
|
2480
2525
|
text: "Loading Myop CLI...",
|
|
2481
2526
|
color: "green"
|
|
2482
2527
|
}).start();
|
|
2483
2528
|
const r = Se();
|
|
2484
|
-
await
|
|
2529
|
+
await Qt(500), n.stop();
|
|
2485
2530
|
const s = y.program.version();
|
|
2486
|
-
await
|
|
2531
|
+
await Kt(s) || await oe(r.configFound);
|
|
2487
2532
|
});
|
|
2488
2533
|
y.program.parse(process.argv);
|
|
2489
2534
|
y.program.opts();
|