launch-doctor 0.4.0 → 0.4.2
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 +50 -7
- package/README.md +82 -402
- package/dist/src/banner.d.ts +22 -0
- package/dist/src/banner.js +35 -0
- package/dist/src/bin.cjs +35 -0
- package/dist/src/bin.d.cts +2 -0
- package/dist/src/checks/access.js +8 -0
- package/dist/src/checks/costs.js +6 -0
- package/dist/src/checks/database.js +29 -0
- package/dist/src/checks/payments.js +12 -0
- package/dist/src/checks/secrets.d.ts +26 -1
- package/dist/src/checks/secrets.js +245 -5
- package/dist/src/cli.js +275 -11
- package/dist/src/fixes.d.ts +8 -1
- package/dist/src/fixes.js +31 -10
- package/dist/src/grade.d.ts +8 -1
- package/dist/src/grade.js +13 -0
- package/dist/src/grades.d.ts +42 -0
- package/dist/src/grades.js +163 -0
- package/dist/src/history.js +9 -2
- package/dist/src/hooks-setup.d.ts +26 -0
- package/dist/src/hooks-setup.js +115 -1
- package/dist/src/index.js +6 -1
- package/dist/src/init.d.ts +32 -2
- package/dist/src/init.js +120 -6
- package/dist/src/live.d.ts +4 -1
- package/dist/src/live.js +62 -23
- package/dist/src/net-guard.d.ts +14 -6
- package/dist/src/net-guard.js +9 -6
- package/dist/src/pinned-http.d.ts +31 -0
- package/dist/src/pinned-http.js +104 -0
- package/dist/src/prompt.d.ts +23 -0
- package/dist/src/prompt.js +88 -0
- package/dist/src/report.d.ts +14 -1
- package/dist/src/report.js +29 -15
- package/dist/src/short-report.d.ts +59 -0
- package/dist/src/short-report.js +241 -0
- package/dist/src/types.d.ts +27 -0
- package/dist/src/util.d.ts +2 -0
- package/dist/src/util.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { shortWhere } from './checks/common.js';
|
|
2
|
+
import { orderedFindings } from './fixes.js';
|
|
3
|
+
import { GRADE_GROUPS } from './grade.js';
|
|
4
|
+
import { bannerLines, bold, dim, gradeColor, green, noticeLines, red, wrap, yellow } from './report.js';
|
|
5
|
+
import { ISSUES_LIST_URL, plural } from './util.js';
|
|
6
|
+
/** How many findings "FIX THESE FIRST" shows. */
|
|
7
|
+
export const TOP_FINDINGS = 3;
|
|
8
|
+
/** Short names for the "Checked ..." line of a clean report. */
|
|
9
|
+
const SHORT_NAMES = {
|
|
10
|
+
secrets: 'secrets',
|
|
11
|
+
database: 'database',
|
|
12
|
+
access: 'access control',
|
|
13
|
+
payments: 'payments',
|
|
14
|
+
costs: 'AI costs',
|
|
15
|
+
email: 'email',
|
|
16
|
+
monitoring: 'monitoring',
|
|
17
|
+
legal: 'legal pages',
|
|
18
|
+
'first-impressions': 'first impressions',
|
|
19
|
+
};
|
|
20
|
+
export function shortCounts(report) {
|
|
21
|
+
const ordered = orderedFindings(report);
|
|
22
|
+
const fresh = ordered.filter((f) => !f.baseline);
|
|
23
|
+
const inGroup = (ids) => {
|
|
24
|
+
const cats = report.categories.filter((c) => ids.includes(c.id));
|
|
25
|
+
return new Set(cats.flatMap((c) => c.findings));
|
|
26
|
+
};
|
|
27
|
+
const security = inGroup(GRADE_GROUPS.security);
|
|
28
|
+
const launch = inGroup(GRADE_GROUPS.launch);
|
|
29
|
+
const count = (set, severity, list = fresh) => list.filter((f) => set.has(f) && f.severity === severity).length;
|
|
30
|
+
const top = fresh.slice(0, TOP_FINDINGS).map((finding) => ({ finding, n: ordered.indexOf(finding) + 1 }));
|
|
31
|
+
const rest = fresh.slice(TOP_FINDINGS);
|
|
32
|
+
return {
|
|
33
|
+
critical: fresh.filter((f) => f.severity === 'critical').length,
|
|
34
|
+
security: { critical: count(security, 'critical'), warning: count(security, 'warning') },
|
|
35
|
+
launch: { critical: count(launch, 'critical'), warning: count(launch, 'warning') },
|
|
36
|
+
top,
|
|
37
|
+
also: {
|
|
38
|
+
critical: rest.filter((f) => f.severity === 'critical').length,
|
|
39
|
+
warning: count(security, 'warning', rest),
|
|
40
|
+
polish: count(launch, 'warning', rest),
|
|
41
|
+
manual: report.categories.reduce((sum, c) => sum + c.manual.length, 0),
|
|
42
|
+
},
|
|
43
|
+
baseline: ordered.length - fresh.length,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function gradeRow(label, g, parts) {
|
|
47
|
+
const letter = g?.grade ? bold(gradeColor(g.grade)(g.grade)) : dim('-');
|
|
48
|
+
const summary = !g?.grade ? dim('not checked') : parts.length ? parts.join(dim(' · ')) : green('all good');
|
|
49
|
+
return ` ${label.padEnd(18)}${letter} ${summary}`;
|
|
50
|
+
}
|
|
51
|
+
/** "a, b and c" */
|
|
52
|
+
function list(items) {
|
|
53
|
+
return items.length < 2 ? (items[0] ?? '') : `${items.slice(0, -1).join(', ')} and ${items.at(-1)}`;
|
|
54
|
+
}
|
|
55
|
+
/** The first sentence of a longer explanation, for findings that have no short reason of their own. */
|
|
56
|
+
function firstSentence(text) {
|
|
57
|
+
const m = /^(.+?[.!?])(?:\s|$)/.exec(text.trim());
|
|
58
|
+
return (m ? m[1] : text.trim()).replace(/\.$/, '');
|
|
59
|
+
}
|
|
60
|
+
/** "Launch Doctor v0.4.1 · my-app · 13 files · Vite, React, Supabase +2", with the stack shortened to fit. */
|
|
61
|
+
function headerLine(report, width) {
|
|
62
|
+
const base = `Launch Doctor v${report.version} · ${report.projectName} · ${plural(report.filesScanned, 'file')}`;
|
|
63
|
+
let stack = report.stack;
|
|
64
|
+
const text = (items, more) => items.length ? ` · ${items.join(', ')}${more ? ` +${more}` : ''}` : more ? ` · +${more}` : '';
|
|
65
|
+
while (stack.length && 2 + base.length + text(stack, report.stack.length - stack.length).length > width) {
|
|
66
|
+
stack = stack.slice(0, -1);
|
|
67
|
+
}
|
|
68
|
+
const rest = text(stack, report.stack.length - stack.length);
|
|
69
|
+
return ` ${bold(`Launch Doctor v${report.version}`)}${dim(base.slice(`Launch Doctor v${report.version}`.length) + rest)}`;
|
|
70
|
+
}
|
|
71
|
+
function findingLines(f, n, width) {
|
|
72
|
+
const indent = ' '.repeat(5);
|
|
73
|
+
const title = f.display?.title ?? f.title;
|
|
74
|
+
const [first, ...more] = wrap(title, width - indent.length, '');
|
|
75
|
+
const lines = [` ${bold(`${n}.`.padEnd(3))}${bold(first ?? '')}`, ...more.map((l) => `${indent}${bold(l)}`)];
|
|
76
|
+
const reason = f.display?.reason ?? firstSentence(f.why);
|
|
77
|
+
const where = f.location ? shortWhere(f.location) : '';
|
|
78
|
+
if (where && indent.length + where.length + 2 + reason.length <= width) {
|
|
79
|
+
lines.push(`${indent}${where} ${dim(reason)}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (where)
|
|
83
|
+
lines.push(`${indent}${where}`);
|
|
84
|
+
lines.push(...wrap(reason, width - indent.length, indent).map(dim));
|
|
85
|
+
}
|
|
86
|
+
if (f.display?.rotate)
|
|
87
|
+
lines.push(`${indent}${yellow('Rotate the key first:')} ${f.display.rotate}`);
|
|
88
|
+
return lines;
|
|
89
|
+
}
|
|
90
|
+
/** Rows of "command what it does", with the descriptions lined up and wrapped to the width. */
|
|
91
|
+
function commandRows(rows, width) {
|
|
92
|
+
const col = Math.max(...rows.map(([cmd]) => cmd.length));
|
|
93
|
+
const descIndent = 4 + col + 3;
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const [cmd, desc] of rows) {
|
|
96
|
+
if (width - descIndent < 24) {
|
|
97
|
+
out.push(` ${cmd}`, ...wrap(desc, width - 6, ' ').map(dim));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const [first, ...more] = wrap(desc, width - descIndent, '');
|
|
101
|
+
out.push(` ${cmd.padEnd(col)} ${dim(first ?? '')}`, ...more.map((l) => ' '.repeat(descIndent) + dim(l)));
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
/** Optional extras this run did not look at, for the clean verdict. */
|
|
106
|
+
function notChecked(report) {
|
|
107
|
+
const out = [];
|
|
108
|
+
const byId = new Map(report.categories.map((c) => [c.id, c]));
|
|
109
|
+
for (const c of report.categories)
|
|
110
|
+
if (c.skipped)
|
|
111
|
+
out.push(`${SHORT_NAMES[c.id] ?? c.name} (skipped)`);
|
|
112
|
+
const email = byId.get('email');
|
|
113
|
+
const dns = email?.manual.find((m) => m.id === 'email-dns');
|
|
114
|
+
if (email?.applicable && dns)
|
|
115
|
+
out.push(`email DNS (${/--domain/.test(dns.how) ? 'add --domain' : 'run online'})`);
|
|
116
|
+
const secrets = byId.get('secrets');
|
|
117
|
+
const history = secrets?.findings.some((f) => f.id === 'secret-in-history') ||
|
|
118
|
+
secrets?.passed.some((p) => /git history/i.test(p) && !/not checked/i.test(p));
|
|
119
|
+
if (secrets?.applicable && !history)
|
|
120
|
+
out.push('git history (add --history)');
|
|
121
|
+
out.push('your live site (launch-doctor scan <url>)');
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The default terminal report: the verdict, two grades, the three things to fix first and what to do next.
|
|
126
|
+
* `--verbose` (and --ci, --changed, --staged, --pr-comment and live scans) print the full report instead.
|
|
127
|
+
*/
|
|
128
|
+
export function renderShortReport(report, opts = {}) {
|
|
129
|
+
const width = Math.max(60, Math.min(100, process.stdout.columns || 80));
|
|
130
|
+
const counts = shortCounts(report);
|
|
131
|
+
const lines = [''];
|
|
132
|
+
if (opts.banner)
|
|
133
|
+
lines.push(...bannerLines());
|
|
134
|
+
lines.push(headerLine(report, width), ...noticeLines(report), '');
|
|
135
|
+
// 1. Verdict
|
|
136
|
+
const warnings = counts.security.warning + counts.launch.warning;
|
|
137
|
+
if (counts.critical) {
|
|
138
|
+
lines.push(` ${bold(red(`NOT READY TO LAUNCH: ${plural(counts.critical, 'critical problem')}`))}`);
|
|
139
|
+
}
|
|
140
|
+
else if (warnings) {
|
|
141
|
+
lines.push(` ${bold(yellow(`NOT READY TO LAUNCH: ${plural(warnings, 'problem')} to fix`))}`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
lines.push(` ${bold(green('Ready, as far as Launch Doctor can tell'))}`);
|
|
145
|
+
const ran = report.categories.filter((c) => c.applicable && !c.skipped).map((c) => SHORT_NAMES[c.id] ?? c.name);
|
|
146
|
+
const checked = ran.length
|
|
147
|
+
? `Checked ${list(ran)} in ${plural(report.filesScanned, 'file')}.`
|
|
148
|
+
: `Checked ${plural(report.filesScanned, 'file')}.`;
|
|
149
|
+
lines.push(...wrap(checked, width - 2, ' ').map(dim));
|
|
150
|
+
lines.push(...wrap("Can't check: your dashboard settings (Supabase, Stripe, hosting), backups, real sign-ins.", width - 2, ' ').map(dim));
|
|
151
|
+
lines.push(...wrap(`Not checked: ${notChecked(report).join(', ')}.`, width - 2, ' ').map(dim));
|
|
152
|
+
}
|
|
153
|
+
lines.push('');
|
|
154
|
+
// 2. The two grades
|
|
155
|
+
const parts = (c, warningWord) => [
|
|
156
|
+
...(c.critical ? [red(`${c.critical} critical`)] : []),
|
|
157
|
+
...(c.warning ? [yellow(plural(c.warning, warningWord))] : []),
|
|
158
|
+
];
|
|
159
|
+
lines.push(gradeRow('Security', report.grades?.security, parts(counts.security, 'warning')));
|
|
160
|
+
lines.push(gradeRow('Launch readiness', report.grades?.launch, parts(counts.launch, 'polish item')));
|
|
161
|
+
if (opts.lastRecorded) {
|
|
162
|
+
lines.push(` ${dim(`Overall grade ${report.grade} (${report.score}). Last recorded grade: ${opts.lastRecorded}`)}`);
|
|
163
|
+
}
|
|
164
|
+
lines.push('');
|
|
165
|
+
// 3. The three things to fix first
|
|
166
|
+
if (counts.top.length) {
|
|
167
|
+
lines.push(` ${bold('FIX THESE FIRST')}`, '');
|
|
168
|
+
for (const { finding, n } of counts.top)
|
|
169
|
+
lines.push(...findingLines(finding, n, width), '');
|
|
170
|
+
}
|
|
171
|
+
// 4. Everything else, counted
|
|
172
|
+
const also = [
|
|
173
|
+
...(counts.also.critical ? [red(`${counts.also.critical} more critical`)] : []),
|
|
174
|
+
...(counts.also.warning ? [yellow(plural(counts.also.warning, 'warning'))] : []),
|
|
175
|
+
...(counts.also.polish ? [plural(counts.also.polish, 'polish item')] : []),
|
|
176
|
+
...(counts.also.manual ? [`${counts.also.manual} to check yourself`] : []),
|
|
177
|
+
];
|
|
178
|
+
if (also.length)
|
|
179
|
+
lines.push(` Also: ${also.join(dim(' · '))}`);
|
|
180
|
+
if (counts.baseline) {
|
|
181
|
+
lines.push(` ${dim(`${plural(counts.baseline, 'existing issue')} (baseline) not shown. Use --no-baseline to list them.`)}`);
|
|
182
|
+
}
|
|
183
|
+
if (report.ignored) {
|
|
184
|
+
lines.push(` ${dim(`${plural(report.ignored, 'item')} hidden by .launchdoctorignore or launch-doctor-ignore comments`)}`);
|
|
185
|
+
}
|
|
186
|
+
for (const id of report.unknownIgnoreIds) {
|
|
187
|
+
lines.push(` ${dim(`Warning: "${id}" in .launchdoctorignore doesn't match any check (typo?)`)}`);
|
|
188
|
+
}
|
|
189
|
+
if (also.length || counts.baseline || report.ignored || report.unknownIgnoreIds.length)
|
|
190
|
+
lines.push('');
|
|
191
|
+
// 5. What to do next
|
|
192
|
+
const target = opts.target ?? '';
|
|
193
|
+
const rows = [];
|
|
194
|
+
const first = counts.top[0];
|
|
195
|
+
if (first)
|
|
196
|
+
rows.push([`npx launch-doctor prompt ${first.n}${target} --copy`, `copy the fix prompt for ${first.n}`]);
|
|
197
|
+
if (opts.fixFile) {
|
|
198
|
+
const anyCritical = orderedFindings(report).some((f) => f.severity === 'critical');
|
|
199
|
+
rows.push([
|
|
200
|
+
opts.fixFile,
|
|
201
|
+
anyCritical ? 'every fix prompt, starting with one for all critical problems' : 'every fix prompt',
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
rows.push([`npx launch-doctor${target} --verbose`, 'the full report']);
|
|
205
|
+
lines.push(` ${bold('Next')}`, ...commandRows(rows, width));
|
|
206
|
+
if (opts.demo && !opts.fixFile)
|
|
207
|
+
lines.push(` ${dim('On your own project, every fix prompt is saved to LAUNCH_FIXES.md.')}`);
|
|
208
|
+
lines.push('');
|
|
209
|
+
lines.push(` ${dim(`Wrong finding? ${ISSUES_LIST_URL}`)}`, '');
|
|
210
|
+
return `${lines.join('\n')}\n`;
|
|
211
|
+
}
|
|
212
|
+
function messageWidth() {
|
|
213
|
+
return Math.max(60, Math.min(100, process.stdout.columns || 80));
|
|
214
|
+
}
|
|
215
|
+
/** First run in a folder with nothing to read: an explanation instead of a grade. */
|
|
216
|
+
export function renderEmptyFolder(report, root) {
|
|
217
|
+
const width = messageWidth();
|
|
218
|
+
return [
|
|
219
|
+
'',
|
|
220
|
+
` ${bold('Launch Doctor')} ${dim(`v${report.version}`)}`,
|
|
221
|
+
'',
|
|
222
|
+
...wrap(`Nothing to check here: no project files were found in ${root}.`, width - 2, ' '),
|
|
223
|
+
...wrap("Run it inside your app's folder (the one with package.json, requirements.txt or similar), or try it on a built-in sample app: npx launch-doctor --demo", width - 2, ' '),
|
|
224
|
+
'',
|
|
225
|
+
'',
|
|
226
|
+
].join('\n');
|
|
227
|
+
}
|
|
228
|
+
/** A project in a language whose code the checks don't read: an explanation instead of a meaningless grade. */
|
|
229
|
+
export function renderOtherLanguage(report, found) {
|
|
230
|
+
const width = messageWidth();
|
|
231
|
+
return [
|
|
232
|
+
'',
|
|
233
|
+
` ${bold('Launch Doctor')} ${dim(`v${report.version} · ${report.projectName}`)}`,
|
|
234
|
+
'',
|
|
235
|
+
...wrap(`This looks like a ${found.language} project (${found.marker}). Launch Doctor's checks are written for JavaScript, TypeScript and Python apps, so it can't give this project a grade.`, width - 2, ' '),
|
|
236
|
+
...wrap('It can still check your deployed site from the outside:', width - 2, ' '),
|
|
237
|
+
' npx launch-doctor scan https://your-site.com',
|
|
238
|
+
'',
|
|
239
|
+
'',
|
|
240
|
+
].join('\n');
|
|
241
|
+
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -20,6 +20,26 @@ export interface Finding {
|
|
|
20
20
|
fingerprint?: string;
|
|
21
21
|
/** True when this finding is in .launchdoctor-baseline.json (an existing, accepted issue). */
|
|
22
22
|
baseline?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* How the short terminal report shows this finding. Display only: ids, titles, fingerprints and
|
|
25
|
+
* baselines never use it. Absent for most warnings, which then show their title and the start of `why`.
|
|
26
|
+
*/
|
|
27
|
+
display?: FindingDisplay;
|
|
28
|
+
}
|
|
29
|
+
export interface FindingDisplay {
|
|
30
|
+
/** Consequence first: "Anyone can use your Stripe account: the live secret key is in your code". */
|
|
31
|
+
title: string;
|
|
32
|
+
/** A few words shown after file:line: "sent to every visitor's browser". */
|
|
33
|
+
reason?: string;
|
|
34
|
+
/** For a leaked key: where to revoke it (a link to the provider's key page, or the menu path). */
|
|
35
|
+
rotate?: string;
|
|
36
|
+
/** For a leaked key: the provider's usage or activity log, to check whether someone else used it. */
|
|
37
|
+
usage?: string;
|
|
38
|
+
}
|
|
39
|
+
/** A grade for a group of categories (see GRADE_GROUPS), computed with the same rules as the overall grade. */
|
|
40
|
+
export interface GroupGrade {
|
|
41
|
+
score: number | null;
|
|
42
|
+
grade: Grade | null;
|
|
23
43
|
}
|
|
24
44
|
/** Something we can't see from the code, so the user has to check it. */
|
|
25
45
|
export interface ManualCheck {
|
|
@@ -82,6 +102,11 @@ export interface Report {
|
|
|
82
102
|
};
|
|
83
103
|
score: number;
|
|
84
104
|
grade: Grade;
|
|
105
|
+
/** Security and Launch readiness grades, shown in the terminal report. Absent for a live site scan. */
|
|
106
|
+
grades?: {
|
|
107
|
+
security: GroupGrade;
|
|
108
|
+
launch: GroupGrade;
|
|
109
|
+
};
|
|
85
110
|
verdict: string;
|
|
86
111
|
/** baseline: how many findings matched .launchdoctor-baseline.json. */
|
|
87
112
|
counts: {
|
|
@@ -125,4 +150,6 @@ export interface Options {
|
|
|
125
150
|
history?: {
|
|
126
151
|
depth: number;
|
|
127
152
|
};
|
|
153
|
+
/** Called before each category is checked, with its name (for a progress line). */
|
|
154
|
+
onProgress?: (step: string) => void;
|
|
128
155
|
}
|
package/dist/src/util.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Where people report false alarms, misses and crashes. */
|
|
2
2
|
export declare const ISSUES_URL = "https://github.com/SHARAJ379/Launch-Doctor/issues/new/choose";
|
|
3
|
+
/** The issue list: shorter, for the one-line footer of the short report. */
|
|
4
|
+
export declare const ISSUES_LIST_URL = "https://github.com/SHARAJ379/Launch-Doctor/issues";
|
|
3
5
|
/** 1-based line number of a character index. */
|
|
4
6
|
export declare function lineAt(text: string, index: number): number;
|
|
5
7
|
/** The full text of the line containing `index`. */
|
package/dist/src/util.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Where people report false alarms, misses and crashes. */
|
|
2
2
|
export const ISSUES_URL = 'https://github.com/SHARAJ379/Launch-Doctor/issues/new/choose';
|
|
3
|
+
/** The issue list: shorter, for the one-line footer of the short report. */
|
|
4
|
+
export const ISSUES_LIST_URL = 'https://github.com/SHARAJ379/Launch-Doctor/issues';
|
|
3
5
|
/** 1-based line number of a character index. */
|
|
4
6
|
export function lineAt(text, index) {
|
|
5
7
|
let line = 1;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "launch-doctor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "A pre-launch checkup for vibe-coded apps. Grades your project A-F on secrets, database safety, payments, AI costs, email, error tracking, legal pages and first impressions, with a copy-paste fix prompt for every issue.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"launch-doctor": "dist/src/
|
|
7
|
+
"launch-doctor": "dist/src/bin.cjs"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/src/index.js",
|
|
10
10
|
"types": "dist/src/index.d.ts",
|