@uipath/filesystem 1.205.0-preview.277 → 1.206.0-preview.279
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/browser.d.ts +1 -1
- package/dist/index.browser.js +60 -53
- package/dist/index.js +69 -45
- package/dist/interfaces.d.ts +50 -1
- package/dist/node.d.ts +8 -2
- package/package.json +2 -2
package/dist/browser.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class BrowserFileSystem implements IFileSystem {
|
|
|
9
9
|
utils: IUtils;
|
|
10
10
|
prepare(): Promise<void>;
|
|
11
11
|
private getFs;
|
|
12
|
-
readFile(path: string): Promise<Uint8Array | null>;
|
|
12
|
+
readFile(path: string): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
13
13
|
readFile(path: string, options: {
|
|
14
14
|
encoding: "utf-8";
|
|
15
15
|
} | "utf-8"): Promise<string | null>;
|
package/dist/index.browser.js
CHANGED
|
@@ -17,7 +17,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
return cached;
|
|
18
18
|
}
|
|
19
19
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
20
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
20
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
21
21
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
22
22
|
for (let key of __getOwnPropNames(mod))
|
|
23
23
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -377,8 +377,8 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
377
377
|
}
|
|
378
378
|
print(root = this._root.get("/")) {
|
|
379
379
|
let str = "";
|
|
380
|
-
const printTree = (
|
|
381
|
-
for (let [file, node] of
|
|
380
|
+
const printTree = (root, indent) => {
|
|
381
|
+
for (let [file, node] of root) {
|
|
382
382
|
if (file === 0)
|
|
383
383
|
continue;
|
|
384
384
|
let stat = node.get(STAT);
|
|
@@ -460,8 +460,8 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
460
460
|
if (filepath === "/")
|
|
461
461
|
throw new EEXIST;
|
|
462
462
|
let dir = this._lookup(path.dirname(filepath));
|
|
463
|
-
let
|
|
464
|
-
if (dir.has(
|
|
463
|
+
let basename2 = path.basename(filepath);
|
|
464
|
+
if (dir.has(basename2)) {
|
|
465
465
|
throw new EEXIST;
|
|
466
466
|
}
|
|
467
467
|
let entry = new Map;
|
|
@@ -473,7 +473,7 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
473
473
|
ino: this.autoinc()
|
|
474
474
|
};
|
|
475
475
|
entry.set(STAT, stat);
|
|
476
|
-
dir.set(
|
|
476
|
+
dir.set(basename2, entry);
|
|
477
477
|
}
|
|
478
478
|
rmdir(filepath) {
|
|
479
479
|
let dir = this._lookup(filepath);
|
|
@@ -482,8 +482,8 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
482
482
|
if (dir.size > 1)
|
|
483
483
|
throw new ENOTEMPTY;
|
|
484
484
|
let parent = this._lookup(path.dirname(filepath));
|
|
485
|
-
let
|
|
486
|
-
parent.delete(
|
|
485
|
+
let basename2 = path.basename(filepath);
|
|
486
|
+
parent.delete(basename2);
|
|
487
487
|
}
|
|
488
488
|
readdir(filepath) {
|
|
489
489
|
let dir = this._lookup(filepath);
|
|
@@ -513,7 +513,7 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
513
513
|
ino = this.autoinc();
|
|
514
514
|
}
|
|
515
515
|
let dir = this._lookup(path.dirname(filepath));
|
|
516
|
-
let
|
|
516
|
+
let basename2 = path.basename(filepath);
|
|
517
517
|
let stat = {
|
|
518
518
|
mode,
|
|
519
519
|
type: "file",
|
|
@@ -523,19 +523,19 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
523
523
|
};
|
|
524
524
|
let entry = new Map;
|
|
525
525
|
entry.set(STAT, stat);
|
|
526
|
-
dir.set(
|
|
526
|
+
dir.set(basename2, entry);
|
|
527
527
|
return stat;
|
|
528
528
|
}
|
|
529
529
|
unlink(filepath) {
|
|
530
530
|
let parent = this._lookup(path.dirname(filepath));
|
|
531
|
-
let
|
|
532
|
-
parent.delete(
|
|
531
|
+
let basename2 = path.basename(filepath);
|
|
532
|
+
parent.delete(basename2);
|
|
533
533
|
}
|
|
534
534
|
rename(oldFilepath, newFilepath) {
|
|
535
|
-
let
|
|
535
|
+
let basename2 = path.basename(newFilepath);
|
|
536
536
|
let entry = this._lookup(oldFilepath);
|
|
537
537
|
let destDir = this._lookup(path.dirname(newFilepath));
|
|
538
|
-
destDir.set(
|
|
538
|
+
destDir.set(basename2, entry);
|
|
539
539
|
this.unlink(oldFilepath);
|
|
540
540
|
}
|
|
541
541
|
stat(filepath) {
|
|
@@ -563,7 +563,7 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
563
563
|
ino = this.autoinc();
|
|
564
564
|
}
|
|
565
565
|
let dir = this._lookup(path.dirname(filepath));
|
|
566
|
-
let
|
|
566
|
+
let basename2 = path.basename(filepath);
|
|
567
567
|
let stat = {
|
|
568
568
|
mode,
|
|
569
569
|
type: "symlink",
|
|
@@ -574,7 +574,7 @@ var require_CacheFS = __commonJS(function(exports, module) {
|
|
|
574
574
|
};
|
|
575
575
|
let entry = new Map;
|
|
576
576
|
entry.set(STAT, stat);
|
|
577
|
-
dir.set(
|
|
577
|
+
dir.set(basename2, entry);
|
|
578
578
|
return stat;
|
|
579
579
|
}
|
|
580
580
|
_du(dir) {
|
|
@@ -642,48 +642,48 @@ var require_idb_keyval_cjs = __commonJS(function(exports) {
|
|
|
642
642
|
store = new Store;
|
|
643
643
|
return store;
|
|
644
644
|
}
|
|
645
|
-
function get(key,
|
|
645
|
+
function get(key, store = getDefaultStore()) {
|
|
646
646
|
let req;
|
|
647
|
-
return
|
|
648
|
-
req =
|
|
647
|
+
return store._withIDBStore("readwrite", (store) => {
|
|
648
|
+
req = store.get(key);
|
|
649
649
|
}).then(() => req.result);
|
|
650
650
|
}
|
|
651
|
-
function set(key, value,
|
|
652
|
-
return
|
|
653
|
-
|
|
651
|
+
function set(key, value, store = getDefaultStore()) {
|
|
652
|
+
return store._withIDBStore("readwrite", (store) => {
|
|
653
|
+
store.put(value, key);
|
|
654
654
|
});
|
|
655
655
|
}
|
|
656
|
-
function update(key, updater,
|
|
657
|
-
return
|
|
658
|
-
const req =
|
|
656
|
+
function update(key, updater, store = getDefaultStore()) {
|
|
657
|
+
return store._withIDBStore("readwrite", (store) => {
|
|
658
|
+
const req = store.get(key);
|
|
659
659
|
req.onsuccess = () => {
|
|
660
|
-
|
|
660
|
+
store.put(updater(req.result), key);
|
|
661
661
|
};
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
|
-
function del(key,
|
|
665
|
-
return
|
|
666
|
-
|
|
664
|
+
function del(key, store = getDefaultStore()) {
|
|
665
|
+
return store._withIDBStore("readwrite", (store) => {
|
|
666
|
+
store.delete(key);
|
|
667
667
|
});
|
|
668
668
|
}
|
|
669
|
-
function clear(
|
|
670
|
-
return
|
|
671
|
-
|
|
669
|
+
function clear(store = getDefaultStore()) {
|
|
670
|
+
return store._withIDBStore("readwrite", (store) => {
|
|
671
|
+
store.clear();
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
|
-
function keys(
|
|
675
|
-
const
|
|
676
|
-
return
|
|
677
|
-
(
|
|
674
|
+
function keys(store = getDefaultStore()) {
|
|
675
|
+
const keys = [];
|
|
676
|
+
return store._withIDBStore("readwrite", (store) => {
|
|
677
|
+
(store.openKeyCursor || store.openCursor).call(store).onsuccess = function() {
|
|
678
678
|
if (!this.result)
|
|
679
679
|
return;
|
|
680
|
-
|
|
680
|
+
keys.push(this.result.key);
|
|
681
681
|
this.result.continue();
|
|
682
682
|
};
|
|
683
|
-
}).then(() =>
|
|
683
|
+
}).then(() => keys);
|
|
684
684
|
}
|
|
685
|
-
function close(
|
|
686
|
-
return
|
|
685
|
+
function close(store = getDefaultStore()) {
|
|
686
|
+
return store._close();
|
|
687
687
|
}
|
|
688
688
|
exports.Store = Store;
|
|
689
689
|
exports.get = get;
|
|
@@ -857,8 +857,8 @@ var require_Mutex2 = __commonJS(function(exports, module) {
|
|
|
857
857
|
navigator.locks.request(this._database + "_lock", { ifAvailable: true }, (lock) => {
|
|
858
858
|
this._has = !!lock;
|
|
859
859
|
resolve(!!lock);
|
|
860
|
-
return new Promise((
|
|
861
|
-
this._release =
|
|
860
|
+
return new Promise((resolve) => {
|
|
861
|
+
this._release = resolve;
|
|
862
862
|
});
|
|
863
863
|
});
|
|
864
864
|
});
|
|
@@ -873,8 +873,8 @@ var require_Mutex2 = __commonJS(function(exports, module) {
|
|
|
873
873
|
navigator.locks.request(this._database + "_lock", { signal: controller.signal }, (lock) => {
|
|
874
874
|
this._has = !!lock;
|
|
875
875
|
resolve(!!lock);
|
|
876
|
-
return new Promise((
|
|
877
|
-
this._release =
|
|
876
|
+
return new Promise((resolve) => {
|
|
877
|
+
this._release = resolve;
|
|
878
878
|
});
|
|
879
879
|
});
|
|
880
880
|
});
|
|
@@ -1426,7 +1426,11 @@ class BrowserFileSystem {
|
|
|
1426
1426
|
if (seg === "." || seg === "")
|
|
1427
1427
|
continue;
|
|
1428
1428
|
if (seg === "..") {
|
|
1429
|
-
normalized.
|
|
1429
|
+
if (normalized.length > 0 && normalized.at(-1) !== "..") {
|
|
1430
|
+
normalized.pop();
|
|
1431
|
+
} else if (!isAbs) {
|
|
1432
|
+
normalized.push(seg);
|
|
1433
|
+
}
|
|
1430
1434
|
} else {
|
|
1431
1435
|
normalized.push(seg);
|
|
1432
1436
|
}
|
|
@@ -1436,7 +1440,7 @@ class BrowserFileSystem {
|
|
|
1436
1440
|
path = {
|
|
1437
1441
|
join: (...paths) => {
|
|
1438
1442
|
const joined = paths.filter(Boolean).join("/");
|
|
1439
|
-
return this.normalizePath(joined);
|
|
1443
|
+
return this.normalizePath(joined) || ".";
|
|
1440
1444
|
},
|
|
1441
1445
|
resolve: (...paths) => {
|
|
1442
1446
|
let resolved = "";
|
|
@@ -1454,20 +1458,23 @@ class BrowserFileSystem {
|
|
|
1454
1458
|
return this.normalizePath(resolved);
|
|
1455
1459
|
},
|
|
1456
1460
|
relative: (from, to) => {
|
|
1457
|
-
const fromParts = this.
|
|
1458
|
-
const toParts = this.
|
|
1461
|
+
const fromParts = this.path.resolve(from).split("/").filter(Boolean);
|
|
1462
|
+
const toParts = this.path.resolve(to).split("/").filter(Boolean);
|
|
1459
1463
|
let common = 0;
|
|
1460
1464
|
while (common < fromParts.length && common < toParts.length && fromParts[common] === toParts[common]) {
|
|
1461
1465
|
common++;
|
|
1462
1466
|
}
|
|
1463
1467
|
const ups = Array(fromParts.length - common).fill("..");
|
|
1464
1468
|
const downs = toParts.slice(common);
|
|
1465
|
-
return [...ups, ...downs].join("/")
|
|
1469
|
+
return [...ups, ...downs].join("/");
|
|
1466
1470
|
},
|
|
1467
1471
|
dirname: (p) => {
|
|
1472
|
+
const isAbs = p.startsWith("/");
|
|
1468
1473
|
const parts = p.split("/").filter(Boolean);
|
|
1469
1474
|
parts.pop();
|
|
1470
|
-
|
|
1475
|
+
if (parts.length === 0)
|
|
1476
|
+
return isAbs ? "/" : ".";
|
|
1477
|
+
return (isAbs ? "/" : "") + parts.join("/");
|
|
1471
1478
|
},
|
|
1472
1479
|
isAbsolute: (p) => p.startsWith("/"),
|
|
1473
1480
|
basename: (p, ext) => {
|
|
@@ -1537,8 +1544,8 @@ class BrowserFileSystem {
|
|
|
1537
1544
|
await this.mkdir(dir);
|
|
1538
1545
|
}
|
|
1539
1546
|
if (typeof data === "string") {
|
|
1540
|
-
const
|
|
1541
|
-
await fs.promises.writeFile(filePath, (
|
|
1547
|
+
const existing = await this.readFile(filePath, "utf-8");
|
|
1548
|
+
await fs.promises.writeFile(filePath, (existing ?? "") + data);
|
|
1542
1549
|
return;
|
|
1543
1550
|
}
|
|
1544
1551
|
const existing = await this.readFile(filePath) ?? new Uint8Array;
|
|
@@ -1778,4 +1785,4 @@ export {
|
|
|
1778
1785
|
setFileSystem
|
|
1779
1786
|
};
|
|
1780
1787
|
|
|
1781
|
-
//# debugId=
|
|
1788
|
+
//# debugId=4688F98F14FC4A4764756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
configurable: true,
|
|
12
|
-
set: __exportSetter.bind(all, name)
|
|
13
|
-
});
|
|
1
|
+
var __esm = (fn, res, err) => () => {
|
|
2
|
+
if (fn)
|
|
3
|
+
try {
|
|
4
|
+
res = fn(fn = 0);
|
|
5
|
+
} catch (e) {
|
|
6
|
+
err = [e];
|
|
7
|
+
}
|
|
8
|
+
if (err)
|
|
9
|
+
throw err[0];
|
|
10
|
+
return res;
|
|
14
11
|
};
|
|
15
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
16
12
|
|
|
17
13
|
// ../../node_modules/is-inside-container/node_modules/is-docker/index.js
|
|
18
14
|
import fs from "node:fs";
|
|
@@ -91,7 +87,7 @@ var init_is_wsl = __esm(() => {
|
|
|
91
87
|
|
|
92
88
|
// ../../node_modules/powershell-utils/index.js
|
|
93
89
|
import process3 from "node:process";
|
|
94
|
-
import { Buffer } from "node:buffer";
|
|
90
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
95
91
|
import { promisify } from "node:util";
|
|
96
92
|
import childProcess from "node:child_process";
|
|
97
93
|
var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
|
|
@@ -117,7 +113,7 @@ var init_powershell_utils = __esm(() => {
|
|
|
117
113
|
"Bypass",
|
|
118
114
|
"-EncodedCommand"
|
|
119
115
|
];
|
|
120
|
-
executePowerShell.encodeCommand = (command) =>
|
|
116
|
+
executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
|
|
121
117
|
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
122
118
|
});
|
|
123
119
|
|
|
@@ -359,12 +355,6 @@ var init_is_in_ssh = __esm(() => {
|
|
|
359
355
|
});
|
|
360
356
|
|
|
361
357
|
// ../../node_modules/open/index.js
|
|
362
|
-
var exports_open = {};
|
|
363
|
-
__export(exports_open, {
|
|
364
|
-
apps: () => apps,
|
|
365
|
-
default: () => open_default,
|
|
366
|
-
openApp: () => openApp
|
|
367
|
-
});
|
|
368
358
|
import process8 from "node:process";
|
|
369
359
|
import path from "node:path";
|
|
370
360
|
import { fileURLToPath } from "node:url";
|
|
@@ -598,21 +588,6 @@ var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEach
|
|
|
598
588
|
...options,
|
|
599
589
|
target
|
|
600
590
|
});
|
|
601
|
-
}, openApp = (name, options) => {
|
|
602
|
-
if (typeof name !== "string" && !Array.isArray(name)) {
|
|
603
|
-
throw new TypeError("Expected a valid `name`");
|
|
604
|
-
}
|
|
605
|
-
const { arguments: appArguments = [] } = options ?? {};
|
|
606
|
-
if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
|
|
607
|
-
throw new TypeError("Expected `appArguments` as Array type");
|
|
608
|
-
}
|
|
609
|
-
return baseOpen({
|
|
610
|
-
...options,
|
|
611
|
-
app: {
|
|
612
|
-
name,
|
|
613
|
-
arguments: appArguments
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
591
|
}, apps, open_default;
|
|
617
592
|
var init_open = __esm(() => {
|
|
618
593
|
init_wsl_utils();
|
|
@@ -669,7 +644,7 @@ var init_open = __esm(() => {
|
|
|
669
644
|
});
|
|
670
645
|
|
|
671
646
|
// src/node.ts
|
|
672
|
-
import { randomUUID } from "node:crypto";
|
|
647
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
673
648
|
import { existsSync } from "node:fs";
|
|
674
649
|
import * as fs6 from "node:fs/promises";
|
|
675
650
|
import * as os2 from "node:os";
|
|
@@ -680,6 +655,9 @@ var LOCK_MAX_WAIT_MS = 20000;
|
|
|
680
655
|
var LOCK_MAX_HOLD_MS = 60000;
|
|
681
656
|
var LOCK_RETRY_MIN_MS = 100;
|
|
682
657
|
var LOCK_RETRY_JITTER_MS = 200;
|
|
658
|
+
var HASH_CHUNK_BYTES = 256 * 1024;
|
|
659
|
+
var hashBuffers = [];
|
|
660
|
+
var HASH_BUFFERS_KEPT = 64;
|
|
683
661
|
|
|
684
662
|
class NodeFileSystem {
|
|
685
663
|
path = {
|
|
@@ -698,16 +676,16 @@ class NodeFileSystem {
|
|
|
698
676
|
};
|
|
699
677
|
utils = {
|
|
700
678
|
open: async (url) => {
|
|
701
|
-
|
|
702
|
-
await
|
|
679
|
+
await Promise.resolve().then(() => init_open());
|
|
680
|
+
await open_default(url);
|
|
703
681
|
}
|
|
704
682
|
};
|
|
705
|
-
async readFile(
|
|
683
|
+
async readFile(path, options) {
|
|
706
684
|
try {
|
|
707
685
|
if (options) {
|
|
708
|
-
return await fs6.readFile(
|
|
686
|
+
return await fs6.readFile(path, "utf-8");
|
|
709
687
|
}
|
|
710
|
-
return await fs6.readFile(
|
|
688
|
+
return await fs6.readFile(path);
|
|
711
689
|
} catch (error) {
|
|
712
690
|
if (this.isEnoent(error))
|
|
713
691
|
return null;
|
|
@@ -737,6 +715,15 @@ class NodeFileSystem {
|
|
|
737
715
|
throw error;
|
|
738
716
|
}
|
|
739
717
|
}
|
|
718
|
+
async readdirEntries(dirPath) {
|
|
719
|
+
try {
|
|
720
|
+
return await fs6.readdir(dirPath, { withFileTypes: true });
|
|
721
|
+
} catch (error) {
|
|
722
|
+
if (this.isEnoent(error))
|
|
723
|
+
return [];
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
740
727
|
async stat(filePath) {
|
|
741
728
|
try {
|
|
742
729
|
const stats = await fs6.stat(filePath);
|
|
@@ -744,7 +731,8 @@ class NodeFileSystem {
|
|
|
744
731
|
isFile: () => stats.isFile(),
|
|
745
732
|
isDirectory: () => stats.isDirectory(),
|
|
746
733
|
size: stats.size,
|
|
747
|
-
mtimeMs: stats.mtimeMs
|
|
734
|
+
mtimeMs: stats.mtimeMs,
|
|
735
|
+
ctimeMs: stats.ctimeMs
|
|
748
736
|
};
|
|
749
737
|
} catch (error) {
|
|
750
738
|
if (this.isEnoent(error))
|
|
@@ -858,6 +846,42 @@ class NodeFileSystem {
|
|
|
858
846
|
throw error;
|
|
859
847
|
}
|
|
860
848
|
}
|
|
849
|
+
async hashFile(filePath) {
|
|
850
|
+
let handle;
|
|
851
|
+
try {
|
|
852
|
+
handle = await fs6.open(filePath, "r");
|
|
853
|
+
} catch (error) {
|
|
854
|
+
if (this.isEnoent(error))
|
|
855
|
+
return null;
|
|
856
|
+
throw error;
|
|
857
|
+
}
|
|
858
|
+
const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
|
|
859
|
+
try {
|
|
860
|
+
const opened = await handle.stat();
|
|
861
|
+
const stats = {
|
|
862
|
+
isFile: () => opened.isFile(),
|
|
863
|
+
isDirectory: () => opened.isDirectory(),
|
|
864
|
+
size: opened.size,
|
|
865
|
+
mtimeMs: opened.mtimeMs,
|
|
866
|
+
ctimeMs: opened.ctimeMs
|
|
867
|
+
};
|
|
868
|
+
const hash = createHash("sha256");
|
|
869
|
+
let size = 0;
|
|
870
|
+
for (;; ) {
|
|
871
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
|
|
872
|
+
if (bytesRead === 0)
|
|
873
|
+
break;
|
|
874
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
875
|
+
size += bytesRead;
|
|
876
|
+
}
|
|
877
|
+
return { sha256: hash.digest("hex"), size, stats };
|
|
878
|
+
} finally {
|
|
879
|
+
if (hashBuffers.length < HASH_BUFFERS_KEPT) {
|
|
880
|
+
hashBuffers.push(buffer);
|
|
881
|
+
}
|
|
882
|
+
await handle.close();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
861
885
|
async realpath(filePath) {
|
|
862
886
|
try {
|
|
863
887
|
return await fs6.realpath(filePath);
|
|
@@ -916,4 +940,4 @@ export {
|
|
|
916
940
|
setFileSystem
|
|
917
941
|
};
|
|
918
942
|
|
|
919
|
-
//# debugId=
|
|
943
|
+
//# debugId=C2EACDA2C01DC6F664756E2164756E21
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -3,6 +3,21 @@ export interface FileSystemStats {
|
|
|
3
3
|
isDirectory(): boolean;
|
|
4
4
|
size: number;
|
|
5
5
|
mtimeMs: number;
|
|
6
|
+
/**
|
|
7
|
+
* When the entry's metadata last changed — moves with every write, and
|
|
8
|
+
* with a tool that sets `mtime` back. Optional: not every backend has one.
|
|
9
|
+
*/
|
|
10
|
+
ctimeMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One directory entry, typed by what the entry itself is — a symlink reports
|
|
14
|
+
* as a link, not as what it points to.
|
|
15
|
+
*/
|
|
16
|
+
export interface FileSystemDirent {
|
|
17
|
+
name: string;
|
|
18
|
+
isFile(): boolean;
|
|
19
|
+
isDirectory(): boolean;
|
|
20
|
+
isSymbolicLink(): boolean;
|
|
6
21
|
}
|
|
7
22
|
export interface IPath {
|
|
8
23
|
join(...paths: string[]): string;
|
|
@@ -22,13 +37,26 @@ export interface IUtils {
|
|
|
22
37
|
open(url: string): Promise<void>;
|
|
23
38
|
}
|
|
24
39
|
export interface IFileSystem {
|
|
25
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The file's bytes, or `null` when it does not exist. The bytes sit on a
|
|
42
|
+
* plain `ArrayBuffer` (never a `SharedArrayBuffer`), so they go straight
|
|
43
|
+
* into `Blob`, `File` and `fetch` bodies without a copy or a cast.
|
|
44
|
+
*/
|
|
45
|
+
readFile(path: string): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
26
46
|
readFile(path: string, options: {
|
|
27
47
|
encoding: "utf-8";
|
|
28
48
|
} | "utf-8"): Promise<string | null>;
|
|
29
49
|
writeFile(path: string, data: string | Uint8Array): Promise<void>;
|
|
30
50
|
appendFile(path: string, data: string | Uint8Array): Promise<void>;
|
|
31
51
|
readdir(path: string): Promise<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* `readdir` with each entry's type, from the listing itself — no `stat`
|
|
54
|
+
* per entry. Like `readdir`, a missing directory lists as empty.
|
|
55
|
+
*
|
|
56
|
+
* Optional so existing implementations and test doubles stay valid; a
|
|
57
|
+
* caller falls back to `readdir` and a `stat` per entry.
|
|
58
|
+
*/
|
|
59
|
+
readdirEntries?(path: string): Promise<FileSystemDirent[]>;
|
|
32
60
|
stat(path: string): Promise<FileSystemStats | null>;
|
|
33
61
|
exists(path: string): Promise<boolean>;
|
|
34
62
|
mkdir(path: string): Promise<void>;
|
|
@@ -85,6 +113,27 @@ export interface IFileSystem {
|
|
|
85
113
|
* caller treats a backend without it as one that has no links.
|
|
86
114
|
*/
|
|
87
115
|
isSymbolicLink?(path: string): Promise<boolean>;
|
|
116
|
+
/**
|
|
117
|
+
* SHA-256 of the file's bytes as lowercase hex, and how many bytes were
|
|
118
|
+
* hashed — streamed, so the file is never held in memory whole. `null`
|
|
119
|
+
* when there is no such file.
|
|
120
|
+
*
|
|
121
|
+
* The size is the count that went through the digest, not a separate
|
|
122
|
+
* `stat`, so the two always describe the same bytes even when the file is
|
|
123
|
+
* being written while it is read.
|
|
124
|
+
*
|
|
125
|
+
* `stats` is the opened file's own metadata, taken from the handle before
|
|
126
|
+
* the first read — the file that was hashed, not whatever the path names
|
|
127
|
+
* a moment earlier or later. Omitted by a backend that cannot provide it.
|
|
128
|
+
*
|
|
129
|
+
* Optional so existing implementations and test doubles stay valid; a
|
|
130
|
+
* caller falls back to `readFile` and hashing the bytes itself.
|
|
131
|
+
*/
|
|
132
|
+
hashFile?(path: string): Promise<{
|
|
133
|
+
sha256: string;
|
|
134
|
+
size: number;
|
|
135
|
+
stats?: FileSystemStats;
|
|
136
|
+
} | null>;
|
|
88
137
|
getTempDir(): Promise<string>;
|
|
89
138
|
copyDirectory(sourcePath: string, destPath: string): Promise<void>;
|
|
90
139
|
path: IPath;
|
package/dist/node.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { FileSystemStats, IEnv, IFileSystem, IPath, IUtils } from "./interfaces.js";
|
|
1
|
+
import type { FileSystemDirent, FileSystemStats, IEnv, IFileSystem, IPath, IUtils } from "./interfaces.js";
|
|
2
2
|
export declare class NodeFileSystem implements IFileSystem {
|
|
3
3
|
path: IPath;
|
|
4
4
|
env: IEnv;
|
|
5
5
|
utils: IUtils;
|
|
6
|
-
readFile(path: string): Promise<Uint8Array | null>;
|
|
6
|
+
readFile(path: string): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
7
7
|
readFile(path: string, options: {
|
|
8
8
|
encoding: "utf-8";
|
|
9
9
|
} | "utf-8"): Promise<string | null>;
|
|
10
10
|
writeFile(filePath: string, data: string | Uint8Array): Promise<void>;
|
|
11
11
|
appendFile(filePath: string, data: string | Uint8Array): Promise<void>;
|
|
12
12
|
readdir(dirPath: string): Promise<string[]>;
|
|
13
|
+
readdirEntries(dirPath: string): Promise<FileSystemDirent[]>;
|
|
13
14
|
stat(filePath: string): Promise<FileSystemStats | null>;
|
|
14
15
|
exists(filePath: string): Promise<boolean>;
|
|
15
16
|
mkdir(dirPath: string): Promise<void>;
|
|
@@ -19,6 +20,11 @@ export declare class NodeFileSystem implements IFileSystem {
|
|
|
19
20
|
rm(filePath: string): Promise<void>;
|
|
20
21
|
rename(oldPath: string, newPath: string): Promise<void>;
|
|
21
22
|
isSymbolicLink(filePath: string): Promise<boolean>;
|
|
23
|
+
hashFile(filePath: string): Promise<{
|
|
24
|
+
sha256: string;
|
|
25
|
+
size: number;
|
|
26
|
+
stats: FileSystemStats;
|
|
27
|
+
} | null>;
|
|
22
28
|
realpath(filePath: string): Promise<string>;
|
|
23
29
|
getTempDir(): Promise<string>;
|
|
24
30
|
copyDirectory(sourcePath: string, destPath: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/filesystem",
|
|
3
3
|
"author": "UiPath",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.206.0-preview.279",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/UiPath/cli.git",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"mihaigirleanu",
|
|
39
39
|
"vlad-uipath"
|
|
40
40
|
],
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d2176feff38d4e91a9d84723af847b2dfd5c6008"
|
|
42
42
|
}
|