@ix-xs/node-comfort 1.2.0 → 2.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +340 -0
  2. package/README.md +137 -548
  3. package/index.js +80 -35
  4. package/package.json +161 -33
  5. package/src/Arr.js +1050 -418
  6. package/src/Async.js +817 -0
  7. package/src/Cache.js +433 -0
  8. package/src/Checker.js +1202 -539
  9. package/src/Cli.js +1293 -0
  10. package/src/Color.js +556 -0
  11. package/src/Crypto.js +1082 -0
  12. package/src/Emitter.js +356 -0
  13. package/src/Env.js +689 -0
  14. package/src/FS.js +1626 -894
  15. package/src/Func.js +823 -356
  16. package/src/Http.js +700 -0
  17. package/src/Id.js +568 -200
  18. package/src/Logger.js +963 -378
  19. package/src/Num.js +965 -360
  20. package/src/Obj.js +1077 -379
  21. package/src/SQLite.js +1629 -1005
  22. package/src/Schema.js +2101 -0
  23. package/src/Str.js +1209 -432
  24. package/src/Sys.js +654 -0
  25. package/src/Time.js +1533 -440
  26. package/src/Utils.js +342 -325
  27. package/src/errors.js +335 -0
  28. package/src/internal/shared.js +415 -0
  29. package/types/index.d.ts +735 -526
  30. package/types/src/Arr.d.ts +533 -145
  31. package/types/src/Arr.d.ts.map +1 -1
  32. package/types/src/Async.d.ts +372 -0
  33. package/types/src/Async.d.ts.map +1 -0
  34. package/types/src/Cache.d.ts +221 -0
  35. package/types/src/Cache.d.ts.map +1 -0
  36. package/types/src/Checker.d.ts +651 -232
  37. package/types/src/Checker.d.ts.map +1 -1
  38. package/types/src/Cli.d.ts +664 -0
  39. package/types/src/Cli.d.ts.map +1 -0
  40. package/types/src/Color.d.ts +300 -0
  41. package/types/src/Color.d.ts.map +1 -0
  42. package/types/src/Crypto.d.ts +620 -0
  43. package/types/src/Crypto.d.ts.map +1 -0
  44. package/types/src/Emitter.d.ts +189 -0
  45. package/types/src/Emitter.d.ts.map +1 -0
  46. package/types/src/Env.d.ts +412 -0
  47. package/types/src/Env.d.ts.map +1 -0
  48. package/types/src/FS.d.ts +717 -238
  49. package/types/src/FS.d.ts.map +1 -1
  50. package/types/src/Func.d.ts +508 -135
  51. package/types/src/Func.d.ts.map +1 -1
  52. package/types/src/Http.d.ts +444 -0
  53. package/types/src/Http.d.ts.map +1 -0
  54. package/types/src/Id.d.ts +199 -66
  55. package/types/src/Id.d.ts.map +1 -1
  56. package/types/src/Logger.d.ts +414 -46
  57. package/types/src/Logger.d.ts.map +1 -1
  58. package/types/src/Num.d.ts +514 -137
  59. package/types/src/Num.d.ts.map +1 -1
  60. package/types/src/Obj.d.ts +453 -104
  61. package/types/src/Obj.d.ts.map +1 -1
  62. package/types/src/SQLite.d.ts +754 -308
  63. package/types/src/SQLite.d.ts.map +1 -1
  64. package/types/src/Schema.d.ts +1189 -0
  65. package/types/src/Schema.d.ts.map +1 -0
  66. package/types/src/Str.d.ts +617 -166
  67. package/types/src/Str.d.ts.map +1 -1
  68. package/types/src/Sys.d.ts +314 -0
  69. package/types/src/Sys.d.ts.map +1 -0
  70. package/types/src/Time.d.ts +759 -204
  71. package/types/src/Time.d.ts.map +1 -1
  72. package/types/src/Utils.d.ts +158 -102
  73. package/types/src/Utils.d.ts.map +1 -1
  74. package/types/src/errors.d.ts +316 -0
  75. package/types/src/errors.d.ts.map +1 -0
  76. package/types/src/internal/shared.d.ts +123 -0
  77. package/types/src/internal/shared.d.ts.map +1 -0
  78. package/types/index.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Str.d.ts","sourceRoot":"","sources":["../../src/Str.js"],"names":[],"mappings":"AA2BE;;;;;;;;GAQG;AACH,gCAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;;;GAQG;AACH,+BAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;;;;GASG;AACH,+BAHW,MAAM,GACJ,MAAM,CAUlB;AAED;;;;;;;;GAQG;AACH,gCAHW,MAAM,GACJ,MAAM,CAMlB;AAED;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JW,OAAO,UACP,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;;;;;;;GAYG;AACH,2BALW,OAAO,KACP,OAAO,YACP,cAAc,GACZ,MAAM,CAQlB;AAED;;;;;;;;;GASG;AACH,+BAJW,OAAO,KACP,OAAO,GACL,MAAM,CAMlB;AAED;;;;;;;;;GASG;AACH,8BAJW,OAAO,KACP,OAAO,GACL,MAAM,CAUlB;AAED;;;;;;;;;;;;GAYG;AACH,+BALW,OAAO,cACP,QAAQ,CAAC,MAAM,CAAC,YAChB,cAAc,GACZ,MAAM,GAAG,SAAS,CAoB9B;AAED;;;;;;;;;;;GAWG;AACH,8BAJW,MAAM,YACN,mBAAmB,GAAG,MAAM,GAC1B,MAAM,CAOlB"}
@@ -0,0 +1,314 @@
1
+ /**
2
+ * Options for `run()` and `exec()`.
3
+ */
4
+ export type RunOptions = {
5
+ /**
6
+ * Where to run the command.
7
+ */
8
+ cwd?: string | undefined;
9
+ /**
10
+ * Extra environment variables, added to `process.env`. `undefined` removes one.
11
+ */
12
+ env?: Record<string, string | undefined> | undefined;
13
+ /**
14
+ * Set to `false` to pass only `env`, without `process.env`.
15
+ */
16
+ extendEnv?: boolean | undefined;
17
+ /**
18
+ * Written to the command's stdin.
19
+ */
20
+ input?: string | Buffer<ArrayBufferLike> | undefined;
21
+ /**
22
+ * Kill the command after this long, like `"30s"`. On Windows, what it started is stopped with it.
23
+ */
24
+ timeout?: string | number | undefined;
25
+ /**
26
+ * Kills the command when aborted. On Windows, what it started is stopped with it.
27
+ */
28
+ signal?: AbortSignal | undefined;
29
+ /**
30
+ * `"inherit"` shows the output live instead of capturing it. Defaults to `"pipe"`.
31
+ */
32
+ stdio?: "pipe" | "inherit" | undefined;
33
+ /**
34
+ * Called for each line of stdout.
35
+ */
36
+ onStdout?: ((line: string) => void) | undefined;
37
+ /**
38
+ * Called for each line of stderr.
39
+ */
40
+ onStderr?: ((line: string) => void) | undefined;
41
+ /**
42
+ * Throw when the exit code isn't 0. Defaults to `true`.
43
+ */
44
+ reject?: boolean | undefined;
45
+ /**
46
+ * Drop the final newline of the output. Defaults to `true`.
47
+ */
48
+ trim?: boolean | undefined;
49
+ };
50
+ /**
51
+ * A finished command.
52
+ */
53
+ export type RunResult = {
54
+ /**
55
+ * The command line that ran.
56
+ */
57
+ command: string;
58
+ stdout: string;
59
+ stderr: string;
60
+ /**
61
+ * `null` if a signal killed it.
62
+ */
63
+ exitCode: number | null;
64
+ signal: string | null;
65
+ /**
66
+ * In milliseconds.
67
+ */
68
+ duration: number;
69
+ };
70
+ /**
71
+ * Options for `onShutdown()`. They apply to all handlers.
72
+ */
73
+ export type ShutdownOptions = {
74
+ /**
75
+ * How long the handlers get before the exit is forced. Defaults to 10 seconds.
76
+ */
77
+ timeout?: string | number | undefined;
78
+ /**
79
+ * Exit code after a clean shutdown. Defaults to `0`.
80
+ */
81
+ exitCode?: number | undefined;
82
+ /**
83
+ * Signals that trigger it. Defaults to `SIGINT`, `SIGTERM` and `SIGHUP`.
84
+ */
85
+ signals?: NodeJS.Signals[] | undefined;
86
+ };
87
+ /**
88
+ * Why the process is stopping: the signal it got, or `"shutdown"` when
89
+ * `sys.shutdown()` was called.
90
+ */
91
+ export type ShutdownReason = NodeJS.Signals | "shutdown";
92
+ /**
93
+ * Returned by `info()`.
94
+ */
95
+ export type SystemInfo = {
96
+ /**
97
+ * `"win32"`, `"darwin"`, `"linux"`...
98
+ */
99
+ platform: NodeJS.Platform;
100
+ /**
101
+ * `"x64"`, `"arm64"`...
102
+ */
103
+ arch: string;
104
+ /**
105
+ * OS release.
106
+ */
107
+ release: string;
108
+ /**
109
+ * Node.js version.
110
+ */
111
+ node: string;
112
+ /**
113
+ * Number of logical CPUs.
114
+ */
115
+ cpus: number;
116
+ cpuModel: string;
117
+ /**
118
+ * System memory, in bytes.
119
+ */
120
+ memory: {
121
+ total: number;
122
+ free: number;
123
+ used: number;
124
+ };
125
+ /**
126
+ * In seconds.
127
+ */
128
+ uptime: number;
129
+ hostname: string;
130
+ user: string;
131
+ pid: number;
132
+ /**
133
+ * Running in CI.
134
+ */
135
+ ci: boolean;
136
+ /**
137
+ * Running in a container.
138
+ */
139
+ docker: boolean;
140
+ /**
141
+ * Running in WSL.
142
+ */
143
+ wsl: boolean;
144
+ };
145
+ /**
146
+ * Runs a program without a shell, so arguments are passed as they are and
147
+ * user input can't inject anything. Resolves with the output; rejects with
148
+ * a `ProcessError` if the exit code isn't 0.
149
+ *
150
+ * @example
151
+ * const { stdout } = await sys.run("git", ["log", "-1", "--format=%s"]);
152
+ * await sys.run("npm", ["install"], { cwd: "./app", stdio: "inherit" });
153
+ * await sys.run("ffmpeg", ["-i", input, output], { timeout: "5m" });
154
+ *
155
+ * @param {string} file A name found in `PATH`, or a path.
156
+ * @param {string[]} [args=[]]
157
+ * @param {RunOptions} [options]
158
+ * @returns {Promise<RunResult>}
159
+ * @throws {ProcessError} If it can't start, fails (unless `reject: false`) or times out.
160
+ */
161
+ export function run(file: string, args?: string[], options?: RunOptions): Promise<RunResult>;
162
+ /**
163
+ * Runs a command line through the shell, so pipes, `&&` and variables
164
+ * work. Don't build it from untrusted input; use `run()` for that.
165
+ *
166
+ * @example
167
+ * const { stdout } = await sys.exec("git status --short | wc -l");
168
+ * const { exitCode } = await sys.exec("npm test", { reject: false, stdio: "inherit" });
169
+ *
170
+ * @param {string} command
171
+ * @param {RunOptions} [options]
172
+ * @returns {Promise<RunResult>}
173
+ * @throws {ProcessError} If it fails (unless `reject: false`) or times out.
174
+ */
175
+ export function exec(command: string, options?: RunOptions): Promise<RunResult>;
176
+ /**
177
+ * Finds an executable in `PATH`, like the `which` command.
178
+ *
179
+ * @example
180
+ * sys.which("git"); // "/usr/bin/git"
181
+ * sys.which("nope"); // undefined
182
+ *
183
+ * @param {string} command
184
+ * @returns {string | undefined}
185
+ */
186
+ export function which(command: string): string | undefined;
187
+ /**
188
+ * Opens a URL, file or folder with the default app.
189
+ *
190
+ * @example
191
+ * sys.open("http://localhost:3000");
192
+ *
193
+ * @param {string} target
194
+ * @returns {boolean} `true` if the opener started.
195
+ */
196
+ export function open(target: string): boolean;
197
+ /**
198
+ * Runs cleanup code when the process is asked to stop (Ctrl+C,
199
+ * `docker stop`, `kill`): close servers, flush logs, disconnect databases.
200
+ * Handlers run in reverse order, then the process exits. If they take
201
+ * longer than `timeout`, the exit is forced; a second Ctrl+C exits at once.
202
+ *
203
+ * @example
204
+ * const server = app.listen(3000);
205
+ * sys.onShutdown(() => new Promise((done) => server.close(done)));
206
+ * sys.onShutdown((reason) => log.info(`Stopping (${reason})`));
207
+ *
208
+ * @param {(reason: ShutdownReason) => unknown} handler Can be async. Gets the signal that stopped the process.
209
+ * @param {ShutdownOptions} [options]
210
+ * @returns {() => void} Removes the handler.
211
+ */
212
+ export function onShutdown(handler: (reason: ShutdownReason) => unknown, options?: ShutdownOptions): () => void;
213
+ /**
214
+ * Stops the process the clean way: runs the `onShutdown()` handlers, then
215
+ * exits. Use it instead of `process.exit()` when something goes wrong for
216
+ * good, so servers and databases still get closed.
217
+ *
218
+ * @example
219
+ * process.on("uncaughtException", (error) => {
220
+ * log.fatal(error);
221
+ * sys.shutdown(1);
222
+ * });
223
+ *
224
+ * @param {number} [exitCode] Defaults to the `exitCode` given to `onShutdown()`, or `0`. A failing handler makes it `1`.
225
+ * @returns {Promise<void>} Never resolves: the process exits first.
226
+ */
227
+ export function shutdown(exitCode?: number): Promise<void>;
228
+ /**
229
+ * Finds a TCP port nobody is listening on. Give a preferred port to get it
230
+ * back when it's free, and another one when it's taken.
231
+ *
232
+ * @example
233
+ * const port = await sys.freePort(3000); // 3000, or a free one if 3000 is in use
234
+ * app.listen(port);
235
+ *
236
+ * @param {number} [preferred] Tried first.
237
+ * @param {string} [host] The address to check. Defaults to all of them.
238
+ * @returns {Promise<number>}
239
+ */
240
+ export function freePort(preferred?: number, host?: string): Promise<number>;
241
+ /**
242
+ * The address of this machine on the local network, like `"192.168.1.20"`.
243
+ * It's what you print next to `localhost` so a phone on the same Wi-Fi can
244
+ * reach a dev server.
245
+ *
246
+ * @example
247
+ * console.log(`http://${sys.localIP() ?? "localhost"}:3000`);
248
+ *
249
+ * @param {4 | 6} [family=4] IPv4 or IPv6.
250
+ * @returns {string | undefined} `undefined` when the machine has no network.
251
+ */
252
+ export function localIP(family?: 4 | 6): string | undefined;
253
+ /**
254
+ * Are we on Windows?
255
+ * @returns {boolean}
256
+ */
257
+ export function isWindows(): boolean;
258
+ /**
259
+ * Are we on macOS?
260
+ * @returns {boolean}
261
+ */
262
+ export function isMac(): boolean;
263
+ /**
264
+ * Are we on Linux? WSL counts.
265
+ * @returns {boolean}
266
+ */
267
+ export function isLinux(): boolean;
268
+ /**
269
+ * Are we running in CI? Detects GitHub Actions, GitLab, CircleCI, Jenkins,
270
+ * Azure, Vercel, Netlify and more.
271
+ *
272
+ * @example
273
+ * if (sys.isCI()) nc.setLevel("warn");
274
+ *
275
+ * @returns {boolean}
276
+ */
277
+ export function isCI(): boolean;
278
+ /**
279
+ * Are we running inside a container?
280
+ *
281
+ * @returns {boolean}
282
+ */
283
+ export function isDocker(): boolean;
284
+ /**
285
+ * Are we running in WSL?
286
+ *
287
+ * @returns {boolean}
288
+ */
289
+ export function isWSL(): boolean;
290
+ /**
291
+ * Facts about the machine and the runtime, handy for bug reports.
292
+ *
293
+ * @example
294
+ * console.table(sys.info());
295
+ *
296
+ * @returns {SystemInfo}
297
+ */
298
+ export function info(): SystemInfo;
299
+ /**
300
+ * Memory used by this process, in bytes.
301
+ *
302
+ * @example
303
+ * nc.num.formatBytes(sys.memory().heapUsed); // "42.1 MB"
304
+ *
305
+ * @returns {{ rss: number, heapTotal: number, heapUsed: number, external: number, arrayBuffers: number }}
306
+ */
307
+ export function memory(): {
308
+ rss: number;
309
+ heapTotal: number;
310
+ heapUsed: number;
311
+ external: number;
312
+ arrayBuffers: number;
313
+ };
314
+ //# sourceMappingURL=Sys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sys.d.ts","sourceRoot":"","s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