anhedral 0.15.0 → 0.17.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 +82 -34
- 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 +0 -11
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -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 -9
- package/dist/dependencies.js +57 -64
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- 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 +4 -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 +56 -25
- 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 +21 -22
- package/dist/stack-registry.d.ts +2 -10
- package/dist/stack-registry.js +12 -98
- 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 +12 -23
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +47 -0
- package/docs/software-factory.md +35 -50
- package/docs/stack-standard.md +19 -70
- package/docs/ui.md +33 -0
- package/docs/verification.md +6 -876
- package/package.json +21 -16
- package/assets/ui/native/button.tsx +0 -85
- package/assets/ui/native/card.tsx +0 -33
- package/assets/ui/native/dialog.tsx +0 -75
- package/assets/ui/native/input.tsx +0 -27
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- 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/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -156
- 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/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -43
- 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/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -69
- 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/dist/index.js
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parseStandardOptions, scaffoldStandardProject, STANDARD_PRODUCTS, STANDARD_USAGE, } from './standard.js';
|
|
2
2
|
export { GENERATOR_VERSION } from './version.js';
|
|
3
|
-
export { CAPABILITIES, CAPABILITY_REGISTRY, createSetupPlan } from './capabilities.js';
|
|
4
|
-
export { inspectProject, validateSetupPlan } from './readiness.js';
|
|
5
|
-
export { registerApplication, readApplication, connectApplication, planDelivery, shipApplication, applicationStatus, verifyApplication, rollbackApplication, recoverApplication, } from './delivery.js';
|
|
6
|
-
export { planProvisioning, provisionApplication } from './provision.js';
|
|
7
|
-
export { setupRepository, githubRepository } from './repository.js';
|
|
8
|
-
export { inspectProviderReadiness } from './provider-readiness.js';
|
|
9
|
-
export { STACK_REGISTRY, STACK_ITEMS, getStackItem } from './stack-registry.js';
|
|
10
|
-
export { inspectWorkspaceGraph } from './workspace-graph.js';
|
|
11
|
-
export { resolveStackRegistry } from './registry/resolve.js';
|
|
12
|
-
export { addStackItems } from './registry/add.js';
|
|
13
|
-
export { PROVIDER_AUTH, requiredProviders, authenticateProviders } from './provider-auth.js';
|
|
14
|
-
export { buildMobileApplication } from './mobile-delivery.js';
|
|
15
|
-
export { shipCloudflareApplication } from './ship.js';
|
|
16
|
-
export { shipSelectedStack } from './ship.js';
|
|
17
|
-
export { planProviderProvisioning, provisionSelectedProviders } from './providers/provision.js';
|
|
18
|
-
export { providerConfigurationTemplate } from './providers/config.js';
|
|
19
|
-
export { validateProviderConfiguration } from './providers/config.js';
|
|
20
|
-
export { PROVIDER_CONFIGURATION_SCHEMA } from './providers/schema.js';
|
|
21
|
-
export { PROVIDER_DEFINITIONS } from './providers/definitions.js';
|
|
22
|
-
export { applicationRuntime } from './providers/runtime.js';
|
|
23
|
-
export { readLifecycleOperation } from './lifecycle.js';
|
|
24
|
-
export { integrationStatus, recoverIntegrationResource } from './providers/recovery.js';
|
|
25
|
-
export { CAPABILITY_CONTRACT, formatCapabilityContract } from './capability-contract.js';
|
|
26
|
-
export { recoverDeliveryLock } from './project-state.js';
|
|
27
|
-
export { inspectApplication } from './project-inspector.js';
|
|
28
|
-
export { PROJECT_CONFIG_FILE, readProjectConfig, readProjectSection, writeProjectSection, hasProjectSection, } from './project-config.js';
|
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.');
|
|
@@ -23,6 +15,8 @@ export function resolveStandardProducts(selected, hosting) {
|
|
|
23
15
|
export function resolveStackRegistry(options) {
|
|
24
16
|
if (options.hosting !== 'cloudflare')
|
|
25
17
|
throw new Error('Anhedral applications use Cloudflare Workers.');
|
|
18
|
+
if (options.products.includes('expo'))
|
|
19
|
+
throw new Error('Legacy Expo source composition is retired. Use anhedral add expo, then anhedral add native-ui. Existing applications are not changed.');
|
|
26
20
|
for (const id of options.products)
|
|
27
21
|
if (!STANDARD_PRODUCTS.includes(id))
|
|
28
22
|
throw new Error(`Unknown stack product: ${id}.`);
|
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,71 @@
|
|
|
1
|
+
import { capabilityReferences } from '../capability-references.js';
|
|
1
2
|
import { put } from './files.js';
|
|
2
3
|
export function writeSetupDocumentation(root, options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This project uses Next.js App Router/OpenNext for web and Expo for iOS/Android, a Hono Cloudflare Worker, Drizzle/D1, and private R2. Better Auth supplies the identity needed for private storage and payments. Shared styling tokens are in packages/styling; native components use the Anhedral-maintained shadcn port in packages/native-ui. Optional integrations are Stripe and RevenueCat only.
|
|
6
|
-
|
|
7
|
-
Hono owns authentication, authorization, persistence, and provider credentials. Clients use API contracts in packages/contracts and never import database/auth server code. Apps must not import each other's source. Keep one root pnpm lockfile. No secrets belong in client bundles.
|
|
8
|
-
|
|
9
|
-
Review SQL produced by pnpm db:generate. Apply local migrations explicitly using pnpm db:migrate. Remote migrations require an explicit --remote and reviewed target. Builds and startup never migrate databases. R2 stays private; the API derives object namespaces from the verified user, never client-supplied ownership.
|
|
10
|
-
|
|
11
|
-
Run pnpm lint, pnpm typecheck, and pnpm build. Verify signup/signin/signout, anonymous rejection and cross-user file isolation. Payment additions require provider sandbox purchase/restore/webhook verification. Keep architecture and dated acceptance evidence in docs/architecture.md and docs/verification.md. Init does not provision, deploy or activate payment services.
|
|
12
|
-
`);
|
|
4
|
+
for (const [file, source] of Object.entries(capabilityReferences()))
|
|
5
|
+
put(root, file, source);
|
|
13
6
|
put(root, 'README.md', `# ${options.name}
|
|
14
7
|
|
|
15
|
-
Next.js
|
|
8
|
+
Next.js on Cloudflare Workers through OpenNext, with Anhedral UI from the start.
|
|
9
|
+
Init starts with apps/web. Review anhedral.json for explicitly composed API/data source.
|
|
10
|
+
Use anhedral stack status to inspect later source additions.
|
|
11
|
+
No providers are provisioned by source generation.
|
|
12
|
+
|
|
13
|
+
## Develop
|
|
16
14
|
|
|
17
|
-
|
|
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.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
## Anhedral UI
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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.
|
|
25
24
|
|
|
26
|
-
|
|
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.
|
|
27
29
|
|
|
28
|
-
|
|
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.
|
|
29
35
|
|
|
30
|
-
##
|
|
36
|
+
## Add strategically
|
|
31
37
|
|
|
32
|
-
|
|
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.
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
Hono owns privileged API operations when selected. Clients and Next server actions
|
|
47
|
+
call the API; applications never import one another's source. Keep database and
|
|
48
|
+
storage credentials server-side. Implement identity, authorization and ownership
|
|
49
|
+
checks before exposing data or files; private storage is not user authorization.
|
|
50
|
+
Review generated SQL and apply migrations explicitly through the selected database tooling.
|
|
51
|
+
`);
|
|
52
|
+
put(root, 'AGENTS.md', `# Minimal application foundation
|
|
35
53
|
|
|
36
|
-
|
|
54
|
+
Start with Next.js/OpenNext/Workers and source-owned Anhedral UI. Do not add an API,
|
|
55
|
+
database, authentication, R2 or native client without a concrete feature need.
|
|
56
|
+
Use anhedral add and stack list/status/doctor to compose selected capabilities.
|
|
57
|
+
Preview additions first, preserve edited source, and configure selected auth methods
|
|
58
|
+
explicitly. Source installation is not provider activation. Use anhedral ui
|
|
59
|
+
add/list/diff/doctor to manage platform-specific source; web uses
|
|
60
|
+
official shadcn and native uses RNR/NativeWind with reviewed Anhedral extensions.
|
|
61
|
+
UI requires its application platform, not Hono or a database. Share tokens, not
|
|
62
|
+
DOM/native primitives. Preserve consumer edits, attribution and upstream metadata.
|
|
63
|
+
Never automatically overwrite installed components. Read version-matched framework
|
|
64
|
+
guides and run pnpm check. Never migrate a configured database during checks/builds.
|
|
65
|
+
Hono owns privileged operations when present. Clients call its API; applications
|
|
66
|
+
must not import another application's source. Keep database/storage secrets on
|
|
67
|
+
the server and implement authorization before exposing private data or files.
|
|
37
68
|
`);
|
|
38
|
-
put(root, 'docs/architecture.md', '# Architecture\n\nNext.js
|
|
39
|
-
put(root, 'docs/verification.md', '# Verification\n\nRecord
|
|
69
|
+
put(root, 'docs/architecture.md', '# Architecture\n\nNext.js → OpenNext → Cloudflare Workers, with Anhedral UI. Record feature-driven additions here.\n');
|
|
70
|
+
put(root, 'docs/verification.md', '# Verification\n\nRecord commands, outcomes and environment. Source generation is not deployment acceptance.\n');
|
|
40
71
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { put } from './files.js';
|
|
2
2
|
export function writeStackDocumentation(root, registry) {
|
|
3
3
|
const sections = registry.items.map((item) => `## ${item.name}\n\n${item.description}.\n\nTargets: ${item.targets.join(', ')}.\n\n${item.environment.length ? 'Environment: ' + item.environment.join(', ') + '.\n\n' : ''}${item.setup ? 'Setup: ' + item.setup.resources.join('; ') + '.\n\nVerify: ' + item.setup.verify.join('; ') + '.\n' : ''}`);
|
|
4
|
-
put(root, 'docs/stack.md', '# Application stack\n\nEvery application uses Next.js App Router/OpenNext for web, Expo for iOS/Android, Hono, Drizzle/D1 and private R2.
|
|
4
|
+
put(root, 'docs/stack.md', '# Application stack\n\nEvery application uses Next.js App Router/OpenNext for web, Expo for iOS/Android, Hono, Drizzle/D1 and private R2. Shared contracts, styling and native shadcn UI are included. Consumers implement application features, identity and integrations.\n\nInit generates source and configuration only. Consumers own cloud provisioning, secrets, migrations and deployment.\n\n' +
|
|
5
5
|
sections.join('\n'));
|
|
6
6
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { put } from './files.js';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export function scaffoldPrivateStorage({ root }) {
|
|
5
|
+
put(root, 'apps/api/src/private-storage.ts', `// Use only after your application has authorized the operation. No HTTP routes are exposed.
|
|
6
|
+
// R2 bucket privacy does not establish end-user authorization.
|
|
7
|
+
export function privateStorage(binding: R2Bucket) {
|
|
8
|
+
return {
|
|
9
|
+
get: (key: string) => binding.get(key),
|
|
10
|
+
put: (key: string, value: ArrayBuffer | ReadableStream) => binding.put(key, value),
|
|
11
|
+
delete: (key: string) => binding.delete(key),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
`);
|
|
15
|
+
const file = 'apps/api/src/index.ts';
|
|
16
|
+
const source = readFileSync(path.join(root, file), 'utf8');
|
|
17
|
+
put(root, file, "import { privateStorage } from './private-storage';\n" +
|
|
18
|
+
source
|
|
19
|
+
.replace('database: () => ReturnType<typeof createDatabase>', 'database: () => ReturnType<typeof createDatabase>; storage: () => ReturnType<typeof privateStorage>')
|
|
20
|
+
.replace("c.set('database', () => createDatabase(c.env.DB));", "c.set('database', () => createDatabase(c.env.DB)); c.set('storage', () => privateStorage(c.env.FILES));"));
|
|
21
|
+
}
|