@darthcav/ts-utils 0.12.3 → 1.0.1

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 (96) hide show
  1. package/README.md +162 -84
  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 +201 -0
  5. package/dist/core/guards.js.map +1 -0
  6. package/dist/core/index.d.ts +17 -0
  7. package/dist/core/index.d.ts.map +1 -0
  8. package/dist/core/index.js +17 -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} +9 -14
  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/delays.d.ts +11 -0
  30. package/dist/node/delays.d.ts.map +1 -0
  31. package/dist/node/delays.js +14 -0
  32. package/dist/node/delays.js.map +1 -0
  33. package/dist/node/index.d.ts +15 -0
  34. package/dist/node/index.d.ts.map +1 -0
  35. package/dist/node/index.js +15 -0
  36. package/dist/node/index.js.map +1 -0
  37. package/dist/node/main.d.ts +158 -0
  38. package/dist/node/main.d.ts.map +1 -0
  39. package/dist/node/main.js +255 -0
  40. package/dist/node/main.js.map +1 -0
  41. package/dist/{monitorMemory.d.ts → node/monitorMemory.d.ts} +14 -5
  42. package/dist/node/monitorMemory.d.ts.map +1 -0
  43. package/dist/{monitorMemory.js → node/monitorMemory.js} +22 -16
  44. package/dist/node/monitorMemory.js.map +1 -0
  45. package/dist/node/osRelease.d.ts +58 -0
  46. package/dist/node/osRelease.d.ts.map +1 -0
  47. package/dist/node/osRelease.js +111 -0
  48. package/dist/node/osRelease.js.map +1 -0
  49. package/dist/node/releaseParsers.d.ts +11 -0
  50. package/dist/node/releaseParsers.d.ts.map +1 -0
  51. package/dist/node/releaseParsers.js +92 -0
  52. package/dist/node/releaseParsers.js.map +1 -0
  53. package/dist/type-testing/index.d.ts +18 -0
  54. package/dist/type-testing/index.d.ts.map +1 -0
  55. package/dist/type-testing/index.js +12 -0
  56. package/dist/type-testing/index.js.map +1 -0
  57. package/package.json +22 -7
  58. package/src/core/guards.ts +239 -0
  59. package/src/core/index.ts +32 -0
  60. package/src/{millisecondsToString.ts → core/millisecondsToString.ts} +9 -16
  61. package/src/core/noop.ts +2 -0
  62. package/src/index.ts +13 -49
  63. package/src/loggers/getConsoleLogger.ts +14 -19
  64. package/src/loggers/index.ts +14 -0
  65. package/src/node/delays.ts +15 -0
  66. package/src/node/index.ts +21 -0
  67. package/src/node/main.ts +419 -0
  68. package/src/{monitorMemory.ts → node/monitorMemory.ts} +24 -18
  69. package/src/node/osRelease.ts +152 -0
  70. package/src/node/releaseParsers.ts +109 -0
  71. package/src/type-testing/index.ts +18 -0
  72. package/dist/main.d.ts +0 -112
  73. package/dist/main.d.ts.map +0 -1
  74. package/dist/main.js +0 -219
  75. package/dist/main.js.map +0 -1
  76. package/dist/millisecondsToString.d.ts.map +0 -1
  77. package/dist/millisecondsToString.js.map +0 -1
  78. package/dist/monitorMemory.d.ts.map +0 -1
  79. package/dist/monitorMemory.js.map +0 -1
  80. package/dist/noop.d.ts +0 -7
  81. package/dist/noop.d.ts.map +0 -1
  82. package/dist/noop.js +0 -7
  83. package/dist/noop.js.map +0 -1
  84. package/dist/osRelease.d.ts +0 -46
  85. package/dist/osRelease.d.ts.map +0 -1
  86. package/dist/osRelease.js +0 -153
  87. package/dist/osRelease.js.map +0 -1
  88. package/dist/types.d.ts +0 -70
  89. package/dist/types.d.ts.map +0 -1
  90. package/dist/types.js +0 -84
  91. package/dist/types.js.map +0 -1
  92. package/src/main.ts +0 -302
  93. package/src/noop.ts +0 -6
  94. package/src/osRelease.ts +0 -174
  95. package/src/types.ts +0 -98
  96. /package/dist/{millisecondsToString.d.ts → core/millisecondsToString.d.ts} +0 -0
@@ -0,0 +1,152 @@
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
+ import { parseOsRelease, parsePlistStrings } from "./releaseParsers.ts"
5
+
6
+ /**
7
+ * OS release information: the normalized `name`, `version`, and `arch`, plus
8
+ * the platform's raw keys by string index:
9
+ *
10
+ * - On Linux, the keys read from the os-release file (`/etc/os-release`, or
11
+ * `/usr/lib/os-release` as a fallback; e.g. `ID`, `PRETTY_NAME`,
12
+ * `ID_LIKE`).
13
+ * - On macOS, the string keys of
14
+ * `/System/Library/CoreServices/SystemVersion.plist` (e.g. `ProductName`,
15
+ * `ProductVersion`, `ProductBuildVersion`).
16
+ */
17
+ export type OsRelease = {
18
+ /** Human-readable OS name, e.g. `"Ubuntu"`, `"macOS"`, or `"Windows 11"`. */
19
+ name: string
20
+ /**
21
+ * OS version string, e.g. `"24.04"`, `"15.1"`, or `"10.0.22000"`. On
22
+ * macOS it is the product version, not the Darwin kernel version (which
23
+ * `os.release()` returns).
24
+ */
25
+ version: string
26
+ /** Processor architecture as returned by `os.arch()`, e.g. `"x64"`. */
27
+ arch: string
28
+ } & RuntimeObject
29
+
30
+ /** Where a platform keeps its release file, and how to read it. */
31
+ type ReleaseFile = {
32
+ /** Candidate files, in lookup order. */
33
+ readonly files: readonly string[]
34
+ /** Parses the file content into a null-prototype record of raw keys. */
35
+ readonly parse: (content: string) => Record<string, string>
36
+ /** Picks the normalized `name` from the raw keys. */
37
+ readonly name: (raw: Record<string, string>) => string
38
+ /** Picks the normalized `version` from the raw keys. */
39
+ readonly version: (raw: Record<string, string>) => string
40
+ }
41
+
42
+ /** The platforms whose release information comes from a file. */
43
+ const RELEASE_FILES: Readonly<Partial<Record<NodeJS.Platform, ReleaseFile>>> = {
44
+ linux: {
45
+ // Per the freedesktop.org spec, `/etc/os-release` takes precedence and
46
+ // `/usr/lib/os-release` is the fallback.
47
+ files: ["/etc/os-release", "/usr/lib/os-release"],
48
+ parse: parseOsRelease,
49
+ name: (raw) => raw["NAME"] ?? raw["PRETTY_NAME"] ?? "",
50
+ version: (raw) => raw["VERSION_ID"] ?? raw["VERSION"] ?? "",
51
+ },
52
+ darwin: {
53
+ files: ["/System/Library/CoreServices/SystemVersion.plist"],
54
+ parse: parsePlistStrings,
55
+ name: (raw) => raw["ProductName"] || "macOS",
56
+ version: (raw) => raw["ProductVersion"] ?? "",
57
+ },
58
+ }
59
+
60
+ /**
61
+ * Windows names by the first three characters of the kernel version. Windows
62
+ * 11 also reports `10.`, so it is told apart by build number.
63
+ */
64
+ const WINDOWS_NAMES: ReadonlyMap<string, string> = new Map([
65
+ ["10.", "10"],
66
+ ["6.3", "8.1"],
67
+ ["6.2", "8"],
68
+ ["6.1", "7"],
69
+ ["6.0", "Vista"],
70
+ ["5.2", "XP 64-Bit Edition"],
71
+ ["5.1", "XP"],
72
+ ["5.0", "2000"],
73
+ ])
74
+
75
+ /** First Windows 11 build number. */
76
+ const WINDOWS_11_BUILD = 22000
77
+
78
+ /** Reads the first readable file of `files`, or returns `null` if none is. */
79
+ function readFirstFile(files: readonly string[]): string | null {
80
+ for (const file of files) {
81
+ try {
82
+ return readFileSync(file, "utf-8")
83
+ } catch {
84
+ // Try the next candidate.
85
+ }
86
+ }
87
+ return null
88
+ }
89
+
90
+ /** Maps a Windows kernel version (e.g. `"10.0.22000"`) to a product name. */
91
+ function windowsName(version: string): string {
92
+ const [major, , build = 0] = version.split(".").map(Number)
93
+ if (major === 10 && build >= WINDOWS_11_BUILD) {
94
+ return "Windows 11"
95
+ }
96
+ return `Windows ${WINDOWS_NAMES.get(version.substring(0, 3)) ?? "unknown version"}`
97
+ }
98
+
99
+ /**
100
+ * Returns OS release information for the current platform (Linux, macOS, or
101
+ * Windows). `arch` always comes from `os.arch()`.
102
+ *
103
+ * - On Linux, it reads `/etc/os-release`, falling back to
104
+ * `/usr/lib/os-release`. `name` comes from `NAME` (or `PRETTY_NAME`) and
105
+ * `version` from `VERSION_ID` (or `VERSION`). Values are unquoted as in a
106
+ * shell; comments and keys that are not upper-case variable names are
107
+ * skipped.
108
+ * - On macOS, it reads `/System/Library/CoreServices/SystemVersion.plist`.
109
+ * `name` is `ProductName` (or `"macOS"`) and `version` is
110
+ * `ProductVersion` (e.g. `"15.1"`), never the Darwin kernel version.
111
+ * - On Windows, `version` is the kernel version, and Windows 11 is told
112
+ * apart from Windows 10 by NT build number (>= 22000).
113
+ *
114
+ * On Linux and macOS, the raw keys of the file are also present.
115
+ *
116
+ * @returns An {@link OsRelease}, or `null` on unsupported platforms or when
117
+ * the release file cannot be read.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * import { asString, osRelease } from "@darthcav/ts-utils"
122
+ *
123
+ * const info = osRelease()
124
+ * if (info) {
125
+ * console.log(info.name) // e.g. "Ubuntu", "macOS", or "Windows 11"
126
+ * // Raw keys are `unknown`; narrow them before use.
127
+ * const prettyName = asString(info["PRETTY_NAME"]) // e.g. "Ubuntu 24.04 LTS" (Linux only)
128
+ * }
129
+ * ```
130
+ */
131
+ export function osRelease(): OsRelease | null {
132
+ const p = platform()
133
+ if (p === "win32") {
134
+ const version = kernelRelease()
135
+ return { name: windowsName(version), version, arch: arch() }
136
+ }
137
+ const source = RELEASE_FILES[p]
138
+ if (source === undefined) {
139
+ return null
140
+ }
141
+ const content = readFirstFile(source.files)
142
+ if (content === null) {
143
+ return null
144
+ }
145
+ const raw = source.parse(content)
146
+ return {
147
+ ...raw,
148
+ name: source.name(raw),
149
+ version: source.version(raw),
150
+ arch: arch(),
151
+ }
152
+ }
@@ -0,0 +1,109 @@
1
+ // Parsers for the OS release files read by `osRelease()`. Internal: the `node`
2
+ // entry point does not re-export them, so they are tested directly.
3
+
4
+ /**
5
+ * Valid os-release keys: shell-compatible, upper-case variable names. This
6
+ * also rules out keys such as `__proto__` or `constructor`.
7
+ */
8
+ const OS_RELEASE_KEY = /^[A-Z][A-Z0-9_]*$/
9
+
10
+ /** A `<key>…</key>` followed by a `<string>…</string>` value in a plist. */
11
+ const PLIST_STRING_ENTRY = /<key>([^<]*)<\/key>\s*<string>([^<]*)<\/string>/g
12
+
13
+ /** Valid plist keys to copy; this also rules out keys such as `__proto__`. */
14
+ const PLIST_KEY = /^[A-Za-z][A-Za-z0-9_]*$/
15
+
16
+ /** The predefined XML entities. */
17
+ const XML_ENTITIES: ReadonlyMap<string, string> = new Map([
18
+ ["amp", "&"],
19
+ ["apos", "'"],
20
+ ["gt", ">"],
21
+ ["lt", "<"],
22
+ ["quot", '"'],
23
+ ])
24
+
25
+ /** Decodes the predefined and numeric character references of XML text. */
26
+ function decodeXml(text: string): string {
27
+ return text.replace(
28
+ /&(?:#x([0-9a-fA-F]+)|#([0-9]+)|([a-z]+));/g,
29
+ (
30
+ match: string,
31
+ hex: string | undefined,
32
+ decimal: string | undefined,
33
+ // Set when neither `hex` nor `decimal` is: one group always matches.
34
+ name: string,
35
+ ) => {
36
+ const codePoint =
37
+ hex !== undefined
38
+ ? Number.parseInt(hex, 16)
39
+ : decimal !== undefined
40
+ ? Number.parseInt(decimal, 10)
41
+ : undefined
42
+ if (codePoint === undefined) {
43
+ return XML_ENTITIES.get(name) ?? match
44
+ }
45
+ return codePoint <= 0x10ffff
46
+ ? String.fromCodePoint(codePoint)
47
+ : match
48
+ },
49
+ )
50
+ }
51
+
52
+ /**
53
+ * Removes one level of shell-style quoting from an os-release value. Double
54
+ * quotes allow the `\\`, `\"`, `` \` `` and `\$` escapes; single quotes are
55
+ * literal.
56
+ */
57
+ function unquote(value: string): string {
58
+ if (value.length >= 2) {
59
+ const quote = value[0]
60
+ if (quote === '"' && value.endsWith('"')) {
61
+ return value.slice(1, -1).replace(/\\([\\"`$])/g, "$1")
62
+ }
63
+ if (quote === "'" && value.endsWith("'")) {
64
+ return value.slice(1, -1)
65
+ }
66
+ }
67
+ return value
68
+ }
69
+
70
+ /**
71
+ * Parses os-release content into a null-prototype record, skipping blank
72
+ * lines, comments, lines without `=`, and invalid keys.
73
+ */
74
+ export function parseOsRelease(content: string): Record<string, string> {
75
+ const raw: Record<string, string> = Object.create(null)
76
+ for (const line of content.split("\n")) {
77
+ const trimmed = line.trim()
78
+ if (trimmed === "" || trimmed.startsWith("#")) {
79
+ continue
80
+ }
81
+ const eq = trimmed.indexOf("=")
82
+ if (eq === -1) {
83
+ continue
84
+ }
85
+ const key = trimmed.substring(0, eq).trim()
86
+ if (!OS_RELEASE_KEY.test(key)) {
87
+ continue
88
+ }
89
+ raw[key] = unquote(trimmed.substring(eq + 1).trim())
90
+ }
91
+ return raw
92
+ }
93
+
94
+ /**
95
+ * Parses the `<string>` entries of an XML property list into a
96
+ * null-prototype record, skipping other value types and invalid keys.
97
+ */
98
+ export function parsePlistStrings(content: string): Record<string, string> {
99
+ const raw: Record<string, string> = Object.create(null)
100
+ for (const [, rawKey = "", value = ""] of content.matchAll(
101
+ PLIST_STRING_ENTRY,
102
+ )) {
103
+ const key = decodeXml(rawKey.trim())
104
+ if (PLIST_KEY.test(key)) {
105
+ raw[key] = decodeXml(value.trim())
106
+ }
107
+ }
108
+ return raw
109
+ }
@@ -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,EAAe,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;GAGG;AACH,MAAM,wBAAwB,GAAG,KAAK,CAAA;AAEtC;;;GAGG;AACH,MAAM,oBAAoB,GAAG,aAAa,CAAA;AAE1C,qEAAqE;AACrE,IAAI,MAAM,GAAG,KAAK,CAAA;AAElB;;;;GAIG;AACH,KAAK,UAAU,SAAS,CAAC,SAAiB;IACt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,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,cAAc,CAAC,MAAM,EAAE;gBACxC,KAAK,EAAE,QAAQ;aAClB,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,UAAU,CAChB,yCAAyC,MAAM,GAAG,EAClD,EAAE,KAAK,EAAE,CACZ,CAAA;QACL,CAAC;QACD,IAAI,kBAAkB,CAAC,IAAI,IAAI,qBAAqB,EAAE,CAAC;YACnD,MAAM,MAAM,GAAG,kBAA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AAA;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"}