fullnative 0.1.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/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/core/env/env.d.ts +34 -0
- package/dist/core/env/env.d.ts.map +1 -0
- package/dist/core/env/env.js +134 -0
- package/dist/core/env/env.js.map +1 -0
- package/dist/core/env/index.d.ts +10 -0
- package/dist/core/env/index.d.ts.map +1 -0
- package/dist/core/env/index.js +10 -0
- package/dist/core/env/index.js.map +1 -0
- package/dist/core/file/File.d.ts +246 -0
- package/dist/core/file/File.d.ts.map +1 -0
- package/dist/core/file/File.js +397 -0
- package/dist/core/file/File.js.map +1 -0
- package/dist/core/file/Folder.d.ts +235 -0
- package/dist/core/file/Folder.d.ts.map +1 -0
- package/dist/core/file/Folder.js +427 -0
- package/dist/core/file/Folder.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/process/Command.d.ts +94 -0
- package/dist/core/process/Command.d.ts.map +1 -0
- package/dist/core/process/Command.js +143 -0
- package/dist/core/process/Command.js.map +1 -0
- package/dist/core/process/LiveProcess.d.ts +134 -0
- package/dist/core/process/LiveProcess.d.ts.map +1 -0
- package/dist/core/process/LiveProcess.js +214 -0
- package/dist/core/process/LiveProcess.js.map +1 -0
- package/dist/core/process/Process.d.ts +108 -0
- package/dist/core/process/Process.d.ts.map +1 -0
- package/dist/core/process/Process.js +138 -0
- package/dist/core/process/Process.js.map +1 -0
- package/dist/core/process/ProcessError.d.ts +50 -0
- package/dist/core/process/ProcessError.d.ts.map +1 -0
- package/dist/core/process/ProcessError.js +62 -0
- package/dist/core/process/ProcessError.js.map +1 -0
- package/dist/core/process/Result.d.ts +61 -0
- package/dist/core/process/Result.d.ts.map +1 -0
- package/dist/core/process/Result.js +89 -0
- package/dist/core/process/Result.js.map +1 -0
- package/dist/core/process/index.d.ts +7 -0
- package/dist/core/process/index.d.ts.map +1 -0
- package/dist/core/process/index.js +6 -0
- package/dist/core/process/index.js.map +1 -0
- package/dist/core/process/types.d.ts +17 -0
- package/dist/core/process/types.d.ts.map +1 -0
- package/dist/core/process/types.js +2 -0
- package/dist/core/process/types.js.map +1 -0
- package/dist/core/shell/Job.d.ts +149 -0
- package/dist/core/shell/Job.d.ts.map +1 -0
- package/dist/core/shell/Job.js +218 -0
- package/dist/core/shell/Job.js.map +1 -0
- package/dist/core/shell/Shell.d.ts +275 -0
- package/dist/core/shell/Shell.d.ts.map +1 -0
- package/dist/core/shell/Shell.js +461 -0
- package/dist/core/shell/Shell.js.map +1 -0
- package/dist/core/shell/index.d.ts +4 -0
- package/dist/core/shell/index.d.ts.map +1 -0
- package/dist/core/shell/index.js +3 -0
- package/dist/core/shell/index.js.map +1 -0
- package/dist/core/shell/types.d.ts +30 -0
- package/dist/core/shell/types.d.ts.map +1 -0
- package/dist/core/shell/types.js +2 -0
- package/dist/core/shell/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { promises as fs, watch } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { File } from "./File.js";
|
|
4
|
+
/**
|
|
5
|
+
* Representa un directorio accesible mediante una API sencilla.
|
|
6
|
+
*/
|
|
7
|
+
export class Folder {
|
|
8
|
+
path;
|
|
9
|
+
constructor(path) {
|
|
10
|
+
this.path = path;
|
|
11
|
+
}
|
|
12
|
+
/** Nombre del directorio (último segmento de la ruta). */
|
|
13
|
+
get name() {
|
|
14
|
+
return path.basename(this.path);
|
|
15
|
+
}
|
|
16
|
+
/** Ruta absoluta del directorio padre. */
|
|
17
|
+
get parent() {
|
|
18
|
+
return path.dirname(this.path);
|
|
19
|
+
}
|
|
20
|
+
/** Instancia de `Folder` que representa al directorio padre. */
|
|
21
|
+
get parentDir() {
|
|
22
|
+
return new Folder(this.parent);
|
|
23
|
+
}
|
|
24
|
+
/** Ruta absoluta resuelta del directorio. */
|
|
25
|
+
get absolute() {
|
|
26
|
+
return path.resolve(this.path);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Verifica si el directorio existe en disco.
|
|
30
|
+
* @returns `true` si existe y es un directorio, `false` en caso contrario.
|
|
31
|
+
*/
|
|
32
|
+
async exists() {
|
|
33
|
+
try {
|
|
34
|
+
const s = await fs.stat(this.path);
|
|
35
|
+
return s.isDirectory();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Indica si el directorio está vacío (sin entradas).
|
|
43
|
+
* @returns `true` si no existe o no contiene entradas, `false` si tiene contenido.
|
|
44
|
+
*/
|
|
45
|
+
async isEmpty() {
|
|
46
|
+
if (!(await this.exists()))
|
|
47
|
+
return true;
|
|
48
|
+
return (await fs.readdir(this.path)).length === 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Obtiene los metadatos (stat) del directorio.
|
|
52
|
+
* @returns Una promesa con el objeto `Stats` de Node.js.
|
|
53
|
+
*/
|
|
54
|
+
async stat() {
|
|
55
|
+
return fs.stat(this.path);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Obtiene la fecha de creación del directorio.
|
|
59
|
+
* @returns La fecha (`birthtime`) de creación.
|
|
60
|
+
*/
|
|
61
|
+
async createdAt() {
|
|
62
|
+
return (await this.stat()).birthtime;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Obtiene la fecha de última modificación del directorio.
|
|
66
|
+
* @returns La fecha (`mtime`) de última modificación.
|
|
67
|
+
*/
|
|
68
|
+
async modifiedAt() {
|
|
69
|
+
return (await this.stat()).mtime;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Calcula el tamaño total del directorio sumando el tamaño de todos los
|
|
73
|
+
* archivos contenidos recursivamente.
|
|
74
|
+
* @returns Tamaño total en bytes (0 si no existe).
|
|
75
|
+
*/
|
|
76
|
+
async size() {
|
|
77
|
+
if (!(await this.exists()))
|
|
78
|
+
return 0;
|
|
79
|
+
let total = 0;
|
|
80
|
+
for (const item of await this.walk()) {
|
|
81
|
+
if (item instanceof File)
|
|
82
|
+
total += await item.size();
|
|
83
|
+
}
|
|
84
|
+
return total;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Crea el directorio (y sus padres) en disco.
|
|
88
|
+
* @returns Promesa que se resuelve al completar la creación.
|
|
89
|
+
*/
|
|
90
|
+
async create() {
|
|
91
|
+
await fs.mkdir(this.path, { recursive: true });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Garantiza que el directorio exista, creándolo si es necesario.
|
|
95
|
+
* @returns Promesa que se resuelve al asegurar la existencia.
|
|
96
|
+
*/
|
|
97
|
+
async ensure() {
|
|
98
|
+
if (!(await this.exists()))
|
|
99
|
+
await this.create();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Elimina el directorio del disco.
|
|
103
|
+
* @param recursive Si `true`, elimina recursivamente su contenido.
|
|
104
|
+
* @returns `true` si existía y fue eliminado, `false` si no existía.
|
|
105
|
+
*/
|
|
106
|
+
async delete(recursive = false) {
|
|
107
|
+
if (!(await this.exists()))
|
|
108
|
+
return false;
|
|
109
|
+
await fs.rmdir(this.path, { recursive });
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Vacía el directorio eliminando todo su contenido (archivos y subdirectorios)
|
|
114
|
+
* sin eliminar el directorio mismo.
|
|
115
|
+
* @returns Promesa que se resuelve al completar el vaciado.
|
|
116
|
+
*/
|
|
117
|
+
async clear() {
|
|
118
|
+
if (!(await this.exists()))
|
|
119
|
+
return;
|
|
120
|
+
const entries = await fs.readdir(this.path, { withFileTypes: true });
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
const full = path.join(this.path, entry.name);
|
|
123
|
+
if (entry.isDirectory()) {
|
|
124
|
+
await new Folder(full).delete(true);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
await fs.unlink(full);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Cambia los permisos del directorio.
|
|
133
|
+
* @param mode Máscode de permisos numérico (ej. `0o755`).
|
|
134
|
+
* @returns Promesa que se resuelve al completar el cambio.
|
|
135
|
+
*/
|
|
136
|
+
async chmod(mode) {
|
|
137
|
+
await fs.chmod(this.path, mode);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Construye una referencia `File` a un archivo dentro de este directorio.
|
|
141
|
+
* @param name Nombre del archivo (relativo al directorio).
|
|
142
|
+
* @returns Una nueva instancia de `File` (no verifica existencia).
|
|
143
|
+
*/
|
|
144
|
+
file(name) {
|
|
145
|
+
return new File(path.join(this.path, name));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Construye una referencia `Folder` a un subdirectorio de este directorio.
|
|
149
|
+
* @param name Nombre del subdirectorio (relativo al directorio).
|
|
150
|
+
* @returns Una nueva instancia de `Folder` (no verifica existencia).
|
|
151
|
+
*/
|
|
152
|
+
dir(name) {
|
|
153
|
+
return new Folder(path.join(this.path, name));
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Verifica si existe un archivo con el nombre dado dentro del directorio.
|
|
157
|
+
* @param name Nombre del archivo a buscar.
|
|
158
|
+
* @returns `true` si el archivo existe, `false` en caso contrario.
|
|
159
|
+
*/
|
|
160
|
+
hasFile(name) {
|
|
161
|
+
return this.file(name).exists();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Verifica si existe un subdirectorio con el nombre dado.
|
|
165
|
+
* @param name Nombre del subdirectorio a buscar.
|
|
166
|
+
* @returns `true` si el subdirectorio existe, `false` en caso contrario.
|
|
167
|
+
*/
|
|
168
|
+
async hasDir(name) {
|
|
169
|
+
return this.dir(name).exists();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Lista las entradas directas (archivos y subdirectorios) del directorio.
|
|
173
|
+
* @returns Arreglo de instancias `File` y `Folder`.
|
|
174
|
+
*/
|
|
175
|
+
async list() {
|
|
176
|
+
const entries = await fs.readdir(this.path, { withFileTypes: true });
|
|
177
|
+
return entries.map((entry) => {
|
|
178
|
+
const full = path.join(this.path, entry.name);
|
|
179
|
+
return entry.isDirectory()
|
|
180
|
+
? new Folder(full)
|
|
181
|
+
: new File(full);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Lista solo los archivos (no directorios) en el nivel actual.
|
|
186
|
+
* @returns Arreglo de instancias `File`.
|
|
187
|
+
*/
|
|
188
|
+
async listFiles() {
|
|
189
|
+
const items = await this.list();
|
|
190
|
+
return items.filter((i) => i instanceof File);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Lista solo los subdirectorios en el nivel actual.
|
|
194
|
+
* @returns Arreglo de instancias `Folder`.
|
|
195
|
+
*/
|
|
196
|
+
async listDirs() {
|
|
197
|
+
const items = await this.list();
|
|
198
|
+
return items.filter((i) => i instanceof Folder);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Lista los nombres de las entradas directas del directorio.
|
|
202
|
+
* @returns Arreglo de cadenas con los nombres de las entradas.
|
|
203
|
+
*/
|
|
204
|
+
async listNames() {
|
|
205
|
+
return fs.readdir(this.path);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Lista los archivos del nivel actual cuya extensión coincide con `ext`.
|
|
209
|
+
* @param ext Extensión a filtrar (con o sin punto inicial, sin distinguir mayúsculas).
|
|
210
|
+
* @returns Arreglo de instancias `File` que coinciden.
|
|
211
|
+
*/
|
|
212
|
+
async listByExt(ext) {
|
|
213
|
+
const files = await this.listFiles();
|
|
214
|
+
const lower = ext.toLowerCase().replace(/^\./, "");
|
|
215
|
+
return files.filter((f) => f.ext.toLowerCase() === lower);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Busca recursivamente un archivo por nombre exacto.
|
|
219
|
+
* @param name Nombre del archivo a buscar.
|
|
220
|
+
* @returns La instancia `File` si se encuentra, `undefined` en caso contrario.
|
|
221
|
+
*/
|
|
222
|
+
async find(name) {
|
|
223
|
+
const items = await this.walk();
|
|
224
|
+
return items.find((i) => i instanceof File && i.name === name);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Busca recursivamente un subdirectorio por nombre exacto.
|
|
228
|
+
* @param name Nombre del subdirectorio a buscar.
|
|
229
|
+
* @returns La instancia `Folder` si se encuentra, `undefined` en caso contrario.
|
|
230
|
+
*/
|
|
231
|
+
async findDir(name) {
|
|
232
|
+
const items = await this.walk();
|
|
233
|
+
return items.find((i) => i instanceof Folder && i.name === name);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Filtra archivos recursivamente mediante una expresión regular.
|
|
237
|
+
* Renombrado desde `glob()`: usa sintaxis **RegExp**, no patrones glob.
|
|
238
|
+
* @param pattern Expresión regular a probar contra la ruta completa de cada archivo.
|
|
239
|
+
* @returns Arreglo de instancias `File` cuya ruta coincide con el patrón.
|
|
240
|
+
*/
|
|
241
|
+
async matchFiles(pattern) {
|
|
242
|
+
const items = await this.walk();
|
|
243
|
+
return items.filter((i) => i instanceof File && pattern.test(i.path));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Recorre recursivamente el directorio acumulando todas las entradas
|
|
247
|
+
* (archivos y subdirectorios) en un arreglo.
|
|
248
|
+
* @returns Arreglo con todas las instancias `File` y `Folder` encontradas.
|
|
249
|
+
*/
|
|
250
|
+
async walk() {
|
|
251
|
+
const result = [];
|
|
252
|
+
if (!(await this.exists()))
|
|
253
|
+
return result;
|
|
254
|
+
const recurse = async (dir) => {
|
|
255
|
+
const items = await dir.list();
|
|
256
|
+
for (const item of items) {
|
|
257
|
+
result.push(item);
|
|
258
|
+
if (item instanceof Folder)
|
|
259
|
+
await recurse(item);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
await recurse(this);
|
|
263
|
+
return result;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Recorre recursivamente y devuelve solo los archivos.
|
|
267
|
+
* @returns Arreglo con todas las instancias `File` encontradas.
|
|
268
|
+
*/
|
|
269
|
+
async walkFiles() {
|
|
270
|
+
const items = await this.walk();
|
|
271
|
+
return items.filter((i) => i instanceof File);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Recorre recursivamente y devuelve solo los subdirectorios.
|
|
275
|
+
* @returns Arreglo con todas las instancias `Folder` encontradas.
|
|
276
|
+
*/
|
|
277
|
+
async walkDirs() {
|
|
278
|
+
const items = await this.walk();
|
|
279
|
+
return items.filter((i) => i instanceof Folder);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Versión streaming de `walk()` como async generator, ideal para carpetas
|
|
283
|
+
* grandes: produce entradas (`File` o `Folder`) a medida que se recorre el
|
|
284
|
+
* árbol, sin acumular todo en memoria.
|
|
285
|
+
* @yields Instancias `File` o `Folder` conforme se descubre cada entrada.
|
|
286
|
+
*/
|
|
287
|
+
async *walkIter() {
|
|
288
|
+
if (!(await this.exists()))
|
|
289
|
+
return;
|
|
290
|
+
const items = await this.list();
|
|
291
|
+
for (const item of items) {
|
|
292
|
+
yield item;
|
|
293
|
+
if (item instanceof Folder) {
|
|
294
|
+
yield* item.walkIter();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Versión streaming de `walkFiles()` como async generator: produce solo
|
|
300
|
+
* archivos a medida que recorre el árbol, sin acumular todo en memoria.
|
|
301
|
+
* @yields Instancias `File` conforme se descubre cada archivo.
|
|
302
|
+
*/
|
|
303
|
+
async *walkFilesIter() {
|
|
304
|
+
for await (const item of this.walkIter()) {
|
|
305
|
+
if (item instanceof File)
|
|
306
|
+
yield item;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Crea un archivo dentro de este directorio con el contenido indicado.
|
|
311
|
+
* @param name Nombre del archivo a crear.
|
|
312
|
+
* @param content Contenido inicial (cadena o `Buffer`, por defecto vacío).
|
|
313
|
+
* @returns La instancia `File` recién creada.
|
|
314
|
+
*/
|
|
315
|
+
async createFile(name, content = "") {
|
|
316
|
+
const file = this.file(name);
|
|
317
|
+
await file.write(content);
|
|
318
|
+
return file;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Crea un subdirectorio dentro de este directorio (garantizando su existencia).
|
|
322
|
+
* @param name Nombre del subdirectorio a crear.
|
|
323
|
+
* @returns La instancia `Folder` del subdirectorio creado.
|
|
324
|
+
*/
|
|
325
|
+
async createDir(name) {
|
|
326
|
+
const dir = this.dir(name);
|
|
327
|
+
await dir.ensure();
|
|
328
|
+
return dir;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Copia este directorio (y todo su contenido) a una ruta destino, creando
|
|
332
|
+
* el destino si no existe.
|
|
333
|
+
* @param dest Ruta absoluta del directorio destino.
|
|
334
|
+
* @returns Una **nueva** instancia de `Folder` apuntando al destino.
|
|
335
|
+
*/
|
|
336
|
+
async copyTo(dest) {
|
|
337
|
+
const target = new Folder(dest);
|
|
338
|
+
await target.ensure();
|
|
339
|
+
for (const item of await this.list()) {
|
|
340
|
+
if (item instanceof File) {
|
|
341
|
+
await item.copyTo(path.join(dest, item.name));
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
await item.copyTo(path.join(dest, item.name));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return target;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Copia este directorio dentro de otro, conservando su nombre.
|
|
351
|
+
* @param parent Ruta del directorio padre destino.
|
|
352
|
+
* @returns Una **nueva** instancia de `Folder` apuntando a `parent/name`.
|
|
353
|
+
*/
|
|
354
|
+
async copyInto(parent) {
|
|
355
|
+
return this.copyTo(path.join(parent, this.name));
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Mueve este directorio a una ruta destino. Crea el directorio padre del
|
|
359
|
+
* destino automáticamente si no existe. **Muta `this.path`** al nuevo destino
|
|
360
|
+
* y devuelve `this` para encadenamiento.
|
|
361
|
+
* @param dest Ruta absoluta del directorio destino.
|
|
362
|
+
* @returns La misma instancia (`this`) con `path` actualizado.
|
|
363
|
+
*/
|
|
364
|
+
async moveTo(dest) {
|
|
365
|
+
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
366
|
+
await fs.rename(this.path, dest);
|
|
367
|
+
this.path = dest;
|
|
368
|
+
return this;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Mueve este directorio dentro de otro, conservando su nombre.
|
|
372
|
+
* **Muta `this.path`** y devuelve `this`.
|
|
373
|
+
* @param parent Ruta del directorio padre destino.
|
|
374
|
+
* @returns La misma instancia (`this`) con `path` actualizado.
|
|
375
|
+
*/
|
|
376
|
+
async moveInto(parent) {
|
|
377
|
+
await this.moveTo(path.join(parent, this.name));
|
|
378
|
+
return this;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Renombra este directorio dentro de su mismo directorio padre.
|
|
382
|
+
* **Muta `this.path`** y devuelve `this`.
|
|
383
|
+
* @param newName Nuevo nombre del directorio (sin ruta).
|
|
384
|
+
* @returns La misma instancia (`this`) con `path` actualizado.
|
|
385
|
+
*/
|
|
386
|
+
async rename(newName) {
|
|
387
|
+
await this.moveTo(path.join(this.parent, newName));
|
|
388
|
+
return this;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Observa cambios en el directorio de forma recursiva.
|
|
392
|
+
* @param callback Función invocada por cada evento (`change` o `rename`).
|
|
393
|
+
* @returns Un `FSWatcher` que debe cerrarse cuando ya no se necesite.
|
|
394
|
+
*/
|
|
395
|
+
async watch(callback) {
|
|
396
|
+
return watch(this.path, { recursive: true }, callback);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Genera una representación visual en árbol (tipo `tree`) del directorio y
|
|
400
|
+
* su contenido recursivo.
|
|
401
|
+
* @returns Una cadena con la representación del árbol.
|
|
402
|
+
*/
|
|
403
|
+
async tree() {
|
|
404
|
+
const lines = [];
|
|
405
|
+
const render = async (dir, prefix, isLast) => {
|
|
406
|
+
const connector = isLast ? "└── " : "├── ";
|
|
407
|
+
lines.push(`${prefix}${connector}${dir.name}/`);
|
|
408
|
+
const items = await dir.list();
|
|
409
|
+
const childPrefix = prefix + (isLast ? " " : "│ ");
|
|
410
|
+
for (let i = 0; i < items.length; i++) {
|
|
411
|
+
const item = items[i];
|
|
412
|
+
const last = i === items.length - 1;
|
|
413
|
+
const childConnector = last ? "└── " : "├── ";
|
|
414
|
+
if (item instanceof Folder) {
|
|
415
|
+
lines.push(`${childPrefix}${childConnector}${item.name}/`);
|
|
416
|
+
await render(item, childPrefix + (last ? " " : "│ "), true);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
lines.push(`${childPrefix}${childConnector}${item.name}`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
await render(this, "", true);
|
|
424
|
+
return lines.join("\n");
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
//# sourceMappingURL=Folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Folder.js","sourceRoot":"","sources":["../../../src/core/file/Folder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;GAEG;A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AAC,MAAM,CAAC,CAAC;YACxD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,MAAM,IAAI,GAAG,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;gBACpC,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC9C,IAAI,IAAI,YAAY,MAAM,EAAE,CAAC;oBAC3B,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,cAAc,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;oBAC3D,MAAM,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;gBACnE,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,cAAc,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QACF,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { File } from "./file/File.js";
|
|
2
|
+
export { Folder } from "./file/Folder.js";
|
|
3
|
+
export { Process, Command, LiveProcess, Result, ProcessError, type ProcessOptions, } from "./process/index.js";
|
|
4
|
+
export { Shell, Job, type ShellConfig, type HistoryItem, type JobOptions, } from "./shell/index.js";
|
|
5
|
+
export { load, get, require } from "./env/index.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,OAAO,EACP,WAAW,EACX,MAAM,EACN,YAAY,EACZ,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,EACL,GAAG,EACH,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { File } from "./file/File.js";
|
|
2
|
+
export { Folder } from "./file/Folder.js";
|
|
3
|
+
export { Process, Command, LiveProcess, Result, ProcessError, } from "./process/index.js";
|
|
4
|
+
export { Shell, Job, } from "./shell/index.js";
|
|
5
|
+
export { load, get, require } from "./env/index.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,OAAO,EACP,WAAW,EACX,MAAM,EACN,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,EACL,GAAG,GAIJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { LiveProcess } from "./LiveProcess.js";
|
|
2
|
+
import { Result } from "./Result.js";
|
|
3
|
+
import type { ProcessOptions } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Builder inmutable para construir un comando antes de ejecutarlo.
|
|
6
|
+
* Permite configurar opciones de forma fluida y luego ejecutar.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Command {
|
|
9
|
+
private readonly _command;
|
|
10
|
+
private readonly _args;
|
|
11
|
+
private readonly _options;
|
|
12
|
+
/**
|
|
13
|
+
* Crea un nuevo `Command`.
|
|
14
|
+
*
|
|
15
|
+
* @param command - Comando a ejecutar.
|
|
16
|
+
* @param args - Argumentos del comando (por defecto, vacío).
|
|
17
|
+
* @param options - Opciones de ejecución (por defecto, vacío).
|
|
18
|
+
*/
|
|
19
|
+
constructor(command: string, args?: readonly string[], options?: ProcessOptions);
|
|
20
|
+
/** Comando a ejecutar. */
|
|
21
|
+
get command(): string;
|
|
22
|
+
/** Argumentos del comando. */
|
|
23
|
+
get args(): readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* Crea una nueva instancia de `Command` con argumentos adicionales
|
|
26
|
+
* añadidos a los existentes.
|
|
27
|
+
*
|
|
28
|
+
* @param args - Argumentos a añadir.
|
|
29
|
+
* @returns Un nuevo `Command` inmutable con los argumentos combinados.
|
|
30
|
+
*/
|
|
31
|
+
withArgs(...args: string[]): Command;
|
|
32
|
+
/**
|
|
33
|
+
* Crea una nueva instancia de `Command` cambiando el directorio de trabajo.
|
|
34
|
+
*
|
|
35
|
+
* @param cwd - Ruta del directorio de trabajo.
|
|
36
|
+
* @returns Un nuevo `Command` inmutable con el `cwd` actualizado.
|
|
37
|
+
*/
|
|
38
|
+
in(cwd: string): Command;
|
|
39
|
+
/**
|
|
40
|
+
* Crea una nueva instancia de `Command` con variables de entorno adicionales,
|
|
41
|
+
* fusionadas con las existentes (o con `process.env` si no se habían definido).
|
|
42
|
+
*
|
|
43
|
+
* @param env - Variables de entorno a añadir o sobrescribir.
|
|
44
|
+
* @returns Un nuevo `Command` inmutable con el entorno actualizado.
|
|
45
|
+
*/
|
|
46
|
+
withEnv(env: Record<string, string>): Command;
|
|
47
|
+
/**
|
|
48
|
+
* Crea una nueva instancia de `Command` con un timeout en milisegundos.
|
|
49
|
+
* Al expirar, el proceso se matará con `SIGTERM`.
|
|
50
|
+
*
|
|
51
|
+
* @param ms - Tiempo máximo de ejecución en milisegundos.
|
|
52
|
+
* @returns Un nuevo `Command` inmutable con el timeout configurado.
|
|
53
|
+
*/
|
|
54
|
+
withTimeout(ms: number): Command;
|
|
55
|
+
/**
|
|
56
|
+
* Crea una nueva instancia de `Command` que envía datos por stdin al iniciar.
|
|
57
|
+
*
|
|
58
|
+
* @param data - Datos a enviar por stdin (texto o buffer).
|
|
59
|
+
* @returns Un nuevo `Command` inmutable con la entrada configurada.
|
|
60
|
+
*/
|
|
61
|
+
withInput(data: string | Buffer): Command;
|
|
62
|
+
/**
|
|
63
|
+
* Crea una nueva instancia de `Command` que lanza un `ProcessError` si el
|
|
64
|
+
* proceso termina con código de salida distinto de 0. Esto hace que
|
|
65
|
+
* `run()` rechace la promesa en lugar de devolver un `Result` fallido.
|
|
66
|
+
*
|
|
67
|
+
* @returns Un nuevo `Command` inmutable con `rejectOnNonZero` activado.
|
|
68
|
+
*/
|
|
69
|
+
throwOnError(): Command;
|
|
70
|
+
/**
|
|
71
|
+
* Inicia el comando y devuelve un `LiveProcess` para interactuar en vivo
|
|
72
|
+
* con stdin/stdout/stderr.
|
|
73
|
+
*
|
|
74
|
+
* @returns Un `LiveProcess` que envuelve el proceso hijo recién iniciado.
|
|
75
|
+
*/
|
|
76
|
+
spawn(): LiveProcess;
|
|
77
|
+
/**
|
|
78
|
+
* Ejecuta el comando, espera a que termine y devuelve el resultado.
|
|
79
|
+
* Si se configuró `throwOnError`, rechaza con `ProcessError` si el código
|
|
80
|
+
* de salida no es 0.
|
|
81
|
+
*
|
|
82
|
+
* @returns El `Result` de la ejecución.
|
|
83
|
+
* @throws {ProcessError} Si `rejectOnNonZero` está activo y el código de salida no es 0.
|
|
84
|
+
*/
|
|
85
|
+
run(): Promise<Result>;
|
|
86
|
+
/**
|
|
87
|
+
* Ejecuta el comando y devuelve solo stdout, con espacios en blanco
|
|
88
|
+
* eliminados de los extremos (trim).
|
|
89
|
+
*
|
|
90
|
+
* @returns El stdout del comando ya trimado.
|
|
91
|
+
*/
|
|
92
|
+
output(): Promise<string>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=Command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../src/core/process/Command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAE1C;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,SAAS,MAAM,EAAO,EAAE,OAAO,GAAE,cAAmB;IAMvF,0BAA0B;IAC1B,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,8BAA8B;IAC9B,IAAI,IAAI,IAAI,SAAS,MAAM,EAAE,CAE5B;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;IAIpC;;;;;OAKG;IACH,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIxB;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO;IAQ7C;;;;;;OAMG;IACH,WAAW,CAAC,EAA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