@oh-gc/cli 0.3.0 → 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 +47 -68
- package/dist/api/prs.d.ts +11 -0
- package/dist/api/prs.js +4 -0
- package/dist/api/prs.js.map +1 -1
- package/dist/commands/issue/create.d.ts +1 -0
- package/dist/commands/issue/create.js +11 -3
- package/dist/commands/issue/create.js.map +1 -1
- package/dist/commands/pr/comment.d.ts +13 -0
- package/dist/commands/pr/comment.js +102 -0
- package/dist/commands/pr/comment.js.map +1 -0
- package/dist/commands/pr/create.d.ts +1 -0
- package/dist/commands/pr/create.js +20 -4
- package/dist/commands/pr/create.js.map +1 -1
- package/dist/git/index.d.ts +11 -0
- package/dist/git/index.js +37 -2
- package/dist/git/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -3,58 +3,33 @@
|
|
|
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
|
|
7
|
-
oh-gc issue
|
|
8
|
-
oh-gc pr
|
|
9
|
-
oh-gc pr
|
|
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
|
---
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
|
-
###
|
|
16
|
+
### npm (Recommended)
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
The easiest way to install `oh-gc` is via npm:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
chmod +x /usr/local/bin/oh-gc
|
|
21
|
+
npm install -g @oh-gc/cli
|
|
22
|
+
oh-gc --help
|
|
24
23
|
```
|
|
25
24
|
|
|
26
|
-
|
|
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+)
|
|
25
|
+
### From Source
|
|
51
26
|
|
|
52
27
|
```bash
|
|
53
28
|
git clone https://gitcode.com/guozejun/ohos_gitcode_cli.git
|
|
54
29
|
cd ohos_gitcode_cli
|
|
55
30
|
npm install
|
|
56
31
|
npm run build
|
|
57
|
-
npm link
|
|
32
|
+
npm link
|
|
58
33
|
```
|
|
59
34
|
|
|
60
35
|
---
|
|
@@ -64,7 +39,7 @@ npm link # makes 'oh-gc' available globally
|
|
|
64
39
|
**1. Log in with your GitCode personal access token:**
|
|
65
40
|
|
|
66
41
|
```bash
|
|
67
|
-
oh-gc auth
|
|
42
|
+
oh-gc auth:login
|
|
68
43
|
# Enter your GitCode personal access token: ••••••••••
|
|
69
44
|
# Logged in as yourname (Your Name)
|
|
70
45
|
```
|
|
@@ -75,13 +50,13 @@ Get a token at: **GitCode → Settings → Access Tokens**
|
|
|
75
50
|
|
|
76
51
|
```bash
|
|
77
52
|
cd your-project # must be a git repo with a gitcode.com remote
|
|
78
|
-
oh-gc issue
|
|
53
|
+
oh-gc issue:list
|
|
79
54
|
```
|
|
80
55
|
|
|
81
56
|
If your remote is not named `origin`, configure it:
|
|
82
57
|
|
|
83
58
|
```bash
|
|
84
|
-
oh-gc repo
|
|
59
|
+
oh-gc repo:set-remote upstream
|
|
85
60
|
```
|
|
86
61
|
|
|
87
62
|
---
|
|
@@ -92,54 +67,58 @@ oh-gc repo set-remote upstream
|
|
|
92
67
|
|
|
93
68
|
| Command | Description |
|
|
94
69
|
|---|---|
|
|
95
|
-
| `oh-gc auth
|
|
96
|
-
| `oh-gc auth
|
|
97
|
-
| `oh-gc auth
|
|
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 |
|
|
98
73
|
|
|
99
74
|
### Issues
|
|
100
75
|
|
|
101
76
|
| Command | Description |
|
|
102
77
|
|---|---|
|
|
103
|
-
| `oh-gc issue
|
|
104
|
-
| `oh-gc issue
|
|
105
|
-
| `oh-gc issue
|
|
106
|
-
| `oh-gc issue
|
|
107
|
-
| `oh-gc issue
|
|
108
|
-
| `oh-gc issue
|
|
109
|
-
| `oh-gc issue
|
|
110
|
-
| `oh-gc issue
|
|
111
|
-
| `oh-gc issue
|
|
112
|
-
| `oh-gc issue
|
|
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 |
|
|
113
89
|
|
|
114
90
|
### Pull Requests
|
|
115
91
|
|
|
116
92
|
| Command | Description |
|
|
117
93
|
|---|---|
|
|
118
|
-
| `oh-gc pr
|
|
119
|
-
| `oh-gc pr
|
|
120
|
-
| `oh-gc pr
|
|
121
|
-
| `oh-gc pr
|
|
122
|
-
| `oh-gc pr
|
|
123
|
-
| `oh-gc pr
|
|
124
|
-
| `oh-gc pr
|
|
125
|
-
| `oh-gc pr
|
|
126
|
-
| `oh-gc pr
|
|
127
|
-
| `oh-gc pr
|
|
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 |
|
|
128
107
|
|
|
129
108
|
### Release
|
|
130
109
|
|
|
131
110
|
| Command | Description |
|
|
132
111
|
|---|---|
|
|
133
|
-
| `oh-gc release
|
|
134
|
-
| `oh-gc release
|
|
135
|
-
| `oh-gc release
|
|
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 |
|
|
136
115
|
|
|
137
116
|
### Repo Config
|
|
138
117
|
|
|
139
118
|
| Command | Description |
|
|
140
119
|
|---|---|
|
|
141
|
-
| `oh-gc repo
|
|
142
|
-
| `oh-gc repo
|
|
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 |
|
|
143
122
|
|
|
144
123
|
### Global Flags
|
|
145
124
|
|
|
@@ -156,11 +135,11 @@ All commands support:
|
|
|
156
135
|
|
|
157
136
|
### Token
|
|
158
137
|
|
|
159
|
-
Stored at `~/.config/gitcode-cli/config.json`. Set via `oh-gc auth
|
|
138
|
+
Stored at `~/.config/gitcode-cli/config.json`. Set via `oh-gc auth:login`, removed via `oh-gc auth:logout`.
|
|
160
139
|
|
|
161
140
|
### Remote
|
|
162
141
|
|
|
163
|
-
By default `oh-gc` uses the `origin` remote. To use a different remote for a specific repo, run `oh-gc repo
|
|
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:
|
|
164
143
|
|
|
165
144
|
```json
|
|
166
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
|
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;AAED,4BAUC;AAED,0BAYC;
|
|
1
|
+
{"version":3,"file":"prs.js","sourceRoot":"","sources":["../../src/api/prs.ts"],"names":[],"mappings":";;AAuCA,0BASC;AAED,sBAOC;AAED,4BAUC;AAED,0BAYC;AAUD,8BAYC;AAzGD,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;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"}
|
|
@@ -7,6 +7,7 @@ export default class IssueCreate extends BaseCommand {
|
|
|
7
7
|
body: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
assignee: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
labels: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
repo: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
11
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
run(): Promise<void>;
|
|
@@ -55,11 +55,17 @@ class IssueCreate extends base_command_1.BaseCommand {
|
|
|
55
55
|
const { flags } = await this.parse(IssueCreate);
|
|
56
56
|
const token = (0, index_1.getToken)();
|
|
57
57
|
if (!token)
|
|
58
|
-
this.error('Not logged in. Run: gc auth login');
|
|
58
|
+
this.error('Not logged in. Run: oh-gc auth login');
|
|
59
59
|
let owner, repo;
|
|
60
60
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if (flags.repo) {
|
|
62
|
+
;
|
|
63
|
+
({ owner, repo } = (0, index_2.parseRepoString)(flags.repo));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
;
|
|
67
|
+
({ owner, repo } = (0, index_2.resolveRepo)());
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
catch (err) {
|
|
65
71
|
this.error(err.message);
|
|
@@ -94,6 +100,7 @@ IssueCreate.description = 'Create a new issue';
|
|
|
94
100
|
IssueCreate.examples = [
|
|
95
101
|
'<%= config.bin %> issue create',
|
|
96
102
|
'<%= config.bin %> issue create --title "Bug" --body "Steps to reproduce..."',
|
|
103
|
+
'<%= config.bin %> issue create --repo openharmony/arkui_ace_engine --title "Bug"',
|
|
97
104
|
];
|
|
98
105
|
IssueCreate.flags = {
|
|
99
106
|
...base_command_1.BaseCommand.baseFlags,
|
|
@@ -101,6 +108,7 @@ IssueCreate.flags = {
|
|
|
101
108
|
body: core_1.Flags.string({ description: 'Issue body' }),
|
|
102
109
|
assignee: core_1.Flags.string({ description: 'Username to assign' }),
|
|
103
110
|
labels: core_1.Flags.string({ description: 'Comma-separated label names' }),
|
|
111
|
+
repo: core_1.Flags.string({ description: 'Target repository (owner/repo), defaults to current repo' }),
|
|
104
112
|
};
|
|
105
113
|
exports.default = IssueCreate;
|
|
106
114
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/issue/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAmC;AACnC,wDAAyC;AACzC,qDAAgD;AAChD,8CAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/issue/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAmC;AACnC,wDAAyC;AACzC,qDAAgD;AAChD,8CAA6C;AAC7C,2CAA8D;AAC9D,6CAA8C;AAC9C,6CAA+C;AAC/C,0CAA0C;AAE1C,KAAK,UAAU,MAAM,CAAC,QAAgB;IACpC,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACrF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,EAAE,CAAC,KAAK,EAAE,CAAA;YACV,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAqB,WAAY,SAAQ,0BAAW;IAgBlD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAE/C,MAAM,KAAK,GAAG,IAAA,gBAAQ,GAAE,CAAA;Q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KAAK,EAAE,CAAC,CAAA;gBAC1D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YAC1B,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;;AAvDM,uBAAW,GAAG,oBAAoB,CAAA;AAClC,oBAAQ,GAAG;IAChB,gCAAgC;IAChC,6EAA6E;IAC7E,kFAAkF;CACnF,CAAA;AACM,iBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,KAAK,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IACnD,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IACjD,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IAC7D,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IACpE,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0DAA0D,EAAE,CAAC;CAChG,CAAA;kBAdkB,WAAW"}
|
|
@@ -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,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,sCAAsC,CAAC,CAAA;QAE9D,IAAI,KAAa,EAAE,IAAY,CAAA;QAC/B,IAAI,CAAC;YACH,CAAC;YAAA,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAA,mBAAW,G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AAG,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"}
|
|
@@ -8,6 +8,7 @@ export default class PRCreate extends BaseCommand {
|
|
|
8
8
|
base: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
head: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
draft: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
repo: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
12
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
13
|
};
|
|
13
14
|
run(): Promise<void>;
|
|
@@ -64,18 +64,32 @@ class PRCreate extends base_command_1.BaseCommand {
|
|
|
64
64
|
const { flags } = await this.parse(PRCreate);
|
|
65
65
|
const token = (0, index_1.getToken)();
|
|
66
66
|
if (!token)
|
|
67
|
-
this.error('Not logged in. Run: gc auth login');
|
|
67
|
+
this.error('Not logged in. Run: oh-gc auth login');
|
|
68
68
|
let owner, repo;
|
|
69
69
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (flags.repo) {
|
|
71
|
+
;
|
|
72
|
+
({ owner, repo } = (0, index_2.parseRepoString)(flags.repo));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
;
|
|
76
|
+
({ owner, repo } = (0, index_2.resolveRepo)());
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
catch (err) {
|
|
74
80
|
this.error(err.message);
|
|
75
81
|
}
|
|
76
|
-
const
|
|
82
|
+
const currentBranch = getCurrentBranch();
|
|
83
|
+
let head = flags.head ?? currentBranch;
|
|
77
84
|
if (!head)
|
|
78
85
|
this.error('Could not determine current branch. Use --head to specify.');
|
|
86
|
+
// For cross-repo PRs, prefix head with fork owner
|
|
87
|
+
if (flags.repo) {
|
|
88
|
+
const forkOwner = (0, index_2.getForkOwner)();
|
|
89
|
+
if (forkOwner && !head.includes(':')) {
|
|
90
|
+
head = `${forkOwner}:${head}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
79
93
|
const title = flags.title ?? (await prompt('Title: '));
|
|
80
94
|
if (!title)
|
|
81
95
|
this.error('Title cannot be empty.');
|
|
@@ -107,6 +121,7 @@ PRCreate.description = 'Create a pull request';
|
|
|
107
121
|
PRCreate.examples = [
|
|
108
122
|
'<%= config.bin %> pr create',
|
|
109
123
|
'<%= config.bin %> pr create --title "Fix bug" --body "Details" --base main',
|
|
124
|
+
'<%= config.bin %> pr create --repo openharmony/arkui_ace_engine --head my-feature',
|
|
110
125
|
];
|
|
111
126
|
PRCreate.flags = {
|
|
112
127
|
...base_command_1.BaseCommand.baseFlags,
|
|
@@ -115,6 +130,7 @@ PRCreate.flags = {
|
|
|
115
130
|
base: core_1.Flags.string({ description: 'Target branch (default: main)', default: 'main' }),
|
|
116
131
|
head: core_1.Flags.string({ description: 'Source branch (default: current branch)' }),
|
|
117
132
|
draft: core_1.Flags.boolean({ description: 'Create as draft PR', default: false }),
|
|
133
|
+
repo: core_1.Flags.string({ description: 'Target repository (owner/repo) for cross-repo PR, defaults to current repo' }),
|
|
118
134
|
};
|
|
119
135
|
exports.default = PRCreate;
|
|
120
136
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/pr/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAmC;AACnC,wDAAyC;AACzC,2DAA6C;AAC7C,qDAAgD;AAChD,8CAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/pr/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAmC;AACnC,wDAAyC;AACzC,2DAA6C;AAC7C,qDAAgD;AAChD,8CAA6C;AAC7C,2CAA4E;AAC5E,uCAAwC;AACxC,6CAA+C;AAC/C,0CAA0C;AAE1C,KAAK,UAAU,MAAM,CAAC,QAAgB;IACpC,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACrF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,EAAE,CAAC,KAAK,EAAE,CAAA;YACV,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB;IACvB,IAAI,CAAC;QACH,OAAO,IAAA,6BAAQ,EAAC,2BAA2B,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC3E,CAAC;IAAC,MAA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EAAE,CAAC;IAChD,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IACrD,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrF,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IAC9E,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC3E,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,4EAA4E,EAAE,CAAC;CAClH,CAAA;kBAfkB,QAAQ"}
|
package/dist/git/index.d.ts
CHANGED
|
@@ -5,7 +5,18 @@ export declare function parseOwnerRepo(url: string): {
|
|
|
5
5
|
owner: string;
|
|
6
6
|
repo: string;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Parse owner/repo from a string like "owner/repo"
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseRepoString(repoStr: string): {
|
|
12
|
+
owner: string;
|
|
13
|
+
repo: string;
|
|
14
|
+
};
|
|
8
15
|
export declare function resolveRepo(): {
|
|
9
16
|
owner: string;
|
|
10
17
|
repo: string;
|
|
11
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Get the fork owner (the owner of origin remote, typically user's fork)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getForkOwner(): string | null;
|
package/dist/git/index.js
CHANGED
|
@@ -4,12 +4,24 @@ exports.getConfiguredRemote = getConfiguredRemote;
|
|
|
4
4
|
exports.setConfiguredRemote = setConfiguredRemote;
|
|
5
5
|
exports.getRemoteUrl = getRemoteUrl;
|
|
6
6
|
exports.parseOwnerRepo = parseOwnerRepo;
|
|
7
|
+
exports.parseRepoString = parseRepoString;
|
|
7
8
|
exports.resolveRepo = resolveRepo;
|
|
9
|
+
exports.getForkOwner = getForkOwner;
|
|
8
10
|
const node_child_process_1 = require("node:child_process");
|
|
9
11
|
const node_fs_1 = require("node:fs");
|
|
10
12
|
const GITCODE_FILE = '.gitcode';
|
|
13
|
+
function isGitcodeFile() {
|
|
14
|
+
if (!(0, node_fs_1.existsSync)(GITCODE_FILE))
|
|
15
|
+
return false;
|
|
16
|
+
try {
|
|
17
|
+
return (0, node_fs_1.statSync)(GITCODE_FILE).isFile();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
function getConfiguredRemote() {
|
|
12
|
-
if ((
|
|
24
|
+
if (isGitcodeFile()) {
|
|
13
25
|
try {
|
|
14
26
|
const data = JSON.parse((0, node_fs_1.readFileSync)(GITCODE_FILE, 'utf8'));
|
|
15
27
|
if (data.remote)
|
|
@@ -22,7 +34,7 @@ function getConfiguredRemote() {
|
|
|
22
34
|
return 'origin';
|
|
23
35
|
}
|
|
24
36
|
function setConfiguredRemote(remote) {
|
|
25
|
-
const existing = (
|
|
37
|
+
const existing = isGitcodeFile()
|
|
26
38
|
? JSON.parse((0, node_fs_1.readFileSync)(GITCODE_FILE, 'utf8'))
|
|
27
39
|
: {};
|
|
28
40
|
existing.remote = remote;
|
|
@@ -43,9 +55,32 @@ function parseOwnerRepo(url) {
|
|
|
43
55
|
}
|
|
44
56
|
return { owner: match[1], repo: match[2] };
|
|
45
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse owner/repo from a string like "owner/repo"
|
|
60
|
+
*/
|
|
61
|
+
function parseRepoString(repoStr) {
|
|
62
|
+
const match = repoStr.match(/^([^/]+)\/([^/]+)$/);
|
|
63
|
+
if (!match) {
|
|
64
|
+
throw new Error(`Invalid repository format: "${repoStr}". Expected "owner/repo".`);
|
|
65
|
+
}
|
|
66
|
+
return { owner: match[1], repo: match[2] };
|
|
67
|
+
}
|
|
46
68
|
function resolveRepo() {
|
|
47
69
|
const remote = getConfiguredRemote();
|
|
48
70
|
const url = getRemoteUrl(remote);
|
|
49
71
|
return parseOwnerRepo(url);
|
|
50
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the fork owner (the owner of origin remote, typically user's fork)
|
|
75
|
+
*/
|
|
76
|
+
function getForkOwner() {
|
|
77
|
+
try {
|
|
78
|
+
const url = getRemoteUrl('origin');
|
|
79
|
+
const { owner } = parseOwnerRepo(url);
|
|
80
|
+
return owner;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
51
86
|
//# sourceMappingURL=index.js.map
|
package/dist/git/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":";;AAkBA,kDAUC;AAED,kDAMC;AAED,oCAMC;AAED,wCAMC;AAKD,0CAMC;AAED,kCAIC;AAKD,oCAQC;AAlFD,2DAA6C;AAC7C,qCAA2E;AAE3E,MAAM,YAAY,GAAG,UAAU,CAAA;AAM/B,SAAS,aAAa;IACpB,IAAI,CAAC,IAAA,oBAAU,EAAC,YAAY,CAAC;QAAE,OAAO,KAAK,CAAA;IAC3C,IAAI,CAAC;QACH,OAAO,IAAA,kBAAQ,EAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAA;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,SAAgB,mBAAmB;IACjC,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,YAAY,EAAE,MAAM,CAAC,CAAkB,CAAA;YAC5E,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO,IA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,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,2BAA2B,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAC5C,CAAC;AAED,SAAgB,WAAW;IACzB,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAA;IACpC,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAA;IAChC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY;IAC1B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;QAClC,MAAM,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,CAAA;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-gc/cli",
|
|
3
|
-
"version": "0.
|
|
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",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"dev": "node bin/dev.js",
|
|
47
47
|
"test": "jest",
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
|
-
"pack:linux": "
|
|
50
|
-
"pack:win": "
|
|
51
|
-
"pack": "
|
|
49
|
+
"pack:linux": "bash scripts/pack-tarball.sh",
|
|
50
|
+
"pack:win": "bash scripts/pack-tarball.sh",
|
|
51
|
+
"pack": "bash scripts/pack-tarball.sh",
|
|
52
52
|
"release": "node bin/run.js release:create",
|
|
53
53
|
"prepublishOnly": "npm run build && npm test",
|
|
54
54
|
"publish:npm": "npm publish --access public"
|