@oh-gc/cli 0.3.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 +186 -0
- package/bin/dev.js +19 -0
- package/bin/run.js +12 -0
- package/dist/api/client.d.ts +9 -0
- package/dist/api/client.js +57 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/issues.d.ts +60 -0
- package/dist/api/issues.js +30 -0
- package/dist/api/issues.js.map +1 -0
- package/dist/api/prs.d.ts +62 -0
- package/dist/api/prs.js +25 -0
- package/dist/api/prs.js.map +1 -0
- package/dist/api/releases.d.ts +33 -0
- package/dist/api/releases.js +41 -0
- package/dist/api/releases.js.map +1 -0
- package/dist/api/user.d.ts +8 -0
- package/dist/api/user.js +8 -0
- package/dist/api/user.js.map +1 -0
- package/dist/base-command.d.ts +6 -0
- package/dist/base-command.js +14 -0
- package/dist/base-command.js.map +1 -0
- package/dist/commands/auth/login.d.ts +9 -0
- package/dist/commands/auth/login.js +77 -0
- package/dist/commands/auth/login.js.map +1 -0
- package/dist/commands/auth/logout.d.ts +9 -0
- package/dist/commands/auth/logout.js +19 -0
- package/dist/commands/auth/logout.js.map +1 -0
- package/dist/commands/auth/status.d.ts +9 -0
- package/dist/commands/auth/status.js +37 -0
- package/dist/commands/auth/status.js.map +1 -0
- package/dist/commands/issue/comment.d.ts +13 -0
- package/dist/commands/issue/comment.js +99 -0
- package/dist/commands/issue/comment.js.map +1 -0
- package/dist/commands/issue/create.d.ts +13 -0
- package/dist/commands/issue/create.js +106 -0
- package/dist/commands/issue/create.js.map +1 -0
- package/dist/commands/issue/list.d.ts +13 -0
- package/dist/commands/issue/list.js +68 -0
- package/dist/commands/issue/list.js.map +1 -0
- package/dist/commands/issue/view.d.ts +12 -0
- package/dist/commands/issue/view.js +64 -0
- package/dist/commands/issue/view.js.map +1 -0
- package/dist/commands/pr/create.d.ts +14 -0
- package/dist/commands/pr/create.js +120 -0
- package/dist/commands/pr/create.js.map +1 -0
- package/dist/commands/pr/list.d.ts +14 -0
- package/dist/commands/pr/list.js +71 -0
- package/dist/commands/pr/list.js.map +1 -0
- package/dist/commands/pr/merge.d.ts +16 -0
- package/dist/commands/pr/merge.js +59 -0
- package/dist/commands/pr/merge.js.map +1 -0
- package/dist/commands/pr/view.d.ts +15 -0
- package/dist/commands/pr/view.js +57 -0
- package/dist/commands/pr/view.js.map +1 -0
- package/dist/commands/release/create.d.ts +16 -0
- package/dist/commands/release/create.js +194 -0
- package/dist/commands/release/create.js.map +1 -0
- package/dist/commands/repo/get-remote.d.ts +9 -0
- package/dist/commands/repo/get-remote.js +22 -0
- package/dist/commands/repo/get-remote.js.map +1 -0
- package/dist/commands/repo/set-remote.d.ts +12 -0
- package/dist/commands/repo/set-remote.js +20 -0
- package/dist/commands/repo/set-remote.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/git/index.d.ts +11 -0
- package/dist/git/index.js +51 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +38 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# oh-gc — GitCode CLI
|
|
2
|
+
|
|
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
|
+
|
|
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
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Linux (Ubuntu / Debian and others)
|
|
17
|
+
|
|
18
|
+
Download and install with one command (requires Node.js 18+):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
curl -fsSL https://api.gitcode.com/guozejun/ohos_gitcode_cli/releases/download/v0.2.0/oh-gc-linux-x64.tar.gz \
|
|
22
|
+
| tar -xz -C /usr/local/bin
|
|
23
|
+
chmod +x /usr/local/bin/oh-gc
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or download manually from the [Releases page](https://gitcode.com/guozejun/ohos_gitcode_cli/releases), then:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
tar -xzf oh-gc-linux-x64.tar.gz -C /usr/local/bin
|
|
30
|
+
chmod +x /usr/local/bin/oh-gc
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To install without root (user-local):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
mkdir -p ~/.local/bin
|
|
37
|
+
tar -xzf oh-gc-linux-x64.tar.gz -C ~/.local/bin
|
|
38
|
+
chmod +x ~/.local/bin/oh-gc
|
|
39
|
+
# Make sure ~/.local/bin is in your PATH
|
|
40
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Windows
|
|
44
|
+
|
|
45
|
+
1. Download `oh-gc-win-x64.zip` from the [Releases page](https://gitcode.com/guozejun/ohos_gitcode_cli/releases)
|
|
46
|
+
2. Extract `oh-gc.cmd`
|
|
47
|
+
3. Move `oh-gc.cmd` to a folder that is on your `PATH`
|
|
48
|
+
4. Open a new terminal and run `oh-gc --help`
|
|
49
|
+
|
|
50
|
+
### From source (requires Node.js 18+)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://gitcode.com/guozejun/ohos_gitcode_cli.git
|
|
54
|
+
cd ohos_gitcode_cli
|
|
55
|
+
npm install
|
|
56
|
+
npm run build
|
|
57
|
+
npm link # makes 'oh-gc' available globally
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
**1. Log in with your GitCode personal access token:**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
oh-gc auth login
|
|
68
|
+
# Enter your GitCode personal access token: ••••••••••
|
|
69
|
+
# Logged in as yourname (Your Name)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Get a token at: **GitCode → Settings → Access Tokens**
|
|
73
|
+
|
|
74
|
+
**2. Navigate to a GitCode repository:**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cd your-project # must be a git repo with a gitcode.com remote
|
|
78
|
+
oh-gc issue list
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If your remote is not named `origin`, configure it:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
oh-gc repo set-remote upstream
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Commands
|
|
90
|
+
|
|
91
|
+
### Auth
|
|
92
|
+
|
|
93
|
+
| Command | Description |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `oh-gc auth login` | Log in with a personal access token |
|
|
96
|
+
| `oh-gc auth logout` | Remove stored token |
|
|
97
|
+
| `oh-gc auth status` | Show currently logged-in user |
|
|
98
|
+
|
|
99
|
+
### Issues
|
|
100
|
+
|
|
101
|
+
| Command | Description |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `oh-gc issue list` | List open issues |
|
|
104
|
+
| `oh-gc issue list --state closed` | List closed issues |
|
|
105
|
+
| `oh-gc issue list --state all` | List all issues |
|
|
106
|
+
| `oh-gc issue list --assignee alice` | Filter by assignee |
|
|
107
|
+
| `oh-gc issue list --search "login bug"` | Search by keyword |
|
|
108
|
+
| `oh-gc issue view <number>` | Show issue detail + recent comments |
|
|
109
|
+
| `oh-gc issue create` | Create issue interactively |
|
|
110
|
+
| `oh-gc issue create --title "Bug" --body "..."` | Create issue with flags |
|
|
111
|
+
| `oh-gc issue comment <number>` | Add a comment interactively |
|
|
112
|
+
| `oh-gc issue comment <number> --body "..."` | Add a comment with a flag |
|
|
113
|
+
|
|
114
|
+
### Pull Requests
|
|
115
|
+
|
|
116
|
+
| Command | Description |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `oh-gc pr list` | List open pull requests |
|
|
119
|
+
| `oh-gc pr list --state merged` | List merged PRs |
|
|
120
|
+
| `oh-gc pr list --author alice` | Filter by author |
|
|
121
|
+
| `oh-gc pr list --reviewer bob` | Filter by reviewer |
|
|
122
|
+
| `oh-gc pr view <number>` | Show PR detail |
|
|
123
|
+
| `oh-gc pr create` | Create PR interactively |
|
|
124
|
+
| `oh-gc pr create --title "..." --base main` | Create PR with flags |
|
|
125
|
+
| `oh-gc pr merge <number>` | Merge PR (default: merge commit) |
|
|
126
|
+
| `oh-gc pr merge <number> --method squash` | Squash merge |
|
|
127
|
+
| `oh-gc pr merge <number> --method rebase` | Rebase merge |
|
|
128
|
+
|
|
129
|
+
### Release
|
|
130
|
+
|
|
131
|
+
| Command | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `oh-gc release create [VERSION]` | Build, test, and publish a release |
|
|
134
|
+
| `oh-gc release create v0.3.0` | Create specific version |
|
|
135
|
+
| `oh-gc release create --prerelease` | Create prerelease |
|
|
136
|
+
|
|
137
|
+
### Repo Config
|
|
138
|
+
|
|
139
|
+
| Command | Description |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `oh-gc repo get-remote` | Show which remote `oh-gc` uses |
|
|
142
|
+
| `oh-gc repo set-remote <name>` | Set which remote `oh-gc` uses |
|
|
143
|
+
|
|
144
|
+
### Global Flags
|
|
145
|
+
|
|
146
|
+
All commands support:
|
|
147
|
+
|
|
148
|
+
| Flag | Description |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `--json` | Output raw JSON instead of formatted table |
|
|
151
|
+
| `--help` | Show command help |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Configuration
|
|
156
|
+
|
|
157
|
+
### Token
|
|
158
|
+
|
|
159
|
+
Stored at `~/.config/gitcode-cli/config.json`. Set via `oh-gc auth login`, removed via `oh-gc auth logout`.
|
|
160
|
+
|
|
161
|
+
### Remote
|
|
162
|
+
|
|
163
|
+
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:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{ "remote": "upstream" }
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
You can commit or gitignore this file — `oh-gc` never modifies `.gitignore`.
|
|
170
|
+
|
|
171
|
+
### Proxy
|
|
172
|
+
|
|
173
|
+
`oh-gc` automatically picks up the standard `https_proxy` / `HTTPS_PROXY` environment variables. No extra configuration needed.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Exit Codes
|
|
178
|
+
|
|
179
|
+
- `0` — success
|
|
180
|
+
- `1` — error (authentication failure, network error, invalid input, etc.)
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT
|
package/bin/dev.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
process.env.NODE_ENV = 'development'
|
|
3
|
+
|
|
4
|
+
// Configure proxy for native fetch (picks up https_proxy / HTTPS_PROXY env vars)
|
|
5
|
+
try {
|
|
6
|
+
const { setGlobalDispatcher, ProxyAgent } = require('undici')
|
|
7
|
+
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY
|
|
8
|
+
if (proxy) setGlobalDispatcher(new ProxyAgent(proxy))
|
|
9
|
+
} catch {}
|
|
10
|
+
|
|
11
|
+
const { run, handle, flush } = require('@oclif/core')
|
|
12
|
+
|
|
13
|
+
require('ts-node').register({
|
|
14
|
+
project: require.resolve('../tsconfig.json'),
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
run(process.argv.slice(2), require.resolve('../package.json'))
|
|
18
|
+
.then(flush)
|
|
19
|
+
.catch(handle)
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
try {
|
|
3
|
+
const { setGlobalDispatcher, ProxyAgent } = require('undici')
|
|
4
|
+
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY
|
|
5
|
+
if (proxy) setGlobalDispatcher(new ProxyAgent(proxy))
|
|
6
|
+
} catch {}
|
|
7
|
+
|
|
8
|
+
const { run, handle, flush } = require('@oclif/core')
|
|
9
|
+
|
|
10
|
+
run(process.argv.slice(2), require.resolve('../package.json'))
|
|
11
|
+
.then(flush)
|
|
12
|
+
.catch(handle)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class GitCodeError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
constructor(statusCode: number, message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function apiRequest<T>(path: string, token: string, options?: {
|
|
6
|
+
method?: string;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
9
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitCodeError = void 0;
|
|
4
|
+
exports.apiRequest = apiRequest;
|
|
5
|
+
const BASE_URL = 'https://api.gitcode.com/api/v5';
|
|
6
|
+
class GitCodeError extends Error {
|
|
7
|
+
constructor(statusCode, message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.name = 'GitCodeError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.GitCodeError = GitCodeError;
|
|
14
|
+
async function apiRequest(path, token, options = {}) {
|
|
15
|
+
const { method = 'GET', body, query } = options;
|
|
16
|
+
const url = new URL(`${BASE_URL}${path}`);
|
|
17
|
+
if (query) {
|
|
18
|
+
for (const [key, value] of Object.entries(query)) {
|
|
19
|
+
if (value !== undefined)
|
|
20
|
+
url.searchParams.set(key, String(value));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let response;
|
|
24
|
+
try {
|
|
25
|
+
response = await fetch(url.toString(), {
|
|
26
|
+
method,
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: `Bearer ${token}`,
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
Accept: 'application/json',
|
|
31
|
+
},
|
|
32
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new GitCodeError(0, 'Could not connect to GitCode. Check your internet connection.');
|
|
37
|
+
}
|
|
38
|
+
if (response.status === 401) {
|
|
39
|
+
await response.text().catch(() => { });
|
|
40
|
+
throw new GitCodeError(401, 'Authentication failed. Check your token or run: gc auth login');
|
|
41
|
+
}
|
|
42
|
+
if (response.status === 429) {
|
|
43
|
+
await response.text().catch(() => { });
|
|
44
|
+
throw new GitCodeError(429, 'Rate limit exceeded. Try again shortly.');
|
|
45
|
+
}
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
const text = await response.text();
|
|
48
|
+
throw new GitCodeError(response.status, `API error ${response.status}: ${text}`);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
return (await response.json());
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new GitCodeError(response.status, `API error ${response.status}: invalid JSON response`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;AASA,gCAwDC;AAjED,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;CACF;AALD,oCAKC;AAEM,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,KAAa,EACb,UAII,EAAE;IAEN,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAE/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAC,CAAA;IACzC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,KAAK,KAAK,SAAS;gBAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;IAED,IAAI,QAAkB,CAAA;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;YACrC,MAAM;YACN,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,kBAAkB;aAC3B;YACD,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC5D,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,YAAY,CAAC,CAAC,EAAE,+DAA+D,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,QAAQ,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,CACpB,GAAG,EACH,+DAA+D,CAChE,CAAA;IACH,CAAC;IAED,IAAI,QAAQ,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,CAAC;QACH,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,QAAQ,CAAC,MAAM,yBAAyB,CAAC,CAAA;IAChG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface Issue {
|
|
2
|
+
id: number;
|
|
3
|
+
number: string;
|
|
4
|
+
html_url: string;
|
|
5
|
+
state: string;
|
|
6
|
+
title: string;
|
|
7
|
+
body: string;
|
|
8
|
+
user: {
|
|
9
|
+
login: string;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
assignee: {
|
|
13
|
+
login: string;
|
|
14
|
+
name: string;
|
|
15
|
+
} | null;
|
|
16
|
+
labels: Array<{
|
|
17
|
+
id: number;
|
|
18
|
+
name: string;
|
|
19
|
+
color: string;
|
|
20
|
+
}>;
|
|
21
|
+
comments: number;
|
|
22
|
+
created_at: string;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IssueComment {
|
|
26
|
+
id: number;
|
|
27
|
+
body: string;
|
|
28
|
+
user: {
|
|
29
|
+
login: string;
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
created_at: string;
|
|
33
|
+
updated_at: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ListIssuesParams {
|
|
36
|
+
state?: string;
|
|
37
|
+
labels?: string;
|
|
38
|
+
sort?: string;
|
|
39
|
+
direction?: string;
|
|
40
|
+
assignee?: string;
|
|
41
|
+
creator?: string;
|
|
42
|
+
search?: string;
|
|
43
|
+
page?: number;
|
|
44
|
+
per_page?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare function listIssues(token: string, owner: string, repo: string, params?: ListIssuesParams): Promise<Issue[]>;
|
|
47
|
+
export declare function getIssue(token: string, owner: string, repo: string, number: string): Promise<Issue>;
|
|
48
|
+
export declare function createIssue(token: string, owner: string, repo: string, params: {
|
|
49
|
+
title: string;
|
|
50
|
+
body: string;
|
|
51
|
+
assignee?: string;
|
|
52
|
+
labels?: string;
|
|
53
|
+
milestone?: number;
|
|
54
|
+
}): Promise<Issue>;
|
|
55
|
+
export declare function createComment(token: string, owner: string, repo: string, number: string, body: string): Promise<IssueComment>;
|
|
56
|
+
export declare function listComments(token: string, owner: string, repo: string, number: string, params?: {
|
|
57
|
+
page?: number;
|
|
58
|
+
per_page?: number;
|
|
59
|
+
order?: string;
|
|
60
|
+
}): Promise<IssueComment[]>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listIssues = listIssues;
|
|
4
|
+
exports.getIssue = getIssue;
|
|
5
|
+
exports.createIssue = createIssue;
|
|
6
|
+
exports.createComment = createComment;
|
|
7
|
+
exports.listComments = listComments;
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
async function listIssues(token, owner, repo, params = {}) {
|
|
10
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/issues`, token, {
|
|
11
|
+
query: params,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function getIssue(token, owner, repo, number) {
|
|
15
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/issues/${number}`, token);
|
|
16
|
+
}
|
|
17
|
+
async function createIssue(token, owner, repo, params) {
|
|
18
|
+
// GitCode API quirk: POST is owner-level (/repos/:owner/issues), repo goes in the body
|
|
19
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/issues`, token, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: { repo, ...params },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async function createComment(token, owner, repo, number, body) {
|
|
25
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/issues/${number}/comments`, token, { method: 'POST', body: { body } });
|
|
26
|
+
}
|
|
27
|
+
async function listComments(token, owner, repo, number, params = {}) {
|
|
28
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/issues/${number}/comments`, token, { query: params });
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=issues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.js","sourceRoot":"","sources":["../../src/api/issues.ts"],"names":[],"mappings":";;AAqCA,gCASC;AAED,4BAOC;AAED,kCAWC;AAED,sCAYC;AAED,oCAYC;AAhGD,qCAAqC;AAqC9B,KAAK,UAAU,UAAU,CAC9B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,SAA2B,EAAE;IAE7B,OAAO,IAAA,mBAAU,EAAU,UAAU,KAAK,IAAI,IAAI,SAAS,EAAE,KAAK,EAAE;QAClE,KAAK,EAAE,MAAqD;KAC7D,CAAC,CAAA;AACJ,CAAC;AAEM,KAAK,UAAU,QAAQ,CAC5B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAc;IAEd,OAAO,IAAA,mBAAU,EAAQ,UAAU,KAAK,IAAI,IAAI,WAAW,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;AAC7E,CAAC;AAEM,KAAK,UAAU,WAAW,CAC/B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAA+F;IAE/F,uFAAuF;IACvF,OAAO,IAAA,mBAAU,EAAQ,UAAU,KAAK,SAAS,EAAE,KAAK,EAAE;QACxD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE;KAC1B,CAAC,CAAA;AACJ,CAAC;AAEM,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAc,EACd,IAAY;IAEZ,OAAO,IAAA,mBAAU,EACf,UAAU,KAAK,IAAI,IAAI,WAAW,MAAM,WAAW,EACnD,KAAK,EACL,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CACnC,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAAc,EACd,SAA+D,EAAE;IAEjE,OAAO,IAAA,mBAAU,EACf,UAAU,KAAK,IAAI,IAAI,WAAW,MAAM,WAAW,EACnD,KAAK,EACL,EAAE,KAAK,EAAE,MAAqD,EAAE,CACjE,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface PR {
|
|
2
|
+
id: number;
|
|
3
|
+
number: number;
|
|
4
|
+
html_url: string;
|
|
5
|
+
state: string;
|
|
6
|
+
title: string;
|
|
7
|
+
body: string;
|
|
8
|
+
draft: boolean;
|
|
9
|
+
mergeable: boolean;
|
|
10
|
+
user: {
|
|
11
|
+
login: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
head: {
|
|
15
|
+
ref: string;
|
|
16
|
+
sha: string;
|
|
17
|
+
label: string;
|
|
18
|
+
};
|
|
19
|
+
base: {
|
|
20
|
+
ref: string;
|
|
21
|
+
sha: string;
|
|
22
|
+
label: string;
|
|
23
|
+
};
|
|
24
|
+
assignees: Array<{
|
|
25
|
+
login: string;
|
|
26
|
+
name: string;
|
|
27
|
+
}>;
|
|
28
|
+
created_at: string;
|
|
29
|
+
updated_at: string;
|
|
30
|
+
merged_at: string | null;
|
|
31
|
+
closed_at: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface MergeResult {
|
|
34
|
+
sha: string;
|
|
35
|
+
merged: number | boolean;
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ListPRsParams {
|
|
39
|
+
state?: string;
|
|
40
|
+
base?: string;
|
|
41
|
+
sort?: string;
|
|
42
|
+
direction?: string;
|
|
43
|
+
author?: string;
|
|
44
|
+
assignee?: string;
|
|
45
|
+
reviewer?: string;
|
|
46
|
+
page?: number;
|
|
47
|
+
per_page?: number;
|
|
48
|
+
}
|
|
49
|
+
export declare function listPRs(token: string, owner: string, repo: string, params?: ListPRsParams): Promise<PR[]>;
|
|
50
|
+
export declare function getPR(token: string, owner: string, repo: string, number: number): Promise<PR>;
|
|
51
|
+
export declare function createPR(token: string, owner: string, repo: string, params: {
|
|
52
|
+
title: string;
|
|
53
|
+
body: string;
|
|
54
|
+
head: string;
|
|
55
|
+
base: string;
|
|
56
|
+
draft?: boolean;
|
|
57
|
+
}): Promise<PR>;
|
|
58
|
+
export declare function mergePR(token: string, owner: string, repo: string, number: number, params?: {
|
|
59
|
+
merge_method?: string;
|
|
60
|
+
title?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
}): Promise<MergeResult>;
|
package/dist/api/prs.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listPRs = listPRs;
|
|
4
|
+
exports.getPR = getPR;
|
|
5
|
+
exports.createPR = createPR;
|
|
6
|
+
exports.mergePR = mergePR;
|
|
7
|
+
const client_1 = require("./client");
|
|
8
|
+
async function listPRs(token, owner, repo, params = {}) {
|
|
9
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls`, token, {
|
|
10
|
+
query: params,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async function getPR(token, owner, repo, number) {
|
|
14
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}`, token);
|
|
15
|
+
}
|
|
16
|
+
async function createPR(token, owner, repo, params) {
|
|
17
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls`, token, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: params,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function mergePR(token, owner, repo, number, params = {}) {
|
|
23
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/pulls/${number}/merge`, token, { method: 'PUT', body: params });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=prs.js.map
|
|
@@ -0,0 +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,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,MAAc;IAEd,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Release {
|
|
2
|
+
id?: number;
|
|
3
|
+
tag_name: string;
|
|
4
|
+
target_commitish: string;
|
|
5
|
+
prerelease: boolean;
|
|
6
|
+
name: string;
|
|
7
|
+
body: string;
|
|
8
|
+
author: {
|
|
9
|
+
id: string;
|
|
10
|
+
login: string;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
created_at: string;
|
|
14
|
+
assets: Array<{
|
|
15
|
+
browser_download_url: string;
|
|
16
|
+
name: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface CreateReleaseParams {
|
|
21
|
+
tag_name: string;
|
|
22
|
+
name: string;
|
|
23
|
+
body: string;
|
|
24
|
+
prerelease: boolean;
|
|
25
|
+
target_commitish: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AttachFile {
|
|
28
|
+
browser_download_url: string;
|
|
29
|
+
name: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function createRelease(token: string, owner: string, repo: string, params: CreateReleaseParams): Promise<Release>;
|
|
32
|
+
export declare function getRelease(token: string, owner: string, repo: string, tag: string): Promise<Release>;
|
|
33
|
+
export declare function uploadReleaseAsset(token: string, owner: string, repo: string, tagName: string, filePath: string): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRelease = createRelease;
|
|
4
|
+
exports.getRelease = getRelease;
|
|
5
|
+
exports.uploadReleaseAsset = uploadReleaseAsset;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
const BASE_URL = 'https://api.gitcode.com/api/v5';
|
|
10
|
+
async function createRelease(token, owner, repo, params) {
|
|
11
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/releases`, token, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
body: params,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function getRelease(token, owner, repo, tag) {
|
|
17
|
+
return (0, client_1.apiRequest)(`/repos/${owner}/${repo}/releases/${tag}`, token);
|
|
18
|
+
}
|
|
19
|
+
async function uploadReleaseAsset(token, owner, repo, tagName, filePath) {
|
|
20
|
+
const fileName = (0, node_path_1.basename)(filePath);
|
|
21
|
+
const fileBuffer = (0, node_fs_1.readFileSync)(filePath);
|
|
22
|
+
// Step 1: Get signed upload URL
|
|
23
|
+
const uploadInfo = await (0, client_1.apiRequest)(`/repos/${owner}/${repo}/releases/${tagName}/upload_url`, token, { query: { file_name: fileName } });
|
|
24
|
+
// Step 2: Upload file to the signed URL
|
|
25
|
+
let response;
|
|
26
|
+
try {
|
|
27
|
+
response = await fetch(uploadInfo.url, {
|
|
28
|
+
method: 'PUT',
|
|
29
|
+
headers: uploadInfo.headers,
|
|
30
|
+
body: fileBuffer,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new client_1.GitCodeError(0, 'Could not connect to GitCode storage. Check your internet connection.');
|
|
35
|
+
}
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const text = await response.text();
|
|
38
|
+
throw new client_1.GitCodeError(response.status, `Upload failed: ${text}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=releases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"releases.js","sourceRoot":"","sources":["../../src/api/releases.ts"],"names":[],"mappings":";;AAoCA,sCAUC;AAED,gCAOC;AAED,gDAiCC;AA1FD,qCAAsC;AACtC,yCAAoC;AACpC,qCAAmD;AAEnD,MAAM,QAAQ,GAAG,gCAAgC,CAAA;AAgC1C,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,KAAa,EACb,IAAY,EACZ,MAA2B;IAE3B,OAAO,IAAA,mBAAU,EAAU,UAAU,KAAK,IAAI,IAAI,WAAW,EAAE,KAAK,EAAE;QACpE,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;AACJ,CAAC;AAEM,KAAK,UAAU,UAAU,CAC9B,KAAa,EACb,KAAa,EACb,IAAY,EACZ,GAAW;IAEX,OAAO,IAAA,mBAAU,EAAU,UAAU,KAAK,IAAI,IAAI,aAAa,GAAG,EAAE,EAAE,KAAK,CAAC,CAAA;AAC9E,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,KAAa,EACb,KAAa,EACb,IAAY,EACZ,OAAe,EACf,QAAgB;IAEhB,MAAM,QAAQ,GAAG,IAAA,oBAAQ,EAAC,QAAQ,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAA;IAEzC,gCAAgC;IAChC,MAAM,UAAU,GAAG,MAAM,IAAA,mBAAU,EACjC,UAAU,KAAK,IAAI,IAAI,aAAa,OAAO,aAAa,EACxD,KAAK,EACL,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CACnC,CAAA;IAED,wCAAwC;IACxC,IAAI,QAAkB,CAAA;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE;YACrC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,IAAI,EAAE,UAAU;SACjB,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,qBAAY,CAAC,CAAC,EAAE,uEAAuE,CAAC,CAAA;IACpG,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,MAAM,IAAI,qBAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,IAAI,EAAE,CAAC,CAAA;IACnE,CAAC;AACH,CAAC"}
|
package/dist/api/user.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrentUser = getCurrentUser;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
async function getCurrentUser(token) {
|
|
6
|
+
return (0, client_1.apiRequest)('/user', token);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/api/user.ts"],"names":[],"mappings":";;AAUA,wCAEC;AAZD,qCAAqC;AAU9B,KAAK,UAAU,cAAc,CAAC,KAAa;IAChD,OAAO,IAAA,mBAAU,EAAc,OAAO,EAAE,KAAK,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCommand = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
class BaseCommand extends core_1.Command {
|
|
6
|
+
}
|
|
7
|
+
exports.BaseCommand = BaseCommand;
|
|
8
|
+
BaseCommand.baseFlags = {
|
|
9
|
+
json: core_1.Flags.boolean({
|
|
10
|
+
description: 'Output raw JSON',
|
|
11
|
+
default: false,
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=base-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAE5C,MAAsB,WAAY,SAAQ,cAAO;;AAAjD,kCAOC;AANQ,qBAAS,GAAG;IACjB,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC;QAClB,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,KAAK;KACf,CAAC;CACH,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class AuthLogin extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|