@gesslar/toolkit 3.9.0 → 3.12.3
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/package.json +3 -3
- package/src/browser/lib/Data.js +89 -5
- package/src/browser/lib/TypeSpec.js +3 -1
- package/src/lib/CappedDirectoryObject.js +71 -470
- package/src/lib/DirectoryObject.js +94 -146
- package/src/lib/FS.js +221 -70
- package/src/lib/FileObject.js +78 -81
- package/src/lib/TempDirectoryObject.js +92 -141
- package/src/lib/Valid.js +1 -1
- package/src/types/browser/lib/Data.d.ts +46 -2
- package/src/types/browser/lib/Data.d.ts.map +1 -1
- package/src/types/browser/lib/TypeSpec.d.ts.map +1 -1
- package/src/types/lib/CappedDirectoryObject.d.ts +30 -55
- package/src/types/lib/CappedDirectoryObject.d.ts.map +1 -1
- package/src/types/lib/DirectoryObject.d.ts +13 -54
- package/src/types/lib/DirectoryObject.d.ts.map +1 -1
- package/src/types/lib/FS.d.ts +115 -15
- package/src/types/lib/FS.d.ts.map +1 -1
- package/src/types/lib/FileObject.d.ts +6 -3
- package/src/types/lib/FileObject.d.ts.map +1 -1
- package/src/types/lib/TempDirectoryObject.d.ts +15 -62
- package/src/types/lib/TempDirectoryObject.d.ts.map +1 -1
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* - Pattern-based content filtering with glob support
|
|
9
9
|
* - Path traversal via walkUp generator
|
|
10
10
|
* - Intelligent path merging for subdirectories and files
|
|
11
|
-
* - Support for temporary directory management
|
|
12
11
|
*
|
|
13
12
|
* @property {string} supplied - The original directory path as supplied to constructor
|
|
14
13
|
* @property {string} path - The absolute resolved directory path
|
|
@@ -18,7 +17,6 @@
|
|
|
18
17
|
* @property {string} extension - The directory extension (typically empty string)
|
|
19
18
|
* @property {string} sep - Platform-specific path separator ('/' or '\\')
|
|
20
19
|
* @property {Array<string>} trail - Path segments split by separator
|
|
21
|
-
* @property {boolean} temporary - Whether this is marked as a temporary directory
|
|
22
20
|
* @property {boolean} isFile - Always false (this is a directory)
|
|
23
21
|
* @property {boolean} isDirectory - Always true
|
|
24
22
|
* @property {DirectoryObject|null} parent - The parent directory (null if root)
|
|
@@ -48,7 +46,6 @@
|
|
|
48
46
|
* const file = dir.getFile("package.json")
|
|
49
47
|
*/
|
|
50
48
|
export default class DirectoryObject extends FS {
|
|
51
|
-
[x: number]: () => object;
|
|
52
49
|
/**
|
|
53
50
|
* Creates a DirectoryObject from the current working directory.
|
|
54
51
|
* Useful when working with pnpx or other tools where the project root
|
|
@@ -63,16 +60,20 @@ export default class DirectoryObject extends FS {
|
|
|
63
60
|
/**
|
|
64
61
|
* Constructs a DirectoryObject instance.
|
|
65
62
|
*
|
|
66
|
-
* @param {string?
|
|
67
|
-
* @param {boolean} [temporary] - Whether this is a temporary directory.
|
|
63
|
+
* @param {string?} [directory="."] - The directory path or DirectoryObject (defaults to current directory)
|
|
68
64
|
*/
|
|
69
|
-
constructor(directory?: string
|
|
65
|
+
constructor(directory?: string | null);
|
|
70
66
|
/**
|
|
71
67
|
* Returns a JSON representation of the DirectoryObject.
|
|
72
68
|
*
|
|
73
69
|
* @returns {object} JSON representation of the DirectoryObject
|
|
74
70
|
*/
|
|
75
71
|
toJSON(): object;
|
|
72
|
+
/**
|
|
73
|
+
* Custom inspect method for Node.js console.
|
|
74
|
+
*
|
|
75
|
+
* @returns {object} JSON representation of this object.
|
|
76
|
+
*/
|
|
76
77
|
/**
|
|
77
78
|
* Checks if the directory exists (async).
|
|
78
79
|
*
|
|
@@ -130,12 +131,6 @@ export default class DirectoryObject extends FS {
|
|
|
130
131
|
* console.log(dir.trail) // ['', 'path', 'to', 'directory']
|
|
131
132
|
*/
|
|
132
133
|
get trail(): Array<string>;
|
|
133
|
-
/**
|
|
134
|
-
* Returns whether this directory is marked as temporary.
|
|
135
|
-
*
|
|
136
|
-
* @returns {boolean} True if this is a temporary directory, false otherwise
|
|
137
|
-
*/
|
|
138
|
-
get temporary(): boolean;
|
|
139
134
|
/**
|
|
140
135
|
* Returns the parent directory of this directory.
|
|
141
136
|
* Returns null if this directory is the root directory.
|
|
@@ -150,42 +145,6 @@ export default class DirectoryObject extends FS {
|
|
|
150
145
|
* console.log(root.parent) // null
|
|
151
146
|
*/
|
|
152
147
|
get parent(): DirectoryObject | null;
|
|
153
|
-
/**
|
|
154
|
-
* Returns the root directory of the filesystem.
|
|
155
|
-
*
|
|
156
|
-
* For DirectoryObject, this walks up to the filesystem root.
|
|
157
|
-
* For CappedDirectoryObject, this returns the cap root.
|
|
158
|
-
*
|
|
159
|
-
* @returns {DirectoryObject} The root directory
|
|
160
|
-
* @example
|
|
161
|
-
* const dir = new DirectoryObject("/usr/local/bin")
|
|
162
|
-
* console.log(dir.root.path) // "/"
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* const capped = new CappedDirectoryObject("/projects/myapp")
|
|
166
|
-
* const sub = capped.getDirectory("src/lib")
|
|
167
|
-
* console.log(sub.root.path) // "/" (virtual, cap root)
|
|
168
|
-
* console.log(sub.root.real.path) // "/projects/myapp"
|
|
169
|
-
*/
|
|
170
|
-
get root(): DirectoryObject;
|
|
171
|
-
/**
|
|
172
|
-
* Recursively removes a temporary directory and all its contents.
|
|
173
|
-
*
|
|
174
|
-
* This method will delete all files and subdirectories within this directory,
|
|
175
|
-
* then delete the directory itself. It only works on directories explicitly
|
|
176
|
-
* marked as temporary for safety.
|
|
177
|
-
*
|
|
178
|
-
* @async
|
|
179
|
-
* @returns {Promise<void>}
|
|
180
|
-
* @throws {Sass} If the directory is not marked as temporary
|
|
181
|
-
* @throws {Sass} If the directory deletion fails
|
|
182
|
-
* @example
|
|
183
|
-
* const tempDir = new TempDirectoryObject("my-temp")
|
|
184
|
-
* await tempDir.assureExists()
|
|
185
|
-
* // ... use the directory ...
|
|
186
|
-
* await tempDir.remove() // Recursively deletes everything
|
|
187
|
-
*/
|
|
188
|
-
remove(): Promise<void>;
|
|
189
148
|
/**
|
|
190
149
|
* Returns false. Because this is a directory.
|
|
191
150
|
*
|
|
@@ -236,7 +195,7 @@ export default class DirectoryObject extends FS {
|
|
|
236
195
|
* Generator that walks up the directory tree, yielding each parent directory.
|
|
237
196
|
* Starts from the current directory and yields each parent until reaching the root.
|
|
238
197
|
*
|
|
239
|
-
* @returns {
|
|
198
|
+
* @returns {DirectoryObject} Generator yielding parent DirectoryObject instances
|
|
240
199
|
* @example
|
|
241
200
|
* const dir = new DirectoryObject('/path/to/deep/directory')
|
|
242
201
|
* for(const parent of dir.walkUp) {
|
|
@@ -248,7 +207,7 @@ export default class DirectoryObject extends FS {
|
|
|
248
207
|
* // /
|
|
249
208
|
* }
|
|
250
209
|
*/
|
|
251
|
-
get walkUp():
|
|
210
|
+
get walkUp(): DirectoryObject;
|
|
252
211
|
/**
|
|
253
212
|
* Deletes an empty directory from the filesystem.
|
|
254
213
|
*
|
|
@@ -286,7 +245,7 @@ export default class DirectoryObject extends FS {
|
|
|
286
245
|
* duplication (e.g., "/projects/toolkit" + "toolkit/src" = "/projects/toolkit/src").
|
|
287
246
|
* The temporary flag is preserved from the parent directory.
|
|
288
247
|
*
|
|
289
|
-
* @param {string}
|
|
248
|
+
* @param {string} dir - The subdirectory path to append (can be nested like "src/lib")
|
|
290
249
|
* @returns {DirectoryObject} A new DirectoryObject instance with the combined path
|
|
291
250
|
* @throws {Sass} If newPath is not a string
|
|
292
251
|
* @example
|
|
@@ -300,7 +259,7 @@ export default class DirectoryObject extends FS {
|
|
|
300
259
|
* const subDir = dir.getDirectory("toolkit/src")
|
|
301
260
|
* console.log(subDir.path) // "/projects/toolkit/src" (not /projects/toolkit/toolkit/src)
|
|
302
261
|
*/
|
|
303
|
-
getDirectory(
|
|
262
|
+
getDirectory(dir: string): DirectoryObject;
|
|
304
263
|
/**
|
|
305
264
|
* Creates a new FileObject by extending this directory's path.
|
|
306
265
|
*
|
|
@@ -308,7 +267,7 @@ export default class DirectoryObject extends FS {
|
|
|
308
267
|
* duplication. The resulting FileObject can be used for reading, writing,
|
|
309
268
|
* and other file operations.
|
|
310
269
|
*
|
|
311
|
-
* @param {string}
|
|
270
|
+
* @param {string} file - The filename to append (can include subdirectories like "src/index.js")
|
|
312
271
|
* @returns {FileObject} A new FileObject instance with the combined path
|
|
313
272
|
* @throws {Sass} If filename is not a string
|
|
314
273
|
* @example
|
|
@@ -321,7 +280,7 @@ export default class DirectoryObject extends FS {
|
|
|
321
280
|
* const file = dir.getFile("src/index.js")
|
|
322
281
|
* const data = await file.read()
|
|
323
282
|
*/
|
|
324
|
-
getFile(
|
|
283
|
+
getFile(file: string): FileObject;
|
|
325
284
|
#private;
|
|
326
285
|
}
|
|
327
286
|
import FS from "./FS.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH;IAmEE;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA/CD;;;;OAIG;IACH,wBAFW,MAAM,OAAC,EA8BjB;IA+BD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IAED;;;;OAIG;IAKH;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,aALa,KAAK,CAAC,MAAM,CAAC,CAOzB;IAED;;;;;;;;;;;;OAYG;IACH,cARa,eAAe,GAAC,IAAI,CAsBhC;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAqBD;;;;;;;;;;;;;;;OAeG;IACH,WAZW,MAAM,GACJ,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;KAAC,CAAC,CAiDpF;IAED;;;;;;;;;;;;OAYG;IACH,uBARW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAyBD;;;;;;;;;;;;;;;OAeG;IACH,cAZa,eAAe,CAc3B;IAED;;;;;;;;;;;;;;OAcG;IACH,UARa,OAAO,CAAC,IAAI,CAAC,CAkBzB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAM5B;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAO5B;IAUD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAdW,MAAM,GACJ,eAAe,CAqB3B;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAbW,MAAM,GACJ,UAAU,CAoBtB;;CACF;eA9jBc,SAAS;uBACD,iBAAiB"}
|
package/src/types/lib/FS.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default class FS {
|
|
|
20
20
|
* @param {string} pathName - The path to convert
|
|
21
21
|
* @returns {string} The URI
|
|
22
22
|
*/
|
|
23
|
-
static
|
|
23
|
+
static pathToUrl(pathName: string): string;
|
|
24
24
|
/**
|
|
25
25
|
* Convert a URI to a path
|
|
26
26
|
*
|
|
@@ -28,22 +28,12 @@ export default class FS {
|
|
|
28
28
|
* @param {string} pathName - The URI to convert
|
|
29
29
|
* @returns {string} The path
|
|
30
30
|
*/
|
|
31
|
-
static
|
|
32
|
-
/**
|
|
33
|
-
* Retrieve all files matching a specific glob pattern.
|
|
34
|
-
*
|
|
35
|
-
* @static
|
|
36
|
-
* @param {string|Array<string>} glob - The glob pattern(s) to search.
|
|
37
|
-
* @returns {Promise<Array<FileObject>>} A promise that resolves to an array of file objects
|
|
38
|
-
* @throws {Sass} If the input is not a string or array of strings.
|
|
39
|
-
* @throws {Sass} If the glob pattern array is empty or for other search failures.
|
|
40
|
-
*/
|
|
41
|
-
static getFiles(glob: string | Array<string>): Promise<Array<FileObject>>;
|
|
31
|
+
static urlToPath(pathName: string): string;
|
|
42
32
|
/**
|
|
43
33
|
* Computes the relative path from one file or directory to another.
|
|
44
34
|
*
|
|
45
|
-
* If the target is outside the source (i.e., the relative path starts with
|
|
46
|
-
* returns the absolute path to the target instead.
|
|
35
|
+
* If the target is outside the source (i.e., the relative path starts with
|
|
36
|
+
* ".."), returns the absolute path to the target instead.
|
|
47
37
|
*
|
|
48
38
|
* @static
|
|
49
39
|
* @param {FileObject|DirectoryObject} from - The source file or directory object
|
|
@@ -52,7 +42,8 @@ export default class FS {
|
|
|
52
42
|
*/
|
|
53
43
|
static relativeOrAbsolutePath(from: FileObject | DirectoryObject, to: FileObject | DirectoryObject): string;
|
|
54
44
|
/**
|
|
55
|
-
* Merge two paths by finding overlapping segments and combining them
|
|
45
|
+
* Merge two paths by finding overlapping segments and combining them
|
|
46
|
+
* efficiently
|
|
56
47
|
*
|
|
57
48
|
* @static
|
|
58
49
|
* @param {string} path1 - The first path
|
|
@@ -71,6 +62,115 @@ export default class FS {
|
|
|
71
62
|
* @returns {string} The resolved path
|
|
72
63
|
*/
|
|
73
64
|
static resolvePath(fromPath: string, toPath: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a candidate path is contained within a container path.
|
|
67
|
+
*
|
|
68
|
+
* @static
|
|
69
|
+
* @param {string} container - The container path to check against
|
|
70
|
+
* @param {string} candidate - The candidate path that might be contained
|
|
71
|
+
* @returns {boolean} True if candidate is within container, false otherwise
|
|
72
|
+
* @throws {Sass} If container is not a non-empty string
|
|
73
|
+
* @throws {Sass} If candidate is not a non-empty string
|
|
74
|
+
* @example
|
|
75
|
+
* FS.pathContains("/home/user", "/home/user/docs") // true
|
|
76
|
+
* FS.pathContains("/home/user", "/home/other") // false
|
|
77
|
+
*/
|
|
78
|
+
static pathContains(container: string, candidate: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Convert an absolute path to a relative path by finding overlapping segments.
|
|
81
|
+
* Returns the relative portion of the 'to' path after the last occurrence
|
|
82
|
+
* of the final segment from the 'from' path.
|
|
83
|
+
*
|
|
84
|
+
* @static
|
|
85
|
+
* @param {string} from - The base path to calculate relative from
|
|
86
|
+
* @param {string} to - The target path to make relative
|
|
87
|
+
* @param {string} [sep=path.sep] - The path separator to use (defaults to system separator)
|
|
88
|
+
* @returns {string|null} The relative path, empty string if paths are identical, or null if no overlap found
|
|
89
|
+
* @example
|
|
90
|
+
* FS.toRelativePath("/projects/toolkit", "/projects/toolkit/src") // "src"
|
|
91
|
+
* FS.toRelativePath("/home/user", "/home/user") // ""
|
|
92
|
+
* FS.toRelativePath("/projects/app", "/other/path") // null
|
|
93
|
+
*/
|
|
94
|
+
static toRelativePath(from: string, to: string, sep?: string): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Find the common root path between two paths by identifying overlapping segments.
|
|
97
|
+
* Returns the portion of 'from' that matches up to the overlap point in 'to'.
|
|
98
|
+
*
|
|
99
|
+
* @static
|
|
100
|
+
* @param {string} from - The first path to compare
|
|
101
|
+
* @param {string} to - The second path to find common root with
|
|
102
|
+
* @param {string} [sep=path.sep] - The path separator to use (defaults to system separator)
|
|
103
|
+
* @returns {string|null} The common root path, the original path if identical, or null if no overlap found
|
|
104
|
+
* @throws {Sass} If from is not a non-empty string
|
|
105
|
+
* @throws {Sass} If to is not a non-empty string
|
|
106
|
+
* @example
|
|
107
|
+
* FS.getCommonRootPath("/projects/toolkit/src", "/projects/toolkit/tests") // "/projects/toolkit"
|
|
108
|
+
* FS.getCommonRootPath("/home/user", "/home/user") // "/home/user"
|
|
109
|
+
* FS.getCommonRootPath("/projects/app", "/other/path") // null
|
|
110
|
+
*/
|
|
111
|
+
static getCommonRootPath(from: string, to: string, sep?: string): string | null;
|
|
112
|
+
/**
|
|
113
|
+
* @typedef {object} PathParts
|
|
114
|
+
* @property {string} base - The file name with extension
|
|
115
|
+
* @property {string} dir - The directory path
|
|
116
|
+
* @property {string} ext - The file extension (including dot)
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Deconstruct a file or directory name into parts.
|
|
120
|
+
*
|
|
121
|
+
* @static
|
|
122
|
+
* @param {string} pathName - The file/directory name to deconstruct
|
|
123
|
+
* @returns {PathParts} The filename parts
|
|
124
|
+
* @throws {Sass} If not a string of more than 1 character
|
|
125
|
+
*/
|
|
126
|
+
static pathParts(pathName: string): {
|
|
127
|
+
/**
|
|
128
|
+
* - The file name with extension
|
|
129
|
+
*/
|
|
130
|
+
base: string;
|
|
131
|
+
/**
|
|
132
|
+
* - The directory path
|
|
133
|
+
*/
|
|
134
|
+
dir: string;
|
|
135
|
+
/**
|
|
136
|
+
* - The file extension (including dot)
|
|
137
|
+
*/
|
|
138
|
+
ext: string;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Convert a virtual capped path to its real filesystem path.
|
|
142
|
+
* For capped objects, resolves the virtual path relative to the cap's real path.
|
|
143
|
+
* For uncapped objects, returns the path unchanged.
|
|
144
|
+
*
|
|
145
|
+
* @static
|
|
146
|
+
* @param {FileObject|DirectoryObject} fileOrDirectoryObject - The file or directory object to convert
|
|
147
|
+
* @returns {string} The real filesystem path
|
|
148
|
+
* @throws {Sass} If parameter is not a FileObject or DirectoryObject
|
|
149
|
+
* @example
|
|
150
|
+
* const temp = new TempDirectoryObject("myapp")
|
|
151
|
+
* const file = temp.getFile("/config.json")
|
|
152
|
+
* FS.virtualToRealPath(file) // "/tmp/myapp-ABC123/config.json"
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* const regular = new FileObject("/home/user/file.txt")
|
|
156
|
+
* FS.virtualToRealPath(regular) // "/home/user/file.txt"
|
|
157
|
+
*/
|
|
158
|
+
static virtualToRealPath(fileOrDirectoryObject: FileObject | DirectoryObject): string;
|
|
159
|
+
/**
|
|
160
|
+
* Convert an absolute path to a relative format by removing the root component.
|
|
161
|
+
* By default, keeps a leading separator (making it "absolute-like relative").
|
|
162
|
+
* Use forceActuallyRelative to get a truly relative path without leading separator.
|
|
163
|
+
*
|
|
164
|
+
* @static
|
|
165
|
+
* @param {string} pathToCheck - The path to convert (returned unchanged if already relative)
|
|
166
|
+
* @param {boolean} [forceActuallyRelative=false] - If true, removes leading separator for truly relative path
|
|
167
|
+
* @returns {string} The relative path (with or without leading separator based on forceActuallyRelative)
|
|
168
|
+
* @example
|
|
169
|
+
* FS.absoluteToRelative("/home/user/docs") // "/home/user/docs" (with leading /)
|
|
170
|
+
* FS.absoluteToRelative("/home/user/docs", true) // "home/user/docs" (truly relative)
|
|
171
|
+
* FS.absoluteToRelative("relative/path") // "relative/path" (unchanged)
|
|
172
|
+
*/
|
|
173
|
+
static absoluteToRelative(pathToCheck: string, forceActuallyRelative?: boolean): string;
|
|
74
174
|
/**
|
|
75
175
|
* Compute the relative path from another file or directory to this instance.
|
|
76
176
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../lib/FS.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../lib/FS.js"],"names":[],"mappings":"AA0BA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAsBtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;;;OAUG;IACH,oCAJW,UAAU,GAAC,eAAe,MAC1B,UAAU,GAAC,eAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;;OASG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA0BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;;;;;;;OAYG;IACH,+BATW,MAAM,aACN,MAAM,GACJ,OAAO,CAcnB;IAED;;;;;;;;;;;;;;OAcG;IACH,4BATW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CAwBvB;IAED;;;;;;;;;;;;;;;OAeG;IACH,+BAXW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CA+BvB;IAED;;;;;OAKG;IAEH;;;;;;;OAOG;IACH,2BAJW,MAAM;;;;cATH,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;MAenB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,gDAZW,UAAU,GAAC,eAAe,GACxB,MAAM,CAiClB;IAED;;;;;;;;;;;;;OAaG;IACH,uCARW,MAAM,0BACN,OAAO,GACL,MAAM,CAkBlB;IA/VD;;;;;;;;;OASG;IACH,kCAJW,UAAU,GAAC,eAAe,GACxB,MAAM,CAWlB;CA8UF;yBAjXa,OAAO,iBAAiB,EAAE,OAAO;8BACjC,OAAO,sBAAsB,EAAE,OAAO"}
|
|
@@ -27,10 +27,10 @@ export default class FileObject extends FS {
|
|
|
27
27
|
/**
|
|
28
28
|
* Constructs a FileObject instance.
|
|
29
29
|
*
|
|
30
|
-
* @param {string
|
|
30
|
+
* @param {string} fileName - The file path
|
|
31
31
|
* @param {DirectoryObject|string|null} [parent] - The parent directory (object or string)
|
|
32
32
|
*/
|
|
33
|
-
constructor(fileName: string
|
|
33
|
+
constructor(fileName: string, parent?: DirectoryObject | string | null);
|
|
34
34
|
/**
|
|
35
35
|
* Returns a JSON representation of the FileObject.
|
|
36
36
|
*
|
|
@@ -51,7 +51,9 @@ export default class FileObject extends FS {
|
|
|
51
51
|
get supplied(): string;
|
|
52
52
|
/**
|
|
53
53
|
* Returns the file path. If the parent is a capped directory, returns the
|
|
54
|
-
* virtual path relative to the cap. Otherwise returns the real filesystem
|
|
54
|
+
* virtual path relative to the cap. Otherwise returns the real filesystem
|
|
55
|
+
* path.
|
|
56
|
+
*
|
|
55
57
|
* Use `.real.path` to always get the actual filesystem path.
|
|
56
58
|
*
|
|
57
59
|
* @returns {string} The file path (virtual if parent is capped, real otherwise)
|
|
@@ -110,6 +112,7 @@ export default class FileObject extends FS {
|
|
|
110
112
|
* @returns {DirectoryObject} The parent directory object
|
|
111
113
|
*/
|
|
112
114
|
get parent(): DirectoryObject;
|
|
115
|
+
get parentPath(): any;
|
|
113
116
|
/**
|
|
114
117
|
* Returns a plain FileObject representing the actual filesystem location.
|
|
115
118
|
* This provides an "escape hatch" when working with capped directories,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;uBAgIe,MAAM;IA/HnB;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA4BF;;;;;OAKG;IACH,sBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EAkDrC;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAelB;IAWD;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;;;;;OAQG;IACH,YAFa,MAAM,CAmBlB;IAED;;;;;OAKG;IACH,WAFa,GAAG,CAQf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IACD;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAFa,eAAe,CAI3B;IAED,sBAEC;IAED;;;;;;;;;;;;;;;OAeG;IACH,YAXa,UAAU,CAatB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAED;;;;OAIG;IACH,YAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC,MAAM,OAAC,CAAC,CAU5B;IAED;;;;;OAKG;IACH,YAFa,OAAO,CAAC,IAAI,OAAC,CAAC,CAU1B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAY3B;IAED;;;;;;;;;;;OAWG;IACH,cARa,OAAO,CAAC,MAAM,CAAC,CAkB3B;IAED;;;;;;;;;;;OAWG;IACH,eARW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CA+BzB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAyBzB;IAED;;;;;;;;;;;;;;OAcG;IACH,gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAkC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAY3B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAiBzB;;CACF;eA3jBc,SAAS;4BADI,sBAAsB"}
|
|
@@ -16,73 +16,26 @@ export default class TempDirectoryObject extends CappedDirectoryObject {
|
|
|
16
16
|
* @throws {Sass} Always throws an error
|
|
17
17
|
*/
|
|
18
18
|
static fromCwd(): void;
|
|
19
|
+
get isTemporary(): boolean;
|
|
20
|
+
get cap(): any;
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* Recursively removes a temporary directory and all its contents.
|
|
21
23
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* This method will delete all files and subdirectories within this directory,
|
|
25
|
+
* then delete the directory itself. It only works on directories explicitly
|
|
26
|
+
* marked as temporary for safety.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* If
|
|
28
|
-
*
|
|
29
|
-
* @param {string?} [name] - Base name for the temp directory (if empty/null, uses OS temp dir)
|
|
30
|
-
* @param {TempDirectoryObject?} [parent] - Optional parent temporary directory
|
|
31
|
-
* @throws {Sass} If name is absolute
|
|
32
|
-
* @throws {Sass} If name is empty (when parent is provided)
|
|
33
|
-
* @throws {Sass} If name contains path separators
|
|
34
|
-
* @throws {Sass} If parent is provided but not a temporary directory
|
|
35
|
-
* @throws {Sass} If parent's lineage does not trace back to the OS temp directory
|
|
36
|
-
* @throws {Sass} If directory creation fails
|
|
37
|
-
* @example
|
|
38
|
-
* // Use OS temp directory directly
|
|
39
|
-
* const temp = new TempDirectoryObject()
|
|
40
|
-
* console.log(temp.path) // "/tmp"
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* // Create with unique name
|
|
44
|
-
* const temp = new TempDirectoryObject("myapp")
|
|
45
|
-
* console.log(temp.path) // "/tmp/myapp-ABC123"
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* // Nested temp directories
|
|
49
|
-
* const parent = new TempDirectoryObject("parent")
|
|
50
|
-
* const child = new TempDirectoryObject("child", parent)
|
|
51
|
-
* await parent.remove() // Removes both parent and child
|
|
52
|
-
*/
|
|
53
|
-
constructor(name?: string | null, parent?: TempDirectoryObject | null);
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new TempDirectoryObject by extending this directory's path.
|
|
56
|
-
*
|
|
57
|
-
* Validates that the resulting path remains within the temp directory tree.
|
|
58
|
-
*
|
|
59
|
-
* @param {string} newPath - The path segment to append
|
|
60
|
-
* @returns {TempDirectoryObject} A new TempDirectoryObject with the extended path
|
|
61
|
-
* @throws {Sass} If the path would escape the temp directory
|
|
62
|
-
* @throws {Sass} If the path is absolute
|
|
63
|
-
* @throws {Sass} If the path contains traversal (..)
|
|
64
|
-
* @example
|
|
65
|
-
* const temp = new TempDirectoryObject("myapp")
|
|
66
|
-
* const subDir = temp.getDirectory("data")
|
|
67
|
-
* console.log(subDir.path) // "/tmp/myapp-ABC123/data"
|
|
68
|
-
*/
|
|
69
|
-
getDirectory(newPath: string): TempDirectoryObject;
|
|
70
|
-
/**
|
|
71
|
-
* Creates a new FileObject by extending this directory's path.
|
|
72
|
-
*
|
|
73
|
-
* Validates that the resulting path remains within the temp directory tree.
|
|
74
|
-
*
|
|
75
|
-
* @param {string} filename - The filename to append
|
|
76
|
-
* @returns {FileObject} A new FileObject with the extended path
|
|
77
|
-
* @throws {Sass} If the path would escape the temp directory
|
|
78
|
-
* @throws {Sass} If the path is absolute
|
|
79
|
-
* @throws {Sass} If the path contains traversal (..)
|
|
28
|
+
* @async
|
|
29
|
+
* @returns {Promise<void>}
|
|
30
|
+
* @throws {Sass} If the directory is not marked as temporary
|
|
31
|
+
* @throws {Sass} If the directory deletion fails
|
|
80
32
|
* @example
|
|
81
|
-
* const
|
|
82
|
-
*
|
|
83
|
-
*
|
|
33
|
+
* const tempDir = new TempDirectoryObject("my-temp")
|
|
34
|
+
* await tempDir.assureExists()
|
|
35
|
+
* // ... use the directory ...
|
|
36
|
+
* await tempDir.remove() // Recursively deletes everything
|
|
84
37
|
*/
|
|
85
|
-
|
|
38
|
+
remove(): Promise<void>;
|
|
86
39
|
#private;
|
|
87
40
|
}
|
|
88
41
|
import CappedDirectoryObject from "./CappedDirectoryObject.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TempDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/TempDirectoryObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TempDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/TempDirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;;;;;;GASG;AACH;IAgIE;;;;;OAKG;IACH,uBAEC;IA1ED,2BAEC;IAwBD,eAEC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,UATa,OAAO,CAAC,IAAI,CAAC,CAWzB;;CA0BF;kCAzJiC,4BAA4B"}
|