launch-doctor 0.2.1 → 0.3.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/CHANGELOG.md +31 -1
- package/README.md +155 -30
- package/dist/src/checks/costs.d.ts +1 -0
- package/dist/src/checks/costs.js +40 -5
- package/dist/src/checks/database.js +122 -3
- package/dist/src/checks/first-impressions.js +227 -117
- package/dist/src/checks/legal.js +27 -13
- package/dist/src/checks/monitoring.js +39 -10
- package/dist/src/checks/payments.js +131 -4
- package/dist/src/checks/secrets.js +103 -7
- package/dist/src/cli.js +90 -3
- package/dist/src/demo.d.ts +13 -0
- package/dist/src/demo.js +58 -2
- package/dist/src/detect.js +4 -1
- package/dist/src/fixes.js +2 -2
- package/dist/src/github.d.ts +80 -0
- package/dist/src/github.js +288 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/init.d.ts +1 -1
- package/dist/src/init.js +2 -2
- package/dist/src/mcp.d.ts +140 -0
- package/dist/src/mcp.js +381 -0
- package/dist/src/project.d.ts +8 -0
- package/dist/src/project.js +102 -6
- package/dist/src/report.d.ts +2 -0
- package/dist/src/report.js +12 -1
- package/dist/src/summary.d.ts +3 -0
- package/dist/src/summary.js +17 -13
- package/dist/src/types.d.ts +2 -0
- package/dist/src/util.d.ts +2 -0
- package/dist/src/util.js +2 -0
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { detectAuth } from '../detect.js';
|
|
1
2
|
import { lineTextAt } from '../util.js';
|
|
2
3
|
import { appCode, at, emptyOutput, notApplicable, where } from './common.js';
|
|
3
4
|
const DEFAULT_TITLE = /<title>\s*(?:Vite \+ (?:React|Vue|Svelte|Preact|Lit|Solid|TS)(?: \+ TS)?|Vite App|React App|Create Next App|Lovable App|Nuxt App|SvelteKit App)\s*<\/title>|title\s*:\s*["'`]Create Next App["'`]|Generated by create next app/i;
|
|
@@ -21,6 +22,14 @@ export const firstImpressionsCheck = {
|
|
|
21
22
|
'not-found-page',
|
|
22
23
|
'robots-sitemap',
|
|
23
24
|
'phone-test',
|
|
25
|
+
'mobile-placeholder-app-id',
|
|
26
|
+
'android-cleartext-traffic',
|
|
27
|
+
'ios-arbitrary-loads',
|
|
28
|
+
'store-listing',
|
|
29
|
+
'store-privacy-labels',
|
|
30
|
+
'store-review-account',
|
|
31
|
+
'device-test',
|
|
32
|
+
'clerk-production-instance',
|
|
24
33
|
],
|
|
25
34
|
run(ctx) {
|
|
26
35
|
const frontend = ctx.files.some((f) => /\.html?$/i.test(f.path) && !/(^|\/)(docs|coverage)\//.test(f.path)) ||
|
|
@@ -36,125 +45,226 @@ export const firstImpressionsCheck = {
|
|
|
36
45
|
'preact',
|
|
37
46
|
'@angular/core',
|
|
38
47
|
]);
|
|
39
|
-
if (!ctx.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Default template titles
|
|
45
|
-
const defaultTitle = ctx.find(DEFAULT_TITLE, appCode, 1)[0];
|
|
46
|
-
if (defaultTitle) {
|
|
47
|
-
const isDescription = /Generated by create next app/i.test(defaultTitle.match[0]);
|
|
48
|
-
const shown = defaultTitle.match[0].replace(/<\/?title>|title\s*:\s*|["'`]/gi, '').trim();
|
|
49
|
-
out.findings.push({
|
|
50
|
-
id: 'default-title',
|
|
51
|
-
severity: 'warning',
|
|
52
|
-
title: isDescription ? `Your page description still says "${shown}"` : `Your browser tab still says "${shown}"`,
|
|
53
|
-
why: isDescription
|
|
54
|
-
? "That's the starter template's description. Google shows it under your link in search results and shared links, and it makes the app look unfinished."
|
|
55
|
-
: "That's the starter template's title. It shows in browser tabs, Google results and shared links, and makes the app look unfinished.",
|
|
56
|
-
location: at(defaultTitle),
|
|
57
|
-
fixPrompt: `My app still uses the template's default page title and description (${where(at(defaultTitle))}). Replace them with my app's real name and a one-sentence description of what it does, and set a title template so each page gets its own title.`,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const lovable = ctx.find(LOVABLE_DEFAULTS, appCode, 1)[0];
|
|
61
|
-
if (lovable) {
|
|
62
|
-
out.findings.push({
|
|
63
|
-
id: 'lovable-default-meta',
|
|
64
|
-
severity: 'warning',
|
|
65
|
-
title: "Lovable's default description or preview image is still in place",
|
|
66
|
-
why: 'Shared links will show Lovable branding instead of your app, which looks like a demo rather than a real product.',
|
|
67
|
-
location: at(lovable),
|
|
68
|
-
fixPrompt: `In ${where(at(lovable))} my app still has Lovable's default meta tags (description, og:image, twitter tags). Replace them with my own app name, description and a 1200×630 preview image.`,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const viteFavicon = ctx.find(/href=["']\/vite\.svg["']/, appCode, 1)[0];
|
|
72
|
-
if (viteFavicon) {
|
|
73
|
-
out.findings.push({
|
|
74
|
-
id: 'default-favicon',
|
|
75
|
-
severity: 'warning',
|
|
76
|
-
title: 'Your site icon is still the Vite logo',
|
|
77
|
-
why: "The little icon in the browser tab and bookmarks is the template's, not yours.",
|
|
78
|
-
location: at(viteFavicon),
|
|
79
|
-
fixPrompt: 'My app still uses the default vite.svg favicon. Help me add my own favicon (and an apple-touch-icon) and update index.html to use them.',
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// Description & social preview
|
|
83
|
-
const hasDescription = ctx.find(/<meta[^>]+name=["']description["']|\bdescription\s*:\s*["'`][^"'`]{10,}|generateMetadata/i, htmlOrLayout, 1).length > 0 ||
|
|
84
|
-
ctx.find(/<meta[^>]+name=["']description["']|\bdescription\s*:\s*["'`][^"'`]{10,}/i, appCode, 1).length > 0;
|
|
85
|
-
if (!hasDescription) {
|
|
86
|
-
out.findings.push({
|
|
87
|
-
id: 'no-description',
|
|
88
|
-
severity: 'warning',
|
|
89
|
-
title: 'No page description',
|
|
90
|
-
why: 'Google shows the description under your link in search results. Without one it picks random text from the page.',
|
|
91
|
-
fixPrompt: "Add a meta description to my app (one or two sentences on what it does and who it's for) in the main layout / index.html, and per-page descriptions for the main pages.",
|
|
92
|
-
});
|
|
48
|
+
if (!ctx.isMobileApp) {
|
|
49
|
+
if (!ctx.isWebApp)
|
|
50
|
+
return notApplicable('Not a web app');
|
|
51
|
+
if (!frontend)
|
|
52
|
+
return notApplicable('No website frontend found');
|
|
93
53
|
}
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
54
|
+
const out = emptyOutput();
|
|
55
|
+
if (ctx.isWebApp && frontend)
|
|
56
|
+
websiteImpressions(ctx, out);
|
|
57
|
+
if (ctx.isMobileApp)
|
|
58
|
+
mobileImpressions(ctx, out);
|
|
59
|
+
if (ctx.uses('@clerk/'))
|
|
60
|
+
out.manual.push(CLERK_PRODUCTION);
|
|
61
|
+
return out;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
function websiteImpressions(ctx, out) {
|
|
65
|
+
// Default template titles
|
|
66
|
+
const defaultTitle = ctx.find(DEFAULT_TITLE, appCode, 1)[0];
|
|
67
|
+
if (defaultTitle) {
|
|
68
|
+
const isDescription = /Generated by create next app/i.test(defaultTitle.match[0]);
|
|
69
|
+
const shown = defaultTitle.match[0].replace(/<\/?title>|title\s*:\s*|["'`]/gi, '').trim();
|
|
70
|
+
out.findings.push({
|
|
71
|
+
id: 'default-title',
|
|
72
|
+
severity: 'warning',
|
|
73
|
+
title: isDescription ? `Your page description still says "${shown}"` : `Your browser tab still says "${shown}"`,
|
|
74
|
+
why: isDescription
|
|
75
|
+
? "That's the starter template's description. Google shows it under your link in search results and shared links, and it makes the app look unfinished."
|
|
76
|
+
: "That's the starter template's title. It shows in browser tabs, Google results and shared links, and makes the app look unfinished.",
|
|
77
|
+
location: at(defaultTitle),
|
|
78
|
+
fixPrompt: `My app still uses the template's default page title and description (${where(at(defaultTitle))}). Replace them with my app's real name and a one-sentence description of what it does, and set a title template so each page gets its own title.`,
|
|
113
79
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
80
|
+
}
|
|
81
|
+
const lovable = ctx.find(LOVABLE_DEFAULTS, appCode, 1)[0];
|
|
82
|
+
if (lovable) {
|
|
83
|
+
out.findings.push({
|
|
84
|
+
id: 'lovable-default-meta',
|
|
85
|
+
severity: 'warning',
|
|
86
|
+
title: "Lovable's default description or preview image is still in place",
|
|
87
|
+
why: 'Shared links will show Lovable branding instead of your app, which looks like a demo rather than a real product.',
|
|
88
|
+
location: at(lovable),
|
|
89
|
+
fixPrompt: `In ${where(at(lovable))} my app still has Lovable's default meta tags (description, og:image, twitter tags). Replace them with my own app name, description and a 1200×630 preview image.`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const viteFavicon = ctx.find(/href=["']\/vite\.svg["']/, appCode, 1)[0];
|
|
93
|
+
if (viteFavicon) {
|
|
94
|
+
out.findings.push({
|
|
95
|
+
id: 'default-favicon',
|
|
96
|
+
severity: 'warning',
|
|
97
|
+
title: 'Your site icon is still the Vite logo',
|
|
98
|
+
why: "The little icon in the browser tab and bookmarks is the template's, not yours.",
|
|
99
|
+
location: at(viteFavicon),
|
|
100
|
+
fixPrompt: 'My app still uses the default vite.svg favicon. Help me add my own favicon (and an apple-touch-icon) and update index.html to use them.',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Description & social preview
|
|
104
|
+
const hasDescription = ctx.find(/<meta[^>]+name=["']description["']|\bdescription\s*:\s*["'`][^"'`]{10,}|generateMetadata/i, htmlOrLayout, 1).length > 0 ||
|
|
105
|
+
ctx.find(/<meta[^>]+name=["']description["']|\bdescription\s*:\s*["'`][^"'`]{10,}/i, appCode, 1).length > 0;
|
|
106
|
+
if (!hasDescription) {
|
|
107
|
+
out.findings.push({
|
|
108
|
+
id: 'no-description',
|
|
109
|
+
severity: 'warning',
|
|
110
|
+
title: 'No page description',
|
|
111
|
+
why: 'Google shows the description under your link in search results. Without one it picks random text from the page.',
|
|
112
|
+
fixPrompt: "Add a meta description to my app (one or two sentences on what it does and who it's for) in the main layout / index.html, and per-page descriptions for the main pages.",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const hasOgImage = ctx.hasPath(/(^|\/)(opengraph-image|twitter-image)\.(png|jpe?g|gif|tsx?|jsx?)$/) ||
|
|
116
|
+
ctx.find(/og:image|twitter:image|openGraph\s*:\s*\{[\s\S]{0,600}?images/i, appCode, 1).length > 0;
|
|
117
|
+
if (hasOgImage && !lovable)
|
|
118
|
+
out.passed.push('Shared links show a preview image');
|
|
119
|
+
else if (!hasOgImage) {
|
|
120
|
+
out.findings.push({
|
|
121
|
+
id: 'no-social-preview',
|
|
122
|
+
severity: 'warning',
|
|
123
|
+
title: 'No preview image when your link is shared',
|
|
124
|
+
why: 'When someone shares your link on WhatsApp, X or LinkedIn, it shows an empty card instead of an image and title, so fewer people click.',
|
|
125
|
+
fixPrompt: 'Add Open Graph and Twitter card tags to my app (title, description, and a 1200×630 preview image) so shared links show a nice preview card. Tell me how to test it with a link-preview checker.',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// Hard-coded localhost URLs
|
|
129
|
+
const localhost = ctx
|
|
130
|
+
.find(/https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?/, (f) => appCode(f) && !CONFIG_OR_SCRIPT.test(f.path) && !ctx.isMobileFile(f.path))
|
|
131
|
+
.filter((m) => {
|
|
132
|
+
const line = lineTextAt(m.file.content, m.index);
|
|
133
|
+
return !/process\.env|import\.meta\.env|Deno\.env|\?\?|\|\||NODE_ENV|console\.|isDev|development/i.test(line);
|
|
134
|
+
});
|
|
135
|
+
if (localhost.length) {
|
|
136
|
+
const m = localhost[0];
|
|
137
|
+
out.findings.push({
|
|
138
|
+
id: 'hardcoded-localhost',
|
|
139
|
+
severity: 'warning',
|
|
140
|
+
title: `Your app calls localhost${localhost.length > 1 ? ` in ${localhost.length} places` : ''}`,
|
|
141
|
+
why: '"localhost" means "this computer". It works while you develop, but for real users it points at their own device, so the feature breaks.',
|
|
142
|
+
location: at(m),
|
|
143
|
+
fixPrompt: `My code has hard-coded localhost URLs (first one: ${where(at(m))}). Replace them with relative URLs (like "/api/...") or an environment variable for the base URL, ` +
|
|
144
|
+
'so the app works both on my computer and when deployed. List every place you changed.',
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// Nice-to-haves
|
|
148
|
+
const nextApp = ctx.hasPath(/(^|\/)app\/(?:.*\/)?page\.(?:t|j)sx?$/);
|
|
149
|
+
const has404 = nextApp
|
|
150
|
+
? ctx.hasPath(/(^|\/)app\/(?:.*\/)?not-found\.(?:t|j)sx?$/)
|
|
151
|
+
: ctx.hasPath(/(^|\/)(404|not-?found|\+error)\.(?:[tj]sx?|vue|svelte|html|astro)$/i) ||
|
|
152
|
+
ctx.find(/path\s*[:=]\s*\{?\s*["']\*["']/, appCode, 1).length > 0;
|
|
153
|
+
if (has404)
|
|
154
|
+
out.passed.push('Has a "page not found" screen');
|
|
155
|
+
else {
|
|
153
156
|
out.manual.push({
|
|
154
|
-
id: '
|
|
155
|
-
title: '
|
|
156
|
-
how: '
|
|
157
|
+
id: 'not-found-page',
|
|
158
|
+
title: 'Add a friendly "page not found" screen',
|
|
159
|
+
how: 'Visit a made-up URL on your live site. It should show your own 404 page with a link back home, not a blank or generic error page.',
|
|
157
160
|
});
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
}
|
|
162
|
+
const hasRobots = ctx.hasPath(/(^|\/)(public\/|static\/)?robots\.txt$|(^|\/)app\/robots\.(t|j)sx?$/);
|
|
163
|
+
const hasSitemap = ctx.hasPath(/(^|\/)(public\/|static\/)?sitemap.*\.xml$|(^|\/)app\/sitemap\.(t|j)sx?$/) || ctx.uses('next-sitemap');
|
|
164
|
+
if (hasRobots && hasSitemap)
|
|
165
|
+
out.passed.push('Has robots.txt and a sitemap for Google');
|
|
166
|
+
else {
|
|
167
|
+
out.manual.push({
|
|
168
|
+
id: 'robots-sitemap',
|
|
169
|
+
title: `Add ${!hasRobots && !hasSitemap ? 'robots.txt and a sitemap' : !hasRobots ? 'robots.txt' : 'a sitemap'} so Google can find your pages`,
|
|
170
|
+
how: 'Then add your site to Google Search Console and submit the sitemap.',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
out.manual.push({
|
|
174
|
+
id: 'phone-test',
|
|
175
|
+
title: 'Open your live site on a real phone',
|
|
176
|
+
how: 'Most visitors will be on mobile. Check sign-up, the main feature and checkout on a phone screen, with slow mobile data.',
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const CLERK_PRODUCTION = {
|
|
180
|
+
id: 'clerk-production-instance',
|
|
181
|
+
title: 'Switch Clerk to a production instance before launch',
|
|
182
|
+
how: "A Clerk development instance is for testing: its sign-in screens show a \"Development mode\" badge and social sign-in uses Clerk's shared Google and GitHub credentials. In the Clerk Dashboard, create the production instance, add your domain's DNS records, set your own OAuth credentials, and use the pk_live_ and sk_live_ keys in your host's environment variables.",
|
|
160
183
|
};
|
|
184
|
+
/** ios.bundleIdentifier / android.package (Expo config) or package / applicationId (native) set to a template value. */
|
|
185
|
+
const PLACEHOLDER_APP_ID = /(?:bundleIdentifier|package|applicationId)["']?\s*[:=]\s*["'](com\.(?:anonymous|example|yourcompany|mycompany|test)\.[\w.-]+)["']/;
|
|
186
|
+
/** Addresses that only work on the developer's machine or network (10.0.2.2 is the Android emulator's name for it). */
|
|
187
|
+
const DEV_ADDRESS = /https?:\/\/(?:localhost|127\.0\.0\.1|10\.0\.2\.2|192\.168\.\d{1,3}\.\d{1,3}|172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3})(?::\d+)?/;
|
|
188
|
+
const isExpoConfig = (f) => /(^|\/)app\.(?:json|config\.[cm]?[jt]s)$/.test(f.path);
|
|
189
|
+
const isAndroidManifest = (f) => /(^|\/)AndroidManifest\.xml$/.test(f.path) && !/(^|\/)src\/debug\//.test(f.path);
|
|
190
|
+
const isInfoPlist = (f) => /(^|\/)Info\.plist$/.test(f.path);
|
|
191
|
+
function mobileImpressions(ctx, out) {
|
|
192
|
+
const mobile = (f) => ctx.isMobileFile(f.path);
|
|
193
|
+
const appId = ctx.find(PLACEHOLDER_APP_ID, (f) => mobile(f) && (isExpoConfig(f) || isAndroidManifest(f)), 1)[0];
|
|
194
|
+
if (appId) {
|
|
195
|
+
const id = appId.match[1];
|
|
196
|
+
out.findings.push({
|
|
197
|
+
id: 'mobile-placeholder-app-id',
|
|
198
|
+
severity: 'warning',
|
|
199
|
+
title: `Your app ID is still a placeholder (${id})`,
|
|
200
|
+
why: 'The App Store and Google Play identify your app by this ID, and once you publish it can never change. Google Play refuses com.example IDs, and a placeholder looks unfinished everywhere it shows.',
|
|
201
|
+
location: at(appId),
|
|
202
|
+
fixPrompt: `My app's ID is still the placeholder "${id}" (${where(at(appId))}). Before my first store upload, change ios.bundleIdentifier and android.package in my Expo config ` +
|
|
203
|
+
'(or the native iOS and Android projects) to a reverse domain I own, like com.mycompany.appname. ' +
|
|
204
|
+
'Then tell me everything else that must match the new ID: EAS credentials, Firebase or Google service files, deep links and OAuth redirect URIs.',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const cleartext = ctx.find(/usesCleartextTraffic["']?\s*[:=]\s*["']?true/, (f) => mobile(f) && (isExpoConfig(f) || isAndroidManifest(f)), 1)[0];
|
|
208
|
+
if (cleartext) {
|
|
209
|
+
out.findings.push({
|
|
210
|
+
id: 'android-cleartext-traffic',
|
|
211
|
+
severity: 'warning',
|
|
212
|
+
title: 'Your Android app allows unencrypted HTTP connections',
|
|
213
|
+
why: 'With cleartext traffic allowed, anyone on the same Wi-Fi can read or change what the app sends and receives, logins included. Android blocks it by default for that reason.',
|
|
214
|
+
location: at(cleartext),
|
|
215
|
+
fixPrompt: `In ${where(at(cleartext))} my Android app allows cleartext (http://) traffic. Please turn usesCleartextTraffic off and make every URL the app calls use https. ` +
|
|
216
|
+
'If a development server truly needs http, allow it only in debug builds (the debug AndroidManifest, or a network security config for that one host).',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const ats = ctx.find(/NSAllowsArbitraryLoads["']?\s*(?::\s*true|<\/key>\s*<true\s*\/>)/, (f) => mobile(f) && (isExpoConfig(f) || isInfoPlist(f)), 1)[0];
|
|
220
|
+
if (ats) {
|
|
221
|
+
out.findings.push({
|
|
222
|
+
id: 'ios-arbitrary-loads',
|
|
223
|
+
severity: 'warning',
|
|
224
|
+
title: 'Your iOS app turns off HTTPS protection (NSAllowsArbitraryLoads)',
|
|
225
|
+
why: "App Transport Security makes iOS refuse unencrypted connections. Turning it off lets anyone on the same network read or change the app's traffic, and Apple asks you to justify it during review.",
|
|
226
|
+
location: at(ats),
|
|
227
|
+
fixPrompt: `In ${where(at(ats))} my iOS app sets NSAllowsArbitraryLoads to true. Please remove it and make every URL the app calls use https. ` +
|
|
228
|
+
'If one host truly needs an exception, add an NSExceptionDomains entry for just that host instead.',
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const devAddress = ctx
|
|
232
|
+
.find(DEV_ADDRESS, (f) => mobile(f) && appCode(f) && !CONFIG_OR_SCRIPT.test(f.path))
|
|
233
|
+
.filter((m) => {
|
|
234
|
+
const line = lineTextAt(m.file.content, m.index);
|
|
235
|
+
return !/process\.env|__DEV__|\?\?|\|\||NODE_ENV|console\.|isDev|development/i.test(line);
|
|
236
|
+
});
|
|
237
|
+
if (devAddress.length) {
|
|
238
|
+
const m = devAddress[0];
|
|
239
|
+
out.findings.push({
|
|
240
|
+
id: 'hardcoded-localhost',
|
|
241
|
+
severity: 'warning',
|
|
242
|
+
title: `Your app calls a development address (${m.match[0]})${devAddress.length > 1 ? ` in ${devAddress.length} places` : ''}`,
|
|
243
|
+
why: "That address only exists on your computer or your Wi-Fi (10.0.2.2 is the Android emulator's name for your computer). On a real user's phone it goes nowhere, so the feature breaks.",
|
|
244
|
+
location: at(m),
|
|
245
|
+
fixPrompt: `My app has hard-coded development URLs (first one: ${where(at(m))}). Replace them with one config value, like an EXPO_PUBLIC_API_URL environment variable, ` +
|
|
246
|
+
'that points at my real https server in release builds and at my computer only during development. List every place you changed.',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
out.manual.push({
|
|
250
|
+
id: 'store-listing',
|
|
251
|
+
title: 'Prepare the store listing',
|
|
252
|
+
how: 'Your own app icon and splash screen (not the template ones), screenshots for the required screen sizes, a short description and a support URL. Both stores check these before approving the app.',
|
|
253
|
+
}, {
|
|
254
|
+
id: 'store-privacy-labels',
|
|
255
|
+
title: "Fill in Apple's App Privacy and Google Play's Data safety forms",
|
|
256
|
+
how: 'List everything the app and its SDKs collect (analytics, crash reports, sign-in, ads). Answers that do not match what the app does are a common reason for rejection.',
|
|
257
|
+
});
|
|
258
|
+
if (detectAuth(ctx)) {
|
|
259
|
+
out.manual.push({
|
|
260
|
+
id: 'store-review-account',
|
|
261
|
+
title: 'Give the app reviewers a test account',
|
|
262
|
+
how: 'Apple and Google reviewers have to sign in. Put a working demo login (and the steps to reach any paid features) in the review notes, or the app gets rejected.',
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
out.manual.push({
|
|
266
|
+
id: 'device-test',
|
|
267
|
+
title: 'Test a release build on a real phone',
|
|
268
|
+
how: 'Install a release build through TestFlight or a Google Play internal test, not Expo Go or a simulator. Try sign-up, the main feature, purchases, push notifications and links that open the app, on slow mobile data.',
|
|
269
|
+
});
|
|
270
|
+
}
|
package/dist/src/checks/legal.js
CHANGED
|
@@ -2,14 +2,20 @@ import { detectAuth, detectCookieAnalytics, detectDatabase, detectEmailProviders
|
|
|
2
2
|
import { isCodeFile } from '../project.js';
|
|
3
3
|
import { appCode, emptyOutput, notApplicable } from './common.js';
|
|
4
4
|
const POLICY_SERVICES = /iubenda\.com|termly\.io|termsfeed\.com|getterms\.io|privacypolicies\.com|termageddon\.com/;
|
|
5
|
-
/** Is there a page (file or link) for one of these words? */
|
|
6
|
-
function hasPage(ctx, words) {
|
|
5
|
+
/** Is there a page (file or link) for one of these words? fullUrls: also count https://site/<word> links. */
|
|
6
|
+
function hasPage(ctx, words, fullUrls = false) {
|
|
7
7
|
const alt = words.join('|');
|
|
8
8
|
const pathRe = new RegExp(`(^|/|-|_)(${alt})([/._-]|$)`, 'i');
|
|
9
9
|
if (ctx.paths.some((p) => pathRe.test(p) && (isCodeFile(p) || /\.(md|mdx|html|txt|pdf)$/i.test(p))))
|
|
10
10
|
return true;
|
|
11
11
|
const linkRe = new RegExp(`["'\`(]/(?:[\\w-]+/)*(?:${alt})[\\w-]*\\b`, 'i');
|
|
12
|
-
|
|
12
|
+
if (ctx.find(linkRe, appCode, 1).length > 0)
|
|
13
|
+
return true;
|
|
14
|
+
if (!fullUrls)
|
|
15
|
+
return false;
|
|
16
|
+
// Mobile apps (and many sites) link to a policy hosted elsewhere: https://myapp.com/privacy
|
|
17
|
+
const urlRe = new RegExp(`https?://[^\\s"'\`]+/(?:[\\w-]+/)*(?:${alt})[\\w-]*\\b`, 'i');
|
|
18
|
+
return ctx.find(urlRe, appCode, 1).length > 0;
|
|
13
19
|
}
|
|
14
20
|
export const legalCheck = {
|
|
15
21
|
id: 'legal',
|
|
@@ -17,9 +23,11 @@ export const legalCheck = {
|
|
|
17
23
|
weight: 1,
|
|
18
24
|
ids: ['no-privacy-policy', 'no-terms', 'no-refund-policy', 'no-contact', 'no-account-deletion', 'cookie-consent'],
|
|
19
25
|
run(ctx) {
|
|
20
|
-
if (!ctx.isWebApp)
|
|
26
|
+
if (!ctx.isWebApp && !ctx.isMobileApp)
|
|
21
27
|
return notApplicable('Not a web app');
|
|
22
28
|
const out = emptyOutput();
|
|
29
|
+
// The App Store asks every app for a privacy policy link, whatever it collects.
|
|
30
|
+
const storeApp = ctx.isMobileApp;
|
|
23
31
|
const auth = detectAuth(ctx);
|
|
24
32
|
const payments = detectPayments(ctx);
|
|
25
33
|
const collectsData = !!auth ||
|
|
@@ -28,8 +36,8 @@ export const legalCheck = {
|
|
|
28
36
|
detectEmailProviders(ctx).length > 0 ||
|
|
29
37
|
detectCookieAnalytics(ctx);
|
|
30
38
|
const policyService = ctx.find(POLICY_SERVICES, appCode, 1).length > 0;
|
|
31
|
-
const hasPrivacy = policyService || hasPage(ctx, ['privacy', 'privacy-policy', 'privacypolicy', 'datenschutz']);
|
|
32
|
-
const hasTerms = policyService || hasPage(ctx, ['terms', 'tos', 'terms-of-service', 'terms-and-conditions', 'terms-of-use']);
|
|
39
|
+
const hasPrivacy = policyService || hasPage(ctx, ['privacy', 'privacy-policy', 'privacypolicy', 'datenschutz'], true);
|
|
40
|
+
const hasTerms = policyService || hasPage(ctx, ['terms', 'tos', 'terms-of-service', 'terms-and-conditions', 'terms-of-use'], true);
|
|
33
41
|
const hasRefund = hasPage(ctx, [
|
|
34
42
|
'refund',
|
|
35
43
|
'refunds',
|
|
@@ -39,18 +47,24 @@ export const legalCheck = {
|
|
|
39
47
|
'returns',
|
|
40
48
|
]);
|
|
41
49
|
const hasContact = hasPage(ctx, ['contact', 'contact-us']) || ctx.find(/mailto:/, appCode, 1).length > 0;
|
|
42
|
-
if (collectsData) {
|
|
50
|
+
if (collectsData || storeApp) {
|
|
43
51
|
if (hasPrivacy)
|
|
44
52
|
out.passed.push('Has a privacy policy');
|
|
45
53
|
else {
|
|
46
54
|
out.findings.push({
|
|
47
55
|
id: 'no-privacy-policy',
|
|
48
56
|
severity: 'warning',
|
|
49
|
-
title: 'No privacy policy page',
|
|
50
|
-
why:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
title: storeApp && !ctx.isWebApp ? 'No privacy policy link in the app' : 'No privacy policy page',
|
|
58
|
+
why: storeApp
|
|
59
|
+
? "The App Store requires a privacy policy link for every app, and Google Play asks for one when an app handles personal data. Privacy laws like GDPR and India's DPDP Act expect one too."
|
|
60
|
+
: "Your app collects personal data (accounts, emails, payments or analytics). Privacy laws like GDPR and India's DPDP Act expect a privacy policy, and Google sign-in, Stripe and app stores ask for one.",
|
|
61
|
+
fixPrompt: storeApp && !ctx.isWebApp
|
|
62
|
+
? 'Write a clear, plain-English privacy policy for my mobile app and help me publish it at a public URL (for example a page on my website). Base it on what the code actually does: ' +
|
|
63
|
+
'what personal data is collected, which SDKs and services receive it (look at my dependencies: auth, database, analytics, crash reporting, payments), how long it is kept, and how users can ask for deletion. ' +
|
|
64
|
+
"Link it from the app's settings and sign-up screens, and remind me to paste the URL into App Store Connect and Google Play Console. Add a note that I should have it reviewed, since you're not a lawyer."
|
|
65
|
+
: 'Create a /privacy page for my app with a clear, plain-English privacy policy. Base it on what the code actually does: list what personal data is collected, ' +
|
|
66
|
+
'which third-party services receive it (look at my dependencies, e.g. auth, database, email, analytics, payments), how long it is kept, and how users can ask for deletion. ' +
|
|
67
|
+
"Link it from the footer and the sign-up form. Add a note that I should have it reviewed, since you're not a lawyer.",
|
|
54
68
|
});
|
|
55
69
|
}
|
|
56
70
|
}
|
|
@@ -114,7 +128,7 @@ export const legalCheck = {
|
|
|
114
128
|
how: 'Your analytics sets cookies. In the EU/UK you need consent before loading it — or switch to a cookieless tool like Plausible or Vercel Analytics.',
|
|
115
129
|
});
|
|
116
130
|
}
|
|
117
|
-
if (!collectsData && !payments && !auth) {
|
|
131
|
+
if (!collectsData && !payments && !auth && !storeApp) {
|
|
118
132
|
out.passed.push("Your app doesn't seem to collect personal data");
|
|
119
133
|
}
|
|
120
134
|
return out;
|
|
@@ -25,16 +25,25 @@ const TRACKERS = [
|
|
|
25
25
|
['@vercel/otel', 'OpenTelemetry'],
|
|
26
26
|
['@opentelemetry/sdk-node', 'OpenTelemetry'],
|
|
27
27
|
['elastic-apm-node', 'Elastic APM'],
|
|
28
|
+
// Mobile (React Native / Expo)
|
|
29
|
+
['sentry-expo', 'Sentry'],
|
|
30
|
+
['@react-native-firebase/crashlytics', 'Firebase Crashlytics'],
|
|
31
|
+
['instabug-reactnative', 'Instabug'],
|
|
32
|
+
['@datadog/mobile-react-native', 'Datadog'],
|
|
33
|
+
['@embrace-io/', 'Embrace'],
|
|
34
|
+
['posthog-react-native', 'PostHog'],
|
|
28
35
|
];
|
|
29
36
|
export const monitoringCheck = {
|
|
30
37
|
id: 'monitoring',
|
|
31
38
|
name: 'Errors & monitoring',
|
|
32
39
|
weight: 1,
|
|
33
|
-
ids: ['no-error-tracking', 'no-error-boundary', 'uptime-monitor', 'know-your-logs'],
|
|
40
|
+
ids: ['no-error-tracking', 'no-error-boundary', 'uptime-monitor', 'know-your-logs', 'store-crash-reports'],
|
|
34
41
|
run(ctx) {
|
|
35
|
-
if (!ctx.isWebApp)
|
|
42
|
+
if (!ctx.isWebApp && !ctx.isMobileApp)
|
|
36
43
|
return notApplicable('Not a web app');
|
|
37
44
|
const out = emptyOutput();
|
|
45
|
+
// An app with no website: crash reports and store dashboards matter, uptime pages don't.
|
|
46
|
+
const mobileOnly = ctx.isMobileApp && !ctx.isWebApp;
|
|
38
47
|
const tracker = TRACKERS.find(([pkg]) => ctx.uses(pkg))?.[1];
|
|
39
48
|
if (tracker) {
|
|
40
49
|
out.passed.push(`Error tracking is set up (${tracker})`);
|
|
@@ -43,10 +52,17 @@ export const monitoringCheck = {
|
|
|
43
52
|
out.findings.push({
|
|
44
53
|
id: 'no-error-tracking',
|
|
45
54
|
severity: 'warning',
|
|
46
|
-
title: 'No error tracking',
|
|
47
|
-
why:
|
|
48
|
-
|
|
49
|
-
"
|
|
55
|
+
title: mobileOnly ? 'No crash reporting' : 'No error tracking',
|
|
56
|
+
why: (mobileOnly
|
|
57
|
+
? "When your app crashes on someone's phone, you won't know unless they leave a one-star review. Most people just uninstall. "
|
|
58
|
+
: "When your app breaks for a user, you won't know unless they bother to tell you. Most people don't — they just leave. ") +
|
|
59
|
+
'We looked for an error tracker (Sentry, PostHog, Bugsnag, Rollbar, Datadog and others) in your dependencies and found none.',
|
|
60
|
+
fixPrompt: mobileOnly
|
|
61
|
+
? 'Add crash reporting to my React Native / Expo app with Sentry (@sentry/react-native; for Expo, add its config plugin in app.json). ' +
|
|
62
|
+
'Upload source maps during the build (EAS Build or the native build) so stack traces point at my code, keep the DSN in config, ' +
|
|
63
|
+
"make sure it doesn't send passwords or personal data, and add a temporary test crash I can trigger once to confirm reports arrive. Then remove the test."
|
|
64
|
+
: 'Add error tracking to my app with Sentry (it has a free plan). Set it up for both the frontend and the backend / API routes, keep the DSN in an environment variable, ' +
|
|
65
|
+
"make sure it doesn't send passwords or personal data, and add a temporary test error I can trigger once to confirm errors show up in Sentry. Then remove the test.",
|
|
50
66
|
});
|
|
51
67
|
}
|
|
52
68
|
// Friendly crash screen instead of a blank white page
|
|
@@ -72,13 +88,26 @@ export const monitoringCheck = {
|
|
|
72
88
|
id: 'no-error-boundary',
|
|
73
89
|
severity: 'warning',
|
|
74
90
|
title: 'No friendly error screen',
|
|
75
|
-
why:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
why: mobileOnly
|
|
92
|
+
? 'If one screen of a React Native app crashes, the whole app closes or shows a blank screen. An error screen shows "Something went wrong — try again" instead.'
|
|
93
|
+
: 'If one part of a React app crashes, the whole page goes blank white. An error screen shows "Something went wrong — try again" and keeps the rest of the app usable.',
|
|
94
|
+
fixPrompt: mobileOnly
|
|
95
|
+
? 'Add an error screen to my React Native app: with Expo Router, export an ErrorBoundary from app/_layout.tsx (it receives the error and a retry function); otherwise wrap the root component with react-error-boundary. Show a friendly "Something went wrong" message with a "Try again" button, and send the error to my crash reporter if I have one.'
|
|
96
|
+
: nextAppRouter || ctx.uses('next')
|
|
97
|
+
? 'Add error pages to my Next.js app: an app/error.tsx with a friendly "Something went wrong" message and a "Try again" button that calls reset(), plus an app/global-error.tsx for crashes in the root layout. Send the error to my error tracker if I have one.'
|
|
98
|
+
: 'Add a React error boundary to my app (the react-error-boundary package is fine) around the main routes, showing a friendly "Something went wrong" message with a "Try again" button instead of a blank page. Send the error to my error tracker if I have one.',
|
|
79
99
|
});
|
|
80
100
|
}
|
|
81
101
|
}
|
|
102
|
+
if (ctx.isMobileApp) {
|
|
103
|
+
out.manual.push({
|
|
104
|
+
id: 'store-crash-reports',
|
|
105
|
+
title: 'Know where the app stores show your crashes',
|
|
106
|
+
how: 'App Store Connect (TestFlight → Crashes, and Xcode Organizer) and Google Play Console → Android vitals list crashes and freezes. Look there before every release, not only after bad reviews.',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (mobileOnly)
|
|
110
|
+
return out;
|
|
82
111
|
out.manual.push({
|
|
83
112
|
id: 'uptime-monitor',
|
|
84
113
|
title: 'Set up a free uptime monitor',
|