@filen/sync 0.1.1 → 0.1.4
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 +661 -661
- package/README.md +1 -1
- package/SECURITY.md +17 -17
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +51 -1
- package/dist/constants.js.map +1 -1
- package/dist/ignorer.d.ts +14 -0
- package/dist/ignorer.js +69 -0
- package/dist/ignorer.js.map +1 -0
- package/dist/index.d.ts +31 -17
- package/dist/index.js +125 -24
- package/dist/index.js.map +1 -1
- package/dist/lib/deltas.d.ts +9 -31
- package/dist/lib/deltas.js +194 -99
- package/dist/lib/deltas.js.map +1 -1
- package/dist/lib/filesystems/local.d.ts +32 -43
- package/dist/lib/filesystems/local.js +383 -106
- package/dist/lib/filesystems/local.js.map +1 -1
- package/dist/lib/filesystems/remote.d.ts +21 -7
- package/dist/lib/filesystems/remote.js +531 -67
- package/dist/lib/filesystems/remote.js.map +1 -1
- package/dist/lib/ipc.d.ts +9 -0
- package/dist/lib/ipc.js +60 -0
- package/dist/lib/ipc.js.map +1 -0
- package/dist/lib/lock.d.ts +13 -0
- package/dist/lib/lock.js +73 -0
- package/dist/lib/lock.js.map +1 -0
- package/dist/lib/logger.d.ts +14 -0
- package/dist/lib/logger.js +93 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/state.d.ts +4 -15
- package/dist/lib/state.js +106 -87
- package/dist/lib/state.js.map +1 -1
- package/dist/lib/sync.d.ts +30 -10
- package/dist/lib/sync.js +363 -36
- package/dist/lib/sync.js.map +1 -1
- package/dist/lib/tasks.d.ts +27 -40
- package/dist/lib/tasks.js +397 -48
- package/dist/lib/tasks.js.map +1 -1
- package/dist/types.d.ts +340 -0
- package/dist/utils.d.ts +42 -0
- package/dist/utils.js +164 -1
- package/dist/utils.js.map +1 -1
- package/index.d.ts +6 -295
- package/jest.config.js +5 -0
- package/package.json +62 -58
- package/tests/utils.test.ts +33 -0
- package/tsconfig.json +24 -24
package/index.d.ts
CHANGED
|
@@ -1,298 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SyncMessage } from "./src/types"
|
|
2
2
|
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
mode: number
|
|
9
|
-
uid: number
|
|
10
|
-
gid: number
|
|
11
|
-
size: number
|
|
12
|
-
dev: number
|
|
13
|
-
nlink: number
|
|
14
|
-
ino: number
|
|
15
|
-
rdev: number
|
|
16
|
-
blksize: number
|
|
17
|
-
blocks: number
|
|
18
|
-
atime: Date
|
|
19
|
-
mtime: Date
|
|
20
|
-
ctime: Date
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface OPERATIONS {
|
|
24
|
-
init?: (cb: (err: number) => void) => void
|
|
25
|
-
error?: (cb: (err: number) => void) => void
|
|
26
|
-
access?: (path: string, mode: number, cb: (err: number) => void) => void
|
|
27
|
-
statfs?: (
|
|
28
|
-
path: string,
|
|
29
|
-
cb: (
|
|
30
|
-
err: number,
|
|
31
|
-
stats?: {
|
|
32
|
-
bsize: number
|
|
33
|
-
frsize: number
|
|
34
|
-
blocks: number
|
|
35
|
-
bfree: number
|
|
36
|
-
bavail: number
|
|
37
|
-
files: number
|
|
38
|
-
ffree: number
|
|
39
|
-
favail: number
|
|
40
|
-
fsid: number
|
|
41
|
-
flag: number
|
|
42
|
-
namemax: number
|
|
43
|
-
}
|
|
44
|
-
) => void
|
|
45
|
-
) => void
|
|
46
|
-
fgetattr?: (path: string, fd: number, cb: (err: number, stat?: Stats) => void) => void
|
|
47
|
-
getattr?: (path: string, cb: (err: number, stat?: Stats) => void) => void
|
|
48
|
-
flush?: (path: string, fd: number, cb: (err: number) => void) => void
|
|
49
|
-
fsync?: (path: string, dataSync: boolean, fd: number, cb: (err: number) => void) => void
|
|
50
|
-
fsyncdir?: (path: string, dataSync: boolean, fd: number, cb: (err: number) => void) => void
|
|
51
|
-
readdir?: (path: string, cb: (err: number, names?: string[], stats?: Stats[]) => void) => void
|
|
52
|
-
truncate?: (path: string, size: number, cb: (err: number) => void) => void
|
|
53
|
-
ftruncate?: (path: string, fd: number, size: number, cb: (err: number) => void) => void
|
|
54
|
-
utimens?: (path: string, atime: Date, mtime: Date, cb: (err: number) => void) => void
|
|
55
|
-
readlink?: (path: string, cb: (err: number, linkName?: string) => void) => void
|
|
56
|
-
chown?: (path: string, uid: number, gid: number, cb: (err: number) => void) => void
|
|
57
|
-
chmod?: (path: string, mode: number, cb: (err: number) => void) => void
|
|
58
|
-
mknod?: (path: string, mode: number, dev: number, cb: (err: number) => void) => void
|
|
59
|
-
setxattr?: (path: string, name: string, value: Buffer, size: number, flags: number, cb: (err: number) => void) => void
|
|
60
|
-
getxattr?: (path: string, name: string, size: number, cb: (err: number) => void) => void
|
|
61
|
-
listxattr?: (path: string, cb: (err: number, list?: string[]) => void) => void
|
|
62
|
-
removexattr?: (path: string, name: string, cb: (err: number) => void) => void
|
|
63
|
-
open?: (path: string, mode: number, cb: (err: number, fd?: number) => void) => void
|
|
64
|
-
opendir?: (path: string, mode: number, cb: (err: number, fd?: number) => void) => void
|
|
65
|
-
read?: (
|
|
66
|
-
path: string,
|
|
67
|
-
fd: number,
|
|
68
|
-
buffer: Buffer,
|
|
69
|
-
length: number,
|
|
70
|
-
position: number,
|
|
71
|
-
// This contradicts the code in index.js for _op_read, where the callback signature is (err, bytesRead)
|
|
72
|
-
// however, it appears that the calling code indeed interprets the "err" position as the value.
|
|
73
|
-
cb: (bytesRead?: number) => void
|
|
74
|
-
) => void
|
|
75
|
-
write?: (
|
|
76
|
-
path: string,
|
|
77
|
-
fd: number,
|
|
78
|
-
buffer: Buffer,
|
|
79
|
-
length: number,
|
|
80
|
-
position: number,
|
|
81
|
-
// This contradicts the code in index.js for _op_write, where the callback signature is (err, bytesWritten)
|
|
82
|
-
// however, it appears that the calling code indeed interprets the "err" position as the value.
|
|
83
|
-
cb: (bytesWritten?: number) => void
|
|
84
|
-
) => void
|
|
85
|
-
// For every open() call there will be exactly one release() call with the same flags and
|
|
86
|
-
// file handle. It is possible to have a file opened more than once, in which case only the
|
|
87
|
-
// last release will mean, that no more reads/writes will happen on the file. The return
|
|
88
|
-
// value of release is ignored.
|
|
89
|
-
release?: (path: string, fd: number, cb: (err: number) => void) => void
|
|
90
|
-
releasedir?: (path: string, fd: number, cb: (err: number) => void) => void
|
|
91
|
-
create?: (path: string, mode: number, cb: (err: number, fd?: number, modePassedOn?: number) => void) => void
|
|
92
|
-
unlink?: (path: string, cb: (err: number) => void) => void
|
|
93
|
-
rename?: (src: string, dest: string, cb: (err: number) => void) => void
|
|
94
|
-
link?: (src: string, dest: string, cb: (err: number) => void) => void
|
|
95
|
-
symlink?: (src: string, dest: string, cb: (err: number) => void) => void
|
|
96
|
-
mkdir?: (path: string, mode: number, cb: (err: number) => void) => void
|
|
97
|
-
rmdir?: (path: string, cb: (err: number) => void) => void
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// See https://github.com/gcasro/fuse
|
|
101
|
-
// See https://man7.org/linux/man-pages/man8/mount.fuse3.8.html
|
|
102
|
-
export interface OPTIONS {
|
|
103
|
-
uid?: number
|
|
104
|
-
gid?: number
|
|
105
|
-
debug?: boolean
|
|
106
|
-
force?: boolean
|
|
107
|
-
timeout?: number
|
|
108
|
-
allowOther?: boolean
|
|
109
|
-
allowRoot?: boolean
|
|
110
|
-
autoUnmount?: boolean
|
|
111
|
-
defaultPermissions?: string
|
|
112
|
-
blkdev?: string
|
|
113
|
-
blksize?: number
|
|
114
|
-
maxRead?: number
|
|
115
|
-
fd?: number
|
|
116
|
-
userId?: number
|
|
117
|
-
fsname?: string
|
|
118
|
-
subtype?: string
|
|
119
|
-
kernelCache?: boolean
|
|
120
|
-
autoCache?: boolean
|
|
121
|
-
umask?: number
|
|
122
|
-
entryTimeout?: number
|
|
123
|
-
attrTimeout?: number
|
|
124
|
-
acAttrTimeout?: number
|
|
125
|
-
noforget?: boolean
|
|
126
|
-
remember?: number
|
|
127
|
-
modules?: string
|
|
128
|
-
volname?: string
|
|
129
|
-
volicon?: string | boolean
|
|
130
|
-
displayFolder?: boolean
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export default class Fuse {
|
|
134
|
-
constructor(mnt: string, ops?: OPERATIONS, opts?: OPTIONS)
|
|
135
|
-
|
|
136
|
-
// Added by @gcas/fuse
|
|
137
|
-
static unmount: (mnt: string, cb: (err: null | Error) => void) => any
|
|
138
|
-
static beforeMount: (cb: (err: null | Error) => any) => void
|
|
139
|
-
static beforeUnmount: (cb: (err: null | Error) => any) => void
|
|
140
|
-
static configure: (cb: (err: null | Error) => any) => void
|
|
141
|
-
static unconfigure: (cb: (err: null | Error) => any) => void
|
|
142
|
-
static isConfigured: (cb: (err: null | Error, result: boolean) => any) => void
|
|
143
|
-
|
|
144
|
-
// Error codes - numeric value retrieved from Fuse instance with errno(code)
|
|
145
|
-
static EPERM: -1
|
|
146
|
-
static ENOENT: -2
|
|
147
|
-
static ESRCH: -3
|
|
148
|
-
static EINTR: -4
|
|
149
|
-
static EIO: -5
|
|
150
|
-
static ENXIO: -6
|
|
151
|
-
static E2BIG: -7
|
|
152
|
-
static ENOEXEC: -8
|
|
153
|
-
static EBADF: -9
|
|
154
|
-
static ECHILD: -10
|
|
155
|
-
static EAGAIN: -11
|
|
156
|
-
static ENOMEM: -12
|
|
157
|
-
static EACCES: -13
|
|
158
|
-
static EFAULT: -14
|
|
159
|
-
static ENOTBLK: -15
|
|
160
|
-
static EBUSY: -16
|
|
161
|
-
static EEXIST: -17
|
|
162
|
-
static EXDEV: -18
|
|
163
|
-
static ENODEV: -19
|
|
164
|
-
static ENOTDIR: -20
|
|
165
|
-
static EISDIR: -21
|
|
166
|
-
static EINVAL: -22
|
|
167
|
-
static ENFILE: -23
|
|
168
|
-
static EMFILE: -24
|
|
169
|
-
static ENOTTY: -25
|
|
170
|
-
static ETXTBSY: -26
|
|
171
|
-
static EFBIG: -27
|
|
172
|
-
static ENOSPC: -28
|
|
173
|
-
static ESPIPE: -29
|
|
174
|
-
static EROFS: -30
|
|
175
|
-
static EMLINK: -31
|
|
176
|
-
static EPIPE: -32
|
|
177
|
-
static EDOM: -33
|
|
178
|
-
static ERANGE: -34
|
|
179
|
-
static EDEADLK: -35
|
|
180
|
-
static ENAMETOOLONG: -36
|
|
181
|
-
static ENOLCK: -37
|
|
182
|
-
static ENOSYS: -38
|
|
183
|
-
static ENOTEMPTY: -39
|
|
184
|
-
static ELOOP: -40
|
|
185
|
-
static EWOULDBLOCK: -11
|
|
186
|
-
static ENOMSG: -42
|
|
187
|
-
static EIDRM: -43
|
|
188
|
-
static ECHRNG: -44
|
|
189
|
-
static EL2NSYNC: -45
|
|
190
|
-
static EL3HLT: -46
|
|
191
|
-
static EL3RST: -47
|
|
192
|
-
static ELNRNG: -48
|
|
193
|
-
static EUNATCH: -49
|
|
194
|
-
static ENOCSI: -50
|
|
195
|
-
static EL2HLT: -51
|
|
196
|
-
static EBADE: -52
|
|
197
|
-
static EBADR: -53
|
|
198
|
-
static EXFULL: -54
|
|
199
|
-
static ENOANO: -55
|
|
200
|
-
static EBADRQC: -56
|
|
201
|
-
static EBADSLT: -57
|
|
202
|
-
static EDEADLOCK: -35
|
|
203
|
-
static EBFONT: -59
|
|
204
|
-
static ENOSTR: -60
|
|
205
|
-
static ENODATA: -61
|
|
206
|
-
static ETIME: -62
|
|
207
|
-
static ENOSR: -63
|
|
208
|
-
static ENONET: -64
|
|
209
|
-
static ENOPKG: -65
|
|
210
|
-
static EREMOTE: -66
|
|
211
|
-
static ENOLINK: -67
|
|
212
|
-
static EADV: -68
|
|
213
|
-
static ESRMNT: -69
|
|
214
|
-
static ECOMM: -70
|
|
215
|
-
static EPROTO: -71
|
|
216
|
-
static EMULTIHOP: -72
|
|
217
|
-
static EDOTDOT: -73
|
|
218
|
-
static EBADMSG: -74
|
|
219
|
-
static EOVERFLOW: -75
|
|
220
|
-
static ENOTUNIQ: -76
|
|
221
|
-
static EBADFD: -77
|
|
222
|
-
static EREMCHG: -78
|
|
223
|
-
static ELIBACC: -79
|
|
224
|
-
static ELIBBAD: -80
|
|
225
|
-
static ELIBSCN: -81
|
|
226
|
-
static ELIBMAX: -82
|
|
227
|
-
static ELIBEXEC: -83
|
|
228
|
-
static EILSEQ: -84
|
|
229
|
-
static ERESTART: -85
|
|
230
|
-
static ESTRPIPE: -86
|
|
231
|
-
static EUSERS: -87
|
|
232
|
-
static ENOTSOCK: -88
|
|
233
|
-
static EDESTADDRREQ: -89
|
|
234
|
-
static EMSGSIZE: -90
|
|
235
|
-
static EPROTOTYPE: -91
|
|
236
|
-
static ENOPROTOOPT: -92
|
|
237
|
-
static EPROTONOSUPPORT: -93
|
|
238
|
-
static ESOCKTNOSUPPORT: -94
|
|
239
|
-
static EOPNOTSUPP: -95
|
|
240
|
-
static EPFNOSUPPORT: -96
|
|
241
|
-
static EAFNOSUPPORT: -97
|
|
242
|
-
static EADDRINUSE: -98
|
|
243
|
-
static EADDRNOTAVAIL: -99
|
|
244
|
-
static ENETDOWN: -100
|
|
245
|
-
static ENETUNREACH: -101
|
|
246
|
-
static ENETRESET: -102
|
|
247
|
-
static ECONNABORTED: -103
|
|
248
|
-
static ECONNRESET: -104
|
|
249
|
-
static ENOBUFS: -105
|
|
250
|
-
static EISCONN: -106
|
|
251
|
-
static ENOTCONN: -107
|
|
252
|
-
static ESHUTDOWN: -108
|
|
253
|
-
static ETOOMANYREFS: -109
|
|
254
|
-
static ETIMEDOUT: -110
|
|
255
|
-
static ECONNREFUSED: -111
|
|
256
|
-
static EHOSTDOWN: -112
|
|
257
|
-
static EHOSTUNREACH: -113
|
|
258
|
-
static EALREADY: -114
|
|
259
|
-
static EINPROGRESS: -115
|
|
260
|
-
static ESTALE: -116
|
|
261
|
-
static EUCLEAN: -117
|
|
262
|
-
static ENOTNAM: -118
|
|
263
|
-
static ENAVAIL: -119
|
|
264
|
-
static EISNAM: -120
|
|
265
|
-
static EREMOTEIO: -121
|
|
266
|
-
static EDQUOT: -122
|
|
267
|
-
static ENOMEDIUM: -123
|
|
268
|
-
static EMEDIUMTYPE: -124
|
|
269
|
-
|
|
270
|
-
public opts: OPTIONS
|
|
271
|
-
public mnt: string
|
|
272
|
-
public ops: OPERATIONS
|
|
273
|
-
public timeout: number
|
|
274
|
-
|
|
275
|
-
public mount: (cb: (err: null | Error) => any) => void
|
|
276
|
-
public unmount: (cb: (err: null | Error) => any) => void
|
|
277
|
-
public errno: (code?: string) => number
|
|
278
|
-
|
|
279
|
-
// From "nanoresource"
|
|
280
|
-
// See https://github.com/mafintosh/nanoresource/blob/master/index.js
|
|
281
|
-
public opening: boolean
|
|
282
|
-
public opened: boolean
|
|
283
|
-
public closing: boolean
|
|
284
|
-
public closed: boolean
|
|
285
|
-
public actives: number
|
|
286
|
-
|
|
287
|
-
public open(cb: (err: Error) => any): void
|
|
288
|
-
|
|
289
|
-
public active(cb?: (err: Error) => any): boolean
|
|
290
|
-
|
|
291
|
-
public inactive(): void
|
|
292
|
-
public inactive(cb: (err: Error, val: any) => any, err: null, val: any): void
|
|
293
|
-
public inactive(cb: (err: Error, val: any) => any, err: Error): void
|
|
294
|
-
|
|
295
|
-
public close(cb?: (err?: Error) => any): void
|
|
296
|
-
public close(allowActive: boolean, cb: (err?: Error) => any): void
|
|
3
|
+
declare global {
|
|
4
|
+
declare namespace NodeJS {
|
|
5
|
+
interface Process {
|
|
6
|
+
onMessage?: (message: SyncMessage) => void
|
|
7
|
+
}
|
|
297
8
|
}
|
|
298
9
|
}
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@filen/sync",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Filen Sync",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"private": false,
|
|
8
|
-
"scripts": {
|
|
9
|
-
"test": "jest
|
|
10
|
-
"lint": "eslint src/**/* --ext .js,.jsx,.ts,.tsx",
|
|
11
|
-
"emitTypes": "tsc --emitDeclarationOnly",
|
|
12
|
-
"tsc": "tsc --build",
|
|
13
|
-
"clear": "rimraf ./dist",
|
|
14
|
-
"build": "npm run clear && npm run lint && npm run tsc",
|
|
15
|
-
"dev": "tsx ./dev/index.ts",
|
|
16
|
-
"yalc": "npm run build && yalc push"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/FilenCloudDienste/filen-sync.git"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"filen"
|
|
24
|
-
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=18"
|
|
27
|
-
},
|
|
28
|
-
"author": "Filen",
|
|
29
|
-
"license": "AGPLv3",
|
|
30
|
-
"bugs": {
|
|
31
|
-
"url": "https://github.com/FilenCloudDienste/filen-sync/issues"
|
|
32
|
-
},
|
|
33
|
-
"homepage": "https://filen.io",
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@jest/globals": "^29.7.0",
|
|
36
|
-
"@types/fs-extra": "^11.0.4",
|
|
37
|
-
"@types/
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/
|
|
40
|
-
"@
|
|
41
|
-
"@typescript-eslint/
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@filen/sync",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Filen Sync",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"lint": "eslint src/**/* --ext .js,.jsx,.ts,.tsx",
|
|
11
|
+
"emitTypes": "tsc --emitDeclarationOnly",
|
|
12
|
+
"tsc": "tsc --build",
|
|
13
|
+
"clear": "rimraf ./dist",
|
|
14
|
+
"build": "npm run clear && npm run lint && npm run tsc",
|
|
15
|
+
"dev": "tsx ./dev/index.ts",
|
|
16
|
+
"yalc": "npm run build && yalc push"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/FilenCloudDienste/filen-sync.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"filen"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18"
|
|
27
|
+
},
|
|
28
|
+
"author": "Filen",
|
|
29
|
+
"license": "AGPLv3",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/FilenCloudDienste/filen-sync/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://filen.io",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@jest/globals": "^29.7.0",
|
|
36
|
+
"@types/fs-extra": "^11.0.4",
|
|
37
|
+
"@types/jest": "^29.5.12",
|
|
38
|
+
"@types/lodash": "^4.17.6",
|
|
39
|
+
"@types/mime-types": "^2.1.4",
|
|
40
|
+
"@types/uuid": "^9.0.8",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
42
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
43
|
+
"cross-env": "^7.0.3",
|
|
44
|
+
"eslint": "^8.56.0",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"rimraf": "^5.0.5",
|
|
47
|
+
"ts-jest": "^29.1.5",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"tsx": "^4.11.0",
|
|
50
|
+
"typescript": "^5.3.3",
|
|
51
|
+
"wait-on": "^7.2.0"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@filen/sdk": "^0.1.134",
|
|
55
|
+
"@parcel/watcher": "^2.4.1",
|
|
56
|
+
"fs-extra": "^11.2.0",
|
|
57
|
+
"ignore": "^5.3.1",
|
|
58
|
+
"lodash": "^4.17.21",
|
|
59
|
+
"rotating-file-stream": "^3.2.3",
|
|
60
|
+
"uuid": "^10.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { replacePathStartWithFromAndTo } from "../src/utils"
|
|
2
|
+
|
|
3
|
+
test("replacePathStartWithFromAndTo basic", () => {
|
|
4
|
+
const path = "/foo/bar"
|
|
5
|
+
const from = "/foo"
|
|
6
|
+
const to = "/baz"
|
|
7
|
+
|
|
8
|
+
expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/baz/bar")
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test("replacePathStartWithFromAndTo basic + extension", () => {
|
|
12
|
+
const path = "/foo/bar.txt"
|
|
13
|
+
const from = "/foo"
|
|
14
|
+
const to = "/baz"
|
|
15
|
+
|
|
16
|
+
expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/baz/bar.txt")
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test("replacePathStartWithFromAndTo same names", () => {
|
|
20
|
+
const path = "/1/1/1/1"
|
|
21
|
+
const from = "/1"
|
|
22
|
+
const to = "/2"
|
|
23
|
+
|
|
24
|
+
expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/2/1/1/1")
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test("replacePathStartWithFromAndTo same names + extension", () => {
|
|
28
|
+
const path = "/1/1/1/1.txt"
|
|
29
|
+
const from = "/1"
|
|
30
|
+
const to = "/2"
|
|
31
|
+
|
|
32
|
+
expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/2/1/1/1.txt")
|
|
33
|
+
})
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"rootDir": "src",
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"lib": ["ES2017", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"target": "ES2017",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"moduleResolution": "node",
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"skipDefaultLibCheck": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"declaration": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"noUncheckedIndexedAccess": true
|
|
18
|
-
},
|
|
19
|
-
"ts-node": {
|
|
20
|
-
"files": true
|
|
21
|
-
},
|
|
22
|
-
"include": ["src", "index.d.ts"],
|
|
23
|
-
"exclude": ["node_modules", "dist", "
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"lib": ["ES2017", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"target": "ES2017",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"skipDefaultLibCheck": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"noUncheckedIndexedAccess": true
|
|
18
|
+
},
|
|
19
|
+
"ts-node": {
|
|
20
|
+
"files": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src", "index.d.ts"],
|
|
23
|
+
"exclude": ["node_modules", "dist", "tests", "docs", ".github", "dev", ".vscode"]
|
|
24
|
+
}
|