@marktiderman/genesis-cli 1.17.3 → 1.19.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.
Files changed (33) hide show
  1. package/README.md +162 -17
  2. package/dist/cli.js +2099 -747
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-1jP8eCZy.d.ts → config-Dj_f9T7J.d.ts} +14 -1
  5. package/dist/doctor.d.ts +3 -3
  6. package/dist/doctor.js +944 -361
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +2 -2
  9. package/dist/expo.js +18 -0
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +29 -16
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +944 -361
  14. package/dist/index.js.map +1 -1
  15. package/dist/starter/README.md +9 -0
  16. package/dist/starter/__tests__/components/gestures.test.tsx +64 -0
  17. package/dist/starter/__tests__/components/resolver.js +14 -2
  18. package/dist/starter/__tests__/components/setup.ts +5 -0
  19. package/dist/starter/__tests__/starter.test.ts +56 -22
  20. package/dist/starter/genesis.config.json +10 -0
  21. package/dist/starter/jest.config.js +3 -0
  22. package/dist/starter/package.json +2 -0
  23. package/dist/starter/src/lib/link-hosts.ts +12 -0
  24. package/dist/starter/src/lib/links.ts +2 -1
  25. package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +7 -2
  26. package/dist/starter/supabase/migrations/20261024000700_genesis_support_findings.sql +339 -0
  27. package/dist/starter/supabase/tests/database/genesis_notifications.test.sql +5 -3
  28. package/dist/starter/supabase/tests/database/genesis_support.test.sql +1 -1
  29. package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +219 -0
  30. package/dist/templates/ci/genesis-upgrade.yml +1 -0
  31. package/dist/vite.js +945 -362
  32. package/dist/vite.js.map +1 -1
  33. package/package.json +3 -3
@@ -209,6 +209,15 @@ native modules use jest-expo's mocks or their library's own. A test fails when t
209
209
  error (`[push]`, `[updates]`, `[observability]`) or React warns about act(); see `reports.ts`.
210
210
  Add a screen's test there; tests that only read files stay in vitest, outside that folder.
211
211
 
212
+ Gestures and animations run in these tests as they are written, on Gesture Handler's mocks
213
+ (`react-native-gesture-handler/jestSetup.js`, in `jest.config.js`) and Reanimated's test mode
214
+ (`setUpTests()` in `setup.ts`, its resolver in `resolver.js`): worklets run on the JS thread with
215
+ Reanimated's web build, so what only the native UI runtime does (frame timing, native-driven
216
+ gestures, cross-thread races) still needs a device or Maestro run. Fire a gesture by its
217
+ `testID` with `fireGestureHandler` and `getByGestureTestId` from
218
+ `react-native-gesture-handler/jest-utils`, and read an animated style with `getAnimatedStyle`;
219
+ `gestures.test.tsx` drags a Pan gesture and checks the shared value it moves.
220
+
212
221
  ## Releasing
213
222
 
214
223
  `eas.json` and `.eas/workflows/` are the release path on EAS Workflows, and `.maestro/` the smoke
@@ -0,0 +1,64 @@
1
+ // @feat:native-starter
2
+ /**
3
+ * Gestures in Jest: Gesture Handler's mocks (`jestSetup.js`, from jest.config.js) and Reanimated's
4
+ * test mode (`setUpTests()` in setup.ts, its resolver in resolver.js). A Pan gesture fires from
5
+ * the test with `fireGestureHandler`, its worklets write a shared value, and the animated style
6
+ * follows: no device, no UI thread, and no rewriting the component onto the JS thread to test it.
7
+ */
8
+ import { describe, expect, it } from "@jest/globals";
9
+ import { act, render, screen } from "@testing-library/react-native";
10
+ import { useState } from "react";
11
+ import { Text } from "react-native";
12
+ import { GestureDetector, GestureHandlerRootView, State, usePanGesture } from "react-native-gesture-handler";
13
+ import { fireGestureHandler, getByGestureTestId } from "react-native-gesture-handler/jest-utils";
14
+ import Animated, { getAnimatedStyle, useAnimatedStyle, useSharedValue } from "react-native-reanimated";
15
+ import { scheduleOnRN } from "react-native-worklets";
16
+
17
+ // Reanimated types its Jest helpers in index.native.d.ts; TypeScript reads the web stub, which takes nothing.
18
+ const animatedStyle = getAnimatedStyle as unknown as (element: unknown) => unknown;
19
+
20
+ /** A card dragged sideways: the offset lives in a shared value, the drop is reported to React. */
21
+ function DraggableCard() {
22
+ const offset = useSharedValue(0);
23
+ const [dropped, setDropped] = useState<number | null>(null);
24
+ const pan = usePanGesture({
25
+ testID: "card-pan",
26
+ onUpdate: (event) => {
27
+ "worklet";
28
+ offset.value = event.translationX;
29
+ },
30
+ onDeactivate: () => {
31
+ "worklet";
32
+ scheduleOnRN(setDropped, offset.value);
33
+ },
34
+ });
35
+ const style = useAnimatedStyle(() => ({ transform: [{ translateX: offset.value }] }));
36
+ return (
37
+ <GestureHandlerRootView>
38
+ <GestureDetector gesture={pan}>
39
+ <Animated.View testID="card" style={style}>
40
+ <Text>{dropped === null ? "Drag me" : `Dropped at ${dropped}`}</Text>
41
+ </Animated.View>
42
+ </GestureDetector>
43
+ </GestureHandlerRootView>
44
+ );
45
+ }
46
+
47
+ describe("gestures in Jest", () => {
48
+ it("drives a Pan gesture's shared value and animated style from the test", async () => {
49
+ await render(<DraggableCard />);
50
+ expect(animatedStyle(screen.getByTestId("card"))).toEqual({ transform: [{ translateX: 0 }] });
51
+
52
+ await act(async () => {
53
+ fireGestureHandler(getByGestureTestId("card-pan"), [
54
+ { state: State.BEGAN, translationX: 0 },
55
+ { state: State.ACTIVE, translationX: 40 },
56
+ { translationX: 120 },
57
+ { state: State.END, translationX: 120 },
58
+ ]);
59
+ });
60
+
61
+ expect(animatedStyle(screen.getByTestId("card"))).toEqual({ transform: [{ translateX: 120 }] });
62
+ expect(await screen.findByText("Dropped at 120")).toBeOnTheScreen();
63
+ });
64
+ });
@@ -3,10 +3,22 @@
3
3
  * one. jest-expo resolves with the `require` and `react-native` conditions only, so it would
4
4
  * find nothing; for `@marktiderman/*` (and only those) this adds `import`. Babel turns the
5
5
  * module into CommonJS on the way in (`alsoTransform` in jest.config.js).
6
+ *
7
+ * Everything then goes through Reanimated's resolver (its Jest guide), which picks the web
8
+ * builds of Reanimated and Worklets: shared values, animated styles and gesture callbacks run
9
+ * in Jest without a UI thread.
6
10
  */
11
+ const reanimatedResolver = require("react-native-reanimated/jest/resolver");
12
+
7
13
  module.exports = (request, options) => {
14
+ // Gesture Handler's native build hands Worklets' UI runtime to its native module once loaded.
15
+ // Jest runs the web Worklets, which has no UI runtime and throws, so that one step takes Gesture
16
+ // Handler's web build (a no-op), as it does on the web. Its gestures still run on its Jest mocks.
17
+ if (request.endsWith("/installUIRuntimeBindings") && options.basedir.includes("react-native-gesture-handler")) {
18
+ return reanimatedResolver(`${request}.web`, options);
19
+ }
8
20
  if (request.startsWith("@marktiderman/")) {
9
- return options.defaultResolver(request, { ...options, conditions: [...(options.conditions ?? []), "import"] });
21
+ return reanimatedResolver(request, { ...options, conditions: [...(options.conditions ?? []), "import"] });
10
22
  }
11
- return options.defaultResolver(request, options);
23
+ return reanimatedResolver(request, options);
12
24
  };
@@ -8,6 +8,11 @@ import { expectedReports } from "./reports";
8
8
  process.env.EXPO_PUBLIC_SUPABASE_URL = "https://test.supabase.invalid";
9
9
  process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY = "test-publishable-key";
10
10
 
11
+ // Reanimated's test mode (its Jest guide, with the resolver in resolver.js): animations run on
12
+ // Jest's timers, and `toHaveAnimatedStyle` checks an animated style. Gesture Handler's mocks load
13
+ // from jest.config.js (`setupFiles`); `__tests__/components/gestures.test.tsx` shows both.
14
+ require("react-native-reanimated").setUpTests();
15
+
11
16
  // Native modules jest-expo has no mock for: each library's own Jest mock.
12
17
  jest.mock("@react-native-async-storage/async-storage", () => require("@react-native-async-storage/async-storage/jest/async-storage-mock"));
13
18
  jest.mock("@react-native-community/netinfo", () => require("@react-native-community/netinfo/jest/netinfo-mock.js"));
@@ -1,11 +1,12 @@
1
1
  // @feat:native-starter @feat:app-updates @feat:push @feat:observability @feat:devtools-overlay @feat:support-feedback @feat:chat @feat:product-roadmap
2
- import { readFileSync, readdirSync, statSync } from "node:fs";
2
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import { dirname, join } from "node:path";
5
5
  import { describe, expect, it } from "vitest";
6
6
  import starter from "../starter.config";
7
7
  import { defineStarter, easConfig, nativePlatforms, privacyBlocks, type StarterConfig } from "../src/lib/define-starter";
8
8
  import { copy, format } from "../src/copy";
9
+ import { linkHosts } from "../src/lib/link-hosts";
9
10
  import { findInlineCopy } from "./inline-copy";
10
11
 
11
12
  const root = join(__dirname, "..");
@@ -16,6 +17,13 @@ const notificationsPackage = dirname(createRequire(join(root, "package.json")).r
16
17
  const shippedSql = (path: string) => readFileSync(join(supabasePackage, "migrations", path), "utf8");
17
18
  const chatPackage = dirname(createRequire(join(root, "package.json")).resolve("@marktiderman/genesis-chat/package.json"));
18
19
  const chatSql = (path: string) => readFileSync(join(chatPackage, "migrations", path), "utf8");
20
+ // A switch that carries a block (genesis.config.json `starter.blocks`): an app made with
21
+ // `genesis init --without <switch>` has none of that block's migrations, tests or functions, so
22
+ // the checks of those files run only while it's on.
23
+ const { updates, push, notifications, support, chat } = starter.features;
24
+ // An app made with `genesis init --beside <web-app>` has no supabase/ folder: its database files
25
+ // are the web app's, so the checks of them run only where the folder is.
26
+ const database = existsSync(join(root, "supabase"));
19
27
 
20
28
  function filesUnder(dir: string): string[] {
21
29
  return readdirSync(join(root, dir)).flatMap((name) => {
@@ -32,7 +40,7 @@ describe("root layout", () => {
32
40
  });
33
41
  });
34
42
 
35
- describe("migrations", () => {
43
+ describe.runIf(database)("migrations", () => {
36
44
  it("each has its own version, so a new app's database applies every one", () => {
37
45
  const versions = filesUnder("supabase/migrations").map((f) => f.split("/").pop()!.split("_")[0]!);
38
46
  expect(new Set(versions).size).toBe(versions.length);
@@ -59,7 +67,7 @@ describe("starter.config.ts", () => {
59
67
  });
60
68
 
61
69
  it("declares in the privacy manifest only the blocks that are on", () => {
62
- expect(privacyBlocks(starter.features)).toEqual(["account", "observability", "push", "support"]);
70
+ expect(privacyBlocks({ observability: true, push: true, support: true })).toEqual(["account", "observability", "push", "support"]);
63
71
  expect(privacyBlocks({ observability: false, push: false, support: false })).toEqual(["account"]);
64
72
  });
65
73
 
@@ -78,12 +86,30 @@ describe("starter.config.ts", () => {
78
86
  expect(() => defineStarter({ ...starter, app: { ...starter.app, easProjectId: "" } })).not.toThrow();
79
87
  });
80
88
 
81
- it("ships with the updates block on and no EAS project (a placeholder for `eas init`)", () => {
82
- expect(starter.features.updates).toBe(true);
89
+ it("ships with no EAS project (a placeholder for `eas init`)", () => {
83
90
  expect(starter.app.easProjectId).toBe("");
84
91
  });
85
92
  });
86
93
 
94
+ describe("deep links", () => {
95
+ it("opens the hosts in genesis.config.json's links block", () => {
96
+ expect(linkHosts({ links: { hosts: ["example.com", "app.example.com"] } })).toEqual(["example.com", "app.example.com"]);
97
+ expect(read("src/lib/links.ts")).toContain("hosts: linkHosts(genesisConfig)");
98
+ });
99
+
100
+ it("has no app links, and doesn't throw, when no domain is configured", () => {
101
+ expect(linkHosts({})).toEqual([]);
102
+ expect(linkHosts({ links: null })).toEqual([]);
103
+ expect(linkHosts({ links: {} })).toEqual([]);
104
+ });
105
+
106
+ it("accepts a genesis.config.json with other keys and no links block (it typechecks)", () => {
107
+ // What a JSON import infers once `links` is removed: no key in common with `links`.
108
+ const noLinks = { doctor: { packs: ["native"] }, starter: { blocks: { push: ["push"] } } };
109
+ expect(linkHosts(noLinks)).toEqual([]);
110
+ });
111
+ });
112
+
87
113
  describe("EAS config", () => {
88
114
  it("turns expo-updates off in builds until there is an EAS project", () => {
89
115
  expect(easConfig({ easProjectId: "" })).toEqual({ updates: { enabled: false } });
@@ -206,7 +232,7 @@ describe("copy catalog", () => {
206
232
  });
207
233
  });
208
234
 
209
- describe("supabase/migrations", () => {
235
+ describe.runIf(database)("supabase/migrations", () => {
210
236
  it("carries @marktiderman/genesis-supabase's account-deletion migration unchanged", () => {
211
237
  const shipped = shippedSql("0001_genesis_account_deletion.sql");
212
238
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_account_deletion.sql"));
@@ -219,19 +245,19 @@ describe("supabase/migrations", () => {
219
245
  expect(read("supabase/tests/database/genesis_account_deletion.test.sql")).toBe(shipped);
220
246
  });
221
247
 
222
- it("carries the app-release-policy migration unchanged (the updates block reads it)", () => {
248
+ it.runIf(updates)("carries the app-release-policy migration unchanged (the updates block reads it)", () => {
223
249
  const shipped = shippedSql("0002_genesis_app_release_policy.sql");
224
250
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_app_release_policy.sql"));
225
251
  expect(copies).toHaveLength(1);
226
252
  expect(read(copies[0]!)).toBe(shipped);
227
253
  });
228
254
 
229
- it("carries its pgTAP test unchanged", () => {
255
+ it.runIf(updates)("carries the app-release-policy pgTAP test unchanged", () => {
230
256
  const shipped = shippedSql("tests/0002_genesis_app_release_policy.test.sql");
231
257
  expect(read("supabase/tests/database/genesis_app_release_policy.test.sql")).toBe(shipped);
232
258
  });
233
259
 
234
- it("applies account deletion before the release policy", () => {
260
+ it.runIf(updates)("applies account deletion before the release policy", () => {
235
261
  const order = filesUnder("supabase/migrations").sort();
236
262
  expect(order.findIndex((f) => f.endsWith("_genesis_account_deletion.sql"))).toBeLessThan(order.findIndex((f) => f.endsWith("_genesis_app_release_policy.sql")));
237
263
  });
@@ -243,7 +269,7 @@ describe("supabase/migrations", () => {
243
269
  expect(read("supabase/tests/database/genesis_apple_token_revocation.test.sql")).toBe(shippedSql("tests/0003_genesis_apple_token_revocation.test.sql"));
244
270
  });
245
271
 
246
- it("carries the push migration unchanged, after the Apple one, without its pgTAP test (superseded by the notifications migration)", () => {
272
+ it.runIf(push)("carries the push migration unchanged, after the Apple one, without its pgTAP test (superseded by the notifications migration)", () => {
247
273
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_push.sql"));
248
274
  expect(copies).toHaveLength(1);
249
275
  expect(read(copies[0]!)).toBe(shippedSql("0005_genesis_push.sql"));
@@ -253,7 +279,7 @@ describe("supabase/migrations", () => {
253
279
  expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_apple_token_revocation.sql")));
254
280
  });
255
281
 
256
- it("carries @marktiderman/genesis-notifications' migration and its pgTAP test unchanged, after every other package's (it adopts the push tables)", () => {
282
+ it.runIf(notifications)("carries @marktiderman/genesis-notifications' migration and its pgTAP test unchanged, after every other package's (it adopts the push tables)", () => {
257
283
  const shipped = (rel: string) => readFileSync(join(notificationsPackage, "migrations", rel), "utf8");
258
284
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_notifications.sql"));
259
285
  expect(copies).toHaveLength(1);
@@ -265,7 +291,7 @@ describe("supabase/migrations", () => {
265
291
  expect(packaged.at(-1)).toBe(copies[0]);
266
292
  });
267
293
 
268
- it("carries the support migration and its pgTAP test unchanged (the support block reads it), after the push one", () => {
294
+ it.runIf(support)("carries the support migration and its pgTAP test unchanged (the support block reads it), after the push one", () => {
269
295
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_support.sql"));
270
296
  expect(copies).toHaveLength(1);
271
297
  expect(read(copies[0]!)).toBe(shippedSql("0006_genesis_support.sql"));
@@ -273,9 +299,20 @@ describe("supabase/migrations", () => {
273
299
  const order = filesUnder("supabase/migrations").sort();
274
300
  expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_push.sql")));
275
301
  });
302
+
303
+ it.runIf(support)("carries genesis-support's findings migration and its pgTAP test unchanged, after the support one", () => {
304
+ const supportPackage = dirname(createRequire(join(root, "package.json")).resolve("@marktiderman/genesis-support/package.json"));
305
+ const shipped = (rel: string) => readFileSync(join(supportPackage, "migrations", rel), "utf8");
306
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_support_findings.sql"));
307
+ expect(copies).toHaveLength(1);
308
+ expect(read(copies[0]!)).toBe(shipped("0003_genesis_support_findings.sql"));
309
+ expect(read("supabase/tests/database/genesis_support_findings.test.sql")).toBe(shipped("tests/0003_genesis_support_findings.test.sql"));
310
+ const order = filesUnder("supabase/migrations").sort();
311
+ expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_support.sql")));
312
+ });
276
313
  });
277
314
 
278
- describe("supabase/functions", () => {
315
+ describe.runIf(database)("supabase/functions", () => {
279
316
  it("carries @marktiderman/genesis-supabase's genesis-apple-revoke function unchanged", () => {
280
317
  const shipped = join(supabasePackage, "functions", "genesis-apple-revoke");
281
318
  const names = readdirSync(shipped).sort();
@@ -290,7 +327,7 @@ describe("supabase/functions", () => {
290
327
  expect(read("supabase/config.toml")).toMatch(/\[functions\.genesis-apple-revoke\]\s*\nverify_jwt = false/);
291
328
  });
292
329
 
293
- it("carries the genesis-push-send function unchanged, deployed without the gateway's JWT check (it checks GENESIS_PUSH_SECRET)", () => {
330
+ it.runIf(push)("carries the genesis-push-send function unchanged, deployed without the gateway's JWT check (it checks GENESIS_PUSH_SECRET)", () => {
294
331
  const shipped = join(supabasePackage, "functions", "genesis-push-send");
295
332
  const names = readdirSync(shipped).sort();
296
333
  expect(names).toEqual(["expo.ts", "handler.ts", "index.ts"]);
@@ -303,8 +340,7 @@ describe("supabase/functions", () => {
303
340
  });
304
341
 
305
342
  describe("push", () => {
306
- it("ships with the push block on, behind the one `push` switch", () => {
307
- expect(starter.features.push).toBe(true);
343
+ it("puts the push block behind the one `push` switch", () => {
308
344
  expect(read("src/lib/app.ts")).toContain("features.push ? createStarterPush() : undefined");
309
345
  });
310
346
 
@@ -321,8 +357,7 @@ describe("push", () => {
321
357
  });
322
358
 
323
359
  describe("support", () => {
324
- it("ships with the support block on, behind the one `support` switch, needing a signed-in person", () => {
325
- expect(starter.features.support).toBe(true);
360
+ it("puts the support block behind the one `support` switch, needing a signed-in person", () => {
326
361
  expect(read("src/lib/app.ts")).toMatch(/blocks: \[[^\]]*\bsupport\b/);
327
362
  expect(read("src/lib/support.ts")).toContain("starter.features.support ? createStarterSupport() : undefined");
328
363
  expect(read("src/lib/app.ts")).toContain('appFeatures: ["account"]');
@@ -342,8 +377,7 @@ describe("support", () => {
342
377
  });
343
378
 
344
379
  describe("chat", () => {
345
- it("ships with chat on, its migration and pgTAP test copied unchanged after the support one, and genesis_chat served by the API", () => {
346
- expect(starter.features.chat).toBe(true);
380
+ it.runIf(chat && database)("carries chat's migration and pgTAP test unchanged after the support one, and serves genesis_chat through the API", () => {
347
381
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_chat.sql"));
348
382
  expect(copies).toHaveLength(1);
349
383
  expect(read(copies[0]!)).toBe(chatSql("0001_genesis_chat.sql"));
@@ -364,7 +398,7 @@ describe("chat", () => {
364
398
  expect(JSON.parse(read("genesis.config.json")).doctor.supabase.exposedSchemas).toContain("genesis_chat");
365
399
  });
366
400
 
367
- it("carries chat's 0002 migration (topics, scheduled send, availability, broadcast, search) and its pgTAP test unchanged, after 0001", () => {
401
+ it.runIf(chat && database)("carries chat's 0002 migration (topics, scheduled send, availability, broadcast, search) and its pgTAP test unchanged, after 0001", () => {
368
402
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_chat_coaching.sql"));
369
403
  expect(copies).toHaveLength(1);
370
404
  expect(read(copies[0]!)).toBe(chatSql("0002_genesis_chat_coaching.sql"));
@@ -409,7 +443,7 @@ describe("chat", () => {
409
443
  expect(read("src/lib/chat.tsx")).toContain("starter.features.chat && starter.features.push");
410
444
  });
411
445
 
412
- it("names people from their auth metadata through chat_people, after the chat migration, with its pgTAP test", () => {
446
+ it.runIf(chat && database)("names people from their auth metadata through chat_people, after the chat migration, with its pgTAP test", () => {
413
447
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_chat_people.sql"));
414
448
  expect(copies).toHaveLength(1);
415
449
  const order = filesUnder("supabase/migrations").sort();
@@ -8,5 +8,15 @@
8
8
  "links": {
9
9
  "hosts": ["example.com"],
10
10
  "paths": ["/notifications", "/messages", "/settings"]
11
+ },
12
+ "starter": {
13
+ "$comment": "The blocks each starter.config.ts switch carries. A block whose switch is off isn't in genesis.lock.json, and genesis upgrade and migrate leave it out (genesis init --without leaves its files out too).",
14
+ "blocks": {
15
+ "updates": ["app-updates"],
16
+ "push": ["push"],
17
+ "notifications": ["notifications"],
18
+ "support": ["support-feedback"],
19
+ "chat": ["chat"]
20
+ }
11
21
  }
12
22
  }
@@ -22,6 +22,9 @@ module.exports = {
22
22
  preset: "jest-expo",
23
23
  // Every test file here is jest's, `.ts` or `.tsx`; vitest.config.mts leaves this folder out.
24
24
  testMatch: ["<rootDir>/__tests__/components/**/*.test.{ts,tsx}"],
25
+ // Gesture Handler's own mocks (its Jest guide), after jest-expo's: gestures fire from tests
26
+ // with `fireGestureHandler` (react-native-gesture-handler/jest-utils), no native module.
27
+ setupFiles: [...expoPreset.setupFiles, "react-native-gesture-handler/jestSetup.js"],
25
28
  setupFilesAfterEnv: ["<rootDir>/__tests__/components/setup.ts"],
26
29
  resolver: "<rootDir>/__tests__/components/resolver.js",
27
30
  moduleNameMapper: {
@@ -72,6 +72,7 @@
72
72
  "react-hook-form": "^7.56.4",
73
73
  "react-native": "0.88.0",
74
74
  "react-native-css-interop": "^0.2.7",
75
+ "react-native-gesture-handler": "~3.3.0",
75
76
  "react-native-keyboard-controller": "1.22.7",
76
77
  "react-native-reanimated": "4.7.1",
77
78
  "react-native-safe-area-context": "~5.10.1",
@@ -84,6 +85,7 @@
84
85
  "zod": "^4.6.6"
85
86
  },
86
87
  "devDependencies": {
88
+ "@jest/globals": "~30.5.2",
87
89
  "@marktiderman/genesis-cli": "workspace:^",
88
90
  "@react-native/jest-preset": "0.88.0",
89
91
  "@testing-library/react-native": "^14.1.0",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The web hosts whose links open in the app: genesis.config.json's `links.hosts`. An app with no
3
+ * domain yet has no `links` block: remove the whole block, since the Expo config plugin rejects
4
+ * one with an empty `hosts` list. It then has no app links and only its schemes open it. Kept
5
+ * free of React Native imports so the tests can read it.
6
+ */
7
+ export type LinkHostsConfig = { readonly links?: { readonly hosts?: readonly string[] } | null; readonly [key: string]: unknown };
8
+
9
+ /** Takes the whole genesis.config.json, so a config with other keys and no `links` still typechecks. */
10
+ export function linkHosts(config: LinkHostsConfig): string[] {
11
+ return [...(config.links?.hosts ?? [])];
12
+ }
@@ -7,6 +7,7 @@ import Constants from "expo-constants";
7
7
  import { createLinkHold, type LinkOptions } from "@marktiderman/genesis-native";
8
8
  import genesisConfig from "../../genesis.config.json";
9
9
  import starter from "../../starter.config";
10
+ import { linkHosts } from "./link-hosts";
10
11
 
11
12
  /**
12
13
  * The schemes this build answers to. withGenesis gives each APP_VARIANT its own
@@ -26,7 +27,7 @@ export function appSchemes(base: string, built: string | readonly string[] | und
26
27
  /** Incoming link paths and the screens they open. `/` is always known; anything else opens `/`. */
27
28
  export const links: LinkOptions = {
28
29
  schemes: appSchemes(starter.app.scheme, Constants.expoConfig?.scheme),
29
- hosts: genesisConfig.links.hosts,
30
+ hosts: linkHosts(genesisConfig),
30
31
  map: {
31
32
  ...(starter.features.notifications ? { "/notifications": "/notifications" } : {}),
32
33
  // The check-in example's link (`genesis-starter://check-in?location=hilltop` fills in the location; `genesis-starter-dev://` in a development build).
@@ -39,6 +39,11 @@ export interface AppleConfig {
39
39
 
40
40
  const TEN_CHARS = /^[A-Z0-9]{10}$/;
41
41
  const CLIENT_ID = /^[A-Za-z0-9][A-Za-z0-9.-]{0,254}$/;
42
+ // The PKCS#8 PEM armour, with the dashes counted (`-{5}`) rather than written out: the literal
43
+ // header is what secret scanners (gitleaks' private-key rule) look for, and every app that installs
44
+ // this function scans it.
45
+ const PEM_KEY = /-{5}BEGIN PRIVATE KEY-{5}[\s\S]+-{5}END PRIVATE KEY-{5}/;
46
+ const PEM_MARKER = /-{5}(?:BEGIN|END) PRIVATE KEY-{5}/g;
42
47
 
43
48
  /**
44
49
  * Reads the Apple settings from the environment. Returns the names that are
@@ -55,7 +60,7 @@ export function readAppleConfig(env: (name: string) => string | undefined): { co
55
60
  .filter(Boolean);
56
61
  if (!TEN_CHARS.test(teamId)) problems.push("APPLE_TEAM_ID (10 capital letters or digits)");
57
62
  if (!TEN_CHARS.test(keyId)) problems.push("APPLE_KEY_ID (10 capital letters or digits)");
58
- if (!/-----BEGIN PRIVATE KEY-----[\s\S]+-----END PRIVATE KEY-----/.test(privateKey)) problems.push("APPLE_PRIVATE_KEY (the .p8 file's PEM text)");
63
+ if (!PEM_KEY.test(privateKey)) problems.push("APPLE_PRIVATE_KEY (the .p8 file's PEM text)");
59
64
  if (clientIds.length === 0 || !clientIds.every((id) => CLIENT_ID.test(id))) problems.push("APPLE_CLIENT_IDS (comma-separated bundle ids or Services IDs)");
60
65
  return problems.length ? { problems } : { config: { teamId, keyId, privateKey, clientIds } };
61
66
  }
@@ -85,7 +90,7 @@ const keyCache = new Map<string, Promise<CryptoKey>>();
85
90
  function signingKey(pem: string): Promise<CryptoKey> {
86
91
  let key = keyCache.get(pem);
87
92
  if (!key) {
88
- const body = pem.replace(/-----(BEGIN|END) PRIVATE KEY-----/g, "").replace(/\s+/g, "");
93
+ const body = pem.replace(PEM_MARKER, "").replace(/\s+/g, "");
89
94
  const der = Uint8Array.from(atob(body), (c) => c.charCodeAt(0));
90
95
  key = crypto.subtle.importKey("pkcs8", der, { name: "ECDSA", namedCurve: "P-256" }, false, ["sign"]);
91
96
  // A bad key must not stay cached as a rejected promise.