@procedures/fs 0.0.0-stage → 0.2.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 +25 -0
- package/LICENSE +21 -0
- package/README.md +895 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +22 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +203 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/fs/copy.d.ts +11 -0
- package/dist/procedures/fs/copy.d.ts.map +1 -0
- package/dist/procedures/fs/copy.js +21 -0
- package/dist/procedures/fs/copy.js.map +1 -0
- package/dist/procedures/fs/exists.d.ts +11 -0
- package/dist/procedures/fs/exists.d.ts.map +1 -0
- package/dist/procedures/fs/exists.js +20 -0
- package/dist/procedures/fs/exists.js.map +1 -0
- package/dist/procedures/fs/glob.d.ts +17 -0
- package/dist/procedures/fs/glob.d.ts.map +1 -0
- package/dist/procedures/fs/glob.js +85 -0
- package/dist/procedures/fs/glob.js.map +1 -0
- package/dist/procedures/fs/index.d.ts +12 -0
- package/dist/procedures/fs/index.d.ts.map +1 -0
- package/dist/procedures/fs/index.js +12 -0
- package/dist/procedures/fs/index.js.map +1 -0
- package/dist/procedures/fs/json.d.ts +11 -0
- package/dist/procedures/fs/json.d.ts.map +1 -0
- package/dist/procedures/fs/json.js +16 -0
- package/dist/procedures/fs/json.js.map +1 -0
- package/dist/procedures/fs/mkdir.d.ts +11 -0
- package/dist/procedures/fs/mkdir.d.ts.map +1 -0
- package/dist/procedures/fs/mkdir.js +39 -0
- package/dist/procedures/fs/mkdir.js.map +1 -0
- package/dist/procedures/fs/move.d.ts +11 -0
- package/dist/procedures/fs/move.d.ts.map +1 -0
- package/dist/procedures/fs/move.js +46 -0
- package/dist/procedures/fs/move.js.map +1 -0
- package/dist/procedures/fs/read.d.ts +11 -0
- package/dist/procedures/fs/read.d.ts.map +1 -0
- package/dist/procedures/fs/read.js +21 -0
- package/dist/procedures/fs/read.js.map +1 -0
- package/dist/procedures/fs/readdir.d.ts +11 -0
- package/dist/procedures/fs/readdir.d.ts.map +1 -0
- package/dist/procedures/fs/readdir.js +38 -0
- package/dist/procedures/fs/readdir.js.map +1 -0
- package/dist/procedures/fs/rm.d.ts +11 -0
- package/dist/procedures/fs/rm.d.ts.map +1 -0
- package/dist/procedures/fs/rm.js +30 -0
- package/dist/procedures/fs/rm.js.map +1 -0
- package/dist/procedures/fs/stat.d.ts +11 -0
- package/dist/procedures/fs/stat.d.ts.map +1 -0
- package/dist/procedures/fs/stat.js +29 -0
- package/dist/procedures/fs/stat.js.map +1 -0
- package/dist/procedures/fs/write.d.ts +11 -0
- package/dist/procedures/fs/write.d.ts.map +1 -0
- package/dist/procedures/fs/write.js +24 -0
- package/dist/procedures/fs/write.js.map +1 -0
- package/dist/procedures/fs.d.ts +5 -0
- package/dist/procedures/fs.d.ts.map +1 -0
- package/dist/procedures/fs.js +5 -0
- package/dist/procedures/fs.js.map +1 -0
- package/dist/register.d.ts +7 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +9 -0
- package/dist/register.js.map +1 -0
- package/dist/types.d.ts +187 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +197 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -3
- package/src/index.ts +17 -0
- package/src/module.ts +265 -0
- package/src/procedures/fs/copy.ts +24 -0
- package/src/procedures/fs/exists.ts +20 -0
- package/src/procedures/fs/glob.ts +92 -0
- package/src/procedures/fs/index.ts +11 -0
- package/src/procedures/fs/json.ts +21 -0
- package/src/procedures/fs/mkdir.ts +43 -0
- package/src/procedures/fs/move.ts +47 -0
- package/src/procedures/fs/read.ts +23 -0
- package/src/procedures/fs/readdir.ts +44 -0
- package/src/procedures/fs/rm.ts +31 -0
- package/src/procedures/fs/stat.ts +30 -0
- package/src/procedures/fs/write.ts +27 -0
- package/src/procedures/fs.ts +5 -0
- package/src/register.ts +11 -0
- package/src/types.ts +407 -0
package/dist/module.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module (no side effects): the procedures of this package as data, for `createRegistry()`.
|
|
3
|
+
*
|
|
4
|
+
* Procedure Registration for filesystem operations
|
|
5
|
+
*
|
|
6
|
+
* Registers fs.* procedures with the client system.
|
|
7
|
+
* This file is referenced by package.json's client.procedures field.
|
|
8
|
+
*/
|
|
9
|
+
import { createProcedure, zodAdapter, defineModule, PROCEDURE_REGISTRY, registerModules } from "@procedures/client";
|
|
10
|
+
import { read } from "./procedures/fs/read.js";
|
|
11
|
+
import { write } from "./procedures/fs/write.js";
|
|
12
|
+
import { exists } from "./procedures/fs/exists.js";
|
|
13
|
+
import { mkdir } from "./procedures/fs/mkdir.js";
|
|
14
|
+
import { rm } from "./procedures/fs/rm.js";
|
|
15
|
+
import { readdir } from "./procedures/fs/readdir.js";
|
|
16
|
+
import { stat } from "./procedures/fs/stat.js";
|
|
17
|
+
import { copy } from "./procedures/fs/copy.js";
|
|
18
|
+
import { move } from "./procedures/fs/move.js";
|
|
19
|
+
import { glob } from "./procedures/fs/glob.js";
|
|
20
|
+
import { readJson } from "./procedures/fs/json.js";
|
|
21
|
+
import { ReadInputSchema, WriteInputSchema, ExistsInputSchema, MkdirInputSchema, RmInputSchema, ReaddirInputSchema, StatInputSchema, CopyInputSchema, MoveInputSchema, GlobInputSchema, ReadJsonInputSchema, ReadOutputSchema, WriteOutputSchema, ExistsOutputSchema, MkdirOutputSchema, RmOutputSchema, ReaddirOutputSchema, StatOutputSchema, CopyOutputSchema, MoveOutputSchema, GlobOutputSchema, ReadJsonOutputSchema, } from "./types.js";
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// Procedure Definitions
|
|
24
|
+
// =============================================================================
|
|
25
|
+
/** The effects of a procedure that reads the files of the host and changes nothing. */
|
|
26
|
+
const READS_FILES = { reads: ["fs"], writes: [] };
|
|
27
|
+
const fsReadProcedure = createProcedure()
|
|
28
|
+
.path(["fs", "read"])
|
|
29
|
+
.input(zodAdapter(ReadInputSchema))
|
|
30
|
+
.output(zodAdapter(ReadOutputSchema))
|
|
31
|
+
.meta({
|
|
32
|
+
description: "Read file contents",
|
|
33
|
+
args: ["path"],
|
|
34
|
+
shorts: { encoding: "e" },
|
|
35
|
+
output: "json",
|
|
36
|
+
effects: READS_FILES,
|
|
37
|
+
})
|
|
38
|
+
.handler(read)
|
|
39
|
+
.build();
|
|
40
|
+
const fsWriteProcedure = createProcedure()
|
|
41
|
+
.path(["fs", "write"])
|
|
42
|
+
.input(zodAdapter(WriteInputSchema))
|
|
43
|
+
.output(zodAdapter(WriteOutputSchema))
|
|
44
|
+
.meta({
|
|
45
|
+
description: "Write content to file",
|
|
46
|
+
args: ["path", "content"],
|
|
47
|
+
shorts: { encoding: "e", mode: "m" },
|
|
48
|
+
output: "json",
|
|
49
|
+
// It replaces the file, or appends to it. A second append adds the content again.
|
|
50
|
+
effects: { reads: [], writes: ["fs"] },
|
|
51
|
+
})
|
|
52
|
+
.handler(write)
|
|
53
|
+
.build();
|
|
54
|
+
const fsExistsProcedure = createProcedure()
|
|
55
|
+
.path(["fs", "exists"])
|
|
56
|
+
.input(zodAdapter(ExistsInputSchema))
|
|
57
|
+
.output(zodAdapter(ExistsOutputSchema))
|
|
58
|
+
.meta({
|
|
59
|
+
description: "Check if file or directory exists",
|
|
60
|
+
args: ["path"],
|
|
61
|
+
shorts: {},
|
|
62
|
+
output: "json",
|
|
63
|
+
effects: READS_FILES,
|
|
64
|
+
})
|
|
65
|
+
.handler(exists)
|
|
66
|
+
.build();
|
|
67
|
+
const fsMkdirProcedure = createProcedure()
|
|
68
|
+
.path(["fs", "mkdir"])
|
|
69
|
+
.input(zodAdapter(MkdirInputSchema))
|
|
70
|
+
.output(zodAdapter(MkdirOutputSchema))
|
|
71
|
+
.meta({
|
|
72
|
+
description: "Create directory",
|
|
73
|
+
args: ["path"],
|
|
74
|
+
shorts: { recursive: "r" },
|
|
75
|
+
output: "json",
|
|
76
|
+
// It creates only a missing folder. An existing folder gives `created: false`.
|
|
77
|
+
effects: { reads: ["fs"], writes: ["fs"], destructive: false, idempotent: true },
|
|
78
|
+
})
|
|
79
|
+
.handler(mkdir)
|
|
80
|
+
.build();
|
|
81
|
+
const fsRmProcedure = createProcedure()
|
|
82
|
+
.path(["fs", "rm"])
|
|
83
|
+
.input(zodAdapter(RmInputSchema))
|
|
84
|
+
.output(zodAdapter(RmOutputSchema))
|
|
85
|
+
.meta({
|
|
86
|
+
description: "Remove file or directory",
|
|
87
|
+
args: ["path"],
|
|
88
|
+
shorts: { recursive: "r", force: "f" },
|
|
89
|
+
output: "json",
|
|
90
|
+
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
91
|
+
})
|
|
92
|
+
.handler(rm)
|
|
93
|
+
.build();
|
|
94
|
+
const fsReaddirProcedure = createProcedure()
|
|
95
|
+
.path(["fs", "readdir"])
|
|
96
|
+
.input(zodAdapter(ReaddirInputSchema))
|
|
97
|
+
.output(zodAdapter(ReaddirOutputSchema))
|
|
98
|
+
.meta({
|
|
99
|
+
description: "Read directory contents",
|
|
100
|
+
args: ["path"],
|
|
101
|
+
shorts: { recursive: "r", includeStats: "s" },
|
|
102
|
+
output: "json",
|
|
103
|
+
effects: READS_FILES,
|
|
104
|
+
})
|
|
105
|
+
.handler(readdir)
|
|
106
|
+
.build();
|
|
107
|
+
const fsStatProcedure = createProcedure()
|
|
108
|
+
.path(["fs", "stat"])
|
|
109
|
+
.input(zodAdapter(StatInputSchema))
|
|
110
|
+
.output(zodAdapter(StatOutputSchema))
|
|
111
|
+
.meta({
|
|
112
|
+
description: "Get file or directory stats",
|
|
113
|
+
args: ["path"],
|
|
114
|
+
shorts: {},
|
|
115
|
+
output: "json",
|
|
116
|
+
effects: READS_FILES,
|
|
117
|
+
})
|
|
118
|
+
.handler(stat)
|
|
119
|
+
.build();
|
|
120
|
+
const fsCopyProcedure = createProcedure()
|
|
121
|
+
.path(["fs", "copy"])
|
|
122
|
+
.input(zodAdapter(CopyInputSchema))
|
|
123
|
+
.output(zodAdapter(CopyOutputSchema))
|
|
124
|
+
.meta({
|
|
125
|
+
description: "Copy file or directory",
|
|
126
|
+
args: ["src", "dest"],
|
|
127
|
+
shorts: { recursive: "r", overwrite: "o" },
|
|
128
|
+
output: "json",
|
|
129
|
+
// With `overwrite`, it replaces the files at the destination
|
|
130
|
+
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
131
|
+
})
|
|
132
|
+
.handler(copy)
|
|
133
|
+
.build();
|
|
134
|
+
const fsMoveProcedure = createProcedure()
|
|
135
|
+
.path(["fs", "move"])
|
|
136
|
+
.input(zodAdapter(MoveInputSchema))
|
|
137
|
+
.output(zodAdapter(MoveOutputSchema))
|
|
138
|
+
.meta({
|
|
139
|
+
description: "Move or rename file/directory",
|
|
140
|
+
args: ["src", "dest"],
|
|
141
|
+
shorts: { overwrite: "o" },
|
|
142
|
+
output: "json",
|
|
143
|
+
// With `overwrite`, it replaces the destination. A second call finds no source and changes nothing.
|
|
144
|
+
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
145
|
+
})
|
|
146
|
+
.handler(move)
|
|
147
|
+
.build();
|
|
148
|
+
const fsGlobProcedure = createProcedure()
|
|
149
|
+
.path(["fs", "glob"])
|
|
150
|
+
.input(zodAdapter(GlobInputSchema))
|
|
151
|
+
.output(zodAdapter(GlobOutputSchema))
|
|
152
|
+
.meta({
|
|
153
|
+
description: "Find files matching glob pattern",
|
|
154
|
+
args: ["pattern"],
|
|
155
|
+
shorts: { cwd: "c", absolute: "a", dot: "d" },
|
|
156
|
+
output: "json",
|
|
157
|
+
effects: READS_FILES,
|
|
158
|
+
})
|
|
159
|
+
.handler(glob)
|
|
160
|
+
.build();
|
|
161
|
+
const fsReadJsonProcedure = createProcedure()
|
|
162
|
+
.path(["fs", "read.json"])
|
|
163
|
+
.input(zodAdapter(ReadJsonInputSchema))
|
|
164
|
+
.output(zodAdapter(ReadJsonOutputSchema))
|
|
165
|
+
.meta({
|
|
166
|
+
description: "Read and parse JSON file",
|
|
167
|
+
args: ["path"],
|
|
168
|
+
shorts: {},
|
|
169
|
+
output: "json",
|
|
170
|
+
effects: READS_FILES,
|
|
171
|
+
})
|
|
172
|
+
.handler(readJson)
|
|
173
|
+
.build();
|
|
174
|
+
// =============================================================================
|
|
175
|
+
// Registration
|
|
176
|
+
// =============================================================================
|
|
177
|
+
/**
|
|
178
|
+
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
179
|
+
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
180
|
+
*/
|
|
181
|
+
export const fsModule = defineModule("@procedures/fs", [
|
|
182
|
+
fsReadProcedure,
|
|
183
|
+
fsWriteProcedure,
|
|
184
|
+
fsExistsProcedure,
|
|
185
|
+
fsMkdirProcedure,
|
|
186
|
+
fsRmProcedure,
|
|
187
|
+
fsReaddirProcedure,
|
|
188
|
+
fsStatProcedure,
|
|
189
|
+
fsCopyProcedure,
|
|
190
|
+
fsMoveProcedure,
|
|
191
|
+
fsGlobProcedure,
|
|
192
|
+
fsReadJsonProcedure,
|
|
193
|
+
]);
|
|
194
|
+
export default fsModule;
|
|
195
|
+
/**
|
|
196
|
+
* This function registers the procedures of @procedures/fs, and of the modules that it requires, in
|
|
197
|
+
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
198
|
+
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
199
|
+
*/
|
|
200
|
+
export function registerFsProcedures(registry = PROCEDURE_REGISTRY) {
|
|
201
|
+
registerModules(registry, [fsModule]);
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO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EAAE;KAC1C,IAAI,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;KACzB,KAAK,CAAC,UAAU,CAAgB,mBAAmB,CAAC,CAAC;KACrD,MAAM,CAAC,UAAU,CAAiB,oBAAoB,CAAC,CAAC;KACxD,IAAI,CAAC;IACJ,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,WAAW;CACrB,CAAC;KACD,OAAO,CAAC,QAAQ,CAAC;KACjB,KAAK,EAAE,CAAC;AAEX,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoB,YAAY,CAAC,gBAAgB,EAAE;IACpE,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,aAAa;IACb,kBAAkB;IAClB,eAAe;IACf,eAAe;IACf,eAAe;IACf,eAAe;IACf,mBAAmB;CACpB,CAAC,CAAC;AAEL,eAAe,QAAQ,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAQ,GAAsB,kBAAkB;IACnF,eAAe,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* copy procedure
|
|
3
|
+
*
|
|
4
|
+
* Copy file or directory
|
|
5
|
+
*/
|
|
6
|
+
import type { CopyInput, CopyOutput } from "../../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Copy file or directory
|
|
9
|
+
*/
|
|
10
|
+
export declare function copy(input: CopyInput): Promise<CopyOutput>;
|
|
11
|
+
//# sourceMappingURL=copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/copy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5D;;GAEG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAWhE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* copy procedure
|
|
3
|
+
*
|
|
4
|
+
* Copy file or directory
|
|
5
|
+
*/
|
|
6
|
+
import { copyFile, cp, constants } from "node:fs/promises";
|
|
7
|
+
/**
|
|
8
|
+
* Copy file or directory
|
|
9
|
+
*/
|
|
10
|
+
export async function copy(input) {
|
|
11
|
+
const { src, dest, recursive, overwrite } = input;
|
|
12
|
+
const flags = overwrite ? 0 : constants.COPYFILE_EXCL;
|
|
13
|
+
if (recursive) {
|
|
14
|
+
await cp(src, dest, { recursive, force: overwrite });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
await copyFile(src, dest, flags);
|
|
18
|
+
}
|
|
19
|
+
return { src, dest };
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../../src/procedures/fs/copy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,KAAgB;IACzC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC;IAEtD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exists procedure
|
|
3
|
+
*
|
|
4
|
+
* Check if file or directory exists
|
|
5
|
+
*/
|
|
6
|
+
import { type ExistsInput, type ExistsOutput } from "../../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Check if file or directory exists
|
|
9
|
+
*/
|
|
10
|
+
export declare function exists(input: ExistsInput): Promise<ExistsOutput>;
|
|
11
|
+
//# sourceMappingURL=exists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/exists.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGrE;;GAEG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAOtE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exists procedure
|
|
3
|
+
*
|
|
4
|
+
* Check if file or directory exists
|
|
5
|
+
*/
|
|
6
|
+
import {} from "../../types.js";
|
|
7
|
+
import { stat } from "./stat.js";
|
|
8
|
+
/**
|
|
9
|
+
* Check if file or directory exists
|
|
10
|
+
*/
|
|
11
|
+
export async function exists(input) {
|
|
12
|
+
try {
|
|
13
|
+
const stats = await stat(input);
|
|
14
|
+
return { exists: true, stats };
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return { exists: false };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=exists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exists.js","sourceRoot":"","sources":["../../../src/procedures/fs/exists.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAuC,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAkB;IAC7C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* glob procedure
|
|
3
|
+
*
|
|
4
|
+
* Find files matching glob pattern
|
|
5
|
+
*
|
|
6
|
+
* The matches are relative to `cwd` (or absolute with `absolute: true`), with "/" separators.
|
|
7
|
+
* `ignore` removes the matches of its patterns and does not enter the folders that they match.
|
|
8
|
+
*
|
|
9
|
+
* Before, `ignore` was stripped by the input schema, and `absolute` and `dot` had no effect:
|
|
10
|
+
* `node:fs` glob has no such options (deep dive DATA-7).
|
|
11
|
+
*/
|
|
12
|
+
import type { GlobInput, GlobOutput } from "../../types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Find files matching glob pattern
|
|
15
|
+
*/
|
|
16
|
+
export declare function glob(input: GlobInput): Promise<GlobOutput>;
|
|
17
|
+
//# sourceMappingURL=glob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAqD5D;;GAEG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAqBhE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* glob procedure
|
|
3
|
+
*
|
|
4
|
+
* Find files matching glob pattern
|
|
5
|
+
*
|
|
6
|
+
* The matches are relative to `cwd` (or absolute with `absolute: true`), with "/" separators.
|
|
7
|
+
* `ignore` removes the matches of its patterns and does not enter the folders that they match.
|
|
8
|
+
*
|
|
9
|
+
* Before, `ignore` was stripped by the input schema, and `absolute` and `dot` had no effect:
|
|
10
|
+
* `node:fs` glob has no such options (deep dive DATA-7).
|
|
11
|
+
*/
|
|
12
|
+
import { glob as nodeGlob, readdir } from "node:fs/promises";
|
|
13
|
+
import { posix, resolve } from "node:path";
|
|
14
|
+
// A character that a file name cannot hold. It takes the place of a leading "." of a name, so
|
|
15
|
+
// that "*" and "**" match dot entries when `dot` is true.
|
|
16
|
+
const DOT = "\u0001";
|
|
17
|
+
/** "a\\b" (Windows) becomes "a/b". */
|
|
18
|
+
function toPosix(path) {
|
|
19
|
+
return path.split("\\").join("/");
|
|
20
|
+
}
|
|
21
|
+
/** Each name of the path that starts with "." starts with DOT instead. */
|
|
22
|
+
function hideDots(path) {
|
|
23
|
+
return path
|
|
24
|
+
.split("/")
|
|
25
|
+
.map((name) => (name.startsWith(".") && name !== "." && name !== ".." ? DOT + name.slice(1) : name))
|
|
26
|
+
.join("/");
|
|
27
|
+
}
|
|
28
|
+
function ignored(path, ignore) {
|
|
29
|
+
return ignore.some((pattern) => posix.matchesGlob(path, pattern));
|
|
30
|
+
}
|
|
31
|
+
/** A folder is not entered when each path inside it is ignored. */
|
|
32
|
+
function folderIgnored(path, ignore) {
|
|
33
|
+
return ignored(`${path}/${DOT}`, ignore) || ignored(path, ignore);
|
|
34
|
+
}
|
|
35
|
+
/** All the matches of `pattern` under `root`, dot entries included. */
|
|
36
|
+
async function walkWithDots(root, pattern, ignore) {
|
|
37
|
+
const hiddenPattern = hideDots(pattern);
|
|
38
|
+
const hiddenIgnore = ignore.map(hideDots);
|
|
39
|
+
const matches = [];
|
|
40
|
+
async function visit(relative) {
|
|
41
|
+
const entries = await readdir(relative ? resolve(root, relative) : root, { withFileTypes: true });
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const path = relative ? `${relative}/${entry.name}` : entry.name;
|
|
44
|
+
const hidden = hideDots(path);
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
if (folderIgnored(hidden, hiddenIgnore))
|
|
47
|
+
continue;
|
|
48
|
+
if (posix.matchesGlob(hidden, hiddenPattern))
|
|
49
|
+
matches.push(path);
|
|
50
|
+
await visit(path);
|
|
51
|
+
}
|
|
52
|
+
else if (posix.matchesGlob(hidden, hiddenPattern) && !ignored(hidden, hiddenIgnore)) {
|
|
53
|
+
matches.push(path);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
await visit("");
|
|
58
|
+
return matches;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Find files matching glob pattern
|
|
62
|
+
*/
|
|
63
|
+
export async function glob(input) {
|
|
64
|
+
const { pattern, absolute, dot } = input;
|
|
65
|
+
const ignore = input.ignore ?? [];
|
|
66
|
+
const root = resolve(input.cwd ?? process.cwd());
|
|
67
|
+
let relative;
|
|
68
|
+
if (dot) {
|
|
69
|
+
relative = await walkWithDots(root, toPosix(pattern), ignore);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
relative = [];
|
|
73
|
+
for await (const match of nodeGlob(pattern, { cwd: root, exclude: [...ignore] })) {
|
|
74
|
+
const path = toPosix(match);
|
|
75
|
+
// The exclude list of node:fs prunes folders. This check also covers the Node versions
|
|
76
|
+
// that ignore it.
|
|
77
|
+
if (!ignored(path, ignore))
|
|
78
|
+
relative.push(path);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
relative.sort();
|
|
82
|
+
const matches = absolute ? relative.map((path) => resolve(root, path)) : relative;
|
|
83
|
+
return { pattern, matches };
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/procedures/fs/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG3C,8FAA8F;AAC9F,0DAA0D;AAC1D,MAAM,GAAG,GAAG,QAAQ,CAAC;AAErB,sCAAsC;AACtC,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,0EAA0E;AAC1E,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACnG,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,MAAyB;IACtD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,mEAAmE;AACnE,SAAS,aAAa,CAAC,IAAY,EAAE,MAAy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IAClF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { read } from "./read.js";
|
|
2
|
+
export { write } from "./write.js";
|
|
3
|
+
export { exists } from "./exists.js";
|
|
4
|
+
export { mkdir } from "./mkdir.js";
|
|
5
|
+
export { rm } from "./rm.js";
|
|
6
|
+
export { readdir } from "./readdir.js";
|
|
7
|
+
export { stat } from "./stat.js";
|
|
8
|
+
export { copy } from "./copy.js";
|
|
9
|
+
export { move } from "./move.js";
|
|
10
|
+
export { glob } from "./glob.js";
|
|
11
|
+
export { readJson } from "./json.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { read } from "./read.js";
|
|
2
|
+
export { write } from "./write.js";
|
|
3
|
+
export { exists } from "./exists.js";
|
|
4
|
+
export { mkdir } from "./mkdir.js";
|
|
5
|
+
export { rm } from "./rm.js";
|
|
6
|
+
export { readdir } from "./readdir.js";
|
|
7
|
+
export { stat } from "./stat.js";
|
|
8
|
+
export { copy } from "./copy.js";
|
|
9
|
+
export { move } from "./move.js";
|
|
10
|
+
export { glob } from "./glob.js";
|
|
11
|
+
export { readJson } from "./json.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/fs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* read.json procedure
|
|
3
|
+
*
|
|
4
|
+
* Read and parse JSON file
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadJsonInput, ReadJsonOutput } from "../../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Read and parse JSON file
|
|
9
|
+
*/
|
|
10
|
+
export declare function readJson(input: ReadJsonInput): Promise<ReadJsonOutput>;
|
|
11
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGpE;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAQ5E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* read.json procedure
|
|
3
|
+
*
|
|
4
|
+
* Read and parse JSON file
|
|
5
|
+
*/
|
|
6
|
+
import { read } from "./read.js";
|
|
7
|
+
/**
|
|
8
|
+
* Read and parse JSON file
|
|
9
|
+
*/
|
|
10
|
+
export async function readJson(input) {
|
|
11
|
+
const { path } = input;
|
|
12
|
+
const { content, stats } = await read({ path, encoding: 'utf8' });
|
|
13
|
+
const data = JSON.parse(content);
|
|
14
|
+
return { path, data, stats };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/procedures/fs/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAoB;IACjD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,MAAM,EACJ,OAAO,EACP,KAAK,EACN,GAAG,MAAM,IAAI,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAG,MAAM,EAAC,CAAC,CAAA;IACzC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mkdir procedure
|
|
3
|
+
*
|
|
4
|
+
* Create directory
|
|
5
|
+
*/
|
|
6
|
+
import { type MkdirInput, type MkdirOutput } from "../../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Create directory
|
|
9
|
+
*/
|
|
10
|
+
export declare function mkdir(input: MkdirInput): Promise<MkdirOutput>;
|
|
11
|
+
//# sourceMappingURL=mkdir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mkdir.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/mkdir.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAY,KAAK,UAAU,EAAE,KAAK,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAG9F;;GAEG;AACH,wBAAsB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CA6BnE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mkdir procedure
|
|
3
|
+
*
|
|
4
|
+
* Create directory
|
|
5
|
+
*/
|
|
6
|
+
import { mkdir as fsMkdir } from "node:fs/promises";
|
|
7
|
+
import { FileType } from "../../types.js";
|
|
8
|
+
import { stat } from "./stat.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create directory
|
|
11
|
+
*/
|
|
12
|
+
export async function mkdir(input) {
|
|
13
|
+
const { path, recursive } = input;
|
|
14
|
+
// Probe the existing path. Only a genuine "not found" (ENOENT) means we
|
|
15
|
+
// should proceed to create it; any other stat error (e.g. EACCES) must
|
|
16
|
+
// propagate rather than being masked by an mkdir attempt.
|
|
17
|
+
let existing;
|
|
18
|
+
try {
|
|
19
|
+
existing = await stat(input);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (err.code !== "ENOENT")
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
if (existing) {
|
|
26
|
+
// The path already exists. It's only a no-op success if it's a directory;
|
|
27
|
+
// an existing file (or other non-directory) is a real conflict, not a
|
|
28
|
+
// silently-"already created" directory.
|
|
29
|
+
if (existing.type === FileType.Directory) {
|
|
30
|
+
return { path, created: false };
|
|
31
|
+
}
|
|
32
|
+
const conflict = new Error(`Cannot create directory: path already exists and is not a directory: ${path}`);
|
|
33
|
+
conflict.code = "EEXIST";
|
|
34
|
+
throw conflict;
|
|
35
|
+
}
|
|
36
|
+
await fsMkdir(path, { recursive });
|
|
37
|
+
return { path, created: true };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=mkdir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mkdir.js","sourceRoot":"","sources":["../../../src/procedures/fs/mkdir.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAsD,MAAM,gBAAgB,CAAC;AAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,KAAiB;IAC3C,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAElC,wEAAwE;IACxE,uEAAuE;IACvE,0DAA0D;IAC1D,IAAI,QAAgC,CAAC;IACrC,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,GAAG,CAAC;IAClE,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,0EAA0E;QAC1E,sEAAsE;QACtE,wCAAwC;QACxC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,SAAS,EAAE,CAAC;YACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAClC,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,KAAK,CACxB,wEAAwE,IAAI,EAAE,CACtD,CAAC;QAC3B,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC;QACzB,MAAM,QAAQ,CAAC;IACjB,CAAC;IAED,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACnC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* move procedure
|
|
3
|
+
*
|
|
4
|
+
* Move or rename file/directory
|
|
5
|
+
*/
|
|
6
|
+
import type { MoveInput, MoveOutput } from "../../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Move or rename file/directory
|
|
9
|
+
*/
|
|
10
|
+
export declare function move(input: MoveInput): Promise<MoveOutput>;
|
|
11
|
+
//# sourceMappingURL=move.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/move.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5D;;GAEG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAgChE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* move procedure
|
|
3
|
+
*
|
|
4
|
+
* Move or rename file/directory
|
|
5
|
+
*/
|
|
6
|
+
import { cp, rename } from "node:fs/promises";
|
|
7
|
+
import { stat } from "./stat.js";
|
|
8
|
+
import { rm } from "./rm.js";
|
|
9
|
+
/**
|
|
10
|
+
* Move or rename file/directory
|
|
11
|
+
*/
|
|
12
|
+
export async function move(input) {
|
|
13
|
+
const { src, dest, overwrite } = input;
|
|
14
|
+
if (!overwrite) {
|
|
15
|
+
try {
|
|
16
|
+
await stat({ path: dest });
|
|
17
|
+
throw new Error(`Destination already exists: ${dest}`);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err.code !== "ENOENT")
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
await rename(src, dest);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err.code === "EXDEV") {
|
|
29
|
+
// Cross-device move: copy then delete the source. When not overwriting,
|
|
30
|
+
// use errorOnExist so an already-present destination throws instead of
|
|
31
|
+
// being silently skipped by `cp` — otherwise the subsequent removal of
|
|
32
|
+
// `src` would lose the files that were never copied over.
|
|
33
|
+
await cp(src, dest, {
|
|
34
|
+
recursive: true,
|
|
35
|
+
force: overwrite,
|
|
36
|
+
errorOnExist: !overwrite,
|
|
37
|
+
});
|
|
38
|
+
await rm({ path: src, recursive: true, force: false });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { src, dest };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=move.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move.js","sourceRoot":"","sources":["../../../src/procedures/fs/move.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,KAAgB;IACzC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAEvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,EAAC,IAAI,EAAG,IAAI,EAAC,CAAC,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;gBAAE,MAAM,GAAG,CAAC;QAClE,CAAC;IACH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACpD,wEAAwE;YACxE,uEAAuE;YACvE,uEAAuE;YACvE,0DAA0D;YAC1D,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE;gBAClB,SAAS,EAAE,IAAI;gBACf,KAAK,EAAE,SAAS;gBAChB,YAAY,EAAE,CAAC,SAAS;aACzB,CAAC,CAAC;YACH,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* read procedure
|
|
3
|
+
*
|
|
4
|
+
* Read file contents
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadInput, ReadOutput } from "../../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Read file contents
|
|
9
|
+
*/
|
|
10
|
+
export declare function read(input: ReadInput): Promise<ReadOutput>;
|
|
11
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/read.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5D;;GAEG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAShE"}
|