anhedral 0.24.0 → 0.24.1
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 +3 -3
- package/assets/launch/AGENTS.md.txt +7 -0
- package/assets/launch/README.md.txt +40 -0
- package/assets/launch/backend-vite.config.ts.txt +18 -0
- package/assets/launch/home.tsx.txt +2 -1
- package/assets/launch/root.tsx.txt +38 -5
- package/assets/launch/router.tsx.txt +3 -2
- package/assets/launch/sign-in.tsx.txt +2 -1
- package/assets/launch/storage-page.tsx.txt +1 -0
- package/assets/launch/styles.css.txt +55 -16
- package/assets/launch/styling-tokens.cjs +45 -0
- package/assets/launch/vite.config.ts.txt +13 -0
- package/assets/stack/api-eslint.config.mjs.txt +2 -0
- package/assets/stack/api-index.ts.txt +1 -0
- package/assets/stack/api-proxy.ts.txt +112 -0
- package/assets/stack/auth-routes.ts.txt +3 -1
- package/assets/stack/auth.ts.txt +5 -4
- package/assets/stack/base-eslint.js.txt +16 -0
- package/assets/stack/billing-mode.ts.txt +2 -0
- package/assets/stack/billing-providers.ts.txt +8 -0
- package/assets/stack/db-index.ts.txt +7 -0
- package/assets/stack/db-migrate.mjs.txt +23 -0
- package/assets/stack/drizzle.config.ts.txt +2 -0
- package/assets/stack/entitlement-guard.ts.txt +2 -0
- package/assets/stack/entitlements.ts.txt +3 -1
- package/assets/stack/payment.test.mjs.txt +7 -1
- package/assets/stack/security.ts.txt +2 -0
- package/assets/stack/shared-eslint.config.mjs.txt +6 -0
- package/assets/stack/storage.ts.txt +3 -1
- package/assets/stack/stripe.ts.txt +4 -2
- package/dist/cli-output.js +1 -1
- package/dist/composition/recipes.d.ts +1 -1
- package/dist/composition/recipes.js +51 -56
- package/dist/dependencies.d.ts +0 -6
- package/dist/dependencies.js +0 -1
- package/dist/launch.d.ts +1 -1
- package/dist/launch.js +25 -103
- package/dist/render.d.ts +0 -10
- package/dist/render.js +1 -38
- package/dist/scaffold/bootstrap.d.ts +1 -2
- package/dist/scaffold/bootstrap.js +4 -8
- package/dist/scaffold/files.d.ts +12 -24
- package/dist/scaffold/files.js +9 -103
- package/dist/scaffold/styling.d.ts +2 -4
- package/dist/scaffold/styling.js +46 -69
- package/dist/scaffold/tanstack.d.ts +1 -1
- package/dist/scaffold/tanstack.js +22 -37
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/software-factory.md +1 -1
- package/package.json +4 -2
- package/dist/api-proxy.d.ts +0 -1
- package/dist/api-proxy.js +0 -48
package/dist/cli-output.js
CHANGED
|
@@ -38,7 +38,7 @@ export function formatResult(_command, value) {
|
|
|
38
38
|
if (data.stack === 'anhedral-stack' && !data.generated)
|
|
39
39
|
return `Foundation preview for ${data.root}.\nStack: Anhedral Stack.\nNo files were written or resources provisioned.`;
|
|
40
40
|
if (data.stack === 'anhedral-stack' && data.generated)
|
|
41
|
-
return `Created ${data.root}.\nStack: Anhedral Stack.\n${data.dependenciesInstalled ? 'Run pnpm dev' : 'Run pnpm install, then pnpm dev'} in the project directory.\
|
|
41
|
+
return `Created ${data.root}.\nStack: Anhedral Stack.\n${data.dependenciesInstalled ? 'Run pnpm dev' : 'Run pnpm install, then pnpm dev'} in the project directory.\nEdit apps/web/src/routes/index.tsx to change the home page.\nSee README.md for checks, additions, and updates.`;
|
|
42
42
|
return (`${data.generated ? 'Created' : 'Foundation preview for'} ${data.root}.\nComponents: ${data.products.join(', ')}.\n` +
|
|
43
43
|
(data.generated
|
|
44
44
|
? 'Review README.md, then run pnpm dev in the project directory. You own development, integrations and hosting.'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CapabilityEditor } from './editor.js';
|
|
2
1
|
import type { Capability } from './catalog.js';
|
|
2
|
+
import { CapabilityEditor } from './editor.js';
|
|
3
3
|
export declare function addCapabilityRecipe(e: CapabilityEditor, id: Capability, name: string): void;
|
|
4
4
|
export declare function composeCapabilities(e: CapabilityEditor, installed: Capability[], operation?: 'compose' | 'update'): void;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CapabilityEditor } from './editor.js';
|
|
3
|
-
import { CAPABILITY_DEPENDENCIES as P } from '../dependencies.js';
|
|
4
|
-
import { STACK_DEPENDENCIES as D } from '../dependencies.js';
|
|
1
|
+
import { CAPABILITY_DEPENDENCIES, STACK_DEPENDENCIES } from '../dependencies.js';
|
|
5
2
|
import { resourceName } from '../render.js';
|
|
3
|
+
import { launchTemplate, stackTemplate, workerConfig } from '../scaffold/files.js';
|
|
6
4
|
import { composeTanstack, addTanstackAuth } from '../scaffold/tanstack.js';
|
|
7
|
-
import {
|
|
8
|
-
const template = (name) => readFileSync(new URL(`../../assets/stack/${name}`, import.meta.url), 'utf8');
|
|
5
|
+
import { CapabilityEditor } from './editor.js';
|
|
9
6
|
const json = (value) => JSON.stringify(value, null, 2) + '\n';
|
|
10
7
|
function dependency(e, app, dependencies) {
|
|
11
8
|
e.merge(`${app}/package.json`, 'dependencies', dependencies);
|
|
@@ -18,7 +15,7 @@ function project(e, directory, name, scripts, dependencies, dev = {}) {
|
|
|
18
15
|
type: 'module',
|
|
19
16
|
scripts,
|
|
20
17
|
dependencies,
|
|
21
|
-
devDependencies: { typescript:
|
|
18
|
+
devDependencies: { typescript: STACK_DEPENDENCIES.typescript, ...dev },
|
|
22
19
|
}));
|
|
23
20
|
}
|
|
24
21
|
function apiConfig(e, key, value) {
|
|
@@ -52,7 +49,7 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
52
49
|
if (!manifest.scripts?.test)
|
|
53
50
|
e.set('apps/api/package.json', ['scripts', 'test'], 'node --import tsx --test tests/*.test.mjs');
|
|
54
51
|
if (!manifest.devDependencies?.tsx && !manifest.dependencies?.tsx)
|
|
55
|
-
e.set('apps/api/package.json', ['devDependencies', 'tsx'],
|
|
52
|
+
e.set('apps/api/package.json', ['devDependencies', 'tsx'], CAPABILITY_DEPENDENCIES.tsx);
|
|
56
53
|
}
|
|
57
54
|
switch (id) {
|
|
58
55
|
case 'hono': {
|
|
@@ -63,21 +60,14 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
63
60
|
deploy: 'wrangler deploy',
|
|
64
61
|
typecheck: 'wrangler types && tsc --noEmit',
|
|
65
62
|
lint: 'eslint . --max-warnings 0',
|
|
66
|
-
}, { hono:
|
|
67
|
-
tsx:
|
|
68
|
-
wrangler:
|
|
69
|
-
'@types/node':
|
|
70
|
-
eslint:
|
|
63
|
+
}, { hono: STACK_DEPENDENCIES.hono }, {
|
|
64
|
+
tsx: CAPABILITY_DEPENDENCIES.tsx,
|
|
65
|
+
wrangler: STACK_DEPENDENCIES.wrangler,
|
|
66
|
+
'@types/node': STACK_DEPENDENCIES['@types/node'],
|
|
67
|
+
eslint: STACK_DEPENDENCIES.eslint,
|
|
71
68
|
'@workspace/eslint-config': 'workspace:*',
|
|
72
69
|
});
|
|
73
|
-
e.create('apps/api/wrangler.jsonc', json(
|
|
74
|
-
$schema: 'node_modules/wrangler/config-schema.json',
|
|
75
|
-
name: resourceName(name, 'api'),
|
|
76
|
-
main: 'src/index.ts',
|
|
77
|
-
compatibility_date: '2026-10-05',
|
|
78
|
-
compatibility_flags: ['nodejs_compat'],
|
|
79
|
-
observability: { enabled: true },
|
|
80
|
-
}));
|
|
70
|
+
e.create('apps/api/wrangler.jsonc', json(workerConfig(resourceName(name, 'api'), 'src/index.ts', '2026-10-05')));
|
|
81
71
|
e.create('apps/api/tsconfig.json', json({
|
|
82
72
|
compilerOptions: {
|
|
83
73
|
target: 'ES2022',
|
|
@@ -91,9 +81,9 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
91
81
|
},
|
|
92
82
|
include: ['src/**/*.ts', 'worker-configuration.d.ts'],
|
|
93
83
|
}));
|
|
94
|
-
e.create('apps/api/eslint.config.mjs',
|
|
95
|
-
e.create('apps/api/tests/backend.test.mjs',
|
|
96
|
-
e.create('apps/api/src/index.ts',
|
|
84
|
+
e.create('apps/api/eslint.config.mjs', stackTemplate('api-eslint.config.mjs.txt'));
|
|
85
|
+
e.create('apps/api/tests/backend.test.mjs', stackTemplate('backend.test.mjs.txt'));
|
|
86
|
+
e.create('apps/api/src/index.ts', stackTemplate('api-index.ts.txt'));
|
|
97
87
|
e.create('apps/api/src/custom-environment.ts', 'export type CustomBindings = Record<never, never>;\nexport type CustomVariables = Record<never, never>;\n');
|
|
98
88
|
const web = 'apps/web/wrangler.jsonc';
|
|
99
89
|
const services = e.json(web).services ?? [];
|
|
@@ -107,7 +97,7 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
107
97
|
else
|
|
108
98
|
e.set(web, ['services'], [{ binding: 'ANHEDRAL_API', service: resourceName(name, 'api') }]);
|
|
109
99
|
e.set('apps/api/package.json', ['devDependencies', 'wrangler'], e.json('apps/web/package.json').devDependencies.wrangler);
|
|
110
|
-
e.create('apps/web/src/lib/api-proxy.ts',
|
|
100
|
+
e.create('apps/web/src/lib/api-proxy.ts', stackTemplate('api-proxy.ts.txt'));
|
|
111
101
|
break;
|
|
112
102
|
}
|
|
113
103
|
case 'database-auth': {
|
|
@@ -116,10 +106,10 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
116
106
|
lint: 'eslint . --max-warnings 0',
|
|
117
107
|
'db:generate': 'drizzle-kit generate',
|
|
118
108
|
'db:migrate': 'node src/migrate.mjs',
|
|
119
|
-
}, { 'drizzle-orm':
|
|
120
|
-
'drizzle-kit':
|
|
121
|
-
'@types/node':
|
|
122
|
-
eslint:
|
|
109
|
+
}, { 'drizzle-orm': STACK_DEPENDENCIES['drizzle-orm'] }, {
|
|
110
|
+
'drizzle-kit': STACK_DEPENDENCIES['drizzle-kit'],
|
|
111
|
+
'@types/node': STACK_DEPENDENCIES['@types/node'],
|
|
112
|
+
eslint: STACK_DEPENDENCIES.eslint,
|
|
123
113
|
'@workspace/eslint-config': 'workspace:*',
|
|
124
114
|
});
|
|
125
115
|
e.set('packages/db/package.json', ['exports'], {
|
|
@@ -139,13 +129,13 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
139
129
|
include: ['src/**/*.ts'],
|
|
140
130
|
}));
|
|
141
131
|
e.create('packages/db/eslint.config.mjs', "import { config } from '@workspace/eslint-config/base';\nexport default config;\n");
|
|
142
|
-
e.create('packages/db/src/index.ts',
|
|
143
|
-
e.create('packages/db/src/schema.ts',
|
|
144
|
-
e.create('packages/db/drizzle/0000_better_auth.sql',
|
|
145
|
-
e.create('packages/db/drizzle/meta/0000_snapshot.json',
|
|
146
|
-
e.create('packages/db/drizzle/meta/_journal.json',
|
|
147
|
-
e.create('packages/db/drizzle.config.ts',
|
|
148
|
-
e.create('packages/db/src/migrate.mjs',
|
|
132
|
+
e.create('packages/db/src/index.ts', stackTemplate('db-index.ts.txt'));
|
|
133
|
+
e.create('packages/db/src/schema.ts', stackTemplate('auth-schema.ts.txt'));
|
|
134
|
+
e.create('packages/db/drizzle/0000_better_auth.sql', stackTemplate('auth-migration.sql.txt'));
|
|
135
|
+
e.create('packages/db/drizzle/meta/0000_snapshot.json', stackTemplate('auth-snapshot.json.txt'));
|
|
136
|
+
e.create('packages/db/drizzle/meta/_journal.json', stackTemplate('auth-journal.json.txt'));
|
|
137
|
+
e.create('packages/db/drizzle.config.ts', stackTemplate('drizzle.config.ts.txt'));
|
|
138
|
+
e.create('packages/db/src/migrate.mjs', stackTemplate('db-migrate.mjs.txt'));
|
|
149
139
|
apiConfig(e, 'd1_databases', [
|
|
150
140
|
{
|
|
151
141
|
binding: 'DB',
|
|
@@ -156,15 +146,15 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
156
146
|
]);
|
|
157
147
|
dependency(e, 'apps/api', {
|
|
158
148
|
'@workspace/db': 'workspace:*',
|
|
159
|
-
zod:
|
|
160
|
-
'better-auth':
|
|
161
|
-
'@better-auth/drizzle-adapter':
|
|
149
|
+
zod: STACK_DEPENDENCIES.zod,
|
|
150
|
+
'better-auth': CAPABILITY_DEPENDENCIES['better-auth'],
|
|
151
|
+
'@better-auth/drizzle-adapter': CAPABILITY_DEPENDENCIES['@better-auth/drizzle-adapter'],
|
|
162
152
|
});
|
|
163
|
-
dependency(e, 'apps/web', { 'better-auth':
|
|
164
|
-
e.create('apps/api/src/auth.ts',
|
|
165
|
-
e.create('apps/api/src/auth-features.ts',
|
|
166
|
-
e.create('apps/api/src/security.ts',
|
|
167
|
-
e.create('apps/api/src/features/auth.ts',
|
|
153
|
+
dependency(e, 'apps/web', { 'better-auth': CAPABILITY_DEPENDENCIES['better-auth'] });
|
|
154
|
+
e.create('apps/api/src/auth.ts', stackTemplate('auth.ts.txt'));
|
|
155
|
+
e.create('apps/api/src/auth-features.ts', stackTemplate('auth-features.ts.txt'));
|
|
156
|
+
e.create('apps/api/src/security.ts', stackTemplate('security.ts.txt'));
|
|
157
|
+
e.create('apps/api/src/features/auth.ts', stackTemplate('auth-routes.ts.txt'));
|
|
168
158
|
addTanstackAuth(e);
|
|
169
159
|
e.merge('package.json', 'scripts', {
|
|
170
160
|
'db:generate': 'pnpm --dir packages/db db:generate',
|
|
@@ -177,19 +167,19 @@ export function addCapabilityRecipe(e, id, name) {
|
|
|
177
167
|
break;
|
|
178
168
|
}
|
|
179
169
|
case 'r2':
|
|
180
|
-
e.create('apps/api/tests/storage.test.mjs',
|
|
181
|
-
e.create('apps/web/src/routes/storage.tsx',
|
|
170
|
+
e.create('apps/api/tests/storage.test.mjs', stackTemplate('storage.test.mjs.txt'));
|
|
171
|
+
e.create('apps/web/src/routes/storage.tsx', launchTemplate('storage-page.tsx.txt'));
|
|
182
172
|
apiConfig(e, 'r2_buckets', [{ binding: 'FILES', bucket_name: resourceName(name, 'files') }]);
|
|
183
|
-
e.create('apps/api/src/features/storage.ts',
|
|
173
|
+
e.create('apps/api/src/features/storage.ts', stackTemplate('storage.ts.txt'));
|
|
184
174
|
break;
|
|
185
175
|
case 'stripe':
|
|
186
|
-
e.create('apps/api/tests/payment.test.mjs',
|
|
187
|
-
dependency(e, 'apps/api', { stripe:
|
|
188
|
-
e.create('apps/api/src/features/stripe.ts',
|
|
189
|
-
e.create('apps/api/src/billing-mode.ts',
|
|
190
|
-
e.create('apps/api/src/features/entitlements.ts',
|
|
191
|
-
e.create('apps/api/src/entitlement-guard.ts',
|
|
192
|
-
e.create('packages/db/src/billing-schema.ts',
|
|
176
|
+
e.create('apps/api/tests/payment.test.mjs', stackTemplate('payment.test.mjs.txt'));
|
|
177
|
+
dependency(e, 'apps/api', { stripe: CAPABILITY_DEPENDENCIES.stripe });
|
|
178
|
+
e.create('apps/api/src/features/stripe.ts', stackTemplate('stripe.ts.txt'));
|
|
179
|
+
e.create('apps/api/src/billing-mode.ts', stackTemplate('billing-mode.ts.txt'));
|
|
180
|
+
e.create('apps/api/src/features/entitlements.ts', stackTemplate('entitlements.ts.txt'));
|
|
181
|
+
e.create('apps/api/src/entitlement-guard.ts', stackTemplate('entitlement-guard.ts.txt'));
|
|
182
|
+
e.create('packages/db/src/billing-schema.ts', stackTemplate('billing-schema.ts.txt'));
|
|
193
183
|
schemaExport(e, 'billing-schema');
|
|
194
184
|
break;
|
|
195
185
|
}
|
|
@@ -214,7 +204,7 @@ export function composeCapabilities(e, installed, operation = 'compose') {
|
|
|
214
204
|
if (installed.includes('database-auth'))
|
|
215
205
|
e.owned('apps/api/src/auth-platform.ts', 'export const platformAuthPlugins = () => [];\n');
|
|
216
206
|
if (installed.includes('stripe'))
|
|
217
|
-
e.owned('apps/api/src/billing-providers.ts',
|
|
207
|
+
e.owned('apps/api/src/billing-providers.ts', stackTemplate('billing-providers.ts.txt'));
|
|
218
208
|
const bindings = [
|
|
219
209
|
'PUBLIC_APP_URL?: string',
|
|
220
210
|
'BETTER_AUTH_SECRET?: string',
|
|
@@ -226,7 +216,12 @@ export function composeCapabilities(e, installed, operation = 'compose') {
|
|
|
226
216
|
bindings.push('FILES: R2Bucket');
|
|
227
217
|
if (installed.includes('stripe'))
|
|
228
218
|
bindings.push('STRIPE_SECRET_KEY?: string', 'STRIPE_WEBHOOK_SECRET?: string', 'STRIPE_PRICE_ID?: string', 'BILLING_ENVIRONMENT?: string', 'BILLING_PROVIDER?: string');
|
|
229
|
-
e.owned('apps/api/src/environment.ts', `import type { CustomBindings, CustomVariables } from './custom-environment';\nexport type AppEnv = {
|
|
219
|
+
e.owned('apps/api/src/environment.ts', `import type { CustomBindings, CustomVariables } from './custom-environment';\nexport type AppEnv = {
|
|
220
|
+
Bindings: CustomBindings & {
|
|
221
|
+
${bindings.map((binding) => ` ${binding};`).join('\n')}
|
|
222
|
+
};
|
|
223
|
+
Variables: CustomVariables & { userId: string; fileKey: string };
|
|
224
|
+
};\n`);
|
|
230
225
|
if (operation === 'update')
|
|
231
226
|
return;
|
|
232
227
|
appendExample(e, 'apps/api/.dev.vars.example', bindings
|
package/dist/dependencies.d.ts
CHANGED
|
@@ -32,12 +32,6 @@ export declare const STACK_DEPENDENCIES: {
|
|
|
32
32
|
readonly undici: "7.30.1";
|
|
33
33
|
readonly stripe: "23.0.0";
|
|
34
34
|
};
|
|
35
|
-
export declare const WORKER_DEV_PORTS: {
|
|
36
|
-
readonly api: {
|
|
37
|
-
readonly http: 8787;
|
|
38
|
-
readonly inspector: 9231;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
35
|
export declare const CAPABILITY_DEPENDENCIES: {
|
|
42
36
|
readonly tsx: "4.23.15";
|
|
43
37
|
readonly 'better-auth': "1.7.7";
|
package/dist/dependencies.js
CHANGED
|
@@ -85,7 +85,6 @@ export const STACK_DEPENDENCIES = {
|
|
|
85
85
|
// renovate: datasource=npm depName=stripe
|
|
86
86
|
stripe: '23.0.0',
|
|
87
87
|
};
|
|
88
|
-
export const WORKER_DEV_PORTS = { api: { http: 8787, inspector: 9231 } };
|
|
89
88
|
// Backend, storage and payments extend the same Anhedral Stack foundation.
|
|
90
89
|
export const CAPABILITY_DEPENDENCIES = {
|
|
91
90
|
tsx: '4.23.15',
|
package/dist/launch.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function launchPlan(options: LaunchOptions): {
|
|
|
17
17
|
products: string[];
|
|
18
18
|
stack: string;
|
|
19
19
|
foundation: string;
|
|
20
|
-
capabilities:
|
|
20
|
+
capabilities: never[];
|
|
21
21
|
targets: string[];
|
|
22
22
|
dryRun: boolean;
|
|
23
23
|
resourcesProvisioned: boolean;
|
package/dist/launch.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { existsSync, lstatSync, mkdirSync, readdirSync, realpathSync, rmdirSync } from 'node:fs';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, realpathSync, rmdirSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { scaffoldStyling } from './scaffold/styling.js';
|
|
8
|
-
import { json, put, sharedPackage } from './scaffold/files.js';
|
|
9
|
-
import { CapabilityEditor } from './composition/editor.js';
|
|
10
|
-
import { addCapabilityRecipe, composeCapabilities } from './composition/recipes.js';
|
|
5
|
+
import { CliArgumentError, commandArguments } from './cli-arguments.js';
|
|
6
|
+
import { printProgress, printResult } from './cli-output.js';
|
|
11
7
|
import { launchCompositionSchema } from './composition/composition.js';
|
|
12
|
-
import {
|
|
8
|
+
import { CapabilityEditor } from './composition/editor.js';
|
|
9
|
+
import { composeCapabilities } from './composition/recipes.js';
|
|
10
|
+
import { PACKAGE_MANAGER, SECURITY_OVERRIDES, STACK_DEPENDENCIES, WORKSPACE_NODE_ENGINE, } from './dependencies.js';
|
|
13
11
|
import { configureDependencyPatches, writeDependencyAudit } from './dependency-patches.js';
|
|
14
12
|
import { setPnpmPolicy } from './pnpm-policy.js';
|
|
15
|
-
import { GENERATOR_VERSION } from './version.js';
|
|
16
|
-
import { PACKAGE_MANAGER, SECURITY_OVERRIDES, STACK_DEPENDENCIES, WORKSPACE_NODE_ENGINE, } from './dependencies.js';
|
|
17
|
-
import { execFile, appendGitignore } from './util.js';
|
|
18
|
-
import { printProgress, printResult } from './cli-output.js';
|
|
19
|
-
import { CliArgumentError, commandArguments } from './cli-arguments.js';
|
|
20
13
|
import { packageNameFromText } from './render.js';
|
|
14
|
+
import { bootstrapWorkspace, assertWorkspaceRuntime } from './scaffold/bootstrap.js';
|
|
15
|
+
import { json, launchTemplate, put } from './scaffold/files.js';
|
|
16
|
+
import { scaffoldStyling } from './scaffold/styling.js';
|
|
17
|
+
import { scaffoldTanstack } from './scaffold/tanstack.js';
|
|
18
|
+
import { runStagedTransaction } from './transactions/transaction.js';
|
|
19
|
+
import { execFile, appendGitignore } from './util.js';
|
|
20
|
+
import { GENERATOR_VERSION } from './version.js';
|
|
21
21
|
export function parseAnhedralStackOptions(args) {
|
|
22
22
|
const parsed = commandArguments('init', args);
|
|
23
23
|
const hasDirectory = parsed.positional.length > 0;
|
|
@@ -34,7 +34,6 @@ export function parseAnhedralStackOptions(args) {
|
|
|
34
34
|
initializeGit: parsed.has('--git') || (!parsed.has('--no-git') && hasDirectory),
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
const launchCapabilities = [];
|
|
38
37
|
function rootFiles(root, name) {
|
|
39
38
|
json(root, 'package.json', {
|
|
40
39
|
name,
|
|
@@ -91,7 +90,7 @@ function rootFiles(root, name) {
|
|
|
91
90
|
foundation: 'tanstack-start',
|
|
92
91
|
generatorVersion: GENERATOR_VERSION,
|
|
93
92
|
identity: 'none',
|
|
94
|
-
capabilities:
|
|
93
|
+
capabilities: {},
|
|
95
94
|
}),
|
|
96
95
|
});
|
|
97
96
|
appendGitignore(root, 'node_modules/\ndist/\n.turbo/\n.wrangler/\n.tanstack/\n.oj-cache/\n*.tsbuildinfo\nworker-configuration.d.ts\n.dev.vars\n.dev.vars.*\n!.dev.vars.example\n.env\n.env.*\n!.env.example\n.anhedral/\n'
|
|
@@ -99,92 +98,16 @@ function rootFiles(root, name) {
|
|
|
99
98
|
.split('\n'));
|
|
100
99
|
writeDependencyAudit(root);
|
|
101
100
|
}
|
|
102
|
-
function documentation(root, name) {
|
|
103
|
-
put(root, 'README.md', `# ${name}
|
|
104
|
-
|
|
105
|
-
Anhedral Stack: web UI powered by OJ and TanStack Start server rendering/server functions
|
|
106
|
-
and editable shadcn components.
|
|
107
|
-
Only the web application is created initially. No backend or provider is provisioned.
|
|
108
|
-
|
|
109
|
-
## Develop
|
|
110
|
-
|
|
111
|
-
Use the Node/pnpm versions in package.json. Run pnpm install if generation skipped
|
|
112
|
-
installation, then pnpm dev and open http://localhost:3000. Run pnpm check and
|
|
113
|
-
pnpm audit:deps before deployment. Editable routes live in apps/web/src/routes.
|
|
114
|
-
Use cd apps/web && pnpm dlx shadcn@4.22.1 add card for more shadcn components.
|
|
115
|
-
Shadcn is the default, not a restriction: use any UI library and preserve local edits.
|
|
116
|
-
Keep LICENSE.shadcn with the copied starter components.
|
|
117
|
-
|
|
118
|
-
## Add services progressively
|
|
119
|
-
|
|
120
|
-
Run anhedral add backend to add Hono, Drizzle/D1 and Better Auth together.
|
|
121
|
-
Then run anhedral add storage for private storage, or anhedral add payment for payments.
|
|
122
|
-
Missing prerequisites stop before writes; --with-dependencies opts into them.
|
|
123
|
-
The public additions are backend, storage and payment; this application is web-only.
|
|
124
|
-
|
|
125
|
-
After adding backend, copy apps/api/.dev.vars.example to apps/api/.dev.vars.
|
|
126
|
-
Set PUBLIC_APP_URL=http://localhost:3000 and generate BETTER_AUTH_SECRET with
|
|
127
|
-
\`node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"\`.
|
|
128
|
-
Auth methods start disabled. Deliberately enable chosen methods in
|
|
129
|
-
apps/api/src/auth-features.ts after configuring email/credentials and policies.
|
|
130
|
-
Run pnpm db:migrate --local explicitly to initialize the isolated local D1 database,
|
|
131
|
-
then pnpm dev. OJ runs the web and auxiliary API Workers with shared local
|
|
132
|
-
persistence. Remote bindings are disabled for local development.
|
|
133
|
-
|
|
134
|
-
R2 routes enforce authenticated owner access. Stripe adds schema and source only:
|
|
135
|
-
run pnpm db:generate, review the SQL, then deliberately apply the local migration
|
|
136
|
-
before exercising subscription/webhook flows. Configure Stripe test credentials,
|
|
137
|
-
allowed prices and signed webhooks; activation and live payments are separate.
|
|
138
|
-
|
|
139
|
-
## Update the stack
|
|
140
|
-
|
|
141
|
-
From the project directory, preview a release before applying it:
|
|
142
|
-
|
|
143
|
-
\`\`\`sh
|
|
144
|
-
pnpm dlx anhedral@latest stack update --dry-run --human
|
|
145
|
-
\`\`\`
|
|
146
|
-
|
|
147
|
-
Review the diff and run the version-pinned apply command printed by the CLI.
|
|
148
|
-
Then run \`pnpm install\` and \`pnpm check\`. The updater refreshes CLI-managed
|
|
149
|
-
adapters for installed features. Your routes, UI and migrations belong to you.
|
|
150
|
-
|
|
151
|
-
## Ownership and deployment
|
|
152
|
-
|
|
153
|
-
Hono owns data, identity and private storage. Web server functions call its scoped
|
|
154
|
-
service binding, never import another application's source or provider credentials.
|
|
155
|
-
Custom API routes belong in apps/api/src/index.ts; schema/migrations in packages/db.
|
|
156
|
-
Composition adapters are fingerprinted and customized files are never overwritten.
|
|
157
|
-
|
|
158
|
-
Builds/startup never migrate databases. Provision D1/R2 only when selected and
|
|
159
|
-
configure environment-specific resources/secrets separately. pnpm build emits web
|
|
160
|
-
Worker artifacts under apps/web/dist and selected API artifacts under apps/api/dist. Anhedral Platform admission
|
|
161
|
-
requires its separately reviewed Anhedral Stack runtime/artifact; generation is not activation.
|
|
162
|
-
`);
|
|
163
|
-
put(root, 'AGENTS.md', `# Anhedral Stack application
|
|
164
|
-
|
|
165
|
-
Use the single Anhedral Stack, starting with TanStack Start and source-owned shadcn UI. Add backend for Hono,
|
|
166
|
-
Drizzle/D1 and Better Auth together. Use the storage and payment additions only when required. Mobile,
|
|
167
|
-
extensions and desktop are outside launch scope.
|
|
168
|
-
|
|
169
|
-
Edit web product routes in apps/web/src/routes, API routes in apps/api/src/index.ts,
|
|
170
|
-
and database schema in packages/db/src. Preserve customized composition adapters,
|
|
171
|
-
semantic UI tokens and attribution. No cross-application source imports.
|
|
172
|
-
Web server functions receive scoped API bindings through request context; keep
|
|
173
|
-
identity, database/storage access and secrets inside Hono. Auth methods require
|
|
174
|
-
explicit activation. Run pnpm check and pnpm audit:deps. Never migrate a configured
|
|
175
|
-
database in builds/tests/startup; apply reviewed SQL deliberately to isolated fixtures.
|
|
176
|
-
`);
|
|
177
|
-
}
|
|
178
101
|
export function launchPlan(options) {
|
|
179
102
|
return {
|
|
180
103
|
schemaVersion: 1,
|
|
181
104
|
cliVersion: GENERATOR_VERSION,
|
|
182
105
|
root: options.root,
|
|
183
106
|
name: options.name,
|
|
184
|
-
products: ['tanstack-start'
|
|
107
|
+
products: ['tanstack-start'],
|
|
185
108
|
stack: 'anhedral-stack',
|
|
186
109
|
foundation: 'tanstack-start',
|
|
187
|
-
capabilities: [
|
|
110
|
+
capabilities: [],
|
|
188
111
|
targets: ['apps/web'],
|
|
189
112
|
dryRun: options.dryRun,
|
|
190
113
|
resourcesProvisioned: false,
|
|
@@ -228,25 +151,24 @@ export async function scaffoldLaunchProject(options, run = execFile, output = {}
|
|
|
228
151
|
prepare: () => assertEmpty(true),
|
|
229
152
|
build: async (stage) => {
|
|
230
153
|
printProgress('Creating the Anhedral Stack…', display);
|
|
231
|
-
bootstrapWorkspace(stage
|
|
154
|
+
bootstrapWorkspace(stage);
|
|
232
155
|
rootFiles(stage, options.name);
|
|
233
|
-
|
|
234
|
-
scaffoldStyling({ root: stage });
|
|
156
|
+
scaffoldStyling(stage);
|
|
235
157
|
scaffoldTanstack(stage, options.name);
|
|
236
158
|
const editor = new CapabilityEditor(stage, {});
|
|
237
|
-
|
|
238
|
-
for (const capability of installed)
|
|
239
|
-
addCapabilityRecipe(editor, capability, options.name);
|
|
240
|
-
composeCapabilities(editor, installed);
|
|
159
|
+
composeCapabilities(editor, []);
|
|
241
160
|
editor.set('anhedral.json', ['capabilities'], {
|
|
242
161
|
schemaVersion: 1,
|
|
243
|
-
installed,
|
|
162
|
+
installed: [],
|
|
244
163
|
managedFiles: editor.managed,
|
|
245
164
|
resourcesProvisionedByCli: false,
|
|
246
165
|
});
|
|
247
166
|
for (const [file, source] of editor.writes)
|
|
248
167
|
put(stage, file, source);
|
|
249
|
-
|
|
168
|
+
put(stage, 'README.md', launchTemplate('README.md.txt')
|
|
169
|
+
.replace('__CLI_VERSION__', GENERATOR_VERSION)
|
|
170
|
+
.replace('__APP_NAME__', () => options.name.replace(/[\r\n]+/g, ' ')));
|
|
171
|
+
put(stage, 'AGENTS.md', launchTemplate('AGENTS.md.txt'));
|
|
250
172
|
if (!options.skipInstall) {
|
|
251
173
|
printProgress('Resolving Anhedral Stack dependencies…', display);
|
|
252
174
|
run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], stage);
|
package/dist/render.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
/** Serialize an arbitrary value as a JavaScript/TypeScript string literal. */
|
|
2
|
-
export declare function jsString(value: string): string;
|
|
3
|
-
/** Escape text placed directly in HTML rather than in a JS string. */
|
|
4
|
-
export declare function htmlText(value: string): string;
|
|
5
|
-
/** Keep generated Markdown headings on one line and prevent heading/code injection. */
|
|
6
|
-
export declare function markdownHeading(value: string): string;
|
|
7
1
|
/** Derive a valid, deterministic unscoped npm package name from arbitrary text. */
|
|
8
2
|
export declare function packageNameFromText(value: string): string;
|
|
9
|
-
export declare function childPackageName(projectName: string, suffix: string): string;
|
|
10
|
-
export declare function identifierSegment(value: string): string;
|
|
11
|
-
/** Provider identity is separate from the npm package/directory name. */
|
|
12
|
-
export declare function providerProjectName(value: string): string;
|
|
13
3
|
/** Keep provider resource names within the shared Workers/R2/Queues naming limits. */
|
|
14
4
|
export declare function resourceName(projectName: string, suffix: string): string;
|
package/dist/render.js
CHANGED
|
@@ -2,24 +2,6 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
const PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
|
|
3
3
|
const MAX_PACKAGE_NAME_LENGTH = 214;
|
|
4
4
|
const RESERVED_PACKAGE_NAMES = new Set(['node_modules', 'favicon.ico']);
|
|
5
|
-
/** Serialize an arbitrary value as a JavaScript/TypeScript string literal. */
|
|
6
|
-
export function jsString(value) {
|
|
7
|
-
return JSON.stringify(value);
|
|
8
|
-
}
|
|
9
|
-
/** Escape text placed directly in HTML rather than in a JS string. */
|
|
10
|
-
export function htmlText(value) {
|
|
11
|
-
return value
|
|
12
|
-
.replace(/&/g, '&')
|
|
13
|
-
.replace(/</g, '<')
|
|
14
|
-
.replace(/>/g, '>')
|
|
15
|
-
.replace(/"/g, '"')
|
|
16
|
-
.replace(/'/g, ''');
|
|
17
|
-
}
|
|
18
|
-
/** Keep generated Markdown headings on one line and prevent heading/code injection. */
|
|
19
|
-
export function markdownHeading(value) {
|
|
20
|
-
const normalized = value.replace(/[\r\n]+/g, ' ').trim() || 'Anhedral App';
|
|
21
|
-
return normalized.replace(/([\\`*_{}\[\]()<>#+.!|~-])/g, '\\$1');
|
|
22
|
-
}
|
|
23
5
|
function assertPackageName(value) {
|
|
24
6
|
const leafName = value.slice(value.lastIndexOf('/') + 1);
|
|
25
7
|
if (value.length > MAX_PACKAGE_NAME_LENGTH ||
|
|
@@ -32,8 +14,6 @@ function assertPackageName(value) {
|
|
|
32
14
|
function compactPackageSegment(value, maximumLength) {
|
|
33
15
|
if (value.length <= maximumLength)
|
|
34
16
|
return value;
|
|
35
|
-
if (maximumLength <= 9)
|
|
36
|
-
return value.slice(0, maximumLength).replace(/[._-]+$/g, '') || 'a';
|
|
37
17
|
const digest = createHash('sha256').update(value, 'utf8').digest('hex').slice(0, 8);
|
|
38
18
|
const prefix = value.slice(0, maximumLength - digest.length - 1).replace(/[._-]+$/g, '') || 'app';
|
|
39
19
|
return `${prefix}-${digest}`;
|
|
@@ -53,18 +33,7 @@ export function packageNameFromText(value) {
|
|
|
53
33
|
normalized = `anhedral-${normalized}`;
|
|
54
34
|
return assertPackageName(compactPackageSegment(normalized, MAX_PACKAGE_NAME_LENGTH));
|
|
55
35
|
}
|
|
56
|
-
|
|
57
|
-
assertPackageName(projectName);
|
|
58
|
-
const normalizedSuffix = packageNameFromText(suffix);
|
|
59
|
-
const separator = projectName.lastIndexOf('/');
|
|
60
|
-
if (separator >= 0) {
|
|
61
|
-
const scope = projectName.slice(0, separator + 1);
|
|
62
|
-
const leaf = compactPackageSegment(`${projectName.slice(separator + 1)}-${normalizedSuffix}`, MAX_PACKAGE_NAME_LENGTH - scope.length);
|
|
63
|
-
return assertPackageName(`${scope}${leaf}`);
|
|
64
|
-
}
|
|
65
|
-
return assertPackageName(compactPackageSegment(`${projectName}-${normalizedSuffix}`, MAX_PACKAGE_NAME_LENGTH));
|
|
66
|
-
}
|
|
67
|
-
export function identifierSegment(value) {
|
|
36
|
+
function identifierSegment(value) {
|
|
68
37
|
const segment = value
|
|
69
38
|
.normalize('NFKD')
|
|
70
39
|
.toLowerCase()
|
|
@@ -72,12 +41,6 @@ export function identifierSegment(value) {
|
|
|
72
41
|
.replace(/^-+|-+$/g, '');
|
|
73
42
|
return segment || 'app';
|
|
74
43
|
}
|
|
75
|
-
/** Provider identity is separate from the npm package/directory name. */
|
|
76
|
-
export function providerProjectName(value) {
|
|
77
|
-
const normalized = identifierSegment(value);
|
|
78
|
-
const digest = createHash('sha256').update(value).digest('hex').slice(0, 8);
|
|
79
|
-
return compactPackageSegment(normalized === value ? normalized : `${normalized}-${digest}`, 63);
|
|
80
|
-
}
|
|
81
44
|
/** Keep provider resource names within the shared Workers/R2/Queues naming limits. */
|
|
82
45
|
export function resourceName(projectName, suffix) {
|
|
83
46
|
const segment = identifierSegment(projectName);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { CommandRunner } from '../command-types.js';
|
|
2
2
|
export declare function assertWorkspaceRuntime(run: CommandRunner, version?: string): void;
|
|
3
|
-
|
|
4
|
-
export declare function bootstrapWorkspace(root: string, name: string, run: CommandRunner): void;
|
|
3
|
+
export declare function bootstrapWorkspace(root: string): void;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
+
import { STACK_DEPENDENCIES } from '../dependencies.js';
|
|
1
2
|
import { supportsWorkspaceRuntime } from '../runtime-policy.js';
|
|
2
3
|
import { execFile } from '../util.js';
|
|
3
|
-
import {
|
|
4
|
-
import { json, put } from './files.js';
|
|
4
|
+
import { json, put, stackTemplate } from './files.js';
|
|
5
5
|
export function assertWorkspaceRuntime(run, version = process.versions.node) {
|
|
6
6
|
if (run === execFile && !supportsWorkspaceRuntime(version))
|
|
7
7
|
throw new Error('Generated workspaces require Node.js 22.13+ on the 22.x line or Node.js 24+.');
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
export function bootstrapWorkspace(root, name, run) {
|
|
11
|
-
assertWorkspaceRuntime(run);
|
|
12
|
-
json(root, 'package.json', { name, private: true });
|
|
13
|
-
put(root, 'pnpm-workspace.yaml', 'packages:\n - apps/*\n - packages/*\n');
|
|
9
|
+
export function bootstrapWorkspace(root) {
|
|
14
10
|
json(root, 'packages/typescript-config/package.json', {
|
|
15
11
|
name: '@workspace/typescript-config',
|
|
16
12
|
private: true,
|
|
@@ -37,6 +33,6 @@ export function bootstrapWorkspace(root, name, run) {
|
|
|
37
33
|
'@typescript-eslint/eslint-plugin': STACK_DEPENDENCIES['@typescript-eslint/eslint-plugin'],
|
|
38
34
|
},
|
|
39
35
|
});
|
|
40
|
-
put(root, 'packages/eslint-config/base.js',
|
|
36
|
+
put(root, 'packages/eslint-config/base.js', stackTemplate('base-eslint.js.txt'));
|
|
41
37
|
put(root, 'packages/eslint-config/react-internal.js', "export { config } from './base.js';\n");
|
|
42
38
|
}
|
package/dist/scaffold/files.d.ts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
name?: string;
|
|
4
|
-
packageManager?: string;
|
|
5
|
-
scripts?: Record<string, string>;
|
|
6
|
-
dependencies?: Record<string, string>;
|
|
7
|
-
devDependencies?: Record<string, string>;
|
|
8
|
-
pnpm?: {
|
|
9
|
-
overrides?: Record<string, string>;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export interface TurboConfig extends Json {
|
|
13
|
-
globalEnv?: string[];
|
|
14
|
-
tasks: Record<string, {
|
|
15
|
-
dependsOn?: string[];
|
|
16
|
-
outputs?: string[];
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export declare function readJson<T extends Json = Json>(root: string, file: string): T;
|
|
1
|
+
export declare function launchTemplate(name: string): string;
|
|
2
|
+
export declare function stackTemplate(name: string): string;
|
|
21
3
|
export declare function json(root: string, file: string, value: unknown): void;
|
|
22
4
|
export declare function put(root: string, file: string, value: string): void;
|
|
23
|
-
export declare function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
export declare function workerConfig(name: string, main: string, compatibilityDate: string): {
|
|
6
|
+
$schema: string;
|
|
7
|
+
name: string;
|
|
8
|
+
main: string;
|
|
9
|
+
compatibility_date: string;
|
|
10
|
+
compatibility_flags: string[];
|
|
11
|
+
observability: {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|