shelfready 0.1.0 → 0.1.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/README.md CHANGED
@@ -8,11 +8,8 @@ Website and the full checklist: **[shelfready.dev](https://shelfready.dev)**
8
8
 
9
9
  ## Quick start
10
10
 
11
- Requires Node 20 or later.
12
-
13
11
  ```sh
14
- git clone https://github.com/halfbatch-studio/shelfready
15
- cd shelfready/cli && npm install && npm run build && npm link # installs the `shelf` command
12
+ brew install halfbatch-studio/tap/shelfready # or: npm install -g shelfready (Node 20+)
16
13
 
17
14
  cd ~/path/to/your-app
18
15
  shelf init --country DE --email support@example.com --brand "Your Studio" --voice I --base-url https://example.com/app/
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env node
2
+ import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { createRequire } from "node:module";
5
+ import { Command, Option } from "commander";
6
+ import { appPrivacy, check, checklist, checklistMarkdown, checkOnline, CURRENT_VERSION, setTicks, factsFromScan, factsToYAML, legalView, migrateFile, needsImpressum, readFacts, renderPages, scan } from "./index.js";
7
+ const program = new Command()
8
+ .name("shelf")
9
+ .description("Get an iOS app ready for the App Store shelf: legal pages, privacy truth, preflight.")
10
+ .version(createRequire(import.meta.url)("../package.json").version);
11
+ const list = (items) => (items.length ? items.join(", ") : "—");
12
+ const factsPath = (repo) => join(resolve(repo), "shelfready.yaml");
13
+ function requireLoaded(repo) {
14
+ const path = factsPath(repo);
15
+ if (!existsSync(path)) {
16
+ console.error(`No shelfready.yaml in ${resolve(repo)}. Run \`shelf init\` first.`);
17
+ process.exit(1);
18
+ }
19
+ try {
20
+ const loaded = readFacts(path);
21
+ if (loaded.fileVersion < CURRENT_VERSION) {
22
+ console.warn(`! shelfready.yaml is schema v${loaded.fileVersion}; using it as v${CURRENT_VERSION} in memory. Run \`shelf migrate\` to update the file.`);
23
+ }
24
+ return loaded;
25
+ }
26
+ catch (e) {
27
+ console.error(String(e instanceof Error ? e.message : e));
28
+ process.exit(1);
29
+ }
30
+ }
31
+ const requireFacts = (repo) => requireLoaded(repo).facts;
32
+ program
33
+ .command("scan")
34
+ .description("Read the repo: bundle IDs, purpose strings, privacy manifests, packages.")
35
+ .argument("[path]", "app repository", ".")
36
+ .option("--json", "print JSON")
37
+ .action((path, opts) => {
38
+ const r = scan(path);
39
+ if (opts.json)
40
+ return console.log(JSON.stringify(r, null, 2));
41
+ console.log(`Projects: ${list(r.xcodeProjects)}`);
42
+ console.log(`Bundle IDs: ${list(r.bundleIdentifiers)}`);
43
+ console.log(`Display names: ${list(r.displayNames)}`);
44
+ console.log(`Purpose strings: ${list(Object.keys(r.purposeStrings).sort())}`);
45
+ console.log(`Packages: ${list(r.packages.map((p) => `${p.identity} ${p.version ?? ""}`.trim()))}`);
46
+ console.log(`Privacy manifests: ${r.privacyManifests.length}`);
47
+ for (const m of r.privacyManifests) {
48
+ console.log(` ${m.path}`);
49
+ console.log(` tracking: ${m.tracking} collected: ${list(m.collectedDataTypes.map((c) => c.type))}`);
50
+ console.log(` required-reason APIs: ${list(m.accessedAPIs.map((a) => `${a.category} ${a.reasons.join(",")}`))}`);
51
+ }
52
+ });
53
+ program
54
+ .command("init")
55
+ .description("Scan the repo and write shelfready.yaml for you to confirm.")
56
+ .argument("[path]", "app repository", ".")
57
+ .requiredOption("--country <code>", "publisher country, ISO code (e.g. DE)")
58
+ .requiredOption("--email <email>", "public contact email")
59
+ .option("--brand <name>", "brand or studio shown on pages")
60
+ .option("--publisher <name>", "legal name (required for traders)")
61
+ .option("--trader", "declare EU trader status (charging for the app or in-app purchases)")
62
+ .option("--phone <number>", "second contact channel for traders")
63
+ .addOption(new Option("--voice <voice>", "how pages speak: I (solo) or we (team)").choices(["I", "we"]).default("we"))
64
+ .option("--base-url <url>", "where the pages will live, e.g. https://example.com/myapp/")
65
+ .option("--force", "overwrite an existing shelfready.yaml")
66
+ .action((path, o) => {
67
+ const out = factsPath(path);
68
+ if (existsSync(out) && !o.force) {
69
+ console.error(`${out} exists. Use --force to overwrite.`);
70
+ process.exit(1);
71
+ }
72
+ if (o.trader && !o.publisher) {
73
+ console.error("Traders must give a legal name with --publisher.");
74
+ process.exit(1);
75
+ }
76
+ const facts = factsFromScan(scan(path), {
77
+ country: o.country,
78
+ email: o.email,
79
+ ...(o.brand ? { brand: o.brand } : {}),
80
+ ...(o.publisher ? { name: o.publisher } : {}),
81
+ trader: !!o.trader,
82
+ voice: o.voice,
83
+ });
84
+ if (o.baseUrl)
85
+ facts.pages.baseURL = o.baseUrl;
86
+ if (facts.publisher.trader && needsImpressum(facts)) {
87
+ Object.assign(facts.publisher, { phone: o.phone ?? "", contactURL: "", vatId: "", legalForm: "", representative: "", register: { court: "", number: "" } });
88
+ }
89
+ writeFileSync(out, factsToYAML(facts));
90
+ console.log(`Wrote ${out}`);
91
+ if (needsImpressum(facts))
92
+ console.log(`Country ${facts.publisher.country} needs an Impressum on the web and inside the app.`);
93
+ if (facts.publisher.trader)
94
+ console.log("Traders: add a business address under publisher.address (never a home address).");
95
+ if (facts.publisher.trader && needsImpressum(facts))
96
+ console.log("DE/AT traders: fill phone or contactURL, vatId, and for companies legalForm, representative and register. Then show LegalView in the app.");
97
+ console.log("Next: add privacyNotes and support.faq, then run `shelf pages`.");
98
+ });
99
+ program
100
+ .command("pages")
101
+ .description("Generate privacy policy, support page and Impressum (DE/AT) as Markdown; --swiftui adds LegalView.swift.")
102
+ .argument("[path]", "app repository", ".")
103
+ .option("--out <dir>", "output folder", "shelfready/pages")
104
+ .option("--swiftui <file>", "also write a SwiftUI LegalView to this file")
105
+ .addOption(new Option("--front-matter <kind>", "front matter for static site generators").choices(["none", "jekyll"]).default("jekyll"))
106
+ .action((path, o) => {
107
+ const facts = requireFacts(path);
108
+ const dir = resolve(path, o.out);
109
+ mkdirSync(dir, { recursive: true });
110
+ for (const page of renderPages(facts)) {
111
+ const permalink = facts.pages.baseURL ? new URL(page.path, facts.pages.baseURL.replace(/\/?$/, "/")).pathname : "";
112
+ const front = o.frontMatter === "jekyll"
113
+ ? `---\nlayout: default\ntitle: ${JSON.stringify(page.title)}\n${permalink ? `permalink: ${permalink}\n` : ""}---\n\n`
114
+ : "";
115
+ const banner = "<!-- Generated by ShelfReady (`shelf pages`) from shelfready.yaml. Edit that file, not this page. -->\n\n";
116
+ writeFileSync(join(dir, page.file), front + banner + page.markdown);
117
+ console.log(`Wrote ${join(o.out, page.file)}`);
118
+ }
119
+ if (o.swiftui) {
120
+ if (!facts.pages.baseURL)
121
+ console.warn("pages.baseURL is empty; the LegalView links will be relative and won't open.");
122
+ writeFileSync(resolve(path, o.swiftui), legalView(facts));
123
+ console.log(`Wrote ${o.swiftui}`);
124
+ }
125
+ });
126
+ program
127
+ .command("store")
128
+ .description("App Store Connect helpers. --privacy-json writes fastlane's app_privacy_details.json.")
129
+ .argument("[path]", "app repository", ".")
130
+ .option("--privacy-json [file]", "write App Privacy answers for fastlane", "fastlane/app_privacy_details.json")
131
+ .action((path, o) => {
132
+ const facts = requireFacts(path);
133
+ const file = resolve(path, typeof o.privacyJson === "string" ? o.privacyJson : "fastlane/app_privacy_details.json");
134
+ const { entries, unmapped } = appPrivacy(facts);
135
+ mkdirSync(resolve(file, ".."), { recursive: true });
136
+ writeFileSync(file, JSON.stringify(entries, null, 2) + "\n");
137
+ console.log(`Wrote ${file}`);
138
+ if (unmapped.length)
139
+ console.warn(`Answer by hand in App Store Connect: ${unmapped.join(", ")}`);
140
+ console.log("Upload with: fastlane run upload_app_privacy_details_to_app_store json_path:" + file);
141
+ console.log("URLs, age rating and submission: use `asc` (not wrapped yet).");
142
+ });
143
+ program
144
+ .command("check")
145
+ .description("Preflight: shelfready.yaml vs the repo, manifests, purpose strings, Impressum. --online also checks the live pages. --ci exits 1 on errors.")
146
+ .argument("[path]", "app repository", ".")
147
+ .option("--online", "check that the pages are live and show what shelfready.yaml says")
148
+ .option("--ci", "exit with code 1 when there are errors")
149
+ .option("--json", "print JSON")
150
+ .addOption(new Option("--format <format>", "output format").choices(["text", "json", "github"]).default("text"))
151
+ .action(async (path, o) => {
152
+ const { facts, fileVersion } = requireLoaded(path);
153
+ let findings = check(facts, scan(path), { fileVersion });
154
+ if (o.online) {
155
+ const online = await checkOnline(facts);
156
+ findings = [...findings.filter((f) => f.level !== "ok"), ...online];
157
+ if (!findings.some((f) => f.level !== "ok"))
158
+ findings.unshift({ level: "ok", rule: "all", message: "shelfready.yaml matches the repo." });
159
+ }
160
+ const format = o.json ? "json" : o.format;
161
+ if (format === "json")
162
+ console.log(JSON.stringify(findings, null, 2));
163
+ else if (format === "github") {
164
+ // GitHub Actions workflow commands: annotations on the run and the pull request.
165
+ const esc = (s) => s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
166
+ for (const f of findings) {
167
+ if (f.level === "ok")
168
+ console.log(`✓ ${f.rule}: ${f.message}`);
169
+ else
170
+ console.log(`::${f.level === "error" ? "error" : "warning"} file=shelfready.yaml,title=${esc(`ShelfReady ${f.rule}`).replace(/[,:]/g, " ")}::${esc(f.message)}`);
171
+ }
172
+ const summary = process.env.GITHUB_STEP_SUMMARY;
173
+ if (summary) {
174
+ const rows = findings.map((f) => `| ${f.level === "error" ? "✗" : f.level === "warn" ? "!" : "✓"} | \`${f.rule}\` | ${f.message.replace(/\|/g, "\\|")} |`);
175
+ appendFileSync(summary, ["### ShelfReady", "", "| | Rule | Finding |", "|---|---|---|", ...rows, ""].join("\n"));
176
+ }
177
+ }
178
+ else
179
+ for (const f of findings)
180
+ console.log(`${f.level === "error" ? "✗" : f.level === "warn" ? "!" : "✓"} ${f.rule}: ${f.message}`);
181
+ if (o.ci && findings.some((f) => f.level === "error"))
182
+ process.exit(1);
183
+ });
184
+ program
185
+ .command("checklist")
186
+ .description("Go-live checklist: automatic items from check, manual items you tick with --done.")
187
+ .argument("[path]", "app repository", ".")
188
+ .option("--online", "also verify that the pages are live")
189
+ .option("--done <ids>", "tick manual items, comma-separated (e.g. trademark,asc-urls)")
190
+ .option("--undo <ids>", "untick manual items")
191
+ .option("--markdown [file]", "print or write the checklist as Markdown")
192
+ .action(async (path, o) => {
193
+ const file = factsPath(path);
194
+ for (const [ids, done] of [[o.done, true], [o.undo, false]]) {
195
+ if (!ids)
196
+ continue;
197
+ try {
198
+ writeFileSync(file, setTicks(file, ids.split(",").map((s) => s.trim()).filter(Boolean), done));
199
+ }
200
+ catch (e) {
201
+ console.error(String(e instanceof Error ? e.message : e));
202
+ process.exit(1);
203
+ }
204
+ }
205
+ const { facts, fileVersion } = requireLoaded(path);
206
+ const s = scan(path);
207
+ const rows = checklist({ facts, scan: s, findings: check(facts, s, { fileVersion }), ...(o.online ? { online: await checkOnline(facts) } : {}) });
208
+ if (o.markdown) {
209
+ const md = checklistMarkdown(rows, facts.app.name);
210
+ if (typeof o.markdown === "string") {
211
+ writeFileSync(resolve(path, o.markdown), md);
212
+ console.log(`Wrote ${o.markdown}`);
213
+ }
214
+ else
215
+ console.log(md);
216
+ return;
217
+ }
218
+ const icon = { done: "✓", todo: "○", fail: "✗" };
219
+ for (const group of [...new Set(rows.map((r) => r.group))]) {
220
+ console.log(`\n${group}`);
221
+ for (const r of rows.filter((x) => x.group === group)) {
222
+ const id = r.automatic ? "" : ` [${r.id}]`;
223
+ console.log(` ${icon[r.status]} ${r.title}${r.detail ? ` (${r.detail})` : ""}${id}`);
224
+ if (r.how)
225
+ console.log(` ${r.how}`);
226
+ }
227
+ }
228
+ const done = rows.filter((r) => r.status === "done").length;
229
+ console.log(`\n${done} of ${rows.length} done.${rows.some((r) => !r.automatic && r.status !== "done") ? " Tick manual items with: shelf checklist --done <id>" : ""}`);
230
+ });
231
+ program
232
+ .command("migrate")
233
+ .description("Update shelfready.yaml to the current schema, keeping your comments and wording.")
234
+ .argument("[path]", "app repository", ".")
235
+ .option("--dry-run", "show what would change without writing")
236
+ .action((path, o) => {
237
+ const file = factsPath(path);
238
+ if (!existsSync(file)) {
239
+ console.error(`No shelfready.yaml in ${resolve(path)}.`);
240
+ process.exit(1);
241
+ }
242
+ let result;
243
+ try {
244
+ result = migrateFile(file);
245
+ }
246
+ catch (e) {
247
+ console.error(String(e instanceof Error ? e.message : e));
248
+ process.exit(1);
249
+ }
250
+ if (result.from === result.to)
251
+ return console.log(`shelfready.yaml is already schema v${result.to}.`);
252
+ console.log(`shelfready.yaml: v${result.from} → v${result.to}`);
253
+ for (const n of result.notes)
254
+ console.log(n);
255
+ if (o.dryRun)
256
+ return console.log("(dry run, nothing written)");
257
+ writeFileSync(file, result.text);
258
+ console.log(`Wrote ${file}. Review the new fields, then run \`shelf check\`.`);
259
+ });
260
+ for (const [name, what] of [
261
+ ["publish", "Publish pages to GitHub Pages or shelfready.dev."],
262
+ ["login", "Sign in to shelfready.dev (device flow)."],
263
+ ]) {
264
+ program
265
+ .command(name)
266
+ .description(`${what} (not built yet)`)
267
+ .action(() => {
268
+ console.log(`\`shelf ${name}\` isn't built yet. See docs/roadmap.md.`);
269
+ process.exit(2);
270
+ });
271
+ }
272
+ await program.parseAsync();
@@ -0,0 +1,20 @@
1
+ import type { Facts } from "./facts.js";
2
+ /**
3
+ * App Store Connect "App Privacy" answers in fastlane's `app_privacy_details.json` format,
4
+ * for `fastlane upload_app_privacy_details_to_app_store` (Apple ID login; no API key path exists).
5
+ * Category, purpose and protection IDs follow fastlane's Spaceship constants.
6
+ */
7
+ export interface AppPrivacyEntry {
8
+ category?: string;
9
+ purposes?: string[];
10
+ data_protections: string[];
11
+ }
12
+ /** Privacy manifest data types → App Store Connect categories. Unmapped types are reported, never guessed. */
13
+ export declare const CATEGORY: Record<string, string>;
14
+ export declare const PURPOSE: Record<string, string>;
15
+ export interface AppPrivacyResult {
16
+ entries: AppPrivacyEntry[];
17
+ /** Data types or purposes with no App Store Connect equivalent; answer these by hand. */
18
+ unmapped: string[];
19
+ }
20
+ export declare function appPrivacy(facts: Facts): AppPrivacyResult;
@@ -0,0 +1,73 @@
1
+ /** Privacy manifest data types → App Store Connect categories. Unmapped types are reported, never guessed. */
2
+ export const CATEGORY = {
3
+ NSPrivacyCollectedDataTypeName: "NAME",
4
+ NSPrivacyCollectedDataTypeEmailAddress: "EMAIL_ADDRESS",
5
+ NSPrivacyCollectedDataTypePhoneNumber: "PHONE_NUMBER",
6
+ NSPrivacyCollectedDataTypePhysicalAddress: "PHYSICAL_ADDRESS",
7
+ NSPrivacyCollectedDataTypeOtherUserContactInfo: "OTHER_CONTACT_INFO",
8
+ NSPrivacyCollectedDataTypeHealth: "HEALTH",
9
+ NSPrivacyCollectedDataTypeFitness: "FITNESS",
10
+ NSPrivacyCollectedDataTypePaymentInfo: "PAYMENT_INFORMATION",
11
+ NSPrivacyCollectedDataTypeCreditInfo: "CREDIT_AND_FRAUD",
12
+ NSPrivacyCollectedDataTypeOtherFinancialInfo: "OTHER_FINANCIAL_INFO",
13
+ NSPrivacyCollectedDataTypePreciseLocation: "PRECISE_LOCATION",
14
+ NSPrivacyCollectedDataTypeCoarseLocation: "COARSE_LOCATION",
15
+ NSPrivacyCollectedDataTypeSensitiveInfo: "SENSITIVE_INFO",
16
+ NSPrivacyCollectedDataTypeContacts: "CONTACTS",
17
+ NSPrivacyCollectedDataTypeEmailsOrTextMessages: "EMAILS_OR_TEXT_MESSAGES",
18
+ NSPrivacyCollectedDataTypePhotosorVideos: "PHOTOS_OR_VIDEOS",
19
+ NSPrivacyCollectedDataTypeAudioData: "AUDIO",
20
+ NSPrivacyCollectedDataTypeGameplayContent: "GAMEPLAY_CONTENT",
21
+ NSPrivacyCollectedDataTypeCustomerSupport: "CUSTOMER_SUPPORT",
22
+ NSPrivacyCollectedDataTypeOtherUserContent: "OTHER_USER_CONTENT",
23
+ NSPrivacyCollectedDataTypeBrowsingHistory: "BROWSING_HISTORY",
24
+ NSPrivacyCollectedDataTypeSearchHistory: "SEARCH_HISTORY",
25
+ NSPrivacyCollectedDataTypeUserID: "USER_ID",
26
+ NSPrivacyCollectedDataTypeDeviceID: "DEVICE_ID",
27
+ NSPrivacyCollectedDataTypePurchaseHistory: "PURCHASE_HISTORY",
28
+ NSPrivacyCollectedDataTypeProductInteraction: "PRODUCT_INTERACTION",
29
+ NSPrivacyCollectedDataTypeAdvertisingData: "ADVERTISING_DATA",
30
+ NSPrivacyCollectedDataTypeOtherUsageData: "OTHER_USAGE_DATA",
31
+ NSPrivacyCollectedDataTypeCrashData: "CRASH_DATA",
32
+ NSPrivacyCollectedDataTypePerformanceData: "PERFORMANCE_DATA",
33
+ NSPrivacyCollectedDataTypeOtherDiagnosticData: "OTHER_DIAGNOSTIC_DATA",
34
+ NSPrivacyCollectedDataTypeOtherDataTypes: "OTHER_DATA",
35
+ };
36
+ export const PURPOSE = {
37
+ NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising: "THIRD_PARTY_ADVERTISING",
38
+ NSPrivacyCollectedDataTypePurposeDeveloperAdvertising: "DEVELOPERS_ADVERTISING",
39
+ NSPrivacyCollectedDataTypePurposeAnalytics: "ANALYTICS",
40
+ NSPrivacyCollectedDataTypePurposeProductPersonalization: "PRODUCT_PERSONALIZATION",
41
+ NSPrivacyCollectedDataTypePurposeAppFunctionality: "APP_FUNCTIONALITY",
42
+ NSPrivacyCollectedDataTypePurposeOther: "OTHER_PURPOSES",
43
+ };
44
+ export function appPrivacy(facts) {
45
+ if (facts.data.collected.length === 0) {
46
+ return { entries: [{ data_protections: ["DATA_NOT_COLLECTED"] }], unmapped: [] };
47
+ }
48
+ const unmapped = new Set();
49
+ const byCategory = new Map();
50
+ for (const item of facts.data.collected) {
51
+ const category = CATEGORY[item.type];
52
+ if (!category) {
53
+ unmapped.add(item.type);
54
+ continue;
55
+ }
56
+ const entry = byCategory.get(category) ?? { purposes: new Set(), protections: new Set() };
57
+ for (const p of item.purposes) {
58
+ const purpose = PURPOSE[p];
59
+ if (purpose)
60
+ entry.purposes.add(purpose);
61
+ else
62
+ unmapped.add(p);
63
+ }
64
+ entry.protections.add(item.linked ? "DATA_LINKED_TO_YOU" : "DATA_NOT_LINKED_TO_YOU");
65
+ if (item.tracking)
66
+ entry.protections.add("DATA_USED_TO_TRACK_YOU");
67
+ byCategory.set(category, entry);
68
+ }
69
+ const entries = [...byCategory.entries()]
70
+ .sort(([a], [b]) => a.localeCompare(b))
71
+ .map(([category, e]) => ({ category, purposes: [...e.purposes].sort(), data_protections: [...e.protections].sort() }));
72
+ return { entries, unmapped: [...unmapped].sort() };
73
+ }
@@ -0,0 +1,15 @@
1
+ import { type Facts } from "./facts.js";
2
+ import type { ScanResult } from "./scan.js";
3
+ export type Level = "error" | "warn" | "ok";
4
+ export interface Finding {
5
+ level: Level;
6
+ rule: string;
7
+ message: string;
8
+ }
9
+ /**
10
+ * Local preflight. Compares shelfready.yaml with what the repo says today, so a new SDK or
11
+ * manifest change that the pages don't reflect fails the build (`shelf check --ci`).
12
+ */
13
+ export declare function check(facts: Facts, scan: ScanResult, opts?: {
14
+ fileVersion?: number;
15
+ }): Finding[];
@@ -0,0 +1,151 @@
1
+ import { readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { appPrivacy } from "./appPrivacy.js";
4
+ import { factsFromScan, isCompany, needsImpressum, pageURL } from "./facts.js";
5
+ import { CURRENT_VERSION } from "./migrate.js";
6
+ import { lookup, sdkCollects } from "./knowledge.js";
7
+ const KNOWN_TOP = new Set(["version", "app", "publisher", "data", "privacyNotes", "support", "pages", "checklist"]);
8
+ const KNOWN_PUBLISHER = new Set([
9
+ "brand", "voice", "name", "country", "email", "trader", "address",
10
+ "phone", "contactURL", "vatId", "legalForm", "representative", "register",
11
+ ]);
12
+ /**
13
+ * Local preflight. Compares shelfready.yaml with what the repo says today, so a new SDK or
14
+ * manifest change that the pages don't reflect fails the build (`shelf check --ci`).
15
+ */
16
+ export function check(facts, scan, opts = {}) {
17
+ const findings = [];
18
+ const add = (level, rule, message) => findings.push({ level, rule, message });
19
+ // The config file itself
20
+ const fileVersion = opts.fileVersion ?? facts.version;
21
+ if (fileVersion < CURRENT_VERSION)
22
+ add("warn", "config.outdated", `shelfready.yaml is schema v${fileVersion}; this shelf uses v${CURRENT_VERSION}. Run \`shelf migrate\` and review the new fields.`);
23
+ for (const k of Object.keys(facts))
24
+ if (!KNOWN_TOP.has(k))
25
+ add("warn", "config.unknownKey", `Unknown key "${k}" in shelfready.yaml (typo, or from a newer shelf?).`);
26
+ for (const k of Object.keys(facts.publisher ?? {}))
27
+ if (!KNOWN_PUBLISHER.has(k))
28
+ add("warn", "config.unknownKey", `Unknown key "publisher.${k}" in shelfready.yaml.`);
29
+ if (facts.publisher.voice !== "I" && facts.publisher.voice !== "we")
30
+ add("error", "config.voice", `publisher.voice must be "I" or "we", not "${facts.publisher.voice}".`);
31
+ const now = factsFromScan(scan, facts.publisher);
32
+ const p = facts.publisher;
33
+ // Drift between the facts and the repo
34
+ const key = (x) => JSON.stringify(x);
35
+ const missing = now.data.collected.filter((c) => !facts.data.collected.some((f) => key(f) === key(c)));
36
+ const extra = facts.data.collected.filter((f) => !now.data.collected.some((c) => key(c) === key(f)));
37
+ if (missing.length) {
38
+ const short = (type) => type.replace("NSPrivacyCollectedDataType", "");
39
+ const origin = (type) => {
40
+ const sdks = now.data.packages.map((p) => lookup(p)).filter((e) => e && sdkCollects(e).some((c) => c.type === type)).map((e) => e.name);
41
+ return sdks.length ? `${short(type)} (${sdks.join(", ")})` : short(type);
42
+ };
43
+ add("error", "drift.collected", `The app or its SDKs collect data not in shelfready.yaml: ${[...new Set(missing.map((m) => m.type))].map(origin).join(", ")}. Add it to data.collected in shelfready.yaml.`);
44
+ }
45
+ if (extra.length)
46
+ add("warn", "drift.collected", `shelfready.yaml lists data no manifest declares: ${extra.map((m) => m.type).join(", ")}`);
47
+ if (now.data.tracking !== facts.data.tracking)
48
+ add("error", "drift.tracking", `Manifests say tracking=${now.data.tracking}, shelfready.yaml says ${facts.data.tracking}`);
49
+ const newPackages = now.data.packages.filter((x) => !facts.data.packages.includes(x));
50
+ if (newPackages.length)
51
+ add("error", "drift.packages", `New packages since the pages were written: ${newPackages.join(", ")}. Check what they collect, then update shelfready.yaml.`);
52
+ // Third-party SDKs against the knowledge base
53
+ for (const pkg of now.data.packages) {
54
+ const entry = lookup(pkg);
55
+ if (!entry) {
56
+ add("warn", "sdk.unknown", `${pkg}: not in ShelfReady's knowledge base. Check its PrivacyInfo.xcprivacy or the vendor's docs and add what it collects to data.collected.`);
57
+ }
58
+ else if (sdkCollects(entry).length === 0 && entry.notes) {
59
+ add("warn", "sdk.yourData", `${entry.name}: ${entry.notes}`);
60
+ }
61
+ }
62
+ if (key(now.app.bundleIdentifiers) !== key(facts.app.bundleIdentifiers))
63
+ add("warn", "drift.bundleIDs", "Bundle identifiers changed since shelfready.yaml was written.");
64
+ // Repo hygiene
65
+ if (scan.privacyManifests.length === 0)
66
+ add("error", "manifest.missing", "No PrivacyInfo.xcprivacy found. Apple requires a privacy manifest.");
67
+ for (const [k, v] of Object.entries(scan.purposeStrings)) {
68
+ if (!v.trim() || /todo|lorem|placeholder/i.test(v))
69
+ add("error", "purpose.placeholder", `${k} looks like a placeholder: "${v}"`);
70
+ }
71
+ for (const m of scan.privacyManifests) {
72
+ for (const api of m.accessedAPIs)
73
+ if (api.reasons.length === 0)
74
+ add("error", "manifest.reasons", `${m.path}: ${api.category} has no reason codes`);
75
+ }
76
+ // Publisher and pages
77
+ if (!p.email)
78
+ add("error", "publisher.email", "A public contact email is required on the support page.");
79
+ if (!facts.pages.baseURL)
80
+ add("warn", "pages.baseURL", "pages.baseURL is empty: set where the pages will live before publishing.");
81
+ if (p.trader) {
82
+ if (!p.name)
83
+ add("error", "trader.name", "Traders must give a legal name.");
84
+ if (!p.address.street || !p.address.city)
85
+ add("error", "trader.address", "Traders must give a business address (never a home address).");
86
+ }
87
+ if (needsImpressum(facts)) {
88
+ const inApp = findInAppImpressum(scan.root, pageURL(facts, "impressum"));
89
+ if (p.trader) {
90
+ // Paid apps: the Impressum should work offline, so the text belongs in the app.
91
+ if (inApp !== "legalView")
92
+ add("error", "impressum.legalView", "DE/AT traders should show the full Impressum inside the app (it must work offline), not only a link: run `shelf pages --swiftui` and show LegalView from Settings.");
93
+ if (!p.phone?.trim() && !p.contactURL?.trim())
94
+ add("error", "trader.contact", "Add a second fast contact channel besides email: publisher.phone or publisher.contactURL.");
95
+ if (!p.vatId?.trim())
96
+ add("warn", "trader.vatId", "No publisher.vatId. Add your USt-IdNr. or Wirtschafts-ID if you have one.");
97
+ if (isCompany(facts)) {
98
+ if (!p.representative?.trim())
99
+ add("error", "trader.representative", `${p.legalForm}: name the managing director(s) in publisher.representative.`);
100
+ if (!p.register?.court?.trim() || !p.register?.number?.trim())
101
+ add("error", "trader.register", `${p.legalForm}: add publisher.register.court and publisher.register.number.`);
102
+ }
103
+ }
104
+ else if (!inApp) {
105
+ add("warn", "impressum.inApp", "The app neither shows a LegalView nor links to the Impressum: add a link, or run `shelf pages --swiftui`.");
106
+ }
107
+ }
108
+ const privacy = appPrivacy(facts);
109
+ if (privacy.unmapped.length)
110
+ add("warn", "appPrivacy.unmapped", `Answer these by hand in App Store Connect: ${privacy.unmapped.join(", ")}`);
111
+ if (!findings.some((f) => f.level !== "ok"))
112
+ add("ok", "all", "shelfready.yaml matches the repo.");
113
+ return findings;
114
+ }
115
+ /** Whether a Swift file defines LegalView (full text) or only links to the Impressum URL. */
116
+ function findInAppImpressum(root, impressumURL) {
117
+ let link = false;
118
+ const stack = [root];
119
+ while (stack.length) {
120
+ const dir = stack.pop();
121
+ let entries;
122
+ try {
123
+ entries = readdirSync(dir);
124
+ }
125
+ catch {
126
+ continue;
127
+ }
128
+ for (const name of entries) {
129
+ if (name.startsWith(".") || name === "node_modules" || name === "build" || name === "DerivedData")
130
+ continue;
131
+ const path = join(dir, name);
132
+ let isDir = false;
133
+ try {
134
+ isDir = statSync(path).isDirectory();
135
+ }
136
+ catch {
137
+ continue;
138
+ }
139
+ if (isDir)
140
+ stack.push(path);
141
+ else if (name.endsWith(".swift")) {
142
+ const source = readFileSync(path, "utf8");
143
+ if (source.includes("struct LegalView"))
144
+ return "legalView";
145
+ if (impressumURL.startsWith("http") && source.includes(impressumURL))
146
+ link = true;
147
+ }
148
+ }
149
+ }
150
+ return link ? "link" : undefined;
151
+ }
@@ -0,0 +1,44 @@
1
+ import type { Finding } from "./check.js";
2
+ import { type Facts } from "./facts.js";
3
+ import type { ScanResult } from "./scan.js";
4
+ /**
5
+ * The go-live checklist for an iOS app. Items ShelfReady can verify are ticked automatically
6
+ * from `check` (and `check --online`); the rest are manual and ticked with `shelf checklist --done <id>`,
7
+ * which stores the date in shelfready.yaml.
8
+ */
9
+ export type Status = "done" | "todo" | "fail";
10
+ export interface Context {
11
+ facts: Facts;
12
+ scan: ScanResult;
13
+ findings: Finding[];
14
+ /** Findings from `check --online`; undefined when not run. */
15
+ online?: Finding[];
16
+ }
17
+ interface Item {
18
+ id: string;
19
+ group: string;
20
+ title: string;
21
+ /** What to do, shown while the item isn't done. */
22
+ how: (c: Context) => string;
23
+ /** Automatic items return a status; manual items leave this out. */
24
+ auto?: (c: Context) => {
25
+ status: Status;
26
+ detail?: string;
27
+ };
28
+ applies?: (facts: Facts) => boolean;
29
+ }
30
+ export interface ChecklistRow {
31
+ id: string;
32
+ group: string;
33
+ title: string;
34
+ status: Status;
35
+ automatic: boolean;
36
+ detail?: string;
37
+ how?: string;
38
+ }
39
+ export declare const ITEMS: Item[];
40
+ export declare function checklist(c: Context): ChecklistRow[];
41
+ export declare function checklistMarkdown(rows: ChecklistRow[], appName: string): string;
42
+ /** Tick or untick manual items in shelfready.yaml, keeping comments and style. Returns the new file text. */
43
+ export declare function setTicks(path: string, ids: string[], done: boolean, date?: string): string;
44
+ export {};