anhedral 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -232
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +33 -0
- package/assets/ui/native/button.tsx +85 -0
- package/assets/ui/native/card.tsx +33 -0
- package/assets/ui/native/dialog.tsx +75 -0
- package/assets/ui/native/input.tsx +27 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/capabilities.d.ts +5 -5
- package/dist/capabilities.js +3 -21
- package/dist/capability-contract.d.ts +3 -3
- package/dist/capability-contract.js +11 -50
- package/dist/cli-delivery.d.ts +1 -1
- package/dist/cli-delivery.js +5 -65
- package/dist/cli-output.js +3 -3
- package/dist/command-schema.js +35 -86
- package/dist/delivery-evidence.d.ts +1 -1
- package/dist/delivery-evidence.js +7 -36
- package/dist/delivery.d.ts +2 -8
- package/dist/delivery.js +20 -101
- package/dist/dependencies.d.ts +6 -57
- package/dist/dependencies.js +54 -188
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/inspector-model.d.ts +2 -2
- package/dist/integration-service-readers.d.ts +1 -2
- package/dist/integration-service-readers.js +3 -84
- package/dist/lifecycle-model.d.ts +1 -1
- package/dist/lifecycle-model.js +1 -1
- package/dist/mobile-delivery.d.ts +1 -1
- package/dist/mobile-delivery.js +4 -0
- package/dist/platforms/mobile.js +30 -121
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +299 -0
- package/dist/project-config.d.ts +1 -1
- package/dist/project-config.js +0 -1
- package/dist/project-inspector.js +5 -36
- package/dist/project-state.d.ts +1 -3
- package/dist/project-state.js +2 -85
- package/dist/provider-auth.js +3 -38
- package/dist/provider-readiness.d.ts +1 -1
- package/dist/provider-readiness.js +5 -24
- package/dist/providers/adapters.js +0 -175
- package/dist/providers/api.d.ts +1 -1
- package/dist/providers/api.js +3 -3
- package/dist/providers/config.js +2 -48
- package/dist/providers/definitions.d.ts +1 -204
- package/dist/providers/definitions.js +0 -85
- package/dist/providers/provision.d.ts +1 -1
- package/dist/providers/receipts.js +1 -11
- package/dist/providers/recovery-verification.js +1 -61
- package/dist/providers/runtime.js +4 -35
- package/dist/providers/state.js +1 -7
- package/dist/provision.d.ts +5 -13
- package/dist/provision.js +4 -80
- package/dist/readiness.d.ts +1 -1
- package/dist/readiness.js +3 -8
- package/dist/registry/add.js +10 -70
- package/dist/registry/bootstrap.d.ts +3 -2
- package/dist/registry/bootstrap.js +4 -13
- package/dist/registry/commands.js +8 -10
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +8 -38
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +26 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +2 -2
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/auth.d.ts +1 -2
- package/dist/scaffold/auth.js +55 -130
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -186
- package/dist/scaffold/billing-schema.d.ts +1 -1
- package/dist/scaffold/billing-schema.js +4 -4
- package/dist/scaffold/billing.js +11 -19
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +18 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +22 -86
- package/dist/scaffold/expo-auth.js +33 -22
- package/dist/scaffold/expo-billing.js +17 -52
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +6 -97
- package/dist/scaffold/integrations.d.ts +1 -3
- package/dist/scaffold/integrations.js +9 -10
- package/dist/scaffold/managed-email.d.ts +3 -0
- package/dist/scaffold/managed-email.js +47 -0
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +69 -0
- package/dist/scaffold/password-reset.d.ts +1 -0
- package/dist/scaffold/password-reset.js +99 -0
- package/dist/scaffold/private-files.d.ts +2 -0
- package/dist/scaffold/private-files.js +78 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/web-billing.d.ts +2 -0
- package/dist/scaffold/web-billing.js +48 -0
- package/dist/scaffold/workspace.js +53 -194
- package/dist/service-deletion.js +1 -1
- package/dist/service-descriptor.js +5 -12
- package/dist/service-model.d.ts +1 -1
- package/dist/service-operations.js +2 -32
- package/dist/service-readers.js +1 -32
- package/dist/services-command.d.ts +1 -1
- package/dist/services-command.js +3 -9
- package/dist/ship.d.ts +3 -316
- package/dist/ship.js +10 -142
- package/dist/stack-registry.d.ts +2 -52
- package/dist/stack-registry.js +55 -403
- package/dist/standard.js +7 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +23 -122
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/software-factory.md +24 -557
- package/docs/stack-standard.md +47 -294
- package/docs/verification.md +320 -0
- package/package.json +20 -22
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
package/dist/vercel.js
DELETED
|
@@ -1,581 +0,0 @@
|
|
|
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';
|
|
4
|
-
import { githubRepository } from './repository.js';
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
|
|
6
|
-
import { randomUUID } from 'node:crypto';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { atomicJson, defaultRunner, withApplicationLock, } from './project-state.js';
|
|
9
|
-
export async function connectVercelApplication(root, options, run = defaultRunner) {
|
|
10
|
-
root = realpathSync(root);
|
|
11
|
-
return withApplicationLock(root, async () => {
|
|
12
|
-
const project = readWeb(root);
|
|
13
|
-
const repository = options.git ? await githubRepository(root, run) : undefined;
|
|
14
|
-
if (project.repository &&
|
|
15
|
-
repository &&
|
|
16
|
-
(project.repository.repoId !== repository.repoId ||
|
|
17
|
-
project.repository.nameWithOwner.toLowerCase() !== repository.nameWithOwner.toLowerCase()))
|
|
18
|
-
throw new Error('GitHub origin differs from the recorded source repository. Reconcile it explicitly.');
|
|
19
|
-
if (existsSync(path.join(root, '.vercel/repo.json')))
|
|
20
|
-
throw new Error('Existing repository links require explicit reconciliation.');
|
|
21
|
-
if (existsSync(path.join(root, '.vercel/project.json')) && !project.projectId)
|
|
22
|
-
throw new Error('Reconcile an existing Vercel project link before automatic connection.');
|
|
23
|
-
if (project.audience !== 'unconfigured' &&
|
|
24
|
-
(project.audience !== options.audience || project.use !== options.use))
|
|
25
|
-
throw new Error('Reconcile an established Vercel audience/use explicitly.');
|
|
26
|
-
const teams = await paginated(root, run, '/v2/teams', 'teams');
|
|
27
|
-
const matches = options.scope
|
|
28
|
-
? teams.filter((team) => team.id === options.scope || team.slug === options.scope)
|
|
29
|
-
: teams;
|
|
30
|
-
if (matches.length !== 1 || !/^team_[a-zA-Z0-9]+$/.test(matches[0].id))
|
|
31
|
-
throw new Error('Select one authorized Vercel team with --scope; account selection is ambiguous or unavailable.');
|
|
32
|
-
const team = await api(root, run, `/v2/teams/${matches[0].id}`, matches[0].id);
|
|
33
|
-
if (team.id !== matches[0].id || typeof team.slug !== 'string')
|
|
34
|
-
throw new Error('Invalid Vercel account identity.');
|
|
35
|
-
const plan = team.billing?.plan;
|
|
36
|
-
if (!['hobby', 'pro', 'enterprise'].includes(plan))
|
|
37
|
-
throw new Error('Cannot verify the selected Vercel plan.');
|
|
38
|
-
if (options.use === 'commercial' && plan === 'hobby')
|
|
39
|
-
throw new Error('Vercel Hobby is for personal non-commercial use. Select an existing suitable Pro/Enterprise account; no paid upgrade was activated.');
|
|
40
|
-
if (project.teamId && project.teamId !== team.id)
|
|
41
|
-
throw new Error('Cannot silently rebind a Vercel application to another account.');
|
|
42
|
-
const projects = await paginated(root, run, `/v9/projects?teamId=${team.id}`, 'projects', team.id);
|
|
43
|
-
const candidates = projects.filter((item) => project.projectId ? item.id === project.projectId : item.name === project.name);
|
|
44
|
-
if (candidates.length > 1)
|
|
45
|
-
throw new Error('Ambiguous Vercel project identity.');
|
|
46
|
-
let provider = candidates[0];
|
|
47
|
-
if (!provider) {
|
|
48
|
-
if (project.projectId || !options.create)
|
|
49
|
-
throw new Error('Selected Vercel project is missing; use --create only for an authorized new project.');
|
|
50
|
-
// First-class project creation does not expose monorepo root/framework settings.
|
|
51
|
-
provider = await api(root, run, `/v11/projects?teamId=${team.id}`, team.id, {
|
|
52
|
-
name: project.name,
|
|
53
|
-
framework: 'nextjs',
|
|
54
|
-
rootDirectory: 'apps/web',
|
|
55
|
-
});
|
|
56
|
-
if (!/^prj_[a-zA-Z0-9]+$/.test(provider.id))
|
|
57
|
-
throw new Error('Provider did not return a Vercel project identity.');
|
|
58
|
-
atomicJson(path.join(root, '.anhedral/vercel-creation.json'), {
|
|
59
|
-
projectId: provider.id,
|
|
60
|
-
teamId: team.id,
|
|
61
|
-
name: project.name,
|
|
62
|
-
});
|
|
63
|
-
provider = await api(root, run, `/v9/projects/${provider.id}?teamId=${team.id}`, team.id, {
|
|
64
|
-
sourceFilesOutsideRootDirectory: true,
|
|
65
|
-
...(options.audience === 'private' ? { ssoProtection: { deploymentType: 'all' } } : {}),
|
|
66
|
-
}, 'PATCH');
|
|
67
|
-
}
|
|
68
|
-
const connected = {
|
|
69
|
-
...project,
|
|
70
|
-
projectId: provider.id,
|
|
71
|
-
teamId: team.id,
|
|
72
|
-
scope: team.slug,
|
|
73
|
-
audience: options.audience,
|
|
74
|
-
use: options.use,
|
|
75
|
-
};
|
|
76
|
-
validateProvider(connected, provider);
|
|
77
|
-
if (existsSync(path.join(root, '.vercel/project.json')))
|
|
78
|
-
context(root, connected);
|
|
79
|
-
if (existsSync(path.join(root, '.vercel/repo.json')))
|
|
80
|
-
throw new Error('Existing repository links require explicit reconciliation.');
|
|
81
|
-
// Environment pins make Vercel skip writing its local link. Use explicit CLI targets during link, then pin subsequent commands.
|
|
82
|
-
const linkingEnv = env(connected);
|
|
83
|
-
delete linkingEnv.VERCEL_PROJECT_ID;
|
|
84
|
-
delete linkingEnv.VERCEL_ORG_ID;
|
|
85
|
-
writeProjectSection(root, 'vercel', connected);
|
|
86
|
-
await run('pnpm', [
|
|
87
|
-
...cli,
|
|
88
|
-
'link',
|
|
89
|
-
'--yes',
|
|
90
|
-
'--project',
|
|
91
|
-
connected.projectId,
|
|
92
|
-
'--scope',
|
|
93
|
-
connected.teamId,
|
|
94
|
-
'--non-interactive',
|
|
95
|
-
], root, linkingEnv);
|
|
96
|
-
const inspected = await inspect(root, connected, run);
|
|
97
|
-
writeProjectSection(root, 'vercel', connected);
|
|
98
|
-
if (repository) {
|
|
99
|
-
const matches = (link) => matchesRepository(link, repository);
|
|
100
|
-
if (inspected.link && !matches(inspected.link))
|
|
101
|
-
throw new Error('Vercel already connects a different Git repository; reconcile it explicitly.');
|
|
102
|
-
if (!inspected.link) {
|
|
103
|
-
try {
|
|
104
|
-
await run('pnpm', [
|
|
105
|
-
...cli,
|
|
106
|
-
'git',
|
|
107
|
-
'connect',
|
|
108
|
-
repository.url,
|
|
109
|
-
'--yes',
|
|
110
|
-
'--project',
|
|
111
|
-
connected.projectId,
|
|
112
|
-
'--scope',
|
|
113
|
-
connected.teamId,
|
|
114
|
-
'--non-interactive',
|
|
115
|
-
], root, env(connected));
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
throw new Error('Vercel could not connect the GitHub repository. Authorize the Vercel GitHub installation for this repository and retry connect --git; the verified project connection was retained.');
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (!matches((await inspect(root, connected, run)).link))
|
|
122
|
-
throw new Error('Vercel did not confirm the selected GitHub repository connection. Check the Vercel GitHub installation access.');
|
|
123
|
-
const linked = (await inspect(root, connected, run)).link;
|
|
124
|
-
if (linked?.productionBranch !== undefined && !validBranch(linked.productionBranch))
|
|
125
|
-
throw new Error('Invalid provider production branch.');
|
|
126
|
-
connected.repository = {
|
|
127
|
-
repoId: repository.repoId,
|
|
128
|
-
nameWithOwner: repository.nameWithOwner,
|
|
129
|
-
...(linked?.productionBranch ? { productionBranch: linked.productionBranch } : {}),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
writeProjectSection(root, 'vercel', connected);
|
|
133
|
-
return { project: connected, plan, planActivated: false };
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
async function adoptActive(root, project, run, operation) {
|
|
137
|
-
const commit = await committedManifest(root, project, run);
|
|
138
|
-
const original = JSON.stringify(project);
|
|
139
|
-
const provider = await inspect(root, project, run);
|
|
140
|
-
const id = provider.targets?.production?.id;
|
|
141
|
-
if (!id || !/^dpl_[a-zA-Z0-9]+$/.test(id))
|
|
142
|
-
throw new Error('No active production deployment is available to recover.');
|
|
143
|
-
const value = await api(root, run, `/v13/deployments/${id}?teamId=${project.teamId}`, project.teamId);
|
|
144
|
-
if (value.id !== id)
|
|
145
|
-
throw new Error('Provider returned a different active deployment identity.');
|
|
146
|
-
const provenance = value.gitSource?.type === 'github' ? 'git' : 'cli';
|
|
147
|
-
const branch = project.repository?.productionBranch;
|
|
148
|
-
if (operation === 'adopt' && provenance !== 'git')
|
|
149
|
-
throw new Error('Adoption requires a Git-driven deployment. Use recovery for CLI provenance.');
|
|
150
|
-
deployment(project, value, commit, provenance, branch);
|
|
151
|
-
if (provenance === 'git')
|
|
152
|
-
await remoteBranch(root, branch, commit, run);
|
|
153
|
-
const records = history(root, project);
|
|
154
|
-
const latest = records.releases.at(-1);
|
|
155
|
-
if (latest?.state === 'deployed' && latest.deploymentId === id && latest.commit === commit) {
|
|
156
|
-
validateRelease(project, value, latest);
|
|
157
|
-
if ((await committedManifest(root, project, run)) !== commit ||
|
|
158
|
-
JSON.stringify(readWeb(root)) !== original ||
|
|
159
|
-
(await inspect(root, project, run)).targets?.production?.id !== id)
|
|
160
|
-
throw new Error('Source or production changed during adoption/recovery refresh.');
|
|
161
|
-
const refreshed = await api(root, run, `/v13/deployments/${id}?teamId=${project.teamId}`, project.teamId);
|
|
162
|
-
validateRelease(project, refreshed, latest);
|
|
163
|
-
if (provenance === 'git')
|
|
164
|
-
await remoteBranch(root, branch, commit, run);
|
|
165
|
-
return {
|
|
166
|
-
projectId: project.id,
|
|
167
|
-
release: latest,
|
|
168
|
-
adopted: false,
|
|
169
|
-
productVerification: latest.verification?.state ?? 'required',
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
await run('pnpm', ['run', 'check'], root, env(project));
|
|
173
|
-
if ((await committedManifest(root, project, run)) !== commit ||
|
|
174
|
-
JSON.stringify(readWeb(root)) !== original ||
|
|
175
|
-
(await inspect(root, project, run)).targets?.production?.id !== id)
|
|
176
|
-
throw new Error('Source or production changed during adoption/recovery checks.');
|
|
177
|
-
const confirmed = await api(root, run, `/v13/deployments/${id}?teamId=${project.teamId}`, project.teamId);
|
|
178
|
-
if (confirmed.id !== id)
|
|
179
|
-
throw new Error('Provider returned a different deployment during adoption/recovery.');
|
|
180
|
-
deployment(project, confirmed, commit, provenance, branch);
|
|
181
|
-
if (provenance === 'git')
|
|
182
|
-
await remoteBranch(root, branch, commit, run);
|
|
183
|
-
const url = https(confirmed.url);
|
|
184
|
-
const release = {
|
|
185
|
-
id: randomUUID(),
|
|
186
|
-
commit,
|
|
187
|
-
operation,
|
|
188
|
-
provenance,
|
|
189
|
-
...(provenance === 'git' ? { branch } : {}),
|
|
190
|
-
state: 'deployed',
|
|
191
|
-
startedAt: new Date().toISOString(),
|
|
192
|
-
deploymentId: id,
|
|
193
|
-
deploymentUrl: url,
|
|
194
|
-
url,
|
|
195
|
-
};
|
|
196
|
-
records.releases.push(release);
|
|
197
|
-
atomicJson(path.join(root, '.anhedral/web-releases.json'), records);
|
|
198
|
-
return { projectId: project.id, release, adopted: true, productVerification: 'required' };
|
|
199
|
-
}
|
|
200
|
-
export async function adoptVercelApplication(root, run = defaultRunner) {
|
|
201
|
-
root = realpathSync(root);
|
|
202
|
-
const result = await withApplicationLock(root, async () => adoptActive(root, readWeb(root), run, 'adopt'));
|
|
203
|
-
writeVercelOverview(root, await vercelApplicationStatus(root));
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
export async function recoverVercelApplication(root, run = defaultRunner) {
|
|
207
|
-
root = realpathSync(root);
|
|
208
|
-
const result = await withApplicationLock(root, async () => {
|
|
209
|
-
const project = readWeb(root);
|
|
210
|
-
if (!project.projectId ||
|
|
211
|
-
!project.teamId ||
|
|
212
|
-
!project.scope ||
|
|
213
|
-
project.audience === 'unconfigured' ||
|
|
214
|
-
project.use === 'unconfigured')
|
|
215
|
-
throw new Error('Recovery requires a committed connected Vercel manifest. Retry connect for interrupted initial setup.');
|
|
216
|
-
await committedManifest(root, project, run);
|
|
217
|
-
env(project);
|
|
218
|
-
// Validate ownership/configuration from explicit API targets before repairing only the ignored local link.
|
|
219
|
-
const team = await api(root, run, `/v2/teams/${project.teamId}`, project.teamId);
|
|
220
|
-
if (team.id !== project.teamId ||
|
|
221
|
-
team.slug !== project.scope ||
|
|
222
|
-
!['hobby', 'pro', 'enterprise'].includes(team.billing?.plan) ||
|
|
223
|
-
(project.use === 'commercial' && team.billing.plan === 'hobby'))
|
|
224
|
-
throw new Error('Recovery account identity or plan differs from committed intent.');
|
|
225
|
-
const provider = await api(root, run, `/v9/projects/${project.projectId}?teamId=${project.teamId}`, project.teamId);
|
|
226
|
-
validateProvider(project, provider);
|
|
227
|
-
if (!existsSync(path.join(root, '.vercel/project.json'))) {
|
|
228
|
-
if (existsSync(path.join(root, '.vercel/repo.json')))
|
|
229
|
-
throw new Error('Reconcile existing Vercel repository links explicitly before recovery.');
|
|
230
|
-
const linkingEnv = env(project);
|
|
231
|
-
delete linkingEnv.VERCEL_PROJECT_ID;
|
|
232
|
-
delete linkingEnv.VERCEL_ORG_ID;
|
|
233
|
-
await run('pnpm', [
|
|
234
|
-
...cli,
|
|
235
|
-
'link',
|
|
236
|
-
'--yes',
|
|
237
|
-
'--project',
|
|
238
|
-
project.projectId,
|
|
239
|
-
'--scope',
|
|
240
|
-
project.teamId,
|
|
241
|
-
'--non-interactive',
|
|
242
|
-
], root, linkingEnv);
|
|
243
|
-
}
|
|
244
|
-
return adoptActive(root, project, run, 'recover');
|
|
245
|
-
});
|
|
246
|
-
writeVercelOverview(root, await vercelApplicationStatus(root));
|
|
247
|
-
return result;
|
|
248
|
-
}
|
|
249
|
-
export function planVercelDelivery(root) {
|
|
250
|
-
const project = readWeb(root);
|
|
251
|
-
return {
|
|
252
|
-
project,
|
|
253
|
-
checks: ['pnpm run check'],
|
|
254
|
-
deployment: ['pnpm', ...cli, 'deploy', '--prod', '--yes'],
|
|
255
|
-
cloudflareServices: hasProjectSection(root, 'cloudflare')
|
|
256
|
-
? 'Default ship deploys Cloudflare services first. Explicit --provider vercel ships only the web app; verify its service dependencies separately.'
|
|
257
|
-
: 'none',
|
|
258
|
-
mutation: false,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
export async function vercelApplicationStatus(root, refresh = false, run = defaultRunner) {
|
|
262
|
-
const project = readWeb(root);
|
|
263
|
-
const records = history(root, project);
|
|
264
|
-
const latest = records.releases.at(-1);
|
|
265
|
-
let activeRecordedVersion;
|
|
266
|
-
if (refresh) {
|
|
267
|
-
const provider = await inspect(root, project, run);
|
|
268
|
-
if (latest?.deploymentId) {
|
|
269
|
-
const value = await api(root, run, `/v13/deployments/${latest.deploymentId}?teamId=${project.teamId}`, project.teamId);
|
|
270
|
-
validateRelease(project, value, latest);
|
|
271
|
-
activeRecordedVersion = provider.targets?.production?.id === latest.deploymentId;
|
|
272
|
-
}
|
|
273
|
-
else
|
|
274
|
-
activeRecordedVersion = false;
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
project,
|
|
278
|
-
releases: records.releases,
|
|
279
|
-
activeRecordedVersion,
|
|
280
|
-
evidence: refresh ? 'provider-refresh' : 'local-history',
|
|
281
|
-
productVerification: activeRecordedVersion === false && latest?.verification
|
|
282
|
-
? 'stale'
|
|
283
|
-
: (latest?.verification?.state ?? 'unverified'),
|
|
284
|
-
management: project.scope ? `https://vercel.com/${project.scope}/${project.name}` : null,
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
export async function configureVercelEnvironment(root, values, run = defaultRunner) {
|
|
288
|
-
const project = readWeb(root);
|
|
289
|
-
if (!project.projectId || !project.teamId)
|
|
290
|
-
throw new Error('Connect Vercel before configuring environment variables.');
|
|
291
|
-
context(root, project);
|
|
292
|
-
await inspect(root, project, run);
|
|
293
|
-
if (!Object.keys(values).length)
|
|
294
|
-
return;
|
|
295
|
-
const response = await api(root, run, `/v10/projects/${project.projectId}/env?upsert=true`, project.teamId, Object.entries(values).map(([key, value]) => ({
|
|
296
|
-
key,
|
|
297
|
-
value,
|
|
298
|
-
type: 'encrypted',
|
|
299
|
-
target: ['production'],
|
|
300
|
-
})));
|
|
301
|
-
const created = Array.isArray(response.created)
|
|
302
|
-
? response.created
|
|
303
|
-
: response.created
|
|
304
|
-
? [response.created]
|
|
305
|
-
: [];
|
|
306
|
-
if (!Array.isArray(response.failed) ||
|
|
307
|
-
response.failed.length ||
|
|
308
|
-
Object.keys(values).some((key) => !created.some((entry) => entry.key === key &&
|
|
309
|
-
(entry.target === 'production' ||
|
|
310
|
-
(Array.isArray(entry.target) && entry.target.includes('production'))))))
|
|
311
|
-
throw new Error('Vercel did not confirm all selected production environment variables; deployment was not started.');
|
|
312
|
-
}
|
|
313
|
-
export async function shipVercelApplication(root, run = defaultRunner) {
|
|
314
|
-
root = realpathSync(root);
|
|
315
|
-
const result = await withApplicationLock(root, async () => {
|
|
316
|
-
const project = readWeb(root);
|
|
317
|
-
if (!project.projectId || !project.teamId || project.audience === 'unconfigured')
|
|
318
|
-
throw new Error('Connect the intended Vercel account, plan and audience before shipping.');
|
|
319
|
-
await inspect(root, project, run);
|
|
320
|
-
const commit = await source(root, run);
|
|
321
|
-
const original = JSON.stringify(project);
|
|
322
|
-
const records = history(root, project);
|
|
323
|
-
const release = {
|
|
324
|
-
id: randomUUID(),
|
|
325
|
-
commit,
|
|
326
|
-
operation: 'ship',
|
|
327
|
-
provenance: 'cli',
|
|
328
|
-
state: 'running',
|
|
329
|
-
startedAt: new Date().toISOString(),
|
|
330
|
-
};
|
|
331
|
-
records.releases.push(release);
|
|
332
|
-
const save = () => atomicJson(path.join(root, '.anhedral/web-releases.json'), records);
|
|
333
|
-
save();
|
|
334
|
-
try {
|
|
335
|
-
await run('pnpm', ['run', 'check'], root, env(project));
|
|
336
|
-
if ((await source(root, run)) !== commit || JSON.stringify(readWeb(root)) !== original)
|
|
337
|
-
throw new Error('Source changed during Vercel checks.');
|
|
338
|
-
await inspect(root, project, run);
|
|
339
|
-
const output = await run('pnpm', [
|
|
340
|
-
...cli,
|
|
341
|
-
'deploy',
|
|
342
|
-
'--prod',
|
|
343
|
-
'--yes',
|
|
344
|
-
'--json',
|
|
345
|
-
'--non-interactive',
|
|
346
|
-
'--scope',
|
|
347
|
-
project.teamId,
|
|
348
|
-
'--meta',
|
|
349
|
-
`anhedralProject=${project.id}`,
|
|
350
|
-
'--meta',
|
|
351
|
-
`anhedralCommit=${commit}`,
|
|
352
|
-
], root, env(project));
|
|
353
|
-
let receipt;
|
|
354
|
-
try {
|
|
355
|
-
receipt = JSON.parse(output);
|
|
356
|
-
}
|
|
357
|
-
catch {
|
|
358
|
-
throw new Error('Vercel CLI did not return a structured deployment receipt.');
|
|
359
|
-
}
|
|
360
|
-
if (receipt.status !== 'ok' ||
|
|
361
|
-
!receipt.deployment ||
|
|
362
|
-
receipt.deployment.readyState !== 'READY' ||
|
|
363
|
-
receipt.deployment.target !== 'production' ||
|
|
364
|
-
typeof receipt.deployment.url !== 'string')
|
|
365
|
-
throw new Error('Vercel CLI did not confirm a ready production deployment.');
|
|
366
|
-
const url = https(receipt.deployment.url);
|
|
367
|
-
if (!new URL(url).hostname.endsWith('.vercel.app'))
|
|
368
|
-
throw new Error('Vercel CLI did not return a deployment URL.');
|
|
369
|
-
const value = await api(root, run, `/v13/deployments/${encodeURIComponent(new URL(url).hostname)}?teamId=${project.teamId}`, project.teamId);
|
|
370
|
-
deployment(project, value, commit);
|
|
371
|
-
if (value.id !== receipt.deployment.id || https(value.url) !== url)
|
|
372
|
-
throw new Error('Deployment URL differs from the provider receipt.');
|
|
373
|
-
const productionUrl = typeof receipt.deployment.productionUrl === 'string'
|
|
374
|
-
? https(receipt.deployment.productionUrl)
|
|
375
|
-
: undefined;
|
|
376
|
-
if (productionUrl && !value.alias?.some((alias) => https(alias) === productionUrl))
|
|
377
|
-
throw new Error('Production URL differs from the provider aliases.');
|
|
378
|
-
release.deploymentId = value.id;
|
|
379
|
-
release.deploymentUrl = url;
|
|
380
|
-
release.url = productionUrl ?? (value.alias?.length ? https(value.alias[0]) : url);
|
|
381
|
-
save();
|
|
382
|
-
const provider = await inspect(root, project, run);
|
|
383
|
-
if (provider.targets?.production?.id !== value.id ||
|
|
384
|
-
(await source(root, run)) !== commit ||
|
|
385
|
-
JSON.stringify(readWeb(root)) !== original)
|
|
386
|
-
throw new Error('Source or active Vercel production deployment changed during delivery.');
|
|
387
|
-
release.state = 'deployed';
|
|
388
|
-
save();
|
|
389
|
-
return { projectId: project.id, release, productVerification: 'required' };
|
|
390
|
-
}
|
|
391
|
-
catch (error) {
|
|
392
|
-
release.state = 'failed';
|
|
393
|
-
save();
|
|
394
|
-
throw error;
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
writeVercelOverview(root, await vercelApplicationStatus(root));
|
|
398
|
-
return result;
|
|
399
|
-
}
|
|
400
|
-
export async function verifyVercelApplication(root, run = defaultRunner) {
|
|
401
|
-
root = realpathSync(root);
|
|
402
|
-
const result = await withApplicationLock(root, async () => {
|
|
403
|
-
const snapshot = await vercelApplicationStatus(root, true, run);
|
|
404
|
-
const latest = snapshot.releases.at(-1);
|
|
405
|
-
if (!latest ||
|
|
406
|
-
latest.state !== 'deployed' ||
|
|
407
|
-
!snapshot.activeRecordedVersion ||
|
|
408
|
-
!latest.url ||
|
|
409
|
-
(await source(root, run)) !== latest.commit)
|
|
410
|
-
throw new Error('Live verification needs the clean source of the active recorded Vercel release.');
|
|
411
|
-
const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
412
|
-
if (typeof pkg.scripts?.['test:live'] !== 'string')
|
|
413
|
-
throw new Error('Implement meaningful application test:live checks before verification.');
|
|
414
|
-
const records = history(root, snapshot.project);
|
|
415
|
-
const release = records.releases.at(-1);
|
|
416
|
-
try {
|
|
417
|
-
await run('pnpm', ['run', 'test:live'], root, {
|
|
418
|
-
...env(snapshot.project),
|
|
419
|
-
ANHEDRAL_APP_URL: latest.url,
|
|
420
|
-
ANHEDRAL_RELEASE_ID: latest.id,
|
|
421
|
-
});
|
|
422
|
-
if (!(await vercelApplicationStatus(root, true, run)).activeRecordedVersion ||
|
|
423
|
-
(await source(root, run)) !== latest.commit)
|
|
424
|
-
throw new Error('Source or production changed during live verification.');
|
|
425
|
-
release.verification = { state: 'passed', checkedAt: new Date().toISOString() };
|
|
426
|
-
}
|
|
427
|
-
catch (error) {
|
|
428
|
-
release.verification = { state: 'failed', checkedAt: new Date().toISOString() };
|
|
429
|
-
atomicJson(path.join(root, '.anhedral/web-releases.json'), records);
|
|
430
|
-
throw error;
|
|
431
|
-
}
|
|
432
|
-
atomicJson(path.join(root, '.anhedral/web-releases.json'), records);
|
|
433
|
-
return {
|
|
434
|
-
projectId: snapshot.project.id,
|
|
435
|
-
releaseId: latest.id,
|
|
436
|
-
verification: release.verification,
|
|
437
|
-
};
|
|
438
|
-
});
|
|
439
|
-
writeVercelOverview(root, await vercelApplicationStatus(root));
|
|
440
|
-
return result;
|
|
441
|
-
}
|
|
442
|
-
export async function rollbackVercelApplication(root, releaseId, dataCompatible, run = defaultRunner) {
|
|
443
|
-
root = realpathSync(root);
|
|
444
|
-
if (!dataCompatible)
|
|
445
|
-
throw new Error('Review schema/resource compatibility and pass --data-compatible. Vercel rollback restores code, not data.');
|
|
446
|
-
const result = await withApplicationLock(root, async () => {
|
|
447
|
-
const project = readWeb(root);
|
|
448
|
-
await inspect(root, project, run);
|
|
449
|
-
const records = history(root, project);
|
|
450
|
-
const desired = records.releases.find((item) => item.id === releaseId);
|
|
451
|
-
if (!desired ||
|
|
452
|
-
desired.state !== 'deployed' ||
|
|
453
|
-
!desired.deploymentId ||
|
|
454
|
-
!desired.deploymentUrl ||
|
|
455
|
-
!desired.url)
|
|
456
|
-
throw new Error('Choose a complete recorded Vercel release.');
|
|
457
|
-
validateRelease(project, await api(root, run, `/v13/deployments/${desired.deploymentId}?teamId=${project.teamId}`, project.teamId), desired);
|
|
458
|
-
const release = {
|
|
459
|
-
id: randomUUID(),
|
|
460
|
-
commit: desired.commit,
|
|
461
|
-
operation: 'rollback',
|
|
462
|
-
provenance: desired.provenance ?? 'cli',
|
|
463
|
-
...(desired.branch ? { branch: desired.branch } : {}),
|
|
464
|
-
state: 'running',
|
|
465
|
-
startedAt: new Date().toISOString(),
|
|
466
|
-
restoredReleaseId: desired.id,
|
|
467
|
-
deploymentId: desired.deploymentId,
|
|
468
|
-
url: desired.url,
|
|
469
|
-
deploymentUrl: desired.deploymentUrl,
|
|
470
|
-
};
|
|
471
|
-
records.releases.push(release);
|
|
472
|
-
const save = () => atomicJson(path.join(root, '.anhedral/web-releases.json'), records);
|
|
473
|
-
save();
|
|
474
|
-
try {
|
|
475
|
-
await run('pnpm', [
|
|
476
|
-
...cli,
|
|
477
|
-
'rollback',
|
|
478
|
-
desired.deploymentUrl,
|
|
479
|
-
'--yes',
|
|
480
|
-
'--non-interactive',
|
|
481
|
-
'--scope',
|
|
482
|
-
project.teamId,
|
|
483
|
-
], root, env(project));
|
|
484
|
-
if ((await inspect(root, project, run)).targets?.production?.id !== desired.deploymentId)
|
|
485
|
-
throw new Error('Vercel did not confirm the restored production version.');
|
|
486
|
-
release.state = 'deployed';
|
|
487
|
-
save();
|
|
488
|
-
return {
|
|
489
|
-
projectId: project.id,
|
|
490
|
-
release,
|
|
491
|
-
dataRestored: false,
|
|
492
|
-
productVerification: 'required',
|
|
493
|
-
automaticProductionUpdates: 'paused-by-provider-rollback',
|
|
494
|
-
nextAction: 'Review and promote a different deployment explicitly to resume automatic production domain assignment.',
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
catch (error) {
|
|
498
|
-
release.state = 'failed';
|
|
499
|
-
save();
|
|
500
|
-
throw error;
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
writeVercelOverview(root, await vercelApplicationStatus(root));
|
|
504
|
-
return result;
|
|
505
|
-
}
|
|
506
|
-
export function writeVercelOverview(root, snapshot) {
|
|
507
|
-
root = realpathSync(root);
|
|
508
|
-
const directory = path.join(root, '.anhedral');
|
|
509
|
-
mkdirSync(directory, { recursive: true });
|
|
510
|
-
if (realpathSync(directory) !== directory)
|
|
511
|
-
throw new Error('Management directory must not be a symbolic link.');
|
|
512
|
-
const escape = (value) => String(value ?? '').replace(/[&<>"']/g, (char) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]);
|
|
513
|
-
const rows = [...snapshot.releases]
|
|
514
|
-
.reverse()
|
|
515
|
-
.map((release) => `<tr><td>${escape(release.state)} · ${escape(release.operation)} · ${escape(release.provenance ?? 'cli')}</td><td>${escape(release.commit)}</td><td>${release.url ? `<a href="${escape(https(release.url))}" rel="noreferrer">Open app</a>` : 'No confirmed URL'}</td></tr>`)
|
|
516
|
-
.join('');
|
|
517
|
-
const file = path.join(directory, 'web-overview.html');
|
|
518
|
-
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
519
|
-
const html = `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><title>${escape(snapshot.project.name)} · Anhedral</title><style>body{font:16px system-ui;max-width:1000px;margin:3rem auto;padding:1rem}td{padding:1rem;overflow-wrap:anywhere}</style><h1>${escape(snapshot.project.name)}</h1><p>Customer-owned Vercel · ${escape(snapshot.project.audience)} · ${escape(snapshot.evidence)} · ${escape(new Date().toISOString())}</p><p>Active recorded production: ${escape(snapshot.activeRecordedVersion ?? 'Not refreshed')}. Product checks: ${escape(snapshot.productVerification)}.</p><p>Native Next.js web app. Cloudflare services, if selected, have separate provider release records.</p><table><tr><th>State</th><th>Source</th><th>App</th></tr>${rows}</table></html>`;
|
|
520
|
-
try {
|
|
521
|
-
writeFileSync(temporary, html, { mode: 0o600, flag: 'wx' });
|
|
522
|
-
return renameOverview(temporary, file);
|
|
523
|
-
}
|
|
524
|
-
finally {
|
|
525
|
-
rmSync(temporary, { force: true });
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
function renameOverview(temporary, file) {
|
|
529
|
-
renameSync(temporary, file);
|
|
530
|
-
return file;
|
|
531
|
-
}
|
|
532
|
-
/** Read-only Web Analytics query for the exact connected project/team. */
|
|
533
|
-
export async function vercelServiceMetrics(root, hours = 24, run = defaultRunner) {
|
|
534
|
-
if (![24, 168].includes(hours))
|
|
535
|
-
throw new Error('Vercel analytics uses complete UTC days.');
|
|
536
|
-
const project = readWeb(root);
|
|
537
|
-
await inspect(root, project, run);
|
|
538
|
-
if (!project.projectId || !project.teamId)
|
|
539
|
-
throw new Error('Connect the exact Vercel project and team before reading analytics.');
|
|
540
|
-
const end = new Date(new Date().toISOString().slice(0, 10) + 'T00:00:00.000Z').toISOString();
|
|
541
|
-
const start = new Date(Date.parse(end) - hours * 3600000).toISOString();
|
|
542
|
-
const query = new URLSearchParams({
|
|
543
|
-
teamId: project.teamId,
|
|
544
|
-
projectId: project.projectId,
|
|
545
|
-
since: start.slice(0, 10),
|
|
546
|
-
until: new Date(Date.parse(end) - 1).toISOString().slice(0, 10),
|
|
547
|
-
by: 'day',
|
|
548
|
-
limit: '100',
|
|
549
|
-
});
|
|
550
|
-
const value = await api(root, run, `/v1/query/web-analytics/visits/aggregate?${query}`, project.teamId);
|
|
551
|
-
if (value.version !== 1 ||
|
|
552
|
-
!Array.isArray(value.data) ||
|
|
553
|
-
value.data.length >= 100 ||
|
|
554
|
-
value.query?.since !== start.slice(0, 10))
|
|
555
|
-
throw new Error('Unsupported or truncated Vercel analytics output.');
|
|
556
|
-
const points = value.data.map((row) => {
|
|
557
|
-
if (!row || typeof row !== 'object')
|
|
558
|
-
throw new Error('Invalid analytics row.');
|
|
559
|
-
const value = row;
|
|
560
|
-
if (typeof value.timestamp !== 'string' ||
|
|
561
|
-
!Number.isFinite(Date.parse(value.timestamp)) ||
|
|
562
|
-
Date.parse(value.timestamp) < Date.parse(start) ||
|
|
563
|
-
Date.parse(value.timestamp) >= Date.parse(end) ||
|
|
564
|
-
[value.pageviews, value.visitors].some((count) => typeof count !== 'number' || !Number.isFinite(count) || count < 0))
|
|
565
|
-
throw new Error('Invalid Vercel analytics values.');
|
|
566
|
-
return {
|
|
567
|
-
time: value.timestamp,
|
|
568
|
-
values: { pageviews: Number(value.pageviews), visitors: Number(value.visitors) },
|
|
569
|
-
};
|
|
570
|
-
});
|
|
571
|
-
return {
|
|
572
|
-
fetchedAt: new Date().toISOString(),
|
|
573
|
-
start,
|
|
574
|
-
end,
|
|
575
|
-
timezone: 'UTC',
|
|
576
|
-
source: 'Vercel Web Analytics (daily buckets)',
|
|
577
|
-
sampled: false,
|
|
578
|
-
points,
|
|
579
|
-
units: { pageviews: 'count', visitors: 'daily bucket count' },
|
|
580
|
-
};
|
|
581
|
-
}
|
package/dist/vinext.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const VINEXT_SERVER_OUTPUT_PLUGIN = "{\n name: 'anhedral:vinext-server-modules',\n apply: 'build',\n enforce: 'post',\n outputOptions(output) {\n if (this.environment.name === 'rsc') {\n return { ...output, chunkFileNames: '[name]-[hash].js' };\n }\n },\n}";
|
|
2
|
-
export declare function configureVinext(root: string, workerName: string, bindings: Record<string, unknown>): void;
|
package/dist/vinext.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { VINEXT_DEPENDENCIES } from './dependencies.js';
|
|
2
|
-
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { writeFile } from './util.js';
|
|
5
|
-
// Vinext externalizes its generated manifests relative to each RSC chunk.
|
|
6
|
-
// Keep those chunks beside the real root modules, including Void's wrapper entry.
|
|
7
|
-
export const VINEXT_SERVER_OUTPUT_PLUGIN = `{
|
|
8
|
-
name: 'anhedral:vinext-server-modules',
|
|
9
|
-
apply: 'build',
|
|
10
|
-
enforce: 'post',
|
|
11
|
-
outputOptions(output) {
|
|
12
|
-
if (this.environment.name === 'rsc') {
|
|
13
|
-
return { ...output, chunkFileNames: '[name]-[hash].js' };
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
}`;
|
|
17
|
-
// Official Vinext App Router integration using the supported Wrangler/Vite adapter.
|
|
18
|
-
// Wrangler's generated dist/server config preserves binding IDs and built assets.
|
|
19
|
-
export function configureVinext(root, workerName, bindings) {
|
|
20
|
-
const put = (file, value) => writeFile(path.join(root, 'apps/web', file), value);
|
|
21
|
-
const pkg = JSON.parse(readFileSync(path.join(root, 'apps/web/package.json'), 'utf8'));
|
|
22
|
-
delete pkg.dependencies?.['@opennextjs/cloudflare'];
|
|
23
|
-
pkg.type = 'module';
|
|
24
|
-
pkg.dependencies = { ...pkg.dependencies, ...VINEXT_DEPENDENCIES.dependencies };
|
|
25
|
-
pkg.devDependencies = { ...pkg.devDependencies, ...VINEXT_DEPENDENCIES.devDependencies };
|
|
26
|
-
pkg.scripts = {
|
|
27
|
-
...pkg.scripts,
|
|
28
|
-
dev: 'vite dev --host 127.0.0.1 --port 3000',
|
|
29
|
-
build: 'vite build',
|
|
30
|
-
start: 'vinext start',
|
|
31
|
-
preview: 'wrangler dev --config dist/server/wrangler.json --port 3000 --persist-to .wrangler/state',
|
|
32
|
-
deploy: 'vite build && wrangler deploy --config dist/server/wrangler.json',
|
|
33
|
-
'build:worker': 'vite build',
|
|
34
|
-
typecheck: 'wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts && tsc --noEmit',
|
|
35
|
-
};
|
|
36
|
-
put('package.json', JSON.stringify(pkg, null, 2) + '\n');
|
|
37
|
-
put('vite.config.ts', `import { defineConfig } from 'vite';
|
|
38
|
-
import vinext from 'vinext';
|
|
39
|
-
import { cloudflare } from '@cloudflare/vite-plugin';
|
|
40
|
-
export default defineConfig({ plugins: [vinext(), cloudflare({ viteEnvironment: { name: 'rsc', childEnvironments: ['ssr'] } }), ${VINEXT_SERVER_OUTPUT_PLUGIN}] });
|
|
41
|
-
`);
|
|
42
|
-
put('wrangler.jsonc', JSON.stringify({
|
|
43
|
-
$schema: 'node_modules/wrangler/config-schema.json',
|
|
44
|
-
name: workerName,
|
|
45
|
-
main: 'vinext/server/fetch-handler',
|
|
46
|
-
compatibility_date: '2026-10-05',
|
|
47
|
-
compatibility_flags: ['nodejs_compat'],
|
|
48
|
-
assets: { binding: 'ASSETS', not_found_handling: 'none' },
|
|
49
|
-
observability: { enabled: true },
|
|
50
|
-
...bindings,
|
|
51
|
-
}, null, 2) + '\n');
|
|
52
|
-
put('next.config.ts', `import type { NextConfig } from 'next';
|
|
53
|
-
const config: NextConfig = { transpilePackages: ['@workspace/ui'] };
|
|
54
|
-
export default config;
|
|
55
|
-
`);
|
|
56
|
-
for (const file of [
|
|
57
|
-
'next.config.js',
|
|
58
|
-
'next.config.mjs',
|
|
59
|
-
'open-next.config.ts',
|
|
60
|
-
'vercel.json',
|
|
61
|
-
'next-env.d.ts',
|
|
62
|
-
])
|
|
63
|
-
rmSync(path.join(root, 'apps/web', file), { force: true });
|
|
64
|
-
const tsFile = path.join(root, 'apps/web/tsconfig.json');
|
|
65
|
-
if (existsSync(tsFile)) {
|
|
66
|
-
const ts = JSON.parse(readFileSync(tsFile, 'utf8'));
|
|
67
|
-
delete ts.compilerOptions?.plugins;
|
|
68
|
-
// Respect the UI package exports (globals.css lives in src/styles, not src).
|
|
69
|
-
if (ts.compilerOptions?.paths)
|
|
70
|
-
delete ts.compilerOptions.paths['@workspace/ui/*'];
|
|
71
|
-
ts.include = ['**/*.ts', '**/*.tsx', '**/*.mts'];
|
|
72
|
-
put('tsconfig.json', JSON.stringify(ts, null, 2) + '\n');
|
|
73
|
-
}
|
|
74
|
-
put('vinext-env.d.ts', '/// <reference types="vinext/types" />\n/// <reference types="vite/client" />\n');
|
|
75
|
-
put('.dev.vars.example', '# Worker secrets are local-only and ignored by Git.\n');
|
|
76
|
-
const uiFile = path.join(root, 'packages/ui/package.json');
|
|
77
|
-
if (existsSync(uiFile)) {
|
|
78
|
-
const ui = JSON.parse(readFileSync(uiFile, 'utf8'));
|
|
79
|
-
ui.dependencies = {
|
|
80
|
-
...ui.dependencies,
|
|
81
|
-
react: VINEXT_DEPENDENCIES.dependencies.react,
|
|
82
|
-
'react-dom': VINEXT_DEPENDENCIES.dependencies['react-dom'],
|
|
83
|
-
};
|
|
84
|
-
writeFile(uiFile, JSON.stringify(ui, null, 2) + '\n');
|
|
85
|
-
}
|
|
86
|
-
}
|