@procedures/gh 0.3.0 → 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/CHANGELOG.md +42 -0
- package/README.md +28 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/module.d.ts +2 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +43 -1
- package/dist/module.js.map +1 -1
- package/dist/procedures/gh/api.d.ts +27 -0
- package/dist/procedures/gh/api.d.ts.map +1 -0
- package/dist/procedures/gh/api.js +114 -0
- package/dist/procedures/gh/api.js.map +1 -0
- package/dist/procedures/gh/index.d.ts +3 -0
- package/dist/procedures/gh/index.d.ts.map +1 -1
- package/dist/procedures/gh/index.js +3 -0
- package/dist/procedures/gh/index.js.map +1 -1
- package/dist/procedures/gh/run/download.d.ts +14 -0
- package/dist/procedures/gh/run/download.d.ts.map +1 -0
- package/dist/procedures/gh/run/download.js +23 -0
- package/dist/procedures/gh/run/download.js.map +1 -0
- package/dist/procedures/gh/shared.d.ts +10 -2
- package/dist/procedures/gh/shared.d.ts.map +1 -1
- package/dist/procedures/gh/shared.js +16 -2
- package/dist/procedures/gh/shared.js.map +1 -1
- package/dist/procedures/gh/workflow/run.d.ts +13 -0
- package/dist/procedures/gh/workflow/run.d.ts.map +1 -0
- package/dist/procedures/gh/workflow/run.js +29 -0
- package/dist/procedures/gh/workflow/run.js.map +1 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/module.ts +67 -1
- package/src/procedures/gh/api.ts +99 -0
- package/src/procedures/gh/index.ts +3 -0
- package/src/procedures/gh/run/download.ts +23 -0
- package/src/procedures/gh/shared.ts +16 -2
- package/src/procedures/gh/workflow/run.ts +30 -0
- package/src/types.ts +57 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @procedures/gh
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [0f75644]
|
|
8
|
+
- Updated dependencies [09e5566]
|
|
9
|
+
- Updated dependencies [ab77f75]
|
|
10
|
+
- Updated dependencies [a47bee6]
|
|
11
|
+
- Updated dependencies [bc74091]
|
|
12
|
+
- @procedures/client@0.5.0
|
|
13
|
+
- @procedures/shell@0.5.0
|
|
14
|
+
|
|
15
|
+
## 0.4.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 2c02cf0: Three new procedures: `gh.workflow.run`, `gh.run.download` and `gh.api`.
|
|
20
|
+
|
|
21
|
+
- `gh.workflow.run` starts a workflow run on a ref, with each input as `-f key=value`. When `gh` prints the URL of the new run, the output has `url` and `run`. It declares `writes: ["network"]`, and it is not destructive.
|
|
22
|
+
- `gh.run.download` downloads the artifacts of a run into `dir`, by `names` or `patterns`. It declares `writes: ["fs"]`. `gh` does not replace a file that exists, so it is not destructive.
|
|
23
|
+
- `gh.api` sends a request to the GitHub API and gives the parsed JSON as `data`. It always sends `--method` (default `GET`). A string field goes as `-f`, another value as `-F`. A JSON `body` goes as `--input` from a temporary file. `paginate` joins the pages of an array. `repo` goes to `gh` as `GH_REPO`.
|
|
24
|
+
- The method of `gh.api` is an input, and `PUT` or `DELETE` can replace or remove data. Thus `gh.api` declares `writes: ["network"]` and is destructive.
|
|
25
|
+
|
|
26
|
+
These procedures are not MCP tools.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [d919678]
|
|
31
|
+
- Updated dependencies [057d69a]
|
|
32
|
+
- Updated dependencies [b2a1a1e]
|
|
33
|
+
- Updated dependencies [057d69a]
|
|
34
|
+
- Updated dependencies [057d69a]
|
|
35
|
+
- Updated dependencies [057d69a]
|
|
36
|
+
- Updated dependencies [057d69a]
|
|
37
|
+
- Updated dependencies [057d69a]
|
|
38
|
+
- Updated dependencies [afd6a19]
|
|
39
|
+
- Updated dependencies [057d69a]
|
|
40
|
+
- Updated dependencies [4c51727]
|
|
41
|
+
- Updated dependencies [4e751da]
|
|
42
|
+
- @procedures/client@0.4.0
|
|
43
|
+
- @procedures/shell@0.4.0
|
|
44
|
+
|
|
3
45
|
## 0.3.0
|
|
4
46
|
|
|
5
47
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
npm install @procedures/gh
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
The GitHub CLI (`gh`) as procedures: pull requests, workflow runs, releases and
|
|
9
|
+
The GitHub CLI (`gh`) as procedures: pull requests, workflow runs, artifacts, releases, issues and the GitHub API. Each procedure runs `gh` through `shell.run` of `@procedures/shell`, with an argument list and no shell. The output is the JSON of `gh --json`.
|
|
10
10
|
|
|
11
11
|
`gh` must be on the `PATH`, with a login (`gh auth login`).
|
|
12
12
|
|
|
@@ -21,18 +21,40 @@ The GitHub CLI (`gh`) as procedures: pull requests, workflow runs, releases and
|
|
|
21
21
|
| `gh.run.list` | The workflow runs: workflow, branch, status, limit | reads |
|
|
22
22
|
| `gh.run.view` | One workflow run with its jobs | reads |
|
|
23
23
|
| `gh.run.rerun` | Run a workflow run again, or only its failed jobs | writes |
|
|
24
|
+
| `gh.run.download` | Download the artifacts of a run: names, patterns, folder | writes `fs` |
|
|
25
|
+
| `gh.workflow.run` | Start a workflow run: workflow, ref, inputs | writes |
|
|
24
26
|
| `gh.release.list` | The releases of a repository | reads |
|
|
25
27
|
| `gh.release.view` | The release of a tag, or the latest release | reads |
|
|
26
28
|
| `gh.issue.list` | The issues: state, label, author, search, limit | reads |
|
|
27
29
|
| `gh.issue.view` | One issue, with its comments | reads |
|
|
28
30
|
| `gh.issue.create` | Open an issue | writes |
|
|
29
31
|
| `gh.issue.comment` | Add a comment to an issue or a pull request | writes |
|
|
32
|
+
| `gh.api` | Send a request to the GitHub API: endpoint, method, fields, body, paginate | writes, destructive |
|
|
30
33
|
|
|
31
34
|
- A read declares `reads: ["network"]` and changes nothing. A write declares `writes: ["network"]`. It makes something new, so it is not destructive, and a second call makes a second one.
|
|
32
35
|
- Each procedure takes `repo` (owner/name), `cwd` and `timeoutMs`. Without `repo`, `gh` uses the repository of the folder.
|
|
33
36
|
- A value that `gh` reads as an argument (a number, a branch, a label) must not start with `-`. A title or a body is the value of its option, so it can start with `-`.
|
|
34
37
|
- A failed command throws an error with the exit code and the text of `gh`. `gh.pr.checks` reports a pending check as an error that tells you to ask again.
|
|
35
38
|
|
|
39
|
+
### Workflow runs and artifacts
|
|
40
|
+
|
|
41
|
+
- `gh.workflow.run` sends each input as `-f key=value`. When GitHub gives the new run, `gh` prints its URL. Then the output has `url` and `run`, the id of the run.
|
|
42
|
+
- Without `run` in the output, find the run with `gh.run.list`. Use the `workflow` and `branch` filters.
|
|
43
|
+
- `gh.run.download` writes the files of the artifacts into `dir`. It declares `writes: ["fs"]`.
|
|
44
|
+
- `gh` puts each artifact in a folder with its name. When the input selects one artifact, the files go directly into `dir`.
|
|
45
|
+
- `gh` does not replace a file that exists. The download then fails. Thus the procedure is not destructive.
|
|
46
|
+
|
|
47
|
+
### The GitHub API
|
|
48
|
+
|
|
49
|
+
- `gh.api` always sends `--method`. The default is `GET`. Without this option, `gh` changes `GET` to `POST` when the call has fields.
|
|
50
|
+
- A string field goes as `-f`, and `gh` sends it as text. A number, a boolean or `null` goes as `-F`, and `gh` converts its type.
|
|
51
|
+
- `GET` sends the fields in the query. The other methods send them in the JSON body.
|
|
52
|
+
- `body` is a JSON value. The procedure writes it to a temporary file for `--input`, and removes the file after the call.
|
|
53
|
+
- `gh api` has no `--repo` option. The procedure gives `repo` to `gh` as `GH_REPO`. Then `gh` replaces `{owner}` and `{repo}` in the endpoint.
|
|
54
|
+
- The output is `{ data }`, the parsed JSON. An empty response (HTTP 204) gives `null`.
|
|
55
|
+
- With `paginate: true`, the pages of an array become one array. The pages of an object become an array of the pages.
|
|
56
|
+
- The method is an input, and `PUT` or `DELETE` can replace or remove data. Thus `gh.api` declares `writes: ["network"]` and keeps the default: destructive.
|
|
57
|
+
|
|
36
58
|
## Use
|
|
37
59
|
|
|
38
60
|
```typescript
|
|
@@ -47,6 +69,11 @@ const { items } = await client.exec(["gh", "run", "list"], { repo: "owner/name",
|
|
|
47
69
|
mark gh run list --repo owner/name --status failure
|
|
48
70
|
```
|
|
49
71
|
|
|
72
|
+
```typescript
|
|
73
|
+
const { run } = await client.exec(["gh", "workflow", "run"], { workflow: "ci.yml", ref: "main", inputs: { shards: "4" } });
|
|
74
|
+
const { data } = await client.exec(["gh", "api"], { endpoint: "repos/{owner}/{repo}/pulls", repo: "owner/name", paginate: true });
|
|
75
|
+
```
|
|
76
|
+
|
|
50
77
|
## Tests
|
|
51
78
|
|
|
52
79
|
`pnpm --filter @procedures/gh test` runs the procedures with a fake shell. The tests examine each argument list, the JSON of `gh`, the failures and the values that cannot become options.
|