gh-manager-cli 1.18.1 → 1.19.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/CHANGELOG.md +7 -0
- package/README.md +23 -0
- package/dist/index.js +129 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.19.0](https://github.com/wiiiimm/gh-manager-cli/compare/v1.18.1...v1.19.0) (2025-09-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **cli:** add org (-o) and token (-t) flags ([#18](https://github.com/wiiiimm/gh-manager-cli/issues/18)) ([029376e](https://github.com/wiiiimm/gh-manager-cli/commit/029376e1465eb9376850c6e19ef2b514020a4542))
|
|
7
|
+
|
|
1
8
|
## [1.18.1](https://github.com/wiiiimm/gh-manager-cli/compare/v1.18.0...v1.18.1) (2025-09-02)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -208,6 +208,29 @@ Notes:
|
|
|
208
208
|
|
|
209
209
|
Launch the app, then use the keys below:
|
|
210
210
|
|
|
211
|
+
### CLI Flags
|
|
212
|
+
|
|
213
|
+
- `--org, -o <slug>`: Start in a specific organisation context (if accessible). Ignores the flag if you don’t have access or if the slug isn’t an organisation.
|
|
214
|
+
- Examples:
|
|
215
|
+
- `gh-manager-cli --org acme`
|
|
216
|
+
- `gh-manager-cli -o acme`
|
|
217
|
+
- `npx gh-manager-cli --org=@acme`
|
|
218
|
+
- `npx gh-manager-cli -o=@acme`
|
|
219
|
+
- Notes:
|
|
220
|
+
- Leading `@` is optional.
|
|
221
|
+
- Personal usernames are not supported by `--org`/`-o` (use default personal context).
|
|
222
|
+
|
|
223
|
+
- `--token, -t <pat>`: Use a Personal Access Token just for this run. Does not persist to config.
|
|
224
|
+
- Examples:
|
|
225
|
+
- `gh-manager-cli --token ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXX`
|
|
226
|
+
- `gh-manager-cli -t=ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXX`
|
|
227
|
+
- Precedence: CLI token > `GITHUB_TOKEN`/`GH_TOKEN` env vars > stored config.
|
|
228
|
+
- Security: Supplying tokens on the command line may be captured in shell history. Prefer env vars or the interactive prompt when possible.
|
|
229
|
+
|
|
230
|
+
- `--help, -h`: Show usage information and exit.
|
|
231
|
+
|
|
232
|
+
- `--version, -v`: Print the current version and exit.
|
|
233
|
+
|
|
211
234
|
### Navigation & View Controls
|
|
212
235
|
- **Top/Bottom**: `Ctrl+G` (top), `G` (bottom)
|
|
213
236
|
- **Page Navigation**: ↑↓ Arrow keys, PageUp/PageDown
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var require_package = __commonJS({
|
|
|
28
28
|
"package.json"(exports, module) {
|
|
29
29
|
module.exports = {
|
|
30
30
|
name: "gh-manager-cli",
|
|
31
|
-
version: "1.
|
|
31
|
+
version: "1.19.0",
|
|
32
32
|
private: false,
|
|
33
33
|
description: "Interactive CLI to manage your GitHub repos (personal) with Ink",
|
|
34
34
|
license: "MIT",
|
|
@@ -404,7 +404,7 @@ async function openGitHubAuthorizationPage() {
|
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
// src/ui/RepoList.tsx
|
|
407
|
-
import React10, { useEffect as useEffect7, useMemo, useState as useState10, useRef } from "react";
|
|
407
|
+
import React10, { useEffect as useEffect7, useMemo, useState as useState10, useRef, useCallback } from "react";
|
|
408
408
|
import { Box as Box13, Text as Text14, useApp, useInput as useInput10, useStdout } from "ink";
|
|
409
409
|
import TextInput4 from "ink-text-input";
|
|
410
410
|
import chalk11 from "chalk";
|
|
@@ -497,8 +497,8 @@ function OrgSwitcher({ token, currentContext, onSelect, onClose }) {
|
|
|
497
497
|
}
|
|
498
498
|
setEnterpriseOrgs(entOrgs);
|
|
499
499
|
if (!isPersonalContext) {
|
|
500
|
-
const
|
|
501
|
-
const index = orgs.findIndex((org) => org.login ===
|
|
500
|
+
const orgLogin = currentContext.login;
|
|
501
|
+
const index = orgs.findIndex((org) => org.login === orgLogin);
|
|
502
502
|
if (index !== -1) {
|
|
503
503
|
setCursor(index + 1);
|
|
504
504
|
}
|
|
@@ -1223,16 +1223,20 @@ var getPageSize = () => {
|
|
|
1223
1223
|
return 15;
|
|
1224
1224
|
};
|
|
1225
1225
|
var PAGE_SIZE = getPageSize();
|
|
1226
|
-
function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextChange }) {
|
|
1226
|
+
function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextChange, initialOrgSlug: initialOrgSlug2 }) {
|
|
1227
1227
|
const { exit } = useApp();
|
|
1228
1228
|
const { stdout } = useStdout();
|
|
1229
1229
|
const client = useMemo(() => makeClient(token), [token]);
|
|
1230
1230
|
const [debugMessages, setDebugMessages] = useState10([]);
|
|
1231
|
-
const addDebugMessage = (msg) => {
|
|
1231
|
+
const addDebugMessage = useCallback((msg) => {
|
|
1232
1232
|
if (process.env.GH_MANAGER_DEBUG === "1") {
|
|
1233
1233
|
setDebugMessages((prev) => [...prev.slice(-9), msg]);
|
|
1234
1234
|
}
|
|
1235
|
-
};
|
|
1235
|
+
}, []);
|
|
1236
|
+
const handleOrgContextChangeRef = useRef(onOrgContextChange);
|
|
1237
|
+
useEffect7(() => {
|
|
1238
|
+
handleOrgContextChangeRef.current = onOrgContextChange;
|
|
1239
|
+
}, [onOrgContextChange]);
|
|
1236
1240
|
React10.useEffect(() => {
|
|
1237
1241
|
addDebugMessage(`[RepoList] Component mounted`);
|
|
1238
1242
|
logger.info("RepoList component mounted", {
|
|
@@ -1299,6 +1303,35 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1299
1303
|
const [changingVisibility, setChangingVisibility] = useState10(false);
|
|
1300
1304
|
const [changeVisibilityError, setChangeVisibilityError] = useState10(null);
|
|
1301
1305
|
const [sortMode, setSortMode] = useState10(false);
|
|
1306
|
+
const appliedInitialOrg = useRef(false);
|
|
1307
|
+
useEffect7(() => {
|
|
1308
|
+
(async () => {
|
|
1309
|
+
if (appliedInitialOrg.current) return;
|
|
1310
|
+
if (!initialOrgSlug2) return;
|
|
1311
|
+
if (!token) return;
|
|
1312
|
+
if (!prefsLoaded) {
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
appliedInitialOrg.current = true;
|
|
1316
|
+
try {
|
|
1317
|
+
const orgs = await fetchViewerOrganizations(client);
|
|
1318
|
+
const slug = initialOrgSlug2.replace(/^@/, "");
|
|
1319
|
+
const match = orgs.find((o) => o.login.toLowerCase() === slug.toLowerCase());
|
|
1320
|
+
if (match) {
|
|
1321
|
+
await handleOrgContextChange({
|
|
1322
|
+
type: "organization",
|
|
1323
|
+
login: match.login,
|
|
1324
|
+
name: match.name || void 0
|
|
1325
|
+
});
|
|
1326
|
+
addDebugMessage(`[--org] Switched context to @${match.login}`);
|
|
1327
|
+
} else {
|
|
1328
|
+
addDebugMessage(`[--org] No access to org @${slug}, ignoring flag`);
|
|
1329
|
+
}
|
|
1330
|
+
} catch (e) {
|
|
1331
|
+
addDebugMessage(`[--org] Failed to apply org flag: ${e.message || e}`);
|
|
1332
|
+
}
|
|
1333
|
+
})();
|
|
1334
|
+
}, [initialOrgSlug2, token, prefsLoaded, client, addDebugMessage]);
|
|
1302
1335
|
function closeArchiveModal() {
|
|
1303
1336
|
setArchiveMode(false);
|
|
1304
1337
|
setArchiveTarget(null);
|
|
@@ -1429,7 +1462,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1429
1462
|
visibilityFilter: "all"
|
|
1430
1463
|
});
|
|
1431
1464
|
if (onOrgContextChange) {
|
|
1432
|
-
|
|
1465
|
+
handleOrgContextChangeRef.current?.(newContext);
|
|
1433
1466
|
}
|
|
1434
1467
|
}
|
|
1435
1468
|
function cancelDeleteModal() {
|
|
@@ -1502,7 +1535,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1502
1535
|
field: sortFieldMap[sortKey],
|
|
1503
1536
|
direction: sortDir.toUpperCase()
|
|
1504
1537
|
};
|
|
1505
|
-
const
|
|
1538
|
+
const orgLogin = ownerContext !== "personal" ? ownerContext.login : void 0;
|
|
1506
1539
|
let privacy;
|
|
1507
1540
|
if (visibilityFilter === "public") privacy = "PUBLIC";
|
|
1508
1541
|
else if (visibilityFilter === "private") privacy = "PRIVATE";
|
|
@@ -1514,7 +1547,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1514
1547
|
overrideForkTracking ?? forkTracking,
|
|
1515
1548
|
policy ?? (after ? "network-only" : "cache-first"),
|
|
1516
1549
|
ownerAffiliations,
|
|
1517
|
-
|
|
1550
|
+
orgLogin,
|
|
1518
1551
|
privacy
|
|
1519
1552
|
);
|
|
1520
1553
|
setItems((prev) => reset || !after ? page.nodes : [...prev, ...page.nodes]);
|
|
@@ -1524,9 +1557,9 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1524
1557
|
if (page.nodes.some((repo) => repo.visibility === "INTERNAL")) {
|
|
1525
1558
|
setHasInternalRepos(true);
|
|
1526
1559
|
}
|
|
1527
|
-
if (!after &&
|
|
1560
|
+
if (!after && orgLogin) {
|
|
1528
1561
|
const client2 = makeClient(token);
|
|
1529
|
-
checkOrganizationIsEnterprise(client2,
|
|
1562
|
+
checkOrganizationIsEnterprise(client2, orgLogin).then((isEnt) => {
|
|
1530
1563
|
setIsEnterpriseOrg(isEnt);
|
|
1531
1564
|
});
|
|
1532
1565
|
}
|
|
@@ -1538,7 +1571,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1538
1571
|
sortDir,
|
|
1539
1572
|
pageSize: PAGE_SIZE,
|
|
1540
1573
|
forkTracking: overrideForkTracking ?? forkTracking,
|
|
1541
|
-
ownerContext:
|
|
1574
|
+
ownerContext: orgLogin ? `org:${orgLogin}` : "personal",
|
|
1542
1575
|
affiliations: ownerAffiliations.join(",")
|
|
1543
1576
|
});
|
|
1544
1577
|
markFetched(key);
|
|
@@ -1577,8 +1610,8 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1577
1610
|
setSearchLoading(true);
|
|
1578
1611
|
try {
|
|
1579
1612
|
const orderBy = { field: sortFieldMap[sortKey], direction: sortDir.toUpperCase() };
|
|
1580
|
-
const
|
|
1581
|
-
addDebugMessage(`[fetchSearchPage] Calling API with viewer="${viewerLogin}", orgLogin="${
|
|
1613
|
+
const orgLogin = ownerContext !== "personal" ? ownerContext.login : void 0;
|
|
1614
|
+
addDebugMessage(`[fetchSearchPage] Calling API with viewer="${viewerLogin}", orgLogin="${orgLogin || "none"}", query="${query.trim()}"`);
|
|
1582
1615
|
const page = await searchRepositoriesUnified(
|
|
1583
1616
|
token,
|
|
1584
1617
|
viewerLogin,
|
|
@@ -1589,7 +1622,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1589
1622
|
orderBy.direction,
|
|
1590
1623
|
forkTracking,
|
|
1591
1624
|
policy ?? (after ? "network-only" : "cache-first"),
|
|
1592
|
-
|
|
1625
|
+
orgLogin
|
|
1593
1626
|
);
|
|
1594
1627
|
addDebugMessage(`[fetchSearchPage] API returned ${page.nodes.length} results, totalCount=${page.totalCount}`);
|
|
1595
1628
|
if (page.nodes.length > 0) {
|
|
@@ -1642,7 +1675,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1642
1675
|
if (ui.ownerContext) {
|
|
1643
1676
|
setOwnerContext(ui.ownerContext);
|
|
1644
1677
|
if (onOrgContextChange) {
|
|
1645
|
-
|
|
1678
|
+
handleOrgContextChangeRef.current?.(ui.ownerContext);
|
|
1646
1679
|
}
|
|
1647
1680
|
if (ui.ownerContext !== "personal") {
|
|
1648
1681
|
const client2 = makeClient(token);
|
|
@@ -1659,7 +1692,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1659
1692
|
useEffect7(() => {
|
|
1660
1693
|
if (!prefsLoaded) return;
|
|
1661
1694
|
let policy = "cache-first";
|
|
1662
|
-
const
|
|
1695
|
+
const orgLogin = ownerContext !== "personal" ? ownerContext.login : void 0;
|
|
1663
1696
|
try {
|
|
1664
1697
|
const key = makeApolloKey({
|
|
1665
1698
|
viewer: viewerLogin || "unknown",
|
|
@@ -1667,7 +1700,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1667
1700
|
sortDir,
|
|
1668
1701
|
pageSize: PAGE_SIZE,
|
|
1669
1702
|
forkTracking,
|
|
1670
|
-
ownerContext:
|
|
1703
|
+
ownerContext: orgLogin ? `org:${orgLogin}` : "personal",
|
|
1671
1704
|
affiliations: ownerAffiliations.join(",")
|
|
1672
1705
|
});
|
|
1673
1706
|
policy = isFresh(key) ? "cache-first" : "network-only";
|
|
@@ -1680,7 +1713,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1680
1713
|
if (!searchActive) {
|
|
1681
1714
|
if (items.length > 0) {
|
|
1682
1715
|
let policy = "cache-first";
|
|
1683
|
-
const
|
|
1716
|
+
const orgLogin = ownerContext !== "personal" ? ownerContext.login : void 0;
|
|
1684
1717
|
try {
|
|
1685
1718
|
const key = makeApolloKey({
|
|
1686
1719
|
viewer: viewerLogin || "unknown",
|
|
@@ -1688,7 +1721,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1688
1721
|
sortDir,
|
|
1689
1722
|
pageSize: PAGE_SIZE,
|
|
1690
1723
|
forkTracking,
|
|
1691
|
-
ownerContext:
|
|
1724
|
+
ownerContext: orgLogin ? `org:${orgLogin}` : "personal",
|
|
1692
1725
|
affiliations: ownerAffiliations.join(",")
|
|
1693
1726
|
});
|
|
1694
1727
|
policy = isFresh(key) ? "cache-first" : "network-only";
|
|
@@ -1720,7 +1753,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1720
1753
|
if (!searchActive) {
|
|
1721
1754
|
if (items.length > 0) {
|
|
1722
1755
|
let policy = "network-only";
|
|
1723
|
-
const
|
|
1756
|
+
const orgLogin = ownerContext !== "personal" ? ownerContext.login : void 0;
|
|
1724
1757
|
fetchPage(null, true, true, void 0, policy);
|
|
1725
1758
|
}
|
|
1726
1759
|
} else {
|
|
@@ -1736,6 +1769,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
|
|
|
1736
1769
|
if (viewerLogin && searchActive && !searchLoading && searchItems.length === 0) {
|
|
1737
1770
|
let policy = "cache-first";
|
|
1738
1771
|
try {
|
|
1772
|
+
const orgLogin = ownerContext !== "personal" ? ownerContext.login : void 0;
|
|
1739
1773
|
const key = makeSearchKey({
|
|
1740
1774
|
viewer: viewerLogin || "unknown",
|
|
1741
1775
|
q: filter.trim(),
|
|
@@ -2841,7 +2875,7 @@ function OAuthProgress({ status, error, deviceCode }) {
|
|
|
2841
2875
|
// src/ui/App.tsx
|
|
2842
2876
|
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2843
2877
|
var packageJson = require_package();
|
|
2844
|
-
function App() {
|
|
2878
|
+
function App({ initialOrgSlug: initialOrgSlug2, inlineToken: inlineToken2, inlineTokenEphemeral }) {
|
|
2845
2879
|
const { exit } = useApp2();
|
|
2846
2880
|
const { stdout } = useStdout2();
|
|
2847
2881
|
const [mode, setMode] = useState12("checking");
|
|
@@ -2855,6 +2889,7 @@ function App() {
|
|
|
2855
2889
|
const [authMethod, setAuthMethod] = useState12("pat");
|
|
2856
2890
|
const [oauthStatus, setOAuthStatus] = useState12("initializing");
|
|
2857
2891
|
const [tokenSource, setTokenSource] = useState12("pat");
|
|
2892
|
+
const [sessionTokenOrigin, setSessionTokenOrigin] = useState12("stored");
|
|
2858
2893
|
const [deviceCodeResponse, setDeviceCodeResponse] = useState12(null);
|
|
2859
2894
|
const [oauthDeviceCode, setOauthDeviceCode] = useState12(null);
|
|
2860
2895
|
const [dims, setDims] = useState12(() => {
|
|
@@ -2879,16 +2914,25 @@ function App() {
|
|
|
2879
2914
|
const stored = getStoredToken();
|
|
2880
2915
|
const source = getTokenSource();
|
|
2881
2916
|
setTokenSource(source);
|
|
2882
|
-
if (
|
|
2917
|
+
if (inlineToken2) {
|
|
2918
|
+
setToken(inlineToken2);
|
|
2919
|
+
setSessionTokenOrigin("cli");
|
|
2920
|
+
setTokenSource("pat");
|
|
2921
|
+
setMode("validating");
|
|
2922
|
+
} else if (env) {
|
|
2883
2923
|
setToken(env);
|
|
2924
|
+
setSessionTokenOrigin("env");
|
|
2925
|
+
setTokenSource("pat");
|
|
2884
2926
|
setMode("validating");
|
|
2885
2927
|
} else if (stored) {
|
|
2886
2928
|
setToken(stored);
|
|
2929
|
+
setSessionTokenOrigin("stored");
|
|
2887
2930
|
setMode("validating");
|
|
2888
2931
|
} else {
|
|
2932
|
+
setSessionTokenOrigin("prompt");
|
|
2889
2933
|
setMode("auth_method_selection");
|
|
2890
2934
|
}
|
|
2891
|
-
}, []);
|
|
2935
|
+
}, [inlineToken2]);
|
|
2892
2936
|
useEffect8(() => {
|
|
2893
2937
|
if (mode !== "oauth_flow") return;
|
|
2894
2938
|
(async () => {
|
|
@@ -2915,6 +2959,7 @@ function App() {
|
|
|
2915
2959
|
storeToken(tokenResult.token, "oauth");
|
|
2916
2960
|
setToken(tokenResult.token);
|
|
2917
2961
|
setTokenSource("oauth");
|
|
2962
|
+
setSessionTokenOrigin("oauth");
|
|
2918
2963
|
if (tokenResult.login) {
|
|
2919
2964
|
setViewer(tokenResult.login);
|
|
2920
2965
|
setOAuthStatus("success");
|
|
@@ -2953,16 +2998,18 @@ function App() {
|
|
|
2953
2998
|
const login = await getViewerLogin(client);
|
|
2954
2999
|
clearTimeout(timeoutId);
|
|
2955
3000
|
setViewer(login);
|
|
2956
|
-
logger.info("User authenticated successfully", {
|
|
2957
|
-
user: login,
|
|
2958
|
-
tokenSource,
|
|
2959
|
-
tokenStored: !getStoredToken()
|
|
2960
|
-
});
|
|
2961
3001
|
setWasRateLimited(false);
|
|
2962
3002
|
setRateLimitReset(null);
|
|
2963
|
-
|
|
3003
|
+
const hadStored = Boolean(getStoredToken());
|
|
3004
|
+
const shouldPersist = !hadStored && !inlineTokenEphemeral && (sessionTokenOrigin === "prompt" || sessionTokenOrigin === "oauth");
|
|
3005
|
+
if (shouldPersist) {
|
|
2964
3006
|
storeToken(token);
|
|
2965
3007
|
}
|
|
3008
|
+
logger.info("User authenticated successfully", {
|
|
3009
|
+
user: login,
|
|
3010
|
+
tokenOrigin: sessionTokenOrigin,
|
|
3011
|
+
willPersist: shouldPersist
|
|
3012
|
+
});
|
|
2966
3013
|
setInput("");
|
|
2967
3014
|
setMode("ready");
|
|
2968
3015
|
} catch (e) {
|
|
@@ -3015,7 +3062,12 @@ function App() {
|
|
|
3015
3062
|
setError(errorMessage);
|
|
3016
3063
|
setInput("");
|
|
3017
3064
|
setToken(null);
|
|
3018
|
-
|
|
3065
|
+
if (sessionTokenOrigin === "stored") {
|
|
3066
|
+
try {
|
|
3067
|
+
clearStoredToken();
|
|
3068
|
+
} catch {
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3019
3071
|
setMode("auth_method_selection");
|
|
3020
3072
|
}
|
|
3021
3073
|
}
|
|
@@ -3025,13 +3077,14 @@ function App() {
|
|
|
3025
3077
|
if (!input.trim()) return;
|
|
3026
3078
|
setToken(input.trim());
|
|
3027
3079
|
setTokenSource("pat");
|
|
3080
|
+
setSessionTokenOrigin("prompt");
|
|
3028
3081
|
setError(null);
|
|
3029
3082
|
setMode("validating");
|
|
3030
3083
|
};
|
|
3031
3084
|
const handleLogout = () => {
|
|
3032
3085
|
logger.info("User logged out", {
|
|
3033
3086
|
previousUser: viewer,
|
|
3034
|
-
|
|
3087
|
+
tokenOrigin: sessionTokenOrigin
|
|
3035
3088
|
});
|
|
3036
3089
|
try {
|
|
3037
3090
|
clearStoredToken();
|
|
@@ -3214,7 +3267,8 @@ function App() {
|
|
|
3214
3267
|
maxVisibleRows: dims.rows - verticalPadding * 2 - 4,
|
|
3215
3268
|
onLogout: handleLogout,
|
|
3216
3269
|
viewerLogin: viewer ?? void 0,
|
|
3217
|
-
onOrgContextChange: setOrgContext
|
|
3270
|
+
onOrgContextChange: setOrgContext,
|
|
3271
|
+
initialOrgSlug: initialOrgSlug2
|
|
3218
3272
|
}
|
|
3219
3273
|
)
|
|
3220
3274
|
] });
|
|
@@ -3223,6 +3277,31 @@ function App() {
|
|
|
3223
3277
|
// src/index.tsx
|
|
3224
3278
|
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3225
3279
|
var argv = process.argv.slice(2);
|
|
3280
|
+
var getFlagValue = (name) => {
|
|
3281
|
+
const idx = argv.findIndex((a) => a === `--${name}` || a.startsWith(`--${name}=`));
|
|
3282
|
+
if (idx === -1) return void 0;
|
|
3283
|
+
const at = argv[idx];
|
|
3284
|
+
if (at.includes("=")) {
|
|
3285
|
+
const [, v] = at.split("=");
|
|
3286
|
+
return v?.trim() || void 0;
|
|
3287
|
+
}
|
|
3288
|
+
const next = argv[idx + 1];
|
|
3289
|
+
if (next && !next.startsWith("-")) return next.trim();
|
|
3290
|
+
return void 0;
|
|
3291
|
+
};
|
|
3292
|
+
var getShortFlagValue = (short) => {
|
|
3293
|
+
const exact = `-${short}`;
|
|
3294
|
+
const idx = argv.findIndex((a) => a === exact || a.startsWith(`${exact}=`));
|
|
3295
|
+
if (idx === -1) return void 0;
|
|
3296
|
+
const at = argv[idx];
|
|
3297
|
+
if (at.includes("=")) {
|
|
3298
|
+
const [, v] = at.split("=");
|
|
3299
|
+
return v?.trim() || void 0;
|
|
3300
|
+
}
|
|
3301
|
+
const next = argv[idx + 1];
|
|
3302
|
+
if (next && !next.startsWith("-")) return next.trim();
|
|
3303
|
+
return void 0;
|
|
3304
|
+
};
|
|
3226
3305
|
if (argv.includes("--version") || argv.includes("-v")) {
|
|
3227
3306
|
const version = import_package.default?.version || "0.0.0";
|
|
3228
3307
|
process.stdout.write(`${version}
|
|
@@ -3234,9 +3313,11 @@ if (argv.includes("--help") || argv.includes("-h")) {
|
|
|
3234
3313
|
gh-manager-cli \u2014 GitHub repo manager (Ink TUI)
|
|
3235
3314
|
|
|
3236
3315
|
Usage:
|
|
3237
|
-
gh-manager-cli
|
|
3238
|
-
gh-manager-cli --
|
|
3239
|
-
gh-manager-cli --
|
|
3316
|
+
gh-manager-cli Launch the TUI
|
|
3317
|
+
gh-manager-cli --org, -o <slug> Start in an organisation context (if accessible)
|
|
3318
|
+
gh-manager-cli --token, -t <pat> Use a token just for this run (not persisted)
|
|
3319
|
+
gh-manager-cli --version Print version
|
|
3320
|
+
gh-manager-cli --help Show help
|
|
3240
3321
|
|
|
3241
3322
|
Env:
|
|
3242
3323
|
GITHUB_TOKEN / GH_TOKEN Personal Access Token
|
|
@@ -3277,10 +3358,20 @@ process.on("unhandledRejection", (reason) => {
|
|
|
3277
3358
|
console.error("Unhandled rejection:", reason?.message || reason);
|
|
3278
3359
|
process.exit(1);
|
|
3279
3360
|
});
|
|
3361
|
+
var initialOrgSlug = (() => {
|
|
3362
|
+
const v = getFlagValue("org") ?? getShortFlagValue("o");
|
|
3363
|
+
if (!v) return void 0;
|
|
3364
|
+
return v.replace(/^@/, "");
|
|
3365
|
+
})();
|
|
3366
|
+
var inlineToken = (() => {
|
|
3367
|
+
const v = getFlagValue("token") ?? getShortFlagValue("t");
|
|
3368
|
+
if (!v) return void 0;
|
|
3369
|
+
return v.trim();
|
|
3370
|
+
})();
|
|
3280
3371
|
logger.debug("Rendering UI");
|
|
3281
3372
|
var { unmount } = render(
|
|
3282
3373
|
/* @__PURE__ */ jsxs17(Box17, { flexDirection: "column", children: [
|
|
3283
|
-
/* @__PURE__ */ jsx18(App, {}),
|
|
3374
|
+
/* @__PURE__ */ jsx18(App, { initialOrgSlug, inlineToken, inlineTokenEphemeral: Boolean(inlineToken) }),
|
|
3284
3375
|
/* @__PURE__ */ jsx18(Text18, { color: "gray" })
|
|
3285
3376
|
] })
|
|
3286
3377
|
);
|