@osdlc/typed-git 0.7.0 → 0.7.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/CHANGELOG.md +14 -0
- package/README.md +145 -138
- package/dist/async.d.ts +22 -23
- package/dist/async.js +22 -23
- package/dist/backend.d.ts +26 -28
- package/dist/backend.js +20 -22
- package/dist/checkout-root.d.ts +33 -32
- package/dist/checkout-root.js +28 -27
- package/dist/client.d.ts +4 -4
- package/dist/client.js +5 -5
- package/dist/failure.d.ts +14 -14
- package/dist/failure.js +15 -15
- package/dist/git-url.d.ts +6 -6
- package/dist/git-url.js +6 -6
- package/dist/index.d.ts +19 -18
- package/dist/index.js +19 -18
- package/dist/outcome.d.ts +29 -27
- package/dist/outcome.js +16 -14
- package/dist/remote-url.d.ts +6 -6
- package/dist/remote-url.js +6 -6
- package/dist/soft.d.ts +5 -5
- package/dist/soft.js +5 -5
- package/dist/sync.d.ts +58 -60
- package/dist/sync.js +56 -58
- package/dist/testing.d.ts +12 -12
- package/dist/testing.js +11 -11
- package/dist/verbs.d.ts +38 -40
- package/dist/verbs.js +40 -42
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@osdlc/typed-git/client
|
|
3
|
-
* git-reference parsers and the checkout walks.
|
|
2
|
+
* `@osdlc/typed-git/client`: the git clients, their backend and runner
|
|
3
|
+
* types, without the git-reference parsers and the checkout walks.
|
|
4
4
|
*
|
|
5
5
|
* The package entry minus two groups. The first is `parseGitUrl`,
|
|
6
6
|
* `gitSshUrl`, `parseRepoRef` and their types, which pull in
|
|
7
7
|
* `hosted-git-info`. The second is the checkout walks: `checkoutRoot`,
|
|
8
8
|
* `discoverCheckouts`, `scanForCheckouts`, their types and their defaults. A
|
|
9
|
-
* consumer that only
|
|
9
|
+
* consumer that only runs git, such as a runner discovery pass or a check script,
|
|
10
10
|
* imports from here and keeps `hosted-git-info` off its module graph. It stays
|
|
11
11
|
* in `dependencies` either way, so this is a bundle saving, not an install
|
|
12
12
|
* one.
|
|
13
13
|
*
|
|
14
14
|
* The package entry is defined as this module plus the URL exports, so there
|
|
15
|
-
* is one
|
|
15
|
+
* is one list of exports rather than two to keep in step.
|
|
16
16
|
*/
|
|
17
17
|
export { Git } from "./sync.js";
|
|
18
18
|
export { AsyncGit } from "./async.js";
|
|
@@ -21,7 +21,7 @@ export { cliBackend, partialBackend, UnsupportedRequest, } from "./backend.js";
|
|
|
21
21
|
export { classifyGitFailure, describeGitFailure, } from "./failure.js";
|
|
22
22
|
export {} from "./outcome.js";
|
|
23
23
|
export { forceWithLeaseArg, parseRefRows, REF_FORMAT, } from "./verbs.js";
|
|
24
|
-
// The
|
|
24
|
+
// The command-seam exports are re-exported so a caller wiring a runner or catching
|
|
25
25
|
// a failure needs one import, not two. `@osdlc/command-seam` is the package
|
|
26
26
|
// that owns these; it is usable on its own, without a git client.
|
|
27
27
|
export { asAsync, CommandFailed, runChecked, runCheckedAsync, spawnRunner, spawnRunnerAsync, } from '@osdlc/command-seam';
|
package/dist/failure.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* {@link GitFailure}: a failed git call, classified.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* {@link GitFailure}: a failed git call, classified. `git.try.*` returns it
|
|
3
|
+
* as the error of a `Result`. Its `cause` is the `CommandFailed` it was read
|
|
4
|
+
* from.
|
|
5
5
|
*
|
|
6
|
-
* The git-specific kinds come from git's stderr, matched in English.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The git-specific kinds come from git's stderr, matched in English. Under a
|
|
7
|
+
* non-English locale git translates its messages. Those keep command-seam's
|
|
8
|
+
* kind, so an unrecognised failure is still an `exit` with git's first stderr
|
|
9
|
+
* line as its message, never a wrong git kind.
|
|
10
10
|
*/
|
|
11
11
|
import { type CommandFailed, type CommandFailureKind } from '@osdlc/command-seam';
|
|
12
12
|
import { type Failure } from '@osdlc/result';
|
|
@@ -55,13 +55,13 @@ export declare function classifyGitFailure(failed: CommandFailed): GitFailure;
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function describeGitFailure(failure: GitFailure): string;
|
|
57
57
|
/**
|
|
58
|
-
* What the
|
|
59
|
-
* the {@link GitFailure} that {@link classifyGitFailure} reads from
|
|
60
|
-
* `CommandFailed` as its `cause`. Its `message` is
|
|
61
|
-
* so it names the command that failed.
|
|
62
|
-
*
|
|
63
|
-
* that reports a thrown failure
|
|
64
|
-
* only command-seam's kinds
|
|
58
|
+
* What the throwing methods throw for a failed git call: a `FailureError`
|
|
59
|
+
* carrying the {@link GitFailure} that {@link classifyGitFailure} reads from
|
|
60
|
+
* it, with the `CommandFailed` as its `cause`. Its `message` is
|
|
61
|
+
* {@link describeGitFailure}, so it names the command that failed. Any other
|
|
62
|
+
* value is returned unchanged. The git kind (a signed-out remote, an
|
|
63
|
+
* unreachable one) lets a CLI that reports a thrown failure pick an exit code
|
|
64
|
+
* for it. A bare `CommandFailed` has only command-seam's kinds.
|
|
65
65
|
*/
|
|
66
66
|
export declare function gitFailureError(error: unknown): unknown;
|
|
67
67
|
/**
|
package/dist/failure.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* {@link GitFailure}: a failed git call, classified.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* {@link GitFailure}: a failed git call, classified. `git.try.*` returns it
|
|
3
|
+
* as the error of a `Result`. Its `cause` is the `CommandFailed` it was read
|
|
4
|
+
* from.
|
|
5
5
|
*
|
|
6
|
-
* The git-specific kinds come from git's stderr, matched in English.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The git-specific kinds come from git's stderr, matched in English. Under a
|
|
7
|
+
* non-English locale git translates its messages. Those keep command-seam's
|
|
8
|
+
* kind, so an unrecognised failure is still an `exit` with git's first stderr
|
|
9
|
+
* line as its message, never a wrong git kind.
|
|
10
10
|
*/
|
|
11
11
|
import { classifyFailure, isCommandFailed, } from '@osdlc/command-seam';
|
|
12
12
|
import { describe, FailureError, isFailure } from '@osdlc/result';
|
|
@@ -121,19 +121,19 @@ export function describeGitFailure(failure) {
|
|
|
121
121
|
return verb === undefined ? `git: ${line}` : `git ${verb}: ${line}`;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
|
-
* What the
|
|
125
|
-
* the {@link GitFailure} that {@link classifyGitFailure} reads from
|
|
126
|
-
* `CommandFailed` as its `cause`. Its `message` is
|
|
127
|
-
* so it names the command that failed.
|
|
128
|
-
*
|
|
129
|
-
* that reports a thrown failure
|
|
130
|
-
* only command-seam's kinds
|
|
124
|
+
* What the throwing methods throw for a failed git call: a `FailureError`
|
|
125
|
+
* carrying the {@link GitFailure} that {@link classifyGitFailure} reads from
|
|
126
|
+
* it, with the `CommandFailed` as its `cause`. Its `message` is
|
|
127
|
+
* {@link describeGitFailure}, so it names the command that failed. Any other
|
|
128
|
+
* value is returned unchanged. The git kind (a signed-out remote, an
|
|
129
|
+
* unreachable one) lets a CLI that reports a thrown failure pick an exit code
|
|
130
|
+
* for it. A bare `CommandFailed` has only command-seam's kinds.
|
|
131
131
|
*/
|
|
132
132
|
export function gitFailureError(error) {
|
|
133
133
|
if (!isCommandFailed(error))
|
|
134
134
|
return error;
|
|
135
135
|
const failure = classifyGitFailure(error);
|
|
136
|
-
// FailureError's message is the bare sentence
|
|
136
|
+
// FailureError's message is the bare sentence. Add the command to it.
|
|
137
137
|
const thrown = new FailureError(failure);
|
|
138
138
|
thrown.message = describeGitFailure(failure);
|
|
139
139
|
return thrown;
|
package/dist/git-url.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parse an arbitrary git repository reference (https, ssh, scp-style,
|
|
3
3
|
* `owner/repo` shorthand, `github:owner/repo`, …) into its host, owner, and
|
|
4
|
-
* project
|
|
5
|
-
*
|
|
4
|
+
* project. It uses `hosted-git-info`, the parser npm itself uses for this.
|
|
5
|
+
* Covers GitHub, GitLab, Bitbucket, and Sourcehut.
|
|
6
6
|
*/
|
|
7
7
|
/** A parsed reference to a repo on a known git host. */
|
|
8
8
|
export interface GitHostInfo {
|
|
@@ -41,10 +41,10 @@ export interface RepoRef {
|
|
|
41
41
|
* repository (a local path, an unknown host).
|
|
42
42
|
*
|
|
43
43
|
* {@link parseGitUrl} reads clone URLs and shorthand but refuses the web
|
|
44
|
-
* pages people
|
|
45
|
-
* takes `/pull/12` as part of the project path. So an http(s) input that
|
|
46
|
-
* fails to parse is retried with its path cut to `/<owner>/<repo
|
|
47
|
-
*
|
|
44
|
+
* pages people often copy, such as a pull request, an issue or a file, because
|
|
45
|
+
* it takes `/pull/12` as part of the project path. So an http(s) input that
|
|
46
|
+
* fails to parse is retried with its path cut to `/<owner>/<repo>`. The owner
|
|
47
|
+
* and repo are then found whatever page the URL came from.
|
|
48
48
|
*
|
|
49
49
|
* `protocol` decides the clone URL only for an input that carries none
|
|
50
50
|
* (`owner/repo`, `github:owner/repo`); an explicit `https://…` or `git@…:`
|
package/dist/git-url.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parse an arbitrary git repository reference (https, ssh, scp-style,
|
|
3
3
|
* `owner/repo` shorthand, `github:owner/repo`, …) into its host, owner, and
|
|
4
|
-
* project
|
|
5
|
-
*
|
|
4
|
+
* project. It uses `hosted-git-info`, the parser npm itself uses for this.
|
|
5
|
+
* Covers GitHub, GitLab, Bitbucket, and Sourcehut.
|
|
6
6
|
*/
|
|
7
7
|
// The ambient declaration must travel with this file: a consumer that pulls
|
|
8
8
|
// git-url.ts in transitively compiles it under its tsconfig, which does not
|
|
@@ -34,10 +34,10 @@ const HTTP_INPUT = /^https?:\/\//i;
|
|
|
34
34
|
* repository (a local path, an unknown host).
|
|
35
35
|
*
|
|
36
36
|
* {@link parseGitUrl} reads clone URLs and shorthand but refuses the web
|
|
37
|
-
* pages people
|
|
38
|
-
* takes `/pull/12` as part of the project path. So an http(s) input that
|
|
39
|
-
* fails to parse is retried with its path cut to `/<owner>/<repo
|
|
40
|
-
*
|
|
37
|
+
* pages people often copy, such as a pull request, an issue or a file, because
|
|
38
|
+
* it takes `/pull/12` as part of the project path. So an http(s) input that
|
|
39
|
+
* fails to parse is retried with its path cut to `/<owner>/<repo>`. The owner
|
|
40
|
+
* and repo are then found whatever page the URL came from.
|
|
41
41
|
*
|
|
42
42
|
* `protocol` decides the clone URL only for an input that carries none
|
|
43
43
|
* (`owner/repo`, `github:owner/repo`); an explicit `https://…` or `git@…:`
|
package/dist/index.d.ts
CHANGED
|
@@ -2,29 +2,30 @@
|
|
|
2
2
|
* `@osdlc/typed-git` — a typed git client for TypeScript, in a synchronous
|
|
3
3
|
* and an awaitable form.
|
|
4
4
|
*
|
|
5
|
-
* Two clients
|
|
5
|
+
* Two clients with the same methods:
|
|
6
6
|
*
|
|
7
|
-
* - {@link Git} is synchronous and always
|
|
8
|
-
* one
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - {@link AsyncGit} is awaitable and takes a {@link GitBackend}
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* client
|
|
7
|
+
* - {@link Git} is synchronous and always runs the `git` CLI. Git calls run
|
|
8
|
+
* one after another gain nothing from being awaited, and a sync client
|
|
9
|
+
* does not force its callers to be async. It takes a `CommandRunner`, so
|
|
10
|
+
* tests can pass a fake.
|
|
11
|
+
* - {@link AsyncGit} is awaitable and takes a {@link GitBackend}, which
|
|
12
|
+
* replaces what performs git, not how a process is spawned. The default
|
|
13
|
+
* backend runs the CLI. Any other implementation works with the same
|
|
14
|
+
* client.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* else throws
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* for
|
|
16
|
+
* Both clients follow one contract. A declared absence returns a value,
|
|
17
|
+
* everything else throws, `try` returns the failure instead of throwing, and
|
|
18
|
+
* `raw` skips the checks. Each verb names the exit codes that mean "not
|
|
19
|
+
* there" for it, such as an unset config key or a ref that does not resolve,
|
|
20
|
+
* and those return `null` / `[]` / `false`. Every other non-zero exit throws
|
|
21
|
+
* the classified failure, so "git broke" is distinct from "nothing there".
|
|
22
|
+
* `git.try.*` is for callers that must tolerate failure. `git.soft.*` is for
|
|
23
|
+
* callers whose fallback is the verb's own absence value.
|
|
23
24
|
*
|
|
24
25
|
* The verb table in `./verbs.ts` is the single definition of every argv,
|
|
25
26
|
* every absence code and every parser, so the two clients cannot drift apart.
|
|
26
|
-
* The one exception is `remoteOwnerRepo`,
|
|
27
|
-
* `parseRemoteUrl
|
|
27
|
+
* The one exception is `remoteOwnerRepo`, which calls `remoteGetUrl` and then
|
|
28
|
+
* `parseRemoteUrl`, and is written in each client.
|
|
28
29
|
*
|
|
29
30
|
* Subpath exports: `./client` is everything here except the git-reference
|
|
30
31
|
* parsers and the checkout walks (and so without `hosted-git-info` on the
|
package/dist/index.js
CHANGED
|
@@ -2,29 +2,30 @@
|
|
|
2
2
|
* `@osdlc/typed-git` — a typed git client for TypeScript, in a synchronous
|
|
3
3
|
* and an awaitable form.
|
|
4
4
|
*
|
|
5
|
-
* Two clients
|
|
5
|
+
* Two clients with the same methods:
|
|
6
6
|
*
|
|
7
|
-
* - {@link Git} is synchronous and always
|
|
8
|
-
* one
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - {@link AsyncGit} is awaitable and takes a {@link GitBackend}
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* client
|
|
7
|
+
* - {@link Git} is synchronous and always runs the `git` CLI. Git calls run
|
|
8
|
+
* one after another gain nothing from being awaited, and a sync client
|
|
9
|
+
* does not force its callers to be async. It takes a `CommandRunner`, so
|
|
10
|
+
* tests can pass a fake.
|
|
11
|
+
* - {@link AsyncGit} is awaitable and takes a {@link GitBackend}, which
|
|
12
|
+
* replaces what performs git, not how a process is spawned. The default
|
|
13
|
+
* backend runs the CLI. Any other implementation works with the same
|
|
14
|
+
* client.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* else throws
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* for
|
|
16
|
+
* Both clients follow one contract. A declared absence returns a value,
|
|
17
|
+
* everything else throws, `try` returns the failure instead of throwing, and
|
|
18
|
+
* `raw` skips the checks. Each verb names the exit codes that mean "not
|
|
19
|
+
* there" for it, such as an unset config key or a ref that does not resolve,
|
|
20
|
+
* and those return `null` / `[]` / `false`. Every other non-zero exit throws
|
|
21
|
+
* the classified failure, so "git broke" is distinct from "nothing there".
|
|
22
|
+
* `git.try.*` is for callers that must tolerate failure. `git.soft.*` is for
|
|
23
|
+
* callers whose fallback is the verb's own absence value.
|
|
23
24
|
*
|
|
24
25
|
* The verb table in `./verbs.ts` is the single definition of every argv,
|
|
25
26
|
* every absence code and every parser, so the two clients cannot drift apart.
|
|
26
|
-
* The one exception is `remoteOwnerRepo`,
|
|
27
|
-
* `parseRemoteUrl
|
|
27
|
+
* The one exception is `remoteOwnerRepo`, which calls `remoteGetUrl` and then
|
|
28
|
+
* `parseRemoteUrl`, and is written in each client.
|
|
28
29
|
*
|
|
29
30
|
* Subpath exports: `./client` is everything here except the git-reference
|
|
30
31
|
* parsers and the checkout walks (and so without `hosted-git-info` on the
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `git.try.*` and `git.soft.*`, and the `Result<T, GitFailure>` that `try`
|
|
3
|
+
* returns.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* commit, a status endpoint that must always answer.
|
|
6
|
-
*
|
|
7
|
-
* here. Two rules
|
|
5
|
+
* `try` is for callers that must tolerate failure: a hook that must never
|
|
6
|
+
* break a commit, a status endpoint that must always answer. It wraps the
|
|
7
|
+
* whole client rather than being a per-verb option, so a new verb needs no
|
|
8
|
+
* code here. Two rules apply:
|
|
8
9
|
*
|
|
9
|
-
* - It catches a thrown git failure
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* {@link GitFailure}, whose `cause` is the
|
|
13
|
-
* from a programmer mistake
|
|
10
|
+
* - It catches a thrown git failure and nothing else. That is the
|
|
11
|
+
* `FailureError` the throwing methods raise, or a bare `CommandFailed`.
|
|
12
|
+
* Both are recognised by shape, so two installed copies of command-seam or
|
|
13
|
+
* result agree. It returns the {@link GitFailure}, whose `cause` is the
|
|
14
|
+
* `CommandFailed`. A `TypeError` from a programmer mistake still
|
|
15
|
+
* propagates.
|
|
14
16
|
* - A declared absence is `{ ok: true }`. `git.try.configGet("no.such.key")`
|
|
15
17
|
* is `{ ok: true, value: null }`, because absence is an answer, not a
|
|
16
18
|
* failure.
|
|
@@ -18,12 +20,11 @@
|
|
|
18
20
|
import { type Result } from '@osdlc/result';
|
|
19
21
|
import { type GitFailure } from './failure.ts';
|
|
20
22
|
/**
|
|
21
|
-
* The methods `try` mirrors: everything
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* included.
|
|
23
|
+
* The methods `try` mirrors: everything except `raw`, `rawChecked`, `at`,
|
|
24
|
+
* and `try` itself. `raw` already returns a `CommandResult` and never throws.
|
|
25
|
+
* `rawChecked` exists to throw. `at(cwd)` returns a new client that has its
|
|
26
|
+
* own `.try`. The types leave them out, but the runtime proxy wraps every
|
|
27
|
+
* function property, these included.
|
|
27
28
|
*/
|
|
28
29
|
type Triable<C> = Omit<C, 'raw' | 'rawChecked' | 'at' | 'try' | 'soft' | 'cwd'>;
|
|
29
30
|
/** Every synchronous client method, returning a `Result<T, GitFailure>`. */
|
|
@@ -43,15 +44,15 @@ export declare function triedAsync<C extends object>(client: C): TriedAsync<C>;
|
|
|
43
44
|
* a nullable, `false` for a boolean. A verb returning anything else (a
|
|
44
45
|
* record, a `Set`, free text) has no absence value, so it has no soft form.
|
|
45
46
|
*
|
|
46
|
-
*
|
|
47
|
-
* `soft.isDirty` reads a broken repo as clean and `soft.branchExists`
|
|
48
|
-
* "no such branch". Do not
|
|
49
|
-
*
|
|
47
|
+
* Take care with booleans. `false` is also the answer for "could not ask", so
|
|
48
|
+
* `soft.isDirty` reads a broken repo as clean and `soft.branchExists` reads it
|
|
49
|
+
* as "no such branch". Do not base a destructive action on a `false` from
|
|
50
|
+
* `soft`. Use `try` there.
|
|
50
51
|
*/
|
|
51
52
|
type SoftKind<R> = R extends readonly unknown[] ? 'empty' : null extends R ? 'null' : R extends boolean ? 'false' : never;
|
|
52
53
|
type Unwrap<R> = R extends Promise<infer U> ? U : R;
|
|
53
54
|
/**
|
|
54
|
-
* Methods left out of
|
|
55
|
+
* Methods left out of `soft` although their return type has an absence
|
|
55
56
|
* value. `configRemoveSection` is a mutation, and no mutation has a soft form.
|
|
56
57
|
*/
|
|
57
58
|
type NoSoftForm = 'configRemoveSection';
|
|
@@ -61,20 +62,21 @@ export type SoftKinds<C> = {
|
|
|
61
62
|
};
|
|
62
63
|
/**
|
|
63
64
|
* Every client method that has an absence value, returning that value
|
|
64
|
-
* instead of throwing
|
|
65
|
+
* instead of throwing the classified failure. One type for both clients: an
|
|
65
66
|
* awaitable method already returns a `Promise`.
|
|
66
67
|
*/
|
|
67
68
|
export type Soft<C> = {
|
|
68
69
|
[K in keyof SoftKinds<C>]: Triable<C>[K & keyof Triable<C>] extends (...a: infer A) => infer R ? (...a: A) => R : never;
|
|
69
70
|
};
|
|
70
71
|
/**
|
|
71
|
-
* The soft
|
|
72
|
-
* to.
|
|
73
|
-
* compile error
|
|
74
|
-
* compile
|
|
72
|
+
* The type of the `soft` table: which absence value each verb with a soft form
|
|
73
|
+
* falls back to. It is typed against the client, so a new list, nullable or
|
|
74
|
+
* boolean verb is a compile error until it is added, and a wrong entry does
|
|
75
|
+
* not compile. `Git` and `AsyncGit` read the same table, so they cannot
|
|
76
|
+
* differ.
|
|
75
77
|
*/
|
|
76
78
|
export type SoftTable = Record<string, 'empty' | 'null' | 'false'>;
|
|
77
|
-
/** A table that must name exactly the
|
|
79
|
+
/** A table that must name exactly the methods of `C` that have a soft form, each with the right kind. */
|
|
78
80
|
export type SoftTableFor<C> = SoftKinds<C>;
|
|
79
81
|
/** Wrap a synchronous client so a failed call returns the verb's absence value. */
|
|
80
82
|
export declare function softSync<C extends object>(client: C, table: SoftTable): Soft<C>;
|
package/dist/outcome.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `git.try.*` and `git.soft.*`, and the `Result<T, GitFailure>` that `try`
|
|
3
|
+
* returns.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* commit, a status endpoint that must always answer.
|
|
6
|
-
*
|
|
7
|
-
* here. Two rules
|
|
5
|
+
* `try` is for callers that must tolerate failure: a hook that must never
|
|
6
|
+
* break a commit, a status endpoint that must always answer. It wraps the
|
|
7
|
+
* whole client rather than being a per-verb option, so a new verb needs no
|
|
8
|
+
* code here. Two rules apply:
|
|
8
9
|
*
|
|
9
|
-
* - It catches a thrown git failure
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* {@link GitFailure}, whose `cause` is the
|
|
13
|
-
* from a programmer mistake
|
|
10
|
+
* - It catches a thrown git failure and nothing else. That is the
|
|
11
|
+
* `FailureError` the throwing methods raise, or a bare `CommandFailed`.
|
|
12
|
+
* Both are recognised by shape, so two installed copies of command-seam or
|
|
13
|
+
* result agree. It returns the {@link GitFailure}, whose `cause` is the
|
|
14
|
+
* `CommandFailed`. A `TypeError` from a programmer mistake still
|
|
15
|
+
* propagates.
|
|
14
16
|
* - A declared absence is `{ ok: true }`. `git.try.configGet("no.such.key")`
|
|
15
17
|
* is `{ ok: true, value: null }`, because absence is an answer, not a
|
|
16
18
|
* failure.
|
|
17
19
|
*/
|
|
18
20
|
import { err, ok } from '@osdlc/result';
|
|
19
21
|
import { thrownGitFailure } from "./failure.js";
|
|
20
|
-
/**
|
|
22
|
+
/** A thrown git failure becomes an `err`; anything else is thrown again. */
|
|
21
23
|
function asFailure(error) {
|
|
22
24
|
const failure = thrownGitFailure(error);
|
|
23
25
|
if (failure !== null)
|
|
@@ -26,15 +28,15 @@ function asFailure(error) {
|
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* A `Proxy` rather than a generated object: it mirrors whatever the client
|
|
29
|
-
* has, including
|
|
30
|
-
*
|
|
31
|
+
* has, including methods like `isDirty` that call other verbs, with no
|
|
32
|
+
* per-verb entry to keep in step. Methods are invoked on the
|
|
31
33
|
* client itself, not on the proxy, so private state stays reachable.
|
|
32
34
|
*/
|
|
33
35
|
function facade(client, wrap) {
|
|
34
36
|
return new Proxy(client, {
|
|
35
37
|
get(target, prop) {
|
|
36
38
|
// Read from the target, not the proxy: a getter (`try` itself) must run
|
|
37
|
-
// against the real client rather than recursing through the
|
|
39
|
+
// against the real client rather than recursing through the proxy.
|
|
38
40
|
const value = Reflect.get(target, prop);
|
|
39
41
|
if (typeof value !== 'function')
|
|
40
42
|
return value;
|
package/dist/remote-url.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host-agnostic reading of a git remote URL into its coordinate.
|
|
3
3
|
*
|
|
4
|
-
* `parseGitUrl` (git-url.ts) is
|
|
5
|
-
* fixed
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
4
|
+
* `parseGitUrl` (git-url.ts) is built on `hosted-git-info`, which knows only a
|
|
5
|
+
* fixed list of hosts and answers null for a self-hosted Forgejo or Gitea. A
|
|
6
|
+
* remote read from a checkout's own config is always a clone URL (scp-style or
|
|
7
|
+
* `scheme://`), so this parses that shape for any host and needs no
|
|
8
|
+
* dependency. That is why `Git.remoteOwnerRepo` uses it rather than
|
|
9
|
+
* `parseGitUrl`, and why it is on the `./client` entry.
|
|
10
10
|
*/
|
|
11
11
|
/** A remote clone URL split into where it lives and what it names. */
|
|
12
12
|
export interface RemoteCoordinate {
|
package/dist/remote-url.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host-agnostic reading of a git remote URL into its coordinate.
|
|
3
3
|
*
|
|
4
|
-
* `parseGitUrl` (git-url.ts) is
|
|
5
|
-
* fixed
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
4
|
+
* `parseGitUrl` (git-url.ts) is built on `hosted-git-info`, which knows only a
|
|
5
|
+
* fixed list of hosts and answers null for a self-hosted Forgejo or Gitea. A
|
|
6
|
+
* remote read from a checkout's own config is always a clone URL (scp-style or
|
|
7
|
+
* `scheme://`), so this parses that shape for any host and needs no
|
|
8
|
+
* dependency. That is why `Git.remoteOwnerRepo` uses it rather than
|
|
9
|
+
* `parseGitUrl`, and why it is on the `./client` entry.
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* Parses `git@host:owner/repo.git` (scp-style) and
|
package/dist/soft.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The soft
|
|
3
|
-
*
|
|
2
|
+
* The `soft` table: the one place that says which verbs have a `git.soft.*`
|
|
3
|
+
* form and what each falls back to.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* boolean
|
|
7
|
-
* is
|
|
5
|
+
* It is typed against both `Git` and `AsyncGit`. Adding a verb that returns
|
|
6
|
+
* a list, a nullable or a boolean to either client is a compile error here
|
|
7
|
+
* until it is added, so the two clients cannot have different `soft` methods.
|
|
8
8
|
* Mutations have no soft form, so `configRemoveSection` is not here.
|
|
9
9
|
*/
|
|
10
10
|
export declare const SOFT_TABLE: {
|
package/dist/soft.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The soft
|
|
3
|
-
*
|
|
2
|
+
* The `soft` table: the one place that says which verbs have a `git.soft.*`
|
|
3
|
+
* form and what each falls back to.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* boolean
|
|
7
|
-
* is
|
|
5
|
+
* It is typed against both `Git` and `AsyncGit`. Adding a verb that returns
|
|
6
|
+
* a list, a nullable or a boolean to either client is a compile error here
|
|
7
|
+
* until it is added, so the two clients cannot have different `soft` methods.
|
|
8
8
|
* Mutations have no soft form, so `configRemoveSection` is not here.
|
|
9
9
|
*/
|
|
10
10
|
export const SOFT_TABLE = {
|