everything-dev 0.3.2 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/cli.js +10 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/api-contract.cjs +172 -0
- package/dist/api-contract.cjs.map +1 -0
- package/dist/api-contract.mjs +171 -0
- package/dist/api-contract.mjs.map +1 -0
- package/dist/api.cjs +124 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +36 -0
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +36 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +119 -0
- package/dist/api.mjs.map +1 -0
- package/dist/app.cjs +156 -0
- package/dist/app.cjs.map +1 -0
- package/dist/app.mjs +153 -0
- package/dist/app.mjs.map +1 -0
- package/dist/cli/catalog.cjs +30 -0
- package/dist/cli/catalog.cjs.map +1 -0
- package/dist/cli/catalog.mjs +29 -0
- package/dist/cli/catalog.mjs.map +1 -0
- package/dist/cli/help.cjs +16 -0
- package/dist/cli/help.cjs.map +1 -0
- package/dist/cli/help.mjs +16 -0
- package/dist/cli/help.mjs.map +1 -0
- package/dist/cli/init.cjs +317 -0
- package/dist/cli/init.cjs.map +1 -0
- package/dist/cli/init.d.cts +36 -0
- package/dist/cli/init.d.cts.map +1 -0
- package/dist/cli/init.d.mts +36 -0
- package/dist/cli/init.d.mts.map +1 -0
- package/dist/cli/init.mjs +309 -0
- package/dist/cli/init.mjs.map +1 -0
- package/dist/cli/parse.cjs +96 -0
- package/dist/cli/parse.cjs.map +1 -0
- package/dist/cli/parse.mjs +95 -0
- package/dist/cli/parse.mjs.map +1 -0
- package/dist/cli/prompts.cjs +42 -0
- package/dist/cli/prompts.cjs.map +1 -0
- package/dist/cli/prompts.mjs +41 -0
- package/dist/cli/prompts.mjs.map +1 -0
- package/dist/cli.cjs +167 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +166 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/components/dev-view.cjs +307 -0
- package/dist/components/dev-view.cjs.map +1 -0
- package/dist/components/dev-view.mjs +306 -0
- package/dist/components/dev-view.mjs.map +1 -0
- package/dist/components/streaming-view.cjs +146 -0
- package/dist/components/streaming-view.cjs.map +1 -0
- package/dist/components/streaming-view.mjs +144 -0
- package/dist/components/streaming-view.mjs.map +1 -0
- package/dist/config.cjs +280 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +35 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +35 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +266 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract.cjs +209 -0
- package/dist/contract.cjs.map +1 -0
- package/dist/contract.d.cts +490 -0
- package/dist/contract.d.cts.map +1 -0
- package/dist/contract.d.mts +490 -0
- package/dist/contract.d.mts.map +1 -0
- package/dist/contract.meta.cjs +104 -0
- package/dist/contract.meta.cjs.map +1 -0
- package/dist/contract.meta.d.cts +141 -0
- package/dist/contract.meta.d.cts.map +1 -0
- package/dist/contract.meta.d.mts +141 -0
- package/dist/contract.meta.d.mts.map +1 -0
- package/dist/contract.meta.mjs +102 -0
- package/dist/contract.meta.mjs.map +1 -0
- package/dist/contract.mjs +186 -0
- package/dist/contract.mjs.map +1 -0
- package/dist/dev-logs.cjs +53 -0
- package/dist/dev-logs.cjs.map +1 -0
- package/dist/dev-logs.mjs +51 -0
- package/dist/dev-logs.mjs.map +1 -0
- package/dist/dev-session.cjs +195 -0
- package/dist/dev-session.cjs.map +1 -0
- package/dist/dev-session.mjs +194 -0
- package/dist/dev-session.mjs.map +1 -0
- package/dist/fastkv.cjs +89 -0
- package/dist/fastkv.cjs.map +1 -0
- package/dist/fastkv.d.cts +11 -0
- package/dist/fastkv.d.cts.map +1 -0
- package/dist/fastkv.d.mts +11 -0
- package/dist/fastkv.d.mts.map +1 -0
- package/dist/fastkv.mjs +82 -0
- package/dist/fastkv.mjs.map +1 -0
- package/dist/federation.server.cjs +27 -0
- package/dist/federation.server.cjs.map +1 -0
- package/dist/federation.server.mjs +27 -0
- package/dist/federation.server.mjs.map +1 -0
- package/dist/host.cjs +367 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +22 -0
- package/dist/host.d.cts.map +1 -0
- package/dist/host.d.mts +22 -0
- package/dist/host.d.mts.map +1 -0
- package/dist/host.mjs +364 -0
- package/dist/host.mjs.map +1 -0
- package/dist/index.cjs +122 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +9 -0
- package/dist/integrity.cjs +39 -0
- package/dist/integrity.cjs.map +1 -0
- package/dist/integrity.d.cts +7 -0
- package/dist/integrity.d.cts.map +1 -0
- package/dist/integrity.d.mts +7 -0
- package/dist/integrity.d.mts.map +1 -0
- package/dist/integrity.mjs +35 -0
- package/dist/integrity.mjs.map +1 -0
- package/dist/mf.cjs +77 -0
- package/dist/mf.cjs.map +1 -0
- package/dist/mf.d.cts +19 -0
- package/dist/mf.d.cts.map +1 -0
- package/dist/mf.d.mts +19 -0
- package/dist/mf.d.mts.map +1 -0
- package/dist/mf.mjs +71 -0
- package/dist/mf.mjs.map +1 -0
- package/dist/near-cli.cjs +196 -0
- package/dist/near-cli.cjs.map +1 -0
- package/dist/near-cli.mjs +193 -0
- package/dist/near-cli.mjs.map +1 -0
- package/dist/network.cjs +9 -0
- package/dist/network.cjs.map +1 -0
- package/dist/network.mjs +8 -0
- package/dist/network.mjs.map +1 -0
- package/dist/orchestrator.cjs +441 -0
- package/dist/orchestrator.cjs.map +1 -0
- package/dist/orchestrator.d.cts +40 -0
- package/dist/orchestrator.d.cts.map +1 -0
- package/dist/orchestrator.d.mts +40 -0
- package/dist/orchestrator.d.mts.map +1 -0
- package/dist/orchestrator.mjs +436 -0
- package/dist/orchestrator.mjs.map +1 -0
- package/dist/plugin.cjs +825 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +347 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +348 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +822 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/process-registry.cjs +120 -0
- package/dist/process-registry.cjs.map +1 -0
- package/dist/process-registry.d.cts +25 -0
- package/dist/process-registry.d.cts.map +1 -0
- package/dist/process-registry.d.mts +25 -0
- package/dist/process-registry.d.mts.map +1 -0
- package/dist/process-registry.mjs +119 -0
- package/dist/process-registry.mjs.map +1 -0
- package/dist/sdk.cjs +61 -0
- package/dist/sdk.d.cts +5 -0
- package/dist/sdk.d.mts +5 -0
- package/dist/sdk.mjs +6 -0
- package/dist/shared.cjs +143 -0
- package/dist/shared.cjs.map +1 -0
- package/dist/shared.d.cts +33 -0
- package/dist/shared.d.cts.map +1 -0
- package/dist/shared.d.mts +33 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +140 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/types.cjs +160 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +269 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +269 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +144 -0
- package/dist/types.mjs.map +1 -0
- package/dist/ui/head.cjs +67 -0
- package/dist/ui/head.cjs.map +1 -0
- package/dist/ui/head.d.cts +19 -0
- package/dist/ui/head.d.cts.map +1 -0
- package/dist/ui/head.d.mts +19 -0
- package/dist/ui/head.d.mts.map +1 -0
- package/dist/ui/head.mjs +61 -0
- package/dist/ui/head.mjs.map +1 -0
- package/dist/ui/index.cjs +32 -0
- package/dist/ui/index.d.cts +7 -0
- package/dist/ui/index.d.mts +7 -0
- package/dist/ui/index.mjs +6 -0
- package/dist/ui/metadata.cjs +106 -0
- package/dist/ui/metadata.cjs.map +1 -0
- package/dist/ui/metadata.d.cts +35 -0
- package/dist/ui/metadata.d.cts.map +1 -0
- package/dist/ui/metadata.d.mts +35 -0
- package/dist/ui/metadata.d.mts.map +1 -0
- package/dist/ui/metadata.mjs +100 -0
- package/dist/ui/metadata.mjs.map +1 -0
- package/dist/ui/router.cjs +56 -0
- package/dist/ui/router.cjs.map +1 -0
- package/dist/ui/router.d.cts +11 -0
- package/dist/ui/router.d.cts.map +1 -0
- package/dist/ui/router.d.mts +11 -0
- package/dist/ui/router.d.mts.map +1 -0
- package/dist/ui/router.mjs +51 -0
- package/dist/ui/router.mjs.map +1 -0
- package/dist/ui/runtime.cjs +65 -0
- package/dist/ui/runtime.cjs.map +1 -0
- package/dist/ui/runtime.d.cts +29 -0
- package/dist/ui/runtime.d.cts.map +1 -0
- package/dist/ui/runtime.d.mts +29 -0
- package/dist/ui/runtime.d.mts.map +1 -0
- package/dist/ui/runtime.mjs +53 -0
- package/dist/ui/runtime.mjs.map +1 -0
- package/dist/ui/types.cjs +0 -0
- package/dist/ui/types.d.cts +52 -0
- package/dist/ui/types.d.cts.map +1 -0
- package/dist/ui/types.d.mts +52 -0
- package/dist/ui/types.d.mts.map +1 -0
- package/dist/ui/types.mjs +1 -0
- package/dist/utils/banner.cjs +24 -0
- package/dist/utils/banner.cjs.map +1 -0
- package/dist/utils/banner.mjs +23 -0
- package/dist/utils/banner.mjs.map +1 -0
- package/dist/utils/linkify.cjs +15 -0
- package/dist/utils/linkify.cjs.map +1 -0
- package/dist/utils/linkify.mjs +14 -0
- package/dist/utils/linkify.mjs.map +1 -0
- package/dist/utils/run.cjs +40 -0
- package/dist/utils/run.cjs.map +1 -0
- package/dist/utils/run.mjs +39 -0
- package/dist/utils/run.mjs.map +1 -0
- package/dist/utils/theme.cjs +44 -0
- package/dist/utils/theme.cjs.map +1 -0
- package/dist/utils/theme.mjs +37 -0
- package/dist/utils/theme.mjs.map +1 -0
- package/package.json +269 -80
- package/src/api-contract.ts +309 -0
- package/src/api.ts +181 -0
- package/src/app.ts +346 -0
- package/src/cli/catalog.ts +49 -0
- package/src/cli/help.ts +13 -0
- package/src/cli/init.ts +415 -0
- package/src/cli/parse.ts +130 -0
- package/src/cli/prompts.ts +64 -0
- package/src/cli.ts +203 -1507
- package/src/components/dev-view.tsx +104 -41
- package/src/components/streaming-view.ts +89 -22
- package/src/config.ts +462 -532
- package/src/contract.meta.ts +96 -0
- package/src/contract.ts +164 -561
- package/src/dev-logs.ts +85 -0
- package/src/dev-session.ts +318 -0
- package/src/fastkv.ts +153 -0
- package/src/federation.server.ts +43 -0
- package/src/host.ts +526 -0
- package/src/index.ts +6 -3
- package/src/integrity.ts +54 -0
- package/src/mf.ts +105 -0
- package/src/near-cli.ts +284 -0
- package/src/network.ts +3 -0
- package/src/orchestrator.ts +648 -0
- package/src/plugin.ts +1116 -2303
- package/src/process-registry.ts +154 -0
- package/src/scripts/sync-api-contract.ts +24 -0
- package/src/sdk.ts +14 -0
- package/src/shared.ts +206 -0
- package/src/types.ts +152 -206
- package/src/ui/head.ts +34 -27
- package/src/ui/index.ts +3 -3
- package/src/ui/metadata.ts +95 -0
- package/src/ui/router.ts +22 -6
- package/src/ui/runtime.ts +55 -6
- package/src/ui/types.ts +24 -11
- package/src/utils/banner.ts +10 -6
- package/src/utils/run.ts +26 -27
- package/src/utils/theme.ts +3 -66
- package/src/components/monitor-view.tsx +0 -475
- package/src/components/status-view.tsx +0 -173
- package/src/lib/env.ts +0 -109
- package/src/lib/near-cli.ts +0 -289
- package/src/lib/nova.ts +0 -266
- package/src/lib/orchestrator.ts +0 -276
- package/src/lib/process-registry.ts +0 -166
- package/src/lib/process.ts +0 -549
- package/src/lib/resource-monitor/assertions.ts +0 -234
- package/src/lib/resource-monitor/command.ts +0 -283
- package/src/lib/resource-monitor/diff.ts +0 -157
- package/src/lib/resource-monitor/errors.ts +0 -127
- package/src/lib/resource-monitor/index.ts +0 -305
- package/src/lib/resource-monitor/platform/darwin.ts +0 -306
- package/src/lib/resource-monitor/platform/index.ts +0 -35
- package/src/lib/resource-monitor/platform/linux.ts +0 -332
- package/src/lib/resource-monitor/platform/windows.ts +0 -298
- package/src/lib/resource-monitor/snapshot.ts +0 -217
- package/src/lib/resource-monitor/types.ts +0 -74
- package/src/lib/session-recorder/errors.ts +0 -102
- package/src/lib/session-recorder/flows/login.ts +0 -210
- package/src/lib/session-recorder/index.ts +0 -361
- package/src/lib/session-recorder/playwright.ts +0 -257
- package/src/lib/session-recorder/report.ts +0 -353
- package/src/lib/session-recorder/server.ts +0 -267
- package/src/lib/session-recorder/types.ts +0 -115
- package/src/lib/sync.ts +0 -1
- package/src/ui/files.ts +0 -134
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { fetchBosConfigFromFastKv } from "../fastkv.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { createWriteStream, existsSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { pipeline } from "node:stream/promises";
|
|
8
|
+
import { glob } from "glob";
|
|
9
|
+
|
|
10
|
+
//#region src/cli/init.ts
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
async function resolveSourceDir(opts) {
|
|
13
|
+
if (opts.source) {
|
|
14
|
+
const sourceDir = resolve(opts.source);
|
|
15
|
+
if (!existsSync(join(sourceDir, "bos.config.json"))) throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);
|
|
16
|
+
return {
|
|
17
|
+
sourceDir,
|
|
18
|
+
parentConfig: JSON.parse(readFileSync(join(sourceDir, "bos.config.json"), "utf-8")),
|
|
19
|
+
cleanup: async () => {}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const parentConfig = await fetchParentConfig(opts.account, opts.gateway);
|
|
23
|
+
if (!parentConfig.repository) throw new Error("Parent config has no repository field — cannot locate template source");
|
|
24
|
+
const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);
|
|
25
|
+
return {
|
|
26
|
+
sourceDir,
|
|
27
|
+
parentConfig,
|
|
28
|
+
cleanup
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function fetchParentConfig(account, gateway) {
|
|
32
|
+
return fetchBosConfigFromFastKv(`bos://${account}/${gateway}`);
|
|
33
|
+
}
|
|
34
|
+
async function downloadTarball(repoUrl) {
|
|
35
|
+
const parsed = parseGitHubUrl(repoUrl);
|
|
36
|
+
if (!parsed) throw new Error(`Cannot parse repository URL: ${repoUrl}`);
|
|
37
|
+
const { owner, repo, branch } = parsed;
|
|
38
|
+
const tarballUrl = `https://api.github.com/repos/${owner}/${repo}/tarball/${branch}`;
|
|
39
|
+
const tmpDir = mkTmpDir("bos-init-tarball-");
|
|
40
|
+
const tarballPath = join(tmpDir, "source.tar.gz");
|
|
41
|
+
const response = await fetch(tarballUrl, {
|
|
42
|
+
headers: { "User-Agent": "everything-dev" },
|
|
43
|
+
redirect: "follow"
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
rmSync(tmpDir, {
|
|
47
|
+
recursive: true,
|
|
48
|
+
force: true
|
|
49
|
+
});
|
|
50
|
+
throw new Error(`GitHub tarball download failed: ${response.status} ${response.statusText}`);
|
|
51
|
+
}
|
|
52
|
+
if (!response.body) {
|
|
53
|
+
rmSync(tmpDir, {
|
|
54
|
+
recursive: true,
|
|
55
|
+
force: true
|
|
56
|
+
});
|
|
57
|
+
throw new Error("GitHub tarball download returned empty body");
|
|
58
|
+
}
|
|
59
|
+
const fileStream = createWriteStream(tarballPath);
|
|
60
|
+
const reader = response.body;
|
|
61
|
+
await pipeline(reader, fileStream);
|
|
62
|
+
const extractDir = mkTmpDir("bos-init-extract-");
|
|
63
|
+
try {
|
|
64
|
+
await require("tar").extract({
|
|
65
|
+
cwd: extractDir,
|
|
66
|
+
file: tarballPath,
|
|
67
|
+
strip: 1
|
|
68
|
+
});
|
|
69
|
+
} catch {
|
|
70
|
+
await execCommand("tar", [
|
|
71
|
+
"-xzf",
|
|
72
|
+
tarballPath,
|
|
73
|
+
"--strip-components=1",
|
|
74
|
+
"-C",
|
|
75
|
+
extractDir
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
rmSync(tmpDir, {
|
|
79
|
+
recursive: true,
|
|
80
|
+
force: true
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
dir: extractDir,
|
|
84
|
+
cleanup: async () => {
|
|
85
|
+
rmSync(extractDir, {
|
|
86
|
+
recursive: true,
|
|
87
|
+
force: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function parseGitHubUrl(url) {
|
|
93
|
+
const httpsMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/.*)?$/);
|
|
94
|
+
if (httpsMatch) return {
|
|
95
|
+
owner: httpsMatch[1],
|
|
96
|
+
repo: httpsMatch[2],
|
|
97
|
+
branch: "main"
|
|
98
|
+
};
|
|
99
|
+
const sshMatch = url.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
100
|
+
if (sshMatch) return {
|
|
101
|
+
owner: sshMatch[1],
|
|
102
|
+
repo: sshMatch[2],
|
|
103
|
+
branch: "main"
|
|
104
|
+
};
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
async function readTemplatekeep(sourceDir) {
|
|
108
|
+
const keepFile = join(sourceDir, ".templatekeep");
|
|
109
|
+
if (!existsSync(keepFile)) return [];
|
|
110
|
+
return readFileSync(keepFile, "utf-8").split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
111
|
+
}
|
|
112
|
+
async function copyFilteredFiles(sourceDir, destination, patterns, options) {
|
|
113
|
+
if (patterns.length === 0) return 0;
|
|
114
|
+
const effectivePatterns = options.withHost ? [...patterns, "host/**"] : patterns.filter((p) => !p.startsWith("host/") && p !== "host/**");
|
|
115
|
+
const allFiles = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const pattern of effectivePatterns) {
|
|
117
|
+
const matches = await glob(pattern, {
|
|
118
|
+
cwd: sourceDir,
|
|
119
|
+
nodir: true,
|
|
120
|
+
dot: true,
|
|
121
|
+
absolute: false
|
|
122
|
+
});
|
|
123
|
+
for (const match of matches) allFiles.add(match);
|
|
124
|
+
}
|
|
125
|
+
mkdirSync(destination, { recursive: true });
|
|
126
|
+
let count = 0;
|
|
127
|
+
for (const filePath of allFiles) {
|
|
128
|
+
const src = join(sourceDir, filePath);
|
|
129
|
+
if (!lstatSync(src).isFile()) continue;
|
|
130
|
+
const dest = join(destination, filePath);
|
|
131
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
132
|
+
writeFileSync(dest, readFileSync(src));
|
|
133
|
+
count++;
|
|
134
|
+
}
|
|
135
|
+
return count;
|
|
136
|
+
}
|
|
137
|
+
async function personalizeConfig(destination, opts) {
|
|
138
|
+
const configPath = join(destination, "bos.config.json");
|
|
139
|
+
if (existsSync(configPath)) {
|
|
140
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
141
|
+
config.extends = `bos://${opts.parentAccount}/${opts.parentGateway}`;
|
|
142
|
+
if (opts.name) config.account = opts.name;
|
|
143
|
+
if (opts.domain) config.domain = opts.domain;
|
|
144
|
+
if (config.app && typeof config.app === "object") {
|
|
145
|
+
const app = config.app;
|
|
146
|
+
for (const entryKey of Object.keys(app)) {
|
|
147
|
+
const entry = app[entryKey];
|
|
148
|
+
if (entry && typeof entry === "object") {
|
|
149
|
+
const e = entry;
|
|
150
|
+
delete e.production;
|
|
151
|
+
delete e.productionIntegrity;
|
|
152
|
+
delete e.ssr;
|
|
153
|
+
delete e.ssrIntegrity;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (config.plugins && typeof config.plugins === "object") {
|
|
158
|
+
const plugins = config.plugins;
|
|
159
|
+
for (const pluginKey of Object.keys(plugins)) {
|
|
160
|
+
const plugin = plugins[pluginKey];
|
|
161
|
+
if (plugin && typeof plugin === "object") {
|
|
162
|
+
const p = plugin;
|
|
163
|
+
delete p.production;
|
|
164
|
+
delete p.productionIntegrity;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
169
|
+
}
|
|
170
|
+
const pkgPath = join(destination, "package.json");
|
|
171
|
+
if (existsSync(pkgPath)) {
|
|
172
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
173
|
+
if (pkg.workspaces && typeof pkg.workspaces === "object") {
|
|
174
|
+
const ws = pkg.workspaces;
|
|
175
|
+
if (Array.isArray(ws.packages)) ws.packages = ws.packages.filter((p) => p !== "host" && !p.startsWith("packages/"));
|
|
176
|
+
}
|
|
177
|
+
if (pkg.scripts && typeof pkg.scripts === "object") {
|
|
178
|
+
const scripts = pkg.scripts;
|
|
179
|
+
const rewrite = (key, from, to) => {
|
|
180
|
+
if (scripts[key]?.includes(from)) scripts[key] = scripts[key].replaceAll(from, to);
|
|
181
|
+
};
|
|
182
|
+
rewrite("dev", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
183
|
+
rewrite("dev:ui", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
184
|
+
rewrite("dev:api", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
185
|
+
rewrite("dev:proxy", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
186
|
+
rewrite("build", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
187
|
+
rewrite("deploy", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
188
|
+
rewrite("publish", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
189
|
+
rewrite("start", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
|
|
190
|
+
if (scripts["sync:api-contract"]) delete scripts["sync:api-contract"];
|
|
191
|
+
if (scripts.postinstall) delete scripts.postinstall;
|
|
192
|
+
if (scripts.typecheck?.includes("sync:api-contract")) scripts.typecheck = scripts.typecheck.replace("bun run sync:api-contract && ", "");
|
|
193
|
+
}
|
|
194
|
+
if (pkg.devDependencies && typeof pkg.devDependencies === "object") {
|
|
195
|
+
const deps = pkg.devDependencies;
|
|
196
|
+
delete deps["every-plugin"];
|
|
197
|
+
delete deps["everything-dev"];
|
|
198
|
+
}
|
|
199
|
+
if (!pkg.dependencies) pkg.dependencies = {};
|
|
200
|
+
const deps = pkg.dependencies;
|
|
201
|
+
if (!deps["everything-dev"]) deps["everything-dev"] = "^1.1.0";
|
|
202
|
+
if (!deps["every-plugin"]) deps["every-plugin"] = "^2.0.0";
|
|
203
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
204
|
+
}
|
|
205
|
+
await resolveWorkspaceRefs(destination, opts.workspaceOpts);
|
|
206
|
+
}
|
|
207
|
+
async function runBunInstall(destination) {
|
|
208
|
+
await execCommand("bun", ["install"], destination);
|
|
209
|
+
}
|
|
210
|
+
const WORKSPACE_VERSION_MAP = {
|
|
211
|
+
"everything-dev": "^1.1.0",
|
|
212
|
+
"every-plugin": "^2.0.0"
|
|
213
|
+
};
|
|
214
|
+
const WORKSPACE_LOCAL_PATHS = {
|
|
215
|
+
"everything-dev": "packages/everything-dev",
|
|
216
|
+
"every-plugin": "packages/every-plugin"
|
|
217
|
+
};
|
|
218
|
+
async function resolveWorkspaceRefs(destination, options) {
|
|
219
|
+
const files = await glob("**/package.json", {
|
|
220
|
+
cwd: destination,
|
|
221
|
+
nodir: true,
|
|
222
|
+
dot: false,
|
|
223
|
+
absolute: false,
|
|
224
|
+
ignore: ["**/node_modules/**"]
|
|
225
|
+
});
|
|
226
|
+
for (const file of files) {
|
|
227
|
+
const filePath = join(destination, file);
|
|
228
|
+
const content = readFileSync(filePath, "utf-8");
|
|
229
|
+
if (!content.includes("workspace:")) continue;
|
|
230
|
+
const pkg = JSON.parse(content);
|
|
231
|
+
let modified = false;
|
|
232
|
+
for (const depField of [
|
|
233
|
+
"dependencies",
|
|
234
|
+
"devDependencies",
|
|
235
|
+
"peerDependencies"
|
|
236
|
+
]) {
|
|
237
|
+
const deps = pkg[depField];
|
|
238
|
+
if (!deps || typeof deps !== "object") continue;
|
|
239
|
+
const map = deps;
|
|
240
|
+
for (const [name, version] of Object.entries(map)) if (version === "workspace:*") {
|
|
241
|
+
const resolved = WORKSPACE_VERSION_MAP[name];
|
|
242
|
+
if (resolved) {
|
|
243
|
+
map[name] = resolved;
|
|
244
|
+
modified = true;
|
|
245
|
+
} else if (name === "host") {
|
|
246
|
+
delete map[name];
|
|
247
|
+
modified = true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (modified) writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
252
|
+
}
|
|
253
|
+
if (options?.localOverrides && options.sourceDir) {
|
|
254
|
+
const rootPkgPath = join(destination, "package.json");
|
|
255
|
+
if (existsSync(rootPkgPath)) {
|
|
256
|
+
const pkg = JSON.parse(readFileSync(rootPkgPath, "utf-8"));
|
|
257
|
+
if (!pkg.overrides) pkg.overrides = {};
|
|
258
|
+
const overrides = pkg.overrides;
|
|
259
|
+
const rootWorkspaces = (pkg.workspaces?.packages ?? []).filter(Boolean);
|
|
260
|
+
for (const [name, relPath] of Object.entries(WORKSPACE_LOCAL_PATHS)) if (!rootWorkspaces.some((ws) => ws === relPath || ws === `plugins/${name}`)) {
|
|
261
|
+
if (existsSync(join(options.sourceDir, relPath, "package.json"))) {
|
|
262
|
+
overrides[name] = `file:${relPath}`;
|
|
263
|
+
rootWorkspaces.push(relPath);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (rootWorkspaces.length > 0) {
|
|
267
|
+
if (!pkg.workspaces) pkg.workspaces = {};
|
|
268
|
+
pkg.workspaces.packages = rootWorkspaces;
|
|
269
|
+
}
|
|
270
|
+
writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function mkTmpDir(prefix) {
|
|
275
|
+
const base = join(tmpdir(), prefix);
|
|
276
|
+
let attempt = 0;
|
|
277
|
+
while (true) {
|
|
278
|
+
const dir = `${base}-${Date.now()}-${attempt}`;
|
|
279
|
+
try {
|
|
280
|
+
mkdirSync(dir, { recursive: true });
|
|
281
|
+
return dir;
|
|
282
|
+
} catch {
|
|
283
|
+
attempt++;
|
|
284
|
+
if (attempt > 10) throw new Error("Failed to create temp directory");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function execCommand(command, args, cwd) {
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
const child = spawn(command, args, {
|
|
291
|
+
cwd,
|
|
292
|
+
stdio: "pipe",
|
|
293
|
+
shell: true
|
|
294
|
+
});
|
|
295
|
+
let stderr = "";
|
|
296
|
+
child.stderr?.on("data", (data) => {
|
|
297
|
+
stderr += data.toString();
|
|
298
|
+
});
|
|
299
|
+
child.on("close", (code) => {
|
|
300
|
+
if (code === 0) resolve();
|
|
301
|
+
else reject(/* @__PURE__ */ new Error(`Command '${command} ${args.join(" ")}' failed with exit code ${code}: ${stderr}`));
|
|
302
|
+
});
|
|
303
|
+
child.on("error", reject);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
//#endregion
|
|
308
|
+
export { copyFilteredFiles, downloadTarball, fetchParentConfig, personalizeConfig, readTemplatekeep, resolveSourceDir, runBunInstall };
|
|
309
|
+
//# sourceMappingURL=init.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.mjs","names":[],"sources":["../../src/cli/init.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport {\n createWriteStream,\n existsSync,\n lstatSync,\n mkdirSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { glob } from \"glob\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport type { BosConfig } from \"../types\";\n\nconst require = createRequire(import.meta.url);\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n account: string;\n gateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.account, opts.gateway);\n\n if (!parentConfig.repository) {\n throw new Error(\"Parent config has no repository field — cannot locate template source\");\n }\n\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n}\n\nexport async function fetchParentConfig(account: string, gateway: string): Promise<BosConfig> {\n const bosUrl = `bos://${account}/${gateway}`;\n return fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n}\n\nexport async function downloadTarball(\n repoUrl: string,\n): Promise<{ dir: string; cleanup: () => Promise<void> }> {\n const parsed = parseGitHubUrl(repoUrl);\n if (!parsed) {\n throw new Error(`Cannot parse repository URL: ${repoUrl}`);\n }\n\n const { owner, repo, branch } = parsed;\n const tarballUrl = `https://api.github.com/repos/${owner}/${repo}/tarball/${branch}`;\n\n const tmpDir = mkTmpDir(\"bos-init-tarball-\");\n const tarballPath = join(tmpDir, \"source.tar.gz\");\n\n const response = await fetch(tarballUrl, {\n headers: { \"User-Agent\": \"everything-dev\" },\n redirect: \"follow\",\n });\n\n if (!response.ok) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(`GitHub tarball download failed: ${response.status} ${response.statusText}`);\n }\n\n if (!response.body) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(\"GitHub tarball download returned empty body\");\n }\n\n const fileStream = createWriteStream(tarballPath);\n const reader = response.body as unknown as NodeJS.ReadableStream;\n await pipeline(reader, fileStream);\n\n const extractDir = mkTmpDir(\"bos-init-extract-\");\n try {\n const tar = require(\"tar\") as {\n extract: (opts: { cwd: string; file: string; strip: number }) => Promise<void>;\n };\n await tar.extract({ cwd: extractDir, file: tarballPath, strip: 1 });\n } catch {\n await execCommand(\"tar\", [\"-xzf\", tarballPath, \"--strip-components=1\", \"-C\", extractDir]);\n }\n\n rmSync(tmpDir, { recursive: true, force: true });\n\n return {\n dir: extractDir,\n cleanup: async () => {\n rmSync(extractDir, { recursive: true, force: true });\n },\n };\n}\n\nfunction parseGitHubUrl(url: string): { owner: string; repo: string; branch: string } | null {\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return { owner: httpsMatch[1], repo: httpsMatch[2], branch: \"main\" };\n }\n\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return { owner: sshMatch[1], repo: sshMatch[2], branch: \"main\" };\n }\n\n return null;\n}\n\nexport async function readTemplatekeep(sourceDir: string): Promise<string[]> {\n const keepFile = join(sourceDir, \".templatekeep\");\n if (!existsSync(keepFile)) {\n return [];\n }\n\n const content = readFileSync(keepFile, \"utf-8\");\n return content\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0 && !line.startsWith(\"#\"));\n}\n\nexport async function copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n options: { withHost: boolean },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const effectivePatterns = options.withHost\n ? [...patterns, \"host/**\"]\n : patterns.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n\n const allFiles = new Set<string>();\n for (const pattern of effectivePatterns) {\n const matches = await glob(pattern, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n });\n for (const match of matches) {\n allFiles.add(match);\n }\n }\n\n mkdirSync(destination, { recursive: true });\n\n let count = 0;\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n\n const dest = join(destination, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n const content = readFileSync(src);\n writeFileSync(dest, content);\n count++;\n }\n\n return count;\n}\n\nexport async function personalizeConfig(\n destination: string,\n opts: {\n parentAccount: string;\n parentGateway: string;\n name?: string;\n domain?: string;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n },\n): Promise<void> {\n const configPath = join(destination, \"bos.config.json\");\n if (existsSync(configPath)) {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n config.extends = `bos://${opts.parentAccount}/${opts.parentGateway}`;\n\n if (opts.name) {\n config.account = opts.name;\n }\n if (opts.domain) {\n config.domain = opts.domain;\n }\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n for (const entryKey of Object.keys(app)) {\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n const e = entry as Record<string, unknown>;\n delete e.production;\n delete e.productionIntegrity;\n delete e.ssr;\n delete e.ssrIntegrity;\n }\n }\n }\n\n if (config.plugins && typeof config.plugins === \"object\") {\n const plugins = config.plugins as Record<string, unknown>;\n for (const pluginKey of Object.keys(plugins)) {\n const plugin = plugins[pluginKey];\n if (plugin && typeof plugin === \"object\") {\n const p = plugin as Record<string, unknown>;\n delete p.production;\n delete p.productionIntegrity;\n }\n }\n }\n\n writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\\n`);\n }\n\n const pkgPath = join(destination, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n\n if (pkg.workspaces && typeof pkg.workspaces === \"object\") {\n const ws = pkg.workspaces as { packages?: string[] };\n if (Array.isArray(ws.packages)) {\n ws.packages = ws.packages.filter((p: string) => p !== \"host\" && !p.startsWith(\"packages/\"));\n }\n }\n\n if (pkg.scripts && typeof pkg.scripts === \"object\") {\n const scripts = pkg.scripts as Record<string, string>;\n const rewrite = (key: string, from: string, to: string) => {\n if (scripts[key]?.includes(from)) {\n scripts[key] = scripts[key].replaceAll(from, to);\n }\n };\n rewrite(\"dev\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"dev:ui\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"dev:api\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"dev:proxy\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"build\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"deploy\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"publish\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"start\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n\n if (scripts[\"sync:api-contract\"]) {\n delete scripts[\"sync:api-contract\"];\n }\n if (scripts.postinstall) {\n delete scripts.postinstall;\n }\n if (scripts.typecheck?.includes(\"sync:api-contract\")) {\n scripts.typecheck = scripts.typecheck.replace(\"bun run sync:api-contract && \", \"\");\n }\n }\n\n if (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n const deps = pkg.devDependencies as Record<string, string>;\n delete deps[\"every-plugin\"];\n delete deps[\"everything-dev\"];\n }\n\n if (!pkg.dependencies) pkg.dependencies = {};\n const deps = pkg.dependencies as Record<string, string>;\n if (!deps[\"everything-dev\"]) deps[\"everything-dev\"] = \"^1.1.0\";\n if (!deps[\"every-plugin\"]) deps[\"every-plugin\"] = \"^2.0.0\";\n\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n await resolveWorkspaceRefs(destination, opts.workspaceOpts);\n}\n\nexport async function runBunInstall(destination: string): Promise<void> {\n await execCommand(\"bun\", [\"install\"], destination);\n}\n\nconst WORKSPACE_VERSION_MAP: Record<string, string> = {\n \"everything-dev\": \"^1.1.0\",\n \"every-plugin\": \"^2.0.0\",\n};\n\nconst WORKSPACE_LOCAL_PATHS: Record<string, string> = {\n \"everything-dev\": \"packages/everything-dev\",\n \"every-plugin\": \"packages/every-plugin\",\n};\n\nasync function resolveWorkspaceRefs(\n destination: string,\n options?: { localOverrides?: boolean; sourceDir?: string },\n): Promise<void> {\n const files = await glob(\"**/package.json\", {\n cwd: destination,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"**/node_modules/**\"],\n });\n\n for (const file of files) {\n const filePath = join(destination, file);\n const content = readFileSync(filePath, \"utf-8\");\n if (!content.includes(\"workspace:\")) continue;\n\n const pkg = JSON.parse(content) as Record<string, unknown>;\n let modified = false;\n\n for (const depField of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const deps = pkg[depField];\n if (!deps || typeof deps !== \"object\") continue;\n const map = deps as Record<string, string>;\n for (const [name, version] of Object.entries(map)) {\n if (version === \"workspace:*\") {\n const resolved = WORKSPACE_VERSION_MAP[name];\n if (resolved) {\n map[name] = resolved;\n modified = true;\n } else if (name === \"host\") {\n delete map[name];\n modified = true;\n }\n }\n }\n }\n\n if (modified) {\n writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n }\n\n if (options?.localOverrides && options.sourceDir) {\n const rootPkgPath = join(destination, \"package.json\");\n if (existsSync(rootPkgPath)) {\n const pkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n if (!pkg.overrides) pkg.overrides = {};\n const overrides = pkg.overrides as Record<string, string>;\n\n const rootWorkspaces = ((pkg.workspaces as Record<string, string[]>)?.packages ?? []).filter(\n Boolean,\n );\n\n for (const [name, relPath] of Object.entries(WORKSPACE_LOCAL_PATHS)) {\n if (!rootWorkspaces.some((ws) => ws === relPath || ws === `plugins/${name}`)) {\n const srcPkgPath = join(options.sourceDir, relPath, \"package.json\");\n if (existsSync(srcPkgPath)) {\n overrides[name] = `file:${relPath}`;\n rootWorkspaces.push(relPath);\n }\n }\n }\n\n if (rootWorkspaces.length > 0) {\n if (!pkg.workspaces) pkg.workspaces = {};\n (pkg.workspaces as Record<string, string[]>).packages = rootWorkspaces;\n }\n\n writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n }\n}\n\nfunction mkTmpDir(prefix: string): string {\n const base = join(tmpdir(), prefix);\n let attempt = 0;\n while (true) {\n const dir = `${base}-${Date.now()}-${attempt}`;\n try {\n mkdirSync(dir, { recursive: true });\n return dir;\n } catch {\n attempt++;\n if (attempt > 10) throw new Error(\"Failed to create temp directory\");\n }\n }\n}\n\nfunction execCommand(command: string, args: string[], cwd?: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n stdio: \"pipe\",\n shell: true,\n });\n let stderr = \"\";\n child.stderr?.on(\"data\", (data: Buffer) => {\n stderr += data.toString();\n });\n child.on(\"close\", (code) => {\n if (code === 0) resolve();\n else\n reject(\n new Error(\n `Command '${command} ${args.join(\" \")}' failed with exit code ${code}: ${stderr}`,\n ),\n );\n });\n child.on(\"error\", reject);\n });\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAQ9C,eAAsB,iBAAiB,MAIb;AACxB,KAAI,KAAK,QAAQ;EACf,MAAM,YAAY,QAAQ,KAAK,OAAO;AACtC,MAAI,CAAC,WAAW,KAAK,WAAW,kBAAkB,CAAC,CACjD,OAAM,IAAI,MAAM,iDAAiD,YAAY;AAK/E,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K,KAAK,IAAI,CAAC,0BAA0B,KAAK,IAAI,SAC1E,CACF;IACH;AACF,QAAM,GAAG,SAAS,OAAO;GACzB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/cli/parse.ts
|
|
3
|
+
function unwrap(schema) {
|
|
4
|
+
let current = schema;
|
|
5
|
+
while (true) {
|
|
6
|
+
const type = current._def?.type;
|
|
7
|
+
if (type === "default" || type === "optional" || type === "nullable" || type === "nullish") {
|
|
8
|
+
const inner = current._def?.innerType;
|
|
9
|
+
if (!inner) break;
|
|
10
|
+
current = inner;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
return current;
|
|
14
|
+
}
|
|
15
|
+
return current;
|
|
16
|
+
}
|
|
17
|
+
function isBooleanSchema(schema) {
|
|
18
|
+
return unwrap(schema)._def?.type === "boolean";
|
|
19
|
+
}
|
|
20
|
+
function coerceValue(raw, schema) {
|
|
21
|
+
switch (unwrap(schema)._def?.type) {
|
|
22
|
+
case "boolean": return raw === "true" || raw === "1" || raw === "yes";
|
|
23
|
+
case "number": {
|
|
24
|
+
const value = Number(raw);
|
|
25
|
+
if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
case "enum": return raw;
|
|
29
|
+
default: return raw;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function toFlagName(field) {
|
|
33
|
+
return `--${field.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`;
|
|
34
|
+
}
|
|
35
|
+
function getShape(schema) {
|
|
36
|
+
const shape = unwrap(schema)._def?.shape;
|
|
37
|
+
if (!shape) return {};
|
|
38
|
+
return shape;
|
|
39
|
+
}
|
|
40
|
+
function parseCommandInput(descriptor, argv) {
|
|
41
|
+
const schema = descriptor.procedure["~orpc"]?.inputSchema;
|
|
42
|
+
if (!schema) return {};
|
|
43
|
+
const shape = getShape(schema);
|
|
44
|
+
const fields = Object.entries(shape);
|
|
45
|
+
const fieldByFlag = /* @__PURE__ */ new Map();
|
|
46
|
+
const positionalFields = [];
|
|
47
|
+
for (const [fieldName] of fields) {
|
|
48
|
+
fieldByFlag.set(toFlagName(fieldName), fieldName);
|
|
49
|
+
if (descriptor.meta.fields?.[fieldName]?.positional) positionalFields.push(fieldName);
|
|
50
|
+
}
|
|
51
|
+
const input = {};
|
|
52
|
+
const positionals = [];
|
|
53
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
54
|
+
const token = argv[i];
|
|
55
|
+
if (!token) continue;
|
|
56
|
+
if (token.startsWith("--no-")) {
|
|
57
|
+
const flagName = `--${token.slice(5)}`;
|
|
58
|
+
const fieldName = fieldByFlag.get(flagName);
|
|
59
|
+
if (!fieldName) throw new Error(`Unknown flag: ${token}`);
|
|
60
|
+
input[fieldName] = false;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (token.startsWith("--")) {
|
|
64
|
+
const [flag, inline] = token.split("=", 2);
|
|
65
|
+
const fieldName = fieldByFlag.get(flag);
|
|
66
|
+
if (!fieldName) throw new Error(`Unknown flag: ${token}`);
|
|
67
|
+
const fieldSchema = shape[fieldName];
|
|
68
|
+
if (isBooleanSchema(fieldSchema)) {
|
|
69
|
+
input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const next = inline ?? argv[i + 1];
|
|
73
|
+
if (next === void 0 || next.startsWith("--")) throw new Error(`Missing value for ${flag}`);
|
|
74
|
+
input[fieldName] = coerceValue(next, fieldSchema);
|
|
75
|
+
if (!inline) i += 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
positionals.push(token);
|
|
79
|
+
}
|
|
80
|
+
if (positionalFields.length > 0) positionalFields.forEach((fieldName, index) => {
|
|
81
|
+
const raw = positionals[index];
|
|
82
|
+
if (raw !== void 0) input[fieldName] = coerceValue(raw, shape[fieldName]);
|
|
83
|
+
});
|
|
84
|
+
else if (positionals.length > 0) {
|
|
85
|
+
const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));
|
|
86
|
+
if (candidate) {
|
|
87
|
+
const [fieldName, fieldSchema] = candidate;
|
|
88
|
+
input[fieldName] = coerceValue(positionals[0], fieldSchema);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return schema.parse(input);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
exports.parseCommandInput = parseCommandInput;
|
|
96
|
+
//# sourceMappingURL=parse.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.cjs","names":[],"sources":["../../src/cli/parse.ts"],"sourcesContent":["import type { CommandDescriptor } from \"./catalog\";\n\ntype SchemaLike = {\n _def?: {\n type?: string;\n innerType?: SchemaLike;\n shape?: Record<string, SchemaLike>;\n values?: Record<string, string> | string[];\n };\n parse: (value: unknown) => unknown;\n};\n\nfunction unwrap(schema: SchemaLike): SchemaLike {\n let current = schema;\n while (true) {\n const type = current._def?.type;\n if (type === \"default\" || type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n const inner = current._def?.innerType;\n if (!inner) break;\n current = inner;\n continue;\n }\n return current;\n }\n return current;\n}\n\nfunction isBooleanSchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"boolean\";\n}\n\nfunction coerceValue(raw: string, schema: SchemaLike): unknown {\n const inner = unwrap(schema);\n switch (inner._def?.type) {\n case \"boolean\":\n return raw === \"true\" || raw === \"1\" || raw === \"yes\";\n case \"number\": {\n const value = Number(raw);\n if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);\n return value;\n }\n case \"enum\":\n return raw;\n default:\n return raw;\n }\n}\n\nfunction toFlagName(field: string): string {\n return `--${field.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase()}`;\n}\n\nfunction getShape(schema: SchemaLike): Record<string, SchemaLike> {\n const inner = unwrap(schema);\n const shape = inner._def?.shape;\n if (!shape) return {};\n return shape;\n}\n\nexport function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {\n const schema = (descriptor.procedure as any)[\"~orpc\"]?.inputSchema as SchemaLike | undefined;\n if (!schema) return {};\n\n const shape = getShape(schema);\n const fields = Object.entries(shape);\n const fieldByFlag = new Map<string, string>();\n const positionalFields: string[] = [];\n\n for (const [fieldName] of fields) {\n fieldByFlag.set(toFlagName(fieldName), fieldName);\n if (descriptor.meta.fields?.[fieldName]?.positional) {\n positionalFields.push(fieldName);\n }\n }\n\n const input: Record<string, unknown> = {};\n const positionals: string[] = [];\n\n for (let i = 0; i < argv.length; i += 1) {\n const token = argv[i];\n if (!token) continue;\n\n if (token.startsWith(\"--no-\")) {\n const flagName = `--${token.slice(5)}`;\n const fieldName = fieldByFlag.get(flagName);\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n input[fieldName] = false;\n continue;\n }\n\n if (token.startsWith(\"--\")) {\n const [flag, inline] = token.split(\"=\", 2);\n const fieldName = fieldByFlag.get(flag);\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n\n const fieldSchema = shape[fieldName];\n if (isBooleanSchema(fieldSchema)) {\n input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;\n continue;\n }\n\n const next = inline ?? argv[i + 1];\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = coerceValue(next, fieldSchema);\n if (!inline) i += 1;\n continue;\n }\n\n positionals.push(token);\n }\n\n if (positionalFields.length > 0) {\n positionalFields.forEach((fieldName, index) => {\n const raw = positionals[index];\n if (raw !== undefined) {\n input[fieldName] = coerceValue(raw, shape[fieldName]);\n }\n });\n } else if (positionals.length > 0) {\n const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));\n if (candidate) {\n const [fieldName, fieldSchema] = candidate;\n input[fieldName] = coerceValue(positionals[0], fieldSchema);\n }\n }\n\n return schema.parse(input);\n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AAO,OAAO,MAAM,MAAM"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region src/cli/parse.ts
|
|
2
|
+
function unwrap(schema) {
|
|
3
|
+
let current = schema;
|
|
4
|
+
while (true) {
|
|
5
|
+
const type = current._def?.type;
|
|
6
|
+
if (type === "default" || type === "optional" || type === "nullable" || type === "nullish") {
|
|
7
|
+
const inner = current._def?.innerType;
|
|
8
|
+
if (!inner) break;
|
|
9
|
+
current = inner;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
return current;
|
|
13
|
+
}
|
|
14
|
+
return current;
|
|
15
|
+
}
|
|
16
|
+
function isBooleanSchema(schema) {
|
|
17
|
+
return unwrap(schema)._def?.type === "boolean";
|
|
18
|
+
}
|
|
19
|
+
function coerceValue(raw, schema) {
|
|
20
|
+
switch (unwrap(schema)._def?.type) {
|
|
21
|
+
case "boolean": return raw === "true" || raw === "1" || raw === "yes";
|
|
22
|
+
case "number": {
|
|
23
|
+
const value = Number(raw);
|
|
24
|
+
if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
case "enum": return raw;
|
|
28
|
+
default: return raw;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function toFlagName(field) {
|
|
32
|
+
return `--${field.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`;
|
|
33
|
+
}
|
|
34
|
+
function getShape(schema) {
|
|
35
|
+
const shape = unwrap(schema)._def?.shape;
|
|
36
|
+
if (!shape) return {};
|
|
37
|
+
return shape;
|
|
38
|
+
}
|
|
39
|
+
function parseCommandInput(descriptor, argv) {
|
|
40
|
+
const schema = descriptor.procedure["~orpc"]?.inputSchema;
|
|
41
|
+
if (!schema) return {};
|
|
42
|
+
const shape = getShape(schema);
|
|
43
|
+
const fields = Object.entries(shape);
|
|
44
|
+
const fieldByFlag = /* @__PURE__ */ new Map();
|
|
45
|
+
const positionalFields = [];
|
|
46
|
+
for (const [fieldName] of fields) {
|
|
47
|
+
fieldByFlag.set(toFlagName(fieldName), fieldName);
|
|
48
|
+
if (descriptor.meta.fields?.[fieldName]?.positional) positionalFields.push(fieldName);
|
|
49
|
+
}
|
|
50
|
+
const input = {};
|
|
51
|
+
const positionals = [];
|
|
52
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
53
|
+
const token = argv[i];
|
|
54
|
+
if (!token) continue;
|
|
55
|
+
if (token.startsWith("--no-")) {
|
|
56
|
+
const flagName = `--${token.slice(5)}`;
|
|
57
|
+
const fieldName = fieldByFlag.get(flagName);
|
|
58
|
+
if (!fieldName) throw new Error(`Unknown flag: ${token}`);
|
|
59
|
+
input[fieldName] = false;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (token.startsWith("--")) {
|
|
63
|
+
const [flag, inline] = token.split("=", 2);
|
|
64
|
+
const fieldName = fieldByFlag.get(flag);
|
|
65
|
+
if (!fieldName) throw new Error(`Unknown flag: ${token}`);
|
|
66
|
+
const fieldSchema = shape[fieldName];
|
|
67
|
+
if (isBooleanSchema(fieldSchema)) {
|
|
68
|
+
input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const next = inline ?? argv[i + 1];
|
|
72
|
+
if (next === void 0 || next.startsWith("--")) throw new Error(`Missing value for ${flag}`);
|
|
73
|
+
input[fieldName] = coerceValue(next, fieldSchema);
|
|
74
|
+
if (!inline) i += 1;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
positionals.push(token);
|
|
78
|
+
}
|
|
79
|
+
if (positionalFields.length > 0) positionalFields.forEach((fieldName, index) => {
|
|
80
|
+
const raw = positionals[index];
|
|
81
|
+
if (raw !== void 0) input[fieldName] = coerceValue(raw, shape[fieldName]);
|
|
82
|
+
});
|
|
83
|
+
else if (positionals.length > 0) {
|
|
84
|
+
const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));
|
|
85
|
+
if (candidate) {
|
|
86
|
+
const [fieldName, fieldSchema] = candidate;
|
|
87
|
+
input[fieldName] = coerceValue(positionals[0], fieldSchema);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return schema.parse(input);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { parseCommandInput };
|
|
95
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../../src/cli/parse.ts"],"sourcesContent":["import type { CommandDescriptor } from \"./catalog\";\n\ntype SchemaLike = {\n _def?: {\n type?: string;\n innerType?: SchemaLike;\n shape?: Record<string, SchemaLike>;\n values?: Record<string, string> | string[];\n };\n parse: (value: unknown) => unknown;\n};\n\nfunction unwrap(schema: SchemaLike): SchemaLike {\n let current = schema;\n while (true) {\n const type = current._def?.type;\n if (type === \"default\" || type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n const inner = current._def?.innerType;\n if (!inner) break;\n current = inner;\n continue;\n }\n return current;\n }\n return current;\n}\n\nfunction isBooleanSchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"boolean\";\n}\n\nfunction coerceValue(raw: string, schema: SchemaLike): unknown {\n const inner = unwrap(schema);\n switch (inner._def?.type) {\n case \"boolean\":\n return raw === \"true\" || raw === \"1\" || raw === \"yes\";\n case \"number\": {\n const value = Number(raw);\n if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);\n return value;\n }\n case \"enum\":\n return raw;\n default:\n return raw;\n }\n}\n\nfunction toFlagName(field: string): string {\n return `--${field.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase()}`;\n}\n\nfunction getShape(schema: SchemaLike): Record<string, SchemaLike> {\n const inner = unwrap(schema);\n const shape = inner._def?.shape;\n if (!shape) return {};\n return shape;\n}\n\nexport function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {\n const schema = (descriptor.procedure as any)[\"~orpc\"]?.inputSchema as SchemaLike | undefined;\n if (!schema) return {};\n\n const shape = getShape(schema);\n const fields = Object.entries(shape);\n const fieldByFlag = new Map<string, string>();\n const positionalFields: string[] = [];\n\n for (const [fieldName] of fields) {\n fieldByFlag.set(toFlagName(fieldName), fieldName);\n if (descriptor.meta.fields?.[fieldName]?.positional) {\n positionalFields.push(fieldName);\n }\n }\n\n const input: Record<string, unknown> = {};\n const positionals: string[] = [];\n\n for (let i = 0; i < argv.length; i += 1) {\n const token = argv[i];\n if (!token) continue;\n\n if (token.startsWith(\"--no-\")) {\n const flagName = `--${token.slice(5)}`;\n const fieldName = fieldByFlag.get(flagName);\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n input[fieldName] = false;\n continue;\n }\n\n if (token.startsWith(\"--\")) {\n const [flag, inline] = token.split(\"=\", 2);\n const fieldName = fieldByFlag.get(flag);\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n\n const fieldSchema = shape[fieldName];\n if (isBooleanSchema(fieldSchema)) {\n input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;\n continue;\n }\n\n const next = inline ?? argv[i + 1];\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = coerceValue(next, fieldSchema);\n if (!inline) i += 1;\n continue;\n }\n\n positionals.push(token);\n }\n\n if (positionalFields.length > 0) {\n positionalFields.forEach((fieldName, index) => {\n const raw = positionals[index];\n if (raw !== undefined) {\n input[fieldName] = coerceValue(raw, shape[fieldName]);\n }\n });\n } else if (positionals.length > 0) {\n const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));\n if (candidate) {\n const [fieldName, fieldSchema] = candidate;\n input[fieldName] = coerceValue(positionals[0], fieldSchema);\n }\n }\n\n return schema.parse(input);\n}\n"],"mappings":";AAYA,SAAS,OAAO,QAAgC;CAC9C,IAAI,UAAU;AACd,QAAO,MAAM;EACX,MAAM,OAAO,Q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cjs');
|
|
2
|
+
let node_readline = require("node:readline");
|
|
3
|
+
|
|
4
|
+
//#region src/cli/prompts.ts
|
|
5
|
+
async function prompt(question, defaultValue) {
|
|
6
|
+
const rl = (0, node_readline.createInterface)({
|
|
7
|
+
input: process.stdin,
|
|
8
|
+
output: process.stdout
|
|
9
|
+
});
|
|
10
|
+
const fullQuestion = `${question}${defaultValue ? ` [${defaultValue}]` : ""}: `;
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
rl.question(fullQuestion, (answer) => {
|
|
13
|
+
rl.close();
|
|
14
|
+
resolve(answer.trim() || defaultValue || "");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async function promptYesNo(question, defaultVal = false) {
|
|
19
|
+
const answer = await prompt(`${question} (${defaultVal ? "Y/n" : "y/N"})`);
|
|
20
|
+
if (!answer) return defaultVal;
|
|
21
|
+
return answer.toLowerCase() === "y" || answer.toLowerCase() === "yes";
|
|
22
|
+
}
|
|
23
|
+
async function promptInitOptions(input) {
|
|
24
|
+
const account = input.account || await prompt("NEAR account", "dev.everything.near");
|
|
25
|
+
const gateway = input.gateway || await prompt("Gateway ID", "everything.dev");
|
|
26
|
+
const destination = input.destination || await prompt("Project directory", gateway);
|
|
27
|
+
const name = input.name || await prompt("New project NEAR account (optional)", "");
|
|
28
|
+
const domain = input.domain || await prompt("New project domain (optional)", "");
|
|
29
|
+
const withHost = input.withHost !== void 0 ? input.withHost : await promptYesNo("Include host?", false);
|
|
30
|
+
return {
|
|
31
|
+
account,
|
|
32
|
+
gateway,
|
|
33
|
+
destination,
|
|
34
|
+
name: name || void 0,
|
|
35
|
+
domain: domain || void 0,
|
|
36
|
+
withHost
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.promptInitOptions = promptInitOptions;
|
|
42
|
+
//# sourceMappingURL=prompts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.cjs","names":[],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import { createInterface } from \"node:readline\";\n\nexport async function prompt(question: string, defaultValue?: string): Promise<string> {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const suffix = defaultValue ? ` [${defaultValue}]` : \"\";\n const fullQuestion = `${question}${suffix}: `;\n\n return new Promise<string>((resolve) => {\n rl.question(fullQuestion, (answer) => {\n rl.close();\n const trimmed = answer.trim();\n resolve(trimmed || defaultValue || \"\");\n });\n });\n}\n\nexport async function promptYesNo(question: string, defaultVal = false): Promise<boolean> {\n const hint = defaultVal ? \"Y/n\" : \"y/N\";\n const answer = await prompt(`${question} (${hint})`);\n if (!answer) return defaultVal;\n return answer.toLowerCase() === \"y\" || answer.toLowerCase() === \"yes\";\n}\n\nexport async function promptInitOptions(input: {\n account?: string;\n gateway?: string;\n destination?: string;\n name?: string;\n domain?: string;\n withHost?: boolean;\n}): Promise<{\n account: string;\n gateway: string;\n destination: string;\n name?: string;\n domain?: string;\n withHost: boolean;\n}> {\n const account = input.account || (await prompt(\"NEAR account\", \"dev.everything.near\"));\n\n const gateway = input.gateway || (await prompt(\"Gateway ID\", \"everything.dev\"));\n\n const destination = input.destination || (await prompt(\"Project directory\", gateway));\n\n const name = input.name || (await prompt(\"New project NEAR account (optional)\", \"\"));\n\n const domain = input.domain || (await prompt(\"New project domain (optional)\", \"\"));\n\n const withHost =\n input.withHost !== undefined ? input.withHost : await promptYesNo(\"Include host?\", false);\n\n return {\n account,\n gateway,\n destination,\n name: name || undefined,\n domain: domain || undefined,\n withHost,\n };\n}\n"],"mappings":";;;;AAEA,eAAsB,OAAO,UAAkB,cAAwC;CACrF,MAAM,wCAAqB;EACzB,OAAO,QAAQ;EACf,QAAQ,QAAQ;EACjB,CAAC;CAGF,MAAM,eAAe,GAAG,WADT,eAAe,KAAK,aAAa,KAAK,GACX;AAE1C,QAAO,IAAI,SAAiB,YAAY;AACtC,KAAG,SAAS,eAAe,WAAW;AACpC,MAAG,OAAO;AAEV,WADgB,OAAO,MAAM,IACV,gBAAgB,GAAG;IACtC;GACF;;AAGJ,eAAsB,YAAY,UAAkB,aAAa,OAAyB;CAExF,MAAM,SAAS,MAAM,OAAO,GAAG,SAAS,IAD3B,aAAa,QAAQ,MACe,GAAG;AACpD,KAAI,CAAC,OAAQ,QAAO;AACpB,QAAO,OAAO,aAAa,KAAK,OAAO,OAAO,aAAa,KAAK;;AAGlE,eAAsB,kBAAkB,OAcrC;CACD,MAAM,UAAU,MAAM,WAAY,MAAM,OAAO,gBAAgB,sBAAsB;CAErF,MAAM,UAAU,MAAM,WAAY,MAAM,OAAO,cAAc,iBAAiB;CAE9E,MAAM,cAAc,MAAM,eAAgB,MAAM,OAAO,qBAAqB,QAAQ;CAEpF,MAAM,OAAO,MAAM,QAAS,MAAM,OAAO,uCAAuC,GAAG;CAEnF,MAAM,SAAS,MAAM,UAAW,MAAM,OAAO,iCAAiC,GAAG;CAEjF,MAAM,WACJ,MAAM,aAAa,SAAY,MAAM,WAAW,MAAM,YAAY,iBAAiB,MAAM;AAE3F,QAAO;EACL;EACA;EACA;EACA,MAAM,QAAQ;EACd,QAAQ,UAAU;EAClB;EACD"}
|