gip-remote 1.2.2 → 1.2.3
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/index.d.ts +47 -7
- package/lib/drive.js +19 -10
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Readable } from 'streamx'
|
|
2
2
|
|
|
3
3
|
interface RemoteOpts {
|
|
4
|
-
name?: string
|
|
5
|
-
store: any
|
|
6
|
-
swarm: any
|
|
7
|
-
key?: Buffer
|
|
8
4
|
timeout?: number
|
|
9
|
-
blind?:
|
|
5
|
+
blind?: any
|
|
10
6
|
}
|
|
11
7
|
|
|
8
|
+
type RemoteLink =
|
|
9
|
+
| string
|
|
10
|
+
| { name: string; key?: Buffer }
|
|
11
|
+
| { drive: { key: Buffer }; pathname?: string }
|
|
12
|
+
|
|
12
13
|
interface GitObject {
|
|
13
14
|
oid: string
|
|
14
15
|
type: string
|
|
@@ -19,6 +20,7 @@ interface GitObject {
|
|
|
19
20
|
interface Ref {
|
|
20
21
|
ref: string
|
|
21
22
|
oid: string
|
|
23
|
+
symref?: string
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
interface RefObject extends GitObject {
|
|
@@ -26,13 +28,14 @@ interface RefObject extends GitObject {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
declare class Remote {
|
|
29
|
-
constructor(
|
|
31
|
+
constructor(store: any, link: RemoteLink, opts?: RemoteOpts)
|
|
30
32
|
|
|
31
33
|
readonly name: string
|
|
32
34
|
readonly core: any
|
|
33
35
|
readonly key: Buffer
|
|
34
36
|
readonly discoveryKey: Buffer
|
|
35
37
|
readonly availablePeers: number
|
|
38
|
+
readonly url: string
|
|
36
39
|
|
|
37
40
|
ready(): Promise<void>
|
|
38
41
|
close(): Promise<void>
|
|
@@ -42,11 +45,20 @@ declare class Remote {
|
|
|
42
45
|
commitOid: string,
|
|
43
46
|
objects: Map<string, { type: string; size: number; data: Buffer }>
|
|
44
47
|
): Promise<void>
|
|
48
|
+
|
|
49
|
+
getHead(): Promise<string | null>
|
|
50
|
+
setHead(branch: string): Promise<void>
|
|
51
|
+
|
|
45
52
|
getAllRefs(): Promise<Ref[]>
|
|
46
53
|
getBranchRef(branch: string): Promise<Ref | null>
|
|
54
|
+
deleteBranch(branchName: string): Promise<boolean>
|
|
55
|
+
|
|
47
56
|
getObject(oid: string): Promise<GitObject | null>
|
|
48
57
|
getRefObjects(commitOid: string, onLoad?: (size: number) => void): Promise<RefObject[]>
|
|
58
|
+
|
|
49
59
|
toDrive(branch: string): Promise<RemoteDrive | null>
|
|
60
|
+
|
|
61
|
+
update(): Promise<void>
|
|
50
62
|
waitForPeers(): Promise<void>
|
|
51
63
|
}
|
|
52
64
|
|
|
@@ -73,6 +85,22 @@ declare class RemoteDrive {
|
|
|
73
85
|
mirror(out: any, opts?: any): any
|
|
74
86
|
}
|
|
75
87
|
|
|
88
|
+
interface ParsedGitPearLink {
|
|
89
|
+
protocol: string
|
|
90
|
+
origin: string
|
|
91
|
+
pathname?: string
|
|
92
|
+
drive: {
|
|
93
|
+
key: Buffer
|
|
94
|
+
length: number
|
|
95
|
+
fork?: number | null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare const GitPearLink: {
|
|
100
|
+
parse(link: string): ParsedGitPearLink
|
|
101
|
+
serialize(o: ParsedGitPearLink): string
|
|
102
|
+
}
|
|
103
|
+
|
|
76
104
|
interface ToDiskOpts {
|
|
77
105
|
gitDir: string
|
|
78
106
|
objects: Array<{ type: string; id: string; size: number; data: Buffer }>
|
|
@@ -107,4 +135,16 @@ declare function walkTree(
|
|
|
107
135
|
prefix: string
|
|
108
136
|
): FileEntry[]
|
|
109
137
|
|
|
110
|
-
export { Remote, RemoteDrive, toDisk, parseCommit, walkTree }
|
|
138
|
+
export { Remote, RemoteDrive, GitPearLink, toDisk, parseCommit, walkTree }
|
|
139
|
+
export type {
|
|
140
|
+
RemoteOpts,
|
|
141
|
+
RemoteLink,
|
|
142
|
+
GitObject,
|
|
143
|
+
Ref,
|
|
144
|
+
RefObject,
|
|
145
|
+
DriveEntry,
|
|
146
|
+
ParsedGitPearLink,
|
|
147
|
+
ToDiskOpts,
|
|
148
|
+
Commit,
|
|
149
|
+
FileEntry
|
|
150
|
+
}
|
package/lib/drive.js
CHANGED
|
@@ -26,15 +26,7 @@ class RemoteDrive extends ReadyResource {
|
|
|
26
26
|
})
|
|
27
27
|
if (!record) return null
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
key,
|
|
31
|
-
value: {
|
|
32
|
-
executable: record.mode === '100755',
|
|
33
|
-
linkname: null,
|
|
34
|
-
blob: { byteLength: record.size },
|
|
35
|
-
metadata: null
|
|
36
|
-
}
|
|
37
|
-
}
|
|
29
|
+
return toEntry(key, record)
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
async get(nameOrEntry) {
|
|
@@ -89,7 +81,7 @@ class RemoteDrive extends ReadyResource {
|
|
|
89
81
|
try {
|
|
90
82
|
for await (const record of stream) {
|
|
91
83
|
if (ignore && ignore(record.path)) continue
|
|
92
|
-
this.push(record.path)
|
|
84
|
+
this.push(toEntry(record.path, record))
|
|
93
85
|
}
|
|
94
86
|
this.push(null)
|
|
95
87
|
cb(null)
|
|
@@ -130,4 +122,21 @@ class RemoteDrive extends ReadyResource {
|
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
|
|
125
|
+
function toEntry(key, record) {
|
|
126
|
+
return {
|
|
127
|
+
key,
|
|
128
|
+
value: {
|
|
129
|
+
executable: record.mode === '100755',
|
|
130
|
+
linkname: null,
|
|
131
|
+
blob: {
|
|
132
|
+
blockOffset: 0,
|
|
133
|
+
blockLength: 0,
|
|
134
|
+
byteOffset: 0,
|
|
135
|
+
byteLength: record.size
|
|
136
|
+
},
|
|
137
|
+
metadata: null
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
133
142
|
module.exports = RemoteDrive
|