@muhkoo/cli 0.13.1-alpha.0 → 0.14.0-alpha.1
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/package.json +2 -2
- package/src/lib/mount.js +27 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muhkoo/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-alpha.1",
|
|
4
4
|
"description": "Command-line interface for the Muhkoo platform — provision backends, deploy apps, and manage agents, functions, databases, and domains.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "vitest run"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@muhkoo/connect": "0.
|
|
42
|
+
"@muhkoo/connect": "0.14.0-alpha.1",
|
|
43
43
|
"snarkjs": "^0.7.0"
|
|
44
44
|
},
|
|
45
45
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
package/src/lib/mount.js
CHANGED
|
@@ -63,6 +63,14 @@ const KEEP_HIDDEN = new Set([".vcsignore", ".gitignore"]);
|
|
|
63
63
|
*/
|
|
64
64
|
const MAX_BYTES = 100 * 1024 * 1024;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* How many files to read at once.
|
|
68
|
+
*
|
|
69
|
+
* Enough to hide per-request latency; low enough not to open a connection per
|
|
70
|
+
* file on a large project.
|
|
71
|
+
*/
|
|
72
|
+
const READ_CONCURRENCY = 8;
|
|
73
|
+
|
|
66
74
|
/** Coalesce editor churn — a save is often several events in a few ms. */
|
|
67
75
|
const SETTLE_MS = 250;
|
|
68
76
|
|
|
@@ -155,6 +163,10 @@ async function scanLocal(dir, includeHidden = false, ignore = () => false) {
|
|
|
155
163
|
export async function scanRemote(vfs, root, includeHidden = false, ignore = () => false) {
|
|
156
164
|
const out = {};
|
|
157
165
|
if (!(await vfs.exists(root))) return out;
|
|
166
|
+
|
|
167
|
+
// Decide what to read BEFORE reading anything, so the filters are applied
|
|
168
|
+
// once and the reads that survive them can go out together.
|
|
169
|
+
const wanted = [];
|
|
158
170
|
for (const abs of await vfs.walk(root)) {
|
|
159
171
|
const key = abs.slice(root.length) || "/" + abs.split("/").pop();
|
|
160
172
|
const rel = key.replace(/^\//, "");
|
|
@@ -167,8 +179,22 @@ export async function scanRemote(vfs, root, includeHidden = false, ignore = () =
|
|
|
167
179
|
// Same dot-entry rule as `scanLocal`, applied to every segment: a remote
|
|
168
180
|
// `.vscode/tasks.json` is as dangerous as a remote `.vscode`.
|
|
169
181
|
if (!includeHidden && rel.split("/").some((part) => isHidden(part) && !KEEP_HIDDEN.has(part))) continue;
|
|
170
|
-
|
|
182
|
+
wanted.push([key, abs]);
|
|
171
183
|
}
|
|
184
|
+
|
|
185
|
+
// Read in PARALLEL. Each file is an independent round trip - a manifest
|
|
186
|
+
// lookup plus its shards - so reading them one after another cost the SUM
|
|
187
|
+
// of the latencies. On a project of any size that is the difference between
|
|
188
|
+
// `mount` taking a moment and looking like it has hung: doodledottie is 38
|
|
189
|
+
// files and 16.5MB, which took over twenty seconds in series.
|
|
190
|
+
const queue = [...wanted];
|
|
191
|
+
await Promise.all(
|
|
192
|
+
Array.from({ length: Math.min(READ_CONCURRENCY, queue.length) }, async () => {
|
|
193
|
+
for (let item = queue.shift(); item !== undefined; item = queue.shift()) {
|
|
194
|
+
out[item[0]] = sha(await vfs.readFile(item[1]));
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
172
198
|
return out;
|
|
173
199
|
}
|
|
174
200
|
|