@c4a/daemon 0.4.12-beta.15 → 0.4.12-beta.16

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.
Files changed (2) hide show
  1. package/index.js +31 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -14402,37 +14402,46 @@ var runGitWithProgress = async (args, options) => new Promise((resolve, reject)
14402
14402
  });
14403
14403
  let lastWeighted = null;
14404
14404
  let stderrBuf = "";
14405
+ const processLine = (trimmed) => {
14406
+ if (!trimmed)
14407
+ return;
14408
+ options.onStderr?.(trimmed);
14409
+ const match = trimmed.match(GIT_PROGRESS_RE);
14410
+ if (match) {
14411
+ const phase = match[1];
14412
+ const raw = Number(match[2]);
14413
+ if (!Number.isNaN(raw)) {
14414
+ const weighted = weightedPercent(phase, raw);
14415
+ if (weighted !== lastWeighted) {
14416
+ lastWeighted = weighted;
14417
+ options.onProgress?.({ percent: weighted, label: trimmed });
14418
+ }
14419
+ }
14420
+ }
14421
+ };
14422
+ const flushBuf = () => {
14423
+ if (stderrBuf.trim()) {
14424
+ processLine(stderrBuf.trim());
14425
+ stderrBuf = "";
14426
+ }
14427
+ };
14428
+ const flushTimer = setInterval(flushBuf, 3000);
14405
14429
  child.stderr.on("data", (chunk) => {
14406
14430
  const text = chunk.toString();
14407
14431
  stderrBuf += text;
14408
14432
  const lines = stderrBuf.split(/[\r\n]+/);
14409
14433
  stderrBuf = lines.pop() ?? "";
14410
14434
  for (const line of lines) {
14411
- const trimmed = line.trim();
14412
- if (!trimmed)
14413
- continue;
14414
- options.onStderr?.(trimmed);
14415
- const match = trimmed.match(GIT_PROGRESS_RE);
14416
- if (match) {
14417
- const phase = match[1];
14418
- const raw = Number(match[2]);
14419
- if (!Number.isNaN(raw)) {
14420
- const weighted = weightedPercent(phase, raw);
14421
- if (weighted !== lastWeighted) {
14422
- lastWeighted = weighted;
14423
- options.onProgress?.({ percent: weighted, label: trimmed });
14424
- }
14425
- }
14426
- }
14435
+ processLine(line.trim());
14427
14436
  }
14428
14437
  });
14429
14438
  child.on("error", (error) => {
14439
+ clearInterval(flushTimer);
14430
14440
  reject(error);
14431
14441
  });
14432
14442
  child.on("close", (code) => {
14433
- if (stderrBuf.trim()) {
14434
- options.onStderr?.(stderrBuf.trim());
14435
- }
14443
+ clearInterval(flushTimer);
14444
+ flushBuf();
14436
14445
  if (code === 0) {
14437
14446
  console.log("[runGitWithProgress] finished successfully");
14438
14447
  resolve();
@@ -14503,6 +14512,7 @@ var getRepoDir = (workDir, repoName) => path8.join(workDir, "repos", repoName);
14503
14512
  var notifyProgress = (notify, percent, detail) => {
14504
14513
  if (!notify)
14505
14514
  return;
14515
+ console.log(`[vcs/clone] notify progress: percent=${percent} detail=${detail ?? ""}`);
14506
14516
  const payload = {
14507
14517
  stage: "cloning",
14508
14518
  label: "cloning",
@@ -14755,9 +14765,10 @@ class RpcHandler {
14755
14765
  return null;
14756
14766
  }
14757
14767
  const rpcError = error instanceof RpcError ? error : undefined;
14768
+ const message = rpcError?.message ?? (error instanceof Error ? error.message : "Internal error");
14758
14769
  return {
14759
14770
  jsonrpc: "2.0",
14760
- error: buildError(rpcError?.code ?? JSON_RPC_ERROR_CODES.INTERNAL_ERROR, rpcError?.message ?? "Internal error", rpcError?.data),
14771
+ error: buildError(rpcError?.code ?? JSON_RPC_ERROR_CODES.INTERNAL_ERROR, message, rpcError?.data),
14761
14772
  id: request.id ?? null
14762
14773
  };
14763
14774
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/daemon",
3
- "version": "0.4.12-beta.15",
3
+ "version": "0.4.12-beta.16",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "c4a-daemon": "./index.js",