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
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { parseDocument } from 'yaml';
|
|
3
|
+
import { CapabilityEditor, fingerprint } from './capability-editor.js';
|
|
4
|
+
import { CAPABILITY_DEPENDENCIES as P } from './dependencies.js';
|
|
5
|
+
import { STACK_DEPENDENCIES as D } from './dependencies.js';
|
|
6
|
+
import { resourceName } from './render.js';
|
|
7
|
+
import { WEB_API_PROXY } from './platforms/web.js';
|
|
8
|
+
const template = (name) => readFileSync(new URL(`../assets/stack/${name}`, import.meta.url), 'utf8');
|
|
9
|
+
const json = (value) => JSON.stringify(value, null, 2) + '\n';
|
|
10
|
+
function dependency(e, app, dependencies) {
|
|
11
|
+
e.merge(`${app}/package.json`, 'dependencies', dependencies);
|
|
12
|
+
}
|
|
13
|
+
function project(e, directory, name, scripts, dependencies, dev = {}) {
|
|
14
|
+
e.create(`${directory}/package.json`, json({
|
|
15
|
+
name,
|
|
16
|
+
private: true,
|
|
17
|
+
version: '0.1.0',
|
|
18
|
+
type: 'module',
|
|
19
|
+
scripts,
|
|
20
|
+
dependencies,
|
|
21
|
+
devDependencies: { typescript: D.typescript, ...dev },
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
function apiConfig(e, key, value) {
|
|
25
|
+
const file = 'apps/api/wrangler.jsonc';
|
|
26
|
+
const current = e.json(file)[key];
|
|
27
|
+
if (Array.isArray(current) && Array.isArray(value)) {
|
|
28
|
+
for (const entry of value) {
|
|
29
|
+
const previous = current.find((item) => item.binding === entry.binding);
|
|
30
|
+
if (previous && JSON.stringify(previous) !== JSON.stringify(entry))
|
|
31
|
+
throw Error(`Preserve existing ${entry.binding} in ${file}; reconcile it first.`);
|
|
32
|
+
if (!previous)
|
|
33
|
+
e.set(file, [key, -1], entry);
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (current !== undefined && JSON.stringify(current) !== JSON.stringify(value))
|
|
38
|
+
throw Error(`Preserve existing ${key} in ${file}; reconcile it before adding this capability.`);
|
|
39
|
+
e.set(file, [key], value);
|
|
40
|
+
}
|
|
41
|
+
function schemaExport(e, module) {
|
|
42
|
+
const file = 'packages/db/src/schema.ts';
|
|
43
|
+
const source = e.read(file);
|
|
44
|
+
if (source === null)
|
|
45
|
+
throw Error('Database schema is missing.');
|
|
46
|
+
// Appending an export preserves all consumer-owned schema declarations.
|
|
47
|
+
e.writes.set(file, source + `\nexport * from './${module}';\n`);
|
|
48
|
+
}
|
|
49
|
+
export function addCapabilityRecipe(e, id, name) {
|
|
50
|
+
switch (id) {
|
|
51
|
+
case 'hono': {
|
|
52
|
+
project(e, 'apps/api', '@workspace/api', {
|
|
53
|
+
dev: 'wrangler dev --port 8787 --inspector-port 9231',
|
|
54
|
+
build: 'wrangler deploy --dry-run --outdir dist',
|
|
55
|
+
deploy: 'wrangler deploy',
|
|
56
|
+
typecheck: 'wrangler types && tsc --noEmit',
|
|
57
|
+
lint: 'eslint . --max-warnings 0',
|
|
58
|
+
}, { hono: D.hono }, {
|
|
59
|
+
wrangler: D.wrangler,
|
|
60
|
+
'@types/node': D['@types/node'],
|
|
61
|
+
eslint: D.eslint,
|
|
62
|
+
'@workspace/eslint-config': 'workspace:*',
|
|
63
|
+
});
|
|
64
|
+
e.create('apps/api/wrangler.jsonc', json({
|
|
65
|
+
$schema: 'node_modules/wrangler/config-schema.json',
|
|
66
|
+
name: resourceName(name, 'api'),
|
|
67
|
+
main: 'src/index.ts',
|
|
68
|
+
compatibility_date: '2026-10-05',
|
|
69
|
+
compatibility_flags: ['nodejs_compat'],
|
|
70
|
+
observability: { enabled: true },
|
|
71
|
+
}));
|
|
72
|
+
e.create('apps/api/tsconfig.json', json({
|
|
73
|
+
compilerOptions: {
|
|
74
|
+
target: 'ES2022',
|
|
75
|
+
lib: ['ES2022'],
|
|
76
|
+
module: 'ESNext',
|
|
77
|
+
moduleResolution: 'Bundler',
|
|
78
|
+
strict: true,
|
|
79
|
+
skipLibCheck: true,
|
|
80
|
+
noEmit: true,
|
|
81
|
+
types: ['node'],
|
|
82
|
+
},
|
|
83
|
+
include: ['src/**/*.ts', 'worker-configuration.d.ts'],
|
|
84
|
+
}));
|
|
85
|
+
e.create('apps/api/eslint.config.mjs', "import { config } from '@workspace/eslint-config/base';\nexport default [...config, {ignores:['dist/**','.wrangler/**','worker-configuration.d.ts']}];\n");
|
|
86
|
+
e.create('apps/api/src/index.ts', template('api-index.ts.txt'));
|
|
87
|
+
e.create('apps/api/src/custom-environment.ts', 'export type CustomBindings = Record<never, never>;\nexport type CustomVariables = Record<never, never>;\n');
|
|
88
|
+
const web = 'apps/web/wrangler.jsonc';
|
|
89
|
+
const services = e.json(web).services ?? [];
|
|
90
|
+
if (!Array.isArray(services) || services.some((s) => s.binding === 'ANHEDRAL_API'))
|
|
91
|
+
throw Error('Existing ANHEDRAL_API binding must be reconciled first.');
|
|
92
|
+
if (e.json(web).services)
|
|
93
|
+
e.set(web, ['services', -1], {
|
|
94
|
+
binding: 'ANHEDRAL_API',
|
|
95
|
+
service: resourceName(name, 'api'),
|
|
96
|
+
});
|
|
97
|
+
else
|
|
98
|
+
e.set(web, ['services'], [{ binding: 'ANHEDRAL_API', service: resourceName(name, 'api') }]);
|
|
99
|
+
e.create('apps/web/lib/api-proxy.ts', WEB_API_PROXY.replace("'idempotency-key'", "'idempotency-key', 'stripe-signature', 'last-event-id'").replace('AbortSignal.timeout(15000)', "AbortSignal.timeout(request.headers.get('accept')?.includes('text/event-stream') ? 35000 : 15000)"));
|
|
100
|
+
e.create('apps/web/lib/server-api.ts', `import 'server-only';
|
|
101
|
+
import { getCloudflareContext } from '@opennextjs/cloudflare';
|
|
102
|
+
import { proxyApi,type ApiBinding } from './api-proxy';
|
|
103
|
+
function apiBinding(candidate:unknown):ApiBinding|undefined {
|
|
104
|
+
if(typeof candidate !== 'object' || candidate===null)return undefined;
|
|
105
|
+
if(typeof Reflect.get(candidate,'fetch') !== 'function')return undefined;
|
|
106
|
+
return candidate as ApiBinding;
|
|
107
|
+
}
|
|
108
|
+
export async function apiRequest(request:Request):Promise<Response>{
|
|
109
|
+
if(process.env.NODE_ENV==='development')return proxyApi(request,{development:true,devOrigin:process.env.API_INTERNAL_URL});
|
|
110
|
+
const {env}=await getCloudflareContext({async:true});
|
|
111
|
+
return proxyApi(request,{development:false,binding:apiBinding(Reflect.get(env,'ANHEDRAL_API'))});
|
|
112
|
+
}
|
|
113
|
+
`);
|
|
114
|
+
e.create('apps/web/app/api/[[...path]]/route.ts', "import { apiRequest } from '@/lib/server-api';\nexport const dynamic = 'force-dynamic';\nexport const GET = apiRequest;\nexport const POST = apiRequest;\nexport const PUT = apiRequest;\nexport const PATCH = apiRequest;\nexport const DELETE = apiRequest;\nexport const HEAD = apiRequest;\nexport const OPTIONS = apiRequest;\n");
|
|
115
|
+
e.create('apps/web/README.hono.md', '# Hono development\n\nSet this in apps/web/.env.local for local development:\n\n```dotenv\nAPI_INTERNAL_URL=http://127.0.0.1:8787\n```\n\nProduction uses the ANHEDRAL_API service binding.\n');
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case 'database-auth': {
|
|
119
|
+
project(e, 'packages/db', '@workspace/db', {
|
|
120
|
+
typecheck: 'tsc --noEmit',
|
|
121
|
+
lint: 'eslint . --max-warnings 0',
|
|
122
|
+
'db:generate': 'drizzle-kit generate',
|
|
123
|
+
'db:migrate': 'node src/migrate.mjs',
|
|
124
|
+
}, { 'drizzle-orm': D['drizzle-orm'] }, {
|
|
125
|
+
'drizzle-kit': D['drizzle-kit'],
|
|
126
|
+
'@types/node': D['@types/node'],
|
|
127
|
+
eslint: D.eslint,
|
|
128
|
+
'@workspace/eslint-config': 'workspace:*',
|
|
129
|
+
});
|
|
130
|
+
e.set('packages/db/package.json', ['exports'], {
|
|
131
|
+
'.': './src/index.ts',
|
|
132
|
+
'./schema': './src/schema.ts',
|
|
133
|
+
});
|
|
134
|
+
e.create('packages/db/tsconfig.json', json({
|
|
135
|
+
compilerOptions: {
|
|
136
|
+
target: 'ES2022',
|
|
137
|
+
module: 'ESNext',
|
|
138
|
+
moduleResolution: 'Bundler',
|
|
139
|
+
strict: true,
|
|
140
|
+
skipLibCheck: true,
|
|
141
|
+
noEmit: true,
|
|
142
|
+
types: ['node'],
|
|
143
|
+
},
|
|
144
|
+
include: ['src/**/*.ts'],
|
|
145
|
+
}));
|
|
146
|
+
e.create('packages/db/eslint.config.mjs', "import { config } from '@workspace/eslint-config/base';\nexport default config;\n");
|
|
147
|
+
e.create('packages/db/src/index.ts', "import { drizzle } from 'drizzle-orm/d1';\nimport * as schema from './schema';\nexport function createDatabase(binding: Parameters<typeof drizzle>[0]) { return drizzle(binding, { schema }); }\n");
|
|
148
|
+
e.create('packages/db/src/schema.ts', template('auth-schema.ts.txt'));
|
|
149
|
+
e.create('packages/db/drizzle/0000_better_auth.sql', template('auth-migration.sql.txt'));
|
|
150
|
+
e.create('packages/db/drizzle/meta/0000_snapshot.json', template('auth-snapshot.json.txt'));
|
|
151
|
+
e.create('packages/db/drizzle/meta/_journal.json', template('auth-journal.json.txt'));
|
|
152
|
+
e.create('packages/db/drizzle.config.ts', "import { defineConfig } from 'drizzle-kit';\nexport default defineConfig({dialect:'sqlite', schema:'./src/schema.ts', out:'./drizzle'});\n");
|
|
153
|
+
e.create('packages/db/src/migrate.mjs', "import { spawnSync } from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nconst args = process.argv.slice(2);\nif(args.length > 1 || args.some((v)=> !['--local','--remote'].includes(v))) throw Error('Use --local or explicitly --remote.');\nif(!process.env.npm_execpath) throw Error('Run through pnpm db:migrate.');\nconst cwd=fileURLToPath(new URL('../../../apps/api/',import.meta.url));\nconst result=spawnSync(process.execPath,[process.env.npm_execpath,'exec','wrangler','d1','migrations','apply','DB',args[0] ?? '--local'],{cwd,stdio:'inherit',shell:false});\nif(result.error)throw result.error;\nprocess.exitCode=result.status ?? 1;\n");
|
|
154
|
+
apiConfig(e, 'd1_databases', [
|
|
155
|
+
{
|
|
156
|
+
binding: 'DB',
|
|
157
|
+
database_name: resourceName(name, 'db'),
|
|
158
|
+
database_id: '00000000-0000-0000-0000-000000000000',
|
|
159
|
+
migrations_dir: '../../packages/db/drizzle',
|
|
160
|
+
},
|
|
161
|
+
]);
|
|
162
|
+
dependency(e, 'apps/api', {
|
|
163
|
+
'@workspace/db': 'workspace:*',
|
|
164
|
+
zod: D.zod,
|
|
165
|
+
'better-auth': P['better-auth'],
|
|
166
|
+
'@better-auth/drizzle-adapter': P['@better-auth/drizzle-adapter'],
|
|
167
|
+
});
|
|
168
|
+
dependency(e, 'apps/web', { 'better-auth': P['better-auth'] });
|
|
169
|
+
e.create('apps/api/src/auth.ts', template('auth.ts.txt'));
|
|
170
|
+
e.create('apps/api/src/auth-features.ts', template('auth-features.ts.txt'));
|
|
171
|
+
e.create('apps/api/src/security.ts', template('security.ts.txt'));
|
|
172
|
+
e.create('apps/api/src/features/auth.ts', template('auth-routes.ts.txt'));
|
|
173
|
+
e.create('apps/web/app/sign-in/page.tsx', template('web-sign-in.tsx.txt'));
|
|
174
|
+
e.create('apps/web/lib/auth-client.ts', "'use client';\nimport { createAuthClient } from 'better-auth/react';\nexport const authClient = createAuthClient();\n");
|
|
175
|
+
e.merge('package.json', 'scripts', {
|
|
176
|
+
'db:generate': 'pnpm --dir packages/db db:generate',
|
|
177
|
+
'db:migrate': 'pnpm --dir packages/db db:migrate',
|
|
178
|
+
});
|
|
179
|
+
e.merge('turbo.json', 'tasks', {
|
|
180
|
+
'db:generate': { cache: false },
|
|
181
|
+
'db:migrate': { cache: false },
|
|
182
|
+
});
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case 'r2':
|
|
186
|
+
apiConfig(e, 'r2_buckets', [{ binding: 'FILES', bucket_name: resourceName(name, 'files') }]);
|
|
187
|
+
e.create('apps/api/src/features/storage.ts', template('storage.ts.txt'));
|
|
188
|
+
break;
|
|
189
|
+
case 'stripe':
|
|
190
|
+
dependency(e, 'apps/api', { stripe: P.stripe });
|
|
191
|
+
e.create('apps/api/src/features/stripe.ts', template('stripe.ts.txt'));
|
|
192
|
+
e.create('apps/api/src/billing-mode.ts', template('billing-mode.ts.txt'));
|
|
193
|
+
e.create('apps/api/src/features/entitlements.ts', template('entitlements.ts.txt'));
|
|
194
|
+
e.create('apps/api/src/entitlement-guard.ts', template('entitlement-guard.ts.txt'));
|
|
195
|
+
e.create('packages/db/src/billing-schema.ts', template('billing-schema.ts.txt'));
|
|
196
|
+
schemaExport(e, 'billing-schema');
|
|
197
|
+
break;
|
|
198
|
+
case 'revenuecat':
|
|
199
|
+
dependency(e, 'apps/mobile', { 'react-native-purchases': P['react-native-purchases'] });
|
|
200
|
+
e.create('apps/api/src/features/revenuecat.ts', template('revenuecat.ts.txt'));
|
|
201
|
+
e.create('apps/mobile/lib/purchases.ts', template('purchases.ts.txt'));
|
|
202
|
+
appendExample(e, 'apps/mobile/.env.example', [
|
|
203
|
+
'EXPO_PUBLIC_REVENUECAT_IOS_KEY',
|
|
204
|
+
'EXPO_PUBLIC_REVENUECAT_ANDROID_KEY',
|
|
205
|
+
]);
|
|
206
|
+
e.create('apps/mobile/components/billing-controls.tsx', template('mobile-billing.tsx.txt'));
|
|
207
|
+
break;
|
|
208
|
+
case 'realtime':
|
|
209
|
+
e.create('packages/db/src/events-schema.ts', template('events-schema.ts.txt'));
|
|
210
|
+
schemaExport(e, 'events-schema');
|
|
211
|
+
e.create('apps/api/src/features/events.ts', template('events.ts.txt'));
|
|
212
|
+
break;
|
|
213
|
+
case 'rtc':
|
|
214
|
+
e.create('apps/api/src/features/rtc.ts', template('rtc.ts.txt'));
|
|
215
|
+
e.create('packages/db/src/rtc-schema.ts', template('rtc-schema.ts.txt'));
|
|
216
|
+
schemaExport(e, 'rtc-schema');
|
|
217
|
+
break;
|
|
218
|
+
case 'ai':
|
|
219
|
+
apiConfig(e, 'ai', { binding: 'AI', remote: true });
|
|
220
|
+
e.create('apps/api/src/features/ai.ts', template('ai.ts.txt'));
|
|
221
|
+
e.create('packages/db/src/ai-schema.ts', template('ai-schema.ts.txt'));
|
|
222
|
+
schemaExport(e, 'ai-schema');
|
|
223
|
+
break;
|
|
224
|
+
case 'expo':
|
|
225
|
+
addExpo(e, name);
|
|
226
|
+
break;
|
|
227
|
+
case 'native-ui':
|
|
228
|
+
addNativeUi(e);
|
|
229
|
+
break;
|
|
230
|
+
case 'wxt':
|
|
231
|
+
addExtension(e);
|
|
232
|
+
break;
|
|
233
|
+
case 'side-panel':
|
|
234
|
+
e.create('apps/extension/entrypoints/sidepanel/index.html', '<!doctype html><html><head><meta charset="UTF-8"><title>Side panel</title></head><body><div id="root"></div><script type="module" src="./main.tsx"></script></body></html>\n');
|
|
235
|
+
e.create('apps/extension/entrypoints/sidepanel/main.tsx', "import { createRoot } from 'react-dom/client';\nimport { App } from '../../components/App';\ncreateRoot(document.getElementById('root')!).render(<App />);\n");
|
|
236
|
+
break;
|
|
237
|
+
case 'gpui':
|
|
238
|
+
addDesktop(e);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function addExpo(e, name) {
|
|
243
|
+
project(e, 'apps/mobile', '@workspace/mobile', {
|
|
244
|
+
dev: 'expo start',
|
|
245
|
+
start: 'expo start',
|
|
246
|
+
android: 'expo run:android',
|
|
247
|
+
ios: 'expo run:ios',
|
|
248
|
+
typecheck: 'tsc --noEmit',
|
|
249
|
+
lint: 'tsc --noEmit',
|
|
250
|
+
build: 'expo export --platform ios --platform android',
|
|
251
|
+
}, {
|
|
252
|
+
expo: P.expo,
|
|
253
|
+
react: P.react,
|
|
254
|
+
'react-native': P['react-native'],
|
|
255
|
+
'expo-secure-store': P['expo-secure-store'],
|
|
256
|
+
'expo-linking': P['expo-linking'],
|
|
257
|
+
'better-auth': P['better-auth'],
|
|
258
|
+
'@better-auth/expo': P['@better-auth/expo'],
|
|
259
|
+
}, { '@types/react': P['@types/react'], 'babel-preset-expo': P['babel-preset-expo'] });
|
|
260
|
+
e.set('apps/mobile/package.json', ['type'], 'commonjs');
|
|
261
|
+
e.set('apps/mobile/package.json', ['main'], 'index.ts');
|
|
262
|
+
const workspaceSource = e.read('pnpm-workspace.yaml');
|
|
263
|
+
if (workspaceSource === null)
|
|
264
|
+
throw Error('Missing pnpm workspace');
|
|
265
|
+
const workspace = parseDocument(workspaceSource);
|
|
266
|
+
if (workspace.errors.length)
|
|
267
|
+
throw Error('Invalid pnpm workspace configuration');
|
|
268
|
+
const existing = workspace.getIn(['overrides', '@expo/cli>zod']);
|
|
269
|
+
if (existing !== undefined && existing !== D.zod)
|
|
270
|
+
throw Error('Preserve the custom Expo Zod override; reconcile it first.');
|
|
271
|
+
workspace.setIn(['overrides', '@expo/cli>zod'], D.zod);
|
|
272
|
+
e.writes.set('pnpm-workspace.yaml', workspace.toString());
|
|
273
|
+
e.create('apps/mobile/app.json', json({
|
|
274
|
+
expo: {
|
|
275
|
+
name,
|
|
276
|
+
slug: resourceName(name, 'mobile'),
|
|
277
|
+
scheme: resourceName(name, 'mobile'),
|
|
278
|
+
version: '1.0.0',
|
|
279
|
+
userInterfaceStyle: 'automatic',
|
|
280
|
+
plugins: ['expo-secure-store'],
|
|
281
|
+
},
|
|
282
|
+
}));
|
|
283
|
+
e.create('apps/mobile/tsconfig.json', json({
|
|
284
|
+
extends: 'expo/tsconfig.base',
|
|
285
|
+
compilerOptions: { strict: true, baseUrl: '.', paths: { '@/*': ['./*'] } },
|
|
286
|
+
}));
|
|
287
|
+
e.create('apps/mobile/babel.config.js', "module.exports = function(api) {api.cache(true);return {presets:['babel-preset-expo']};};\n");
|
|
288
|
+
e.create('apps/mobile/index.ts', "import './anhedral-entry';\n");
|
|
289
|
+
e.create('apps/mobile/App.tsx', "import { View, Text } from 'react-native';\nexport default function App() { return <View style={{flex:1,alignItems:'center',justifyContent:'center'}}><Text>Your Expo application</Text></View>; }\n");
|
|
290
|
+
e.create('apps/mobile/components/session-controls.tsx', template('mobile-session.tsx.txt'));
|
|
291
|
+
e.create('apps/mobile/lib/auth-client.ts', template('mobile-auth.ts.txt').replaceAll('__SCHEME__', JSON.stringify(resourceName(name, 'mobile'))));
|
|
292
|
+
e.create('apps/mobile/.env.example', '# Public application URL only, never a server secret. Use a device-reachable development origin.\nEXPO_PUBLIC_API_URL=https://your-app.example\n');
|
|
293
|
+
dependency(e, 'apps/api', { '@better-auth/expo': P['@better-auth/expo'] });
|
|
294
|
+
}
|
|
295
|
+
function addNativeUi(e) {
|
|
296
|
+
dependency(e, 'apps/mobile', {
|
|
297
|
+
nativewind: P.nativewind,
|
|
298
|
+
'react-native-css-interop': P['react-native-css-interop'],
|
|
299
|
+
'react-native-reanimated': P['react-native-reanimated'],
|
|
300
|
+
'react-native-worklets': P['react-native-worklets'],
|
|
301
|
+
'react-native-safe-area-context': P['react-native-safe-area-context'],
|
|
302
|
+
'class-variance-authority': P['class-variance-authority'],
|
|
303
|
+
clsx: P.clsx,
|
|
304
|
+
'tailwind-merge': P['tailwind-merge'],
|
|
305
|
+
'tailwindcss-animate': P['tailwindcss-animate'],
|
|
306
|
+
'@rn-primitives/portal': P['@rn-primitives/portal'],
|
|
307
|
+
'@rn-primitives/slot': P['@rn-primitives/slot'],
|
|
308
|
+
});
|
|
309
|
+
e.merge('apps/mobile/package.json', 'devDependencies', { tailwindcss: P.tailwindcss });
|
|
310
|
+
e.create('apps/mobile/components.json', json({
|
|
311
|
+
$schema: 'https://ui.shadcn.com/schema.json',
|
|
312
|
+
style: 'new-york',
|
|
313
|
+
rsc: false,
|
|
314
|
+
tsx: true,
|
|
315
|
+
tailwind: {
|
|
316
|
+
config: 'tailwind.config.js',
|
|
317
|
+
css: 'global.css',
|
|
318
|
+
baseColor: 'neutral',
|
|
319
|
+
cssVariables: true,
|
|
320
|
+
},
|
|
321
|
+
aliases: {
|
|
322
|
+
components: '@/components',
|
|
323
|
+
ui: '@/components/ui',
|
|
324
|
+
utils: '@/lib/utils',
|
|
325
|
+
lib: '@/lib',
|
|
326
|
+
hooks: '@/hooks',
|
|
327
|
+
},
|
|
328
|
+
}));
|
|
329
|
+
for (const file of [
|
|
330
|
+
'global.css',
|
|
331
|
+
'tailwind.config.js',
|
|
332
|
+
'metro.config.js',
|
|
333
|
+
'nativewind-env.d.ts',
|
|
334
|
+
'lib/utils.ts',
|
|
335
|
+
])
|
|
336
|
+
e.create(`apps/mobile/${file}`, template('native-' + file.replaceAll('/', '-') + '.txt'));
|
|
337
|
+
// Dedicated entry: NativeWind/PortalHost integration never replaces the user's App.
|
|
338
|
+
if (e.json('apps/mobile/package.json').main !== 'index.ts')
|
|
339
|
+
throw Error('Preserve the custom Expo entry; reconcile NativeWind/PortalHost setup first.');
|
|
340
|
+
e.set('apps/mobile/package.json', ['main'], 'anhedral-entry.tsx');
|
|
341
|
+
for (const name of ['button', 'text'])
|
|
342
|
+
e.create(`apps/mobile/components/ui/${name}.tsx`, template(`native-${name}.tsx.txt`));
|
|
343
|
+
if (e.read('apps/mobile/App.tsx') === null)
|
|
344
|
+
throw Error('Preserve the custom Expo layout; reconcile the NativeWind root entry first.');
|
|
345
|
+
const babel = 'apps/mobile/babel.config.js';
|
|
346
|
+
const expected = "module.exports = function(api) {api.cache(true);return {presets:['babel-preset-expo']};};\n";
|
|
347
|
+
if (e.read(babel) !== expected)
|
|
348
|
+
throw Error('Preserve edited Expo Babel configuration; reconcile NativeWind first.');
|
|
349
|
+
e.writes.set(babel, "module.exports = function(api) {api.cache(true);return {presets:[['babel-preset-expo',{jsxImportSource:'nativewind'}],'nativewind/babel']};};\n");
|
|
350
|
+
e.create('apps/mobile/.anhedral-ui.json', json({
|
|
351
|
+
schemaVersion: 1,
|
|
352
|
+
platform: 'native',
|
|
353
|
+
catalogRevision: '2026-10-26.1',
|
|
354
|
+
nativeStyling: 'nativewind4',
|
|
355
|
+
sourceOwned: true,
|
|
356
|
+
automaticUpdates: false,
|
|
357
|
+
}));
|
|
358
|
+
e.create('apps/mobile/UPSTREAM.json', json({
|
|
359
|
+
catalogRevision: '2026-10-26.1',
|
|
360
|
+
source: 'https://github.com/founded-labs/react-native-reusables/tree/385834c2196f8a303cbc9057d1ac768f3bde0a3b',
|
|
361
|
+
automaticUpdates: false,
|
|
362
|
+
files: Object.fromEntries(['button', 'text'].map((name) => [
|
|
363
|
+
`components/ui/${name}.tsx`,
|
|
364
|
+
{ sha256: fingerprint(template(`native-${name}.tsx.txt`)) },
|
|
365
|
+
])),
|
|
366
|
+
}));
|
|
367
|
+
for (const name of ['LICENSE.react-native-reusables', 'LICENSE.shadcn'])
|
|
368
|
+
e.create(`apps/mobile/ANHEDRAL_UI_LICENSES/${name}`, readFileSync(new URL(`../assets/ui/${name}`, import.meta.url), 'utf8'));
|
|
369
|
+
}
|
|
370
|
+
function addExtension(e) {
|
|
371
|
+
project(e, 'apps/extension', '@workspace/extension', {
|
|
372
|
+
dev: 'wxt',
|
|
373
|
+
build: 'wxt build',
|
|
374
|
+
zip: 'wxt zip',
|
|
375
|
+
typecheck: 'wxt prepare && tsc --noEmit',
|
|
376
|
+
lint: 'wxt prepare && tsc --noEmit',
|
|
377
|
+
postinstall: 'wxt prepare',
|
|
378
|
+
}, { react: P.react, 'react-dom': P.react }, {
|
|
379
|
+
wxt: P.wxt,
|
|
380
|
+
'@wxt-dev/module-react': P['@wxt-dev/module-react'],
|
|
381
|
+
'@types/react': P['@types/react'],
|
|
382
|
+
'@types/react-dom': P['@types/react-dom'],
|
|
383
|
+
});
|
|
384
|
+
e.create('apps/extension/entrypoints/background.ts', "import {configureCapabilities} from '../anhedral-background';\nexport default defineBackground(()=>{configureCapabilities();});\n");
|
|
385
|
+
e.create('apps/extension/wxt.config.ts', "import {defineConfig} from 'wxt';\nconst origin=process.env.WXT_API_ORIGIN || 'https://your-app.example';\nconst url=new URL(origin);\nif(url.protocol !== 'https:' && !(url.protocol === 'http:' && ['localhost','127.0.0.1'].includes(url.hostname)))throw Error('Choose a secure API origin');\nexport default defineConfig({modules:['@wxt-dev/module-react'], manifest:{name:'Anhedral application extension',permissions:['storage'],host_permissions:[url.origin+'/*']}});\n");
|
|
386
|
+
e.create('apps/extension/tsconfig.json', json({ extends: './.wxt/tsconfig.json', compilerOptions: { strict: true, jsx: 'react-jsx' } }));
|
|
387
|
+
e.create('apps/extension/entrypoints/popup/index.html', '<!doctype html><html><head><meta charset="UTF-8"><title>Application</title></head><body><div id="root"></div><script type="module" src="./main.tsx"></script></body></html>\n');
|
|
388
|
+
e.create('apps/extension/entrypoints/popup/main.tsx', "import {createRoot} from 'react-dom/client';\nimport {App} from '../../components/App';\ncreateRoot(document.getElementById('root')!).render(<App />);\n");
|
|
389
|
+
e.create('apps/extension/components/App.tsx', 'export function App(){return <main><h1>Your application</h1><p>Configure the API origin and an explicit sign-in flow before accessing private data.</p></main>;}\n');
|
|
390
|
+
e.create('apps/extension/.env.example', 'WXT_API_ORIGIN=https://your-app.example\n');
|
|
391
|
+
}
|
|
392
|
+
function addDesktop(e) {
|
|
393
|
+
project(e, 'apps/desktop', '@workspace/desktop', {
|
|
394
|
+
dev: 'cargo run',
|
|
395
|
+
build: 'cargo build',
|
|
396
|
+
typecheck: 'cargo check',
|
|
397
|
+
lint: 'cargo fmt --check',
|
|
398
|
+
test: 'cargo test',
|
|
399
|
+
}, {});
|
|
400
|
+
e.create('apps/desktop/Cargo.toml', '[package]\nname = "anhedral-desktop"\nversion = "0.1.0"\nedition = "2024"\n\n[dependencies]\ngpui = { version = "=0.2.2", features = ["runtime_shaders"] }\n');
|
|
401
|
+
e.create('apps/desktop/src/main.rs', template('desktop.rs.txt'));
|
|
402
|
+
e.create('apps/desktop/.gitignore', '/target/\n');
|
|
403
|
+
e.create('apps/desktop/.env.example', '# Desktop binaries run natively, not on Workers.\nANHEDRAL_API_ORIGIN=https://your-app.example\n');
|
|
404
|
+
}
|
|
405
|
+
export function composeCapabilities(e, installed) {
|
|
406
|
+
if (!installed.includes('hono'))
|
|
407
|
+
return;
|
|
408
|
+
if (installed.includes('expo'))
|
|
409
|
+
composeMobile(e, installed);
|
|
410
|
+
if (installed.includes('wxt'))
|
|
411
|
+
e.owned('apps/extension/anhedral-background.ts', installed.includes('side-panel')
|
|
412
|
+
? "import {browser} from 'wxt/browser';\nexport function configureCapabilities(){if(browser.sidePanel)void browser.sidePanel.setPanelBehavior({openPanelOnActionClick:true}).catch(()=>console.error('Side Panel setup failed'));}\n"
|
|
413
|
+
: 'export function configureCapabilities(){}\n');
|
|
414
|
+
const features = [
|
|
415
|
+
['database-auth', 'authRoutes', 'auth'],
|
|
416
|
+
['r2', 'storageRoutes', 'storage'],
|
|
417
|
+
['stripe', 'stripeRoutes', 'stripe'],
|
|
418
|
+
['stripe', 'entitlementRoutes', 'entitlements'],
|
|
419
|
+
['revenuecat', 'revenuecatRoutes', 'revenuecat'],
|
|
420
|
+
['realtime', 'eventRoutes', 'events'],
|
|
421
|
+
['rtc', 'rtcRoutes', 'rtc'],
|
|
422
|
+
['ai', 'aiRoutes', 'ai'],
|
|
423
|
+
];
|
|
424
|
+
const chosen = features.filter(([id]) => installed.includes(id));
|
|
425
|
+
e.owned('apps/api/src/capabilities.ts', "// CLI-owned composition. Add custom routes in index.ts; edited composition is never overwritten.\nimport { Hono } from 'hono';\nimport type { AppEnv } from './environment';\n" +
|
|
426
|
+
chosen
|
|
427
|
+
.map(([, symbol, file]) => `import { ${symbol} } from './features/${file}';\n`)
|
|
428
|
+
.join('') +
|
|
429
|
+
'export const capabilities = new Hono<AppEnv>();\n' +
|
|
430
|
+
chosen.map(([, symbol]) => `capabilities.route('/', ${symbol});\n`).join(''));
|
|
431
|
+
if (installed.includes('database-auth'))
|
|
432
|
+
e.owned('apps/api/src/auth-platform.ts', installed.includes('expo')
|
|
433
|
+
? "import { expo } from '@better-auth/expo';\nexport const platformAuthPlugins = () => [expo()];\n"
|
|
434
|
+
: 'export const platformAuthPlugins = () => [];\n');
|
|
435
|
+
if (installed.includes('stripe'))
|
|
436
|
+
e.owned('apps/api/src/billing-providers.ts', "import type {AppEnv} from './environment';\nimport {stripeEntitled} from './features/stripe';\n" +
|
|
437
|
+
(installed.includes('revenuecat')
|
|
438
|
+
? "import {revenuecatEntitled} from './features/revenuecat';\n"
|
|
439
|
+
: '') +
|
|
440
|
+
"export const billingProviders:Record<string,(env:AppEnv['Bindings'],userId:string)=>Promise<boolean>>={stripe:stripeEntitled" +
|
|
441
|
+
(installed.includes('revenuecat') ? ',revenuecat:revenuecatEntitled' : '') +
|
|
442
|
+
'};\n');
|
|
443
|
+
const bindings = [
|
|
444
|
+
'PUBLIC_APP_URL?: string',
|
|
445
|
+
'BETTER_AUTH_SECRET?: string',
|
|
446
|
+
'AUTH_TRUSTED_ORIGINS?: string',
|
|
447
|
+
];
|
|
448
|
+
if (installed.includes('database-auth'))
|
|
449
|
+
bindings.push('DB: D1Database');
|
|
450
|
+
if (installed.includes('r2'))
|
|
451
|
+
bindings.push('FILES: R2Bucket');
|
|
452
|
+
if (installed.includes('stripe'))
|
|
453
|
+
bindings.push('STRIPE_SECRET_KEY?: string', 'STRIPE_WEBHOOK_SECRET?: string', 'STRIPE_PRICE_ID?: string', 'BILLING_ENVIRONMENT?: string', 'BILLING_PROVIDER?: string');
|
|
454
|
+
if (installed.includes('revenuecat'))
|
|
455
|
+
bindings.push('REVENUECAT_SECRET_KEY?: string', 'REVENUECAT_WEBHOOK_AUTH?: string', 'REVENUECAT_APP_ID?: string', 'REVENUECAT_ENTITLEMENT?: string');
|
|
456
|
+
if (installed.includes('rtc'))
|
|
457
|
+
bindings.push('RTC_APP_ID?: string', 'RTC_APP_SECRET?: string');
|
|
458
|
+
if (installed.includes('ai'))
|
|
459
|
+
bindings.push('AI: Ai', 'AI_MODEL?: string', 'AI_DAILY_LIMIT?: string');
|
|
460
|
+
e.owned('apps/api/src/environment.ts', `import type { CustomBindings, CustomVariables } from './custom-environment';\nexport type AppEnv = { Bindings: CustomBindings & {${bindings.join(';\n')}}; Variables: CustomVariables & {userId:string;fileKey:string} };\n`);
|
|
461
|
+
appendExample(e, 'apps/api/.dev.vars.example', bindings
|
|
462
|
+
.filter((binding) => binding.includes('string'))
|
|
463
|
+
.map((binding) => binding.split('?')[0]));
|
|
464
|
+
}
|
|
465
|
+
function composeMobile(e, installed) {
|
|
466
|
+
const ui = installed.includes('native-ui');
|
|
467
|
+
const billing = installed.includes('revenuecat');
|
|
468
|
+
e.owned('apps/mobile/anhedral-entry.tsx', (ui
|
|
469
|
+
? "import './global.css';\nimport {PortalHost} from '@rn-primitives/portal';\nimport {SafeAreaProvider} from 'react-native-safe-area-context';\n"
|
|
470
|
+
: '') +
|
|
471
|
+
"import {registerRootComponent} from 'expo';\nimport {View} from 'react-native';\nimport App from './App';\nimport {SessionControls} from './components/session-controls';\n" +
|
|
472
|
+
(billing
|
|
473
|
+
? "import {BillingControls} from './components/billing-controls';\nimport {disconnectPurchases} from './lib/purchases';\n"
|
|
474
|
+
: '') +
|
|
475
|
+
'function Root(){return ' +
|
|
476
|
+
(ui ? '<SafeAreaProvider>' : '') +
|
|
477
|
+
'<View style={{flex:1}}><App /><SessionControls' +
|
|
478
|
+
(billing ? ' onSignOut={disconnectPurchases}' : '') +
|
|
479
|
+
'>' +
|
|
480
|
+
(billing ? '<BillingControls/>' : '') +
|
|
481
|
+
'</SessionControls></View>' +
|
|
482
|
+
(ui ? '<PortalHost/></SafeAreaProvider>' : '') +
|
|
483
|
+
';}\nregisterRootComponent(Root);\n');
|
|
484
|
+
e.owned('apps/mobile/components/action-button.tsx', ui
|
|
485
|
+
? "import {Button} from './ui/button';\nimport {Text} from './ui/text';\nexport function ActionButton({label,...props}:{label:string;onPress:()=>void;disabled?:boolean}) {return <Button {...props}><Text>{label}</Text></Button>;}\n"
|
|
486
|
+
: "import {Button} from 'react-native';\nexport function ActionButton({label,...props}:{label:string;onPress:()=>void;disabled?:boolean}) {return <Button title={label} {...props}/>;}\n");
|
|
487
|
+
const file = '.fallowrc.json';
|
|
488
|
+
const current = e.json(file).ignoreDependencies ?? [];
|
|
489
|
+
const peers = ui
|
|
490
|
+
? [
|
|
491
|
+
'babel-preset-expo',
|
|
492
|
+
'react-native-css-interop',
|
|
493
|
+
'react-native-reanimated',
|
|
494
|
+
'react-native-worklets',
|
|
495
|
+
]
|
|
496
|
+
: ['babel-preset-expo'];
|
|
497
|
+
e.set(file, ['ignoreDependencies'], [...new Set([...current, ...peers])]);
|
|
498
|
+
if (ui) {
|
|
499
|
+
const rules = e.json(file).ignoreExports ?? [];
|
|
500
|
+
const rule = {
|
|
501
|
+
file: 'apps/mobile/components/ui/button.tsx',
|
|
502
|
+
exports: ['buttonVariants', 'buttonTextVariants'],
|
|
503
|
+
};
|
|
504
|
+
if (!rules.some((value) => JSON.stringify(value) === JSON.stringify(rule)))
|
|
505
|
+
e.set(file, ['ignoreExports'], [...rules, rule]);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function appendExample(e, file, keys) {
|
|
509
|
+
const current = e.read(file);
|
|
510
|
+
const source = current ?? '# Copy selected values to the local environment. Never commit secrets.\n';
|
|
511
|
+
const existing = new Set([...source.matchAll(/^([A-Z_]+)=/gm)].map((match) => match[1]));
|
|
512
|
+
const additions = keys.filter((key) => !existing.has(key));
|
|
513
|
+
if (!additions.length)
|
|
514
|
+
return;
|
|
515
|
+
const value = source.trimEnd() + '\n' + additions.map((key) => key + '=').join('\n') + '\n';
|
|
516
|
+
if (current === null)
|
|
517
|
+
e.create(file, value);
|
|
518
|
+
else
|
|
519
|
+
e.writes.set(file, value);
|
|
520
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
export function capabilityReferences() {
|
|
3
|
+
return {
|
|
4
|
+
'docs/anhedral/capabilities.md': readFileSync(new URL('../docs/capabilities.md', import.meta.url), 'utf8'),
|
|
5
|
+
'docs/anhedral/ui.md': readFileSync(new URL('../docs/ui.md', import.meta.url), 'utf8'),
|
|
6
|
+
};
|
|
7
|
+
}
|
package/dist/cli-commands.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/** Dispatch only after global help, output mode and working-directory handling. */
|
|
1
|
+
import type { OutputOptions } from './cli-output.js';
|
|
3
2
|
export declare function runCommand(command: string, args: string[], output: OutputOptions): Promise<void>;
|