@eliware/common 1.1.5 → 1.1.7
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/README.md +16 -0
- package/examples/example.mjs +37 -0
- package/package.json +14 -11
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
A small ESM convenience package that provides one stable import surface for Eliware's shared Node.js utilities.
|
|
4
4
|
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 26 or newer
|
|
8
|
+
- Published Eliware dependency packages matching the versions in `package.json`
|
|
9
|
+
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
7
12
|
```bash
|
|
@@ -64,16 +69,27 @@ const options: RegisterSignalsOptions = { exit: false };
|
|
|
64
69
|
const registration = registerSignals(options);
|
|
65
70
|
```
|
|
66
71
|
|
|
72
|
+
## Errors / Troubleshooting
|
|
73
|
+
|
|
74
|
+
This package is a compatibility layer and delegates behavior to its underlying packages. For logging, path, error-handler, or signal-handler failures, consult the corresponding dependency documentation. Keep dependency versions synchronized with the public exports and declarations.
|
|
75
|
+
|
|
67
76
|
## Development
|
|
68
77
|
|
|
69
78
|
```bash
|
|
70
79
|
npm install
|
|
71
80
|
npm test
|
|
72
81
|
npm run lint
|
|
82
|
+
npm run test:gaps
|
|
83
|
+
npm run typecheck
|
|
84
|
+
npm run pack
|
|
73
85
|
```
|
|
74
86
|
|
|
75
87
|
This package is a re-export/compatibility layer. Its tests verify the public export contract and representative delegation to the underlying packages; implementation behavior is tested in those dependency packages.
|
|
76
88
|
|
|
89
|
+
## Security
|
|
90
|
+
|
|
91
|
+
Do not log secrets or include credentials or machine-specific paths in examples. Review delegated package behavior and keep dependencies updated before publishing.
|
|
92
|
+
|
|
77
93
|
## Links
|
|
78
94
|
|
|
79
95
|
- [GitHub](https://github.com/eliware/common)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fs,
|
|
3
|
+
log,
|
|
4
|
+
path,
|
|
5
|
+
pathUrl,
|
|
6
|
+
resolvePath,
|
|
7
|
+
registerHandlers,
|
|
8
|
+
registerSignals,
|
|
9
|
+
} from '@eliware/common';
|
|
10
|
+
|
|
11
|
+
const configPath = path(import.meta, '.env');
|
|
12
|
+
const configUrl = pathUrl(import.meta, '.env');
|
|
13
|
+
const configDirectory = resolvePath(import.meta);
|
|
14
|
+
|
|
15
|
+
log.info('Common package example', {
|
|
16
|
+
configPath,
|
|
17
|
+
configUrl,
|
|
18
|
+
configDirectory,
|
|
19
|
+
files: fs.readdirSync(configDirectory),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const errorHandlers = registerHandlers({
|
|
23
|
+
events: ['uncaughtException', 'unhandledRejection'],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const signals = registerSignals({
|
|
27
|
+
shutdownHook: async signal => {
|
|
28
|
+
log.info(`Cleaning up after ${signal}`);
|
|
29
|
+
errorHandlers.removeHandlers();
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
log.info('Handlers registered. Send SIGTERM or SIGINT to shut down gracefully.');
|
|
34
|
+
|
|
35
|
+
// Keep the process alive for this demonstration; real applications usually
|
|
36
|
+
// stay alive because they have a server, worker, or other active resource.
|
|
37
|
+
void signals;
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliware/common",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.7",
|
|
5
5
|
"description": "An ESM/Jest/Node-friendly utility for resolving file and directory paths, logging, error handling, and signal handling in both ESM environments.",
|
|
6
|
-
"module": "index.mjs",
|
|
7
6
|
"types": "index.d.ts",
|
|
8
7
|
"files": [
|
|
9
8
|
"index.mjs",
|
|
9
|
+
"src",
|
|
10
10
|
"index.d.ts",
|
|
11
11
|
"README.md",
|
|
12
12
|
"LICENSE",
|
|
13
|
-
"
|
|
13
|
+
"examples"
|
|
14
14
|
],
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"test": "npx --node-options=\"--experimental-vm-modules --no-warnings\" jest --detectOpenHandles --silent --coverage",
|
|
23
|
-
"test:gaps": "npm test
|
|
24
|
-
"lint": "npx oxlint ."
|
|
22
|
+
"test": "npx --node-options=\"--experimental-vm-modules --no-warnings\" jest --detectOpenHandles --silent --coverage --coverageProvider=v8",
|
|
23
|
+
"test:gaps": "npm test 2>&1 | grep '|' | grep -vF '| 100 | 100 | 100 | 100 |'",
|
|
24
|
+
"lint": "npx oxlint .",
|
|
25
|
+
"typecheck": "tsc --project tsconfig.json",
|
|
26
|
+
"pack": "npm pack --dry-run"
|
|
25
27
|
},
|
|
26
28
|
"repository": {
|
|
27
29
|
"type": "git",
|
|
@@ -44,7 +46,8 @@
|
|
|
44
46
|
},
|
|
45
47
|
"homepage": "https://github.com/eliware/common#readme",
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"jest": "^30.4.2"
|
|
49
|
+
"jest": "^30.4.2",
|
|
50
|
+
"typescript": "^7.0.2"
|
|
48
51
|
},
|
|
49
52
|
"jest": {
|
|
50
53
|
"testEnvironment": "node",
|
|
@@ -54,9 +57,9 @@
|
|
|
54
57
|
]
|
|
55
58
|
},
|
|
56
59
|
"dependencies": {
|
|
57
|
-
"@eliware/errors": "^1.1.
|
|
58
|
-
"@eliware/log": "^1.1.
|
|
59
|
-
"@eliware/path": "^1.1.
|
|
60
|
-
"@eliware/signals": "^1.1.
|
|
60
|
+
"@eliware/errors": "^1.1.8",
|
|
61
|
+
"@eliware/log": "^1.1.11",
|
|
62
|
+
"@eliware/path": "^1.1.8",
|
|
63
|
+
"@eliware/signals": "^1.1.6"
|
|
61
64
|
}
|
|
62
65
|
}
|