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