@e-mc/file-manager 0.13.0 → 0.13.2
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/README.md +10 -10
- package/index.js +23 -11
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.2/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { ChecksumValue, DataSource, IncrementalMatch, TaskAction } from "./squared";
|
|
@@ -296,15 +296,15 @@ NOTE: **FileManager** is a sub-class of [Host](https://www.npmjs.com/package/@e-
|
|
|
296
296
|
|
|
297
297
|
## References
|
|
298
298
|
|
|
299
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
300
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
301
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
302
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
303
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
304
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
305
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
306
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
307
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
299
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/squared.d.ts
|
|
300
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/asset.d.ts
|
|
301
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/core.d.ts
|
|
302
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/filemanager.d.ts
|
|
303
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/logger.d.ts
|
|
304
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/module.d.ts
|
|
305
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/node.d.ts
|
|
306
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/request.d.ts
|
|
307
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/settings.d.ts
|
|
308
308
|
|
|
309
309
|
* https://www.npmjs.com/package/@types/node
|
|
310
310
|
|
package/index.js
CHANGED
|
@@ -132,10 +132,20 @@ function bundleTorrent(host, files, mimeType, encoding) {
|
|
|
132
132
|
return output;
|
|
133
133
|
}
|
|
134
134
|
function recurseDir(output, subDirs, options) {
|
|
135
|
-
const { ignore, sortBy, recursive } = options;
|
|
135
|
+
const { ignore, ignoreRoot, sortBy, recursive } = options;
|
|
136
|
+
const fromDir = subDirs.length > 1 ? path.posix.join(...subDirs.slice(1)) : null;
|
|
137
|
+
if (ignoreRoot.length > 0 && fromDir && pm.isMatch(fromDir + '/', ignoreRoot, core_1.Host.PLATFORM_WIN32 ? { nocase: true } : undefined)) {
|
|
138
|
+
return output;
|
|
139
|
+
}
|
|
140
|
+
const ignoreGlob = ignore.length > 0 ? pm(ignore, core_1.Host.PLATFORM_WIN32 ? { nocase: true, matchBase: true } : { matchBase: true }) : null;
|
|
136
141
|
const baseDir = path.join(...subDirs);
|
|
137
142
|
const items = fs.readdirSync(baseDir, { withFileTypes: true })
|
|
138
|
-
.filter(item =>
|
|
143
|
+
.filter(item => {
|
|
144
|
+
if (ignoreGlob && ignoreGlob(fromDir ? path.posix.join(fromDir, item.name) : item.name)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return item.name;
|
|
148
|
+
})
|
|
139
149
|
.sort((a, b) => {
|
|
140
150
|
if (sortBy > 0) {
|
|
141
151
|
if (a.isDirectory() && !b.isDirectory()) {
|
|
@@ -150,11 +160,12 @@ function recurseDir(output, subDirs, options) {
|
|
|
150
160
|
for (const item of items) {
|
|
151
161
|
if (!item.isDirectory()) {
|
|
152
162
|
const pathname = path.join(baseDir, item.name);
|
|
153
|
-
if (
|
|
154
|
-
|
|
163
|
+
if (item.isSymbolicLink() && core_1.Host.isDir(pathname) || ignore.length > 0 && (core_1.Host.PLATFORM_WIN32 ? ignore.includes(pathname.toLowerCase()) : ignore.includes(pathname))) {
|
|
164
|
+
continue;
|
|
155
165
|
}
|
|
166
|
+
output.push(pathname);
|
|
156
167
|
}
|
|
157
|
-
else if (recursive) {
|
|
168
|
+
else if (recursive && (subDirs.length > 1 || (core_1.Host.PLATFORM_WIN32 ? !ignoreRoot.includes(item.name.toLowerCase()) : !ignoreRoot.includes(item.name)))) {
|
|
158
169
|
recurseDir(output, subDirs.concat(item.name), options);
|
|
159
170
|
}
|
|
160
171
|
}
|
|
@@ -196,7 +207,7 @@ function filterPaths(rootDir, values, options = {}) {
|
|
|
196
207
|
const [glob, globAbs] = createMatchNegate(include, options);
|
|
197
208
|
for (let i = 0; i < values.length; ++i) {
|
|
198
209
|
const value = values[i];
|
|
199
|
-
if (!isMatch(value,
|
|
210
|
+
if (!isMatch(value, globAbs) && !isMatch(value.substring(rootDir.length), glob)) {
|
|
200
211
|
values.splice(i--, 1);
|
|
201
212
|
}
|
|
202
213
|
}
|
|
@@ -210,7 +221,7 @@ function filterPaths(rootDir, values, options = {}) {
|
|
|
210
221
|
const [glob, globAbs] = createMatchNegate(exclude, options);
|
|
211
222
|
for (let i = 0; i < values.length; ++i) {
|
|
212
223
|
const value = values[i];
|
|
213
|
-
if (isMatch(value,
|
|
224
|
+
if (isMatch(value, globAbs) || isMatch(value.substring(rootDir.length), glob)) {
|
|
214
225
|
values.splice(i--, 1);
|
|
215
226
|
}
|
|
216
227
|
}
|
|
@@ -321,7 +332,7 @@ function setBufferTarget(item, buffer) {
|
|
|
321
332
|
}
|
|
322
333
|
}
|
|
323
334
|
async function doVerifyChecksum(root, from, options, nested) {
|
|
324
|
-
const { digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], verbose = true, joinRoot } = options;
|
|
335
|
+
const { digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], ignoreRoot = [], verbose = true, joinRoot } = options;
|
|
325
336
|
const parent = recursive === 1 && typeof verbose !== 'number';
|
|
326
337
|
let algorithm = options.algorithm;
|
|
327
338
|
from ||= checksumFile(algorithm);
|
|
@@ -349,7 +360,7 @@ async function doVerifyChecksum(root, from, options, nested) {
|
|
|
349
360
|
const filename = path.basename(from);
|
|
350
361
|
const files = [];
|
|
351
362
|
from = joinRoot ? path.join(root, filename) : path.resolve(from);
|
|
352
|
-
recurseDir(files, [root], { ignore: [...ignore, from], sortBy, recursive });
|
|
363
|
+
recurseDir(files, [root], { ignore: [...mapPosix(ignore), from], ignoreRoot: mapPosix(ignoreRoot), sortBy, recursive });
|
|
353
364
|
const items = fs.readFileSync(from, 'utf8').split('\n').map(item => {
|
|
354
365
|
const index = item.indexOf(' ');
|
|
355
366
|
return [item.substring(0, index), path.join(root, item.substring(index + 1))];
|
|
@@ -474,6 +485,7 @@ const isDownloadAll = (type) => type === 4 || type === 0;
|
|
|
474
485
|
const hasFiles = (type, uri) => type === 3 || type === 4 || type === 0 && request_1.isRclone(uri);
|
|
475
486
|
const hasIncremental = (value) => value === "etag" || value === "exists";
|
|
476
487
|
const matchPathname = (value) => core_1.Host.PLATFORM_WIN32 ? value.toLowerCase() : value;
|
|
488
|
+
const mapPosix = (values) => core_1.Host.PLATFORM_WIN32 ? values.map(value => core_1.Permission.toPosix(value).toLowerCase()) : values;
|
|
477
489
|
const formatPercent = (value) => Math.round(value).toString().padStart(3) + '%';
|
|
478
490
|
const formatLength = (value, length) => `${length} ${value + (length === 1 ? '' : 's')}`;
|
|
479
491
|
const checkEOF = (value) => /\n$/.test(value) ? value : value + '\n';
|
|
@@ -1448,13 +1460,13 @@ class FileManager extends core_1.Host {
|
|
|
1448
1460
|
else {
|
|
1449
1461
|
options ||= {};
|
|
1450
1462
|
}
|
|
1451
|
-
const { algorithm, digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], verbose = false, joinRoot } = options;
|
|
1463
|
+
const { algorithm, digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], ignoreRoot = [], verbose = false, joinRoot } = options;
|
|
1452
1464
|
to ||= checksumFile(algorithm);
|
|
1453
1465
|
let result = [];
|
|
1454
1466
|
try {
|
|
1455
1467
|
const filename = path.basename(to);
|
|
1456
1468
|
to = joinRoot ? path.join(root, to) : path.resolve(to);
|
|
1457
|
-
recurseDir(result, [root], { ignore: [...ignore, to], sortBy, recursive });
|
|
1469
|
+
recurseDir(result, [root], { ignore: [...mapPosix(ignore), to], ignoreRoot: mapPosix(ignoreRoot), sortBy, recursive });
|
|
1458
1470
|
const output = [];
|
|
1459
1471
|
for (const pathname of result = filterPaths(root, result, options)) {
|
|
1460
1472
|
if (recursive === 1 && path.basename(pathname) === filename) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/file-manager",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "FileManager constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@e-mc/cloud": "0.13.
|
|
23
|
-
"@e-mc/compress": "0.13.
|
|
24
|
-
"@e-mc/core": "0.13.
|
|
25
|
-
"@e-mc/document": "0.13.
|
|
26
|
-
"@e-mc/image": "0.13.
|
|
27
|
-
"@e-mc/request": "0.13.
|
|
28
|
-
"@e-mc/task": "0.13.
|
|
29
|
-
"@e-mc/types": "0.13.
|
|
30
|
-
"@e-mc/watch": "0.13.
|
|
22
|
+
"@e-mc/cloud": "0.13.2",
|
|
23
|
+
"@e-mc/compress": "0.13.2",
|
|
24
|
+
"@e-mc/core": "0.13.2",
|
|
25
|
+
"@e-mc/document": "0.13.2",
|
|
26
|
+
"@e-mc/image": "0.13.2",
|
|
27
|
+
"@e-mc/request": "0.13.2",
|
|
28
|
+
"@e-mc/task": "0.13.2",
|
|
29
|
+
"@e-mc/types": "0.13.2",
|
|
30
|
+
"@e-mc/watch": "0.13.2",
|
|
31
31
|
"chalk": "4.1.2",
|
|
32
32
|
"diff": "^8.0.2",
|
|
33
33
|
"picomatch": "^4.0.3"
|