create-disposabl-app 0.5.0 → 0.6.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 (87) hide show
  1. package/README.md +12 -0
  2. package/dist/disposabl.js +541 -0
  3. package/dist/index.js +91 -8
  4. package/dist/templates/default/.github/scripts/android-build.sh +18 -0
  5. package/dist/templates/default/.github/scripts/disposabl.mjs +95 -0
  6. package/dist/templates/default/.github/scripts/expo-channel.sh +10 -0
  7. package/dist/templates/default/.github/scripts/expo-env.sh +17 -0
  8. package/dist/templates/default/.github/scripts/expo-fingerprint.sh +19 -0
  9. package/dist/templates/default/.github/scripts/expo-update.sh +11 -0
  10. package/dist/templates/default/.github/scripts/package-release.sh +23 -0
  11. package/dist/templates/default/.github/scripts/platforms.sh +37 -0
  12. package/dist/templates/default/.github/scripts/release-publish.sh +28 -0
  13. package/dist/templates/default/.github/scripts/release-source.sh +14 -0
  14. package/dist/templates/default/.github/scripts/verify-artifacts.sh +13 -0
  15. package/dist/templates/default/.github/scripts/web-deploy.sh +10 -0
  16. package/dist/templates/default/.github/workflows/pipeline.yml +299 -0
  17. package/dist/templates/default/apps/mobile/AGENTS.md +2 -2
  18. package/dist/templates/default/apps/mobile/README.md +4 -3
  19. package/dist/templates/default/apps/mobile/app.json +3 -4
  20. package/dist/templates/default/apps/mobile/assets/images/android-icon-foreground.png +0 -0
  21. package/dist/templates/default/apps/mobile/assets/images/android-icon-monochrome.png +0 -0
  22. package/dist/templates/default/apps/mobile/assets/images/icon.png +0 -0
  23. package/dist/templates/default/apps/mobile/assets/images/splash-icon.png +0 -0
  24. package/dist/templates/default/apps/mobile/eas.json +5 -0
  25. package/dist/templates/default/apps/mobile/package.json +5 -4
  26. package/dist/templates/default/apps/web/package.json +1 -1
  27. package/dist/templates/default/apps/web/src/routeTree.gen.ts +0 -44
  28. package/dist/templates/default/apps/web/src/router/__root.tsx +1 -1
  29. package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +0 -1
  30. package/dist/templates/default/apps/web/src/router/index.tsx +11 -3
  31. package/dist/templates/default/bun.lock +19 -5
  32. package/dist/templates/default/bunfig.toml +0 -2
  33. package/dist/templates/default/package.json +3 -3
  34. package/dist/templates/default/packages/backend/AGENTS.md +15 -13
  35. package/dist/templates/default/packages/backend/README.md +6 -28
  36. package/dist/templates/default/packages/backend/convex/_generated/ai/ai-files.state.json +1 -1
  37. package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +32 -6
  38. package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +8 -0
  39. package/dist/templates/default/packages/backend/convex/apps/actions/create.ts +19 -0
  40. package/dist/templates/default/packages/backend/convex/apps/internal.ts +197 -0
  41. package/dist/templates/default/packages/backend/convex/auth.ts +1 -1
  42. package/dist/templates/default/packages/backend/convex/convex.config.ts +8 -0
  43. package/dist/templates/default/packages/backend/convex/github/actions/http.ts +40 -0
  44. package/dist/templates/default/packages/backend/convex/github/actions/internal.ts +189 -0
  45. package/dist/templates/default/packages/backend/convex/github/actions/oidc.ts +75 -0
  46. package/dist/templates/default/packages/backend/convex/github/actions/provision.ts +80 -0
  47. package/dist/templates/default/packages/backend/convex/github/actions/tokens.ts +66 -0
  48. package/dist/templates/default/packages/backend/convex/github/internal.ts +34 -0
  49. package/dist/templates/default/packages/backend/convex/http.ts +3 -0
  50. package/dist/templates/default/packages/backend/convex/previews/internal.ts +270 -0
  51. package/dist/templates/default/packages/backend/convex/previews/token/actions/create.ts +69 -0
  52. package/dist/templates/default/packages/backend/convex/previews/token/actions/management.ts +133 -0
  53. package/dist/templates/default/packages/backend/convex/previews/token/internal.ts +1 -0
  54. package/dist/templates/default/packages/backend/convex/releases/internal.ts +28 -0
  55. package/dist/templates/default/packages/backend/convex/schema.ts +34 -4
  56. package/dist/templates/default/packages/backend/convex/users/index.ts +21 -0
  57. package/dist/templates/default/packages/backend/convex/users/internal.ts +44 -0
  58. package/dist/templates/default/packages/backend/convex/validator.ts +87 -0
  59. package/dist/templates/default/packages/backend/generate.ts +6 -1
  60. package/dist/templates/default/packages/backend/generated/openapi.json +961 -43
  61. package/dist/templates/default/packages/backend/generated/pages.json +0 -8
  62. package/dist/templates/default/packages/backend/generated/platforms.ts +14 -2
  63. package/dist/templates/default/packages/backend/package.json +1 -1
  64. package/dist/templates/default/packages/cli/README.md +15 -9
  65. package/dist/templates/default/packages/cli/auth.ts +11 -3
  66. package/dist/templates/default/packages/cli/commands.ts +236 -0
  67. package/dist/templates/default/packages/cli/index.ts +2 -142
  68. package/dist/templates/default/packages/cli/preview.ts +157 -0
  69. package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +2 -1
  70. package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +35 -1
  71. package/dist/templates/default/packages/disposabl-kit/mobile/lib/logo.png +0 -0
  72. package/dist/templates/default/packages/disposabl-kit/mobile/screens/account.tsx +1 -1
  73. package/dist/templates/default/packages/disposabl-kit/mobile/screens/home.tsx +20 -5
  74. package/dist/templates/default/packages/sdk/README.md +8 -4
  75. package/dist/templates/default/packages/sdk/src/config.ts +14 -7
  76. package/dist/templates/default/packages/sdk/src/generated/index.ts +48 -13
  77. package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +139 -27
  78. package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +440 -37
  79. package/package.json +6 -3
  80. package/dist/templates/default/.github/README.md +0 -99
  81. package/dist/templates/default/.github/actionlint.yaml +0 -6
  82. package/dist/templates/default/.github/workflows/pipeline.yml.example +0 -546
  83. package/dist/templates/default/apps/web/src/router/_authenticated/todos/$id.tsx +0 -27
  84. package/dist/templates/default/apps/web/src/router/_authenticated/todos/index.tsx +0 -33
  85. package/dist/templates/default/packages/backend/convex/todos/index.ts +0 -26
  86. package/dist/templates/default/packages/backend/convex/todos/internal.ts +0 -43
  87. package/dist/templates/default/packages/backend/convex/users.ts +0 -43
@@ -1,546 +0,0 @@
1
- name: Pipeline
2
- on:
3
- pull_request:
4
- branches: [main]
5
- push:
6
- branches: [main]
7
- permissions:
8
- contents: read
9
- pull-requests: read
10
- concurrency:
11
- group: preview-${{ github.head_ref || github.ref_name }}
12
- cancel-in-progress: ${{ github.event_name == 'pull_request' }}
13
- env:
14
- CHANNEL: &channel ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}
15
- DISPOSABL_MOBILE_CHANNEL: *channel
16
- EAS_ENVIRONMENT: ${{ github.event_name == 'push' && 'production' || 'preview' }}
17
- EAS_CLI: eas-cli@27.2.0
18
- BUN_VERSION: &bun-version '1.4.4'
19
- NODE_VERSION: &node-version '24'
20
- LINUX_RUNNER: &linux-runner blacksmith-4vcpu-ubuntu-2404
21
- WEB_RUNNER: &web-runner blacksmith-2vcpu-ubuntu-2404
22
- WINDOWS_RUNNER: &windows-runner blacksmith-2vcpu-windows-2025
23
- MACOS_RUNNER: &macos-runner blacksmith-6vcpu-macos-26
24
- MACOS_BUNDLE_ID: dev.disposabl.starter.desktop
25
- RELEASE_PREFIX: app
26
- DISPOSABL_ANDROID_VERSION_CODE: ${{ github.run_number }}
27
- DISPOSABL_IOS_BUILD_NUMBER: ${{ github.run_number }}
28
- GH_TOKEN: ${{ github.token }}
29
- GH_REPO: ${{ github.repository }}
30
- SOURCE: ${{ github.event.pull_request.head.sha || github.sha }}
31
- SOURCE_PATH: ${{ github.event_name == 'pull_request' && format('pulls/{0}', github.event.number) || 'git/ref/heads/main' }}
32
- DISPOSABL_RELEASE_VERSION: 1.0.${{ github.run_number }}
33
-
34
- jobs:
35
- web:
36
- name: Web
37
- permissions: &release-permissions
38
- contents: write
39
- pull-requests: read
40
- timeout-minutes: 45
41
- runs-on: *web-runner
42
- outputs:
43
- android_build: ${{ steps.fingerprint.outputs.build }}
44
- android_runtime: ${{ steps.fingerprint.outputs.runtime }}
45
- android_manifest: ${{ steps.fingerprint.outputs.manifest }}
46
- ios_build: ${{ steps.ios.outputs.build }}
47
- ios_manifest: ${{ steps.ios.outputs.manifest }}
48
- convex_url: ${{ steps.deploy.outputs.CONVEX_URL }}
49
- convex_site_url: ${{ steps.deploy.outputs.CONVEX_SITE_URL }}
50
- env:
51
- PLATFORM: android
52
- EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
53
- EXPO_PROJECT_ID: ${{ vars.EXPO_PROJECT_ID }}
54
- EXPO_OWNER: ${{ vars.EXPO_OWNER }}
55
- EXPO_SLUG: ${{ vars.EXPO_SLUG }}
56
- EXPO_NO_DOTENV: '1'
57
- steps:
58
- - &checkout
59
- name: Checkout
60
- uses: actions/checkout@v6
61
- with: {ref: "${{ env.SOURCE }}", persist-credentials: false}
62
- - &platforms
63
- name: Platforms
64
- shell: bash
65
- id: platforms
66
- env:
67
- BEFORE: ${{ github.event.before }}
68
- PR: ${{ github.event.number }}
69
- TRUSTED: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
70
- run: |
71
- if [[ "$GITHUB_JOB" == android || "$GITHUB_JOB" == ios ]]; then exit; fi
72
- if [[ "$TRUSTED" != true ]]; then printf 'android=false\nios=false\ndesktop=[]\nselected=false\n' >> "$GITHUB_OUTPUT"; exit; fi
73
- if [[ -n "$PR" ]]; then
74
- gh api "repos/$GH_REPO/pulls/$PR/files?per_page=100" --paginate --jq '.[] | .filename, (.previous_filename // empty)' > "$RUNNER_TEMP/changes"
75
- elif [[ -z "$BEFORE" || "$BEFORE" =~ ^0+$ ]]; then echo disposabl.json > "$RUNNER_TEMP/changes"
76
- else
77
- git -c credential.helper= -c 'credential.helper=!gh auth git-credential' fetch --depth=1 origin "$BEFORE"
78
- git diff --name-only --no-renames "$BEFORE" "$SOURCE" > "$RUNNER_TEMP/changes"
79
- fi
80
- node --input-type=module -e '
81
- import {readFileSync} from "node:fs";
82
- import {execFileSync} from "node:child_process";
83
- const relevant = p => p && !/(^|\/)\.agents\/|\.(md|mdx)$/.test(p);
84
- const paths = readFileSync(`${process.env.RUNNER_TEMP}/changes`, "utf8").split(/\r?\n/).filter(relevant);
85
- const enabled = JSON.parse(readFileSync("disposabl.json", "utf8")).platforms;
86
- const api = path => JSON.parse(execFileSync("gh", ["api", `repos/${process.env.GH_REPO}/${path}`], {encoding: "utf8", stdio: ["ignore", "pipe", "ignore"]}));
87
- const changes = platform => {
88
- if (!process.env.PR) return paths;
89
- try {
90
- const release = api(`releases/tags/${process.env.RELEASE_PREFIX}-${process.env.CHANNEL}-${platform}`);
91
- const base = /^Source: ([a-f0-9]{40})$/m.exec(release.body || "")?.[1];
92
- if (release.draft || !base) return paths;
93
- if (base === process.env.SOURCE) return [];
94
- const diff = api(`compare/${base}...${process.env.SOURCE}`);
95
- // GitHub caps comparison files at 300; never skip on a truncated result.
96
- return !["ahead", "identical"].includes(diff.status) || !Array.isArray(diff.files) || diff.files.length >= 300 ? ["disposabl.json"] : diff.files.flatMap(f => [f.filename, f.previous_filename]).filter(relevant);
97
- } catch { return paths; }
98
- };
99
- const affected = (platform, directory) => enabled.includes(platform) && changes(platform).some(p => p.startsWith(directory) || /^(bun.lock$|package.json$|disposabl.json$|turbo.json$|bunfig.toml$|patches\/|\.github\/workflows\/pipeline.yml$|packages\/(?!backend\/|create-disposabl-app\/))/.test(p));
100
- const target = process.env.DISPOSABL_DESKTOP_PLATFORM;
101
- for (const platform of ["android", "ios"]) console.log(`${platform}=${!target && affected(platform, "apps/mobile/")}`);
102
- const desktop = ["linux", "windows", "macos"].filter(platform => target === platform && affected(platform, "apps/desktop/"));
103
- console.log(`desktop=${JSON.stringify(desktop)}\nselected=${desktop.includes(process.env.DISPOSABL_DESKTOP_PLATFORM)}`);
104
- ' >> "$GITHUB_OUTPUT"
105
- - &node
106
- name: Node
107
- if: github.job != 'desktop' || steps.platforms.outputs.selected == 'true'
108
- uses: actions/setup-node@v6
109
- with: {node-version: *node-version, package-manager-cache: false}
110
- - &bun
111
- name: Bun
112
- if: github.job != 'desktop' || steps.platforms.outputs.selected == 'true'
113
- uses: oven-sh/setup-bun@v2
114
- with: {bun-version: *bun-version}
115
- - &cache
116
- name: Cache
117
- if: github.job != 'desktop' || steps.platforms.outputs.selected == 'true'
118
- uses: actions/cache@v4
119
- with:
120
- path: ~/.bun/install/cache
121
- key: bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-${{ hashFiles('bun.lock') }}
122
- restore-keys: bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-
123
- - &install
124
- name: Install
125
- if: github.job != 'desktop' || steps.platforms.outputs.selected == 'true'
126
- run: bun install --frozen-lockfile ${{ github.job == 'desktop' && '--filter desktop' || (github.job == 'ios' || github.job == 'android') && '--filter @disposabl/mobile' || '' }}
127
- - name: Check
128
- run: bun run check
129
- - name: Build selected clients
130
- run: |
131
- for package in cli sdk; do
132
- if test -f "packages/$package/package.json"; then bun run --cwd "packages/$package" build; fi
133
- done
134
- - name: Deploy
135
- id: deploy
136
- env:
137
- TRUSTED: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
138
- CONVEX_DEPLOY_KEY: ${{ secrets[github.event_name == 'push' && 'CONVEX_DEPLOY_KEY' || 'CONVEX_DEPLOY_KEY_PREVIEW'] }}
139
- run: |
140
- if [[ "$TRUSTED" != true ]]; then VITE_CONVEX_URL=https://ci.invalid VITE_CONVEX_SITE_URL=https://ci.invalid bun run build --filter=@disposabl/web; exit; fi
141
- : "${CONVEX_DEPLOY_KEY:?Configure the Convex deployment secret for this repository}"
142
- cd packages/backend
143
- export AUTH_TARGET=--prod
144
- target=()
145
- if [[ "$CHANNEL" != production ]]; then export AUTH_TARGET="--preview-name $CHANNEL"; target=(--preview-name "$CHANNEL"); fi
146
- bun x --no-install convex deploy --yes "${target[@]}" --cmd-url-env-var-name CONVEX_URL --cmd 'for name in CONVEX_URL CONVEX_SITE_URL; do value=$(printenv "$name"); test -n "$value" || exit 1; for prefix in "" VITE_ EXPO_PUBLIC_; do export "$prefix$name=$value"; printf "%s=%s\n" "$prefix$name" "$value" | tee -a "$GITHUB_ENV" >> "$GITHUB_OUTPUT"; done; done; bun x --no-install --package @convex-dev/auth auth --keys-only $AUTH_TARGET && bun run --cwd ../.. build --filter=@disposabl/web'
147
- bun x --no-install static-hosting upload $AUTH_TARGET --no-spa --dist ../../apps/web/dist/client
148
- - &expo
149
- name: Expo
150
- if: github.job == 'ios' || github.job == 'android' || steps.platforms.outputs.android == 'true' || steps.platforms.outputs.ios == 'true'
151
- working-directory: apps/mobile
152
- run: |
153
- jq --arg channel "$CHANNEL" '.build["ios-" + env.EAS_ENVIRONMENT].channel = $channel' eas.json > "$RUNNER_TEMP/eas.json"
154
- mv "$RUNNER_TEMP/eas.json" eas.json
155
- bun x "$EAS_CLI" env:pull --environment "$EAS_ENVIRONMENT" --path "$RUNNER_TEMP/expo.env" --non-interactive
156
- bun -e '
157
- import {parseEnv} from "node:util";
158
- import {appendFileSync, readFileSync} from "node:fs";
159
- for (const [key, value] of Object.entries(parseEnv(readFileSync(`${process.env.RUNNER_TEMP}/expo.env`, "utf8")))) {
160
- // Web and mobile use the same backend from this deployment.
161
- if (/^CONVEX_(URL|SITE_URL)$/.test(key) && value !== process.env[key]) throw new Error(`EAS overrides the deployed backend: ${key}`);
162
- if (/^(EXPO_PUBLIC_|VITE_)?CONVEX_(URL|SITE_URL)$/.test(key)) continue;
163
- if (/^(GITHUB_|RUNNER_|GH_|DISPOSABL_|BUN_|CI$|NODE_OPTIONS$|PATH$|HOME$|SOURCE(_PATH)?$|CHANNEL$|PLATFORM$|RELEASE_PREFIX$|MACOS_|EAS_(ENVIRONMENT|CLI)$|EXPO_(TOKEN|PROJECT_ID|OWNER|SLUG|NO_DOTENV)$)/.test(key)) throw new Error(`Reserved EAS variable: ${key}`);
164
- const delimiter = crypto.randomUUID();
165
- appendFileSync(process.env.GITHUB_ENV, `${key}<<${delimiter}\n${value}\n${delimiter}\n`);
166
- }
167
- '
168
- - name: Channel
169
- if: steps.platforms.outputs.android == 'true' || steps.platforms.outputs.ios == 'true'
170
- working-directory: apps/mobile
171
- run: |
172
- for ((offset=0; ; offset+=25)); do
173
- bun x "$EAS_CLI" channel:list --json --limit 25 --offset "$offset" > "$RUNNER_TEMP/channels.json"
174
- if jq -e --arg channel "$CHANNEL" 'any(.currentPage[]; .name == $channel)' "$RUNNER_TEMP/channels.json" > /dev/null; then
175
- jq -e --arg channel "$CHANNEL" '.currentPage[] | select(.name == $channel) | (.isPaused == false) and (.updateBranches | length == 1) and (.updateBranches[0].name == $channel) and ((.branchMapping | fromjson).data == [{branchId: .updateBranches[0].id, branchMappingLogic: "true"}])' "$RUNNER_TEMP/channels.json" > /dev/null || { echo 'Preview channel must point only to its same-named branch'; exit 1; }
176
- break
177
- fi
178
- if [[ $(jq '.currentPage | length' "$RUNNER_TEMP/channels.json") -lt 25 ]]; then bun x "$EAS_CLI" channel:create "$CHANNEL" --non-interactive; break; fi
179
- done
180
- - name: Fingerprint
181
- id: fingerprint
182
- if: steps.platforms.outputs.android == 'true'
183
- working-directory: apps/mobile
184
- run: |
185
- for ((page=1; ; page++)); do
186
- gh api "repos/$GH_REPO/releases?per_page=100&page=$page" > "$RUNNER_TEMP/releases.json"
187
- jq --arg tag "$RELEASE_PREFIX-$CHANNEL-android" --arg legacy "$RELEASE_PREFIX-$CHANNEL" '[.[] | select(.draft | not) | select(.tag_name == $tag or .tag_name == $legacy or (.tag_name | startswith($legacy + "-"))) | select(any(.assets[]; .name == "android.apk"))] | sort_by(.tag_name != $tag, .tag_name != $legacy) | .[0] // {}' "$RUNNER_TEMP/releases.json" > "$RUNNER_TEMP/release.json"
188
- if jq -e '.id' "$RUNNER_TEMP/release.json" > /dev/null || [[ $(jq length "$RUNNER_TEMP/releases.json") -lt 100 ]]; then break; fi
189
- done
190
- bun x --no-install expo config --json > "$RUNNER_TEMP/mobile.json"
191
- RUNTIME=$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er 'select(.fingerprintSources != null) | .runtimeVersion | select(test("^[a-f0-9]{40,64}$"))')
192
- export RUNTIME
193
- bun -e '
194
- const config = await Bun.file(`${process.env.RUNNER_TEMP}/mobile.json`).json();
195
- if (!config.extra?.eas?.projectId) throw new Error("Link an Expo project first");
196
- const wanted = {channel: process.env.CHANNEL, projectId: config.extra.eas.projectId, applicationId: config.android.package, runtimeVersion: process.env.RUNTIME};
197
- const release = await Bun.file(`${process.env.RUNNER_TEMP}/release.json`).json();
198
- const prior = JSON.parse(/<!-- android (\{[^\n]+\}) -->/.exec(release.body || "")?.[1] || "null");
199
- const reusable = prior && Object.keys(wanted).every(k => prior[k] === wanted[k]) && /^[a-f0-9]{64}$/.test(prior.sha256 || "") && release.assets.some(a => a.name === "android.apk" && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${prior.sha256}`);
200
- console.log(`build=${!reusable}\nruntime=${wanted.runtimeVersion}\nmanifest=${JSON.stringify(wanted)}\ntag=${reusable ? release.tag_name : ""}\nsha=${reusable ? prior.sha256 : ""}`);
201
- ' >> "$GITHUB_OUTPUT"
202
- - name: Update
203
- if: steps.fingerprint.outputs.build == 'false'
204
- env:
205
- TAG: ${{ steps.fingerprint.outputs.tag }}
206
- SHA: ${{ steps.fingerprint.outputs.sha }}
207
- RUNTIME: ${{ steps.fingerprint.outputs.runtime }}
208
- MANIFEST: ${{ steps.fingerprint.outputs.manifest }}
209
- run: |
210
- mkdir -p dist/release
211
- gh release download "$TAG" --pattern android.apk --dir dist/release
212
- echo "$SHA dist/release/android.apk" | sha256sum --check
213
- cd apps/mobile
214
- bun x --no-install expo export --platform android --output-dir dist/update
215
- test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
216
- test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end')" = "$SOURCE"
217
- bun x "$EAS_CLI" update --platform android --channel "$CHANNEL" --environment "$EAS_ENVIRONMENT" --skip-bundler --input-dir dist/update --message "$SOURCE" --non-interactive
218
- jq --arg sha "$SHA" '. + {sha256: $sha, action: "update"}' <<< "$MANIFEST" > ../../dist/release/android.json
219
- - name: iOS
220
- id: ios
221
- if: steps.platforms.outputs.ios == 'true'
222
- working-directory: apps/mobile
223
- run: |
224
- runtime() { bun x --no-install expo-updates runtimeversion:resolve --platform ios --workflow managed | jq -er '.runtimeVersion | select(test("^[a-f0-9]{40,64}$"))'; }
225
- fingerprint=$(runtime)
226
- bun x --no-install expo config --json > "$RUNNER_TEMP/ios-config.json"
227
- gh api "repos/$GH_REPO/releases?per_page=100" --paginate --slurp | jq --arg tag "$RELEASE_PREFIX-$CHANNEL-ios" 'add | map(select(.draft | not) | select(.tag_name == $tag or (.tag_name | startswith($tag + "-")))) | .[0] // {}' > "$RUNNER_TEMP/ios-release.json"
228
- RUNTIME="$fingerprint" bun -e '
229
- const config = await Bun.file(`${process.env.RUNNER_TEMP}/ios-config.json`).json();
230
- const wanted = {channel: process.env.CHANNEL, projectId: config.extra.eas.projectId, applicationId: config.ios.bundleIdentifier, runtimeVersion: process.env.RUNTIME};
231
- const release = await Bun.file(`${process.env.RUNNER_TEMP}/ios-release.json`).json();
232
- const prior = JSON.parse(/<!-- ios (\{[^\n]+\}) -->/.exec(release.body || "")?.[1] || "null");
233
- const reusable = prior && Object.keys(wanted).every(k => prior[k] === wanted[k]) && Date.parse(prior.expiresAt) > Date.now() && /^[a-f0-9]{64}$/.test(prior.sha256 || "") && release.assets.some(a => a.name === "ios.ipa" && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${prior.sha256}`);
234
- await Bun.write(`${process.env.RUNNER_TEMP}/ios-build`, String(!reusable));
235
- console.log(`build=${!reusable}\nmanifest=${JSON.stringify(wanted)}`);
236
- ' >> "$GITHUB_OUTPUT"
237
- if [[ $(cat "$RUNNER_TEMP/ios-build") == true ]]; then echo "iOS needs a new signed IPA; the iOS job will build it." >> "$GITHUB_STEP_SUMMARY"; exit 0; fi
238
- bun x --no-install expo export --platform ios --output-dir dist/update-ios
239
- test "$(runtime)" = "$fingerprint"
240
- test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end')" = "$SOURCE"
241
- bun x "$EAS_CLI" update --platform ios --channel "$CHANNEL" --environment "$EAS_ENVIRONMENT" --skip-bundler --input-dir dist/update-ios --message "$SOURCE" --non-interactive
242
- if [[ "$CHANNEL" != production ]]; then
243
- test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq .head.sha)" = "$SOURCE"
244
- tag=$(jq -r .tag_name "$RUNNER_TEMP/ios-release.json")
245
- jq -r --arg source "$SOURCE" '.body | sub("(?m)^Source: [a-f0-9]+"; "Source: " + $source)' "$RUNNER_TEMP/ios-release.json" > "$RUNNER_TEMP/ios-notes.md"
246
- gh api --method PATCH "repos/$GH_REPO/git/refs/tags/$tag" -f sha="$SOURCE" -F force=true > /dev/null
247
- gh release edit "$tag" --notes-file "$RUNNER_TEMP/ios-notes.md"
248
- fi
249
- echo "iOS update published to $CHANNEL." >> "$GITHUB_STEP_SUMMARY"
250
- - &publish
251
- name: Publish
252
- if: github.job == 'ios' || github.job == 'android' || (github.job == 'web' && hashFiles('dist/release/android.json') != '') || steps.platforms.outputs.selected == 'true'
253
- shell: bash
254
- run: |
255
- check_source() { test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end')" = "$SOURCE"; }
256
- check_source
257
- for file in dist/release/*; do test -f "$file"; test -s "$file"; done
258
- case "$PLATFORM" in
259
- android) test -s dist/release/android.apk; test -s dist/release/android.json ;;
260
- ios) test -s dist/release/ios.ipa; test -s dist/release/ios.json ;;
261
- linux) compgen -G 'dist/release/*.deb' > /dev/null; compgen -G 'dist/release/*.rpm' > /dev/null ;;
262
- windows) compgen -G 'dist/release/*.exe' > /dev/null; compgen -G 'dist/release/*.nupkg' > /dev/null; test -s dist/release/RELEASES ;;
263
- macos) compgen -G 'dist/release/*.dmg' > /dev/null ;;
264
- *) exit 1 ;;
265
- esac
266
- TAG="$RELEASE_PREFIX-$CHANNEL-$PLATFORM"
267
- if [[ '${{ github.event_name }}' == push ]]; then TAG+="-${{ github.run_id }}-${{ github.run_attempt }}"; fi
268
- printf "Platform: %s\nSource: %s\n" "$PLATFORM" "$SOURCE" > notes.md
269
- if [[ -f dist/release/macos.txt ]]; then cat dist/release/macos.txt >> notes.md; fi
270
- if [[ -f dist/release/android.json ]]; then echo "<!-- android $(jq -c . dist/release/android.json) -->" >> notes.md; fi
271
- if [[ -f dist/release/ios.json ]]; then echo "<!-- ios $(jq -c . dist/release/ios.json) -->" >> notes.md; fi
272
- if gh release view "$TAG" --json assets > previous.json; then
273
- check_source
274
- gh release upload "$TAG" dist/release/* --clobber
275
- while IFS= read -r asset; do
276
- asset=${asset%$'\r'}
277
- if [[ ! -f "dist/release/$asset" ]]; then check_source; gh release delete-asset "$TAG" "$asset" --yes; fi
278
- done < <(jq -r '.assets[].name' previous.json)
279
- check_source
280
- if [[ '${{ github.event_name }}' == pull_request ]]; then gh api --method PATCH "repos/$GH_REPO/git/refs/tags/$TAG" -f sha="$SOURCE" -F force=true > /dev/null; fi
281
- else
282
- gh release create "$TAG" dist/release/* --draft --target "$SOURCE" --title "$CHANNEL / $PLATFORM" --notes-file notes.md --prerelease=${{ github.event_name == 'pull_request' }}
283
- fi
284
- check_source
285
- gh release edit "$TAG" --title "$CHANNEL / $PLATFORM" --notes-file notes.md --draft=false --prerelease=${{ github.event_name == 'pull_request' }} --latest=false
286
- echo "Release: https://github.com/$GH_REPO/releases/tag/$TAG" >> "$GITHUB_STEP_SUMMARY"
287
-
288
- android:
289
- name: Android
290
- needs: web
291
- if: needs.web.outputs.android_build == 'true'
292
- permissions: *release-permissions
293
- runs-on: *linux-runner
294
- timeout-minutes: 60
295
- env:
296
- PLATFORM: android
297
- EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
298
- EXPO_PROJECT_ID: ${{ vars.EXPO_PROJECT_ID }}
299
- EXPO_OWNER: ${{ vars.EXPO_OWNER }}
300
- EXPO_SLUG: ${{ vars.EXPO_SLUG }}
301
- EXPO_NO_DOTENV: '1'
302
- CONVEX_URL: ${{ needs.web.outputs.convex_url }}
303
- CONVEX_SITE_URL: ${{ needs.web.outputs.convex_site_url }}
304
- EXPO_PUBLIC_CONVEX_URL: ${{ needs.web.outputs.convex_url }}
305
- EXPO_PUBLIC_CONVEX_SITE_URL: ${{ needs.web.outputs.convex_site_url }}
306
- steps:
307
- - *checkout
308
- - *platforms
309
- - *node
310
- - *bun
311
- - *cache
312
- - *install
313
- - *expo
314
- - name: Java
315
- uses: actions/setup-java@v5
316
- with: {distribution: temurin, java-version: '17'}
317
- - name: SDK
318
- uses: android-actions/setup-android@v3
319
- with: {packages: platform-tools}
320
- - name: Gradle
321
- uses: gradle/actions/setup-gradle@v4
322
- with: {cache-read-only: false}
323
- - name: Build
324
- working-directory: apps/mobile
325
- env:
326
- RUNTIME: ${{ needs.web.outputs.android_runtime }}
327
- DISPOSABL_ANDROID_CHANNEL: *channel
328
- MANIFEST: ${{ needs.web.outputs.android_manifest }}
329
- ANDROID_KEYSTORE_BASE64: ${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_BASE64 || '' }}
330
- ANDROID_KEYSTORE_PASSWORD: ${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_PASSWORD || '' }}
331
- ANDROID_KEY_ALIAS: ${{ github.event_name == 'push' && secrets.ANDROID_KEY_ALIAS || '' }}
332
- ANDROID_KEY_PASSWORD: ${{ github.event_name == 'push' && secrets.ANDROID_KEY_PASSWORD || '' }}
333
- run: |
334
- test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end')" = "$SOURCE"
335
- if [[ "$CHANNEL" == production ]]; then
336
- : "${ANDROID_KEYSTORE_BASE64:?}" "${ANDROID_KEYSTORE_PASSWORD:?}" "${ANDROID_KEY_ALIAS:?}" "${ANDROID_KEY_PASSWORD:?}"
337
- export ANDROID_KEYSTORE_PATH="$RUNNER_TEMP/android-release.jks"
338
- trap 'rm -f "$ANDROID_KEYSTORE_PATH"' EXIT
339
- (umask 077; printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_PATH")
340
- fi
341
- bun x --no-install expo prebuild --platform android --no-install
342
- test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
343
- (cd android && ./gradlew :app:assembleRelease --no-daemon --build-cache)
344
- apk=android/app/build/outputs/apk/release/app-release.apk
345
- test "$(unzip -p "$apk" assets/fingerprint)" = "$RUNTIME"
346
- test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
347
- mkdir -p ../../dist/release
348
- cp "$apk" ../../dist/release/android.apk
349
- jq --arg sha "$(sha256sum "$apk" | cut -d' ' -f1)" '. + {sha256: $sha, action: "build"}' <<< "$MANIFEST" > ../../dist/release/android.json
350
- - *publish
351
-
352
- ios:
353
- name: iOS
354
- needs: web
355
- if: needs.web.outputs.ios_build == 'true'
356
- permissions: *release-permissions
357
- runs-on: *macos-runner
358
- timeout-minutes: 60
359
- env:
360
- PLATFORM: ios
361
- EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
362
- EXPO_PROJECT_ID: ${{ vars.EXPO_PROJECT_ID }}
363
- EXPO_OWNER: ${{ vars.EXPO_OWNER }}
364
- EXPO_SLUG: ${{ vars.EXPO_SLUG }}
365
- EXPO_NO_DOTENV: '1'
366
- CONVEX_URL: ${{ needs.web.outputs.convex_url }}
367
- CONVEX_SITE_URL: ${{ needs.web.outputs.convex_site_url }}
368
- EXPO_PUBLIC_CONVEX_URL: ${{ needs.web.outputs.convex_url }}
369
- EXPO_PUBLIC_CONVEX_SITE_URL: ${{ needs.web.outputs.convex_site_url }}
370
- MANIFEST: ${{ needs.web.outputs.ios_manifest }}
371
- steps:
372
- - *checkout
373
- - *platforms
374
- - *node
375
- - *bun
376
- - *cache
377
- - *install
378
- - *expo
379
- - name: Pods
380
- uses: actions/cache@v4
381
- with:
382
- path: ~/Library/Caches/CocoaPods
383
- key: pods-${{ runner.arch }}-${{ hashFiles('bun.lock') }}
384
- restore-keys: pods-${{ runner.arch }}-
385
- - name: Build
386
- working-directory: apps/mobile
387
- run: |
388
- test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end')" = "$SOURCE"
389
- mkdir -p ../../dist/release
390
- bun x "$EAS_CLI" build --platform ios --profile "ios-$EAS_ENVIRONMENT" --local --non-interactive --output ../../dist/release/ios.ipa
391
- - name: Verify
392
- run: |
393
- unzip -q dist/release/ios.ipa -d "$RUNNER_TEMP/ipa"
394
- apps=("$RUNNER_TEMP/ipa/Payload/"*.app)
395
- test "${#apps[@]}" -eq 1
396
- app=${apps[0]}
397
- codesign --verify --deep --strict "$app"
398
- test "$(plutil -extract CFBundleIdentifier raw -o - "$app/Info.plist")" = "$(jq -r .applicationId <<< "$MANIFEST")"
399
- runtime=$(plutil -extract EXUpdatesRuntimeVersion raw -o - "$app/Expo.plist")
400
- if [[ "$runtime" == "file:fingerprint" ]]; then
401
- fingerprints=()
402
- while IFS= read -r path; do fingerprints+=("$path"); done < <(find "$app" -path '*/EXUpdates.bundle/fingerprint' -type f)
403
- if [[ ${#fingerprints[@]} -ne 1 ]]; then
404
- echo "Expected one EXUpdates.bundle/fingerprint, found ${#fingerprints[@]}" >&2
405
- exit 1
406
- fi
407
- runtime=$(cat "${fingerprints[0]}")
408
- fi
409
- expected_runtime=$(jq -r .runtimeVersion <<< "$MANIFEST")
410
- if [[ "$runtime" != "$expected_runtime" ]]; then
411
- echo "iOS runtime version mismatch: expected $expected_runtime, found $runtime" >&2
412
- exit 1
413
- fi
414
- test "$(plutil -extract EXUpdatesRequestHeaders.expo-channel-name raw -o - "$app/Expo.plist")" = "$CHANNEL"
415
- security cms -D -i "$app/embedded.mobileprovision" > "$RUNNER_TEMP/profile.plist"
416
- expires=$(python3 -c 'import datetime,plistlib,sys; p=plistlib.load(open(sys.argv[1],"rb")); expiry=p["ExpirationDate"].replace(tzinfo=datetime.timezone.utc); assert p.get("ProvisionedDevices") and not p["Entitlements"].get("get-task-allow",False) and expiry>datetime.datetime.now(datetime.timezone.utc); print(expiry.isoformat())' "$RUNNER_TEMP/profile.plist")
417
- jq --arg sha "$(shasum -a 256 dist/release/ios.ipa | cut -d' ' -f1)" --arg expires "$expires" '. + {sha256: $sha, expiresAt: $expires}' <<< "$MANIFEST" > dist/release/ios.json
418
- - *publish
419
-
420
- desktop:
421
- permissions: *release-permissions
422
- name: ${{ matrix.platform }}
423
- if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
424
- strategy:
425
- fail-fast: false
426
- matrix:
427
- include:
428
- - {platform: linux, runner: *linux-runner}
429
- - {platform: windows, runner: *windows-runner}
430
- - {platform: macos, runner: *macos-runner}
431
- runs-on: ${{ matrix.runner }}
432
- timeout-minutes: 30
433
- env:
434
- PLATFORM: ${{ matrix.platform }}
435
- DISPOSABL_DESKTOP_PLATFORM: ${{ matrix.platform }}
436
- MACOS_NOTARIZE: ${{ secrets.MACOS_CERTIFICATES_P12_PRODUCTION != '' && secrets.MACOS_CERTIFICATES_PASSWORD_PRODUCTION != '' && secrets.MACOS_APPLE_API_KEY_P8_PRODUCTION != '' && secrets.MACOS_APPLE_API_KEY_ID_PRODUCTION != '' && secrets.MACOS_APPLE_API_ISSUER_PRODUCTION != '' }}
437
- electron_config_cache: ${{ github.workspace }}/.cache/electron
438
- steps:
439
- - *checkout
440
- - *platforms
441
- - *node
442
- - *bun
443
- - *cache
444
- - *install
445
- - name: Electron
446
- if: steps.platforms.outputs.selected == 'true'
447
- uses: actions/cache@v4
448
- with:
449
- path: .cache/electron
450
- key: electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('bun.lock') }}
451
- - name: Packages
452
- if: steps.platforms.outputs.selected == 'true' && matrix.platform == 'linux'
453
- run: command -v fakeroot && command -v rpmbuild && command -v dpkg-deb || { sudo apt-get update && sudo apt-get install -y fakeroot dpkg rpm; }
454
- # Apple credentials are optional for both previews and production.
455
- - name: Sign
456
- if: steps.platforms.outputs.selected == 'true' && matrix.platform == 'macos' && env.MACOS_NOTARIZE == 'true'
457
- uses: apple-actions/import-codesign-certs@v7.2.0
458
- with:
459
- p12-file-base64: ${{ secrets.MACOS_CERTIFICATES_P12_PRODUCTION }}
460
- p12-password: ${{ secrets.MACOS_CERTIFICATES_PASSWORD_PRODUCTION }}
461
- - name: Notary
462
- if: steps.platforms.outputs.selected == 'true' && matrix.platform == 'macos' && env.MACOS_NOTARIZE == 'true'
463
- env:
464
- API_KEY_P8: ${{ secrets.MACOS_APPLE_API_KEY_P8_PRODUCTION }}
465
- API_KEY_ID: ${{ secrets.MACOS_APPLE_API_KEY_ID_PRODUCTION }}
466
- API_ISSUER: ${{ secrets.MACOS_APPLE_API_ISSUER_PRODUCTION }}
467
- run: |
468
- : "${API_KEY_P8:?Configure MACOS_APPLE_API_KEY_P8_PRODUCTION}" "${API_KEY_ID:?Configure MACOS_APPLE_API_KEY_ID_PRODUCTION}" "${API_ISSUER:?Configure MACOS_APPLE_API_ISSUER_PRODUCTION}"
469
- umask 077
470
- printf '%s' "$API_KEY_P8" > "$RUNNER_TEMP/notary.p8"
471
- printf 'APPLE_API_KEY=%s\nAPPLE_API_KEY_ID=%s\nAPPLE_API_ISSUER=%s\n' "$RUNNER_TEMP/notary.p8" "$API_KEY_ID" "$API_ISSUER" >> "$GITHUB_ENV"
472
- - name: Build
473
- if: steps.platforms.outputs.selected == 'true'
474
- run: bun run --cwd apps/desktop preview
475
- - name: Verify
476
- if: steps.platforms.outputs.selected == 'true' && matrix.platform == 'macos'
477
- run: |
478
- images=(dist/release/*.dmg)
479
- test "${#images[@]}" -eq 1 && test -s "${images[0]}"
480
- mkdir -p "$RUNNER_TEMP/macos-verify"
481
- hdiutil attach "${images[0]}" -readonly -nobrowse -mountpoint "$RUNNER_TEMP/macos-verify"
482
- trap 'hdiutil detach "$RUNNER_TEMP/macos-verify"' EXIT
483
- apps=("$RUNNER_TEMP/macos-verify/"*.app)
484
- test "${#apps[@]}" -eq 1 && test -d "${apps[0]}"
485
- codesign --verify --deep --strict "${apps[0]}"
486
- if [[ "$MACOS_NOTARIZE" == true ]]; then
487
- spctl --assess --type execute --verbose "${apps[0]}"
488
- xcrun stapler validate "${apps[0]}"
489
- echo 'macOS: Apple Silicon, Developer ID signed and notarized.' > dist/release/macos.txt
490
- else
491
- echo 'macOS: Apple Silicon, ad hoc signed and NOT notarized. If blocked, use System Settings > Privacy & Security > Open Anyway. https://support.apple.com/102445' > dist/release/macos.txt
492
- fi
493
- cat dist/release/macos.txt >> "$GITHUB_STEP_SUMMARY"
494
- - *publish
495
- - name: Clean
496
- if: always() && matrix.platform == 'macos'
497
- run: rm -f "$RUNNER_TEMP/notary.p8"
498
-
499
- packages:
500
- name: Package / ${{ matrix.package }}
501
- needs: web
502
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
503
- runs-on: ubuntu-latest
504
- permissions:
505
- contents: write
506
- id-token: write
507
- concurrency:
508
- group: npm-${{ matrix.package }}
509
- cancel-in-progress: false
510
- queue: max
511
- strategy:
512
- fail-fast: false
513
- matrix:
514
- package: [cli, sdk]
515
- steps:
516
- - uses: actions/checkout@v6
517
- with:
518
- fetch-depth: 0
519
- persist-credentials: false
520
- - name: Selected package
521
- id: selected
522
- run: echo "exists=$(test -f packages/${{ matrix.package }}/package.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
523
- - uses: actions/setup-node@v6
524
- if: steps.selected.outputs.exists == 'true'
525
- with:
526
- node-version: '24'
527
- package-manager-cache: false
528
- - uses: oven-sh/setup-bun@v2
529
- if: steps.selected.outputs.exists == 'true'
530
- with:
531
- bun-version: '1.4.4'
532
- - name: Install and generate
533
- if: steps.selected.outputs.exists == 'true'
534
- run: |
535
- bun install --frozen-lockfile
536
- bun run generate
537
- - name: Validate package
538
- if: steps.selected.outputs.exists == 'true'
539
- run: bun run --cwd packages/${{ matrix.package }} typecheck
540
- - name: Publish
541
- if: steps.selected.outputs.exists == 'true'
542
- working-directory: packages/${{ matrix.package }}
543
- run: bun run release
544
- env:
545
- GITHUB_TOKEN: ${{ github.token }}
546
- npm_config_workspaces_update: 'false'
@@ -1,27 +0,0 @@
1
- import { createFileRoute, Link } from "@tanstack/react-router";
2
- import { useQuery } from "convex/react";
3
- import { api } from "../../../../../../packages/backend/convex/_generated/api";
4
- import type { Id } from "../../../../../../packages/backend/convex/_generated/dataModel";
5
-
6
- export const Route = createFileRoute("/_providers/_authenticated/todos/$id")({
7
- component: Todo,
8
- errorComponent: () => <p role="alert">Unable to load todo.</p>,
9
- });
10
-
11
- export function Todo() {
12
- const { id } = Route.useParams();
13
- const todo = useQuery(api.todos.index.get, { id: id as Id<"todos"> });
14
-
15
- return (
16
- <main>
17
- <Link to="/todos">Todos</Link>
18
- {todo === undefined ? (
19
- <p>Loading todo…</p>
20
- ) : todo === null ? (
21
- <p>Todo not found.</p>
22
- ) : (
23
- <h1>{todo.title}</h1>
24
- )}
25
- </main>
26
- );
27
- }
@@ -1,33 +0,0 @@
1
- import { createFileRoute, Link } from "@tanstack/react-router";
2
- import { useQuery } from "convex/react";
3
- import { api } from "../../../../../../packages/backend/convex/_generated/api";
4
-
5
- export const Route = createFileRoute("/_providers/_authenticated/todos/")({
6
- component: Todos,
7
- errorComponent: () => <p role="alert">Unable to load todos.</p>,
8
- });
9
-
10
- export function Todos() {
11
- const todos = useQuery(api.todos.index.list, {});
12
-
13
- return (
14
- <main>
15
- <h1>Todos</h1>
16
- {todos === undefined ? (
17
- <p>Loading todos…</p>
18
- ) : todos.length === 0 ? (
19
- <p>No todos yet.</p>
20
- ) : (
21
- <ul>
22
- {todos.map((todo) => (
23
- <li key={todo._id}>
24
- <Link to="/todos/$id" params={{ id: todo._id }}>
25
- {todo.title}
26
- </Link>
27
- </li>
28
- ))}
29
- </ul>
30
- )}
31
- </main>
32
- );
33
- }
@@ -1,26 +0,0 @@
1
- import { getAuthUserId } from "@convex-dev/auth/server";
2
- import { ConvexError, v } from "convex/values";
3
- import { internal } from "../_generated/api";
4
- import type { Doc } from "../_generated/dataModel";
5
- import { query } from "../_generated/server";
6
- import schema from "../schema";
7
-
8
- export const list = query({
9
- args: {},
10
- returns: v.array(schema.doc("todos")),
11
- handler: async (ctx): Promise<Doc<"todos">[]> => {
12
- const userId = await getAuthUserId(ctx);
13
- if (!userId) throw new ConvexError("Not signed in");
14
- return await ctx.runQuery(internal.todos.internal.list, { userId });
15
- },
16
- });
17
-
18
- export const get = query({
19
- args: { id: v.id("todos") },
20
- returns: v.union(schema.doc("todos"), v.null()),
21
- handler: async (ctx, { id }): Promise<Doc<"todos"> | null> => {
22
- const userId = await getAuthUserId(ctx);
23
- if (!userId) throw new ConvexError("Not signed in");
24
- return await ctx.runQuery(internal.todos.internal.get, { userId, id });
25
- },
26
- });