anhedral 0.11.0 → 0.11.2
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 +50 -170
- package/assets/patches/LICENSE.braces +21 -0
- package/assets/patches/LICENSE.node-forge +50 -0
- package/assets/patches/audit-deps.mjs +167 -0
- package/assets/patches/braces@3.0.3.patch +127 -0
- package/assets/patches/node-forge@1.4.0.patch +41 -0
- package/dist/auth-schema.js +3 -3
- package/dist/bin.js +15 -11
- package/dist/capabilities.d.ts +4 -4
- package/dist/capabilities.js +6 -2
- package/dist/capability-contract.js +22 -5
- package/dist/catalog-model.d.ts +24 -0
- package/dist/catalog-model.js +1 -0
- package/dist/catalog-registration.d.ts +16 -0
- package/dist/catalog-registration.js +22 -0
- package/dist/catalog-snapshot.d.ts +5 -0
- package/dist/catalog-snapshot.js +97 -0
- package/dist/cli-arguments.js +1 -1
- package/dist/cli-output.js +27 -2
- package/dist/cloudflare.d.ts +7 -1
- package/dist/cloudflare.js +36 -6
- package/dist/command-schema.js +49 -5
- package/dist/delivery.d.ts +10 -3
- package/dist/delivery.js +154 -37
- package/dist/dependencies.d.ts +24 -0
- package/dist/dependencies.js +48 -0
- package/dist/dependency-patches.d.ts +7 -0
- package/dist/dependency-patches.js +125 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/inspector-model.d.ts +9 -1
- package/dist/integration-service-readers.d.ts +13 -0
- package/dist/integration-service-readers.js +173 -0
- package/dist/lifecycle.d.ts +0 -1
- package/dist/lifecycle.js +0 -1
- package/dist/neon-service-data.d.ts +8 -0
- package/dist/neon-service-data.js +117 -0
- package/dist/pnpm-policy.d.ts +2 -2
- package/dist/pnpm-policy.js +19 -45
- package/dist/project-catalog.d.ts +41 -0
- package/dist/project-catalog.js +288 -0
- package/dist/project-config.d.ts +14 -0
- package/dist/project-config.js +89 -0
- package/dist/project-inspector.js +73 -17
- package/dist/project-lifecycle.d.ts +25 -0
- package/dist/project-lifecycle.js +57 -0
- package/dist/project-state.d.ts +5 -1
- package/dist/project-state.js +122 -16
- package/dist/provider-auth.js +2 -3
- package/dist/provider-readiness.js +27 -10
- package/dist/providers/adapters.js +4 -1
- package/dist/providers/api.d.ts +1 -0
- package/dist/providers/api.js +1 -0
- package/dist/providers/config.js +6 -8
- package/dist/providers/provision.js +1 -1
- package/dist/providers/recovery.d.ts +1 -1
- package/dist/providers/runtime.d.ts +1 -1
- package/dist/providers/runtime.js +46 -23
- package/dist/providers/state.d.ts +1 -2
- package/dist/providers/state.js +14 -54
- package/dist/provision.d.ts +9 -0
- package/dist/provision.js +30 -1
- package/dist/r2-service-data.d.ts +2 -0
- package/dist/r2-service-data.js +136 -0
- package/dist/readiness.js +9 -13
- package/dist/registry/add.js +64 -21
- package/dist/registry/commands.js +7 -9
- package/dist/registry/options.d.ts +1 -1
- package/dist/registry/options.js +4 -4
- package/dist/registry/receipt.d.ts +1 -0
- package/dist/registry/receipt.js +19 -4
- package/dist/registry/resolve.js +5 -1
- package/dist/registry/usage.js +1 -5
- package/dist/render.d.ts +2 -0
- package/dist/render.js +6 -0
- package/dist/runtime-policy.d.ts +4 -0
- package/dist/runtime-policy.js +21 -0
- package/dist/scaffold/bootstrap.js +2 -2
- package/dist/scaffold/compose.js +9 -3
- package/dist/scaffold/database.js +107 -25
- package/dist/scaffold/documentation.js +18 -13
- package/dist/scaffold/lint.d.ts +4 -0
- package/dist/scaffold/lint.js +56 -0
- package/dist/scaffold/neon-realtime.d.ts +2 -0
- package/dist/scaffold/neon-realtime.js +97 -0
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/void.d.ts +4 -0
- package/dist/scaffold/void.js +256 -0
- package/dist/scaffold/web.js +7 -1
- package/dist/scaffold/workspace.js +120 -29
- package/dist/service-deletion.d.ts +29 -0
- package/dist/service-deletion.js +195 -0
- package/dist/service-descriptor.d.ts +10 -0
- package/dist/service-descriptor.js +78 -0
- package/dist/service-model.d.ts +49 -0
- package/dist/service-model.js +8 -0
- package/dist/service-operations.d.ts +29 -0
- package/dist/service-operations.js +78 -0
- package/dist/service-readers.d.ts +8 -0
- package/dist/service-readers.js +247 -0
- package/dist/services-command.d.ts +39 -0
- package/dist/services-command.js +100 -0
- package/dist/ship.d.ts +36 -8
- package/dist/ship.js +39 -13
- package/dist/stack-registry.d.ts +4 -2
- package/dist/stack-registry.js +41 -11
- package/dist/standard.js +23 -4
- package/dist/transaction.d.ts +2 -0
- package/dist/transaction.js +10 -0
- package/dist/util.js +17 -2
- package/dist/vercel.d.ts +2 -0
- package/dist/vercel.js +69 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vinext.d.ts +1 -0
- package/dist/vinext.js +13 -1
- package/dist/void-execution.d.ts +10 -0
- package/dist/void-execution.js +94 -0
- package/dist/void-migrations.d.ts +6 -0
- package/dist/void-migrations.js +110 -0
- package/dist/void-state.d.ts +16 -0
- package/dist/void-state.js +65 -0
- package/dist/void.d.ts +3 -0
- package/dist/void.js +5 -0
- package/docs/cli-design.md +2 -2
- package/docs/plugin-ui.md +51 -10
- package/docs/provider-configuration.md +10 -11
- package/docs/software-factory.md +192 -0
- package/docs/stack-standard.md +142 -0
- package/docs/void-verification.md +185 -0
- package/package.json +23 -21
- package/assets/anhedral-mark.svg +0 -4
- package/assets/anhedral-stack-technical.svg +0 -322
- package/assets/anhedral-stack.svg +0 -322
- package/assets/anhedral.svg +0 -4
- package/assets/favicon.ico +0 -0
- package/assets/security/LICENSES.txt +0 -63
- package/assets/security/audit-deps.mjs +0 -300
- package/assets/security/braces-regression.mjs +0 -102
- package/assets/security/braces@3.0.3.patch +0 -285
- package/assets/security/decode-uri-component@0.2.2.patch +0 -149
- package/assets/security/decoder-regression.mjs +0 -37
- package/assets/security/forge-regression.mjs +0 -46
- package/assets/security/manifest.json +0 -53
- package/assets/security/node-forge@1.4.0.patch +0 -26
- package/dist/security-backports.d.ts +0 -3
- package/dist/security-backports.js +0 -26
- package/docs/application-stack-standard.md +0 -75
- package/docs/delivery-workflow.md +0 -97
package/dist/project-state.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hasProjectSection, readProjectSection, writeProjectSection } from './project-config.js';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
1
3
|
import { randomUUID } from 'node:crypto';
|
|
2
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
5
|
import { existsSync, lstatSync, fstatSync, openSync, closeSync, unlinkSync, rmdirSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
|
|
@@ -5,9 +7,9 @@ import { spawn } from 'node:child_process';
|
|
|
5
7
|
import path from 'node:path';
|
|
6
8
|
import { hostname } from 'node:os';
|
|
7
9
|
import { readBoundedFile } from './bounded-file.js';
|
|
10
|
+
import { validateSetupPlan } from './readiness.js';
|
|
8
11
|
import { parse } from 'jsonc-parser';
|
|
9
12
|
import { resolveCommand } from './command.js';
|
|
10
|
-
const manifestName = 'anhedral.project.json';
|
|
11
13
|
const stateDirectory = '.anhedral';
|
|
12
14
|
const accountPattern = /^[a-f0-9]{32}$/i;
|
|
13
15
|
const workerPattern = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
@@ -21,11 +23,94 @@ export function atomicJson(file, value) {
|
|
|
21
23
|
rmSync(temporary, { force: true });
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
export function configurationFile(directory) {
|
|
27
|
+
const canonical = path.join(directory, 'anhedral.cloudflare.json');
|
|
28
|
+
return existsSync(canonical) ? canonical : path.join(directory, 'wrangler.jsonc');
|
|
29
|
+
}
|
|
30
|
+
export function usesVoid(project) {
|
|
31
|
+
return project.deliveryEngine === 'void';
|
|
32
|
+
}
|
|
33
|
+
function mergeVoidConfig(previous, resolved, authored) {
|
|
34
|
+
if (isDeepStrictEqual(previous, authored))
|
|
35
|
+
return resolved;
|
|
36
|
+
if (Array.isArray(previous) && Array.isArray(resolved) && Array.isArray(authored)) {
|
|
37
|
+
const identity = (value) => {
|
|
38
|
+
if (value && typeof value === 'object')
|
|
39
|
+
for (const key of ['binding', 'name', 'tag', 'class_name', 'pattern', 'route']) {
|
|
40
|
+
const item = value[key];
|
|
41
|
+
if (typeof item === 'string')
|
|
42
|
+
return `${key}:${item}`;
|
|
43
|
+
}
|
|
44
|
+
return JSON.stringify(value);
|
|
45
|
+
};
|
|
46
|
+
return [
|
|
47
|
+
...authored.map((item) => {
|
|
48
|
+
const before = previous.find((entry) => identity(entry) === identity(item));
|
|
49
|
+
const after = resolved.find((entry) => identity(entry) === identity(item));
|
|
50
|
+
return before !== undefined && after !== undefined
|
|
51
|
+
? mergeVoidConfig(before, after, item)
|
|
52
|
+
: item;
|
|
53
|
+
}),
|
|
54
|
+
...resolved.filter((item) => !previous.some((entry) => identity(entry) === identity(item)) &&
|
|
55
|
+
!authored.some((entry) => identity(entry) === identity(item))),
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
const object = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
59
|
+
if (object(previous) && object(resolved) && object(authored)) {
|
|
60
|
+
const result = {};
|
|
61
|
+
for (const key of new Set([
|
|
62
|
+
...Object.keys(previous),
|
|
63
|
+
...Object.keys(resolved),
|
|
64
|
+
...Object.keys(authored),
|
|
65
|
+
])) {
|
|
66
|
+
if (key in authored)
|
|
67
|
+
Object.defineProperty(result, key, {
|
|
68
|
+
value: mergeVoidConfig(previous[key], resolved[key], authored[key]),
|
|
69
|
+
enumerable: true,
|
|
70
|
+
});
|
|
71
|
+
else if (!(key in previous) && key in resolved)
|
|
72
|
+
Object.defineProperty(result, key, { value: resolved[key], enumerable: true });
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
return authored;
|
|
77
|
+
}
|
|
78
|
+
export function resolveVoidCloudflareConfig(authored, lock) {
|
|
79
|
+
const value = structuredClone(authored);
|
|
80
|
+
if (lock.version !== 1 ||
|
|
81
|
+
!lock.source ||
|
|
82
|
+
typeof lock.source !== 'object' ||
|
|
83
|
+
Array.isArray(lock.source) ||
|
|
84
|
+
!lock.resolved ||
|
|
85
|
+
typeof lock.resolved !== 'object' ||
|
|
86
|
+
Array.isArray(lock.resolved) ||
|
|
87
|
+
typeof lock.text !== 'string')
|
|
88
|
+
throw new Error('Invalid pinned Void resource lock.');
|
|
89
|
+
// The generated Void configuration omits resource-ID scaffolding placeholders.
|
|
90
|
+
// Match that authored input when applying Void's resolved resource identities.
|
|
91
|
+
for (const [field, key] of [
|
|
92
|
+
['d1_databases', 'database_id'],
|
|
93
|
+
['kv_namespaces', 'id'],
|
|
94
|
+
['pipelines', 'stream'],
|
|
95
|
+
]) {
|
|
96
|
+
if (Array.isArray(value[field]))
|
|
97
|
+
for (const entry of value[field]) {
|
|
98
|
+
if (entry && typeof entry[key] === 'string' && entry[key].startsWith('REPLACE_WITH_'))
|
|
99
|
+
delete entry[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return mergeVoidConfig(lock.source, lock.resolved, value);
|
|
103
|
+
}
|
|
24
104
|
export function readConfig(directory) {
|
|
25
105
|
const errors = [];
|
|
26
|
-
const value = parse(readFileSync(
|
|
106
|
+
const value = parse(readFileSync(configurationFile(directory), 'utf8'), errors);
|
|
27
107
|
if (errors.length || !value || typeof value !== 'object' || Array.isArray(value))
|
|
28
108
|
throw new Error('Invalid Wrangler JSONC configuration.');
|
|
109
|
+
const lockFile = path.join(directory, 'void.lock.json');
|
|
110
|
+
if (existsSync(path.join(directory, 'anhedral.cloudflare.json')) && existsSync(lockFile)) {
|
|
111
|
+
const lock = JSON.parse(readFileSync(lockFile, 'utf8'));
|
|
112
|
+
return resolveVoidCloudflareConfig(value, lock);
|
|
113
|
+
}
|
|
29
114
|
return value;
|
|
30
115
|
}
|
|
31
116
|
export function targetDirectory(root, target) {
|
|
@@ -38,15 +123,14 @@ export function targetDirectory(root, target) {
|
|
|
38
123
|
}
|
|
39
124
|
export function registerApplication(root, extendTargets = false) {
|
|
40
125
|
root = realpathSync(root);
|
|
41
|
-
const existing =
|
|
126
|
+
const existing = hasProjectSection(root, 'cloudflare') ? readApplication(root) : undefined;
|
|
42
127
|
if (existing && !extendTargets)
|
|
43
128
|
return existing;
|
|
44
|
-
const setup =
|
|
45
|
-
|
|
46
|
-
throw new Error('Automatic delivery currently supports Cloudflare projects.');
|
|
129
|
+
const setup = readProjectSection(root, 'setup');
|
|
130
|
+
validateSetupPlan(setup);
|
|
47
131
|
const targets = readdirSync(path.join(root, 'apps'), { withFileTypes: true })
|
|
48
132
|
.filter((entry) => entry.isDirectory())
|
|
49
|
-
.filter((entry) => existsSync(path.join(root, 'apps', entry.name
|
|
133
|
+
.filter((entry) => existsSync(configurationFile(path.join(root, 'apps', entry.name))))
|
|
50
134
|
.map((entry) => {
|
|
51
135
|
const workerName = readConfig(path.join(root, 'apps', entry.name)).name;
|
|
52
136
|
if (typeof workerName !== 'string' || !workerPattern.test(workerName))
|
|
@@ -54,13 +138,23 @@ export function registerApplication(root, extendTargets = false) {
|
|
|
54
138
|
return { id: entry.name, directory: `apps/${entry.name}`, workerName };
|
|
55
139
|
})
|
|
56
140
|
.sort((a, b) => (a.id === 'web' ? 1 : b.id === 'web' ? -1 : a.id.localeCompare(b.id)));
|
|
141
|
+
const selectedEngine = targets.length &&
|
|
142
|
+
targets.every((target) => existsSync(path.join(root, target.directory, 'void.config.ts')))
|
|
143
|
+
? 'void'
|
|
144
|
+
: 'wrangler';
|
|
57
145
|
if (existing) {
|
|
58
146
|
if (existing.targets.some((target) => !targets.some((candidate) => candidate.id === target.id &&
|
|
59
147
|
candidate.directory === target.directory &&
|
|
60
148
|
candidate.workerName === target.workerName)))
|
|
61
149
|
throw new Error('Addition cannot replace existing delivery targets.');
|
|
62
|
-
const extended = {
|
|
63
|
-
|
|
150
|
+
const extended = {
|
|
151
|
+
...existing,
|
|
152
|
+
// A native-only registration has no Cloudflare runtime to preserve.
|
|
153
|
+
// Select the first actual targets' engine while keeping project identity.
|
|
154
|
+
deliveryEngine: existing.targets.length ? existing.deliveryEngine : selectedEngine,
|
|
155
|
+
targets,
|
|
156
|
+
};
|
|
157
|
+
writeProjectSection(root, 'cloudflare', extended);
|
|
64
158
|
return extended;
|
|
65
159
|
}
|
|
66
160
|
const project = {
|
|
@@ -69,6 +163,7 @@ export function registerApplication(root, extendTargets = false) {
|
|
|
69
163
|
name: JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')).name ?? path.basename(root),
|
|
70
164
|
ownership: 'customer',
|
|
71
165
|
provider: 'cloudflare',
|
|
166
|
+
deliveryEngine: selectedEngine,
|
|
72
167
|
accountId: null,
|
|
73
168
|
audience: 'unconfigured',
|
|
74
169
|
targets,
|
|
@@ -77,16 +172,17 @@ export function registerApplication(root, extendTargets = false) {
|
|
|
77
172
|
const ignored = existsSync(ignoreFile) ? readFileSync(ignoreFile, 'utf8') : '';
|
|
78
173
|
if (!ignored.split(/\r?\n/).includes('.anhedral/'))
|
|
79
174
|
writeFileSync(ignoreFile, ignored + (ignored.endsWith('\n') || !ignored ? '' : '\n') + '.anhedral/\n');
|
|
80
|
-
|
|
175
|
+
writeProjectSection(root, 'cloudflare', project);
|
|
81
176
|
return project;
|
|
82
177
|
}
|
|
83
178
|
export function readApplication(root) {
|
|
84
|
-
const project =
|
|
179
|
+
const project = readProjectSection(root, 'cloudflare');
|
|
85
180
|
if (project.schemaVersion !== 1 ||
|
|
86
181
|
typeof project.id !== 'string' ||
|
|
87
182
|
!/^[a-f0-9-]{36}$/i.test(project.id) ||
|
|
88
183
|
project.ownership !== 'customer' ||
|
|
89
184
|
project.provider !== 'cloudflare' ||
|
|
185
|
+
!['void', 'wrangler'].includes(project.deliveryEngine) ||
|
|
90
186
|
!(project.accountId === null || accountPattern.test(project.accountId)) ||
|
|
91
187
|
!['unconfigured', 'public', 'private'].includes(project.audience) ||
|
|
92
188
|
!Array.isArray(project.targets))
|
|
@@ -114,14 +210,18 @@ export function readApplication(root) {
|
|
|
114
210
|
}
|
|
115
211
|
return project;
|
|
116
212
|
}
|
|
117
|
-
export const defaultRunner = (command, args, cwd, env) => new Promise((resolve, reject) => {
|
|
213
|
+
export const defaultRunner = (command, args, cwd, env, input) => new Promise((resolve, reject) => {
|
|
118
214
|
const invocation = resolveCommand(command, args);
|
|
119
215
|
const child = spawn(invocation.command, invocation.args, {
|
|
120
216
|
cwd,
|
|
121
217
|
env,
|
|
122
218
|
detached: process.platform !== 'win32',
|
|
123
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
219
|
+
stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],
|
|
124
220
|
});
|
|
221
|
+
if (input !== undefined) {
|
|
222
|
+
child.stdin?.on('error', () => { });
|
|
223
|
+
child.stdin?.end(input);
|
|
224
|
+
}
|
|
125
225
|
let output = '';
|
|
126
226
|
let oversized = false;
|
|
127
227
|
let interrupted = false;
|
|
@@ -152,7 +252,7 @@ export const defaultRunner = (command, args, cwd, env) => new Promise((resolve,
|
|
|
152
252
|
};
|
|
153
253
|
process.once('SIGINT', interrupt);
|
|
154
254
|
process.once('SIGTERM', interrupt);
|
|
155
|
-
child.stdout
|
|
255
|
+
child.stdout?.on('data', (chunk) => {
|
|
156
256
|
if (!oversized)
|
|
157
257
|
output += chunk.toString();
|
|
158
258
|
if (output.length > 8 * 1024 * 1024) {
|
|
@@ -161,11 +261,17 @@ export const defaultRunner = (command, args, cwd, env) => new Promise((resolve,
|
|
|
161
261
|
}
|
|
162
262
|
});
|
|
163
263
|
// Do not persist raw build/provider output: it can contain credentials or customer data.
|
|
164
|
-
child.stderr
|
|
264
|
+
child.stderr?.resume();
|
|
265
|
+
const requestedDeadline = Number(env.ANHEDRAL_COMMAND_TIMEOUT_MS);
|
|
266
|
+
const commandDeadline = Number.isInteger(requestedDeadline) &&
|
|
267
|
+
requestedDeadline >= 1 &&
|
|
268
|
+
requestedDeadline <= 20 * 60 * 1000
|
|
269
|
+
? requestedDeadline
|
|
270
|
+
: 20 * 60 * 1000;
|
|
165
271
|
const timer = setTimeout(() => {
|
|
166
272
|
timedOut = true;
|
|
167
273
|
stop();
|
|
168
|
-
},
|
|
274
|
+
}, commandDeadline);
|
|
169
275
|
const clean = () => {
|
|
170
276
|
clearTimeout(timer);
|
|
171
277
|
if (forceTimer)
|
package/dist/provider-auth.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
1
|
import { EAS_CLI_VERSION, STACK_DEPENDENCIES } from './dependencies.js';
|
|
3
2
|
import { realpathSync } from 'node:fs';
|
|
4
3
|
import { spawn } from 'node:child_process';
|
|
5
|
-
import {
|
|
4
|
+
import { readProjectSection } from './project-config.js';
|
|
6
5
|
import { validateSetupPlan } from './readiness.js';
|
|
7
6
|
import { resolveCommand } from './command.js';
|
|
8
7
|
import { defaultRunner } from './project-state.js';
|
|
@@ -75,7 +74,7 @@ export function requiredProviders(root) {
|
|
|
75
74
|
root = realpathSync(root);
|
|
76
75
|
let plan;
|
|
77
76
|
try {
|
|
78
|
-
plan =
|
|
77
|
+
plan = readProjectSection(root, 'setup');
|
|
79
78
|
validateSetupPlan(plan);
|
|
80
79
|
}
|
|
81
80
|
catch {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasProjectSection, readProjectSection } from './project-config.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { inspectProject } from './readiness.js';
|
|
4
4
|
import { defaultRunner } from './project-state.js';
|
|
5
5
|
import { vercelApplicationStatus } from './vercel.js';
|
|
6
6
|
import { applicationStatus } from './delivery.js';
|
|
7
|
+
import { supportsVoidRuntime, VOID_VERSION } from './void.js';
|
|
8
|
+
import { supportsWorkspaceRuntime } from './runtime-policy.js';
|
|
9
|
+
import { PACKAGE_MANAGER } from './dependencies.js';
|
|
7
10
|
/** Explicit opt-in: checks local tools and existing provider context without setup or deployment. */
|
|
8
11
|
export async function inspectProviderReadiness(root, run = defaultRunner) {
|
|
9
12
|
root = path.resolve(root);
|
|
@@ -24,13 +27,28 @@ export async function inspectProviderReadiness(root, run = defaultRunner) {
|
|
|
24
27
|
checks.push({ id, ok: false, detail, nextAction });
|
|
25
28
|
}
|
|
26
29
|
};
|
|
27
|
-
|
|
30
|
+
let voidTargets = [];
|
|
31
|
+
try {
|
|
32
|
+
const manifest = readProjectSection(root, 'cloudflare');
|
|
33
|
+
if (manifest.deliveryEngine === 'void' && Array.isArray(manifest.targets))
|
|
34
|
+
voidTargets = manifest.targets.filter((target) => typeof target.directory === 'string' && /^apps\/[a-z0-9-]+$/.test(target.directory));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Provider readiness below reports invalid or unconfigured manifests.
|
|
38
|
+
}
|
|
28
39
|
checks.push({
|
|
29
40
|
id: 'node',
|
|
30
|
-
ok:
|
|
31
|
-
|
|
41
|
+
ok: voidTargets.length
|
|
42
|
+
? supportsVoidRuntime(process.versions.node)
|
|
43
|
+
: supportsWorkspaceRuntime(process.versions.node),
|
|
44
|
+
detail: voidTargets.length
|
|
45
|
+
? 'Void applications require Node.js 24.21.0 or newer.'
|
|
46
|
+
: 'Generated workspaces require Node 22.13+ on 22.x, or Node 24+.',
|
|
32
47
|
});
|
|
33
|
-
|
|
48
|
+
for (const target of voidTargets)
|
|
49
|
+
await check(`void:${target.directory}`, async () => (await run('pnpm', ['exec', 'void', '--version'], path.join(root, target.directory), environment)).trim() === VOID_VERSION, `Pinned Void ${VOID_VERSION} is available in ${target.directory}`, 'Install the committed workspace lockfile and the pinned Void version.');
|
|
50
|
+
await check('pnpm', async () => (await run('pnpm', ['--version'], root, environment)).trim() ===
|
|
51
|
+
PACKAGE_MANAGER.slice('pnpm@'.length), `${PACKAGE_MANAGER} is available`, `Install ${PACKAGE_MANAGER} before operating this workspace.`);
|
|
34
52
|
await check('git', async () => (await run('git', ['--version'], root, environment)).startsWith('git version '), 'Git is available', 'Install Git.');
|
|
35
53
|
await check('git-identity', async () => Boolean((await run('git', ['var', 'GIT_AUTHOR_IDENT'], root, environment)).trim()), 'Git author identity is configured; its value is not recorded', 'Configure your own Git name and email locally.');
|
|
36
54
|
await check('github', async () => {
|
|
@@ -41,11 +59,10 @@ export async function inspectProviderReadiness(root, run = defaultRunner) {
|
|
|
41
59
|
}, 'GitHub CLI can identify its authenticated account', 'Complete gh auth login locally for the intended GitHub account.');
|
|
42
60
|
const providers = [];
|
|
43
61
|
for (const provider of ['vercel', 'cloudflare']) {
|
|
44
|
-
const file = path.join(root, provider === 'vercel' ? 'anhedral.web.json' : 'anhedral.project.json');
|
|
45
|
-
if (!existsSync(file))
|
|
46
|
-
continue;
|
|
47
62
|
try {
|
|
48
|
-
|
|
63
|
+
if (!hasProjectSection(root, provider))
|
|
64
|
+
continue;
|
|
65
|
+
const manifest = readProjectSection(root, provider);
|
|
49
66
|
const connected = provider === 'vercel' ? manifest.projectId && manifest.teamId : manifest.accountId;
|
|
50
67
|
if (!connected || manifest.audience === 'unconfigured')
|
|
51
68
|
throw new Error('unconfigured');
|
|
@@ -67,7 +84,7 @@ export async function inspectProviderReadiness(root, run = defaultRunner) {
|
|
|
67
84
|
provider,
|
|
68
85
|
connection: 'blocked',
|
|
69
86
|
deployment: 'unverified',
|
|
70
|
-
nextAction: `Inspect ${
|
|
87
|
+
nextAction: `Inspect the ${provider} section in anhedral.json and sign in to its recorded account. Connect an unconfigured app or run recover for a fresh clone; do not change the audience to bypass access checks.`,
|
|
71
88
|
});
|
|
72
89
|
}
|
|
73
90
|
}
|
|
@@ -44,7 +44,10 @@ async function neon(context) {
|
|
|
44
44
|
if (!['postgres:', 'postgresql:'].includes(parsed.protocol) ||
|
|
45
45
|
!parsed.hostname.endsWith('.neon.tech'))
|
|
46
46
|
throw new Error('Neon returned an unexpected database connection.');
|
|
47
|
-
return result({ project: id }, { DATABASE_URL: uri }
|
|
47
|
+
return result({ project: id }, { DATABASE_URL: uri }, [
|
|
48
|
+
'Configure DATABASE_URL_UNPOOLED with the intended direct migration connection in ignored packages/db/.env; runtime provisioning does not configure migration credentials.',
|
|
49
|
+
'Run pnpm db:generate, review the SQL, then run pnpm db:migrate against the intended database before testing authentication or application data.',
|
|
50
|
+
]);
|
|
48
51
|
}
|
|
49
52
|
async function clerk(context) {
|
|
50
53
|
const { settings: config, api } = context;
|
package/dist/providers/api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function object(value: unknown): ApiObject;
|
|
|
4
4
|
export declare function list(value: unknown): ApiObject[];
|
|
5
5
|
export declare function text(value: unknown): string;
|
|
6
6
|
export declare function resourceId(value: unknown): string;
|
|
7
|
+
/** Stable configuration and operation identity, never a password verifier. */
|
|
7
8
|
export declare function digest(value: unknown): string;
|
|
8
9
|
export declare const CREDENTIALS: Record<IntegrationProvider, string>;
|
|
9
10
|
export interface ApiRequest {
|
package/dist/providers/api.js
CHANGED
|
@@ -23,6 +23,7 @@ export function resourceId(value) {
|
|
|
23
23
|
throw new Error('Provider returned an invalid resource ID.');
|
|
24
24
|
return id;
|
|
25
25
|
}
|
|
26
|
+
/** Stable configuration and operation identity, never a password verifier. */
|
|
26
27
|
export function digest(value) {
|
|
27
28
|
const canonical = (item) => Array.isArray(item)
|
|
28
29
|
? item.map(canonical)
|
package/dist/providers/config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { hasProjectSection, readProjectSection } from '../project-config.js';
|
|
4
3
|
import { validateSetupPlan } from '../readiness.js';
|
|
5
4
|
import { INTEGRATION_PROVIDERS, PROVIDER_DEFINITIONS, PROVIDER_EVENT_PATTERN, PROVIDER_IDENTITY_PATTERN, PROVIDER_TEXT_PATTERN, PROVIDER_WEBHOOK_PATTERN, } from './definitions.js';
|
|
6
5
|
export { INTEGRATION_PROVIDERS } from './definitions.js';
|
|
@@ -65,16 +64,15 @@ export function validateProviderConfiguration(value, selected = INTEGRATION_PROV
|
|
|
65
64
|
}
|
|
66
65
|
export function providerConfiguration(root) {
|
|
67
66
|
root = realpathSync(root);
|
|
68
|
-
const file = path.join(root, 'anhedral.providers.json');
|
|
69
67
|
const selected = selectedIntegrations(root);
|
|
70
|
-
if (!
|
|
68
|
+
if (!hasProjectSection(root, 'providers'))
|
|
71
69
|
return { schemaVersion: 1, providers: {} };
|
|
72
70
|
let value;
|
|
73
71
|
try {
|
|
74
|
-
value =
|
|
72
|
+
value = readProjectSection(root, 'providers');
|
|
75
73
|
}
|
|
76
74
|
catch {
|
|
77
|
-
throw new Error('Invalid anhedral.providers.
|
|
75
|
+
throw new Error('Invalid anhedral.json providers configuration.');
|
|
78
76
|
}
|
|
79
77
|
validateProviderConfiguration(value, selected);
|
|
80
78
|
return value;
|
|
@@ -154,7 +152,7 @@ export function providerRequirements(id, config) {
|
|
|
154
152
|
return missing;
|
|
155
153
|
}
|
|
156
154
|
export function selectedIntegrations(root) {
|
|
157
|
-
const setup =
|
|
155
|
+
const setup = readProjectSection(root, 'setup');
|
|
158
156
|
validateSetupPlan(setup);
|
|
159
157
|
return INTEGRATION_PROVIDERS.filter((id) => setup.products.includes(id) || (id === 'openai' && setup.products.includes('ai-sdk')));
|
|
160
158
|
}
|
|
@@ -35,7 +35,7 @@ export async function provisionSelectedProviders(root, dryRun = false, run = def
|
|
|
35
35
|
return { ...plan, ready: plan.configured, results: [], configuredFiles: [] };
|
|
36
36
|
for (const provider of plan.providers) {
|
|
37
37
|
if (provider.missing.length)
|
|
38
|
-
throw new Error(`${provider.provider}: complete anhedral.
|
|
38
|
+
throw new Error(`${provider.provider}: complete anhedral.json providers configuration (${provider.missing.join(', ')}).`);
|
|
39
39
|
if (!environment[provider.credential])
|
|
40
40
|
throw new Error(`${provider.provider}: supply ${provider.credential} before provisioning.`);
|
|
41
41
|
}
|
|
@@ -6,8 +6,8 @@ export declare function integrationStatus(root: string): {
|
|
|
6
6
|
providers: {
|
|
7
7
|
provider: string;
|
|
8
8
|
operations: {
|
|
9
|
+
descriptor: import("./state.js").OperationDescriptor;
|
|
9
10
|
recovery: string;
|
|
10
|
-
descriptor?: import("./state.js").OperationDescriptor | undefined;
|
|
11
11
|
resources?: import("./receipts.js").MinimalReceipt | undefined;
|
|
12
12
|
operation: string;
|
|
13
13
|
status: "pending" | "complete";
|
|
@@ -6,5 +6,5 @@ export declare function runtimeTargets(root: string, values: RuntimeValues): Rec
|
|
|
6
6
|
export declare function configureRuntime(root: string, values: RuntimeValues, run: DeliveryRunner): Promise<string[]>;
|
|
7
7
|
export declare function configuredRuntime(root: string): RuntimeValues;
|
|
8
8
|
/** Read application-owned credentials separately from integration receipts. Never write,
|
|
9
|
-
* return unrelated environment keys, or copy
|
|
9
|
+
* return unrelated environment keys, or copy server secrets to other targets. */
|
|
10
10
|
export declare function applicationRuntime(root: string, run: DeliveryRunner): Promise<Record<string, RuntimeValues>>;
|
|
@@ -2,14 +2,22 @@ import path from 'node:path';
|
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { existsSync, lstatSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
5
|
+
import { readProjectSection } from '../project-config.js';
|
|
5
6
|
import { atomicJson, readConfig } from '../project-state.js';
|
|
6
7
|
import { digest } from './api.js';
|
|
7
8
|
import { validateSetupPlan } from '../readiness.js';
|
|
8
9
|
import { isIP } from 'node:net';
|
|
9
10
|
import { providerConfiguration } from './config.js';
|
|
11
|
+
function serverRuntimeFile(root, runtime, hosting) {
|
|
12
|
+
const directory = `apps/${runtime}`;
|
|
13
|
+
if (runtime === 'web' && hosting === 'vercel')
|
|
14
|
+
return `${directory}/.env.local`;
|
|
15
|
+
return `${directory}/${existsSync(path.join(root, directory, 'void.config.ts')) ? '.env' : '.dev.vars'}`;
|
|
16
|
+
}
|
|
10
17
|
export const RUNTIME_KEYS = [
|
|
11
18
|
'BETTER_AUTH_SECRET',
|
|
12
19
|
'BETTER_AUTH_URL',
|
|
20
|
+
'NEON_REALTIME_SECRET',
|
|
13
21
|
'DATABASE_URL',
|
|
14
22
|
'CLERK_SECRET_KEY',
|
|
15
23
|
'CLERK_PUBLISHABLE_KEY',
|
|
@@ -37,22 +45,20 @@ function validateValues(values) {
|
|
|
37
45
|
}
|
|
38
46
|
export function runtimeTargets(root, values) {
|
|
39
47
|
validateValues(values);
|
|
40
|
-
const setup =
|
|
48
|
+
const setup = readProjectSection(root, 'setup');
|
|
41
49
|
validateSetupPlan(setup);
|
|
42
50
|
const targets = {};
|
|
43
51
|
const runtime = setup.products.includes('hono') ? 'api' : 'web';
|
|
44
52
|
const server = Object.fromEntries(Object.entries(values).filter(([key]) => !key.startsWith('EXPO_PUBLIC_')));
|
|
45
53
|
if (existsSync(path.join(root, `apps/${runtime}`)))
|
|
46
|
-
targets[
|
|
54
|
+
targets[serverRuntimeFile(root, runtime, setup.hosting)] = server;
|
|
47
55
|
if (runtime === 'api' &&
|
|
48
56
|
existsSync(path.join(root, 'apps/web')) &&
|
|
49
57
|
values.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY)
|
|
50
|
-
targets[
|
|
58
|
+
targets[serverRuntimeFile(root, 'web', setup.hosting)] = {
|
|
51
59
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: values.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
|
|
52
60
|
...(values.CLERK_SECRET_KEY ? { CLERK_SECRET_KEY: values.CLERK_SECRET_KEY } : {}),
|
|
53
61
|
};
|
|
54
|
-
if (values.DATABASE_URL && existsSync(path.join(root, 'packages/db')))
|
|
55
|
-
targets['packages/db/.env'] = { DATABASE_URL: values.DATABASE_URL };
|
|
56
62
|
if (setup.products.includes('expo')) {
|
|
57
63
|
const mobile = Object.fromEntries(Object.entries(values).filter(([key]) => key.startsWith('EXPO_PUBLIC_')));
|
|
58
64
|
if (values.CLERK_PUBLISHABLE_KEY)
|
|
@@ -187,18 +193,24 @@ function publicAuthOrigin(value) {
|
|
|
187
193
|
!['localhost', 'local', 'internal', 'test', 'invalid', 'example'].some((suffix) => hostname === suffix || hostname.endsWith(`.${suffix}`)));
|
|
188
194
|
}
|
|
189
195
|
/** Read application-owned credentials separately from integration receipts. Never write,
|
|
190
|
-
* return unrelated environment keys, or copy
|
|
196
|
+
* return unrelated environment keys, or copy server secrets to other targets. */
|
|
191
197
|
export async function applicationRuntime(root, run) {
|
|
192
198
|
root = realpathSync(root);
|
|
193
|
-
const setup =
|
|
199
|
+
const setup = readProjectSection(root, 'setup');
|
|
194
200
|
validateSetupPlan(setup);
|
|
195
|
-
|
|
201
|
+
const betterAuth = setup.products.includes('better-auth');
|
|
202
|
+
const neonRealtime = setup.products.includes('neon-realtime');
|
|
203
|
+
const keys = [
|
|
204
|
+
...(betterAuth ? ['BETTER_AUTH_SECRET', 'BETTER_AUTH_URL'] : []),
|
|
205
|
+
...(neonRealtime ? ['NEON_REALTIME_SECRET'] : []),
|
|
206
|
+
];
|
|
207
|
+
if (!keys.length)
|
|
196
208
|
return {};
|
|
197
209
|
const runtime = setup.products.includes('hono') ? 'api' : 'web';
|
|
198
|
-
const relative =
|
|
210
|
+
const relative = serverRuntimeFile(root, runtime, setup.hosting);
|
|
199
211
|
const file = path.join(root, relative);
|
|
200
212
|
if (!existsSync(file))
|
|
201
|
-
throw new Error(`Configure
|
|
213
|
+
throw new Error(`Configure ${keys.join(' and ')} in ignored ${relative} before shipping.`);
|
|
202
214
|
if (realpathSync(path.dirname(file)) !== path.dirname(file) ||
|
|
203
215
|
!lstatSync(file).isFile() ||
|
|
204
216
|
lstatSync(file).isSymbolicLink())
|
|
@@ -210,22 +222,33 @@ export async function applicationRuntime(root, run) {
|
|
|
210
222
|
if ((await run('git', ['check-ignore', '--no-index', '--', relative], root, process.env)).trim() !==
|
|
211
223
|
relative)
|
|
212
224
|
throw new Error('Ignore application runtime files before shipping.');
|
|
213
|
-
if (relative.endsWith('/.
|
|
214
|
-
existsSync(path.join(path.dirname(file), 'wrangler.jsonc'))
|
|
225
|
+
if (!relative.endsWith('/.env.local') &&
|
|
226
|
+
(existsSync(path.join(path.dirname(file), 'wrangler.jsonc')) ||
|
|
227
|
+
existsSync(path.join(path.dirname(file), 'anhedral.cloudflare.json')))) {
|
|
215
228
|
const config = readConfig(path.dirname(file));
|
|
216
229
|
if (config.vars &&
|
|
217
230
|
typeof config.vars === 'object' &&
|
|
218
|
-
|
|
219
|
-
throw new Error(
|
|
231
|
+
keys.some((key) => Object.hasOwn(config.vars, key)))
|
|
232
|
+
throw new Error(`Remove ${neonRealtime ? 'application runtime' : 'Better Auth'} values from tracked Wrangler vars, review and commit that change, then configure the private runtime file before shipping.`);
|
|
220
233
|
}
|
|
221
234
|
const content = readBoundedFile(file, MAX_PROJECT_JSON_BYTES).toString('utf8');
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
const values = {};
|
|
236
|
+
if (betterAuth) {
|
|
237
|
+
const secret = applicationValue(content, 'BETTER_AUTH_SECRET');
|
|
238
|
+
if (secret.length < 32 ||
|
|
239
|
+
/change.?me|replace.?me|placeholder|your.?secret|example|generate.?me/i.test(secret) ||
|
|
240
|
+
new Set(secret).size < 8)
|
|
241
|
+
throw new Error('BETTER_AUTH_SECRET requires a generated nonplaceholder secret of at least 32 characters.');
|
|
242
|
+
const origin = applicationValue(content, 'BETTER_AUTH_URL');
|
|
243
|
+
if (!publicAuthOrigin(origin))
|
|
244
|
+
throw new Error('BETTER_AUTH_URL must be an HTTPS public origin without credentials, path, query or fragment.');
|
|
245
|
+
Object.assign(values, { BETTER_AUTH_SECRET: secret, BETTER_AUTH_URL: origin });
|
|
246
|
+
}
|
|
247
|
+
if (neonRealtime) {
|
|
248
|
+
const secret = applicationValue(content, 'NEON_REALTIME_SECRET');
|
|
249
|
+
if (/change.?me|replace.?me|placeholder|your.?secret|example|generate.?me/i.test(secret))
|
|
250
|
+
throw new Error('Configure the nonplaceholder NEON_REALTIME_SECRET from the intended Neon Realtime service.');
|
|
251
|
+
values.NEON_REALTIME_SECRET = secret;
|
|
252
|
+
}
|
|
253
|
+
return { [relative]: values };
|
|
231
254
|
}
|
|
@@ -12,8 +12,8 @@ export declare function readProviderStateStatus(directory: string): {
|
|
|
12
12
|
providers: {
|
|
13
13
|
provider: string;
|
|
14
14
|
operations: {
|
|
15
|
+
descriptor: OperationDescriptor;
|
|
15
16
|
recovery: string;
|
|
16
|
-
descriptor?: OperationDescriptor | undefined;
|
|
17
17
|
resources?: MinimalReceipt | undefined;
|
|
18
18
|
operation: string;
|
|
19
19
|
status: "pending" | "complete";
|
|
@@ -31,7 +31,6 @@ export declare class ProvisioningState {
|
|
|
31
31
|
constructor(directory: string, write?: typeof atomicJson);
|
|
32
32
|
private assertCredentials;
|
|
33
33
|
private retainCredentials;
|
|
34
|
-
private migrate;
|
|
35
34
|
/** No configurations, credentials, provider payloads or mutation bodies in status. */
|
|
36
35
|
status(): {
|
|
37
36
|
schemaVersion: number;
|