@marktiderman/genesis-cli 1.6.0 → 1.7.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 (139) hide show
  1. package/README.md +156 -1
  2. package/dist/cli.js +2769 -567
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-CUdwT-nY.d.ts → config-CrZbM3jD.d.ts} +45 -2
  5. package/dist/doctor.d.ts +2 -2
  6. package/dist/doctor.js +133 -5
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +91 -8
  9. package/dist/expo.js +207 -14
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +502 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +140 -9
  14. package/dist/index.js.map +1 -1
  15. package/dist/scaffolder.d.ts +1 -1
  16. package/dist/scaffolder.js +7 -4
  17. package/dist/scaffolder.js.map +1 -1
  18. package/dist/starter/.eas/scripts/rollout-health.mjs +85 -0
  19. package/dist/starter/.eas/workflows/deploy-production.yml +149 -0
  20. package/dist/starter/.eas/workflows/e2e.yml +77 -0
  21. package/dist/starter/.eas/workflows/pr-preview.yml +117 -0
  22. package/dist/starter/.eas/workflows/rollout.yml +120 -0
  23. package/dist/starter/.env.example +11 -0
  24. package/dist/starter/.fingerprintignore +7 -0
  25. package/dist/starter/.maestro/README.md +38 -0
  26. package/dist/starter/.maestro/config.yaml +5 -0
  27. package/dist/starter/.maestro/flows/deep-link.yaml +22 -0
  28. package/dist/starter/.maestro/flows/launch.yaml +17 -0
  29. package/dist/starter/.maestro/flows/settings-version.yaml +28 -0
  30. package/dist/starter/.maestro/flows/sign-in-screen.yaml +17 -0
  31. package/dist/starter/.maestro/subflows/sign-in.yaml +20 -0
  32. package/dist/starter/README.md +314 -0
  33. package/dist/starter/__tests__/app-config.test.ts +51 -0
  34. package/dist/starter/__tests__/check-in-photos.test.ts +57 -0
  35. package/dist/starter/__tests__/components/css-stub.js +2 -0
  36. package/dist/starter/__tests__/components/fake-supabase.ts +136 -0
  37. package/dist/starter/__tests__/components/links.test.ts +25 -0
  38. package/dist/starter/__tests__/components/render-app.ts +22 -0
  39. package/dist/starter/__tests__/components/reports.ts +10 -0
  40. package/dist/starter/__tests__/components/resolver.js +12 -0
  41. package/dist/starter/__tests__/components/root-layout.test.tsx +55 -0
  42. package/dist/starter/__tests__/components/session-storage.test.tsx +81 -0
  43. package/dist/starter/__tests__/components/settings.test.tsx +134 -0
  44. package/dist/starter/__tests__/components/setup.ts +69 -0
  45. package/dist/starter/__tests__/components/sign-in.test.tsx +90 -0
  46. package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +19 -0
  47. package/dist/starter/__tests__/components/tabs.test.tsx +43 -0
  48. package/dist/starter/__tests__/components/tabs.ts +12 -0
  49. package/dist/starter/__tests__/entry.test.ts +28 -0
  50. package/dist/starter/__tests__/inline-copy.ts +59 -0
  51. package/dist/starter/__tests__/starter.test.ts +319 -0
  52. package/dist/starter/_gitignore +13 -0
  53. package/dist/starter/app.config.ts +44 -0
  54. package/dist/starter/babel.config.js +9 -0
  55. package/dist/starter/eas.json +47 -0
  56. package/dist/starter/eslint.config.js +5 -0
  57. package/dist/starter/genesis.config.json +12 -0
  58. package/dist/starter/global.css +3 -0
  59. package/dist/starter/index.ts +14 -0
  60. package/dist/starter/jest.config.js +36 -0
  61. package/dist/starter/metro.config.js +38 -0
  62. package/dist/starter/package.json +93 -0
  63. package/dist/starter/pnpm-workspace.yaml +73 -0
  64. package/dist/starter/src/app/(app)/(home)/_layout.tsx +6 -0
  65. package/dist/starter/src/app/(app)/(home)/check-in.tsx +41 -0
  66. package/dist/starter/src/app/(app)/(home)/index.tsx +34 -0
  67. package/dist/starter/src/app/(app)/_layout.tsx +27 -0
  68. package/dist/starter/src/app/(app)/notifications/_layout.tsx +6 -0
  69. package/dist/starter/src/app/(app)/notifications/index.tsx +36 -0
  70. package/dist/starter/src/app/(app)/settings/_layout.tsx +6 -0
  71. package/dist/starter/src/app/(app)/settings/index.tsx +96 -0
  72. package/dist/starter/src/app/(app)/settings/notifications.tsx +16 -0
  73. package/dist/starter/src/app/(app)/settings/support/[id].tsx +23 -0
  74. package/dist/starter/src/app/(app)/settings/support/ideas.tsx +20 -0
  75. package/dist/starter/src/app/(app)/settings/support/index.tsx +20 -0
  76. package/dist/starter/src/app/(app)/settings/support/new.tsx +35 -0
  77. package/dist/starter/src/app/(app)/settings/support/shipped.tsx +20 -0
  78. package/dist/starter/src/app/+native-intent.ts +11 -0
  79. package/dist/starter/src/app/_layout.tsx +20 -0
  80. package/dist/starter/src/app/sign-in.tsx +69 -0
  81. package/dist/starter/src/copy.ts +118 -0
  82. package/dist/starter/src/forms/check-in.json +121 -0
  83. package/dist/starter/src/lib/account.ts +42 -0
  84. package/dist/starter/src/lib/app.ts +52 -0
  85. package/dist/starter/src/lib/auth.ts +80 -0
  86. package/dist/starter/src/lib/check-in-photos.ts +66 -0
  87. package/dist/starter/src/lib/check-in.ts +85 -0
  88. package/dist/starter/src/lib/define-starter.ts +148 -0
  89. package/dist/starter/src/lib/devtools-overlay.ts +34 -0
  90. package/dist/starter/src/lib/devtools.ts +23 -0
  91. package/dist/starter/src/lib/env.ts +33 -0
  92. package/dist/starter/src/lib/google-signin.ts +23 -0
  93. package/dist/starter/src/lib/links.ts +40 -0
  94. package/dist/starter/src/lib/native-modules.ts +27 -0
  95. package/dist/starter/src/lib/notifications.ts +15 -0
  96. package/dist/starter/src/lib/observability.ts +45 -0
  97. package/dist/starter/src/lib/push.ts +49 -0
  98. package/dist/starter/src/lib/supabase.ts +65 -0
  99. package/dist/starter/src/lib/support.ts +44 -0
  100. package/dist/starter/src/lib/updates.ts +61 -0
  101. package/dist/starter/starter.config.ts +37 -0
  102. package/dist/starter/supabase/config.toml +26 -0
  103. package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +237 -0
  104. package/dist/starter/supabase/functions/genesis-apple-revoke/handler.ts +227 -0
  105. package/dist/starter/supabase/functions/genesis-apple-revoke/index.ts +55 -0
  106. package/dist/starter/supabase/functions/genesis-push-send/expo.ts +117 -0
  107. package/dist/starter/supabase/functions/genesis-push-send/handler.ts +462 -0
  108. package/dist/starter/supabase/functions/genesis-push-send/index.ts +54 -0
  109. package/dist/starter/supabase/migrations/20261024000000_genesis_account_deletion.sql +133 -0
  110. package/dist/starter/supabase/migrations/20261024000100_genesis_app_release_policy.sql +82 -0
  111. package/dist/starter/supabase/migrations/20261024000200_genesis_apple_token_revocation.sql +205 -0
  112. package/dist/starter/supabase/migrations/20261024000400_genesis_push.sql +524 -0
  113. package/dist/starter/supabase/migrations/20261024000600_genesis_support.sql +846 -0
  114. package/dist/starter/supabase/tests/database/genesis_account_deletion.test.sql +138 -0
  115. package/dist/starter/supabase/tests/database/genesis_app_release_policy.test.sql +148 -0
  116. package/dist/starter/supabase/tests/database/genesis_apple_token_revocation.test.sql +230 -0
  117. package/dist/starter/supabase/tests/database/genesis_push.test.sql +407 -0
  118. package/dist/starter/supabase/tests/database/genesis_support.test.sql +552 -0
  119. package/dist/starter/tailwind.config.mjs +15 -0
  120. package/dist/starter/tsconfig.json +14 -0
  121. package/dist/starter/vitest.config.mts +7 -0
  122. package/dist/templates/ci/app-ci.yml +17 -0
  123. package/dist/templates/ci/genesis-upgrade.yml +21 -0
  124. package/dist/templates/ci/supabase-ci.yml +20 -0
  125. package/dist/templates/eas/eas.json +47 -0
  126. package/dist/templates/eas/scripts/rollout-health.mjs +85 -0
  127. package/dist/templates/eas/workflows/deploy-production.yml +149 -0
  128. package/dist/templates/eas/workflows/e2e.yml +77 -0
  129. package/dist/templates/eas/workflows/pr-preview.yml +117 -0
  130. package/dist/templates/eas/workflows/rollout.yml +120 -0
  131. package/dist/templates/maestro/config.yaml +5 -0
  132. package/dist/templates/maestro/flows/deep-link.yaml +22 -0
  133. package/dist/templates/maestro/flows/launch.yaml +17 -0
  134. package/dist/templates/maestro/flows/settings-version.yaml +28 -0
  135. package/dist/templates/maestro/flows/sign-in-screen.yaml +17 -0
  136. package/dist/templates/maestro/subflows/sign-in.yaml +20 -0
  137. package/dist/vite.js +133 -5
  138. package/dist/vite.js.map +1 -1
  139. package/package.json +4 -4
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Runs before every component test file. The app's Supabase client is swapped for the fake
3
+ * in `fake-supabase.ts`; everything else is the starter's own code on jest-expo's mocks.
4
+ */
5
+ import { afterEach, beforeEach, jest } from "@jest/globals";
6
+ import { expectedReports } from "./reports";
7
+
8
+ process.env.EXPO_PUBLIC_SUPABASE_URL = "https://test.supabase.invalid";
9
+ process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY = "test-publishable-key";
10
+
11
+ // Native modules jest-expo has no mock for: each library's own Jest mock.
12
+ jest.mock("@react-native-async-storage/async-storage", () => require("@react-native-async-storage/async-storage/jest/async-storage-mock"));
13
+ jest.mock("@react-native-community/netinfo", () => require("@react-native-community/netinfo/jest/netinfo-mock.js"));
14
+ jest.mock("react-native-keyboard-controller", () => require("react-native-keyboard-controller/jest"));
15
+ // jest-expo's expo-notifications mock returns listener subscriptions without `remove`, which the
16
+ // push block calls; this one is the subset the block uses, on a device that hasn't been asked yet.
17
+ jest.mock("expo-notifications", () => {
18
+ const subscription = () => ({ remove: () => {} });
19
+ return {
20
+ setNotificationHandler: () => {},
21
+ setNotificationChannelAsync: async () => null,
22
+ getPermissionsAsync: async () => ({ status: "undetermined", granted: false, canAskAgain: true, expires: "never" }),
23
+ requestPermissionsAsync: async () => ({ status: "denied", granted: false, canAskAgain: false, expires: "never" }),
24
+ getExpoPushTokenAsync: async () => ({ type: "expo", data: "ExponentPushToken[test]" }),
25
+ addPushTokenListener: subscription,
26
+ addNotificationResponseReceivedListener: subscription,
27
+ getLastNotificationResponse: () => null,
28
+ clearLastNotificationResponse: () => {},
29
+ setBadgeCountAsync: async () => true,
30
+ getBadgeCountAsync: async () => 0,
31
+ AndroidImportance: { DEFAULT: 3 },
32
+ };
33
+ });
34
+ // jest-expo's expo-updates mock answers `checkForUpdateAsync` with nothing; the server has no update.
35
+ jest.mock("expo-updates", () => ({
36
+ ...jest.requireActual<object>("expo-updates"),
37
+ checkForUpdateAsync: async () => ({ isAvailable: false, isRollBackToEmbedded: false }),
38
+ }));
39
+
40
+ jest.mock("@/lib/supabase", () => {
41
+ const { fakeSupabase, sessionReady } = jest.requireActual<typeof import("./fake-supabase")>("./fake-supabase");
42
+ return { supabase: fakeSupabase, sessionReady };
43
+ });
44
+
45
+ // A block that reports an error (`[push] …`, `[updates] …`, the observability sink's
46
+ // `[observability] …`) only warns in the app; here it fails the test, as does a React update
47
+ // outside act(). A mock that's missing something the app calls can't pass in silence.
48
+ // A test that provokes a report on purpose names it with `expectReport` (from `./reports`).
49
+ const LOUD = [/^\[(push|updates|observability)\] /, /not wrapped in act\(/];
50
+ const heard: string[] = [];
51
+ const originals = { warn: console.warn, error: console.error };
52
+ beforeEach(() => {
53
+ // Installed per test: a test file's `jest.restoreAllMocks()` takes these off with its own spies.
54
+ for (const level of ["warn", "error"] as const) {
55
+ if (jest.isMockFunction(console[level])) continue;
56
+ jest.spyOn(console, level).mockImplementation((...args: unknown[]) => {
57
+ const line = args.map(String).join(" ");
58
+ if (LOUD.some((pattern) => pattern.test(line)) && !expectedReports.some((pattern) => pattern.test(line))) {
59
+ heard.push(`console.${level}: ${line.split("\n")[0]}`);
60
+ }
61
+ originals[level](...args);
62
+ });
63
+ }
64
+ });
65
+ afterEach(() => {
66
+ expectedReports.length = 0;
67
+ const lines = heard.splice(0);
68
+ if (lines.length > 0) throw new Error(`The app reported problems during this test:\n${lines.join("\n")}`);
69
+ });
@@ -0,0 +1,90 @@
1
+ import { afterEach, describe, expect, it, jest } from "@jest/globals";
2
+ import { Alert } from "react-native";
3
+ import { screen, userEvent } from "@testing-library/react-native";
4
+ import { copy, format } from "@/copy";
5
+ import { fakeSupabase, next } from "./fake-supabase";
6
+ import { expectPathname, renderApp } from "./render-app";
7
+
8
+ const t = copy.signIn;
9
+
10
+ async function fillAndSubmit(email: string, password: string) {
11
+ const user = userEvent.setup();
12
+ const emailField = await screen.findByTestId("auth-screen-form-email");
13
+ const passwordField = screen.getByTestId("auth-screen-form-password");
14
+ await user.clear(emailField);
15
+ if (email) await user.type(emailField, email);
16
+ await user.clear(passwordField);
17
+ if (password) await user.type(passwordField, password);
18
+ await user.press(screen.getByTestId("auth-screen-form-submit"));
19
+ }
20
+
21
+ describe("sign-in screen", () => {
22
+ afterEach(() => {
23
+ jest.restoreAllMocks();
24
+ });
25
+
26
+ it("is where a signed-out person lands, with the catalog's copy, the email form and Sign in with Apple", async () => {
27
+ const app = await renderApp("/", null);
28
+ expect(await screen.findByText(t.headline)).toBeOnTheScreen();
29
+ await expectPathname(app, "/sign-in");
30
+ expect(screen.getByText(t.subhead)).toBeOnTheScreen();
31
+ expect(screen.getByTestId("auth-screen-form-email")).toBeOnTheScreen();
32
+ expect(screen.getByTestId("auth-screen-form-password")).toBeOnTheScreen();
33
+ expect(screen.getByText(t.submit)).toBeOnTheScreen();
34
+ expect(screen.getByTestId("auth-screen-social-apple")).toBeOnTheScreen();
35
+ // `features.googleSignIn` is off in starter.config.ts.
36
+ expect(screen.queryByTestId("auth-screen-social-google")).not.toBeOnTheScreen();
37
+ });
38
+
39
+ it("signs in with the typed email and password, then goes home", async () => {
40
+ const app = await renderApp("/sign-in", null);
41
+ await fillAndSubmit("person@example.com", "correct horse");
42
+ expect(await screen.findByTestId("home")).toBeOnTheScreen();
43
+ expect(fakeSupabase.auth.signInWithPassword).toHaveBeenCalledTimes(1);
44
+ expect(fakeSupabase.auth.signInWithPassword).toHaveBeenCalledWith({ email: "person@example.com", password: "correct horse" });
45
+ expect(fakeSupabase.auth.signUp).not.toHaveBeenCalled();
46
+ await expectPathname(app, "/");
47
+ });
48
+
49
+ it("refuses an empty email or password before calling Supabase", async () => {
50
+ await renderApp("/sign-in", null);
51
+ await fillAndSubmit("", "a password");
52
+ expect(await screen.findByText(t.emailRequired)).toBeOnTheScreen();
53
+ await fillAndSubmit("person@example.com", "");
54
+ expect(await screen.findByText(t.passwordRequired)).toBeOnTheScreen();
55
+ expect(fakeSupabase.auth.signInWithPassword).not.toHaveBeenCalled();
56
+ });
57
+
58
+ it("shows the catalog's message for Supabase's error code, never the server's text", async () => {
59
+ const app = await renderApp("/sign-in", null);
60
+ next.authError = "invalid_credentials";
61
+ await fillAndSubmit("person@example.com", "wrong");
62
+ expect(await screen.findByText(t.errors.invalid_credentials)).toBeOnTheScreen();
63
+ expect(screen.queryByText("server text for invalid_credentials")).not.toBeOnTheScreen();
64
+ expect(app.getPathname()).toBe("/sign-in");
65
+ });
66
+
67
+ it("creates an account after the switch, and asks to confirm the email when Supabase wants it", async () => {
68
+ const alert = jest.spyOn(Alert, "alert").mockImplementation(() => {});
69
+ const app = await renderApp("/sign-in", null);
70
+ await userEvent.setup().press(await screen.findByTestId("sign-in-switch"));
71
+ expect(screen.getByText(t.createSubmit)).toBeOnTheScreen();
72
+ // The subhead follows the mode: creating an account doesn't say "Sign in".
73
+ expect(screen.getByText(t.createSubhead)).toBeOnTheScreen();
74
+ expect(screen.queryByText(t.subhead)).not.toBeOnTheScreen();
75
+ next.confirmEmail = true;
76
+ await fillAndSubmit("new@example.com", "a long password");
77
+ // Back to "Sign in" once the account exists and waits for its confirmation.
78
+ expect(await screen.findByText(t.submit)).toBeOnTheScreen();
79
+ expect(fakeSupabase.auth.signUp).toHaveBeenCalledWith({ email: "new@example.com", password: "a long password" });
80
+ expect(fakeSupabase.auth.signInWithPassword).not.toHaveBeenCalled();
81
+ expect(alert).toHaveBeenCalledWith(t.checkInboxTitle, format(t.checkInboxBody, { email: "new@example.com" }));
82
+ expect(app.getPathname()).toBe("/sign-in");
83
+ });
84
+
85
+ it("sends a signed-in person who opens sign-in home", async () => {
86
+ const app = await renderApp("/sign-in", "person@example.com");
87
+ expect(await screen.findByTestId("home")).toBeOnTheScreen();
88
+ await expectPathname(app, "/");
89
+ });
90
+ });
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it, jest } from "@jest/globals";
2
+ import { screen } from "@testing-library/react-native";
3
+ import { copy } from "@/copy";
4
+ import { renderApp } from "./render-app";
5
+ import { tabTitles } from "./tabs";
6
+
7
+ // This file's app has `features.notifications` off; every other switch is the starter's own.
8
+ jest.mock("../../starter.config", () => {
9
+ const actual = jest.requireActual<{ default: { features: object } }>("../../starter.config").default;
10
+ return { __esModule: true, default: { ...actual, features: { ...actual.features, notifications: false } } };
11
+ });
12
+
13
+ describe("tabs with a feature off", () => {
14
+ it("hides the Notifications tab when features.notifications is off", async () => {
15
+ await renderApp("/", "person@example.com");
16
+ await screen.findByTestId("home");
17
+ expect(tabTitles()).toEqual([copy.tabs.home, copy.tabs.settings]);
18
+ });
19
+ });
@@ -0,0 +1,43 @@
1
+ import { describe, expect, it } from "@jest/globals";
2
+ import { act, screen } from "@testing-library/react-native";
3
+ import { router } from "expo-router";
4
+ import { copy } from "@/copy";
5
+ import { emit } from "./fake-supabase";
6
+ import { expectPathname, renderApp } from "./render-app";
7
+ import { tabTitles } from "./tabs";
8
+
9
+ describe("tabs", () => {
10
+ it("opens a signed-in person on Home, with Home, Notifications and Settings in the tab bar", async () => {
11
+ const app = await renderApp("/", "person@example.com");
12
+ expect(await screen.findByTestId("home")).toBeOnTheScreen();
13
+ expect(app.getPathname()).toBe("/");
14
+ expect(tabTitles()).toEqual([copy.tabs.home, copy.tabs.notifications, copy.tabs.settings]);
15
+ });
16
+
17
+ it("routes each tab to its screen", async () => {
18
+ const app = await renderApp("/", "person@example.com");
19
+ await screen.findByTestId("home");
20
+ // A tab switch, as the tab bar makes it (expo-router's testRouter asserts the internal no-animation param too).
21
+ await act(async () => router.navigate("/notifications"));
22
+ expect(await screen.findByText(copy.notifications.emptyTitle)).toBeOnTheScreen();
23
+ await expectPathname(app, "/notifications");
24
+ await act(async () => router.navigate("/settings"));
25
+ expect(await screen.findByTestId("settings-row-email")).toBeOnTheScreen();
26
+ await expectPathname(app, "/settings");
27
+ });
28
+
29
+ it("sends a signed-out deep link into a tab to sign-in", async () => {
30
+ const app = await renderApp("/settings", null);
31
+ expect(await screen.findByText(copy.signIn.headline)).toBeOnTheScreen();
32
+ await expectPathname(app, "/sign-in");
33
+ expect(screen.queryByTestId("settings")).not.toBeOnTheScreen();
34
+ });
35
+
36
+ it("leaves the tabs for sign-in when the session ends elsewhere", async () => {
37
+ const app = await renderApp("/notifications", "person@example.com");
38
+ await screen.findByText(copy.notifications.emptyTitle);
39
+ await act(async () => emit("SIGNED_OUT", null));
40
+ expect(await screen.findByText(copy.signIn.headline)).toBeOnTheScreen();
41
+ await expectPathname(app, "/sign-in");
42
+ });
43
+ });
@@ -0,0 +1,12 @@
1
+ import { screen } from "@testing-library/react-native";
2
+
3
+ /**
4
+ * The native tab bar's tabs, as react-native-screens renders them under Jest: one
5
+ * `RNSTabsScreen*` host view per tab, titled with its label. There is no role or text
6
+ * query for these (the bar itself is native), so the tests read the host views.
7
+ */
8
+ export function tabTitles(): string[] {
9
+ return screen.container
10
+ .queryAll((node) => typeof node.type === "string" && node.type.startsWith("RNSTabsScreen"))
11
+ .map((node) => String(node.props.title));
12
+ }
@@ -0,0 +1,28 @@
1
+ // @feat:native-starter @feat:native-app-shell
2
+ /**
3
+ * The app's entry (`index.ts`): the dependency warnings the app can't act on are kept out of
4
+ * LogBox before expo-router loads, since NativeWind's runtime warns while the first screen is
5
+ * required. Otherwise React Native 0.88 pins "Open debugger to view warnings." over the native tab
6
+ * bar and the first tab tap after a launch, or after a link opened the app, lands on it.
7
+ */
8
+ import { readFileSync } from "node:fs";
9
+ import { join } from "node:path";
10
+ import { describe, expect, it } from "vitest";
11
+
12
+ const root = join(__dirname, "..");
13
+ const read = (path: string) => readFileSync(join(root, path), "utf8");
14
+
15
+ describe("index.ts", () => {
16
+ it("is the app's entry", () => {
17
+ expect(JSON.parse(read("package.json")).main).toBe("index.ts");
18
+ });
19
+
20
+ it("ignores the known warnings first, then requires expo-router's entry (a require, so it isn't hoisted)", () => {
21
+ const source = read("index.ts");
22
+ const ignore = source.indexOf("ignoreKnownDependencyWarnings(LogBox, __DEV__);");
23
+ const entry = source.indexOf('require("expo-router/entry");');
24
+ expect(ignore).toBeGreaterThan(-1);
25
+ expect(entry).toBeGreaterThan(ignore);
26
+ expect(source).not.toMatch(/^import ["']expo-router\/entry["']/m);
27
+ });
28
+ });
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Finds user-facing text written into code instead of read from `src/copy.ts`,
3
+ * by walking the TypeScript syntax tree (so `a > b`, generics and comments
4
+ * can't be mistaken for JSX text, and `{"…"}` children can't hide it):
5
+ *
6
+ * - JSX text with a letter in it, and string or template literals as JSX children;
7
+ * - string attributes, except the ones that are never shown (`testID`, `href`, `variant`…);
8
+ * - the title and message of `Alert.alert` / `Alert.prompt`;
9
+ * - object properties that hold copy (`title: "…"`, `text: "…"`, `label: "…"`…).
10
+ */
11
+ import ts from "typescript";
12
+
13
+ /** JSX attributes whose strings are identifiers, routes, icons or styles, never shown as text. */
14
+ const NON_COPY_ATTRIBUTES = new Set([
15
+ "testID", "nativeID", "id", "key", "name", "href", "src", "md", "sf", "variant", "size", "mode", "type", "appearance",
16
+ "className", "contentClassName", "textClassName", "style", "autoComplete", "textContentType", "keyboardType",
17
+ "returnKeyType", "autoCapitalize", "accessibilityRole", "behavior", "statusBar", "themeMode", "pointerEvents",
18
+ ]);
19
+
20
+ /** Object keys whose string values are shown to people. */
21
+ const COPY_KEYS = new Set([
22
+ "title", "label", "text", "message", "subtitle", "body", "headline", "subhead", "description", "placeholder",
23
+ "headerTitle", "emptyTitle", "emptyBody", "submitLabel", "errorMessage", "accessibilityLabel", "accessibilityHint",
24
+ ]);
25
+
26
+ const hasLetter = (s: string) => /\p{L}/u.test(s);
27
+ const isStringish = (n: ts.Node): n is ts.StringLiteral | ts.NoSubstitutionTemplateLiteral | ts.TemplateExpression =>
28
+ ts.isStringLiteral(n) || ts.isNoSubstitutionTemplateLiteral(n) || ts.isTemplateExpression(n);
29
+ const textOf = (n: ts.Node, source: ts.SourceFile) => n.getText(source).replace(/\s+/g, " ").trim();
30
+
31
+ export function findInlineCopy(code: string, fileName = "file.tsx"): string[] {
32
+ const source = ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true, fileName.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
33
+ const hits: string[] = [];
34
+ const hit = (n: ts.Node) => {
35
+ const { line } = source.getLineAndCharacterOfPosition(n.getStart(source));
36
+ hits.push(`${fileName}:${line + 1}: ${textOf(n, source)}`);
37
+ };
38
+ const stringHasLetter = (n: ts.Node) => isStringish(n) && hasLetter(n.getText(source).slice(1, -1));
39
+
40
+ const visit = (node: ts.Node) => {
41
+ if (ts.isJsxText(node) && hasLetter(node.text)) hit(node);
42
+ if (ts.isJsxExpression(node) && node.expression && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent)) && stringHasLetter(node.expression)) {
43
+ hit(node);
44
+ }
45
+ if (ts.isJsxAttribute(node) && node.initializer && !NON_COPY_ATTRIBUTES.has(node.name.getText(source))) {
46
+ const value = ts.isJsxExpression(node.initializer) ? node.initializer.expression : node.initializer;
47
+ if (value && stringHasLetter(value)) hit(node);
48
+ }
49
+ if (ts.isCallExpression(node) && /^Alert\.(alert|prompt)$/.test(node.expression.getText(source))) {
50
+ for (const arg of node.arguments.slice(0, 2)) if (stringHasLetter(arg)) hit(arg);
51
+ }
52
+ if (ts.isPropertyAssignment(node) && COPY_KEYS.has(node.name.getText(source).replace(/["']/g, "")) && stringHasLetter(node.initializer)) {
53
+ hit(node);
54
+ }
55
+ ts.forEachChild(node, visit);
56
+ };
57
+ visit(source);
58
+ return hits;
59
+ }
@@ -0,0 +1,319 @@
1
+ // @feat:native-starter @feat:app-updates @feat:push @feat:observability @feat:devtools-overlay @feat:support-feedback
2
+ import { readFileSync, readdirSync, statSync } from "node:fs";
3
+ import { createRequire } from "node:module";
4
+ import { dirname, join } from "node:path";
5
+ import { describe, expect, it } from "vitest";
6
+ import starter from "../starter.config";
7
+ import { defineStarter, easConfig, nativePlatforms, privacyBlocks, type StarterConfig } from "../src/lib/define-starter";
8
+ import { copy, format } from "../src/copy";
9
+ import { findInlineCopy } from "./inline-copy";
10
+
11
+ const root = join(__dirname, "..");
12
+ const read = (path: string) => readFileSync(join(root, path), "utf8");
13
+ // Wherever the package manager put it (hoisted to the workspace root here).
14
+ const supabasePackage = dirname(createRequire(join(root, "package.json")).resolve("@marktiderman/genesis-supabase/package.json"));
15
+ const shippedSql = (path: string) => readFileSync(join(supabasePackage, "migrations", path), "utf8");
16
+
17
+ function filesUnder(dir: string): string[] {
18
+ return readdirSync(join(root, dir)).flatMap((name) => {
19
+ const path = join(dir, name);
20
+ return statSync(join(root, path)).isDirectory() ? filesUnder(path) : [path];
21
+ });
22
+ }
23
+
24
+ describe("root layout", () => {
25
+ it("stays within 30 lines: GenesisNativeApp owns everything above the screens", () => {
26
+ const lines = read("src/app/_layout.tsx").trimEnd().split("\n");
27
+ expect(lines.length).toBeLessThanOrEqual(30);
28
+ expect(lines.join("\n")).toContain("<GenesisNativeApp");
29
+ });
30
+ });
31
+
32
+ describe("starter.config.ts", () => {
33
+ it("refuses a config with no way to sign in", () => {
34
+ const none: StarterConfig = { ...starter, features: { ...starter.features, emailSignIn: false, appleSignIn: false } };
35
+ expect(() => defineStarter(none)).toThrow(/nobody can sign in/);
36
+ });
37
+
38
+ it("builds for iOS only when email sign-in is off (Apple's button shows only on iOS)", () => {
39
+ expect(nativePlatforms({ emailSignIn: true })).toEqual(["ios", "android"]);
40
+ expect(nativePlatforms({ emailSignIn: false })).toEqual(["ios"]);
41
+ expect(nativePlatforms({ emailSignIn: false, googleSignIn: true })).toEqual(["ios", "android"]);
42
+ });
43
+
44
+ it("ships Google sign-in off, and refuses it without Apple (Guideline 4.8)", () => {
45
+ expect(starter.features.googleSignIn).toBe(false);
46
+ const googleOnly: StarterConfig = { ...starter, features: { ...starter.features, appleSignIn: false, googleSignIn: true } };
47
+ expect(() => defineStarter(googleOnly)).toThrow(/Guideline 4.8/);
48
+ expect(() => defineStarter({ ...starter, features: { ...starter.features, googleSignIn: true } })).not.toThrow();
49
+ });
50
+
51
+ it("declares in the privacy manifest only the blocks that are on", () => {
52
+ expect(privacyBlocks(starter.features)).toEqual(["account", "observability", "push", "support"]);
53
+ expect(privacyBlocks({ observability: false, push: false, support: false })).toEqual(["account"]);
54
+ });
55
+
56
+ it("leaves the Apple nonce to the package default (32 random bytes), not a UUID", () => {
57
+ const auth = read("src/lib/auth.ts");
58
+ expect(auth).not.toMatch(/randomUUID/);
59
+ expect(auth).not.toMatch(/randomNonce/);
60
+ });
61
+
62
+ it("refuses a scheme written as a URL", () => {
63
+ expect(() => defineStarter({ ...starter, app: { ...starter.app, scheme: "myapp://" } })).toThrow(/app\.scheme/);
64
+ });
65
+
66
+ it("refuses an EAS project id that isn't a UUID", () => {
67
+ expect(() => defineStarter({ ...starter, app: { ...starter.app, easProjectId: "my-project" } })).toThrow(/easProjectId/);
68
+ expect(() => defineStarter({ ...starter, app: { ...starter.app, easProjectId: "" } })).not.toThrow();
69
+ });
70
+
71
+ it("ships with the updates block on and no EAS project (a placeholder for `eas init`)", () => {
72
+ expect(starter.features.updates).toBe(true);
73
+ expect(starter.app.easProjectId).toBe("");
74
+ });
75
+ });
76
+
77
+ describe("EAS config", () => {
78
+ it("turns expo-updates off in builds until there is an EAS project", () => {
79
+ expect(easConfig({ easProjectId: "" })).toEqual({ updates: { enabled: false } });
80
+ });
81
+
82
+ it("points updates at the project and links it", () => {
83
+ const id = "0b5a2c7e-1d3f-4a6b-9c8d-7e6f5a4b3c2d";
84
+ expect(easConfig({ easProjectId: id })).toEqual({
85
+ updates: { enabled: true, url: `https://u.expo.dev/${id}` },
86
+ extra: { eas: { projectId: id } },
87
+ });
88
+ });
89
+ });
90
+
91
+ describe("fingerprint", () => {
92
+ // app.config.ts imports starter.config.ts and define-starter.ts, so the fingerprint would hash
93
+ // them as files and a JavaScript-only switch (updates, queryPersistence…) would change the
94
+ // runtime version: installed builds would stop getting updates. .fingerprintignore leaves them
95
+ // out; what they mean for the native build is in the evaluated config, which is hashed.
96
+ it("leaves the files app.config.ts imports out, and app.config.ts imports nothing else", () => {
97
+ const ignored = read(".fingerprintignore").split("\n").filter((l) => l && !l.startsWith("#"));
98
+ expect(ignored).toEqual(["starter.config.ts", "src/lib/define-starter.ts"]);
99
+ const imports = [...read("app.config.ts").matchAll(/^import .*from "(.+)";$/gm)].map((m) => m[1]);
100
+ expect(imports).toEqual(["expo/config", "./starter.config", "./src/lib/define-starter"]);
101
+ });
102
+
103
+ it("app.config.ts reads no JavaScript-only switch", () => {
104
+ expect(read("app.config.ts")).not.toMatch(/features\.(updates|queryPersistence|queryLifecycle|keyboardScroll|deepLinks|notifications|accountDeletion|wipeSessionOnReinstall|refreshWhileActive|observability|devtools)/);
105
+ });
106
+ });
107
+
108
+ describe("devtools overlay", () => {
109
+ // Metro folds `__DEV__` and `process.env.EXPO_PUBLIC_*` at build time and drops the dead branch
110
+ // before it collects dependencies, so the overlay is in a bundle only behind this condition.
111
+ it("is imported only from devtools-overlay.ts, which only devtools.ts requires, behind the build-time condition", () => {
112
+ const importers = filesUnder("src").filter((f) => /\.tsx?$/.test(f) && /from "@marktiderman\/genesis-native\/devtools"/.test(read(f)));
113
+ // devtools.ts imports a type only, which the compiler erases.
114
+ expect(importers.sort()).toEqual([join("src", "lib", "devtools-overlay.ts"), join("src", "lib", "devtools.ts")]);
115
+ expect(read("src/lib/devtools.ts")).toMatch(/^import type \{ DevtoolsBlock \} from "@marktiderman\/genesis-native\/devtools";$/m);
116
+ const requirers = filesUnder("src").filter((f) => /devtools-overlay/.test(read(f)) && !f.endsWith("devtools-overlay.ts"));
117
+ expect(requirers).toEqual([join("src", "lib", "devtools.ts")]);
118
+ const gate = read("src/lib/devtools.ts");
119
+ expect(gate).toContain(
120
+ '__DEV__ || process.env.EXPO_PUBLIC_APP_VARIANT === "development" || process.env.EXPO_PUBLIC_APP_VARIANT === "preview"\n ? starter.features.devtools',
121
+ );
122
+ expect(gate).not.toMatch(/^import .*devtools-overlay/m);
123
+ });
124
+
125
+ it("every EAS build profile sets EXPO_PUBLIC_APP_VARIANT to its APP_VARIANT", () => {
126
+ const eas = JSON.parse(read("eas.json")) as { build: Record<string, { env?: Record<string, string> }> };
127
+ for (const [name, profile] of Object.entries(eas.build)) {
128
+ if (profile.env?.APP_VARIANT) expect(profile.env.EXPO_PUBLIC_APP_VARIANT, name).toBe(profile.env.APP_VARIANT);
129
+ }
130
+ });
131
+ });
132
+
133
+ describe("copy catalog", () => {
134
+ it("has no empty strings", () => {
135
+ const empty: string[] = [];
136
+ const walk = (node: unknown, path: string) => {
137
+ if (typeof node === "string") {
138
+ if (!node.trim()) empty.push(path);
139
+ } else for (const [key, value] of Object.entries(node as object)) walk(value, path ? `${path}.${key}` : key);
140
+ };
141
+ walk(copy, "");
142
+ expect(empty).toEqual([]);
143
+ });
144
+
145
+ it("fills placeholders and leaves unknown ones", () => {
146
+ expect(format("Sent to {email} {other}", { email: "a@b.c" })).toBe("Sent to a@b.c {other}");
147
+ });
148
+
149
+ // Every user-facing string comes from src/copy.ts, so a translation covers the whole app.
150
+ it("is the only source of user-facing text in src", () => {
151
+ const files = filesUnder("src").filter((f) => /\.tsx?$/.test(f) && f !== join("src", "copy.ts"));
152
+ const offenders = files.flatMap((file) => findInlineCopy(read(file), file));
153
+ expect(offenders).toEqual([]);
154
+ });
155
+
156
+ it("the check finds inline copy and ignores code that only looks like it", () => {
157
+ const flagged = findInlineCopy(
158
+ [
159
+ "const a = <Text>Signed in as {email}</Text>;",
160
+ 'const b = <Text>{"Hello"}</Text>;',
161
+ "const c = <Text>{`Hi ${name}`}</Text>;",
162
+ 'const d = <Screen title="Hi" subtitle={"There"} />;',
163
+ 'Alert.alert("Oops", "It broke");',
164
+ 'const e = { text: "Cancel", label: `Ünïcode` };',
165
+ 'const f = <Text>3 items</Text>; const u = "https://x"; const g = <Text>Hi</Text>;',
166
+ ].join("\n"),
167
+ "probe.tsx",
168
+ );
169
+ expect(flagged.map((h) => h.slice(h.indexOf(": ") + 2))).toEqual([
170
+ "Signed in as",
171
+ '{"Hello"}',
172
+ "{`Hi ${name}`}",
173
+ 'title="Hi"',
174
+ 'subtitle={"There"}',
175
+ '"Oops"',
176
+ '"It broke"',
177
+ 'text: "Cancel"',
178
+ "label: `Ünïcode`",
179
+ "3 items",
180
+ "Hi",
181
+ ]);
182
+ const clean = findInlineCopy(
183
+ [
184
+ "const a = x > y && z < w;",
185
+ "const b = () => useSession<Session>();",
186
+ "const c: Promise<Item[]> = load();",
187
+ 'const d = <Redirect href="/sign-in" />;',
188
+ 'const e = <Tab name="(home)" testID="home" md="home" variant="ghost" />;',
189
+ "const f = <Text>{copy.home.title}</Text>;",
190
+ "Alert.alert(t.title, t.body, [{ text: t.cancel }]);",
191
+ '// <Text>a comment</Text> and a "quoted" word',
192
+ ].join("\n"),
193
+ "probe.tsx",
194
+ );
195
+ expect(clean).toEqual([]);
196
+ });
197
+ });
198
+
199
+ describe("supabase/migrations", () => {
200
+ it("carries @marktiderman/genesis-supabase's account-deletion migration unchanged", () => {
201
+ const shipped = shippedSql("0001_genesis_account_deletion.sql");
202
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_account_deletion.sql"));
203
+ expect(copies).toHaveLength(1);
204
+ expect(read(copies[0]!)).toBe(shipped);
205
+ });
206
+
207
+ it("carries its pgTAP test unchanged", () => {
208
+ const shipped = shippedSql("tests/0001_genesis_account_deletion.test.sql");
209
+ expect(read("supabase/tests/database/genesis_account_deletion.test.sql")).toBe(shipped);
210
+ });
211
+
212
+ it("carries the app-release-policy migration unchanged (the updates block reads it)", () => {
213
+ const shipped = shippedSql("0002_genesis_app_release_policy.sql");
214
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_app_release_policy.sql"));
215
+ expect(copies).toHaveLength(1);
216
+ expect(read(copies[0]!)).toBe(shipped);
217
+ });
218
+
219
+ it("carries its pgTAP test unchanged", () => {
220
+ const shipped = shippedSql("tests/0002_genesis_app_release_policy.test.sql");
221
+ expect(read("supabase/tests/database/genesis_app_release_policy.test.sql")).toBe(shipped);
222
+ });
223
+
224
+ it("applies account deletion before the release policy", () => {
225
+ const order = filesUnder("supabase/migrations").sort();
226
+ expect(order.findIndex((f) => f.endsWith("_genesis_account_deletion.sql"))).toBeLessThan(order.findIndex((f) => f.endsWith("_genesis_app_release_policy.sql")));
227
+ });
228
+
229
+ it("carries the Apple token revocation migration and its pgTAP test unchanged", () => {
230
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_apple_token_revocation.sql"));
231
+ expect(copies).toHaveLength(1);
232
+ expect(read(copies[0]!)).toBe(shippedSql("0003_genesis_apple_token_revocation.sql"));
233
+ expect(read("supabase/tests/database/genesis_apple_token_revocation.test.sql")).toBe(shippedSql("tests/0003_genesis_apple_token_revocation.test.sql"));
234
+ });
235
+
236
+ it("carries the push migration and its pgTAP test unchanged (the push block reads it), after the Apple one", () => {
237
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_push.sql"));
238
+ expect(copies).toHaveLength(1);
239
+ expect(read(copies[0]!)).toBe(shippedSql("0005_genesis_push.sql"));
240
+ expect(read("supabase/tests/database/genesis_push.test.sql")).toBe(shippedSql("tests/0005_genesis_push.test.sql"));
241
+ const order = filesUnder("supabase/migrations").sort();
242
+ expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_apple_token_revocation.sql")));
243
+ });
244
+
245
+ it("carries the support migration and its pgTAP test unchanged (the support block reads it), after the push one", () => {
246
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_support.sql"));
247
+ expect(copies).toHaveLength(1);
248
+ expect(read(copies[0]!)).toBe(shippedSql("0006_genesis_support.sql"));
249
+ expect(read("supabase/tests/database/genesis_support.test.sql")).toBe(shippedSql("tests/0006_genesis_support.test.sql"));
250
+ const order = filesUnder("supabase/migrations").sort();
251
+ expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_push.sql")));
252
+ });
253
+ });
254
+
255
+ describe("supabase/functions", () => {
256
+ it("carries @marktiderman/genesis-supabase's genesis-apple-revoke function unchanged", () => {
257
+ const shipped = join(supabasePackage, "functions", "genesis-apple-revoke");
258
+ const names = readdirSync(shipped).sort();
259
+ expect(names).toEqual(["apple.ts", "handler.ts", "index.ts"]);
260
+ expect(readdirSync(join(root, "supabase/functions/genesis-apple-revoke")).sort()).toEqual(names);
261
+ for (const name of names) {
262
+ expect(read(`supabase/functions/genesis-apple-revoke/${name}`), name).toBe(readFileSync(join(shipped, name), "utf8"));
263
+ }
264
+ });
265
+
266
+ it("deploys it without the gateway's JWT check (the function checks the caller itself)", () => {
267
+ expect(read("supabase/config.toml")).toMatch(/\[functions\.genesis-apple-revoke\]\s*\nverify_jwt = false/);
268
+ });
269
+
270
+ it("carries the genesis-push-send function unchanged, deployed without the gateway's JWT check (it checks GENESIS_PUSH_SECRET)", () => {
271
+ const shipped = join(supabasePackage, "functions", "genesis-push-send");
272
+ const names = readdirSync(shipped).sort();
273
+ expect(names).toEqual(["expo.ts", "handler.ts", "index.ts"]);
274
+ expect(readdirSync(join(root, "supabase/functions/genesis-push-send")).sort()).toEqual(names);
275
+ for (const name of names) {
276
+ expect(read(`supabase/functions/genesis-push-send/${name}`), name).toBe(readFileSync(join(shipped, name), "utf8"));
277
+ }
278
+ expect(read("supabase/config.toml")).toMatch(/\[functions\.genesis-push-send\]\s*\nverify_jwt = false/);
279
+ });
280
+ });
281
+
282
+ describe("push", () => {
283
+ it("ships with the push block on, behind the one `push` switch", () => {
284
+ expect(starter.features.push).toBe(true);
285
+ expect(read("src/lib/app.ts")).toContain("features.push ? createStarterPush() : undefined");
286
+ });
287
+
288
+ it("keeps expo-notifications in the build whichever way the switch is, so turning push off is JavaScript only", () => {
289
+ expect(read("app.config.ts")).toMatch(/plugins: \[[^\]]*"expo-notifications"/);
290
+ expect(read("app.config.ts")).not.toContain("features.push");
291
+ });
292
+
293
+ it("asks for permission only through the soft prompt, never from the root layout", () => {
294
+ expect(read("src/app/_layout.tsx")).not.toMatch(/requestPermissions|offer\(/);
295
+ const asking = filesUnder("src").filter((f) => /requestPermissionsAsync/.test(read(f)));
296
+ expect(asking).toEqual([]);
297
+ });
298
+ });
299
+
300
+ describe("support", () => {
301
+ it("ships with the support block on, behind the one `support` switch, needing a signed-in person", () => {
302
+ expect(starter.features.support).toBe(true);
303
+ expect(read("src/lib/app.ts")).toMatch(/blocks: \[[^\]]*\bsupport\b/);
304
+ expect(read("src/lib/support.ts")).toContain("starter.features.support ? createStarterSupport() : undefined");
305
+ expect(read("src/lib/app.ts")).toContain('appFeatures: ["account"]');
306
+ });
307
+
308
+ it("has a route file for every route the block declares, each sending you back to Settings when support is off", () => {
309
+ const routes = ["index", "new", "[id]", "ideas", "shipped"].map((name) => join("src/app/(app)/settings/support", `${name}.tsx`));
310
+ for (const route of routes) expect(read(route), route).toContain("if (!starter.features.support");
311
+ expect(read("src/lib/support.ts")).toContain('supportBasePath = "/settings/support"');
312
+ });
313
+
314
+ it("keeps view-shot and expo-sensors in the build whichever way the switch is, so turning support off is JavaScript only", () => {
315
+ expect(read("app.config.ts")).not.toContain("features.support");
316
+ const pkg = JSON.parse(read("package.json")) as { dependencies: Record<string, string> };
317
+ expect(Object.keys(pkg.dependencies)).toEqual(expect.arrayContaining(["react-native-view-shot", "expo-sensors", "@marktiderman/genesis-support"]));
318
+ });
319
+ });