@uipath/filesystem 1.206.0-preview.303 → 1.207.0-preview.305
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 +2 -2
- package/dist/index.browser.js +5 -3
- package/dist/index.js +30 -8
- package/dist/interfaces.d.ts +52 -3
- package/dist/node.d.ts +5 -4
- package/package.json +2 -2
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileSystemStats, IEnv, IFileSystem, IPath, IUtils } from "./interfaces.js";
|
|
1
|
+
import type { CopyDirectoryOptions, FileSystemStats, IEnv, IFileSystem, IPath, IUtils } from "./interfaces.js";
|
|
2
2
|
export declare class BrowserFileSystem implements IFileSystem {
|
|
3
3
|
private initialized;
|
|
4
4
|
private fsInstance;
|
|
@@ -27,7 +27,7 @@ export declare class BrowserFileSystem implements IFileSystem {
|
|
|
27
27
|
isSymbolicLink(_filePath: string): Promise<boolean>;
|
|
28
28
|
realpath(filePath: string): Promise<string>;
|
|
29
29
|
getTempDir(): Promise<string>;
|
|
30
|
-
copyDirectory(sourcePath: string, destPath: string): Promise<void>;
|
|
30
|
+
copyDirectory(sourcePath: string, destPath: string, options?: CopyDirectoryOptions): Promise<void>;
|
|
31
31
|
private isEnoent;
|
|
32
32
|
private isEexist;
|
|
33
33
|
private checkRootDirectory;
|
package/dist/index.browser.js
CHANGED
|
@@ -1714,7 +1714,7 @@ class BrowserFileSystem {
|
|
|
1714
1714
|
await this.mkdir(dir);
|
|
1715
1715
|
return dir;
|
|
1716
1716
|
}
|
|
1717
|
-
async copyDirectory(sourcePath, destPath) {
|
|
1717
|
+
async copyDirectory(sourcePath, destPath, options) {
|
|
1718
1718
|
const sourceStats = await this.stat(sourcePath);
|
|
1719
1719
|
if (!sourceStats) {
|
|
1720
1720
|
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
@@ -1731,7 +1731,9 @@ class BrowserFileSystem {
|
|
|
1731
1731
|
if (!entryStats)
|
|
1732
1732
|
continue;
|
|
1733
1733
|
if (entryStats.isDirectory()) {
|
|
1734
|
-
|
|
1734
|
+
if (options?.skipDirectoryNames?.includes(entry))
|
|
1735
|
+
continue;
|
|
1736
|
+
await this.copyDirectory(srcEntry, destEntry, options);
|
|
1735
1737
|
} else if (entryStats.isFile()) {
|
|
1736
1738
|
const content = await this.readFile(srcEntry);
|
|
1737
1739
|
if (content !== null) {
|
|
@@ -1785,4 +1787,4 @@ export {
|
|
|
1785
1787
|
setFileSystem
|
|
1786
1788
|
};
|
|
1787
1789
|
|
|
1788
|
-
//# debugId=
|
|
1790
|
+
//# debugId=7ADE99667A9770F164756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -692,12 +692,26 @@ class NodeFileSystem {
|
|
|
692
692
|
throw error;
|
|
693
693
|
}
|
|
694
694
|
}
|
|
695
|
-
async writeFile(filePath, data) {
|
|
695
|
+
async writeFile(filePath, data, options) {
|
|
696
696
|
const dir = path2.dirname(filePath);
|
|
697
697
|
if (dir) {
|
|
698
698
|
await fs6.mkdir(dir, { recursive: true });
|
|
699
699
|
}
|
|
700
|
-
|
|
700
|
+
if (options?.mode === undefined || process.platform === "win32") {
|
|
701
|
+
if (options?.exclusive) {
|
|
702
|
+
await fs6.writeFile(filePath, data, { flag: "wx" });
|
|
703
|
+
} else {
|
|
704
|
+
await fs6.writeFile(filePath, data);
|
|
705
|
+
}
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
|
|
709
|
+
try {
|
|
710
|
+
await handle.chmod(options.mode);
|
|
711
|
+
await handle.writeFile(data);
|
|
712
|
+
} finally {
|
|
713
|
+
await handle.close();
|
|
714
|
+
}
|
|
701
715
|
}
|
|
702
716
|
async appendFile(filePath, data) {
|
|
703
717
|
const dir = path2.dirname(filePath);
|
|
@@ -732,7 +746,8 @@ class NodeFileSystem {
|
|
|
732
746
|
isDirectory: () => stats.isDirectory(),
|
|
733
747
|
size: stats.size,
|
|
734
748
|
mtimeMs: stats.mtimeMs,
|
|
735
|
-
ctimeMs: stats.ctimeMs
|
|
749
|
+
ctimeMs: stats.ctimeMs,
|
|
750
|
+
mode: stats.mode
|
|
736
751
|
};
|
|
737
752
|
} catch (error) {
|
|
738
753
|
if (this.isEnoent(error))
|
|
@@ -743,8 +758,13 @@ class NodeFileSystem {
|
|
|
743
758
|
async exists(filePath) {
|
|
744
759
|
return existsSync(filePath);
|
|
745
760
|
}
|
|
746
|
-
async mkdir(dirPath) {
|
|
747
|
-
await fs6.mkdir(dirPath, { recursive: true });
|
|
761
|
+
async mkdir(dirPath, options) {
|
|
762
|
+
await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
|
|
763
|
+
}
|
|
764
|
+
async chmod(targetPath, mode) {
|
|
765
|
+
if (process.platform === "win32")
|
|
766
|
+
return;
|
|
767
|
+
await fs6.chmod(targetPath, mode);
|
|
748
768
|
}
|
|
749
769
|
async acquireLock(lockPath) {
|
|
750
770
|
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
@@ -894,7 +914,7 @@ class NodeFileSystem {
|
|
|
894
914
|
async getTempDir() {
|
|
895
915
|
return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
|
|
896
916
|
}
|
|
897
|
-
async copyDirectory(sourcePath, destPath) {
|
|
917
|
+
async copyDirectory(sourcePath, destPath, options) {
|
|
898
918
|
const sourceStats = await this.stat(sourcePath);
|
|
899
919
|
if (!sourceStats) {
|
|
900
920
|
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
@@ -911,7 +931,9 @@ class NodeFileSystem {
|
|
|
911
931
|
if (!entryStats)
|
|
912
932
|
continue;
|
|
913
933
|
if (entryStats.isDirectory()) {
|
|
914
|
-
|
|
934
|
+
if (options?.skipDirectoryNames?.includes(entry))
|
|
935
|
+
continue;
|
|
936
|
+
await this.copyDirectory(srcEntry, destEntry, options);
|
|
915
937
|
} else if (entryStats.isFile()) {
|
|
916
938
|
const content = await this.readFile(srcEntry);
|
|
917
939
|
if (content !== null) {
|
|
@@ -940,4 +962,4 @@ export {
|
|
|
940
962
|
setFileSystem
|
|
941
963
|
};
|
|
942
964
|
|
|
943
|
-
//# debugId=
|
|
965
|
+
//# debugId=0FCDBF061483938B64756E2164756E21
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export interface FileSystemStats {
|
|
|
8
8
|
* with a tool that sets `mtime` back. Optional: not every backend has one.
|
|
9
9
|
*/
|
|
10
10
|
ctimeMs?: number;
|
|
11
|
+
/**
|
|
12
|
+
* File type and permission bits (`st_mode`). Only backends with POSIX
|
|
13
|
+
* permissions (Node) set it; mask with `0o777` for the permission bits.
|
|
14
|
+
*/
|
|
15
|
+
mode?: number;
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* One directory entry, typed by what the entry itself is — a symlink reports
|
|
@@ -36,6 +41,29 @@ export interface IEnv {
|
|
|
36
41
|
export interface IUtils {
|
|
37
42
|
open(url: string): Promise<void>;
|
|
38
43
|
}
|
|
44
|
+
/** Options for {@link IFileSystem.copyDirectory}. */
|
|
45
|
+
export interface CopyDirectoryOptions {
|
|
46
|
+
/** Directory names to leave out of the copy, at any depth. */
|
|
47
|
+
skipDirectoryNames?: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* POSIX permission bits for an entry a call creates (e.g. `0o600`). Backends
|
|
51
|
+
* without POSIX permissions (browser, memory, Windows) ignore it, so it
|
|
52
|
+
* protects secrets only where other local users can read files.
|
|
53
|
+
*/
|
|
54
|
+
export interface FileModeOptions {
|
|
55
|
+
mode?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface WriteFileOptions extends FileModeOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Create the file, failing with `EEXIST` when anything is already at
|
|
60
|
+
* `path` — a file, or a symlink, which is never followed. Lets a caller
|
|
61
|
+
* that needs a file nobody else has opened (a credentials temp file in a
|
|
62
|
+
* shared directory) know it got one. Backends with a single user (browser,
|
|
63
|
+
* memory) ignore it and overwrite.
|
|
64
|
+
*/
|
|
65
|
+
exclusive?: boolean;
|
|
66
|
+
}
|
|
39
67
|
export interface IFileSystem {
|
|
40
68
|
/**
|
|
41
69
|
* The file's bytes, or `null` when it does not exist. The bytes sit on a
|
|
@@ -46,7 +74,13 @@ export interface IFileSystem {
|
|
|
46
74
|
readFile(path: string, options: {
|
|
47
75
|
encoding: "utf-8";
|
|
48
76
|
} | "utf-8"): Promise<string | null>;
|
|
49
|
-
|
|
77
|
+
/**
|
|
78
|
+
* With `mode`, the file holds those permission bits before any of `data`
|
|
79
|
+
* is written — an existing file is tightened too, so its new content is
|
|
80
|
+
* never readable under the old bits. Parent directories it creates get
|
|
81
|
+
* the default mode.
|
|
82
|
+
*/
|
|
83
|
+
writeFile(path: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
|
|
50
84
|
appendFile(path: string, data: string | Uint8Array): Promise<void>;
|
|
51
85
|
readdir(path: string): Promise<string[]>;
|
|
52
86
|
/**
|
|
@@ -59,7 +93,18 @@ export interface IFileSystem {
|
|
|
59
93
|
readdirEntries?(path: string): Promise<FileSystemDirent[]>;
|
|
60
94
|
stat(path: string): Promise<FileSystemStats | null>;
|
|
61
95
|
exists(path: string): Promise<boolean>;
|
|
62
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Creates `path` and any missing parents. `mode` applies only to the
|
|
98
|
+
* directories this call creates; an existing directory keeps its bits.
|
|
99
|
+
*/
|
|
100
|
+
mkdir(path: string, options?: FileModeOptions): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Sets the POSIX permission bits of an existing file or directory.
|
|
103
|
+
* Optional: an adapter without POSIX permissions (browser, memory) omits
|
|
104
|
+
* it, so callers use `fs.chmod?.(...)`. Windows does nothing, as with
|
|
105
|
+
* {@link FileModeOptions}.
|
|
106
|
+
*/
|
|
107
|
+
chmod?(path: string, mode: number): Promise<void>;
|
|
63
108
|
/**
|
|
64
109
|
* Acquire a cross-process advisory lock for `path`, serializing work
|
|
65
110
|
* across concurrent processes that would otherwise race on the same
|
|
@@ -135,7 +180,11 @@ export interface IFileSystem {
|
|
|
135
180
|
stats?: FileSystemStats;
|
|
136
181
|
} | null>;
|
|
137
182
|
getTempDir(): Promise<string>;
|
|
138
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Copy a directory tree. Directories named in `skipDirectoryNames` are
|
|
185
|
+
* left out at any depth, with everything inside them.
|
|
186
|
+
*/
|
|
187
|
+
copyDirectory(sourcePath: string, destPath: string, options?: CopyDirectoryOptions): Promise<void>;
|
|
139
188
|
path: IPath;
|
|
140
189
|
env: IEnv;
|
|
141
190
|
utils: IUtils;
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileSystemDirent, FileSystemStats, IEnv, IFileSystem, IPath, IUtils } from "./interfaces.js";
|
|
1
|
+
import type { CopyDirectoryOptions, FileModeOptions, FileSystemDirent, FileSystemStats, IEnv, IFileSystem, IPath, IUtils, WriteFileOptions } from "./interfaces.js";
|
|
2
2
|
export declare class NodeFileSystem implements IFileSystem {
|
|
3
3
|
path: IPath;
|
|
4
4
|
env: IEnv;
|
|
@@ -7,13 +7,14 @@ export declare class NodeFileSystem implements IFileSystem {
|
|
|
7
7
|
readFile(path: string, options: {
|
|
8
8
|
encoding: "utf-8";
|
|
9
9
|
} | "utf-8"): Promise<string | null>;
|
|
10
|
-
writeFile(filePath: string, data: string | Uint8Array): Promise<void>;
|
|
10
|
+
writeFile(filePath: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
|
|
11
11
|
appendFile(filePath: string, data: string | Uint8Array): Promise<void>;
|
|
12
12
|
readdir(dirPath: string): Promise<string[]>;
|
|
13
13
|
readdirEntries(dirPath: string): Promise<FileSystemDirent[]>;
|
|
14
14
|
stat(filePath: string): Promise<FileSystemStats | null>;
|
|
15
15
|
exists(filePath: string): Promise<boolean>;
|
|
16
|
-
mkdir(dirPath: string): Promise<void>;
|
|
16
|
+
mkdir(dirPath: string, options?: FileModeOptions): Promise<void>;
|
|
17
|
+
chmod(targetPath: string, mode: number): Promise<void>;
|
|
17
18
|
acquireLock(lockPath: string): Promise<() => Promise<void>>;
|
|
18
19
|
private canonicalizeLockTarget;
|
|
19
20
|
private createLockRelease;
|
|
@@ -27,7 +28,7 @@ export declare class NodeFileSystem implements IFileSystem {
|
|
|
27
28
|
} | null>;
|
|
28
29
|
realpath(filePath: string): Promise<string>;
|
|
29
30
|
getTempDir(): Promise<string>;
|
|
30
|
-
copyDirectory(sourcePath: string, destPath: string): Promise<void>;
|
|
31
|
+
copyDirectory(sourcePath: string, destPath: string, options?: CopyDirectoryOptions): Promise<void>;
|
|
31
32
|
private isEnoent;
|
|
32
33
|
private hasErrnoCode;
|
|
33
34
|
}
|
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.207.0-preview.305",
|
|
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": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
|
|
42
42
|
}
|