@d0paminedriven/fs 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/dist/chunk-I6PDZOED.js +44 -0
- package/dist/chunk-K45COKAJ.js +531 -0
- package/dist/fs/index.cjs +568 -0
- package/dist/fs/index.d.cts +243 -0
- package/dist/fs/index.d.ts +243 -0
- package/dist/fs/index.js +8 -0
- package/dist/index.cjs +575 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +13 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.d.cts +216 -0
- package/dist/types/index.d.ts +216 -0
- package/dist/types/index.js +7 -0
- package/package.json +70 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
|
|
3
|
+
type BufferEncodingUnion = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | "utf-16le";
|
|
4
|
+
interface Dict<T> {
|
|
5
|
+
[key: string]: T | undefined;
|
|
6
|
+
}
|
|
7
|
+
interface ProcessEnv extends Dict<string> {
|
|
8
|
+
readonly VERCEL_ENV: typeof process.env.VERCEL_ENV;
|
|
9
|
+
readonly NODE_ENV: typeof process.env.NODE_ENV;
|
|
10
|
+
/**
|
|
11
|
+
* Can be used to change the default timezone at runtime
|
|
12
|
+
*/
|
|
13
|
+
TZ?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ProcessEnvOptions {
|
|
16
|
+
uid?: number | undefined;
|
|
17
|
+
gid?: number | undefined;
|
|
18
|
+
cwd?: string | URL | undefined;
|
|
19
|
+
env?: ProcessEnv | undefined;
|
|
20
|
+
}
|
|
21
|
+
interface CommonOptions extends ProcessEnvOptions {
|
|
22
|
+
/**
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
windowsHide?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
29
|
+
timeout?: number | undefined;
|
|
30
|
+
}
|
|
31
|
+
type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array;
|
|
32
|
+
type Signals = "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" | "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" | "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
|
|
33
|
+
type ArrayBufferView = DataView | TypedArray;
|
|
34
|
+
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
35
|
+
type StdioOptions = IOType | (IOType | "ipc" | stream.Stream | number | null | undefined)[];
|
|
36
|
+
interface CommonExecOptions extends CommonOptions {
|
|
37
|
+
input?: string | ArrayBufferView | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings.
|
|
40
|
+
* If passed as an array, the first element is used for `stdin`, the second for
|
|
41
|
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
|
42
|
+
* specify the `stdio` behavior beyond the standard streams.
|
|
43
|
+
*
|
|
44
|
+
* @default 'pipe'
|
|
45
|
+
*/
|
|
46
|
+
stdio?: StdioOptions | undefined;
|
|
47
|
+
killSignal?: Signals | number | undefined;
|
|
48
|
+
maxBuffer?: number | undefined;
|
|
49
|
+
encoding?: BufferEncoding | "buffer" | null | undefined;
|
|
50
|
+
}
|
|
51
|
+
interface ExecSyncOptions extends CommonExecOptions {
|
|
52
|
+
shell?: string | undefined;
|
|
53
|
+
}
|
|
54
|
+
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
|
|
55
|
+
encoding: BufferEncoding;
|
|
56
|
+
}
|
|
57
|
+
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
|
|
58
|
+
encoding?: "buffer" | null | undefined;
|
|
59
|
+
}
|
|
60
|
+
interface ObjEncodingOptions {
|
|
61
|
+
encoding?: BufferEncodingUnion | null | undefined;
|
|
62
|
+
}
|
|
63
|
+
type OpenMode = string | number;
|
|
64
|
+
interface Abortable {
|
|
65
|
+
/**
|
|
66
|
+
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
|
67
|
+
*/
|
|
68
|
+
signal?: AbortSignal | undefined;
|
|
69
|
+
}
|
|
70
|
+
type Mode = string | number;
|
|
71
|
+
interface MkDirOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Indicates whether parent folders should be created.
|
|
74
|
+
* If a folder was created, the path to the first created folder will be returned.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
recursive?: boolean | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* A file mode. If a string is passed, it is parsed as an octal integer. If not specified
|
|
80
|
+
* @default 0o777
|
|
81
|
+
*/
|
|
82
|
+
mode?: Mode | undefined;
|
|
83
|
+
}
|
|
84
|
+
type BashEnv = "development" | "production" | "test" | undefined;
|
|
85
|
+
type CoercionUnion = string | Uint8Array | readonly number[];
|
|
86
|
+
type WriteStreamDataShape = WithImplicitCoercion<CoercionUnion>;
|
|
87
|
+
type WriteStreamProps<T extends string = string> = {
|
|
88
|
+
data: WithImplicitCoercion<CoercionUnion>;
|
|
89
|
+
cwd: string;
|
|
90
|
+
path: T;
|
|
91
|
+
};
|
|
92
|
+
type WriteStreamOptions = BufferEncodingUnion | {
|
|
93
|
+
encoding?: BufferEncodingUnion;
|
|
94
|
+
autoClose?: boolean;
|
|
95
|
+
emitClose?: boolean;
|
|
96
|
+
start?: number;
|
|
97
|
+
highWaterMark?: number;
|
|
98
|
+
flush?: boolean;
|
|
99
|
+
};
|
|
100
|
+
type WriteFileAsyncDataUnion = WithImplicitCoercion<string> | {
|
|
101
|
+
[Symbol.toPrimitive](hint: "string"): string;
|
|
102
|
+
};
|
|
103
|
+
type ReadDirOptions = BufferEncodingUnion | ((ObjEncodingOptions & {
|
|
104
|
+
withFileTypes?: false | undefined;
|
|
105
|
+
recursive?: boolean | undefined;
|
|
106
|
+
}) | null);
|
|
107
|
+
type WriteFileAsyncOptions = (ObjEncodingOptions & {
|
|
108
|
+
mode?: Mode | undefined;
|
|
109
|
+
flag?: OpenMode | undefined;
|
|
110
|
+
} & Abortable) | BufferEncodingUnion | null;
|
|
111
|
+
type WriteFileAsyncProps<T extends string = string> = {
|
|
112
|
+
path: T;
|
|
113
|
+
cwd: string;
|
|
114
|
+
data: WriteFileAsyncDataUnion;
|
|
115
|
+
options?: (ObjEncodingOptions & {
|
|
116
|
+
mode?: Mode | undefined;
|
|
117
|
+
flag?: OpenMode | undefined;
|
|
118
|
+
} & Abortable) | BufferEncodingUnion | null;
|
|
119
|
+
};
|
|
120
|
+
type ReadDirProps<T extends string> = {
|
|
121
|
+
path: T;
|
|
122
|
+
options?: ReadDirOptions;
|
|
123
|
+
};
|
|
124
|
+
type MkDirSyncOptions = Mode | (MkDirOptions & {
|
|
125
|
+
recursive?: boolean | undefined;
|
|
126
|
+
}) | null | undefined;
|
|
127
|
+
type MkDirSyncProps<T extends string> = {
|
|
128
|
+
cwd: string;
|
|
129
|
+
path: T;
|
|
130
|
+
options?: Mode | (MkDirOptions & {
|
|
131
|
+
recursive?: boolean | undefined;
|
|
132
|
+
}) | null | undefined;
|
|
133
|
+
};
|
|
134
|
+
interface ExecuteCommandProps<T extends string> extends ExecSyncOptionsWithBufferEncoding {
|
|
135
|
+
command: T;
|
|
136
|
+
}
|
|
137
|
+
type ConditionalPromise<T> = T | Promise<T>;
|
|
138
|
+
type UnwrapPromise<T> = T extends Promise<infer U> | PromiseLike<infer U> ? U : T;
|
|
139
|
+
type RemoveFields<T, P extends keyof T = keyof T> = {
|
|
140
|
+
[S in keyof T as Exclude<S, P>]: T[S];
|
|
141
|
+
};
|
|
142
|
+
type ConditionalToRequired<T, Z extends keyof T = keyof T> = RemoveFields<T, Z> & {
|
|
143
|
+
[Q in Z]-?: T[Q];
|
|
144
|
+
};
|
|
145
|
+
type RequiredToConditional<T, X extends keyof T = keyof T> = RemoveFields<T, X> & {
|
|
146
|
+
[Q in X]?: T[Q];
|
|
147
|
+
};
|
|
148
|
+
type FieldToConditionallyNever<T, X extends keyof T = keyof T> = RemoveFields<T, X> & {
|
|
149
|
+
[Q in X]?: XOR<T[Q], never>;
|
|
150
|
+
};
|
|
151
|
+
type ExcludeFieldEnumerable<T, K extends keyof T> = RemoveFields<T, K>;
|
|
152
|
+
type ArrayOrReadOnlyArray<T> = T[] | readonly T[];
|
|
153
|
+
type Unenumerate<T> = T extends readonly (infer U)[] | (infer U)[] ? U : T;
|
|
154
|
+
type Without<T, U> = {
|
|
155
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
156
|
+
};
|
|
157
|
+
type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
158
|
+
type Depth<Y extends {
|
|
159
|
+
[record: string | symbol | number]: unknown;
|
|
160
|
+
}, X extends keyof Y = keyof Y> = {
|
|
161
|
+
[H in keyof Y[X]]: Y[X][H][keyof Y[X][H]];
|
|
162
|
+
};
|
|
163
|
+
type InferDepth<T> = T extends Depth<infer U, infer X> ? U[X] : T;
|
|
164
|
+
type OmitSrc<T> = T extends `src/${infer U}` ? U : T;
|
|
165
|
+
type InjectScriptsProps<T> = {
|
|
166
|
+
content: {
|
|
167
|
+
scripts: {
|
|
168
|
+
[record: string]: string;
|
|
169
|
+
};
|
|
170
|
+
} & {
|
|
171
|
+
[record: string]: string | number | boolean | {
|
|
172
|
+
[record: string]: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
tuplesToInject: T;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Expect that the thing passed to Expect<T> is true.
|
|
179
|
+
*
|
|
180
|
+
* For instance, `Expect<true>` won't error. But
|
|
181
|
+
* `Expect<false>` will error.
|
|
182
|
+
*/
|
|
183
|
+
type Expect<T extends true> = T;
|
|
184
|
+
/**
|
|
185
|
+
* Checks that X and Y are exactly equal.
|
|
186
|
+
*
|
|
187
|
+
* For instance, `Equal<'a', 'a'>` is true. But
|
|
188
|
+
* `Equal<'a', 'b'>` is false.
|
|
189
|
+
*
|
|
190
|
+
* This also checks for exact intersection equality. So
|
|
191
|
+
* `Equal<{ a: string; b: string }, { a: string; b: string }>`
|
|
192
|
+
* is true. But `Equal<{ a: string; b: string }, { a: string; } & { b: string }>`
|
|
193
|
+
* is false.
|
|
194
|
+
*/
|
|
195
|
+
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
196
|
+
/**
|
|
197
|
+
* Checks that Y is assignable to X.
|
|
198
|
+
*
|
|
199
|
+
* For instance, `Extends<string, 'a'>` is true. This is because
|
|
200
|
+
* 'a' can be passed to a function which expects a string.
|
|
201
|
+
*
|
|
202
|
+
* But `Extends<'a', string>` is false. This is because a string
|
|
203
|
+
* CANNOT be passed to a function which expects 'a'.
|
|
204
|
+
*/
|
|
205
|
+
type Extends<X, Y> = Y extends X ? true : false;
|
|
206
|
+
type ParsedUrlInfo = {
|
|
207
|
+
href: string;
|
|
208
|
+
protocol: string;
|
|
209
|
+
baseUrl: string;
|
|
210
|
+
host: string;
|
|
211
|
+
pathname: string;
|
|
212
|
+
search: string;
|
|
213
|
+
hash: string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export type { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
|
|
3
|
+
type BufferEncodingUnion = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | "utf-16le";
|
|
4
|
+
interface Dict<T> {
|
|
5
|
+
[key: string]: T | undefined;
|
|
6
|
+
}
|
|
7
|
+
interface ProcessEnv extends Dict<string> {
|
|
8
|
+
readonly VERCEL_ENV: typeof process.env.VERCEL_ENV;
|
|
9
|
+
readonly NODE_ENV: typeof process.env.NODE_ENV;
|
|
10
|
+
/**
|
|
11
|
+
* Can be used to change the default timezone at runtime
|
|
12
|
+
*/
|
|
13
|
+
TZ?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ProcessEnvOptions {
|
|
16
|
+
uid?: number | undefined;
|
|
17
|
+
gid?: number | undefined;
|
|
18
|
+
cwd?: string | URL | undefined;
|
|
19
|
+
env?: ProcessEnv | undefined;
|
|
20
|
+
}
|
|
21
|
+
interface CommonOptions extends ProcessEnvOptions {
|
|
22
|
+
/**
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
windowsHide?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
29
|
+
timeout?: number | undefined;
|
|
30
|
+
}
|
|
31
|
+
type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array;
|
|
32
|
+
type Signals = "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" | "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" | "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
|
|
33
|
+
type ArrayBufferView = DataView | TypedArray;
|
|
34
|
+
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
35
|
+
type StdioOptions = IOType | (IOType | "ipc" | stream.Stream | number | null | undefined)[];
|
|
36
|
+
interface CommonExecOptions extends CommonOptions {
|
|
37
|
+
input?: string | ArrayBufferView | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings.
|
|
40
|
+
* If passed as an array, the first element is used for `stdin`, the second for
|
|
41
|
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
|
42
|
+
* specify the `stdio` behavior beyond the standard streams.
|
|
43
|
+
*
|
|
44
|
+
* @default 'pipe'
|
|
45
|
+
*/
|
|
46
|
+
stdio?: StdioOptions | undefined;
|
|
47
|
+
killSignal?: Signals | number | undefined;
|
|
48
|
+
maxBuffer?: number | undefined;
|
|
49
|
+
encoding?: BufferEncoding | "buffer" | null | undefined;
|
|
50
|
+
}
|
|
51
|
+
interface ExecSyncOptions extends CommonExecOptions {
|
|
52
|
+
shell?: string | undefined;
|
|
53
|
+
}
|
|
54
|
+
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
|
|
55
|
+
encoding: BufferEncoding;
|
|
56
|
+
}
|
|
57
|
+
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
|
|
58
|
+
encoding?: "buffer" | null | undefined;
|
|
59
|
+
}
|
|
60
|
+
interface ObjEncodingOptions {
|
|
61
|
+
encoding?: BufferEncodingUnion | null | undefined;
|
|
62
|
+
}
|
|
63
|
+
type OpenMode = string | number;
|
|
64
|
+
interface Abortable {
|
|
65
|
+
/**
|
|
66
|
+
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
|
67
|
+
*/
|
|
68
|
+
signal?: AbortSignal | undefined;
|
|
69
|
+
}
|
|
70
|
+
type Mode = string | number;
|
|
71
|
+
interface MkDirOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Indicates whether parent folders should be created.
|
|
74
|
+
* If a folder was created, the path to the first created folder will be returned.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
recursive?: boolean | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* A file mode. If a string is passed, it is parsed as an octal integer. If not specified
|
|
80
|
+
* @default 0o777
|
|
81
|
+
*/
|
|
82
|
+
mode?: Mode | undefined;
|
|
83
|
+
}
|
|
84
|
+
type BashEnv = "development" | "production" | "test" | undefined;
|
|
85
|
+
type CoercionUnion = string | Uint8Array | readonly number[];
|
|
86
|
+
type WriteStreamDataShape = WithImplicitCoercion<CoercionUnion>;
|
|
87
|
+
type WriteStreamProps<T extends string = string> = {
|
|
88
|
+
data: WithImplicitCoercion<CoercionUnion>;
|
|
89
|
+
cwd: string;
|
|
90
|
+
path: T;
|
|
91
|
+
};
|
|
92
|
+
type WriteStreamOptions = BufferEncodingUnion | {
|
|
93
|
+
encoding?: BufferEncodingUnion;
|
|
94
|
+
autoClose?: boolean;
|
|
95
|
+
emitClose?: boolean;
|
|
96
|
+
start?: number;
|
|
97
|
+
highWaterMark?: number;
|
|
98
|
+
flush?: boolean;
|
|
99
|
+
};
|
|
100
|
+
type WriteFileAsyncDataUnion = WithImplicitCoercion<string> | {
|
|
101
|
+
[Symbol.toPrimitive](hint: "string"): string;
|
|
102
|
+
};
|
|
103
|
+
type ReadDirOptions = BufferEncodingUnion | ((ObjEncodingOptions & {
|
|
104
|
+
withFileTypes?: false | undefined;
|
|
105
|
+
recursive?: boolean | undefined;
|
|
106
|
+
}) | null);
|
|
107
|
+
type WriteFileAsyncOptions = (ObjEncodingOptions & {
|
|
108
|
+
mode?: Mode | undefined;
|
|
109
|
+
flag?: OpenMode | undefined;
|
|
110
|
+
} & Abortable) | BufferEncodingUnion | null;
|
|
111
|
+
type WriteFileAsyncProps<T extends string = string> = {
|
|
112
|
+
path: T;
|
|
113
|
+
cwd: string;
|
|
114
|
+
data: WriteFileAsyncDataUnion;
|
|
115
|
+
options?: (ObjEncodingOptions & {
|
|
116
|
+
mode?: Mode | undefined;
|
|
117
|
+
flag?: OpenMode | undefined;
|
|
118
|
+
} & Abortable) | BufferEncodingUnion | null;
|
|
119
|
+
};
|
|
120
|
+
type ReadDirProps<T extends string> = {
|
|
121
|
+
path: T;
|
|
122
|
+
options?: ReadDirOptions;
|
|
123
|
+
};
|
|
124
|
+
type MkDirSyncOptions = Mode | (MkDirOptions & {
|
|
125
|
+
recursive?: boolean | undefined;
|
|
126
|
+
}) | null | undefined;
|
|
127
|
+
type MkDirSyncProps<T extends string> = {
|
|
128
|
+
cwd: string;
|
|
129
|
+
path: T;
|
|
130
|
+
options?: Mode | (MkDirOptions & {
|
|
131
|
+
recursive?: boolean | undefined;
|
|
132
|
+
}) | null | undefined;
|
|
133
|
+
};
|
|
134
|
+
interface ExecuteCommandProps<T extends string> extends ExecSyncOptionsWithBufferEncoding {
|
|
135
|
+
command: T;
|
|
136
|
+
}
|
|
137
|
+
type ConditionalPromise<T> = T | Promise<T>;
|
|
138
|
+
type UnwrapPromise<T> = T extends Promise<infer U> | PromiseLike<infer U> ? U : T;
|
|
139
|
+
type RemoveFields<T, P extends keyof T = keyof T> = {
|
|
140
|
+
[S in keyof T as Exclude<S, P>]: T[S];
|
|
141
|
+
};
|
|
142
|
+
type ConditionalToRequired<T, Z extends keyof T = keyof T> = RemoveFields<T, Z> & {
|
|
143
|
+
[Q in Z]-?: T[Q];
|
|
144
|
+
};
|
|
145
|
+
type RequiredToConditional<T, X extends keyof T = keyof T> = RemoveFields<T, X> & {
|
|
146
|
+
[Q in X]?: T[Q];
|
|
147
|
+
};
|
|
148
|
+
type FieldToConditionallyNever<T, X extends keyof T = keyof T> = RemoveFields<T, X> & {
|
|
149
|
+
[Q in X]?: XOR<T[Q], never>;
|
|
150
|
+
};
|
|
151
|
+
type ExcludeFieldEnumerable<T, K extends keyof T> = RemoveFields<T, K>;
|
|
152
|
+
type ArrayOrReadOnlyArray<T> = T[] | readonly T[];
|
|
153
|
+
type Unenumerate<T> = T extends readonly (infer U)[] | (infer U)[] ? U : T;
|
|
154
|
+
type Without<T, U> = {
|
|
155
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
156
|
+
};
|
|
157
|
+
type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
158
|
+
type Depth<Y extends {
|
|
159
|
+
[record: string | symbol | number]: unknown;
|
|
160
|
+
}, X extends keyof Y = keyof Y> = {
|
|
161
|
+
[H in keyof Y[X]]: Y[X][H][keyof Y[X][H]];
|
|
162
|
+
};
|
|
163
|
+
type InferDepth<T> = T extends Depth<infer U, infer X> ? U[X] : T;
|
|
164
|
+
type OmitSrc<T> = T extends `src/${infer U}` ? U : T;
|
|
165
|
+
type InjectScriptsProps<T> = {
|
|
166
|
+
content: {
|
|
167
|
+
scripts: {
|
|
168
|
+
[record: string]: string;
|
|
169
|
+
};
|
|
170
|
+
} & {
|
|
171
|
+
[record: string]: string | number | boolean | {
|
|
172
|
+
[record: string]: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
tuplesToInject: T;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Expect that the thing passed to Expect<T> is true.
|
|
179
|
+
*
|
|
180
|
+
* For instance, `Expect<true>` won't error. But
|
|
181
|
+
* `Expect<false>` will error.
|
|
182
|
+
*/
|
|
183
|
+
type Expect<T extends true> = T;
|
|
184
|
+
/**
|
|
185
|
+
* Checks that X and Y are exactly equal.
|
|
186
|
+
*
|
|
187
|
+
* For instance, `Equal<'a', 'a'>` is true. But
|
|
188
|
+
* `Equal<'a', 'b'>` is false.
|
|
189
|
+
*
|
|
190
|
+
* This also checks for exact intersection equality. So
|
|
191
|
+
* `Equal<{ a: string; b: string }, { a: string; b: string }>`
|
|
192
|
+
* is true. But `Equal<{ a: string; b: string }, { a: string; } & { b: string }>`
|
|
193
|
+
* is false.
|
|
194
|
+
*/
|
|
195
|
+
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
196
|
+
/**
|
|
197
|
+
* Checks that Y is assignable to X.
|
|
198
|
+
*
|
|
199
|
+
* For instance, `Extends<string, 'a'>` is true. This is because
|
|
200
|
+
* 'a' can be passed to a function which expects a string.
|
|
201
|
+
*
|
|
202
|
+
* But `Extends<'a', string>` is false. This is because a string
|
|
203
|
+
* CANNOT be passed to a function which expects 'a'.
|
|
204
|
+
*/
|
|
205
|
+
type Extends<X, Y> = Y extends X ? true : false;
|
|
206
|
+
type ParsedUrlInfo = {
|
|
207
|
+
href: string;
|
|
208
|
+
protocol: string;
|
|
209
|
+
baseUrl: string;
|
|
210
|
+
host: string;
|
|
211
|
+
pathname: string;
|
|
212
|
+
search: string;
|
|
213
|
+
hash: string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export type { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR };
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@d0paminedriven/fs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "convenient fs helpers",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"source": "src/index.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
"*": {
|
|
12
|
+
"*": [
|
|
13
|
+
"dist/*.d.ts",
|
|
14
|
+
"dist/*/index.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"fs": [
|
|
17
|
+
"dist/fs/index.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"types": [
|
|
20
|
+
"dist/types/index.d.ts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"sideEffects": true,
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/**/*.{js,cjs,d.ts,d.cts,css}"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./dist/index.js",
|
|
33
|
+
"./*": "./dist/*.js",
|
|
34
|
+
"./fs": "./dist/fs/index.js",
|
|
35
|
+
"./types": "./dist/types/index.js"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"dotenv": "^16.4.7"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@microsoft/api-extractor": "^7.49.1",
|
|
42
|
+
"@swc/core": "^1.10.7",
|
|
43
|
+
"@swc/wasm": "^1.10.7",
|
|
44
|
+
"@types/node": "^22.10.7",
|
|
45
|
+
"chokidar": "^4.0.3",
|
|
46
|
+
"dotenv": "^16.4.7",
|
|
47
|
+
"dotenv-cli": "^8.0.0",
|
|
48
|
+
"dotenv-expand": "^12.0.1",
|
|
49
|
+
"eslint": "latest",
|
|
50
|
+
"jiti": "^2.4.2",
|
|
51
|
+
"prettier": "latest",
|
|
52
|
+
"terser": "^5.37.0",
|
|
53
|
+
"tslib": "latest",
|
|
54
|
+
"tsup": "latest",
|
|
55
|
+
"tsx": "latest",
|
|
56
|
+
"typescript": "latest",
|
|
57
|
+
"typescript-eslint": "latest",
|
|
58
|
+
"@portfolio/eslint-config": "1.0.0",
|
|
59
|
+
"@portfolio/prettier-config": "0.1.0",
|
|
60
|
+
"@portfolio/tsconfig": "0.1.0"
|
|
61
|
+
},
|
|
62
|
+
"prettier": "@portfolio/prettier-config",
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup",
|
|
65
|
+
"dev": "pnpm build",
|
|
66
|
+
"lint": "eslint",
|
|
67
|
+
"clean": "git clean -xdf .turbo dist node_modules",
|
|
68
|
+
"fix": "npm pkg fix"
|
|
69
|
+
}
|
|
70
|
+
}
|