@oh-gc/cli 0.4.1 → 0.4.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/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
  A command-line interface for [GitCode](https://gitcode.com), modeled after GitHub CLI (`gh`). Manage issues, pull requests, and authentication without leaving the terminal.
4
4
 
5
5
  ```
6
- oh-gc issue list
7
- oh-gc issue view 12
8
- oh-gc pr create --title "Fix login bug" --base main
9
- oh-gc pr merge 5 --method squash
6
+ oh-gc issue:list
7
+ oh-gc issue:view 12
8
+ oh-gc pr:create --title "Fix login bug" --base main
9
+ oh-gc pr:merge 5 --method squash
10
10
  ```
11
11
 
12
12
  ---
@@ -39,7 +39,7 @@ npm link
39
39
  **1. Log in with your GitCode personal access token:**
40
40
 
41
41
  ```bash
42
- oh-gc auth login
42
+ oh-gc auth:login
43
43
  # Enter your GitCode personal access token: ••••••••••
44
44
  # Logged in as yourname (Your Name)
45
45
  ```
@@ -50,13 +50,13 @@ Get a token at: **GitCode → Settings → Access Tokens**
50
50
 
51
51
  ```bash
52
52
  cd your-project # must be a git repo with a gitcode.com remote
53
- oh-gc issue list
53
+ oh-gc issue:list
54
54
  ```
55
55
 
56
56
  If your remote is not named `origin`, configure it:
57
57
 
58
58
  ```bash
59
- oh-gc repo set-remote upstream
59
+ oh-gc repo:set-remote upstream
60
60
  ```
61
61
 
62
62
  ---
@@ -67,54 +67,58 @@ oh-gc repo set-remote upstream
67
67
 
68
68
  | Command | Description |
69
69
  |---|---|
70
- | `oh-gc auth login` | Log in with a personal access token |
71
- | `oh-gc auth logout` | Remove stored token |
72
- | `oh-gc auth status` | Show currently logged-in user |
70
+ | `oh-gc auth:login` | Log in with a personal access token |
71
+ | `oh-gc auth:logout` | Remove stored token |
72
+ | `oh-gc auth:status` | Show currently logged-in user |
73
73
 
74
74
  ### Issues
75
75
 
76
76
  | Command | Description |
77
77
  |---|---|
78
- | `oh-gc issue list` | List open issues |
79
- | `oh-gc issue list --state closed` | List closed issues |
80
- | `oh-gc issue list --state all` | List all issues |
81
- | `oh-gc issue list --assignee alice` | Filter by assignee |
82
- | `oh-gc issue list --search "login bug"` | Search by keyword |
83
- | `oh-gc issue view <number>` | Show issue detail + recent comments |
84
- | `oh-gc issue create` | Create issue interactively |
85
- | `oh-gc issue create --title "Bug" --body "..."` | Create issue with flags |
86
- | `oh-gc issue comment <number>` | Add a comment interactively |
87
- | `oh-gc issue comment <number> --body "..."` | Add a comment with a flag |
78
+ | `oh-gc issue:list` | List open issues |
79
+ | `oh-gc issue:list --state closed` | List closed issues |
80
+ | `oh-gc issue:list --state all` | List all issues |
81
+ | `oh-gc issue:list --assignee alice` | Filter by assignee |
82
+ | `oh-gc issue:list --search "login bug"` | Search by keyword |
83
+ | `oh-gc issue:view <number>` | Show issue detail + recent comments |
84
+ | `oh-gc issue:create` | Create issue interactively |
85
+ | `oh-gc issue:create --title "Bug" --body "..."` | Create issue with flags |
86
+ | `oh-gc issue:create --repo owner/repo --title "Bug"` | Create issue on different repo |
87
+ | `oh-gc issue:comment <number>` | Add a comment interactively |
88
+ | `oh-gc issue:comment <number> --body "..."` | Add a comment with a flag |
88
89
 
89
90
  ### Pull Requests
90
91
 
91
92
  | Command | Description |
92
93
  |---|---|
93
- | `oh-gc pr list` | List open pull requests |
94
- | `oh-gc pr list --state merged` | List merged PRs |
95
- | `oh-gc pr list --author alice` | Filter by author |
96
- | `oh-gc pr list --reviewer bob` | Filter by reviewer |
97
- | `oh-gc pr view <number>` | Show PR detail |
98
- | `oh-gc pr create` | Create PR interactively |
99
- | `oh-gc pr create --title "..." --base main` | Create PR with flags |
100
- | `oh-gc pr merge <number>` | Merge PR (default: merge commit) |
101
- | `oh-gc pr merge <number> --method squash` | Squash merge |
102
- | `oh-gc pr merge <number> --method rebase` | Rebase merge |
94
+ | `oh-gc pr:list` | List open pull requests |
95
+ | `oh-gc pr:list --state merged` | List merged PRs |
96
+ | `oh-gc pr:list --author alice` | Filter by author |
97
+ | `oh-gc pr:list --reviewer bob` | Filter by reviewer |
98
+ | `oh-gc pr:view <number>` | Show PR detail |
99
+ | `oh-gc pr:create` | Create PR interactively |
100
+ | `oh-gc pr:create --title "..." --base main` | Create PR with flags |
101
+ | `oh-gc pr:create --repo owner/repo --head feature` | Create cross-repo PR |
102
+ | `oh-gc pr:comment <number>` | Add a comment interactively |
103
+ | `oh-gc pr:comment <number> --body "..."` | Add a comment with a flag |
104
+ | `oh-gc pr:merge <number>` | Merge PR (default: merge commit) |
105
+ | `oh-gc pr:merge <number> --method squash` | Squash merge |
106
+ | `oh-gc pr:merge <number> --method rebase` | Rebase merge |
103
107
 
104
108
  ### Release
105
109
 
106
110
  | Command | Description |
107
111
  |---|---|
108
- | `oh-gc release create [VERSION]` | Build, test, and publish a release |
109
- | `oh-gc release create v0.3.0` | Create specific version |
110
- | `oh-gc release create --prerelease` | Create prerelease |
112
+ | `oh-gc release:create [VERSION]` | Build, test, and publish a release |
113
+ | `oh-gc release:create v0.3.0` | Create specific version |
114
+ | `oh-gc release:create --prerelease` | Create prerelease |
111
115
 
112
116
  ### Repo Config
113
117
 
114
118
  | Command | Description |
115
119
  |---|---|
116
- | `oh-gc repo get-remote` | Show which remote `oh-gc` uses |
117
- | `oh-gc repo set-remote <name>` | Set which remote `oh-gc` uses |
120
+ | `oh-gc repo:get-remote` | Show which remote `oh-gc` uses |
121
+ | `oh-gc repo:set-remote <name>` | Set which remote `oh-gc` uses |
118
122
 
119
123
  ### Global Flags
120
124
 
@@ -131,11 +135,11 @@ All commands support:
131
135
 
132
136
  ### Token
133
137
 
134
- Stored at `~/.config/gitcode-cli/config.json`. Set via `oh-gc auth login`, removed via `oh-gc auth logout`.
138
+ Stored at `~/.config/gitcode-cli/config.json`. Set via `oh-gc auth:login`, removed via `oh-gc auth:logout`.
135
139
 
136
140
  ### Remote
137
141
 
138
- By default `oh-gc` uses the `origin` remote. To use a different remote for a specific repo, run `oh-gc repo set-remote <name>`. This writes a `.gitcode` file in the repo root:
142
+ By default `oh-gc` uses the `origin` remote. To use a different remote for a specific repo, run `oh-gc repo:set-remote <name>`. This writes a `.gitcode` file in the repo root:
139
143
 
140
144
  ```json
141
145
  { "remote": "upstream" }
package/dist/api/prs.d.ts CHANGED
@@ -60,3 +60,14 @@ export declare function mergePR(token: string, owner: string, repo: string, numb
60
60
  title?: string;
61
61
  description?: string;
62
62
  }): Promise<MergeResult>;
63
+ export interface PRComment {
64
+ id: string;
65
+ body: string;
66
+ html_url?: string;
67
+ user?: {
68
+ login: string;
69
+ name: string;
70
+ };
71
+ created_at?: string;
72
+ }
73
+ export declare function commentPR(token: string, owner: string, repo: string, number: number, body: string): Promise<PRComment>;
package/dist/api/prs.js CHANGED
@@ -4,6 +4,7 @@ exports.listPRs = listPRs;
4
4
  exports.getPR = getPR;
5
5
  exports.createPR = createPR;
6
6
  exports.mergePR = mergePR;
7
+ exports.commentPR = commentPR;
7
8
  const client_1 = require("./client");
8
9
  async function listPRs(token, owner, repo, params = {}) {
9
10
  return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls`, token, {
@@ -22,4 +23,7 @@ async function createPR(token, owner, repo, params) {
22
23
  async function mergePR(token, owner, repo, number, params = {}) {
23
24
  return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/merge`, token, { method: 'PUT', body: params });
24
25
  }
26
+ async function commentPR(token, owner, repo, number, body) {
27
+ return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/comments`, token, { method: 'POST', body: { body } });
28
+ }
25
29
  //# sourceMappingURL=prs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prs.js","sourceRoot":"","sources":["../../src/api/prs.ts"],"names":[],"mappings":";;AAuCA,0BASC;AAED,sBAOC;AAED,4BAUC;AAED,0BAYC;AAnFD,qCAAqC;AAuC9B,KAAK,UAAU,OAAO,CAC3B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,SAAwB,EAAE;IAE1B,OAAO,IAAA,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Ed,OAAO,IAAA,mBAAU,EAAK,UAAU,KAAK,IAAI,IAAI,UAAU,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;AACzE,CAAC;AAEM,KAAK,UAAU,QAAQ,CAC5B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAoF;IAEpF,OAAO,IAAA,mBAAU,EAAK,UAAU,KAAK,IAAI,IAAI,QAAQ,EAAE,KAAK,EAAE;QAC5D,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;AACJ,CAAC;AAEM,KAAK,UAAU,OAAO,CAC3B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAc,EACd,SAA0E,EAAE;IAE5E,OAAO,IAAA,mBAAU,EACf,UAAU,KAAK,IAAI,IAAI,UAAU,MAAM,QAAQ,EAC/C,KAAK,EACL,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAChC,CAAA;AACH,CAAC;AAUM,KAAK,UAAU,SAAS,CAC7B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAc,EACd,IAAY;IAEZ,OAAO,IAAA,mBAAU,EACf,UAAU,KAAK,IAAI,IAAI,UAAU,MAAM,WAAW,EAClD,KAAK,EACL,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CACnC,CAAA;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class PRComment extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ number: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ body: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const core_1 = require("@oclif/core");
37
+ const readline = __importStar(require("node:readline"));
38
+ const base_command_1 = require("../../base-command");
39
+ const index_1 = require("../../config/index");
40
+ const index_2 = require("../../git/index");
41
+ const prs_1 = require("../../api/prs");
42
+ const client_1 = require("../../api/client");
43
+ const index_3 = require("../../ui/index");
44
+ class PRComment extends base_command_1.BaseCommand {
45
+ async run() {
46
+ const { args, flags } = await this.parse(PRComment);
47
+ const token = (0, index_1.getToken)();
48
+ if (!token)
49
+ this.error('Not logged in. Run: oh-gc auth:login');
50
+ let owner, repo;
51
+ try {
52
+ ;
53
+ ({ owner, repo } = (0, index_2.resolveRepo)());
54
+ }
55
+ catch (err) {
56
+ this.error(err.message);
57
+ }
58
+ let body = flags.body;
59
+ if (!body) {
60
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
61
+ body = await new Promise((resolve) => {
62
+ rl.question('Comment: ', (answer) => {
63
+ rl.close();
64
+ resolve(answer.trim());
65
+ });
66
+ });
67
+ }
68
+ if (!body)
69
+ this.error('Comment body cannot be empty.');
70
+ try {
71
+ const comment = await (0, prs_1.commentPR)(token, owner, repo, parseInt(args.number, 10), body);
72
+ if (flags.json) {
73
+ (0, index_3.printJson)(comment);
74
+ }
75
+ else {
76
+ this.log(`Added comment on PR #${args.number}`);
77
+ if (comment.html_url) {
78
+ this.log(comment.html_url);
79
+ }
80
+ }
81
+ }
82
+ catch (err) {
83
+ if (err instanceof client_1.GitCodeError)
84
+ this.error(err.message);
85
+ this.error('Could not connect to GitCode. Check your internet connection.');
86
+ }
87
+ }
88
+ }
89
+ PRComment.description = 'Add a comment to a pull request';
90
+ PRComment.examples = [
91
+ '<%= config.bin %> pr:comment 12',
92
+ '<%= config.bin %> pr:comment 12 --body "Looks good to me!"',
93
+ ];
94
+ PRComment.args = {
95
+ number: core_1.Args.string({ description: 'Pull request number', required: true }),
96
+ };
97
+ PRComment.flags = {
98
+ ...base_command_1.BaseCommand.baseFlags,
99
+ body: core_1.Flags.string({ description: 'Comment body' }),
100
+ };
101
+ exports.default = PRComment;
102
+ //# sourceMappingURL=comment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../src/commands/pr/comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAyC;AACzC,wDAAyC;AACzC,qDAAgD;AAChD,8CAA6C;AAC7C,2CAA6C;AAC7C,uCAAyC;AACzC,6CAA+C;AAC/C,0CAA0C;AAE1C,MAAqB,SAAU,SAAQ,0BAAW;IAchD,KAAK,CAAC,GAAG;QACP,MAAM,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pF,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBACf,IAAA,iBAAS,EAAC,OAAO,CAAC,CAAA;YACpB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;gBAC/C,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;oBACrB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;gBAC5B,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,qBAAY;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACxD,IAAI,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;;AAtDM,qBAAW,GAAG,iCAAiC,CAAA;AAC/C,kBAAQ,GAAG;IAChB,iCAAiC;IACjC,4DAA4D;CAC7D,CAAA;AACM,cAAI,GAAG;IACZ,MAAM,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;CAC5E,CAAA;AACM,eAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;CACpD,CAAA;kBAZkB,SAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-gc/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "GitCode CLI — manage issues and PRs from the terminal",
5
5
  "license": "MIT",
6
6
  "author": "guozejun",