just-git 1.3.7 → 1.4.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 +17 -8
- package/dist/{hooks-DNBNCTgb.d.ts → hooks-C7c_BLqp.d.ts} +18 -62
- package/dist/index.d.ts +2 -2
- package/dist/index.js +322 -322
- package/dist/repo/index.d.ts +3 -148
- package/dist/repo/index.js +11 -11
- package/dist/server/index.d.ts +115 -78
- package/dist/server/index.js +70 -69
- package/dist/writing-CnM1ufDP.d.ts +204 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,17 @@ Both `fs` and `cwd` can be set once in `createGit` and overridden per-call. `cwd
|
|
|
61
61
|
|
|
62
62
|
### Server
|
|
63
63
|
|
|
64
|
-
Stand up a git server
|
|
64
|
+
Stand up a git server in two lines. Storage defaults to in-memory; swap in SQLite, PostgreSQL, or your own backend for persistence:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { createServer } from "just-git/server";
|
|
68
|
+
|
|
69
|
+
const server = createServer({ autoCreate: true });
|
|
70
|
+
Bun.serve({ fetch: server.fetch });
|
|
71
|
+
// git push http://localhost:3000/my-repo main ← repo created on first push
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Add branch protection, auth, and push hooks as needed:
|
|
65
75
|
|
|
66
76
|
```ts
|
|
67
77
|
import { createServer, BunSqliteStorage } from "just-git/server";
|
|
@@ -73,24 +83,23 @@ const server = createServer({
|
|
|
73
83
|
autoCreate: true,
|
|
74
84
|
policy: { protectedBranches: ["main"] },
|
|
75
85
|
hooks: {
|
|
76
|
-
preReceive: ({
|
|
77
|
-
if (!
|
|
86
|
+
preReceive: ({ auth }) => {
|
|
87
|
+
if (!auth.request?.headers.has("Authorization"))
|
|
78
88
|
return { reject: true, message: "unauthorized" };
|
|
79
89
|
},
|
|
80
|
-
postReceive: async ({ repo,
|
|
90
|
+
postReceive: async ({ repo, repoId, updates }) => {
|
|
81
91
|
for (const u of updates) {
|
|
82
92
|
const files = await getChangedFiles(repo, u.oldHash, u.newHash);
|
|
83
|
-
console.log(`${
|
|
93
|
+
console.log(`${repoId}: ${u.ref} — ${files.length} files changed`);
|
|
84
94
|
}
|
|
85
95
|
},
|
|
86
96
|
},
|
|
87
97
|
});
|
|
88
98
|
|
|
89
99
|
Bun.serve({ fetch: server.fetch });
|
|
90
|
-
// git clone http://localhost:3000/my-repo ← works with real git
|
|
91
100
|
```
|
|
92
101
|
|
|
93
|
-
Uses web-standard `Request`/`Response`. Works with Bun, Hono, Cloudflare Workers, or any fetch-compatible runtime. For Node.js, use `server.nodeHandler` with `http.createServer` and `BetterSqlite3Storage` for `better-sqlite3`. SSH is supported via `server.handleSession`. See [SERVER.md](docs/SERVER.md) for the full API.
|
|
102
|
+
Uses web-standard `Request`/`Response`. Works with Bun, Hono, Cloudflare Workers, or any fetch-compatible runtime. For Node.js, use `server.nodeHandler` with `http.createServer` and `BetterSqlite3Storage` for `better-sqlite3`. SSH is supported via `server.handleSession`. The [`Storage` interface](docs/SERVER.md#custom-storage) is small enough to plug in any datastore. See [SERVER.md](docs/SERVER.md) for the full API.
|
|
94
103
|
|
|
95
104
|
## Repo module
|
|
96
105
|
|
|
@@ -125,7 +134,7 @@ See [REPO.md](docs/REPO.md) for the full API, the `GitRepo` interface, and the h
|
|
|
125
134
|
- **Local paths**: direct filesystem transfer between repositories.
|
|
126
135
|
- **Cross-VFS**: clone, fetch, and push between isolated in-memory filesystems via `resolveRemote`. See [CLIENT.md](docs/CLIENT.md#multi-agent-collaboration).
|
|
127
136
|
- **Smart HTTP**: clone, fetch, and push against real Git servers (e.g. GitHub) via Git Smart HTTP protocol. Auth via `credentials` option or `GIT_HTTP_BEARER_TOKEN` / `GIT_HTTP_USER` + `GIT_HTTP_PASSWORD` env vars.
|
|
128
|
-
- **In-process server**: connect a git client to a `GitServer` without any network stack via `server.asNetwork()`. All server hooks,
|
|
137
|
+
- **In-process server**: connect a git client to a `GitServer` without any network stack via `server.asNetwork()`. All server hooks, auth, and policy enforcement work identically to real HTTP. See [CLIENT.md](docs/CLIENT.md#in-process-server).
|
|
129
138
|
|
|
130
139
|
### Internals
|
|
131
140
|
|
|
@@ -389,7 +389,7 @@ interface PostCommitEvent {
|
|
|
389
389
|
/** Fired before a three-way merge commit is written. Return a {@link Rejection} to block. */
|
|
390
390
|
interface PreMergeCommitEvent {
|
|
391
391
|
readonly repo: GitRepo;
|
|
392
|
-
readonly
|
|
392
|
+
readonly message: string;
|
|
393
393
|
readonly treeHash: ObjectId;
|
|
394
394
|
readonly headHash: ObjectId;
|
|
395
395
|
readonly theirsHash: ObjectId;
|
|
@@ -435,7 +435,7 @@ interface PreRebaseEvent {
|
|
|
435
435
|
interface PreCheckoutEvent {
|
|
436
436
|
readonly repo: GitRepo;
|
|
437
437
|
readonly target: string;
|
|
438
|
-
readonly mode: "switch" | "detach" | "create-branch"
|
|
438
|
+
readonly mode: "switch" | "detach" | "create-branch";
|
|
439
439
|
}
|
|
440
440
|
/** Fired before a fetch begins. Return a {@link Rejection} to block. */
|
|
441
441
|
interface PreFetchEvent {
|
|
@@ -451,7 +451,7 @@ interface PostFetchEvent {
|
|
|
451
451
|
readonly repo: GitRepo;
|
|
452
452
|
readonly remote: string;
|
|
453
453
|
readonly url: string;
|
|
454
|
-
readonly
|
|
454
|
+
readonly updatedRefCount: number;
|
|
455
455
|
}
|
|
456
456
|
/** Fired before a clone begins. Return a {@link Rejection} to block. */
|
|
457
457
|
interface PreCloneEvent {
|
|
@@ -487,7 +487,7 @@ interface PostPullEvent {
|
|
|
487
487
|
interface PreResetEvent {
|
|
488
488
|
readonly repo: GitRepo;
|
|
489
489
|
readonly mode: "soft" | "mixed" | "hard" | "paths";
|
|
490
|
-
readonly
|
|
490
|
+
readonly targetRef: string | null;
|
|
491
491
|
}
|
|
492
492
|
/** Fired after a reset completes. */
|
|
493
493
|
interface PostResetEvent {
|
|
@@ -495,72 +495,34 @@ interface PostResetEvent {
|
|
|
495
495
|
readonly mode: "soft" | "mixed" | "hard" | "paths";
|
|
496
496
|
readonly targetHash: ObjectId | null;
|
|
497
497
|
}
|
|
498
|
-
/**
|
|
499
|
-
interface
|
|
500
|
-
readonly repo: GitRepo;
|
|
501
|
-
readonly dryRun: boolean;
|
|
502
|
-
readonly force: boolean;
|
|
503
|
-
readonly removeDirs: boolean;
|
|
504
|
-
readonly removeIgnored: boolean;
|
|
505
|
-
readonly onlyIgnored: boolean;
|
|
506
|
-
}
|
|
507
|
-
/** Fired after `git clean` completes. */
|
|
508
|
-
interface PostCleanEvent {
|
|
498
|
+
/** Base type for pre-hooks that apply a commit (cherry-pick, revert). */
|
|
499
|
+
interface PreApplyEvent {
|
|
509
500
|
readonly repo: GitRepo;
|
|
510
|
-
readonly
|
|
511
|
-
readonly
|
|
501
|
+
readonly mode: string;
|
|
502
|
+
readonly commitRef: string | null;
|
|
512
503
|
}
|
|
513
|
-
/**
|
|
514
|
-
interface
|
|
504
|
+
/** Base type for post-hooks that apply a commit (cherry-pick, revert). */
|
|
505
|
+
interface PostApplyEvent {
|
|
515
506
|
readonly repo: GitRepo;
|
|
516
|
-
readonly
|
|
517
|
-
readonly
|
|
518
|
-
readonly
|
|
519
|
-
readonly force: boolean;
|
|
520
|
-
}
|
|
521
|
-
/** Fired after `git rm` completes. */
|
|
522
|
-
interface PostRmEvent {
|
|
523
|
-
readonly repo: GitRepo;
|
|
524
|
-
readonly removedPaths: readonly string[];
|
|
525
|
-
readonly cached: boolean;
|
|
507
|
+
readonly mode: string;
|
|
508
|
+
readonly commitHash: ObjectId | null;
|
|
509
|
+
readonly hadConflicts: boolean;
|
|
526
510
|
}
|
|
527
511
|
/** Fired before a cherry-pick. Return a {@link Rejection} to block. */
|
|
528
|
-
interface PreCherryPickEvent {
|
|
529
|
-
readonly repo: GitRepo;
|
|
512
|
+
interface PreCherryPickEvent extends PreApplyEvent {
|
|
530
513
|
readonly mode: "pick" | "continue" | "abort";
|
|
531
|
-
readonly commit: string | null;
|
|
532
514
|
}
|
|
533
515
|
/** Fired after a cherry-pick completes. */
|
|
534
|
-
interface PostCherryPickEvent {
|
|
535
|
-
readonly repo: GitRepo;
|
|
516
|
+
interface PostCherryPickEvent extends PostApplyEvent {
|
|
536
517
|
readonly mode: "pick" | "continue" | "abort";
|
|
537
|
-
readonly commitHash: ObjectId | null;
|
|
538
|
-
readonly hadConflicts: boolean;
|
|
539
518
|
}
|
|
540
519
|
/** Fired before a revert. Return a {@link Rejection} to block. */
|
|
541
|
-
interface PreRevertEvent {
|
|
542
|
-
readonly repo: GitRepo;
|
|
520
|
+
interface PreRevertEvent extends PreApplyEvent {
|
|
543
521
|
readonly mode: "revert" | "continue" | "abort";
|
|
544
|
-
readonly commit: string | null;
|
|
545
522
|
}
|
|
546
523
|
/** Fired after a revert completes. */
|
|
547
|
-
interface PostRevertEvent {
|
|
548
|
-
readonly repo: GitRepo;
|
|
524
|
+
interface PostRevertEvent extends PostApplyEvent {
|
|
549
525
|
readonly mode: "revert" | "continue" | "abort";
|
|
550
|
-
readonly commitHash: ObjectId | null;
|
|
551
|
-
readonly hadConflicts: boolean;
|
|
552
|
-
}
|
|
553
|
-
/** Fired before a stash operation. Return a {@link Rejection} to block. */
|
|
554
|
-
interface PreStashEvent {
|
|
555
|
-
readonly repo: GitRepo;
|
|
556
|
-
readonly action: "push" | "pop" | "apply" | "list" | "drop" | "show" | "clear";
|
|
557
|
-
readonly ref: string | null;
|
|
558
|
-
}
|
|
559
|
-
/** Fired after a stash operation completes. */
|
|
560
|
-
interface PostStashEvent {
|
|
561
|
-
readonly repo: GitRepo;
|
|
562
|
-
readonly action: "push" | "pop" | "apply" | "list" | "drop" | "show" | "clear";
|
|
563
|
-
readonly ok: boolean;
|
|
564
526
|
}
|
|
565
527
|
/** Fired whenever a ref is created or updated. */
|
|
566
528
|
interface RefUpdateEvent {
|
|
@@ -620,11 +582,8 @@ interface GitHooks {
|
|
|
620
582
|
prePull?: (event: PrePullEvent) => PreHookReturn;
|
|
621
583
|
preRebase?: (event: PreRebaseEvent) => PreHookReturn;
|
|
622
584
|
preReset?: (event: PreResetEvent) => PreHookReturn;
|
|
623
|
-
preClean?: (event: PreCleanEvent) => PreHookReturn;
|
|
624
|
-
preRm?: (event: PreRmEvent) => PreHookReturn;
|
|
625
585
|
preCherryPick?: (event: PreCherryPickEvent) => PreHookReturn;
|
|
626
586
|
preRevert?: (event: PreRevertEvent) => PreHookReturn;
|
|
627
|
-
preStash?: (event: PreStashEvent) => PreHookReturn;
|
|
628
587
|
postCommit?: (event: PostCommitEvent) => PostHookReturn;
|
|
629
588
|
postMerge?: (event: PostMergeEvent) => PostHookReturn;
|
|
630
589
|
postCheckout?: (event: PostCheckoutEvent) => PostHookReturn;
|
|
@@ -633,11 +592,8 @@ interface GitHooks {
|
|
|
633
592
|
postClone?: (event: PostCloneEvent) => PostHookReturn;
|
|
634
593
|
postPull?: (event: PostPullEvent) => PostHookReturn;
|
|
635
594
|
postReset?: (event: PostResetEvent) => PostHookReturn;
|
|
636
|
-
postClean?: (event: PostCleanEvent) => PostHookReturn;
|
|
637
|
-
postRm?: (event: PostRmEvent) => PostHookReturn;
|
|
638
595
|
postCherryPick?: (event: PostCherryPickEvent) => PostHookReturn;
|
|
639
596
|
postRevert?: (event: PostRevertEvent) => PostHookReturn;
|
|
640
|
-
postStash?: (event: PostStashEvent) => PostHookReturn;
|
|
641
597
|
onRefUpdate?: (event: RefUpdateEvent) => void;
|
|
642
598
|
onRefDelete?: (event: RefDeleteEvent) => void;
|
|
643
599
|
onObjectWrite?: (event: ObjectWriteEvent) => void;
|
|
@@ -653,4 +609,4 @@ interface GitHooks {
|
|
|
653
609
|
*/
|
|
654
610
|
declare function composeGitHooks(...hookSets: (GitHooks | undefined)[]): GitHooks;
|
|
655
611
|
|
|
656
|
-
export { type
|
|
612
|
+
export { type Rejection as $, type AfterCommandEvent as A, type BeforeCommandEvent as B, type CredentialProvider as C, type DirectRef as D, type ExecResult as E, type FileSystem as F, type GitHooks as G, type HttpAuth as H, type IdentityOverride as I, type PreCommitEvent as J, type PreFetchEvent as K, type PreMergeCommitEvent as L, type MergeMsgEvent as M, type NetworkPolicy as N, type ObjectStore as O, type PackObject as P, type PrePullEvent as Q, type RemoteResolver as R, type PrePushEvent as S, type PreRebaseEvent as T, type PreResetEvent as U, type PreRevertEvent as V, type RawObject as W, type Ref as X, type RefDeleteEvent as Y, type RefEntry as Z, type RefUpdateEvent as _, type RefStore as a, type SymbolicRef as a0, composeGitHooks as a1, isRejection as a2, type TreeEntry as a3, type TreeDiffEntry as a4, type ConfigOverrides as b, type FileStat as c, type GitContext as d, type Commit as e, type CommitMsgEvent as f, type GitRepo as g, type Identity as h, type ObjectId as i, type ObjectType as j, type ObjectWriteEvent as k, type PostApplyEvent as l, type PostCheckoutEvent as m, type PostCherryPickEvent as n, type PostCloneEvent as o, type PostCommitEvent as p, type PostFetchEvent as q, type PostMergeEvent as r, type PostPullEvent as s, type PostPushEvent as t, type PostResetEvent as u, type PostRevertEvent as v, type PreApplyEvent as w, type PreCheckoutEvent as x, type PreCherryPickEvent as y, type PreCloneEvent as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, E as ExecResult, c as FileStat, d as GitContext } from './hooks-
|
|
2
|
-
export { A as AfterCommandEvent, B as BeforeCommandEvent, e as Commit, f as CommitMsgEvent, D as DirectRef, g as GitRepo, H as HttpAuth, h as Identity, M as MergeMsgEvent, i as ObjectId, j as ObjectType, k as ObjectWriteEvent, P as PackObject, l as
|
|
1
|
+
import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, E as ExecResult, c as FileStat, d as GitContext } from './hooks-C7c_BLqp.js';
|
|
2
|
+
export { A as AfterCommandEvent, B as BeforeCommandEvent, e as Commit, f as CommitMsgEvent, D as DirectRef, g as GitRepo, H as HttpAuth, h as Identity, M as MergeMsgEvent, i as ObjectId, j as ObjectType, k as ObjectWriteEvent, P as PackObject, l as PostApplyEvent, m as PostCheckoutEvent, n as PostCherryPickEvent, o as PostCloneEvent, p as PostCommitEvent, q as PostFetchEvent, r as PostMergeEvent, s as PostPullEvent, t as PostPushEvent, u as PostResetEvent, v as PostRevertEvent, w as PreApplyEvent, x as PreCheckoutEvent, y as PreCherryPickEvent, z as PreCloneEvent, J as PreCommitEvent, K as PreFetchEvent, L as PreMergeCommitEvent, Q as PrePullEvent, S as PrePushEvent, T as PreRebaseEvent, U as PreResetEvent, V as PreRevertEvent, W as RawObject, X as Ref, Y as RefDeleteEvent, Z as RefEntry, _ as RefUpdateEvent, $ as Rejection, a0 as SymbolicRef, a1 as composeGitHooks, a2 as isRejection } from './hooks-C7c_BLqp.js';
|
|
3
3
|
|
|
4
4
|
/** Options for subcommand execution (mirrors just-bash's CommandExecOptions). */
|
|
5
5
|
interface CommandExecOptions {
|