touch-all 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -18
- package/dist/lib/index.js +826 -46
- package/dist/lib/src/_commonTypes.d.ts +12 -0
- package/dist/lib/{cli.d.ts → src/cli.d.ts} +1 -1
- package/dist/lib/src/fsGenerator.d.ts +4 -0
- package/dist/lib/{fsNormalizator.d.ts → src/fsNormalizator.d.ts} +2 -1
- package/dist/slim/touch-all.js +913 -91
- package/package.json +11 -10
- package/dist/lib/_commonTypes.d.ts +0 -5
- package/dist/lib/fsGenerator.d.ts +0 -4
- /package/dist/lib/{_commonErrors.d.ts → src/_commonErrors.d.ts} +0 -0
- /package/dist/lib/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/lib/{parser.d.ts → src/parser.d.ts} +0 -0
- /package/dist/lib/{touch-all.d.ts → src/touch-all.d.ts} +0 -0
package/dist/lib/index.js
CHANGED
|
@@ -1,11 +1,777 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
// node_modules/@effect/platform/dist/esm/FileSystem.js
|
|
16
|
+
var exports_FileSystem = {};
|
|
17
|
+
__export(exports_FileSystem, {
|
|
18
|
+
makeNoop: () => makeNoop2,
|
|
19
|
+
make: () => make2,
|
|
20
|
+
layerNoop: () => layerNoop2,
|
|
21
|
+
isFile: () => isFile,
|
|
22
|
+
WatchEventUpdate: () => WatchEventUpdate,
|
|
23
|
+
WatchEventRemove: () => WatchEventRemove,
|
|
24
|
+
WatchEventCreate: () => WatchEventCreate,
|
|
25
|
+
WatchBackend: () => WatchBackend,
|
|
26
|
+
TiB: () => TiB2,
|
|
27
|
+
Size: () => Size2,
|
|
28
|
+
PiB: () => PiB2,
|
|
29
|
+
MiB: () => MiB2,
|
|
30
|
+
KiB: () => KiB2,
|
|
31
|
+
GiB: () => GiB2,
|
|
32
|
+
FileTypeId: () => FileTypeId,
|
|
33
|
+
FileSystem: () => FileSystem,
|
|
34
|
+
FileDescriptor: () => FileDescriptor
|
|
35
|
+
});
|
|
36
|
+
import * as Brand from "effect/Brand";
|
|
37
|
+
import * as Context from "effect/Context";
|
|
38
|
+
import * as Data2 from "effect/Data";
|
|
39
|
+
|
|
40
|
+
// node_modules/@effect/platform/dist/esm/internal/fileSystem.js
|
|
41
|
+
import * as Channel from "effect/Channel";
|
|
42
|
+
import * as Chunk from "effect/Chunk";
|
|
43
|
+
import { GenericTag } from "effect/Context";
|
|
44
|
+
import * as Effect from "effect/Effect";
|
|
45
|
+
import { identity, pipe } from "effect/Function";
|
|
46
|
+
import * as Layer from "effect/Layer";
|
|
47
|
+
import * as Option from "effect/Option";
|
|
48
|
+
import * as Sink from "effect/Sink";
|
|
49
|
+
import * as Stream from "effect/Stream";
|
|
50
|
+
|
|
51
|
+
// node_modules/@effect/platform/dist/esm/Error.js
|
|
52
|
+
import * as Data from "effect/Data";
|
|
53
|
+
import * as Predicate from "effect/Predicate";
|
|
54
|
+
import * as Schema from "effect/Schema";
|
|
55
|
+
var TypeId = /* @__PURE__ */ Symbol.for("@effect/platform/Error");
|
|
56
|
+
var Module = /* @__PURE__ */ Schema.Literal("Clipboard", "Command", "FileSystem", "KeyValueStore", "Path", "Stream", "Terminal");
|
|
57
|
+
|
|
58
|
+
class BadArgument extends (/* @__PURE__ */ Schema.TaggedError("@effect/platform/Error/BadArgument")("BadArgument", {
|
|
59
|
+
module: Module,
|
|
60
|
+
method: Schema.String,
|
|
61
|
+
description: /* @__PURE__ */ Schema.optional(Schema.String),
|
|
62
|
+
cause: /* @__PURE__ */ Schema.optional(Schema.Defect)
|
|
63
|
+
})) {
|
|
64
|
+
[TypeId] = TypeId;
|
|
65
|
+
get message() {
|
|
66
|
+
return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
var SystemErrorReason = /* @__PURE__ */ Schema.Literal("AlreadyExists", "BadResource", "Busy", "InvalidData", "NotFound", "PermissionDenied", "TimedOut", "UnexpectedEof", "Unknown", "WouldBlock", "WriteZero");
|
|
70
|
+
|
|
71
|
+
class SystemError extends (/* @__PURE__ */ Schema.TaggedError("@effect/platform/Error/SystemError")("SystemError", {
|
|
72
|
+
reason: SystemErrorReason,
|
|
73
|
+
module: Module,
|
|
74
|
+
method: Schema.String,
|
|
75
|
+
description: /* @__PURE__ */ Schema.optional(Schema.String),
|
|
76
|
+
syscall: /* @__PURE__ */ Schema.optional(Schema.String),
|
|
77
|
+
pathOrDescriptor: /* @__PURE__ */ Schema.optional(/* @__PURE__ */ Schema.Union(Schema.String, Schema.Number)),
|
|
78
|
+
cause: /* @__PURE__ */ Schema.optional(Schema.Defect)
|
|
79
|
+
})) {
|
|
80
|
+
[TypeId] = TypeId;
|
|
81
|
+
get message() {
|
|
82
|
+
return `${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// node_modules/@effect/platform/dist/esm/internal/fileSystem.js
|
|
87
|
+
var tag = /* @__PURE__ */ GenericTag("@effect/platform/FileSystem");
|
|
88
|
+
var Size = (bytes) => typeof bytes === "bigint" ? bytes : BigInt(bytes);
|
|
89
|
+
var KiB = (n) => Size(n * 1024);
|
|
90
|
+
var MiB = (n) => Size(n * 1024 * 1024);
|
|
91
|
+
var GiB = (n) => Size(n * 1024 * 1024 * 1024);
|
|
92
|
+
var TiB = (n) => Size(n * 1024 * 1024 * 1024 * 1024);
|
|
93
|
+
var bigint1024 = /* @__PURE__ */ BigInt(1024);
|
|
94
|
+
var bigintPiB = bigint1024 * bigint1024 * bigint1024 * bigint1024 * bigint1024;
|
|
95
|
+
var PiB = (n) => Size(BigInt(n) * bigintPiB);
|
|
96
|
+
var make = (impl) => {
|
|
97
|
+
return tag.of({
|
|
98
|
+
...impl,
|
|
99
|
+
exists: (path) => pipe(impl.access(path), Effect.as(true), Effect.catchTag("SystemError", (e) => e.reason === "NotFound" ? Effect.succeed(false) : Effect.fail(e))),
|
|
100
|
+
readFileString: (path, encoding) => Effect.tryMap(impl.readFile(path), {
|
|
101
|
+
try: (_) => new TextDecoder(encoding).decode(_),
|
|
102
|
+
catch: (cause) => new BadArgument({
|
|
103
|
+
module: "FileSystem",
|
|
104
|
+
method: "readFileString",
|
|
105
|
+
description: "invalid encoding",
|
|
106
|
+
cause
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
stream: (path, options) => pipe(impl.open(path, {
|
|
110
|
+
flag: "r"
|
|
111
|
+
}), options?.offset ? Effect.tap((file) => file.seek(options.offset, "start")) : identity, Effect.map((file) => stream(file, options)), Stream.unwrapScoped),
|
|
112
|
+
sink: (path, options) => pipe(impl.open(path, {
|
|
113
|
+
flag: "w",
|
|
114
|
+
...options
|
|
115
|
+
}), Effect.map((file) => Sink.forEach((_) => file.writeAll(_))), Sink.unwrapScoped),
|
|
116
|
+
writeFileString: (path, data, options) => Effect.flatMap(Effect.try({
|
|
117
|
+
try: () => new TextEncoder().encode(data),
|
|
118
|
+
catch: (cause) => new BadArgument({
|
|
119
|
+
module: "FileSystem",
|
|
120
|
+
method: "writeFileString",
|
|
121
|
+
description: "could not encode string",
|
|
122
|
+
cause
|
|
123
|
+
})
|
|
124
|
+
}), (_) => impl.writeFile(path, _, options))
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
var notFound = (method, path) => new SystemError({
|
|
128
|
+
module: "FileSystem",
|
|
129
|
+
method,
|
|
130
|
+
reason: "NotFound",
|
|
131
|
+
description: "No such file or directory",
|
|
132
|
+
pathOrDescriptor: path
|
|
133
|
+
});
|
|
134
|
+
var makeNoop = (fileSystem) => {
|
|
135
|
+
return {
|
|
136
|
+
access(path) {
|
|
137
|
+
return Effect.fail(notFound("access", path));
|
|
138
|
+
},
|
|
139
|
+
chmod(path) {
|
|
140
|
+
return Effect.fail(notFound("chmod", path));
|
|
141
|
+
},
|
|
142
|
+
chown(path) {
|
|
143
|
+
return Effect.fail(notFound("chown", path));
|
|
144
|
+
},
|
|
145
|
+
copy(path) {
|
|
146
|
+
return Effect.fail(notFound("copy", path));
|
|
147
|
+
},
|
|
148
|
+
copyFile(path) {
|
|
149
|
+
return Effect.fail(notFound("copyFile", path));
|
|
150
|
+
},
|
|
151
|
+
exists() {
|
|
152
|
+
return Effect.succeed(false);
|
|
153
|
+
},
|
|
154
|
+
link(path) {
|
|
155
|
+
return Effect.fail(notFound("link", path));
|
|
156
|
+
},
|
|
157
|
+
makeDirectory() {
|
|
158
|
+
return Effect.die("not implemented");
|
|
159
|
+
},
|
|
160
|
+
makeTempDirectory() {
|
|
161
|
+
return Effect.die("not implemented");
|
|
162
|
+
},
|
|
163
|
+
makeTempDirectoryScoped() {
|
|
164
|
+
return Effect.die("not implemented");
|
|
165
|
+
},
|
|
166
|
+
makeTempFile() {
|
|
167
|
+
return Effect.die("not implemented");
|
|
168
|
+
},
|
|
169
|
+
makeTempFileScoped() {
|
|
170
|
+
return Effect.die("not implemented");
|
|
171
|
+
},
|
|
172
|
+
open(path) {
|
|
173
|
+
return Effect.fail(notFound("open", path));
|
|
174
|
+
},
|
|
175
|
+
readDirectory(path) {
|
|
176
|
+
return Effect.fail(notFound("readDirectory", path));
|
|
177
|
+
},
|
|
178
|
+
readFile(path) {
|
|
179
|
+
return Effect.fail(notFound("readFile", path));
|
|
180
|
+
},
|
|
181
|
+
readFileString(path) {
|
|
182
|
+
return Effect.fail(notFound("readFileString", path));
|
|
183
|
+
},
|
|
184
|
+
readLink(path) {
|
|
185
|
+
return Effect.fail(notFound("readLink", path));
|
|
186
|
+
},
|
|
187
|
+
realPath(path) {
|
|
188
|
+
return Effect.fail(notFound("realPath", path));
|
|
189
|
+
},
|
|
190
|
+
remove() {
|
|
191
|
+
return Effect.void;
|
|
192
|
+
},
|
|
193
|
+
rename(oldPath) {
|
|
194
|
+
return Effect.fail(notFound("rename", oldPath));
|
|
195
|
+
},
|
|
196
|
+
sink(path) {
|
|
197
|
+
return Sink.fail(notFound("sink", path));
|
|
198
|
+
},
|
|
199
|
+
stat(path) {
|
|
200
|
+
return Effect.fail(notFound("stat", path));
|
|
201
|
+
},
|
|
202
|
+
stream(path) {
|
|
203
|
+
return Stream.fail(notFound("stream", path));
|
|
204
|
+
},
|
|
205
|
+
symlink(fromPath) {
|
|
206
|
+
return Effect.fail(notFound("symlink", fromPath));
|
|
207
|
+
},
|
|
208
|
+
truncate(path) {
|
|
209
|
+
return Effect.fail(notFound("truncate", path));
|
|
210
|
+
},
|
|
211
|
+
utimes(path) {
|
|
212
|
+
return Effect.fail(notFound("utimes", path));
|
|
213
|
+
},
|
|
214
|
+
watch(path) {
|
|
215
|
+
return Stream.fail(notFound("watch", path));
|
|
216
|
+
},
|
|
217
|
+
writeFile(path) {
|
|
218
|
+
return Effect.fail(notFound("writeFile", path));
|
|
219
|
+
},
|
|
220
|
+
writeFileString(path) {
|
|
221
|
+
return Effect.fail(notFound("writeFileString", path));
|
|
222
|
+
},
|
|
223
|
+
...fileSystem
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
var layerNoop = (fileSystem) => Layer.succeed(tag, makeNoop(fileSystem));
|
|
227
|
+
var stream = (file, {
|
|
228
|
+
bufferSize = 16,
|
|
229
|
+
bytesToRead: bytesToRead_,
|
|
230
|
+
chunkSize: chunkSize_ = Size(64 * 1024)
|
|
231
|
+
} = {}) => {
|
|
232
|
+
const bytesToRead = bytesToRead_ !== undefined ? Size(bytesToRead_) : undefined;
|
|
233
|
+
const chunkSize = Size(chunkSize_);
|
|
234
|
+
function loop(totalBytesRead) {
|
|
235
|
+
if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) {
|
|
236
|
+
return Channel.void;
|
|
237
|
+
}
|
|
238
|
+
const toRead = bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? bytesToRead - totalBytesRead : chunkSize;
|
|
239
|
+
return Channel.flatMap(file.readAlloc(toRead), Option.match({
|
|
240
|
+
onNone: () => Channel.void,
|
|
241
|
+
onSome: (buf) => Channel.flatMap(Channel.write(Chunk.of(buf)), (_) => loop(totalBytesRead + BigInt(buf.length)))
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
return Stream.bufferChunks(Stream.fromChannel(loop(BigInt(0))), {
|
|
245
|
+
capacity: bufferSize
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// node_modules/@effect/platform/dist/esm/FileSystem.js
|
|
250
|
+
var Size2 = Size;
|
|
251
|
+
var KiB2 = KiB;
|
|
252
|
+
var MiB2 = MiB;
|
|
253
|
+
var GiB2 = GiB;
|
|
254
|
+
var TiB2 = TiB;
|
|
255
|
+
var PiB2 = PiB;
|
|
256
|
+
var FileSystem = tag;
|
|
257
|
+
var make2 = make;
|
|
258
|
+
var makeNoop2 = makeNoop;
|
|
259
|
+
var layerNoop2 = layerNoop;
|
|
260
|
+
var FileTypeId = /* @__PURE__ */ Symbol.for("@effect/platform/FileSystem/File");
|
|
261
|
+
var isFile = (u) => typeof u === "object" && u !== null && (FileTypeId in u);
|
|
262
|
+
var FileDescriptor = /* @__PURE__ */ Brand.nominal();
|
|
263
|
+
var WatchEventCreate = /* @__PURE__ */ Data2.tagged("Create");
|
|
264
|
+
var WatchEventUpdate = /* @__PURE__ */ Data2.tagged("Update");
|
|
265
|
+
var WatchEventRemove = /* @__PURE__ */ Data2.tagged("Remove");
|
|
266
|
+
|
|
267
|
+
class WatchBackend extends (/* @__PURE__ */ Context.Tag("@effect/platform/FileSystem/WatchBackend")()) {
|
|
268
|
+
}
|
|
269
|
+
// node_modules/@effect/platform/dist/esm/Path.js
|
|
270
|
+
var exports_Path = {};
|
|
271
|
+
__export(exports_Path, {
|
|
272
|
+
layer: () => layer2,
|
|
273
|
+
TypeId: () => TypeId3,
|
|
274
|
+
Path: () => Path2
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// node_modules/@effect/platform/dist/esm/internal/path.js
|
|
278
|
+
import { GenericTag as GenericTag2 } from "effect/Context";
|
|
279
|
+
import * as Effect2 from "effect/Effect";
|
|
280
|
+
import { identity as identity2 } from "effect/Function";
|
|
281
|
+
import * as Layer2 from "effect/Layer";
|
|
282
|
+
var TypeId2 = /* @__PURE__ */ Symbol.for("@effect/platform/Path");
|
|
283
|
+
var Path = /* @__PURE__ */ GenericTag2("@effect/platform/Path");
|
|
284
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
285
|
+
let res = "";
|
|
286
|
+
let lastSegmentLength = 0;
|
|
287
|
+
let lastSlash = -1;
|
|
288
|
+
let dots = 0;
|
|
289
|
+
let code;
|
|
290
|
+
for (let i = 0;i <= path.length; ++i) {
|
|
291
|
+
if (i < path.length) {
|
|
292
|
+
code = path.charCodeAt(i);
|
|
293
|
+
} else if (code === 47) {
|
|
294
|
+
break;
|
|
295
|
+
} else {
|
|
296
|
+
code = 47;
|
|
297
|
+
}
|
|
298
|
+
if (code === 47) {
|
|
299
|
+
if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) {
|
|
300
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
|
301
|
+
if (res.length > 2) {
|
|
302
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
303
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
304
|
+
if (lastSlashIndex === -1) {
|
|
305
|
+
res = "";
|
|
306
|
+
lastSegmentLength = 0;
|
|
307
|
+
} else {
|
|
308
|
+
res = res.slice(0, lastSlashIndex);
|
|
309
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
310
|
+
}
|
|
311
|
+
lastSlash = i;
|
|
312
|
+
dots = 0;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
316
|
+
res = "";
|
|
317
|
+
lastSegmentLength = 0;
|
|
318
|
+
lastSlash = i;
|
|
319
|
+
dots = 0;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (allowAboveRoot) {
|
|
324
|
+
if (res.length > 0) {
|
|
325
|
+
res += "/..";
|
|
326
|
+
} else {
|
|
327
|
+
res = "..";
|
|
328
|
+
}
|
|
329
|
+
lastSegmentLength = 2;
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
if (res.length > 0) {
|
|
333
|
+
res += "/" + path.slice(lastSlash + 1, i);
|
|
334
|
+
} else {
|
|
335
|
+
res = path.slice(lastSlash + 1, i);
|
|
336
|
+
}
|
|
337
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
338
|
+
}
|
|
339
|
+
lastSlash = i;
|
|
340
|
+
dots = 0;
|
|
341
|
+
} else if (code === 46 && dots !== -1) {
|
|
342
|
+
++dots;
|
|
343
|
+
} else {
|
|
344
|
+
dots = -1;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return res;
|
|
348
|
+
}
|
|
349
|
+
function _format(sep, pathObject) {
|
|
350
|
+
const dir = pathObject.dir || pathObject.root;
|
|
351
|
+
const base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
352
|
+
if (!dir) {
|
|
353
|
+
return base;
|
|
354
|
+
}
|
|
355
|
+
if (dir === pathObject.root) {
|
|
356
|
+
return dir + base;
|
|
357
|
+
}
|
|
358
|
+
return dir + sep + base;
|
|
359
|
+
}
|
|
360
|
+
function fromFileUrl(url) {
|
|
361
|
+
if (url.protocol !== "file:") {
|
|
362
|
+
return Effect2.fail(new BadArgument({
|
|
363
|
+
module: "Path",
|
|
364
|
+
method: "fromFileUrl",
|
|
365
|
+
description: "URL must be of scheme file"
|
|
366
|
+
}));
|
|
367
|
+
} else if (url.hostname !== "") {
|
|
368
|
+
return Effect2.fail(new BadArgument({
|
|
369
|
+
module: "Path",
|
|
370
|
+
method: "fromFileUrl",
|
|
371
|
+
description: "Invalid file URL host"
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
const pathname = url.pathname;
|
|
375
|
+
for (let n = 0;n < pathname.length; n++) {
|
|
376
|
+
if (pathname[n] === "%") {
|
|
377
|
+
const third = pathname.codePointAt(n + 2) | 32;
|
|
378
|
+
if (pathname[n + 1] === "2" && third === 102) {
|
|
379
|
+
return Effect2.fail(new BadArgument({
|
|
380
|
+
module: "Path",
|
|
381
|
+
method: "fromFileUrl",
|
|
382
|
+
description: "must not include encoded / characters"
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return Effect2.succeed(decodeURIComponent(pathname));
|
|
388
|
+
}
|
|
389
|
+
var resolve = function resolve2() {
|
|
390
|
+
let resolvedPath = "";
|
|
391
|
+
let resolvedAbsolute = false;
|
|
392
|
+
let cwd = undefined;
|
|
393
|
+
for (let i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
|
|
394
|
+
let path;
|
|
395
|
+
if (i >= 0) {
|
|
396
|
+
path = arguments[i];
|
|
397
|
+
} else {
|
|
398
|
+
const process = globalThis.process;
|
|
399
|
+
if (cwd === undefined && "process" in globalThis && typeof process === "object" && process !== null && typeof process.cwd === "function") {
|
|
400
|
+
cwd = process.cwd();
|
|
401
|
+
}
|
|
402
|
+
path = cwd;
|
|
403
|
+
}
|
|
404
|
+
if (path.length === 0) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
resolvedPath = path + "/" + resolvedPath;
|
|
408
|
+
resolvedAbsolute = path.charCodeAt(0) === 47;
|
|
409
|
+
}
|
|
410
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
411
|
+
if (resolvedAbsolute) {
|
|
412
|
+
if (resolvedPath.length > 0) {
|
|
413
|
+
return "/" + resolvedPath;
|
|
414
|
+
} else {
|
|
415
|
+
return "/";
|
|
416
|
+
}
|
|
417
|
+
} else if (resolvedPath.length > 0) {
|
|
418
|
+
return resolvedPath;
|
|
419
|
+
} else {
|
|
420
|
+
return ".";
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
var CHAR_FORWARD_SLASH = 47;
|
|
424
|
+
function toFileUrl(filepath) {
|
|
425
|
+
const outURL = new URL("file://");
|
|
426
|
+
let resolved = resolve(filepath);
|
|
427
|
+
const filePathLast = filepath.charCodeAt(filepath.length - 1);
|
|
428
|
+
if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") {
|
|
429
|
+
resolved += "/";
|
|
430
|
+
}
|
|
431
|
+
outURL.pathname = encodePathChars(resolved);
|
|
432
|
+
return Effect2.succeed(outURL);
|
|
433
|
+
}
|
|
434
|
+
var percentRegEx = /%/g;
|
|
435
|
+
var backslashRegEx = /\\/g;
|
|
436
|
+
var newlineRegEx = /\n/g;
|
|
437
|
+
var carriageReturnRegEx = /\r/g;
|
|
438
|
+
var tabRegEx = /\t/g;
|
|
439
|
+
function encodePathChars(filepath) {
|
|
440
|
+
if (filepath.includes("%")) {
|
|
441
|
+
filepath = filepath.replace(percentRegEx, "%25");
|
|
442
|
+
}
|
|
443
|
+
if (filepath.includes("\\")) {
|
|
444
|
+
filepath = filepath.replace(backslashRegEx, "%5C");
|
|
445
|
+
}
|
|
446
|
+
if (filepath.includes(`
|
|
447
|
+
`)) {
|
|
448
|
+
filepath = filepath.replace(newlineRegEx, "%0A");
|
|
449
|
+
}
|
|
450
|
+
if (filepath.includes("\r")) {
|
|
451
|
+
filepath = filepath.replace(carriageReturnRegEx, "%0D");
|
|
452
|
+
}
|
|
453
|
+
if (filepath.includes("\t")) {
|
|
454
|
+
filepath = filepath.replace(tabRegEx, "%09");
|
|
455
|
+
}
|
|
456
|
+
return filepath;
|
|
457
|
+
}
|
|
458
|
+
var posixImpl = /* @__PURE__ */ Path.of({
|
|
459
|
+
[TypeId2]: TypeId2,
|
|
460
|
+
resolve,
|
|
461
|
+
normalize(path) {
|
|
462
|
+
if (path.length === 0)
|
|
463
|
+
return ".";
|
|
464
|
+
const isAbsolute = path.charCodeAt(0) === 47;
|
|
465
|
+
const trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
|
466
|
+
path = normalizeStringPosix(path, !isAbsolute);
|
|
467
|
+
if (path.length === 0 && !isAbsolute)
|
|
468
|
+
path = ".";
|
|
469
|
+
if (path.length > 0 && trailingSeparator)
|
|
470
|
+
path += "/";
|
|
471
|
+
if (isAbsolute)
|
|
472
|
+
return "/" + path;
|
|
473
|
+
return path;
|
|
474
|
+
},
|
|
475
|
+
isAbsolute(path) {
|
|
476
|
+
return path.length > 0 && path.charCodeAt(0) === 47;
|
|
477
|
+
},
|
|
478
|
+
join() {
|
|
479
|
+
if (arguments.length === 0) {
|
|
480
|
+
return ".";
|
|
481
|
+
}
|
|
482
|
+
let joined;
|
|
483
|
+
for (let i = 0;i < arguments.length; ++i) {
|
|
484
|
+
const arg = arguments[i];
|
|
485
|
+
if (arg.length > 0) {
|
|
486
|
+
if (joined === undefined) {
|
|
487
|
+
joined = arg;
|
|
488
|
+
} else {
|
|
489
|
+
joined += "/" + arg;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (joined === undefined) {
|
|
494
|
+
return ".";
|
|
495
|
+
}
|
|
496
|
+
return posixImpl.normalize(joined);
|
|
497
|
+
},
|
|
498
|
+
relative(from, to) {
|
|
499
|
+
if (from === to)
|
|
500
|
+
return "";
|
|
501
|
+
from = posixImpl.resolve(from);
|
|
502
|
+
to = posixImpl.resolve(to);
|
|
503
|
+
if (from === to)
|
|
504
|
+
return "";
|
|
505
|
+
let fromStart = 1;
|
|
506
|
+
for (;fromStart < from.length; ++fromStart) {
|
|
507
|
+
if (from.charCodeAt(fromStart) !== 47) {
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const fromEnd = from.length;
|
|
512
|
+
const fromLen = fromEnd - fromStart;
|
|
513
|
+
let toStart = 1;
|
|
514
|
+
for (;toStart < to.length; ++toStart) {
|
|
515
|
+
if (to.charCodeAt(toStart) !== 47) {
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const toEnd = to.length;
|
|
520
|
+
const toLen = toEnd - toStart;
|
|
521
|
+
const length = fromLen < toLen ? fromLen : toLen;
|
|
522
|
+
let lastCommonSep = -1;
|
|
523
|
+
let i = 0;
|
|
524
|
+
for (;i <= length; ++i) {
|
|
525
|
+
if (i === length) {
|
|
526
|
+
if (toLen > length) {
|
|
527
|
+
if (to.charCodeAt(toStart + i) === 47) {
|
|
528
|
+
return to.slice(toStart + i + 1);
|
|
529
|
+
} else if (i === 0) {
|
|
530
|
+
return to.slice(toStart + i);
|
|
531
|
+
}
|
|
532
|
+
} else if (fromLen > length) {
|
|
533
|
+
if (from.charCodeAt(fromStart + i) === 47) {
|
|
534
|
+
lastCommonSep = i;
|
|
535
|
+
} else if (i === 0) {
|
|
536
|
+
lastCommonSep = 0;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
const fromCode = from.charCodeAt(fromStart + i);
|
|
542
|
+
const toCode = to.charCodeAt(toStart + i);
|
|
543
|
+
if (fromCode !== toCode) {
|
|
544
|
+
break;
|
|
545
|
+
} else if (fromCode === 47) {
|
|
546
|
+
lastCommonSep = i;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
let out = "";
|
|
550
|
+
for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i) {
|
|
551
|
+
if (i === fromEnd || from.charCodeAt(i) === 47) {
|
|
552
|
+
if (out.length === 0) {
|
|
553
|
+
out += "..";
|
|
554
|
+
} else {
|
|
555
|
+
out += "/..";
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (out.length > 0) {
|
|
560
|
+
return out + to.slice(toStart + lastCommonSep);
|
|
561
|
+
} else {
|
|
562
|
+
toStart += lastCommonSep;
|
|
563
|
+
if (to.charCodeAt(toStart) === 47) {
|
|
564
|
+
++toStart;
|
|
565
|
+
}
|
|
566
|
+
return to.slice(toStart);
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
dirname(path) {
|
|
570
|
+
if (path.length === 0)
|
|
571
|
+
return ".";
|
|
572
|
+
let code = path.charCodeAt(0);
|
|
573
|
+
const hasRoot = code === 47;
|
|
574
|
+
let end = -1;
|
|
575
|
+
let matchedSlash = true;
|
|
576
|
+
for (let i = path.length - 1;i >= 1; --i) {
|
|
577
|
+
code = path.charCodeAt(i);
|
|
578
|
+
if (code === 47) {
|
|
579
|
+
if (!matchedSlash) {
|
|
580
|
+
end = i;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
matchedSlash = false;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (end === -1)
|
|
588
|
+
return hasRoot ? "/" : ".";
|
|
589
|
+
if (hasRoot && end === 1)
|
|
590
|
+
return "//";
|
|
591
|
+
return path.slice(0, end);
|
|
592
|
+
},
|
|
593
|
+
basename(path, ext) {
|
|
594
|
+
let start = 0;
|
|
595
|
+
let end = -1;
|
|
596
|
+
let matchedSlash = true;
|
|
597
|
+
let i;
|
|
598
|
+
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
599
|
+
if (ext.length === path.length && ext === path)
|
|
600
|
+
return "";
|
|
601
|
+
let extIdx = ext.length - 1;
|
|
602
|
+
let firstNonSlashEnd = -1;
|
|
603
|
+
for (i = path.length - 1;i >= 0; --i) {
|
|
604
|
+
const code = path.charCodeAt(i);
|
|
605
|
+
if (code === 47) {
|
|
606
|
+
if (!matchedSlash) {
|
|
607
|
+
start = i + 1;
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
} else {
|
|
611
|
+
if (firstNonSlashEnd === -1) {
|
|
612
|
+
matchedSlash = false;
|
|
613
|
+
firstNonSlashEnd = i + 1;
|
|
614
|
+
}
|
|
615
|
+
if (extIdx >= 0) {
|
|
616
|
+
if (code === ext.charCodeAt(extIdx)) {
|
|
617
|
+
if (--extIdx === -1) {
|
|
618
|
+
end = i;
|
|
619
|
+
}
|
|
620
|
+
} else {
|
|
621
|
+
extIdx = -1;
|
|
622
|
+
end = firstNonSlashEnd;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (start === end)
|
|
628
|
+
end = firstNonSlashEnd;
|
|
629
|
+
else if (end === -1)
|
|
630
|
+
end = path.length;
|
|
631
|
+
return path.slice(start, end);
|
|
632
|
+
} else {
|
|
633
|
+
for (i = path.length - 1;i >= 0; --i) {
|
|
634
|
+
if (path.charCodeAt(i) === 47) {
|
|
635
|
+
if (!matchedSlash) {
|
|
636
|
+
start = i + 1;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
} else if (end === -1) {
|
|
640
|
+
matchedSlash = false;
|
|
641
|
+
end = i + 1;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (end === -1)
|
|
645
|
+
return "";
|
|
646
|
+
return path.slice(start, end);
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
extname(path) {
|
|
650
|
+
let startDot = -1;
|
|
651
|
+
let startPart = 0;
|
|
652
|
+
let end = -1;
|
|
653
|
+
let matchedSlash = true;
|
|
654
|
+
let preDotState = 0;
|
|
655
|
+
for (let i = path.length - 1;i >= 0; --i) {
|
|
656
|
+
const code = path.charCodeAt(i);
|
|
657
|
+
if (code === 47) {
|
|
658
|
+
if (!matchedSlash) {
|
|
659
|
+
startPart = i + 1;
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
if (end === -1) {
|
|
665
|
+
matchedSlash = false;
|
|
666
|
+
end = i + 1;
|
|
667
|
+
}
|
|
668
|
+
if (code === 46) {
|
|
669
|
+
if (startDot === -1) {
|
|
670
|
+
startDot = i;
|
|
671
|
+
} else if (preDotState !== 1) {
|
|
672
|
+
preDotState = 1;
|
|
673
|
+
}
|
|
674
|
+
} else if (startDot !== -1) {
|
|
675
|
+
preDotState = -1;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
679
|
+
return "";
|
|
680
|
+
}
|
|
681
|
+
return path.slice(startDot, end);
|
|
682
|
+
},
|
|
683
|
+
format: function format(pathObject) {
|
|
684
|
+
if (pathObject === null || typeof pathObject !== "object") {
|
|
685
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
686
|
+
}
|
|
687
|
+
return _format("/", pathObject);
|
|
688
|
+
},
|
|
689
|
+
parse(path) {
|
|
690
|
+
const ret = {
|
|
691
|
+
root: "",
|
|
692
|
+
dir: "",
|
|
693
|
+
base: "",
|
|
694
|
+
ext: "",
|
|
695
|
+
name: ""
|
|
696
|
+
};
|
|
697
|
+
if (path.length === 0)
|
|
698
|
+
return ret;
|
|
699
|
+
let code = path.charCodeAt(0);
|
|
700
|
+
const isAbsolute = code === 47;
|
|
701
|
+
let start;
|
|
702
|
+
if (isAbsolute) {
|
|
703
|
+
ret.root = "/";
|
|
704
|
+
start = 1;
|
|
705
|
+
} else {
|
|
706
|
+
start = 0;
|
|
707
|
+
}
|
|
708
|
+
let startDot = -1;
|
|
709
|
+
let startPart = 0;
|
|
710
|
+
let end = -1;
|
|
711
|
+
let matchedSlash = true;
|
|
712
|
+
let i = path.length - 1;
|
|
713
|
+
let preDotState = 0;
|
|
714
|
+
for (;i >= start; --i) {
|
|
715
|
+
code = path.charCodeAt(i);
|
|
716
|
+
if (code === 47) {
|
|
717
|
+
if (!matchedSlash) {
|
|
718
|
+
startPart = i + 1;
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
if (end === -1) {
|
|
724
|
+
matchedSlash = false;
|
|
725
|
+
end = i + 1;
|
|
726
|
+
}
|
|
727
|
+
if (code === 46) {
|
|
728
|
+
if (startDot === -1)
|
|
729
|
+
startDot = i;
|
|
730
|
+
else if (preDotState !== 1)
|
|
731
|
+
preDotState = 1;
|
|
732
|
+
} else if (startDot !== -1) {
|
|
733
|
+
preDotState = -1;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
737
|
+
if (end !== -1) {
|
|
738
|
+
if (startPart === 0 && isAbsolute)
|
|
739
|
+
ret.base = ret.name = path.slice(1, end);
|
|
740
|
+
else
|
|
741
|
+
ret.base = ret.name = path.slice(startPart, end);
|
|
742
|
+
}
|
|
743
|
+
} else {
|
|
744
|
+
if (startPart === 0 && isAbsolute) {
|
|
745
|
+
ret.name = path.slice(1, startDot);
|
|
746
|
+
ret.base = path.slice(1, end);
|
|
747
|
+
} else {
|
|
748
|
+
ret.name = path.slice(startPart, startDot);
|
|
749
|
+
ret.base = path.slice(startPart, end);
|
|
750
|
+
}
|
|
751
|
+
ret.ext = path.slice(startDot, end);
|
|
752
|
+
}
|
|
753
|
+
if (startPart > 0)
|
|
754
|
+
ret.dir = path.slice(0, startPart - 1);
|
|
755
|
+
else if (isAbsolute)
|
|
756
|
+
ret.dir = "/";
|
|
757
|
+
return ret;
|
|
758
|
+
},
|
|
759
|
+
sep: "/",
|
|
760
|
+
fromFileUrl,
|
|
761
|
+
toFileUrl,
|
|
762
|
+
toNamespacedPath: identity2
|
|
763
|
+
});
|
|
764
|
+
var layer = /* @__PURE__ */ Layer2.succeed(Path, posixImpl);
|
|
765
|
+
|
|
766
|
+
// node_modules/@effect/platform/dist/esm/Path.js
|
|
767
|
+
var TypeId3 = TypeId2;
|
|
768
|
+
var Path2 = Path;
|
|
769
|
+
var layer2 = layer;
|
|
1
770
|
// src/fsGenerator.ts
|
|
2
|
-
import { Effect as
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import fs from "node:fs";
|
|
771
|
+
import { Effect as Effect4 } from "effect";
|
|
5
772
|
|
|
6
773
|
// src/fsNormalizator.ts
|
|
7
|
-
import {
|
|
8
|
-
import { Effect } from "effect";
|
|
774
|
+
import { Effect as Effect3 } from "effect";
|
|
9
775
|
|
|
10
776
|
// src/_commonErrors.ts
|
|
11
777
|
class PathTraversalError {
|
|
@@ -31,42 +797,44 @@ class FsError {
|
|
|
31
797
|
}
|
|
32
798
|
|
|
33
799
|
// src/fsNormalizator.ts
|
|
34
|
-
var resolveProjectPathToBase = (projectPath, basePath) => {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
800
|
+
var resolveProjectPathToBase = (projectPath, basePath) => Effect3.gen(function* () {
|
|
801
|
+
const path = yield* exports_Path.Path;
|
|
802
|
+
const filePath = projectPath.startsWith(path.sep) ? `.${projectPath}` : projectPath;
|
|
803
|
+
const absolute = path.resolve(basePath, filePath);
|
|
804
|
+
const rel = path.relative(basePath, absolute);
|
|
38
805
|
if (rel.startsWith("..")) {
|
|
39
|
-
return
|
|
806
|
+
return yield* Effect3.fail(new PathTraversalError(["project:", projectPath, "base:", basePath].join(" ")));
|
|
40
807
|
}
|
|
41
|
-
return
|
|
42
|
-
};
|
|
808
|
+
return absolute;
|
|
809
|
+
});
|
|
43
810
|
|
|
44
811
|
// src/fsGenerator.ts
|
|
45
|
-
var fileStructureCreator = (items, basePath) =>
|
|
46
|
-
yield*
|
|
812
|
+
var fileStructureCreator = (items, basePath) => Effect4.gen(function* () {
|
|
813
|
+
const fs = yield* exports_FileSystem.FileSystem;
|
|
814
|
+
const path = yield* exports_Path.Path;
|
|
815
|
+
yield* Effect4.logInfo(`Creating structure in: ${basePath}`);
|
|
47
816
|
for (const item of items) {
|
|
48
|
-
const fullPath = yield*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
yield* _(Effect2.logInfo(` Created directory: ${item.path}`));
|
|
817
|
+
const fullPath = yield* resolveProjectPathToBase(item.path, basePath);
|
|
818
|
+
const dir = path.dirname(fullPath);
|
|
819
|
+
switch (item.type) {
|
|
820
|
+
case "file":
|
|
821
|
+
yield* fs.makeDirectory(dir, { recursive: true });
|
|
822
|
+
yield* fs.writeFile(fullPath, new Uint8Array);
|
|
823
|
+
yield* Effect4.logInfo(` Created file: ${item.path}`);
|
|
824
|
+
break;
|
|
825
|
+
case "symlink":
|
|
826
|
+
yield* fs.makeDirectory(dir, { recursive: true });
|
|
827
|
+
yield* fs.symlink(item.target, fullPath);
|
|
828
|
+
yield* Effect4.logInfo(` Created symlink: ${item.path} -> ${item.target}`);
|
|
829
|
+
break;
|
|
830
|
+
case "folder":
|
|
831
|
+
yield* fs.makeDirectory(fullPath, { recursive: true });
|
|
832
|
+
yield* Effect4.logInfo(` Created directory: ${item.path}`);
|
|
833
|
+
break;
|
|
66
834
|
}
|
|
67
835
|
}
|
|
68
|
-
yield*
|
|
69
|
-
✓ Structure created successfully!`)
|
|
836
|
+
yield* Effect4.logInfo(`
|
|
837
|
+
✓ Structure created successfully!`);
|
|
70
838
|
});
|
|
71
839
|
// src/parser.ts
|
|
72
840
|
var parserFolderStructure = (treeString) => {
|
|
@@ -79,38 +847,50 @@ var parserFolderStructure = (treeString) => {
|
|
|
79
847
|
for (const line of lines) {
|
|
80
848
|
const [p01 = "", _comment01] = line.split("#");
|
|
81
849
|
const [p02 = "", _comment02] = p01.split("//");
|
|
82
|
-
const
|
|
83
|
-
const
|
|
850
|
+
const [p03a = "", _comment03] = p02.split("<-");
|
|
851
|
+
const [p03b = "", _comment04] = p03a.split("←");
|
|
852
|
+
const p04 = p03b.replace(/[│├└─\t]/g, " ");
|
|
853
|
+
const cleanLine = p04.trim().replace(/^\.\//, "");
|
|
84
854
|
if (!cleanLine)
|
|
85
855
|
continue;
|
|
86
856
|
if (cleanLine === "/")
|
|
87
857
|
continue;
|
|
88
858
|
if (cleanLine.endsWith("../"))
|
|
89
859
|
continue;
|
|
90
|
-
const indent = countLeadingSpaces(
|
|
860
|
+
const indent = countLeadingSpaces(p04);
|
|
91
861
|
indentSize = indentSize === 0 && indent > 0 ? indent : indentSize;
|
|
92
862
|
const level = indentSize === 0 ? 0 : indent / indentSize;
|
|
93
863
|
if (previousIndentLevel >= level) {
|
|
94
864
|
pathStack.splice(level, pathStack.length - level);
|
|
95
865
|
}
|
|
96
866
|
previousIndentLevel = level;
|
|
97
|
-
const
|
|
867
|
+
const arrowIndex = cleanLine.indexOf("->");
|
|
868
|
+
if (arrowIndex !== -1) {
|
|
869
|
+
const linkName = cleanLine.slice(0, arrowIndex).trim();
|
|
870
|
+
const target = cleanLine.slice(arrowIndex + 2).trim();
|
|
871
|
+
if (!linkName || !target)
|
|
872
|
+
continue;
|
|
873
|
+
const nameParts = linkName.split("/").filter(Boolean);
|
|
874
|
+
pathStack.push(nameParts);
|
|
875
|
+
const path2 = pathStack.flat().join("/");
|
|
876
|
+
pathStack.pop();
|
|
877
|
+
result.push({ type: "symlink", path: path2, target });
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
const isFolder = cleanLine.endsWith("/");
|
|
98
881
|
const name = cleanLine.split("/").filter(Boolean);
|
|
99
882
|
pathStack.push(name);
|
|
100
|
-
const
|
|
101
|
-
result.push({
|
|
102
|
-
|
|
103
|
-
isFile
|
|
104
|
-
});
|
|
105
|
-
if (isFile) {
|
|
883
|
+
const path = pathStack.flat().join("/");
|
|
884
|
+
result.push(isFolder ? { type: "folder", path } : { type: "file", path });
|
|
885
|
+
if (!isFolder) {
|
|
106
886
|
pathStack.pop();
|
|
107
887
|
}
|
|
108
888
|
}
|
|
109
889
|
return result;
|
|
110
890
|
};
|
|
111
891
|
function countLeadingSpaces(str) {
|
|
112
|
-
const
|
|
113
|
-
return
|
|
892
|
+
const match2 = str.match(/^[\s]*/);
|
|
893
|
+
return match2 ? match2[0].length : 0;
|
|
114
894
|
}
|
|
115
895
|
export {
|
|
116
896
|
resolveProjectPathToBase,
|