@procedures/fs 0.2.2 → 0.3.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 +52 -0
- package/README.md +73 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/handlers.d.ts +40 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +163 -0
- package/dist/handlers.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +23 -2
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +94 -3
- package/dist/module.js.map +1 -1
- package/dist/procedures/fs/hash.d.ts +12 -0
- package/dist/procedures/fs/hash.d.ts.map +1 -0
- package/dist/procedures/fs/hash.js +23 -0
- package/dist/procedures/fs/hash.js.map +1 -0
- package/dist/procedures/fs/index.d.ts +4 -0
- package/dist/procedures/fs/index.d.ts.map +1 -1
- package/dist/procedures/fs/index.js +4 -0
- package/dist/procedures/fs/index.js.map +1 -1
- package/dist/procedures/fs/temp.d.ts +14 -0
- package/dist/procedures/fs/temp.d.ts.map +1 -0
- package/dist/procedures/fs/temp.js +20 -0
- package/dist/procedures/fs/temp.js.map +1 -0
- package/dist/procedures/fs/watch.d.ts +14 -0
- package/dist/procedures/fs/watch.d.ts.map +1 -0
- package/dist/procedures/fs/watch.js +26 -0
- package/dist/procedures/fs/watch.js.map +1 -0
- package/dist/procedures/fs/write-json.d.ts +12 -0
- package/dist/procedures/fs/write-json.d.ts.map +1 -0
- package/dist/procedures/fs/write-json.js +33 -0
- package/dist/procedures/fs/write-json.js.map +1 -0
- package/dist/root.d.ts +52 -0
- package/dist/root.d.ts.map +1 -0
- package/dist/root.js +129 -0
- package/dist/root.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +37 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/handlers.ts +214 -0
- package/src/index.ts +2 -0
- package/src/module.ts +127 -4
- package/src/procedures/fs/hash.ts +25 -0
- package/src/procedures/fs/index.ts +4 -0
- package/src/procedures/fs/temp.ts +22 -0
- package/src/procedures/fs/watch.ts +26 -0
- package/src/procedures/fs/write-json.ts +32 -0
- package/src/root.ts +139 -0
- package/src/types.ts +106 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The handlers of the file procedures with a root (roadmap R33).
|
|
3
|
+
*
|
|
4
|
+
* `fsModule` has the plain handlers: they operate on each path. `createFsModule({ root })`
|
|
5
|
+
* replaces each handler with the handler of `rootedHandlers(root)`. That handler sends the paths
|
|
6
|
+
* of its input through `inRoot()`, then starts the plain handler with the absolute path.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReadInput, ReadOutput, WriteInput, WriteOutput, ExistsInput, ExistsOutput, MkdirInput, MkdirOutput, RmInput, RmOutput, ReaddirInput, ReaddirOutput, StatInput, StatOutput, CopyInput, CopyOutput, MoveInput, MoveOutput, GlobInput, GlobOutput, ReadJsonInput, ReadJsonOutput, FsWriteJsonInput, FsWriteJsonOutput, FsHashInput, FsHashOutput, FsTempInput, FsTempOutput, FsWatchInput, FsWatchOutput } from "./types.js";
|
|
9
|
+
/** One handler for each file procedure. */
|
|
10
|
+
export interface FsHandlers {
|
|
11
|
+
read: (input: ReadInput) => Promise<ReadOutput>;
|
|
12
|
+
write: (input: WriteInput) => Promise<WriteOutput>;
|
|
13
|
+
exists: (input: ExistsInput) => Promise<ExistsOutput>;
|
|
14
|
+
mkdir: (input: MkdirInput) => Promise<MkdirOutput>;
|
|
15
|
+
rm: (input: RmInput) => Promise<RmOutput>;
|
|
16
|
+
readdir: (input: ReaddirInput) => Promise<ReaddirOutput>;
|
|
17
|
+
stat: (input: StatInput) => Promise<StatOutput>;
|
|
18
|
+
copy: (input: CopyInput) => Promise<CopyOutput>;
|
|
19
|
+
move: (input: MoveInput) => Promise<MoveOutput>;
|
|
20
|
+
glob: (input: GlobInput) => Promise<GlobOutput>;
|
|
21
|
+
readJson: (input: ReadJsonInput) => Promise<ReadJsonOutput>;
|
|
22
|
+
writeJson: (input: FsWriteJsonInput) => Promise<FsWriteJsonOutput>;
|
|
23
|
+
hash: (input: FsHashInput) => Promise<FsHashOutput>;
|
|
24
|
+
temp: (input: FsTempInput) => Promise<FsTempOutput>;
|
|
25
|
+
watch: (input: FsWatchInput, ctx?: {
|
|
26
|
+
signal?: AbortSignal | undefined;
|
|
27
|
+
}) => AsyncGenerator<FsWatchOutput, void, undefined>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The name of the handler of each procedure, by the key of the procedure. `createFsModule()`
|
|
31
|
+
* refuses a procedure that is not in this list, so a new procedure cannot skip the root.
|
|
32
|
+
*/
|
|
33
|
+
export declare const HANDLER_NAMES: Readonly<Record<string, keyof FsHandlers>>;
|
|
34
|
+
/**
|
|
35
|
+
* This function gives the handlers that confine each path to `root`. The root is resolved
|
|
36
|
+
* against the working folder of the process when the function starts. It must exist when a
|
|
37
|
+
* procedure starts.
|
|
38
|
+
*/
|
|
39
|
+
export declare function rootedHandlers(root: string): FsHandlers;
|
|
40
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EAC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EAAE,GAAG,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;KAAE,KAAK,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;CAC5H;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,UAAU,CAAC,CAgBpE,CAAC;AAaF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAgGvD"}
|
package/dist/handlers.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The handlers of the file procedures with a root (roadmap R33).
|
|
3
|
+
*
|
|
4
|
+
* `fsModule` has the plain handlers: they operate on each path. `createFsModule({ root })`
|
|
5
|
+
* replaces each handler with the handler of `rootedHandlers(root)`. That handler sends the paths
|
|
6
|
+
* of its input through `inRoot()`, then starts the plain handler with the absolute path.
|
|
7
|
+
*/
|
|
8
|
+
import { platform } from "node:process";
|
|
9
|
+
import { isAbsolute, resolve } from "node:path";
|
|
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 { fsWriteJson } from "./procedures/fs/write-json.js";
|
|
22
|
+
import { fsHash } from "./procedures/fs/hash.js";
|
|
23
|
+
import { fsTemp } from "./procedures/fs/temp.js";
|
|
24
|
+
import { fsWatch } from "./procedures/fs/watch.js";
|
|
25
|
+
import { inRoot, isOutsideRoot, outsideRoot, realPathIsInside, resolveRoot } from "./root.js";
|
|
26
|
+
/**
|
|
27
|
+
* The name of the handler of each procedure, by the key of the procedure. `createFsModule()`
|
|
28
|
+
* refuses a procedure that is not in this list, so a new procedure cannot skip the root.
|
|
29
|
+
*/
|
|
30
|
+
export const HANDLER_NAMES = {
|
|
31
|
+
"fs.read": "read",
|
|
32
|
+
"fs.write": "write",
|
|
33
|
+
"fs.exists": "exists",
|
|
34
|
+
"fs.mkdir": "mkdir",
|
|
35
|
+
"fs.rm": "rm",
|
|
36
|
+
"fs.readdir": "readdir",
|
|
37
|
+
"fs.stat": "stat",
|
|
38
|
+
"fs.copy": "copy",
|
|
39
|
+
"fs.move": "move",
|
|
40
|
+
"fs.glob": "glob",
|
|
41
|
+
"fs.read.json": "readJson",
|
|
42
|
+
"fs.write.json": "writeJson",
|
|
43
|
+
"fs.hash": "hash",
|
|
44
|
+
"fs.temp": "temp",
|
|
45
|
+
"fs.watch": "watch",
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* True for a glob pattern that can match outside its folder: an absolute pattern, a pattern that
|
|
49
|
+
* goes up with `..` (also in a brace or a group), or a pattern that starts with a drive on Windows.
|
|
50
|
+
* The handler also removes each match outside the root, so this check only gives a clear error.
|
|
51
|
+
*/
|
|
52
|
+
function patternLeavesFolder(pattern) {
|
|
53
|
+
if (isAbsolute(pattern) || pattern.startsWith("/") || pattern.startsWith("\\"))
|
|
54
|
+
return true;
|
|
55
|
+
if (platform === "win32" && /^[a-zA-Z]:/.test(pattern))
|
|
56
|
+
return true;
|
|
57
|
+
return pattern.split(/[\\/{},()|]/).includes("..");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* This function gives the handlers that confine each path to `root`. The root is resolved
|
|
61
|
+
* against the working folder of the process when the function starts. It must exist when a
|
|
62
|
+
* procedure starts.
|
|
63
|
+
*/
|
|
64
|
+
export function rootedHandlers(root) {
|
|
65
|
+
const folder = resolve(root);
|
|
66
|
+
/** The root of one call (its real path can change between two calls), and the check of its paths. */
|
|
67
|
+
const check = async (procedure) => {
|
|
68
|
+
const resolved = await resolveRoot(folder);
|
|
69
|
+
const at = ["fs", procedure];
|
|
70
|
+
return { root: resolved, inside: (path) => inRoot(resolved, path, at) };
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
read: async (input) => {
|
|
74
|
+
const { inside } = await check("read");
|
|
75
|
+
return read({ ...input, path: await inside(input.path) });
|
|
76
|
+
},
|
|
77
|
+
write: async (input) => {
|
|
78
|
+
const { inside } = await check("write");
|
|
79
|
+
return write({ ...input, path: await inside(input.path) });
|
|
80
|
+
},
|
|
81
|
+
exists: async (input) => {
|
|
82
|
+
const { inside } = await check("exists");
|
|
83
|
+
return exists({ ...input, path: await inside(input.path) });
|
|
84
|
+
},
|
|
85
|
+
mkdir: async (input) => {
|
|
86
|
+
const { inside } = await check("mkdir");
|
|
87
|
+
return mkdir({ ...input, path: await inside(input.path) });
|
|
88
|
+
},
|
|
89
|
+
rm: async (input) => {
|
|
90
|
+
const { inside } = await check("rm");
|
|
91
|
+
return rm({ ...input, path: await inside(input.path) });
|
|
92
|
+
},
|
|
93
|
+
stat: async (input) => {
|
|
94
|
+
const { inside } = await check("stat");
|
|
95
|
+
return stat({ ...input, path: await inside(input.path) });
|
|
96
|
+
},
|
|
97
|
+
readJson: async (input) => {
|
|
98
|
+
const { inside } = await check("read.json");
|
|
99
|
+
return readJson({ ...input, path: await inside(input.path) });
|
|
100
|
+
},
|
|
101
|
+
writeJson: async (input) => {
|
|
102
|
+
const { inside } = await check("write.json");
|
|
103
|
+
return fsWriteJson({ ...input, path: await inside(input.path) });
|
|
104
|
+
},
|
|
105
|
+
hash: async (input) => {
|
|
106
|
+
const { inside } = await check("hash");
|
|
107
|
+
return fsHash({ ...input, path: await inside(input.path) });
|
|
108
|
+
},
|
|
109
|
+
// The temporary folders of a root are in its folder .tmp, so they stay inside the root
|
|
110
|
+
temp: async (input) => {
|
|
111
|
+
const { inside } = await check("temp");
|
|
112
|
+
return fsTemp(input, await inside(".tmp"));
|
|
113
|
+
},
|
|
114
|
+
watch: async function* (input, ctx) {
|
|
115
|
+
const { inside } = await check("watch");
|
|
116
|
+
yield* fsWatch({ ...input, path: await inside(input.path) }, ctx?.signal);
|
|
117
|
+
},
|
|
118
|
+
copy: async (input) => {
|
|
119
|
+
const { inside } = await check("copy");
|
|
120
|
+
return copy({ ...input, src: await inside(input.src), dest: await inside(input.dest) });
|
|
121
|
+
},
|
|
122
|
+
move: async (input) => {
|
|
123
|
+
const { inside } = await check("move");
|
|
124
|
+
return move({ ...input, src: await inside(input.src), dest: await inside(input.dest) });
|
|
125
|
+
},
|
|
126
|
+
readdir: async (input) => {
|
|
127
|
+
const { inside } = await check("readdir");
|
|
128
|
+
// The stats of an entry follow a symlink: an entry whose target is outside the root gets no stats
|
|
129
|
+
const result = await readdir({ ...input, path: await inside(input.path), includeStats: false });
|
|
130
|
+
if (input.includeStats) {
|
|
131
|
+
for (const entry of result.entries) {
|
|
132
|
+
try {
|
|
133
|
+
await inside(entry.path);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (isOutsideRoot(error))
|
|
137
|
+
continue;
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
entry.stats = await stat({ path: entry.path });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
},
|
|
145
|
+
glob: async (input) => {
|
|
146
|
+
const { root: resolved, inside } = await check("glob");
|
|
147
|
+
const cwd = await inside(input.cwd ?? ".");
|
|
148
|
+
if (patternLeavesFolder(input.pattern)) {
|
|
149
|
+
throw outsideRoot(["fs", "glob"], `the pattern ${JSON.stringify(input.pattern)} can match outside the folder ${cwd}`);
|
|
150
|
+
}
|
|
151
|
+
// A match through a symlink whose target is outside the root is left out
|
|
152
|
+
const found = await glob({ ...input, cwd, absolute: false });
|
|
153
|
+
const matches = [];
|
|
154
|
+
for (const match of found.matches) {
|
|
155
|
+
const absolute = resolve(cwd, match);
|
|
156
|
+
if (await realPathIsInside(resolved, absolute))
|
|
157
|
+
matches.push(input.absolute ? absolute : match);
|
|
158
|
+
}
|
|
159
|
+
return { pattern: input.pattern, matches };
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,E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,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7D,MAAM,OAAO,GAAa,EAAE,CAAC;YAC7B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrC,IAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC;oBAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAClG,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,iDAAiD;AACjD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/module.d.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Registers fs.* procedures with the client system.
|
|
7
7
|
* This file is referenced by package.json's client.procedures field.
|
|
8
|
+
*
|
|
9
|
+
* `fsModule` operates on each path. `createFsModule({ root })` gives the same procedures, and
|
|
10
|
+
* each path of their input must be in the root (roadmap R33, `root.ts`).
|
|
8
11
|
*/
|
|
9
12
|
import { type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
|
|
10
13
|
/**
|
|
@@ -13,10 +16,28 @@ import { type ProcedureModule, type ProcedureRegistry } from "@procedures/client
|
|
|
13
16
|
*/
|
|
14
17
|
export declare const fsModule: ProcedureModule;
|
|
15
18
|
export default fsModule;
|
|
19
|
+
/** The options of `createFsModule()`. */
|
|
20
|
+
export interface FsModuleOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The folder that confines each path of the procedures (roadmap R33). A relative path of an
|
|
23
|
+
* input starts at the root. A path outside the root gives `FORBIDDEN` with the reason
|
|
24
|
+
* `outside-root`. A relative root starts at the working folder of the process. Without a root,
|
|
25
|
+
* the procedures operate on each path, as `fsModule` does.
|
|
26
|
+
*/
|
|
27
|
+
root?: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This function gives the module of this package. Without `root`, it gives `fsModule`. With
|
|
31
|
+
* `root`, it gives a module with the same name and procedures, whose handlers confine each path
|
|
32
|
+
* of the input to the root. A host gives it to `createRegistry()` before its bundles, so it
|
|
33
|
+
* replaces the `fsModule` that the bundles require (the first module of a name counts).
|
|
34
|
+
*/
|
|
35
|
+
export declare function createFsModule(options?: FsModuleOptions): ProcedureModule;
|
|
16
36
|
/**
|
|
17
37
|
* This function registers the procedures of @procedures/fs, and of the modules that it requires, in
|
|
18
38
|
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
19
|
-
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
39
|
+
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9). With
|
|
40
|
+
* `options.root`, each path of an input must be in the root.
|
|
20
41
|
*/
|
|
21
|
-
export declare function registerFsProcedures(registry?: ProcedureRegistry): void;
|
|
42
|
+
export declare function registerFsProcedures(registry?: ProcedureRegistry, options?: FsModuleOptions): void;
|
|
22
43
|
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA8E,KAAK,eAAe,EAAuC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAyTnM;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,eAgBnB,CAAC;eAEU,QAAQ;AAEvB,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,eAAe,CAW7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,iBAAsC,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAE1H"}
|
package/dist/module.js
CHANGED
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Registers fs.* procedures with the client system.
|
|
7
7
|
* This file is referenced by package.json's client.procedures field.
|
|
8
|
+
*
|
|
9
|
+
* `fsModule` operates on each path. `createFsModule({ root })` gives the same procedures, and
|
|
10
|
+
* each path of their input must be in the root (roadmap R33, `root.ts`).
|
|
8
11
|
*/
|
|
9
12
|
import { createProcedure, zodAdapter, defineModule, PROCEDURE_REGISTRY, registerModules } from "@procedures/client";
|
|
13
|
+
import { HANDLER_NAMES, rootedHandlers } from "./handlers.js";
|
|
10
14
|
import { read } from "./procedures/fs/read.js";
|
|
11
15
|
import { write } from "./procedures/fs/write.js";
|
|
12
16
|
import { exists } from "./procedures/fs/exists.js";
|
|
@@ -19,6 +23,11 @@ import { move } from "./procedures/fs/move.js";
|
|
|
19
23
|
import { glob } from "./procedures/fs/glob.js";
|
|
20
24
|
import { readJson } from "./procedures/fs/json.js";
|
|
21
25
|
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";
|
|
26
|
+
import { fsWriteJson } from "./procedures/fs/write-json.js";
|
|
27
|
+
import { fsHash } from "./procedures/fs/hash.js";
|
|
28
|
+
import { fsTemp } from "./procedures/fs/temp.js";
|
|
29
|
+
import { fsWatch } from "./procedures/fs/watch.js";
|
|
30
|
+
import { FsWriteJsonInputSchema, FsWriteJsonOutputSchema, FsHashInputSchema, FsHashOutputSchema, FsTempInputSchema, FsTempOutputSchema, FsWatchInputSchema, FsWatchOutputSchema, } from "./types.js";
|
|
22
31
|
// =============================================================================
|
|
23
32
|
// Procedure Definitions
|
|
24
33
|
// =============================================================================
|
|
@@ -171,6 +180,63 @@ const fsReadJsonProcedure = createProcedure()
|
|
|
171
180
|
})
|
|
172
181
|
.handler(readJson)
|
|
173
182
|
.build();
|
|
183
|
+
// fs.write.json, fs.hash, fs.temp and fs.watch (roadmap R44)
|
|
184
|
+
const fsWriteJsonProcedure = createProcedure()
|
|
185
|
+
.path(["fs", "write.json"])
|
|
186
|
+
.input(zodAdapter(FsWriteJsonInputSchema))
|
|
187
|
+
.output(zodAdapter(FsWriteJsonOutputSchema))
|
|
188
|
+
.meta({
|
|
189
|
+
description: "Write a value as a JSON file, with a rename at the end",
|
|
190
|
+
args: ["path"],
|
|
191
|
+
shorts: {},
|
|
192
|
+
output: "json",
|
|
193
|
+
// It replaces the file: destructive, and the same input gives the same file
|
|
194
|
+
effects: { reads: [], writes: ["fs"], destructive: true, idempotent: true },
|
|
195
|
+
})
|
|
196
|
+
.handler(fsWriteJson)
|
|
197
|
+
.build();
|
|
198
|
+
const fsHashProcedure = createProcedure()
|
|
199
|
+
.path(["fs", "hash"])
|
|
200
|
+
.input(zodAdapter(FsHashInputSchema))
|
|
201
|
+
.output(zodAdapter(FsHashOutputSchema))
|
|
202
|
+
.meta({
|
|
203
|
+
description: "The hash of a file",
|
|
204
|
+
args: ["path"],
|
|
205
|
+
shorts: { algorithm: "a" },
|
|
206
|
+
output: "json",
|
|
207
|
+
effects: READS_FILES,
|
|
208
|
+
})
|
|
209
|
+
.handler((input) => fsHash(input))
|
|
210
|
+
.build();
|
|
211
|
+
const fsTempProcedure = createProcedure()
|
|
212
|
+
.path(["fs", "temp"])
|
|
213
|
+
.input(zodAdapter(FsTempInputSchema))
|
|
214
|
+
.output(zodAdapter(FsTempOutputSchema))
|
|
215
|
+
.meta({
|
|
216
|
+
description: "Make a temporary folder",
|
|
217
|
+
args: [],
|
|
218
|
+
shorts: {},
|
|
219
|
+
output: "json",
|
|
220
|
+
// It makes a new folder each time, and changes nothing that exists
|
|
221
|
+
effects: { reads: [], writes: ["fs"], destructive: false, idempotent: false },
|
|
222
|
+
})
|
|
223
|
+
.handler((input) => fsTemp(input))
|
|
224
|
+
.build();
|
|
225
|
+
const fsWatchProcedure = createProcedure()
|
|
226
|
+
.path(["fs", "watch"])
|
|
227
|
+
.input(zodAdapter(FsWatchInputSchema))
|
|
228
|
+
.output(zodAdapter(FsWatchOutputSchema))
|
|
229
|
+
.meta({
|
|
230
|
+
description: "The changes of a file or folder, as a stream",
|
|
231
|
+
args: ["path"],
|
|
232
|
+
shorts: { recursive: "r" },
|
|
233
|
+
output: "streaming",
|
|
234
|
+
effects: READS_FILES,
|
|
235
|
+
// The stream has no end: it stops when the reader stops (roadmap R15)
|
|
236
|
+
stream: { unbounded: true },
|
|
237
|
+
})
|
|
238
|
+
.handler(((input, ctx) => fsWatch(input, ctx?.signal)))
|
|
239
|
+
.build();
|
|
174
240
|
// =============================================================================
|
|
175
241
|
// Registration
|
|
176
242
|
// =============================================================================
|
|
@@ -190,14 +256,39 @@ export const fsModule = defineModule("@procedures/fs", [
|
|
|
190
256
|
fsMoveProcedure,
|
|
191
257
|
fsGlobProcedure,
|
|
192
258
|
fsReadJsonProcedure,
|
|
259
|
+
fsWriteJsonProcedure,
|
|
260
|
+
fsHashProcedure,
|
|
261
|
+
fsTempProcedure,
|
|
262
|
+
fsWatchProcedure,
|
|
193
263
|
]);
|
|
194
264
|
export default fsModule;
|
|
265
|
+
/**
|
|
266
|
+
* This function gives the module of this package. Without `root`, it gives `fsModule`. With
|
|
267
|
+
* `root`, it gives a module with the same name and procedures, whose handlers confine each path
|
|
268
|
+
* of the input to the root. A host gives it to `createRegistry()` before its bundles, so it
|
|
269
|
+
* replaces the `fsModule` that the bundles require (the first module of a name counts).
|
|
270
|
+
*/
|
|
271
|
+
export function createFsModule(options = {}) {
|
|
272
|
+
if (options.root === undefined)
|
|
273
|
+
return fsModule;
|
|
274
|
+
const handlers = rootedHandlers(options.root);
|
|
275
|
+
const procedures = fsModule.procedures.map((procedure) => {
|
|
276
|
+
const key = procedure.path.join(".");
|
|
277
|
+
const name = HANDLER_NAMES[key];
|
|
278
|
+
// A procedure without a rooted handler would operate outside the root
|
|
279
|
+
if (name === undefined)
|
|
280
|
+
throw new Error(`The root of @procedures/fs has no handler for ${key}: add it to rootedHandlers()`);
|
|
281
|
+
return { ...procedure, handler: handlers[name] };
|
|
282
|
+
});
|
|
283
|
+
return defineModule("@procedures/fs", procedures);
|
|
284
|
+
}
|
|
195
285
|
/**
|
|
196
286
|
* This function registers the procedures of @procedures/fs, and of the modules that it requires, in
|
|
197
287
|
* 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).
|
|
288
|
+
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9). With
|
|
289
|
+
* `options.root`, each path of an input must be in the root.
|
|
199
290
|
*/
|
|
200
|
-
export function registerFsProcedures(registry = PROCEDURE_REGISTRY) {
|
|
201
|
-
registerModules(registry, [
|
|
291
|
+
export function registerFsProcedures(registry = PROCEDURE_REGISTRY, options = {}) {
|
|
292
|
+
registerModules(registry, [createFsModule(options)]);
|
|
202
293
|
}
|
|
203
294
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAyD,kBAAkB,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AACnM,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,EAAE,EAA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ACH,MAAM,UAAU,oBAAoB,CAAC,QAAQ,GAAsB,kBAAkB,EAAE,OAAO,GAAoB,EAAE;IAClH,eAAe,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs.hash procedure (roadmap R44)
|
|
3
|
+
*
|
|
4
|
+
* The hash of a file. The procedure reads the file as a stream, so a large file does not fill
|
|
5
|
+
* the memory.
|
|
6
|
+
*/
|
|
7
|
+
import type { FsHashInput, FsHashOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* The hash of a file
|
|
10
|
+
*/
|
|
11
|
+
export declare function fsHash(input: FsHashInput): Promise<FsHashOutput>;
|
|
12
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;GAEG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAUtE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs.hash procedure (roadmap R44)
|
|
3
|
+
*
|
|
4
|
+
* The hash of a file. The procedure reads the file as a stream, so a large file does not fill
|
|
5
|
+
* the memory.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { createReadStream } from "node:fs";
|
|
9
|
+
/**
|
|
10
|
+
* The hash of a file
|
|
11
|
+
*/
|
|
12
|
+
export async function fsHash(input) {
|
|
13
|
+
const algorithm = input.algorithm ?? "sha256";
|
|
14
|
+
const hash = createHash(algorithm);
|
|
15
|
+
let size = 0;
|
|
16
|
+
for await (const chunk of createReadStream(input.path)) {
|
|
17
|
+
const bytes = chunk;
|
|
18
|
+
size += bytes.length;
|
|
19
|
+
hash.update(bytes);
|
|
20
|
+
}
|
|
21
|
+
return { path: input.path, algorithm, hash: hash.digest("hex"), size };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/procedures/fs/hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAkB;IAC7C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,QAAQ,CAAC;IAC9C,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,KAAe,CAAC;QAC9B,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -9,4 +9,8 @@ export { copy } from "./copy.js";
|
|
|
9
9
|
export { move } from "./move.js";
|
|
10
10
|
export { glob } from "./glob.js";
|
|
11
11
|
export { readJson } from "./json.js";
|
|
12
|
+
export { fsWriteJson } from "./write-json.js";
|
|
13
|
+
export { fsHash } from "./hash.js";
|
|
14
|
+
export { fsTemp } from "./temp.js";
|
|
15
|
+
export { fsWatch } from "./watch.js";
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -9,4 +9,8 @@ export { copy } from "./copy.js";
|
|
|
9
9
|
export { move } from "./move.js";
|
|
10
10
|
export { glob } from "./glob.js";
|
|
11
11
|
export { readJson } from "./json.js";
|
|
12
|
+
export { fsWriteJson } from "./write-json.js";
|
|
13
|
+
export { fsHash } from "./hash.js";
|
|
14
|
+
export { fsTemp } from "./temp.js";
|
|
15
|
+
export { fsWatch } from "./watch.js";
|
|
12
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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"}
|
|
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;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs.temp procedure (roadmap R44)
|
|
3
|
+
*
|
|
4
|
+
* Make a temporary folder with a name that no other folder has. Without a root, the folder is in
|
|
5
|
+
* the temporary folder of the system. With the root of `createFsModule({ root })`, it is in the
|
|
6
|
+
* folder `.tmp` of the root, so it stays inside the root.
|
|
7
|
+
*/
|
|
8
|
+
import type { FsTempInput, FsTempOutput } from "../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Make a temporary folder. `base` is the folder that holds it (default: the temporary folder of
|
|
11
|
+
* the system).
|
|
12
|
+
*/
|
|
13
|
+
export declare function fsTemp(input: FsTempInput, base?: string): Promise<FsTempOutput>;
|
|
14
|
+
//# sourceMappingURL=temp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temp.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/temp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;GAGG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,MAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAI/F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs.temp procedure (roadmap R44)
|
|
3
|
+
*
|
|
4
|
+
* Make a temporary folder with a name that no other folder has. Without a root, the folder is in
|
|
5
|
+
* the temporary folder of the system. With the root of `createFsModule({ root })`, it is in the
|
|
6
|
+
* folder `.tmp` of the root, so it stays inside the root.
|
|
7
|
+
*/
|
|
8
|
+
import { mkdir, mkdtemp } from "node:fs/promises";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
/**
|
|
12
|
+
* Make a temporary folder. `base` is the folder that holds it (default: the temporary folder of
|
|
13
|
+
* the system).
|
|
14
|
+
*/
|
|
15
|
+
export async function fsTemp(input, base = tmpdir()) {
|
|
16
|
+
await mkdir(base, { recursive: true });
|
|
17
|
+
const path = await mkdtemp(join(base, input.prefix ?? "procedures-"));
|
|
18
|
+
return { path };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=temp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temp.js","sourceRoot":"","sources":["../../../src/procedures/fs/temp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAkB,EAAE,IAAI,GAAW,MAAM,EAAE;IACtE,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC;IACtE,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs.watch procedure (roadmap R44)
|
|
3
|
+
*
|
|
4
|
+
* The changes of a file or folder, as a stream: one item for each change that the platform
|
|
5
|
+
* reports. The stream has no end: it stops when the reader stops or the signal of the call
|
|
6
|
+
* aborts. The platform decides the details: a change can give two items, and some platforms
|
|
7
|
+
* give no file name.
|
|
8
|
+
*/
|
|
9
|
+
import type { FsWatchInput, FsWatchOutput } from "../../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* The changes of a file or folder, as a stream
|
|
12
|
+
*/
|
|
13
|
+
export declare function fsWatch(input: FsWatchInput, signal?: AbortSignal): AsyncGenerator<FsWatchOutput, void, undefined>;
|
|
14
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/procedures/fs/watch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAElE;;GAEG;AACH,wBAAuB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,CAUxH"}
|