launch-doctor 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/README.md +376 -2
- package/dist/src/baseline.d.ts +14 -0
- package/dist/src/baseline.js +71 -0
- package/dist/src/checks/common.d.ts +16 -0
- package/dist/src/checks/common.js +33 -0
- package/dist/src/checks/costs.d.ts +8 -0
- package/dist/src/checks/costs.js +210 -0
- package/dist/src/checks/database.d.ts +2 -0
- package/dist/src/checks/database.js +239 -0
- package/dist/src/checks/email.d.ts +19 -0
- package/dist/src/checks/email.js +270 -0
- package/dist/src/checks/first-impressions.d.ts +2 -0
- package/dist/src/checks/first-impressions.js +160 -0
- package/dist/src/checks/legal.d.ts +2 -0
- package/dist/src/checks/legal.js +122 -0
- package/dist/src/checks/monitoring.d.ts +2 -0
- package/dist/src/checks/monitoring.js +93 -0
- package/dist/src/checks/payments.d.ts +2 -0
- package/dist/src/checks/payments.js +188 -0
- package/dist/src/checks/secrets.d.ts +23 -0
- package/dist/src/checks/secrets.js +355 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +404 -0
- package/dist/src/comments.d.ts +8 -0
- package/dist/src/comments.js +143 -0
- package/dist/src/demo.d.ts +2 -0
- package/dist/src/demo.js +54 -0
- package/dist/src/detect.d.ts +10 -0
- package/dist/src/detect.js +129 -0
- package/dist/src/fixes.d.ts +3 -0
- package/dist/src/fixes.js +67 -0
- package/dist/src/grade.d.ts +16 -0
- package/dist/src/grade.js +52 -0
- package/dist/src/history.d.ts +16 -0
- package/dist/src/history.js +88 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +147 -0
- package/dist/src/init.d.ts +9 -0
- package/dist/src/init.js +49 -0
- package/dist/src/live.d.ts +16 -0
- package/dist/src/live.js +509 -0
- package/dist/src/project.d.ts +97 -0
- package/dist/src/project.js +724 -0
- package/dist/src/report.d.ts +6 -0
- package/dist/src/report.js +136 -0
- package/dist/src/routes.d.ts +40 -0
- package/dist/src/routes.js +227 -0
- package/dist/src/sarif.d.ts +14 -0
- package/dist/src/sarif.js +54 -0
- package/dist/src/summary.d.ts +6 -0
- package/dist/src/summary.js +44 -0
- package/dist/src/types.d.ts +102 -0
- package/dist/src/types.js +1 -0
- package/dist/src/util.d.ts +13 -0
- package/dist/src/util.js +75 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +21 -0
- package/package.json +61 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.1] - 2026-11-27
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Settings that only mention a sensitive word (for example `VITE_PASSWORD_MIN_LENGTH`) are no longer reported as secrets exposed through a public variable.
|
|
15
|
+
- A DNS lookup that times out or is refused (common for long SPF records, which need DNS over TCP) is retried, and if it still fails the report says it couldn't check, instead of warning that the SPF or DMARC record is missing.
|
|
16
|
+
- An `import ... from "pkg"` written inside a string (help text, prompts, docs) no longer counts as using that package, which caused false payment and AI findings.
|
|
17
|
+
|
|
18
|
+
## [0.2.0] - 2026-11-04
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `launch-doctor scan <url>` checks a deployed site from the outside: downloadable `.env`, `.git` and SQL backups, public source maps, API keys in the JavaScript, Supabase tables readable with the public key, and HTTPS and security headers. `--no-db` skips the Supabase test.
|
|
23
|
+
- AI endpoints are now judged one handler at a time: auth and rate limiting must be reachable from that handler, including through local imports.
|
|
24
|
+
- `--fail-on <critical|warning>` chooses the lowest severity that makes `--ci` exit with code 1.
|
|
25
|
+
- Inline ignores: a `launch-doctor-ignore <id>` comment on a finding's line or the line above silences that one finding (`//`, `#`, `/* */`, `<!-- -->` and SQL `--` comments).
|
|
26
|
+
- `--only <ids>` and `--skip <ids>` run or skip categories; skipped categories don't count toward the grade.
|
|
27
|
+
- GitHub Actions job summary: when `GITHUB_STEP_SUMMARY` is set, a Markdown summary is added to the job page.
|
|
28
|
+
- `--sarif <file>` writes SARIF 2.1.0 for GitHub code scanning.
|
|
29
|
+
- Baselines: `--update-baseline` writes `.launchdoctor-baseline.json`; later runs mark known findings, collapse them and leave them out of `--ci`. `--no-baseline` ignores the file.
|
|
30
|
+
- `launch-doctor init` creates a commented `.launchdoctorignore` and a GitHub Actions workflow without overwriting existing files.
|
|
31
|
+
- `--history` and `--history-depth <n>` find API keys that were removed from the code but are still in git history.
|
|
32
|
+
- Comment-aware matching: commented-out code no longer counts as an error boundary, account deletion, rate limiter, auth check or webhook verification.
|
|
33
|
+
- Supabase policies are graded by how open they are: open write policies are critical, write policies open to any signed-in user are a warning, and public read policies go on the checklist.
|
|
34
|
+
- Email: a sender domain that doesn't exist in DNS gets one clear warning, and a missing root SPF record is a checklist item (not a warning) for Amazon SES, Postmark and SendGrid.
|
|
35
|
+
- Web-app detection: monitoring, legal and first-impressions checks only run on web apps.
|
|
36
|
+
- Unknown ids in `.launchdoctorignore` are reported as a warning.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Any critical finding now gives an F, in its category and overall.
|
|
41
|
+
- Removed all emojis from the terminal report, `LAUNCH_FIXES.md`, `--help` and the docs. The report uses `[CRITICAL]`, `[WARN]`, `[PASS]` and `[ ]` labels.
|
|
42
|
+
- `--json` and `--ci` no longer write `LAUNCH_FIXES.md` unless `--out` is given.
|
|
43
|
+
- An existing `LAUNCH_FIXES.md` is rewritten (with an "All clear" section) when nothing is left to fix.
|
|
44
|
+
- In `.launchdoctorignore`, a bare word that names an existing file or folder is treated as a path.
|
|
45
|
+
- Requires Node.js 22 or newer.
|
|
46
|
+
- Match line numbers use cached line starts and a binary search, which is faster on large files.
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- Middleware only counts as protecting AI routes when it actually blocks signed-out requests and covers `/api` (Supabase's `updateSession()` alone doesn't).
|
|
51
|
+
- The rate-limit check no longer passes on comments, `RateLimitError` handling, or a package that is installed but never imported.
|
|
52
|
+
- Sending an `Authorization` header to the AI provider is no longer mistaken for a user auth check.
|
|
53
|
+
- A global `app.use(express.json())` with no `express.raw()` is reported, because it breaks Stripe signature checks.
|
|
54
|
+
- Every Stripe webhook route is checked on its own; one verified webhook no longer hides an unverified one.
|
|
55
|
+
- DKIM records that contain only the public key (`p=...`) are recognised.
|
|
56
|
+
- Truncated scans (more than 20,000 files) are still sorted.
|
|
57
|
+
- The `--demo` temp folder is deleted even if the scan crashes.
|
|
58
|
+
- Every git command runs with `core.fsmonitor=false`, so scanning an untrusted folder can't make git run a program from that folder's `.git/config`.
|
|
59
|
+
|
|
60
|
+
## [0.1.0] - 2026-11-02
|
|
61
|
+
|
|
62
|
+
First release.
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
- `npx launch-doctor`: grades a project A-F in eight categories (secrets and keys, database and backups, payments, AI and API costs, email delivery, errors and monitoring, legal and trust, first impressions).
|
|
67
|
+
- Plain-English explanations and a copy-paste fix prompt for every finding, saved to `LAUNCH_FIXES.md`.
|
|
68
|
+
- "Check yourself" checklist items for things code can't show.
|
|
69
|
+
- Live DNS check of SPF, DKIM and DMARC for the sending domain.
|
|
70
|
+
- `--json`, `--ci`, `--offline`, `--out`, `--no-file`, `--domain` and `--demo`.
|
|
71
|
+
- `.launchdoctorignore` for silencing findings by id or skipping paths.
|
|
72
|
+
- Support for JavaScript / TypeScript and Python projects.
|
|
73
|
+
|
|
74
|
+
[Unreleased]: https://github.com/SHARAJ379/launch-doctor/compare/v0.2.1...HEAD
|
|
75
|
+
[0.2.1]: https://github.com/SHARAJ379/launch-doctor/compare/v0.2.0...v0.2.1
|
|
76
|
+
[0.2.0]: https://github.com/SHARAJ379/launch-doctor/compare/v0.1.0...v0.2.0
|
|
77
|
+
[0.1.0]: https://github.com/SHARAJ379/launch-doctor/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sharaj R Shetty
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,377 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Launch Doctor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A pre-launch checkup for vibe-coded apps: one command, an A-F grade, and a fix prompt for every problem.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/SHARAJ379/launch-doctor/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/launch-doctor)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
Launch Doctor scans your project for the problems that hurt apps after launch: leaked API keys, databases anyone can read, payments that can be faked, emails that land in spam, AI endpoints that can run up your bill, missing legal pages, and leftover template defaults. It is built for developers who ship with AI coding tools (Claude Code, Cursor, Lovable, Bolt, Windsurf) and may not read every line of generated code. Every finding is explained in plain English and includes a prompt you can paste straight back into your AI assistant. It has no runtime dependencies, requires no account, and your code never leaves your machine.
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx launch-doctor
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Scan the built-in sample app full of common mistakes:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx launch-doctor --demo
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Initialize configuration and GitHub Actions files:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx launch-doctor init
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Requires Node.js 22 or newer.
|
|
31
|
+
|
|
32
|
+
## Example output
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Launch Doctor v0.2.0
|
|
36
|
+
Checked my-weekend-saas · 12 files · Vite, React, Supabase, Stripe, OpenAI
|
|
37
|
+
|
|
38
|
+
Overall grade F Not ready to launch: fix 6 critical issues first
|
|
39
|
+
|
|
40
|
+
F Secrets & keys 2 critical · 1 to fix · 1 to check
|
|
41
|
+
F Database & backups 2 critical · 1 to check
|
|
42
|
+
F Payments 1 critical · 2 to check
|
|
43
|
+
F AI & API costs 1 critical · 1 to fix · 1 to check
|
|
44
|
+
B Email delivery 1 to fix · 3 to check
|
|
45
|
+
C Errors & monitoring 2 to fix · 2 to check
|
|
46
|
+
D Legal & trust 5 to fix
|
|
47
|
+
D First impressions 5 to fix · 3 to check
|
|
48
|
+
|
|
49
|
+
MUST FIX BEFORE LAUNCH (6)
|
|
50
|
+
|
|
51
|
+
[CRITICAL] Stripe live secret key is written directly in your code
|
|
52
|
+
src/lib/stripe.ts:1
|
|
53
|
+
This file is sent to every visitor's browser, so anyone can copy the key
|
|
54
|
+
(sk_live_…exe9) and use your account.
|
|
55
|
+
|
|
56
|
+
[CRITICAL] Secret exposed through the public variable VITE_OPENAI_API_KEY
|
|
57
|
+
.env:3
|
|
58
|
+
Anything starting with VITE_ gets copied into your website's JavaScript,
|
|
59
|
+
so every visitor can read it. That prefix is only for values that are safe
|
|
60
|
+
to be public.
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
Fix prompts saved to LAUNCH_FIXES.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Project workflow
|
|
67
|
+
|
|
68
|
+
Launch Doctor operates across two integrated workflows: an automated internal analysis pipeline that inspects your repository, and a developer-in-the-loop remediation lifecycle designed to pair with AI coding assistants.
|
|
69
|
+
|
|
70
|
+
### 1. Internal analysis pipeline
|
|
71
|
+
|
|
72
|
+
The following diagram outlines the multi-stage static analysis pipeline executed on every scan:
|
|
73
|
+
|
|
74
|
+
```mermaid
|
|
75
|
+
flowchart TD
|
|
76
|
+
Start["User / CI triggers: launch-doctor"] --> ParseArgs["1. Argument & Option Parsing"]
|
|
77
|
+
ParseArgs --> LoadContext["2. Project Ingestion & File Discovery"]
|
|
78
|
+
LoadContext --> DetectStack["3. Technology Stack & Environment Detection"]
|
|
79
|
+
DetectStack --> ChecksSuite
|
|
80
|
+
|
|
81
|
+
subgraph ChecksSuite["4. Evaluation across 8 Check Modules"]
|
|
82
|
+
direction TB
|
|
83
|
+
C1["Secrets & Keys Scan"]
|
|
84
|
+
C2["Database Security & RLS"]
|
|
85
|
+
C3["Payment Webhooks & Verification"]
|
|
86
|
+
C4["AI Endpoints & Cost Controls"]
|
|
87
|
+
C5["Email DNS & Configuration"]
|
|
88
|
+
C6["Error Boundaries & Monitoring"]
|
|
89
|
+
C7["Legal & Compliance Pages"]
|
|
90
|
+
C8["First Impressions & Defaults"]
|
|
91
|
+
C_Hist["Optional: Git History Commit Walk"]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
ChecksSuite --> FilterIgnore["5. Suppression & Baseline Filtering"]
|
|
95
|
+
FilterIgnore --> ScoringEngine["6. Scoring & Grading Engine"]
|
|
96
|
+
ScoringEngine --> OutputDispatch
|
|
97
|
+
|
|
98
|
+
subgraph OutputDispatch["7. Multi-Target Outputs"]
|
|
99
|
+
direction TB
|
|
100
|
+
Out1["Terminal Dashboard Output"]
|
|
101
|
+
Out2["LAUNCH_FIXES.md Prompt Catalog"]
|
|
102
|
+
Out3["JSON / SARIF 2.1.0 Reports"]
|
|
103
|
+
Out4["GitHub Actions Step Summary"]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
OutputDispatch --> ExitEval["8. Exit Code Evaluation (0, 1, or 2)"]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Pipeline stages in detail
|
|
110
|
+
|
|
111
|
+
1. **Argument parsing and validation (`src/cli.ts`):**
|
|
112
|
+
Evaluates CLI flags, path arguments, targeted categories (`--only`, `--skip`), severity thresholds (`--fail-on`), output destinations (`--out`, `--sarif`), and runtime modifiers (`--ci`, `--offline`, `--history`, `--demo`).
|
|
113
|
+
2. **Project ingestion and tree traversal (`src/project.ts`):**
|
|
114
|
+
Walks the project root, automatically skipping `node_modules`, build artifacts (`dist`, `build`, `.next`), binary formats, and hidden folders (except `.github`). Ingests package manifests (`package.json`, `requirements.txt`, `pyproject.toml`), git status, and `.launchdoctorignore` patterns.
|
|
115
|
+
3. **Stack and environment detection (`src/detect.ts`, `src/comments.ts`):**
|
|
116
|
+
Identifies frameworks (Next.js, Vite, React, Vue, Express), server routes (including Flask and Django), database configurations (Supabase, Firebase, Prisma), payment gateways (Stripe, Razorpay), error trackers (Sentry, PostHog), and email services. Prepares a comment-stripped view of source files so commented-out code is not mistaken for active protection.
|
|
117
|
+
4. **Multi-category check execution (`src/checks/`):**
|
|
118
|
+
Runs audits across all 8 categories. If `--history` is enabled, an incremental git commit walker inspects the last `n` commits (default 500) for secrets that were removed from HEAD but remain exposed in commit history.
|
|
119
|
+
5. **Suppression and baseline matching (`src/baseline.ts`):**
|
|
120
|
+
Applies inline `launch-doctor-ignore <id>` comments and `.launchdoctorignore` path or id rules. If `.launchdoctor-baseline.json` is present and baseline mode is active, matches existing findings by ID, relative file path, and line content fingerprint.
|
|
121
|
+
6. **Scoring and grading engine (`src/grade.ts`):**
|
|
122
|
+
Calculates category and overall scores from weighted deductions. Strict scoring ceilings ensure that any critical finding caps both the category score and the overall score at 39 (grade F).
|
|
123
|
+
7. **Multi-target reporting and artifact generation (`src/report.ts`, `src/fixes.ts`, `src/sarif.ts`, `src/summary.ts`):**
|
|
124
|
+
Renders the CLI terminal dashboard, generates `LAUNCH_FIXES.md` with copy-paste prompts for AI models, outputs structured JSON or SARIF 2.1.0 files when requested, and populates GitHub Actions job summaries via `GITHUB_STEP_SUMMARY`.
|
|
125
|
+
8. **Process exit resolution (`src/cli.ts`):**
|
|
126
|
+
Returns exit code 0 whenever the scan finishes (with `--ci`, only when nothing is at or above `--fail-on`), code 1 for CI gate failures, and code 2 for invalid arguments or unexpected runtime errors.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### 2. Developer and AI remediation lifecycle
|
|
131
|
+
|
|
132
|
+
Launch Doctor is built to fit directly into your daily development cycle, especially when pairing with AI assistants:
|
|
133
|
+
|
|
134
|
+
```mermaid
|
|
135
|
+
flowchart LR
|
|
136
|
+
Dev["1. Local Development (AI / Human)"] --> Scan["2. Run npx launch-doctor"]
|
|
137
|
+
Scan --> Check{"Grade & Findings?"}
|
|
138
|
+
Check -- "Issues Found (Grade < A)" --> ReadFixes["3. Open LAUNCH_FIXES.md"]
|
|
139
|
+
ReadFixes --> PastePrompt["4. Paste Prompts to AI Tool"]
|
|
140
|
+
PastePrompt --> ReScan["5. Re-run Scan to Verify"]
|
|
141
|
+
ReScan --> Check
|
|
142
|
+
Check -- "Clean (Grade A or Baseline)" --> Commit["6. Commit & Push Code"]
|
|
143
|
+
Commit --> CI["7. CI/CD PR Gate (--ci)"]
|
|
144
|
+
CI --> Deploy["8. Safe Production Launch"]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
1. **Pre-flight scan:** Before shipping changes or merging a branch, run `npx launch-doctor` in your workspace.
|
|
148
|
+
2. **Review findings:** Check your letter grade (A-F), category breakdown, and critical blockers in the terminal.
|
|
149
|
+
3. **Copy prompts to AI tools:** Open `LAUNCH_FIXES.md`. Copy the specific problem prompt or the single batch prompt and paste it into Claude Code, Cursor, Windsurf, Lovable, or Bolt.
|
|
150
|
+
4. **Verify remediation:** Re-run `npx launch-doctor` to verify the fixes and watch your grade increase.
|
|
151
|
+
5. **Establish baseline for legacy debt:** If you are adopting Launch Doctor on an existing project, run `npx launch-doctor --update-baseline` so CI only reports new issues.
|
|
152
|
+
6. **Automate CI gating:** Add `npx launch-doctor --ci` to your pull request workflow to catch regressions before they merge.
|
|
153
|
+
|
|
154
|
+
## What it checks
|
|
155
|
+
|
|
156
|
+
| Category | What it catches | Severity range |
|
|
157
|
+
|---|---|---|
|
|
158
|
+
| Secrets & keys (`secrets`) | Stripe, OpenAI, Anthropic, OpenRouter, Groq, Hugging Face, Supabase, AWS, GitHub, Slack, SendGrid, and Resend keys in code; Supabase `service_role` keys; private keys; database URLs with passwords; secrets in `NEXT_PUBLIC_` / `VITE_` variables; `.env` files committed or not in `.gitignore`; with `--history`, keys still in git history | Warning to critical |
|
|
159
|
+
| Database & backups (`database`) | Supabase tables without Row Level Security; policies that let anyone write (`using (true)`); write policies open to any signed-in user; Firebase test-mode or open rules; SQLite on serverless hosting; `prisma db push` / `--accept-data-loss` instead of migrations | Warning to critical |
|
|
160
|
+
| Payments (`payments`) | Stripe webhooks that don't verify the signature (each route checked separately); webhooks or global `express.json()` that parse the body before verifying; no webhook at all; Razorpay payments never verified on the server | Warning to critical |
|
|
161
|
+
| AI & API costs (`costs`) | Paid AI or SMS APIs called from the browser; `dangerouslyAllowBrowser: true`; AI endpoints with no login check (middleware only counts if it really blocks `/api`); no real rate limiter | Warning to critical |
|
|
162
|
+
| Email delivery (`email`) | Resend's test sender; personal Gmail SMTP; sender domains that don't exist; missing SPF or DMARC (live DNS check); a checklist reminder when Supabase Auth still uses its built-in test mailer | Warning |
|
|
163
|
+
| Errors & monitoring (`monitoring`) | No error tracking (Sentry, PostHog, and others); no error boundary or `error.tsx`, so crashes show a blank page | Warning |
|
|
164
|
+
| Legal & trust (`legal`) | No privacy policy, terms, refund policy, or contact page; no way for users to delete their account; a checklist reminder about cookie consent when analytics set cookies | Warning |
|
|
165
|
+
| First impressions (`first-impressions`) | "Vite + React" / "Create Next App" titles and descriptions; Vite favicon; Lovable default meta tags; no description or social preview image; hard-coded `localhost` URLs | Warning |
|
|
166
|
+
|
|
167
|
+
Most categories also add **"check yourself"** items for things code cannot show, such as automated database backups, provider spending limits, a real test purchase, and uptime monitoring. Monitoring, legal, and first impressions checks only run on web apps (a frontend framework, server routes, or an `index.html`). Command-line tools and libraries skip them automatically.
|
|
168
|
+
|
|
169
|
+
## Live site scan
|
|
170
|
+
|
|
171
|
+
`npx launch-doctor scan https://myapp.com` checks your deployed site the way an attacker would, from the outside. It makes a few dozen ordinary `GET` requests (at most about 90, when Supabase tables are tested) and never changes anything. Only scan sites you own or are allowed to test.
|
|
172
|
+
|
|
173
|
+
| Category | What it catches | Severity range |
|
|
174
|
+
|---|---|---|
|
|
175
|
+
| Exposed files & keys (`live-exposure`) | `/.env`, `/.git` and SQL backups that can be downloaded (the content is verified, so single-page apps that answer 200 for every path are not flagged); public source maps; API keys inside the JavaScript every visitor downloads | Warning to critical |
|
|
176
|
+
| Open database (`live-database`) | Supabase `service_role` key in the page; tables that return rows to anyone holding the public anon key (only `GET`, one row per table, and rows are never saved or shown) | Critical |
|
|
177
|
+
| HTTPS & headers (`live-headers`) | Plain http; http that doesn't redirect to https; missing HSTS, Content-Security-Policy, `X-Content-Type-Options`, frame protection and `Referrer-Policy` | Warning to critical |
|
|
178
|
+
|
|
179
|
+
The report uses the same grades and `--json`, `--ci`, `--fail-on`, `--out` and `--no-file` options. Fix prompts go to `LAUNCH_FIXES_LIVE.md` in the current folder. Run `npx launch-doctor scan --help` for the options.
|
|
180
|
+
|
|
181
|
+
## Grading
|
|
182
|
+
|
|
183
|
+
- **Category score** = 100 − 50 per critical finding − 15 per warning.
|
|
184
|
+
- Any critical finding caps the category at 39, which is an F.
|
|
185
|
+
- Without a critical finding the score never drops below 40, so warnings alone cannot produce an F.
|
|
186
|
+
- **Overall score** is the weighted average of the categories that ran:
|
|
187
|
+
- Weights: secrets (3), database (3), payments (3), costs (2), email (1), monitoring (1), legal (1), and first impressions (1).
|
|
188
|
+
- Categories that do not apply, or are skipped with `--only` / `--skip`, are excluded.
|
|
189
|
+
- **Caps on the overall score:**
|
|
190
|
+
- Any critical finding anywhere caps the overall score at 39 (F).
|
|
191
|
+
- Any warning caps it at 89, so an A requires zero warnings and zero critical issues.
|
|
192
|
+
- **Grade tiers:** A ≥ 90, B ≥ 75, C ≥ 60, D ≥ 40, F < 40.
|
|
193
|
+
- "Check yourself" items do not alter the numerical grade. Baseline findings count toward the grade for awareness, but are ignored by the `--ci` exit code.
|
|
194
|
+
|
|
195
|
+
## CLI reference
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
npx launch-doctor [folder] [options]
|
|
199
|
+
npx launch-doctor init [folder]
|
|
200
|
+
npx launch-doctor scan <url> [options]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Flag | Default | Description |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| `[folder]` | `.` | Project folder to check |
|
|
206
|
+
| `--domain <domain>` | auto-detected | Domain you send email from; checks SPF, DKIM and DMARC |
|
|
207
|
+
| `--out <file>` | `LAUNCH_FIXES.md` in the project | Where to save the fix prompts |
|
|
208
|
+
| `--no-file` | off | Don't write the fix prompts file |
|
|
209
|
+
| `--json` | off | Print the full report as JSON (no fix file unless `--out` is given) |
|
|
210
|
+
| `--sarif <file>` | off | Also write a SARIF 2.1.0 file for GitHub code scanning |
|
|
211
|
+
| `--offline` | off | Skip network checks (email DNS) |
|
|
212
|
+
| `--ci` | off | Exit with code 1 on findings at or above `--fail-on` (no fix file unless `--out`) |
|
|
213
|
+
| `--fail-on <level>` | `critical` | With `--ci`, the lowest severity that fails: `critical` or `warning` |
|
|
214
|
+
| `--only <ids>` | all | Run only these categories (comma-separated) |
|
|
215
|
+
| `--skip <ids>` | none | Skip these categories (comma-separated) |
|
|
216
|
+
| `--history` | off | Also look for keys still in git history |
|
|
217
|
+
| `--history-depth <n>` | `500` | How many commits `--history` reads |
|
|
218
|
+
| `--update-baseline` | off | Save today's findings to `.launchdoctor-baseline.json` as accepted |
|
|
219
|
+
| `--no-baseline` | off | Ignore `.launchdoctor-baseline.json` and show every finding |
|
|
220
|
+
| `--demo` | off | Scan a built-in sample app full of mistakes |
|
|
221
|
+
| `-h`, `--help` | | Show help |
|
|
222
|
+
| `-v`, `--version` | | Show the version |
|
|
223
|
+
| `init [folder]` | `.` | Create `.launchdoctorignore` and `.github/workflows/launch-doctor.yml` (never overwrites) |
|
|
224
|
+
| `scan <url>` | | Check your deployed site from the outside (see [Live site scan](#live-site-scan)) |
|
|
225
|
+
| `--no-db` | off | With `scan`, don't test Supabase tables with the public key found in the page |
|
|
226
|
+
|
|
227
|
+
Category ids for `--only` and `--skip`: `secrets`, `database`, `payments`, `costs`, `email`, `monitoring`, `legal`, `first-impressions`. Skipped categories show as "skipped" and don't count toward the grade.
|
|
228
|
+
|
|
229
|
+
**Exit codes**
|
|
230
|
+
|
|
231
|
+
| Code | Meaning |
|
|
232
|
+
|---|---|
|
|
233
|
+
| `0` | The scan finished (and with `--ci`, no findings at or above `--fail-on`) |
|
|
234
|
+
| `1` | `--ci` was given and there are findings at or above `--fail-on` (baseline findings excluded) |
|
|
235
|
+
| `2` | Usage error (unknown flag, invalid argument, folder not found) or a crash |
|
|
236
|
+
|
|
237
|
+
## Configuration
|
|
238
|
+
|
|
239
|
+
### `.launchdoctorignore`
|
|
240
|
+
|
|
241
|
+
One entry per line. Run `npx launch-doctor init` to generate a starter template.
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
no-error-tracking
|
|
245
|
+
no-account-deletion
|
|
246
|
+
legacy/
|
|
247
|
+
scripts/seed.ts
|
|
248
|
+
**/*.fixture.ts
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A plain word without path characters represents a finding id. Anything containing `/`, `*`, or `.`, or matching an existing file or folder on disk, is treated as a path pattern. Finding ids that do not correspond to any known check produce a warning to catch typos.
|
|
252
|
+
|
|
253
|
+
### Inline ignores
|
|
254
|
+
|
|
255
|
+
To silence a specific finding at a single line, place a `launch-doctor-ignore <id>` directive on that line or the line directly above it. All directive styles are supported (`//`, `#`, `/* */`, `<!-- -->`, SQL `--`), and multiple ids can be separated by commas:
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
// launch-doctor-ignore stripe-test-key
|
|
259
|
+
const STRIPE_TEST_KEY = 'sk_test_...';
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Baseline
|
|
263
|
+
|
|
264
|
+
When adding Launch Doctor to an existing codebase, record current findings so CI checks focus exclusively on new issues:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npx launch-doctor --update-baseline
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
On subsequent runs:
|
|
271
|
+
- Matching findings are tagged with `baseline: true` in JSON output.
|
|
272
|
+
- They are summarized in terminal output as a single "N existing issues (baseline)" line.
|
|
273
|
+
- They are excluded from `--ci` / `--fail-on` failure checks.
|
|
274
|
+
|
|
275
|
+
Findings are tracked by check ID, file path, and a fingerprint of the offending line, preserving baseline matches even as line numbers shift. Run with `--no-baseline` to display all suppressed findings.
|
|
276
|
+
|
|
277
|
+
## CI integration
|
|
278
|
+
|
|
279
|
+
The `npx launch-doctor init` command creates this GitHub Actions workflow:
|
|
280
|
+
|
|
281
|
+
```yaml
|
|
282
|
+
name: Launch Doctor
|
|
283
|
+
on: [pull_request]
|
|
284
|
+
jobs:
|
|
285
|
+
check:
|
|
286
|
+
runs-on: ubuntu-latest
|
|
287
|
+
steps:
|
|
288
|
+
- uses: actions/checkout@v5
|
|
289
|
+
- uses: actions/setup-node@v5
|
|
290
|
+
with:
|
|
291
|
+
node-version: 22
|
|
292
|
+
- run: npx launch-doctor --ci
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- **Severity gating:** By default, `--ci` exits with code 1 only on critical findings. Add `--fail-on warning` to fail builds on warnings as well.
|
|
296
|
+
- **Job summaries:** When running in GitHub Actions, Launch Doctor automatically writes a markdown summary (including overall grade, category scorecard, and itemized issues with their file and line) to the GitHub Actions job summary tab via `GITHUB_STEP_SUMMARY`.
|
|
297
|
+
- **Code scanning alerts:** Export findings to SARIF 2.1.0 format to populate alerts directly in your repository Security tab. The upload step needs permission to write security events, so add it to the job:
|
|
298
|
+
|
|
299
|
+
```yaml
|
|
300
|
+
permissions:
|
|
301
|
+
contents: read
|
|
302
|
+
security-events: write
|
|
303
|
+
steps:
|
|
304
|
+
# ...checkout and setup-node as above...
|
|
305
|
+
- run: npx launch-doctor --sarif launch-doctor.sarif --no-file
|
|
306
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
307
|
+
if: always()
|
|
308
|
+
with:
|
|
309
|
+
sarif_file: launch-doctor.sarif
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Using with AI coding tools
|
|
313
|
+
|
|
314
|
+
Launch Doctor outputs `LAUNCH_FIXES.md` directly into your project root. Each entry includes the exact file and line number, an explanation of the risk, and a tailored prompt ready to paste into your AI assistant. It also includes a single batch prompt at the top of the file.
|
|
315
|
+
|
|
316
|
+
### With Claude Code
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
! npx launch-doctor
|
|
320
|
+
Fix the issues in LAUNCH_FIXES.md one at a time, starting with the critical ones. Explain each change before making it.
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### With Cursor, Windsurf, Lovable, or Bolt
|
|
324
|
+
|
|
325
|
+
1. Run `npx launch-doctor` in your integrated terminal.
|
|
326
|
+
2. Open `LAUNCH_FIXES.md`.
|
|
327
|
+
3. Copy one fix prompt into the chat window.
|
|
328
|
+
4. Review and accept the code edit.
|
|
329
|
+
5. Re-run `npx launch-doctor` to observe your score improve.
|
|
330
|
+
|
|
331
|
+
## Privacy and network use
|
|
332
|
+
|
|
333
|
+
Launch Doctor analyzes your codebase locally on your device. Your source code, findings, and credentials are never uploaded to any remote server. Detected secrets are masked in reports (for example, `sk_live_…exe9`).
|
|
334
|
+
|
|
335
|
+
- **Email DNS validation:** This is the only network check a folder scan performs. When your project sends transactional email and a domain is identified (either discovered in code or specified via `--domain`), Launch Doctor queries your system DNS resolver for NS and TXT records (including root SPF, `send.<domain>`, `_dmarc.<domain>`, and common DKIM selectors). No code or private data is transmitted. Pass `--offline` to disable DNS lookups entirely. The `--demo` command never touches the network.
|
|
336
|
+
- **Live site scan (`scan <url>`):** sends ordinary `GET` requests to the address you give and to Supabase when your page uses it. Nothing is sent anywhere else, and nothing is uploaded.
|
|
337
|
+
- **Git history analysis (`--history`):** Runs local `git log` commands directly on your system without network requests.
|
|
338
|
+
- **Package installation:** standard `npx` retrieval via the npm registry.
|
|
339
|
+
|
|
340
|
+
## Limitations
|
|
341
|
+
|
|
342
|
+
Launch Doctor provides rapid pre-launch hygiene, not a full penetration test or manual security audit:
|
|
343
|
+
|
|
344
|
+
- It uses pattern analysis and heuristic inspection; it may occasionally flag safe code or miss complex multi-file logic. Use `.launchdoctorignore` or inline comments where appropriate.
|
|
345
|
+
- It cannot inspect third-party web dashboards. Settings configured via web consoles in Supabase, Firebase, Stripe, or cloud hosts appear on the "check yourself" manual checklist.
|
|
346
|
+
- JavaScript, TypeScript, and Python codebases receive the deepest static analysis coverage.
|
|
347
|
+
- Route analysis works per handler and follows local imports 2 levels deep. Dynamic imports and unusual route shapes may not be followed.
|
|
348
|
+
|
|
349
|
+
For applications processing significant financial transactions or sensitive personal health data, combine automated checks with a human security review.
|
|
350
|
+
|
|
351
|
+
## Roadmap
|
|
352
|
+
|
|
353
|
+
- [x] Live URL inspection (`launch-doctor scan <url>`: exposed `.env`, source maps, security headers, open Supabase tables via anonymous key)
|
|
354
|
+
- [ ] GitHub Action bot to post interactive review comments on pull requests
|
|
355
|
+
- [ ] Model Context Protocol (MCP) server for direct Claude Code and Cursor integration
|
|
356
|
+
- [ ] Extended provider coverage (Clerk, Convex, Appwrite, Lemon Squeezy, Paddle)
|
|
357
|
+
- [ ] Mobile framework support (Expo, React Native)
|
|
358
|
+
|
|
359
|
+
## Contributing
|
|
360
|
+
|
|
361
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local environment setup, architecture notes, and instructions on creating new checks. All contributors are expected to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
362
|
+
|
|
363
|
+
## Contributors
|
|
364
|
+
|
|
365
|
+
Thanks to everyone who has helped build Launch Doctor. Contributors are listed here once their pull request is merged.
|
|
366
|
+
|
|
367
|
+
- [@SHARAJ379](https://github.com/SHARAJ379): creator and maintainer
|
|
368
|
+
|
|
369
|
+
Want to be on this list? Pick an open issue labelled `good first issue` or `help wanted`.
|
|
370
|
+
|
|
371
|
+
## Security
|
|
372
|
+
|
|
373
|
+
Please do not report security vulnerabilities in public issues. Refer to [SECURITY.md](SECURITY.md) for instructions on confidential disclosure.
|
|
374
|
+
|
|
375
|
+
## License
|
|
376
|
+
|
|
377
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProjectContext } from './project.js';
|
|
2
|
+
import type { Finding, Report } from './types.js';
|
|
3
|
+
export declare const BASELINE_FILE = ".launchdoctor-baseline.json";
|
|
4
|
+
/**
|
|
5
|
+
* A stable fingerprint: finding id + file + a hash of the trimmed text of the matched line.
|
|
6
|
+
* It doesn't include the line number, so it survives lines moving up or down.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fingerprint(ctx: ProjectContext, f: Finding): string;
|
|
9
|
+
/** Fingerprints in the project's baseline file, or null if there is none (or it can't be read). */
|
|
10
|
+
export declare function loadBaseline(root: string): Set<string> | null;
|
|
11
|
+
/** Save every current finding as the new baseline. Returns how many were saved. */
|
|
12
|
+
export declare function writeBaseline(root: string, report: Report): number;
|
|
13
|
+
/** Mark findings that are in the baseline. Returns how many matched. */
|
|
14
|
+
export declare function applyBaseline(report: Report, baseline: Set<string>): number;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
export const BASELINE_FILE = '.launchdoctor-baseline.json';
|
|
5
|
+
/**
|
|
6
|
+
* A stable fingerprint: finding id + file + a hash of the trimmed text of the matched line.
|
|
7
|
+
* It doesn't include the line number, so it survives lines moving up or down.
|
|
8
|
+
*/
|
|
9
|
+
export function fingerprint(ctx, f) {
|
|
10
|
+
const file = f.location?.file ?? '';
|
|
11
|
+
let text = '';
|
|
12
|
+
if (file && f.location?.line) {
|
|
13
|
+
const content = ctx.file(file)?.content;
|
|
14
|
+
if (content)
|
|
15
|
+
text = content.split(/\r?\n/)[f.location.line - 1]?.trim() ?? '';
|
|
16
|
+
}
|
|
17
|
+
if (!text)
|
|
18
|
+
text = f.title;
|
|
19
|
+
const hash = createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
20
|
+
return `${f.id}|${file}|${hash}`;
|
|
21
|
+
}
|
|
22
|
+
/** Fingerprints in the project's baseline file, or null if there is none (or it can't be read). */
|
|
23
|
+
export function loadBaseline(root) {
|
|
24
|
+
let raw;
|
|
25
|
+
try {
|
|
26
|
+
raw = readFileSync(join(root, BASELINE_FILE), 'utf8');
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const data = JSON.parse(raw);
|
|
33
|
+
return new Set((data.findings ?? []).map((e) => e.fingerprint).filter((f) => typeof f === 'string'));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Save every current finding as the new baseline. Returns how many were saved. */
|
|
40
|
+
export function writeBaseline(root, report) {
|
|
41
|
+
const findings = report.categories.flatMap((c) => c.findings).filter((f) => f.fingerprint);
|
|
42
|
+
const data = {
|
|
43
|
+
tool: 'launch-doctor',
|
|
44
|
+
version: 1,
|
|
45
|
+
generatedAt: report.generatedAt,
|
|
46
|
+
findings: findings.map((f) => ({
|
|
47
|
+
fingerprint: f.fingerprint,
|
|
48
|
+
id: f.id,
|
|
49
|
+
...(f.location ? { file: f.location.file } : {}),
|
|
50
|
+
})),
|
|
51
|
+
};
|
|
52
|
+
writeFileSync(join(root, BASELINE_FILE), `${JSON.stringify(data, null, 2)}\n`);
|
|
53
|
+
return findings.length;
|
|
54
|
+
}
|
|
55
|
+
/** Mark findings that are in the baseline. Returns how many matched. */
|
|
56
|
+
export function applyBaseline(report, baseline) {
|
|
57
|
+
let matched = 0;
|
|
58
|
+
for (const c of report.categories) {
|
|
59
|
+
for (const f of c.findings) {
|
|
60
|
+
if (f.fingerprint && baseline.has(f.fingerprint)) {
|
|
61
|
+
f.baseline = true;
|
|
62
|
+
matched++;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
delete f.baseline;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
report.counts.baseline = matched;
|
|
70
|
+
return matched;
|
|
71
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Match, type ProjectContext, type SourceFile } from '../project.js';
|
|
2
|
+
export { isRouteLike } from '../project.js';
|
|
3
|
+
import type { CheckOutput, Location } from '../types.js';
|
|
4
|
+
export declare function emptyOutput(): CheckOutput;
|
|
5
|
+
export declare function notApplicable(note: string): CheckOutput;
|
|
6
|
+
export declare function at(m: Match): Location;
|
|
7
|
+
/** "src/app.ts (line 4)": for sentences and prompts. */
|
|
8
|
+
export declare function where(loc?: Location): string;
|
|
9
|
+
/** "src/app.ts:4": for lists and headings (clickable in most editors). */
|
|
10
|
+
export declare function shortWhere(loc?: Location): string;
|
|
11
|
+
/** App code we care about: real source files, not tests. */
|
|
12
|
+
export declare const appCode: (f: SourceFile) => boolean;
|
|
13
|
+
/** App code that runs on the server. */
|
|
14
|
+
export declare function serverCode(ctx: ProjectContext): (f: SourceFile) => boolean;
|
|
15
|
+
/** App code that runs in the browser. */
|
|
16
|
+
export declare function clientCode(ctx: ProjectContext): (f: SourceFile) => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isCodeFile, isTestPath } from '../project.js';
|
|
2
|
+
export { isRouteLike } from '../project.js';
|
|
3
|
+
export function emptyOutput() {
|
|
4
|
+
return { applicable: true, findings: [], passed: [], manual: [] };
|
|
5
|
+
}
|
|
6
|
+
export function notApplicable(note) {
|
|
7
|
+
return { applicable: false, note, findings: [], passed: [], manual: [] };
|
|
8
|
+
}
|
|
9
|
+
export function at(m) {
|
|
10
|
+
return { file: m.file.path, line: m.line };
|
|
11
|
+
}
|
|
12
|
+
/** "src/app.ts (line 4)": for sentences and prompts. */
|
|
13
|
+
export function where(loc) {
|
|
14
|
+
if (!loc)
|
|
15
|
+
return '';
|
|
16
|
+
return loc.line ? `${loc.file} (line ${loc.line})` : loc.file;
|
|
17
|
+
}
|
|
18
|
+
/** "src/app.ts:4": for lists and headings (clickable in most editors). */
|
|
19
|
+
export function shortWhere(loc) {
|
|
20
|
+
if (!loc)
|
|
21
|
+
return '';
|
|
22
|
+
return loc.line ? `${loc.file}:${loc.line}` : loc.file;
|
|
23
|
+
}
|
|
24
|
+
/** App code we care about: real source files, not tests. */
|
|
25
|
+
export const appCode = (f) => isCodeFile(f) && !isTestPath(f.path);
|
|
26
|
+
/** App code that runs on the server. */
|
|
27
|
+
export function serverCode(ctx) {
|
|
28
|
+
return (f) => appCode(f) && !ctx.isClient(f);
|
|
29
|
+
}
|
|
30
|
+
/** App code that runs in the browser. */
|
|
31
|
+
export function clientCode(ctx) {
|
|
32
|
+
return (f) => appCode(f) && ctx.isClient(f);
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SourceFile } from '../project.js';
|
|
2
|
+
import type { Check } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* True when a Next.js-style middleware (or proxy) file blocks signed-out users AND runs on /api routes.
|
|
5
|
+
* Middleware that only refreshes the session (e.g. Supabase's updateSession) doesn't count.
|
|
6
|
+
*/
|
|
7
|
+
export declare function middlewareBlocksApi(f: SourceFile, code?: string): boolean;
|
|
8
|
+
export declare const costsCheck: Check;
|