@osdlc/typed-gh 0.15.0 → 0.16.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 +8 -0
- package/README.md +39 -5
- package/dist/async.js +3 -3
- package/dist/doors.d.ts +5 -5
- package/dist/doors.js +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/sync.js +3 -3
- package/dist/verbs.d.ts +27 -11
- package/dist/verbs.js +25 -5
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @osdlc/typed-gh
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 51efdb6: `raw(argv)` and `rawChecked(argv)` are new verbs: `Gh.raw` and `Gh.rawChecked` as functions, so a tool can make a call the verb table lacks without constructing a `Gh`. Through `runVerb`, `raw` returns the `CommandResult` whatever the exit code, and `rawChecked` returns it when `gh` exits 0 with its whole output and throws the classified `GhFailure` otherwise. Neither is `readOnly`. Both clients' `raw` and `rawChecked` methods now run these verbs. The one visible change is that `AsyncGh.raw` rejects, rather than throwing at the call site, when a runner throws synchronously, as `rawChecked` already did.
|
|
8
|
+
|
|
9
|
+
The README has a new section, "Keeping a bundle small": a bundled tool that makes a few calls should import the verbs it calls and run them with `runVerb`, because a bundler cannot drop a class's unused methods. For a diff and one raw checked call, that is 14.4 KB against 68.0 KB through `Gh` (`bun build --minify`). The decision and the measurements are in `docs/planning/decisions/bundle-size.md`.
|
|
10
|
+
|
|
3
11
|
## 0.15.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -419,6 +419,34 @@ const repos = await runVerbAsync(repoList('acme', {}, { hostname: 'ghe.example.c
|
|
|
419
419
|
`(binary, argv, opts) => result` function is not a runner; wrap it yourself as
|
|
420
420
|
`{ run: (argv, opts) => fn('gh', argv, opts) }`.
|
|
421
421
|
|
|
422
|
+
`raw(argv)` and `rawChecked(argv)` are `Gh.raw` and `Gh.rawChecked` as verbs, for a call the verb
|
|
423
|
+
table does not have. Through `runVerb`, `raw` returns the `CommandResult` whatever the exit code,
|
|
424
|
+
and `rawChecked` returns it when `gh` exits 0 with its whole output and throws the classified
|
|
425
|
+
failure otherwise. Like the methods, they add no `--repo` and no host.
|
|
426
|
+
|
|
427
|
+
## Keeping a bundle small
|
|
428
|
+
|
|
429
|
+
A tool that is bundled and makes a few `gh` calls should import the verbs it calls and run them
|
|
430
|
+
with `runVerb`, and not construct a `Gh`. A bundler drops a function that nothing imports, but it
|
|
431
|
+
cannot drop a method a class never calls. So one `new Gh()` keeps every verb and parser in the
|
|
432
|
+
bundle, and the verb path keeps only the verbs you import:
|
|
433
|
+
|
|
434
|
+
```ts
|
|
435
|
+
import { defaultRunnerFactory, prDiff, rawChecked, runVerb } from '@osdlc/typed-gh'
|
|
436
|
+
|
|
437
|
+
const runner = defaultRunnerFactory('gh')
|
|
438
|
+
const opts = { cwd: '/repo' }
|
|
439
|
+
const diff = runVerb(prDiff(42), runner, opts)
|
|
440
|
+
const files = runVerb(rawChecked(['api', 'repos/{owner}/{repo}/pulls/42/files']), runner, opts)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Built with `bun build --minify`, those two calls take 14.4 KB through `runVerb` and 68.0 KB through
|
|
444
|
+
`Gh` (7.6 KB of each is command-seam's runner). The verb path gives up `try`, `soft` and the
|
|
445
|
+
helpers that make several calls (`prFind`, `openPrFor`, `prViewSettled`): catch the `FailureError`
|
|
446
|
+
instead. A tool that already uses many methods loses little by constructing `Gh`. The measurements
|
|
447
|
+
and the reasons `Gh` is not split into entry points are in
|
|
448
|
+
[docs/planning/decisions/bundle-size.md](docs/planning/decisions/bundle-size.md).
|
|
449
|
+
|
|
422
450
|
## `AsyncGh`
|
|
423
451
|
|
|
424
452
|
The awaitable form of `Gh`, with the same methods, for code that runs many calls at once and must
|
|
@@ -573,7 +601,9 @@ experimental.
|
|
|
573
601
|
- `AsyncCallOptions`: `timeoutMs` and `signal`, accepted by sixteen methods of `AsyncGh`.
|
|
574
602
|
- `defaultRunnerFactory` and `RunnerFactory`: how a client makes its default runner for `gh`.
|
|
575
603
|
- `runVerb` and `runVerbAsync`, with `RunVerbOptions` and `RunVerbAsyncOptions`: run one verb through
|
|
576
|
-
a runner you own, with its `env`, `input`, timeout and checked contract applied.
|
|
604
|
+
a runner you own, with its `env`, `input`, timeout and checked contract applied. With the verb
|
|
605
|
+
functions, they are the way to call `gh` without a `Gh`, which keeps a bundle small (see
|
|
606
|
+
"Keeping a bundle small").
|
|
577
607
|
|
|
578
608
|
Methods on both clients:
|
|
579
609
|
|
|
@@ -601,10 +631,11 @@ Methods on both clients:
|
|
|
601
631
|
|
|
602
632
|
A verb is plain data: argv, a `checked` flag, a `readOnly` flag, optional stdin and environment,
|
|
603
633
|
and a `parse` function. `readOnly` is true for every query and `prDiff`, and false for every
|
|
604
|
-
mutation
|
|
605
|
-
Each verb takes an optional `GhTarget` last
|
|
606
|
-
`
|
|
607
|
-
`
|
|
634
|
+
mutation and for `raw` and `rawChecked`, so a caller that keeps an allowlist of safe calls can check
|
|
635
|
+
a verb before running it. Each verb takes an optional `GhTarget` last, except `raw` and
|
|
636
|
+
`rawChecked`, which take only argv. Each client method has a verb of the same name, except `at`,
|
|
637
|
+
`withRepo`, `prViewSettled`, `openPrFor`, `prFind`, `authenticated`, `ready` and `ownerRepo`.
|
|
638
|
+
`openPrsForBranch` is a verb with no method.
|
|
608
639
|
|
|
609
640
|
- `GhVerb`: the shape of a verb. `GhTarget`: the `repo` and `hostname` a verb talks to.
|
|
610
641
|
- Verb builders: `prList`, `prView`, `prBody`, `openPrsForBranch`, `prReviewThreads`, `prDiff`,
|
|
@@ -612,6 +643,9 @@ Each verb takes an optional `GhTarget` last. Each client method has a verb of th
|
|
|
612
643
|
`createReview`, `issueList`, `issueView`, `labelList`, `setIssueLabel`, `createLabel`,
|
|
613
644
|
`editLabel`, `issueCommentEdit`, `repoList`, `repoView`, `searchPrs`, `api`, `graphql`,
|
|
614
645
|
`installed` and `authStatus`.
|
|
646
|
+
- `raw` and `rawChecked`: any argv as a verb whose value is the `CommandResult`. `raw` returns it
|
|
647
|
+
whatever the exit code; `rawChecked` throws the classified failure unless `gh` exits 0 with its
|
|
648
|
+
whole output.
|
|
615
649
|
- `pickPrForBranch`: the first row whose head branch is exactly the one you name. `prList({ head })`
|
|
616
650
|
already filters exactly. This is for rows from elsewhere, such as a `head:` search. It takes plain
|
|
617
651
|
rows or a `ListResult`, so `openPrsForBranch`'s or `prList`'s parsed answer passes straight in.
|
package/dist/async.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* block the event loop, such as many per-PR queries at once.
|
|
12
12
|
*/
|
|
13
13
|
import { spawnRunnerAsync } from '@osdlc/command-seam';
|
|
14
|
-
import {
|
|
14
|
+
import { softAsync, triedAsync } from "./doors.js";
|
|
15
15
|
import { runVerbAsync } from "./run.js";
|
|
16
16
|
import { ownerRepoSlug, parseOwnerRepo, parsePrRef } from "./repo.js";
|
|
17
17
|
import * as v from "./verbs.js";
|
|
@@ -80,11 +80,11 @@ export class AsyncGh {
|
|
|
80
80
|
* `.at(dir)` first.
|
|
81
81
|
*/
|
|
82
82
|
raw(argv, opts = {}) {
|
|
83
|
-
return this.
|
|
83
|
+
return this.exec(v.raw(argv), opts);
|
|
84
84
|
}
|
|
85
85
|
/** Run any `gh` call. Rejects with the classified failure on a non-zero exit. Adds no `--repo`, as {@link AsyncGh.raw}. */
|
|
86
86
|
rawChecked(argv, opts = {}) {
|
|
87
|
-
return
|
|
87
|
+
return this.exec(v.rawChecked(argv), opts);
|
|
88
88
|
}
|
|
89
89
|
/** Run one verb from the table, checked or unchecked as the verb says. */
|
|
90
90
|
async exec(verb, call = {}) {
|
package/dist/doors.d.ts
CHANGED
|
@@ -27,11 +27,11 @@ import type { GhVerb } from './verbs.ts';
|
|
|
27
27
|
* Read the result of running `verb` as the methods that throw do.
|
|
28
28
|
*
|
|
29
29
|
* A checked verb has already thrown on a non-zero exit (the runner is
|
|
30
|
-
* {@link runCheckedGh}). A probe (`installed`, `authStatus`, `api`)
|
|
31
|
-
* failure in its value. A read that exited non-zero throws the
|
|
32
|
-
* failure, unless the verb's `absent` says gh's answer was "there
|
|
33
|
-
* thing", which `parse` turns into `null`. A read that exited 0 but
|
|
34
|
-
* could not be read completely, and throws.
|
|
30
|
+
* {@link runCheckedGh}). A probe (`installed`, `authStatus`, `api`, `raw`)
|
|
31
|
+
* carries its failure in its value. A read that exited non-zero throws the
|
|
32
|
+
* classified failure, unless the verb's `absent` says gh's answer was "there
|
|
33
|
+
* is no such thing", which `parse` turns into `null`. A read that exited 0 but
|
|
34
|
+
* parsed to `null` could not be read completely, and throws.
|
|
35
35
|
*
|
|
36
36
|
* A result flagged `outputIncomplete` throws for every verb but a probe, as
|
|
37
37
|
* typed-git's `gate` does: gh exited, but the runner stopped reading at the
|
package/dist/doors.js
CHANGED
|
@@ -26,11 +26,11 @@ import { classifyGhFailure, unreadableFailure } from "./failure.js";
|
|
|
26
26
|
* Read the result of running `verb` as the methods that throw do.
|
|
27
27
|
*
|
|
28
28
|
* A checked verb has already thrown on a non-zero exit (the runner is
|
|
29
|
-
* {@link runCheckedGh}). A probe (`installed`, `authStatus`, `api`)
|
|
30
|
-
* failure in its value. A read that exited non-zero throws the
|
|
31
|
-
* failure, unless the verb's `absent` says gh's answer was "there
|
|
32
|
-
* thing", which `parse` turns into `null`. A read that exited 0 but
|
|
33
|
-
* could not be read completely, and throws.
|
|
29
|
+
* {@link runCheckedGh}). A probe (`installed`, `authStatus`, `api`, `raw`)
|
|
30
|
+
* carries its failure in its value. A read that exited non-zero throws the
|
|
31
|
+
* classified failure, unless the verb's `absent` says gh's answer was "there
|
|
32
|
+
* is no such thing", which `parse` turns into `null`. A read that exited 0 but
|
|
33
|
+
* parsed to `null` could not be read completely, and throws.
|
|
34
34
|
*
|
|
35
35
|
* A result flagged `outputIncomplete` throws for every verb but a probe, as
|
|
36
36
|
* typed-git's `gate` does: gh exited, but the runner stopped reading at the
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { classifyGhFailure, type GhFailure, type GhFailureKind } from './failure
|
|
|
23
23
|
export { type Soft, type TriedAsync, type TriedSync } from './doors.ts';
|
|
24
24
|
export { runVerb, runVerbAsync, type RunVerbAsyncOptions, type RunVerbOptions } from './run.ts';
|
|
25
25
|
export { Gh, defaultRunnerFactory, type GhOptions, type GhRepoOptions, type RunnerFactory, } from './sync.ts';
|
|
26
|
-
export { api, authStatus, createPr, editPr, editPrBody, fromTarget, graphql, createLabel, createReview, editLabel, installed, issueList, issueView, labelList, nodesAt, openPrsForBranch, pickPrForBranch, prBody, prComment, prSetDraft, issueCommentEdit, prDiff, prList, prMerge, prReviewThreads, prUpdateBranch, prView, repoList, repoView, searchPrs, setIssueLabel, PR_LIST_FIELDS, PR_REF_FIELDS, PR_VIEW_FIELDS, REPO_FIELDS, SEARCH_PR_FIELDS, type ApiOptions, type ApiResponse, type AuthStatus, type CreateLabelOptions, type CreatePrOptions, type CreateReviewOptions, type FromTarget, type GhTarget, type GraphqlOptions, type GraphqlVariable, type GhVerb, type IssueListOptions, type ListResult, type PrListOptions, type PrMergeMethod, type RepoListOptions, type ReviewComment, type ReviewThread, type SearchPrsOptions, } from './verbs.ts';
|
|
26
|
+
export { api, authStatus, createPr, editPr, editPrBody, fromTarget, graphql, createLabel, createReview, editLabel, installed, issueList, issueView, labelList, nodesAt, openPrsForBranch, pickPrForBranch, prBody, prComment, prSetDraft, issueCommentEdit, prDiff, prList, prMerge, prReviewThreads, prUpdateBranch, prView, raw, rawChecked, repoList, repoView, searchPrs, setIssueLabel, PR_LIST_FIELDS, PR_REF_FIELDS, PR_VIEW_FIELDS, REPO_FIELDS, SEARCH_PR_FIELDS, type ApiOptions, type ApiResponse, type AuthStatus, type CreateLabelOptions, type CreatePrOptions, type CreateReviewOptions, type FromTarget, type GhTarget, type GraphqlOptions, type GraphqlVariable, type GhVerb, type IssueListOptions, type ListResult, type PrListOptions, type PrMergeMethod, type RepoListOptions, type ReviewComment, type ReviewThread, type SearchPrsOptions, } from './verbs.ts';
|
|
27
27
|
export { anyCheckFailed, normalizeAuthorLogin, parsePullRequest } from './parse.ts';
|
|
28
28
|
export { ownerRepoSlug, parseOwnerRepo, parsePrRef, parsePrUrl, type PrRef, type PullRequestRef, } from './repo.ts';
|
|
29
29
|
export type { Actor, CheckConclusion, CheckRun, Comment, IssueRow, Label, MergeableState, MergeStateStatus, OwnerRepo, PullRequest, PrSearchHit, PullRequestState, Repository, RepositoryVisibility, Review, ReviewDecision, ReviewState, } from './types.ts';
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { classifyGhFailure } from "./failure.js";
|
|
|
23
23
|
export {} from "./doors.js";
|
|
24
24
|
export { runVerb, runVerbAsync } from "./run.js";
|
|
25
25
|
export { Gh, defaultRunnerFactory, } from "./sync.js";
|
|
26
|
-
export { api, authStatus, createPr, editPr, editPrBody, fromTarget, graphql, createLabel, createReview, editLabel, installed, issueList, issueView, labelList, nodesAt, openPrsForBranch, pickPrForBranch, prBody, prComment, prSetDraft, issueCommentEdit, prDiff, prList, prMerge, prReviewThreads, prUpdateBranch, prView, repoList, repoView, searchPrs, setIssueLabel, PR_LIST_FIELDS, PR_REF_FIELDS, PR_VIEW_FIELDS, REPO_FIELDS, SEARCH_PR_FIELDS, } from "./verbs.js";
|
|
26
|
+
export { api, authStatus, createPr, editPr, editPrBody, fromTarget, graphql, createLabel, createReview, editLabel, installed, issueList, issueView, labelList, nodesAt, openPrsForBranch, pickPrForBranch, prBody, prComment, prSetDraft, issueCommentEdit, prDiff, prList, prMerge, prReviewThreads, prUpdateBranch, prView, raw, rawChecked, repoList, repoView, searchPrs, setIssueLabel, PR_LIST_FIELDS, PR_REF_FIELDS, PR_VIEW_FIELDS, REPO_FIELDS, SEARCH_PR_FIELDS, } from "./verbs.js";
|
|
27
27
|
export { anyCheckFailed, normalizeAuthorLogin, parsePullRequest } from "./parse.js";
|
|
28
28
|
export { ownerRepoSlug, parseOwnerRepo, parsePrRef, parsePrUrl, } from "./repo.js";
|
|
29
29
|
// command-seam's error and runner types appear in this package's signatures, so
|
package/dist/sync.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* `raw` and `rawChecked` run any `gh` call.
|
|
18
18
|
*/
|
|
19
19
|
import { spawnRunner } from '@osdlc/command-seam';
|
|
20
|
-
import {
|
|
20
|
+
import { softSync, triedSync } from "./doors.js";
|
|
21
21
|
import { runVerb } from "./run.js";
|
|
22
22
|
import * as v from "./verbs.js";
|
|
23
23
|
import { ownerRepoSlug, parseOwnerRepo, parsePrRef } from "./repo.js";
|
|
@@ -122,11 +122,11 @@ export class Gh {
|
|
|
122
122
|
* `.at(dir)` first.
|
|
123
123
|
*/
|
|
124
124
|
raw(argv, opts = {}) {
|
|
125
|
-
return this.
|
|
125
|
+
return this.exec(v.raw(argv), opts.timeoutMs);
|
|
126
126
|
}
|
|
127
127
|
/** Run any `gh` call. Throws the classified failure on a non-zero exit. Adds no `--repo`, as {@link Gh.raw}. */
|
|
128
128
|
rawChecked(argv, opts = {}) {
|
|
129
|
-
return
|
|
129
|
+
return this.exec(v.rawChecked(argv), opts.timeoutMs);
|
|
130
130
|
}
|
|
131
131
|
/** Run one verb from the table, checked or unchecked as the verb says. */
|
|
132
132
|
exec(verb, timeoutMs) {
|
package/dist/verbs.d.ts
CHANGED
|
@@ -7,22 +7,23 @@
|
|
|
7
7
|
* their own runner all use the same definitions and the same parsing.
|
|
8
8
|
*
|
|
9
9
|
* `checked` marks a verb the runner throws for on a non-zero exit, with
|
|
10
|
-
* stderr. That is every mutation,
|
|
11
|
-
* queries run unchecked, and `parse` turns a failure into
|
|
12
|
-
* what `soft` returns. The clients' methods that throw read
|
|
13
|
-
* `settle` (see `doors.ts`) instead. There a failure throws,
|
|
14
|
-
* verb declares `absent` or is a `probe`.
|
|
10
|
+
* stderr. That is every mutation, `prDiff`, which is a read, and
|
|
11
|
+
* `rawChecked`. Other queries run unchecked, and `parse` turns a failure into
|
|
12
|
+
* `null`, which is what `soft` returns. The clients' methods that throw read
|
|
13
|
+
* them through `settle` (see `doors.ts`) instead. There a failure throws,
|
|
14
|
+
* except where the verb declares `absent` or is a `probe`.
|
|
15
15
|
*/
|
|
16
16
|
import { type CommandResult } from '@osdlc/command-seam';
|
|
17
17
|
import type { IssueRow, Label, PrSearchHit, PullRequest, Repository } from './types.ts';
|
|
18
18
|
/** One `gh` invocation: what to run, and how to read what came back. */
|
|
19
19
|
export interface GhVerb<T> {
|
|
20
20
|
argv: string[];
|
|
21
|
-
/** True for every mutation and
|
|
21
|
+
/** True for every mutation, `prDiff` and `rawChecked`: throw on a non-zero exit instead of parsing. */
|
|
22
22
|
checked: boolean;
|
|
23
23
|
/**
|
|
24
24
|
* True when the call only reads and changes nothing on GitHub. Every query
|
|
25
|
-
* is read-only, and so is `prDiff`. No mutation is
|
|
25
|
+
* is read-only, and so is `prDiff`. No mutation is, and neither are `raw`
|
|
26
|
+
* and `rawChecked`, whose argv the library cannot judge. A caller that
|
|
26
27
|
* keeps an allowlist of safe calls can check this before running a verb.
|
|
27
28
|
*/
|
|
28
29
|
readOnly: boolean;
|
|
@@ -34,10 +35,10 @@ export interface GhVerb<T> {
|
|
|
34
35
|
*/
|
|
35
36
|
env?: Record<string, string> | undefined;
|
|
36
37
|
/**
|
|
37
|
-
* True for a
|
|
38
|
-
* `authStatus` and `
|
|
39
|
-
* plain method and from `try`; they have no soft form. Other reads
|
|
40
|
-
* from the plain method when gh exits non-zero.
|
|
38
|
+
* True for a call whose failure is part of its answer. `installed`,
|
|
39
|
+
* `authStatus`, `api` and `raw` return what `parse` makes of any result,
|
|
40
|
+
* from the plain method and from `try`; they have no soft form. Other reads
|
|
41
|
+
* throw from the plain method when gh exits non-zero.
|
|
41
42
|
*/
|
|
42
43
|
probe?: boolean | undefined;
|
|
43
44
|
/**
|
|
@@ -507,6 +508,21 @@ export interface CreateReviewOptions {
|
|
|
507
508
|
* @experimental
|
|
508
509
|
*/
|
|
509
510
|
export declare function createReview(number: number, opts: CreateReviewOptions, target?: GhTarget): GhVerb<string>;
|
|
511
|
+
/**
|
|
512
|
+
* Any `gh` call, as a verb whose value is the `CommandResult`, whatever the
|
|
513
|
+
* exit code: `Gh.raw` as data. It adds no `--repo` and no host, so put them
|
|
514
|
+
* in `argv`. It is a `probe`, so `runVerb` returns a failed or cut-short
|
|
515
|
+
* result rather than throwing, and it is not `readOnly`, since the library
|
|
516
|
+
* cannot tell what `argv` does.
|
|
517
|
+
*/
|
|
518
|
+
export declare function raw(argv: readonly string[]): GhVerb<CommandResult>;
|
|
519
|
+
/**
|
|
520
|
+
* {@link raw}, checked: `Gh.rawChecked` as data. `runVerb` returns the
|
|
521
|
+
* `CommandResult` when gh exits 0 with its whole output, and otherwise throws
|
|
522
|
+
* a `FailureError` carrying the classified `GhFailure`. So a tool that runs
|
|
523
|
+
* one call the verb table lacks needs no `Gh` for it.
|
|
524
|
+
*/
|
|
525
|
+
export declare function rawChecked(argv: readonly string[]): GhVerb<CommandResult>;
|
|
510
526
|
/**
|
|
511
527
|
* The first row whose `headRefName` exactly equals `branch`, or null.
|
|
512
528
|
*
|
package/dist/verbs.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* their own runner all use the same definitions and the same parsing.
|
|
8
8
|
*
|
|
9
9
|
* `checked` marks a verb the runner throws for on a non-zero exit, with
|
|
10
|
-
* stderr. That is every mutation,
|
|
11
|
-
* queries run unchecked, and `parse` turns a failure into
|
|
12
|
-
* what `soft` returns. The clients' methods that throw read
|
|
13
|
-
* `settle` (see `doors.ts`) instead. There a failure throws,
|
|
14
|
-
* verb declares `absent` or is a `probe`.
|
|
10
|
+
* stderr. That is every mutation, `prDiff`, which is a read, and
|
|
11
|
+
* `rawChecked`. Other queries run unchecked, and `parse` turns a failure into
|
|
12
|
+
* `null`, which is what `soft` returns. The clients' methods that throw read
|
|
13
|
+
* them through `settle` (see `doors.ts`) instead. There a failure throws,
|
|
14
|
+
* except where the verb declares `absent` or is a `probe`.
|
|
15
15
|
*/
|
|
16
16
|
import { notAnOption, stderrOrError } from '@osdlc/command-seam';
|
|
17
17
|
import { parseLabels, parsePrSearchHit, parsePullRequest, parseRepository } from "./parse.js";
|
|
@@ -1098,6 +1098,26 @@ export function createReview(number, opts, target) {
|
|
|
1098
1098
|
},
|
|
1099
1099
|
};
|
|
1100
1100
|
}
|
|
1101
|
+
// ── raw calls ───────────────────────────────────────────────────────────────
|
|
1102
|
+
/**
|
|
1103
|
+
* Any `gh` call, as a verb whose value is the `CommandResult`, whatever the
|
|
1104
|
+
* exit code: `Gh.raw` as data. It adds no `--repo` and no host, so put them
|
|
1105
|
+
* in `argv`. It is a `probe`, so `runVerb` returns a failed or cut-short
|
|
1106
|
+
* result rather than throwing, and it is not `readOnly`, since the library
|
|
1107
|
+
* cannot tell what `argv` does.
|
|
1108
|
+
*/
|
|
1109
|
+
export function raw(argv) {
|
|
1110
|
+
return { argv: [...argv], checked: false, readOnly: false, probe: true, parse: (r) => r };
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* {@link raw}, checked: `Gh.rawChecked` as data. `runVerb` returns the
|
|
1114
|
+
* `CommandResult` when gh exits 0 with its whole output, and otherwise throws
|
|
1115
|
+
* a `FailureError` carrying the classified `GhFailure`. So a tool that runs
|
|
1116
|
+
* one call the verb table lacks needs no `Gh` for it.
|
|
1117
|
+
*/
|
|
1118
|
+
export function rawChecked(argv) {
|
|
1119
|
+
return { argv: [...argv], checked: true, readOnly: false, parse: (r) => r };
|
|
1120
|
+
}
|
|
1101
1121
|
// ── helpers over the parsed rows ────────────────────────────────────────────
|
|
1102
1122
|
/**
|
|
1103
1123
|
* The first row whose `headRefName` exactly equals `branch`, or null.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdlc/typed-gh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A typed GitHub client for TypeScript over the gh CLI. A total PullRequest/Review/CheckRun model, pure argv builders and parsers, and a tri-modal client — queries return parsed values, mutations throw, raw() is the escape hatch. Uses gh's own credentials; reads no token.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "sksizer",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@vitest/coverage-v8": "^5.0.5",
|
|
57
57
|
"oxlint": "^1.65.0",
|
|
58
58
|
"prettier": "3.9.6",
|
|
59
|
+
"rolldown": "^1.2.14",
|
|
59
60
|
"typescript": "~6.0.3",
|
|
60
61
|
"vitest": "^5.0.5",
|
|
61
62
|
"@osdlc/prettier-config": "^0.3.1",
|