@myop/cli 0.1.18 β 0.1.19
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 +446 -461
- package/package.json +1 -1
package/dist/myop-cli.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import F from "ora";
|
|
3
|
-
import { select as
|
|
4
|
-
import { Command as
|
|
5
|
-
import { execSync as re, spawn as
|
|
3
|
+
import { select as _e, Separator as ue } from "@inquirer/prompts";
|
|
4
|
+
import { Command as Ge, Option as ce } from "commander";
|
|
5
|
+
import { execSync as re, spawn as Ye } from "child_process";
|
|
6
6
|
import Z from "path";
|
|
7
7
|
import A from "fs";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { URL as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
const
|
|
8
|
+
import ge from "crypto";
|
|
9
|
+
import Ke from "http";
|
|
10
|
+
import { URL as Ne, URLSearchParams as ke } from "url";
|
|
11
|
+
import Xe from "open";
|
|
12
|
+
import Qe from "os";
|
|
13
|
+
const Ze = `
|
|
14
14
|
Usage: myop [OPTIONS] COMMAND [ARGS]...
|
|
15
15
|
|
|
16
16
|
A powerful command-line interface for managing your Myop projects.
|
|
@@ -52,7 +52,7 @@ Examples:
|
|
|
52
52
|
verbose: !1
|
|
53
53
|
},
|
|
54
54
|
myopConfig: null
|
|
55
|
-
},
|
|
55
|
+
}, Ee = {
|
|
56
56
|
name: "π₯ Install Myop generated dependencies",
|
|
57
57
|
value: "myopInstall",
|
|
58
58
|
description: "Fetch and generates Myop dependencies. flows including components, refs and props.",
|
|
@@ -64,69 +64,69 @@ Examples:
|
|
|
64
64
|
}
|
|
65
65
|
process.exit();
|
|
66
66
|
}
|
|
67
|
-
},
|
|
67
|
+
}, qe = (e) => {
|
|
68
68
|
const o = Z.join(d.executionPath, e);
|
|
69
69
|
console.info(`reading config file from: ${o}`);
|
|
70
|
-
const
|
|
71
|
-
return console.info("config file loaded, ",
|
|
72
|
-
},
|
|
73
|
-
const
|
|
74
|
-
console.info(`writing config file to: ${
|
|
70
|
+
const s = A.readFileSync(o, "utf8"), r = JSON.parse(s);
|
|
71
|
+
return console.info("config file loaded, ", r), r;
|
|
72
|
+
}, he = (e, o) => {
|
|
73
|
+
const s = Z.join(d.executionPath, e);
|
|
74
|
+
console.info(`writing config file to: ${s}`);
|
|
75
75
|
try {
|
|
76
|
-
const
|
|
77
|
-
A.writeFileSync(
|
|
78
|
-
} catch (
|
|
79
|
-
throw console.info(`error ${
|
|
80
|
-
β οΈ Failed write config file to ${
|
|
76
|
+
const r = JSON.stringify(o, null, 2);
|
|
77
|
+
A.writeFileSync(s, r), console.info(`config file updated ${r}`);
|
|
78
|
+
} catch (r) {
|
|
79
|
+
throw console.info(`error ${r} while writing to ${s}, JSON: ${o}`), console.log(`
|
|
80
|
+
β οΈ Failed write config file to ${s}, for more info use verbose flag`), r;
|
|
81
81
|
}
|
|
82
|
-
},
|
|
82
|
+
}, Te = {
|
|
83
83
|
name: "π Add flow definition to your project",
|
|
84
84
|
value: "addFlow",
|
|
85
85
|
description: "Adds flow to yours myop.config.json",
|
|
86
86
|
_action: (e) => {
|
|
87
|
-
d.myopConfig.flows.includes(e) || d.myopConfig.flows.push(e),
|
|
87
|
+
d.myopConfig.flows.includes(e) || d.myopConfig.flows.push(e), he(d.options.configPath, d.myopConfig);
|
|
88
88
|
},
|
|
89
89
|
action: async () => {
|
|
90
90
|
}
|
|
91
|
-
},
|
|
91
|
+
}, Pe = {
|
|
92
92
|
name: "π« Remove flow definition from your project",
|
|
93
93
|
value: "removeFlow",
|
|
94
94
|
description: "Removes flow to yours myop.config.json",
|
|
95
95
|
_action: (e) => {
|
|
96
|
-
d.myopConfig.flows = d.myopConfig.flows.filter((o) => o !== e),
|
|
96
|
+
d.myopConfig.flows = d.myopConfig.flows.filter((o) => o !== e), he(d.options.configPath, d.myopConfig);
|
|
97
97
|
},
|
|
98
98
|
action: () => {
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, et = {
|
|
101
101
|
name: "π Quit",
|
|
102
102
|
value: "quit",
|
|
103
103
|
description: "Quit and continue coding.",
|
|
104
104
|
action: () => {
|
|
105
105
|
process.exit();
|
|
106
106
|
}
|
|
107
|
-
},
|
|
107
|
+
}, tt = {
|
|
108
108
|
name: "π’ Create new component",
|
|
109
109
|
value: "-",
|
|
110
110
|
disabled: "(not available yet)"
|
|
111
|
-
},
|
|
111
|
+
}, ot = {
|
|
112
112
|
name: "π΅ Create new experience",
|
|
113
113
|
value: "-",
|
|
114
114
|
disabled: "(not available yet)"
|
|
115
|
-
},
|
|
115
|
+
}, nt = {
|
|
116
116
|
name: "π‘ Create new skin",
|
|
117
117
|
value: "-",
|
|
118
118
|
disabled: "(not available yet)"
|
|
119
|
-
},
|
|
119
|
+
}, st = {
|
|
120
120
|
name: "π΄ Create new flow",
|
|
121
121
|
value: "-",
|
|
122
122
|
disabled: "(not available yet)"
|
|
123
|
-
},
|
|
123
|
+
}, rt = {
|
|
124
124
|
name: "π Define new custom Myop message",
|
|
125
125
|
value: "generateMyopMessage",
|
|
126
126
|
description: "οΈHelp you creates the right structure for a new Myop message, including types and handlers.",
|
|
127
127
|
disabled: "(not available yet)"
|
|
128
|
-
},
|
|
129
|
-
function
|
|
128
|
+
}, it = [rt, tt, ot, nt, st];
|
|
129
|
+
function at(e, o, s, r) {
|
|
130
130
|
return `<!DOCTYPE html>
|
|
131
131
|
<html lang="en">
|
|
132
132
|
<head>
|
|
@@ -134,7 +134,7 @@ function it(e, o, n, a) {
|
|
|
134
134
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
135
135
|
<title>Myop DevTools - localhost:${e}</title>
|
|
136
136
|
<style>
|
|
137
|
-
${
|
|
137
|
+
${s}
|
|
138
138
|
</style>
|
|
139
139
|
</head>
|
|
140
140
|
<body>
|
|
@@ -211,32 +211,32 @@ ${n}
|
|
|
211
211
|
// Inject PORT as a global variable for the app to use
|
|
212
212
|
window.PORT = ${e};
|
|
213
213
|
|
|
214
|
-
${
|
|
214
|
+
${r}
|
|
215
215
|
<\/script>
|
|
216
216
|
</body>
|
|
217
217
|
</html>`;
|
|
218
218
|
}
|
|
219
|
-
async function
|
|
220
|
-
const e = await import("fs"), o = await import("path"), { exec:
|
|
219
|
+
async function Re() {
|
|
220
|
+
const e = await import("fs"), o = await import("path"), { exec: s } = await import("child_process"), r = await import("http"), { createHash: f } = await import("node:crypto");
|
|
221
221
|
let c;
|
|
222
222
|
if (import.meta.url.startsWith("file://")) {
|
|
223
|
-
const t = new URL(import.meta.url).pathname,
|
|
224
|
-
c = o.default.dirname(
|
|
223
|
+
const t = new URL(import.meta.url).pathname, i = process.platform === "win32" && t.startsWith("/") ? t.slice(1) : t;
|
|
224
|
+
c = o.default.dirname(i);
|
|
225
225
|
} else
|
|
226
226
|
c = o.default.dirname(import.meta.url);
|
|
227
|
-
const m = o.default.join(c, "commands", "dev", "management-website"), w = e.default.readFileSync(o.default.join(m, "styles.css"), "utf-8"), I = e.default.readFileSync(o.default.join(m, "app.js"), "utf-8"), u = 9292, y = 9293,
|
|
227
|
+
const m = o.default.join(c, "commands", "dev", "management-website"), w = e.default.readFileSync(o.default.join(m, "styles.css"), "utf-8"), I = e.default.readFileSync(o.default.join(m, "app.js"), "utf-8"), u = 9292, y = 9293, b = "./dist";
|
|
228
228
|
let j = !1, v = !1;
|
|
229
|
-
const
|
|
230
|
-
let
|
|
229
|
+
const T = /* @__PURE__ */ new Map(), z = d.program.getOptionValue("config") || "./myop.config.json";
|
|
230
|
+
let S, k, h = !1;
|
|
231
231
|
try {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
} catch (
|
|
235
|
-
console.error("β Error reading myop.config.json:",
|
|
232
|
+
const n = e.default.readFileSync(z, "utf-8"), t = JSON.parse(n);
|
|
233
|
+
S = t.componentId || "DEV", k = t.componentName || t.name || null, h = t.HMR === !0, h && console.log("π₯ HMR enabled");
|
|
234
|
+
} catch (n) {
|
|
235
|
+
console.error("β Error reading myop.config.json:", n.message), process.exit(1);
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
if (
|
|
239
|
-
return
|
|
237
|
+
const M = async () => {
|
|
238
|
+
if (S !== "DEV" && S !== "NEW")
|
|
239
|
+
return S;
|
|
240
240
|
try {
|
|
241
241
|
const t = ((await new Promise((l, p) => {
|
|
242
242
|
const g = {
|
|
@@ -245,9 +245,9 @@ async function ke() {
|
|
|
245
245
|
path: "/_list",
|
|
246
246
|
method: "GET",
|
|
247
247
|
timeout: 1e3
|
|
248
|
-
},
|
|
248
|
+
}, $ = r.default.request(g, (N) => {
|
|
249
249
|
let H = "";
|
|
250
|
-
|
|
250
|
+
N.on("data", (L) => H += L), N.on("end", () => {
|
|
251
251
|
try {
|
|
252
252
|
l(JSON.parse(H));
|
|
253
253
|
} catch {
|
|
@@ -255,23 +255,23 @@ async function ke() {
|
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
257
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}),
|
|
258
|
+
$.on("error", () => l({ components: [] })), $.on("timeout", () => {
|
|
259
|
+
$.destroy(), l({ components: [] });
|
|
260
|
+
}), $.end();
|
|
261
261
|
})).components || []).map(([l]) => l).filter((l) => l === "DEV" || l === "NEW" || /^DEV\d+$/.test(l) || /^NEW\d+$/.test(l));
|
|
262
262
|
if (t.length === 0)
|
|
263
263
|
return "DEV1";
|
|
264
|
-
const
|
|
264
|
+
const i = t.map((l) => {
|
|
265
265
|
if (l === "DEV" || l === "NEW") return 1;
|
|
266
266
|
const p = l.match(/^DEV(\d+)$/), g = l.match(/^NEW(\d+)$/);
|
|
267
267
|
return p ? parseInt(p[1], 10) : g ? parseInt(g[1], 10) : 0;
|
|
268
268
|
}).filter((l) => l > 0);
|
|
269
|
-
return `DEV${Math.max(...
|
|
269
|
+
return `DEV${Math.max(...i, 0) + 1}`;
|
|
270
270
|
} catch {
|
|
271
271
|
return "DEV1";
|
|
272
272
|
}
|
|
273
|
-
},
|
|
274
|
-
const t = o.default.extname(
|
|
273
|
+
}, E = process.cwd(), K = (n) => {
|
|
274
|
+
const t = o.default.extname(n).toLowerCase();
|
|
275
275
|
return {
|
|
276
276
|
".html": "text/html",
|
|
277
277
|
".js": "text/javascript",
|
|
@@ -283,9 +283,9 @@ async function ke() {
|
|
|
283
283
|
".svg": "image/svg+xml",
|
|
284
284
|
".ico": "image/x-icon"
|
|
285
285
|
}[t] || "application/octet-stream";
|
|
286
|
-
},
|
|
287
|
-
if (
|
|
288
|
-
const
|
|
286
|
+
}, x = /* @__PURE__ */ new Map(), q = [], He = 50, D = [], W = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), Le = (n, t, i) => {
|
|
287
|
+
if (n.url.startsWith("/_hmr/")) {
|
|
288
|
+
const a = n.url.split("/_hmr/")[1], l = n.headers["sec-websocket-key"], p = f("sha1").update(l + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
|
|
289
289
|
t.write(
|
|
290
290
|
`HTTP/1.1 101 Switching Protocols\r
|
|
291
291
|
Upgrade: websocket\r
|
|
@@ -293,50 +293,50 @@ Connection: Upgrade\r
|
|
|
293
293
|
Sec-WebSocket-Accept: ${p}\r
|
|
294
294
|
\r
|
|
295
295
|
`
|
|
296
|
-
), U.has(
|
|
297
|
-
const g = U.get(
|
|
298
|
-
g && (g.delete(t), g.size === 0 && U.delete(
|
|
296
|
+
), U.has(a) || U.set(a, /* @__PURE__ */ new Set()), U.get(a).add(t), console.log(`π HMR client connected: ${a}`), t.on("close", () => {
|
|
297
|
+
const g = U.get(a);
|
|
298
|
+
g && (g.delete(t), g.size === 0 && U.delete(a)), console.log(`π HMR client disconnected: ${a}`);
|
|
299
299
|
}), t.on("error", () => {
|
|
300
|
-
const g = U.get(
|
|
300
|
+
const g = U.get(a);
|
|
301
301
|
g && g.delete(t);
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
-
}, de =
|
|
305
|
-
if (t.setHeader("Content-Type", "application/json"),
|
|
306
|
-
let
|
|
307
|
-
|
|
304
|
+
}, de = r.default.createServer((n, t) => {
|
|
305
|
+
if (t.setHeader("Content-Type", "application/json"), n.method === "POST" && n.url === "/_register") {
|
|
306
|
+
let i = "";
|
|
307
|
+
n.on("data", (a) => i += a), n.on("end", () => {
|
|
308
308
|
try {
|
|
309
|
-
const { componentId:
|
|
310
|
-
|
|
309
|
+
const { componentId: a, distPath: l, componentName: p } = JSON.parse(i);
|
|
310
|
+
x.set(a, { path: l, name: p || null });
|
|
311
311
|
const g = p ? ` (${p})` : "";
|
|
312
|
-
console.log(`β
Registered: ${
|
|
313
|
-
const
|
|
314
|
-
id:
|
|
312
|
+
console.log(`β
Registered: ${a}${g} -> ${l}`), t.writeHead(200), t.end(JSON.stringify({ success: !0, registered: Array.from(x.keys()) }));
|
|
313
|
+
const $ = Array.from(x.entries()).map(([N, H]) => ({
|
|
314
|
+
id: N,
|
|
315
315
|
path: H.path,
|
|
316
316
|
name: H.name
|
|
317
317
|
}));
|
|
318
|
-
D.forEach((
|
|
318
|
+
D.forEach((N) => {
|
|
319
319
|
try {
|
|
320
|
-
|
|
320
|
+
N.write(`data: ${JSON.stringify({
|
|
321
321
|
type: "components",
|
|
322
|
-
components:
|
|
322
|
+
components: $
|
|
323
323
|
})}
|
|
324
324
|
|
|
325
325
|
`);
|
|
326
326
|
} catch {
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
|
-
} catch (
|
|
330
|
-
t.writeHead(400), t.end(JSON.stringify({ error:
|
|
329
|
+
} catch (a) {
|
|
330
|
+
t.writeHead(400), t.end(JSON.stringify({ error: a.message }));
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
|
-
} else if (
|
|
334
|
-
let
|
|
335
|
-
|
|
333
|
+
} else if (n.method === "POST" && n.url === "/_unregister") {
|
|
334
|
+
let i = "";
|
|
335
|
+
n.on("data", (a) => i += a), n.on("end", () => {
|
|
336
336
|
try {
|
|
337
|
-
const { componentId:
|
|
338
|
-
|
|
339
|
-
const l = Array.from(
|
|
337
|
+
const { componentId: a } = JSON.parse(i);
|
|
338
|
+
x.delete(a), console.log(`β Unregistered: ${a}`), t.writeHead(200), t.end(JSON.stringify({ success: !0 }));
|
|
339
|
+
const l = Array.from(x.entries()).map(([p, g]) => ({
|
|
340
340
|
id: p,
|
|
341
341
|
path: g.path,
|
|
342
342
|
name: g.name
|
|
@@ -352,81 +352,81 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
352
352
|
} catch {
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
|
-
} catch (
|
|
356
|
-
t.writeHead(400), t.end(JSON.stringify({ error:
|
|
355
|
+
} catch (a) {
|
|
356
|
+
t.writeHead(400), t.end(JSON.stringify({ error: a.message }));
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
|
-
} else
|
|
360
|
-
}), ee =
|
|
361
|
-
if (
|
|
359
|
+
} else n.method === "GET" && n.url === "/_list" ? (t.writeHead(200), t.end(JSON.stringify({ components: Array.from(x.entries()) }))) : (t.writeHead(404), t.end(JSON.stringify({ error: "Not found" })));
|
|
360
|
+
}), ee = r.default.createServer((n, t) => {
|
|
361
|
+
if (n.url.includes("..")) {
|
|
362
362
|
t.writeHead(403, { "Content-Type": "text/plain" }), t.end("Forbidden");
|
|
363
363
|
return;
|
|
364
364
|
}
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
368
|
-
if (!
|
|
365
|
+
const i = new URL(n.url, `http://localhost:${u}`), a = i.pathname, l = a.split("/").filter((_) => _);
|
|
366
|
+
if (a.startsWith("/consume")) {
|
|
367
|
+
const _ = i.searchParams.get("id");
|
|
368
|
+
if (!_) {
|
|
369
369
|
t.writeHead(400, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "Component ID required. Use /consume?id=<componentId>" }));
|
|
370
370
|
return;
|
|
371
371
|
}
|
|
372
|
-
const R =
|
|
373
|
-
let C = "Unknown",
|
|
374
|
-
if (
|
|
375
|
-
const O =
|
|
372
|
+
const R = x.get(_), J = R ? R.path : null, je = (V) => {
|
|
373
|
+
let C = "Unknown", P = "Unknown";
|
|
374
|
+
if (n.headers.referer || n.headers.referrer) {
|
|
375
|
+
const O = n.headers.referer || n.headers.referrer;
|
|
376
376
|
try {
|
|
377
377
|
const G = new URL(O);
|
|
378
|
-
C = G.origin,
|
|
378
|
+
C = G.origin, P = G.hostname || G.origin;
|
|
379
379
|
} catch {
|
|
380
|
-
C = O,
|
|
380
|
+
C = O, P = O;
|
|
381
381
|
}
|
|
382
|
-
} else if (
|
|
382
|
+
} else if (n.headers.origin)
|
|
383
383
|
try {
|
|
384
|
-
const O = new URL(
|
|
385
|
-
C = O.origin,
|
|
384
|
+
const O = new URL(n.headers.origin);
|
|
385
|
+
C = O.origin, P = O.hostname || O.origin;
|
|
386
386
|
} catch {
|
|
387
|
-
C =
|
|
387
|
+
C = n.headers.origin, P = n.headers.origin;
|
|
388
388
|
}
|
|
389
|
-
else if (
|
|
390
|
-
const O =
|
|
391
|
-
O === "::1" || O === "::ffff:127.0.0.1" ? (C = "localhost",
|
|
389
|
+
else if (n.socket.remoteAddress) {
|
|
390
|
+
const O = n.socket.remoteAddress;
|
|
391
|
+
O === "::1" || O === "::ffff:127.0.0.1" ? (C = "localhost", P = "localhost (direct)") : (C = O, P = O.replace("::ffff:", ""));
|
|
392
392
|
}
|
|
393
|
-
const pe =
|
|
393
|
+
const pe = n.headers.referer || n.headers.referrer || C, ne = {
|
|
394
394
|
type: "request",
|
|
395
|
-
componentId:
|
|
395
|
+
componentId: _,
|
|
396
396
|
timestamp: Date.now(),
|
|
397
|
-
servedLocally:
|
|
397
|
+
servedLocally: V,
|
|
398
398
|
referrer: pe,
|
|
399
399
|
origin: C,
|
|
400
|
-
originLabel:
|
|
400
|
+
originLabel: P
|
|
401
401
|
};
|
|
402
|
-
|
|
402
|
+
W.has(C) || (W.set(C, {
|
|
403
403
|
url: C,
|
|
404
|
-
label:
|
|
404
|
+
label: P,
|
|
405
405
|
firstSeen: Date.now(),
|
|
406
406
|
requestCount: 0
|
|
407
407
|
}), D.forEach((O) => {
|
|
408
408
|
try {
|
|
409
409
|
O.write(`data: ${JSON.stringify({
|
|
410
410
|
type: "origins",
|
|
411
|
-
origins: Array.from(
|
|
411
|
+
origins: Array.from(W.values())
|
|
412
412
|
})}
|
|
413
413
|
|
|
414
414
|
`);
|
|
415
415
|
} catch {
|
|
416
416
|
}
|
|
417
417
|
}));
|
|
418
|
-
const
|
|
419
|
-
|
|
418
|
+
const me = W.get(C);
|
|
419
|
+
me.requestCount++, D.forEach((O) => {
|
|
420
420
|
try {
|
|
421
421
|
O.write(`data: ${JSON.stringify({
|
|
422
422
|
type: "origins",
|
|
423
|
-
origins: Array.from(
|
|
423
|
+
origins: Array.from(W.values())
|
|
424
424
|
})}
|
|
425
425
|
|
|
426
426
|
`);
|
|
427
427
|
} catch {
|
|
428
428
|
}
|
|
429
|
-
}), q.push(ne), q.length >
|
|
429
|
+
}), q.push(ne), q.length > He && q.shift(), D.forEach((O) => {
|
|
430
430
|
try {
|
|
431
431
|
O.write(`data: ${JSON.stringify(ne)}
|
|
432
432
|
|
|
@@ -436,38 +436,38 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
436
436
|
});
|
|
437
437
|
};
|
|
438
438
|
if (J) {
|
|
439
|
-
const
|
|
440
|
-
e.default.readFile(
|
|
439
|
+
const V = o.default.join(J, "index.html");
|
|
440
|
+
e.default.readFile(V, "utf-8", (C, P) => {
|
|
441
441
|
if (C) {
|
|
442
|
-
console.log(`β File not found: ${
|
|
442
|
+
console.log(`β File not found: ${V}`), t.writeHead(404, { "Content-Type": "application/json" }), t.end(JSON.stringify({ error: "index.html not found" }));
|
|
443
443
|
return;
|
|
444
444
|
}
|
|
445
|
-
const pe = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
445
|
+
const pe = be(P, _), ne = `dev-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, me = {
|
|
446
446
|
item: {
|
|
447
|
-
name:
|
|
448
|
-
id:
|
|
447
|
+
name: _,
|
|
448
|
+
id: _,
|
|
449
449
|
consume_variant: [
|
|
450
450
|
{
|
|
451
|
-
id:
|
|
451
|
+
id: ne,
|
|
452
452
|
name: "dev version",
|
|
453
453
|
loader: {
|
|
454
454
|
type: "HTMLLoader",
|
|
455
455
|
shadowRootMode: "localFrame",
|
|
456
|
-
HTML:
|
|
456
|
+
HTML: pe
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
]
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
|
-
console.log(`β
Serving consume JSON for: ${
|
|
462
|
+
console.log(`β
Serving consume JSON for: ${_}`), je(!0), t.writeHead(200, {
|
|
463
463
|
"Content-Type": "application/json",
|
|
464
464
|
"Access-Control-Allow-Origin": "*"
|
|
465
|
-
}), t.end(JSON.stringify(
|
|
465
|
+
}), t.end(JSON.stringify(me, null, 2));
|
|
466
466
|
});
|
|
467
467
|
} else {
|
|
468
|
-
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${
|
|
469
|
-
const
|
|
470
|
-
|
|
468
|
+
console.log(`π‘ Proxying consume request to cloud.myop.dev for: ${_}`);
|
|
469
|
+
const V = `https://cloud.myop.dev/consume${i.search}`;
|
|
470
|
+
je(!1), fetch(V).then((C) => C.text()).then((C) => {
|
|
471
471
|
t.writeHead(200, {
|
|
472
472
|
"Content-Type": "application/json",
|
|
473
473
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -478,26 +478,26 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
478
478
|
}
|
|
479
479
|
return;
|
|
480
480
|
}
|
|
481
|
-
if (
|
|
481
|
+
if (a === "/events") {
|
|
482
482
|
t.writeHead(200, {
|
|
483
483
|
"Content-Type": "text/event-stream",
|
|
484
484
|
"Cache-Control": "no-cache",
|
|
485
485
|
Connection: "keep-alive",
|
|
486
486
|
"Access-Control-Allow-Origin": "*"
|
|
487
487
|
}), D.push(t);
|
|
488
|
-
const
|
|
488
|
+
const _ = Array.from(x.entries()).map(([R, J]) => ({
|
|
489
489
|
id: R,
|
|
490
490
|
path: J.path,
|
|
491
491
|
name: J.name
|
|
492
492
|
}));
|
|
493
493
|
t.write(`data: ${JSON.stringify({
|
|
494
494
|
type: "components",
|
|
495
|
-
components:
|
|
495
|
+
components: _
|
|
496
496
|
})}
|
|
497
497
|
|
|
498
498
|
`), t.write(`data: ${JSON.stringify({
|
|
499
499
|
type: "origins",
|
|
500
|
-
origins: Array.from(
|
|
500
|
+
origins: Array.from(W.values())
|
|
501
501
|
})}
|
|
502
502
|
|
|
503
503
|
`), t.write(`data: ${JSON.stringify({
|
|
@@ -505,14 +505,14 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
505
505
|
log: q
|
|
506
506
|
})}
|
|
507
507
|
|
|
508
|
-
`),
|
|
508
|
+
`), n.on("close", () => {
|
|
509
509
|
const R = D.indexOf(t);
|
|
510
510
|
R !== -1 && D.splice(R, 1);
|
|
511
511
|
});
|
|
512
512
|
return;
|
|
513
513
|
}
|
|
514
514
|
if (l.length === 0) {
|
|
515
|
-
t.writeHead(200, { "Content-Type": "text/html" }), t.end(
|
|
515
|
+
t.writeHead(200, { "Content-Type": "text/html" }), t.end(at(u, y, w, I));
|
|
516
516
|
return;
|
|
517
517
|
}
|
|
518
518
|
if (l[0] !== "view") {
|
|
@@ -523,14 +523,14 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
523
523
|
t.writeHead(400, { "Content-Type": "text/plain" }), t.end("Component ID required. Use /view/<componentId>/");
|
|
524
524
|
return;
|
|
525
525
|
}
|
|
526
|
-
const p = l[1], g =
|
|
526
|
+
const p = l[1], g = x.get(p);
|
|
527
527
|
if (!g) {
|
|
528
528
|
t.writeHead(404, { "Content-Type": "text/plain" }), t.end(`Component not found: ${p}`);
|
|
529
529
|
return;
|
|
530
530
|
}
|
|
531
|
-
const
|
|
532
|
-
console.log(`π₯ Request: ${
|
|
533
|
-
if (
|
|
531
|
+
const $ = g.path, N = l.slice(2), H = N.length === 0 ? "index.html" : N.join("/"), L = o.default.join($, H);
|
|
532
|
+
console.log(`π₯ Request: ${n.url} -> ${L}`), e.default.readFile(L, (_, R) => {
|
|
533
|
+
if (_) {
|
|
534
534
|
console.log(`β File not found: ${L}`), t.writeHead(404, { "Content-Type": "text/plain" }), t.end("Not Found");
|
|
535
535
|
return;
|
|
536
536
|
}
|
|
@@ -540,55 +540,46 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
540
540
|
"Access-Control-Allow-Origin": "*"
|
|
541
541
|
}), t.end(R);
|
|
542
542
|
});
|
|
543
|
-
}),
|
|
544
|
-
const
|
|
545
|
-
componentId:
|
|
546
|
-
distPath: o.default.resolve(
|
|
547
|
-
componentName:
|
|
548
|
-
}),
|
|
543
|
+
}), Se = () => new Promise((n, t) => {
|
|
544
|
+
const i = JSON.stringify({
|
|
545
|
+
componentId: S,
|
|
546
|
+
distPath: o.default.resolve(E, b),
|
|
547
|
+
componentName: k
|
|
548
|
+
}), a = {
|
|
549
549
|
hostname: "localhost",
|
|
550
550
|
port: y,
|
|
551
551
|
path: "/_register",
|
|
552
552
|
method: "POST",
|
|
553
553
|
headers: {
|
|
554
554
|
"Content-Type": "application/json",
|
|
555
|
-
"Content-Length": Buffer.byteLength(
|
|
555
|
+
"Content-Length": Buffer.byteLength(i)
|
|
556
556
|
}
|
|
557
|
-
}, l =
|
|
557
|
+
}, l = r.default.request(a, (p) => {
|
|
558
558
|
let g = "";
|
|
559
|
-
p.on("data", (
|
|
560
|
-
p.statusCode === 200 ?
|
|
559
|
+
p.on("data", ($) => g += $), p.on("end", () => {
|
|
560
|
+
p.statusCode === 200 ? n(JSON.parse(g)) : t(new Error(`Registration failed: ${p.statusCode}`));
|
|
561
561
|
});
|
|
562
562
|
});
|
|
563
|
-
l.on("error", t), l.write(
|
|
564
|
-
}),
|
|
565
|
-
const
|
|
563
|
+
l.on("error", t), l.write(i), l.end();
|
|
564
|
+
}), Je = () => new Promise((n, t) => {
|
|
565
|
+
const i = JSON.stringify({ componentId: S }), a = {
|
|
566
566
|
hostname: "localhost",
|
|
567
567
|
port: y,
|
|
568
568
|
path: "/_unregister",
|
|
569
569
|
method: "POST",
|
|
570
570
|
headers: {
|
|
571
571
|
"Content-Type": "application/json",
|
|
572
|
-
"Content-Length": Buffer.byteLength(
|
|
572
|
+
"Content-Length": Buffer.byteLength(i)
|
|
573
573
|
}
|
|
574
|
-
}, l =
|
|
575
|
-
|
|
574
|
+
}, l = r.default.request(a, (p) => {
|
|
575
|
+
n();
|
|
576
576
|
});
|
|
577
|
-
l.on("error", () =>
|
|
578
|
-
}),
|
|
579
|
-
if (!h) return;
|
|
580
|
-
const s = o.default.join(S, "index.html");
|
|
581
|
-
try {
|
|
582
|
-
let t = e.default.readFileSync(s, "utf-8");
|
|
583
|
-
if (t.includes("<!-- MYOP HMR -->")) {
|
|
584
|
-
const i = t.indexOf("<!-- MYOP HMR -->"), l = t.indexOf("<\/script>", i) + 9;
|
|
585
|
-
t = t.slice(0, i) + t.slice(l);
|
|
586
|
-
}
|
|
587
|
-
const r = `
|
|
577
|
+
l.on("error", () => n()), l.write(i), l.end();
|
|
578
|
+
}), Ue = (n) => `
|
|
588
579
|
<!-- MYOP HMR -->
|
|
589
580
|
<script>
|
|
590
581
|
(function() {
|
|
591
|
-
const componentId = '${
|
|
582
|
+
const componentId = '${n}';
|
|
592
583
|
const wsUrl = 'ws://localhost:${y}/_hmr/' + componentId;
|
|
593
584
|
let ws;
|
|
594
585
|
let reconnectAttempts = 0;
|
|
@@ -689,57 +680,51 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
689
680
|
connect();
|
|
690
681
|
})();
|
|
691
682
|
<\/script>
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
Buffer.from([129, r]),
|
|
683
|
+
`, be = (n, t) => {
|
|
684
|
+
if (!h) return n;
|
|
685
|
+
const i = Ue(t);
|
|
686
|
+
return n.includes("</body>") ? n.replace("</body>", `${i}</body>`) : n.includes("</html>") ? n.replace("</html>", `${i}</html>`) : n + i;
|
|
687
|
+
}, Be = (n) => {
|
|
688
|
+
const t = Buffer.from(n), i = t.length;
|
|
689
|
+
let a;
|
|
690
|
+
return i < 126 ? a = Buffer.concat([
|
|
691
|
+
Buffer.from([129, i]),
|
|
702
692
|
// FIN + text frame, length
|
|
703
693
|
t
|
|
704
|
-
]) :
|
|
694
|
+
]) : i < 65536 ? a = Buffer.concat([
|
|
705
695
|
Buffer.from([129, 126]),
|
|
706
696
|
// FIN + text frame, extended length
|
|
707
|
-
Buffer.from([
|
|
697
|
+
Buffer.from([i >> 8, i & 255]),
|
|
708
698
|
// 16-bit length
|
|
709
699
|
t
|
|
710
|
-
]) :
|
|
700
|
+
]) : a = Buffer.concat([
|
|
711
701
|
Buffer.from([129, 127]),
|
|
712
702
|
// FIN + text frame, extended length
|
|
713
|
-
Buffer.from([0, 0, 0, 0,
|
|
703
|
+
Buffer.from([0, 0, 0, 0, i >> 24, i >> 16 & 255, i >> 8 & 255, i & 255]),
|
|
714
704
|
// 64-bit length
|
|
715
705
|
t
|
|
716
|
-
]),
|
|
717
|
-
},
|
|
706
|
+
]), a;
|
|
707
|
+
}, ze = () => {
|
|
718
708
|
if (!h) return;
|
|
719
|
-
const
|
|
720
|
-
if (!
|
|
709
|
+
const n = U.get(S);
|
|
710
|
+
if (!n || n.size === 0)
|
|
721
711
|
return;
|
|
722
|
-
console.log(`π₯ Notifying ${
|
|
723
|
-
const t = o.default.join(
|
|
712
|
+
console.log(`π₯ Notifying ${n.size} HMR client(s)`);
|
|
713
|
+
const t = o.default.join(b, "index.html");
|
|
724
714
|
try {
|
|
725
|
-
|
|
726
|
-
if (r.includes("<!-- MYOP HMR -->")) {
|
|
727
|
-
const p = r.indexOf("<!-- MYOP HMR -->"), g = r.indexOf("<\/script>", p) + 9;
|
|
728
|
-
r = r.slice(0, p) + r.slice(g);
|
|
729
|
-
}
|
|
730
|
-
const i = JSON.stringify({
|
|
715
|
+
const i = e.default.readFileSync(t, "utf-8"), a = be(i, S), l = JSON.stringify({
|
|
731
716
|
type: "update",
|
|
732
|
-
html:
|
|
733
|
-
}),
|
|
734
|
-
|
|
717
|
+
html: a
|
|
718
|
+
}), p = Be(l);
|
|
719
|
+
n.forEach((g) => {
|
|
735
720
|
try {
|
|
736
|
-
|
|
721
|
+
g.write(p);
|
|
737
722
|
} catch {
|
|
738
|
-
|
|
723
|
+
n.delete(g);
|
|
739
724
|
}
|
|
740
725
|
});
|
|
741
|
-
} catch (
|
|
742
|
-
console.error("β Failed to read HTML for HMR:",
|
|
726
|
+
} catch (i) {
|
|
727
|
+
console.error("β Failed to read HTML for HMR:", i.message);
|
|
743
728
|
}
|
|
744
729
|
};
|
|
745
730
|
let xe = !1;
|
|
@@ -749,157 +734,157 @@ Sec-WebSocket-Accept: ${p}\r
|
|
|
749
734
|
return;
|
|
750
735
|
}
|
|
751
736
|
j = !0, console.log(`
|
|
752
|
-
π¨ Building...`),
|
|
753
|
-
if (j = !1,
|
|
754
|
-
const
|
|
755
|
-
if (!xe &&
|
|
756
|
-
xe = !0, console.log("π¦ Missing dependencies detected, running npm install..."),
|
|
737
|
+
π¨ Building...`), s("npm run build", (n, t, i) => {
|
|
738
|
+
if (j = !1, n) {
|
|
739
|
+
const a = n.message + (i || "");
|
|
740
|
+
if (!xe && a.includes("ERR_MODULE_NOT_FOUND") && a.includes("esbuild")) {
|
|
741
|
+
xe = !0, console.log("π¦ Missing dependencies detected, running npm install..."), s("npm install", (l, p, g) => {
|
|
757
742
|
l ? (console.error("β Failed to install dependencies:", l.message), g && console.error(g)) : (console.log("β
Dependencies installed"), te());
|
|
758
743
|
});
|
|
759
744
|
return;
|
|
760
745
|
}
|
|
761
|
-
console.error("β Build failed:",
|
|
746
|
+
console.error("β Build failed:", n.message), i && console.error(i);
|
|
762
747
|
} else
|
|
763
|
-
console.log("β
Build completed"), t && console.log(t),
|
|
748
|
+
console.log("β
Build completed"), t && console.log(t), ze();
|
|
764
749
|
v && (v = !1, te());
|
|
765
750
|
});
|
|
766
|
-
},
|
|
767
|
-
e.default.readdir(
|
|
768
|
-
t || (
|
|
769
|
-
const l = o.default.join(
|
|
770
|
-
if (
|
|
771
|
-
|
|
772
|
-
else if (
|
|
773
|
-
const p = o.default.extname(
|
|
751
|
+
}, Ce = /* @__PURE__ */ new Set(), $e = (n) => {
|
|
752
|
+
e.default.readdir(n, { withFileTypes: !0 }, (t, i) => {
|
|
753
|
+
t || (i.forEach((a) => {
|
|
754
|
+
const l = o.default.join(n, a.name);
|
|
755
|
+
if (a.isDirectory())
|
|
756
|
+
a.name !== "node_modules" && a.name !== "dist" && !a.name.startsWith(".") && $e(l);
|
|
757
|
+
else if (a.isFile()) {
|
|
758
|
+
const p = o.default.extname(a.name);
|
|
774
759
|
if (p === ".js" || p === ".css" || p === ".html")
|
|
775
760
|
try {
|
|
776
761
|
const g = e.default.readFileSync(l, "utf-8");
|
|
777
|
-
|
|
762
|
+
T.set(l, g);
|
|
778
763
|
} catch {
|
|
779
764
|
}
|
|
780
765
|
}
|
|
781
|
-
}),
|
|
766
|
+
}), Ce.has(n) || (Ce.add(n), e.default.watch(n, (a, l) => {
|
|
782
767
|
if (!l) return;
|
|
783
768
|
const p = o.default.extname(l);
|
|
784
769
|
if (p !== ".js" && p !== ".css" && p !== ".html") return;
|
|
785
|
-
const g = o.default.join(
|
|
770
|
+
const g = o.default.join(n, l);
|
|
786
771
|
setTimeout(() => {
|
|
787
772
|
try {
|
|
788
|
-
const
|
|
789
|
-
|
|
773
|
+
const $ = e.default.readFileSync(g, "utf-8"), N = T.get(g);
|
|
774
|
+
$ !== N && (T.set(g, $), console.log(`π File changed: ${g}`), te());
|
|
790
775
|
} catch {
|
|
791
776
|
}
|
|
792
777
|
}, 50);
|
|
793
778
|
})));
|
|
794
779
|
});
|
|
795
|
-
},
|
|
780
|
+
}, Me = () => {
|
|
796
781
|
console.log(`
|
|
797
|
-
π¨ Component: ${
|
|
782
|
+
π¨ Component: ${S}`), te(), $e(E), console.log("π Watching .js, .css, and .html files for changes..."), console.log(`Press Ctrl+C to stop
|
|
798
783
|
`);
|
|
799
|
-
},
|
|
784
|
+
}, We = () => new Promise((n) => {
|
|
800
785
|
const t = {
|
|
801
786
|
hostname: "localhost",
|
|
802
787
|
port: y,
|
|
803
788
|
path: "/_list",
|
|
804
789
|
method: "GET",
|
|
805
790
|
timeout: 1e3
|
|
806
|
-
},
|
|
807
|
-
|
|
791
|
+
}, i = r.default.request(t, (a) => {
|
|
792
|
+
n(!0);
|
|
808
793
|
});
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
}),
|
|
812
|
-
}),
|
|
813
|
-
const t =
|
|
814
|
-
if (
|
|
794
|
+
i.on("error", () => n(!1)), i.on("timeout", () => {
|
|
795
|
+
i.destroy(), n(!1);
|
|
796
|
+
}), i.end();
|
|
797
|
+
}), Ve = () => new Promise((n) => {
|
|
798
|
+
const t = r.default.createServer((i, a) => {
|
|
799
|
+
if (a.setHeader("Content-Type", "application/json"), i.method === "POST" && i.url === "/_register") {
|
|
815
800
|
let l = "";
|
|
816
|
-
|
|
801
|
+
i.on("data", (p) => l += p), i.on("end", () => {
|
|
817
802
|
try {
|
|
818
|
-
const { componentId: p, distPath: g, componentName:
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
console.log(`β
Registered: ${p}${
|
|
803
|
+
const { componentId: p, distPath: g, componentName: $ } = JSON.parse(l);
|
|
804
|
+
x.set(p, { path: g, name: $ || null });
|
|
805
|
+
const N = $ ? ` (${$})` : "";
|
|
806
|
+
console.log(`β
Registered: ${p}${N} -> ${g}`), a.writeHead(200), a.end(JSON.stringify({ success: !0, registered: Array.from(x.keys()) }));
|
|
822
807
|
} catch (p) {
|
|
823
|
-
|
|
808
|
+
a.writeHead(400), a.end(JSON.stringify({ error: p.message }));
|
|
824
809
|
}
|
|
825
810
|
});
|
|
826
|
-
} else if (
|
|
811
|
+
} else if (i.method === "POST" && i.url === "/_unregister") {
|
|
827
812
|
let l = "";
|
|
828
|
-
|
|
813
|
+
i.on("data", (p) => l += p), i.on("end", () => {
|
|
829
814
|
try {
|
|
830
815
|
const { componentId: p } = JSON.parse(l);
|
|
831
|
-
|
|
816
|
+
x.delete(p), console.log(`β Unregistered: ${p}`), a.writeHead(200), a.end(JSON.stringify({ success: !0 }));
|
|
832
817
|
} catch (p) {
|
|
833
|
-
|
|
818
|
+
a.writeHead(400), a.end(JSON.stringify({ error: p.message }));
|
|
834
819
|
}
|
|
835
820
|
});
|
|
836
|
-
} else
|
|
821
|
+
} else i.method === "GET" && i.url === "/_list" ? (a.writeHead(200), a.end(JSON.stringify({ components: Array.from(x.entries()) }))) : (a.writeHead(404), a.end(JSON.stringify({ error: "Not found" })));
|
|
837
822
|
});
|
|
838
823
|
t.on("error", () => {
|
|
839
|
-
|
|
824
|
+
n(!1);
|
|
840
825
|
}), t.listen(y, () => {
|
|
841
826
|
console.log(`
|
|
842
827
|
π Taking over as server...`), console.log(`π‘ Management server on port ${y}`), ee.on("error", () => {
|
|
843
|
-
t.close(),
|
|
828
|
+
t.close(), n(!1);
|
|
844
829
|
}), ee.listen(u, () => {
|
|
845
|
-
console.log(`π‘ Main server running at http://localhost:${u}`),
|
|
846
|
-
path: o.default.resolve(
|
|
847
|
-
name:
|
|
830
|
+
console.log(`π‘ Main server running at http://localhost:${u}`), x.set(S, {
|
|
831
|
+
path: o.default.resolve(E, b),
|
|
832
|
+
name: k
|
|
848
833
|
});
|
|
849
|
-
const
|
|
850
|
-
console.log(`β
Registered component: ${
|
|
834
|
+
const i = k ? ` (${k})` : "";
|
|
835
|
+
console.log(`β
Registered component: ${S}${i}`), console.log(`π‘ Access at: http://localhost:${u}/view/${S}/`), n(!0);
|
|
851
836
|
});
|
|
852
837
|
});
|
|
853
838
|
});
|
|
854
839
|
let oe;
|
|
855
|
-
const
|
|
840
|
+
const Oe = () => {
|
|
856
841
|
oe = setInterval(async () => {
|
|
857
|
-
await
|
|
858
|
-
β οΈ Server appears to be down, attempting to take over...`), await
|
|
842
|
+
await We() || (clearInterval(oe), console.log(`
|
|
843
|
+
β οΈ Server appears to be down, attempting to take over...`), await Ve() ? console.log("β
Successfully took over as server") : (console.log("βΉοΈ Another instance took over, re-registering..."), setTimeout(async () => {
|
|
859
844
|
try {
|
|
860
|
-
await
|
|
861
|
-
} catch (
|
|
862
|
-
console.error("β Failed to re-register:",
|
|
845
|
+
await Se(), console.log(`β
Re-registered component: ${S}`), Oe();
|
|
846
|
+
} catch (i) {
|
|
847
|
+
console.error("β Failed to re-register:", i.message);
|
|
863
848
|
}
|
|
864
849
|
}, 2e3)));
|
|
865
850
|
}, 3e3);
|
|
866
|
-
},
|
|
851
|
+
}, Ie = async () => {
|
|
867
852
|
console.log(`
|
|
868
853
|
|
|
869
|
-
π Shutting down...`), oe && clearInterval(oe), await
|
|
854
|
+
π Shutting down...`), oe && clearInterval(oe), await Je(), process.exit(0);
|
|
870
855
|
};
|
|
871
|
-
process.on("SIGINT",
|
|
872
|
-
if (
|
|
856
|
+
process.on("SIGINT", Ie), process.on("SIGTERM", Ie), de.on("error", async (n) => {
|
|
857
|
+
if (n.code === "EADDRINUSE") {
|
|
873
858
|
console.log(`
|
|
874
859
|
π Connecting to existing dev server...`);
|
|
875
860
|
try {
|
|
876
|
-
|
|
877
|
-
const t = await
|
|
878
|
-
console.log(`β
Registered component: ${
|
|
861
|
+
S = await M();
|
|
862
|
+
const t = await Se();
|
|
863
|
+
console.log(`β
Registered component: ${S}`), console.log(`π‘ Access at: http://localhost:${u}/view/${S}/`), console.log(`π All registered components: ${t.registered.join(", ")}`), Me(), Oe();
|
|
879
864
|
} catch (t) {
|
|
880
865
|
console.error("β Failed to register component:", t.message), process.exit(1);
|
|
881
866
|
}
|
|
882
867
|
} else
|
|
883
|
-
console.error("β Management server error:",
|
|
884
|
-
}), de.on("upgrade",
|
|
868
|
+
console.error("β Management server error:", n.message), process.exit(1);
|
|
869
|
+
}), de.on("upgrade", Le), de.listen(y, async () => {
|
|
885
870
|
console.log(`
|
|
886
|
-
π Starting shared dev server...`), console.log(`π‘ Management server on port ${y}`), ee.on("error", (
|
|
887
|
-
console.error("β Main server error:",
|
|
871
|
+
π Starting shared dev server...`), console.log(`π‘ Management server on port ${y}`), ee.on("error", (n) => {
|
|
872
|
+
console.error("β Main server error:", n.message), process.exit(1);
|
|
888
873
|
}), ee.listen(u, async () => {
|
|
889
|
-
console.log(`π‘ Main server running at http://localhost:${u}`), (
|
|
890
|
-
path: o.default.resolve(
|
|
891
|
-
name:
|
|
874
|
+
console.log(`π‘ Main server running at http://localhost:${u}`), (S === "DEV" || S === "NEW") && (S = "DEV1"), x.set(S, {
|
|
875
|
+
path: o.default.resolve(E, b),
|
|
876
|
+
name: k
|
|
892
877
|
});
|
|
893
|
-
const
|
|
894
|
-
console.log(`β
Registered component: ${
|
|
878
|
+
const n = k ? ` (${k})` : "";
|
|
879
|
+
console.log(`β
Registered component: ${S}${n}`), console.log(`π‘ Access at: http://localhost:${u}/view/${S}/`), Me();
|
|
895
880
|
});
|
|
896
881
|
});
|
|
897
882
|
}
|
|
898
|
-
const
|
|
899
|
-
function
|
|
900
|
-
A.existsSync(
|
|
883
|
+
const fe = Z.join(Qe.homedir(), ".myop"), Q = Z.join(fe, "credentials.json");
|
|
884
|
+
function ct() {
|
|
885
|
+
A.existsSync(fe) || A.mkdirSync(fe, { recursive: !0, mode: 448 });
|
|
901
886
|
}
|
|
902
|
-
function
|
|
887
|
+
function ye() {
|
|
903
888
|
try {
|
|
904
889
|
if (!A.existsSync(Q))
|
|
905
890
|
return null;
|
|
@@ -909,8 +894,8 @@ function he() {
|
|
|
909
894
|
return console.info("Failed to read credentials:", e.message), null;
|
|
910
895
|
}
|
|
911
896
|
}
|
|
912
|
-
function
|
|
913
|
-
|
|
897
|
+
function Fe(e) {
|
|
898
|
+
ct();
|
|
914
899
|
const o = {
|
|
915
900
|
...e,
|
|
916
901
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -920,40 +905,40 @@ function Te(e) {
|
|
|
920
905
|
// Read/write for owner only
|
|
921
906
|
});
|
|
922
907
|
}
|
|
923
|
-
function
|
|
908
|
+
function Ae() {
|
|
924
909
|
try {
|
|
925
910
|
return A.existsSync(Q) && A.unlinkSync(Q), !0;
|
|
926
911
|
} catch (e) {
|
|
927
912
|
return console.error("Failed to clear credentials:", e.message), !1;
|
|
928
913
|
}
|
|
929
914
|
}
|
|
930
|
-
function
|
|
915
|
+
function lt(e) {
|
|
931
916
|
if (!e || !e.expiresAt)
|
|
932
917
|
return !0;
|
|
933
|
-
const o = 5 * 60 * 1e3,
|
|
934
|
-
return Date.now() >
|
|
918
|
+
const o = 5 * 60 * 1e3, s = new Date(e.expiresAt).getTime();
|
|
919
|
+
return Date.now() > s - o;
|
|
935
920
|
}
|
|
936
|
-
function
|
|
937
|
-
const e =
|
|
921
|
+
function we() {
|
|
922
|
+
const e = ye();
|
|
938
923
|
return e ? {
|
|
939
924
|
email: e.userEmail,
|
|
940
925
|
userId: e.userId
|
|
941
926
|
} : null;
|
|
942
927
|
}
|
|
943
|
-
const Y = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", ie = 19284,
|
|
944
|
-
function
|
|
945
|
-
return
|
|
928
|
+
const Y = process.env.MYOP_MCP_URL || "https://mcp.myop.dev", ie = 19284, ve = `http://localhost:${ie}/callback`, dt = "myop-cli";
|
|
929
|
+
function pt() {
|
|
930
|
+
return ge.randomBytes(32).toString("base64url");
|
|
946
931
|
}
|
|
947
|
-
function
|
|
948
|
-
return
|
|
932
|
+
function mt(e) {
|
|
933
|
+
return ge.createHash("sha256").update(e).digest("base64url");
|
|
949
934
|
}
|
|
950
|
-
async function
|
|
935
|
+
async function ut() {
|
|
951
936
|
const e = await fetch(`${Y}/oauth/register`, {
|
|
952
937
|
method: "POST",
|
|
953
938
|
headers: { "Content-Type": "application/json" },
|
|
954
939
|
body: JSON.stringify({
|
|
955
|
-
client_name:
|
|
956
|
-
redirect_uris: [
|
|
940
|
+
client_name: dt,
|
|
941
|
+
redirect_uris: [ve],
|
|
957
942
|
grant_types: ["authorization_code", "refresh_token"],
|
|
958
943
|
response_types: ["code"]
|
|
959
944
|
})
|
|
@@ -964,7 +949,7 @@ async function mt() {
|
|
|
964
949
|
}
|
|
965
950
|
return e.json();
|
|
966
951
|
}
|
|
967
|
-
function se(e, o,
|
|
952
|
+
function se(e, o, s, r = null) {
|
|
968
953
|
const f = {
|
|
969
954
|
success: `<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#4ade80" stroke-width="2">
|
|
970
955
|
<circle cx="12" cy="12" r="10"/>
|
|
@@ -1116,8 +1101,8 @@ function se(e, o, n, a = null) {
|
|
|
1116
1101
|
${f[e] || f.error}
|
|
1117
1102
|
</div>
|
|
1118
1103
|
<h1>${o}</h1>
|
|
1119
|
-
<p class="message">${
|
|
1120
|
-
${
|
|
1104
|
+
<p class="message">${s}</p>
|
|
1105
|
+
${r ? `<div class="details"><code>Error:</code> ${r}</div>` : ""}
|
|
1121
1106
|
<div class="hint">
|
|
1122
1107
|
<span>Press</span>
|
|
1123
1108
|
<kbd>β</kbd><kbd>W</kbd>
|
|
@@ -1130,10 +1115,10 @@ function se(e, o, n, a = null) {
|
|
|
1130
1115
|
</body>
|
|
1131
1116
|
</html>`;
|
|
1132
1117
|
}
|
|
1133
|
-
function
|
|
1134
|
-
return new Promise((o,
|
|
1135
|
-
const
|
|
1136
|
-
const m = new
|
|
1118
|
+
function ft(e) {
|
|
1119
|
+
return new Promise((o, s) => {
|
|
1120
|
+
const r = Ke.createServer((f, c) => {
|
|
1121
|
+
const m = new Ne(f.url, `http://localhost:${ie}`);
|
|
1137
1122
|
if (m.pathname === "/callback") {
|
|
1138
1123
|
const w = m.searchParams.get("code"), I = m.searchParams.get("state"), u = m.searchParams.get("error");
|
|
1139
1124
|
if (u) {
|
|
@@ -1142,7 +1127,7 @@ function ut(e) {
|
|
|
1142
1127
|
"Authentication Failed",
|
|
1143
1128
|
"Unable to complete the authentication process.",
|
|
1144
1129
|
u
|
|
1145
|
-
)),
|
|
1130
|
+
)), r.close(), s(new Error(`OAuth error: ${u}`));
|
|
1146
1131
|
return;
|
|
1147
1132
|
}
|
|
1148
1133
|
if (I !== e) {
|
|
@@ -1151,7 +1136,7 @@ function ut(e) {
|
|
|
1151
1136
|
"Security Error",
|
|
1152
1137
|
"State mismatch detected. This could indicate a CSRF attack. Please try authenticating again.",
|
|
1153
1138
|
"state_mismatch"
|
|
1154
|
-
)),
|
|
1139
|
+
)), r.close(), s(new Error("State mismatch"));
|
|
1155
1140
|
return;
|
|
1156
1141
|
}
|
|
1157
1142
|
if (!w) {
|
|
@@ -1160,59 +1145,59 @@ function ut(e) {
|
|
|
1160
1145
|
"Missing Authorization Code",
|
|
1161
1146
|
"No authorization code was received from the server.",
|
|
1162
1147
|
"missing_code"
|
|
1163
|
-
)),
|
|
1148
|
+
)), r.close(), s(new Error("No authorization code"));
|
|
1164
1149
|
return;
|
|
1165
1150
|
}
|
|
1166
1151
|
c.writeHead(200, { "Content-Type": "text/html" }), c.end(se(
|
|
1167
1152
|
"success",
|
|
1168
1153
|
"Authentication Successful",
|
|
1169
1154
|
"You have been authenticated successfully. Return to the terminal to continue."
|
|
1170
|
-
)),
|
|
1155
|
+
)), r.close(), o(w);
|
|
1171
1156
|
} else
|
|
1172
1157
|
c.writeHead(404), c.end("Not found");
|
|
1173
1158
|
});
|
|
1174
|
-
|
|
1159
|
+
r.listen(ie, () => {
|
|
1175
1160
|
console.info(`OAuth callback server listening on port ${ie}`);
|
|
1176
1161
|
}), setTimeout(() => {
|
|
1177
|
-
|
|
1162
|
+
r.close(), s(new Error("Authentication timed out"));
|
|
1178
1163
|
}, 5 * 60 * 1e3);
|
|
1179
1164
|
});
|
|
1180
1165
|
}
|
|
1181
|
-
async function
|
|
1182
|
-
const
|
|
1166
|
+
async function gt(e, o, s) {
|
|
1167
|
+
const r = await fetch(`${Y}/oauth/token`, {
|
|
1183
1168
|
method: "POST",
|
|
1184
1169
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1185
|
-
body: new
|
|
1170
|
+
body: new ke({
|
|
1186
1171
|
grant_type: "authorization_code",
|
|
1187
1172
|
code: e,
|
|
1188
1173
|
client_id: o,
|
|
1189
|
-
redirect_uri:
|
|
1190
|
-
code_verifier:
|
|
1174
|
+
redirect_uri: ve,
|
|
1175
|
+
code_verifier: s
|
|
1191
1176
|
})
|
|
1192
1177
|
});
|
|
1193
|
-
if (!
|
|
1194
|
-
const f = await
|
|
1178
|
+
if (!r.ok) {
|
|
1179
|
+
const f = await r.json();
|
|
1195
1180
|
throw new Error(f.error_description || f.error || "Token exchange failed");
|
|
1196
1181
|
}
|
|
1197
|
-
return
|
|
1182
|
+
return r.json();
|
|
1198
1183
|
}
|
|
1199
|
-
async function
|
|
1200
|
-
const
|
|
1184
|
+
async function ht(e, o) {
|
|
1185
|
+
const s = await fetch(`${Y}/oauth/token`, {
|
|
1201
1186
|
method: "POST",
|
|
1202
1187
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1203
|
-
body: new
|
|
1188
|
+
body: new ke({
|
|
1204
1189
|
grant_type: "refresh_token",
|
|
1205
1190
|
refresh_token: e,
|
|
1206
1191
|
client_id: o
|
|
1207
1192
|
})
|
|
1208
1193
|
});
|
|
1209
|
-
if (!
|
|
1210
|
-
const
|
|
1211
|
-
throw new Error(
|
|
1194
|
+
if (!s.ok) {
|
|
1195
|
+
const r = await s.json();
|
|
1196
|
+
throw new Error(r.error_description || r.error || "Token refresh failed");
|
|
1212
1197
|
}
|
|
1213
|
-
return
|
|
1198
|
+
return s.json();
|
|
1214
1199
|
}
|
|
1215
|
-
async function
|
|
1200
|
+
async function yt(e) {
|
|
1216
1201
|
var f, c, m;
|
|
1217
1202
|
const o = await fetch(`${Y}/mcp`, {
|
|
1218
1203
|
method: "POST",
|
|
@@ -1232,81 +1217,81 @@ async function ht(e) {
|
|
|
1232
1217
|
});
|
|
1233
1218
|
if (!o.ok)
|
|
1234
1219
|
throw new Error("Failed to get user info");
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1237
|
-
throw new Error(
|
|
1238
|
-
const
|
|
1239
|
-
if (
|
|
1240
|
-
return JSON.parse(
|
|
1220
|
+
const s = await o.json();
|
|
1221
|
+
if (s.error)
|
|
1222
|
+
throw new Error(s.error.message);
|
|
1223
|
+
const r = (m = (c = (f = s.result) == null ? void 0 : f.content) == null ? void 0 : c[0]) == null ? void 0 : m.text;
|
|
1224
|
+
if (r)
|
|
1225
|
+
return JSON.parse(r);
|
|
1241
1226
|
throw new Error("Invalid response from whoami");
|
|
1242
1227
|
}
|
|
1243
1228
|
async function X() {
|
|
1244
1229
|
const e = F("Starting authentication...").start();
|
|
1245
1230
|
try {
|
|
1246
1231
|
e.text = "Registering OAuth client...";
|
|
1247
|
-
const
|
|
1232
|
+
const s = (await ut()).client_id, r = pt(), f = mt(r), c = ge.randomBytes(16).toString("hex");
|
|
1248
1233
|
e.text = "Waiting for authorization...";
|
|
1249
|
-
const m =
|
|
1250
|
-
w.searchParams.set("response_type", "code"), w.searchParams.set("client_id",
|
|
1234
|
+
const m = ft(c), w = new Ne(`${Y}/oauth/authorize`);
|
|
1235
|
+
w.searchParams.set("response_type", "code"), w.searchParams.set("client_id", s), w.searchParams.set("redirect_uri", ve), w.searchParams.set("code_challenge", f), w.searchParams.set("code_challenge_method", "S256"), w.searchParams.set("state", c), e.stop(), console.log(`
|
|
1251
1236
|
π Opening browser for authentication...`), console.log("If the browser does not open, visit:"), console.log(` ${w.toString()}
|
|
1252
|
-
`), await
|
|
1237
|
+
`), await Xe(w.toString());
|
|
1253
1238
|
const I = await m;
|
|
1254
1239
|
e.start("Exchanging authorization code...");
|
|
1255
|
-
const u = await
|
|
1240
|
+
const u = await gt(I, s, r);
|
|
1256
1241
|
e.text = "Getting user info...";
|
|
1257
|
-
const y = await
|
|
1242
|
+
const y = await yt(u.access_token), b = {
|
|
1258
1243
|
accessToken: u.access_token,
|
|
1259
1244
|
refreshToken: u.refresh_token,
|
|
1260
1245
|
expiresAt: new Date(Date.now() + u.expires_in * 1e3).toISOString(),
|
|
1261
|
-
clientId:
|
|
1246
|
+
clientId: s,
|
|
1262
1247
|
userId: y.userId,
|
|
1263
1248
|
userEmail: y.email
|
|
1264
1249
|
};
|
|
1265
|
-
return
|
|
1250
|
+
return Fe(b), e.succeed(`Authenticated as ${y.email}`), b;
|
|
1266
1251
|
} catch (o) {
|
|
1267
1252
|
throw e.fail(`Authentication failed: ${o.message}`), o;
|
|
1268
1253
|
}
|
|
1269
1254
|
}
|
|
1270
|
-
async function
|
|
1271
|
-
const e =
|
|
1255
|
+
async function De() {
|
|
1256
|
+
const e = ye();
|
|
1272
1257
|
if (!e) {
|
|
1273
1258
|
console.log("Not currently logged in.");
|
|
1274
1259
|
return;
|
|
1275
1260
|
}
|
|
1276
|
-
|
|
1261
|
+
Ae(), console.log(`β
Logged out (was: ${e.userEmail})`);
|
|
1277
1262
|
}
|
|
1278
|
-
async function
|
|
1279
|
-
let e =
|
|
1263
|
+
async function wt() {
|
|
1264
|
+
let e = ye();
|
|
1280
1265
|
if (!e)
|
|
1281
1266
|
return console.log(`Not logged in. Starting authentication...
|
|
1282
1267
|
`), await X();
|
|
1283
|
-
if (!
|
|
1268
|
+
if (!lt(e))
|
|
1284
1269
|
return e;
|
|
1285
1270
|
if (e.refreshToken) {
|
|
1286
1271
|
const o = F("Refreshing access token...").start();
|
|
1287
1272
|
try {
|
|
1288
|
-
const
|
|
1273
|
+
const s = await ht(
|
|
1289
1274
|
e.refreshToken,
|
|
1290
1275
|
e.clientId
|
|
1291
1276
|
);
|
|
1292
1277
|
return e = {
|
|
1293
1278
|
...e,
|
|
1294
|
-
accessToken:
|
|
1295
|
-
refreshToken:
|
|
1296
|
-
expiresAt: new Date(Date.now() +
|
|
1297
|
-
},
|
|
1279
|
+
accessToken: s.access_token,
|
|
1280
|
+
refreshToken: s.refresh_token,
|
|
1281
|
+
expiresAt: new Date(Date.now() + s.expires_in * 1e3).toISOString()
|
|
1282
|
+
}, Fe(e), o.succeed("Token refreshed"), e;
|
|
1298
1283
|
} catch {
|
|
1299
|
-
return o.warn("Token refresh failed, please log in again"),
|
|
1284
|
+
return o.warn("Token refresh failed, please log in again"), Ae(), await X();
|
|
1300
1285
|
}
|
|
1301
1286
|
}
|
|
1302
1287
|
return console.log(`Session expired. Please log in again.
|
|
1303
1288
|
`), await X();
|
|
1304
1289
|
}
|
|
1305
|
-
function
|
|
1290
|
+
function vt() {
|
|
1306
1291
|
return Y;
|
|
1307
1292
|
}
|
|
1308
1293
|
const ae = "@myop/cli";
|
|
1309
|
-
async function
|
|
1294
|
+
async function St() {
|
|
1310
1295
|
try {
|
|
1311
1296
|
const e = await fetch(`https://registry.npmjs.org/${ae}/latest`);
|
|
1312
1297
|
return e.ok ? (await e.json()).version : null;
|
|
@@ -1314,28 +1299,28 @@ async function vt() {
|
|
|
1314
1299
|
return null;
|
|
1315
1300
|
}
|
|
1316
1301
|
}
|
|
1317
|
-
function
|
|
1318
|
-
const
|
|
1319
|
-
for (let f = 0; f < Math.max(
|
|
1320
|
-
const c =
|
|
1302
|
+
function bt(e, o) {
|
|
1303
|
+
const s = e.split(".").map(Number), r = o.split(".").map(Number);
|
|
1304
|
+
for (let f = 0; f < Math.max(s.length, r.length); f++) {
|
|
1305
|
+
const c = s[f] || 0, m = r[f] || 0;
|
|
1321
1306
|
if (c > m) return 1;
|
|
1322
1307
|
if (c < m) return -1;
|
|
1323
1308
|
}
|
|
1324
1309
|
return 0;
|
|
1325
1310
|
}
|
|
1326
|
-
async function
|
|
1311
|
+
async function xt(e) {
|
|
1327
1312
|
const o = F({
|
|
1328
1313
|
text: "Checking for updates...",
|
|
1329
1314
|
color: "cyan"
|
|
1330
|
-
}).start(),
|
|
1331
|
-
if (o.stop(), !
|
|
1315
|
+
}).start(), s = await St();
|
|
1316
|
+
if (o.stop(), !s || bt(s, e) <= 0)
|
|
1332
1317
|
return !1;
|
|
1333
1318
|
console.log(`
|
|
1334
|
-
π¦ New version available: ${e} β ${
|
|
1319
|
+
π¦ New version available: ${e} β ${s}
|
|
1335
1320
|
`);
|
|
1336
|
-
let
|
|
1321
|
+
let r;
|
|
1337
1322
|
try {
|
|
1338
|
-
|
|
1323
|
+
r = await _e({
|
|
1339
1324
|
message: "Would you like to update now?",
|
|
1340
1325
|
choices: [
|
|
1341
1326
|
{ name: "Yes, update now", value: !0 },
|
|
@@ -1348,15 +1333,15 @@ async function St(e) {
|
|
|
1348
1333
|
π Goodbye!
|
|
1349
1334
|
`), process.exit(0)), f;
|
|
1350
1335
|
}
|
|
1351
|
-
if (
|
|
1336
|
+
if (r) {
|
|
1352
1337
|
const f = F({
|
|
1353
|
-
text: `Updating ${ae} to v${
|
|
1338
|
+
text: `Updating ${ae} to v${s}...`,
|
|
1354
1339
|
color: "green"
|
|
1355
1340
|
}).start();
|
|
1356
1341
|
try {
|
|
1357
|
-
return re(`npm install -g ${ae}@latest`, { stdio: "pipe" }), f.succeed(`Updated to v${
|
|
1342
|
+
return re(`npm install -g ${ae}@latest`, { stdio: "pipe" }), f.succeed(`Updated to v${s}`), console.log(`
|
|
1358
1343
|
π Restarting with new version...
|
|
1359
|
-
`),
|
|
1344
|
+
`), Ye("myop", process.argv.slice(2), {
|
|
1360
1345
|
stdio: "inherit",
|
|
1361
1346
|
shell: !0
|
|
1362
1347
|
}).on("close", (m) => {
|
|
@@ -1370,7 +1355,7 @@ You can manually update by running: npm install -g ${ae}@latest
|
|
|
1370
1355
|
}
|
|
1371
1356
|
return !1;
|
|
1372
1357
|
}
|
|
1373
|
-
const
|
|
1358
|
+
const Ct = (e) => new Promise((o) => setTimeout(o, e));
|
|
1374
1359
|
d.executionPath = process.cwd();
|
|
1375
1360
|
const le = (e = !1) => {
|
|
1376
1361
|
const o = d.program.getOptionValue("verbose");
|
|
@@ -1380,43 +1365,43 @@ const le = (e = !1) => {
|
|
|
1380
1365
|
verbose: o
|
|
1381
1366
|
};
|
|
1382
1367
|
try {
|
|
1383
|
-
return d.myopConfig =
|
|
1384
|
-
} catch (
|
|
1368
|
+
return d.myopConfig = qe(d.options.configPath), { configFound: !0 };
|
|
1369
|
+
} catch (s) {
|
|
1385
1370
|
if (e) {
|
|
1386
1371
|
console.info(`
|
|
1387
1372
|
β οΈ failed read config file from ${d.options.configPath}, trying to create new one`);
|
|
1388
1373
|
try {
|
|
1389
|
-
const
|
|
1374
|
+
const r = {
|
|
1390
1375
|
author: "@myop-cli",
|
|
1391
1376
|
flows: []
|
|
1392
1377
|
};
|
|
1393
|
-
return
|
|
1378
|
+
return he(d.options.configPath, r), d.myopConfig = r, { configFound: !0 };
|
|
1394
1379
|
} catch {
|
|
1395
|
-
return console.info("Error details :",
|
|
1380
|
+
return console.info("Error details :", s), { configFound: !1, error: s };
|
|
1396
1381
|
}
|
|
1397
1382
|
} else
|
|
1398
|
-
return console.info("Error details :",
|
|
1383
|
+
return console.info("Error details :", s), { configFound: !1, error: s };
|
|
1399
1384
|
}
|
|
1400
1385
|
};
|
|
1401
1386
|
[
|
|
1402
|
-
new
|
|
1403
|
-
...
|
|
1387
|
+
new ue(),
|
|
1388
|
+
...it
|
|
1404
1389
|
];
|
|
1405
|
-
const
|
|
1406
|
-
d.program = new
|
|
1407
|
-
d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version(
|
|
1390
|
+
const $t = "0.1.19";
|
|
1391
|
+
d.program = new Ge();
|
|
1392
|
+
d.program.name("@myop/cli").description("Myop CLI - Remote UI Made Easy").version($t);
|
|
1408
1393
|
d.program.addOption(new ce("-c, --config <value>", "myop.config.json file location").default("./myop.config.json", "./myop.config.json"));
|
|
1409
1394
|
d.program.addOption(new ce("-h, --help", "Show helpful information"));
|
|
1410
1395
|
d.program.addOption(new ce("-v, --verbose", "Enables verbose output mode for the command-line interface (CLI)."));
|
|
1411
1396
|
d.program.addOption(new ce("--ci", "CI mode: print status info (version, config, auth) as JSON and exit without prompts"));
|
|
1412
1397
|
d.program.command("add").description("Install Myop assets").addArgument("type").addArgument("id").action((e, o) => {
|
|
1413
|
-
le(!0), console.info("adding ", e, o, d.options.configPath), e === "flow" &&
|
|
1398
|
+
le(!0), console.info("adding ", e, o, d.options.configPath), e === "flow" && Te._action(o), process.exit();
|
|
1414
1399
|
});
|
|
1415
1400
|
d.program.command("remove").description("Remove Myop asset").argument("<type>", "Myop asset type").argument("<id>", "Asset id").action((e, o) => {
|
|
1416
|
-
le(), console.info("removing ", e, o, d.options.configPath), e === "flow" &&
|
|
1401
|
+
le(), console.info("removing ", e, o, d.options.configPath), e === "flow" && Pe._action(o), process.exit();
|
|
1417
1402
|
});
|
|
1418
1403
|
d.program.command("install").description("Install Myop assets").action(async () => {
|
|
1419
|
-
le(), await
|
|
1404
|
+
le(), await Ee.action();
|
|
1420
1405
|
});
|
|
1421
1406
|
d.program.command("login").description("Authenticate with Myop platform").action(async () => {
|
|
1422
1407
|
try {
|
|
@@ -1427,22 +1412,22 @@ d.program.command("login").description("Authenticate with Myop platform").action
|
|
|
1427
1412
|
process.exit(0);
|
|
1428
1413
|
});
|
|
1429
1414
|
d.program.command("logout").description("Clear stored credentials").action(async () => {
|
|
1430
|
-
await
|
|
1415
|
+
await De(), process.exit(0);
|
|
1431
1416
|
});
|
|
1432
1417
|
d.program.command("whoami").description("Show current authenticated user").action(async () => {
|
|
1433
|
-
const e =
|
|
1418
|
+
const e = we();
|
|
1434
1419
|
e && e.email ? console.log(`Logged in as: ${e.email}`) : console.log("Not logged in. Run `myop login` to authenticate."), process.exit(0);
|
|
1435
1420
|
});
|
|
1436
1421
|
d.program.command("sync").description("Build and upload component to Myop platform").option("--skip-build", "Skip the build step").action(async (e) => {
|
|
1437
|
-
var j, v,
|
|
1438
|
-
const o = d.program.getOptionValue("config") || "./myop.config.json",
|
|
1422
|
+
var j, v, T, z, S, k;
|
|
1423
|
+
const o = d.program.getOptionValue("config") || "./myop.config.json", s = await import("fs"), { execSync: r } = await import("child_process"), f = await import("path");
|
|
1439
1424
|
let c = {};
|
|
1440
|
-
if (
|
|
1425
|
+
if (s.existsSync(o))
|
|
1441
1426
|
try {
|
|
1442
|
-
const h =
|
|
1427
|
+
const h = s.readFileSync(o, "utf-8");
|
|
1443
1428
|
c = JSON.parse(h);
|
|
1444
|
-
const
|
|
1445
|
-
console.log(`π Found config: ${
|
|
1429
|
+
const M = c.name || c.componentName;
|
|
1430
|
+
console.log(`π Found config: ${M || "Unnamed component"}`), c.componentId && console.log(` Component ID: ${c.componentId}`);
|
|
1446
1431
|
} catch (h) {
|
|
1447
1432
|
console.error(`β οΈ Failed to parse ${o}:`, h.message);
|
|
1448
1433
|
}
|
|
@@ -1451,20 +1436,20 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1451
1436
|
if (!e.skipBuild) {
|
|
1452
1437
|
const h = F("Building project...").start();
|
|
1453
1438
|
try {
|
|
1454
|
-
|
|
1455
|
-
} catch (
|
|
1456
|
-
h.fail("Build failed"), console.error(
|
|
1439
|
+
r("npm run build", { stdio: "pipe" }), h.succeed("Build completed");
|
|
1440
|
+
} catch (M) {
|
|
1441
|
+
h.fail("Build failed"), console.error(M.message), process.exit(1);
|
|
1457
1442
|
}
|
|
1458
1443
|
}
|
|
1459
1444
|
const m = "./dist/index.html";
|
|
1460
|
-
|
|
1445
|
+
s.existsSync(m) || (console.error("β Error: ./dist/index.html not found"), console.log(" Make sure your build outputs to ./dist/index.html"), process.exit(1));
|
|
1461
1446
|
let w;
|
|
1462
1447
|
try {
|
|
1463
|
-
w = await
|
|
1448
|
+
w = await wt();
|
|
1464
1449
|
} catch (h) {
|
|
1465
1450
|
console.error("β Authentication failed:", h.message), process.exit(1);
|
|
1466
1451
|
}
|
|
1467
|
-
const I =
|
|
1452
|
+
const I = vt();
|
|
1468
1453
|
let u = F("Requesting upload URL...").start(), y;
|
|
1469
1454
|
try {
|
|
1470
1455
|
const h = await fetch(`${I}/mcp`, {
|
|
@@ -1489,11 +1474,11 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1489
1474
|
});
|
|
1490
1475
|
if (!h.ok)
|
|
1491
1476
|
throw new Error(`Server returned ${h.status}`);
|
|
1492
|
-
const
|
|
1493
|
-
if (
|
|
1494
|
-
throw new Error(
|
|
1495
|
-
const
|
|
1496
|
-
if (y = JSON.parse(
|
|
1477
|
+
const M = await h.json();
|
|
1478
|
+
if (M.error)
|
|
1479
|
+
throw new Error(M.error.message);
|
|
1480
|
+
const E = (T = (v = (j = M.result) == null ? void 0 : j.content) == null ? void 0 : v[0]) == null ? void 0 : T.text;
|
|
1481
|
+
if (y = JSON.parse(E), !y.success)
|
|
1497
1482
|
throw new Error(y.error);
|
|
1498
1483
|
u.succeed("Upload URL obtained");
|
|
1499
1484
|
} catch (h) {
|
|
@@ -1501,20 +1486,20 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1501
1486
|
}
|
|
1502
1487
|
u = F("Uploading component...").start();
|
|
1503
1488
|
try {
|
|
1504
|
-
const h =
|
|
1505
|
-
let
|
|
1506
|
-
const
|
|
1507
|
-
if (
|
|
1508
|
-
|
|
1489
|
+
const h = s.readFileSync(m, "utf-8");
|
|
1490
|
+
let M;
|
|
1491
|
+
const E = y.curlCommand.match(/(?:"|\\")([^"\\]+(?:\\.[^"\\]*)*)(?:"|\\")$/);
|
|
1492
|
+
if (E)
|
|
1493
|
+
M = E[1];
|
|
1509
1494
|
else {
|
|
1510
|
-
const
|
|
1511
|
-
if (
|
|
1512
|
-
|
|
1495
|
+
const x = y.curlCommand.match(/(https:\/\/[^\s"\\]+)/);
|
|
1496
|
+
if (x)
|
|
1497
|
+
M = x[1];
|
|
1513
1498
|
else
|
|
1514
1499
|
throw new Error("Could not parse presigned URL from: " + y.curlCommand);
|
|
1515
1500
|
}
|
|
1516
|
-
console.info("Uploading to:",
|
|
1517
|
-
const K = await fetch(
|
|
1501
|
+
console.info("Uploading to:", M.substring(0, 100) + "...");
|
|
1502
|
+
const K = await fetch(M, {
|
|
1518
1503
|
method: "PUT",
|
|
1519
1504
|
headers: {
|
|
1520
1505
|
"Content-Type": "text/html"
|
|
@@ -1522,15 +1507,15 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1522
1507
|
body: h
|
|
1523
1508
|
});
|
|
1524
1509
|
if (!K.ok) {
|
|
1525
|
-
const
|
|
1526
|
-
throw new Error(`Upload failed with status ${K.status}: ${
|
|
1510
|
+
const x = await K.text();
|
|
1511
|
+
throw new Error(`Upload failed with status ${K.status}: ${x}`);
|
|
1527
1512
|
}
|
|
1528
1513
|
u.succeed("Component uploaded");
|
|
1529
1514
|
} catch (h) {
|
|
1530
1515
|
u.fail("Upload failed"), console.error(" ", h.message), h.cause && console.error(" Cause:", h.cause), process.exit(1);
|
|
1531
1516
|
}
|
|
1532
1517
|
u = F("Confirming upload...").start();
|
|
1533
|
-
let
|
|
1518
|
+
let b;
|
|
1534
1519
|
try {
|
|
1535
1520
|
const h = await fetch(`${I}/mcp`, {
|
|
1536
1521
|
method: "POST",
|
|
@@ -1552,31 +1537,31 @@ d.program.command("sync").description("Build and upload component to Myop platfo
|
|
|
1552
1537
|
});
|
|
1553
1538
|
if (!h.ok)
|
|
1554
1539
|
throw new Error(`Server returned ${h.status}`);
|
|
1555
|
-
const
|
|
1556
|
-
if (
|
|
1557
|
-
throw new Error(
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1560
|
-
throw new Error(
|
|
1540
|
+
const M = await h.json();
|
|
1541
|
+
if (M.error)
|
|
1542
|
+
throw new Error(M.error.message);
|
|
1543
|
+
const E = (k = (S = (z = M.result) == null ? void 0 : z.content) == null ? void 0 : S[0]) == null ? void 0 : k.text;
|
|
1544
|
+
if (b = JSON.parse(E), !b.success)
|
|
1545
|
+
throw new Error(b.error);
|
|
1561
1546
|
u.succeed("Upload confirmed");
|
|
1562
1547
|
} catch (h) {
|
|
1563
1548
|
u.fail("Confirmation failed"), console.error(" ", h.message), process.exit(1);
|
|
1564
1549
|
}
|
|
1565
|
-
if (
|
|
1566
|
-
c.componentId =
|
|
1550
|
+
if (b.isNewComponent || !c.componentId) {
|
|
1551
|
+
c.componentId = b.componentId, c.organization = b.orgId, c.name || (c.name = b.componentName);
|
|
1567
1552
|
try {
|
|
1568
|
-
|
|
1553
|
+
s.writeFileSync(o, JSON.stringify(c, null, 2)), console.log(`
|
|
1569
1554
|
π Updated ${o} with componentId`);
|
|
1570
1555
|
} catch (h) {
|
|
1571
1556
|
console.log(`
|
|
1572
|
-
β οΈ Could not update ${o}: ${h.message}`), console.log(` Please add componentId: "${
|
|
1557
|
+
β οΈ Could not update ${o}: ${h.message}`), console.log(` Please add componentId: "${b.componentId}" manually`);
|
|
1573
1558
|
}
|
|
1574
1559
|
}
|
|
1575
1560
|
console.log(`
|
|
1576
|
-
β
Sync completed successfully!`), console.log(` Component: ${
|
|
1561
|
+
β
Sync completed successfully!`), console.log(` Component: ${b.componentName}`), console.log(` Dashboard: ${b.dashboardUrl}`), process.exit(0);
|
|
1577
1562
|
});
|
|
1578
|
-
d.program.command("dev").description("Start development server with file watching").action(
|
|
1579
|
-
const
|
|
1563
|
+
d.program.command("dev").description("Start development server with file watching").action(Re);
|
|
1564
|
+
const Mt = () => {
|
|
1580
1565
|
try {
|
|
1581
1566
|
re("git --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
1582
1567
|
} catch {
|
|
@@ -1599,21 +1584,21 @@ const $t = () => {
|
|
|
1599
1584
|
deletions: 0
|
|
1600
1585
|
};
|
|
1601
1586
|
const o = e.split(`
|
|
1602
|
-
`),
|
|
1587
|
+
`), s = o[o.length - 1], r = s.match(/(\d+) insertion/), f = s.match(/(\d+) deletion/), c = s.match(/(\d+) file/);
|
|
1603
1588
|
return {
|
|
1604
1589
|
files: c ? parseInt(c[1]) : 0,
|
|
1605
|
-
insertions:
|
|
1590
|
+
insertions: r ? parseInt(r[1]) : 0,
|
|
1606
1591
|
deletions: f ? parseInt(f[1]) : 0
|
|
1607
1592
|
};
|
|
1608
1593
|
} catch {
|
|
1609
1594
|
return null;
|
|
1610
1595
|
}
|
|
1611
1596
|
}, B = async (e = !1, o = !1) => {
|
|
1612
|
-
var y,
|
|
1613
|
-
const
|
|
1597
|
+
var y, b, j;
|
|
1598
|
+
const s = we(), r = !!(s != null && s.email), f = ((y = d.myopConfig) == null ? void 0 : y.name) || ((b = d.myopConfig) == null ? void 0 : b.componentName), c = (j = d.myopConfig) == null ? void 0 : j.componentId, m = Mt();
|
|
1614
1599
|
console.log(`
|
|
1615
1600
|
βββββββββββββββββββββββββββββββββββββββββββββββββββ`), console.log("β β"), console.log("β Welcome to Myop CLI - Remote UI Made Easy β"), console.log("β β"), console.log(`βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
1616
|
-
`), e && f ? (console.log(` Component: ${f}`), c ? (console.log(` ID: ${c}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${c}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${
|
|
1601
|
+
`), e && f ? (console.log(` Component: ${f}`), c ? (console.log(` ID: ${c}`), console.log(` Dashboard: https://dashboard.myop.dev/dashboard/2.0/component/${c}`)) : console.log(" ID: (not yet pushed)")) : console.log(" Component: No myop.config.json found"), console.log(` User: ${r ? s.email : "Not logged in"}`), m != null && m.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")) : m != null && m.notARepo ? console.log(" Changes: Not a git repository") : m && (m.insertions > 0 || m.deletions > 0) ? console.log(` Changes: ${m.files} file${m.files !== 1 ? "s" : ""} | \x1B[32m+${m.insertions}\x1B[0m \x1B[31m-${m.deletions}\x1B[0m`) : m && console.log(" Changes: No uncommitted changes"), console.log("");
|
|
1617
1602
|
const I = [
|
|
1618
1603
|
{
|
|
1619
1604
|
emoji: "π",
|
|
@@ -1627,7 +1612,7 @@ const $t = () => {
|
|
|
1627
1612
|
label: f ? `Push "${f}"` : "Push component",
|
|
1628
1613
|
value: "sync",
|
|
1629
1614
|
help: "Builds project & uploads dist/index.html to Myop",
|
|
1630
|
-
disabled: e ?
|
|
1615
|
+
disabled: e ? r ? !1 : "(login required)" : "(no config file)"
|
|
1631
1616
|
},
|
|
1632
1617
|
{
|
|
1633
1618
|
emoji: "π οΈ ",
|
|
@@ -1643,18 +1628,18 @@ const $t = () => {
|
|
|
1643
1628
|
disabled: v.disabled
|
|
1644
1629
|
}));
|
|
1645
1630
|
I.push(
|
|
1646
|
-
new
|
|
1631
|
+
new ue(),
|
|
1647
1632
|
{
|
|
1648
|
-
name: o &&
|
|
1649
|
-
Clears stored credentials from this machine` : o && !
|
|
1650
|
-
Opens browser to authenticate with Myop` :
|
|
1651
|
-
value:
|
|
1633
|
+
name: o && r ? `π Logout (${s.email})
|
|
1634
|
+
Clears stored credentials from this machine` : o && !r ? `π Login to Myop
|
|
1635
|
+
Opens browser to authenticate with Myop` : r ? `π Logout (${s.email})` : "π Login to Myop",
|
|
1636
|
+
value: r ? "logout" : "login"
|
|
1652
1637
|
},
|
|
1653
1638
|
{
|
|
1654
1639
|
name: o ? "π Hide help" : "π Show help",
|
|
1655
1640
|
value: "help"
|
|
1656
1641
|
},
|
|
1657
|
-
new
|
|
1642
|
+
new ue(),
|
|
1658
1643
|
{
|
|
1659
1644
|
name: "π Exit",
|
|
1660
1645
|
value: "exit"
|
|
@@ -1662,7 +1647,7 @@ const $t = () => {
|
|
|
1662
1647
|
);
|
|
1663
1648
|
let u;
|
|
1664
1649
|
try {
|
|
1665
|
-
u = await
|
|
1650
|
+
u = await _e({
|
|
1666
1651
|
message: "What would you like to do?",
|
|
1667
1652
|
choices: I
|
|
1668
1653
|
});
|
|
@@ -1674,7 +1659,7 @@ const $t = () => {
|
|
|
1674
1659
|
}
|
|
1675
1660
|
switch (u) {
|
|
1676
1661
|
case "init":
|
|
1677
|
-
await
|
|
1662
|
+
await Ot();
|
|
1678
1663
|
break;
|
|
1679
1664
|
case "sync":
|
|
1680
1665
|
console.log(`
|
|
@@ -1688,18 +1673,18 @@ Running sync...
|
|
|
1688
1673
|
await B(!0, o);
|
|
1689
1674
|
break;
|
|
1690
1675
|
case "dev":
|
|
1691
|
-
await
|
|
1676
|
+
await Re();
|
|
1692
1677
|
break;
|
|
1693
1678
|
case "login":
|
|
1694
1679
|
try {
|
|
1695
1680
|
await X(), console.log(`
|
|
1696
1681
|
`), await B(e, o);
|
|
1697
|
-
} catch (
|
|
1698
|
-
console.error("Login failed:",
|
|
1682
|
+
} catch (T) {
|
|
1683
|
+
console.error("Login failed:", T.message), await B(e, o);
|
|
1699
1684
|
}
|
|
1700
1685
|
break;
|
|
1701
1686
|
case "logout":
|
|
1702
|
-
await
|
|
1687
|
+
await De(), console.log(`
|
|
1703
1688
|
`), await B(e, o);
|
|
1704
1689
|
break;
|
|
1705
1690
|
case "help":
|
|
@@ -1708,8 +1693,8 @@ Running sync...
|
|
|
1708
1693
|
case "exit":
|
|
1709
1694
|
process.exit(0);
|
|
1710
1695
|
}
|
|
1711
|
-
},
|
|
1712
|
-
const { input: e, select: o } = await import("@inquirer/prompts"),
|
|
1696
|
+
}, Ot = async () => {
|
|
1697
|
+
const { input: e, select: o } = await import("@inquirer/prompts"), s = await import("fs"), f = (await import("path")).default.basename(process.cwd());
|
|
1713
1698
|
let c, m;
|
|
1714
1699
|
try {
|
|
1715
1700
|
c = await e({
|
|
@@ -1736,7 +1721,7 @@ Running sync...
|
|
|
1736
1721
|
author: "@myop-cli"
|
|
1737
1722
|
}, I = d.program.getOptionValue("config") || "./myop.config.json";
|
|
1738
1723
|
try {
|
|
1739
|
-
|
|
1724
|
+
s.writeFileSync(I, JSON.stringify(w, null, 2)), console.log(`
|
|
1740
1725
|
β
Created ${I}`);
|
|
1741
1726
|
const u = {
|
|
1742
1727
|
name: c.toLowerCase().replace(/\s+/g, "-"),
|
|
@@ -1750,7 +1735,7 @@ Running sync...
|
|
|
1750
1735
|
esbuild: "^0.24.0"
|
|
1751
1736
|
}
|
|
1752
1737
|
};
|
|
1753
|
-
|
|
1738
|
+
s.writeFileSync("package.json", JSON.stringify(u, null, 2)), console.log("β
Created package.json"), s.mkdirSync("src/modules", { recursive: !0 }), s.mkdirSync("src/styles", { recursive: !0 }), s.writeFileSync("build.js", `import * as esbuild from 'esbuild';
|
|
1754
1739
|
import fs from 'fs';
|
|
1755
1740
|
import path from 'path';
|
|
1756
1741
|
|
|
@@ -1830,7 +1815,7 @@ fs.writeFileSync('dist/index.html', html);
|
|
|
1830
1815
|
console.log('β
Built dist/index.html');
|
|
1831
1816
|
console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS files\`);
|
|
1832
1817
|
`), console.log("β
Created build.js");
|
|
1833
|
-
const
|
|
1818
|
+
const b = `<!DOCTYPE html>
|
|
1834
1819
|
<html lang="en">
|
|
1835
1820
|
<head>
|
|
1836
1821
|
<meta charset="UTF-8">
|
|
@@ -1847,7 +1832,7 @@ console.log(\` Bundled \${jsFiles.length} JS modules, \${cssFiles.length} CSS
|
|
|
1847
1832
|
</body>
|
|
1848
1833
|
</html>
|
|
1849
1834
|
`;
|
|
1850
|
-
|
|
1835
|
+
s.writeFileSync("index.html", b), console.log("β
Created index.html");
|
|
1851
1836
|
const j = `// ${c} - Entry Point
|
|
1852
1837
|
import { init } from './modules/app.js';
|
|
1853
1838
|
import { setupMyopInterface } from './modules/myop.js';
|
|
@@ -1857,7 +1842,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
1857
1842
|
setupMyopInterface();
|
|
1858
1843
|
});
|
|
1859
1844
|
`;
|
|
1860
|
-
|
|
1845
|
+
s.writeFileSync("src/index.js", j), console.log("β
Created src/index.js");
|
|
1861
1846
|
const v = `// ${c} - Main Application Logic
|
|
1862
1847
|
|
|
1863
1848
|
export function init() {
|
|
@@ -1866,7 +1851,7 @@ export function init() {
|
|
|
1866
1851
|
// Your component logic here
|
|
1867
1852
|
}
|
|
1868
1853
|
`;
|
|
1869
|
-
|
|
1854
|
+
s.writeFileSync("src/modules/app.js", v), console.log("β
Created src/modules/app.js"), s.writeFileSync("src/modules/myop.js", `// Myop Interface - Communication with host app
|
|
1870
1855
|
|
|
1871
1856
|
export function setupMyopInterface() {
|
|
1872
1857
|
// Called when host app sends data to this component
|
|
@@ -1886,8 +1871,8 @@ export function setupMyopInterface() {
|
|
|
1886
1871
|
/* Add your CSS imports here - they will be auto-bundled */
|
|
1887
1872
|
@import './main.css';
|
|
1888
1873
|
`;
|
|
1889
|
-
|
|
1890
|
-
const
|
|
1874
|
+
s.writeFileSync("src/styles/index.css", z), console.log("β
Created src/styles/index.css");
|
|
1875
|
+
const S = `/* ${c} - Main Styles */
|
|
1891
1876
|
|
|
1892
1877
|
* {
|
|
1893
1878
|
box-sizing: border-box;
|
|
@@ -1916,7 +1901,7 @@ p {
|
|
|
1916
1901
|
line-height: 1.5;
|
|
1917
1902
|
}
|
|
1918
1903
|
`;
|
|
1919
|
-
|
|
1904
|
+
s.writeFileSync("src/styles/main.css", S), console.log("β
Created src/styles/main.css"), console.log(`
|
|
1920
1905
|
π¦ Next steps:`), console.log(" 1. npm install"), console.log(" 2. npm run build"), console.log(` 3. myop sync
|
|
1921
1906
|
`), d.myopConfig = w, await B(!0);
|
|
1922
1907
|
} catch (u) {
|
|
@@ -1924,8 +1909,8 @@ p {
|
|
|
1924
1909
|
}
|
|
1925
1910
|
};
|
|
1926
1911
|
d.program.command("default", { isDefault: !0 }).action(async () => {
|
|
1927
|
-
if (d.program.getOptionValue("help") && (console.log(
|
|
1928
|
-
const m = await import("fs"), w = d.program.getOptionValue("config") || "./myop.config.json", I = d.program.version(), u =
|
|
1912
|
+
if (d.program.getOptionValue("help") && (console.log(Ze), process.exit()), d.program.getOptionValue("ci")) {
|
|
1913
|
+
const m = await import("fs"), w = d.program.getOptionValue("config") || "./myop.config.json", I = d.program.version(), u = we();
|
|
1929
1914
|
let y = { found: !1 };
|
|
1930
1915
|
try {
|
|
1931
1916
|
if (m.existsSync(w)) {
|
|
@@ -1941,7 +1926,7 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
1941
1926
|
} catch (j) {
|
|
1942
1927
|
y = { found: !1, error: j.message };
|
|
1943
1928
|
}
|
|
1944
|
-
const
|
|
1929
|
+
const b = {
|
|
1945
1930
|
version: I,
|
|
1946
1931
|
config: y,
|
|
1947
1932
|
auth: {
|
|
@@ -1949,16 +1934,16 @@ d.program.command("default", { isDefault: !0 }).action(async () => {
|
|
|
1949
1934
|
email: (u == null ? void 0 : u.email) || null
|
|
1950
1935
|
}
|
|
1951
1936
|
};
|
|
1952
|
-
console.log(JSON.stringify(
|
|
1937
|
+
console.log(JSON.stringify(b, null, 2)), process.exit(0);
|
|
1953
1938
|
}
|
|
1954
|
-
let
|
|
1939
|
+
let s = F({
|
|
1955
1940
|
text: "Loading Myop CLI...",
|
|
1956
1941
|
color: "green"
|
|
1957
1942
|
}).start();
|
|
1958
|
-
const
|
|
1959
|
-
await
|
|
1943
|
+
const r = le();
|
|
1944
|
+
await Ct(500), s.stop();
|
|
1960
1945
|
const f = d.program.version();
|
|
1961
|
-
await
|
|
1946
|
+
await xt(f) || await B(r.configFound);
|
|
1962
1947
|
});
|
|
1963
1948
|
d.program.parse(process.argv);
|
|
1964
1949
|
d.program.opts();
|