lambda-doctor 0.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.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ <div align="center">
2
+
3
+ # ๐Ÿฉบ Lambda Doctor
4
+
5
+ **Diagnose and fix AWS Lambda cold start performance issues.**
6
+
7
+ Static analysis CLI that scans your Node.js Lambda project and tells you exactly what's slowing down your cold starts โ€” and how to fix it.
8
+
9
+ [![npm](https://img.shields.io/npm/v/lambda-doctor)](https://www.npmjs.com/package/lambda-doctor)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
11
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
12
+
13
+ [Quick Start](#quick-start) ยท [What It Checks](#what-it-checks) ยท [Example Output](#example-output) ยท [How It Works](#how-it-works)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## The Problem
20
+
21
+ Your Lambda cold starts take 3+ seconds. You've read every blog post. You know you should "use smaller packages" and "bundle your code" โ€” but which packages are actually heavy? Are your imports tree-shakeable? Is your AWS SDK setup optimal?
22
+
23
+ **Lambda Doctor** runs a single command and gives you a prioritized, actionable report with estimated millisecond savings for each issue.
24
+
25
+ ## Quick Start
26
+
27
+ ```bash
28
+ npm install -g lambda-doctor
29
+ ```
30
+
31
+ ```bash
32
+ lambda-doctor analyze ./my-lambda
33
+ ```
34
+
35
+ That's it. You get a full diagnosis in seconds.
36
+
37
+ ## What It Checks
38
+
39
+ | Analyzer | What it does | Severity |
40
+ |---|---|---|
41
+ | **Bundle Size** | Scans `node_modules`, reports total size and top 10 largest packages | ๐Ÿ”ด >50MB, โš ๏ธ >10MB |
42
+ | **Heavy Dependencies** | Flags known heavy packages (moment, lodash, axios, etc.) and dev tools in production | ๐Ÿ”ด dev tools in prod, โš ๏ธ heavy deps |
43
+ | **Import Analysis** | Detects `import *` (tree-shaking blocker) and top-level heavy imports | โš ๏ธ per pattern |
44
+ | **AWS SDK** | Detects v2 usage, incomplete v2โ†’v3 migration, unnecessary clients (e.g. SSO in Lambda) | ๐Ÿ”ด v2, โš ๏ธ mixed |
45
+ | **Bundler Detection** | Checks for esbuild/webpack/rollup/tsup โ€” no bundler = biggest improvement opportunity | ๐Ÿ”ด no bundler |
46
+
47
+ ## Example Output
48
+
49
+ ```
50
+ ๐Ÿฉบ Lambda Doctor โ€” Diagnosis Report
51
+
52
+ ๐Ÿ”ด CRITICAL Dev tool "typescript" in production dependencies
53
+ โ†’ Move "typescript" from "dependencies" to "devDependencies".
54
+ โฑ Est. improvement: ~500ms
55
+
56
+ ๐Ÿ”ด CRITICAL Using AWS SDK v2 (aws-sdk)
57
+ โ†’ Migrate to AWS SDK v3 (@aws-sdk/client-*). Only import the clients you need.
58
+ โฑ Est. improvement: ~400ms
59
+
60
+ ๐Ÿ”ด CRITICAL No bundler detected
61
+ โ†’ Add esbuild (fastest) or webpack to bundle your Lambda function.
62
+ โฑ Est. improvement: ~500ms
63
+
64
+ โš ๏ธ WARNING Heavy dependency: moment
65
+ โ†’ Use dayjs (2KB) or date-fns with tree-shaking.
66
+ โฑ Est. improvement: ~50ms
67
+
68
+ โš ๏ธ WARNING Wildcard import of "aws-sdk" prevents tree-shaking
69
+ โ†’ Use named imports: import { specificFunction } from "aws-sdk"
70
+ โฑ Est. improvement: ~20ms
71
+
72
+ Summary: 3 critical | 12 warnings | 1 info
73
+ ๐Ÿš€ Total estimated cold start improvement: ~2742.5ms
74
+ ```
75
+
76
+ ## How It Works
77
+
78
+ ```
79
+ lambda-doctor analyze ./my-lambda
80
+ โ”‚
81
+ โ–ผ
82
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
83
+ โ”‚ Read package.json โ”‚
84
+ โ”‚ Scan node_modules โ”‚
85
+ โ”‚ Parse source files โ”‚
86
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
87
+ โ”‚
88
+ โ–ผ
89
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
90
+ โ”‚ 5 Analyzers (run in parallel) โ”‚
91
+ โ”‚ โ”œโ”€ Bundle Size โ”‚
92
+ โ”‚ โ”œโ”€ Heavy Dependencies โ”‚
93
+ โ”‚ โ”œโ”€ Import Analysis โ”‚
94
+ โ”‚ โ”œโ”€ AWS SDK โ”‚
95
+ โ”‚ โ””โ”€ Bundler Detection โ”‚
96
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
97
+ โ”‚
98
+ โ–ผ
99
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
100
+ โ”‚ Diagnosis Report โ”‚
101
+ โ”‚ โ”œโ”€ Prioritized by severity โ”‚
102
+ โ”‚ โ”œโ”€ Actionable recommendations โ”‚
103
+ โ”‚ โ””โ”€ Estimated ms savings each โ”‚
104
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
105
+ ```
106
+
107
+ All analyzers run in parallel and never crash โ€” if one fails, you still get results from the others.
108
+
109
+ ## CLI Options
110
+
111
+ ```bash
112
+ # Console output (default)
113
+ lambda-doctor analyze ./my-lambda
114
+
115
+ # JSON output (for CI/CD pipelines)
116
+ lambda-doctor analyze ./my-lambda --format json
117
+ ```
118
+
119
+ ### Exit Codes
120
+
121
+ - `0` โ€” No critical issues found
122
+ - `1` โ€” Critical issues detected (useful for CI gates)
123
+
124
+ ## Requirements
125
+
126
+ - Node.js >= 18
127
+
128
+ ## Contributing
129
+
130
+ Contributions are welcome! Please check out the [issues](https://github.com/ozers/lambda-doctor/issues) page.
131
+
132
+ ```bash
133
+ git clone https://github.com/ozers/lambda-doctor.git
134
+ cd lambda-doctor
135
+ npm install
136
+ npm run build
137
+ npm test
138
+ ```
139
+
140
+ ## License
141
+
142
+ [MIT](LICENSE)
143
+
144
+ ---
145
+
146
+ <div align="center">
147
+
148
+ Built by [Ozer](https://github.com/ozers) โ€” because staring at CloudWatch cold start metrics at 2am shouldn't be a regular thing.
149
+
150
+ </div>