filefive 1.8.0 → 2.0.1
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/dist/App.js +6 -8
- package/dist/Connection.js +7 -8
- package/dist/FileWatcher.js +4 -5
- package/dist/Local.js +62 -22
- package/dist/LocalWatcher.js +21 -16
- package/dist/Password.js +5 -5
- package/dist/Queue.js +8 -8
- package/dist/RemoteFiles.js +5 -5
- package/dist/RemoteWatcher.js +1 -2
- package/dist/commands/checkVer.js +6 -3
- package/dist/commands/clear.js +2 -2
- package/dist/commands/connect.js +9 -8
- package/dist/commands/duplicate.js +2 -2
- package/dist/commands/mkdir.js +4 -4
- package/dist/commands/open.js +3 -2
- package/dist/commands/remove.js +2 -3
- package/dist/commands/rename.js +3 -3
- package/dist/commands/saveConnection.js +4 -6
- package/dist/commands/saveSettings.js +2 -2
- package/dist/commands/settings.js +7 -6
- package/dist/commands/write.js +2 -2
- package/dist/fs/Ftp.js +8 -7
- package/dist/fs/Local.js +7 -7
- package/dist/fs/S3.js +12 -11
- package/dist/fs/SFtp.js +11 -10
- package/dist/index.js +9 -8
- package/dist/public/index.js +1 -1
- package/dist/queues/Copy.js +5 -5
- package/dist/queues/Download.js +2 -2
- package/dist/queues/Queue.js +9 -9
- package/dist/queues/Remove.js +4 -4
- package/dist/queues/Upload.js +3 -3
- package/dist/transformers/git.js +11 -10
- package/dist/utils/os.js +17 -0
- package/dist/utils/path.js +4 -4
- package/dist/win.js +20 -0
- package/package.json +13 -13
package/dist/App.js
CHANGED
|
@@ -3,9 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const posix_1 = require("node:path/posix");
|
|
9
7
|
const types_1 = require("./types");
|
|
10
8
|
const Connection_1 = __importDefault(require("./Connection"));
|
|
11
9
|
const LocalWatcher_1 = __importDefault(require("./LocalWatcher"));
|
|
@@ -19,11 +17,11 @@ const URI_1 = require("./utils/URI");
|
|
|
19
17
|
const Local_2 = __importDefault(require("./transformers/Local"));
|
|
20
18
|
class App {
|
|
21
19
|
static async bootstrap(handle, emitter, opener) {
|
|
22
|
-
const dataPath = (0,
|
|
23
|
-
const connPath = (0,
|
|
24
|
-
(0,
|
|
25
|
-
(0, Local_1.touch)((0,
|
|
26
|
-
const settingsPath = (0,
|
|
20
|
+
const dataPath = (0, posix_1.join)((0, Local_1.pwd)(), '.f5');
|
|
21
|
+
const connPath = (0, posix_1.join)(dataPath, 'connections');
|
|
22
|
+
(0, Local_1.mkDirRecursive)(connPath);
|
|
23
|
+
(0, Local_1.touch)((0, posix_1.join)(dataPath, 'credentials.json'), JSON.stringify([]));
|
|
24
|
+
const settingsPath = (0, posix_1.join)(dataPath, 'settings.json');
|
|
27
25
|
if (!(0, Local_1.stat)(settingsPath)) {
|
|
28
26
|
await (0, Local_1.touch)(settingsPath);
|
|
29
27
|
commands_1.commands.saveSettings(settingsPath, await commands_1.commands.getSettings(settingsPath));
|
package/dist/Connection.js
CHANGED
|
@@ -36,22 +36,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const node_path_1 = require("node:path");
|
|
39
|
+
const Local_1 = require("./Local");
|
|
40
|
+
const posix_1 = require("node:path/posix");
|
|
42
41
|
const ReferenceCountMap_1 = __importDefault(require("./utils/ReferenceCountMap"));
|
|
43
42
|
const types_1 = require("./types");
|
|
44
43
|
const URI_1 = require("./utils/URI");
|
|
45
44
|
const uniqid_1 = __importDefault(require("./utils/uniqid"));
|
|
46
45
|
const log_1 = __importStar(require("./log"));
|
|
47
|
-
const
|
|
46
|
+
const Local_2 = __importDefault(require("./fs/Local"));
|
|
48
47
|
const SFtp_1 = __importStar(require("./fs/SFtp"));
|
|
49
48
|
const Ftp_1 = __importStar(require("./fs/Ftp"));
|
|
50
49
|
const S3_1 = __importStar(require("./fs/S3"));
|
|
51
50
|
const options_1 = __importDefault(require("./options"));
|
|
52
51
|
class default_1 {
|
|
53
52
|
static initialize() {
|
|
54
|
-
this.shared.set(types_1.LocalFileSystemID, new
|
|
53
|
+
this.shared.set(types_1.LocalFileSystemID, new Local_2.default);
|
|
55
54
|
}
|
|
56
55
|
static async open(protocol, user, host, port, password, privatekey) {
|
|
57
56
|
const id = (0, URI_1.connectionID)(protocol, user, host, port);
|
|
@@ -66,9 +65,9 @@ class default_1 {
|
|
|
66
65
|
this.protocols.set(id, protocol);
|
|
67
66
|
if (privatekey) {
|
|
68
67
|
if (privatekey.startsWith('~')) {
|
|
69
|
-
privatekey = (0,
|
|
68
|
+
privatekey = (0, posix_1.join)((0, Local_1.pwd)(), privatekey.substring(1));
|
|
70
69
|
}
|
|
71
|
-
this.credentials.set(id, ['key', (0,
|
|
70
|
+
this.credentials.set(id, ['key', await (0, Local_1.readInBuffer)(privatekey)]);
|
|
72
71
|
}
|
|
73
72
|
else {
|
|
74
73
|
this.credentials.set(id, ['password', password]);
|
|
@@ -90,7 +89,7 @@ class default_1 {
|
|
|
90
89
|
}
|
|
91
90
|
static async transmit(id) {
|
|
92
91
|
if (id == types_1.LocalFileSystemID) {
|
|
93
|
-
return [new
|
|
92
|
+
return [new Local_2.default, () => { }];
|
|
94
93
|
}
|
|
95
94
|
const conn = await this.hold(id);
|
|
96
95
|
if (conn) {
|
package/dist/FileWatcher.js
CHANGED
|
@@ -3,8 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
6
|
+
const posix_1 = require("node:path/posix");
|
|
8
7
|
const Local_1 = require("./Local");
|
|
9
8
|
const ReferenceCountMap_1 = __importDefault(require("./utils/ReferenceCountMap"));
|
|
10
9
|
class default_1 {
|
|
@@ -19,10 +18,10 @@ class default_1 {
|
|
|
19
18
|
try {
|
|
20
19
|
const ac = new AbortController();
|
|
21
20
|
this.watched.set(path, ac);
|
|
22
|
-
for await (const { eventType, filename } of (0,
|
|
21
|
+
for await (const { eventType, filename } of (0, Local_1.watchChanges)(path, ac)) {
|
|
23
22
|
let newPath = path;
|
|
24
|
-
if (eventType == "rename" && (0,
|
|
25
|
-
newPath = (0,
|
|
23
|
+
if (eventType == "rename" && (0, posix_1.basename)(path) !== filename) {
|
|
24
|
+
newPath = (0, posix_1.join)((0, posix_1.dirname)(path), filename);
|
|
26
25
|
this.watched.renameKey(path, newPath);
|
|
27
26
|
}
|
|
28
27
|
try {
|
package/dist/Local.js
CHANGED
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isWin = isWin;
|
|
7
|
+
exports.osify = osify;
|
|
8
|
+
exports.unosify = unosify;
|
|
3
9
|
exports.pwd = pwd;
|
|
4
10
|
exports.stat = stat;
|
|
5
11
|
exports.list = list;
|
|
12
|
+
exports.mkDirRecursive = mkDirRecursive;
|
|
6
13
|
exports.move = move;
|
|
7
14
|
exports.copy = copy;
|
|
8
15
|
exports.del = del;
|
|
9
16
|
exports.touch = touch;
|
|
10
|
-
exports.watch = watch;
|
|
11
17
|
exports.read = read;
|
|
18
|
+
exports.readInBuffer = readInBuffer;
|
|
19
|
+
exports.write = write;
|
|
20
|
+
exports.watch = watch;
|
|
21
|
+
exports.watchChanges = watchChanges;
|
|
12
22
|
const node_os_1 = require("node:os");
|
|
13
|
-
const
|
|
23
|
+
const posix_1 = require("node:path/posix");
|
|
24
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
25
|
const node_fs_1 = require("node:fs");
|
|
15
26
|
const promises_1 = require("node:fs/promises");
|
|
27
|
+
const os_1 = require("./utils/os");
|
|
28
|
+
const win_1 = require("./win");
|
|
29
|
+
function isWin() {
|
|
30
|
+
return (0, node_os_1.platform)() === 'win32';
|
|
31
|
+
}
|
|
32
|
+
function osify(path) {
|
|
33
|
+
return isWin() ? (0, os_1.unixToWin)(path) : path;
|
|
34
|
+
}
|
|
35
|
+
function unosify(path) {
|
|
36
|
+
return isWin() ? (0, os_1.winToUnix)(path) : path;
|
|
37
|
+
}
|
|
16
38
|
function pwd() {
|
|
17
|
-
return (0, node_os_1.homedir)();
|
|
39
|
+
return unosify((0, node_os_1.homedir)());
|
|
18
40
|
}
|
|
19
41
|
function stat(path) {
|
|
20
|
-
path = (0,
|
|
42
|
+
path = (0, posix_1.normalize)(path);
|
|
43
|
+
const actualPath = osify(path);
|
|
21
44
|
try {
|
|
22
|
-
let stat = (0, node_fs_1.lstatSync)(
|
|
45
|
+
let stat = (0, node_fs_1.lstatSync)(actualPath);
|
|
23
46
|
let target;
|
|
24
47
|
if (stat.isSymbolicLink()) {
|
|
25
|
-
target = (0, node_fs_1.readlinkSync)(
|
|
26
|
-
if (!(0,
|
|
27
|
-
target =
|
|
48
|
+
target = (0, node_fs_1.readlinkSync)(actualPath);
|
|
49
|
+
if (!(0, posix_1.isAbsolute)(target)) {
|
|
50
|
+
target = node_path_1.default.normalize(node_path_1.default.join(node_path_1.default.dirname(actualPath), target));
|
|
28
51
|
}
|
|
29
52
|
stat = (0, node_fs_1.statSync)(target);
|
|
30
53
|
}
|
|
31
54
|
return {
|
|
32
55
|
path,
|
|
33
|
-
name: (0,
|
|
56
|
+
name: (0, posix_1.basename)(path),
|
|
34
57
|
dir: stat.isDirectory(),
|
|
35
58
|
size: stat.size, // in bytes
|
|
36
59
|
modified: stat.mtime,
|
|
@@ -43,44 +66,61 @@ function stat(path) {
|
|
|
43
66
|
}
|
|
44
67
|
}
|
|
45
68
|
function list(dir) {
|
|
46
|
-
|
|
69
|
+
let actialDir = osify(dir);
|
|
70
|
+
if (actialDir == '\\') {
|
|
71
|
+
return (0, win_1.getDrives)().map(path => stat(unosify(path))).filter(f => f);
|
|
72
|
+
}
|
|
73
|
+
return (0, node_fs_1.readdirSync)(actialDir).map(name => stat((0, posix_1.join)(dir, name))).filter(f => f);
|
|
74
|
+
}
|
|
75
|
+
async function mkDirRecursive(path) {
|
|
76
|
+
return (0, promises_1.mkdir)(osify(path), { recursive: true });
|
|
47
77
|
}
|
|
48
78
|
async function move(from, to, force = false) {
|
|
49
|
-
await (
|
|
79
|
+
await mkDirRecursive((0, posix_1.dirname)(to));
|
|
50
80
|
const existing = stat(to);
|
|
51
81
|
if (existing) {
|
|
52
82
|
if (force) {
|
|
53
|
-
await (0, promises_1.unlink)(to);
|
|
83
|
+
await (0, promises_1.unlink)(osify(to));
|
|
54
84
|
}
|
|
55
85
|
else {
|
|
56
86
|
return existing;
|
|
57
87
|
}
|
|
58
88
|
}
|
|
59
|
-
await (0, promises_1.rename)(from, to);
|
|
89
|
+
await (0, promises_1.rename)(osify(from), osify(to));
|
|
60
90
|
return true;
|
|
61
91
|
}
|
|
62
92
|
async function copy(from, to, force = false) {
|
|
63
|
-
await (
|
|
93
|
+
await mkDirRecursive((0, posix_1.dirname)(to));
|
|
64
94
|
const existing = stat(to);
|
|
65
95
|
if (existing && !force) {
|
|
66
96
|
return existing;
|
|
67
97
|
}
|
|
68
|
-
await (0, promises_1.cp)(from, to, { recursive: true });
|
|
98
|
+
await (0, promises_1.cp)(osify(from), osify(to), { recursive: true });
|
|
69
99
|
return true;
|
|
70
100
|
}
|
|
71
101
|
async function del(path) {
|
|
72
|
-
return (0, promises_1.rm)(path, { recursive: true, force: true });
|
|
102
|
+
return (0, promises_1.rm)(osify(path), { recursive: true, force: true });
|
|
73
103
|
}
|
|
74
104
|
async function touch(path, data) {
|
|
75
105
|
if (!stat(path)) {
|
|
76
|
-
await (
|
|
77
|
-
data !== undefined ? await (0, promises_1.writeFile)(path, data) : await (await (0, promises_1.open)(path, 'a')).close();
|
|
106
|
+
await mkDirRecursive((0, posix_1.dirname)(path));
|
|
107
|
+
data !== undefined ? await (0, promises_1.writeFile)(osify(path), data) : await (await (0, promises_1.open)(osify(path), 'a')).close();
|
|
78
108
|
}
|
|
79
109
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
110
|
+
async function read(path) {
|
|
111
|
+
return (0, promises_1.readFile)(osify(path), { encoding: 'utf8' });
|
|
112
|
+
}
|
|
113
|
+
async function readInBuffer(path) {
|
|
114
|
+
return (0, promises_1.readFile)(osify(path));
|
|
115
|
+
}
|
|
116
|
+
async function write(path, data) {
|
|
117
|
+
return (0, promises_1.writeFile)(osify(path), data);
|
|
118
|
+
}
|
|
119
|
+
function watch(path, listener, onError) {
|
|
120
|
+
const watcher = (0, node_fs_1.watch)(osify(path), listener);
|
|
121
|
+
watcher.on('error', onError);
|
|
82
122
|
return () => watcher.close();
|
|
83
123
|
}
|
|
84
|
-
|
|
85
|
-
return
|
|
124
|
+
function watchChanges(path, ac) {
|
|
125
|
+
return (0, promises_1.watch)(osify(path), { signal: ac.signal });
|
|
86
126
|
}
|
package/dist/LocalWatcher.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const posix_1 = require("node:path/posix");
|
|
7
7
|
const Local_1 = require("./Local");
|
|
8
8
|
const ReferenceCountMap_1 = __importDefault(require("./utils/ReferenceCountMap"));
|
|
9
9
|
class default_1 {
|
|
@@ -14,22 +14,27 @@ class default_1 {
|
|
|
14
14
|
}
|
|
15
15
|
watch(dir) {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.watched.
|
|
22
|
-
|
|
17
|
+
try {
|
|
18
|
+
this.watched.inc(dir) || this.watched.set(dir, (0, Local_1.watch)(dir, (event, target) => {
|
|
19
|
+
if (event == 'rename') {
|
|
20
|
+
const child = (0, posix_1.join)(dir, target);
|
|
21
|
+
if (this.watched.has(child) && !(0, Local_1.stat)(child)) {
|
|
22
|
+
this.watched.del(child);
|
|
23
|
+
this.onMissing(child);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
26
|
+
try {
|
|
27
|
+
this.listener(dir, (0, Local_1.list)(dir), event, target);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
this.watched.del(dir);
|
|
31
|
+
this.onMissing(dir);
|
|
32
|
+
}
|
|
33
|
+
}, () => this.watched.del(dir)));
|
|
34
|
+
}
|
|
35
|
+
catch (e) { // an existing dir may be not watchable, e.g. network drive in Windows
|
|
36
|
+
this.watched.del(dir);
|
|
37
|
+
}
|
|
33
38
|
const files = (0, Local_1.list)(dir);
|
|
34
39
|
this.listener(dir, files);
|
|
35
40
|
return files;
|
package/dist/Password.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const Local_1 = require("./Local");
|
|
4
|
+
const posix_1 = require("node:path/posix");
|
|
5
5
|
class Passwords {
|
|
6
6
|
static async load(dir, onMiss) {
|
|
7
|
-
this.saveFile = (0,
|
|
7
|
+
this.saveFile = (0, posix_1.join)(dir, 'credentials.json');
|
|
8
8
|
this.resolve = onMiss;
|
|
9
|
-
this.store = new Map(JSON.parse((await (0,
|
|
9
|
+
this.store = new Map(JSON.parse((await (0, Local_1.read)(this.saveFile)).toString()).map(([id, password]) => [id, [password, true]]));
|
|
10
10
|
}
|
|
11
11
|
static set(id, password, remember, save) {
|
|
12
12
|
if (password === false) {
|
|
@@ -38,7 +38,7 @@ class Passwords {
|
|
|
38
38
|
this.pending.delete(id);
|
|
39
39
|
}
|
|
40
40
|
static dump() {
|
|
41
|
-
(0,
|
|
41
|
+
(0, Local_1.write)(this.saveFile, JSON.stringify(Array.from(this.store.entries())
|
|
42
42
|
.filter(([, [, save]]) => save)
|
|
43
43
|
.map(([id, [password,]]) => [id, password])));
|
|
44
44
|
}
|
package/dist/Queue.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.queues = void 0;
|
|
7
|
-
const
|
|
7
|
+
const posix_1 = require("node:path/posix");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
9
|
const Local_1 = require("./Local");
|
|
10
10
|
const URI_1 = require("./utils/URI");
|
|
@@ -106,7 +106,7 @@ class Queue {
|
|
|
106
106
|
}
|
|
107
107
|
log_1.default.log(`start uploading ${from.path} -> ${to}`);
|
|
108
108
|
try {
|
|
109
|
-
const dir = (0,
|
|
109
|
+
const dir = (0, posix_1.dirname)(to);
|
|
110
110
|
if (!this.touched.has(dir)) {
|
|
111
111
|
await fs.mkdir(dir);
|
|
112
112
|
}
|
|
@@ -126,7 +126,7 @@ class Queue {
|
|
|
126
126
|
catch (e) { }
|
|
127
127
|
return [];
|
|
128
128
|
});
|
|
129
|
-
const exists = async (path) => (await ls((0,
|
|
129
|
+
const exists = async (path) => (await ls((0, posix_1.dirname)(path))).find((0, ramda_1.whereEq)({ path }));
|
|
130
130
|
this.processing = this.queue$.subscribe(async ({ from, to, action }) => {
|
|
131
131
|
let a = action ?? this.action;
|
|
132
132
|
const existing = await exists(to);
|
|
@@ -154,7 +154,7 @@ class Queue {
|
|
|
154
154
|
this.totalCnt = paths.length;
|
|
155
155
|
const touched = new Map();
|
|
156
156
|
paths.forEach(async (path) => {
|
|
157
|
-
const dir = (0,
|
|
157
|
+
const dir = (0, posix_1.dirname)(path);
|
|
158
158
|
const [conn, close] = await Connection_1.default.transmit(this.connId);
|
|
159
159
|
if (!touched.has(dir)) {
|
|
160
160
|
try {
|
|
@@ -164,7 +164,7 @@ class Queue {
|
|
|
164
164
|
touched.set(dir, null);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
const name = (0,
|
|
167
|
+
const name = (0, posix_1.basename)(path);
|
|
168
168
|
const file = touched.get(dir)?.find(f => f.name == name);
|
|
169
169
|
if (file) {
|
|
170
170
|
try {
|
|
@@ -198,10 +198,10 @@ class Queue {
|
|
|
198
198
|
}
|
|
199
199
|
async enqueue(paths, dest, ls) {
|
|
200
200
|
const add = async (path, to) => {
|
|
201
|
-
const from = (await ls((0,
|
|
201
|
+
const from = (await ls((0, posix_1.dirname)(path))).find((0, ramda_1.whereEq)({ path }));
|
|
202
202
|
from && (from.dir ?
|
|
203
|
-
(await ls(path)).forEach(async (f) => await add(f.path, (0,
|
|
204
|
-
this.queue.push({ from, to: (0,
|
|
203
|
+
(await ls(path)).forEach(async (f) => await add(f.path, (0, posix_1.join)(to, (0, posix_1.basename)(path)))) :
|
|
204
|
+
this.queue.push({ from, to: (0, posix_1.join)(to, (0, posix_1.basename)(path)) }));
|
|
205
205
|
};
|
|
206
206
|
for (const path of paths) {
|
|
207
207
|
await add(path, dest);
|
package/dist/RemoteFiles.js
CHANGED
|
@@ -8,7 +8,7 @@ const types_1 = require("./types");
|
|
|
8
8
|
const URI_1 = require("./utils/URI");
|
|
9
9
|
const commands_1 = require("./commands");
|
|
10
10
|
const node_os_1 = require("node:os");
|
|
11
|
-
const
|
|
11
|
+
const posix_1 = require("node:path/posix");
|
|
12
12
|
const promises_1 = require("node:fs/promises");
|
|
13
13
|
const FileWatcher_1 = __importDefault(require("./FileWatcher"));
|
|
14
14
|
const Connection_1 = __importDefault(require("./Connection"));
|
|
@@ -18,8 +18,8 @@ const watcher = new FileWatcher_1.default(path => send(path));
|
|
|
18
18
|
async function open(file, onLoad) {
|
|
19
19
|
const { path } = (0, URI_1.parseURI)(file);
|
|
20
20
|
try {
|
|
21
|
-
const tmpDir = await (0, promises_1.mkdtemp)((0,
|
|
22
|
-
const tmpName = (0,
|
|
21
|
+
const tmpDir = await (0, promises_1.mkdtemp)((0, posix_1.join)((0, node_os_1.tmpdir)(), 'f5-'));
|
|
22
|
+
const tmpName = (0, posix_1.join)(tmpDir, (0, posix_1.basename)(path));
|
|
23
23
|
return commands_1.commands.copy([file], (0, URI_1.createURI)(types_1.LocalFileSystemID, tmpDir), false, null, null, null, () => {
|
|
24
24
|
files.set(tmpName, { file, deletion: resetDeletion(tmpName, null), sending: false, changed: false });
|
|
25
25
|
watcher.watch(tmpName);
|
|
@@ -45,7 +45,7 @@ async function send(file) {
|
|
|
45
45
|
const [conn, close] = await Connection_1.default.transmit(id);
|
|
46
46
|
await conn.put(file, path);
|
|
47
47
|
close();
|
|
48
|
-
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0,
|
|
48
|
+
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, posix_1.dirname)(path)));
|
|
49
49
|
watched.sending = false;
|
|
50
50
|
if (watched.changed) {
|
|
51
51
|
watched.changed = false;
|
|
@@ -56,6 +56,6 @@ function resetDeletion(file, current) {
|
|
|
56
56
|
clearTimeout(current);
|
|
57
57
|
return setTimeout(() => {
|
|
58
58
|
files.delete(file);
|
|
59
|
-
(0, promises_1.rm)((0,
|
|
59
|
+
(0, promises_1.rm)((0, posix_1.dirname)(file), { force: true, recursive: true });
|
|
60
60
|
}, 1000 * 60 * 60);
|
|
61
61
|
}
|
package/dist/RemoteWatcher.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
6
|
const ReferenceCountMap_1 = __importDefault(require("./utils/ReferenceCountMap"));
|
|
8
7
|
const Connection_1 = __importDefault(require("./Connection"));
|
|
9
8
|
const URI_1 = require("./utils/URI");
|
|
@@ -24,7 +23,7 @@ class RemoteWatcher {
|
|
|
24
23
|
if (this.watched.has(uri)) {
|
|
25
24
|
this.list(uri);
|
|
26
25
|
Array.from(this.watched.keys()).forEach(dir => {
|
|
27
|
-
if (dir.startsWith(uri +
|
|
26
|
+
if (dir.startsWith(uri + '/')) {
|
|
28
27
|
this.list(dir);
|
|
29
28
|
}
|
|
30
29
|
});
|
|
@@ -7,9 +7,12 @@ exports.default = default_1;
|
|
|
7
7
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
8
8
|
async function default_1() {
|
|
9
9
|
// https://github.com/npm/registry
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
try {
|
|
11
|
+
const server = await fetch('https://registry.npmjs.com/filefive/latest').then(resp => resp.json());
|
|
12
|
+
if (typeof server === 'object' && 'version' in server) {
|
|
13
|
+
return server.version == package_json_1.default.version ? null : [package_json_1.default.version, server.version];
|
|
14
|
+
}
|
|
13
15
|
}
|
|
16
|
+
catch (e) { }
|
|
14
17
|
return null;
|
|
15
18
|
}
|
package/dist/commands/clear.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
7
|
+
const posix_1 = require("node:path/posix");
|
|
8
8
|
const types_1 = require("../types");
|
|
9
9
|
const URI_1 = require("../utils/URI");
|
|
10
10
|
const Connection_1 = __importDefault(require("../Connection"));
|
|
@@ -13,6 +13,6 @@ async function default_1(file) {
|
|
|
13
13
|
const { id, path } = (0, URI_1.parseURI)(file);
|
|
14
14
|
await Connection_1.default.get(id).write(path, '');
|
|
15
15
|
if (id != types_1.LocalFileSystemID) {
|
|
16
|
-
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0,
|
|
16
|
+
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, posix_1.dirname)(path)));
|
|
17
17
|
}
|
|
18
18
|
}
|
package/dist/commands/connect.js
CHANGED
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.explorerSettings = explorerSettings;
|
|
7
7
|
exports.default = default_1;
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
8
|
const path_1 = require("path");
|
|
9
|
+
const Local_1 = require("../Local");
|
|
10
10
|
const types_1 = require("../types");
|
|
11
|
-
const
|
|
11
|
+
const Local_2 = require("../fs/Local");
|
|
12
12
|
const URI_1 = require("../utils/URI");
|
|
13
13
|
const Connection_1 = __importDefault(require("../Connection"));
|
|
14
14
|
const Password_1 = __importDefault(require("../Password"));
|
|
@@ -35,13 +35,14 @@ function explorerSettings(attributes, config) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
async function default_1(file, onError) {
|
|
38
|
-
const stat =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
/* const stat = statSync(file) // TODO
|
|
39
|
+
if (!stat.isFile() && !stat.isSymbolicLink()) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
*/
|
|
42
43
|
let config;
|
|
43
44
|
try {
|
|
44
|
-
config = JSON.parse((0,
|
|
45
|
+
config = JSON.parse(await (0, Local_1.read)(file));
|
|
45
46
|
}
|
|
46
47
|
catch (e) {
|
|
47
48
|
throw new Error(`Invalid connection file ${file}`);
|
|
@@ -75,7 +76,7 @@ async function default_1(file, onError) {
|
|
|
75
76
|
attributes,
|
|
76
77
|
pwd,
|
|
77
78
|
theme: config.theme ?? 'black',
|
|
78
|
-
local: explorerSettings(
|
|
79
|
+
local: explorerSettings(Local_2.ATTRIBUTES, config.local),
|
|
79
80
|
remote: explorerSettings(attributes, config.remote),
|
|
80
81
|
path: {
|
|
81
82
|
local: config.path?.local,
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
7
|
+
const posix_1 = require("node:path/posix");
|
|
8
8
|
const URI_1 = require("../utils/URI");
|
|
9
9
|
const types_1 = require("../types");
|
|
10
10
|
const Queue_1 = require("../queues/Queue");
|
|
@@ -19,7 +19,7 @@ function default_1(src, filter) {
|
|
|
19
19
|
const targets = new Map();
|
|
20
20
|
src.forEach(uri => {
|
|
21
21
|
const { path } = (0, URI_1.parseURI)(uri);
|
|
22
|
-
const parent = (0,
|
|
22
|
+
const parent = (0, posix_1.dirname)(path);
|
|
23
23
|
if (!targets.has(parent)) {
|
|
24
24
|
targets.set(parent, []);
|
|
25
25
|
}
|
package/dist/commands/mkdir.js
CHANGED
|
@@ -5,23 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
7
|
const types_1 = require("../types");
|
|
8
|
-
const
|
|
8
|
+
const Local_1 = require("../Local");
|
|
9
9
|
const Connection_1 = __importDefault(require("../Connection"));
|
|
10
10
|
const URI_1 = require("../utils/URI");
|
|
11
|
-
const
|
|
11
|
+
const posix_1 = require("node:path/posix");
|
|
12
12
|
const path_1 = require("../utils/path");
|
|
13
13
|
const App_1 = __importDefault(require("../App"));
|
|
14
14
|
async function default_1(name, parent) {
|
|
15
15
|
let { id, path } = (0, URI_1.parseURI)(parent);
|
|
16
16
|
try {
|
|
17
17
|
if (id == types_1.LocalFileSystemID) {
|
|
18
|
-
await (0,
|
|
18
|
+
await (0, Local_1.mkDirRecursive)((0, posix_1.join)(path, name));
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
const parts = (0, path_1.split)(name);
|
|
22
22
|
const conn = Connection_1.default.get(id);
|
|
23
23
|
for (let i = 0; i < parts.length; i++) {
|
|
24
|
-
path = (0,
|
|
24
|
+
path = (0, posix_1.join)(path, parts[i]);
|
|
25
25
|
try {
|
|
26
26
|
await conn.mkdir(path);
|
|
27
27
|
}
|
package/dist/commands/open.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const URI_1 = require("../utils/URI");
|
|
5
5
|
const RemoteFiles_1 = require("../RemoteFiles");
|
|
6
|
+
const Local_1 = require("../Local");
|
|
6
7
|
async function default_1(file, app, opener) {
|
|
7
8
|
if ((0, URI_1.isLocal)(file)) {
|
|
8
9
|
const { id, path } = (0, URI_1.parseURI)(file);
|
|
@@ -10,10 +11,10 @@ async function default_1(file, app, opener) {
|
|
|
10
11
|
// open files through protocol links
|
|
11
12
|
// vscode://file/<path>
|
|
12
13
|
// vscode-insiders://file/<path>
|
|
13
|
-
opener(`vscode://file/${path}`);
|
|
14
|
+
opener(`vscode://file/${(0, Local_1.osify)(path)}`);
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
|
-
opener(path);
|
|
17
|
+
opener((0, Local_1.osify)(path));
|
|
17
18
|
}
|
|
18
19
|
return '';
|
|
19
20
|
}
|
package/dist/commands/remove.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
7
|
const types_1 = require("../types");
|
|
8
|
-
const promises_1 = require("node:fs/promises");
|
|
9
8
|
const Local_1 = require("../Local");
|
|
10
9
|
const URI_1 = require("../utils/URI");
|
|
11
10
|
const uniqid_1 = __importDefault(require("../utils/uniqid"));
|
|
@@ -21,10 +20,10 @@ async function default_1(files, connPath, immediately = false) {
|
|
|
21
20
|
if ((0, URI_1.isLocal)(files[0])) {
|
|
22
21
|
const paths = files.map(p => (0, URI_1.parseURI)(p)['path']);
|
|
23
22
|
if (immediately) {
|
|
24
|
-
paths.forEach(path => (0,
|
|
23
|
+
paths.forEach(path => (0, Local_1.del)(path));
|
|
25
24
|
}
|
|
26
25
|
else {
|
|
27
|
-
(await trash).default(paths);
|
|
26
|
+
(await trash).default(paths.map(path => (0, Local_1.osify)(path)));
|
|
28
27
|
}
|
|
29
28
|
paths.forEach(path => {
|
|
30
29
|
if (path.startsWith(connPath) && !(0, Local_1.stat)(path)?.dir) {
|
package/dist/commands/rename.js
CHANGED
|
@@ -4,18 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
7
|
+
const posix_1 = require("node:path/posix");
|
|
8
8
|
const URI_1 = require("../utils/URI");
|
|
9
9
|
const Connection_1 = __importDefault(require("../Connection"));
|
|
10
10
|
const App_1 = __importDefault(require("../App"));
|
|
11
11
|
async function default_1(uri, name) {
|
|
12
12
|
const { id, path } = (0, URI_1.parseURI)(uri);
|
|
13
|
-
const to = (0,
|
|
13
|
+
const to = (0, posix_1.join)((0, posix_1.dirname)(path), name);
|
|
14
14
|
if (path == to) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
await Connection_1.default.get(id).rename(path, to);
|
|
18
18
|
if (!(0, URI_1.isLocal)(uri)) {
|
|
19
|
-
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0,
|
|
19
|
+
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, posix_1.dirname)(path)));
|
|
20
20
|
}
|
|
21
21
|
}
|