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.
@@ -5,11 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSettings = getSettings;
7
7
  exports.default = default_1;
8
- const Local_1 = require("../Local");
9
8
  const URI_1 = require("../utils/URI");
10
- const Local_2 = require("../Local");
9
+ const Local_1 = require("../Local");
11
10
  const ramda_1 = require("ramda");
12
- const promises_1 = require("node:fs/promises");
13
11
  const Password_1 = __importDefault(require("../Password"));
14
12
  function getSettings(settings) {
15
13
  return {
@@ -20,8 +18,8 @@ function getSettings(settings) {
20
18
  };
21
19
  }
22
20
  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) {
21
+ const content = (0, Local_1.stat)(path) ? await (0, Local_1.read)(path) : null;
22
+ if ((0, Local_1.stat)(path) && !content) {
25
23
  throw new Error(`Cant read connection file: ${path} ${typeof content}`);
26
24
  }
27
25
  let config = content ? JSON.parse(content) : {};
@@ -48,5 +46,5 @@ async function default_1(path, settings) {
48
46
  if (!config) {
49
47
  throw new Error(`Save invalid config into ${path}`);
50
48
  }
51
- await (0, promises_1.writeFile)(path, JSON.stringify(config));
49
+ await (0, Local_1.write)(path, JSON.stringify(config));
52
50
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = default_1;
4
- const promises_1 = require("node:fs/promises");
4
+ const Local_1 = require("../Local");
5
5
  const saveConnection_1 = require("./saveConnection");
6
6
  const ramda_1 = require("ramda");
7
7
  const _1 = require(".");
@@ -18,5 +18,5 @@ async function default_1(path, changes) {
18
18
  path: settings.path,
19
19
  sync: settings.sync
20
20
  };
21
- await (0, promises_1.writeFile)(path, JSON.stringify(config));
21
+ await (0, Local_1.write)(path, JSON.stringify(config));
22
22
  }
@@ -4,8 +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 node_os_1 = require("node:os");
8
- const node_path_1 = require("node:path");
7
+ const posix_1 = require("node:path/posix");
9
8
  const Local_1 = require("../Local");
10
9
  const Local_2 = require("../fs/Local");
11
10
  const connect_1 = require("./connect");
@@ -20,10 +19,12 @@ async function default_1(path) {
20
19
  config = JSON.parse(await (0, Local_1.read)(path));
21
20
  }
22
21
  catch (e) { }
22
+ const home = (0, Local_1.pwd)();
23
23
  const settings = {
24
- home: (0, node_os_1.homedir)(),
25
- settings: (0, node_path_1.join)((0, node_os_1.homedir)(), '.f5', 'settings.json'),
26
- connections: (0, node_path_1.join)((0, node_os_1.homedir)(), '.f5', 'connections'),
24
+ isWin: (0, Local_1.isWin)(),
25
+ home,
26
+ settings: (0, posix_1.join)(home, '.f5', 'settings.json'),
27
+ connections: (0, posix_1.join)(home, '.f5', 'connections'),
27
28
  keybindings: keybindings_json_1.default,
28
29
  mode: config?.mode ?? 'system',
29
30
  theme: config?.theme ?? 'black',
@@ -32,7 +33,7 @@ async function default_1(path) {
32
33
  sizeFmt: config?.sizeFmt ?? '0.0 b',
33
34
  local: (0, connect_1.explorerSettings)(Local_2.ATTRIBUTES, config?.local),
34
35
  remote: (0, connect_1.explorerSettings)(Local_2.ATTRIBUTES, config?.remote),
35
- path: config?.path ?? { local: (0, node_os_1.homedir)(), remote: (0, node_os_1.homedir)() },
36
+ path: config?.path ?? { local: home, remote: home },
36
37
  sync: config?.sync ?? null
37
38
  };
38
39
  if (settings.fileTheme) {
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = default_1;
7
7
  const Connection_1 = __importDefault(require("../Connection"));
8
8
  const URI_1 = require("../utils/URI");
9
- const node_path_1 = require("node:path");
9
+ const posix_1 = require("node:path/posix");
10
10
  const App_1 = __importDefault(require("../App"));
11
11
  async function default_1(file, content) {
12
12
  const { id, path } = (0, URI_1.parseURI)(file);
13
13
  await Connection_1.default.get(id).write(path, content);
14
14
  if (!(0, URI_1.isLocal)(file)) {
15
- App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, node_path_1.dirname)(path)));
15
+ App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, posix_1.dirname)(path)));
16
16
  }
17
17
  }
package/dist/fs/Ftp.js CHANGED
@@ -37,12 +37,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ATTRIBUTES = void 0;
40
- const node_path_1 = require("node:path");
40
+ const posix_1 = require("node:path/posix");
41
41
  const node_os_1 = require("node:os");
42
42
  const promises_1 = require("node:fs/promises");
43
43
  const fs = __importStar(require("fs"));
44
44
  const ftp_1 = __importDefault(require("ftp"));
45
45
  const FileSystem_1 = require("../FileSystem");
46
+ const Local_1 = require("../Local");
46
47
  // https://github.com/mscdex/node-ftp
47
48
  exports.ATTRIBUTES = [
48
49
  {
@@ -118,11 +119,11 @@ class Ftp extends FileSystem_1.FileSystem {
118
119
  .filter(f => f.name != '.' && f.name != '..')
119
120
  .map(f => {
120
121
  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));
122
+ if (target && !(0, posix_1.isAbsolute)(target)) {
123
+ target = (0, posix_1.normalize)((0, posix_1.join)(dir, target));
123
124
  }
124
125
  return {
125
- path: (0, node_path_1.join)(dir, f.name),
126
+ path: (0, posix_1.join)(dir, f.name),
126
127
  name: f.name,
127
128
  dir: f.type == 'd',
128
129
  size: f.size,
@@ -144,7 +145,7 @@ class Ftp extends FileSystem_1.FileSystem {
144
145
  reject(err);
145
146
  }
146
147
  else {
147
- const dest = fs.createWriteStream(toLocal);
148
+ const dest = fs.createWriteStream((0, Local_1.osify)(toLocal));
148
149
  dest.on('finish', () => resolve());
149
150
  source.pipe(dest);
150
151
  }
@@ -154,7 +155,7 @@ class Ftp extends FileSystem_1.FileSystem {
154
155
  async put(fromLocal, toRemote) {
155
156
  await this.open();
156
157
  return new Promise((resolve, reject) => {
157
- this.connection.put(fromLocal, toRemote, e => e ? reject(e) : resolve());
158
+ this.connection.put((0, Local_1.osify)(fromLocal), toRemote, e => e ? reject(e) : resolve());
158
159
  });
159
160
  }
160
161
  async rm(path, recursive) {
@@ -179,7 +180,7 @@ class Ftp extends FileSystem_1.FileSystem {
179
180
  return Promise.reject(new Error("FTP doesn't support remote duplication"));
180
181
  }
181
182
  async write(path, s) {
182
- const tmp = (0, node_path_1.join)((0, node_os_1.tmpdir)(), (0, node_path_1.basename)(path));
183
+ const tmp = (0, posix_1.join)((0, node_os_1.tmpdir)(), (0, posix_1.basename)(path));
183
184
  await (0, promises_1.writeFile)(tmp, s);
184
185
  await this.put(tmp, path);
185
186
  (0, promises_1.rm)(tmp);
package/dist/fs/Local.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ATTRIBUTES = void 0;
4
4
  const promises_1 = require("node:fs/promises");
5
- const node_path_1 = require("node:path");
5
+ const posix_1 = require("node:path/posix");
6
6
  const FileSystem_1 = require("../FileSystem");
7
7
  const Local_1 = require("../Local");
8
8
  const types_1 = require("../types");
@@ -45,24 +45,24 @@ class Local extends FileSystem_1.FileSystem {
45
45
  return (0, Local_1.del)(path);
46
46
  }
47
47
  async mkdir(path) {
48
- await (0, promises_1.mkdir)(path, { recursive: true });
48
+ await (0, Local_1.mkDirRecursive)(path);
49
49
  }
50
50
  async rename(from, to) {
51
- await (0, promises_1.rename)(from, to);
51
+ await (0, Local_1.move)(from, to);
52
52
  }
53
53
  async mv(from, to) {
54
54
  try {
55
55
  await (0, Local_1.del)(to);
56
56
  }
57
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);
58
+ await (0, Local_1.mkDirRecursive)((0, posix_1.dirname)(to));
59
+ await (0, Local_1.move)(from, to);
60
60
  }
61
61
  async cp(from, to, recursive) {
62
- await (0, promises_1.cp)(from, to, { recursive, force: true });
62
+ await (0, promises_1.cp)((0, Local_1.osify)(from), (0, Local_1.osify)(to), { recursive, force: true });
63
63
  }
64
64
  async write(path, data) {
65
- return (0, promises_1.writeFile)(path, data);
65
+ return (0, Local_1.write)(path, data);
66
66
  }
67
67
  }
68
68
  exports.default = Local;
package/dist/fs/S3.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ATTRIBUTES = void 0;
4
- const node_path_1 = require("node:path");
4
+ const posix_1 = require("node:path/posix");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const path_1 = require("../utils/path");
7
+ const Local_1 = require("../Local");
7
8
  const FileSystem_1 = require("../FileSystem");
8
9
  const client_s3_1 = require("@aws-sdk/client-s3");
9
10
  // https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
@@ -79,8 +80,8 @@ class S3 extends FileSystem_1.FileSystem {
79
80
  }));
80
81
  return [
81
82
  ...(output.CommonPrefixes ?? []).map(prefix => ({
82
- path: (0, node_path_1.resolve)('/', parts[0], prefix.Prefix),
83
- name: (0, node_path_1.basename)(prefix.Prefix),
83
+ path: (0, posix_1.resolve)('/', parts[0], prefix.Prefix),
84
+ name: (0, posix_1.basename)(prefix.Prefix),
84
85
  dir: true,
85
86
  size: 0,
86
87
  modified: new Date()
@@ -88,8 +89,8 @@ class S3 extends FileSystem_1.FileSystem {
88
89
  ...(output.Contents ?? [])
89
90
  .filter(({ Key }) => Key != target)
90
91
  .map(item => ({
91
- path: (0, node_path_1.resolve)('/', parts[0], item.Key),
92
- name: (0, node_path_1.basename)(item.Key),
92
+ path: (0, posix_1.resolve)('/', parts[0], item.Key),
93
+ name: (0, posix_1.basename)(item.Key),
93
94
  dir: false,
94
95
  size: item.Size,
95
96
  modified: new Date(item.LastModified)
@@ -104,7 +105,7 @@ class S3 extends FileSystem_1.FileSystem {
104
105
  }));
105
106
  if (output.Body) {
106
107
  const body = output.Body;
107
- const writeStream = (0, node_fs_1.createWriteStream)(toLocal);
108
+ const writeStream = (0, node_fs_1.createWriteStream)((0, Local_1.osify)(toLocal));
108
109
  body.pipe(writeStream);
109
110
  return new Promise((resolve, reject) => {
110
111
  writeStream.on('finish', resolve);
@@ -120,7 +121,7 @@ class S3 extends FileSystem_1.FileSystem {
120
121
  Key: parts.slice(1).join('/')
121
122
  }));
122
123
  const partSize = 5 * 1024 * 1024;
123
- const fromStream = (0, node_fs_1.createReadStream)(fromLocal, { highWaterMark: partSize });
124
+ const fromStream = (0, node_fs_1.createReadStream)((0, Local_1.osify)(fromLocal), { highWaterMark: partSize });
124
125
  let buffer = [];
125
126
  let partNumber = 1;
126
127
  const uploadParts = [];
@@ -176,7 +177,7 @@ class S3 extends FileSystem_1.FileSystem {
176
177
  return this.mv(from, to);
177
178
  }
178
179
  async mv(from, to) {
179
- const isDir = (await this.ls((0, node_path_1.dirname)(from))).find(({ path }) => path == from)?.dir ?? false;
180
+ const isDir = (await this.ls((0, posix_1.dirname)(from))).find(({ path }) => path == from)?.dir ?? false;
180
181
  await this.cp(from, to, isDir);
181
182
  const recursiveRm = async (path) => {
182
183
  await Promise.all((await this.ls(path)).map(f => f.dir ? recursiveRm(f.path) : this.rm(f.path, false)));
@@ -186,13 +187,13 @@ class S3 extends FileSystem_1.FileSystem {
186
187
  }
187
188
  async cp(from, to, recursive) {
188
189
  if (recursive) {
189
- await Promise.all((await this.ls(from)).map(f => this.cp(f.path, (0, node_path_1.resolve)(to, f.name), f.dir)));
190
+ await Promise.all((await this.ls(from)).map(f => this.cp(f.path, (0, posix_1.resolve)(to, f.name), f.dir)));
190
191
  }
191
192
  else {
192
193
  const parts = (0, path_1.split)(from);
193
194
  await this.connection.send(new client_s3_1.CopyObjectCommand({
194
195
  Bucket: parts[0],
195
- CopySource: (0, node_path_1.resolve)(from) + (recursive ? '/' : ''),
196
+ CopySource: (0, posix_1.resolve)(from) + (recursive ? '/' : ''),
196
197
  Key: (0, path_1.split)(to).slice(1).join('/') + (recursive ? '/' : '')
197
198
  }));
198
199
  }
@@ -213,7 +214,7 @@ class S3 extends FileSystem_1.FileSystem {
213
214
  async listBuckets() {
214
215
  const output = await this.connection.send(new client_s3_1.ListBucketsCommand({}));
215
216
  return (output.Buckets ?? []).map(bucket => ({
216
- path: (0, node_path_1.join)('/', bucket.Name),
217
+ path: (0, posix_1.join)('/', bucket.Name),
217
218
  name: bucket.Name,
218
219
  dir: true,
219
220
  size: 0,
package/dist/fs/SFtp.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ATTRIBUTES = void 0;
4
- const node_path_1 = require("node:path");
4
+ const posix_1 = require("node:path/posix");
5
5
  const ssh2_1 = require("ssh2");
6
6
  const FileSystem_1 = require("../FileSystem");
7
+ const Local_1 = require("../Local");
7
8
  // https://github.com/mscdex/ssh2/blob/master/SFTP.md
8
9
  // https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-4.3
9
10
  // see also https://github.com/theophilusx/ssh2-sftp-client
@@ -107,13 +108,13 @@ class SFtp extends FileSystem_1.FileSystem {
107
108
  const files = [];
108
109
  for (let f of list) {
109
110
  if (f.attrs.isSymbolicLink()) {
110
- let target = await this.readlink((0, node_path_1.join)(dir, f.filename));
111
- if (!(0, node_path_1.isAbsolute)(target)) {
112
- target = (0, node_path_1.normalize)((0, node_path_1.join)(dir, target));
111
+ let target = await this.readlink((0, posix_1.join)(dir, f.filename));
112
+ if (!(0, posix_1.isAbsolute)(target)) {
113
+ target = (0, posix_1.normalize)((0, posix_1.join)(dir, target));
113
114
  }
114
115
  const targetStat = await this.stat(target);
115
116
  files.push({
116
- path: (0, node_path_1.join)(dir, f.filename),
117
+ path: (0, posix_1.join)(dir, f.filename),
117
118
  name: f.filename,
118
119
  dir: f.attrs.isDirectory(),
119
120
  size: targetStat.size,
@@ -126,7 +127,7 @@ class SFtp extends FileSystem_1.FileSystem {
126
127
  }
127
128
  else {
128
129
  files.push({
129
- path: (0, node_path_1.join)(dir, f.filename),
130
+ path: (0, posix_1.join)(dir, f.filename),
130
131
  name: f.filename,
131
132
  dir: f.attrs.isDirectory(),
132
133
  size: f.attrs.size,
@@ -156,13 +157,13 @@ class SFtp extends FileSystem_1.FileSystem {
156
157
  async get(fromRemote, toLocal) {
157
158
  const sftp = await this.open();
158
159
  return new Promise((resolve, reject) => {
159
- sftp.fastGet(fromRemote, toLocal, (e) => e ? reject(new Error(this.decodeError(e))) : resolve());
160
+ sftp.fastGet(fromRemote, (0, Local_1.osify)(toLocal), (e) => e ? reject(new Error(this.decodeError(e))) : resolve());
160
161
  });
161
162
  }
162
163
  async put(fromLocal, toRemote) {
163
164
  const sftp = await this.open();
164
165
  return new Promise((resolve, reject) => {
165
- sftp.fastPut(fromLocal, toRemote, e => e ? reject(new Error(this.decodeError(e) + ` ${toRemote}`)) : resolve());
166
+ sftp.fastPut((0, Local_1.osify)(fromLocal), toRemote, e => e ? reject(new Error(this.decodeError(e) + ` ${toRemote}`)) : resolve());
166
167
  });
167
168
  }
168
169
  async rm(path, recursive) {
@@ -196,7 +197,7 @@ class SFtp extends FileSystem_1.FileSystem {
196
197
  }
197
198
  async mv(from, to) {
198
199
  await this.exec(`rm -Rf '${to}'`);
199
- await this.exec(`mkdir -p '${(0, node_path_1.dirname)(to)}'`);
200
+ await this.exec(`mkdir -p '${(0, posix_1.dirname)(to)}'`);
200
201
  return this.exec(`mv -f '${from}' '${to}'`);
201
202
  }
202
203
  async cp(from, to, recursive) {
@@ -204,7 +205,7 @@ class SFtp extends FileSystem_1.FileSystem {
204
205
  if (recursive) {
205
206
  return this.exec(`cp -fR '${from}' '${to}'`);
206
207
  }
207
- await this.exec(`mkdir -p '${(0, node_path_1.dirname)(to)}'`);
208
+ await this.exec(`mkdir -p '${(0, posix_1.dirname)(to)}'`);
208
209
  return this.exec(`cp -f '${from}' '${to}'`);
209
210
  }
210
211
  async write(path, s) {
package/dist/index.js CHANGED
@@ -6,9 +6,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const express_1 = __importDefault(require("express"));
8
8
  const multer_1 = __importDefault(require("multer"));
9
- const path_1 = require("path");
9
+ const posix_1 = require("node:path/posix");
10
+ const node_path_1 = __importDefault(require("node:path"));
10
11
  const node_os_1 = require("node:os");
11
- const promises_1 = require("node:fs/promises");
12
+ const Local_1 = require("./Local");
12
13
  const App_1 = __importDefault(require("./App"));
13
14
  const ws_1 = require("ws");
14
15
  const open = import("open");
@@ -35,8 +36,7 @@ app.use(function (req, res, next) {
35
36
  next();
36
37
  });
37
38
  app.use(express_1.default.json());
38
- app.use(express_1.default.static((0, path_1.resolve)(__dirname, 'public')));
39
- app.use(express_1.default.static((0, path_1.resolve)(__dirname, '../dist/public')));
39
+ app.use(express_1.default.static(node_path_1.default.resolve(__dirname, 'public')));
40
40
  const server = app.listen(port, async () => {
41
41
  console.log(`FileFive is up on http://localhost:${port}`);
42
42
  if (process.env.NODE_ENV !== 'development') {
@@ -60,12 +60,13 @@ const upload = (0, multer_1.default)({ dest: (0, node_os_1.tmpdir)() });
60
60
  app.post('/api/upload', upload.array('files'), async function (req, res) {
61
61
  if (Array.isArray(req.files)) {
62
62
  const src = [];
63
- for (const { path, originalname } of req.files) {
64
- const fnm = (0, path_1.join)((0, path_1.dirname)(path), originalname);
65
- await (0, promises_1.rename)(path, fnm);
63
+ for (const { path: osPath, originalname } of req.files) {
64
+ const path = (0, Local_1.unosify)(osPath);
65
+ const fnm = (0, posix_1.join)((0, posix_1.dirname)(path), originalname);
66
+ await (0, Local_1.move)(path, fnm);
66
67
  src.push(fnm);
67
68
  }
68
- commands_1.commands.copy(src.map(path => (0, URI_1.createURI)(types_1.LocalFileSystemID, path)), req.body['to'], true, null, null, null, () => src.forEach(path => (0, promises_1.rm)(path, { force: true })));
69
+ commands_1.commands.copy(src.map(path => (0, URI_1.createURI)(types_1.LocalFileSystemID, path)), req.body['to'], true, null, null, null, () => src.forEach(path => (0, Local_1.del)(path)));
69
70
  }
70
71
  res.json(true);
71
72
  });