@gesslar/toolkit 3.8.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 +87 -467
- package/src/lib/DirectoryObject.js +109 -147
- package/src/lib/FS.js +221 -70
- package/src/lib/FileObject.js +78 -81
- package/src/lib/TempDirectoryObject.js +93 -129
- 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 +48 -56
- package/src/types/lib/CappedDirectoryObject.d.ts.map +1 -1
- package/src/types/lib/DirectoryObject.d.ts +24 -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 +19 -59
- 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,20 +46,34 @@
|
|
|
48
46
|
* const file = dir.getFile("package.json")
|
|
49
47
|
*/
|
|
50
48
|
export default class DirectoryObject extends FS {
|
|
51
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Creates a DirectoryObject from the current working directory.
|
|
51
|
+
* Useful when working with pnpx or other tools where the project root
|
|
52
|
+
* needs to be determined at runtime.
|
|
53
|
+
*
|
|
54
|
+
* @returns {DirectoryObject} A DirectoryObject representing the current working directory
|
|
55
|
+
* @example
|
|
56
|
+
* const projectRoot = DirectoryObject.fromCwd()
|
|
57
|
+
* console.log(projectRoot.path) // process.cwd()
|
|
58
|
+
*/
|
|
59
|
+
static fromCwd(): DirectoryObject;
|
|
52
60
|
/**
|
|
53
61
|
* Constructs a DirectoryObject instance.
|
|
54
62
|
*
|
|
55
|
-
* @param {string?
|
|
56
|
-
* @param {boolean} [temporary] - Whether this is a temporary directory.
|
|
63
|
+
* @param {string?} [directory="."] - The directory path or DirectoryObject (defaults to current directory)
|
|
57
64
|
*/
|
|
58
|
-
constructor(directory?:
|
|
65
|
+
constructor(directory?: string | null);
|
|
59
66
|
/**
|
|
60
67
|
* Returns a JSON representation of the DirectoryObject.
|
|
61
68
|
*
|
|
62
69
|
* @returns {object} JSON representation of the DirectoryObject
|
|
63
70
|
*/
|
|
64
71
|
toJSON(): object;
|
|
72
|
+
/**
|
|
73
|
+
* Custom inspect method for Node.js console.
|
|
74
|
+
*
|
|
75
|
+
* @returns {object} JSON representation of this object.
|
|
76
|
+
*/
|
|
65
77
|
/**
|
|
66
78
|
* Checks if the directory exists (async).
|
|
67
79
|
*
|
|
@@ -119,12 +131,6 @@ export default class DirectoryObject extends FS {
|
|
|
119
131
|
* console.log(dir.trail) // ['', 'path', 'to', 'directory']
|
|
120
132
|
*/
|
|
121
133
|
get trail(): Array<string>;
|
|
122
|
-
/**
|
|
123
|
-
* Returns whether this directory is marked as temporary.
|
|
124
|
-
*
|
|
125
|
-
* @returns {boolean} True if this is a temporary directory, false otherwise
|
|
126
|
-
*/
|
|
127
|
-
get temporary(): boolean;
|
|
128
134
|
/**
|
|
129
135
|
* Returns the parent directory of this directory.
|
|
130
136
|
* Returns null if this directory is the root directory.
|
|
@@ -139,42 +145,6 @@ export default class DirectoryObject extends FS {
|
|
|
139
145
|
* console.log(root.parent) // null
|
|
140
146
|
*/
|
|
141
147
|
get parent(): DirectoryObject | null;
|
|
142
|
-
/**
|
|
143
|
-
* Returns the root directory of the filesystem.
|
|
144
|
-
*
|
|
145
|
-
* For DirectoryObject, this walks up to the filesystem root.
|
|
146
|
-
* For CappedDirectoryObject, this returns the cap root.
|
|
147
|
-
*
|
|
148
|
-
* @returns {DirectoryObject} The root directory
|
|
149
|
-
* @example
|
|
150
|
-
* const dir = new DirectoryObject("/usr/local/bin")
|
|
151
|
-
* console.log(dir.root.path) // "/"
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* const capped = new CappedDirectoryObject("/projects/myapp")
|
|
155
|
-
* const sub = capped.getDirectory("src/lib")
|
|
156
|
-
* console.log(sub.root.path) // "/" (virtual, cap root)
|
|
157
|
-
* console.log(sub.root.real.path) // "/projects/myapp"
|
|
158
|
-
*/
|
|
159
|
-
get root(): DirectoryObject;
|
|
160
|
-
/**
|
|
161
|
-
* Recursively removes a temporary directory and all its contents.
|
|
162
|
-
*
|
|
163
|
-
* This method will delete all files and subdirectories within this directory,
|
|
164
|
-
* then delete the directory itself. It only works on directories explicitly
|
|
165
|
-
* marked as temporary for safety.
|
|
166
|
-
*
|
|
167
|
-
* @async
|
|
168
|
-
* @returns {Promise<void>}
|
|
169
|
-
* @throws {Sass} If the directory is not marked as temporary
|
|
170
|
-
* @throws {Sass} If the directory deletion fails
|
|
171
|
-
* @example
|
|
172
|
-
* const tempDir = new TempDirectoryObject("my-temp")
|
|
173
|
-
* await tempDir.assureExists()
|
|
174
|
-
* // ... use the directory ...
|
|
175
|
-
* await tempDir.remove() // Recursively deletes everything
|
|
176
|
-
*/
|
|
177
|
-
remove(): Promise<void>;
|
|
178
148
|
/**
|
|
179
149
|
* Returns false. Because this is a directory.
|
|
180
150
|
*
|
|
@@ -225,7 +195,7 @@ export default class DirectoryObject extends FS {
|
|
|
225
195
|
* Generator that walks up the directory tree, yielding each parent directory.
|
|
226
196
|
* Starts from the current directory and yields each parent until reaching the root.
|
|
227
197
|
*
|
|
228
|
-
* @returns {
|
|
198
|
+
* @returns {DirectoryObject} Generator yielding parent DirectoryObject instances
|
|
229
199
|
* @example
|
|
230
200
|
* const dir = new DirectoryObject('/path/to/deep/directory')
|
|
231
201
|
* for(const parent of dir.walkUp) {
|
|
@@ -237,7 +207,7 @@ export default class DirectoryObject extends FS {
|
|
|
237
207
|
* // /
|
|
238
208
|
* }
|
|
239
209
|
*/
|
|
240
|
-
get walkUp():
|
|
210
|
+
get walkUp(): DirectoryObject;
|
|
241
211
|
/**
|
|
242
212
|
* Deletes an empty directory from the filesystem.
|
|
243
213
|
*
|
|
@@ -275,7 +245,7 @@ export default class DirectoryObject extends FS {
|
|
|
275
245
|
* duplication (e.g., "/projects/toolkit" + "toolkit/src" = "/projects/toolkit/src").
|
|
276
246
|
* The temporary flag is preserved from the parent directory.
|
|
277
247
|
*
|
|
278
|
-
* @param {string}
|
|
248
|
+
* @param {string} dir - The subdirectory path to append (can be nested like "src/lib")
|
|
279
249
|
* @returns {DirectoryObject} A new DirectoryObject instance with the combined path
|
|
280
250
|
* @throws {Sass} If newPath is not a string
|
|
281
251
|
* @example
|
|
@@ -289,7 +259,7 @@ export default class DirectoryObject extends FS {
|
|
|
289
259
|
* const subDir = dir.getDirectory("toolkit/src")
|
|
290
260
|
* console.log(subDir.path) // "/projects/toolkit/src" (not /projects/toolkit/toolkit/src)
|
|
291
261
|
*/
|
|
292
|
-
getDirectory(
|
|
262
|
+
getDirectory(dir: string): DirectoryObject;
|
|
293
263
|
/**
|
|
294
264
|
* Creates a new FileObject by extending this directory's path.
|
|
295
265
|
*
|
|
@@ -297,7 +267,7 @@ export default class DirectoryObject extends FS {
|
|
|
297
267
|
* duplication. The resulting FileObject can be used for reading, writing,
|
|
298
268
|
* and other file operations.
|
|
299
269
|
*
|
|
300
|
-
* @param {string}
|
|
270
|
+
* @param {string} file - The filename to append (can include subdirectories like "src/index.js")
|
|
301
271
|
* @returns {FileObject} A new FileObject instance with the combined path
|
|
302
272
|
* @throws {Sass} If filename is not a string
|
|
303
273
|
* @example
|
|
@@ -310,7 +280,7 @@ export default class DirectoryObject extends FS {
|
|
|
310
280
|
* const file = dir.getFile("src/index.js")
|
|
311
281
|
* const data = await file.read()
|
|
312
282
|
*/
|
|
313
|
-
getFile(
|
|
283
|
+
getFile(file: string): FileObject;
|
|
314
284
|
#private;
|
|
315
285
|
}
|
|
316
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"}
|
|
@@ -10,72 +10,32 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export default class TempDirectoryObject extends CappedDirectoryObject {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* TempDirectoryObject does not support fromCwd() since it is specifically
|
|
14
|
+
* designed to work within the OS temporary directory tree.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
* exist immediately after the constructor returns.
|
|
17
|
-
*
|
|
18
|
-
* If no name is provided, uses the OS temp directory directly. If a name
|
|
19
|
-
* is provided without a parent, creates a new directory with a unique suffix.
|
|
20
|
-
* If a parent is provided, creates a subdirectory within that parent.
|
|
21
|
-
*
|
|
22
|
-
* @param {string?} [name] - Base name for the temp directory (if empty/null, uses OS temp dir)
|
|
23
|
-
* @param {TempDirectoryObject?} [parent] - Optional parent temporary directory
|
|
24
|
-
* @throws {Sass} If name is absolute
|
|
25
|
-
* @throws {Sass} If name is empty (when parent is provided)
|
|
26
|
-
* @throws {Sass} If name contains path separators
|
|
27
|
-
* @throws {Sass} If parent is provided but not a temporary directory
|
|
28
|
-
* @throws {Sass} If parent's lineage does not trace back to the OS temp directory
|
|
29
|
-
* @throws {Sass} If directory creation fails
|
|
30
|
-
* @example
|
|
31
|
-
* // Use OS temp directory directly
|
|
32
|
-
* const temp = new TempDirectoryObject()
|
|
33
|
-
* console.log(temp.path) // "/tmp"
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // Create with unique name
|
|
37
|
-
* const temp = new TempDirectoryObject("myapp")
|
|
38
|
-
* console.log(temp.path) // "/tmp/myapp-ABC123"
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* // Nested temp directories
|
|
42
|
-
* const parent = new TempDirectoryObject("parent")
|
|
43
|
-
* const child = new TempDirectoryObject("child", parent)
|
|
44
|
-
* await parent.remove() // Removes both parent and child
|
|
45
|
-
*/
|
|
46
|
-
constructor(name?: string | null, parent?: TempDirectoryObject | null);
|
|
47
|
-
/**
|
|
48
|
-
* Creates a new TempDirectoryObject by extending this directory's path.
|
|
49
|
-
*
|
|
50
|
-
* Validates that the resulting path remains within the temp directory tree.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} newPath - The path segment to append
|
|
53
|
-
* @returns {TempDirectoryObject} A new TempDirectoryObject with the extended path
|
|
54
|
-
* @throws {Sass} If the path would escape the temp directory
|
|
55
|
-
* @throws {Sass} If the path is absolute
|
|
56
|
-
* @throws {Sass} If the path contains traversal (..)
|
|
57
|
-
* @example
|
|
58
|
-
* const temp = new TempDirectoryObject("myapp")
|
|
59
|
-
* const subDir = temp.getDirectory("data")
|
|
60
|
-
* console.log(subDir.path) // "/tmp/myapp-ABC123/data"
|
|
16
|
+
* @throws {Sass} Always throws an error
|
|
61
17
|
*/
|
|
62
|
-
|
|
18
|
+
static fromCwd(): void;
|
|
19
|
+
get isTemporary(): boolean;
|
|
20
|
+
get cap(): any;
|
|
63
21
|
/**
|
|
64
|
-
*
|
|
22
|
+
* Recursively removes a temporary directory and all its contents.
|
|
65
23
|
*
|
|
66
|
-
*
|
|
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.
|
|
67
27
|
*
|
|
68
|
-
* @
|
|
69
|
-
* @returns {
|
|
70
|
-
* @throws {Sass} If the
|
|
71
|
-
* @throws {Sass} If the
|
|
72
|
-
* @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
|
|
73
32
|
* @example
|
|
74
|
-
* const
|
|
75
|
-
*
|
|
76
|
-
*
|
|
33
|
+
* const tempDir = new TempDirectoryObject("my-temp")
|
|
34
|
+
* await tempDir.assureExists()
|
|
35
|
+
* // ... use the directory ...
|
|
36
|
+
* await tempDir.remove() // Recursively deletes everything
|
|
77
37
|
*/
|
|
78
|
-
|
|
38
|
+
remove(): Promise<void>;
|
|
79
39
|
#private;
|
|
80
40
|
}
|
|
81
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"}
|