anhedral 0.13.0 → 0.15.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 +35 -232
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +33 -0
- package/assets/ui/native/button.tsx +85 -0
- package/assets/ui/native/card.tsx +33 -0
- package/assets/ui/native/dialog.tsx +75 -0
- package/assets/ui/native/input.tsx +27 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/theme-switcher.tsx +22 -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/capabilities.d.ts +5 -5
- package/dist/capabilities.js +3 -21
- package/dist/capability-contract.d.ts +3 -3
- package/dist/capability-contract.js +11 -50
- package/dist/cli-delivery.d.ts +1 -1
- package/dist/cli-delivery.js +5 -65
- package/dist/cli-output.js +3 -3
- package/dist/command-schema.js +35 -86
- package/dist/delivery-evidence.d.ts +1 -1
- package/dist/delivery-evidence.js +7 -36
- package/dist/delivery.d.ts +2 -8
- package/dist/delivery.js +20 -101
- package/dist/dependencies.d.ts +6 -57
- package/dist/dependencies.js +54 -188
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/inspector-model.d.ts +2 -2
- package/dist/integration-service-readers.d.ts +1 -2
- package/dist/integration-service-readers.js +3 -84
- package/dist/lifecycle-model.d.ts +1 -1
- package/dist/lifecycle-model.js +1 -1
- package/dist/mobile-delivery.d.ts +1 -1
- package/dist/mobile-delivery.js +4 -0
- package/dist/platforms/mobile.js +30 -121
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +299 -0
- package/dist/project-config.d.ts +1 -1
- package/dist/project-config.js +0 -1
- package/dist/project-inspector.js +5 -36
- package/dist/project-state.d.ts +1 -3
- package/dist/project-state.js +2 -85
- package/dist/provider-auth.js +3 -38
- package/dist/provider-readiness.d.ts +1 -1
- package/dist/provider-readiness.js +5 -24
- package/dist/providers/adapters.js +0 -175
- package/dist/providers/api.d.ts +1 -1
- package/dist/providers/api.js +3 -3
- package/dist/providers/config.js +2 -48
- package/dist/providers/definitions.d.ts +1 -204
- package/dist/providers/definitions.js +0 -85
- package/dist/providers/provision.d.ts +1 -1
- package/dist/providers/receipts.js +1 -11
- package/dist/providers/recovery-verification.js +1 -61
- package/dist/providers/runtime.js +4 -35
- package/dist/providers/state.js +1 -7
- package/dist/provision.d.ts +5 -13
- package/dist/provision.js +4 -80
- package/dist/readiness.d.ts +1 -1
- package/dist/readiness.js +3 -8
- package/dist/registry/add.js +10 -70
- package/dist/registry/bootstrap.d.ts +3 -2
- package/dist/registry/bootstrap.js +4 -13
- package/dist/registry/commands.js +8 -10
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +8 -38
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +26 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +2 -2
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/auth.d.ts +1 -2
- package/dist/scaffold/auth.js +55 -130
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -186
- package/dist/scaffold/billing-schema.d.ts +1 -1
- package/dist/scaffold/billing-schema.js +4 -4
- package/dist/scaffold/billing.js +11 -19
- 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 +18 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +22 -86
- package/dist/scaffold/expo-auth.js +33 -22
- package/dist/scaffold/expo-billing.js +17 -52
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +6 -97
- package/dist/scaffold/integrations.d.ts +1 -3
- package/dist/scaffold/integrations.js +9 -10
- package/dist/scaffold/managed-email.d.ts +3 -0
- package/dist/scaffold/managed-email.js +47 -0
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +69 -0
- package/dist/scaffold/password-reset.d.ts +1 -0
- package/dist/scaffold/password-reset.js +99 -0
- package/dist/scaffold/private-files.d.ts +2 -0
- package/dist/scaffold/private-files.js +78 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/web-billing.d.ts +2 -0
- package/dist/scaffold/web-billing.js +48 -0
- package/dist/scaffold/workspace.js +53 -194
- package/dist/service-deletion.js +1 -1
- package/dist/service-descriptor.js +5 -12
- package/dist/service-model.d.ts +1 -1
- package/dist/service-operations.js +2 -32
- package/dist/service-readers.js +1 -32
- package/dist/services-command.d.ts +1 -1
- package/dist/services-command.js +3 -9
- package/dist/ship.d.ts +3 -316
- package/dist/ship.js +10 -142
- package/dist/stack-registry.d.ts +2 -52
- package/dist/stack-registry.js +55 -403
- package/dist/standard.js +7 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +23 -122
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/software-factory.md +24 -557
- package/docs/stack-standard.md +47 -294
- package/docs/verification.md +320 -0
- package/package.json +20 -22
- 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/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- 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/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
package/dist/platforms/mobile.js
CHANGED
|
@@ -3,79 +3,9 @@ import path from 'node:path';
|
|
|
3
3
|
import { writeReactLintConfig } from './lint.js';
|
|
4
4
|
import { appendGitignore, writeFile } from '../util.js';
|
|
5
5
|
import { childPackageName, jsString } from '../render.js';
|
|
6
|
-
import { MOBILE_APP_DEPENDENCIES,
|
|
6
|
+
import { MOBILE_APP_DEPENDENCIES, EAS_CLI_VERSION } from '../dependencies.js';
|
|
7
|
+
import { scaffoldNativeUI } from '../scaffold/native-ui.js';
|
|
7
8
|
import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
|
|
8
|
-
function writeReactNativeReusablesConfig(dir) {
|
|
9
|
-
writeFile(path.join(dir, 'components.json'), JSON.stringify({
|
|
10
|
-
$schema: 'https://ui.shadcn.com/schema.json',
|
|
11
|
-
style: 'new-york',
|
|
12
|
-
rsc: false,
|
|
13
|
-
tsx: true,
|
|
14
|
-
tailwind: {
|
|
15
|
-
config: 'tailwind.config.js',
|
|
16
|
-
css: 'global.css',
|
|
17
|
-
baseColor: 'neutral',
|
|
18
|
-
cssVariables: true,
|
|
19
|
-
},
|
|
20
|
-
aliases: {
|
|
21
|
-
components: '@/components',
|
|
22
|
-
utils: '@/lib/utils',
|
|
23
|
-
ui: '@/components/ui',
|
|
24
|
-
lib: '@/lib',
|
|
25
|
-
hooks: '@/hooks',
|
|
26
|
-
},
|
|
27
|
-
iconLibrary: 'lucide',
|
|
28
|
-
}, null, 2) + '\n');
|
|
29
|
-
writeFile(path.join(dir, 'lib/utils.ts'), `import { clsx, type ClassValue } from 'clsx';
|
|
30
|
-
import { twMerge } from 'tailwind-merge';
|
|
31
|
-
|
|
32
|
-
export function cn(...inputs: ClassValue[]) {
|
|
33
|
-
return twMerge(clsx(inputs));
|
|
34
|
-
}
|
|
35
|
-
`);
|
|
36
|
-
writeFile(path.join(dir, 'components/ui/button.tsx'), `import { Pressable, Text, type PressableProps } from 'react-native';
|
|
37
|
-
import { cn } from '@/lib/utils';
|
|
38
|
-
|
|
39
|
-
type ButtonProps = Omit<PressableProps, 'children'> & { children: string; className?: string };
|
|
40
|
-
|
|
41
|
-
export function Button({ children, className, ...props }: ButtonProps) {
|
|
42
|
-
return <Pressable accessibilityRole="button" className={cn('h-10 items-center justify-center rounded-md bg-primary px-4', className)} {...props}>
|
|
43
|
-
<Text className="font-medium text-primary-foreground">{children}</Text>
|
|
44
|
-
</Pressable>;
|
|
45
|
-
}
|
|
46
|
-
`);
|
|
47
|
-
writeFile(path.join(dir, 'babel.config.js'), `module.exports = function (api) {
|
|
48
|
-
api.cache(true);
|
|
49
|
-
return {
|
|
50
|
-
presets: [['babel-preset-expo', { jsxImportSource: 'nativewind' }], 'nativewind/babel'],
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
`);
|
|
54
|
-
writeFile(path.join(dir, 'metro.config.js'), `const { getDefaultConfig } = require('expo/metro-config');
|
|
55
|
-
const { withNativeWind } = require('nativewind/metro');
|
|
56
|
-
|
|
57
|
-
const config = getDefaultConfig(__dirname);
|
|
58
|
-
|
|
59
|
-
module.exports = withNativeWind(config, { input: './global.css', inlineRem: 16 });
|
|
60
|
-
`);
|
|
61
|
-
writeFile(path.join(dir, 'nativewind-env.d.ts'), '/// <reference types="nativewind/types" />\n');
|
|
62
|
-
writeFile(path.join(dir, 'styles.d.ts'), "declare module '*.css';\n");
|
|
63
|
-
writeFile(path.join(dir, 'tailwind.config.js'), `const { hairlineWidth } = require('nativewind/theme');
|
|
64
|
-
|
|
65
|
-
/** @type {import('tailwindcss').Config} */
|
|
66
|
-
module.exports = {
|
|
67
|
-
content: ['./app/**/*.{ts,tsx}', './components/**/*.{ts,tsx}'],
|
|
68
|
-
presets: [require('nativewind/preset'), require('@workspace/styling/tailwind')],
|
|
69
|
-
theme: { extend: { borderWidth: { hairline: hairlineWidth() } } },
|
|
70
|
-
future: { hoverOnlyWhenSupported: true },
|
|
71
|
-
plugins: [require('tailwindcss-animate')],
|
|
72
|
-
};
|
|
73
|
-
`);
|
|
74
|
-
writeFile(path.join(dir, 'global.css'), `@tailwind base;
|
|
75
|
-
@tailwind components;
|
|
76
|
-
@tailwind utilities;
|
|
77
|
-
`);
|
|
78
|
-
}
|
|
79
9
|
function expoScheme(projectName) {
|
|
80
10
|
const unscoped = projectName.replace(/^@[^/]+\//, '');
|
|
81
11
|
const safe = unscoped.toLowerCase().replace(/[^a-z0-9+.-]+/g, '-');
|
|
@@ -96,30 +26,29 @@ export async function scaffoldExpo(context) {
|
|
|
96
26
|
const displayName = options.name;
|
|
97
27
|
const nameLiteral = jsString(displayName);
|
|
98
28
|
writeReactLintConfig(dir);
|
|
29
|
+
writeFile(path.join(dir, 'babel.config.js'), "module.exports = function(api) { api.cache(true); return { presets: ['babel-preset-expo'] }; };\n");
|
|
99
30
|
writeFile(path.join(dir, 'package.json'), JSON.stringify({
|
|
100
31
|
name: childPackageName(projectName, 'mobile'),
|
|
101
32
|
version: '0.1.0',
|
|
102
33
|
private: true,
|
|
103
34
|
main: 'expo-router/entry',
|
|
104
35
|
scripts: {
|
|
105
|
-
dev: 'expo start -c',
|
|
106
36
|
android: 'expo start -c --android',
|
|
107
37
|
ios: 'expo start -c --ios',
|
|
108
|
-
|
|
109
|
-
build: 'pnpm typecheck
|
|
110
|
-
|
|
38
|
+
start: 'expo start -c',
|
|
39
|
+
build: 'pnpm typecheck',
|
|
40
|
+
typecheck: 'tsc --noEmit',
|
|
41
|
+
lint: 'eslint . --max-warnings 0',
|
|
111
42
|
'eas:login': `pnpm dlx eas-cli@${EAS_CLI_VERSION} login`,
|
|
112
43
|
'build:simulator:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile simulator`,
|
|
113
44
|
'build:internal:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile preview`,
|
|
114
45
|
'build:internal:android': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform android --profile preview`,
|
|
115
46
|
'build:production:ios': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform ios --profile production`,
|
|
116
47
|
'build:production:android': `pnpm dlx eas-cli@${EAS_CLI_VERSION} build --platform android --profile production`,
|
|
117
|
-
typecheck: 'tsc --noEmit',
|
|
118
|
-
lint: 'eslint app components lib --max-warnings 0',
|
|
119
48
|
},
|
|
120
49
|
dependencies: {
|
|
121
50
|
...MOBILE_APP_DEPENDENCIES.dependencies,
|
|
122
|
-
|
|
51
|
+
'@workspace/native-ui': 'workspace:*',
|
|
123
52
|
'@workspace/styling': 'workspace:*',
|
|
124
53
|
},
|
|
125
54
|
devDependencies: {
|
|
@@ -136,7 +65,7 @@ export async function scaffoldExpo(context) {
|
|
|
136
65
|
orientation: 'portrait',
|
|
137
66
|
userInterfaceStyle: 'automatic',
|
|
138
67
|
scheme: expoScheme(projectName),
|
|
139
|
-
|
|
68
|
+
platforms: ['ios', 'android'],
|
|
140
69
|
plugins: ['expo-router', 'expo-status-bar'],
|
|
141
70
|
experiments: { reactCompiler: true, typedRoutes: true },
|
|
142
71
|
},
|
|
@@ -148,35 +77,31 @@ export async function scaffoldExpo(context) {
|
|
|
148
77
|
noUncheckedIndexedAccess: true,
|
|
149
78
|
paths: { '@/*': ['./*'] },
|
|
150
79
|
},
|
|
151
|
-
include: [
|
|
152
|
-
'**/*.ts',
|
|
153
|
-
'**/*.tsx',
|
|
154
|
-
'.expo/types/**/*.ts',
|
|
155
|
-
'expo-env.d.ts',
|
|
156
|
-
'nativewind-env.d.ts',
|
|
157
|
-
],
|
|
80
|
+
include: ['**/*.ts', '**/*.tsx', '.expo/types/**/*.ts', 'expo-env.d.ts'],
|
|
158
81
|
exclude: ['node_modules', 'worker', '.output', 'worker-configuration.d.ts'],
|
|
159
82
|
}, null, 2) + '\n');
|
|
160
|
-
|
|
161
|
-
writeFile(path.join(dir, '
|
|
162
|
-
import '@/lib/development-client';
|
|
163
|
-
|
|
164
|
-
import {
|
|
83
|
+
scaffoldNativeUI(root);
|
|
84
|
+
writeFile(path.join(dir, 'components/ui/button.tsx'), "export { Button } from '@workspace/native-ui';\n");
|
|
85
|
+
writeFile(path.join(dir, 'app/_layout.tsx'), `import '@/lib/development-client';
|
|
86
|
+
import { ThemeProvider } from '@workspace/native-ui';
|
|
87
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
165
88
|
import { Stack } from 'expo-router';
|
|
166
89
|
|
|
167
90
|
export default function RootLayout() {
|
|
168
|
-
return
|
|
91
|
+
return <SafeAreaProvider><ThemeProvider><Stack /></ThemeProvider></SafeAreaProvider>;
|
|
169
92
|
}
|
|
170
93
|
`);
|
|
171
94
|
writeFile(path.join(dir, 'lib/development-client.ts'), 'export {};\n');
|
|
172
95
|
writeFile(path.join(dir, 'lib/development-client.native.ts'), "import 'expo-dev-client';\n");
|
|
173
|
-
writeFile(path.join(dir, 'app/index.tsx'),
|
|
174
|
-
import {
|
|
96
|
+
writeFile(path.join(dir, 'app/index.tsx'), `import { useEffect, useState } from 'react';
|
|
97
|
+
import { api } from '@/lib/api-client';
|
|
98
|
+
import { StatusBar } from 'expo-status-bar';
|
|
99
|
+
import { Linking } from 'react-native';
|
|
100
|
+
import { Screen, Stack, Text } from '@workspace/native-ui';
|
|
175
101
|
import { Button } from '@/components/ui/button';
|
|
176
102
|
|
|
177
103
|
export default function HomeScreen() {
|
|
178
|
-
|
|
179
|
-
? `const [connection, setConnection] = useState('Connecting to the API…');
|
|
104
|
+
const [connection, setConnection] = useState('Connecting to the API…');
|
|
180
105
|
const [pending, setPending] = useState(true);
|
|
181
106
|
useEffect(() => {
|
|
182
107
|
let active = true;
|
|
@@ -193,31 +118,15 @@ export default function HomeScreen() {
|
|
|
193
118
|
catch { setConnection('Unable to reach the API. Check the server and device API origin.'); }
|
|
194
119
|
finally { setPending(false); }
|
|
195
120
|
}
|
|
196
|
-
`
|
|
197
|
-
: ''}
|
|
198
|
-
return (
|
|
199
|
-
<ScrollView style={styles.screen} contentInsetAdjustmentBehavior="automatic" contentContainerStyle={styles.container}>
|
|
200
|
-
<StatusBar style="auto" />
|
|
201
|
-
<View style={styles.content}>
|
|
202
|
-
<Text accessibilityRole="header" style={styles.title}>{${nameLiteral}}</Text>
|
|
203
|
-
<Text selectable style={styles.subtitle}>Expo application scaffold generated by Anhedral.</Text>
|
|
204
|
-
${context.has('hono')
|
|
205
|
-
? `<Text accessibilityLiveRegion="polite">{connection}</Text>
|
|
206
|
-
<Button disabled={pending} onPress={() => void checkConnection()}>{pending ? 'Connecting…' : 'Check API connection'}</Button>`
|
|
207
|
-
: ''}
|
|
208
|
-
<Button onPress={() => void Linking.openURL('https://docs.expo.dev')}>Learn more</Button>
|
|
209
|
-
</View>
|
|
210
|
-
</ScrollView>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
121
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
122
|
+
return <Screen><StatusBar style="auto" /><Stack>
|
|
123
|
+
<Text variant="heading" accessibilityRole="header">{${nameLiteral}}</Text>
|
|
124
|
+
<Text variant="muted">Native iOS and Android application generated by Anhedral.</Text>
|
|
125
|
+
<Text accessibilityLiveRegion="polite">{connection}</Text>
|
|
126
|
+
<Button disabled={pending} onPress={() => void checkConnection()}>{pending ? 'Connecting…' : 'Check API connection'}</Button>
|
|
127
|
+
<Button onPress={() => void Linking.openURL('https://docs.expo.dev')}>Learn more</Button>
|
|
128
|
+
</Stack></Screen>;
|
|
129
|
+
}
|
|
221
130
|
`);
|
|
222
131
|
writeFile(path.join(dir, '.env.example'), '');
|
|
223
132
|
writeFile(path.join(dir, 'eas.json'), JSON.stringify({
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
+
export declare function scaffoldWeb({ root, options }: RecipeContext): void;
|
|
3
|
+
export declare const WEB_API_PROXY = "export interface ApiBinding { fetch(request: Request): Promise<Response> }\ntype Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };\nfunction developmentOrigin(configured?: string): string {\n const url = new URL(configured || 'http://127.0.0.1:8787');\n const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);\n const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];\n if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');\n return url.origin;\n}\nfunction backendOrigin(options: Options): string {\n if (options.development) return developmentOrigin(options.devOrigin);\n if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');\n return 'https://api.internal';\n}\nfunction apiTarget(request: Request, origin: string): URL {\n const url = new URL(request.url);\n if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');\n return new URL(url.pathname + url.search, origin);\n}\nfunction forwardedHeaders(request: Request): Headers {\n const headers = new Headers();\n for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {\n const value = request.headers.get(name); if (value) headers.set(name, value);\n }\n return headers;\n}\nfunction upstreamRequest(request: Request, target: URL): Request {\n const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };\n if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }\n return new Request(target, settings);\n}\nfunction privateResponse(response: Response, development: boolean): Response {\n const headers = new Headers(response.headers);\n for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);\n // Node fetch already decoded the local HTTP response. Next must frame/compress\n // those decoded bytes itself; the sidecar's wire headers no longer describe them.\n if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }\n headers.set('cache-control', 'private, no-store');\n return new Response(response.body, { status: response.status, headers });\n}\nexport async function proxyApi(request: Request, options: Options): Promise<Response> {\n try {\n const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));\n const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);\n return privateResponse(response, options.development);\n } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }\n}\n";
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { resourceName, childPackageName, jsString } from '../render.js';
|
|
4
|
+
import { WEB_DEPENDENCIES } from '../dependencies.js';
|
|
5
|
+
import { json, put, workerConfig } from '../scaffold/files.js';
|
|
6
|
+
export function scaffoldWeb({ root, options }) {
|
|
7
|
+
const app = 'apps/web';
|
|
8
|
+
json(root, `${app}/package.json`, {
|
|
9
|
+
name: childPackageName(options.name, 'web'),
|
|
10
|
+
private: true,
|
|
11
|
+
version: '0.1.0',
|
|
12
|
+
type: 'module',
|
|
13
|
+
scripts: {
|
|
14
|
+
dev: 'next dev --turbopack --hostname 0.0.0.0 --port 3000',
|
|
15
|
+
'build:next': 'next build --webpack',
|
|
16
|
+
build: 'opennextjs-cloudflare build && pnpm build:worker',
|
|
17
|
+
'build:worker': 'wrangler deploy --dry-run --outdir dist',
|
|
18
|
+
preview: 'wrangler dev --port 3000 --inspector-port 9230',
|
|
19
|
+
deploy: 'wrangler deploy',
|
|
20
|
+
start: 'next start --hostname 0.0.0.0 --port 3000',
|
|
21
|
+
typecheck: 'next typegen && tsc --noEmit',
|
|
22
|
+
lint: 'eslint . --max-warnings 0',
|
|
23
|
+
},
|
|
24
|
+
dependencies: {
|
|
25
|
+
...WEB_DEPENDENCIES.dependencies,
|
|
26
|
+
'@workspace/contracts': 'workspace:*',
|
|
27
|
+
'@workspace/styling': 'workspace:*',
|
|
28
|
+
},
|
|
29
|
+
devDependencies: {
|
|
30
|
+
...WEB_DEPENDENCIES.devDependencies,
|
|
31
|
+
'@workspace/eslint-config': 'workspace:*',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
json(root, `${app}/wrangler.jsonc`, {
|
|
35
|
+
...workerConfig(resourceName(options.name, 'web')),
|
|
36
|
+
main: '.open-next/worker.js',
|
|
37
|
+
compatibility_flags: ['nodejs_compat', 'global_fetch_strictly_public'],
|
|
38
|
+
assets: { directory: '.open-next/assets', binding: 'ASSETS' },
|
|
39
|
+
services: [
|
|
40
|
+
{ binding: 'ANHEDRAL_API', service: resourceName(options.name, 'api') },
|
|
41
|
+
{ binding: 'WORKER_SELF_REFERENCE', service: resourceName(options.name, 'web') },
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
put(root, `${app}/next.config.ts`, `import type { NextConfig } from 'next';
|
|
45
|
+
const previewOrigin = process.env.NODE_ENV === 'development' ? process.env.ANHEDRAL_PREVIEW_ORIGIN : undefined;
|
|
46
|
+
let allowedDevOrigins: string[] = [];
|
|
47
|
+
if (previewOrigin) {
|
|
48
|
+
const url = new URL(previewOrigin);
|
|
49
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.pathname !== '/' || url.search || url.hash) throw new Error('ANHEDRAL_PREVIEW_ORIGIN must be an HTTP(S) origin.');
|
|
50
|
+
allowedDevOrigins = [url.hostname];
|
|
51
|
+
}
|
|
52
|
+
const config: NextConfig = { allowedDevOrigins, transpilePackages: ['@workspace/contracts', '@workspace/styling'], images: { unoptimized: true } };
|
|
53
|
+
export default config;
|
|
54
|
+
`);
|
|
55
|
+
put(root, `${app}/open-next.config.ts`, `import { defineCloudflareConfig } from '@opennextjs/cloudflare';
|
|
56
|
+
const config = { ...defineCloudflareConfig(), buildCommand: 'pnpm build:next' };
|
|
57
|
+
export default config;
|
|
58
|
+
`);
|
|
59
|
+
json(root, `${app}/tsconfig.json`, {
|
|
60
|
+
compilerOptions: {
|
|
61
|
+
target: 'ES2022',
|
|
62
|
+
lib: ['DOM', 'DOM.Iterable', 'ES2022'],
|
|
63
|
+
allowJs: true,
|
|
64
|
+
skipLibCheck: true,
|
|
65
|
+
strict: true,
|
|
66
|
+
noEmit: true,
|
|
67
|
+
esModuleInterop: true,
|
|
68
|
+
module: 'ESNext',
|
|
69
|
+
moduleResolution: 'Bundler',
|
|
70
|
+
resolveJsonModule: true,
|
|
71
|
+
isolatedModules: true,
|
|
72
|
+
jsx: 'react-jsx',
|
|
73
|
+
incremental: true,
|
|
74
|
+
plugins: [{ name: 'next' }],
|
|
75
|
+
paths: { '@/*': ['./*'] },
|
|
76
|
+
},
|
|
77
|
+
include: [
|
|
78
|
+
'next-env.d.ts',
|
|
79
|
+
'**/*.ts',
|
|
80
|
+
'**/*.tsx',
|
|
81
|
+
'.next/types/**/*.ts',
|
|
82
|
+
'.next/dev/types/**/*.ts',
|
|
83
|
+
],
|
|
84
|
+
exclude: ['node_modules', '.open-next', 'dist'],
|
|
85
|
+
});
|
|
86
|
+
put(root, `${app}/next-env.d.ts`, '/// <reference types="next" />\n/// <reference types="next/image-types/global" />\n');
|
|
87
|
+
put(root, `${app}/eslint.config.mjs`, `import { defineConfig, globalIgnores } from 'eslint/config';
|
|
88
|
+
import next from 'eslint-config-next/core-web-vitals';
|
|
89
|
+
import ts from 'eslint-config-next/typescript';
|
|
90
|
+
export default defineConfig([...next, ...ts, globalIgnores(['.next/**', '.open-next/**', 'dist/**', 'next-env.d.ts', 'worker-configuration.d.ts'])]);
|
|
91
|
+
`);
|
|
92
|
+
json(root, `${app}/components.json`, {
|
|
93
|
+
$schema: 'https://ui.shadcn.com/schema.json',
|
|
94
|
+
style: 'base-nova',
|
|
95
|
+
rsc: true,
|
|
96
|
+
tsx: true,
|
|
97
|
+
tailwind: { config: '', css: 'app/globals.css', baseColor: 'neutral', cssVariables: true },
|
|
98
|
+
aliases: {
|
|
99
|
+
components: '@/components',
|
|
100
|
+
ui: '@/components/ui',
|
|
101
|
+
utils: '@/lib/utils',
|
|
102
|
+
lib: '@/lib',
|
|
103
|
+
hooks: '@/hooks',
|
|
104
|
+
},
|
|
105
|
+
iconLibrary: 'lucide',
|
|
106
|
+
});
|
|
107
|
+
put(root, `${app}/lib/utils.ts`, `import { clsx, type ClassValue } from 'clsx';
|
|
108
|
+
import { twMerge } from 'tailwind-merge';
|
|
109
|
+
export function cn(...values: ClassValue[]) { return twMerge(clsx(values)); }
|
|
110
|
+
`);
|
|
111
|
+
for (const component of ['button', 'input', 'label'])
|
|
112
|
+
put(root, `${app}/components/ui/${component}.tsx`, readFileSync(fileURLToPath(new URL(`../../assets/ui/web/${component}.tsx`, import.meta.url)), 'utf8'));
|
|
113
|
+
for (const file of ['LICENSE.shadcn', 'UPSTREAM.json'])
|
|
114
|
+
put(root, `${app}/${file}`, readFileSync(fileURLToPath(new URL(`../../assets/ui/${file}`, import.meta.url)), 'utf8'));
|
|
115
|
+
put(root, `${app}/postcss.config.mjs`, "const config = { plugins: { '@tailwindcss/postcss': {} } };\nexport default config;\n");
|
|
116
|
+
put(root, `${app}/app/globals.css`, `@import 'tailwindcss';
|
|
117
|
+
@import '@workspace/styling/globals.css';
|
|
118
|
+
@theme inline {
|
|
119
|
+
--color-background: hsl(var(--background)); --color-foreground: hsl(var(--foreground));
|
|
120
|
+
--color-primary: hsl(var(--primary)); --color-primary-foreground: hsl(var(--primary-foreground));
|
|
121
|
+
--color-secondary: hsl(var(--secondary)); --color-secondary-foreground: hsl(var(--secondary-foreground));
|
|
122
|
+
--color-muted: hsl(var(--muted)); --color-muted-foreground: hsl(var(--muted-foreground));
|
|
123
|
+
--color-border: hsl(var(--border)); --color-input: hsl(var(--input)); --color-ring: hsl(var(--ring));
|
|
124
|
+
--color-destructive: hsl(var(--destructive)); --radius-md: var(--radius); --radius-lg: calc(var(--radius) + 2px);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
* { box-sizing: border-box; } body { margin: 0; background: hsl(var(--background)); color: hsl(var(--foreground)); font-family: Arial, Helvetica, sans-serif; }
|
|
128
|
+
h1 { font-size: 2rem; font-weight: 600; line-height: 1.2; letter-spacing: -.025em; } h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
|
|
129
|
+
main { max-width: 64rem; margin: 0 auto; padding: 4rem 1.5rem; } nav, form, .stack { display: flex; gap: 1rem; } form, .stack { flex-direction: column; } form { max-width: 26rem; } label { display: grid; gap: .5rem; }
|
|
130
|
+
a { color: inherit; } .button, input { min-height: 2.75rem; padding: .65rem 1rem; border: 1px solid hsl(var(--border)); border-radius: var(--radius); font: inherit; }
|
|
131
|
+
.button { cursor: pointer; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); } .button:disabled { opacity: .5; cursor: default; } input { background: hsl(var(--background)); color: inherit; }
|
|
132
|
+
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 3px; } .muted { color: hsl(var(--muted-foreground)); }
|
|
133
|
+
`);
|
|
134
|
+
put(root, `${app}/app/layout.tsx`, `import type { Metadata } from 'next';
|
|
135
|
+
import Link from 'next/link';
|
|
136
|
+
import './globals.css';
|
|
137
|
+
export const metadata: Metadata = { title: ${jsString(options.name)}, description: 'Anhedral application' };
|
|
138
|
+
export default function Layout({ children }: { children: React.ReactNode }) { return <html lang="en"><body><main><nav aria-label="Main"><Link href="/">Home</Link><Link href="/account">Account</Link></nav>{children}</main></body></html>; }
|
|
139
|
+
`);
|
|
140
|
+
put(root, `${app}/app/page.tsx`, `import { headers } from 'next/headers';
|
|
141
|
+
export default async function Home() {
|
|
142
|
+
const request = await headers();
|
|
143
|
+
return <section className="stack"><h1>${escapeJsx(options.name)}</h1><p>Next.js on Cloudflare, with a shared Hono API.</p><p className="muted" data-rendering="server">Rendered on the server for {request.get('host') ?? 'this request'}.</p></section>;
|
|
144
|
+
}
|
|
145
|
+
`);
|
|
146
|
+
put(root, `${app}/app/loading.tsx`, `export default function Loading() { return <p role="status">Loading…</p>; }\n`);
|
|
147
|
+
put(root, `${app}/app/error.tsx`, `'use client';\nexport default function ErrorPage({ reset }: { reset: () => void }) { return <section><h1>Unable to load this page</h1><button onClick={reset}>Try again</button></section>; }\n`);
|
|
148
|
+
put(root, `${app}/lib/api-proxy.ts`, WEB_API_PROXY);
|
|
149
|
+
put(root, `${app}/lib/server-api.ts`, `import 'server-only';
|
|
150
|
+
import { getCloudflareContext } from '@opennextjs/cloudflare';
|
|
151
|
+
import { proxyApi, type ApiBinding } from './api-proxy';
|
|
152
|
+
function isApiBinding(value: unknown): value is ApiBinding {
|
|
153
|
+
return typeof value === 'object' && value !== null && typeof Reflect.get(value, 'fetch') === 'function';
|
|
154
|
+
}
|
|
155
|
+
async function productionBinding(): Promise<ApiBinding | undefined> {
|
|
156
|
+
const { env } = await getCloudflareContext({ async: true });
|
|
157
|
+
const candidate: unknown = Reflect.get(env, 'ANHEDRAL_API');
|
|
158
|
+
return isApiBinding(candidate) ? candidate : undefined;
|
|
159
|
+
}
|
|
160
|
+
export async function apiRequest(request: Request): Promise<Response> {
|
|
161
|
+
const development = process.env.NODE_ENV === 'development';
|
|
162
|
+
const binding = development ? undefined : await productionBinding();
|
|
163
|
+
return proxyApi(request, { binding, development, devOrigin: process.env.API_INTERNAL_URL });
|
|
164
|
+
}
|
|
165
|
+
`);
|
|
166
|
+
put(root, `${app}/app/api/[[...path]]/route.ts`, `import { apiRequest } from '@/lib/server-api';
|
|
167
|
+
export const dynamic = 'force-dynamic';
|
|
168
|
+
export const GET = apiRequest;
|
|
169
|
+
export const POST = apiRequest;
|
|
170
|
+
export const PUT = apiRequest;
|
|
171
|
+
export const PATCH = apiRequest;
|
|
172
|
+
export const DELETE = apiRequest;
|
|
173
|
+
export const HEAD = apiRequest;
|
|
174
|
+
export const OPTIONS = apiRequest;
|
|
175
|
+
`);
|
|
176
|
+
put(root, `${app}/lib/auth-client.ts`, `import { createAuthClient } from 'better-auth/react';\nexport const authClient = createAuthClient();\n`);
|
|
177
|
+
put(root, `${app}/app/sign-in/page.tsx`, WEB_SIGN_IN);
|
|
178
|
+
put(root, `${app}/components/sign-out.tsx`, `'use client';
|
|
179
|
+
import { useState } from 'react';
|
|
180
|
+
import { useRouter } from 'next/navigation';
|
|
181
|
+
import { authClient } from '@/lib/auth-client';
|
|
182
|
+
import { Button } from '@/components/ui/button';
|
|
183
|
+
export function SignOut() { const [error, setError] = useState(''); const [pending, setPending] = useState(false); const router = useRouter();
|
|
184
|
+
async function logout() { setPending(true); setError(''); try { const result = await authClient.signOut(); if (result.error) throw Error('Unable to sign out.'); router.replace('/sign-in'); router.refresh(); } catch { setError('Unable to sign out. Please retry.'); } finally { setPending(false); } }
|
|
185
|
+
return <><Button disabled={pending} onClick={() => void logout()}>{pending ? 'Signing out…' : 'Sign out'}</Button><p role="status">{error}</p></>; }
|
|
186
|
+
`);
|
|
187
|
+
put(root, `${app}/app/account/page.tsx`, `import { headers } from 'next/headers';
|
|
188
|
+
import { redirect } from 'next/navigation';
|
|
189
|
+
import { sessionSchema } from '@workspace/contracts';
|
|
190
|
+
import { apiRequest } from '@/lib/server-api';
|
|
191
|
+
import { SignOut } from '@/components/sign-out';
|
|
192
|
+
export default async function Account() {
|
|
193
|
+
const incoming = await headers();
|
|
194
|
+
const response = await apiRequest(new Request('https://app.internal/api/session', { headers: { cookie: incoming.get('cookie') ?? '' } }));
|
|
195
|
+
if (response.status === 401) redirect('/sign-in');
|
|
196
|
+
if (!response.ok) throw Error('Session verification is unavailable.');
|
|
197
|
+
const { user } = sessionSchema.parse(await response.json());
|
|
198
|
+
return <section className="stack"><h1>Account</h1><p>{user.email}</p><SignOut /></section>;
|
|
199
|
+
}
|
|
200
|
+
`);
|
|
201
|
+
put(root, `${app}/.env.example`, '# Development only. Production uses the ANHEDRAL_API service binding.\nAPI_INTERNAL_URL=http://127.0.0.1:8787\n');
|
|
202
|
+
}
|
|
203
|
+
function escapeJsx(value) {
|
|
204
|
+
return value
|
|
205
|
+
.replaceAll('&', '&')
|
|
206
|
+
.replaceAll('<', '<')
|
|
207
|
+
.replaceAll('>', '>')
|
|
208
|
+
.replaceAll('{', '{')
|
|
209
|
+
.replaceAll('}', '}');
|
|
210
|
+
}
|
|
211
|
+
export const WEB_API_PROXY = `export interface ApiBinding { fetch(request: Request): Promise<Response> }
|
|
212
|
+
type Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };
|
|
213
|
+
function developmentOrigin(configured?: string): string {
|
|
214
|
+
const url = new URL(configured || 'http://127.0.0.1:8787');
|
|
215
|
+
const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
216
|
+
const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];
|
|
217
|
+
if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');
|
|
218
|
+
return url.origin;
|
|
219
|
+
}
|
|
220
|
+
function backendOrigin(options: Options): string {
|
|
221
|
+
if (options.development) return developmentOrigin(options.devOrigin);
|
|
222
|
+
if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');
|
|
223
|
+
return 'https://api.internal';
|
|
224
|
+
}
|
|
225
|
+
function apiTarget(request: Request, origin: string): URL {
|
|
226
|
+
const url = new URL(request.url);
|
|
227
|
+
if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');
|
|
228
|
+
return new URL(url.pathname + url.search, origin);
|
|
229
|
+
}
|
|
230
|
+
function forwardedHeaders(request: Request): Headers {
|
|
231
|
+
const headers = new Headers();
|
|
232
|
+
for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
|
|
233
|
+
const value = request.headers.get(name); if (value) headers.set(name, value);
|
|
234
|
+
}
|
|
235
|
+
return headers;
|
|
236
|
+
}
|
|
237
|
+
function upstreamRequest(request: Request, target: URL): Request {
|
|
238
|
+
const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };
|
|
239
|
+
if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }
|
|
240
|
+
return new Request(target, settings);
|
|
241
|
+
}
|
|
242
|
+
function privateResponse(response: Response, development: boolean): Response {
|
|
243
|
+
const headers = new Headers(response.headers);
|
|
244
|
+
for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
|
|
245
|
+
// Node fetch already decoded the local HTTP response. Next must frame/compress
|
|
246
|
+
// those decoded bytes itself; the sidecar's wire headers no longer describe them.
|
|
247
|
+
if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }
|
|
248
|
+
headers.set('cache-control', 'private, no-store');
|
|
249
|
+
return new Response(response.body, { status: response.status, headers });
|
|
250
|
+
}
|
|
251
|
+
export async function proxyApi(request: Request, options: Options): Promise<Response> {
|
|
252
|
+
try {
|
|
253
|
+
const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));
|
|
254
|
+
const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);
|
|
255
|
+
return privateResponse(response, options.development);
|
|
256
|
+
} catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }
|
|
257
|
+
}
|
|
258
|
+
`;
|
|
259
|
+
const WEB_SIGN_IN = `'use client';
|
|
260
|
+
import { useRef, useState, type FormEvent } from 'react';
|
|
261
|
+
import { useRouter } from 'next/navigation';
|
|
262
|
+
import Link from 'next/link';
|
|
263
|
+
import { authClient } from '@/lib/auth-client';
|
|
264
|
+
import { Button } from '@/components/ui/button';
|
|
265
|
+
import { Input } from '@/components/ui/input';
|
|
266
|
+
import { Label } from '@/components/ui/label';
|
|
267
|
+
function verificationPending(create: boolean, signedIn: boolean): boolean { return create && !signedIn; }
|
|
268
|
+
async function requestVerification(email: string) {
|
|
269
|
+
const result = await authClient.sendVerificationEmail({ email, callbackURL: '/sign-in' });
|
|
270
|
+
if (result.error) throw Error('Verification unavailable');
|
|
271
|
+
}
|
|
272
|
+
async function authenticate(data: FormData, create: boolean) {
|
|
273
|
+
const email = String(data.get('email')); const password = String(data.get('password')); const name = String(data.get('name'));
|
|
274
|
+
const result = create ? await authClient.signUp.email({ email, password, name, callbackURL: '/sign-in' }) : await authClient.signIn.email({ email, password });
|
|
275
|
+
if (result.error) throw Error('Sign in failed.');
|
|
276
|
+
return Boolean(result.data?.token);
|
|
277
|
+
}
|
|
278
|
+
export default function SignIn() {
|
|
279
|
+
const form = useRef<HTMLFormElement>(null);
|
|
280
|
+
const router = useRouter(); const [create, setCreate] = useState(false); const [pending, setPending] = useState(false); const [error, setError] = useState('');
|
|
281
|
+
async function submit(event: FormEvent<HTMLFormElement>) { event.preventDefault(); if (pending) return; setPending(true); setError('');
|
|
282
|
+
const data = new FormData(event.currentTarget);
|
|
283
|
+
try { const signedIn = await authenticate(data, create); if (verificationPending(create, signedIn)) { form.current?.reset(); setCreate(false); setError('Check your email to verify your account, then sign in.'); return; } router.replace('/account'); router.refresh(); } catch { setError('Unable to sign in. Check your details and retry.'); } finally { setPending(false); }
|
|
284
|
+
}
|
|
285
|
+
async function resend() {
|
|
286
|
+
const input = form.current?.querySelector<HTMLInputElement>('[name="email"]');
|
|
287
|
+
if (pending || !input?.reportValidity()) return;
|
|
288
|
+
const email = input.value;
|
|
289
|
+
setPending(true); setError('');
|
|
290
|
+
try {
|
|
291
|
+
await requestVerification(email);
|
|
292
|
+
setError('If verification is needed, check your email for the link.');
|
|
293
|
+
} catch { setError('Unable to request verification. Please retry.'); }
|
|
294
|
+
finally { setPending(false); }
|
|
295
|
+
}
|
|
296
|
+
const labels = create ? { title: 'Create account', password: 'new-password', toggle: 'Use an existing account' } : { title: 'Sign in', password: 'current-password', toggle: 'Create an account' };
|
|
297
|
+
return <section className="stack"><h1>{labels.title}</h1><form ref={form} onSubmit={submit}>{create && <Label>Name<Input name="name" required autoComplete="name" /></Label>}<Label>Email<Input name="email" type="email" required autoComplete="email" /></Label><Label>Password<Input name="password" type="password" minLength={8} required autoComplete={labels.password} /></Label><Button type="submit" disabled={pending}>{pending ? 'Working…' : labels.title}</Button><p role="status">{error}</p><Link href="/reset-password">Forgot your password?</Link><Button type="button" disabled={pending} onClick={() => void resend()}>Resend verification email</Button><Button type="button" disabled={pending} onClick={() => setCreate(!create)}>{labels.toggle}</Button></form></section>;
|
|
298
|
+
}
|
|
299
|
+
`;
|
package/dist/project-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const PROJECT_CONFIG_FILE = "anhedral.json";
|
|
2
2
|
export declare const PROJECT_CONFIG_MAX_BYTES: number;
|
|
3
|
-
export declare const PROJECT_CONFIG_SECTIONS: readonly ["identity", "standard", "setup", "providers", "cloudflare", "
|
|
3
|
+
export declare const PROJECT_CONFIG_SECTIONS: readonly ["identity", "standard", "setup", "providers", "cloudflare", "registry"];
|
|
4
4
|
export type ProjectSection = (typeof PROJECT_CONFIG_SECTIONS)[number];
|
|
5
5
|
export type ProjectConfig = {
|
|
6
6
|
schemaVersion: 1;
|
package/dist/project-config.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { resolveVoidCloudflareConfig } from './project-state.js';
|
|
2
1
|
import { projectLifecycle } from './project-lifecycle.js';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import { existsSync, lstatSync, readdirSync, realpathSync } from 'node:fs';
|
|
@@ -225,18 +224,12 @@ export function inspectApplication(root) {
|
|
|
225
224
|
permissions: 'unknown',
|
|
226
225
|
billing: 'unknown',
|
|
227
226
|
});
|
|
228
|
-
if (products.includes('hono')
|
|
229
|
-
products.includes('vinext') ||
|
|
230
|
-
(products.includes('next') && selection.data.hosting === 'cloudflare'))
|
|
227
|
+
if (products.includes('hono'))
|
|
231
228
|
add('cloudflare', null, [
|
|
232
229
|
'Authenticate and connect the intended account and audience; verify service eligibility and required scopes.',
|
|
233
230
|
]);
|
|
234
|
-
if (products.includes('next') && selection.data.hosting === 'vercel')
|
|
235
|
-
add('vercel', null, [
|
|
236
|
-
'Authenticate and connect the intended team, project, plan, and audience.',
|
|
237
|
-
]);
|
|
238
231
|
for (const [id, definition] of Object.entries(PROVIDER_DEFINITIONS))
|
|
239
|
-
if (products.includes(id)
|
|
232
|
+
if (products.includes(id))
|
|
240
233
|
add(id, definition.credential, definition.ownerSteps);
|
|
241
234
|
if (products.includes('expo'))
|
|
242
235
|
add('expo', null, [
|
|
@@ -298,13 +291,7 @@ export function inspectApplication(root) {
|
|
|
298
291
|
});
|
|
299
292
|
};
|
|
300
293
|
for (const application of apps()) {
|
|
301
|
-
const
|
|
302
|
-
const lock = declaration ? document(`${application}/void.lock.json`) : null;
|
|
303
|
-
const config = declaration
|
|
304
|
-
? lock
|
|
305
|
-
? resolveVoidCloudflareConfig(declaration, lock)
|
|
306
|
-
: declaration
|
|
307
|
-
: document(`${application}/wrangler.jsonc`);
|
|
294
|
+
const config = document(`${application}/wrangler.jsonc`);
|
|
308
295
|
if (config) {
|
|
309
296
|
for (const [field, kind, idField] of [
|
|
310
297
|
['d1_databases', 'D1', 'database_id'],
|
|
@@ -394,9 +381,7 @@ export function inspectApplication(root) {
|
|
|
394
381
|
for (const value of values) {
|
|
395
382
|
try {
|
|
396
383
|
let entry;
|
|
397
|
-
|
|
398
|
-
entry = release(value, value.url);
|
|
399
|
-
else {
|
|
384
|
+
{
|
|
400
385
|
const members = array(value.targets ?? []).map(object);
|
|
401
386
|
const ids = members.map((member) => name(member.target));
|
|
402
387
|
if (new Set(ids).size !== ids.length || ids.some((id) => !known.includes(id)))
|
|
@@ -431,7 +416,7 @@ export function inspectApplication(root) {
|
|
|
431
416
|
}
|
|
432
417
|
function hostingTargets() {
|
|
433
418
|
const targets = [];
|
|
434
|
-
for (const provider of ['cloudflare'
|
|
419
|
+
for (const provider of ['cloudflare']) {
|
|
435
420
|
try {
|
|
436
421
|
const project = projectSection(provider);
|
|
437
422
|
if (!project)
|
|
@@ -497,22 +482,6 @@ export function inspectApplication(root) {
|
|
|
497
482
|
const targets = section([], 'Delivery targets are unavailable.', () => {
|
|
498
483
|
const values = hostingTargets();
|
|
499
484
|
const applications = apps();
|
|
500
|
-
for (const [app, provider] of [
|
|
501
|
-
['apps/desktop', 'desktop'],
|
|
502
|
-
['apps/extension', 'extension'],
|
|
503
|
-
])
|
|
504
|
-
if (applications.includes(app))
|
|
505
|
-
values.push({
|
|
506
|
-
id: `${provider}:application`,
|
|
507
|
-
provider,
|
|
508
|
-
application: app,
|
|
509
|
-
audience: 'not-applicable',
|
|
510
|
-
accountReference: null,
|
|
511
|
-
latestAttempt: null,
|
|
512
|
-
lastSuccessful: null,
|
|
513
|
-
delivery: 'scaffold-only',
|
|
514
|
-
liveStatus: 'unknown',
|
|
515
|
-
});
|
|
516
485
|
if (applications.includes('apps/mobile')) {
|
|
517
486
|
for (const platform of ['ios', 'android']) {
|
|
518
487
|
const target = {
|