@ondrej-svec/hog 1.6.1 → 1.6.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/dist/cli.js +108 -53
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1957,6 +1957,31 @@ function findFallback(items, oldSection) {
|
|
|
1957
1957
|
}
|
|
1958
1958
|
return items.find((i) => i.type === "header") ?? items[0];
|
|
1959
1959
|
}
|
|
1960
|
+
function relocateOnToggle(state, section) {
|
|
1961
|
+
if (!state.selectedId) return { selectedId: null, selectedSection: null };
|
|
1962
|
+
const selected = state.allItems.find((i) => i.id === state.selectedId);
|
|
1963
|
+
if (!selected) return { selectedId: state.selectedId, selectedSection: state.selectedSection };
|
|
1964
|
+
const insideCollapsedSubSection = selected.subSection === section;
|
|
1965
|
+
const insideCollapsedSection = !insideCollapsedSubSection && selected.section === section && selected.type !== "header";
|
|
1966
|
+
if (insideCollapsedSubSection) {
|
|
1967
|
+
const subHeader = state.allItems.find((i) => i.id === section && i.type === "subHeader");
|
|
1968
|
+
if (subHeader) return { selectedId: subHeader.id, selectedSection: subHeader.section };
|
|
1969
|
+
} else if (insideCollapsedSection) {
|
|
1970
|
+
const header = state.allItems.find((i) => i.section === section && i.type === "header");
|
|
1971
|
+
if (header) return { selectedId: header.id, selectedSection: header.section };
|
|
1972
|
+
}
|
|
1973
|
+
return { selectedId: state.selectedId, selectedSection: state.selectedSection };
|
|
1974
|
+
}
|
|
1975
|
+
function relocateOnCollapseAll(state) {
|
|
1976
|
+
if (!state.selectedId) return { selectedId: null, selectedSection: null };
|
|
1977
|
+
const selected = state.allItems.find((i) => i.id === state.selectedId);
|
|
1978
|
+
if (!selected || selected.type === "header") {
|
|
1979
|
+
return { selectedId: state.selectedId, selectedSection: state.selectedSection };
|
|
1980
|
+
}
|
|
1981
|
+
const header = state.allItems.find((i) => i.section === selected.section && i.type === "header");
|
|
1982
|
+
if (header) return { selectedId: header.id, selectedSection: header.section };
|
|
1983
|
+
return { selectedId: state.selectedId, selectedSection: state.selectedSection };
|
|
1984
|
+
}
|
|
1960
1985
|
function navReducer(state, action) {
|
|
1961
1986
|
switch (action.type) {
|
|
1962
1987
|
case "SET_ITEMS": {
|
|
@@ -1973,7 +1998,8 @@ function navReducer(state, action) {
|
|
|
1973
1998
|
...state,
|
|
1974
1999
|
selectedSection: selected?.section ?? state.selectedSection,
|
|
1975
2000
|
sections,
|
|
1976
|
-
collapsedSections
|
|
2001
|
+
collapsedSections,
|
|
2002
|
+
allItems: action.items
|
|
1977
2003
|
};
|
|
1978
2004
|
}
|
|
1979
2005
|
const fallback = findFallback(action.items, state.selectedSection);
|
|
@@ -1981,7 +2007,8 @@ function navReducer(state, action) {
|
|
|
1981
2007
|
selectedId: fallback?.id ?? null,
|
|
1982
2008
|
selectedSection: fallback?.section ?? null,
|
|
1983
2009
|
sections,
|
|
1984
|
-
collapsedSections
|
|
2010
|
+
collapsedSections,
|
|
2011
|
+
allItems: action.items
|
|
1985
2012
|
};
|
|
1986
2013
|
}
|
|
1987
2014
|
case "SELECT": {
|
|
@@ -1993,15 +2020,19 @@ function navReducer(state, action) {
|
|
|
1993
2020
|
}
|
|
1994
2021
|
case "TOGGLE_SECTION": {
|
|
1995
2022
|
const next = new Set(state.collapsedSections);
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
} else {
|
|
2023
|
+
const isCollapsing = !next.has(action.section);
|
|
2024
|
+
if (isCollapsing) {
|
|
1999
2025
|
next.add(action.section);
|
|
2026
|
+
const cursor = relocateOnToggle(state, action.section);
|
|
2027
|
+
return { ...state, collapsedSections: next, ...cursor };
|
|
2000
2028
|
}
|
|
2029
|
+
next.delete(action.section);
|
|
2001
2030
|
return { ...state, collapsedSections: next };
|
|
2002
2031
|
}
|
|
2003
2032
|
case "COLLAPSE_ALL": {
|
|
2004
|
-
|
|
2033
|
+
const next = new Set(state.sections);
|
|
2034
|
+
const cursor = relocateOnCollapseAll(state);
|
|
2035
|
+
return { ...state, collapsedSections: next, ...cursor };
|
|
2005
2036
|
}
|
|
2006
2037
|
default:
|
|
2007
2038
|
return state;
|
|
@@ -2021,7 +2052,8 @@ function useNavigation(allItems) {
|
|
|
2021
2052
|
selectedId: null,
|
|
2022
2053
|
selectedSection: null,
|
|
2023
2054
|
sections: [],
|
|
2024
|
-
collapsedSections: /* @__PURE__ */ new Set()
|
|
2055
|
+
collapsedSections: /* @__PURE__ */ new Set(),
|
|
2056
|
+
allItems: []
|
|
2025
2057
|
});
|
|
2026
2058
|
const prevItemsRef = useRef4(null);
|
|
2027
2059
|
if (allItems !== prevItemsRef.current) {
|
|
@@ -2068,6 +2100,7 @@ function useNavigation(allItems) {
|
|
|
2068
2100
|
const toggleSection = useCallback5(() => {
|
|
2069
2101
|
const currentItem = visibleItems[selectedIndex];
|
|
2070
2102
|
if (!currentItem) return;
|
|
2103
|
+
if (currentItem.type === "item") return;
|
|
2071
2104
|
const key = currentItem.type === "subHeader" ? currentItem.id : currentItem.section;
|
|
2072
2105
|
dispatch({ type: "TOGGLE_SECTION", section: key });
|
|
2073
2106
|
}, [selectedIndex, visibleItems]);
|
|
@@ -2231,6 +2264,11 @@ var init_use_toast = __esm({
|
|
|
2231
2264
|
|
|
2232
2265
|
// src/board/hooks/use-ui-state.ts
|
|
2233
2266
|
import { useCallback as useCallback7, useReducer as useReducer2 } from "react";
|
|
2267
|
+
function enterStatusMode(state) {
|
|
2268
|
+
if (state.mode !== "normal" && state.mode !== "overlay:bulkAction") return state;
|
|
2269
|
+
const previousMode = state.mode === "overlay:bulkAction" ? "multiSelect" : "normal";
|
|
2270
|
+
return { ...state, mode: "overlay:status", previousMode };
|
|
2271
|
+
}
|
|
2234
2272
|
function uiReducer(state, action) {
|
|
2235
2273
|
switch (action.type) {
|
|
2236
2274
|
case "ENTER_SEARCH":
|
|
@@ -2240,12 +2278,7 @@ function uiReducer(state, action) {
|
|
|
2240
2278
|
if (state.mode !== "normal") return state;
|
|
2241
2279
|
return { ...state, mode: "overlay:comment", previousMode: "normal" };
|
|
2242
2280
|
case "ENTER_STATUS":
|
|
2243
|
-
|
|
2244
|
-
return {
|
|
2245
|
-
...state,
|
|
2246
|
-
mode: "overlay:status",
|
|
2247
|
-
previousMode: state.mode === "overlay:bulkAction" ? "multiSelect" : "normal"
|
|
2248
|
-
};
|
|
2281
|
+
return enterStatusMode(state);
|
|
2249
2282
|
case "ENTER_CREATE":
|
|
2250
2283
|
if (state.mode !== "normal") return state;
|
|
2251
2284
|
return { ...state, mode: "overlay:create", previousMode: "normal" };
|
|
@@ -2565,16 +2598,16 @@ var init_bulk_action_menu = __esm({
|
|
|
2565
2598
|
|
|
2566
2599
|
// src/board/ink-instance.ts
|
|
2567
2600
|
function setInkInstance(instance) {
|
|
2568
|
-
|
|
2601
|
+
inkInstance = instance;
|
|
2569
2602
|
}
|
|
2570
2603
|
function getInkInstance() {
|
|
2571
|
-
return
|
|
2604
|
+
return inkInstance;
|
|
2572
2605
|
}
|
|
2573
|
-
var
|
|
2606
|
+
var inkInstance;
|
|
2574
2607
|
var init_ink_instance = __esm({
|
|
2575
2608
|
"src/board/ink-instance.ts"() {
|
|
2576
2609
|
"use strict";
|
|
2577
|
-
|
|
2610
|
+
inkInstance = null;
|
|
2578
2611
|
}
|
|
2579
2612
|
});
|
|
2580
2613
|
|
|
@@ -2630,8 +2663,8 @@ function CommentInput({
|
|
|
2630
2663
|
tmpDir = mkdtempSync(join3(tmpdir(), "hog-comment-"));
|
|
2631
2664
|
tmpFile = join3(tmpDir, "comment.md");
|
|
2632
2665
|
writeFileSync3(tmpFile, value);
|
|
2633
|
-
const
|
|
2634
|
-
|
|
2666
|
+
const inkInstance2 = getInkInstance();
|
|
2667
|
+
inkInstance2?.clear();
|
|
2635
2668
|
setRawMode(false);
|
|
2636
2669
|
spawnSync(cmd, [...extraArgs, tmpFile], { stdio: "inherit" });
|
|
2637
2670
|
const content = readFileSync3(tmpFile, "utf-8").trim();
|
|
@@ -2643,7 +2676,7 @@ function CommentInput({
|
|
|
2643
2676
|
}
|
|
2644
2677
|
} finally {
|
|
2645
2678
|
onResumeRef.current?.();
|
|
2646
|
-
if (
|
|
2679
|
+
if (tmpDir) {
|
|
2647
2680
|
try {
|
|
2648
2681
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
2649
2682
|
} catch {
|
|
@@ -3202,8 +3235,8 @@ function NlCreateOverlay({
|
|
|
3202
3235
|
tmpDir = mkdtempSync2(join4(tmpdir2(), "hog-body-"));
|
|
3203
3236
|
tmpFile = join4(tmpDir, "body.md");
|
|
3204
3237
|
writeFileSync4(tmpFile, body);
|
|
3205
|
-
const
|
|
3206
|
-
|
|
3238
|
+
const inkInstance2 = getInkInstance();
|
|
3239
|
+
inkInstance2?.clear();
|
|
3207
3240
|
setRawMode(false);
|
|
3208
3241
|
spawnSync2(cmd, [...extraArgs, tmpFile], { stdio: "inherit" });
|
|
3209
3242
|
const content = readFileSync4(tmpFile, "utf-8");
|
|
@@ -3392,6 +3425,42 @@ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
|
3392
3425
|
function isTerminal(name) {
|
|
3393
3426
|
return TERMINAL_STATUS_RE2.test(name);
|
|
3394
3427
|
}
|
|
3428
|
+
function handlePickerInput(input2, key, state) {
|
|
3429
|
+
if (key.escape) {
|
|
3430
|
+
state.onCancel();
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
if (key.return) {
|
|
3434
|
+
if (state.submittedRef.current) return;
|
|
3435
|
+
const opt = state.options[state.selectedIdx];
|
|
3436
|
+
if (!opt) return;
|
|
3437
|
+
if (isTerminal(opt.name) && state.showTerminalStatuses) {
|
|
3438
|
+
state.onConfirmTerminal();
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
state.submittedRef.current = true;
|
|
3442
|
+
state.onSelect(opt.id);
|
|
3443
|
+
return;
|
|
3444
|
+
}
|
|
3445
|
+
if (input2 === "j" || key.downArrow) {
|
|
3446
|
+
state.onNavigate((i) => Math.min(i + 1, state.options.length - 1));
|
|
3447
|
+
}
|
|
3448
|
+
if (input2 === "k" || key.upArrow) {
|
|
3449
|
+
state.onNavigate((i) => Math.max(i - 1, 0));
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
function handleConfirmInput(input2, key, state) {
|
|
3453
|
+
if (input2 === "y" || input2 === "Y") {
|
|
3454
|
+
if (!state.submittedRef.current) {
|
|
3455
|
+
state.submittedRef.current = true;
|
|
3456
|
+
if (state.opt) state.onSelect(state.opt.id);
|
|
3457
|
+
}
|
|
3458
|
+
return;
|
|
3459
|
+
}
|
|
3460
|
+
if (input2 === "n" || input2 === "N" || key.escape) {
|
|
3461
|
+
state.onExitConfirm();
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3395
3464
|
function StatusPicker({
|
|
3396
3465
|
options,
|
|
3397
3466
|
currentStatus,
|
|
@@ -3407,38 +3476,24 @@ function StatusPicker({
|
|
|
3407
3476
|
const submittedRef = useRef10(false);
|
|
3408
3477
|
useInput10((input2, key) => {
|
|
3409
3478
|
if (confirmingTerminal) {
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
submittedRef
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
}
|
|
3417
|
-
if (input2 === "n" || input2 === "N" || key.escape) {
|
|
3418
|
-
setConfirmingTerminal(false);
|
|
3419
|
-
return;
|
|
3420
|
-
}
|
|
3421
|
-
return;
|
|
3422
|
-
}
|
|
3423
|
-
if (key.escape) return onCancel();
|
|
3424
|
-
if (key.return) {
|
|
3425
|
-
if (submittedRef.current) return;
|
|
3426
|
-
const opt = options[selectedIdx];
|
|
3427
|
-
if (!opt) return;
|
|
3428
|
-
if (isTerminal(opt.name) && showTerminalStatuses) {
|
|
3429
|
-
setConfirmingTerminal(true);
|
|
3430
|
-
return;
|
|
3431
|
-
}
|
|
3432
|
-
submittedRef.current = true;
|
|
3433
|
-
onSelect(opt.id);
|
|
3479
|
+
handleConfirmInput(input2, key, {
|
|
3480
|
+
opt: options[selectedIdx],
|
|
3481
|
+
submittedRef,
|
|
3482
|
+
onSelect,
|
|
3483
|
+
onExitConfirm: () => setConfirmingTerminal(false)
|
|
3484
|
+
});
|
|
3434
3485
|
return;
|
|
3435
3486
|
}
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3487
|
+
handlePickerInput(input2, key, {
|
|
3488
|
+
options,
|
|
3489
|
+
selectedIdx,
|
|
3490
|
+
showTerminalStatuses,
|
|
3491
|
+
submittedRef,
|
|
3492
|
+
onSelect,
|
|
3493
|
+
onCancel,
|
|
3494
|
+
onConfirmTerminal: () => setConfirmingTerminal(true),
|
|
3495
|
+
onNavigate: setSelectedIdx
|
|
3496
|
+
});
|
|
3442
3497
|
});
|
|
3443
3498
|
if (confirmingTerminal) {
|
|
3444
3499
|
const opt = options[selectedIdx];
|
|
@@ -5804,7 +5859,7 @@ function resolveProjectId(projectId) {
|
|
|
5804
5859
|
process.exit(1);
|
|
5805
5860
|
}
|
|
5806
5861
|
var program = new Command();
|
|
5807
|
-
program.name("hog").description("Personal command deck \u2014 unified task dashboard for GitHub Projects + TickTick").version("1.6.
|
|
5862
|
+
program.name("hog").description("Personal command deck \u2014 unified task dashboard for GitHub Projects + TickTick").version("1.6.2").option("--json", "Force JSON output").option("--human", "Force human-readable output").hook("preAction", (thisCommand) => {
|
|
5808
5863
|
const opts = thisCommand.opts();
|
|
5809
5864
|
if (opts.json) setFormat("json");
|
|
5810
5865
|
if (opts.human) setFormat("human");
|