anhedral 0.13.0 → 0.16.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 (360) hide show
  1. package/README.md +23 -229
  2. package/assets/patches/audit-deps.mjs +12 -2
  3. package/assets/stack/ai-schema.ts.txt +5 -0
  4. package/assets/stack/ai.ts.txt +30 -0
  5. package/assets/stack/api-index.ts.txt +15 -0
  6. package/assets/stack/auth-features.ts.txt +4 -0
  7. package/assets/stack/auth-journal.json.txt +13 -0
  8. package/assets/stack/auth-migration.sql.txt +53 -0
  9. package/assets/stack/auth-routes.ts.txt +11 -0
  10. package/assets/stack/auth-schema.ts.txt +64 -0
  11. package/assets/stack/auth-snapshot.json.txt +346 -0
  12. package/assets/stack/auth.ts.txt +32 -0
  13. package/assets/stack/billing-mode.ts.txt +8 -0
  14. package/assets/stack/billing-schema.ts.txt +11 -0
  15. package/assets/stack/desktop.rs.txt +21 -0
  16. package/assets/stack/entitlement-guard.ts.txt +32 -0
  17. package/assets/stack/entitlements.ts.txt +8 -0
  18. package/assets/stack/events-schema.ts.txt +12 -0
  19. package/assets/stack/events.ts.txt +59 -0
  20. package/assets/stack/mobile-auth.ts.txt +25 -0
  21. package/assets/stack/mobile-billing.tsx.txt +63 -0
  22. package/assets/stack/mobile-session.tsx.txt +83 -0
  23. package/assets/stack/native-button.tsx.txt +108 -0
  24. package/assets/stack/native-global.css.txt +4 -0
  25. package/assets/stack/native-lib-utils.ts.txt +5 -0
  26. package/assets/stack/native-metro.config.js.txt +6 -0
  27. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  28. package/assets/stack/native-tailwind.config.js.txt +73 -0
  29. package/assets/stack/native-text.tsx.txt +89 -0
  30. package/assets/stack/purchases.ts.txt +65 -0
  31. package/assets/stack/revenuecat.ts.txt +88 -0
  32. package/assets/stack/rtc-schema.ts.txt +10 -0
  33. package/assets/stack/rtc.ts.txt +122 -0
  34. package/assets/stack/security.ts.txt +31 -0
  35. package/assets/stack/storage.ts.txt +36 -0
  36. package/assets/stack/stripe.ts.txt +126 -0
  37. package/assets/stack/web-sign-in.tsx.txt +51 -0
  38. package/assets/ui/LICENSE.react-native-reusables +21 -0
  39. package/assets/ui/LICENSE.shadcn +21 -0
  40. package/assets/ui/UPSTREAM.json +39 -0
  41. package/assets/ui/catalog.json +891 -0
  42. package/assets/ui/extensions/registry.json +6 -0
  43. package/assets/ui/native/_controls.tsx +521 -0
  44. package/assets/ui/native/_core.tsx +118 -0
  45. package/assets/ui/native/_data.tsx +200 -0
  46. package/assets/ui/native/_display.tsx +453 -0
  47. package/assets/ui/native/_feedback.tsx +242 -0
  48. package/assets/ui/native/_legacy-dialog.tsx +38 -0
  49. package/assets/ui/native/_motion.tsx +520 -0
  50. package/assets/ui/native/_overlay.tsx +402 -0
  51. package/assets/ui/native/_selection.tsx +366 -0
  52. package/assets/ui/native/accordion.tsx +1 -0
  53. package/assets/ui/native/alert-dialog.tsx +11 -0
  54. package/assets/ui/native/alert.tsx +1 -0
  55. package/assets/ui/native/aspect-ratio.tsx +1 -0
  56. package/assets/ui/native/attachment.tsx +8 -0
  57. package/assets/ui/native/avatar.tsx +8 -0
  58. package/assets/ui/native/badge.tsx +1 -0
  59. package/assets/ui/native/breadcrumb.tsx +9 -0
  60. package/assets/ui/native/bubble.tsx +1 -0
  61. package/assets/ui/native/button-group.tsx +1 -0
  62. package/assets/ui/native/button.tsx +86 -0
  63. package/assets/ui/native/calendar.tsx +170 -0
  64. package/assets/ui/native/card.tsx +44 -0
  65. package/assets/ui/native/carousel.tsx +1 -0
  66. package/assets/ui/native/chart.tsx +193 -0
  67. package/assets/ui/native/checkbox.tsx +1 -0
  68. package/assets/ui/native/code-block.tsx +137 -0
  69. package/assets/ui/native/collapsible.tsx +1 -0
  70. package/assets/ui/native/combobox.tsx +1 -0
  71. package/assets/ui/native/command.tsx +11 -0
  72. package/assets/ui/native/context-menu.tsx +16 -0
  73. package/assets/ui/native/data-table.tsx +1 -0
  74. package/assets/ui/native/date-picker.tsx +43 -0
  75. package/assets/ui/native/dialog.tsx +15 -0
  76. package/assets/ui/native/direction.tsx +1 -0
  77. package/assets/ui/native/drawer.tsx +10 -0
  78. package/assets/ui/native/dropdown-menu.tsx +16 -0
  79. package/assets/ui/native/empty.tsx +8 -0
  80. package/assets/ui/native/field.tsx +13 -0
  81. package/assets/ui/native/hover-card.tsx +1 -0
  82. package/assets/ui/native/input-group.tsx +8 -0
  83. package/assets/ui/native/input-otp.tsx +1 -0
  84. package/assets/ui/native/input.tsx +28 -0
  85. package/assets/ui/native/item.tsx +12 -0
  86. package/assets/ui/native/kbd.tsx +1 -0
  87. package/assets/ui/native/label.tsx +4 -0
  88. package/assets/ui/native/layout.tsx +26 -0
  89. package/assets/ui/native/marker.tsx +1 -0
  90. package/assets/ui/native/menubar.tsx +17 -0
  91. package/assets/ui/native/message-scroller.tsx +6 -0
  92. package/assets/ui/native/message.tsx +10 -0
  93. package/assets/ui/native/native-select.tsx +1 -0
  94. package/assets/ui/native/navigation-menu.tsx +10 -0
  95. package/assets/ui/native/pagination.tsx +9 -0
  96. package/assets/ui/native/popover.tsx +1 -0
  97. package/assets/ui/native/progress.tsx +1 -0
  98. package/assets/ui/native/questionnaire.tsx +130 -0
  99. package/assets/ui/native/radio-group.tsx +1 -0
  100. package/assets/ui/native/registry.json +1103 -0
  101. package/assets/ui/native/resizable.tsx +1 -0
  102. package/assets/ui/native/scroll-area.tsx +1 -0
  103. package/assets/ui/native/select.tsx +11 -0
  104. package/assets/ui/native/separator.tsx +1 -0
  105. package/assets/ui/native/sheet.tsx +10 -0
  106. package/assets/ui/native/sidebar.tsx +22 -0
  107. package/assets/ui/native/skeleton.tsx +1 -0
  108. package/assets/ui/native/slider.tsx +1 -0
  109. package/assets/ui/native/spinner.tsx +1 -0
  110. package/assets/ui/native/switch.tsx +1 -0
  111. package/assets/ui/native/table.tsx +10 -0
  112. package/assets/ui/native/tabs.tsx +1 -0
  113. package/assets/ui/native/text.tsx +20 -0
  114. package/assets/ui/native/textarea.tsx +1 -0
  115. package/assets/ui/native/theme-switcher.tsx +22 -0
  116. package/assets/ui/native/toast.tsx +11 -0
  117. package/assets/ui/native/toggle-group.tsx +1 -0
  118. package/assets/ui/native/toggle.tsx +1 -0
  119. package/assets/ui/native/tooltip.tsx +1 -0
  120. package/assets/ui/native/trace.tsx +20 -0
  121. package/assets/ui/native/typography.tsx +15 -0
  122. package/assets/ui/theme-storage.ts +25 -0
  123. package/assets/ui/theme.tsx +66 -0
  124. package/assets/ui/web/button.tsx +59 -0
  125. package/assets/ui/web/input.tsx +21 -0
  126. package/assets/ui/web/label.tsx +19 -0
  127. package/dist/bin.js +7 -12
  128. package/dist/capabilities.d.ts +4 -33
  129. package/dist/capabilities.js +2 -84
  130. package/dist/capability-catalog.d.ts +83 -0
  131. package/dist/capability-catalog.js +121 -0
  132. package/dist/capability-command.d.ts +3 -0
  133. package/dist/capability-command.js +188 -0
  134. package/dist/capability-editor.d.ts +17 -0
  135. package/dist/capability-editor.js +97 -0
  136. package/dist/capability-recipes.d.ts +4 -0
  137. package/dist/capability-recipes.js +520 -0
  138. package/dist/capability-references.d.ts +4 -0
  139. package/dist/capability-references.js +7 -0
  140. package/dist/cli-commands.d.ts +1 -2
  141. package/dist/cli-commands.js +10 -104
  142. package/dist/cli-output.d.ts +1 -2
  143. package/dist/cli-output.js +6 -251
  144. package/dist/command-schema.js +40 -374
  145. package/dist/dependencies.d.ts +34 -62
  146. package/dist/dependencies.js +112 -199
  147. package/dist/index.d.ts +1 -45
  148. package/dist/index.js +1 -30
  149. package/dist/platforms/mobile.js +29 -139
  150. package/dist/platforms/web.d.ts +3 -0
  151. package/dist/platforms/web.js +251 -0
  152. package/dist/project-config.d.ts +2 -13
  153. package/dist/project-config.js +10 -83
  154. package/dist/registry/context.js +0 -1
  155. package/dist/registry/options.js +6 -40
  156. package/dist/registry/resolve.d.ts +3 -4
  157. package/dist/registry/resolve.js +18 -108
  158. package/dist/registry/types.d.ts +1 -7
  159. package/dist/registry/usage.js +3 -9
  160. package/dist/runtime-policy.d.ts +0 -2
  161. package/dist/runtime-policy.js +0 -16
  162. package/dist/scaffold/backend.d.ts +0 -4
  163. package/dist/scaffold/backend.js +1 -189
  164. package/dist/scaffold/bootstrap.d.ts +2 -3
  165. package/dist/scaffold/bootstrap.js +37 -43
  166. package/dist/scaffold/compose.js +2 -14
  167. package/dist/scaffold/database.d.ts +1 -1
  168. package/dist/scaffold/database.js +19 -126
  169. package/dist/scaffold/documentation.d.ts +0 -1
  170. package/dist/scaffold/documentation.js +82 -84
  171. package/dist/scaffold/expo-runtime.d.ts +2 -2
  172. package/dist/scaffold/expo-runtime.js +9 -101
  173. package/dist/scaffold/native-ui.d.ts +2 -0
  174. package/dist/scaffold/native-ui.js +74 -0
  175. package/dist/scaffold/stack-documentation.d.ts +0 -1
  176. package/dist/scaffold/stack-documentation.js +3 -49
  177. package/dist/scaffold/storage.d.ts +2 -0
  178. package/dist/scaffold/storage.js +21 -0
  179. package/dist/scaffold/styling.d.ts +1 -1
  180. package/dist/scaffold/styling.js +20 -28
  181. package/dist/scaffold/workspace.js +63 -199
  182. package/dist/stack-registry.d.ts +2 -58
  183. package/dist/stack-registry.js +22 -446
  184. package/dist/standard.js +7 -24
  185. package/dist/ui-catalog.d.ts +26 -0
  186. package/dist/ui-catalog.js +31 -0
  187. package/dist/ui-command.d.ts +3 -0
  188. package/dist/ui-command.js +219 -0
  189. package/dist/ui-project.d.ts +22 -0
  190. package/dist/ui-project.js +110 -0
  191. package/dist/version.d.ts +1 -1
  192. package/dist/version.js +1 -1
  193. package/docs/anhedral-stack.md +4 -119
  194. package/docs/capabilities.md +110 -0
  195. package/docs/native-ui.md +102 -0
  196. package/docs/software-factory.md +16 -577
  197. package/docs/stack-standard.md +11 -307
  198. package/docs/ui.md +33 -0
  199. package/docs/verification.md +511 -0
  200. package/package.json +26 -27
  201. package/dist/access.d.ts +0 -10
  202. package/dist/access.js +0 -93
  203. package/dist/auth-schema-snapshot.d.ts +0 -346
  204. package/dist/auth-schema-snapshot.js +0 -347
  205. package/dist/auth-schema.d.ts +0 -1
  206. package/dist/auth-schema.js +0 -57
  207. package/dist/capability-contract.d.ts +0 -47
  208. package/dist/capability-contract.js +0 -168
  209. package/dist/catalog-model.d.ts +0 -24
  210. package/dist/catalog-model.js +0 -1
  211. package/dist/catalog-registration.d.ts +0 -16
  212. package/dist/catalog-registration.js +0 -22
  213. package/dist/catalog-snapshot.d.ts +0 -5
  214. package/dist/catalog-snapshot.js +0 -97
  215. package/dist/cli-delivery.d.ts +0 -3
  216. package/dist/cli-delivery.js +0 -172
  217. package/dist/cloudflare.d.ts +0 -25
  218. package/dist/cloudflare.js +0 -226
  219. package/dist/delivery-evidence.d.ts +0 -62
  220. package/dist/delivery-evidence.js +0 -186
  221. package/dist/delivery.d.ts +0 -88
  222. package/dist/delivery.js +0 -570
  223. package/dist/inspector-model.d.ts +0 -123
  224. package/dist/inspector-model.js +0 -1
  225. package/dist/integration-service-readers.d.ts +0 -13
  226. package/dist/integration-service-readers.js +0 -173
  227. package/dist/lifecycle-model.d.ts +0 -15
  228. package/dist/lifecycle-model.js +0 -20
  229. package/dist/lifecycle.d.ts +0 -11
  230. package/dist/lifecycle.js +0 -91
  231. package/dist/management.d.ts +0 -3
  232. package/dist/management.js +0 -47
  233. package/dist/mobile-delivery.d.ts +0 -77
  234. package/dist/mobile-delivery.js +0 -366
  235. package/dist/neon-service-data.d.ts +0 -8
  236. package/dist/neon-service-data.js +0 -117
  237. package/dist/platforms/desktop.d.ts +0 -2
  238. package/dist/platforms/desktop.js +0 -415
  239. package/dist/platforms/extension.d.ts +0 -2
  240. package/dist/platforms/extension.js +0 -328
  241. package/dist/project-catalog.d.ts +0 -41
  242. package/dist/project-catalog.js +0 -288
  243. package/dist/project-inspector.d.ts +0 -4
  244. package/dist/project-inspector.js +0 -702
  245. package/dist/project-lifecycle.d.ts +0 -25
  246. package/dist/project-lifecycle.js +0 -57
  247. package/dist/project-state.d.ts +0 -49
  248. package/dist/project-state.js +0 -563
  249. package/dist/provider-auth.d.ts +0 -41
  250. package/dist/provider-auth.js +0 -215
  251. package/dist/provider-readiness.d.ts +0 -30
  252. package/dist/provider-readiness.js +0 -104
  253. package/dist/providers/adapters.d.ts +0 -17
  254. package/dist/providers/adapters.js +0 -278
  255. package/dist/providers/api.d.ts +0 -29
  256. package/dist/providers/api.js +0 -253
  257. package/dist/providers/config.d.ts +0 -15
  258. package/dist/providers/config.js +0 -182
  259. package/dist/providers/definitions.d.ts +0 -318
  260. package/dist/providers/definitions.js +0 -127
  261. package/dist/providers/provision.d.ts +0 -24
  262. package/dist/providers/provision.js +0 -76
  263. package/dist/providers/receipts.d.ts +0 -20
  264. package/dist/providers/receipts.js +0 -66
  265. package/dist/providers/recovery-verification.d.ts +0 -7
  266. package/dist/providers/recovery-verification.js +0 -112
  267. package/dist/providers/recovery.d.ts +0 -30
  268. package/dist/providers/recovery.js +0 -34
  269. package/dist/providers/runtime.d.ts +0 -10
  270. package/dist/providers/runtime.js +0 -265
  271. package/dist/providers/schema.d.ts +0 -28
  272. package/dist/providers/schema.js +0 -49
  273. package/dist/providers/state.d.ts +0 -55
  274. package/dist/providers/state.js +0 -289
  275. package/dist/provision.d.ts +0 -55
  276. package/dist/provision.js +0 -284
  277. package/dist/r2-service-data.d.ts +0 -2
  278. package/dist/r2-service-data.js +0 -136
  279. package/dist/readiness.d.ts +0 -23
  280. package/dist/readiness.js +0 -122
  281. package/dist/registry/add.d.ts +0 -24
  282. package/dist/registry/add.js +0 -270
  283. package/dist/registry/bootstrap.d.ts +0 -2
  284. package/dist/registry/bootstrap.js +0 -14
  285. package/dist/registry/commands.d.ts +0 -3
  286. package/dist/registry/commands.js +0 -85
  287. package/dist/registry/presets.d.ts +0 -4
  288. package/dist/registry/presets.js +0 -41
  289. package/dist/registry/preview.d.ts +0 -11
  290. package/dist/registry/preview.js +0 -91
  291. package/dist/registry/receipt.d.ts +0 -3
  292. package/dist/registry/receipt.js +0 -68
  293. package/dist/repository.d.ts +0 -24
  294. package/dist/repository.js +0 -96
  295. package/dist/scaffold/auth.d.ts +0 -3
  296. package/dist/scaffold/auth.js +0 -151
  297. package/dist/scaffold/billing-config.d.ts +0 -1
  298. package/dist/scaffold/billing-config.js +0 -73
  299. package/dist/scaffold/billing-contracts.d.ts +0 -2
  300. package/dist/scaffold/billing-contracts.js +0 -48
  301. package/dist/scaffold/billing-providers.d.ts +0 -1
  302. package/dist/scaffold/billing-providers.js +0 -249
  303. package/dist/scaffold/billing-schema.d.ts +0 -1
  304. package/dist/scaffold/billing-schema.js +0 -34
  305. package/dist/scaffold/billing-security.d.ts +0 -1
  306. package/dist/scaffold/billing-security.js +0 -46
  307. package/dist/scaffold/billing-server.d.ts +0 -1
  308. package/dist/scaffold/billing-server.js +0 -139
  309. package/dist/scaffold/billing-store.d.ts +0 -1
  310. package/dist/scaffold/billing-store.js +0 -72
  311. package/dist/scaffold/billing.d.ts +0 -2
  312. package/dist/scaffold/billing.js +0 -216
  313. package/dist/scaffold/cloudflare-services.d.ts +0 -8
  314. package/dist/scaffold/cloudflare-services.js +0 -198
  315. package/dist/scaffold/expo-auth.d.ts +0 -3
  316. package/dist/scaffold/expo-auth.js +0 -192
  317. package/dist/scaffold/expo-billing.d.ts +0 -3
  318. package/dist/scaffold/expo-billing.js +0 -292
  319. package/dist/scaffold/integrations.d.ts +0 -4
  320. package/dist/scaffold/integrations.js +0 -12
  321. package/dist/scaffold/lint.d.ts +0 -4
  322. package/dist/scaffold/lint.js +0 -56
  323. package/dist/scaffold/neon-realtime.d.ts +0 -2
  324. package/dist/scaffold/neon-realtime.js +0 -97
  325. package/dist/scaffold/services.d.ts +0 -5
  326. package/dist/scaffold/services.js +0 -108
  327. package/dist/scaffold/stream.d.ts +0 -2
  328. package/dist/scaffold/stream.js +0 -114
  329. package/dist/scaffold/void.d.ts +0 -4
  330. package/dist/scaffold/void.js +0 -264
  331. package/dist/scaffold/web.d.ts +0 -2
  332. package/dist/scaffold/web.js +0 -130
  333. package/dist/service-deletion.d.ts +0 -29
  334. package/dist/service-deletion.js +0 -195
  335. package/dist/service-descriptor.d.ts +0 -10
  336. package/dist/service-descriptor.js +0 -78
  337. package/dist/service-model.d.ts +0 -49
  338. package/dist/service-model.js +0 -8
  339. package/dist/service-operations.d.ts +0 -29
  340. package/dist/service-operations.js +0 -78
  341. package/dist/service-readers.d.ts +0 -8
  342. package/dist/service-readers.js +0 -247
  343. package/dist/services-command.d.ts +0 -39
  344. package/dist/services-command.js +0 -102
  345. package/dist/ship.d.ts +0 -348
  346. package/dist/ship.js +0 -239
  347. package/dist/vercel-project.d.ts +0 -101
  348. package/dist/vercel-project.js +0 -305
  349. package/dist/vercel.d.ts +0 -67
  350. package/dist/vercel.js +0 -581
  351. package/dist/vinext.d.ts +0 -2
  352. package/dist/vinext.js +0 -86
  353. package/dist/void-execution.d.ts +0 -10
  354. package/dist/void-execution.js +0 -94
  355. package/dist/void-migrations.d.ts +0 -6
  356. package/dist/void-migrations.js +0 -110
  357. package/dist/void-state.d.ts +0 -16
  358. package/dist/void-state.js +0 -65
  359. package/dist/void.d.ts +0 -3
  360. package/dist/void.js +0 -5
@@ -1,85 +0,0 @@
1
- import { CAPABILITY_CONTRACT, formatCapabilityContract } from '../capability-contract.js';
2
- import { addStackItems } from './add.js';
3
- import { STACK_REGISTRY, STANDARD_PRODUCTS, getStackItem } from '../stack-registry.js';
4
- import { printResult } from '../cli-output.js';
5
- import { commandHelp } from './usage.js';
6
- import { CliArgumentError, suggest } from '../cli-arguments.js';
7
- export async function runRegistry(args, json, output = { json }) {
8
- const positional = args.filter((arg) => arg !== '--json');
9
- if (positional.includes('--help') || positional.includes('-h')) {
10
- console.log(commandHelp('registry'));
11
- return;
12
- }
13
- if (positional.some((arg) => arg.startsWith('-')))
14
- throw new Error('Unknown registry option.');
15
- const [action = 'list', name, ...extra] = positional;
16
- if (action === 'capabilities' && !name && !extra.length) {
17
- if (output.quiet && !json)
18
- return;
19
- console.log(json ? JSON.stringify(CAPABILITY_CONTRACT, null, 2) : formatCapabilityContract());
20
- return;
21
- }
22
- if (action === 'list' && !name && !extra.length) {
23
- if (output.quiet && !json)
24
- return;
25
- console.log(json
26
- ? JSON.stringify(STACK_REGISTRY, null, 2)
27
- : STACK_REGISTRY.items
28
- .map((item) => `${item.name} (${item.type}) — ${item.description}`)
29
- .join('\n'));
30
- return;
31
- }
32
- if (action === 'view' && name && !extra.length) {
33
- if (!STACK_REGISTRY.items.some((item) => item.name === name)) {
34
- const correction = suggest(name, STACK_REGISTRY.items.map((item) => item.name));
35
- throw new CliArgumentError(`Unknown bundled registry item.${correction ? ` Did you mean ${correction}?` : ''}`, 'Run anhedral registry list.');
36
- }
37
- printResult('registry', getStackItem(name), { ...output, json });
38
- return;
39
- }
40
- throw new Error('Use registry list, registry view <item>, or registry capabilities.');
41
- }
42
- export async function runAdd(args, output = {}) {
43
- if (args.includes('--help') || args.includes('-h')) {
44
- console.log(commandHelp('add'));
45
- return;
46
- }
47
- const positional = [];
48
- let preview;
49
- for (let index = 0; index < args.length; index++) {
50
- const arg = args[index];
51
- if (arg === '--diff' || arg === '--view') {
52
- if (preview)
53
- throw new Error('Select one source preview: --diff or --view.');
54
- preview = { mode: arg === '--diff' ? 'diff' : 'view' };
55
- const next = args[index + 1];
56
- if (next &&
57
- !next.startsWith('-') &&
58
- !STANDARD_PRODUCTS.includes(next)) {
59
- preview.path = next;
60
- index++;
61
- }
62
- continue;
63
- }
64
- if (['--dry-run', '--skip-install', '--json'].includes(arg))
65
- continue;
66
- if (arg.startsWith('-'))
67
- throw new Error(`Unknown add option: ${arg}.`);
68
- positional.push(arg);
69
- }
70
- const items = positional;
71
- if (!items.length)
72
- throw new Error('Select bundled parts: anhedral add <items...> [--cwd <directory>].');
73
- for (const item of items) {
74
- if (STANDARD_PRODUCTS.includes(item))
75
- continue;
76
- const correction = suggest(item, STANDARD_PRODUCTS);
77
- throw new CliArgumentError(`Unknown stack part.${correction ? ` Did you mean ${correction}?` : ''}`, 'Select a project with --cwd <directory> and run anhedral registry list for bundled parts.');
78
- }
79
- printResult('add', await addStackItems(process.cwd(), {
80
- items,
81
- dryRun: args.includes('--dry-run') || Boolean(preview),
82
- skipInstall: args.includes('--skip-install'),
83
- ...(preview ? { preview } : {}),
84
- }), { ...output, json: args.includes('--json') });
85
- }
@@ -1,4 +0,0 @@
1
- import type { StandardProduct } from './types.js';
2
- /** A compatible product selection, not mutually exclusive catalog alternatives. */
3
- export declare const FULL_PRODUCT: readonly StandardProduct[];
4
- export declare function applyPreset(name: string, selected: Set<StandardProduct>): void;
@@ -1,41 +0,0 @@
1
- /** A compatible product selection, not mutually exclusive catalog alternatives. */
2
- export const FULL_PRODUCT = Object.freeze([
3
- 'expo',
4
- 'hono',
5
- 'wxt',
6
- 'd1',
7
- 'better-auth',
8
- 'r2',
9
- 'kv',
10
- 'stripe',
11
- 'revenuecat',
12
- 'workers-ai',
13
- 'analytics-engine',
14
- 'basin',
15
- 'realtime',
16
- 'realtimekit',
17
- 'images',
18
- 'stream',
19
- 'video',
20
- 'queues',
21
- 'cron',
22
- 'workflows',
23
- 'resend',
24
- 'sentry',
25
- ]);
26
- export function applyPreset(name, selected) {
27
- if (!['minimal', 'full-product'].includes(name))
28
- throw new Error('preset must be minimal or full-product.');
29
- if (name === 'minimal')
30
- return;
31
- // Explicit provider/frontend choices replace the preset's corresponding default.
32
- for (const id of FULL_PRODUCT) {
33
- if (id === 'expo' && (selected.has('next') || selected.has('vinext')))
34
- continue;
35
- if (id === 'd1' && (selected.has('neon') || selected.has('neon-realtime')))
36
- continue;
37
- if (id === 'better-auth' && selected.has('clerk'))
38
- continue;
39
- selected.add(id);
40
- }
41
- }
@@ -1,11 +0,0 @@
1
- export declare const MAX_PREVIEW_TOTAL_BYTES: number;
2
- export interface SourcePreview {
3
- path: string;
4
- content?: string;
5
- diff?: string;
6
- unavailable?: string;
7
- }
8
- export declare function validatePreviewPath(file: string): void;
9
- /** A single contextual hunk is linear in file size and remains an applicable unified patch. */
10
- export declare function sourceDiff(file: string, before: string | undefined, after: string): string;
11
- export declare function sourcePreview(root: string, stage: string, file: string, mode: 'diff' | 'view'): SourcePreview;
@@ -1,91 +0,0 @@
1
- import path from 'node:path';
2
- import { existsSync } from 'node:fs';
3
- import { readBoundedFile } from '../bounded-file.js';
4
- const MAX_PREVIEW_FILE_BYTES = 256 * 1024;
5
- export const MAX_PREVIEW_TOTAL_BYTES = 1024 * 1024;
6
- export function validatePreviewPath(file) {
7
- if (!file ||
8
- path.posix.isAbsolute(file) ||
9
- file.includes('\\') ||
10
- /[\x00-\x1f\x7f]/.test(file) ||
11
- file
12
- .split('/')
13
- .some((part) => !part ||
14
- ['.', '..', '.anhedral'].includes(part) ||
15
- (/^(?:\.env|\.dev\.vars)(?:\.|$)/.test(part) && !part.endsWith('.example'))))
16
- throw new Error('Select a relative generated source path; private environment and state files cannot be previewed.');
17
- }
18
- /** A single contextual hunk is linear in file size and remains an applicable unified patch. */
19
- export function sourceDiff(file, before, after) {
20
- const lines = (content) => content === '' ? [] : content.split('\n').slice(0, content.endsWith('\n') ? -1 : undefined);
21
- const oldLines = lines(before ?? '');
22
- const newLines = lines(after);
23
- if (before === after)
24
- return '';
25
- let prefix = 0;
26
- while (prefix < oldLines.length &&
27
- prefix < newLines.length &&
28
- oldLines[prefix] === newLines[prefix])
29
- prefix++;
30
- // Newline-only changes must still include the final line in the patch.
31
- if (prefix && oldLines.length === newLines.length && prefix === oldLines.length)
32
- prefix--;
33
- let suffix = 0;
34
- while ((before ?? '').endsWith('\n') === after.endsWith('\n') &&
35
- suffix < oldLines.length - prefix &&
36
- suffix < newLines.length - prefix &&
37
- oldLines.at(-suffix - 1) === newLines.at(-suffix - 1))
38
- suffix++;
39
- const start = Math.max(0, prefix - 3);
40
- const oldEnd = Math.min(oldLines.length, oldLines.length - suffix + 3);
41
- const newEnd = Math.min(newLines.length, newLines.length - suffix + 3);
42
- const output = [
43
- `diff --git a/${file} b/${file}`,
44
- ...(before === undefined ? ['new file mode 100644'] : []),
45
- `--- ${before === undefined ? '/dev/null' : `a/${file}`}`,
46
- `+++ b/${file}`,
47
- `@@ -${oldEnd - start ? start + 1 : start},${oldEnd - start} +${newEnd - start ? start + 1 : start},${newEnd - start} @@`,
48
- ];
49
- if (before === undefined && !after)
50
- return output.slice(0, 2).join('\n') + '\n';
51
- const append = (prefix, line, last, content) => {
52
- output.push(`${prefix}${line}`);
53
- if (last && !content.endsWith('\n'))
54
- output.push('\');
55
- };
56
- for (let index = start; index < prefix; index++)
57
- output.push(` ${oldLines[index]}`);
58
- for (let index = prefix; index < oldLines.length - suffix; index++)
59
- append('-', oldLines[index], index === oldLines.length - 1, before ?? '');
60
- for (let index = prefix; index < newLines.length - suffix; index++)
61
- append('+', newLines[index], index === newLines.length - 1, after);
62
- for (let index = oldLines.length - suffix; index < oldEnd; index++)
63
- append(' ', oldLines[index], index === oldLines.length - 1, after);
64
- return output.join('\n') + '\n';
65
- }
66
- export function sourcePreview(root, stage, file, mode) {
67
- validatePreviewPath(file);
68
- const decode = (directory) => new TextDecoder('utf-8', { fatal: true }).decode(readBoundedFile(path.join(directory, file), MAX_PREVIEW_FILE_BYTES));
69
- let after;
70
- let before;
71
- try {
72
- after = decode(stage);
73
- if (after.includes('\x00'))
74
- throw new Error('Binary file');
75
- if (mode === 'diff' && existsSync(path.join(root, file))) {
76
- before = decode(root);
77
- if (before.includes('\x00'))
78
- throw new Error('Binary file');
79
- }
80
- }
81
- catch {
82
- return {
83
- path: file,
84
- unavailable: 'Binary, nonregular or oversized file; source preview is unavailable (256 KiB limit).',
85
- };
86
- }
87
- return {
88
- path: file,
89
- ...(mode === 'view' ? { content: after } : { diff: sourceDiff(file, before, after) }),
90
- };
91
- }
@@ -1,3 +0,0 @@
1
- export declare function sourceFiles(root: string): Map<string, string>;
2
- export declare function configurationFingerprints(root: string): Record<string, string>;
3
- export declare function recordScaffoldFiles(root: string): void;
@@ -1,68 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { readFileSync, readdirSync } from 'node:fs';
3
- import path from 'node:path';
4
- import { PROJECT_CONFIG_FILE, readProjectConfig, readProjectSection, writeProjectSection, } from '../project-config.js';
5
- const excluded = new Set([
6
- '.pnpm-store',
7
- '.artifacts',
8
- '.git',
9
- 'node_modules',
10
- '.next',
11
- '.open-next',
12
- '.wrangler',
13
- '.void',
14
- '.vinext',
15
- '.void-wrangler.jsonc',
16
- '.turbo',
17
- 'dist',
18
- '.output',
19
- '.expo',
20
- '.fallow',
21
- '.anhedral',
22
- '.anhedral-audit-report.json',
23
- '.anhedral.lock',
24
- '.anhedral-txn',
25
- PROJECT_CONFIG_FILE,
26
- ]);
27
- export function sourceFiles(root) {
28
- const files = new Map();
29
- const visit = (directory) => {
30
- for (const entry of readdirSync(path.join(root, directory), { withFileTypes: true })) {
31
- if (excluded.has(entry.name))
32
- continue;
33
- const relative = directory ? `${directory}/${entry.name}` : entry.name;
34
- // Deployment mirrors are disposable; reviewed SQL lives in packages/db/drizzle.
35
- if (/^apps\/[^/]+\/db\/migrations$/.test(relative))
36
- continue;
37
- // Local credentials are never seeded into an addition transaction or fingerprint receipt.
38
- if (/^(?:\.env|\.dev\.vars)(?:\.|$)/.test(entry.name) && !entry.name.endsWith('.example'))
39
- continue;
40
- if (entry.isSymbolicLink())
41
- throw new Error(`Source symlinks are unsupported: ${relative}.`);
42
- if (entry.isDirectory())
43
- visit(relative);
44
- else if (entry.isFile())
45
- files.set(relative, createHash('sha256')
46
- .update(readFileSync(path.join(root, relative)))
47
- .digest('hex'));
48
- }
49
- };
50
- visit('');
51
- return files;
52
- }
53
- export function configurationFingerprints(root) {
54
- return Object.fromEntries(Object.entries(readProjectConfig(root))
55
- .filter(([section]) => !['schemaVersion', 'registry'].includes(section))
56
- .map(([section, value]) => [
57
- section,
58
- createHash('sha256').update(JSON.stringify(value)).digest('hex'),
59
- ]));
60
- }
61
- export function recordScaffoldFiles(root) {
62
- const receipt = readProjectSection(root, 'registry');
63
- writeProjectSection(root, 'registry', {
64
- ...receipt,
65
- files: Object.fromEntries(sourceFiles(root)),
66
- configuration: configurationFingerprints(root),
67
- });
68
- }
@@ -1,24 +0,0 @@
1
- import { type DeliveryRunner } from './project-state.js';
2
- interface Repository {
3
- repoId: number;
4
- nameWithOwner: string;
5
- url: string;
6
- isPrivate: boolean;
7
- viewerPermission: string;
8
- owner: {
9
- login: string;
10
- };
11
- }
12
- export declare function githubRepository(root: string, run?: DeliveryRunner): Promise<Repository>;
13
- export declare function setupRepository(root: string, options: {
14
- owner?: string;
15
- name?: string;
16
- create?: boolean;
17
- visibility: 'private' | 'public';
18
- }, run?: DeliveryRunner): Promise<{
19
- repository: Repository;
20
- branch: string;
21
- commit: string;
22
- ownership: string;
23
- }>;
24
- export {};
@@ -1,96 +0,0 @@
1
- import { realpathSync } from 'node:fs';
2
- import { defaultRunner, withApplicationLock } from './project-state.js';
3
- function environment() {
4
- if (process.env.GH_HOST && process.env.GH_HOST !== 'github.com')
5
- throw new Error('Repository automation supports github.com; reconcile the selected GitHub host explicitly.');
6
- return {
7
- ...process.env,
8
- GH_HOST: 'github.com',
9
- GH_PROMPT_DISABLED: '1',
10
- GIT_TERMINAL_PROMPT: '0',
11
- };
12
- }
13
- function identity(remote) {
14
- const match = /^(?:https:\/\/github\.com\/|git@github\.com:)([a-zA-Z0-9-]+\/[a-zA-Z0-9_.-]+?)(?:\.git)?$/.exec(remote);
15
- if (!match || match[1].endsWith('/.') || match[1].endsWith('/..'))
16
- throw new Error('Origin must identify one GitHub repository without embedded credentials.');
17
- return match[1];
18
- }
19
- async function ownCheckout(root, run) {
20
- if (realpathSync((await run('git', ['rev-parse', '--show-toplevel'], root, environment())).trim()) !== root)
21
- throw new Error('Initialize the app in its own Git repository; do not use a parent repository.');
22
- }
23
- export async function githubRepository(root, run = defaultRunner) {
24
- root = realpathSync(root);
25
- await ownCheckout(root, run);
26
- const remotes = (await run('git', ['remote', 'get-url', '--all', 'origin'], root, environment()))
27
- .trim()
28
- .split(/\r?\n/);
29
- const pushes = (await run('git', ['remote', 'get-url', '--push', '--all', 'origin'], root, environment()))
30
- .trim()
31
- .split(/\r?\n/);
32
- if (remotes.length !== 1 || pushes.length !== 1 || identity(remotes[0]) !== identity(pushes[0]))
33
- throw new Error('Reconcile ambiguous or mismatched GitHub fetch/push origins.');
34
- const name = identity(remotes[0]);
35
- const repository = JSON.parse(await run('gh', ['repo', 'view', name, '--json', 'nameWithOwner,url,isPrivate,viewerPermission,owner'], root, environment()));
36
- if (repository.nameWithOwner?.toLowerCase() !== name.toLowerCase() ||
37
- repository.url?.toLowerCase() !== `https://github.com/${name}`.toLowerCase() ||
38
- repository.owner?.login?.toLowerCase() !== name.split('/')[0].toLowerCase() ||
39
- !['ADMIN', 'MAINTAIN', 'WRITE'].includes(repository.viewerPermission) ||
40
- typeof repository.isPrivate !== 'boolean')
41
- throw new Error('GitHub did not verify the selected repository identity and write access.');
42
- repository.repoId = JSON.parse(await run('gh', ['api', `repos/${name}`, '--jq', '.id'], root, environment()));
43
- if (!Number.isSafeInteger(repository.repoId) || repository.repoId <= 0)
44
- throw new Error('GitHub did not return a stable repository ID.');
45
- return repository;
46
- }
47
- export async function setupRepository(root, options, run = defaultRunner) {
48
- root = realpathSync(root);
49
- return withApplicationLock(root, async () => {
50
- await ownCheckout(root, run);
51
- if ((await run('git', ['status', '--porcelain'], root, environment())).trim())
52
- throw new Error('Review files and commit the application before repository setup; secrets must remain ignored.');
53
- const commit = (await run('git', ['rev-parse', 'HEAD'], root, environment())).trim();
54
- if (!/^[a-f0-9]{40,64}$/.test(commit))
55
- throw new Error('Create a reviewed initial source commit first.');
56
- const user = JSON.parse(await run('gh', ['api', 'user'], root, environment()));
57
- const owner = options.owner ?? user.login;
58
- const name = options.name ?? root.split('/').at(-1);
59
- if (!/^[a-zA-Z0-9-]+$/.test(owner ?? '') ||
60
- !/^[a-zA-Z0-9_.-]+$/.test(name) ||
61
- ['.', '..'].includes(name))
62
- throw new Error('Select a valid GitHub account and repository name.');
63
- const remotes = (await run('git', ['remote'], root, environment())).trim().split(/\r?\n/);
64
- if (!remotes.includes('origin')) {
65
- if (!options.create)
66
- throw new Error('No origin: use --create for an authorized new GitHub repository.');
67
- await run('gh', [
68
- 'repo',
69
- 'create',
70
- `${owner}/${name}`,
71
- `--${options.visibility}`,
72
- '--source',
73
- '.',
74
- '--remote',
75
- 'origin',
76
- ], root, environment());
77
- }
78
- const repository = await githubRepository(root, run);
79
- if (repository.nameWithOwner.toLowerCase() !== `${owner}/${name}`.toLowerCase() ||
80
- repository.isPrivate !== (options.visibility === 'private'))
81
- throw new Error('Existing repository ownership/name/visibility differs; origin and visibility were not replaced.');
82
- if ((await run('git', ['status', '--porcelain'], root, environment())).trim() ||
83
- (await run('git', ['rev-parse', 'HEAD'], root, environment())).trim() !== commit)
84
- throw new Error('Source changed during repository setup; nothing was pushed.');
85
- const branch = (await run('git', ['symbolic-ref', '--short', 'HEAD'], root, environment())).trim();
86
- if (!branch || branch.startsWith('-'))
87
- throw new Error('Select the intended source branch before pushing.');
88
- await run('git', ['push', '--set-upstream', 'origin', `HEAD:refs/heads/${branch}`], root, environment());
89
- const remote = (await run('git', ['ls-remote', '--heads', 'origin', `refs/heads/${branch}`], root, environment()))
90
- .trim()
91
- .split(/\s+/);
92
- if (remote[0] !== commit || remote[1] !== `refs/heads/${branch}`)
93
- throw new Error('GitHub did not confirm the pushed source commit.');
94
- return { repository, branch, commit, ownership: 'customer' };
95
- });
96
- }
@@ -1,3 +0,0 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
- export declare function scaffoldBetterAuth({ root, options, runtimeApp, has, updating, }: RecipeContext): void;
3
- export declare function scaffoldClerk({ root, has }: RecipeContext): void;
@@ -1,151 +0,0 @@
1
- import { scaffoldContracts, scaffoldWebAuth } from './backend.js';
2
- import { expoAuthScheme, scaffoldExpoAuth } from './expo-auth.js';
3
- import { jsString } from '../render.js';
4
- import { writeEnvironmentFile } from './environment.js';
5
- import { STACK_DEPENDENCIES } from '../dependencies.js';
6
- import { existsSync, readFileSync } from 'node:fs';
7
- import path from 'node:path';
8
- import { writeBetterAuthSchema } from '../auth-schema.js';
9
- import { put, patchPackage, sharedPackage } from './files.js';
10
- export function scaffoldBetterAuth({ root, options, runtimeApp, has, updating, }) {
11
- const scheme = has('expo') ? expoAuthScheme(root) : undefined;
12
- writeBetterAuthSchema(root, has('neon'));
13
- sharedPackage(root, 'auth', `${scheme ? "import { expo } from '@better-auth/expo';\n" : ''}import { betterAuth } from 'better-auth';
14
- import { drizzleAdapter } from '@better-auth/drizzle-adapter';
15
- import type { createDatabase } from '@workspace/db';
16
- export function createAuth(db: ReturnType<typeof createDatabase>, secret: string, baseURL: string, trustedOrigins: string[] = [new URL(baseURL).origin${scheme ? `, ${jsString(scheme + '://')}` : ''}]) {
17
- return betterAuth({
18
- database: drizzleAdapter(db, { provider: '${has('neon') ? 'pg' : 'sqlite'}', transaction: false }),
19
- secret,
20
- baseURL,
21
- trustedOrigins,
22
- ${scheme ? 'plugins: [expo()],' : ''}
23
- emailAndPassword: { enabled: true },
24
- });
25
- }
26
- `, {
27
- 'better-auth': STACK_DEPENDENCIES['better-auth'],
28
- ...(scheme ? { '@better-auth/expo': STACK_DEPENDENCIES['@better-auth/expo'] } : {}),
29
- '@better-auth/drizzle-adapter': STACK_DEPENDENCIES['@better-auth/drizzle-adapter'],
30
- '@workspace/db': 'workspace:*',
31
- });
32
- patchPackage(root, `apps/${runtimeApp}/package.json`, {
33
- dependencies: { '@workspace/auth': 'workspace:*', '@workspace/db': 'workspace:*' },
34
- });
35
- const connection = has('neon') ? 'createDatabase(env.DATABASE_URL)' : 'createDatabase(env.DB)';
36
- if (has('hono')) {
37
- if (!existsSync(path.join(root, 'packages/contracts/package.json')))
38
- scaffoldContracts(root);
39
- patchPackage(root, 'apps/api/package.json', {
40
- dependencies: { '@workspace/contracts': 'workspace:*' },
41
- });
42
- const source = readFileSync(path.join(root, 'apps/api/src/index.ts'), 'utf8');
43
- put(root, 'apps/api/src/index.ts', `import { createAuth } from '@workspace/auth';\n${source.includes("import { createDatabase } from '@workspace/db'") ? '' : "import { createDatabase } from '@workspace/db';\n"}import { sessionSchema } from '@workspace/contracts';\n` +
44
- source.replace('export default app;', `app.get('/api/session', async (c) => {\n const env = c.env;\n const session = await createAuth(${connection}, env.BETTER_AUTH_SECRET, env.BETTER_AUTH_URL).api.getSession({ headers: c.req.raw.headers });\n c.header('cache-control', 'private, no-store');\n if (!session) return c.json({ error: 'Unauthorized' }, 401);\n return c.json(sessionSchema.parse({ user: session.user }));\n});\napp.on(['GET', 'POST'], '/api/auth/*', async (c) => {\n const env = c.env;\n const database = ${connection};\n return await createAuth(database, env.BETTER_AUTH_SECRET, env.BETTER_AUTH_URL).handler(c.req.raw);\n});\nexport default app;`));
45
- }
46
- else {
47
- put(root, 'apps/web/app/api/auth/[...all]/route.ts', `${has('vinext') ? "import { env } from 'cloudflare:workers';" : options.hosting === 'cloudflare' ? "import { getCloudflareContext } from '@opennextjs/cloudflare';" : ''}
48
- import { createAuth } from '@workspace/auth';
49
- import { createDatabase } from '@workspace/db';
50
- async function handler(request: Request) {
51
- ${options.hosting === 'cloudflare' && !has('vinext') ? 'const { env } = await getCloudflareContext({ async: true });' : ''}
52
- const database = ${options.hosting === 'vercel' ? 'createDatabase(process.env.DATABASE_URL!)' : connection};
53
- return await createAuth(database, ${options.hosting === 'cloudflare' ? 'env.BETTER_AUTH_SECRET, env.BETTER_AUTH_URL' : 'process.env.BETTER_AUTH_SECRET!, process.env.BETTER_AUTH_URL!'}).handler(request);
54
- }
55
- export { handler as GET, handler as POST };
56
- `);
57
- if (options.hosting === 'cloudflare' && !has('vinext'))
58
- put(root, 'apps/web/cloudflare-env.d.ts', `interface CloudflareEnv { BETTER_AUTH_SECRET: string; BETTER_AUTH_URL: string; ${has('neon') ? 'DATABASE_URL: string;' : "DB: Parameters<typeof import('drizzle-orm/d1').drizzle>[0];"} }\n`);
59
- if (has('vinext')) {
60
- put(root, 'apps/web/secrets.d.ts', 'declare namespace Cloudflare { interface Env { BETTER_AUTH_SECRET: string; BETTER_AUTH_URL: string } }\n');
61
- }
62
- patchPackage(root, 'apps/web/package.json', {
63
- dependencies: { 'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'] },
64
- });
65
- }
66
- writeEnvironmentFile(root, `apps/${runtimeApp}/${runtimeApp === 'web' && options.hosting === 'vercel' ? '.env.example' : '.dev.vars.example'}`, {
67
- ...(has('neon') ? { DATABASE_URL: '' } : {}),
68
- BETTER_AUTH_SECRET: '',
69
- BETTER_AUTH_URL: `http://localhost:${has('vinext') || has('next') || has('expo') ? '3000' : '8787'}`,
70
- });
71
- if (has('hono') && (has('vinext') || has('next')))
72
- scaffoldWebAuth(root);
73
- if (scheme)
74
- scaffoldExpoAuth(root, scheme, !updating);
75
- if (has('hono'))
76
- put(root, 'apps/api/src/secrets.d.ts', 'interface Env { BETTER_AUTH_SECRET: string; BETTER_AUTH_URL: string }\n');
77
- }
78
- export function scaffoldClerk({ root, has }) {
79
- if (has('next') || has('vinext')) {
80
- patchPackage(root, 'apps/web/package.json', {
81
- dependencies: { '@clerk/nextjs': STACK_DEPENDENCIES['@clerk/nextjs'] },
82
- });
83
- const layoutPath = path.join(root, 'apps/web/app/layout.tsx');
84
- if (existsSync(layoutPath)) {
85
- const layout = readFileSync(layoutPath, 'utf8');
86
- if (!layout.includes('ClerkProvider')) {
87
- const wrapped = layout.replace(/(<body\b[^>]*>)([\s\S]*?)(<\/body>)/, '$1<ClerkProvider>$2</ClerkProvider>$3');
88
- if (wrapped === layout)
89
- throw new Error('Cannot configure ClerkProvider: the web layout must contain a body element.');
90
- put(root, 'apps/web/app/layout.tsx', 'import { ClerkProvider } from "@clerk/nextjs";\n' + wrapped);
91
- }
92
- }
93
- put(root, 'apps/web/app/sign-in/[[...sign-in]]/page.tsx', `import { Suspense } from 'react';
94
- import { SignIn } from '@clerk/nextjs';
95
-
96
- export default function SignInPage() {
97
- return (
98
- <Suspense fallback={<p role="status">Loading sign in…</p>}>
99
- <SignIn />
100
- </Suspense>
101
- );
102
- }
103
- `);
104
- put(root, 'apps/web/app/sign-up/[[...sign-up]]/page.tsx', `import { Suspense } from 'react';
105
- import { SignUp } from '@clerk/nextjs';
106
-
107
- export default function SignUpPage() {
108
- return (
109
- <Suspense fallback={<p role="status">Loading sign up…</p>}>
110
- <SignUp />
111
- </Suspense>
112
- );
113
- }
114
- `);
115
- put(root, 'apps/web/proxy.ts', `import { clerkMiddleware } from '@clerk/nextjs/server';
116
- import type { NextMiddleware } from 'next/server';
117
-
118
- const proxy: NextMiddleware = clerkMiddleware();
119
- export default proxy;
120
- export const config = { matcher: ['/((?!_next|[^?]*\\\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)', '/(api|trpc)(.*)'] };
121
- `);
122
- // Middleware makes auth available; product routes must explicitly require identity and authorization.
123
- }
124
- if (has('hono')) {
125
- sharedPackage(root, 'auth', `import { createClerkClient } from '@clerk/backend';
126
-
127
- export async function authenticate(
128
- request: Request,
129
- secretKey: string,
130
- publishableKey: string,
131
- authorizedParties: string[],
132
- ) {
133
- if (!secretKey || !publishableKey || authorizedParties.length === 0) {
134
- throw new Error('Configure Clerk keys and explicit authorized origins before authenticating.');
135
- }
136
- return createClerkClient({ secretKey, publishableKey }).authenticateRequest(request, {
137
- authorizedParties,
138
- });
139
- }
140
- `, { '@clerk/backend': STACK_DEPENDENCIES['@clerk/backend'] });
141
- writeEnvironmentFile(root, 'apps/api/.dev.vars.example', {
142
- CLERK_SECRET_KEY: '',
143
- CLERK_PUBLISHABLE_KEY: '',
144
- });
145
- }
146
- if (has('next') || has('vinext'))
147
- writeEnvironmentFile(root, 'apps/web/.env.example', {
148
- NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: '',
149
- CLERK_SECRET_KEY: '',
150
- });
151
- }
@@ -1 +0,0 @@
1
- export declare const BILLING_CONFIG = "import { z } from 'zod';\n\nexport interface BillingEnv {\n BILLING_ORIGIN: string;\n BILLING_ENVIRONMENT: string;\n BILLING_PLANS_JSON?: string;\n BILLING_ENTITLEMENTS_JSON: string;\n BILLING_PREMIUM_ENTITLEMENT?: string;\n STRIPE_SECRET_KEY?: string;\n STRIPE_WEBHOOK_SECRET?: string;\n REVENUECAT_SECRET_KEY?: string;\n REVENUECAT_WEBHOOK_AUTHORIZATION?: string;\n REVENUECAT_WEBHOOK_SIGNING_SECRET?: string;\n REVENUECAT_APP_IDS_JSON?: string;\n REVENUECAT_PROJECT_ID?: string;\n}\nconst key = z.string().regex(/^[a-zA-Z0-9_.-]{1,100}$/);\nconst planSchema = z.object({ label: z.string().min(1).max(100), stripePriceId: z.string().regex(/^price_[a-zA-Z0-9]+$/), entitlement: key }).strict();\nconst plansSchema = z.record(key, planSchema);\nexport type Plan = z.infer<typeof planSchema>;\nexport interface Config {\n origin: string;\n environment: 'sandbox' | 'production';\n plans: Record<string, Plan>;\n entitlements: string[];\n appIds: string[];\n projectId: string;\n demoEntitlement: string;\n}\nfunction json(value: string | undefined, fallback: string): unknown {\n return JSON.parse(value ?? fallback);\n}\nfunction protocolAllowed(url: URL, environment: 'sandbox' | 'production'): boolean {\n if (url.protocol === 'https:') return true;\n if (environment !== 'sandbox') return false;\n return url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);\n}\nfunction origin(value: string, environment: 'sandbox' | 'production'): string {\n const url = new URL(value);\n if (!protocolAllowed(url, environment)) throw new Error('Billing requires HTTPS; sandbox HTTP is loopback-only.');\n if ([url.username, url.password, url.pathname !== '/', url.search, url.hash].some(Boolean)) throw new Error('Billing requires an origin without credentials or a path.');\n return url.origin;\n}\nexport function billingConfig(env: BillingEnv): Config {\n const environment = z.enum(['sandbox', 'production']).parse(env.BILLING_ENVIRONMENT);\n const plans = plansSchema.parse(json(env.BILLING_PLANS_JSON, '{}'));\n const entitlements = z.array(key).min(1).max(100).parse(json(env.BILLING_ENTITLEMENTS_JSON, '[]'));\n if (Object.values(plans).some((plan) => !entitlements.includes(plan.entitlement))) throw new Error('Every billing plan needs an allowed entitlement.');\n return {\n origin: origin(env.BILLING_ORIGIN, environment),\n environment,\n plans, entitlements,\n appIds: z.array(z.string().regex(/^app[a-zA-Z0-9_]+$/)).max(50).parse(json(env.REVENUECAT_APP_IDS_JSON, '[]')),\n projectId: env.REVENUECAT_PROJECT_ID ?? '',\n demoEntitlement: key.parse(env.BILLING_PREMIUM_ENTITLEMENT ?? 'premium'),\n };\n}\nexport function requireValue(value: string | undefined): string {\n if (!value?.trim()) throw new Error('Billing provider configuration is incomplete.');\n return value;\n}\nexport async function digest(value: string): Promise<string> {\n const bytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\nexport async function equalSecret(actual: string, expected: string): Promise<boolean> {\n // Fixed-length digests make comparison independent of secret length.\n const values = await Promise.all([digest(actual), digest(expected)]);\n let difference = 0;\n for (let index = 0; index < values[0].length; index++) difference |= values[0].charCodeAt(index) ^ values[1].charCodeAt(index);\n return difference === 0;\n}\n";