@oh-gc/cli 0.4.4 → 0.5.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/README.md +19 -0
- package/dist/api/client.js +8 -1
- package/dist/api/client.js.map +1 -1
- package/dist/api/prs.d.ts +101 -0
- package/dist/api/prs.js +107 -0
- package/dist/api/prs.js.map +1 -1
- package/dist/commands/pr/comments.d.ts +18 -0
- package/dist/commands/pr/comments.js +72 -0
- package/dist/commands/pr/comments.js.map +1 -0
- package/dist/commands/pr/commits.d.ts +16 -0
- package/dist/commands/pr/commits.js +59 -0
- package/dist/commands/pr/commits.js.map +1 -0
- package/dist/commands/pr/diff.d.ts +19 -0
- package/dist/commands/pr/diff.js +110 -0
- package/dist/commands/pr/diff.js.map +1 -0
- package/dist/commands/pr/labels.d.ts +17 -0
- package/dist/commands/pr/labels.js +71 -0
- package/dist/commands/pr/labels.js.map +1 -0
- package/dist/commands/pr/link.d.ts +17 -0
- package/dist/commands/pr/link.js +64 -0
- package/dist/commands/pr/link.js.map +1 -0
- package/dist/commands/pr/logs.d.ts +16 -0
- package/dist/commands/pr/logs.js +59 -0
- package/dist/commands/pr/logs.js.map +1 -0
- package/dist/commands/pr/review.d.ts +16 -0
- package/dist/commands/pr/review.js +56 -0
- package/dist/commands/pr/review.js.map +1 -0
- package/dist/commands/pr/reviewers.d.ts +18 -0
- package/dist/commands/pr/reviewers.js +71 -0
- package/dist/commands/pr/reviewers.js.map +1 -0
- package/dist/commands/pr/test.d.ts +16 -0
- package/dist/commands/pr/test.js +56 -0
- package/dist/commands/pr/test.js.map +1 -0
- package/dist/commands/pr/testers.d.ts +18 -0
- package/dist/commands/pr/testers.js +71 -0
- package/dist/commands/pr/testers.js.map +1 -0
- package/dist/commands/pr/update.d.ts +20 -0
- package/dist/commands/pr/update.js +67 -0
- package/dist/commands/pr/update.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,9 @@ oh-gc repo:set-remote upstream
|
|
|
96
96
|
| `oh-gc pr:list --author alice` | Filter by author |
|
|
97
97
|
| `oh-gc pr:list --reviewer bob` | Filter by reviewer |
|
|
98
98
|
| `oh-gc pr:view <number>` | Show PR detail |
|
|
99
|
+
| `oh-gc pr:diff <number>` | View changes in a PR |
|
|
100
|
+
| `oh-gc pr:diff <number> --name-only` | Show only changed file names |
|
|
101
|
+
| `oh-gc pr:diff <number> --json` | Output raw JSON |
|
|
99
102
|
| `oh-gc pr:create` | Create PR interactively |
|
|
100
103
|
| `oh-gc pr:create --title "..." --base main` | Create PR with flags |
|
|
101
104
|
| `oh-gc pr:create --repo owner/repo --head feature` | Create cross-repo PR |
|
|
@@ -103,9 +106,25 @@ oh-gc repo:set-remote upstream
|
|
|
103
106
|
| `oh-gc pr:comment <number> --body "..."` | Add a comment with a flag |
|
|
104
107
|
| `oh-gc pr:comment <number> --repo owner/repo --body "..."` | Add comment on different repo |
|
|
105
108
|
| `oh-gc pr:comment <number> --body "..." --path file.ts --line 10` | Comment on specific line |
|
|
109
|
+
| `oh-gc pr:update <number> --title "..."` | Update PR title, body, or state |
|
|
110
|
+
| `oh-gc pr:update <number> --state closed` | Close a PR |
|
|
106
111
|
| `oh-gc pr:merge <number>` | Merge PR (default: merge commit) |
|
|
107
112
|
| `oh-gc pr:merge <number> --method squash` | Squash merge |
|
|
108
113
|
| `oh-gc pr:merge <number> --method rebase` | Rebase merge |
|
|
114
|
+
| `oh-gc pr:commits <number>` | List commits in a PR |
|
|
115
|
+
| `oh-gc pr:comments <number>` | List comments on a PR |
|
|
116
|
+
| `oh-gc pr:comments <number> --delete <id>` | Delete a PR comment |
|
|
117
|
+
| `oh-gc pr:reviewers <number> alice,bob` | Assign reviewers |
|
|
118
|
+
| `oh-gc pr:reviewers <number> alice --remove` | Remove a reviewer |
|
|
119
|
+
| `oh-gc pr:testers <number> alice,bob` | Assign testers |
|
|
120
|
+
| `oh-gc pr:testers <number> alice --remove` | Remove a tester |
|
|
121
|
+
| `oh-gc pr:review <number>` | Approve a PR review |
|
|
122
|
+
| `oh-gc pr:test <number>` | Mark PR test as passed |
|
|
123
|
+
| `oh-gc pr:labels <number> bug,feature` | Add labels to a PR |
|
|
124
|
+
| `oh-gc pr:labels <number> bug --remove` | Remove a label |
|
|
125
|
+
| `oh-gc pr:link <number> 1,2` | Link issues to a PR |
|
|
126
|
+
| `oh-gc pr:link <number> 1,2 --remove` | Unlink issues |
|
|
127
|
+
| `oh-gc pr:logs <number>` | Show PR operation logs |
|
|
109
128
|
|
|
110
129
|
### Release
|
|
111
130
|
|
package/dist/api/client.js
CHANGED
|
@@ -47,8 +47,15 @@ async function apiRequest(path, token, options = {}) {
|
|
|
47
47
|
const text = await response.text();
|
|
48
48
|
throw new GitCodeError(response.status, `API error ${response.status}: ${text}`);
|
|
49
49
|
}
|
|
50
|
+
if (response.status === 204) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const text = await response.text();
|
|
54
|
+
if (!text) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
50
57
|
try {
|
|
51
|
-
return
|
|
58
|
+
return JSON.parse(text);
|
|
52
59
|
}
|
|
53
60
|
catch {
|
|
54
61
|
throw new GitCodeError(response.status, `API error ${response.status}: invalid JSON response`);
|
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;AASA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;AASA,gCAiEC;AA1ED,MAAM,QAAQ,GAAG,gCAAgC,CAAA;AAEjD,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAmB,UAAkB,EAAE,OAAe;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QADG,eAAU,GAAV,UAAU,CAAQ;QAEnC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAA;IAC5B,CAAC;CAC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AQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACrC,MAAM,IAAI,YAAY,CAAC,GAAG,EAAE,yCAAyC,CAAC,CAAA;IACxE,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,OAAO,SAAc,CAAA;IACvB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAc,CAAA;IACvB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,QAAQ,CAAC,MAAM,yBAAyB,CAAC,CAAA;IAChG,CAAC;AACH,CAAC"}
|
package/dist/api/prs.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare function mergePR(token: string, owner: string, repo: string, numb
|
|
|
64
64
|
}): Promise<MergeResult>;
|
|
65
65
|
export interface PRComment {
|
|
66
66
|
id: string;
|
|
67
|
+
note_id: number;
|
|
67
68
|
body: string;
|
|
68
69
|
html_url?: string;
|
|
69
70
|
user?: {
|
|
@@ -76,3 +77,103 @@ export declare function commentPR(token: string, owner: string, repo: string, nu
|
|
|
76
77
|
path?: string;
|
|
77
78
|
position?: number;
|
|
78
79
|
}): Promise<PRComment>;
|
|
80
|
+
export interface PRFile {
|
|
81
|
+
sha: string;
|
|
82
|
+
filename: string;
|
|
83
|
+
status: string;
|
|
84
|
+
additions: number;
|
|
85
|
+
deletions: number;
|
|
86
|
+
changes?: number;
|
|
87
|
+
blob_url: string;
|
|
88
|
+
raw_url: string;
|
|
89
|
+
patch?: {
|
|
90
|
+
diff: string;
|
|
91
|
+
old_path: string;
|
|
92
|
+
new_path: string;
|
|
93
|
+
a_mode: string;
|
|
94
|
+
b_mode: string;
|
|
95
|
+
new_file: boolean;
|
|
96
|
+
renamed_file: boolean;
|
|
97
|
+
deleted_file: boolean;
|
|
98
|
+
too_large: boolean;
|
|
99
|
+
added_lines: number;
|
|
100
|
+
removed_lines: number;
|
|
101
|
+
};
|
|
102
|
+
too_large?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export declare function getPRFiles(token: string, owner: string, repo: string, number: number): Promise<PRFile[]>;
|
|
105
|
+
export interface UpdatePRParams {
|
|
106
|
+
title?: string;
|
|
107
|
+
body?: string;
|
|
108
|
+
state?: string;
|
|
109
|
+
labels?: string;
|
|
110
|
+
draft?: boolean;
|
|
111
|
+
milestone_number?: number;
|
|
112
|
+
}
|
|
113
|
+
export declare function updatePR(token: string, owner: string, repo: string, number: number, params: UpdatePRParams): Promise<PR>;
|
|
114
|
+
export interface PRCommit {
|
|
115
|
+
sha: string;
|
|
116
|
+
html_url: string;
|
|
117
|
+
commit: {
|
|
118
|
+
author: {
|
|
119
|
+
login?: string;
|
|
120
|
+
name: string;
|
|
121
|
+
email: string;
|
|
122
|
+
date: string;
|
|
123
|
+
};
|
|
124
|
+
message: string;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export declare function listPRCommits(token: string, owner: string, repo: string, number: number, params?: {
|
|
128
|
+
page?: number;
|
|
129
|
+
per_page?: number;
|
|
130
|
+
}): Promise<PRCommit[]>;
|
|
131
|
+
export declare function listPRComments(token: string, owner: string, repo: string, number: number, params?: {
|
|
132
|
+
page?: number;
|
|
133
|
+
per_page?: number;
|
|
134
|
+
direction?: string;
|
|
135
|
+
comment_type?: string;
|
|
136
|
+
}): Promise<PRComment[]>;
|
|
137
|
+
export declare function deletePRComment(token: string, owner: string, repo: string, noteId: number): Promise<void>;
|
|
138
|
+
export interface PRUser {
|
|
139
|
+
id: number;
|
|
140
|
+
login: string;
|
|
141
|
+
name: string;
|
|
142
|
+
avatar_url?: string;
|
|
143
|
+
}
|
|
144
|
+
export declare function assignReviewers(token: string, owner: string, repo: string, number: number, reviewers: string, append?: boolean): Promise<PRUser[]>;
|
|
145
|
+
export declare function removeReviewers(token: string, owner: string, repo: string, number: number, reviewers: string): Promise<PRUser[]>;
|
|
146
|
+
export declare function assignTesters(token: string, owner: string, repo: string, number: number, testers: string, append?: boolean): Promise<PRUser[]>;
|
|
147
|
+
export declare function removeTesters(token: string, owner: string, repo: string, number: number, testers: string): Promise<PRUser[]>;
|
|
148
|
+
export declare function submitReview(token: string, owner: string, repo: string, number: number, force?: boolean): Promise<unknown>;
|
|
149
|
+
export declare function submitTest(token: string, owner: string, repo: string, number: number, force?: boolean): Promise<unknown>;
|
|
150
|
+
export interface PRLabel {
|
|
151
|
+
id: number;
|
|
152
|
+
name: string;
|
|
153
|
+
color: string;
|
|
154
|
+
}
|
|
155
|
+
export declare function addPRLabels(token: string, owner: string, repo: string, number: number, labels: string[]): Promise<PRLabel[]>;
|
|
156
|
+
export declare function removePRLabel(token: string, owner: string, repo: string, number: number, names: string): Promise<void>;
|
|
157
|
+
export interface LinkedIssue {
|
|
158
|
+
id?: number;
|
|
159
|
+
number: string | number;
|
|
160
|
+
title: string;
|
|
161
|
+
state?: string;
|
|
162
|
+
}
|
|
163
|
+
export declare function linkIssues(token: string, owner: string, repo: string, number: number, issues: number[]): Promise<LinkedIssue[]>;
|
|
164
|
+
export declare function unlinkIssues(token: string, owner: string, repo: string, number: number, issues: number[]): Promise<LinkedIssue[]>;
|
|
165
|
+
export interface PROperateLog {
|
|
166
|
+
id: number;
|
|
167
|
+
action: string;
|
|
168
|
+
content: string;
|
|
169
|
+
created_at: string;
|
|
170
|
+
user: {
|
|
171
|
+
login: string;
|
|
172
|
+
name: string;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export declare function listPROperateLogs(token: string, owner: string, repo: string, number: number, params?: {
|
|
176
|
+
page?: number;
|
|
177
|
+
per_page?: number;
|
|
178
|
+
sort?: string;
|
|
179
|
+
}): Promise<PROperateLog[]>;
|
package/dist/api/prs.js
CHANGED
|
@@ -5,6 +5,22 @@ exports.getPR = getPR;
|
|
|
5
5
|
exports.createPR = createPR;
|
|
6
6
|
exports.mergePR = mergePR;
|
|
7
7
|
exports.commentPR = commentPR;
|
|
8
|
+
exports.getPRFiles = getPRFiles;
|
|
9
|
+
exports.updatePR = updatePR;
|
|
10
|
+
exports.listPRCommits = listPRCommits;
|
|
11
|
+
exports.listPRComments = listPRComments;
|
|
12
|
+
exports.deletePRComment = deletePRComment;
|
|
13
|
+
exports.assignReviewers = assignReviewers;
|
|
14
|
+
exports.removeReviewers = removeReviewers;
|
|
15
|
+
exports.assignTesters = assignTesters;
|
|
16
|
+
exports.removeTesters = removeTesters;
|
|
17
|
+
exports.submitReview = submitReview;
|
|
18
|
+
exports.submitTest = submitTest;
|
|
19
|
+
exports.addPRLabels = addPRLabels;
|
|
20
|
+
exports.removePRLabel = removePRLabel;
|
|
21
|
+
exports.linkIssues = linkIssues;
|
|
22
|
+
exports.unlinkIssues = unlinkIssues;
|
|
23
|
+
exports.listPROperateLogs = listPROperateLogs;
|
|
8
24
|
const client_1 = require("./client");
|
|
9
25
|
async function listPRs(token, owner, repo, params = {}) {
|
|
10
26
|
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls`, token, {
|
|
@@ -31,4 +47,95 @@ async function commentPR(token, owner, repo, number, body, options) {
|
|
|
31
47
|
requestBody.position = options.position;
|
|
32
48
|
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/comments`, token, { method: 'POST', body: requestBody });
|
|
33
49
|
}
|
|
50
|
+
async function getPRFiles(token, owner, repo, number) {
|
|
51
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/files`, token);
|
|
52
|
+
}
|
|
53
|
+
async function updatePR(token, owner, repo, number, params) {
|
|
54
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}`, token, {
|
|
55
|
+
method: 'PATCH',
|
|
56
|
+
body: params,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async function listPRCommits(token, owner, repo, number, params = {}) {
|
|
60
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/commits`, token, {
|
|
61
|
+
query: params,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// --- PR Comments (list / delete) ---
|
|
65
|
+
async function listPRComments(token, owner, repo, number, params = {}) {
|
|
66
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/comments`, token, {
|
|
67
|
+
query: params,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function deletePRComment(token, owner, repo, noteId) {
|
|
71
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/comments/${noteId}`, token, {
|
|
72
|
+
method: 'DELETE',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async function assignReviewers(token, owner, repo, number, reviewers, append = false) {
|
|
76
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/reviewers`, token, {
|
|
77
|
+
method: 'POST',
|
|
78
|
+
body: { reviewers, add: append },
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async function removeReviewers(token, owner, repo, number, reviewers) {
|
|
82
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/reviewers`, token, {
|
|
83
|
+
method: 'DELETE',
|
|
84
|
+
body: { reviewers },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// --- Testers ---
|
|
88
|
+
async function assignTesters(token, owner, repo, number, testers, append = false) {
|
|
89
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/testers`, token, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
body: { testers, add: append },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async function removeTesters(token, owner, repo, number, testers) {
|
|
95
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/testers`, token, {
|
|
96
|
+
method: 'DELETE',
|
|
97
|
+
body: { testers },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// --- Review & Test ---
|
|
101
|
+
async function submitReview(token, owner, repo, number, force = false) {
|
|
102
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/review`, token, {
|
|
103
|
+
method: 'POST',
|
|
104
|
+
body: { force },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async function submitTest(token, owner, repo, number, force = false) {
|
|
108
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/test`, token, {
|
|
109
|
+
method: 'POST',
|
|
110
|
+
body: { force },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async function addPRLabels(token, owner, repo, number, labels) {
|
|
114
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/labels`, token, {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
body: labels,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async function removePRLabel(token, owner, repo, number, names) {
|
|
120
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/labels/${names}`, token, {
|
|
121
|
+
method: 'DELETE',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function linkIssues(token, owner, repo, number, issues) {
|
|
125
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/issues`, token, {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
body: issues,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function unlinkIssues(token, owner, repo, number, issues) {
|
|
131
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/issues`, token, {
|
|
132
|
+
method: 'DELETE',
|
|
133
|
+
body: issues,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async function listPROperateLogs(token, owner, repo, number, params = {}) {
|
|
137
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/operate_logs`, token, {
|
|
138
|
+
query: params,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
34
141
|
//# sourceMappingURL=prs.js.map
|
package/dist/api/prs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prs.js","sourceRoot":"","sources":["../../src/api/prs.ts"],"names":[],"mappings":";;AAuCA,0BASC;AAED,sBAOC;AAWD,4BAUC;AAED,0BAYC;
|
|
1
|
+
{"version":3,"file":"prs.js","sourceRoot":"","sources":["../../src/api/prs.ts"],"names":[],"mappings":";;AAuCA,0BASC;AAED,sBAOC;AAWD,4BAUC;AAED,0BAYC;AAWD,8BAiBC;AA2BD,gCAOC;AAaD,4BAWC;AAaD,sCAUC;AAID,wCAUC;AAED,0CASC;AAWD,0CAYC;AAED,0CAWC;AAID,sCAYC;AAED,sCAWC;AAID,oCAWC;AAED,gCAWC;AAUD,kCAWC;AAED,sCAUC;AAWD,gCAWC;AAED,oCAWC;AAYD,8CAUC;AAzZD,qCAAqC;AAuC9B,KAAK,UAAU,OAAO,CAC3B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,SAAwB,EAAE;IAE1B,OAAO,IAAA,mBAAU,EAAO,UAAU,KAAK,IAAI,IAAI,QAAQ,EAAE,KAAK,EAAE;QAC9D,KAAK,EAAE,MAAqD;KAC7D,CAAC,CAAA;AACJ,CAAC;AAEM,KAAK,UAAU,KAAK,CACzB,KAAa,EACb,KAAa,EACb,IAAY,EACZ,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,CAAC,CAAA;AACJ,CAAC;AAYM,KAAK,UAAU,iBAAiB,CACrC,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAc,EACd,SAA8D,EAAE;IAEhE,OAAO,IAAA,mBAAU,EAAiB,UAAU,KAAK,IAAI,IAAI,UAAU,MAAM,eAAe,EAAE,KAAK,EAAE;QAC/F,KAAK,EAAE,MAAqD;KAC7D,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class PRComments extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
number: import("@oclif/core/lib/interfaces").Arg<number, {
|
|
7
|
+
max?: number | undefined;
|
|
8
|
+
min?: number | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
static flags: {
|
|
12
|
+
limit: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
delete: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
'comment-type': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../base-command");
|
|
5
|
+
const index_1 = require("../../config/index");
|
|
6
|
+
const index_2 = require("../../git/index");
|
|
7
|
+
const prs_1 = require("../../api/prs");
|
|
8
|
+
const client_1 = require("../../api/client");
|
|
9
|
+
const index_3 = require("../../ui/index");
|
|
10
|
+
class PRComments extends base_command_1.BaseCommand {
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(PRComments);
|
|
13
|
+
const token = (0, index_1.getToken)();
|
|
14
|
+
if (!token)
|
|
15
|
+
this.error('Not logged in. Run: gc auth login');
|
|
16
|
+
let owner, repo;
|
|
17
|
+
try {
|
|
18
|
+
;
|
|
19
|
+
({ owner, repo } = (0, index_2.resolveRepo)());
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
this.error(err.message);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
if (flags.delete) {
|
|
26
|
+
await (0, prs_1.deletePRComment)(token, owner, repo, flags.delete);
|
|
27
|
+
this.log(`Deleted comment ${flags.delete}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const comments = await (0, prs_1.listPRComments)(token, owner, repo, args.number, {
|
|
31
|
+
per_page: flags.limit,
|
|
32
|
+
comment_type: flags['comment-type'],
|
|
33
|
+
});
|
|
34
|
+
if (flags.json) {
|
|
35
|
+
(0, index_3.printJson)(comments);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, index_3.printTable)(comments.map((c) => ({
|
|
39
|
+
id: c.id,
|
|
40
|
+
author: c.user?.login ?? '-',
|
|
41
|
+
created: c.created_at ? (0, index_3.formatDate)(c.created_at) : '-',
|
|
42
|
+
body: (c.body || '').slice(0, 80),
|
|
43
|
+
})), ['id', 'author', 'created', 'body']);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err instanceof client_1.GitCodeError)
|
|
47
|
+
this.error(err.message);
|
|
48
|
+
this.error('Could not connect to GitCode. Check your internet connection.');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
PRComments.description = 'List or delete comments on a pull request';
|
|
53
|
+
PRComments.examples = [
|
|
54
|
+
'<%= config.bin %> pr comments 5',
|
|
55
|
+
'<%= config.bin %> pr comments 5 --limit 10',
|
|
56
|
+
'<%= config.bin %> pr comments 5 --delete 12345',
|
|
57
|
+
'<%= config.bin %> pr comments 5 --comment-type diff_comment',
|
|
58
|
+
];
|
|
59
|
+
PRComments.args = {
|
|
60
|
+
number: core_1.Args.integer({ description: 'PR number', required: true }),
|
|
61
|
+
};
|
|
62
|
+
PRComments.flags = {
|
|
63
|
+
...base_command_1.BaseCommand.baseFlags,
|
|
64
|
+
limit: core_1.Flags.integer({ description: 'Max number of comments to show', default: 30 }),
|
|
65
|
+
delete: core_1.Flags.integer({ description: 'Comment note_id to delete' }),
|
|
66
|
+
'comment-type': core_1.Flags.string({
|
|
67
|
+
description: 'Filter by comment type',
|
|
68
|
+
options: ['diff_comment', 'pr_comment'],
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
exports.default = PRComments;
|
|
72
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../../src/commands/pr/comments.ts"],"names":[],"mappings":";;AAAA,sCAAyC;AACzC,qDAAgD;AAChD,8CAA6C;AAC7C,2CAA6C;AAC7C,uCAA+D;AAC/D,6CAA+C;AAC/C,0CAAkE;AAElE,MAAqB,UAAW,SAAQ,0BAAW;IAqBjD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QAEpD,MAAM,KAAK,GAAG,IAAA,gBAAQ,GAAE,CAAA;QACxB,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;QAE3D,IAAI,KAAa,EAAE,IAAY,CAAA;QAC/B,IAAI,CAAC;YACH,CAAC;YAAA,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAA,mBAAW,GAAE,CAAC,CAAA;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,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,GAAG,CAAC,OAAO,CAAC,CAAA;YACxD,IAAI,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;;AA/DM,sBAAW,GAAG,2CAA2C,CAAA;AACzD,mBAAQ,GAAG;IAChB,iCAAiC;IACjC,4CAA4C;IAC5C,gDAAgD;IAChD,6DAA6D;CAC9D,CAAA;AACM,eAAI,GAAG;IACZ,MAAM,EAAE,WAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;CACnE,CAAA;AACM,gBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACpF,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IACnE,cAAc,EAAE,YAAK,CAAC,MAAM,CAAC;QAC3B,WAAW,EAAE,wBAAwB;QACrC,OAAO,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC;KACxC,CAAC;CACH,CAAA;kBAnBkB,UAAU"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class PRCommits extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
number: import("@oclif/core/lib/interfaces").Arg<number, {
|
|
7
|
+
max?: number | undefined;
|
|
8
|
+
min?: number | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
static flags: {
|
|
12
|
+
limit: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../base-command");
|
|
5
|
+
const index_1 = require("../../config/index");
|
|
6
|
+
const index_2 = require("../../git/index");
|
|
7
|
+
const prs_1 = require("../../api/prs");
|
|
8
|
+
const client_1 = require("../../api/client");
|
|
9
|
+
const index_3 = require("../../ui/index");
|
|
10
|
+
class PRCommits extends base_command_1.BaseCommand {
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(PRCommits);
|
|
13
|
+
const token = (0, index_1.getToken)();
|
|
14
|
+
if (!token)
|
|
15
|
+
this.error('Not logged in. Run: gc auth login');
|
|
16
|
+
let owner, repo;
|
|
17
|
+
try {
|
|
18
|
+
;
|
|
19
|
+
({ owner, repo } = (0, index_2.resolveRepo)());
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
this.error(err.message);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const commits = await (0, prs_1.listPRCommits)(token, owner, repo, args.number, {
|
|
26
|
+
per_page: flags.limit,
|
|
27
|
+
});
|
|
28
|
+
if (flags.json) {
|
|
29
|
+
(0, index_3.printJson)(commits);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
(0, index_3.printTable)(commits.map((c) => ({
|
|
33
|
+
sha: c.sha.slice(0, 8),
|
|
34
|
+
author: c.commit.author.name,
|
|
35
|
+
date: (0, index_3.formatDate)(c.commit.author.date),
|
|
36
|
+
message: c.commit.message.slice(0, 72),
|
|
37
|
+
})), ['sha', 'author', 'date', 'message']);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err instanceof client_1.GitCodeError)
|
|
41
|
+
this.error(err.message);
|
|
42
|
+
this.error('Could not connect to GitCode. Check your internet connection.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
PRCommits.description = 'List commits on a pull request';
|
|
47
|
+
PRCommits.examples = [
|
|
48
|
+
'<%= config.bin %> pr commits 5',
|
|
49
|
+
'<%= config.bin %> pr commits 5 --limit 10',
|
|
50
|
+
];
|
|
51
|
+
PRCommits.args = {
|
|
52
|
+
number: core_1.Args.integer({ description: 'PR number', required: true }),
|
|
53
|
+
};
|
|
54
|
+
PRCommits.flags = {
|
|
55
|
+
...base_command_1.BaseCommand.baseFlags,
|
|
56
|
+
limit: core_1.Flags.integer({ description: 'Max number of commits to show', default: 30 }),
|
|
57
|
+
};
|
|
58
|
+
exports.default = PRCommits;
|
|
59
|
+
//# sourceMappingURL=commits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../../../src/commands/pr/commits.ts"],"names":[],"mappings":";;AAAA,sCAAyC;AACzC,qDAAgD;AAChD,8CAA6C;AAC7C,2CAA6C;AAC7C,uCAA6C;AAC7C,6CAA+C;AAC/C,0CAAkE;AAElE,MAAqB,SAAU,SAAQ,0BAAW;IAchD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAEnD,MAAM,KAAK,GAAG,IAAA,gBAAQ,GAAE,CAAA;QACxB,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;QAE3D,IAAI,KAAa,EAAE,IAAY,CAAA;QAC/B,IAAI,CAAC;YACH,CAAC;YAAA,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAA,mBAAW,GAAE,CAAC,CAAA;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAE,GAAa,CAAC,OAAO,CAAC,CAAA;QACpC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,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AAK,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;CACpF,CAAA;kBAZkB,SAAS"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class PRDiff extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
number: import("@oclif/core/lib/interfaces").Arg<number, {
|
|
7
|
+
max?: number | undefined;
|
|
8
|
+
min?: number | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
static flags: {
|
|
12
|
+
'name-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
color: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
private getStatusIcon;
|
|
18
|
+
private getStatusText;
|
|
19
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../base-command");
|
|
5
|
+
const index_1 = require("../../config/index");
|
|
6
|
+
const index_2 = require("../../git/index");
|
|
7
|
+
const prs_1 = require("../../api/prs");
|
|
8
|
+
const client_1 = require("../../api/client");
|
|
9
|
+
const index_3 = require("../../ui/index");
|
|
10
|
+
class PRDiff extends base_command_1.BaseCommand {
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(PRDiff);
|
|
13
|
+
const token = (0, index_1.getToken)();
|
|
14
|
+
if (!token)
|
|
15
|
+
this.error('Not logged in. Run: gc auth login');
|
|
16
|
+
let owner, repo;
|
|
17
|
+
try {
|
|
18
|
+
;
|
|
19
|
+
({ owner, repo } = (0, index_2.resolveRepo)());
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
this.error(err.message);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const files = await (0, prs_1.getPRFiles)(token, owner, repo, args.number);
|
|
26
|
+
if (flags.json) {
|
|
27
|
+
(0, index_3.printJson)(files);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (flags['name-only']) {
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const statusIcon = this.getStatusIcon(file.status);
|
|
33
|
+
this.log(`${statusIcon} ${file.filename}`);
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Output full diff
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
this.log(`diff --git a/${file.filename} b/${file.filename}`);
|
|
40
|
+
const statusText = this.getStatusText(file.status);
|
|
41
|
+
this.log(`status: ${statusText} | +${file.additions} -${file.deletions}`);
|
|
42
|
+
this.log('---');
|
|
43
|
+
// The diff content is in file.patch.diff
|
|
44
|
+
if (file.patch?.diff) {
|
|
45
|
+
this.log(file.patch.diff);
|
|
46
|
+
}
|
|
47
|
+
else if (file.too_large) {
|
|
48
|
+
this.log('(File too large to display)');
|
|
49
|
+
}
|
|
50
|
+
this.log('');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (err instanceof client_1.GitCodeError)
|
|
55
|
+
this.error(err.message);
|
|
56
|
+
this.error('Could not connect to GitCode. Check your internet connection.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getStatusIcon(status) {
|
|
60
|
+
switch (status) {
|
|
61
|
+
case 'added':
|
|
62
|
+
return 'A';
|
|
63
|
+
case 'deleted':
|
|
64
|
+
return 'D';
|
|
65
|
+
case 'modified':
|
|
66
|
+
return 'M';
|
|
67
|
+
case 'renamed':
|
|
68
|
+
return 'R';
|
|
69
|
+
default:
|
|
70
|
+
return '?';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
getStatusText(status) {
|
|
74
|
+
switch (status) {
|
|
75
|
+
case 'added':
|
|
76
|
+
return 'new file';
|
|
77
|
+
case 'deleted':
|
|
78
|
+
return 'deleted';
|
|
79
|
+
case 'modified':
|
|
80
|
+
return 'modified';
|
|
81
|
+
case 'renamed':
|
|
82
|
+
return 'renamed';
|
|
83
|
+
default:
|
|
84
|
+
return status;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
PRDiff.description = 'View changes in a pull request';
|
|
89
|
+
PRDiff.examples = [
|
|
90
|
+
'<%= config.bin %> pr diff 5',
|
|
91
|
+
'<%= config.bin %> pr diff 5 --name-only',
|
|
92
|
+
'<%= config.bin %> pr diff 5 --color never',
|
|
93
|
+
];
|
|
94
|
+
PRDiff.args = {
|
|
95
|
+
number: core_1.Args.integer({ description: 'PR number', required: true }),
|
|
96
|
+
};
|
|
97
|
+
PRDiff.flags = {
|
|
98
|
+
...base_command_1.BaseCommand.baseFlags,
|
|
99
|
+
'name-only': core_1.Flags.boolean({
|
|
100
|
+
description: 'Display only names of changed files',
|
|
101
|
+
default: false,
|
|
102
|
+
}),
|
|
103
|
+
color: core_1.Flags.string({
|
|
104
|
+
description: 'Use color in diff output: {always|never|auto}',
|
|
105
|
+
default: 'auto',
|
|
106
|
+
options: ['always', 'never', 'auto'],
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
109
|
+
exports.default = PRDiff;
|
|
110
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/commands/pr/diff.ts"],"names":[],"mappings":";;AAAA,sCAAyC;AACzC,qDAAgD;AAChD,8CAA6C;AAC7C,2CAA6C;AAC7C,uCAA0C;AAC1C,6CAA+C;AAC/C,0CAA0C;AAE1C,MAAqB,MAAO,SAAQ,0BAAW;IAuB7C,KAAK,C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S,CAAA;YAClB;gBACE,OAAO,MAAM,CAAA;QACjB,CAAC;IACH,CAAC;;AApGM,kBAAW,GAAG,gCAAgC,CAAA;AAC9C,eAAQ,GAAG;IAChB,6BAA6B;IAC7B,yCAAyC;IACzC,2CAA2C;CAC5C,CAAA;AACM,WAAI,GAAG;IACZ,MAAM,EAAE,WAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;CACnE,CAAA;AACM,YAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC;QACzB,WAAW,EAAE,qCAAqC;QAClD,OAAO,EAAE,KAAK;KACf,CAAC;IACF,KAAK,EAAE,YAAK,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,+CAA+C;QAC5D,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;KACrC,CAAC;CACH,CAAA;kBArBkB,MAAM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class PRLabels extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
number: import("@oclif/core/lib/interfaces").Arg<number, {
|
|
7
|
+
max?: number | undefined;
|
|
8
|
+
min?: number | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
labels: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
static flags: {
|
|
13
|
+
remove: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|