anhedral 0.17.0 → 0.19.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 +33 -68
- package/assets/contracts/LICENSE +201 -0
- package/assets/contracts/LICENSE.environment +201 -0
- package/assets/contracts/LICENSE.operations +201 -0
- package/assets/contracts/deployment-provenance.json +15 -0
- package/assets/contracts/environment-provenance.json +11 -0
- package/assets/contracts/operations-provenance.json +12 -0
- package/assets/launch/application.server.ts.txt +13 -0
- package/assets/launch/auth-client.ts.txt +4 -0
- package/assets/launch/home.tsx.txt +20 -0
- package/assets/launch/minimal-application.server.ts.txt +5 -0
- package/assets/launch/minimal-server.ts.txt +7 -0
- package/assets/launch/oj/OJ.LICENSE +21 -0
- package/assets/launch/oj/run.mjs +82 -0
- package/assets/launch/oj/runtime.json +21 -0
- package/assets/launch/request-context.ts.txt +3 -0
- package/assets/launch/root.tsx.txt +26 -0
- package/assets/launch/router.tsx.txt +21 -0
- package/assets/launch/server.ts.txt +15 -0
- package/assets/launch/sign-in.tsx.txt +53 -0
- package/assets/launch/styles.css.txt +19 -0
- package/assets/security/credential-patterns.d.mts +3 -0
- package/assets/security/credential-patterns.mjs +59 -0
- package/assets/stack/api-index.ts.txt +6 -1
- package/assets/stack/stripe.ts.txt +30 -13
- package/assets/ui/catalog.json +36 -324
- package/dist/{platforms/web.d.ts → api-proxy.d.ts} +1 -3
- package/dist/api-proxy.js +48 -0
- package/dist/bin.js +55 -36
- package/dist/capability-catalog.d.ts +36 -57
- package/dist/capability-catalog.js +65 -67
- package/dist/capability-command.d.ts +3 -3
- package/dist/capability-command.js +146 -59
- package/dist/capability-editor.js +6 -5
- package/dist/capability-recipes.js +9 -296
- package/dist/cli-arguments.d.ts +2 -0
- package/dist/cli-arguments.js +101 -50
- package/dist/cli-commands.d.ts +1 -1
- package/dist/cli-commands.js +31 -5
- package/dist/cli-errors.d.ts +18 -0
- package/dist/cli-errors.js +63 -0
- package/dist/cli-output.d.ts +22 -0
- package/dist/cli-output.js +42 -7
- package/dist/command-runner.js +88 -0
- package/dist/command-schema.d.ts +16 -0
- package/dist/command-schema.js +496 -21
- package/dist/command-types.d.ts +1 -0
- package/dist/command-types.js +1 -0
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +201 -0
- package/dist/composition.d.ts +25 -0
- package/dist/composition.js +28 -0
- package/dist/contracts/cli-transport.d.ts +316 -0
- package/dist/contracts/cli-transport.js +236 -0
- package/dist/contracts/deployment.d.ts +233 -0
- package/dist/contracts/deployment.js +198 -0
- package/dist/contracts/environment-file.d.ts +7 -0
- package/dist/contracts/environment-file.js +112 -0
- package/dist/contracts/environment-transport.d.ts +79 -0
- package/dist/contracts/environment-transport.js +110 -0
- package/dist/contracts/production-transport.d.ts +71 -0
- package/dist/contracts/production-transport.js +56 -0
- package/dist/contracts/runtime-logs-transport.d.ts +127 -0
- package/dist/contracts/runtime-logs-transport.js +50 -0
- package/dist/contracts/source-bundle.d.ts +11 -0
- package/dist/contracts/source-bundle.js +197 -0
- package/dist/contracts/source-profile.d.ts +4 -0
- package/dist/contracts/source-profile.js +5 -0
- package/dist/contracts/staging-transport.d.ts +79 -0
- package/dist/contracts/staging-transport.js +43 -0
- package/dist/dependencies.d.ts +9 -27
- package/dist/dependencies.js +19 -66
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/launch.d.ts +27 -0
- package/dist/launch.js +262 -0
- package/dist/platform-command.d.ts +9 -0
- package/dist/platform-command.js +787 -0
- package/dist/platform-environment.d.ts +18 -0
- package/dist/platform-environment.js +257 -0
- package/dist/platform-operations.d.ts +26 -0
- package/dist/platform-operations.js +155 -0
- package/dist/platform-production.d.ts +16 -0
- package/dist/platform-production.js +135 -0
- package/dist/platform-source.d.ts +8 -0
- package/dist/platform-source.js +111 -0
- package/dist/platform-state.d.ts +15 -0
- package/dist/platform-state.js +229 -0
- package/dist/platforms/tanstack.d.ts +10 -0
- package/dist/platforms/tanstack.js +248 -0
- package/dist/registry/usage.d.ts +4 -1
- package/dist/registry/usage.js +59 -4
- package/dist/scaffold/bootstrap.d.ts +3 -3
- package/dist/scaffold/styling.d.ts +3 -2
- package/dist/transaction.js +28 -3
- package/dist/ui-catalog.d.ts +3 -5
- package/dist/ui-catalog.js +8 -24
- package/dist/ui-command.d.ts +3 -1
- package/dist/ui-command.js +74 -72
- package/dist/ui-project.d.ts +4 -2
- package/dist/ui-project.js +40 -38
- package/dist/util.js +40 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +23 -89
- package/docs/software-factory.md +208 -9
- package/docs/stack-standard.md +7 -17
- package/docs/ui.md +9 -22
- package/package.json +26 -22
- package/assets/stack/ai-schema.ts.txt +0 -5
- package/assets/stack/ai.ts.txt +0 -30
- package/assets/stack/desktop.rs.txt +0 -21
- package/assets/stack/events-schema.ts.txt +0 -12
- package/assets/stack/events.ts.txt +0 -59
- package/assets/stack/mobile-auth.ts.txt +0 -25
- package/assets/stack/mobile-billing.tsx.txt +0 -63
- package/assets/stack/mobile-session.tsx.txt +0 -83
- package/assets/stack/native-button.tsx.txt +0 -108
- package/assets/stack/native-global.css.txt +0 -4
- package/assets/stack/native-lib-utils.ts.txt +0 -5
- package/assets/stack/native-metro.config.js.txt +0 -6
- package/assets/stack/native-nativewind-env.d.ts.txt +0 -1
- package/assets/stack/native-tailwind.config.js.txt +0 -73
- package/assets/stack/native-text.tsx.txt +0 -89
- package/assets/stack/purchases.ts.txt +0 -65
- package/assets/stack/revenuecat.ts.txt +0 -88
- package/assets/stack/rtc-schema.ts.txt +0 -10
- package/assets/stack/rtc.ts.txt +0 -122
- package/assets/stack/web-sign-in.tsx.txt +0 -51
- package/dist/capabilities.d.ts +0 -11
- package/dist/capabilities.js +0 -14
- package/dist/dependency-order.d.ts +0 -2
- package/dist/dependency-order.js +0 -24
- package/dist/platforms/lint.d.ts +0 -1
- package/dist/platforms/lint.js +0 -5
- package/dist/platforms/web.js +0 -251
- package/dist/project-config.d.ts +0 -3
- package/dist/project-config.js +0 -16
- package/dist/registry/context.d.ts +0 -3
- package/dist/registry/context.js +0 -20
- package/dist/registry/options.d.ts +0 -2
- package/dist/registry/options.js +0 -44
- package/dist/registry/resolve.d.ts +0 -11
- package/dist/registry/resolve.js +0 -46
- package/dist/registry/types.d.ts +0 -60
- package/dist/scaffold/api.d.ts +0 -2
- package/dist/scaffold/api.js +0 -38
- package/dist/scaffold/backend.d.ts +0 -2
- package/dist/scaffold/backend.js +0 -36
- package/dist/scaffold/compose.d.ts +0 -4
- package/dist/scaffold/compose.js +0 -30
- package/dist/scaffold/database.d.ts +0 -2
- package/dist/scaffold/database.js +0 -41
- package/dist/scaffold/documentation.d.ts +0 -2
- package/dist/scaffold/documentation.js +0 -71
- package/dist/scaffold/environment.d.ts +0 -4
- package/dist/scaffold/environment.js +0 -22
- package/dist/scaffold/stack-documentation.d.ts +0 -2
- package/dist/scaffold/stack-documentation.js +0 -6
- package/dist/scaffold/storage.d.ts +0 -2
- package/dist/scaffold/storage.js +0 -21
- package/dist/scaffold/workspace.d.ts +0 -3
- package/dist/scaffold/workspace.js +0 -131
- package/dist/stack-registry.d.ts +0 -35
- package/dist/stack-registry.js +0 -189
- package/dist/standard.d.ts +0 -8
- package/dist/standard.js +0 -94
- package/dist/workspace-graph.d.ts +0 -7
- package/dist/workspace-graph.js +0 -74
- package/docs/anhedral-stack.md +0 -12
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/native-ui.md +0 -47
- /package/dist/{registry/types.js → command-runner.d.ts} +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { capabilityReferences } from '../capability-references.js';
|
|
2
|
-
import { put } from './files.js';
|
|
3
|
-
export function writeSetupDocumentation(root, options) {
|
|
4
|
-
for (const [file, source] of Object.entries(capabilityReferences()))
|
|
5
|
-
put(root, file, source);
|
|
6
|
-
put(root, 'README.md', `# ${options.name}
|
|
7
|
-
|
|
8
|
-
Next.js on Cloudflare Workers through OpenNext, with Anhedral UI from the start.
|
|
9
|
-
Init starts with apps/web. Review anhedral.json for explicitly composed API/data source.
|
|
10
|
-
Use anhedral stack status to inspect later source additions.
|
|
11
|
-
No providers are provisioned by source generation.
|
|
12
|
-
|
|
13
|
-
## Develop
|
|
14
|
-
|
|
15
|
-
Use the Node/pnpm versions in package.json. Run pnpm install if generation skipped
|
|
16
|
-
installation, then pnpm dev. Open the URL printed by Next.js.
|
|
17
|
-
|
|
18
|
-
## Anhedral UI
|
|
19
|
-
|
|
20
|
-
The initial page uses editable Button, Input and Label source from the reviewed
|
|
21
|
-
shadcn baseline. Application-local source belongs to you. Shared tokens live in
|
|
22
|
-
packages/styling; preserve attribution in ANHEDRAL_UI_LICENSES and UPSTREAM.json.
|
|
23
|
-
Anhedral UI is a CLI/catalog/theme convention, not a runtime component package.
|
|
24
|
-
|
|
25
|
-
Use anhedral ui list, anhedral ui add card --web, anhedral ui diff button --web,
|
|
26
|
-
and anhedral ui doctor --web. Use --cwd apps/web to select this application or
|
|
27
|
-
--all explicitly for multiple clients. --dry-run previews init/add without network
|
|
28
|
-
or writes. Updates are opt-in; never overwrite customized components silently.
|
|
29
|
-
|
|
30
|
-
Native UI uses the React Native Reusables NativeWind registry in compatible Expo
|
|
31
|
-
projects, preferring reviewed Anhedral extensions when present. It requires Expo,
|
|
32
|
-
not a backend. Use anhedral add expo, then add native-ui, for the reviewed client/setup recipes.
|
|
33
|
-
Standalone UI commands do not create native clients or backend services; existing
|
|
34
|
-
Expo applications need the upstream NativeWind/RNR setup before native ui init.
|
|
35
|
-
|
|
36
|
-
## Add strategically
|
|
37
|
-
|
|
38
|
-
Add Hono when a dedicated API is justified, then Drizzle/D1/Better Auth when the
|
|
39
|
-
product needs data and authentication. Use anhedral add <capability> --dry-run --json
|
|
40
|
-
to review changes, then apply them. Missing parents require explicit selection or
|
|
41
|
-
--with-dependencies. See docs/anhedral/capabilities.md for the complete catalog and
|
|
42
|
-
source-protection contract. No provision or deployment command is implemented here.
|
|
43
|
-
Consumers own integrations, deployment and application distribution. Run pnpm check
|
|
44
|
-
and review your changes before deployment. Builds/startup never migrate databases.
|
|
45
|
-
|
|
46
|
-
Hono owns privileged API operations when selected. Clients and Next server actions
|
|
47
|
-
call the API; applications never import one another's source. Keep database and
|
|
48
|
-
storage credentials server-side. Implement identity, authorization and ownership
|
|
49
|
-
checks before exposing data or files; private storage is not user authorization.
|
|
50
|
-
Review generated SQL and apply migrations explicitly through the selected database tooling.
|
|
51
|
-
`);
|
|
52
|
-
put(root, 'AGENTS.md', `# Minimal application foundation
|
|
53
|
-
|
|
54
|
-
Start with Next.js/OpenNext/Workers and source-owned Anhedral UI. Do not add an API,
|
|
55
|
-
database, authentication, R2 or native client without a concrete feature need.
|
|
56
|
-
Use anhedral add and stack list/status/doctor to compose selected capabilities.
|
|
57
|
-
Preview additions first, preserve edited source, and configure selected auth methods
|
|
58
|
-
explicitly. Source installation is not provider activation. Use anhedral ui
|
|
59
|
-
add/list/diff/doctor to manage platform-specific source; web uses
|
|
60
|
-
official shadcn and native uses RNR/NativeWind with reviewed Anhedral extensions.
|
|
61
|
-
UI requires its application platform, not Hono or a database. Share tokens, not
|
|
62
|
-
DOM/native primitives. Preserve consumer edits, attribution and upstream metadata.
|
|
63
|
-
Never automatically overwrite installed components. Read version-matched framework
|
|
64
|
-
guides and run pnpm check. Never migrate a configured database during checks/builds.
|
|
65
|
-
Hono owns privileged operations when present. Clients call its API; applications
|
|
66
|
-
must not import another application's source. Keep database/storage secrets on
|
|
67
|
-
the server and implement authorization before exposing private data or files.
|
|
68
|
-
`);
|
|
69
|
-
put(root, 'docs/architecture.md', '# Architecture\n\nNext.js → OpenNext → Cloudflare Workers, with Anhedral UI. Record feature-driven additions here.\n');
|
|
70
|
-
put(root, 'docs/verification.md', '# Verification\n\nRecord commands, outcomes and environment. Source generation is not deployment acceptance.\n');
|
|
71
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ResolvedStackRegistry } from '../registry/resolve.js';
|
|
2
|
-
/** Extend examples without discarding earlier recipe defaults or customer comments. */
|
|
3
|
-
export declare function writeEnvironmentFile(root: string, file: string, variables: Record<string, string>): void;
|
|
4
|
-
export declare function writeEnvironmentExample(root: string, registry: ResolvedStackRegistry): void;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { put } from './files.js';
|
|
4
|
-
/** Extend examples without discarding earlier recipe defaults or customer comments. */
|
|
5
|
-
export function writeEnvironmentFile(root, file, variables) {
|
|
6
|
-
const destination = path.join(root, file);
|
|
7
|
-
let content = existsSync(destination) ? readFileSync(destination, 'utf8') : '';
|
|
8
|
-
const keys = new Set([...content.matchAll(/^[ \t]*(?:export[ \t]+)?([A-Z][A-Z0-9_]*)[ \t]*=/gm)].map((match) => match[1]));
|
|
9
|
-
const additions = Object.entries(variables)
|
|
10
|
-
.filter(([key]) => !keys.has(key))
|
|
11
|
-
.map(([key, value]) => `${key}=${value}`);
|
|
12
|
-
if (additions.length) {
|
|
13
|
-
if (content && !content.endsWith('\n'))
|
|
14
|
-
content += '\n';
|
|
15
|
-
content += additions.join('\n') + '\n';
|
|
16
|
-
}
|
|
17
|
-
put(root, file, content || '\n');
|
|
18
|
-
}
|
|
19
|
-
export function writeEnvironmentExample(root, registry) {
|
|
20
|
-
const names = [...new Set(registry.items.flatMap((item) => item.environment))].sort();
|
|
21
|
-
writeEnvironmentFile(root, '.env.example', Object.fromEntries(names.map((name) => [name, ''])));
|
|
22
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { put } from './files.js';
|
|
2
|
-
export function writeStackDocumentation(root, registry) {
|
|
3
|
-
const sections = registry.items.map((item) => `## ${item.name}\n\n${item.description}.\n\nTargets: ${item.targets.join(', ')}.\n\n${item.environment.length ? 'Environment: ' + item.environment.join(', ') + '.\n\n' : ''}${item.setup ? 'Setup: ' + item.setup.resources.join('; ') + '.\n\nVerify: ' + item.setup.verify.join('; ') + '.\n' : ''}`);
|
|
4
|
-
put(root, 'docs/stack.md', '# Application stack\n\nEvery application uses Next.js App Router/OpenNext for web, Expo for iOS/Android, Hono, Drizzle/D1 and private R2. Shared contracts, styling and native shadcn UI are included. Consumers implement application features, identity and integrations.\n\nInit generates source and configuration only. Consumers own cloud provisioning, secrets, migrations and deployment.\n\n' +
|
|
5
|
-
sections.join('\n'));
|
|
6
|
-
}
|
package/dist/scaffold/storage.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { put } from './files.js';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
export function scaffoldPrivateStorage({ root }) {
|
|
5
|
-
put(root, 'apps/api/src/private-storage.ts', `// Use only after your application has authorized the operation. No HTTP routes are exposed.
|
|
6
|
-
// R2 bucket privacy does not establish end-user authorization.
|
|
7
|
-
export function privateStorage(binding: R2Bucket) {
|
|
8
|
-
return {
|
|
9
|
-
get: (key: string) => binding.get(key),
|
|
10
|
-
put: (key: string, value: ArrayBuffer | ReadableStream) => binding.put(key, value),
|
|
11
|
-
delete: (key: string) => binding.delete(key),
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
`);
|
|
15
|
-
const file = 'apps/api/src/index.ts';
|
|
16
|
-
const source = readFileSync(path.join(root, file), 'utf8');
|
|
17
|
-
put(root, file, "import { privateStorage } from './private-storage';\n" +
|
|
18
|
-
source
|
|
19
|
-
.replace('database: () => ReturnType<typeof createDatabase>', 'database: () => ReturnType<typeof createDatabase>; storage: () => ReturnType<typeof privateStorage>')
|
|
20
|
-
.replace("c.set('database', () => createDatabase(c.env.DB));", "c.set('database', () => createDatabase(c.env.DB)); c.set('storage', () => privateStorage(c.env.FILES));"));
|
|
21
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { writeProjectSection } from '../project-config.js';
|
|
2
|
-
import { OPENNEXT_GLOB_VERSION, STACK_DEPENDENCIES, WORKSPACE_NODE_ENGINE, PACKAGE_MANAGER, } from '../dependencies.js';
|
|
3
|
-
import { writeDependencyAudit } from '../dependency-patches.js';
|
|
4
|
-
import { setPnpmPolicy } from '../pnpm-policy.js';
|
|
5
|
-
import { appendGitignore } from '../util.js';
|
|
6
|
-
import { createSetupPlan } from '../capabilities.js';
|
|
7
|
-
import { json, put, patchPackage } from './files.js';
|
|
8
|
-
import { writeSetupDocumentation } from './documentation.js';
|
|
9
|
-
import { writeStackDocumentation } from './stack-documentation.js';
|
|
10
|
-
import { writeEnvironmentExample } from './environment.js';
|
|
11
|
-
export function writeStandardRoot(root, options, registry, updating = false) {
|
|
12
|
-
patchPackage(root, 'package.json', {
|
|
13
|
-
name: options.name,
|
|
14
|
-
private: true,
|
|
15
|
-
packageManager: PACKAGE_MANAGER,
|
|
16
|
-
engines: { node: WORKSPACE_NODE_ENGINE },
|
|
17
|
-
scripts: {
|
|
18
|
-
dev: 'turbo dev',
|
|
19
|
-
build: 'turbo build --concurrency=1',
|
|
20
|
-
lint: 'turbo lint',
|
|
21
|
-
typecheck: 'turbo typecheck',
|
|
22
|
-
test: 'turbo test',
|
|
23
|
-
...(options.products.includes('d1')
|
|
24
|
-
? {
|
|
25
|
-
'db:generate': 'turbo run db:generate --filter=@workspace/db',
|
|
26
|
-
'db:migrate': 'turbo run db:migrate --filter=@workspace/db',
|
|
27
|
-
}
|
|
28
|
-
: {}),
|
|
29
|
-
audit: 'node scripts/audit.mjs',
|
|
30
|
-
'audit:full': 'fallow --fail-on-issues',
|
|
31
|
-
'audit:deps': 'node scripts/audit-deps.mjs',
|
|
32
|
-
check: 'pnpm lint && pnpm typecheck && pnpm run audit && pnpm audit:deps && pnpm test && pnpm build',
|
|
33
|
-
},
|
|
34
|
-
devDependencies: { turbo: STACK_DEPENDENCIES.turbo, fallow: STACK_DEPENDENCIES.fallow },
|
|
35
|
-
});
|
|
36
|
-
writeDependencyAudit(root, updating);
|
|
37
|
-
put(root, 'scripts/audit.mjs', `import { spawnSync } from 'node:child_process';
|
|
38
|
-
const entry = process.env.npm_execpath;
|
|
39
|
-
if (!entry) throw new Error('Run this check through pnpm run audit.');
|
|
40
|
-
const result = spawnSync(process.execPath, [entry, 'exec', 'fallow', '--fail-on-issues'], { stdio: 'inherit', shell: false });
|
|
41
|
-
if (result.error) throw result.error;
|
|
42
|
-
process.exitCode = result.status ?? 1;
|
|
43
|
-
`);
|
|
44
|
-
json(root, '.fallowrc.json', {
|
|
45
|
-
ignorePatterns: [
|
|
46
|
-
'scripts/audit.mjs',
|
|
47
|
-
'scripts/audit-deps.mjs',
|
|
48
|
-
'**/.wrangler/**',
|
|
49
|
-
'**/dist/**',
|
|
50
|
-
'**/.next/**',
|
|
51
|
-
'**/.open-next/**',
|
|
52
|
-
'**/worker-configuration.d.ts',
|
|
53
|
-
],
|
|
54
|
-
});
|
|
55
|
-
json(root, 'turbo.json', {
|
|
56
|
-
$schema: 'https://turbo.build/schema.json',
|
|
57
|
-
globalDependencies: ['**/.env', '**/.env.*', '**/.dev.vars', '**/.dev.vars.*'],
|
|
58
|
-
globalEnv: [
|
|
59
|
-
...new Set(['npm_execpath', ...registry.items.flatMap((item) => item.environment)]),
|
|
60
|
-
].sort(),
|
|
61
|
-
tasks: {
|
|
62
|
-
dev: { cache: false, persistent: true },
|
|
63
|
-
lint: { dependsOn: ['^lint'] },
|
|
64
|
-
typecheck: {
|
|
65
|
-
dependsOn: ['^typecheck'],
|
|
66
|
-
outputs: ['worker-configuration.d.ts', 'next-env.d.ts', '.next/types/**'],
|
|
67
|
-
},
|
|
68
|
-
test: { dependsOn: ['^build'], outputs: ['coverage/**'] },
|
|
69
|
-
...(options.products.includes('d1')
|
|
70
|
-
? {
|
|
71
|
-
'db:generate': { cache: false },
|
|
72
|
-
'db:migrate': {
|
|
73
|
-
cache: false,
|
|
74
|
-
passThroughEnv: ['CLOUDFLARE_API_TOKEN', 'CLOUDFLARE_ACCOUNT_ID'],
|
|
75
|
-
},
|
|
76
|
-
}
|
|
77
|
-
: {}),
|
|
78
|
-
build: {
|
|
79
|
-
dependsOn: ['^build'],
|
|
80
|
-
outputs: ['dist/**', '.open-next/**', '.next/**', '!.next/cache/**'],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
setPnpmPolicy(root, {
|
|
85
|
-
...(!updating ? { packages: ['apps/*', 'packages/*'] } : {}),
|
|
86
|
-
// OpenNext's node-minify dependency pins the vulnerable glob CLI.
|
|
87
|
-
overrides: {
|
|
88
|
-
'@node-minify/core>glob': OPENNEXT_GLOB_VERSION,
|
|
89
|
-
'miniflare>undici': STACK_DEPENDENCIES.undici,
|
|
90
|
-
},
|
|
91
|
-
sharedWorkspaceLockfile: true,
|
|
92
|
-
allowBuilds: undefined,
|
|
93
|
-
onlyBuiltDependencies: ['esbuild', 'sharp', 'unrs-resolver', 'workerd'],
|
|
94
|
-
});
|
|
95
|
-
appendGitignore(root, [
|
|
96
|
-
'node_modules/',
|
|
97
|
-
'dist/',
|
|
98
|
-
'.output/',
|
|
99
|
-
'.next/',
|
|
100
|
-
'.open-next/',
|
|
101
|
-
'*.tsbuildinfo',
|
|
102
|
-
'.turbo/',
|
|
103
|
-
'.expo/',
|
|
104
|
-
'.wrangler/',
|
|
105
|
-
'.dev.vars',
|
|
106
|
-
'.dev.vars.*',
|
|
107
|
-
'!.dev.vars.example',
|
|
108
|
-
'.env',
|
|
109
|
-
'.env.*',
|
|
110
|
-
'!.env.example',
|
|
111
|
-
'.fallow/',
|
|
112
|
-
'.anhedral/',
|
|
113
|
-
'.anhedral-audit-report.json',
|
|
114
|
-
'worker-configuration.d.ts',
|
|
115
|
-
'next-env.d.ts',
|
|
116
|
-
]);
|
|
117
|
-
writeEnvironmentExample(root, registry);
|
|
118
|
-
writeStackDocumentation(root, registry);
|
|
119
|
-
writeProjectSection(root, 'standard', {
|
|
120
|
-
schemaVersion: 1,
|
|
121
|
-
standard: 'anhedral-application-stack',
|
|
122
|
-
products: options.products,
|
|
123
|
-
hosting: 'cloudflare',
|
|
124
|
-
bootstrap: { command: 'anhedral init', source: 'bundled' },
|
|
125
|
-
status: 'starter',
|
|
126
|
-
resourcesProvisioned: false,
|
|
127
|
-
});
|
|
128
|
-
writeProjectSection(root, 'setup', createSetupPlan({ ...options, dryRun: false }, registry));
|
|
129
|
-
if (!updating)
|
|
130
|
-
writeSetupDocumentation(root, options);
|
|
131
|
-
}
|
package/dist/stack-registry.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ItemDefinition, StackRegistryItem, RecipeContext } from './registry/types.js';
|
|
2
|
-
/** Every product owns its source recipe, setup requirements and composition policy here. */
|
|
3
|
-
declare const PRODUCT_ITEMS: {
|
|
4
|
-
next: ItemDefinition;
|
|
5
|
-
hono: ItemDefinition;
|
|
6
|
-
d1: ItemDefinition;
|
|
7
|
-
r2: ItemDefinition;
|
|
8
|
-
styling: ItemDefinition;
|
|
9
|
-
};
|
|
10
|
-
export type StandardProduct = keyof typeof PRODUCT_ITEMS;
|
|
11
|
-
export declare const STANDARD_PRODUCTS: readonly ("hono" | "r2" | "next" | "styling" | "d1")[];
|
|
12
|
-
declare const DEFINITIONS: {
|
|
13
|
-
next: ItemDefinition;
|
|
14
|
-
hono: ItemDefinition;
|
|
15
|
-
d1: ItemDefinition;
|
|
16
|
-
r2: ItemDefinition;
|
|
17
|
-
styling: ItemDefinition;
|
|
18
|
-
workspace: ItemDefinition;
|
|
19
|
-
typescript: ItemDefinition;
|
|
20
|
-
eslint: ItemDefinition;
|
|
21
|
-
};
|
|
22
|
-
export type StackItemId = keyof typeof DEFINITIONS;
|
|
23
|
-
export declare function getStackDefinition(name: string): ItemDefinition;
|
|
24
|
-
export declare function getStackItem(name: string): StackRegistryItem;
|
|
25
|
-
export declare const STACK_ITEMS: Record<"hono" | "r2" | "next" | "eslint" | "typescript" | "workspace" | "styling" | "d1", StackRegistryItem>;
|
|
26
|
-
export declare const STACK_REGISTRY: {
|
|
27
|
-
schemaVersion: number;
|
|
28
|
-
name: string;
|
|
29
|
-
cliVersion: string;
|
|
30
|
-
items: StackRegistryItem[];
|
|
31
|
-
};
|
|
32
|
-
export declare function installStackItem(item: StackRegistryItem, context: RecipeContext): void | Promise<void>;
|
|
33
|
-
/** Validate authored definitions during build, before shipping either catalog. */
|
|
34
|
-
export declare function validateStackCatalog(): void;
|
|
35
|
-
export {};
|
package/dist/stack-registry.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { scaffoldStyling } from './scaffold/styling.js';
|
|
2
|
-
import { resourceName } from './render.js';
|
|
3
|
-
import { dependencyOrder } from './dependency-order.js';
|
|
4
|
-
import { GENERATOR_VERSION } from './version.js';
|
|
5
|
-
import { scaffoldApi } from './scaffold/api.js';
|
|
6
|
-
import { scaffoldDatabase } from './scaffold/database.js';
|
|
7
|
-
import { scaffoldWeb } from './platforms/web.js';
|
|
8
|
-
import { scaffoldPrivateStorage } from './scaffold/storage.js';
|
|
9
|
-
import { sharedPackage } from './scaffold/files.js';
|
|
10
|
-
function requirements(purpose, tools, access, credentials, resources, verify) {
|
|
11
|
-
return { purpose, tools, access, credentials, resources, verify };
|
|
12
|
-
}
|
|
13
|
-
function packageSource(name, source, dependencies) {
|
|
14
|
-
return { name, source, dependencies };
|
|
15
|
-
}
|
|
16
|
-
function defineItems(configurations) {
|
|
17
|
-
return Object.fromEntries(Object.entries(configurations).map(([name, configuration]) => [
|
|
18
|
-
name,
|
|
19
|
-
{
|
|
20
|
-
name,
|
|
21
|
-
version: GENERATOR_VERSION,
|
|
22
|
-
selection: {},
|
|
23
|
-
registryDependencies: ['workspace', 'typescript', 'eslint'],
|
|
24
|
-
environment: [],
|
|
25
|
-
installer: configuration.type === 'foundation' ? 'bootstrap' : 'recipe',
|
|
26
|
-
...configuration,
|
|
27
|
-
},
|
|
28
|
-
]));
|
|
29
|
-
}
|
|
30
|
-
/** Every product owns its source recipe, setup requirements and composition policy here. */
|
|
31
|
-
const PRODUCT_ITEMS = defineItems({
|
|
32
|
-
next: {
|
|
33
|
-
type: 'application',
|
|
34
|
-
description: 'Full Next.js App Router web application on Cloudflare OpenNext',
|
|
35
|
-
targets: ['apps/web'],
|
|
36
|
-
registryDependencies: ['workspace', 'typescript', 'eslint', 'styling'],
|
|
37
|
-
setup: requirements('Server-rendered web application', ['Browser control', 'Wrangler'], ['Cloudflare Workers deployment access'], [], ['Next.js Worker and assets; no backend or database provisioned'], ['Request-rendered HTML, RSC and editable Anhedral UI source']),
|
|
38
|
-
install: scaffoldWeb,
|
|
39
|
-
environment: ['ANHEDRAL_PREVIEW_ORIGIN'],
|
|
40
|
-
},
|
|
41
|
-
hono: {
|
|
42
|
-
type: 'application',
|
|
43
|
-
description: 'Shared Hono OpenAPI Worker',
|
|
44
|
-
targets: ['apps/api'],
|
|
45
|
-
registryDependencies: ['workspace', 'typescript', 'eslint'],
|
|
46
|
-
setup: requirements('Shared OpenAPI backend', ['Wrangler'], ['Cloudflare Workers deployment access'], [], ['API Worker; application routes and authorization'], ['Health contract and application-owned authorization']),
|
|
47
|
-
install: scaffoldApi,
|
|
48
|
-
},
|
|
49
|
-
d1: {
|
|
50
|
-
type: 'package',
|
|
51
|
-
description: 'Reusable Drizzle D1 database package and explicit migration tooling',
|
|
52
|
-
targets: ['packages/db', 'apps/api'],
|
|
53
|
-
selection: {},
|
|
54
|
-
registryDependencies: ['workspace', 'typescript', 'eslint', 'hono'],
|
|
55
|
-
setup: requirements('SQLite-compatible hosted persistence', ['Wrangler'], ['Cloudflare D1 access'], [], ['D1 database, DB binding and reviewed migrations'], ['Migration, constraints, transactional behavior and runtime queries']),
|
|
56
|
-
install: scaffoldDatabase,
|
|
57
|
-
configure: ({ options }) => ({
|
|
58
|
-
d1_databases: [
|
|
59
|
-
{
|
|
60
|
-
binding: 'DB',
|
|
61
|
-
database_name: resourceName(options.name, 'db'),
|
|
62
|
-
database_id: 'REPLACE_WITH_D1_ID',
|
|
63
|
-
migrations_dir: '../../packages/db/drizzle',
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
}),
|
|
67
|
-
runtime: 'worker',
|
|
68
|
-
},
|
|
69
|
-
r2: {
|
|
70
|
-
type: 'integration',
|
|
71
|
-
description: 'Server-only private R2 storage foundation',
|
|
72
|
-
targets: ['apps/api/src/private-storage.ts'],
|
|
73
|
-
registryDependencies: ['workspace', 'typescript', 'eslint', 'hono'],
|
|
74
|
-
setup: requirements('Private remote files', ['Wrangler'], ['Cloudflare R2 bucket/binding access'], [], ['Private R2 bucket and FILES binding; no public object routes'], [
|
|
75
|
-
'Keep public access disabled; implement application authorization before adding object routes',
|
|
76
|
-
]),
|
|
77
|
-
install: scaffoldPrivateStorage,
|
|
78
|
-
configure: ({ options }) => ({
|
|
79
|
-
r2_buckets: [{ binding: 'FILES', bucket_name: resourceName(options.name, 'private-files') }],
|
|
80
|
-
}),
|
|
81
|
-
runtime: 'worker',
|
|
82
|
-
},
|
|
83
|
-
styling: {
|
|
84
|
-
type: 'package',
|
|
85
|
-
description: 'Shared platform-independent styling tokens',
|
|
86
|
-
targets: ['packages/styling'],
|
|
87
|
-
registryDependencies: ['workspace', 'typescript', 'eslint'],
|
|
88
|
-
setup: requirements('Shared styling definitions', [], [], [], ['Shared light/dark tokens, web CSS and optional RNR/NativeWind source'], ['Consistency across selected interfaces; preserve platform-specific components']),
|
|
89
|
-
package: packageSource('styling', `import { light, dark, spacing } from './tokens.cjs';
|
|
90
|
-
|
|
91
|
-
export const styling = {
|
|
92
|
-
colors: {
|
|
93
|
-
foreground: 'hsl(' + light['--foreground'] + ')',
|
|
94
|
-
background: 'hsl(' + light['--background'] + ')',
|
|
95
|
-
},
|
|
96
|
-
spacing,
|
|
97
|
-
themes: { light, dark },
|
|
98
|
-
};
|
|
99
|
-
`, {}),
|
|
100
|
-
install: scaffoldStyling,
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
export const STANDARD_PRODUCTS = Object.freeze(Object.keys(PRODUCT_ITEMS));
|
|
104
|
-
const FOUNDATION_ITEMS = defineItems({
|
|
105
|
-
workspace: {
|
|
106
|
-
type: 'foundation',
|
|
107
|
-
description: 'pnpm workspace with one root lockfile, pinned Turborepo and shared checks',
|
|
108
|
-
targets: ['package.json', 'pnpm-workspace.yaml', 'turbo.json'],
|
|
109
|
-
registryDependencies: [],
|
|
110
|
-
},
|
|
111
|
-
typescript: {
|
|
112
|
-
type: 'foundation',
|
|
113
|
-
description: 'Shared TypeScript configuration',
|
|
114
|
-
targets: ['packages/typescript-config'],
|
|
115
|
-
registryDependencies: ['workspace'],
|
|
116
|
-
},
|
|
117
|
-
eslint: {
|
|
118
|
-
type: 'foundation',
|
|
119
|
-
description: 'Shared ESLint configuration',
|
|
120
|
-
targets: ['packages/eslint-config'],
|
|
121
|
-
registryDependencies: ['workspace'],
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
function freeze(value) {
|
|
125
|
-
if (value && typeof value === 'object') {
|
|
126
|
-
for (const child of Object.values(value))
|
|
127
|
-
freeze(child);
|
|
128
|
-
Object.freeze(value);
|
|
129
|
-
}
|
|
130
|
-
return value;
|
|
131
|
-
}
|
|
132
|
-
const DEFINITIONS = freeze({ ...FOUNDATION_ITEMS, ...PRODUCT_ITEMS });
|
|
133
|
-
function describe(definition) {
|
|
134
|
-
const { install: _install, configure: _configure, ...metadata } = definition;
|
|
135
|
-
return structuredClone(metadata);
|
|
136
|
-
}
|
|
137
|
-
export function getStackDefinition(name) {
|
|
138
|
-
if (!Object.hasOwn(DEFINITIONS, name))
|
|
139
|
-
throw new Error(`Unknown stack registry item: ${name}.`);
|
|
140
|
-
return DEFINITIONS[name];
|
|
141
|
-
}
|
|
142
|
-
export function getStackItem(name) {
|
|
143
|
-
return describe(getStackDefinition(name));
|
|
144
|
-
}
|
|
145
|
-
export const STACK_ITEMS = freeze(Object.fromEntries(Object.keys(DEFINITIONS).map((name) => [name, getStackItem(name)])));
|
|
146
|
-
export const STACK_REGISTRY = freeze({
|
|
147
|
-
schemaVersion: 1,
|
|
148
|
-
name: 'anhedral',
|
|
149
|
-
cliVersion: GENERATOR_VERSION,
|
|
150
|
-
items: Object.values(STACK_ITEMS),
|
|
151
|
-
});
|
|
152
|
-
export function installStackItem(item, context) {
|
|
153
|
-
const definition = getStackDefinition(item.name);
|
|
154
|
-
if (item.package) {
|
|
155
|
-
const recipe = item.package;
|
|
156
|
-
sharedPackage(context.root, recipe.name, recipe.source, recipe.dependencies);
|
|
157
|
-
}
|
|
158
|
-
return definition.install?.(context);
|
|
159
|
-
}
|
|
160
|
-
/** Validate authored definitions during build, before shipping either catalog. */
|
|
161
|
-
export function validateStackCatalog() {
|
|
162
|
-
dependencyOrder(new Map(Object.entries(DEFINITIONS).map(([name, item]) => [name, item.registryDependencies])), 'Authored stack registry');
|
|
163
|
-
for (const [name, definition] of Object.entries(DEFINITIONS)) {
|
|
164
|
-
if (definition.name !== name)
|
|
165
|
-
throw new Error(`Registry identity mismatch: ${name}.`);
|
|
166
|
-
for (const dependency of [
|
|
167
|
-
...definition.registryDependencies,
|
|
168
|
-
...(definition.selection.conflicts ?? []),
|
|
169
|
-
...(definition.selection.requiresAny ?? []),
|
|
170
|
-
...(definition.selection.requiresAll ?? []),
|
|
171
|
-
])
|
|
172
|
-
getStackDefinition(dependency);
|
|
173
|
-
if (definition.type !== 'foundation' &&
|
|
174
|
-
(!definition.setup ||
|
|
175
|
-
(definition.installer === 'recipe' && !definition.install && !definition.package)))
|
|
176
|
-
throw new Error(`Incomplete registry recipe: ${name}.`);
|
|
177
|
-
if (definition.installer === 'configuration' && !definition.configure)
|
|
178
|
-
throw new Error(`Missing registry configuration: ${name}.`);
|
|
179
|
-
for (const target of definition.targets) {
|
|
180
|
-
if (!target ||
|
|
181
|
-
target.startsWith('/') ||
|
|
182
|
-
target.includes('\\') ||
|
|
183
|
-
target.split('/').some((part) => part === '..'))
|
|
184
|
-
throw new Error(`Invalid registry target: ${name}.`);
|
|
185
|
-
}
|
|
186
|
-
if (definition.environment.some((key) => !/^[A-Z][A-Z0-9_]*$/.test(key)))
|
|
187
|
-
throw new Error(`Invalid registry environment key: ${name}.`);
|
|
188
|
-
}
|
|
189
|
-
}
|
package/dist/standard.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { parseStandardOptions } from './registry/options.js';
|
|
2
|
-
import { STANDARD_USAGE } from './registry/usage.js';
|
|
3
|
-
import type { StandardOptions, StandardRunner } from './registry/types.js';
|
|
4
|
-
import { type OutputOptions } from './cli-output.js';
|
|
5
|
-
export { parseStandardOptions, STANDARD_USAGE };
|
|
6
|
-
export { STANDARD_PRODUCTS } from './stack-registry.js';
|
|
7
|
-
export type { StandardOptions, StandardProduct, StandardRunner } from './registry/types.js';
|
|
8
|
-
export declare function scaffoldStandardProject(options: StandardOptions, run?: StandardRunner, output?: OutputOptions): Promise<void>;
|
package/dist/standard.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { writeProjectSection } from './project-config.js';
|
|
2
|
-
import { configureDependencyPatches } from './dependency-patches.js';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { existsSync, lstatSync, mkdirSync, readdirSync, realpathSync, rmdirSync } from 'node:fs';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { spawnSync } from 'node:child_process';
|
|
7
|
-
import { execFile } from './util.js';
|
|
8
|
-
import { runStagedTransaction } from './transaction.js';
|
|
9
|
-
import { createSetupPlan } from './capabilities.js';
|
|
10
|
-
import { bootstrapWorkspace, assertWorkspaceRuntime } from './scaffold/bootstrap.js';
|
|
11
|
-
import { composeStack } from './scaffold/compose.js';
|
|
12
|
-
import { parseStandardOptions } from './registry/options.js';
|
|
13
|
-
import { STANDARD_USAGE } from './registry/usage.js';
|
|
14
|
-
import { printProgress, printResult } from './cli-output.js';
|
|
15
|
-
export { parseStandardOptions, STANDARD_USAGE };
|
|
16
|
-
export { STANDARD_PRODUCTS } from './stack-registry.js';
|
|
17
|
-
export async function scaffoldStandardProject(options, run = execFile, output = {}) {
|
|
18
|
-
const plan = createSetupPlan(options);
|
|
19
|
-
const display = { ...output, json: options.json };
|
|
20
|
-
if (options.dryRun) {
|
|
21
|
-
printResult('init', plan, { ...output, json: options.json });
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
assertWorkspaceRuntime(run);
|
|
25
|
-
const root = options.root;
|
|
26
|
-
const previousQuiet = process.env.ANHEDRAL_QUIET;
|
|
27
|
-
if (options.json)
|
|
28
|
-
process.env.ANHEDRAL_QUIET = '1';
|
|
29
|
-
let created = false;
|
|
30
|
-
try {
|
|
31
|
-
if (!existsSync(root)) {
|
|
32
|
-
mkdirSync(root, { recursive: true });
|
|
33
|
-
created = true;
|
|
34
|
-
}
|
|
35
|
-
if (lstatSync(root).isSymbolicLink() || !lstatSync(root).isDirectory())
|
|
36
|
-
throw new Error('Destination must be a real directory.');
|
|
37
|
-
const unexpected = readdirSync(root).filter((name) => !['.git', '.gitignore'].includes(name));
|
|
38
|
-
if (unexpected.length)
|
|
39
|
-
throw new Error(`Destination must be empty (apart from .git/.gitignore): ${unexpected[0]}`);
|
|
40
|
-
const commitPaths = [];
|
|
41
|
-
await runStagedTransaction(root, {
|
|
42
|
-
commitPaths,
|
|
43
|
-
seedPaths: existsSync(path.join(root, '.gitignore')) ? ['.gitignore'] : [],
|
|
44
|
-
prepare: () => {
|
|
45
|
-
const entries = readdirSync(root).filter((name) => !['.git', '.gitignore', '.anhedral.lock', '.anhedral-txn'].includes(name));
|
|
46
|
-
if (entries.length)
|
|
47
|
-
throw new Error('Destination changed before generation.');
|
|
48
|
-
},
|
|
49
|
-
build: async (stageRoot) => {
|
|
50
|
-
printProgress('Creating the Next.js and Anhedral UI workspace…', display);
|
|
51
|
-
bootstrapWorkspace(stageRoot, options.name, run);
|
|
52
|
-
printProgress('Composing the selected stack…', display);
|
|
53
|
-
await composeStack(stageRoot, options, plan.registry);
|
|
54
|
-
writeProjectSection(stageRoot, 'identity', {
|
|
55
|
-
schemaVersion: 1,
|
|
56
|
-
id: randomUUID(),
|
|
57
|
-
});
|
|
58
|
-
if (!options.skipInstall) {
|
|
59
|
-
printProgress('Resolving pinned dependencies…', display);
|
|
60
|
-
run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], stageRoot);
|
|
61
|
-
if (configureDependencyPatches(stageRoot))
|
|
62
|
-
run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], stageRoot);
|
|
63
|
-
}
|
|
64
|
-
commitPaths.push(...readdirSync(stageRoot).filter((name) => name !== 'node_modules'));
|
|
65
|
-
},
|
|
66
|
-
afterCommit: () => {
|
|
67
|
-
if (options.initializeGit) {
|
|
68
|
-
const checkout = spawnSync('git', ['rev-parse', '--show-toplevel'], {
|
|
69
|
-
cwd: root,
|
|
70
|
-
encoding: 'utf8',
|
|
71
|
-
});
|
|
72
|
-
if (checkout.status !== 0 || realpathSync(checkout.stdout.trim()) !== realpathSync(root))
|
|
73
|
-
run('git', ['init'], root);
|
|
74
|
-
}
|
|
75
|
-
if (!options.skipInstall) {
|
|
76
|
-
printProgress('Installing workspace dependencies…', display);
|
|
77
|
-
run('pnpm', ['install', '--frozen-lockfile'], root);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
printResult('init', {
|
|
82
|
-
...plan,
|
|
83
|
-
generated: true,
|
|
84
|
-
}, { ...output, json: options.json });
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
if (created && existsSync(root) && readdirSync(root).length === 0)
|
|
88
|
-
rmdirSync(root);
|
|
89
|
-
if (previousQuiet === undefined)
|
|
90
|
-
delete process.env.ANHEDRAL_QUIET;
|
|
91
|
-
else
|
|
92
|
-
process.env.ANHEDRAL_QUIET = previousQuiet;
|
|
93
|
-
}
|
|
94
|
-
}
|