filefive 1.0.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/CHANGELOG.md +2 -0
- package/LICENSE +674 -0
- package/README.md +53 -0
- package/dist/App.js +69 -0
- package/dist/Connection.js +193 -0
- package/dist/FileSystem.js +13 -0
- package/dist/FileWatcher.js +44 -0
- package/dist/Local.js +86 -0
- package/dist/LocalWatcher.js +48 -0
- package/dist/Password.js +51 -0
- package/dist/Queue.js +236 -0
- package/dist/RemoteWatcher.js +44 -0
- package/dist/Session.js +21 -0
- package/dist/commands/clear.js +22 -0
- package/dist/commands/connect.js +87 -0
- package/dist/commands/copy.js +65 -0
- package/dist/commands/disconnect.js +12 -0
- package/dist/commands/duplicate.js +44 -0
- package/dist/commands/getConnection.js +17 -0
- package/dist/commands/index.js +42 -0
- package/dist/commands/mkdir.js +42 -0
- package/dist/commands/read.js +13 -0
- package/dist/commands/remove.js +56 -0
- package/dist/commands/rename.js +21 -0
- package/dist/commands/resolve.js +14 -0
- package/dist/commands/saveConnection.js +50 -0
- package/dist/commands/saveSettings.js +21 -0
- package/dist/commands/settings.js +33 -0
- package/dist/commands/unwatch.js +14 -0
- package/dist/commands/watch.js +25 -0
- package/dist/commands/write.js +17 -0
- package/dist/fs/Ftp.js +188 -0
- package/dist/fs/Local.js +68 -0
- package/dist/fs/SFtp.js +268 -0
- package/dist/index.js +69 -0
- package/dist/keybindings.json +58 -0
- package/dist/log.js +147 -0
- package/dist/options.js +5 -0
- package/dist/public/76e5e3fe6b35d5e6a980.woff2 +0 -0
- package/dist/public/assets/android-chrome-144x144.png +0 -0
- package/dist/public/assets/android-chrome-192x192.png +0 -0
- package/dist/public/assets/android-chrome-256x256.png +0 -0
- package/dist/public/assets/android-chrome-36x36.png +0 -0
- package/dist/public/assets/android-chrome-384x384.png +0 -0
- package/dist/public/assets/android-chrome-48x48.png +0 -0
- package/dist/public/assets/android-chrome-512x512.png +0 -0
- package/dist/public/assets/android-chrome-72x72.png +0 -0
- package/dist/public/assets/android-chrome-96x96.png +0 -0
- package/dist/public/assets/apple-touch-icon-1024x1024.png +0 -0
- package/dist/public/assets/apple-touch-icon-114x114.png +0 -0
- package/dist/public/assets/apple-touch-icon-120x120.png +0 -0
- package/dist/public/assets/apple-touch-icon-144x144.png +0 -0
- package/dist/public/assets/apple-touch-icon-152x152.png +0 -0
- package/dist/public/assets/apple-touch-icon-167x167.png +0 -0
- package/dist/public/assets/apple-touch-icon-180x180.png +0 -0
- package/dist/public/assets/apple-touch-icon-57x57.png +0 -0
- package/dist/public/assets/apple-touch-icon-60x60.png +0 -0
- package/dist/public/assets/apple-touch-icon-72x72.png +0 -0
- package/dist/public/assets/apple-touch-icon-76x76.png +0 -0
- package/dist/public/assets/apple-touch-icon-precomposed.png +0 -0
- package/dist/public/assets/apple-touch-icon.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1125x2436.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1136x640.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1170x2532.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1179x2556.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1242x2208.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1242x2688.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1284x2778.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1290x2796.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1334x750.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1488x2266.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1536x2048.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1620x2160.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1640x2160.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1668x2224.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1668x2388.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-1792x828.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2048x1536.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2048x2732.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2160x1620.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2160x1640.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2208x1242.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2224x1668.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2266x1488.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2388x1668.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2436x1125.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2532x1170.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2556x1179.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2688x1242.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2732x2048.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2778x1284.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-2796x1290.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-640x1136.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-750x1334.png +0 -0
- package/dist/public/assets/apple-touch-startup-image-828x1792.png +0 -0
- package/dist/public/assets/browserconfig.xml +12 -0
- package/dist/public/assets/favicon-16x16.png +0 -0
- package/dist/public/assets/favicon-32x32.png +0 -0
- package/dist/public/assets/favicon-48x48.png +0 -0
- package/dist/public/assets/favicon.ico +0 -0
- package/dist/public/assets/manifest.webmanifest +68 -0
- package/dist/public/assets/mstile-144x144.png +0 -0
- package/dist/public/assets/mstile-150x150.png +0 -0
- package/dist/public/assets/mstile-310x150.png +0 -0
- package/dist/public/assets/mstile-310x310.png +0 -0
- package/dist/public/assets/mstile-70x70.png +0 -0
- package/dist/public/assets/yandex-browser-50x50.png +0 -0
- package/dist/public/assets/yandex-browser-manifest.json +9 -0
- package/dist/public/ceb05254cedfa895b512.ttf +0 -0
- package/dist/public/f72efa639bb45d29e62f.ttf +0 -0
- package/dist/public/index.html +1 -0
- package/dist/public/index.js +2 -0
- package/dist/public/index.js.LICENSE.txt +43 -0
- package/dist/queues/Copy.js +69 -0
- package/dist/queues/Download.js +30 -0
- package/dist/queues/Duplicate.js +27 -0
- package/dist/queues/Queue.js +214 -0
- package/dist/queues/Remove.js +82 -0
- package/dist/queues/Upload.js +57 -0
- package/dist/transform.js +24 -0
- package/dist/types.js +46 -0
- package/dist/utils/ReferenceCountMap.js +61 -0
- package/dist/utils/URI.js +44 -0
- package/dist/utils/filter.js +24 -0
- package/dist/utils/path.js +12 -0
- package/dist/utils/uniqid.js +6 -0
- package/package.json +68 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const Local_1 = require("../Local");
|
|
10
|
+
const URI_1 = require("../utils/URI");
|
|
11
|
+
const uniqid_1 = __importDefault(require("../utils/uniqid"));
|
|
12
|
+
const Queue_1 = require("../queues/Queue");
|
|
13
|
+
const Remove_1 = __importDefault(require("../queues/Remove"));
|
|
14
|
+
const trash = import("trash");
|
|
15
|
+
const App_1 = __importDefault(require("../App"));
|
|
16
|
+
const ramda_1 = require("ramda");
|
|
17
|
+
async function default_1(files, force, connPath, immediately = false) {
|
|
18
|
+
if (!files.length) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!force) {
|
|
22
|
+
App_1.default.onError({ type: types_1.FailureType.ConfirmDeletion, files });
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if ((0, URI_1.isLocal)(files[0])) {
|
|
26
|
+
const paths = files.map(p => (0, URI_1.parseURI)(p)['path']);
|
|
27
|
+
if (immediately) {
|
|
28
|
+
paths.forEach(path => (0, promises_1.rm)(path, { recursive: true, force: true }));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
(await trash).default(paths);
|
|
32
|
+
}
|
|
33
|
+
paths.forEach(path => {
|
|
34
|
+
if (path.startsWith(connPath) && !(0, Local_1.stat)(path)?.dir) {
|
|
35
|
+
// TODO delete from credentials
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const connId = (0, URI_1.parseURI)(files[0])['id'];
|
|
41
|
+
const id = (0, uniqid_1.default)();
|
|
42
|
+
const queue = new Remove_1.default(connId, files.map((0, ramda_1.pipe)(URI_1.parseURI, (0, ramda_1.prop)('path'))), state => App_1.default.onQueueUpdate(id, { type: types_1.QueueEventType.Update, state }), error => {
|
|
43
|
+
App_1.default.onError({
|
|
44
|
+
type: types_1.FailureType.RemoteError,
|
|
45
|
+
id: this.connId,
|
|
46
|
+
message: error.message ?? String(error)
|
|
47
|
+
});
|
|
48
|
+
}, () => {
|
|
49
|
+
Queue_1.queues.delete(id);
|
|
50
|
+
App_1.default.onQueueUpdate(id, { type: types_1.QueueEventType.Complete });
|
|
51
|
+
}, App_1.default.remoteWatcher);
|
|
52
|
+
Queue_1.queues.set(id, queue);
|
|
53
|
+
App_1.default.onQueueUpdate(id, { type: types_1.QueueEventType.Create, queueType: types_1.QueueType.Remove, connection: connId });
|
|
54
|
+
queue.create();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const URI_1 = require("../utils/URI");
|
|
9
|
+
const Connection_1 = __importDefault(require("../Connection"));
|
|
10
|
+
const App_1 = __importDefault(require("../App"));
|
|
11
|
+
async function default_1(uri, name) {
|
|
12
|
+
const { id, path } = (0, URI_1.parseURI)(uri);
|
|
13
|
+
const to = (0, node_path_1.join)((0, node_path_1.dirname)(path), name);
|
|
14
|
+
if (path == to) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
await Connection_1.default.get(id).rename(path, to);
|
|
18
|
+
if (!(0, URI_1.isLocal)(uri)) {
|
|
19
|
+
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, node_path_1.dirname)(path)));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const Queue_1 = require("../queues/Queue");
|
|
8
|
+
const Session_1 = __importDefault(require("../Session"));
|
|
9
|
+
function default_1(id, action, forAll, sid) {
|
|
10
|
+
if (sid) {
|
|
11
|
+
Session_1.default.set(sid, { action });
|
|
12
|
+
}
|
|
13
|
+
Queue_1.queues.get(id)?.resolve(action, forAll);
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSettings = getSettings;
|
|
7
|
+
exports.default = default_1;
|
|
8
|
+
const Local_1 = require("../Local");
|
|
9
|
+
const URI_1 = require("../utils/URI");
|
|
10
|
+
const Local_2 = require("../Local");
|
|
11
|
+
const ramda_1 = require("ramda");
|
|
12
|
+
const promises_1 = require("node:fs/promises");
|
|
13
|
+
const Password_1 = __importDefault(require("../Password"));
|
|
14
|
+
function getSettings(settings) {
|
|
15
|
+
return {
|
|
16
|
+
columns: settings.columns.filter((0, ramda_1.whereEq)({ visible: true })).map(({ name, width }) => ({ name, width })),
|
|
17
|
+
sort: settings.sort,
|
|
18
|
+
history: settings.history,
|
|
19
|
+
filter: settings.filter
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function default_1(path, settings) {
|
|
23
|
+
const content = (0, Local_2.stat)(path) ? await (0, Local_1.read)(path) : null;
|
|
24
|
+
if ((0, Local_2.stat)(path) && !content) {
|
|
25
|
+
throw new Error(`Cant read connection file: ${path} ${typeof content}`);
|
|
26
|
+
}
|
|
27
|
+
let config = content ? JSON.parse(content) : {};
|
|
28
|
+
if ('scheme' in settings) {
|
|
29
|
+
config = { ...config, ...(0, ramda_1.omit)(['password'], settings) };
|
|
30
|
+
if (settings.password.length) {
|
|
31
|
+
Password_1.default.save((0, URI_1.connectionID)(settings.scheme, settings.user, settings.host, settings.port), settings.password);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (settings.local) {
|
|
36
|
+
config.local = getSettings(settings.local);
|
|
37
|
+
}
|
|
38
|
+
if (settings.remote) {
|
|
39
|
+
config.remote = getSettings(settings.remote);
|
|
40
|
+
}
|
|
41
|
+
if (settings.path) {
|
|
42
|
+
config.path = settings.path;
|
|
43
|
+
}
|
|
44
|
+
config.sync = settings.sync;
|
|
45
|
+
}
|
|
46
|
+
if (!config) {
|
|
47
|
+
throw new Error(`Save invalid config into ${path}`);
|
|
48
|
+
}
|
|
49
|
+
await (0, promises_1.writeFile)(path, JSON.stringify(config));
|
|
50
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const saveConnection_1 = require("./saveConnection");
|
|
6
|
+
const ramda_1 = require("ramda");
|
|
7
|
+
const _1 = require(".");
|
|
8
|
+
async function default_1(path, changes) {
|
|
9
|
+
const settings = (0, ramda_1.mergeDeepRight)(await _1.commands.getSettings(path), changes);
|
|
10
|
+
const config = {
|
|
11
|
+
mode: settings.mode,
|
|
12
|
+
theme: settings.theme,
|
|
13
|
+
timeFmt: settings.timeFmt,
|
|
14
|
+
sizeFmt: settings.sizeFmt,
|
|
15
|
+
local: (0, saveConnection_1.getSettings)(settings.local),
|
|
16
|
+
remote: (0, saveConnection_1.getSettings)(settings.remote),
|
|
17
|
+
path: settings.path,
|
|
18
|
+
sync: settings.sync
|
|
19
|
+
};
|
|
20
|
+
await (0, promises_1.writeFile)(path, JSON.stringify(config));
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const node_os_1 = require("node:os");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const Local_1 = require("../Local");
|
|
10
|
+
const Local_2 = require("../fs/Local");
|
|
11
|
+
const connect_1 = require("./connect");
|
|
12
|
+
const keybindings_json_1 = __importDefault(require("../keybindings.json"));
|
|
13
|
+
async function default_1(path) {
|
|
14
|
+
let config = null;
|
|
15
|
+
try {
|
|
16
|
+
config = JSON.parse(await (0, Local_1.read)(path));
|
|
17
|
+
}
|
|
18
|
+
catch (e) { }
|
|
19
|
+
return {
|
|
20
|
+
home: (0, node_os_1.homedir)(),
|
|
21
|
+
settings: (0, node_path_1.join)((0, node_os_1.homedir)(), '.f5', 'settings.json'),
|
|
22
|
+
connections: (0, node_path_1.join)((0, node_os_1.homedir)(), '.f5', 'connections'),
|
|
23
|
+
keybindings: keybindings_json_1.default,
|
|
24
|
+
mode: config?.mode ?? 'system',
|
|
25
|
+
theme: config?.theme ?? 'black',
|
|
26
|
+
timeFmt: config?.timeFmt ?? 'yyyy-MM-dd HH:mm',
|
|
27
|
+
sizeFmt: config?.sizeFmt ?? '0.0 b',
|
|
28
|
+
local: (0, connect_1.explorerSettings)(Local_2.ATTRIBUTES, config?.local),
|
|
29
|
+
remote: (0, connect_1.explorerSettings)(Local_2.ATTRIBUTES, config?.remote),
|
|
30
|
+
path: config?.path ?? { local: (0, node_os_1.homedir)(), remote: (0, node_os_1.homedir)() },
|
|
31
|
+
sync: config?.sync ?? null
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const URI_1 = require("../utils/URI");
|
|
5
|
+
async function default_1(uri, local, remote, file) {
|
|
6
|
+
if ((0, URI_1.isLocal)(uri)) {
|
|
7
|
+
const { path } = (0, URI_1.parseURI)(uri);
|
|
8
|
+
local.unwatch(path);
|
|
9
|
+
file.unwatch(path);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
remote.unwatch(uri);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const URI_1 = require("../utils/URI");
|
|
5
|
+
const Local_1 = require("../Local");
|
|
6
|
+
async function default_1(uri, local, remote, file) {
|
|
7
|
+
if ((0, URI_1.isLocal)(uri)) {
|
|
8
|
+
const { path } = (0, URI_1.parseURI)(uri);
|
|
9
|
+
const f = (0, Local_1.stat)(path);
|
|
10
|
+
if (f) {
|
|
11
|
+
if (f.dir) {
|
|
12
|
+
local.watch(path);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
file.watch(path);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
local.watch(path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
remote.watch(uri);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const Connection_1 = __importDefault(require("../Connection"));
|
|
8
|
+
const URI_1 = require("../utils/URI");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const App_1 = __importDefault(require("../App"));
|
|
11
|
+
async function default_1(file, content) {
|
|
12
|
+
const { id, path } = (0, URI_1.parseURI)(file);
|
|
13
|
+
await Connection_1.default.get(id).write(path, content);
|
|
14
|
+
if (!(0, URI_1.isLocal)(file)) {
|
|
15
|
+
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, node_path_1.dirname)(path)));
|
|
16
|
+
}
|
|
17
|
+
}
|
package/dist/fs/Ftp.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ATTRIBUTES = void 0;
|
|
40
|
+
const node_path_1 = require("node:path");
|
|
41
|
+
const node_os_1 = require("node:os");
|
|
42
|
+
const promises_1 = require("node:fs/promises");
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const ftp_1 = __importDefault(require("ftp"));
|
|
45
|
+
const FileSystem_1 = require("../FileSystem");
|
|
46
|
+
// https://github.com/mscdex/node-ftp
|
|
47
|
+
exports.ATTRIBUTES = [
|
|
48
|
+
{
|
|
49
|
+
name: "name",
|
|
50
|
+
type: FileSystem_1.FileAttributeType.String,
|
|
51
|
+
title: "Name"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "size",
|
|
55
|
+
type: FileSystem_1.FileAttributeType.Number,
|
|
56
|
+
title: "Size"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "modified",
|
|
60
|
+
type: FileSystem_1.FileAttributeType.Date,
|
|
61
|
+
title: "Last Modified"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "rights",
|
|
65
|
+
type: FileSystem_1.FileAttributeType.Rights,
|
|
66
|
+
title: "Rights"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
function parseRights(part) {
|
|
70
|
+
return (part.includes('r') ? 'r' : '-') + (part.includes('w') ? 'w' : '-') + (part.includes('x') ? 'x' : '-');
|
|
71
|
+
}
|
|
72
|
+
class Ftp extends FileSystem_1.FileSystem {
|
|
73
|
+
constructor(host, user, password, port = 21, onError, onClose = () => { }) {
|
|
74
|
+
super();
|
|
75
|
+
this.host = host;
|
|
76
|
+
this.user = user;
|
|
77
|
+
this.password = password;
|
|
78
|
+
this.port = port;
|
|
79
|
+
this.onError = onError;
|
|
80
|
+
this.onClose = onClose;
|
|
81
|
+
this.connection = new ftp_1.default();
|
|
82
|
+
this.connection.on('close', () => {
|
|
83
|
+
this.connected = undefined;
|
|
84
|
+
this.onClose();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async open() {
|
|
88
|
+
if (this.connected === undefined) {
|
|
89
|
+
this.connected = new Promise((resolve, reject) => {
|
|
90
|
+
this.connection
|
|
91
|
+
.on('ready', () => {
|
|
92
|
+
this.connection.on('error', this.onError);
|
|
93
|
+
resolve(this.uri = `ftp://${this.user}@${this.host}:${this.port}`);
|
|
94
|
+
})
|
|
95
|
+
.on('error', reject);
|
|
96
|
+
});
|
|
97
|
+
this.connection.connect({ host: this.host, user: this.user, password: this.password, port: this.port });
|
|
98
|
+
}
|
|
99
|
+
return this.connected;
|
|
100
|
+
}
|
|
101
|
+
close() {
|
|
102
|
+
this.connected != undefined && this.connection.end();
|
|
103
|
+
}
|
|
104
|
+
opened() {
|
|
105
|
+
return this.connected != undefined;
|
|
106
|
+
}
|
|
107
|
+
async pwd() {
|
|
108
|
+
await this.open();
|
|
109
|
+
return new Promise((resolve, reject) => this.connection.pwd((e, pwd) => e ? reject(e) : resolve(pwd)));
|
|
110
|
+
}
|
|
111
|
+
async ls(dir) {
|
|
112
|
+
await this.open();
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
this.connection.list(dir, (err, list) => {
|
|
115
|
+
err ?
|
|
116
|
+
reject(err) :
|
|
117
|
+
resolve(list
|
|
118
|
+
.filter(f => f.name != '.' && f.name != '..')
|
|
119
|
+
.map(f => {
|
|
120
|
+
let target = f.target;
|
|
121
|
+
if (target && !(0, node_path_1.isAbsolute)(target)) {
|
|
122
|
+
target = (0, node_path_1.normalize)((0, node_path_1.join)(dir, target));
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
path: (0, node_path_1.join)(dir, f.name),
|
|
126
|
+
name: f.name,
|
|
127
|
+
dir: f.type == 'd',
|
|
128
|
+
size: f.size,
|
|
129
|
+
modified: f.date,
|
|
130
|
+
owner: f.owner,
|
|
131
|
+
group: f.group,
|
|
132
|
+
rights: f.rights ? parseRights(f.rights.user) + parseRights(f.rights.group) + parseRights(f.rights.other) : '',
|
|
133
|
+
target
|
|
134
|
+
};
|
|
135
|
+
}));
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async get(fromRemote, toLocal) {
|
|
140
|
+
await this.open();
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
this.connection.get(fromRemote, (err, source) => {
|
|
143
|
+
if (err) {
|
|
144
|
+
reject(err);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const dest = fs.createWriteStream(toLocal);
|
|
148
|
+
dest.on('finish', () => resolve());
|
|
149
|
+
source.pipe(dest);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async put(fromLocal, toRemote) {
|
|
155
|
+
await this.open();
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
this.connection.put(fromLocal, toRemote, e => e ? reject(e) : resolve());
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async rm(path, recursive) {
|
|
161
|
+
await this.open();
|
|
162
|
+
return new Promise((resolve, reject) => recursive ?
|
|
163
|
+
this.connection.rmdir(path, true, e => e ? reject(e) : resolve()) :
|
|
164
|
+
this.connection.delete(path, e => e ? reject(e) : resolve()));
|
|
165
|
+
}
|
|
166
|
+
async mkdir(path) {
|
|
167
|
+
await this.open();
|
|
168
|
+
return new Promise((resolve, reject) => this.connection.mkdir(path, true, e => e ? reject(e) : resolve()));
|
|
169
|
+
}
|
|
170
|
+
async rename(from, to) {
|
|
171
|
+
await this.open();
|
|
172
|
+
return new Promise((resolve, reject) => this.connection.rename(from, to, e => e ? reject(e) : resolve()));
|
|
173
|
+
}
|
|
174
|
+
async mv(from, to) {
|
|
175
|
+
await this.open();
|
|
176
|
+
return new Promise((resolve, reject) => this.connection.rename(from, to, e => e ? reject(e) : resolve()));
|
|
177
|
+
}
|
|
178
|
+
async cp(from, to, recursive) {
|
|
179
|
+
return Promise.reject(new Error("FTP doesn't support remote duplication"));
|
|
180
|
+
}
|
|
181
|
+
async write(path, s) {
|
|
182
|
+
const tmp = (0, node_path_1.join)((0, node_os_1.tmpdir)(), (0, node_path_1.basename)(path));
|
|
183
|
+
await (0, promises_1.writeFile)(tmp, s);
|
|
184
|
+
await this.put(tmp, path);
|
|
185
|
+
(0, promises_1.rm)(tmp);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.default = Ftp;
|
package/dist/fs/Local.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ATTRIBUTES = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const FileSystem_1 = require("../FileSystem");
|
|
7
|
+
const Local_1 = require("../Local");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
exports.ATTRIBUTES = [
|
|
10
|
+
{
|
|
11
|
+
name: "name",
|
|
12
|
+
type: FileSystem_1.FileAttributeType.String,
|
|
13
|
+
title: "Name"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "size",
|
|
17
|
+
type: FileSystem_1.FileAttributeType.Number,
|
|
18
|
+
title: "Size"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "modified",
|
|
22
|
+
type: FileSystem_1.FileAttributeType.Date,
|
|
23
|
+
title: "Last Modified"
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
class Local extends FileSystem_1.FileSystem {
|
|
27
|
+
open() {
|
|
28
|
+
return Promise.resolve(types_1.LocalFileSystemID);
|
|
29
|
+
}
|
|
30
|
+
opened() { return true; }
|
|
31
|
+
close() { }
|
|
32
|
+
pwd() {
|
|
33
|
+
return Promise.resolve((0, Local_1.pwd)());
|
|
34
|
+
}
|
|
35
|
+
ls(dir) {
|
|
36
|
+
return Promise.resolve((0, Local_1.list)(dir));
|
|
37
|
+
}
|
|
38
|
+
async get(fromRemote, toLocal) {
|
|
39
|
+
await (0, Local_1.copy)(fromRemote, toLocal, true);
|
|
40
|
+
}
|
|
41
|
+
async put(fromLocal, toRemote) {
|
|
42
|
+
await (0, Local_1.copy)(fromLocal, toRemote);
|
|
43
|
+
}
|
|
44
|
+
async rm(path, recursive) {
|
|
45
|
+
return (0, Local_1.del)(path);
|
|
46
|
+
}
|
|
47
|
+
async mkdir(path) {
|
|
48
|
+
await (0, promises_1.mkdir)(path, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
async rename(from, to) {
|
|
51
|
+
await (0, promises_1.rename)(from, to);
|
|
52
|
+
}
|
|
53
|
+
async mv(from, to) {
|
|
54
|
+
try {
|
|
55
|
+
await (0, Local_1.del)(to);
|
|
56
|
+
}
|
|
57
|
+
catch (e) { }
|
|
58
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(to), { recursive: true });
|
|
59
|
+
await (0, promises_1.rename)(from, to);
|
|
60
|
+
}
|
|
61
|
+
async cp(from, to, recursive) {
|
|
62
|
+
await (0, promises_1.cp)(from, to, { recursive, force: true });
|
|
63
|
+
}
|
|
64
|
+
async write(path, data) {
|
|
65
|
+
await (0, promises_1.writeFile)(path, data);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = Local;
|