@darthcav/ts-utils 0.12.3 → 1.0.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 (85) hide show
  1. package/README.md +152 -81
  2. package/dist/core/guards.d.ts +176 -0
  3. package/dist/core/guards.d.ts.map +1 -0
  4. package/dist/core/guards.js +207 -0
  5. package/dist/core/guards.js.map +1 -0
  6. package/dist/core/index.d.ts +16 -0
  7. package/dist/core/index.d.ts.map +1 -0
  8. package/dist/core/index.js +16 -0
  9. package/dist/core/index.js.map +1 -0
  10. package/dist/core/millisecondsToString.d.ts.map +1 -0
  11. package/dist/{millisecondsToString.js → core/millisecondsToString.js} +3 -4
  12. package/dist/core/millisecondsToString.js.map +1 -0
  13. package/dist/core/noop.d.ts +3 -0
  14. package/dist/core/noop.d.ts.map +1 -0
  15. package/dist/core/noop.js +3 -0
  16. package/dist/core/noop.js.map +1 -0
  17. package/dist/index.d.ts +13 -17
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +12 -10
  20. package/dist/index.js.map +1 -1
  21. package/dist/loggers/getConsoleLogger.d.ts +11 -12
  22. package/dist/loggers/getConsoleLogger.d.ts.map +1 -1
  23. package/dist/loggers/getConsoleLogger.js +14 -19
  24. package/dist/loggers/getConsoleLogger.js.map +1 -1
  25. package/dist/loggers/index.d.ts +14 -0
  26. package/dist/loggers/index.d.ts.map +1 -0
  27. package/dist/loggers/index.js +14 -0
  28. package/dist/loggers/index.js.map +1 -0
  29. package/dist/node/index.d.ts +15 -0
  30. package/dist/node/index.d.ts.map +1 -0
  31. package/dist/node/index.js +15 -0
  32. package/dist/node/index.js.map +1 -0
  33. package/dist/node/main.d.ts +156 -0
  34. package/dist/node/main.d.ts.map +1 -0
  35. package/dist/node/main.js +261 -0
  36. package/dist/node/main.js.map +1 -0
  37. package/dist/{monitorMemory.d.ts → node/monitorMemory.d.ts} +3 -5
  38. package/dist/node/monitorMemory.d.ts.map +1 -0
  39. package/dist/{monitorMemory.js → node/monitorMemory.js} +4 -7
  40. package/dist/node/monitorMemory.js.map +1 -0
  41. package/dist/node/osRelease.d.ts +55 -0
  42. package/dist/node/osRelease.d.ts.map +1 -0
  43. package/dist/{osRelease.js → node/osRelease.js} +77 -24
  44. package/dist/node/osRelease.js.map +1 -0
  45. package/dist/type-testing/index.d.ts +18 -0
  46. package/dist/type-testing/index.d.ts.map +1 -0
  47. package/dist/type-testing/index.js +12 -0
  48. package/dist/type-testing/index.js.map +1 -0
  49. package/package.json +20 -5
  50. package/src/core/guards.ts +243 -0
  51. package/src/core/index.ts +31 -0
  52. package/src/{millisecondsToString.ts → core/millisecondsToString.ts} +3 -4
  53. package/src/core/noop.ts +2 -0
  54. package/src/index.ts +13 -49
  55. package/src/loggers/getConsoleLogger.ts +14 -19
  56. package/src/loggers/index.ts +14 -0
  57. package/src/node/index.ts +21 -0
  58. package/src/node/main.ts +427 -0
  59. package/src/{monitorMemory.ts → node/monitorMemory.ts} +4 -7
  60. package/src/node/osRelease.ts +251 -0
  61. package/src/type-testing/index.ts +18 -0
  62. package/dist/main.d.ts +0 -112
  63. package/dist/main.d.ts.map +0 -1
  64. package/dist/main.js +0 -219
  65. package/dist/main.js.map +0 -1
  66. package/dist/millisecondsToString.d.ts.map +0 -1
  67. package/dist/millisecondsToString.js.map +0 -1
  68. package/dist/monitorMemory.d.ts.map +0 -1
  69. package/dist/monitorMemory.js.map +0 -1
  70. package/dist/noop.d.ts +0 -7
  71. package/dist/noop.d.ts.map +0 -1
  72. package/dist/noop.js +0 -7
  73. package/dist/noop.js.map +0 -1
  74. package/dist/osRelease.d.ts +0 -46
  75. package/dist/osRelease.d.ts.map +0 -1
  76. package/dist/osRelease.js.map +0 -1
  77. package/dist/types.d.ts +0 -70
  78. package/dist/types.d.ts.map +0 -1
  79. package/dist/types.js +0 -84
  80. package/dist/types.js.map +0 -1
  81. package/src/main.ts +0 -302
  82. package/src/noop.ts +0 -6
  83. package/src/osRelease.ts +0 -174
  84. package/src/types.ts +0 -98
  85. /package/dist/{millisecondsToString.d.ts → core/millisecondsToString.d.ts} +0 -0
@@ -0,0 +1,251 @@
1
+ import { readFileSync } from "node:fs"
2
+ import { arch, release as kernelRelease, platform } from "node:os"
3
+ import type { RuntimeObject } from "../core/guards.ts"
4
+
5
+ /**
6
+ * OS release information: the normalized `name`, `version`, and `arch`, plus
7
+ * the platform's raw keys by string index:
8
+ *
9
+ * - On Linux, the keys read from the os-release file (`/etc/os-release`, or
10
+ * `/usr/lib/os-release` as a fallback; e.g. `ID`, `PRETTY_NAME`,
11
+ * `ID_LIKE`).
12
+ * - On macOS, the string keys of
13
+ * `/System/Library/CoreServices/SystemVersion.plist` (e.g. `ProductName`,
14
+ * `ProductVersion`, `ProductBuildVersion`).
15
+ */
16
+ export type OsRelease = {
17
+ /** Human-readable OS name, e.g. `"Ubuntu"`, `"macOS"`, or `"Windows 11"`. */
18
+ name: string
19
+ /**
20
+ * OS version string, e.g. `"24.04"`, `"15.1"`, or `"10.0.22000"`. On
21
+ * macOS it is the product version, not the Darwin kernel version (which
22
+ * `os.release()` returns).
23
+ */
24
+ version: string
25
+ /** Processor architecture as returned by `os.arch()`, e.g. `"x64"`. */
26
+ arch: string
27
+ } & RuntimeObject
28
+
29
+ /**
30
+ * Candidate os-release files, in lookup order. Per the freedesktop.org spec,
31
+ * `/etc/os-release` takes precedence and `/usr/lib/os-release` is the fallback.
32
+ */
33
+ const OS_RELEASE_FILES = ["/etc/os-release", "/usr/lib/os-release"] as const
34
+
35
+ /**
36
+ * Valid os-release keys: shell-compatible, upper-case variable names. This
37
+ * also rules out keys such as `__proto__` or `constructor`.
38
+ */
39
+ const OS_RELEASE_KEY = /^[A-Z][A-Z0-9_]*$/
40
+
41
+ /** The macOS property list with the product name and version. */
42
+ const MACOS_SYSTEM_VERSION_FILE =
43
+ "/System/Library/CoreServices/SystemVersion.plist"
44
+
45
+ /** A `<key>…</key>` followed by a `<string>…</string>` value in a plist. */
46
+ const PLIST_STRING_ENTRY = /<key>([^<]*)<\/key>\s*<string>([^<]*)<\/string>/g
47
+
48
+ /** Valid plist keys to copy; this also rules out keys such as `__proto__`. */
49
+ const PLIST_KEY = /^[A-Za-z][A-Za-z0-9_]*$/
50
+
51
+ /** The predefined XML entities. */
52
+ const XML_ENTITIES: Readonly<Record<string, string>> = {
53
+ amp: "&",
54
+ apos: "'",
55
+ gt: ">",
56
+ lt: "<",
57
+ quot: '"',
58
+ }
59
+
60
+ /** Reads the first readable file of `files`, or returns `null` if none is. */
61
+ function readFirstFile(files: readonly string[]): string | null {
62
+ for (const file of files) {
63
+ try {
64
+ return readFileSync(file, "utf-8")
65
+ } catch {
66
+ // Try the next candidate.
67
+ }
68
+ }
69
+ return null
70
+ }
71
+
72
+ /** Decodes the predefined and numeric character references of XML text. */
73
+ function decodeXml(text: string): string {
74
+ return text.replace(
75
+ /&(?:#x([0-9a-fA-F]+)|#([0-9]+)|([a-z]+));/g,
76
+ (match, hex?: string, decimal?: string, name?: string) => {
77
+ if (hex !== undefined || decimal !== undefined) {
78
+ const codePoint = Number.parseInt(
79
+ hex ?? decimal ?? "",
80
+ hex === undefined ? 10 : 16,
81
+ )
82
+ return codePoint <= 0x10ffff
83
+ ? String.fromCodePoint(codePoint)
84
+ : match
85
+ }
86
+ return (
87
+ (name !== undefined && Object.hasOwn(XML_ENTITIES, name)
88
+ ? XML_ENTITIES[name]
89
+ : undefined) ?? match
90
+ )
91
+ },
92
+ )
93
+ }
94
+
95
+ /**
96
+ * Parses the `<string>` entries of an XML property list into a
97
+ * null-prototype record, skipping other value types and invalid keys.
98
+ */
99
+ function parsePlistStrings(content: string): Record<string, string> {
100
+ const raw: Record<string, string> = Object.create(null)
101
+ for (const [, rawKey = "", value = ""] of content.matchAll(
102
+ PLIST_STRING_ENTRY,
103
+ )) {
104
+ const key = decodeXml(rawKey.trim())
105
+ if (PLIST_KEY.test(key)) {
106
+ raw[key] = decodeXml(value.trim())
107
+ }
108
+ }
109
+ return raw
110
+ }
111
+
112
+ /**
113
+ * Removes one level of shell-style quoting from an os-release value. Double
114
+ * quotes allow the `\\`, `\"`, `` \` `` and `\$` escapes; single quotes are
115
+ * literal.
116
+ */
117
+ function unquote(value: string): string {
118
+ if (value.length >= 2) {
119
+ const quote = value[0]
120
+ if (quote === '"' && value.endsWith('"')) {
121
+ return value.slice(1, -1).replace(/\\([\\"`$])/g, "$1")
122
+ }
123
+ if (quote === "'" && value.endsWith("'")) {
124
+ return value.slice(1, -1)
125
+ }
126
+ }
127
+ return value
128
+ }
129
+
130
+ /**
131
+ * Parses os-release content into a null-prototype record, skipping blank
132
+ * lines, comments, lines without `=`, and invalid keys.
133
+ */
134
+ function parseOsRelease(content: string): Record<string, string> {
135
+ const raw: Record<string, string> = Object.create(null)
136
+ for (const line of content.split("\n")) {
137
+ const trimmed = line.trim()
138
+ if (trimmed === "" || trimmed.startsWith("#")) {
139
+ continue
140
+ }
141
+ const eq = trimmed.indexOf("=")
142
+ if (eq === -1) {
143
+ continue
144
+ }
145
+ const key = trimmed.substring(0, eq).trim()
146
+ if (!OS_RELEASE_KEY.test(key)) {
147
+ continue
148
+ }
149
+ raw[key] = unquote(trimmed.substring(eq + 1).trim())
150
+ }
151
+ return raw
152
+ }
153
+
154
+ /**
155
+ * Returns OS release information for the current platform (Linux, macOS, or
156
+ * Windows). `arch` always comes from `os.arch()`.
157
+ *
158
+ * - On Linux, it reads `/etc/os-release`, falling back to
159
+ * `/usr/lib/os-release`. `name` comes from `NAME` (or `PRETTY_NAME`) and
160
+ * `version` from `VERSION_ID` (or `VERSION`). Values are unquoted as in a
161
+ * shell; comments and keys that are not upper-case variable names are
162
+ * skipped.
163
+ * - On macOS, it reads `/System/Library/CoreServices/SystemVersion.plist`.
164
+ * `name` is `ProductName` (or `"macOS"`) and `version` is
165
+ * `ProductVersion` (e.g. `"15.1"`), never the Darwin kernel version.
166
+ * - On Windows, `version` is the kernel version, and Windows 11 is told
167
+ * apart from Windows 10 by NT build number (>= 22000).
168
+ *
169
+ * On Linux and macOS, the raw keys of the file are also present.
170
+ *
171
+ * @returns An {@link OsRelease}, or `null` on unsupported platforms or when
172
+ * the release file cannot be read.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * import { osRelease } from "@darthcav/ts-utils"
177
+ *
178
+ * const info = osRelease()
179
+ * if (info) console.log(info.name) // e.g. "Ubuntu", "macOS", or "Windows 11"
180
+ * if (info) console.log(info.PRETTY_NAME) // e.g. "Ubuntu 24.04 LTS" (Linux only)
181
+ * ```
182
+ */
183
+ export function osRelease(): OsRelease | null {
184
+ const p = platform()
185
+ if (p === "linux") {
186
+ const content = readFirstFile(OS_RELEASE_FILES)
187
+ if (content === null) {
188
+ return null
189
+ }
190
+ const raw = parseOsRelease(content)
191
+ return {
192
+ ...raw,
193
+ name: raw["NAME"] ?? raw["PRETTY_NAME"] ?? "",
194
+ version: raw["VERSION_ID"] ?? raw["VERSION"] ?? "",
195
+ arch: arch(),
196
+ }
197
+ }
198
+ if (p === "darwin") {
199
+ const content = readFirstFile([MACOS_SYSTEM_VERSION_FILE])
200
+ if (content === null) {
201
+ return null
202
+ }
203
+ const raw = parsePlistStrings(content)
204
+ return {
205
+ ...raw,
206
+ name: raw["ProductName"] || "macOS",
207
+ version: raw["ProductVersion"] ?? "",
208
+ arch: arch(),
209
+ }
210
+ }
211
+ if (p === "win32") {
212
+ const version = kernelRelease()
213
+ const [major, , build] = version.split(".").map(Number)
214
+ let name = "Windows "
215
+ if (major === 10 && (build ?? 0) >= 22000) {
216
+ name += "11"
217
+ } else {
218
+ switch (version.substring(0, 3)) {
219
+ case "10.":
220
+ name += "10"
221
+ break
222
+ case "6.3":
223
+ name += "8.1"
224
+ break
225
+ case "6.2":
226
+ name += "8"
227
+ break
228
+ case "6.1":
229
+ name += "7"
230
+ break
231
+ case "6.0":
232
+ name += "Vista"
233
+ break
234
+ case "5.2":
235
+ name += "XP 64-Bit Edition"
236
+ break
237
+ case "5.1":
238
+ name += "XP"
239
+ break
240
+ case "5.0":
241
+ name += "2000"
242
+ break
243
+ default:
244
+ name += "unknown version"
245
+ break
246
+ }
247
+ }
248
+ return { name, version, arch: arch() }
249
+ }
250
+ return null
251
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Type-level testing helpers. They are types only and add no code at runtime.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import type { Assert, Equal } from "@darthcav/ts-utils/type-testing"
7
+ * ```
8
+ *
9
+ * @module type-testing
10
+ */
11
+
12
+ export type { Assert } from "./Assert.ts"
13
+ export type { Equal } from "./Equal.ts"
14
+ export type { Extends } from "./Extends.ts"
15
+ export type { IsAny } from "./IsAny.ts"
16
+ export type { IsNever } from "./IsNever.ts"
17
+ export type { IsUnknown } from "./IsUnknown.ts"
18
+ export type { Not } from "./Not.ts"
package/dist/main.d.ts DELETED
@@ -1,112 +0,0 @@
1
- import { type Logger } from "@logtape/logtape";
2
- /**
3
- * A function that performs the actual application launch after process
4
- * lifecycle handlers have been set up by {@link main}. Use a closure to
5
- * capture any context needed (e.g. a logger).
6
- *
7
- * It may be asynchronous: if it throws or its promise rejects, {@link main}
8
- * logs the failure and exits the process with status `1`.
9
- */
10
- export type LauncherFunction = () => void | Promise<void>;
11
- /**
12
- * Options for {@link main}. All of them are optional.
13
- */
14
- export type MainOptions = {
15
- /**
16
- * Function invoked after all process handlers are registered. Use a
17
- * closure to capture any context needed (e.g. a logger).
18
- */
19
- launcher?: LauncherFunction;
20
- /**
21
- * When greater than `0`, starts periodic memory logging every
22
- * `monitorMemoryHours` hours via {@link monitorMemory} (which validates
23
- * the value). Must be `0` or a positive finite number; negative values
24
- * and `NaN` throw. Defaults to `0` (disabled).
25
- */
26
- monitorMemoryHours?: number;
27
- /**
28
- * When `true` (default), registers `SIGINT` and `SIGTERM` handlers that
29
- * log, flush the logs, and stop the process. Set to `false` when the
30
- * application manages its own graceful shutdown (e.g. closing servers or
31
- * database connections).
32
- */
33
- defaultInterruptionHandler?: boolean;
34
- /**
35
- * Maximum time in milliseconds to wait for the logtape sinks to flush
36
- * before the process exits. Must be between `0` and 2³¹ − 1. Defaults to
37
- * `3000`.
38
- */
39
- flushTimeoutMs?: number;
40
- };
41
- /**
42
- * Bootstraps an application process: logs startup information, optionally
43
- * registers handlers for `SIGINT` and `SIGTERM` (see
44
- * {@link MainOptions.defaultInterruptionHandler}), always registers handlers
45
- * for `uncaughtException` and `unhandledRejection`, optionally starts memory
46
- * monitoring, then runs the optional launcher function.
47
- *
48
- * The process title, PID, name, and `NODE_ENV` are logged at `info` level.
49
- * The Node.js process options (`execArgv` and `NODE_OPTIONS`) are logged at
50
- * `debug` level only, since they can reveal sensitive flags such as
51
- * `--inspect=0.0.0.0` or `--require` paths.
52
- *
53
- * Before the process exits, the configured logtape sinks are flushed and
54
- * disposed (for at most `flushTimeoutMs`, 3 seconds by default), so buffered
55
- * or asynchronous sinks do not lose the final messages. On `SIGINT`/`SIGTERM`
56
- * the signal is logged at `info` level and then re-raised, so the process ends
57
- * as killed by that signal (exit status 130/143), which shells and
58
- * supervisors such as systemd treat as a clean stop. If another listener for
59
- * that signal is registered, the process exits with status
60
- * `128 + signal number` instead. Uncaught exceptions, unhandled rejections,
61
- * and launcher failures exit with status `1`. A second signal or error during
62
- * the flush exits immediately.
63
- *
64
- * Only one `main` call can be active at a time: calling it again before
65
- * running the returned teardown function throws, instead of registering a
66
- * second set of handlers.
67
- *
68
- * @param name - Human-readable application name used in log output.
69
- * @param logger - Logger instance used for all startup and lifecycle messages.
70
- * @param options - Optional {@link MainOptions}.
71
- * @returns A teardown function that removes the process handlers registered
72
- * by this call and stops the memory monitoring, allowing `main` to be called
73
- * again (e.g. in tests). It does not exit the process; calling it more than
74
- * once is harmless.
75
- * @throws {TypeError} If `options` is not an object.
76
- * @throws {Error} If another `main` call is still active.
77
- * @throws {RangeError} If `monitorMemoryHours` or `flushTimeoutMs` is out of
78
- * range. Nothing is registered in that case.
79
- *
80
- * @example Without options:
81
- * ```ts
82
- * main("my-app", logger)
83
- * ```
84
- *
85
- * @example With an async launcher and memory monitoring every 2 hours:
86
- * ```ts
87
- * main("my-app", logger, {
88
- * launcher: async () => {
89
- * await connectToDatabase()
90
- * startServer()
91
- * },
92
- * monitorMemoryHours: 2,
93
- * })
94
- * ```
95
- *
96
- * @example Managing graceful shutdown in the application:
97
- * ```ts
98
- * let server: Server | undefined
99
- * const teardown = main("my-app", logger, {
100
- * launcher: () => {
101
- * server = startServer()
102
- * },
103
- * defaultInterruptionHandler: false,
104
- * })
105
- * process.once("SIGTERM", async () => {
106
- * await server?.close()
107
- * teardown()
108
- * })
109
- * ```
110
- */
111
- export declare function main(name: string, logger: Logger, options?: MainOptions): () => void;
112
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAA;AA8CvD;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEzD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IAC3B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,wBAAgB,IAAI,CAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,WAAW,GACtB,MAAM,IAAI,CA0IZ"}
package/dist/main.js DELETED
@@ -1,219 +0,0 @@
1
- import { constants } from "node:os";
2
- import process, { env, execArgv, pid, title } from "node:process";
3
- import { dispose } from "@logtape/logtape";
4
- import { monitorMemory } from "./monitorMemory.js";
5
- /**
6
- * Default upper bound for flushing log sinks before the process exits, so a
7
- * hanging sink cannot block shutdown.
8
- */
9
- const DEFAULT_FLUSH_TIMEOUT_MS = 3_000;
10
- /**
11
- * Longest delay `setTimeout` supports (2³¹ − 1 ms). Node.js silently replaces
12
- * larger delays with 1 ms.
13
- */
14
- const MAX_FLUSH_TIMEOUT_MS = 2_147_483_647;
15
- /** Whether a {@link main} call is active, i.e. not yet torn down. */
16
- let active = false;
17
- /**
18
- * Flushes and disposes the configured logtape sinks, giving up after
19
- * `timeoutMs`. Never rejects: logging is best effort while the process is
20
- * shutting down.
21
- */
22
- async function flushLogs(timeoutMs) {
23
- let timer;
24
- try {
25
- await Promise.race([
26
- dispose(),
27
- new Promise((resolve) => {
28
- timer = setTimeout(resolve, timeoutMs);
29
- }),
30
- ]);
31
- }
32
- catch {
33
- // Ignore sink errors: the process is exiting anyway.
34
- }
35
- finally {
36
- clearTimeout(timer);
37
- }
38
- }
39
- /** Renders an error (with its stack when available) or any other value. */
40
- function describe(value) {
41
- return value instanceof Error
42
- ? (value.stack ?? String(value))
43
- : String(value);
44
- }
45
- /**
46
- * Bootstraps an application process: logs startup information, optionally
47
- * registers handlers for `SIGINT` and `SIGTERM` (see
48
- * {@link MainOptions.defaultInterruptionHandler}), always registers handlers
49
- * for `uncaughtException` and `unhandledRejection`, optionally starts memory
50
- * monitoring, then runs the optional launcher function.
51
- *
52
- * The process title, PID, name, and `NODE_ENV` are logged at `info` level.
53
- * The Node.js process options (`execArgv` and `NODE_OPTIONS`) are logged at
54
- * `debug` level only, since they can reveal sensitive flags such as
55
- * `--inspect=0.0.0.0` or `--require` paths.
56
- *
57
- * Before the process exits, the configured logtape sinks are flushed and
58
- * disposed (for at most `flushTimeoutMs`, 3 seconds by default), so buffered
59
- * or asynchronous sinks do not lose the final messages. On `SIGINT`/`SIGTERM`
60
- * the signal is logged at `info` level and then re-raised, so the process ends
61
- * as killed by that signal (exit status 130/143), which shells and
62
- * supervisors such as systemd treat as a clean stop. If another listener for
63
- * that signal is registered, the process exits with status
64
- * `128 + signal number` instead. Uncaught exceptions, unhandled rejections,
65
- * and launcher failures exit with status `1`. A second signal or error during
66
- * the flush exits immediately.
67
- *
68
- * Only one `main` call can be active at a time: calling it again before
69
- * running the returned teardown function throws, instead of registering a
70
- * second set of handlers.
71
- *
72
- * @param name - Human-readable application name used in log output.
73
- * @param logger - Logger instance used for all startup and lifecycle messages.
74
- * @param options - Optional {@link MainOptions}.
75
- * @returns A teardown function that removes the process handlers registered
76
- * by this call and stops the memory monitoring, allowing `main` to be called
77
- * again (e.g. in tests). It does not exit the process; calling it more than
78
- * once is harmless.
79
- * @throws {TypeError} If `options` is not an object.
80
- * @throws {Error} If another `main` call is still active.
81
- * @throws {RangeError} If `monitorMemoryHours` or `flushTimeoutMs` is out of
82
- * range. Nothing is registered in that case.
83
- *
84
- * @example Without options:
85
- * ```ts
86
- * main("my-app", logger)
87
- * ```
88
- *
89
- * @example With an async launcher and memory monitoring every 2 hours:
90
- * ```ts
91
- * main("my-app", logger, {
92
- * launcher: async () => {
93
- * await connectToDatabase()
94
- * startServer()
95
- * },
96
- * monitorMemoryHours: 2,
97
- * })
98
- * ```
99
- *
100
- * @example Managing graceful shutdown in the application:
101
- * ```ts
102
- * let server: Server | undefined
103
- * const teardown = main("my-app", logger, {
104
- * launcher: () => {
105
- * server = startServer()
106
- * },
107
- * defaultInterruptionHandler: false,
108
- * })
109
- * process.once("SIGTERM", async () => {
110
- * await server?.close()
111
- * teardown()
112
- * })
113
- * ```
114
- */
115
- export function main(name, logger, options) {
116
- // Rejects the positional arguments removed in 0.11.0 (e.g. a launcher
117
- // function) from untyped callers, instead of silently ignoring them.
118
- if (options !== undefined &&
119
- (typeof options !== "object" || options === null)) {
120
- throw new TypeError(`main: "options" must be a MainOptions object, received ${options === null ? "null" : typeof options}`);
121
- }
122
- const { launcher, monitorMemoryHours = 0, defaultInterruptionHandler = true, flushTimeoutMs = DEFAULT_FLUSH_TIMEOUT_MS, } = options ?? {};
123
- // Positive values are validated further by `monitorMemory`.
124
- if (!Number.isFinite(monitorMemoryHours) || monitorMemoryHours < 0) {
125
- throw new RangeError(`main: "monitorMemoryHours" must be 0 (disabled) or a positive finite number, received ${monitorMemoryHours}`);
126
- }
127
- if (!Number.isFinite(flushTimeoutMs) ||
128
- flushTimeoutMs < 0 ||
129
- flushTimeoutMs > MAX_FLUSH_TIMEOUT_MS) {
130
- throw new RangeError(`main: "flushTimeoutMs" must be a finite number between 0 and ${MAX_FLUSH_TIMEOUT_MS}, received ${flushTimeoutMs}`);
131
- }
132
- if (active) {
133
- throw new Error("main: already active; call the teardown function returned by the previous main() call first");
134
- }
135
- const __logger = logger.getChild(["main"]);
136
- __logger.info `Main process launched [${title} :: ${pid}]`;
137
- __logger.info `Process name: ${name}`;
138
- __logger.info `Node.js environment: ${env["NODE_ENV"] ?? ""}`;
139
- // Process options can reveal sensitive flags (e.g. `--inspect=0.0.0.0`
140
- // or `--require` paths), so they are only logged at debug level.
141
- __logger.debug `Node.js process options: ${execArgv.concat(env["NODE_OPTIONS"] ?? []).join(" | ")}`;
142
- // Started before any handler is registered: it throws on invalid hours.
143
- const stopMonitoring = monitorMemoryHours > 0
144
- ? monitorMemory(__logger, monitorMemoryHours)
145
- : undefined;
146
- // Set once a shutdown starts: a second signal or error while the logs are
147
- // being flushed exits immediately instead of waiting again.
148
- let shuttingDown = false;
149
- const exitAfterFlush = async (exit) => {
150
- if (!shuttingDown) {
151
- shuttingDown = true;
152
- await flushLogs(flushTimeoutMs);
153
- }
154
- exit();
155
- };
156
- const removeListeners = [];
157
- if (defaultInterruptionHandler) {
158
- for (const signal of ["SIGINT", "SIGTERM"]) {
159
- const onSignal = () => {
160
- __logger.info `Process interrupted. Received signal: ${signal}`;
161
- return exitAfterFlush(() => {
162
- // Re-raise the signal with its default disposition so the
163
- // process ends as killed by it. Exit with the conventional
164
- // status instead if another listener would intercept it.
165
- process.off(signal, onSignal);
166
- if (process.listenerCount(signal) === 0) {
167
- process.kill(pid, signal);
168
- }
169
- else {
170
- process.exit(128 + constants.signals[signal]);
171
- }
172
- });
173
- };
174
- process.on(signal, onSignal);
175
- removeListeners.push(() => process.off(signal, onSignal));
176
- }
177
- }
178
- const onUncaughtException = (error, origin) => {
179
- __logger.error `Uncaught exception: ${describe(error)}`;
180
- __logger.error `Exception origin: ${origin}`;
181
- return exitAfterFlush(() => process.exit(1));
182
- };
183
- process.on("uncaughtException", onUncaughtException);
184
- removeListeners.push(() => process.off("uncaughtException", onUncaughtException));
185
- const onUnhandledRejection = (reason) => {
186
- __logger.error `Unhandled promise rejection. Reason:\n${describe(reason)}`;
187
- return exitAfterFlush(() => process.exit(1));
188
- };
189
- process.on("unhandledRejection", onUnhandledRejection);
190
- removeListeners.push(() => process.off("unhandledRejection", onUnhandledRejection));
191
- active = true;
192
- let tornDown = false;
193
- const teardown = () => {
194
- if (tornDown) {
195
- return;
196
- }
197
- tornDown = true;
198
- stopMonitoring?.();
199
- for (const remove of removeListeners) {
200
- remove();
201
- }
202
- active = false;
203
- };
204
- const onLauncherFailure = (error) => {
205
- __logger.error `Launcher failed: ${describe(error)}`;
206
- return exitAfterFlush(() => process.exit(1));
207
- };
208
- try {
209
- const result = launcher?.();
210
- if (result !== undefined) {
211
- Promise.resolve(result).catch(onLauncherFailure);
212
- }
213
- }
214
- catch (error) {
215
- void onLauncherFailure(error);
216
- }
217
- return teardown;
218
- }
219
- //# sourceMappingURL=main.js.map
package/dist/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,OAAO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AG,KAAK,CAAA;IAClB,CAAC,CAAA;IAED,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAiB,EAAE;QACxD,QAAQ,CAAC,KAAK,CAAA,oBAAoB,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAA;QACnD,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC,CAAA;IACD,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,EAAE,EAAE,CAAA;QAC3B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACpD,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,KAAK,iBAAiB,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC;IAED,OAAO,QAAQ,CAAA;AACnB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"millisecondsToString.d.ts","sourceRoot":"","sources":["../src/millisecondsToString.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,CAmBtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"millisecondsToString.js","sourceRoot":"","sources":["../src/millisecondsToString.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAA;AAEjE,SAAS,oBAAoB,CAAC,MAAc;IACxC,IAAI,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAI,CAAC;YACD,SAAS,GAAG,IAAI,IAAI,CAAC,cA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AS,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC;QACrD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;QAChD,YAAY,EAAE,SAAS,GAAG,IAAI;KACjC,CAAC,CAAA;IAEF,OAAO,iBAAiB,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3E,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"monitorMemory.d.ts","sourceRoot":"","sources":["../src/monitorMemory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAY9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,MAAM,IAAI,CAiC5E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"monitorMemory.js","sourceRoot":"","sources":["../src/monitorMemory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,uDAAuD;AACvD,MAAM,YAAY,GAAG,EAAE,GAAG,KAAK,CAAA;AAE/B;;;GAGG;AACH,MAAM,YAAY,GAAG,aAAa,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,QAAgB,EAAE;IAC5D,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,KAAK,CAAA;IACrC,IACI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACvB,KAAK,GAAG,YAAY;QACpB,KAAK,GAAG,YAAY,EACtB,CAAC;QACC,MAAM,IAAI,UAAU,CAChB,0DAA0D,YAAY,GAAG,SAAS,QAAQ,YAAY,GAAG,SAAS,wCAAwC,KAAK,EAAE,CACpK,CAAA;IACL,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,CAAA;IAEnD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAA;QAC7C,MAAM,eAAe,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;QACtD,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAA;QAC5D,kEAAkE;QAClE,qEAAqE;QACrE,iEAAiE;QACjE,QAAQ,CAAC,IAAI,CAAC,mBAAmB,eAAe,EAAE,EAAE;YAChD,MAAM,EAAE,eAAe;YACvB,QAAQ;SACX,CAAC,CAAA;QACF,QAAQ,CAAC,IAAI,CACT,oHAAoH,EACpH,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CACzC,CAAA;IACL,CAAC,EAAE,KAAK,CAAC,CAAA;IACT,oDAAoD;IACpD,KAAK,CAAC,KAAK,EAAE,CAAA;IAEb,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACrC,CAAC"}
package/dist/noop.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * A no-op function that does nothing and returns `void`.
3
- *
4
- * Useful as a placeholder callback, default handler, or in tests.
5
- */
6
- export declare const noop: () => void;
7
- //# sourceMappingURL=noop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../src/noop.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,IAAI,QAAO,IAAU,CAAA"}
package/dist/noop.js DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * A no-op function that does nothing and returns `void`.
3
- *
4
- * Useful as a placeholder callback, default handler, or in tests.
5
- */
6
- export const noop = () => { };
7
- //# sourceMappingURL=noop.js.map
package/dist/noop.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"noop.js","sourceRoot":"","sources":["../src/noop.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAA"}