@hologit/holo-tree 0.1.1 → 0.2.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 +19 -4
- package/index.d.ts +86 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -39,14 +39,26 @@ blob content crosses as `Buffer` (binary-safe).
|
|
|
39
39
|
| `repo.createTreeFromRef(ref)` → `Tree` | `repo::create_tree_from_ref` | resolves ref→commit→tree |
|
|
40
40
|
| `repo.createTree()` → `Tree` | `MutableTree::empty` | |
|
|
41
41
|
| `repo.commitTree(treeHash, parents[], msg)` → hash | `repo::commit_tree` | uses git-config identity |
|
|
42
|
-
| `repo.updateRef(ref, hash)` | `repo::update_ref` | |
|
|
42
|
+
| `repo.updateRef(ref, hash, expectedOldHash?)` | `repo::update_ref` | compare-and-swap when `expectedOldHash` given; force otherwise |
|
|
43
|
+
| `repo.resolveRef(ref)` → `hash\|null` | `repo::resolve_ref` | peels tags; `null` if unresolved |
|
|
44
|
+
| `repo.writeBlob(buf)` → hash | `gix write_blob` | hash bytes into the ODB, no tree |
|
|
43
45
|
| `tree.writeChild(path, text)` → hash | `MutableTree::write_child` | UTF-8 text |
|
|
44
46
|
| `tree.writeChildBytes(path, buf)` → hash | `MutableTree::write_child_bytes` | binary |
|
|
45
47
|
| `tree.readBlob(path)` → `Buffer\|null` | `MutableTree::read_blob` | |
|
|
48
|
+
| `tree.getChild(path)` → `{type,hash,mode}\|null` | `MutableTree::get_child` | read-only; deep path |
|
|
49
|
+
| `tree.getChildren(path)` → `[{name,type,hash,mode}]` | `get_subtree`+`ensure_children` | read-only; direct children |
|
|
50
|
+
| `tree.getBlobMap(path?)` → `[{path,hash,mode}]` | `get_subtree`+`get_blob_map` | read-only; paths relative to subtree |
|
|
46
51
|
| `tree.deleteChildDeep(path)` → bool | `MutableTree::delete_child_deep` | |
|
|
52
|
+
| `tree.clearChildren(path)` | `MutableTree::clear_children` | O(1) subtree wipe |
|
|
53
|
+
| `tree.merge(other, {files?, mode})` | `MutableTree::merge` | `mode`: `overlay`/`replace`/`underlay` |
|
|
47
54
|
| `tree.write()` → treeHash | `MutableTree::write` | |
|
|
48
55
|
| `emptyTreeHash()` → hash | `tree::empty_tree_id` | module fn |
|
|
49
56
|
|
|
57
|
+
`mode` values are the git filemode as a number (e.g. `33188` = `0o100644`). Tree
|
|
58
|
+
hashes reported by the read-only navigators reflect the last `write()`/load and
|
|
59
|
+
are stale for a subtree mutated since — flush with `write()` for canonical
|
|
60
|
+
hashes.
|
|
61
|
+
|
|
50
62
|
## Building
|
|
51
63
|
|
|
52
64
|
Requires a Rust toolchain and `@napi-rs/cli` (a devDependency):
|
|
@@ -102,7 +114,7 @@ exist on npm before trusted publishing can be turned on.
|
|
|
102
114
|
# platform packages first, then the main package:
|
|
103
115
|
for d in npm/*/ ; do ( cd "$d" && npm publish --access public ); done
|
|
104
116
|
npm publish --access public --ignore-scripts # main; skip the napi
|
|
105
|
-
# prepublish
|
|
117
|
+
# prepublish hook
|
|
106
118
|
```
|
|
107
119
|
|
|
108
120
|
3. **Turn on trusted publishing** on npmjs.com for **each** of the four packages
|
|
@@ -112,11 +124,14 @@ exist on npm before trusted publishing can be turned on.
|
|
|
112
124
|
### Releases (after bootstrap — fully automated, tokenless)
|
|
113
125
|
|
|
114
126
|
```sh
|
|
115
|
-
git tag holo-tree-v0.1.
|
|
127
|
+
git tag holo-tree-v0.1.1 && git push origin holo-tree-v0.1.1
|
|
116
128
|
```
|
|
117
129
|
|
|
118
130
|
The tag drives the published version; CI builds all three platforms, then
|
|
119
|
-
publishes via OIDC (provenance
|
|
131
|
+
publishes via OIDC (provenance). No secret needed. The `holo-tree-v*` tag is the
|
|
132
|
+
release marker — napi runs with `--skip-gh-release` so it does **not** create a
|
|
133
|
+
bare `v<version>` GitHub release/tag (which would collide with hologit's own
|
|
134
|
+
`v*` JS-package release namespace).
|
|
120
135
|
|
|
121
136
|
To add or drop a platform later, edit `napi.triples.additional` +
|
|
122
137
|
`optionalDependencies` in `package.json`, run `napi create-npm-dir -t .`, add the
|
package/index.d.ts
CHANGED
|
@@ -17,6 +17,41 @@ export interface Signature {
|
|
|
17
17
|
timeSeconds?: number
|
|
18
18
|
offsetMinutes?: number
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* A child entry returned by read-only navigation. `type` is `"tree"`,
|
|
22
|
+
* `"blob"`, or `"commit"`; `mode` is the git filemode as a number
|
|
23
|
+
* (e.g. `33188` = `0o100644`, `16384` = `0o040000` for a tree).
|
|
24
|
+
*/
|
|
25
|
+
export interface ChildInfo {
|
|
26
|
+
type: string
|
|
27
|
+
hash: string
|
|
28
|
+
mode: number
|
|
29
|
+
}
|
|
30
|
+
/** A named child entry, returned by `getChildren`. */
|
|
31
|
+
export interface NamedChildInfo {
|
|
32
|
+
name: string
|
|
33
|
+
type: string
|
|
34
|
+
hash: string
|
|
35
|
+
mode: number
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A blob entry in a flattened blob map, returned by `getBlobMap`. `path` is
|
|
39
|
+
* relative to the navigated subtree.
|
|
40
|
+
*/
|
|
41
|
+
export interface BlobEntry {
|
|
42
|
+
path: string
|
|
43
|
+
hash: string
|
|
44
|
+
mode: number
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for `Tree.merge`. `mode` is `"overlay"`, `"replace"`, or
|
|
48
|
+
* `"underlay"`; `files` is an optional list of glob patterns restricting which
|
|
49
|
+
* paths merge (omit to merge everything).
|
|
50
|
+
*/
|
|
51
|
+
export interface MergeOpts {
|
|
52
|
+
files?: Array<string>
|
|
53
|
+
mode: string
|
|
54
|
+
}
|
|
20
55
|
/**
|
|
21
56
|
* A handle to a git repository, backed by gix.
|
|
22
57
|
*
|
|
@@ -43,8 +78,28 @@ export declare class Repo {
|
|
|
43
78
|
* identity, then a "holo-tree" default. Returns the new commit hash.
|
|
44
79
|
*/
|
|
45
80
|
commitTree(treeHash: string, parents: Array<string>, message: string, author?: Signature | undefined | null, committer?: Signature | undefined | null): string
|
|
46
|
-
/**
|
|
47
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Point a ref at an object hash.
|
|
83
|
+
*
|
|
84
|
+
* When `expectedOldHash` is provided this is a **compare-and-swap**: the
|
|
85
|
+
* update only succeeds if the ref currently resolves to exactly that hash,
|
|
86
|
+
* so a concurrent writer who moved the ref makes the swap fail rather than
|
|
87
|
+
* silently clobbering their commit. Omit it to force the ref (the prior
|
|
88
|
+
* unconditional behavior).
|
|
89
|
+
*/
|
|
90
|
+
updateRef(refname: string, hash: string, expectedOldHash?: string | undefined | null): void
|
|
91
|
+
/**
|
|
92
|
+
* Resolve a ref / rev-spec (branch, tag, `HEAD`, hash, …) to its commit
|
|
93
|
+
* hash, peeling annotated tags. Returns `null` when the ref does not
|
|
94
|
+
* resolve — the natural "does this ref exist?" probe before a CAS
|
|
95
|
+
* `updateRef`.
|
|
96
|
+
*/
|
|
97
|
+
resolveRef(gitRef: string): string | null
|
|
98
|
+
/**
|
|
99
|
+
* Hash raw bytes as a loose blob in the ODB and return its hash, without
|
|
100
|
+
* inserting it into any tree. Binary-safe.
|
|
101
|
+
*/
|
|
102
|
+
writeBlob(content: Buffer): string
|
|
48
103
|
}
|
|
49
104
|
/**
|
|
50
105
|
* A mutable, in-memory git tree.
|
|
@@ -70,8 +125,37 @@ export declare class Tree {
|
|
|
70
125
|
writeChildBytes(path: string, content: Buffer): string
|
|
71
126
|
/** Read a blob's bytes at `path`, or `null` if no blob exists there. */
|
|
72
127
|
readBlob(path: string): Buffer | null
|
|
128
|
+
/**
|
|
129
|
+
* Read-only: look up the child at a deep `path` and report its type,
|
|
130
|
+
* hash, and mode, or `null` if nothing exists there.
|
|
131
|
+
*/
|
|
132
|
+
getChild(path: string): ChildInfo | null
|
|
133
|
+
/**
|
|
134
|
+
* Read-only: list the direct children of the subtree at `path` (use `"."`
|
|
135
|
+
* for the root). Returns an empty array if `path` is missing or not a tree.
|
|
136
|
+
*/
|
|
137
|
+
getChildren(path: string): Array<NamedChildInfo>
|
|
138
|
+
/**
|
|
139
|
+
* Read-only: recursively collect every blob under the subtree at `path`
|
|
140
|
+
* (defaults to the whole tree) into a flat list. Each `path` is relative
|
|
141
|
+
* to the navigated subtree. Returns an empty array if `path` is missing.
|
|
142
|
+
*/
|
|
143
|
+
getBlobMap(path?: string | undefined | null): Array<BlobEntry>
|
|
73
144
|
/** Delete a child at a deep `path`. Returns whether it existed. */
|
|
74
145
|
deleteChildDeep(path: string): boolean
|
|
146
|
+
/**
|
|
147
|
+
* Clear all children under a deep `path` in O(1) — replace the subtree
|
|
148
|
+
* there with the empty tree (and dirty its ancestors) without loading the
|
|
149
|
+
* cleared subtree's contents. `path == "."` clears the whole tree. Used to
|
|
150
|
+
* wipe a directory before a full rewrite.
|
|
151
|
+
*/
|
|
152
|
+
clearChildren(path: string): void
|
|
153
|
+
/**
|
|
154
|
+
* Merge another tree into this one in place, per `options.mode`
|
|
155
|
+
* (`overlay`/`replace`/`underlay`) and optional `options.files` globs.
|
|
156
|
+
* `other` must be a *different* `Tree` instance.
|
|
157
|
+
*/
|
|
158
|
+
merge(other: Tree, options: MergeOpts): void
|
|
75
159
|
/** Flush dirty subtrees to the ODB and return the resulting tree hash. */
|
|
76
160
|
write(): string
|
|
77
161
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hologit/holo-tree",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Node.js native binding for holo-tree — mutable in-memory git trees via gix",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"index.d.ts"
|
|
30
30
|
],
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@hologit/holo-tree-linux-x64-gnu": "0.
|
|
33
|
-
"@hologit/holo-tree-darwin-arm64": "0.
|
|
34
|
-
"@hologit/holo-tree-win32-x64-msvc": "0.
|
|
32
|
+
"@hologit/holo-tree-linux-x64-gnu": "0.2.0",
|
|
33
|
+
"@hologit/holo-tree-darwin-arm64": "0.2.0",
|
|
34
|
+
"@hologit/holo-tree-win32-x64-msvc": "0.2.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"artifacts": "napi artifacts",
|
|
38
38
|
"build": "napi build --platform --release",
|
|
39
39
|
"build:debug": "napi build --platform",
|
|
40
|
-
"prepublishOnly": "napi prepublish -t npm",
|
|
40
|
+
"prepublishOnly": "napi prepublish -t npm --skip-gh-release",
|
|
41
41
|
"test": "node --test test/",
|
|
42
42
|
"version": "napi version"
|
|
43
43
|
},
|