Skip to content

Commit c4662bb

Browse files
authored
Feat logging (#29)
* feat(logger): add logging feature * feat(logger): Add pino logger and support worker threads for file writing using esbuil dbundler * feat(logger): add logfile formatting like pino-pretty but within logstream (not stdio) * feat(logger): resolve tests * chore(config): update jest confgi for coverage
1 parent b0f7728 commit c4662bb

19 files changed

+1498
-460
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# misc
44
.DS_Store
55
*.log*
6-
.amazon_q
6+
.vscode
77

88
# dependencies
99
**/.yarn/*

esbuild.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { build } = require('esbuild');
2+
const esbuildPluginPino = require('esbuild-plugin-pino');
3+
4+
async function runBuild() {
5+
try {
6+
await build({
7+
entryPoints: ['src/index.ts'],
8+
bundle: true,
9+
platform: 'node',
10+
target: 'node18',
11+
outdir: 'dist',
12+
sourcemap: true,
13+
minify: true,
14+
banner: {
15+
js: '#!/usr/bin/env node',
16+
},
17+
plugins: [
18+
esbuildPluginPino({
19+
transports: [] // No transports needed, we're using direct file output
20+
}),
21+
],
22+
// We're bundling everything for a standalone executable
23+
external: [],
24+
});
25+
console.log('Build completed successfully!');
26+
} catch (error) {
27+
console.error('Build failed:', error);
28+
process.exit(1);
29+
}
30+
}
31+
32+
runBuild();

jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ module.exports = {
1111
],
1212
},
1313
collectCoverage: true,
14+
collectCoverageFrom: [
15+
'src/**/*.ts',
16+
'!src/**/*.spec.ts',
17+
'!src/**/*.d.ts',
18+
'!src/types.d.ts',
19+
'!src/**/index.ts',
20+
],
21+
coverageReporters: ['text', 'lcov', 'clover', 'json'],
22+
coverageDirectory: 'coverage',
1423
coverageThreshold: {
1524
global: {
1625
branches: 25,

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "@serverless-dna/powertools-mcp",
33
"version": "0.6.0",
44
"description": "Powertools for AWS Lambda Documentation MCP Server",
5-
"main": "dist/bundle.js",
5+
"main": "dist/index.js",
66
"bin": {
7-
"powertools-mcp": "dist/bundle.js"
7+
"powertools-mcp": "dist/index.js"
88
},
99
"files": [
1010
"dist/",
@@ -25,15 +25,16 @@
2525
"homepage": "https://github.com/serverless-dna/powertools-mcp#readme",
2626
"scripts": {
2727
"prebuild": "rimraf dist/* && pnpm lint",
28-
"build": "rollup -c",
29-
"postbuild": "chmod +x dist/bundle.js",
28+
"build": "node esbuild.config.js",
29+
"postbuild": "chmod +x dist/index.js",
3030
"test": "jest",
3131
"lint": "eslint --config eslint.config.mjs",
32-
"test:ci": "jest --ci",
32+
"test:ci": "jest --ci --coverage",
3333
"lint:fix": "eslint --fix --config eslint.config.mjs",
3434
"postversion": "pnpm build",
3535
"release": "semantic-release",
36-
"mcp:local": "pnpm build && npx -y @modelcontextprotocol/inspector node dist/bundle.js"
36+
"release:dry-run": "semantic-release --dry-run",
37+
"mcp:local": "pnpm build && npx -y @modelcontextprotocol/inspector node dist/index.js"
3738
},
3839
"keywords": [
3940
"aws",
@@ -58,18 +59,17 @@
5859
"lunr": "^2.3.9",
5960
"lunr-languages": "^1.14.0",
6061
"make-fetch-happen": "^14.0.3",
62+
"pino": "^9.6.0",
63+
"pino-pretty": "^13.0.0",
6164
"turndown": "^7.2.0",
6265
"zod": "^3.24.3",
6366
"zod-to-json-schema": "^3.24.5"
6467
},
6568
"devDependencies": {
6669
"@eslint/js": "^9.25.0",
67-
"@rollup/plugin-commonjs": "^28.0.3",
68-
"@rollup/plugin-json": "^6.1.0",
69-
"@rollup/plugin-node-resolve": "^16.0.1",
70-
"@rollup/plugin-terser": "^0.4.4",
71-
"@rollup/plugin-typescript": "^12.1.2",
70+
"@jest/globals": "^29.7.0",
7271
"@semantic-release/changelog": "^6.0.3",
72+
"@semantic-release/git": "^10.0.1",
7373
"@semantic-release/github": "^11.0.1",
7474
"@types/jest": "^29.5.14",
7575
"@types/lunr": "^2.3.7",
@@ -78,6 +78,8 @@
7878
"@types/turndown": "^5.0.5",
7979
"@typescript-eslint/eslint-plugin": "^8.30.1",
8080
"@typescript-eslint/parser": "^8.30.1",
81+
"esbuild": "^0.25.4",
82+
"esbuild-plugin-pino": "^2.2.2",
8183
"eslint": "^9.25.0",
8284
"eslint-config-prettier": "^10.1.2",
8385
"eslint-import-resolver-typescript": "^4.3.3",
@@ -91,7 +93,6 @@
9193
"jest": "^29.7.0",
9294
"prettier": "^3.5.3",
9395
"rimraf": "^6.0.1",
94-
"rollup": "^4.40.0",
9596
"semantic-release": "^24.2.3",
9697
"ts-jest": "^29.3.2",
9798
"typescript": "^5.8.3"

0 commit comments

Comments
 (0)