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.
- package/README.md +23 -229
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +39 -0
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +86 -0
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +44 -0
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +15 -0
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +28 -0
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -84
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +40 -374
- package/dist/dependencies.d.ts +34 -62
- package/dist/dependencies.js +112 -199
- package/dist/index.d.ts +1 -45
- package/dist/index.js +1 -30
- package/dist/platforms/mobile.js +29 -139
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +251 -0
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -83
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +6 -40
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +18 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +3 -9
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -189
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +19 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +82 -84
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +9 -101
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +74 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/workspace.js +63 -199
- package/dist/stack-registry.d.ts +2 -58
- package/dist/stack-registry.js +22 -446
- package/dist/standard.js +7 -24
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -119
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -577
- package/docs/stack-standard.md +11 -307
- package/docs/ui.md +33 -0
- package/docs/verification.md +511 -0
- package/package.json +26 -27
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -168
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -172
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -186
- package/dist/delivery.d.ts +0 -88
- package/dist/delivery.js +0 -570
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -13
- package/dist/integration-service-readers.js +0 -173
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -366
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -702
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -49
- package/dist/project-state.js +0 -563
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -215
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -104
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -278
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -182
- package/dist/providers/definitions.d.ts +0 -318
- package/dist/providers/definitions.js +0 -127
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -66
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -112
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -265
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -289
- package/dist/provision.d.ts +0 -55
- package/dist/provision.js +0 -284
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -122
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -270
- package/dist/registry/bootstrap.d.ts +0 -2
- package/dist/registry/bootstrap.js +0 -14
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -85
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -3
- package/dist/scaffold/auth.js +0 -151
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -216
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -192
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -292
- package/dist/scaffold/integrations.d.ts +0 -4
- package/dist/scaffold/integrations.js +0 -12
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -78
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -78
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -247
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -102
- package/dist/ship.d.ts +0 -348
- package/dist/ship.js +0 -239
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
package/dist/scaffold/compose.js
CHANGED
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
import { scaffoldCloudflareServiceContext } from './cloudflare-services.js';
|
|
2
1
|
import { writeProjectSection } from '../project-config.js';
|
|
3
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
4
3
|
import path from 'node:path';
|
|
5
4
|
import { installStackItem } from '../stack-registry.js';
|
|
6
5
|
import { createRecipeContext } from '../registry/context.js';
|
|
7
6
|
import { inspectWorkspaceGraph } from '../workspace-graph.js';
|
|
8
7
|
import { writeStandardRoot } from './workspace.js';
|
|
9
|
-
import { normalizeSharedLint } from './lint.js';
|
|
10
|
-
import { configureVoidDelivery } from './void.js';
|
|
11
8
|
/** Only used in a fresh staged workspace. Existing applications are never overlaid. */
|
|
12
9
|
export async function composeStack(root, options, registry) {
|
|
13
10
|
const context = createRecipeContext(root, options);
|
|
14
|
-
if (!context.has('next') && !context.has('vinext')) {
|
|
15
|
-
for (const directory of ['apps/web', 'packages/ui'])
|
|
16
|
-
rmSync(path.join(root, directory), { recursive: true, force: true });
|
|
17
|
-
}
|
|
18
11
|
for (const item of registry.items)
|
|
19
12
|
Object.assign(context.bindings, item.bindings);
|
|
20
13
|
for (const item of registry.items) {
|
|
21
14
|
if (item.installer === 'recipe')
|
|
22
15
|
await installStackItem(item, context);
|
|
23
16
|
}
|
|
24
|
-
scaffoldCloudflareServiceContext(context);
|
|
25
|
-
normalizeSharedLint(root);
|
|
26
17
|
writeStandardRoot(root, options, registry);
|
|
27
|
-
configureVoidDelivery(root);
|
|
28
18
|
for (const item of registry.items) {
|
|
29
19
|
for (const target of item.targets) {
|
|
30
|
-
if (!existsSync(path.join(root, target))
|
|
31
|
-
!(target.endsWith('/wrangler.jsonc') &&
|
|
32
|
-
existsSync(path.join(root, target.replace('/wrangler.jsonc', '/anhedral.cloudflare.json')))))
|
|
20
|
+
if (!existsSync(path.join(root, target)))
|
|
33
21
|
throw new Error(`Registry target missing: ${item.name} -> ${target}.`);
|
|
34
22
|
}
|
|
35
23
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
export declare function scaffoldDatabase({ root
|
|
2
|
+
export declare function scaffoldDatabase({ root }: RecipeContext): void;
|
|
@@ -1,148 +1,41 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { writeEnvironmentFile } from './environment.js';
|
|
4
3
|
import { STACK_DEPENDENCIES } from '../dependencies.js';
|
|
5
|
-
import { put, patchPackage,
|
|
6
|
-
export function scaffoldDatabase({ root
|
|
7
|
-
|
|
8
|
-
const postgres = has('neon');
|
|
9
|
-
const directory = 'packages/db';
|
|
10
|
-
sharedPackage(root, 'db', postgres
|
|
11
|
-
? `import { drizzle } from 'drizzle-orm/neon-http';
|
|
12
|
-
import { neon } from '@neondatabase/serverless';
|
|
13
|
-
import * as schema from './schema';
|
|
14
|
-
export function createDatabase(connectionString: string) {
|
|
15
|
-
// HTTP supports independent queries and batches; migrations use a separate transactional connection.
|
|
16
|
-
return drizzle(neon(connectionString), { schema });
|
|
17
|
-
}
|
|
18
|
-
`
|
|
19
|
-
: `import { drizzle } from 'drizzle-orm/d1';
|
|
4
|
+
import { put, patchPackage, sharedPackage } from './files.js';
|
|
5
|
+
export function scaffoldDatabase({ root }) {
|
|
6
|
+
sharedPackage(root, 'db', `import { drizzle } from 'drizzle-orm/d1';
|
|
20
7
|
import * as schema from './schema';
|
|
21
8
|
export function createDatabase(binding: Parameters<typeof drizzle>[0]) { return drizzle(binding, { schema }); }
|
|
22
|
-
`, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
: {}),
|
|
27
|
-
});
|
|
28
|
-
put(root, `${directory}/src/schema.ts`, '// Define product tables here; generate and review SQL before migration.\nexport {};\n');
|
|
29
|
-
put(root, `${directory}/drizzle/.gitkeep`, '');
|
|
30
|
-
if (postgres)
|
|
31
|
-
put(root, `${directory}/migration-environment.ts`, `import { existsSync } from 'node:fs';
|
|
32
|
-
import { loadEnvFile } from 'node:process';
|
|
33
|
-
import { fileURLToPath } from 'node:url';
|
|
34
|
-
const root = new URL('./', import.meta.url);
|
|
35
|
-
export function migrationEnvironment() {
|
|
36
|
-
// Existing process values win; local overrides precede shared defaults.
|
|
37
|
-
for (const name of ['.env.local', '.env']) {
|
|
38
|
-
const file = fileURLToPath(new URL(name, root));
|
|
39
|
-
if (existsSync(file)) loadEnvFile(file);
|
|
40
|
-
}
|
|
41
|
-
return { root, connectionString: process.env.DATABASE_URL_UNPOOLED };
|
|
42
|
-
}
|
|
43
|
-
`);
|
|
44
|
-
put(root, `${directory}/drizzle.config.ts`, postgres
|
|
45
|
-
? `import { relative } from 'node:path';
|
|
46
|
-
import { fileURLToPath } from 'node:url';
|
|
47
|
-
import { defineConfig } from 'drizzle-kit';
|
|
48
|
-
import { migrationEnvironment } from './migration-environment';
|
|
49
|
-
const { root, connectionString: url } = migrationEnvironment();
|
|
50
|
-
export default defineConfig({
|
|
51
|
-
dialect: 'postgresql',
|
|
52
|
-
schema: fileURLToPath(new URL('./src/schema.ts', root)),
|
|
53
|
-
out: relative(process.cwd(), fileURLToPath(new URL('./drizzle/', root))),
|
|
54
|
-
...(url ? { dbCredentials: { url } } : {}),
|
|
55
|
-
});
|
|
56
|
-
`
|
|
57
|
-
: `import { fileURLToPath } from 'node:url';
|
|
9
|
+
`, { 'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'] });
|
|
10
|
+
put(root, 'packages/db/src/schema.ts', '// Add application tables here. Generate and review SQL before migration.\nexport {};\n');
|
|
11
|
+
put(root, 'packages/db/drizzle/.gitkeep', '');
|
|
12
|
+
put(root, 'packages/db/drizzle.config.ts', `import { fileURLToPath } from 'node:url';
|
|
58
13
|
import { relative } from 'node:path';
|
|
59
14
|
import { defineConfig } from 'drizzle-kit';
|
|
60
|
-
export default defineConfig({
|
|
61
|
-
dialect: 'sqlite',
|
|
62
|
-
schema: fileURLToPath(new URL('./src/schema.ts', import.meta.url)),
|
|
63
|
-
out: relative(process.cwd(), fileURLToPath(new URL('./drizzle/', import.meta.url))),
|
|
64
|
-
});
|
|
15
|
+
export default defineConfig({ dialect: 'sqlite', schema: fileURLToPath(new URL('./src/schema.ts', import.meta.url)), out: relative(process.cwd(), fileURLToPath(new URL('./drizzle/', import.meta.url))) });
|
|
65
16
|
`);
|
|
66
|
-
put(root,
|
|
67
|
-
? `import { fileURLToPath } from 'node:url';
|
|
68
|
-
import { Pool, neonConfig } from '@neondatabase/serverless';
|
|
69
|
-
import { drizzle } from 'drizzle-orm/neon-serverless';
|
|
70
|
-
import { migrate } from 'drizzle-orm/neon-serverless/migrator';
|
|
71
|
-
import { migrationEnvironment } from '../migration-environment';
|
|
72
|
-
const { root, connectionString } = migrationEnvironment();
|
|
73
|
-
if (!connectionString) throw new Error('Configure DATABASE_URL_UNPOOLED for the intended migration branch and role.');
|
|
74
|
-
let url: URL;
|
|
75
|
-
try { url = new URL(connectionString); } catch { throw new Error('Configure a valid direct PostgreSQL migration URL.'); }
|
|
76
|
-
if (!['postgres:', 'postgresql:'].includes(url.protocol) || url.hostname.includes('-pooler.'))
|
|
77
|
-
throw new Error('Migrations require a direct PostgreSQL connection.');
|
|
78
|
-
neonConfig.webSocketConstructor = WebSocket;
|
|
79
|
-
const pool = new Pool({ connectionString });
|
|
80
|
-
try {
|
|
81
|
-
await migrate(drizzle(pool), { migrationsFolder: fileURLToPath(new URL('drizzle/', root)) });
|
|
82
|
-
} catch {
|
|
83
|
-
throw new Error('Database migration failed. Inspect the selected branch and migration history before retrying.');
|
|
84
|
-
} finally {
|
|
85
|
-
await pool.end();
|
|
86
|
-
}
|
|
87
|
-
`
|
|
88
|
-
: `import { spawnSync } from 'node:child_process';
|
|
17
|
+
put(root, 'packages/db/src/migrate.ts', `import { spawnSync } from 'node:child_process';
|
|
89
18
|
import { fileURLToPath } from 'node:url';
|
|
90
19
|
const args = process.argv.slice(2);
|
|
91
|
-
if (args.length > 1 || args.some((arg) => !['--local', '--remote'].includes(arg)))
|
|
92
|
-
throw new Error('Usage: pnpm db:migrate [--local|--remote] (defaults to local).');
|
|
20
|
+
if (args.length > 1 || args.some((arg) => !['--local', '--remote'].includes(arg))) throw new Error('Usage: pnpm db:migrate [--local|--remote] (defaults to local).');
|
|
93
21
|
const pnpm = process.env.npm_execpath;
|
|
94
22
|
if (!pnpm) throw new Error('Run migrations through pnpm db:migrate.');
|
|
95
|
-
const root = fileURLToPath(new URL('../../../apps
|
|
96
|
-
const result = spawnSync(process.execPath, [pnpm, 'exec', 'wrangler', 'd1', 'migrations', 'apply', 'DB',
|
|
97
|
-
args[0] ?? '--local', '--config', fileURLToPath(new URL('../../../apps/${runtimeApp}/wrangler.jsonc', import.meta.url)),
|
|
98
|
-
], { cwd: root, stdio: 'inherit', shell: false });
|
|
23
|
+
const root = fileURLToPath(new URL('../../../apps/api/', import.meta.url));
|
|
24
|
+
const result = spawnSync(process.execPath, [pnpm, 'exec', 'wrangler', 'd1', 'migrations', 'apply', 'DB', args[0] ?? '--local', '--config', fileURLToPath(new URL('../../../apps/api/wrangler.jsonc', import.meta.url))], { cwd: root, stdio: 'inherit', shell: false });
|
|
99
25
|
if (result.error) throw result.error;
|
|
100
26
|
process.exitCode = result.status ?? 1;
|
|
101
27
|
`);
|
|
102
|
-
patchPackage(root,
|
|
28
|
+
patchPackage(root, 'packages/db/package.json', {
|
|
103
29
|
exports: { '.': './src/index.ts', './schema': './src/schema.ts' },
|
|
104
|
-
dependencies: {
|
|
105
|
-
'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'],
|
|
106
|
-
...(postgres
|
|
107
|
-
? { '@neondatabase/serverless': STACK_DEPENDENCIES['@neondatabase/serverless'] }
|
|
108
|
-
: {}),
|
|
109
|
-
},
|
|
110
30
|
devDependencies: {
|
|
111
31
|
'drizzle-kit': STACK_DEPENDENCIES['drizzle-kit'],
|
|
112
|
-
tsx: STACK_DEPENDENCIES
|
|
113
|
-
|
|
32
|
+
tsx: STACK_DEPENDENCIES.tsx,
|
|
33
|
+
wrangler: STACK_DEPENDENCIES.wrangler,
|
|
114
34
|
},
|
|
115
35
|
scripts: { 'db:generate': 'drizzle-kit generate', 'db:migrate': 'tsx src/migrate.ts' },
|
|
116
36
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
patchPackage(root, 'apps/api/package.json', {
|
|
122
|
-
dependencies: { '@workspace/db': 'workspace:*' },
|
|
123
|
-
});
|
|
124
|
-
const source = readFileSync(path.join(root, 'apps/api/src/index.ts'), 'utf8');
|
|
125
|
-
put(root, 'apps/api/src/index.ts', "import { createDatabase } from '@workspace/db';\n" +
|
|
126
|
-
source
|
|
127
|
-
.replace(source.includes('Variables: {') ? 'Variables: {' : 'Bindings: Env', source.includes('Variables: {')
|
|
128
|
-
? 'Variables: { database: () => ReturnType<typeof createDatabase>;'
|
|
129
|
-
: 'Bindings: Env; Variables: { database: () => ReturnType<typeof createDatabase> }')
|
|
130
|
-
.replace('const health = createRoute({', `// Construct the database only when a route needs it: c.get('database')().
|
|
131
|
-
app.use('/api/*', async (c, next) => {
|
|
132
|
-
c.set('database', () => createDatabase(${postgres ? 'c.env.DATABASE_URL' : 'c.env.DB'}));
|
|
133
|
-
await next();
|
|
134
|
-
});
|
|
135
|
-
const health = createRoute({`));
|
|
136
|
-
}
|
|
137
|
-
if (postgres) {
|
|
138
|
-
const native = runtimeApp === 'web' && options.hosting === 'vercel';
|
|
139
|
-
writeEnvironmentFile(root, `${app}/${native ? '.env.example' : '.dev.vars.example'}`, {
|
|
140
|
-
DATABASE_URL: '',
|
|
141
|
-
});
|
|
142
|
-
writeEnvironmentFile(root, `${directory}/.env.example`, { DATABASE_URL_UNPOOLED: '' });
|
|
143
|
-
if (!native)
|
|
144
|
-
put(root, `${app}/${runtimeApp === 'api' ? 'src/' : ''}database-secrets.d.ts`, runtimeApp === 'api'
|
|
145
|
-
? 'interface Env { DATABASE_URL: string }\n'
|
|
146
|
-
: 'declare namespace Cloudflare { interface Env { DATABASE_URL: string } }\n');
|
|
147
|
-
}
|
|
37
|
+
patchPackage(root, 'apps/api/package.json', { dependencies: { '@workspace/db': 'workspace:*' } });
|
|
38
|
+
const source = readFileSync(path.join(root, 'apps/api/src/index.ts'), 'utf8');
|
|
39
|
+
put(root, 'apps/api/src/index.ts', "import { createDatabase } from '@workspace/db';\n" +
|
|
40
|
+
source.replace('const app = new OpenAPIHono<{ Bindings: Env }>();', "const app = new OpenAPIHono<{ Bindings: Env; Variables: { database: () => ReturnType<typeof createDatabase> } }>();\napp.use('*', async (c, next) => { c.set('database', () => createDatabase(c.env.DB)); await next(); });"));
|
|
148
41
|
}
|
|
@@ -1,104 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { markdownHeading } from '../render.js';
|
|
3
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
1
|
+
import { capabilityReferences } from '../capability-references.js';
|
|
5
2
|
import { put } from './files.js';
|
|
6
|
-
export function workerBuildSuffix(options) {
|
|
7
|
-
return options.products.includes('next') && options.hosting === 'cloudflare'
|
|
8
|
-
? ' && pnpm build:worker'
|
|
9
|
-
: '';
|
|
10
|
-
}
|
|
11
3
|
export function writeSetupDocumentation(root, options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
if (!options.products.includes('hono') && !options.products.includes('expo')) {
|
|
5
|
+
for (const [file, source] of Object.entries(capabilityReferences()))
|
|
6
|
+
put(root, file, source);
|
|
7
|
+
put(root, 'README.md', `# ${options.name}
|
|
8
|
+
|
|
9
|
+
Next.js on Cloudflare Workers through OpenNext, with Anhedral UI from the start.
|
|
10
|
+
Init creates only apps/web. Use anhedral stack status to inspect later source additions.
|
|
11
|
+
No providers are provisioned by source generation.
|
|
12
|
+
|
|
13
|
+
## Develop
|
|
14
|
+
|
|
15
|
+
Use the Node/pnpm versions in package.json. Run pnpm install if generation skipped
|
|
16
|
+
installation, then pnpm dev. Open the URL printed by Next.js.
|
|
17
|
+
|
|
18
|
+
## Anhedral UI
|
|
19
|
+
|
|
20
|
+
The initial page uses editable Button, Input and Label source from the reviewed
|
|
21
|
+
shadcn baseline. Application-local source belongs to you. Shared tokens live in
|
|
22
|
+
packages/styling; preserve attribution in ANHEDRAL_UI_LICENSES and UPSTREAM.json.
|
|
23
|
+
Anhedral UI is a CLI/catalog/theme convention, not a runtime component package.
|
|
24
|
+
|
|
25
|
+
Use anhedral ui list, anhedral ui add card --web, anhedral ui diff button --web,
|
|
26
|
+
and anhedral ui doctor --web. Use --cwd apps/web to select this application or
|
|
27
|
+
--all explicitly for multiple clients. --dry-run previews init/add without network
|
|
28
|
+
or writes. Updates are opt-in; never overwrite customized components silently.
|
|
29
|
+
|
|
30
|
+
Native UI uses the React Native Reusables NativeWind registry in compatible Expo
|
|
31
|
+
projects, preferring reviewed Anhedral extensions when present. It requires Expo,
|
|
32
|
+
not a backend. Use anhedral add expo, then add native-ui, for the reviewed client/setup recipes.
|
|
33
|
+
Standalone UI commands do not create native clients or backend services; existing
|
|
34
|
+
Expo applications need the upstream NativeWind/RNR setup before native ui init.
|
|
35
|
+
|
|
36
|
+
## Add strategically
|
|
37
|
+
|
|
38
|
+
Add Hono when a dedicated API is justified, then Drizzle/D1/Better Auth when the
|
|
39
|
+
product needs data and authentication. Use anhedral add <capability> --dry-run --json
|
|
40
|
+
to review changes, then apply them. Missing parents require explicit selection or
|
|
41
|
+
--with-dependencies. See docs/anhedral/capabilities.md for the complete catalog and
|
|
42
|
+
source-protection contract. No provision or deployment command is implemented here.
|
|
43
|
+
Consumers own integrations, deployment and application distribution. Run pnpm check
|
|
44
|
+
and review your changes before deployment. Builds/startup never migrate databases.
|
|
45
|
+
`);
|
|
46
|
+
put(root, 'AGENTS.md', `# Minimal application foundation
|
|
47
|
+
|
|
48
|
+
Start with Next.js/OpenNext/Workers and source-owned Anhedral UI. Do not add an API,
|
|
49
|
+
database, authentication, R2 or native client without a concrete feature need.
|
|
50
|
+
Use anhedral add and stack list/status/doctor to compose selected capabilities.
|
|
51
|
+
Preview additions first, preserve edited source, and configure selected auth methods
|
|
52
|
+
explicitly. Source installation is not provider activation. Use anhedral ui
|
|
53
|
+
add/list/diff/doctor to manage platform-specific source; web uses
|
|
54
|
+
official shadcn and native uses RNR/NativeWind with reviewed Anhedral extensions.
|
|
55
|
+
UI requires its application platform, not Hono or a database. Share tokens, not
|
|
56
|
+
DOM/native primitives. Preserve consumer edits, attribution and upstream metadata.
|
|
57
|
+
Never automatically overwrite installed components. Read version-matched framework
|
|
58
|
+
guides and run pnpm check. Never migrate a configured database during checks/builds.
|
|
59
|
+
`);
|
|
60
|
+
put(root, 'docs/architecture.md', '# Architecture\n\nNext.js → OpenNext → Cloudflare Workers, with Anhedral UI. Record feature-driven additions here.\n');
|
|
61
|
+
put(root, 'docs/verification.md', '# Verification\n\nRecord commands, outcomes and environment. Source generation is not deployment acceptance.\n');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
put(root, 'README.md', `# ${options.name}
|
|
24
65
|
|
|
25
|
-
|
|
66
|
+
Next.js App Router/OpenNext + Expo native + shadcn UI + Hono/workerd + Drizzle/D1 + private R2.
|
|
26
67
|
|
|
27
|
-
|
|
68
|
+
## Develop locally
|
|
28
69
|
|
|
29
|
-
|
|
70
|
+
Use the Node and pnpm versions in package.json. Run pnpm install if generation used --skip-install. Run pnpm dev and open the web URL printed by Next (normally http://localhost:3000). Hono runs on http://127.0.0.1:8787; web /api/health proxies to it. No accounts or secrets are needed for the starter health flow.
|
|
30
71
|
|
|
31
|
-
|
|
72
|
+
Start native separately with pnpm --dir apps/mobile start. Copy apps/mobile/.env.example to apps/mobile/.env and set EXPO_PUBLIC_API_URL to the API origin reachable from the device. Local HTTP is development-only; use HTTPS outside development.
|
|
32
73
|
|
|
33
|
-
|
|
74
|
+
## UI and device capabilities
|
|
34
75
|
|
|
35
|
-
|
|
76
|
+
Web uses DOM shadcn; native uses editable source in packages/native-ui. Share tokens through packages/styling. The shadcn fork is an upstream review source, not an application runtime dependency. Review copied provenance and licenses; adopt later UI changes explicitly without overwriting your edits.
|
|
36
77
|
|
|
37
|
-
|
|
78
|
+
Use Expo SDK packages directly for application capabilities. UI components may compose them for presentation, such as a Copy button using Expo Clipboard; application permissions, background work, uploads and push registration belong to your application. Keep the tested Expo/React Native/React runtime consistent with native-ui peers. Add packages as needed from apps/mobile with pnpm expo install <package>, checking platform support and native configuration. Rebuild the development client after native dependency/configuration changes. Validate web separately from Android/iOS; use physical devices for device-only capabilities.
|
|
38
79
|
|
|
39
|
-
|
|
40
|
-
`);
|
|
41
|
-
put(root, 'README.md', `# ${markdownHeading(options.name)}
|
|
80
|
+
## Data and private storage
|
|
42
81
|
|
|
43
|
-
|
|
82
|
+
Add tables in packages/db/src/schema.ts. Run pnpm db:generate, review SQL, then explicitly run pnpm db:migrate (local by default). Builds and startup do not migrate databases. Configure real D1 and private R2 identities in apps/api/wrangler.jsonc for your own deployment. Never enable public bucket access or put service credentials in clients.
|
|
44
83
|
|
|
45
|
-
|
|
84
|
+
apps/api/src/private-storage.ts is a server-side helper; it exposes no file routes. Implement your application's identity, authorization, ownership and limits before exposing database or object APIs.
|
|
46
85
|
|
|
47
|
-
|
|
86
|
+
## Your application
|
|
48
87
|
|
|
49
|
-
|
|
88
|
+
You own development, authentication, email, payments and hosting. Add Stripe or RevenueCat yourself if needed. This scaffold has no Platform account, managed provider connection or production activation. Generated configuration and scripts are yours to change. See docs/stack.md and run pnpm check before reviewing changes.
|
|
89
|
+
`);
|
|
90
|
+
put(root, 'AGENTS.md', `# Application foundation
|
|
50
91
|
|
|
51
|
-
|
|
92
|
+
Use Next.js App Router/OpenNext for web, Expo for native, DOM shadcn and the Anhedral native shadcn port, Hono on Workers/workerd, Drizzle/D1 and private R2. Shared contracts belong in packages/contracts, native components in packages/native-ui, tokens in packages/styling, and server schema/migrations in packages/db.
|
|
52
93
|
|
|
53
|
-
|
|
94
|
+
Hono owns privileged operations. Clients and Next server actions call the API; apps never import one another's source. Keep database/storage credentials server-side. The starter has no authentication, payment integration or public file APIs. Implement identity and authorization before exposing private data. A private bucket is not user authorization.
|
|
54
95
|
|
|
55
|
-
|
|
56
|
-
${has('neon') ? 'Configure DATABASE_URL_UNPOOLED separately in packages/db/.env for transactional migrations on the intended branch. Configure server-only DATABASE_URL for the intended Neon branch and role. Direct HTTP needs no Hyperdrive or connection cleanup. Review migrations and authorization; interactive transactions require a reviewed WebSocket or PostgreSQL adapter.\n' : ''}
|
|
57
|
-
${has('neon') || has('d1') ? 'packages/db/src owns the reusable database factory, schema and migration entry point. Generated SQL lives in packages/db/drizzle; the config resolves paths from its own directory. Run pnpm db:generate, review SQL, then pnpm db:migrate. These tasks are uncached and separate from application builds. D1 defaults to local; pass -- --remote explicitly for the selected Worker database. Browser and native interfaces use an API, never database credentials.\n' : ''}
|
|
58
|
-
${has('expo') && has('better-auth') ? 'Expo identity includes the server Expo plugin with the exact configured scheme, SecureStore native client/cookie adapter, separate browser client, sign-in/account screens and shared protected session contracts. Configure secrets/origins and apply reviewed migrations. Local transport checks do not replace development-build/device acceptance. ' : ''}${has('better-auth') ? 'Core Better Auth tables are included in the Drizzle schema. Review and apply migrations before using /api/auth. Configure BETTER_AUTH_SECRET, BETTER_AUTH_URL and trusted origins for the correct environment.\n' : ''}
|
|
59
|
-
${has('clerk') ? `${has('next') || has('vinext') ? 'The web starter includes ClerkProvider, middleware and sign-in/sign-up pages. Configure NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and server-only CLERK_SECRET_KEY. ' : ''}${has('hono') ? 'packages/auth exports a Clerk request authentication helper. Configure its server secret and publishable key, supply explicit authorized origins, and wire it into product routes; the API health route remains public. ' : ''}Authentication does not establish resource authorization.\n` : ''}
|
|
60
|
-
${has('r2') ? 'FILES is a private R2 binding. Implement authentication and file-level authorization before exposing file routes. Clients never receive R2 credentials.\n' : ''}
|
|
61
|
-
${has('neon-realtime') ? 'Neon Realtime is an optional beta live SQL foundation, separate from Durable Object rooms. Read [packages/neon-realtime/README.md](packages/neon-realtime/README.md) for the server/client factories and Drizzle adapter. Manually enable the intended branch, configure exact allowed origins and set server-only NEON_REALTIME_SECRET with DATABASE_URL; NEON_REALTIME_URL is public client transport configuration. Authenticate sealing requests and scope every query to verified user/tenant access. Implement subscriptions, authorized renewal and isolation tests; RLS, automatic Realtime provisioning and a public SQL endpoint are not provided. Live behavior remains unverified.\n' : ''}
|
|
62
|
-
${has('stream') ? 'Cloudflare Stream provides optional one-to-many WHIP/WHEP live video. Follow packages/stream/README.md and import the management factory only from @workspace/stream/server. Configure server-only STREAM_API_TOKEN and STREAM_ACCOUNT_ID manually. Authorize creators and input ownership; never return secret WHIP URLs to viewers. Implement playback token issuance for private media, browser signaling/UI and session cleanup. Stream activation, live inputs and runtime credentials are not automatically provisioned; live behavior remains unverified.\n' : ''}
|
|
63
|
-
${has('realtime') ? 'Durable Object rooms support hibernating WebSockets; the public entrypoint remains disabled until room authorization and short-lived tickets are implemented.\n' : ''}
|
|
64
|
-
${has('queues') ? 'Queue processing retries unimplemented jobs and uses a dead-letter queue. Add product processing and transactional idempotency before acknowledging messages.\n' : ''}
|
|
65
|
-
${has('basin') ? 'Basin uses a Pipelines stream binding. Configure its stream, sink, R2/catalog and SQL in client-owned infrastructure; it is distinct from operational logs.\n' : ''}
|
|
66
|
-
${has('neon') ? 'Neon provisioning configures the server runtime DATABASE_URL only. Set a separate direct DATABASE_URL_UNPOOLED in ignored packages/db/.env for the intended migration database and role. Run pnpm db:generate, review SQL, then pnpm db:migrate before testing authentication or application data.\n' : ''}
|
|
67
|
-
The root pnpm test command runs workspace test tasks; no application tests or test:live script are generated. Implement them for the product before verification.\n\nProvider packages are SDK factories or integration boundaries, not finished business features. Connect only needed packages to server entrypoints. Selected Stripe/RevenueCat billing generates authenticated Hono APIs, provider-verified webhook inbox, scheduled reconciliation and DB-backed entitlement enforcement; read packages/billing/README.md, configure plans/keys/IDs and review/apply SQL. Independent providers share the verified auth user ID; clients never grant access. Local data needs a platform-specific SQLite/filesystem adapter. Sentry needs a platform SDK and runtime initialization. Expo + Better Auth generates native/browser session clients, exact trusted scheme and sign-in/account screens; verify native behavior on a development build/device. Selected RevenueCat generates native purchase/restore/manage wiring; real development-build/store purchase acceptance remains required.
|
|
96
|
+
Keep DOM shadcn and native UI implementations separate, sharing tokens and contracts. Import editable application-local UI source; preserve its provenance, licenses and consumer edits during explicit updates. Use Expo SDK APIs directly for feature capabilities, adding UI adapters only for meaningful presentation or interaction. Keep permission policy and background/provider behavior in application services. The mobile app owns the tested Expo/React Native/React runtime; native-ui peers must match it. Add only needed SDK packages using Expo's compatible installer from apps/mobile and inspect platform support/autolinking/config plugins. Rebuild development clients for native changes and verify Android/iOS behavior separately from browser rendering. Consider @expo/ui controls selectively; do not replace the native port wholesale.
|
|
68
97
|
|
|
69
|
-
|
|
70
|
-
`);
|
|
71
|
-
put(root, '.github/workflows/check.yml', `name: Check
|
|
72
|
-
on:
|
|
73
|
-
pull_request:
|
|
74
|
-
push:
|
|
75
|
-
branches: [main]
|
|
76
|
-
permissions:
|
|
77
|
-
contents: read
|
|
78
|
-
jobs:
|
|
79
|
-
check:
|
|
80
|
-
runs-on: ubuntu-latest
|
|
81
|
-
timeout-minutes: 20
|
|
82
|
-
steps:
|
|
83
|
-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
|
|
84
|
-
with:
|
|
85
|
-
fetch-depth: 0
|
|
86
|
-
persist-credentials: false
|
|
87
|
-
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271
|
|
88
|
-
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
|
|
89
|
-
with:
|
|
90
|
-
node-version: '${voidSelected ? '24.21.0' : '22'}'
|
|
91
|
-
cache: pnpm
|
|
92
|
-
- run: pnpm install --frozen-lockfile
|
|
93
|
-
- run: pnpm lint && pnpm typecheck && pnpm audit:deps
|
|
94
|
-
- name: Audit pull request
|
|
95
|
-
if: github.event_name == 'pull_request'
|
|
96
|
-
env:
|
|
97
|
-
AUDIT_BASE: \${{ github.event.pull_request.base.sha }}
|
|
98
|
-
run: pnpm exec fallow audit --base "$AUDIT_BASE"
|
|
99
|
-
- name: Audit branch
|
|
100
|
-
if: github.event_name != 'pull_request'
|
|
101
|
-
run: pnpm audit:full
|
|
102
|
-
- run: pnpm test && pnpm build${workerBuildSuffix(options)}
|
|
98
|
+
Use pnpm dev for web/API and pnpm --dir apps/mobile start for native. Read version-matched framework documentation. Run pnpm check and exercise changed flows. Review generated SQL and apply migrations explicitly; never migrate a configured remote database during tests, build or startup. Consumers own integration and hosting decisions. Preserve existing source; never reinitialize over an application.
|
|
103
99
|
`);
|
|
100
|
+
put(root, 'docs/architecture.md', '# Architecture\n\nNext.js / Expo → Hono → Drizzle/D1 and private R2. Record application-owned identity, access rules and integrations here.\n');
|
|
101
|
+
put(root, 'docs/verification.md', '# Verification\n\nRecord commands, outcomes and environment. Generated source is not production acceptance.\n');
|
|
104
102
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
/**
|
|
3
|
-
export declare function scaffoldExpoRuntime({ root
|
|
2
|
+
/** Native uses the public product origin; all browser transport belongs to Next. */
|
|
3
|
+
export declare function scaffoldExpoRuntime({ root }: RecipeContext): void;
|
|
@@ -1,109 +1,19 @@
|
|
|
1
1
|
import { writeEnvironmentFile } from './environment.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Expo remains a static universal client. Its Worker owns only assets and API transport. */
|
|
6
|
-
export function scaffoldExpoRuntime({ root, options, has }) {
|
|
2
|
+
import { patchPackage, put } from './files.js';
|
|
3
|
+
/** Native uses the public product origin; all browser transport belongs to Next. */
|
|
4
|
+
export function scaffoldExpoRuntime({ root }) {
|
|
7
5
|
const directory = 'apps/mobile';
|
|
8
|
-
const api = has('hono');
|
|
9
|
-
const webPort = has('vinext') || has('next') ? 3001 : 3000;
|
|
10
|
-
json(root, `${directory}/wrangler.jsonc`, {
|
|
11
|
-
...workerConfig(resourceName(options.name, 'mobile')),
|
|
12
|
-
main: 'worker/index.ts',
|
|
13
|
-
assets: {
|
|
14
|
-
directory: './dist',
|
|
15
|
-
binding: 'ASSETS',
|
|
16
|
-
run_worker_first: ['/api', '/api/*'],
|
|
17
|
-
html_handling: 'auto-trailing-slash',
|
|
18
|
-
not_found_handling: '404-page',
|
|
19
|
-
},
|
|
20
|
-
...(api ? { services: [{ binding: 'API', service: resourceName(options.name, 'api') }] } : {}),
|
|
21
|
-
});
|
|
22
6
|
patchPackage(root, `${directory}/package.json`, {
|
|
23
|
-
|
|
24
|
-
dev: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
|
|
25
|
-
start: 'expo start -c',
|
|
26
|
-
web: 'pnpm dev',
|
|
27
|
-
build: 'pnpm typecheck && pnpm build:web && pnpm build:worker',
|
|
28
|
-
'build:worker': 'wrangler deploy --dry-run --outdir .output/worker',
|
|
29
|
-
preview: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
|
|
30
|
-
deploy: 'pnpm build:web && wrangler deploy',
|
|
31
|
-
typecheck: 'tsc --noEmit && pnpm typecheck:worker',
|
|
32
|
-
'typecheck:worker': 'tsc --project tsconfig.worker.json --noEmit',
|
|
33
|
-
lint: 'eslint app components lib worker --max-warnings 0',
|
|
34
|
-
},
|
|
35
|
-
...(api ? { dependencies: { '@workspace/contracts': 'workspace:*' } } : {}),
|
|
36
|
-
devDependencies: { wrangler: STACK_DEPENDENCIES.wrangler },
|
|
37
|
-
});
|
|
38
|
-
json(root, `${directory}/tsconfig.worker.json`, {
|
|
39
|
-
compilerOptions: {
|
|
40
|
-
target: 'ES2022',
|
|
41
|
-
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
42
|
-
module: 'ESNext',
|
|
43
|
-
moduleResolution: 'Bundler',
|
|
44
|
-
strict: true,
|
|
45
|
-
skipLibCheck: true,
|
|
46
|
-
noEmit: true,
|
|
47
|
-
types: [],
|
|
48
|
-
},
|
|
49
|
-
include: ['worker/**/*.ts'],
|
|
50
|
-
});
|
|
51
|
-
put(root, `${directory}/worker/index.ts`, `interface Binding { fetch(request: Request): Promise<Response> }
|
|
52
|
-
interface Env { ASSETS: Binding; ${api ? 'API: Binding;' : ''} }
|
|
53
|
-
|
|
54
|
-
${api
|
|
55
|
-
? `// Browser-supplied edge identity headers never cross the API boundary.
|
|
56
|
-
function forwardedHeaders(request: Request): Headers {
|
|
57
|
-
const headers = new Headers();
|
|
58
|
-
for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
|
|
59
|
-
const value = request.headers.get(name);
|
|
60
|
-
if (value) headers.set(name, value);
|
|
61
|
-
}
|
|
62
|
-
return headers;
|
|
63
|
-
}
|
|
64
|
-
function privateResponse(response: Response): Response {
|
|
65
|
-
const headers = new Headers(response.headers);
|
|
66
|
-
for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
|
|
67
|
-
headers.set('cache-control', 'private, no-store');
|
|
68
|
-
return new Response(response.body, { status: response.status, headers });
|
|
69
|
-
}
|
|
70
|
-
async function proxyApi(request: Request, env: Env): Promise<Response> {
|
|
71
|
-
const url = new URL(request.url);
|
|
72
|
-
const target = new URL('https://api.internal');
|
|
73
|
-
target.pathname = url.pathname;
|
|
74
|
-
target.search = url.search;
|
|
75
|
-
try {
|
|
76
|
-
const upstream = new Request(new Request(target, request), {
|
|
77
|
-
headers: forwardedHeaders(request), redirect: 'manual',
|
|
78
|
-
signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]),
|
|
7
|
+
dependencies: { '@workspace/contracts': 'workspace:*' },
|
|
79
8
|
});
|
|
80
|
-
|
|
81
|
-
} catch {
|
|
82
|
-
return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
`
|
|
86
|
-
: ''}
|
|
87
|
-
export default {
|
|
88
|
-
async fetch(request: Request, env: Env): Promise<Response> {
|
|
89
|
-
const pathname = new URL(request.url).pathname;
|
|
90
|
-
const apiPath = pathname === '/api' || pathname.startsWith('/api/');
|
|
91
|
-
if (!apiPath) return env.ASSETS.fetch(request);
|
|
92
|
-
${api ? 'return proxyApi(request, env);' : "return Response.json({ error: 'API not configured' }, { status: 404, headers: { 'cache-control': 'private, no-store' } });"}
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
`);
|
|
96
|
-
if (!api)
|
|
97
|
-
return;
|
|
98
|
-
put(root, `${directory}/lib/api-client.ts`, `import { Platform } from 'react-native';
|
|
99
|
-
import { createApiClient } from '@workspace/contracts';
|
|
9
|
+
put(root, `${directory}/lib/api-client.ts`, `import { createApiClient } from '@workspace/contracts';
|
|
100
10
|
|
|
101
11
|
type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
|
|
102
12
|
|
|
103
13
|
function validProtocol(url: URL): boolean {
|
|
104
14
|
return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
|
|
105
15
|
}
|
|
106
|
-
|
|
16
|
+
function nativeApiOrigin(): string {
|
|
107
17
|
const configured = process.env.EXPO_PUBLIC_API_URL;
|
|
108
18
|
if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
|
|
109
19
|
const origin = new URL(configured);
|
|
@@ -113,18 +23,16 @@ export function nativeApiOrigin(): string {
|
|
|
113
23
|
return origin.origin;
|
|
114
24
|
}
|
|
115
25
|
function apiBaseURL(): string {
|
|
116
|
-
if (Platform.OS === 'web') return '/api';
|
|
117
26
|
return nativeApiOrigin() + '/api';
|
|
118
27
|
}
|
|
119
28
|
|
|
120
|
-
//
|
|
121
|
-
|
|
29
|
+
// Consumers can extend transport headers for their own application. No server secret belongs here.
|
|
30
|
+
function createApplicationApiClient(options: Options = {}) {
|
|
122
31
|
const client = () => createApiClient(apiBaseURL(), {
|
|
123
|
-
...options, credentials:
|
|
32
|
+
...options, credentials: 'omit',
|
|
124
33
|
});
|
|
125
34
|
return {
|
|
126
35
|
health: (init?: RequestInit) => client().health(init),
|
|
127
|
-
session: (init?: RequestInit) => client().session(init),
|
|
128
36
|
};
|
|
129
37
|
}
|
|
130
38
|
|