anhedral 0.15.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 +29 -38
- 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/UPSTREAM.json +7 -1
- 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 +2 -1
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +16 -5
- 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 +14 -74
- 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 +2 -1
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -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/textarea.tsx +1 -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/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -66
- 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 +39 -322
- package/dist/dependencies.d.ts +29 -6
- package/dist/dependencies.js +61 -14
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- package/dist/platforms/mobile.js +1 -20
- package/dist/platforms/web.d.ts +1 -1
- package/dist/platforms/web.js +27 -75
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -82
- package/dist/registry/options.js +1 -5
- package/dist/registry/resolve.d.ts +1 -1
- package/dist/registry/resolve.js +2 -10
- package/dist/registry/usage.js +3 -9
- package/dist/scaffold/backend.js +0 -3
- package/dist/scaffold/database.js +2 -1
- package/dist/scaffold/documentation.js +82 -20
- package/dist/scaffold/expo-runtime.js +3 -4
- package/dist/scaffold/native-ui.js +12 -7
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/workspace.js +26 -21
- package/dist/stack-registry.d.ts +2 -8
- package/dist/stack-registry.js +11 -87
- package/dist/standard.js +1 -11
- 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 -20
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -44
- package/docs/stack-standard.md +11 -60
- package/docs/ui.md +33 -0
- package/docs/verification.md +191 -0
- package/package.json +19 -18
- 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 -129
- 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 -112
- 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 -157
- package/dist/delivery.d.ts +0 -82
- package/dist/delivery.js +0 -489
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -12
- package/dist/integration-service-readers.js +0 -92
- 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 -370
- 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 -671
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -47
- package/dist/project-state.js +0 -480
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -180
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -85
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -103
- 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 -136
- package/dist/providers/definitions.d.ts +0 -115
- package/dist/providers/definitions.js +0 -42
- 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 -56
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -52
- 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 -234
- 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 -283
- package/dist/provision.d.ts +0 -47
- package/dist/provision.js +0 -208
- 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 -117
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -210
- package/dist/registry/bootstrap.d.ts +0 -3
- package/dist/registry/bootstrap.js +0 -5
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -83
- 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 -2
- package/dist/scaffold/auth.js +0 -76
- 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 -208
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -203
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -257
- package/dist/scaffold/integrations.d.ts +0 -2
- package/dist/scaffold/integrations.js +0 -11
- package/dist/scaffold/managed-email.d.ts +0 -3
- package/dist/scaffold/managed-email.js +0 -47
- package/dist/scaffold/password-reset.d.ts +0 -1
- package/dist/scaffold/password-reset.js +0 -99
- package/dist/scaffold/private-files.d.ts +0 -2
- package/dist/scaffold/private-files.js +0 -78
- package/dist/scaffold/web-billing.d.ts +0 -2
- package/dist/scaffold/web-billing.js +0 -48
- 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 -71
- 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 -48
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -216
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -96
- package/dist/ship.d.ts +0 -35
- package/dist/ship.js +0 -107
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
package/dist/platforms/mobile.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { writeReactLintConfig } from './lint.js';
|
|
4
4
|
import { appendGitignore, writeFile } from '../util.js';
|
|
5
5
|
import { childPackageName, jsString } from '../render.js';
|
|
6
|
-
import { MOBILE_APP_DEPENDENCIES
|
|
6
|
+
import { MOBILE_APP_DEPENDENCIES } from '../dependencies.js';
|
|
7
7
|
import { scaffoldNativeUI } from '../scaffold/native-ui.js';
|
|
8
8
|
import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
|
|
9
9
|
function expoScheme(projectName) {
|
|
@@ -39,12 +39,6 @@ export async function scaffoldExpo(context) {
|
|
|
39
39
|
build: 'pnpm typecheck',
|
|
40
40
|
typecheck: 'tsc --noEmit',
|
|
41
41
|
lint: 'eslint . --max-warnings 0',
|
|
42
|
-
'eas:login': `pnpm dlx eas-cli@${EAS_CLI_VERSION} login`,
|
|
43
|
-
'build:simulator:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile simulator`,
|
|
44
|
-
'build:internal:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile preview`,
|
|
45
|
-
'build:internal:android': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform android --profile preview`,
|
|
46
|
-
'build:production:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile production`,
|
|
47
|
-
'build:production:android': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform android --profile production`,
|
|
48
42
|
},
|
|
49
43
|
dependencies: {
|
|
50
44
|
...MOBILE_APP_DEPENDENCIES.dependencies,
|
|
@@ -129,19 +123,6 @@ export default function HomeScreen() {
|
|
|
129
123
|
}
|
|
130
124
|
`);
|
|
131
125
|
writeFile(path.join(dir, '.env.example'), '');
|
|
132
|
-
writeFile(path.join(dir, 'eas.json'), JSON.stringify({
|
|
133
|
-
cli: { version: '>= 16.0.0' },
|
|
134
|
-
build: {
|
|
135
|
-
development: { developmentClient: true, distribution: 'internal' },
|
|
136
|
-
preview: {
|
|
137
|
-
environment: 'preview',
|
|
138
|
-
distribution: 'internal',
|
|
139
|
-
android: { buildType: 'apk' },
|
|
140
|
-
},
|
|
141
|
-
simulator: { environment: 'preview', ios: { simulator: true } },
|
|
142
|
-
production: { environment: 'production', autoIncrement: true },
|
|
143
|
-
},
|
|
144
|
-
}, null, 2) + '\n');
|
|
145
126
|
scaffoldExpoRuntime(context);
|
|
146
127
|
appendGitignore(dir, [
|
|
147
128
|
'.env',
|
package/dist/platforms/web.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
export declare function scaffoldWeb({ root, options }: RecipeContext): void;
|
|
2
|
+
export declare function scaffoldWeb({ root, options, has }: RecipeContext): void;
|
|
3
3
|
export declare const WEB_API_PROXY = "export interface ApiBinding { fetch(request: Request): Promise<Response> }\ntype Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };\nfunction developmentOrigin(configured?: string): string {\n const url = new URL(configured || 'http://127.0.0.1:8787');\n const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);\n const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];\n if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');\n return url.origin;\n}\nfunction backendOrigin(options: Options): string {\n if (options.development) return developmentOrigin(options.devOrigin);\n if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');\n return 'https://api.internal';\n}\nfunction apiTarget(request: Request, origin: string): URL {\n const url = new URL(request.url);\n if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');\n return new URL(url.pathname + url.search, origin);\n}\nfunction forwardedHeaders(request: Request): Headers {\n const headers = new Headers();\n for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {\n const value = request.headers.get(name); if (value) headers.set(name, value);\n }\n return headers;\n}\nfunction upstreamRequest(request: Request, target: URL): Request {\n const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };\n if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }\n return new Request(target, settings);\n}\nfunction privateResponse(response: Response, development: boolean): Response {\n const headers = new Headers(response.headers);\n for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);\n // Node fetch already decoded the local HTTP response. Next must frame/compress\n // those decoded bytes itself; the sidecar's wire headers no longer describe them.\n if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }\n headers.set('cache-control', 'private, no-store');\n return new Response(response.body, { status: response.status, headers });\n}\nexport async function proxyApi(request: Request, options: Options): Promise<Response> {\n try {\n const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));\n const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);\n return privateResponse(response, options.development);\n } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }\n}\n";
|
package/dist/platforms/web.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { initializeUiMetadata } from '../ui-project.js';
|
|
1
2
|
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import path from 'node:path';
|
|
3
5
|
import { resourceName, childPackageName, jsString } from '../render.js';
|
|
4
6
|
import { WEB_DEPENDENCIES } from '../dependencies.js';
|
|
5
7
|
import { json, put, workerConfig } from '../scaffold/files.js';
|
|
6
|
-
export function scaffoldWeb({ root, options }) {
|
|
8
|
+
export function scaffoldWeb({ root, options, has }) {
|
|
7
9
|
const app = 'apps/web';
|
|
8
10
|
json(root, `${app}/package.json`, {
|
|
9
11
|
name: childPackageName(options.name, 'web'),
|
|
@@ -23,7 +25,7 @@ export function scaffoldWeb({ root, options }) {
|
|
|
23
25
|
},
|
|
24
26
|
dependencies: {
|
|
25
27
|
...WEB_DEPENDENCIES.dependencies,
|
|
26
|
-
'@workspace/contracts': 'workspace:*',
|
|
28
|
+
...(has('hono') ? { '@workspace/contracts': 'workspace:*' } : {}),
|
|
27
29
|
'@workspace/styling': 'workspace:*',
|
|
28
30
|
},
|
|
29
31
|
devDependencies: {
|
|
@@ -37,7 +39,9 @@ export function scaffoldWeb({ root, options }) {
|
|
|
37
39
|
compatibility_flags: ['nodejs_compat', 'global_fetch_strictly_public'],
|
|
38
40
|
assets: { directory: '.open-next/assets', binding: 'ASSETS' },
|
|
39
41
|
services: [
|
|
40
|
-
|
|
42
|
+
...(has('hono')
|
|
43
|
+
? [{ binding: 'ANHEDRAL_API', service: resourceName(options.name, 'api') }]
|
|
44
|
+
: []),
|
|
41
45
|
{ binding: 'WORKER_SELF_REFERENCE', service: resourceName(options.name, 'web') },
|
|
42
46
|
],
|
|
43
47
|
});
|
|
@@ -49,7 +53,7 @@ if (previewOrigin) {
|
|
|
49
53
|
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.pathname !== '/' || url.search || url.hash) throw new Error('ANHEDRAL_PREVIEW_ORIGIN must be an HTTP(S) origin.');
|
|
50
54
|
allowedDevOrigins = [url.hostname];
|
|
51
55
|
}
|
|
52
|
-
const config: NextConfig = { allowedDevOrigins, transpilePackages: ['@workspace/contracts', '@workspace/styling'], images: { unoptimized: true } };
|
|
56
|
+
const config: NextConfig = { allowedDevOrigins, transpilePackages: ${JSON.stringify(has('hono') ? ['@workspace/contracts', '@workspace/styling'] : ['@workspace/styling'])}, images: { unoptimized: true } };
|
|
53
57
|
export default config;
|
|
54
58
|
`);
|
|
55
59
|
put(root, `${app}/open-next.config.ts`, `import { defineCloudflareConfig } from '@opennextjs/cloudflare';
|
|
@@ -104,6 +108,7 @@ export default defineConfig([...next, ...ts, globalIgnores(['.next/**', '.open-n
|
|
|
104
108
|
},
|
|
105
109
|
iconLibrary: 'lucide',
|
|
106
110
|
});
|
|
111
|
+
initializeUiMetadata(path.join(root, app), 'web');
|
|
107
112
|
put(root, `${app}/lib/utils.ts`, `import { clsx, type ClassValue } from 'clsx';
|
|
108
113
|
import { twMerge } from 'tailwind-merge';
|
|
109
114
|
export function cn(...values: ClassValue[]) { return twMerge(clsx(values)); }
|
|
@@ -135,16 +140,29 @@ a { color: inherit; } .button, input { min-height: 2.75rem; padding: .65rem 1rem
|
|
|
135
140
|
import Link from 'next/link';
|
|
136
141
|
import './globals.css';
|
|
137
142
|
export const metadata: Metadata = { title: ${jsString(options.name)}, description: 'Anhedral application' };
|
|
138
|
-
export default function Layout({ children }: { children: React.ReactNode }) { return <html lang="en"><body><main><nav aria-label="Main"><Link href="/">Home</Link
|
|
143
|
+
export default function Layout({ children }: { children: React.ReactNode }) { return <html lang="en"><body><main><nav aria-label="Main"><Link href="/">Home</Link></nav>{children}</main></body></html>; }
|
|
139
144
|
`);
|
|
140
|
-
put(root, `${app}/app/page.tsx`, `import {
|
|
141
|
-
export default
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
put(root, `${app}/app/page.tsx`, `import { FoundationExample } from '@/components/foundation-example';
|
|
146
|
+
export default function Home() {
|
|
147
|
+
return <section className="stack"><h1>${escapeJsx(options.name)}</h1><p>Next.js on Cloudflare, with Anhedral UI.</p><p className="muted" data-rendering="server">Prerendered at build time; ready to hydrate in the browser.</p><FoundationExample /></section>;
|
|
148
|
+
}
|
|
149
|
+
`);
|
|
150
|
+
put(root, `${app}/components/foundation-example.tsx`, `'use client';
|
|
151
|
+
import { useState } from 'react';
|
|
152
|
+
import { Button } from '@/components/ui/button';
|
|
153
|
+
import { Input } from '@/components/ui/input';
|
|
154
|
+
import { Label } from '@/components/ui/label';
|
|
155
|
+
export function FoundationExample() {
|
|
156
|
+
const [idea, setIdea] = useState('My next application');
|
|
157
|
+
return <section className="stack"><Label htmlFor="idea">What will you build?</Label><Input id="idea" value={idea} onChange={event => setIdea(event.target.value)} /><p aria-live="polite">{idea}</p><Button onClick={() => setIdea('My next application')}>Reset example</Button></section>;
|
|
144
158
|
}
|
|
145
159
|
`);
|
|
146
160
|
put(root, `${app}/app/loading.tsx`, `export default function Loading() { return <p role="status">Loading…</p>; }\n`);
|
|
147
161
|
put(root, `${app}/app/error.tsx`, `'use client';\nexport default function ErrorPage({ reset }: { reset: () => void }) { return <section><h1>Unable to load this page</h1><button onClick={reset}>Try again</button></section>; }\n`);
|
|
162
|
+
put(root, `${app}/public/_headers`, '/_next/static/*\n Cache-Control: public, max-age=31536000, immutable\n/*\n X-Content-Type-Options: nosniff\n');
|
|
163
|
+
put(root, `${app}/public/robots.txt`, 'User-agent: *\nAllow: /\n');
|
|
164
|
+
if (!has('hono'))
|
|
165
|
+
return;
|
|
148
166
|
put(root, `${app}/lib/api-proxy.ts`, WEB_API_PROXY);
|
|
149
167
|
put(root, `${app}/lib/server-api.ts`, `import 'server-only';
|
|
150
168
|
import { getCloudflareContext } from '@opennextjs/cloudflare';
|
|
@@ -172,31 +190,6 @@ export const PATCH = apiRequest;
|
|
|
172
190
|
export const DELETE = apiRequest;
|
|
173
191
|
export const HEAD = apiRequest;
|
|
174
192
|
export const OPTIONS = apiRequest;
|
|
175
|
-
`);
|
|
176
|
-
put(root, `${app}/lib/auth-client.ts`, `import { createAuthClient } from 'better-auth/react';\nexport const authClient = createAuthClient();\n`);
|
|
177
|
-
put(root, `${app}/app/sign-in/page.tsx`, WEB_SIGN_IN);
|
|
178
|
-
put(root, `${app}/components/sign-out.tsx`, `'use client';
|
|
179
|
-
import { useState } from 'react';
|
|
180
|
-
import { useRouter } from 'next/navigation';
|
|
181
|
-
import { authClient } from '@/lib/auth-client';
|
|
182
|
-
import { Button } from '@/components/ui/button';
|
|
183
|
-
export function SignOut() { const [error, setError] = useState(''); const [pending, setPending] = useState(false); const router = useRouter();
|
|
184
|
-
async function logout() { setPending(true); setError(''); try { const result = await authClient.signOut(); if (result.error) throw Error('Unable to sign out.'); router.replace('/sign-in'); router.refresh(); } catch { setError('Unable to sign out. Please retry.'); } finally { setPending(false); } }
|
|
185
|
-
return <><Button disabled={pending} onClick={() => void logout()}>{pending ? 'Signing out…' : 'Sign out'}</Button><p role="status">{error}</p></>; }
|
|
186
|
-
`);
|
|
187
|
-
put(root, `${app}/app/account/page.tsx`, `import { headers } from 'next/headers';
|
|
188
|
-
import { redirect } from 'next/navigation';
|
|
189
|
-
import { sessionSchema } from '@workspace/contracts';
|
|
190
|
-
import { apiRequest } from '@/lib/server-api';
|
|
191
|
-
import { SignOut } from '@/components/sign-out';
|
|
192
|
-
export default async function Account() {
|
|
193
|
-
const incoming = await headers();
|
|
194
|
-
const response = await apiRequest(new Request('https://app.internal/api/session', { headers: { cookie: incoming.get('cookie') ?? '' } }));
|
|
195
|
-
if (response.status === 401) redirect('/sign-in');
|
|
196
|
-
if (!response.ok) throw Error('Session verification is unavailable.');
|
|
197
|
-
const { user } = sessionSchema.parse(await response.json());
|
|
198
|
-
return <section className="stack"><h1>Account</h1><p>{user.email}</p><SignOut /></section>;
|
|
199
|
-
}
|
|
200
193
|
`);
|
|
201
194
|
put(root, `${app}/.env.example`, '# Development only. Production uses the ANHEDRAL_API service binding.\nAPI_INTERNAL_URL=http://127.0.0.1:8787\n');
|
|
202
195
|
}
|
|
@@ -256,44 +249,3 @@ export async function proxyApi(request: Request, options: Options): Promise<Resp
|
|
|
256
249
|
} catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }
|
|
257
250
|
}
|
|
258
251
|
`;
|
|
259
|
-
const WEB_SIGN_IN = `'use client';
|
|
260
|
-
import { useRef, useState, type FormEvent } from 'react';
|
|
261
|
-
import { useRouter } from 'next/navigation';
|
|
262
|
-
import Link from 'next/link';
|
|
263
|
-
import { authClient } from '@/lib/auth-client';
|
|
264
|
-
import { Button } from '@/components/ui/button';
|
|
265
|
-
import { Input } from '@/components/ui/input';
|
|
266
|
-
import { Label } from '@/components/ui/label';
|
|
267
|
-
function verificationPending(create: boolean, signedIn: boolean): boolean { return create && !signedIn; }
|
|
268
|
-
async function requestVerification(email: string) {
|
|
269
|
-
const result = await authClient.sendVerificationEmail({ email, callbackURL: '/sign-in' });
|
|
270
|
-
if (result.error) throw Error('Verification unavailable');
|
|
271
|
-
}
|
|
272
|
-
async function authenticate(data: FormData, create: boolean) {
|
|
273
|
-
const email = String(data.get('email')); const password = String(data.get('password')); const name = String(data.get('name'));
|
|
274
|
-
const result = create ? await authClient.signUp.email({ email, password, name, callbackURL: '/sign-in' }) : await authClient.signIn.email({ email, password });
|
|
275
|
-
if (result.error) throw Error('Sign in failed.');
|
|
276
|
-
return Boolean(result.data?.token);
|
|
277
|
-
}
|
|
278
|
-
export default function SignIn() {
|
|
279
|
-
const form = useRef<HTMLFormElement>(null);
|
|
280
|
-
const router = useRouter(); const [create, setCreate] = useState(false); const [pending, setPending] = useState(false); const [error, setError] = useState('');
|
|
281
|
-
async function submit(event: FormEvent<HTMLFormElement>) { event.preventDefault(); if (pending) return; setPending(true); setError('');
|
|
282
|
-
const data = new FormData(event.currentTarget);
|
|
283
|
-
try { const signedIn = await authenticate(data, create); if (verificationPending(create, signedIn)) { form.current?.reset(); setCreate(false); setError('Check your email to verify your account, then sign in.'); return; } router.replace('/account'); router.refresh(); } catch { setError('Unable to sign in. Check your details and retry.'); } finally { setPending(false); }
|
|
284
|
-
}
|
|
285
|
-
async function resend() {
|
|
286
|
-
const input = form.current?.querySelector<HTMLInputElement>('[name="email"]');
|
|
287
|
-
if (pending || !input?.reportValidity()) return;
|
|
288
|
-
const email = input.value;
|
|
289
|
-
setPending(true); setError('');
|
|
290
|
-
try {
|
|
291
|
-
await requestVerification(email);
|
|
292
|
-
setError('If verification is needed, check your email for the link.');
|
|
293
|
-
} catch { setError('Unable to request verification. Please retry.'); }
|
|
294
|
-
finally { setPending(false); }
|
|
295
|
-
}
|
|
296
|
-
const labels = create ? { title: 'Create account', password: 'new-password', toggle: 'Use an existing account' } : { title: 'Sign in', password: 'current-password', toggle: 'Create an account' };
|
|
297
|
-
return <section className="stack"><h1>{labels.title}</h1><form ref={form} onSubmit={submit}>{create && <Label>Name<Input name="name" required autoComplete="name" /></Label>}<Label>Email<Input name="email" type="email" required autoComplete="email" /></Label><Label>Password<Input name="password" type="password" minLength={8} required autoComplete={labels.password} /></Label><Button type="submit" disabled={pending}>{pending ? 'Working…' : labels.title}</Button><p role="status">{error}</p><Link href="/reset-password">Forgot your password?</Link><Button type="button" disabled={pending} onClick={() => void resend()}>Resend verification email</Button><Button type="button" disabled={pending} onClick={() => setCreate(!create)}>{labels.toggle}</Button></form></section>;
|
|
298
|
-
}
|
|
299
|
-
`;
|
package/dist/project-config.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
export declare const PROJECT_CONFIG_FILE = "anhedral.json";
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export type ProjectSection = (typeof PROJECT_CONFIG_SECTIONS)[number];
|
|
5
|
-
export type ProjectConfig = {
|
|
6
|
-
schemaVersion: 1;
|
|
7
|
-
} & Partial<Record<ProjectSection, unknown>>;
|
|
8
|
-
/** Validate the envelope independently; each domain validates its own selected section. */
|
|
9
|
-
export declare function parseProjectConfig(value: unknown): ProjectConfig;
|
|
10
|
-
export declare function projectConfigPath(root: string): string;
|
|
11
|
-
export declare function readProjectConfig(root: string): ProjectConfig;
|
|
12
|
-
export declare function hasProjectSection(root: string, section: ProjectSection): boolean;
|
|
13
|
-
export declare function readProjectSection<T = any>(root: string, section: ProjectSection): T;
|
|
14
|
-
export declare function writeProjectSection(root: string, section: ProjectSection, value: unknown): void;
|
|
2
|
+
/** Called only inside a fresh staged workspace. Contains nonsecret generation provenance. */
|
|
3
|
+
export declare function writeProjectSection(root: string, section: string, value: unknown): void;
|
package/dist/project-config.js
CHANGED
|
@@ -1,88 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { lstatSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
|
-
import { withSourceWriteLock } from './transaction.js';
|
|
5
|
-
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from './bounded-file.js';
|
|
6
3
|
export const PROJECT_CONFIG_FILE = 'anhedral.json';
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'setup',
|
|
12
|
-
'providers',
|
|
13
|
-
'cloudflare',
|
|
14
|
-
'registry',
|
|
15
|
-
];
|
|
16
|
-
/** Validate the envelope independently; each domain validates its own selected section. */
|
|
17
|
-
export function parseProjectConfig(value) {
|
|
18
|
-
if (!value ||
|
|
19
|
-
typeof value !== 'object' ||
|
|
20
|
-
Array.isArray(value) ||
|
|
21
|
-
value.schemaVersion !== 1 ||
|
|
22
|
-
Object.keys(value).some((key) => key !== 'schemaVersion' && !PROJECT_CONFIG_SECTIONS.includes(key)))
|
|
23
|
-
throw new Error('Invalid anhedral.json configuration.');
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
export function projectConfigPath(root) {
|
|
27
|
-
return path.join(root, PROJECT_CONFIG_FILE);
|
|
28
|
-
}
|
|
29
|
-
export function readProjectConfig(root) {
|
|
30
|
-
const source = readBoundedFile(projectConfigPath(root), PROJECT_CONFIG_MAX_BYTES).toString('utf8');
|
|
31
|
-
try {
|
|
32
|
-
return parseProjectConfig(JSON.parse(source));
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
throw new Error('Invalid anhedral.json configuration.');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function assertSection(section) {
|
|
39
|
-
if (!PROJECT_CONFIG_SECTIONS.includes(section))
|
|
40
|
-
throw new Error('Unknown anhedral.json section.');
|
|
41
|
-
}
|
|
42
|
-
export function hasProjectSection(root, section) {
|
|
43
|
-
assertSection(section);
|
|
44
|
-
if (!lstatSync(projectConfigPath(root), { throwIfNoEntry: false }))
|
|
45
|
-
return false;
|
|
46
|
-
return Object.hasOwn(readProjectConfig(root), section);
|
|
47
|
-
}
|
|
48
|
-
// Domain callers retain responsibility for validating their complete section contracts.
|
|
49
|
-
export function readProjectSection(root, section) {
|
|
50
|
-
assertSection(section);
|
|
51
|
-
const value = readProjectConfig(root)[section];
|
|
52
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
53
|
-
throw new Error(`Missing or invalid anhedral.json ${section} section.`);
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
/** Atomically replace one section while preserving other domains' configuration. */
|
|
57
|
-
function writeSection(root, section, value) {
|
|
58
|
-
assertSection(section);
|
|
59
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
60
|
-
throw new Error(`Invalid anhedral.json ${section} section.`);
|
|
61
|
-
const file = projectConfigPath(root);
|
|
62
|
-
const previous = lstatSync(file, { throwIfNoEntry: false }) ? readProjectConfig(root) : {};
|
|
63
|
-
const config = { ...previous, schemaVersion: 1, [section]: value };
|
|
64
|
-
const ordered = {
|
|
65
|
-
schemaVersion: 1,
|
|
66
|
-
...Object.fromEntries(PROJECT_CONFIG_SECTIONS.filter((key) => Object.hasOwn(config, key)).map((key) => [
|
|
67
|
-
key,
|
|
68
|
-
config[key],
|
|
69
|
-
])),
|
|
70
|
-
};
|
|
71
|
-
const bytes = JSON.stringify(ordered, null, 2) + '\n';
|
|
72
|
-
if (Buffer.byteLength(bytes) > PROJECT_CONFIG_MAX_BYTES)
|
|
73
|
-
throw new Error('anhedral.json exceeds its size limit.');
|
|
74
|
-
// Avoid changing source bytes or permissions when the requested section is unchanged.
|
|
75
|
-
if (lstatSync(file, { throwIfNoEntry: false }) && readFileSync(file, 'utf8') === bytes)
|
|
76
|
-
return;
|
|
77
|
-
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
4
|
+
/** Called only inside a fresh staged workspace. Contains nonsecret generation provenance. */
|
|
5
|
+
export function writeProjectSection(root, section, value) {
|
|
6
|
+
const file = path.join(root, PROJECT_CONFIG_FILE);
|
|
7
|
+
let previous = {};
|
|
78
8
|
try {
|
|
79
|
-
|
|
80
|
-
renameSync(temporary, file);
|
|
9
|
+
previous = JSON.parse(readFileSync(file, 'utf8'));
|
|
81
10
|
}
|
|
82
|
-
|
|
83
|
-
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error.code !== 'ENOENT')
|
|
13
|
+
throw error;
|
|
84
14
|
}
|
|
85
|
-
}
|
|
86
|
-
export function writeProjectSection(root, section, value) {
|
|
87
|
-
withSourceWriteLock(root, () => writeSection(root, section, value));
|
|
15
|
+
writeFileSync(file, JSON.stringify({ ...previous, schemaVersion: 1, [section]: value }, null, 2) + '\n');
|
|
88
16
|
}
|
package/dist/registry/options.js
CHANGED
|
@@ -18,11 +18,7 @@ function parseStandardFlags(remaining) {
|
|
|
18
18
|
gitSpecified = readGitFlag(token, gitSpecified);
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
products.add(token.slice(2));
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
throw new Error(`Unknown init option: ${token}. The core stack is always included; optional additions are --stripe and --revenuecat.`);
|
|
21
|
+
throw new Error(`Unknown init option: ${token}. Run anhedral init --help.`);
|
|
26
22
|
}
|
|
27
23
|
return { products, hosting, gitSpecified };
|
|
28
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hosting, StandardOptions, StandardProduct, StackRegistryItem } from './types.js';
|
|
2
2
|
export declare const CORE_PRODUCTS: readonly StandardProduct[];
|
|
3
|
-
/** Every initialization uses
|
|
3
|
+
/** Every initialization uses the same foundation. */
|
|
4
4
|
export declare function resolveStandardProducts(selected: Set<StandardProduct>, hosting: Hosting): void;
|
|
5
5
|
export interface ResolvedStackRegistry {
|
|
6
6
|
schemaVersion: number;
|
package/dist/registry/resolve.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { dependencyOrder } from '../dependency-order.js';
|
|
2
2
|
import { STANDARD_PRODUCTS, STACK_REGISTRY, getStackDefinition, getStackItem, } from '../stack-registry.js';
|
|
3
3
|
import { createResolutionContext } from './context.js';
|
|
4
|
-
export const CORE_PRODUCTS = [
|
|
5
|
-
|
|
6
|
-
'expo',
|
|
7
|
-
'hono',
|
|
8
|
-
'd1',
|
|
9
|
-
'r2',
|
|
10
|
-
'better-auth',
|
|
11
|
-
'styling',
|
|
12
|
-
];
|
|
13
|
-
/** Every initialization uses one foundation; only payment additions are optional. */
|
|
4
|
+
export const CORE_PRODUCTS = ['next', 'styling'];
|
|
5
|
+
/** Every initialization uses the same foundation. */
|
|
14
6
|
export function resolveStandardProducts(selected, hosting) {
|
|
15
7
|
if (hosting !== 'cloudflare')
|
|
16
8
|
throw new Error('Anhedral applications use Cloudflare Workers.');
|
package/dist/registry/usage.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { COMMANDS, GLOBAL_OPTIONS, optionHelp } from '../command-schema.js';
|
|
2
|
-
// Preserve the presentation API for consumers; all option text comes from typed definitions.
|
|
3
2
|
export const COMMAND_HELP = Object.fromEntries(Object.entries(COMMANDS).map(([name, entry]) => [
|
|
4
3
|
name,
|
|
5
|
-
{ ...entry, options: entry.options.
|
|
4
|
+
{ ...entry, options: entry.options.map(optionHelp) },
|
|
6
5
|
]));
|
|
7
|
-
const primary = ['init', 'auth', 'ship', 'add', 'registry', 'inspect', 'doctor', 'connect'];
|
|
8
|
-
const common = GLOBAL_OPTIONS.map(optionHelp);
|
|
9
6
|
export function commandHelp(command) {
|
|
10
7
|
const entry = COMMAND_HELP[command];
|
|
11
8
|
if (!entry)
|
|
12
9
|
return undefined;
|
|
13
|
-
return `${entry.description}\n\nUsage: anhedral ${entry.usage}\n\nOptions:\n${[...entry.options, ...
|
|
10
|
+
return `${entry.description}\n\nUsage: anhedral ${entry.usage}\n\nOptions:\n${[...entry.options, ...GLOBAL_OPTIONS.map(optionHelp)].map((option) => ` ${option}`).join('\n')}\n\n${entry.note}\n`;
|
|
14
11
|
}
|
|
15
|
-
export const STANDARD_USAGE = `Anhedral
|
|
16
|
-
.filter(([name]) => !primary.includes(name))
|
|
17
|
-
.map(([name, entry]) => ` ${name.padEnd(12)}${entry.description}`)
|
|
18
|
-
.join('\n')}\n\nDefault: Next.js web + native Expo + Hono + Drizzle/D1 + private R2, with Better Auth and shared styling. Stripe and RevenueCat are the only optional additions.\nExamples:\n anhedral init client-app\n anhedral init client-app --stripe --revenuecat\n anhedral auth client-app\n anhedral ship client-app --dry-run\n\nUse anhedral <command> --help for options and examples.\nUse anhedral help <command> for the same focused help.\nGlobal options:\n${common.map((option) => ` ${option}`).join('\n')}\n -v, --version Show the CLI version.\n`;
|
|
12
|
+
export const STANDARD_USAGE = `Anhedral — an open-source stack foundation\n\n${commandHelp('init')}\n${commandHelp('ui')}\n${commandHelp('add')}\n${commandHelp('stack')}\n -v, --version Show the CLI version.\n`;
|
package/dist/scaffold/backend.js
CHANGED
|
@@ -6,14 +6,11 @@ export function scaffoldContracts(root) {
|
|
|
6
6
|
import { createHttpClient, type HttpOptions } from './http';
|
|
7
7
|
|
|
8
8
|
export const healthSchema = z.object({ ok: z.literal(true) });
|
|
9
|
-
export const sessionSchema = z.object({ user: z.object({ id: z.string(), name: z.string(), email: z.email() }) });
|
|
10
|
-
export type Session = z.infer<typeof sessionSchema>;
|
|
11
9
|
|
|
12
10
|
export function createApiClient(baseURL = '/api', options: HttpOptions = {}) {
|
|
13
11
|
const request = createHttpClient(baseURL, options);
|
|
14
12
|
return {
|
|
15
13
|
health: (init?: RequestInit) => request('/health', healthSchema, init),
|
|
16
|
-
session: (init?: RequestInit) => request('/session', sessionSchema, init),
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
16
|
`, { zod: STACK_DEPENDENCIES.zod });
|
|
@@ -36,5 +36,6 @@ process.exitCode = result.status ?? 1;
|
|
|
36
36
|
});
|
|
37
37
|
patchPackage(root, 'apps/api/package.json', { dependencies: { '@workspace/db': 'workspace:*' } });
|
|
38
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" +
|
|
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(); });"));
|
|
40
41
|
}
|
|
@@ -1,40 +1,102 @@
|
|
|
1
|
+
import { capabilityReferences } from '../capability-references.js';
|
|
1
2
|
import { put } from './files.js';
|
|
2
3
|
export function writeSetupDocumentation(root, options) {
|
|
3
|
-
|
|
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}
|
|
4
8
|
|
|
5
|
-
|
|
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.
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
## Develop
|
|
8
14
|
|
|
9
|
-
|
|
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.
|
|
10
17
|
|
|
11
|
-
|
|
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.
|
|
12
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
|
+
}
|
|
13
64
|
put(root, 'README.md', `# ${options.name}
|
|
14
65
|
|
|
15
|
-
Next.js
|
|
66
|
+
Next.js App Router/OpenNext + Expo native + shadcn UI + Hono/workerd + Drizzle/D1 + private R2.
|
|
16
67
|
|
|
17
|
-
##
|
|
68
|
+
## Develop locally
|
|
18
69
|
|
|
19
|
-
Use the Node and pnpm versions in package.json.
|
|
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.
|
|
20
71
|
|
|
21
|
-
|
|
22
|
-
2. Run pnpm db:generate, review the generated SQL, then pnpm db:migrate (local D1 only by default).
|
|
23
|
-
3. Run pnpm dev. Open http://localhost:3000. Create an account using the Sign in / account link.
|
|
24
|
-
4. Native development uses pnpm --dir apps/mobile start. Configure EXPO_PUBLIC_API_URL in apps/mobile/.env for an API address reachable by the device and set BETTER_AUTH_URL to that origin when testing native. Use HTTPS outside local development.
|
|
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.
|
|
25
73
|
|
|
26
|
-
##
|
|
74
|
+
## UI and device capabilities
|
|
27
75
|
|
|
28
|
-
|
|
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.
|
|
77
|
+
|
|
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.
|
|
79
|
+
|
|
80
|
+
## Data and private storage
|
|
81
|
+
|
|
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.
|
|
83
|
+
|
|
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.
|
|
85
|
+
|
|
86
|
+
## Your application
|
|
87
|
+
|
|
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
|
|
29
91
|
|
|
30
|
-
|
|
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.
|
|
31
93
|
|
|
32
|
-
|
|
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.
|
|
33
95
|
|
|
34
|
-
|
|
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.
|
|
35
97
|
|
|
36
|
-
|
|
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.
|
|
37
99
|
`);
|
|
38
|
-
put(root, 'docs/architecture.md', '# Architecture\n\nNext.js
|
|
39
|
-
put(root, 'docs/verification.md', '# Verification\n\nRecord
|
|
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');
|
|
40
102
|
}
|
|
@@ -13,7 +13,7 @@ type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
|
|
|
13
13
|
function validProtocol(url: URL): boolean {
|
|
14
14
|
return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
function nativeApiOrigin(): string {
|
|
17
17
|
const configured = process.env.EXPO_PUBLIC_API_URL;
|
|
18
18
|
if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
|
|
19
19
|
const origin = new URL(configured);
|
|
@@ -26,14 +26,13 @@ function apiBaseURL(): string {
|
|
|
26
26
|
return nativeApiOrigin() + '/api';
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
//
|
|
30
|
-
|
|
29
|
+
// Consumers can extend transport headers for their own application. No server secret belongs here.
|
|
30
|
+
function createApplicationApiClient(options: Options = {}) {
|
|
31
31
|
const client = () => createApiClient(apiBaseURL(), {
|
|
32
32
|
...options, credentials: 'omit',
|
|
33
33
|
});
|
|
34
34
|
return {
|
|
35
35
|
health: (init?: RequestInit) => client().health(init),
|
|
36
|
-
session: (init?: RequestInit) => client().session(init),
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
|