@aigne/afs-git 1.11.0-beta → 1.11.0-beta.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/LICENSE.md +17 -84
- package/README.md +0 -4
- package/dist/index.cjs +145 -20
- package/dist/index.d.cts +159 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +159 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +145 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/LICENSE.md
CHANGED
|
@@ -1,93 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
# Proprietary License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. Unauthorized copying, modification, distribution, or use of
|
|
7
|
+
this Software, via any medium, is strictly prohibited.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
The Software is provided for internal use only within ArcBlock, Inc. and its
|
|
10
|
+
authorized affiliates.
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## No License Granted
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
-
the limitations and conditions below.
|
|
14
|
+
No license, express or implied, is granted to any party for any purpose.
|
|
15
|
+
All rights are reserved by ArcBlock, Inc.
|
|
15
16
|
|
|
16
|
-
##
|
|
17
|
+
## Public Artifact Distribution
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Portions of this Software may be released publicly under separate open-source
|
|
20
|
+
licenses (such as MIT License) through designated public repositories. Such
|
|
21
|
+
public releases are governed by their respective licenses and do not affect
|
|
22
|
+
the proprietary nature of this repository.
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
-
software that is protected by the license key.
|
|
24
|
+
## Contact
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
-
to applicable law.
|
|
29
|
-
|
|
30
|
-
## Patents
|
|
31
|
-
|
|
32
|
-
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
-
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
-
sale, import and have imported the software, in each case subject to the
|
|
35
|
-
limitations and conditions in this license. This license does not cover any
|
|
36
|
-
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
-
the software. If you or your company make any written claim that the software
|
|
38
|
-
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
-
the software granted under these terms ends immediately. If your company makes
|
|
40
|
-
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
-
company.
|
|
42
|
-
|
|
43
|
-
## Notices
|
|
44
|
-
|
|
45
|
-
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
-
also gets a copy of these terms.
|
|
47
|
-
|
|
48
|
-
If you modify the software, you must include in any modified copies of the
|
|
49
|
-
software prominent notices stating that you have modified the software.
|
|
50
|
-
|
|
51
|
-
## No Other Rights
|
|
52
|
-
|
|
53
|
-
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
-
these terms.
|
|
55
|
-
|
|
56
|
-
## Termination
|
|
57
|
-
|
|
58
|
-
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
-
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
-
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
-
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
-
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
-
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
-
to terminate automatically and permanently.
|
|
65
|
-
|
|
66
|
-
## No Liability
|
|
67
|
-
|
|
68
|
-
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
-
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
-
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
-
legal claim.*
|
|
72
|
-
|
|
73
|
-
## Definitions
|
|
74
|
-
|
|
75
|
-
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
-
software the licensor makes available under these terms, including any portion
|
|
77
|
-
of it.
|
|
78
|
-
|
|
79
|
-
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
-
|
|
81
|
-
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
-
organization that you work for, plus all organizations that have control over,
|
|
83
|
-
are under the control of, or are under common control with that
|
|
84
|
-
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
-
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
-
otherwise. Control can be direct or indirect.
|
|
87
|
-
|
|
88
|
-
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
-
these terms.
|
|
90
|
-
|
|
91
|
-
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
-
|
|
93
|
-
**trademark** means trademarks, service marks, and similar rights.
|
|
26
|
+
For licensing inquiries, contact: legal@arcblock.io
|
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -9,11 +9,12 @@ let simple_git = require("simple-git");
|
|
|
9
9
|
let zod = require("zod");
|
|
10
10
|
|
|
11
11
|
//#region src/index.ts
|
|
12
|
-
const execFileAsync = (0, node_util.promisify)(node_child_process.execFile);
|
|
13
12
|
const LIST_MAX_LIMIT = 1e3;
|
|
13
|
+
const execFileAsync = (0, node_util.promisify)(node_child_process.execFile);
|
|
14
14
|
const afsGitOptionsSchema = (0, _aigne_afs_utils_zod.camelize)(zod.z.object({
|
|
15
15
|
name: (0, _aigne_afs_utils_zod.optionalize)(zod.z.string()),
|
|
16
|
-
repoPath: zod.z.string().describe("The path to the git repository"),
|
|
16
|
+
repoPath: (0, _aigne_afs_utils_zod.optionalize)(zod.z.string().describe("The path to the git repository")),
|
|
17
|
+
remoteUrl: (0, _aigne_afs_utils_zod.optionalize)(zod.z.string().describe("Remote repository URL (https or git protocol)")),
|
|
17
18
|
description: (0, _aigne_afs_utils_zod.optionalize)(zod.z.string().describe("A description of the repository")),
|
|
18
19
|
branches: (0, _aigne_afs_utils_zod.optionalize)(zod.z.array(zod.z.string()).describe("List of branches to expose")),
|
|
19
20
|
accessMode: (0, _aigne_afs_utils_zod.optionalize)(zod.z.enum(["readonly", "readwrite"]).describe("Access mode for this module")),
|
|
@@ -21,35 +22,107 @@ const afsGitOptionsSchema = (0, _aigne_afs_utils_zod.camelize)(zod.z.object({
|
|
|
21
22
|
commitAuthor: (0, _aigne_afs_utils_zod.optionalize)(zod.z.object({
|
|
22
23
|
name: zod.z.string(),
|
|
23
24
|
email: zod.z.string()
|
|
24
|
-
}))
|
|
25
|
-
|
|
25
|
+
})),
|
|
26
|
+
depth: (0, _aigne_afs_utils_zod.optionalize)(zod.z.number().describe("Clone depth for shallow clone")),
|
|
27
|
+
autoCleanup: (0, _aigne_afs_utils_zod.optionalize)(zod.z.boolean().describe("Automatically clean up cloned repository on cleanup()")),
|
|
28
|
+
cloneOptions: (0, _aigne_afs_utils_zod.optionalize)(zod.z.object({ auth: (0, _aigne_afs_utils_zod.optionalize)(zod.z.object({
|
|
29
|
+
username: (0, _aigne_afs_utils_zod.optionalize)(zod.z.string()),
|
|
30
|
+
password: (0, _aigne_afs_utils_zod.optionalize)(zod.z.string())
|
|
31
|
+
})) }))
|
|
32
|
+
}).refine((data) => data.repoPath || data.remoteUrl, { message: "Either repoPath or remoteUrl must be provided" }));
|
|
26
33
|
var AFSGit = class AFSGit {
|
|
27
34
|
static schema() {
|
|
28
35
|
return afsGitOptionsSchema;
|
|
29
36
|
}
|
|
30
37
|
static async load({ filepath, parsed }) {
|
|
31
|
-
|
|
38
|
+
const instance = new AFSGit({
|
|
32
39
|
...await AFSGit.schema().parseAsync(parsed),
|
|
33
40
|
cwd: (0, node_path.dirname)(filepath)
|
|
34
41
|
});
|
|
42
|
+
await instance.ready();
|
|
43
|
+
return instance;
|
|
35
44
|
}
|
|
45
|
+
initPromise;
|
|
36
46
|
git;
|
|
37
47
|
tempBase;
|
|
38
48
|
worktrees = /* @__PURE__ */ new Map();
|
|
39
49
|
repoHash;
|
|
50
|
+
isAutoCloned = false;
|
|
51
|
+
clonedPath;
|
|
52
|
+
repoPath;
|
|
40
53
|
constructor(options) {
|
|
41
54
|
this.options = options;
|
|
42
55
|
(0, _aigne_afs_utils_zod.zodParse)(afsGitOptionsSchema, options);
|
|
43
56
|
let repoPath;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
let repoName;
|
|
58
|
+
if (options.repoPath) {
|
|
59
|
+
repoPath = (0, node_path.isAbsolute)(options.repoPath) ? options.repoPath : (0, node_path.join)(options.cwd || process.cwd(), options.repoPath);
|
|
60
|
+
repoName = (0, node_path.basename)(repoPath);
|
|
61
|
+
} else if (options.remoteUrl) {
|
|
62
|
+
const urlParts = options.remoteUrl.split("/");
|
|
63
|
+
repoName = urlParts[urlParts.length - 1]?.replace(/\.git$/, "") || "git";
|
|
64
|
+
const repoHash = (0, node_crypto.createHash)("md5").update(options.remoteUrl).digest("hex").substring(0, 8);
|
|
65
|
+
repoPath = (0, node_path.join)((0, node_os.tmpdir)(), `afs-git-remote-${repoHash}`);
|
|
66
|
+
} else throw new Error("Either repoPath or remoteUrl must be provided");
|
|
67
|
+
this.repoPath = repoPath;
|
|
68
|
+
this.name = options.name || repoName;
|
|
48
69
|
this.description = options.description;
|
|
49
70
|
this.accessMode = options.accessMode ?? "readonly";
|
|
50
|
-
this.git = (0, simple_git.simpleGit)(repoPath);
|
|
51
71
|
this.repoHash = (0, node_crypto.createHash)("md5").update(repoPath).digest("hex").substring(0, 8);
|
|
52
72
|
this.tempBase = (0, node_path.join)((0, node_os.tmpdir)(), `afs-git-${this.repoHash}`);
|
|
73
|
+
this.git = null;
|
|
74
|
+
this.initPromise = this.initialize();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Wait for async initialization to complete
|
|
78
|
+
*/
|
|
79
|
+
async ready() {
|
|
80
|
+
await this.initPromise;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Async initialization logic (runs in constructor)
|
|
84
|
+
* Handles cloning remote repositories if needed
|
|
85
|
+
*/
|
|
86
|
+
async initialize() {
|
|
87
|
+
const options = this.options;
|
|
88
|
+
if (options.remoteUrl) {
|
|
89
|
+
const targetPath = options.repoPath ? (0, node_path.isAbsolute)(options.repoPath) ? options.repoPath : (0, node_path.join)(options.cwd || process.cwd(), options.repoPath) : this.repoPath;
|
|
90
|
+
if (!options.repoPath) this.isAutoCloned = true;
|
|
91
|
+
if (!await (0, node_fs_promises.stat)(targetPath).then(() => true).catch(() => false)) {
|
|
92
|
+
const singleBranch = options.branches?.length === 1 ? options.branches[0] : void 0;
|
|
93
|
+
await AFSGit.cloneRepository(options.remoteUrl, targetPath, {
|
|
94
|
+
depth: options.depth ?? 1,
|
|
95
|
+
branch: singleBranch,
|
|
96
|
+
auth: options.cloneOptions?.auth
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (targetPath !== this.repoPath) {
|
|
100
|
+
this.repoPath = targetPath;
|
|
101
|
+
this.repoHash = (0, node_crypto.createHash)("md5").update(targetPath).digest("hex").substring(0, 8);
|
|
102
|
+
this.tempBase = (0, node_path.join)((0, node_os.tmpdir)(), `afs-git-${this.repoHash}`);
|
|
103
|
+
}
|
|
104
|
+
this.clonedPath = this.isAutoCloned ? targetPath : void 0;
|
|
105
|
+
}
|
|
106
|
+
this.git = (0, simple_git.simpleGit)(this.repoPath);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Clone a remote repository to local path
|
|
110
|
+
*/
|
|
111
|
+
static async cloneRepository(remoteUrl, targetPath, options = {}) {
|
|
112
|
+
const git = (0, simple_git.simpleGit)();
|
|
113
|
+
const cloneArgs = [];
|
|
114
|
+
if (options.depth) cloneArgs.push("--depth", options.depth.toString());
|
|
115
|
+
if (options.branch) cloneArgs.push("--branch", options.branch, "--single-branch");
|
|
116
|
+
let cloneUrl = remoteUrl;
|
|
117
|
+
if (options.auth?.username && options.auth?.password) {
|
|
118
|
+
if (remoteUrl.startsWith("https://")) {
|
|
119
|
+
const url = new URL(remoteUrl);
|
|
120
|
+
url.username = encodeURIComponent(options.auth.username);
|
|
121
|
+
url.password = encodeURIComponent(options.auth.password);
|
|
122
|
+
cloneUrl = url.toString();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
await git.clone(cloneUrl, targetPath, cloneArgs);
|
|
53
126
|
}
|
|
54
127
|
name;
|
|
55
128
|
description;
|
|
@@ -136,8 +209,8 @@ var AFSGit = class AFSGit {
|
|
|
136
209
|
async ensureWorktree(branch) {
|
|
137
210
|
if (this.worktrees.has(branch)) return this.worktrees.get(branch);
|
|
138
211
|
if ((await this.git.revparse(["--abbrev-ref", "HEAD"])).trim() === branch) {
|
|
139
|
-
this.worktrees.set(branch, this.
|
|
140
|
-
return this.
|
|
212
|
+
this.worktrees.set(branch, this.repoPath);
|
|
213
|
+
return this.repoPath;
|
|
141
214
|
}
|
|
142
215
|
const worktreePath = (0, node_path.join)(this.tempBase, branch);
|
|
143
216
|
if (!await (0, node_fs_promises.stat)(worktreePath).then(() => true).catch(() => false)) {
|
|
@@ -242,18 +315,36 @@ var AFSGit = class AFSGit {
|
|
|
242
315
|
return `/${encodedBranch}/${filePath}`;
|
|
243
316
|
}
|
|
244
317
|
async list(path, options) {
|
|
318
|
+
await this.ready();
|
|
245
319
|
const { branch, filePath } = this.parsePath(path);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
320
|
+
const maxDepth = options?.maxDepth ?? 1;
|
|
321
|
+
const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);
|
|
322
|
+
if (!branch) {
|
|
323
|
+
const branches = await this.getBranches();
|
|
324
|
+
const entries = [];
|
|
325
|
+
for (const name of branches) {
|
|
326
|
+
if (entries.length >= limit) break;
|
|
327
|
+
const encodedPath = this.buildPath(name);
|
|
328
|
+
entries.push({
|
|
329
|
+
id: encodedPath,
|
|
330
|
+
path: encodedPath,
|
|
331
|
+
metadata: { type: "directory" }
|
|
332
|
+
});
|
|
333
|
+
if (maxDepth > 1) {
|
|
334
|
+
const branchResult = await this.listWithGitLsTree(name, "", {
|
|
335
|
+
...options,
|
|
336
|
+
maxDepth: maxDepth - 1,
|
|
337
|
+
limit: limit - entries.length
|
|
338
|
+
});
|
|
339
|
+
entries.push(...branchResult.data);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return { data: entries };
|
|
343
|
+
}
|
|
254
344
|
return this.listWithGitLsTree(branch, filePath, options);
|
|
255
345
|
}
|
|
256
346
|
async read(path, _options) {
|
|
347
|
+
await this.ready();
|
|
257
348
|
const { branch, filePath } = this.parsePath(path);
|
|
258
349
|
if (!branch) return { data: {
|
|
259
350
|
id: "/",
|
|
@@ -322,6 +413,7 @@ var AFSGit = class AFSGit {
|
|
|
322
413
|
}
|
|
323
414
|
}
|
|
324
415
|
async write(path, entry, options) {
|
|
416
|
+
await this.ready();
|
|
325
417
|
const { branch, filePath } = this.parsePath(path);
|
|
326
418
|
if (!branch || !filePath) throw new Error("Cannot write to root or branch root");
|
|
327
419
|
const worktreePath = await this.ensureWorktree(branch);
|
|
@@ -366,6 +458,7 @@ var AFSGit = class AFSGit {
|
|
|
366
458
|
} };
|
|
367
459
|
}
|
|
368
460
|
async delete(path, options) {
|
|
461
|
+
await this.ready();
|
|
369
462
|
const { branch, filePath } = this.parsePath(path);
|
|
370
463
|
if (!branch || !filePath) throw new Error("Cannot delete root or branch root");
|
|
371
464
|
const worktreePath = await this.ensureWorktree(branch);
|
|
@@ -388,6 +481,7 @@ var AFSGit = class AFSGit {
|
|
|
388
481
|
return { message: `Successfully deleted: ${path}` };
|
|
389
482
|
}
|
|
390
483
|
async rename(oldPath, newPath, options) {
|
|
484
|
+
await this.ready();
|
|
391
485
|
const { branch: oldBranch, filePath: oldFilePath } = this.parsePath(oldPath);
|
|
392
486
|
const { branch: newBranch, filePath: newFilePath } = this.parsePath(newPath);
|
|
393
487
|
if (!oldBranch || !oldFilePath) throw new Error("Cannot rename from root or branch root");
|
|
@@ -418,6 +512,7 @@ var AFSGit = class AFSGit {
|
|
|
418
512
|
return { message: `Successfully renamed '${oldPath}' to '${newPath}'` };
|
|
419
513
|
}
|
|
420
514
|
async search(path, query, options) {
|
|
515
|
+
await this.ready();
|
|
421
516
|
const { branch, filePath } = this.parsePath(path);
|
|
422
517
|
if (!branch) return {
|
|
423
518
|
data: [],
|
|
@@ -476,9 +571,32 @@ var AFSGit = class AFSGit {
|
|
|
476
571
|
}
|
|
477
572
|
}
|
|
478
573
|
/**
|
|
574
|
+
* Fetch latest changes from remote
|
|
575
|
+
*/
|
|
576
|
+
async fetch() {
|
|
577
|
+
await this.ready();
|
|
578
|
+
await this.git.fetch();
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Pull latest changes from remote for current branch
|
|
582
|
+
*/
|
|
583
|
+
async pull() {
|
|
584
|
+
await this.ready();
|
|
585
|
+
await this.git.pull();
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Push local changes to remote
|
|
589
|
+
*/
|
|
590
|
+
async push(branch) {
|
|
591
|
+
await this.ready();
|
|
592
|
+
if (branch) await this.git.push("origin", branch);
|
|
593
|
+
else await this.git.push();
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
479
596
|
* Cleanup all worktrees (useful when unmounting)
|
|
480
597
|
*/
|
|
481
598
|
async cleanup() {
|
|
599
|
+
await this.ready();
|
|
482
600
|
for (const [_branch, worktreePath] of this.worktrees) try {
|
|
483
601
|
await this.git.raw([
|
|
484
602
|
"worktree",
|
|
@@ -494,6 +612,13 @@ var AFSGit = class AFSGit {
|
|
|
494
612
|
force: true
|
|
495
613
|
});
|
|
496
614
|
} catch {}
|
|
615
|
+
const autoCleanup = this.options.autoCleanup ?? true;
|
|
616
|
+
if (this.isAutoCloned && autoCleanup && this.clonedPath) try {
|
|
617
|
+
await (0, node_fs_promises.rm)(this.clonedPath, {
|
|
618
|
+
recursive: true,
|
|
619
|
+
force: true
|
|
620
|
+
});
|
|
621
|
+
} catch {}
|
|
497
622
|
}
|
|
498
623
|
};
|
|
499
624
|
|
package/dist/index.d.cts
CHANGED
|
@@ -4,8 +4,28 @@ import { z } from "zod";
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
interface AFSGitOptions {
|
|
6
6
|
name?: string;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Local path to git repository.
|
|
9
|
+
* If remoteUrl is provided and repoPath doesn't exist, will clone to this path.
|
|
10
|
+
* If remoteUrl is provided and repoPath is not specified, clones to temp directory.
|
|
11
|
+
*/
|
|
12
|
+
repoPath?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Remote repository URL (https or git protocol).
|
|
15
|
+
* If provided, will clone the repository if repoPath doesn't exist.
|
|
16
|
+
* Examples:
|
|
17
|
+
* - https://github.com/user/repo.git
|
|
18
|
+
* - git@github.com:user/repo.git
|
|
19
|
+
*/
|
|
20
|
+
remoteUrl?: string;
|
|
8
21
|
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* List of branches to expose/access.
|
|
24
|
+
* Also used for clone optimization when cloning from remoteUrl:
|
|
25
|
+
* - Single branch (e.g., ['main']): Uses --single-branch for faster clone
|
|
26
|
+
* - Multiple branches: Clones all branches, filters access to specified ones
|
|
27
|
+
* - Not specified: All branches are accessible
|
|
28
|
+
*/
|
|
9
29
|
branches?: string[];
|
|
10
30
|
/**
|
|
11
31
|
* Access mode for this module.
|
|
@@ -26,14 +46,38 @@ interface AFSGitOptions {
|
|
|
26
46
|
name: string;
|
|
27
47
|
email: string;
|
|
28
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Clone depth for shallow clone (only used when cloning from remoteUrl)
|
|
51
|
+
* @default 1
|
|
52
|
+
*/
|
|
53
|
+
depth?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Automatically clean up cloned repository on cleanup()
|
|
56
|
+
* Only applies when repository was auto-cloned to temp directory
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
autoCleanup?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Git clone options (only used when cloning from remoteUrl)
|
|
62
|
+
*/
|
|
63
|
+
cloneOptions?: {
|
|
64
|
+
/**
|
|
65
|
+
* Authentication credentials for private repositories
|
|
66
|
+
*/
|
|
67
|
+
auth?: {
|
|
68
|
+
username?: string;
|
|
69
|
+
password?: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
29
72
|
}
|
|
30
73
|
declare class AFSGit implements AFSModule {
|
|
31
74
|
options: AFSGitOptions & {
|
|
32
75
|
cwd?: string;
|
|
33
76
|
};
|
|
34
|
-
static schema(): z.ZodEffects<z.ZodObject<{
|
|
77
|
+
static schema(): z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
35
78
|
name: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
36
|
-
repoPath: z.
|
|
79
|
+
repoPath: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
80
|
+
remoteUrl: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
37
81
|
description: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
38
82
|
branches: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
|
|
39
83
|
accessMode: z.ZodType<"readonly" | "readwrite" | undefined, z.ZodTypeDef, "readonly" | "readwrite" | undefined>;
|
|
@@ -45,9 +89,23 @@ declare class AFSGit implements AFSModule {
|
|
|
45
89
|
name: string;
|
|
46
90
|
email: string;
|
|
47
91
|
} | undefined>;
|
|
92
|
+
depth: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
93
|
+
autoCleanup: z.ZodType<boolean | undefined, z.ZodTypeDef, boolean | undefined>;
|
|
94
|
+
cloneOptions: z.ZodType<{
|
|
95
|
+
auth?: {
|
|
96
|
+
username?: string | undefined;
|
|
97
|
+
password?: string | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
} | undefined, z.ZodTypeDef, {
|
|
100
|
+
auth?: {
|
|
101
|
+
username?: string | undefined;
|
|
102
|
+
password?: string | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
} | undefined>;
|
|
48
105
|
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
repoPath: string;
|
|
50
106
|
name?: string | undefined;
|
|
107
|
+
repoPath?: string | undefined;
|
|
108
|
+
remoteUrl?: string | undefined;
|
|
51
109
|
description?: string | undefined;
|
|
52
110
|
branches?: string[] | undefined;
|
|
53
111
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
@@ -56,9 +114,18 @@ declare class AFSGit implements AFSModule {
|
|
|
56
114
|
name: string;
|
|
57
115
|
email: string;
|
|
58
116
|
} | undefined;
|
|
117
|
+
depth?: number | undefined;
|
|
118
|
+
autoCleanup?: boolean | undefined;
|
|
119
|
+
cloneOptions?: {
|
|
120
|
+
auth?: {
|
|
121
|
+
username?: string | undefined;
|
|
122
|
+
password?: string | undefined;
|
|
123
|
+
} | undefined;
|
|
124
|
+
} | undefined;
|
|
59
125
|
}, {
|
|
60
|
-
repoPath: string;
|
|
61
126
|
name?: string | undefined;
|
|
127
|
+
repoPath?: string | undefined;
|
|
128
|
+
remoteUrl?: string | undefined;
|
|
62
129
|
description?: string | undefined;
|
|
63
130
|
branches?: string[] | undefined;
|
|
64
131
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
@@ -67,9 +134,18 @@ declare class AFSGit implements AFSModule {
|
|
|
67
134
|
name: string;
|
|
68
135
|
email: string;
|
|
69
136
|
} | undefined;
|
|
137
|
+
depth?: number | undefined;
|
|
138
|
+
autoCleanup?: boolean | undefined;
|
|
139
|
+
cloneOptions?: {
|
|
140
|
+
auth?: {
|
|
141
|
+
username?: string | undefined;
|
|
142
|
+
password?: string | undefined;
|
|
143
|
+
} | undefined;
|
|
144
|
+
} | undefined;
|
|
70
145
|
}>, {
|
|
71
|
-
repoPath: string;
|
|
72
146
|
name?: string | undefined;
|
|
147
|
+
repoPath?: string | undefined;
|
|
148
|
+
remoteUrl?: string | undefined;
|
|
73
149
|
description?: string | undefined;
|
|
74
150
|
branches?: string[] | undefined;
|
|
75
151
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
@@ -78,18 +154,83 @@ declare class AFSGit implements AFSModule {
|
|
|
78
154
|
name: string;
|
|
79
155
|
email: string;
|
|
80
156
|
} | undefined;
|
|
157
|
+
depth?: number | undefined;
|
|
158
|
+
autoCleanup?: boolean | undefined;
|
|
159
|
+
cloneOptions?: {
|
|
160
|
+
auth?: {
|
|
161
|
+
username?: string | undefined;
|
|
162
|
+
password?: string | undefined;
|
|
163
|
+
} | undefined;
|
|
164
|
+
} | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
name?: string | undefined;
|
|
167
|
+
repoPath?: string | undefined;
|
|
168
|
+
remoteUrl?: string | undefined;
|
|
169
|
+
description?: string | undefined;
|
|
170
|
+
branches?: string[] | undefined;
|
|
171
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
172
|
+
autoCommit?: boolean | undefined;
|
|
173
|
+
commitAuthor?: {
|
|
174
|
+
name: string;
|
|
175
|
+
email: string;
|
|
176
|
+
} | undefined;
|
|
177
|
+
depth?: number | undefined;
|
|
178
|
+
autoCleanup?: boolean | undefined;
|
|
179
|
+
cloneOptions?: {
|
|
180
|
+
auth?: {
|
|
181
|
+
username?: string | undefined;
|
|
182
|
+
password?: string | undefined;
|
|
183
|
+
} | undefined;
|
|
184
|
+
} | undefined;
|
|
185
|
+
}>, {
|
|
186
|
+
name?: string | undefined;
|
|
187
|
+
repoPath?: string | undefined;
|
|
188
|
+
remoteUrl?: string | undefined;
|
|
189
|
+
description?: string | undefined;
|
|
190
|
+
branches?: string[] | undefined;
|
|
191
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
192
|
+
autoCommit?: boolean | undefined;
|
|
193
|
+
commitAuthor?: {
|
|
194
|
+
name: string;
|
|
195
|
+
email: string;
|
|
196
|
+
} | undefined;
|
|
197
|
+
depth?: number | undefined;
|
|
198
|
+
autoCleanup?: boolean | undefined;
|
|
199
|
+
cloneOptions?: {
|
|
200
|
+
auth?: {
|
|
201
|
+
username?: string | undefined;
|
|
202
|
+
password?: string | undefined;
|
|
203
|
+
} | undefined;
|
|
204
|
+
} | undefined;
|
|
81
205
|
}, any>;
|
|
82
206
|
static load({
|
|
83
207
|
filepath,
|
|
84
208
|
parsed
|
|
85
209
|
}: AFSModuleLoadParams): Promise<AFSGit>;
|
|
210
|
+
private initPromise;
|
|
86
211
|
private git;
|
|
87
212
|
private tempBase;
|
|
88
213
|
private worktrees;
|
|
89
214
|
private repoHash;
|
|
215
|
+
private isAutoCloned;
|
|
216
|
+
private clonedPath?;
|
|
217
|
+
private repoPath;
|
|
90
218
|
constructor(options: AFSGitOptions & {
|
|
91
219
|
cwd?: string;
|
|
92
220
|
});
|
|
221
|
+
/**
|
|
222
|
+
* Wait for async initialization to complete
|
|
223
|
+
*/
|
|
224
|
+
ready(): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Async initialization logic (runs in constructor)
|
|
227
|
+
* Handles cloning remote repositories if needed
|
|
228
|
+
*/
|
|
229
|
+
private initialize;
|
|
230
|
+
/**
|
|
231
|
+
* Clone a remote repository to local path
|
|
232
|
+
*/
|
|
233
|
+
private static cloneRepository;
|
|
93
234
|
name: string;
|
|
94
235
|
description?: string;
|
|
95
236
|
accessMode: AFSAccessMode;
|
|
@@ -138,6 +279,18 @@ declare class AFSGit implements AFSModule {
|
|
|
138
279
|
message?: string;
|
|
139
280
|
}>;
|
|
140
281
|
search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
|
|
282
|
+
/**
|
|
283
|
+
* Fetch latest changes from remote
|
|
284
|
+
*/
|
|
285
|
+
fetch(): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Pull latest changes from remote for current branch
|
|
288
|
+
*/
|
|
289
|
+
pull(): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Push local changes to remote
|
|
292
|
+
*/
|
|
293
|
+
push(branch?: string): Promise<void>;
|
|
141
294
|
/**
|
|
142
295
|
* Cleanup all worktrees (useful when unmounting)
|
|
143
296
|
*/
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UAiCiB,aAAA;EAAA,IAAA;EAAA;AA6GjB;;;;EA7GiB,QAAA;EAAA;AA6GjB;;;;;;EA7GiB,SAAA;EAAA,WAAA;EAAA;AA6GjB;;;;;;EA7GiB,QAAA;EAAA;AA6GjB;;;;;EA7GiB,UAAA,GA+BF,aAAA;EAAA;AA8Ef;;;EA9Ee,UAAA;EAAA;AA8Ef;;EA9Ee,YAAA;IAAA,IAAA;IAAA,KAAA;EAAA;EAAA;AA8Ef;;;EA9Ee,KAAA;EAAA;AA8Ef;;;;EA9Ee,WAAA;EAAA;AA8Ef;;EA9Ee,YAAA;IAAA;AA8Ef;;IA9Ee,IAAA;MAAA,QAAA;MAAA,QAAA;IAAA;EAAA;AAAA;AAAA,cA8EF,MAAA,YAAkB,SAAA;EAAA,OAAA,EAqBD,aAAA;IAAA,GAAA;EAAA;EAAA,OAAA,OAAA,GApBf,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;IAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAI2B,mBAAA,GAAmB,OAAA,CAAA,MAAA;EAAA,QAAA,WAAA;EAAA,QAAA,GAAA;EAAA,QAAA,QAAA;EAAA,QAAA,SAAA;EAAA,QAAA,QAAA;EAAA,QAAA,YAAA;EAAA,QAAA,UAAA;EAAA,QAAA,QAAA;EAAA,YAAA,OAAA,EAgB/B,aAAA;IAAA,GAAA;EAAA;EAAA;;;EAAA,MAAA,GAgDb,OAAA;EAAA;;;;EAAA,QAAA,UAAA;EAAA;;;EAAA,eAAA,eAAA;EAAA,IAAA;EAAA,WAAA;EAAA,UAAA,EAgGH,aAAA;EAAA;;;;;;;;;EAAA,QAAA,SAAA;EAAA;;;EAAA,QAAA,WAAA;EAAA;;;EAAA,QAAA,YAAA;EAAA;;;EAAA,QAAA,WAAA;EAAA;;;EAAA,QAAA,cAAA;EAAA;;;EAAA,QAAA,iBAAA;EAAA;;;;;;EAAA,QAAA,SAAA;EAAA,KAAA,IAAA,UAAA,OAAA,GA8PuB,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAAA,KAAA,IAAA,UAAA,QAAA,GAyCxB,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAAA,MAAA,IAAA,UAAA,KAAA,EAgGpD,oBAAA,EAAA,OAAA,GACG,eAAA,GACT,OAAA,CAAQ,cAAA;EAAA,OAAA,IAAA,UAAA,OAAA,GA2E0B,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EAAA,OAAA,OAAA,UAAA,OAAA,UAAA,OAAA,GAoDpD,gBAAA,GACT,OAAA;IAAA,OAAA;EAAA;EAAA,OAAA,IAAA,UAAA,KAAA,UAAA,OAAA,GAyEiD,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EAAA;;;EAAA,MAAA,GAuFhE,OAAA;EAAA;;;EAAA,KAAA,GAQD,OAAA;EAAA;;;EAAA,KAAA,MAAA,YAQe,OAAA;EAAA;;;EAAA,QAAA,GAYZ,OAAA;AAAA"}
|