@bretwardjames/ghp-cli 0.1.2 → 0.1.3
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/branch-linker.d.ts +31 -9
- package/dist/branch-linker.d.ts.map +1 -1
- package/dist/branch-linker.js +61 -35
- package/dist/branch-linker.js.map +1 -1
- package/dist/git-utils.d.ts +6 -52
- package/dist/git-utils.d.ts.map +1 -1
- package/dist/git-utils.js +7 -137
- package/dist/git-utils.js.map +1 -1
- package/dist/github-api.d.ts +17 -146
- package/dist/github-api.d.ts.map +1 -1
- package/dist/github-api.js +48 -864
- package/dist/github-api.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +6 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/branch-linker.d.ts
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CLI-specific branch linker with file-based storage.
|
|
3
|
+
*
|
|
4
|
+
* This module wraps the core BranchLinker with a file-based StorageAdapter
|
|
5
|
+
* that stores links in ~/.config/ghp-cli/branch-links.json
|
|
6
|
+
*/
|
|
7
|
+
import { BranchLinker, type StorageAdapter, type BranchLink } from '@bretwardjames/ghp-core';
|
|
8
|
+
/**
|
|
9
|
+
* File-based storage adapter for CLI usage
|
|
10
|
+
*/
|
|
11
|
+
declare const fileStorageAdapter: StorageAdapter;
|
|
12
|
+
declare const linker: BranchLinker;
|
|
13
|
+
/**
|
|
14
|
+
* Create a link between a branch and an issue.
|
|
15
|
+
* Backwards-compatible function signature for existing CLI code.
|
|
16
|
+
*/
|
|
9
17
|
export declare function linkBranch(branch: string, issueNumber: number, issueTitle: string, itemId: string, repo: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Remove the link for an issue.
|
|
20
|
+
* @returns true if a link was removed, false if no link existed
|
|
21
|
+
*/
|
|
10
22
|
export declare function unlinkBranch(repo: string, issueNumber: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Get the branch linked to an issue.
|
|
25
|
+
*/
|
|
11
26
|
export declare function getBranchForIssue(repo: string, issueNumber: number): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Get the full link info for a branch.
|
|
29
|
+
*/
|
|
12
30
|
export declare function getIssueForBranch(repo: string, branch: string): BranchLink | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get all links for a repository.
|
|
33
|
+
*/
|
|
13
34
|
export declare function getAllLinksForRepo(repo: string): BranchLink[];
|
|
14
|
-
export {};
|
|
35
|
+
export type { BranchLink } from '@bretwardjames/ghp-core';
|
|
36
|
+
export { linker, fileStorageAdapter };
|
|
15
37
|
//# sourceMappingURL=branch-linker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-linker.d.ts","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"branch-linker.d.ts","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EACH,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,UAAU,EAClB,MAAM,yBAAyB,CAAC;AAKjC;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,cAmBzB,CAAC;AAGF,QAAA,MAAM,MAAM,cAAuC,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,UAAU,CACtB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACb,IAAI,CAIN;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAcvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIlF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAGjF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAG7D;AAGD,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/branch-linker.js
CHANGED
|
@@ -1,60 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-specific branch linker with file-based storage.
|
|
3
|
+
*
|
|
4
|
+
* This module wraps the core BranchLinker with a file-based StorageAdapter
|
|
5
|
+
* that stores links in ~/.config/ghp-cli/branch-links.json
|
|
6
|
+
*/
|
|
1
7
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
2
8
|
import { homedir } from 'os';
|
|
3
9
|
import { join } from 'path';
|
|
10
|
+
import { BranchLinker, } from '@bretwardjames/ghp-core';
|
|
4
11
|
const DATA_DIR = join(homedir(), '.config', 'ghp-cli');
|
|
5
12
|
const LINKS_FILE = join(DATA_DIR, 'branch-links.json');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* File-based storage adapter for CLI usage
|
|
15
|
+
*/
|
|
16
|
+
const fileStorageAdapter = {
|
|
17
|
+
load() {
|
|
18
|
+
try {
|
|
19
|
+
if (existsSync(LINKS_FILE)) {
|
|
20
|
+
const data = readFileSync(LINKS_FILE, 'utf-8');
|
|
21
|
+
return JSON.parse(data);
|
|
22
|
+
}
|
|
11
23
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
+
catch {
|
|
25
|
+
// Ignore errors, return empty array
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
},
|
|
29
|
+
save(links) {
|
|
30
|
+
if (!existsSync(DATA_DIR)) {
|
|
31
|
+
mkdirSync(DATA_DIR, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
writeFileSync(LINKS_FILE, JSON.stringify(links, null, 2));
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
// Create singleton linker instance
|
|
37
|
+
const linker = new BranchLinker(fileStorageAdapter);
|
|
38
|
+
/**
|
|
39
|
+
* Create a link between a branch and an issue.
|
|
40
|
+
* Backwards-compatible function signature for existing CLI code.
|
|
41
|
+
*/
|
|
24
42
|
export function linkBranch(branch, issueNumber, issueTitle, itemId, repo) {
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
filtered.push({
|
|
29
|
-
branch,
|
|
30
|
-
issueNumber,
|
|
31
|
-
issueTitle,
|
|
32
|
-
itemId,
|
|
33
|
-
repo,
|
|
34
|
-
linkedAt: new Date().toISOString(),
|
|
35
|
-
});
|
|
36
|
-
saveLinks(filtered);
|
|
43
|
+
// Use sync-like behavior for backwards compatibility
|
|
44
|
+
// The file adapter is synchronous so this works
|
|
45
|
+
linker.link(branch, issueNumber, issueTitle, itemId, repo);
|
|
37
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Remove the link for an issue.
|
|
49
|
+
* @returns true if a link was removed, false if no link existed
|
|
50
|
+
*/
|
|
38
51
|
export function unlinkBranch(repo, issueNumber) {
|
|
39
|
-
|
|
52
|
+
// Load, filter, and save synchronously for backwards compatibility
|
|
53
|
+
const adapter = fileStorageAdapter;
|
|
54
|
+
const links = adapter.load();
|
|
40
55
|
const filtered = links.filter(l => !(l.repo === repo && l.issueNumber === issueNumber));
|
|
41
56
|
if (filtered.length === links.length) {
|
|
42
|
-
return false;
|
|
57
|
+
return false;
|
|
43
58
|
}
|
|
44
|
-
|
|
59
|
+
adapter.save(filtered);
|
|
45
60
|
return true;
|
|
46
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the branch linked to an issue.
|
|
64
|
+
*/
|
|
47
65
|
export function getBranchForIssue(repo, issueNumber) {
|
|
48
|
-
const links =
|
|
66
|
+
const links = fileStorageAdapter.load();
|
|
49
67
|
const link = links.find(l => l.repo === repo && l.issueNumber === issueNumber);
|
|
50
68
|
return link?.branch || null;
|
|
51
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the full link info for a branch.
|
|
72
|
+
*/
|
|
52
73
|
export function getIssueForBranch(repo, branch) {
|
|
53
|
-
const links =
|
|
74
|
+
const links = fileStorageAdapter.load();
|
|
54
75
|
return links.find(l => l.repo === repo && l.branch === branch) || null;
|
|
55
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Get all links for a repository.
|
|
79
|
+
*/
|
|
56
80
|
export function getAllLinksForRepo(repo) {
|
|
57
|
-
const links =
|
|
81
|
+
const links = fileStorageAdapter.load();
|
|
58
82
|
return links.filter(l => l.repo === repo);
|
|
59
83
|
}
|
|
84
|
+
// Also export the linker instance and adapter for advanced usage
|
|
85
|
+
export { linker, fileStorageAdapter };
|
|
60
86
|
//# sourceMappingURL=branch-linker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-linker.js","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"branch-linker.js","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AA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AAC,IAAI,IAAI,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,EAAkB,CAAC;IACxD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC9C,CAAC;AAKD,iEAAiE;AACjE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/git-utils.d.ts
CHANGED
|
@@ -1,55 +1,9 @@
|
|
|
1
|
-
import type { RepoInfo } from './types.js';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Git utilities re-exported from core library.
|
|
3
|
+
*
|
|
4
|
+
* For CLI usage, all functions use process.cwd() by default.
|
|
5
|
+
* The core library accepts an optional { cwd } parameter for IDE integrations.
|
|
4
6
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
* Parse a GitHub URL into owner and repo name
|
|
8
|
-
*/
|
|
9
|
-
export declare function parseGitHubUrl(url: string): RepoInfo | null;
|
|
10
|
-
/**
|
|
11
|
-
* Get the current git branch
|
|
12
|
-
*/
|
|
13
|
-
export declare function getCurrentBranch(): Promise<string | null>;
|
|
14
|
-
/**
|
|
15
|
-
* Check if there are uncommitted changes
|
|
16
|
-
*/
|
|
17
|
-
export declare function hasUncommittedChanges(): Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Check if a branch exists locally
|
|
20
|
-
*/
|
|
21
|
-
export declare function branchExists(branchName: string): Promise<boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* Create and checkout a new branch
|
|
24
|
-
*/
|
|
25
|
-
export declare function createBranch(branchName: string): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Checkout an existing branch
|
|
28
|
-
*/
|
|
29
|
-
export declare function checkoutBranch(branchName: string): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Pull latest from origin
|
|
32
|
-
*/
|
|
33
|
-
export declare function pullLatest(): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Fetch from origin
|
|
36
|
-
*/
|
|
37
|
-
export declare function fetchOrigin(): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Get number of commits behind origin
|
|
40
|
-
*/
|
|
41
|
-
export declare function getCommitsBehind(branch: string): Promise<number>;
|
|
42
|
-
/**
|
|
43
|
-
* Sanitize a string for use in a branch name
|
|
44
|
-
*/
|
|
45
|
-
export declare function sanitizeForBranchName(str: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* Generate a branch name from a pattern
|
|
48
|
-
*/
|
|
49
|
-
export declare function generateBranchName(pattern: string, vars: {
|
|
50
|
-
user: string;
|
|
51
|
-
number: number | null;
|
|
52
|
-
title: string;
|
|
53
|
-
repo: string;
|
|
54
|
-
}, maxLength?: number): string;
|
|
7
|
+
export { detectRepository, getCurrentBranch, hasUncommittedChanges, branchExists, createBranch, checkoutBranch, pullLatest, fetchOrigin, getCommitsBehind, getCommitsAhead, isGitRepository, getRepositoryRoot, sanitizeForBranchName, generateBranchName, getDefaultBranch, parseGitHubUrl, } from '@bretwardjames/ghp-core';
|
|
8
|
+
export type { RepoInfo, GitOptions } from '@bretwardjames/ghp-core';
|
|
55
9
|
//# sourceMappingURL=git-utils.d.ts.map
|
package/dist/git-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACjB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/git-utils.js
CHANGED
|
@@ -1,140 +1,10 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
const execAsync = promisify(exec);
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
2
|
+
* Git utilities re-exported from core library.
|
|
3
|
+
*
|
|
4
|
+
* For CLI usage, all functions use process.cwd() by default.
|
|
5
|
+
* The core library accepts an optional { cwd } parameter for IDE integrations.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const url = stdout.trim();
|
|
11
|
-
return parseGitHubUrl(url);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Parse a GitHub URL into owner and repo name
|
|
19
|
-
*/
|
|
20
|
-
export function parseGitHubUrl(url) {
|
|
21
|
-
// Handle SSH format: git@github.com:owner/repo.git
|
|
22
|
-
const sshMatch = url.match(/git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
|
|
23
|
-
if (sshMatch) {
|
|
24
|
-
return {
|
|
25
|
-
owner: sshMatch[1],
|
|
26
|
-
name: sshMatch[2],
|
|
27
|
-
fullName: `${sshMatch[1]}/${sshMatch[2]}`,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// Handle HTTPS format: https://github.com/owner/repo.git
|
|
31
|
-
const httpsMatch = url.match(/https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/);
|
|
32
|
-
if (httpsMatch) {
|
|
33
|
-
return {
|
|
34
|
-
owner: httpsMatch[1],
|
|
35
|
-
name: httpsMatch[2],
|
|
36
|
-
fullName: `${httpsMatch[1]}/${httpsMatch[2]}`,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get the current git branch
|
|
43
|
-
*/
|
|
44
|
-
export async function getCurrentBranch() {
|
|
45
|
-
try {
|
|
46
|
-
const { stdout } = await execAsync('git branch --show-current');
|
|
47
|
-
return stdout.trim() || null;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Check if there are uncommitted changes
|
|
55
|
-
*/
|
|
56
|
-
export async function hasUncommittedChanges() {
|
|
57
|
-
try {
|
|
58
|
-
const { stdout } = await execAsync('git status --porcelain');
|
|
59
|
-
return stdout.trim().length > 0;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Check if a branch exists locally
|
|
67
|
-
*/
|
|
68
|
-
export async function branchExists(branchName) {
|
|
69
|
-
try {
|
|
70
|
-
await execAsync(`git show-ref --verify --quiet refs/heads/${branchName}`);
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Create and checkout a new branch
|
|
79
|
-
*/
|
|
80
|
-
export async function createBranch(branchName) {
|
|
81
|
-
await execAsync(`git checkout -b "${branchName}"`);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Checkout an existing branch
|
|
85
|
-
*/
|
|
86
|
-
export async function checkoutBranch(branchName) {
|
|
87
|
-
await execAsync(`git checkout "${branchName}"`);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Pull latest from origin
|
|
91
|
-
*/
|
|
92
|
-
export async function pullLatest() {
|
|
93
|
-
await execAsync('git pull');
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Fetch from origin
|
|
97
|
-
*/
|
|
98
|
-
export async function fetchOrigin() {
|
|
99
|
-
await execAsync('git fetch origin');
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get number of commits behind origin
|
|
103
|
-
*/
|
|
104
|
-
export async function getCommitsBehind(branch) {
|
|
105
|
-
try {
|
|
106
|
-
await fetchOrigin();
|
|
107
|
-
const { stdout } = await execAsync(`git rev-list --count ${branch}..origin/${branch}`);
|
|
108
|
-
return parseInt(stdout.trim(), 10) || 0;
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
return 0;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Sanitize a string for use in a branch name
|
|
116
|
-
*/
|
|
117
|
-
export function sanitizeForBranchName(str) {
|
|
118
|
-
return str
|
|
119
|
-
.toLowerCase()
|
|
120
|
-
.replace(/[^a-z0-9-]/g, '-')
|
|
121
|
-
.replace(/-+/g, '-')
|
|
122
|
-
.replace(/^-|-$/g, '')
|
|
123
|
-
.substring(0, 50);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Generate a branch name from a pattern
|
|
127
|
-
*/
|
|
128
|
-
export function generateBranchName(pattern, vars, maxLength = 60) {
|
|
129
|
-
const sanitizedTitle = sanitizeForBranchName(vars.title);
|
|
130
|
-
let branch = pattern
|
|
131
|
-
.replace('{user}', vars.user)
|
|
132
|
-
.replace('{number}', vars.number?.toString() || 'draft')
|
|
133
|
-
.replace('{title}', sanitizedTitle)
|
|
134
|
-
.replace('{repo}', vars.repo);
|
|
135
|
-
if (branch.length > maxLength) {
|
|
136
|
-
branch = branch.substring(0, maxLength).replace(/-$/, '');
|
|
137
|
-
}
|
|
138
|
-
return branch;
|
|
139
|
-
}
|
|
7
|
+
// Re-export all git utilities from core
|
|
8
|
+
// These all use process.cwd() by default, which is correct for CLI usage
|
|
9
|
+
export { detectRepository, getCurrentBranch, hasUncommittedChanges, branchExists, createBranch, checkoutBranch, pullLatest, fetchOrigin, getCommitsBehind, getCommitsAhead, isGitRepository, getRepositoryRoot, sanitizeForBranchName, generateBranchName, getDefaultBranch, parseGitHubUrl, } from '@bretwardjames/ghp-core';
|
|
140
10
|
//# sourceMappingURL=git-utils.js.map
|
package/dist/git-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-utils.js","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"git-utils.js","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wCAAwC;AACxC,yEAAyE;AACzE,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACjB,MAAM,yBAAyB,CAAC"}
|
package/dist/github-api.d.ts
CHANGED
|
@@ -1,148 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Get projects linked to a repository
|
|
16
|
-
*/
|
|
17
|
-
getProjects(repo: RepoInfo): Promise<Project[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Get items from a project
|
|
20
|
-
*/
|
|
21
|
-
getProjectItems(projectId: string, projectTitle: string): Promise<ProjectItem[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Get the Status field info for a project
|
|
24
|
-
*/
|
|
25
|
-
getStatusField(projectId: string): Promise<StatusField | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Get project views
|
|
28
|
-
*/
|
|
29
|
-
getProjectViews(projectId: string): Promise<Array<{
|
|
30
|
-
name: string;
|
|
31
|
-
filter: string | null;
|
|
32
|
-
}>>;
|
|
33
|
-
/**
|
|
34
|
-
* Update an item's status
|
|
35
|
-
*/
|
|
36
|
-
updateItemStatus(projectId: string, itemId: string, fieldId: string, optionId: string): Promise<boolean>;
|
|
37
|
-
/**
|
|
38
|
-
* Find an item by issue number across all projects for this repo
|
|
39
|
-
*/
|
|
40
|
-
findItemByNumber(repo: RepoInfo, issueNumber: number): Promise<ProjectItem | null>;
|
|
41
|
-
/**
|
|
42
|
-
* Get all fields for a project
|
|
43
|
-
*/
|
|
44
|
-
getProjectFields(projectId: string): Promise<Array<{
|
|
45
|
-
id: string;
|
|
46
|
-
name: string;
|
|
47
|
-
type: string;
|
|
48
|
-
options?: Array<{
|
|
49
|
-
id: string;
|
|
50
|
-
name: string;
|
|
51
|
-
}>;
|
|
52
|
-
}>>;
|
|
53
|
-
/**
|
|
54
|
-
* Set a field value on a project item
|
|
55
|
-
*/
|
|
56
|
-
setFieldValue(projectId: string, itemId: string, fieldId: string, value: {
|
|
57
|
-
text?: string;
|
|
58
|
-
number?: number;
|
|
59
|
-
singleSelectOptionId?: string;
|
|
60
|
-
}): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* Create a new issue
|
|
63
|
-
*/
|
|
64
|
-
createIssue(repo: RepoInfo, title: string, body?: string): Promise<{
|
|
65
|
-
id: string;
|
|
66
|
-
number: number;
|
|
67
|
-
} | null>;
|
|
68
|
-
/**
|
|
69
|
-
* Add an issue to a project
|
|
70
|
-
*/
|
|
71
|
-
addToProject(projectId: string, contentId: string): Promise<string | null>;
|
|
72
|
-
/**
|
|
73
|
-
* Get full issue details including body and comments
|
|
74
|
-
*/
|
|
75
|
-
getIssueDetails(repo: RepoInfo, issueNumber: number): Promise<IssueDetails | null>;
|
|
76
|
-
/**
|
|
77
|
-
* Add a comment to an issue or PR
|
|
78
|
-
*/
|
|
79
|
-
addComment(repo: RepoInfo, issueNumber: number, body: string): Promise<boolean>;
|
|
80
|
-
/**
|
|
81
|
-
* Get repository collaborators (for @ mention suggestions)
|
|
82
|
-
*/
|
|
83
|
-
getCollaborators(repo: RepoInfo): Promise<Collaborator[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Get recent issues (for # reference suggestions)
|
|
86
|
-
*/
|
|
87
|
-
getRecentIssues(repo: RepoInfo, limit?: number): Promise<IssueReference[]>;
|
|
88
|
-
/**
|
|
89
|
-
* Get the active label name for a user
|
|
90
|
-
*/
|
|
91
|
-
getActiveLabelName(): string;
|
|
92
|
-
/**
|
|
93
|
-
* Ensure a label exists in the repository, create if it doesn't
|
|
94
|
-
*/
|
|
95
|
-
ensureLabel(repo: RepoInfo, labelName: string, color?: string): Promise<boolean>;
|
|
96
|
-
/**
|
|
97
|
-
* Add a label to an issue
|
|
98
|
-
*/
|
|
99
|
-
addLabelToIssue(repo: RepoInfo, issueNumber: number, labelName: string): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* Remove a label from an issue
|
|
102
|
-
*/
|
|
103
|
-
removeLabelFromIssue(repo: RepoInfo, issueNumber: number, labelName: string): Promise<boolean>;
|
|
104
|
-
/**
|
|
105
|
-
* Find all issues with a specific label
|
|
106
|
-
*/
|
|
107
|
-
findIssuesWithLabel(repo: RepoInfo, labelName: string): Promise<number[]>;
|
|
108
|
-
/**
|
|
109
|
-
* Get available issue types for a repository
|
|
110
|
-
*/
|
|
111
|
-
getIssueTypes(repo: RepoInfo): Promise<Array<{
|
|
112
|
-
id: string;
|
|
113
|
-
name: string;
|
|
114
|
-
}>>;
|
|
115
|
-
/**
|
|
116
|
-
* Set the issue type on an issue
|
|
117
|
-
*/
|
|
118
|
-
setIssueType(repo: RepoInfo, issueNumber: number, issueTypeId: string): Promise<boolean>;
|
|
1
|
+
/**
|
|
2
|
+
* CLI-specific GitHub API wrapper.
|
|
3
|
+
*
|
|
4
|
+
* This module wraps the core GitHubAPI class with CLI-specific behavior:
|
|
5
|
+
* - Token from `gh auth token` or environment variables
|
|
6
|
+
* - Chalk-colored error messages
|
|
7
|
+
* - process.exit on auth errors
|
|
8
|
+
*/
|
|
9
|
+
import { GitHubAPI as CoreGitHubAPI } from '@bretwardjames/ghp-core';
|
|
10
|
+
/**
|
|
11
|
+
* Extended GitHubAPI class for CLI with pre-configured token provider
|
|
12
|
+
*/
|
|
13
|
+
declare class CLIGitHubAPI extends CoreGitHubAPI {
|
|
14
|
+
constructor();
|
|
119
15
|
}
|
|
120
|
-
export
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
state: string;
|
|
124
|
-
type: 'issue' | 'pull_request';
|
|
125
|
-
createdAt: string;
|
|
126
|
-
author: string;
|
|
127
|
-
labels: Array<{
|
|
128
|
-
name: string;
|
|
129
|
-
color: string;
|
|
130
|
-
}>;
|
|
131
|
-
comments: Array<{
|
|
132
|
-
author: string;
|
|
133
|
-
body: string;
|
|
134
|
-
createdAt: string;
|
|
135
|
-
}>;
|
|
136
|
-
totalComments: number;
|
|
137
|
-
}
|
|
138
|
-
export interface Collaborator {
|
|
139
|
-
login: string;
|
|
140
|
-
name: string | null;
|
|
141
|
-
}
|
|
142
|
-
export interface IssueReference {
|
|
143
|
-
number: number;
|
|
144
|
-
title: string;
|
|
145
|
-
state: string;
|
|
146
|
-
}
|
|
147
|
-
export declare const api: GitHubAPI;
|
|
16
|
+
export type { RepoInfo, Project, ProjectItem, StatusField, IssueDetails, Collaborator, IssueReference, } from '@bretwardjames/ghp-core';
|
|
17
|
+
export declare const api: CLIGitHubAPI;
|
|
18
|
+
export { CLIGitHubAPI as GitHubAPI };
|
|
148
19
|
//# sourceMappingURL=github-api.d.ts.map
|
package/dist/github-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-api.d.ts","sourceRoot":"","sources":["../src/github-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-api.d.ts","sourceRoot":"","sources":["../src/github-api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EACH,SAAS,IAAI,aAAa,EAG7B,MAAM,yBAAyB,CAAC;AAgDjC;;GAEG;AACH,cAAM,YAAa,SAAQ,aAAa;;CAOvC;AAGD,YAAY,EACR,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,GACjB,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,GAAG,cAAqB,CAAC;AAGtC,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,CAAC"}
|