type-git 0.3.0-beta.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/README.md +38 -18
- package/dist/adapters/bun/index.cjs +13187 -0
- package/dist/adapters/bun/index.cjs.map +1 -1
- package/dist/adapters/bun/index.d.cts +11 -6
- package/dist/adapters/bun/index.d.ts +11 -6
- package/dist/adapters/bun/index.js +13176 -0
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +13187 -0
- package/dist/adapters/deno/index.cjs.map +1 -1
- package/dist/adapters/deno/index.d.cts +11 -6
- package/dist/adapters/deno/index.d.ts +11 -6
- package/dist/adapters/deno/index.js +13176 -0
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +8231 -1249
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +8 -4268
- package/dist/adapters/node/index.d.ts +8 -4268
- package/dist/adapters/node/index.js +8231 -1249
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/client-KHa1WMIH.d.cts +12041 -0
- package/dist/client-KHa1WMIH.d.ts +12041 -0
- package/dist/index.cjs +8230 -1264
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8230 -1264
- package/dist/index.js.map +1 -1
- package/docs/migrations/0.4.0.md +93 -0
- package/package.json +9 -4
- package/dist/adapters-CZ8wj9Kr.d.cts +0 -850
- package/dist/adapters-CZ8wj9Kr.d.ts +0 -850
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Migrating to 0.4.0
|
|
2
|
+
|
|
3
|
+
0.4.0 strengthens the contract between typed inputs, Git's output, and return values. It contains source-breaking changes for callers using ambiguous repository flags, conflicting options, or alternate output formats. `raw()` remains available for arbitrary Git commands and returns unparsed stdout/stderr and the exit code.
|
|
4
|
+
|
|
5
|
+
## Repository types
|
|
6
|
+
|
|
7
|
+
Literal options still infer the precise repository type. A runtime boolean now returns `WorktreeRepo | BareRepo`. All repository objects expose a readonly `kind` discriminator:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const repo = await git.clone(url, destination, { bare: configuredBare });
|
|
11
|
+
if (repo.kind === 'worktree') {
|
|
12
|
+
await repo.status();
|
|
13
|
+
} else {
|
|
14
|
+
await repo.fetch();
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`git.openRaw()` can be narrowed the same way, without assertions or asynchronous type checks. Node, Bun, and Deno now all export `TypeGit` from their runtime subpaths, with identical overloads.
|
|
19
|
+
|
|
20
|
+
## Output modes and return types
|
|
21
|
+
|
|
22
|
+
| Call | 0.4.0 result |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| `repo.lsTree('HEAD')` | `LsTreeEntry[]` with actual object metadata |
|
|
25
|
+
| `repo.lsTree('HEAD', { long: true })` | Entries with blob sizes where available |
|
|
26
|
+
| `repo.lsTree('HEAD', { nameOnly: true })` | `string[]` of paths |
|
|
27
|
+
| `repo.lsTree('HEAD', { objectOnly: true })` | `string[]` of object IDs |
|
|
28
|
+
| `repo.diff(undefined, { nameOnly: true })` | `string[]` of paths |
|
|
29
|
+
| `repo.diff(undefined, { nameStatus: true })` | `DiffResult` with actual status, rename source, and similarity |
|
|
30
|
+
| `config.getRaw(key)` | `string | undefined` |
|
|
31
|
+
| `config.getRaw(key, { all: true })` | `string[]`, including `[]` for a missing key |
|
|
32
|
+
|
|
33
|
+
Variable output-mode options return a union. Narrow the result or branch before calling when a precise type is needed. Filename-only results no longer invent blob metadata or mark every change as modified.
|
|
34
|
+
|
|
35
|
+
Status, tree, and structured diff queries use NUL-delimited output internally. Paths retain spaces, quotes, tabs, newlines, and Unicode. `status()` uses porcelain v2; `porcelain: 1` and `nullTerminated: false` are rejected. `showStash` now exposes `stash` when Git emits the header.
|
|
36
|
+
|
|
37
|
+
## Conflicting and unsupported options
|
|
38
|
+
|
|
39
|
+
Conflicts are rejected by TypeScript and by `GitArgumentError` before Git runs. This includes protocol selection, shallow-fetch modes, `fetch({ all, remote })`, `push({ all, refspec })`, force versus force-with-lease, checkout/switch creation modes, conflict-side selection, commit message sources, rebase/sequencer controls, LFS all-versus-filter modes, and mixed rev-parse queries. False flags remain valid when they do not activate a competing mode.
|
|
40
|
+
|
|
41
|
+
Control calls such as `rebase({ abort: true })` cannot also carry mutation options such as `upstream`. Pathspec files are a separate input mode:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
await repo.add([], { pathspecFromFile: 'paths.txt' });
|
|
45
|
+
await repo.add(['src/index.ts']);
|
|
46
|
+
// Mixing the two input sources is rejected.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The typed API rejects these options; use `raw()` when that exact CLI behavior is needed:
|
|
50
|
+
|
|
51
|
+
| API | Options routed to `raw()` |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `lsRemote` | `getUrl`, `symref` (use `remote.getUrl()` for configured remote URLs) |
|
|
54
|
+
| `status` | `verbose` |
|
|
55
|
+
| `log` | `source`, `decorate`, `decorateRefs`, `decorateRefsExclude`, `stat`, `shortstat`, `nameOnly`, `nameStatus` |
|
|
56
|
+
| `fetch` | `multiple` |
|
|
57
|
+
| `commit` | `dryRun`, `reeditMessage` |
|
|
58
|
+
| `diff` | `noIndex` |
|
|
59
|
+
| `cherryPick`, `revert` | `noVerify` (Git does not support this flag for these commands) |
|
|
60
|
+
| `config.list` | `nameOnly` |
|
|
61
|
+
| `lfs.pull` | `ref` (pull operates on the checked-out ref; use `lfs.fetch` for other refs) |
|
|
62
|
+
| `lfs.status` | `porcelain` |
|
|
63
|
+
| `lfs.lsFiles` | `debug`, `nameOnly` |
|
|
64
|
+
|
|
65
|
+
For example, use `repo.raw(['commit', '--dry-run'])` to inspect a prospective commit, rather than receiving metadata for an unrelated existing HEAD. `diff`'s `mergeBase` option is now a boolean flag; pass the comparison revision as `target`.
|
|
66
|
+
|
|
67
|
+
This does not model every Git version or repository state in the type system. Unsupported flags on an older installed Git, missing refs, authentication failures, and network failures remain runtime Git errors. Numeric counts and limits are checked at runtime because plain TypeScript `number` includes negative, fractional, and non-finite values.
|
|
68
|
+
|
|
69
|
+
## Lossless values and explicit errors
|
|
70
|
+
|
|
71
|
+
- Commit bodies now retain their whitespace and control characters. Apply `.trim()` explicitly if your application needs the former trimmed behavior. `log()` fixes the wire format and suppresses notes, signatures, decorations, patches, and color. `useMailmap` selects mailmap-aware fields.
|
|
72
|
+
- The exported `GIT_LOG_FORMAT` / `parseGitLog()` contract now uses eleven NUL-delimited fields with `git log -z`; update custom callers and fixtures using the previous SOH record separator.
|
|
73
|
+
- `parseRecords('\0')` now returns `['']`, preserving one empty value.
|
|
74
|
+
- Config reads preserve empty values, multiline values, and surrounding whitespace. Config enum values are checked and common boolean spellings are normalized. `config.list()` retains requested origin and scope metadata. Use `getRaw()` for values outside `ConfigSchema`.
|
|
75
|
+
- Missing config keys produce `undefined` (scalar) or `[]` (all values). Malformed config and cancelled operations throw, rather than masquerading as missing values.
|
|
76
|
+
- Merge conflicts return `{ success: false, conflicts }`. Other merge failures throw `GitError`; cancellation is always `Aborted`.
|
|
77
|
+
- `commit({ quiet: true })` returns real statistics from machine-readable output. Stash metadata is obtained in one formatted command.
|
|
78
|
+
- Malformed structured status/tree/log/LFS output throws `ParseError` rather than silently dropping records. Spawn failures are normalized to `GitError`.
|
|
79
|
+
- Already-cancelled repository operations do not spawn Git. Cancelled clone/init calls preserve destinations that existed before the operation.
|
|
80
|
+
|
|
81
|
+
## Git LFS
|
|
82
|
+
|
|
83
|
+
`lfs.status()` and `lfs.lsFiles()` always request JSON. Explicit `json: true` is accepted; `json: false` is rejected. Use a Git LFS version supporting JSON for both commands.
|
|
84
|
+
|
|
85
|
+
`LfsStatus.files[].status` is the actual Git LFS status code (for example `A` or `M`). `size` is optional; an unknown size is no longer fabricated as zero. `lfs.lsFiles()` returns full OIDs and exact byte sizes from JSON. Empty file lists are handled explicitly.
|
|
86
|
+
|
|
87
|
+
`lfs.fetch()` honors `dryRun`, `refetch`, and `json`, combines include/exclude arrays into comma-separated filters, and requests progress through `GIT_LFS_FORCE_PROGRESS` rather than an unsupported `--progress` flag. Git and LFS callbacks remain separate: `onProgress` and `onLfsProgress`.
|
|
88
|
+
|
|
89
|
+
## Validation and coverage
|
|
90
|
+
|
|
91
|
+
`pnpm typecheck` includes compile-time acceptance/rejection tests for public overloads and option combinations. The same repository scenario runs on Node, Bun, and Deno, in addition to real-Git regression tests and package installation tests. CI includes Node 20/22/24 on Linux/Windows and a Git 2.25 compatibility job. Version-dependent features such as config scope and status stash headers require the corresponding Git support.
|
|
92
|
+
|
|
93
|
+
Git's machine-output specifications: [status](https://git-scm.com/docs/git-status), [ls-tree](https://git-scm.com/docs/git-ls-tree), [diff](https://git-scm.com/docs/git-diff), and [config](https://git-scm.com/docs/git-config).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Type-safe Git wrapper library with LFS support, progress tracking, and abort control for Node.js/Deno/Bun",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"files": [
|
|
60
60
|
"dist",
|
|
61
61
|
"README.md",
|
|
62
|
-
"LICENSE"
|
|
62
|
+
"LICENSE",
|
|
63
|
+
"docs/migrations"
|
|
63
64
|
],
|
|
64
65
|
"repository": {
|
|
65
66
|
"type": "git",
|
|
@@ -87,13 +88,17 @@
|
|
|
87
88
|
"format:check": "biome format src",
|
|
88
89
|
"check": "biome check src",
|
|
89
90
|
"check:fix": "biome check --write src",
|
|
90
|
-
"typecheck": "tsc --noEmit && pnpm test:types",
|
|
91
|
+
"typecheck": "pnpm constraints:check && pnpm commands:check && tsc --noEmit && pnpm test:types",
|
|
91
92
|
"docs:dev": "pnpm --filter type-git-docs dev",
|
|
92
93
|
"docs:build": "pnpm --filter type-git-docs build",
|
|
93
94
|
"docs:preview": "pnpm --filter type-git-docs preview",
|
|
94
95
|
"changeset": "changeset",
|
|
95
96
|
"version-packages": "changeset version",
|
|
96
97
|
"release": "changeset publish",
|
|
97
|
-
"test:types": "tsc --project
|
|
98
|
+
"test:types": "tsc --project tsconfig.contracts.json",
|
|
99
|
+
"constraints:generate": "node scripts/constraints.mjs && node scripts/command-coverage.mjs",
|
|
100
|
+
"constraints:check": "node scripts/constraints.mjs --check && node scripts/command-coverage.mjs --check",
|
|
101
|
+
"commands:generate": "node scripts/commands.mjs",
|
|
102
|
+
"commands:check": "node scripts/commands.mjs --check"
|
|
98
103
|
}
|
|
99
104
|
}
|