zapdev 1.5.0 → 1.6.0
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/cli.js +41 -23
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -554,7 +554,7 @@ function _getBuiltinFlags(long, short, userNames, userAliases) {
|
|
|
554
554
|
// package.json
|
|
555
555
|
var package_default = {
|
|
556
556
|
name: "zapdev",
|
|
557
|
-
version: "1.
|
|
557
|
+
version: "1.6.0",
|
|
558
558
|
description: "Fast, performant and lightweight git chores and dev tools using your terminal and an OpenAI-compatible LLM endpoint.",
|
|
559
559
|
type: "module",
|
|
560
560
|
bin: {
|
|
@@ -2176,6 +2176,18 @@ var R2 = (e2, t3, n4) => {
|
|
|
2176
2176
|
};
|
|
2177
2177
|
var z = R2;
|
|
2178
2178
|
|
|
2179
|
+
// src/lib/errors.ts
|
|
2180
|
+
var GitOutputError = class extends Error {
|
|
2181
|
+
constructor(message, hookFailureReported = false) {
|
|
2182
|
+
super(message);
|
|
2183
|
+
this.hookFailureReported = hookFailureReported;
|
|
2184
|
+
}
|
|
2185
|
+
hookFailureReported;
|
|
2186
|
+
};
|
|
2187
|
+
function errorMessage(error) {
|
|
2188
|
+
return error instanceof Error ? error.message : String(error);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2179
2191
|
// src/lib/git-hooks.ts
|
|
2180
2192
|
function createHookReporter(onHook, onTimeout, timeout) {
|
|
2181
2193
|
const hooks = /* @__PURE__ */ new Map();
|
|
@@ -2226,7 +2238,11 @@ async function git(args, cwd, onHook) {
|
|
|
2226
2238
|
}
|
|
2227
2239
|
});
|
|
2228
2240
|
let timeoutError;
|
|
2229
|
-
|
|
2241
|
+
let hookFailureReported = false;
|
|
2242
|
+
const { report, close } = createHookReporter((event) => {
|
|
2243
|
+
if (onHook && event.phase === "exit" && event.exitCode !== 0) hookFailureReported = true;
|
|
2244
|
+
onHook?.(event);
|
|
2245
|
+
}, (name) => {
|
|
2230
2246
|
if (timeoutError || child.pid === void 0) return;
|
|
2231
2247
|
timeoutError = new Error(`${name} hook timed out after ${timeout / 1e3} seconds`);
|
|
2232
2248
|
try {
|
|
@@ -2247,7 +2263,9 @@ async function git(args, cwd, onHook) {
|
|
|
2247
2263
|
const result = await child;
|
|
2248
2264
|
if (timeoutError) throw timeoutError;
|
|
2249
2265
|
if (result.exitCode !== 0) {
|
|
2250
|
-
|
|
2266
|
+
const message = result.stderr.trim() || `git ${args.join(" ")} failed`;
|
|
2267
|
+
if (interactive) throw new GitOutputError(message, hookFailureReported);
|
|
2268
|
+
throw new Error(message);
|
|
2251
2269
|
}
|
|
2252
2270
|
return result.stdout;
|
|
2253
2271
|
} finally {
|
|
@@ -2287,7 +2305,7 @@ async function getStagedDiff(repo) {
|
|
|
2287
2305
|
return git(["diff", "--cached"], repo);
|
|
2288
2306
|
}
|
|
2289
2307
|
async function commit(repo, message, onHook) {
|
|
2290
|
-
await git(["commit", "-m", message], repo, onHook);
|
|
2308
|
+
await git(["commit", "--quiet", "-m", message], repo, onHook);
|
|
2291
2309
|
}
|
|
2292
2310
|
async function currentBranch(repo) {
|
|
2293
2311
|
return (await git(["symbolic-ref", "--short", "HEAD"], repo)).trim();
|
|
@@ -2305,19 +2323,19 @@ async function hasUpstream(repo) {
|
|
|
2305
2323
|
return result !== null;
|
|
2306
2324
|
}
|
|
2307
2325
|
async function push(repo, onHook) {
|
|
2308
|
-
await git(["push"], repo, onHook);
|
|
2326
|
+
await git(["push", "--quiet"], repo, onHook);
|
|
2309
2327
|
}
|
|
2310
2328
|
async function pushSetUpstream(repo, branch, onHook) {
|
|
2311
|
-
await git(["push", "-u", "origin", branch], repo, onHook);
|
|
2329
|
+
await git(["push", "--quiet", "-u", "origin", branch], repo, onHook);
|
|
2312
2330
|
}
|
|
2313
2331
|
async function pullRebase(repo, onHook) {
|
|
2314
|
-
await git(["pull", "--rebase"], repo, onHook);
|
|
2332
|
+
await git(["pull", "--quiet", "--rebase"], repo, onHook);
|
|
2315
2333
|
}
|
|
2316
2334
|
async function pullMerge(repo, onHook) {
|
|
2317
|
-
await git(["pull", "--no-rebase", "--no-edit"], repo, onHook);
|
|
2335
|
+
await git(["pull", "--quiet", "--no-rebase", "--no-edit"], repo, onHook);
|
|
2318
2336
|
}
|
|
2319
2337
|
async function fetchRemote(repo, onHook) {
|
|
2320
|
-
await git(["fetch"], repo, onHook);
|
|
2338
|
+
await git(["fetch", "--quiet"], repo, onHook);
|
|
2321
2339
|
}
|
|
2322
2340
|
async function behindCount(repo) {
|
|
2323
2341
|
const out = await tryGit(["rev-list", "--count", `HEAD..${UPSTREAM_REF}`], repo);
|
|
@@ -2336,11 +2354,6 @@ async function repoRoot(dir) {
|
|
|
2336
2354
|
return (await tryGit(["rev-parse", "--show-toplevel"], dir))?.trim() ?? null;
|
|
2337
2355
|
}
|
|
2338
2356
|
|
|
2339
|
-
// src/lib/errors.ts
|
|
2340
|
-
function errorMessage(error) {
|
|
2341
|
-
return error instanceof Error ? error.message : String(error);
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
2357
|
// src/lib/gitleaks.ts
|
|
2345
2358
|
async function hasGitleaks() {
|
|
2346
2359
|
try {
|
|
@@ -2576,7 +2589,7 @@ var commitCommand = defineCommand({
|
|
|
2576
2589
|
committed.push(draft);
|
|
2577
2590
|
log.success(`${draft.label}: committed ${draft.message}`);
|
|
2578
2591
|
} catch (error) {
|
|
2579
|
-
|
|
2592
|
+
reportGitFailure(`${draft.pendingLabel}: commit failed`, error);
|
|
2580
2593
|
process.exitCode = 1;
|
|
2581
2594
|
}
|
|
2582
2595
|
}
|
|
@@ -2603,7 +2616,7 @@ var commitCommand = defineCommand({
|
|
|
2603
2616
|
);
|
|
2604
2617
|
if (!pushed) process.exitCode = 1;
|
|
2605
2618
|
} catch (error) {
|
|
2606
|
-
|
|
2619
|
+
reportGitFailure(`${repository.label}: push failed`, error);
|
|
2607
2620
|
process.exitCode = 1;
|
|
2608
2621
|
}
|
|
2609
2622
|
}
|
|
@@ -2611,14 +2624,19 @@ var commitCommand = defineCommand({
|
|
|
2611
2624
|
if (interactive) outro(process.exitCode ? "Finished with errors." : "Done.");
|
|
2612
2625
|
}
|
|
2613
2626
|
});
|
|
2627
|
+
function reportGitFailure(message, error, level = "error") {
|
|
2628
|
+
if (error instanceof GitOutputError && error.hookFailureReported) return;
|
|
2629
|
+
log[level](error instanceof GitOutputError ? message : `${message}: ${errorMessage(error)}`);
|
|
2630
|
+
}
|
|
2614
2631
|
function reportHooks(label) {
|
|
2632
|
+
const options = { secondarySymbol: "" };
|
|
2615
2633
|
return (event) => {
|
|
2616
2634
|
const hook = `${label}: ${event.name}`;
|
|
2617
2635
|
if (event.phase === "start") {
|
|
2618
|
-
log.
|
|
2636
|
+
log.step(styleText3("bold", hook), options);
|
|
2619
2637
|
} else {
|
|
2620
|
-
if (event.exitCode === 0) log.success(`${hook}
|
|
2621
|
-
else log.error(`${hook}
|
|
2638
|
+
if (event.exitCode === 0) log.success(`${hook}: completed`, options);
|
|
2639
|
+
else log.error(`${hook}: failed (exit ${event.exitCode})`, options);
|
|
2622
2640
|
}
|
|
2623
2641
|
};
|
|
2624
2642
|
}
|
|
@@ -2662,7 +2680,7 @@ async function syncWithUpstream({ repo, label }, strategy) {
|
|
|
2662
2680
|
log.success(`${label}: ${strategy === "rebase" ? "rebased on upstream" : "merged upstream"}`);
|
|
2663
2681
|
return true;
|
|
2664
2682
|
} catch (error) {
|
|
2665
|
-
|
|
2683
|
+
reportGitFailure(`${label}: ${actionLabel} failed (resolve conflicts, then push)`, error);
|
|
2666
2684
|
return false;
|
|
2667
2685
|
}
|
|
2668
2686
|
}
|
|
@@ -2677,10 +2695,10 @@ async function pushOptimistic(repository, canPrompt, strategy) {
|
|
|
2677
2695
|
if (!syncStrategy || !await syncWithUpstream(repository, syncStrategy)) return false;
|
|
2678
2696
|
const retry = await tryPush(repository, doPush);
|
|
2679
2697
|
if (retry.ok) return true;
|
|
2680
|
-
|
|
2698
|
+
reportGitFailure(`${label}: push failed`, retry.error);
|
|
2681
2699
|
return false;
|
|
2682
2700
|
}
|
|
2683
|
-
|
|
2701
|
+
reportGitFailure(`${label}: push failed`, first.error);
|
|
2684
2702
|
return false;
|
|
2685
2703
|
}
|
|
2686
2704
|
async function chooseSyncStrategy({ label }, interactive) {
|
|
@@ -2720,7 +2738,7 @@ async function isBehind({ repo, label }) {
|
|
|
2720
2738
|
log.info(`${label}: ${behind > 0 ? `Behind upstream by ${behind} commit${behind > 1 ? "s" : ""}` : "Up to date with upstream"}`);
|
|
2721
2739
|
return behind > 0;
|
|
2722
2740
|
} catch (error) {
|
|
2723
|
-
|
|
2741
|
+
reportGitFailure(`${label}: could not check upstream`, error, "warn");
|
|
2724
2742
|
return false;
|
|
2725
2743
|
}
|
|
2726
2744
|
}
|