anhedral 0.11.2 → 0.13.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 +171 -18
- package/dist/bin.js +48 -493
- package/dist/capabilities.d.ts +3 -3
- package/dist/capability-contract.js +16 -1
- package/dist/cli-arguments.d.ts +8 -0
- package/dist/cli-arguments.js +32 -0
- package/dist/cli-commands.d.ts +3 -0
- package/dist/cli-commands.js +114 -0
- package/dist/cli-delivery.d.ts +3 -0
- package/dist/cli-delivery.js +172 -0
- package/dist/cli-output.js +231 -205
- package/dist/command-schema.js +8 -2
- package/dist/command.js +9 -11
- package/dist/delivery-evidence.d.ts +62 -0
- package/dist/delivery-evidence.js +186 -0
- package/dist/delivery.d.ts +3 -40
- package/dist/delivery.js +7 -182
- package/dist/dependencies.d.ts +7 -1
- package/dist/dependencies.js +15 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mobile-delivery.d.ts +21 -44
- package/dist/mobile-delivery.js +127 -80
- package/dist/platforms/mobile.d.ts +1 -1
- package/dist/platforms/mobile.js +44 -3
- package/dist/project-state.js +4 -1
- package/dist/provider-auth.js +9 -3
- package/dist/providers/adapters.js +9 -3
- package/dist/providers/runtime.js +11 -0
- package/dist/readiness.js +4 -2
- package/dist/registry/add.js +40 -7
- package/dist/registry/options.js +12 -0
- package/dist/registry/presets.d.ts +4 -0
- package/dist/registry/presets.js +41 -0
- package/dist/registry/resolve.d.ts +3 -1
- package/dist/registry/resolve.js +40 -14
- package/dist/registry/types.d.ts +1 -0
- package/dist/registry/usage.js +1 -1
- package/dist/runtime-policy.js +4 -1
- package/dist/scaffold/api.js +10 -2
- package/dist/scaffold/auth.d.ts +1 -1
- package/dist/scaffold/auth.js +22 -6
- package/dist/scaffold/backend.d.ts +6 -0
- package/dist/scaffold/backend.js +224 -0
- package/dist/scaffold/billing-config.d.ts +1 -0
- package/dist/scaffold/billing-config.js +73 -0
- package/dist/scaffold/billing-contracts.d.ts +2 -0
- package/dist/scaffold/billing-contracts.js +48 -0
- package/dist/scaffold/billing-providers.d.ts +1 -0
- package/dist/scaffold/billing-providers.js +249 -0
- package/dist/scaffold/billing-schema.d.ts +1 -0
- package/dist/scaffold/billing-schema.js +34 -0
- package/dist/scaffold/billing-security.d.ts +1 -0
- package/dist/scaffold/billing-security.js +46 -0
- package/dist/scaffold/billing-server.d.ts +1 -0
- package/dist/scaffold/billing-server.js +139 -0
- package/dist/scaffold/billing-store.d.ts +1 -0
- package/dist/scaffold/billing-store.js +72 -0
- package/dist/scaffold/billing.d.ts +2 -0
- package/dist/scaffold/billing.js +216 -0
- package/dist/scaffold/cloudflare-services.d.ts +8 -0
- package/dist/scaffold/cloudflare-services.js +198 -0
- package/dist/scaffold/compose.js +2 -0
- package/dist/scaffold/database.js +19 -2
- package/dist/scaffold/documentation.js +11 -6
- package/dist/scaffold/expo-auth.d.ts +3 -0
- package/dist/scaffold/expo-auth.js +192 -0
- package/dist/scaffold/expo-billing.d.ts +3 -0
- package/dist/scaffold/expo-billing.js +292 -0
- package/dist/scaffold/expo-runtime.d.ts +3 -0
- package/dist/scaffold/expo-runtime.js +134 -0
- package/dist/scaffold/integrations.d.ts +2 -1
- package/dist/scaffold/integrations.js +7 -2
- package/dist/scaffold/stream.d.ts +2 -0
- package/dist/scaffold/stream.js +114 -0
- package/dist/scaffold/void.js +13 -5
- package/dist/scaffold/web.js +2 -0
- package/dist/scaffold/workspace.js +6 -1
- package/dist/service-readers.js +1 -1
- package/dist/services-command.js +8 -6
- package/dist/ship.d.ts +15 -15
- package/dist/ship.js +3 -1
- package/dist/stack-registry.d.ts +13 -2
- package/dist/stack-registry.js +152 -16
- package/dist/transaction-lock.d.ts +15 -0
- package/dist/transaction-lock.js +227 -0
- package/dist/transaction.js +2 -208
- package/dist/vercel-project.d.ts +101 -0
- package/dist/vercel-project.js +305 -0
- package/dist/vercel.d.ts +3 -36
- package/dist/vercel.js +3 -300
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +122 -0
- package/docs/software-factory.md +402 -7
- package/docs/stack-standard.md +226 -49
- package/docs/verification.md +557 -0
- package/package.json +7 -7
- package/docs/cli-design.md +0 -67
- package/docs/plugin-ui.md +0 -102
- package/docs/provider-configuration.md +0 -116
- package/docs/void-verification.md +0 -185
package/dist/vercel.js
CHANGED
|
@@ -1,206 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cli, readWeb, env, context, api, paginated, validateProvider, matchesRepository, inspect, history, source, https, validBranch, deployment, validateRelease, committedManifest, remoteBranch, } from './vercel-project.js';
|
|
2
|
+
export { registerVercelApplication } from './vercel-project.js';
|
|
3
|
+
import { hasProjectSection, writeProjectSection } from './project-config.js';
|
|
2
4
|
import { githubRepository } from './repository.js';
|
|
3
|
-
import { providerProjectName } from './render.js';
|
|
4
5
|
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
|
|
5
6
|
import { randomUUID } from 'node:crypto';
|
|
6
7
|
import path from 'node:path';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
8
|
import { atomicJson, defaultRunner, withApplicationLock, } from './project-state.js';
|
|
9
|
-
// Keep provider commands reproducible independently of globally installed tooling.
|
|
10
|
-
const cli = ['dlx', 'vercel@62.7.0'];
|
|
11
|
-
const manifest = 'anhedral.json';
|
|
12
|
-
function webDirectory(root) {
|
|
13
|
-
root = realpathSync(root);
|
|
14
|
-
const directory = realpathSync(path.join(root, 'apps/web'));
|
|
15
|
-
if (!directory.startsWith(root + path.sep))
|
|
16
|
-
throw new Error('Web directory escapes the application.');
|
|
17
|
-
return directory;
|
|
18
|
-
}
|
|
19
|
-
export function registerVercelApplication(root) {
|
|
20
|
-
root = realpathSync(root);
|
|
21
|
-
webDirectory(root);
|
|
22
|
-
if (hasProjectSection(root, 'vercel'))
|
|
23
|
-
return readWeb(root);
|
|
24
|
-
const setup = readProjectSection(root, 'setup');
|
|
25
|
-
if (setup.hosting !== 'vercel')
|
|
26
|
-
throw new Error('This application did not select Vercel web hosting.');
|
|
27
|
-
const packageName = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')).name;
|
|
28
|
-
if (typeof packageName !== 'string' || !packageName)
|
|
29
|
-
throw new Error('A package name is required to register the Vercel project.');
|
|
30
|
-
const name = providerProjectName(packageName);
|
|
31
|
-
const project = {
|
|
32
|
-
schemaVersion: 1,
|
|
33
|
-
id: randomUUID(),
|
|
34
|
-
name,
|
|
35
|
-
ownership: 'customer',
|
|
36
|
-
provider: 'vercel',
|
|
37
|
-
directory: 'apps/web',
|
|
38
|
-
teamId: null,
|
|
39
|
-
projectId: null,
|
|
40
|
-
scope: null,
|
|
41
|
-
audience: 'unconfigured',
|
|
42
|
-
use: 'unconfigured',
|
|
43
|
-
};
|
|
44
|
-
const ignore = path.join(root, '.gitignore');
|
|
45
|
-
let source = existsSync(ignore) ? readFileSync(ignore, 'utf8') : '';
|
|
46
|
-
for (const entry of ['.anhedral/', '.vercel/'])
|
|
47
|
-
if (!source.split(/\r?\n/).includes(entry))
|
|
48
|
-
source += (source && !source.endsWith('\n') ? '\n' : '') + entry + '\n';
|
|
49
|
-
writeFileSync(ignore, source);
|
|
50
|
-
writeProjectSection(root, 'vercel', project);
|
|
51
|
-
return project;
|
|
52
|
-
}
|
|
53
|
-
function readWeb(root) {
|
|
54
|
-
webDirectory(root);
|
|
55
|
-
const project = readProjectSection(root, 'vercel');
|
|
56
|
-
if (project.schemaVersion !== 1 ||
|
|
57
|
-
!/^[a-f0-9-]{36}$/.test(project.id) ||
|
|
58
|
-
project.provider !== 'vercel' ||
|
|
59
|
-
project.ownership !== 'customer' ||
|
|
60
|
-
project.directory !== 'apps/web' ||
|
|
61
|
-
!/^[a-z0-9][a-z0-9-]{0,62}$/.test(project.name) ||
|
|
62
|
-
!['unconfigured', 'public', 'private'].includes(project.audience) ||
|
|
63
|
-
!['unconfigured', 'personal', 'commercial'].includes(project.use) ||
|
|
64
|
-
!(project.teamId === null || /^team_[a-zA-Z0-9]+$/.test(project.teamId)) ||
|
|
65
|
-
!(project.projectId === null || /^prj_[a-zA-Z0-9]+$/.test(project.projectId)) ||
|
|
66
|
-
!(project.scope === null || /^[a-zA-Z0-9_-]+$/.test(project.scope)) ||
|
|
67
|
-
(project.repository !== undefined &&
|
|
68
|
-
(!Number.isSafeInteger(project.repository?.repoId) ||
|
|
69
|
-
project.repository.repoId <= 0 ||
|
|
70
|
-
!/^[a-zA-Z0-9-]+\/[a-zA-Z0-9_.-]+$/.test(project.repository.nameWithOwner) ||
|
|
71
|
-
(project.repository.productionBranch !== undefined &&
|
|
72
|
-
!validBranch(project.repository.productionBranch)))))
|
|
73
|
-
throw new Error('Invalid Vercel application manifest.');
|
|
74
|
-
return project;
|
|
75
|
-
}
|
|
76
|
-
function env(project) {
|
|
77
|
-
if (project &&
|
|
78
|
-
((process.env.VERCEL_PROJECT_ID && process.env.VERCEL_PROJECT_ID !== project.projectId) ||
|
|
79
|
-
(process.env.VERCEL_ORG_ID && process.env.VERCEL_ORG_ID !== project.teamId)))
|
|
80
|
-
throw new Error('Vercel environment selects a different project/account.');
|
|
81
|
-
return {
|
|
82
|
-
...process.env,
|
|
83
|
-
CI: '1',
|
|
84
|
-
NO_COLOR: '1',
|
|
85
|
-
...(project?.projectId
|
|
86
|
-
? { VERCEL_PROJECT_ID: project.projectId, VERCEL_ORG_ID: project.teamId }
|
|
87
|
-
: {}),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function context(root, project) {
|
|
91
|
-
const file = path.join(root, '.vercel/project.json');
|
|
92
|
-
if (existsSync(path.join(root, '.vercel/repo.json')))
|
|
93
|
-
throw new Error('Reconcile existing Vercel repository links explicitly before using automatic delivery.');
|
|
94
|
-
if (!existsSync(file))
|
|
95
|
-
throw new Error('Run anhedral connect to link the selected Vercel project.');
|
|
96
|
-
if (realpathSync(path.dirname(file)) !== path.join(realpathSync(root), '.vercel'))
|
|
97
|
-
throw new Error('Vercel link directory must not be a symbolic link.');
|
|
98
|
-
const link = JSON.parse(readFileSync(file, 'utf8'));
|
|
99
|
-
if (link.orgId !== project.teamId || link.projectId !== project.projectId)
|
|
100
|
-
throw new Error('Local Vercel link differs from the recorded customer account/project.');
|
|
101
|
-
}
|
|
102
|
-
async function api(root, run, endpoint, scope, body, method = 'POST') {
|
|
103
|
-
if (!/^\/v\d+\//.test(endpoint) || endpoint.includes('..') || endpoint.includes('#'))
|
|
104
|
-
throw new Error('Invalid Vercel API path.');
|
|
105
|
-
const temporary = path.join(tmpdir(), `anhedral-vercel-${randomUUID()}.json`);
|
|
106
|
-
const args = [
|
|
107
|
-
...cli,
|
|
108
|
-
'api',
|
|
109
|
-
endpoint,
|
|
110
|
-
'--raw',
|
|
111
|
-
'--non-interactive',
|
|
112
|
-
...(scope ? ['--scope', scope] : []),
|
|
113
|
-
];
|
|
114
|
-
try {
|
|
115
|
-
if (body) {
|
|
116
|
-
writeFileSync(temporary, JSON.stringify(body), { mode: 0o600, flag: 'wx' });
|
|
117
|
-
args.push('-X', method, '--input', temporary);
|
|
118
|
-
}
|
|
119
|
-
const output = await run('pnpm', args, root, env());
|
|
120
|
-
let value;
|
|
121
|
-
try {
|
|
122
|
-
value = JSON.parse(output);
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
throw new Error('Vercel did not return valid provider JSON.');
|
|
126
|
-
}
|
|
127
|
-
if (!value || typeof value !== 'object' || value.error || value.status === 'error')
|
|
128
|
-
throw new Error('Vercel rejected the request; verify login, scope and project permissions.');
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
finally {
|
|
132
|
-
rmSync(temporary, { force: true });
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
async function paginated(root, run, endpoint, key, scope) {
|
|
136
|
-
const result = [];
|
|
137
|
-
let cursor;
|
|
138
|
-
for (let page = 0; page < 1000; page++) {
|
|
139
|
-
const data = await api(root, run, `${endpoint}${endpoint.includes('?') ? '&' : '?'}limit=100${cursor ? `&until=${cursor}` : ''}`, scope);
|
|
140
|
-
if (!Array.isArray(data[key]))
|
|
141
|
-
throw new Error('Invalid Vercel provider listing.');
|
|
142
|
-
result.push(...data[key]);
|
|
143
|
-
if (data[key].length === 0)
|
|
144
|
-
return result;
|
|
145
|
-
const next = data.pagination?.next;
|
|
146
|
-
if (next === null || next === undefined)
|
|
147
|
-
return result;
|
|
148
|
-
if (typeof next !== 'number' || !Number.isFinite(next) || next === cursor)
|
|
149
|
-
throw new Error('Invalid Vercel pagination cursor.');
|
|
150
|
-
cursor = next;
|
|
151
|
-
}
|
|
152
|
-
throw new Error('Vercel listing exceeded pagination bounds.');
|
|
153
|
-
}
|
|
154
|
-
function protection(project, provider) {
|
|
155
|
-
const all = provider.ssoProtection?.deploymentType === 'all';
|
|
156
|
-
if (project.audience === 'private' && !all)
|
|
157
|
-
throw new Error('Private Vercel hosting requires verified protection for all deployments, including production. Configure Vercel Authentication for every deployment in the selected project; protection was not disabled or purchased.');
|
|
158
|
-
if (project.audience === 'public' && (all || provider.passwordProtection))
|
|
159
|
-
throw new Error('Provider production protection differs from the requested public audience. Reconcile it explicitly.');
|
|
160
|
-
}
|
|
161
|
-
function validateProvider(project, value) {
|
|
162
|
-
if (value.id !== project.projectId ||
|
|
163
|
-
value.accountId !== project.teamId ||
|
|
164
|
-
value.name !== project.name ||
|
|
165
|
-
value.framework !== 'nextjs' ||
|
|
166
|
-
value.rootDirectory !== project.directory ||
|
|
167
|
-
value.sourceFilesOutsideRootDirectory !== true)
|
|
168
|
-
throw new Error('Vercel provider account, framework or monorepo root differs from the manifest.');
|
|
169
|
-
protection(project, value);
|
|
170
|
-
if (project.repository &&
|
|
171
|
-
(!matchesRepository(value.link, project.repository) ||
|
|
172
|
-
(project.repository.productionBranch !== undefined &&
|
|
173
|
-
value.link?.productionBranch !== project.repository.productionBranch)))
|
|
174
|
-
throw new Error('Vercel Git repository differs from the recorded source repository. Reconcile it explicitly.');
|
|
175
|
-
}
|
|
176
|
-
function matchesRepository(link, repository) {
|
|
177
|
-
const [owner, name] = repository.nameWithOwner.split('/');
|
|
178
|
-
return (link?.type === 'github' &&
|
|
179
|
-
link.repoId === repository.repoId &&
|
|
180
|
-
link.org?.toLowerCase() === owner.toLowerCase() &&
|
|
181
|
-
link.repo?.toLowerCase() === name.toLowerCase());
|
|
182
|
-
}
|
|
183
|
-
async function inspect(root, project, run) {
|
|
184
|
-
context(root, project);
|
|
185
|
-
env(project);
|
|
186
|
-
const team = await api(root, run, `/v2/teams/${project.teamId}`, project.teamId);
|
|
187
|
-
if (team.id !== project.teamId ||
|
|
188
|
-
!['hobby', 'pro', 'enterprise'].includes(team.billing?.plan) ||
|
|
189
|
-
(project.use === 'commercial' && team.billing.plan === 'hobby'))
|
|
190
|
-
throw new Error('Selected Vercel account plan no longer supports the recorded application use.');
|
|
191
|
-
const linked = JSON.parse(await run('pnpm', [...cli, 'project', 'inspect', '--json', '--non-interactive', '--scope', project.teamId], root, env(project)));
|
|
192
|
-
if (linked.id !== project.projectId || linked.owner?.slug !== project.scope)
|
|
193
|
-
throw new Error('Vercel CLI resolved a different project/account.');
|
|
194
|
-
const provider = await api(root, run, `/v9/projects/${project.projectId}?teamId=${project.teamId}`, project.teamId);
|
|
195
|
-
validateProvider(project, provider);
|
|
196
|
-
if (project.repository) {
|
|
197
|
-
const repository = await githubRepository(root, run);
|
|
198
|
-
if (repository.repoId !== project.repository.repoId ||
|
|
199
|
-
repository.nameWithOwner.toLowerCase() !== project.repository.nameWithOwner.toLowerCase())
|
|
200
|
-
throw new Error('GitHub origin differs from the recorded source repository. Reconcile it explicitly.');
|
|
201
|
-
}
|
|
202
|
-
return provider;
|
|
203
|
-
}
|
|
204
9
|
export async function connectVercelApplication(root, options, run = defaultRunner) {
|
|
205
10
|
root = realpathSync(root);
|
|
206
11
|
return withApplicationLock(root, async () => {
|
|
@@ -328,108 +133,6 @@ export async function connectVercelApplication(root, options, run = defaultRunne
|
|
|
328
133
|
return { project: connected, plan, planActivated: false };
|
|
329
134
|
});
|
|
330
135
|
}
|
|
331
|
-
function history(root, project) {
|
|
332
|
-
const file = path.join(root, '.anhedral/web-releases.json');
|
|
333
|
-
const value = existsSync(file)
|
|
334
|
-
? JSON.parse(readFileSync(file, 'utf8'))
|
|
335
|
-
: { schemaVersion: 1, projectId: project.id, releases: [] };
|
|
336
|
-
if (value.schemaVersion !== 1 || value.projectId !== project.id || !Array.isArray(value.releases))
|
|
337
|
-
throw new Error('Vercel release history differs from project identity.');
|
|
338
|
-
return value;
|
|
339
|
-
}
|
|
340
|
-
async function source(root, run) {
|
|
341
|
-
if (realpathSync((await run('git', ['rev-parse', '--show-toplevel'], root, env())).trim()) !==
|
|
342
|
-
root ||
|
|
343
|
-
(await run('git', ['status', '--porcelain'], root, env())).trim())
|
|
344
|
-
throw new Error('Commit the application and manifest in their own repository before delivery/verification.');
|
|
345
|
-
const commit = (await run('git', ['rev-parse', 'HEAD'], root, env())).trim();
|
|
346
|
-
if (!/^[a-f0-9]{40,64}$/.test(commit))
|
|
347
|
-
throw new Error('Invalid source commit.');
|
|
348
|
-
return commit;
|
|
349
|
-
}
|
|
350
|
-
function https(value) {
|
|
351
|
-
const url = new URL(value.startsWith('https://') ? value : `https://${value}`);
|
|
352
|
-
if (url.protocol !== 'https:' ||
|
|
353
|
-
url.username ||
|
|
354
|
-
url.password ||
|
|
355
|
-
url.port ||
|
|
356
|
-
url.search ||
|
|
357
|
-
url.hash ||
|
|
358
|
-
url.pathname !== '/')
|
|
359
|
-
throw new Error('Invalid provider deployment URL.');
|
|
360
|
-
return url.origin;
|
|
361
|
-
}
|
|
362
|
-
function validBranch(branch) {
|
|
363
|
-
return (typeof branch === 'string' &&
|
|
364
|
-
branch.length > 0 &&
|
|
365
|
-
branch.length < 256 &&
|
|
366
|
-
!branch.startsWith('-') &&
|
|
367
|
-
!branch.startsWith('/') &&
|
|
368
|
-
!branch.endsWith('/') &&
|
|
369
|
-
!branch.endsWith('.') &&
|
|
370
|
-
!branch.includes('..') &&
|
|
371
|
-
!branch.includes('@{') &&
|
|
372
|
-
!/[\x00-\x20\x7f~^:?*\\[\]]/.test(branch) &&
|
|
373
|
-
!branch.split('/').some((part) => !part || part.startsWith('.') || part.endsWith('.lock')));
|
|
374
|
-
}
|
|
375
|
-
function deployment(project, value, commit, provenance = 'cli', branch) {
|
|
376
|
-
if (!/^[a-f0-9]{40,64}$/.test(commit) ||
|
|
377
|
-
!/^dpl_[a-zA-Z0-9]+$/.test(value.id) ||
|
|
378
|
-
value.projectId !== project.projectId ||
|
|
379
|
-
value.ownerId !== project.teamId ||
|
|
380
|
-
value.readyState !== 'READY' ||
|
|
381
|
-
value.target !== 'production')
|
|
382
|
-
throw new Error('Vercel deployment is not ready or differs from account/project/source provenance.');
|
|
383
|
-
if (provenance === 'git') {
|
|
384
|
-
const repository = project.repository;
|
|
385
|
-
const git = value.gitSource;
|
|
386
|
-
const identity = git?.repoId !== undefined && String(git.repoId) === String(repository?.repoId);
|
|
387
|
-
if (!repository ||
|
|
388
|
-
!branch ||
|
|
389
|
-
!validBranch(branch) ||
|
|
390
|
-
git?.type !== 'github' ||
|
|
391
|
-
!identity ||
|
|
392
|
-
git.sha !== commit ||
|
|
393
|
-
git.ref !== branch ||
|
|
394
|
-
git.prId != null)
|
|
395
|
-
throw new Error('Git deployment differs from the recorded repository, production branch or source commit.');
|
|
396
|
-
}
|
|
397
|
-
else if (value.meta?.anhedralProject !== project.id || value.meta?.anhedralCommit !== commit)
|
|
398
|
-
throw new Error('Vercel deployment differs from recorded CLI provenance.');
|
|
399
|
-
https(value.url);
|
|
400
|
-
}
|
|
401
|
-
function validateRelease(project, value, release) {
|
|
402
|
-
deployment(project, value, release.commit, release.provenance ?? 'cli', release.branch);
|
|
403
|
-
if (value.id !== release.deploymentId ||
|
|
404
|
-
!release.deploymentUrl ||
|
|
405
|
-
https(value.url) !== https(release.deploymentUrl))
|
|
406
|
-
throw new Error('Recorded deployment identity or URL differs from provider evidence.');
|
|
407
|
-
}
|
|
408
|
-
async function committedManifest(root, project, run) {
|
|
409
|
-
const commit = await source(root, run);
|
|
410
|
-
let recorded;
|
|
411
|
-
try {
|
|
412
|
-
const configuration = JSON.parse(await run('git', ['show', `HEAD:${manifest}`], root, env(project)));
|
|
413
|
-
if (configuration.schemaVersion !== 1)
|
|
414
|
-
throw new Error('Invalid committed project configuration.');
|
|
415
|
-
recorded = configuration.vercel;
|
|
416
|
-
}
|
|
417
|
-
catch {
|
|
418
|
-
throw new Error('Commit the Vercel identity manifest before adoption or recovery.');
|
|
419
|
-
}
|
|
420
|
-
if (JSON.stringify(recorded) !== JSON.stringify(project))
|
|
421
|
-
throw new Error('Committed Vercel identity differs from the application manifest.');
|
|
422
|
-
return commit;
|
|
423
|
-
}
|
|
424
|
-
async function remoteBranch(root, branch, commit, run) {
|
|
425
|
-
if (!validBranch(branch))
|
|
426
|
-
throw new Error('Record an explicit valid production branch before Git adoption.');
|
|
427
|
-
const ref = `refs/heads/${branch}`;
|
|
428
|
-
const output = (await run('git', ['ls-remote', '--heads', 'origin', ref], root, env())).trim();
|
|
429
|
-
const rows = output.split(/\r?\n/).filter(Boolean);
|
|
430
|
-
if (rows.length !== 1 || rows[0] !== `${commit}\t${ref}`)
|
|
431
|
-
throw new Error('Remote production branch does not match the exact clean source commit.');
|
|
432
|
-
}
|
|
433
136
|
async function adoptActive(root, project, run, operation) {
|
|
434
137
|
const commit = await committedManifest(root, project, run);
|
|
435
138
|
const original = JSON.stringify(project);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const GENERATOR_VERSION = "0.
|
|
1
|
+
export declare const GENERATOR_VERSION = "0.13.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const GENERATOR_VERSION = '0.
|
|
1
|
+
export const GENERATOR_VERSION = '0.13.0';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Anhedral progressive stack
|
|
2
|
+
|
|
3
|
+
**Start minimal. Add capabilities for real needs. Select `--preset full-product`
|
|
4
|
+
when the complete foundation is appropriate.**
|
|
5
|
+
|
|
6
|
+
```mermaid
|
|
7
|
+
%%{init: {"flowchart": {"curve": "linear", "nodeSpacing": 35, "rankSpacing": 50, "padding": 18}}}%%
|
|
8
|
+
flowchart TB
|
|
9
|
+
subgraph minimal["1 · Minimal default"]
|
|
10
|
+
client["Expo · web / iOS / Android<br/>React Native Reusables · shadcn conventions<br/>NativeWind · shared tokens"]
|
|
11
|
+
web["Cloudflare static web Worker"]
|
|
12
|
+
client -->|"web export"| web
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
subgraph optional["2 · Optional capabilities · choose independently"]
|
|
16
|
+
backend["Hono API · Cloudflare Workers<br/>Public contracts · authorization"]
|
|
17
|
+
core["Data, accounts and files<br/>Drizzle / D1 · Better Auth · private R2 · KV"]
|
|
18
|
+
compute["AI, analytics and processing<br/>Workers AI · Analytics Engine · Basin<br/>Images · Queues · Cron · Workflows"]
|
|
19
|
+
media["Realtime and video<br/>Durable Object rooms · RealtimeKit<br/>Stream live / uploaded video"]
|
|
20
|
+
payments["Payments<br/>Stripe web · RevenueCat native<br/>Shared entitlements enforced by Hono"]
|
|
21
|
+
clients["Additional client<br/>WXT browser side panel"]
|
|
22
|
+
operations["External operations<br/>Resend email · Sentry monitoring"]
|
|
23
|
+
backend -.-> core
|
|
24
|
+
backend -.-> compute
|
|
25
|
+
backend -.-> media
|
|
26
|
+
backend -.-> payments
|
|
27
|
+
backend -.-> operations
|
|
28
|
+
clients -.->|"when a backend is needed"| backend
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
web ~~~ clients
|
|
32
|
+
web -.->|"add API service binding"| backend
|
|
33
|
+
client -.->|"native HTTPS when selected"| backend
|
|
34
|
+
|
|
35
|
+
subgraph full["3 · Full-product preset · selection summary"]
|
|
36
|
+
preset["Minimal app + all capabilities above<br/>22 selected products · no provider activation"]
|
|
37
|
+
end
|
|
38
|
+
core ~~~ preset
|
|
39
|
+
compute ~~~ preset
|
|
40
|
+
media ~~~ preset
|
|
41
|
+
payments ~~~ preset
|
|
42
|
+
operations ~~~ preset
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Solid lines show the minimal delivery path. Dashed lines summarize optional
|
|
46
|
+
integrations, not every network request or deployment. The full-product group is a
|
|
47
|
+
selection summary, not another runtime. Grouped capabilities remain separate
|
|
48
|
+
services; their exact connections depend on the implemented product.
|
|
49
|
+
|
|
50
|
+
## Minimal default
|
|
51
|
+
|
|
52
|
+
| Part | Default |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| Client | Expo + React Native + Expo Router |
|
|
55
|
+
| Components | React Native Reusables with **shadcn conventions** |
|
|
56
|
+
| Styling | NativeWind + shared design tokens |
|
|
57
|
+
| Workspace | TypeScript + pnpm + Turborepo; shared TypeScript/ESLint configuration |
|
|
58
|
+
| Web hosting | Static Expo export on a Cloudflare asset Worker |
|
|
59
|
+
| Native delivery | Local development; EAS and app stores when requested |
|
|
60
|
+
|
|
61
|
+
Plain `anhedral init my-app` creates no API, auth, database, storage binding or
|
|
62
|
+
billing package. Static dynamic routes need build-time paths; SSR is a deliberate
|
|
63
|
+
alternative.
|
|
64
|
+
|
|
65
|
+
**Growth is additive.** `hono` adds the API and contracts. `d1` adds Hono and SQL.
|
|
66
|
+
`better-auth` adds Hono and a database. `r2` adds private server-side file storage.
|
|
67
|
+
Dependencies resolve automatically: an AI tool can have an API without accounts,
|
|
68
|
+
and an anonymous app can use SQL. Additions preserve edited source; backend or
|
|
69
|
+
hosting-engine migrations require explicit review.
|
|
70
|
+
|
|
71
|
+
## Payments and AI
|
|
72
|
+
|
|
73
|
+
| Add | What it supplies |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `stripe` | Web Checkout/customer portal; Hono, identity and durable billing state |
|
|
76
|
+
| `revenuecat` | Native purchase/restore/manage flows; shared identity and entitlements |
|
|
77
|
+
| `workers-ai` | Hono + AI binding; no implicit accounts, database or subscriptions |
|
|
78
|
+
|
|
79
|
+
Stripe and RevenueCat are independent. Hono verifies webhooks, reconciles provider
|
|
80
|
+
state and enforces paid access. Native purchases use Apple/Google billing;
|
|
81
|
+
RevenueCat synchronizes subscription state. Client purchase results never authorize
|
|
82
|
+
server operations. AI routes still need models, validation and usage limits.
|
|
83
|
+
|
|
84
|
+
## Services, add-ons and alternatives
|
|
85
|
+
|
|
86
|
+
| Capability | Selection | Scope |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| Analytics | `analytics-engine`, `basin` | Event dataset/helper; private Pipelines stream |
|
|
89
|
+
| Images | `images` | Binding and private raw-byte transform helper |
|
|
90
|
+
| Video | `video`, `stream` | Private uploaded-video helper; WHIP/WHEP live input helper |
|
|
91
|
+
| Conferencing | `realtimekit` | Server meeting and participant-token helpers |
|
|
92
|
+
| App messaging | `realtime` | Durable Object room Worker |
|
|
93
|
+
| Jobs | `queues`, `cron`, `workflows` | Queue/DLQ, scheduled and durable Worker foundations |
|
|
94
|
+
| Cache | `kv` | Eventually consistent configuration/cache |
|
|
95
|
+
| Extension | `wxt` | Browser side panel API, entrypoints and permissions |
|
|
96
|
+
| Operations | `resend`, `sentry` | Email factory and monitoring integration boundary |
|
|
97
|
+
| **Next.js on Vercel** | `next` | Usual explicit web frontend alternative |
|
|
98
|
+
| **Vinext on Cloudflare** | `vinext` | Additional explicit web frontend alternative |
|
|
99
|
+
| Data / identity alternatives | `neon`, `clerk` | Replace D1 / Better Auth |
|
|
100
|
+
| Specialized additions | `neon-realtime`, `openai` / `ai-sdk`, `posthog`, `electron`, `local-data` | Live SQL, alternative AI, product analytics, desktop or local persistence |
|
|
101
|
+
|
|
102
|
+
**Full-product includes:** Expo, WXT, Hono, Better Auth, D1, R2, KV, Stripe,
|
|
103
|
+
RevenueCat, Workers AI, Analytics Engine, Basin, Images, RealtimeKit, Durable Object
|
|
104
|
+
rooms, uploaded video, live Stream video, Queues, Cron, Workflows, Resend and Sentry.
|
|
105
|
+
Explicit Next.js/Vinext, Neon and Clerk replace their corresponding preset defaults.
|
|
106
|
+
|
|
107
|
+
Cloudflare hosts selected web/API, data, storage, AI and media services. Payment
|
|
108
|
+
providers, app stores, Resend, Sentry and Vercel remain external. Media travels
|
|
109
|
+
directly between clients and media services; Hono handles authorization and token
|
|
110
|
+
issuance. Provider activation, product routes/UI and real acceptance remain work
|
|
111
|
+
after scaffolding—especially room authorization, media clients and job processing.
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
anhedral init my-app
|
|
115
|
+
anhedral add better-auth --cwd my-app --dry-run --json
|
|
116
|
+
anhedral init complete --preset full-product --dry-run --json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Deployable code lives in `apps/*`; shared code lives in `packages/*`. Contracts,
|
|
120
|
+
database, auth, billing and service packages appear when selected. Small apps avoid
|
|
121
|
+
unneeded infrastructure; complex products use the same boundaries with more
|
|
122
|
+
capabilities.
|