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/scaffold/files.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import { writeFile } from '../util.js';
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
if (error instanceof SyntaxError)
|
|
12
|
-
throw new Error(`Invalid JSON in ${file}.`);
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
16
|
-
throw new Error(`Expected a JSON object: ${file}.`);
|
|
17
|
-
return value;
|
|
4
|
+
export function launchTemplate(name) {
|
|
5
|
+
return readFileSync(new URL(`../../assets/launch/${name}`, import.meta.url), 'utf8');
|
|
6
|
+
}
|
|
7
|
+
export function stackTemplate(name) {
|
|
8
|
+
return readFileSync(new URL(`../../assets/stack/${name}`, import.meta.url), 'utf8');
|
|
18
9
|
}
|
|
19
10
|
export function json(root, file, value) {
|
|
20
11
|
writeFile(path.join(root, file), JSON.stringify(value, null, 2) + '\n');
|
|
@@ -22,98 +13,13 @@ export function json(root, file, value) {
|
|
|
22
13
|
export function put(root, file, value) {
|
|
23
14
|
writeFile(path.join(root, file), value);
|
|
24
15
|
}
|
|
25
|
-
export function
|
|
26
|
-
const current = readJson(root, file);
|
|
27
|
-
const merged = { ...current, ...patch };
|
|
28
|
-
for (const key of ['scripts', 'dependencies', 'devDependencies']) {
|
|
29
|
-
if (patch[key])
|
|
30
|
-
merged[key] = { ...current[key], ...patch[key] };
|
|
31
|
-
}
|
|
32
|
-
json(root, file, merged);
|
|
33
|
-
}
|
|
34
|
-
export function workerConfig(name) {
|
|
16
|
+
export function workerConfig(name, main, compatibilityDate) {
|
|
35
17
|
return {
|
|
36
18
|
$schema: 'node_modules/wrangler/config-schema.json',
|
|
37
19
|
name,
|
|
38
|
-
main
|
|
39
|
-
compatibility_date:
|
|
20
|
+
main,
|
|
21
|
+
compatibility_date: compatibilityDate,
|
|
40
22
|
compatibility_flags: ['nodejs_compat'],
|
|
41
23
|
observability: { enabled: true },
|
|
42
24
|
};
|
|
43
25
|
}
|
|
44
|
-
export function worker(root, app, config, source, dependencies = {}) {
|
|
45
|
-
const ports = WORKER_DEV_PORTS[app];
|
|
46
|
-
if (!ports)
|
|
47
|
-
throw new Error(`Unknown Worker application: ${app}.`);
|
|
48
|
-
json(root, `apps/${app}/package.json`, {
|
|
49
|
-
name: `@workspace/${app}`,
|
|
50
|
-
private: true,
|
|
51
|
-
type: 'module',
|
|
52
|
-
scripts: {
|
|
53
|
-
dev: `wrangler dev --port ${ports.http} --inspector-port ${ports.inspector}`,
|
|
54
|
-
build: 'wrangler deploy --dry-run --outdir dist',
|
|
55
|
-
deploy: 'wrangler deploy',
|
|
56
|
-
typecheck: 'wrangler types && tsc --noEmit',
|
|
57
|
-
lint: 'eslint . --max-warnings 0',
|
|
58
|
-
},
|
|
59
|
-
dependencies,
|
|
60
|
-
devDependencies: {
|
|
61
|
-
wrangler: STACK_DEPENDENCIES['wrangler'],
|
|
62
|
-
typescript: STACK_DEPENDENCIES['typescript'],
|
|
63
|
-
'@types/node': STACK_DEPENDENCIES['@types/node'],
|
|
64
|
-
eslint: STACK_DEPENDENCIES['eslint'],
|
|
65
|
-
'@workspace/eslint-config': 'workspace:*',
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
json(root, `apps/${app}/wrangler.jsonc`, config);
|
|
69
|
-
json(root, `apps/${app}/tsconfig.json`, {
|
|
70
|
-
compilerOptions: {
|
|
71
|
-
target: 'ES2022',
|
|
72
|
-
lib: ['ES2022'],
|
|
73
|
-
module: 'ESNext',
|
|
74
|
-
moduleResolution: 'Bundler',
|
|
75
|
-
strict: true,
|
|
76
|
-
noUnusedLocals: true,
|
|
77
|
-
noUnusedParameters: true,
|
|
78
|
-
skipLibCheck: true,
|
|
79
|
-
noEmit: true,
|
|
80
|
-
types: ['node'],
|
|
81
|
-
},
|
|
82
|
-
include: ['src/**/*.ts', 'worker-configuration.d.ts'],
|
|
83
|
-
});
|
|
84
|
-
put(root, `apps/${app}/eslint.config.mjs`, 'import { config } from "@workspace/eslint-config/base";\nexport default [...config, { ignores: ["dist/**", ".wrangler/**", "worker-configuration.d.ts"] }, { files: ["**/*.ts"], rules: { "no-undef": "off", "no-unused-vars": "off" } }];\n');
|
|
85
|
-
put(root, `apps/${app}/src/index.ts`, source);
|
|
86
|
-
}
|
|
87
|
-
export function sharedPackage(root, name, source, dependencies) {
|
|
88
|
-
json(root, `packages/${name}/package.json`, {
|
|
89
|
-
name: `@workspace/${name}`,
|
|
90
|
-
private: true,
|
|
91
|
-
type: 'module',
|
|
92
|
-
exports: { '.': './src/index.ts' },
|
|
93
|
-
scripts: { typecheck: 'tsc --noEmit', lint: 'eslint . --max-warnings 0' },
|
|
94
|
-
dependencies,
|
|
95
|
-
devDependencies: {
|
|
96
|
-
typescript: STACK_DEPENDENCIES['typescript'],
|
|
97
|
-
'@types/node': STACK_DEPENDENCIES['@types/node'],
|
|
98
|
-
eslint: STACK_DEPENDENCIES['eslint'],
|
|
99
|
-
'@workspace/eslint-config': 'workspace:*',
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
json(root, `packages/${name}/tsconfig.json`, {
|
|
103
|
-
compilerOptions: {
|
|
104
|
-
target: 'ES2022',
|
|
105
|
-
lib: ['ES2022', 'DOM'],
|
|
106
|
-
module: 'ESNext',
|
|
107
|
-
moduleResolution: 'Bundler',
|
|
108
|
-
strict: true,
|
|
109
|
-
noUnusedLocals: true,
|
|
110
|
-
noUnusedParameters: true,
|
|
111
|
-
skipLibCheck: true,
|
|
112
|
-
noEmit: true,
|
|
113
|
-
types: ['node'],
|
|
114
|
-
},
|
|
115
|
-
include: ['src/**/*.ts'],
|
|
116
|
-
});
|
|
117
|
-
put(root, `packages/${name}/eslint.config.mjs`, 'import { config } from "@workspace/eslint-config/base";\nexport default [...config, { ignores: ["dist/**", ".wrangler/**", "worker-configuration.d.ts"] }, { files: ["**/*.ts"], rules: { "no-undef": "off", "no-unused-vars": "off" } }];\n');
|
|
118
|
-
put(root, `packages/${name}/src/index.ts`, source);
|
|
119
|
-
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare function scaffoldStyling(
|
|
3
|
-
root: string;
|
|
4
|
-
}): void;
|
|
1
|
+
/** Generate CSS from the same tokens the styling package exports. */
|
|
2
|
+
export declare function scaffoldStyling(root: string): void;
|
package/dist/scaffold/styling.js
CHANGED
|
@@ -1,76 +1,53 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import
|
|
3
|
-
import { json,
|
|
4
|
-
/**
|
|
5
|
-
export function scaffoldStyling(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'--muted-foreground': '0 0% 45.1%',
|
|
19
|
-
'--accent': '0 0% 96.1%',
|
|
20
|
-
'--accent-foreground': '0 0% 9%',
|
|
21
|
-
'--destructive': '0 84.2% 60.2%',
|
|
22
|
-
'--destructive-foreground': '0 0% 98%',
|
|
23
|
-
'--border': '0 0% 89.8%',
|
|
24
|
-
'--input': '0 0% 89.8%',
|
|
25
|
-
'--ring': '0 0% 63.9%',
|
|
26
|
-
'--radius': '0.5rem',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.dark = {
|
|
30
|
-
...exports.light,
|
|
31
|
-
'--background': '0 0% 9%',
|
|
32
|
-
'--foreground': '0 0% 98%',
|
|
33
|
-
'--card': '0 0% 9%',
|
|
34
|
-
'--card-foreground': '0 0% 98%',
|
|
35
|
-
'--popover': '0 0% 9%',
|
|
36
|
-
'--popover-foreground': '0 0% 98%',
|
|
37
|
-
'--primary': '0 0% 98%',
|
|
38
|
-
'--primary-foreground': '0 0% 9%',
|
|
39
|
-
'--secondary': '0 0% 14.9%',
|
|
40
|
-
'--secondary-foreground': '0 0% 98%',
|
|
41
|
-
'--muted': '0 0% 14.9%',
|
|
42
|
-
'--muted-foreground': '0 0% 63.9%',
|
|
43
|
-
'--accent': '0 0% 14.9%',
|
|
44
|
-
'--accent-foreground': '0 0% 98%',
|
|
45
|
-
'--destructive': '0 70.9% 59.4%',
|
|
46
|
-
'--border': '0 0% 14.9%',
|
|
47
|
-
'--input': '0 0% 14.9%',
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
exports.spacing = { small: 4, medium: 8, large: 16 };
|
|
51
|
-
`);
|
|
52
|
-
patchPackage(root, 'packages/styling/package.json', {
|
|
53
|
-
exports: {
|
|
54
|
-
'.': './src/index.ts',
|
|
55
|
-
'./globals.css': './globals.css',
|
|
2
|
+
import { STACK_DEPENDENCIES } from '../dependencies.js';
|
|
3
|
+
import { json, launchTemplate, put, stackTemplate } from './files.js';
|
|
4
|
+
/** Generate CSS from the same tokens the styling package exports. */
|
|
5
|
+
export function scaffoldStyling(root) {
|
|
6
|
+
json(root, 'packages/styling/package.json', {
|
|
7
|
+
name: '@workspace/styling',
|
|
8
|
+
private: true,
|
|
9
|
+
type: 'module',
|
|
10
|
+
exports: { '.': './src/index.ts', './globals.css': './globals.css' },
|
|
11
|
+
scripts: { typecheck: 'tsc --noEmit', lint: 'eslint . --max-warnings 0' },
|
|
12
|
+
dependencies: {},
|
|
13
|
+
devDependencies: {
|
|
14
|
+
typescript: STACK_DEPENDENCIES.typescript,
|
|
15
|
+
'@types/node': STACK_DEPENDENCIES['@types/node'],
|
|
16
|
+
eslint: STACK_DEPENDENCIES.eslint,
|
|
17
|
+
'@workspace/eslint-config': 'workspace:*',
|
|
56
18
|
},
|
|
57
19
|
});
|
|
58
|
-
const tokens = createRequire(import.meta.url)(path.join(root, 'packages/styling/src/tokens.cjs'));
|
|
59
|
-
const rule = (selector, values) => selector +
|
|
60
|
-
' {\n' +
|
|
61
|
-
Object.entries(values)
|
|
62
|
-
.map(([key, value]) => ' ' + key + ': ' + value + ';')
|
|
63
|
-
.join('\n') +
|
|
64
|
-
'\n}\n';
|
|
65
|
-
put(root, 'packages/styling/globals.css', rule(':root', tokens.light) +
|
|
66
|
-
'@media (prefers-color-scheme: dark) {\n' +
|
|
67
|
-
rule(':root', tokens.dark) +
|
|
68
|
-
'}\n');
|
|
69
|
-
put(root, 'packages/styling/src/tokens.d.cts', 'export const light: Record<string, string>;\nexport const dark: Record<string, string>;\nexport const spacing: { small: number; medium: number; large: number };\n');
|
|
70
|
-
const config = readJson(root, 'packages/styling/tsconfig.json');
|
|
71
20
|
json(root, 'packages/styling/tsconfig.json', {
|
|
72
|
-
|
|
73
|
-
|
|
21
|
+
compilerOptions: {
|
|
22
|
+
target: 'ES2022',
|
|
23
|
+
lib: ['ES2022', 'DOM'],
|
|
24
|
+
module: 'ESNext',
|
|
25
|
+
moduleResolution: 'Bundler',
|
|
26
|
+
strict: true,
|
|
27
|
+
noUnusedLocals: true,
|
|
28
|
+
noUnusedParameters: true,
|
|
29
|
+
skipLibCheck: true,
|
|
30
|
+
noEmit: true,
|
|
31
|
+
types: ['node'],
|
|
32
|
+
allowJs: true,
|
|
33
|
+
},
|
|
74
34
|
include: ['src/**/*.ts', 'src/**/*.cjs'],
|
|
75
35
|
});
|
|
36
|
+
put(root, 'packages/styling/eslint.config.mjs', stackTemplate('shared-eslint.config.mjs.txt'));
|
|
37
|
+
put(root, 'packages/styling/src/index.ts', "export { light, dark, spacing } from './tokens.cjs';\n");
|
|
38
|
+
put(root, 'packages/styling/src/tokens.cjs', launchTemplate('styling-tokens.cjs'));
|
|
39
|
+
const tokens = createRequire(import.meta.url)('../../assets/launch/styling-tokens.cjs');
|
|
40
|
+
const theme = (values, indent = '') => [
|
|
41
|
+
indent + ':root {',
|
|
42
|
+
...Object.entries(values).map(([key, value]) => `${indent} ${key}: ${value};`),
|
|
43
|
+
indent + '}',
|
|
44
|
+
].join('\n');
|
|
45
|
+
put(root, 'packages/styling/globals.css', [
|
|
46
|
+
theme(tokens.light),
|
|
47
|
+
'@media (prefers-color-scheme: dark) {',
|
|
48
|
+
theme(tokens.dark, ' '),
|
|
49
|
+
'}',
|
|
50
|
+
'',
|
|
51
|
+
].join('\n'));
|
|
52
|
+
put(root, 'packages/styling/src/tokens.d.cts', 'export const light: Record<string, string>;\nexport const dark: Record<string, string>;\nexport const spacing: { small: number; medium: number; large: number };\n');
|
|
76
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CapabilityEditor } from '../composition/editor.js';
|
|
2
1
|
import type { Capability } from '../composition/catalog.js';
|
|
2
|
+
import { CapabilityEditor } from '../composition/editor.js';
|
|
3
3
|
/** The launch foundation is a web service; Hono owns application services and data. */
|
|
4
4
|
export declare function scaffoldTanstack(root: string, name: string): void;
|
|
5
5
|
/** One-time source upgrade, planned in the same bounded overlay as each addition. */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { secureWorkspacePolicy } from '../pnpm-policy.js';
|
|
2
1
|
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { ANHEDRAL_STACK_DEPENDENCIES, WEB_DEPENDENCIES } from '../dependencies.js';
|
|
4
2
|
import { CapabilityEditor, fingerprint } from '../composition/editor.js';
|
|
3
|
+
import { ANHEDRAL_STACK_DEPENDENCIES, WEB_DEPENDENCIES } from '../dependencies.js';
|
|
4
|
+
import { secureWorkspacePolicy } from '../pnpm-policy.js';
|
|
5
5
|
import { resourceName } from '../render.js';
|
|
6
|
-
import { json, put, workerConfig } from './files.js';
|
|
7
|
-
const template = (name) => readFileSync(new URL(`../../assets/launch/${name}`, import.meta.url), 'utf8');
|
|
6
|
+
import { json, launchTemplate, put, workerConfig } from './files.js';
|
|
8
7
|
/** The launch foundation is a web service; Hono owns application services and data. */
|
|
9
8
|
export function scaffoldTanstack(root, name) {
|
|
10
9
|
const app = 'apps/web';
|
|
@@ -17,10 +16,7 @@ export function scaffoldTanstack(root, name) {
|
|
|
17
16
|
type: 'module',
|
|
18
17
|
scripts: {
|
|
19
18
|
test: 'node --experimental-strip-types --test tests/*.test.mjs',
|
|
20
|
-
|
|
21
|
-
build: 'node ../../scripts/oj.mjs build .',
|
|
22
|
-
preview: 'wrangler dev --config dist/ssr/wrangler.json --port 3000',
|
|
23
|
-
deploy: 'wrangler deploy --config dist/ssr/wrangler.json',
|
|
19
|
+
...ojScripts,
|
|
24
20
|
typecheck: 'wrangler types && tsr generate && tsc --noEmit',
|
|
25
21
|
lint: 'eslint . --max-warnings 0',
|
|
26
22
|
},
|
|
@@ -52,9 +48,7 @@ export function scaffoldTanstack(root, name) {
|
|
|
52
48
|
},
|
|
53
49
|
});
|
|
54
50
|
json(root, `${app}/wrangler.jsonc`, {
|
|
55
|
-
...workerConfig(resourceName(name, 'web')),
|
|
56
|
-
main: 'src/server.ts',
|
|
57
|
-
compatibility_date: '2026-11-02',
|
|
51
|
+
...workerConfig(resourceName(name, 'web'), 'src/server.ts', '2026-11-02'),
|
|
58
52
|
services: [],
|
|
59
53
|
});
|
|
60
54
|
json(root, `${app}/tsconfig.json`, {
|
|
@@ -81,7 +75,10 @@ export function scaffoldTanstack(root, name) {
|
|
|
81
75
|
generatedRouteTree: './src/routeTree.gen.ts',
|
|
82
76
|
});
|
|
83
77
|
put(root, `${app}/eslint.config.mjs`, `import { config } from '@workspace/eslint-config/react-internal';
|
|
84
|
-
export default [
|
|
78
|
+
export default [
|
|
79
|
+
...config,
|
|
80
|
+
{ ignores: ['dist/**', '.wrangler/**', 'src/routeTree.gen.ts', 'worker-configuration.d.ts'] },
|
|
81
|
+
];
|
|
85
82
|
`);
|
|
86
83
|
json(root, `${app}/components.json`, {
|
|
87
84
|
$schema: 'https://ui.shadcn.com/schema.json',
|
|
@@ -100,14 +97,16 @@ export default [...config, { ignores: ['dist/**', '.wrangler/**', 'src/routeTree
|
|
|
100
97
|
});
|
|
101
98
|
put(root, `${app}/src/lib/utils.ts`, `import { clsx, type ClassValue } from 'clsx';
|
|
102
99
|
import { twMerge } from 'tailwind-merge';
|
|
103
|
-
export function cn(...values: ClassValue[]) {
|
|
100
|
+
export function cn(...values: ClassValue[]) {
|
|
101
|
+
return twMerge(clsx(values));
|
|
102
|
+
}
|
|
104
103
|
`);
|
|
105
104
|
for (const component of ['button', 'input', 'label'])
|
|
106
105
|
put(root, `${app}/src/components/ui/${component}.tsx`, readFileSync(new URL(`../../assets/ui/web/${component}.tsx`, import.meta.url), 'utf8'));
|
|
107
106
|
for (const file of ['LICENSE.shadcn', 'UPSTREAM.json'])
|
|
108
107
|
put(root, `${app}/${file}`, readFileSync(new URL(`../../assets/ui/${file}`, import.meta.url), 'utf8'));
|
|
109
108
|
put(root, `${app}/postcss.config.mjs`, "export default { plugins: { '@tailwindcss/postcss': {} } };\n");
|
|
110
|
-
put(root, `${app}/src/starter.ts`, `export const starterTitle = ${JSON.stringify(name)};\n`);
|
|
109
|
+
put(root, `${app}/src/starter.ts`, `export const starterTitle = ${/^[a-z0-9._-]+$/.test(name) ? `'${name}'` : JSON.stringify(name)};\n`);
|
|
111
110
|
const files = {
|
|
112
111
|
'tests/application.test.mjs': 'application.test.mjs.txt',
|
|
113
112
|
'src/router.tsx': 'router.tsx.txt',
|
|
@@ -117,7 +116,7 @@ export function cn(...values: ClassValue[]) { return twMerge(clsx(values)); }
|
|
|
117
116
|
'src/styles.css': 'styles.css.txt',
|
|
118
117
|
};
|
|
119
118
|
for (const [destination, source] of Object.entries(files))
|
|
120
|
-
put(root, `${app}/${destination}`,
|
|
119
|
+
put(root, `${app}/${destination}`, launchTemplate(source));
|
|
121
120
|
put(root, `${app}/public/robots.txt`, 'User-agent: *\nAllow: /\n');
|
|
122
121
|
put(root, `${app}/public/_headers`, '/assets/*\n Cache-Control: public, max-age=31536000, immutable\n/*\n X-Content-Type-Options: nosniff\n');
|
|
123
122
|
}
|
|
@@ -142,21 +141,7 @@ const ojFiles = {
|
|
|
142
141
|
'scripts/OJ.LICENSE': 'oj/OJ.LICENSE',
|
|
143
142
|
};
|
|
144
143
|
function tanstackViteConfiguration(installed) {
|
|
145
|
-
|
|
146
|
-
return `import { fileURLToPath } from 'node:url';
|
|
147
|
-
import { defineConfig } from 'vite';
|
|
148
|
-
import { cloudflare } from '@cloudflare/vite-plugin';
|
|
149
|
-
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
150
|
-
import react from '@vitejs/plugin-react';
|
|
151
|
-
export default defineConfig(${backend ? '({ command }) => (' : ''}{
|
|
152
|
-
resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
|
|
153
|
-
plugins: [
|
|
154
|
-
cloudflare({ viteEnvironment: { name: 'ssr' }, ${backend ? "auxiliaryWorkers: command === 'serve' ? [{ configPath: '../api/wrangler.jsonc' }] : [], persistState: { path: fileURLToPath(new URL('../api/.wrangler/state', import.meta.url)) }, " : ''}remoteBindings: false }),
|
|
155
|
-
tanstackStart({ server: { entry: './server.ts' } }),
|
|
156
|
-
react(),
|
|
157
|
-
],
|
|
158
|
-
}${backend ? ')' : ''});
|
|
159
|
-
`;
|
|
144
|
+
return launchTemplate(installed.includes('hono') ? 'backend-vite.config.ts.txt' : 'vite.config.ts.txt');
|
|
160
145
|
}
|
|
161
146
|
/** One-time source upgrade, planned in the same bounded overlay as each addition. */
|
|
162
147
|
export function normalizeOjFoundation(e, installed, refreshConfiguration = false) {
|
|
@@ -189,7 +174,7 @@ export function normalizeOjFoundation(e, installed, refreshConfiguration = false
|
|
|
189
174
|
fingerprint(currentEntry) ===
|
|
190
175
|
'703adff2e57adfbbdb7fa90b4dadffde8617c86cc31a185943931ef7c623eca7' &&
|
|
191
176
|
e.managed[serverEntry] === fingerprint(currentEntry)) {
|
|
192
|
-
e.owned(serverEntry,
|
|
177
|
+
e.owned(serverEntry, launchTemplate('server.ts.txt'));
|
|
193
178
|
changed = true;
|
|
194
179
|
}
|
|
195
180
|
const rootRoute = 'apps/web/src/routes/__root.tsx';
|
|
@@ -197,7 +182,7 @@ export function normalizeOjFoundation(e, installed, refreshConfiguration = false
|
|
|
197
182
|
// A one-way repair of the exact shipped document, without owning customer routes.
|
|
198
183
|
if (rootSource !== null &&
|
|
199
184
|
fingerprint(rootSource) === '21af7892e39130c9ec3d7ffb583b3f5d24bee771440ca253d8d7b8ce41be9801') {
|
|
200
|
-
e.writes.set(rootRoute,
|
|
185
|
+
e.writes.set(rootRoute, launchTemplate('root.tsx.txt'));
|
|
201
186
|
changed = true;
|
|
202
187
|
}
|
|
203
188
|
else if (rootSource !== null && /\bfrom\s*(['"])\.\.\/styles\.css\?url\1/.test(rootSource))
|
|
@@ -209,7 +194,7 @@ export function normalizeOjFoundation(e, installed, refreshConfiguration = false
|
|
|
209
194
|
}
|
|
210
195
|
}
|
|
211
196
|
for (const [destination, asset] of Object.entries(ojFiles)) {
|
|
212
|
-
const desired =
|
|
197
|
+
const desired = launchTemplate(asset);
|
|
213
198
|
if (e.read(destination) !== desired) {
|
|
214
199
|
e.owned(destination, desired);
|
|
215
200
|
changed = true;
|
|
@@ -243,8 +228,8 @@ export function composeTanstack(e, installed, refreshConfiguration = false) {
|
|
|
243
228
|
normalizeOjFoundation(e, installed, refreshConfiguration);
|
|
244
229
|
const backend = installed.includes('hono');
|
|
245
230
|
const auth = installed.includes('database-auth');
|
|
246
|
-
e.owned('apps/web/src/server.ts',
|
|
247
|
-
e.owned('apps/web/src/lib/application.server.ts',
|
|
231
|
+
e.owned('apps/web/src/server.ts', launchTemplate(backend ? 'server.ts.txt' : 'minimal-server.ts.txt'));
|
|
232
|
+
e.owned('apps/web/src/lib/application.server.ts', launchTemplate(backend ? 'application.server.ts.txt' : 'minimal-application.server.ts.txt')
|
|
248
233
|
.replaceAll('__AUTHENTICATION__', String(auth))
|
|
249
234
|
.replaceAll('__STORAGE__', String(installed.includes('r2')))
|
|
250
235
|
.replaceAll('__PAYMENT__', String(installed.includes('stripe'))));
|
|
@@ -253,6 +238,6 @@ export function composeTanstack(e, installed, refreshConfiguration = false) {
|
|
|
253
238
|
/** Install account source only when the backend authentication capability is added. */
|
|
254
239
|
export function addTanstackAuth(e) {
|
|
255
240
|
assertTanstack(e);
|
|
256
|
-
e.create('apps/web/src/lib/auth-client.ts',
|
|
257
|
-
e.create('apps/web/src/routes/sign-in.tsx',
|
|
241
|
+
e.create('apps/web/src/lib/auth-client.ts', launchTemplate('auth-client.ts.txt'));
|
|
242
|
+
e.create('apps/web/src/routes/sign-in.tsx', launchTemplate('sign-in.tsx.txt'));
|
|
258
243
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const GENERATOR_VERSION = "0.24.
|
|
1
|
+
export declare const GENERATOR_VERSION = "0.24.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const GENERATOR_VERSION = '0.24.
|
|
1
|
+
export const GENERATOR_VERSION = '0.24.1';
|
package/docs/software-factory.md
CHANGED
|
@@ -39,7 +39,7 @@ with revision, checks, failures and remaining gaps. Keep raw reports in ignored
|
|
|
39
39
|
`.artifacts/`. Historical notes are not current instructions.
|
|
40
40
|
|
|
41
41
|
Canonical docs live in `docs/`; `pnpm build` refreshes bundled plugin references.
|
|
42
|
-
Current generated app guidance lives in `
|
|
42
|
+
Current generated app guidance lives in `assets/launch/README.md.txt` and `assets/launch/AGENTS.md.txt`. OJ runs development and builds for the single TanStack Start foundation. Preserve shipped
|
|
43
43
|
reference paths, source-generation safety, dependency patch gates, UI provenance,
|
|
44
44
|
licenses and exact-artifact packaging. A build does not publish npm or update an
|
|
45
45
|
installed plugin. See [Contributing](https://github.com/anhedral/anhedral-cli/blob/main/.github/CONTRIBUTING.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anhedral",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "The open-source Anhedral API client for building, configuring and deploying apps, with editable source generation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -89,7 +89,9 @@
|
|
|
89
89
|
"test:patch": "node tests/test-braces-install.mjs && node tests/test-forge-install.mjs",
|
|
90
90
|
"check:boundaries": "node scripts/checks/repository-boundaries.mjs",
|
|
91
91
|
"test:tanstack-runtime": "pnpm build && node scripts/runtime/tanstack-runtime-smoke.mjs",
|
|
92
|
-
"check:standalone": "node scripts/checks/standalone-checkout.mjs"
|
|
92
|
+
"check:standalone": "node scripts/checks/standalone-checkout.mjs",
|
|
93
|
+
"examples:check": "node scripts/checks/generated-examples.mjs",
|
|
94
|
+
"examples:refresh": "node scripts/checks/generated-examples.mjs --write"
|
|
93
95
|
},
|
|
94
96
|
"keywords": [
|
|
95
97
|
"cli",
|
package/dist/api-proxy.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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. The server must frame/compress\n // those decoded bytes itself; the sidecar's wire headers no longer describe them.\n if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }\n headers.set('cache-control', 'private, no-store');\n return new Response(response.body, { status: response.status, headers });\n}\nexport async function proxyApi(request: Request, options: Options): Promise<Response> {\n try {\n const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));\n const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);\n return privateResponse(response, options.development);\n } catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }\n}\n";
|
package/dist/api-proxy.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export const WEB_API_PROXY = `export interface ApiBinding { fetch(request: Request): Promise<Response> }
|
|
2
|
-
type Options = { binding?: ApiBinding; development: boolean; devOrigin?: string; send?: typeof fetch };
|
|
3
|
-
function developmentOrigin(configured?: string): string {
|
|
4
|
-
const url = new URL(configured || 'http://127.0.0.1:8787');
|
|
5
|
-
const loopback = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
6
|
-
const invalid = [url.protocol !== 'http:', !loopback.has(url.hostname), url.username, url.password, url.pathname !== '/', url.search, url.hash];
|
|
7
|
-
if (invalid.some(Boolean)) throw Error('API_INTERNAL_URL must be a loopback HTTP origin.');
|
|
8
|
-
return url.origin;
|
|
9
|
-
}
|
|
10
|
-
function backendOrigin(options: Options): string {
|
|
11
|
-
if (options.development) return developmentOrigin(options.devOrigin);
|
|
12
|
-
if ([!options.binding, options.devOrigin].some(Boolean)) throw Error('Production requires the API service binding.');
|
|
13
|
-
return 'https://api.internal';
|
|
14
|
-
}
|
|
15
|
-
function apiTarget(request: Request, origin: string): URL {
|
|
16
|
-
const url = new URL(request.url);
|
|
17
|
-
if (!/^\\/api(?:\\/|$)/.test(url.pathname)) throw Error('Unexpected API path.');
|
|
18
|
-
return new URL(url.pathname + url.search, origin);
|
|
19
|
-
}
|
|
20
|
-
function forwardedHeaders(request: Request): Headers {
|
|
21
|
-
const headers = new Headers();
|
|
22
|
-
for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
|
|
23
|
-
const value = request.headers.get(name); if (value) headers.set(name, value);
|
|
24
|
-
}
|
|
25
|
-
return headers;
|
|
26
|
-
}
|
|
27
|
-
function upstreamRequest(request: Request, target: URL): Request {
|
|
28
|
-
const settings: RequestInit & { duplex?: 'half' } = { method: request.method, headers: forwardedHeaders(request), redirect: 'manual', signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]) };
|
|
29
|
-
if (!['GET', 'HEAD'].includes(request.method)) { settings.body = request.body; settings.duplex = 'half'; }
|
|
30
|
-
return new Request(target, settings);
|
|
31
|
-
}
|
|
32
|
-
function privateResponse(response: Response, development: boolean): Response {
|
|
33
|
-
const headers = new Headers(response.headers);
|
|
34
|
-
for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
|
|
35
|
-
// Node fetch already decoded the local HTTP response. The server must frame/compress
|
|
36
|
-
// those decoded bytes itself; the sidecar's wire headers no longer describe them.
|
|
37
|
-
if (development) { headers.delete('content-encoding'); headers.delete('content-length'); }
|
|
38
|
-
headers.set('cache-control', 'private, no-store');
|
|
39
|
-
return new Response(response.body, { status: response.status, headers });
|
|
40
|
-
}
|
|
41
|
-
export async function proxyApi(request: Request, options: Options): Promise<Response> {
|
|
42
|
-
try {
|
|
43
|
-
const upstream = upstreamRequest(request, apiTarget(request, backendOrigin(options)));
|
|
44
|
-
const response = options.development ? await (options.send ?? fetch)(upstream) : await options.binding!.fetch(upstream);
|
|
45
|
-
return privateResponse(response, options.development);
|
|
46
|
-
} catch { return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } }); }
|
|
47
|
-
}
|
|
48
|
-
`;
|