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/provision.js
CHANGED
|
@@ -8,30 +8,9 @@ import { cloudflareRequest, listCloudflare } from './cloudflare.js';
|
|
|
8
8
|
const resourceTypes = {
|
|
9
9
|
d1: { endpoint: '/d1/database', nameField: 'name', idField: 'uuid' },
|
|
10
10
|
r2: { endpoint: '/r2/buckets', nameField: 'name', idField: 'name' },
|
|
11
|
-
kv: { endpoint: '/storage/kv/namespaces', nameField: 'title', idField: 'id' },
|
|
12
|
-
queue: { endpoint: '/queues', nameField: 'queue_name', idField: 'queue_id' },
|
|
13
|
-
stream: { endpoint: '/pipelines/v1/streams', nameField: 'name', idField: 'id' },
|
|
14
11
|
};
|
|
15
12
|
async function listResources(request, kind) {
|
|
16
13
|
const { endpoint } = resourceTypes[kind];
|
|
17
|
-
if (kind === 'stream') {
|
|
18
|
-
const streams = [];
|
|
19
|
-
let bytes = 0;
|
|
20
|
-
for (let page = 0; page < 1000; page++) {
|
|
21
|
-
const response = await request('GET', `${endpoint}?page=${page}&per_page=100`);
|
|
22
|
-
if (!Array.isArray(response.result))
|
|
23
|
-
throw new Error('Unsupported stream listing.');
|
|
24
|
-
if (response.result.some((item) => !item || typeof item !== 'object' || Array.isArray(item)))
|
|
25
|
-
throw new Error('Unsupported stream resource.');
|
|
26
|
-
streams.push(...response.result);
|
|
27
|
-
bytes += Buffer.byteLength(JSON.stringify(response.result));
|
|
28
|
-
if (streams.length > 10_000 || bytes > 10 * 1024 * 1024)
|
|
29
|
-
throw new Error('Stream listing exceeded collection limit; select resource IDs explicitly.');
|
|
30
|
-
if (response.result.length < 100)
|
|
31
|
-
return streams;
|
|
32
|
-
}
|
|
33
|
-
throw new Error('Stream listing exceeded pagination limit.');
|
|
34
|
-
}
|
|
35
14
|
if (kind !== 'r2')
|
|
36
15
|
return listCloudflare(request, endpoint);
|
|
37
16
|
const value = (await request('GET', endpoint)).result;
|
|
@@ -39,15 +18,6 @@ async function listResources(request, kind) {
|
|
|
39
18
|
throw new Error('Unsupported or truncated R2 bucket listing; select resources explicitly with provider tooling.');
|
|
40
19
|
return value.buckets;
|
|
41
20
|
}
|
|
42
|
-
async function assertPrivateStream(request, id) {
|
|
43
|
-
if (!/^[a-f0-9]{32}$/i.test(id))
|
|
44
|
-
throw new Error('Invalid Basin stream ID.');
|
|
45
|
-
const stream = (await request('GET', `${resourceTypes.stream.endpoint}/${id}`)).result;
|
|
46
|
-
if (stream?.http?.enabled !== false ||
|
|
47
|
-
stream.worker_binding?.enabled !== true ||
|
|
48
|
-
stream.format?.type !== 'json')
|
|
49
|
-
throw new Error('Basin stream must use a private Worker binding with JSON events and HTTP ingestion disabled.');
|
|
50
|
-
}
|
|
51
21
|
/** Provisioning and recovery use the same independently verified private-storage policy. */
|
|
52
22
|
async function assertPrivateBucket(request, name) {
|
|
53
23
|
const endpoint = `${resourceTypes.r2.endpoint}/${encodeURIComponent(name)}/domains`;
|
|
@@ -74,7 +44,6 @@ export function planProvisioning(root) {
|
|
|
74
44
|
for (const [kind, field] of [
|
|
75
45
|
['d1', 'd1_databases'],
|
|
76
46
|
['r2', 'r2_buckets'],
|
|
77
|
-
['kv', 'kv_namespaces'],
|
|
78
47
|
]) {
|
|
79
48
|
const entries = config[field];
|
|
80
49
|
if (entries === undefined)
|
|
@@ -84,12 +53,8 @@ export function planProvisioning(root) {
|
|
|
84
53
|
entries.forEach((entry, index) => {
|
|
85
54
|
if (!entry || typeof entry.binding !== 'string' || entry.jurisdiction)
|
|
86
55
|
throw new Error('Use an explicit provider workflow for jurisdiction-specific resources.');
|
|
87
|
-
const name = resourceName(kind === 'd1'
|
|
88
|
-
|
|
89
|
-
: kind === 'r2'
|
|
90
|
-
? entry.bucket_name
|
|
91
|
-
: (entry.anhedral_name ?? `${project.name}-${entry.binding.toLowerCase()}`));
|
|
92
|
-
const id = kind === 'd1' ? entry.database_id : kind === 'kv' ? entry.id : undefined;
|
|
56
|
+
const name = resourceName(kind === 'd1' ? entry.database_name : entry.bucket_name);
|
|
57
|
+
const id = kind === 'd1' ? entry.database_id : undefined;
|
|
93
58
|
resources.push({
|
|
94
59
|
kind,
|
|
95
60
|
name,
|
|
@@ -99,40 +64,12 @@ export function planProvisioning(root) {
|
|
|
99
64
|
});
|
|
100
65
|
});
|
|
101
66
|
}
|
|
102
|
-
const queues = config.queues;
|
|
103
|
-
for (const entry of [...(queues?.producers ?? []), ...(queues?.consumers ?? [])]) {
|
|
104
|
-
resources.push({ kind: 'queue', name: resourceName(entry.queue), target: target.id });
|
|
105
|
-
if ('dead_letter_queue' in entry && entry.dead_letter_queue)
|
|
106
|
-
resources.push({
|
|
107
|
-
kind: 'queue',
|
|
108
|
-
name: resourceName(entry.dead_letter_queue),
|
|
109
|
-
target: target.id,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
if (config.pipelines !== undefined) {
|
|
113
|
-
if (!Array.isArray(config.pipelines))
|
|
114
|
-
throw new Error('Invalid Basin stream bindings.');
|
|
115
|
-
config.pipelines.forEach((entry, index) => {
|
|
116
|
-
if (!entry ||
|
|
117
|
-
typeof entry.binding !== 'string' ||
|
|
118
|
-
typeof entry.stream !== 'string' ||
|
|
119
|
-
entry.pipeline)
|
|
120
|
-
throw new Error('Use explicit Basin stream bindings.');
|
|
121
|
-
resources.push({
|
|
122
|
-
kind: 'stream',
|
|
123
|
-
name: resourceName(`${project.name}-${entry.binding.toLowerCase()}`),
|
|
124
|
-
target: target.id,
|
|
125
|
-
id: entry.stream.startsWith('REPLACE_WITH_') ? undefined : entry.stream,
|
|
126
|
-
field: ['pipelines', index, 'stream'],
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
67
|
}
|
|
131
68
|
return {
|
|
132
69
|
projectId: project.id,
|
|
133
70
|
accountId: project.accountId,
|
|
134
71
|
resources,
|
|
135
|
-
externalIntegrations: [
|
|
72
|
+
externalIntegrations: [],
|
|
136
73
|
};
|
|
137
74
|
}
|
|
138
75
|
export async function provisionApplication(root, dryRun = false, run = defaultRunner, suppliedRequest) {
|
|
@@ -141,8 +78,6 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
|
|
|
141
78
|
assertNoDeletedServices(root, plan.resources);
|
|
142
79
|
if (dryRun)
|
|
143
80
|
return { ...plan, mutation: false };
|
|
144
|
-
if (readApplication(root).deliveryEngine === 'void')
|
|
145
|
-
return { ...plan, mutation: false, writer: 'void', deferredToDeployment: true };
|
|
146
81
|
return withApplicationLock(root, async () => {
|
|
147
82
|
const project = readApplication(root);
|
|
148
83
|
const plan = planProvisioning(root);
|
|
@@ -171,7 +106,7 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
|
|
|
171
106
|
previous.resources.some((entry) => !entry ||
|
|
172
107
|
typeof entry !== 'object' ||
|
|
173
108
|
Array.isArray(entry) ||
|
|
174
|
-
!['d1', 'r2'
|
|
109
|
+
!['d1', 'r2'].includes(String(entry.kind)) ||
|
|
175
110
|
['name', 'id'].some((field) => typeof entry[field] !== 'string') ||
|
|
176
111
|
typeof entry.reused !== 'boolean'))
|
|
177
112
|
throw new Error('Previous resource ownership cannot be verified.');
|
|
@@ -197,13 +132,6 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
|
|
|
197
132
|
if (!value)
|
|
198
133
|
value = (await request('POST', endpoint, {
|
|
199
134
|
[nameField]: resource.name,
|
|
200
|
-
...(resource.kind === 'stream'
|
|
201
|
-
? {
|
|
202
|
-
http: { enabled: false, authentication: true },
|
|
203
|
-
worker_binding: { enabled: true },
|
|
204
|
-
format: { type: 'json', unstructured: true },
|
|
205
|
-
}
|
|
206
|
-
: {}),
|
|
207
135
|
})).result;
|
|
208
136
|
if (!value || typeof value[idField] !== 'string' || !value[idField])
|
|
209
137
|
throw new Error('Provider did not return a resource identity; inspect provider state before retrying.');
|
|
@@ -231,8 +159,6 @@ export async function provisionApplication(root, dryRun = false, run = defaultRu
|
|
|
231
159
|
});
|
|
232
160
|
if (resource.kind === 'r2')
|
|
233
161
|
await assertPrivateBucket(request, resource.name);
|
|
234
|
-
if (resource.kind === 'stream')
|
|
235
|
-
await assertPrivateStream(request, receipt.id);
|
|
236
162
|
}
|
|
237
163
|
assertConfiguration();
|
|
238
164
|
if (resource.id && receipt.id !== resource.id)
|
|
@@ -276,8 +202,6 @@ export async function inspectApplicationResources(root, request) {
|
|
|
276
202
|
throw new Error('Committed resource identity differs from the registered account; recovery will not replace it.');
|
|
277
203
|
if (resource.kind === 'r2')
|
|
278
204
|
await assertPrivateBucket(request, resource.name);
|
|
279
|
-
if (resource.kind === 'stream')
|
|
280
|
-
await assertPrivateStream(request, id);
|
|
281
205
|
receipts.push({ kind: resource.kind, name: resource.name, id, target: resource.target });
|
|
282
206
|
}
|
|
283
207
|
return { resources: receipts, externalIntegrations: plan.externalIntegrations };
|
package/dist/readiness.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function validateSetupPlan(plan: unknown): asserts plan is {
|
|
|
17
17
|
cliVersion: string;
|
|
18
18
|
registryVersion: 1;
|
|
19
19
|
products: StandardProduct[];
|
|
20
|
-
hosting: 'cloudflare'
|
|
20
|
+
hosting: 'cloudflare';
|
|
21
21
|
name?: string;
|
|
22
22
|
registry: ResolvedStackRegistry;
|
|
23
23
|
};
|
package/dist/readiness.js
CHANGED
|
@@ -45,12 +45,7 @@ export function inspectProject(root) {
|
|
|
45
45
|
}
|
|
46
46
|
record('selection', standard.schemaVersion === 1 &&
|
|
47
47
|
JSON.stringify(standard.products) === JSON.stringify(plan.products) &&
|
|
48
|
-
standard.hosting ===
|
|
49
|
-
(plan.products.includes('next') ||
|
|
50
|
-
plan.products.includes('vinext') ||
|
|
51
|
-
plan.products.includes('expo')
|
|
52
|
-
? plan.hosting
|
|
53
|
-
: null), 'Setup plan matches project selection');
|
|
48
|
+
standard.hosting === plan.hosting, 'Setup plan matches project selection');
|
|
54
49
|
}
|
|
55
50
|
catch {
|
|
56
51
|
record('setup-plan', false, 'Missing, invalid or unsupported setup plan; inspect the project before changing it');
|
|
@@ -78,11 +73,11 @@ export function validateSetupPlan(plan) {
|
|
|
78
73
|
!value.products.length ||
|
|
79
74
|
!value.products.every((id) => STANDARD_PRODUCTS.includes(id)))
|
|
80
75
|
throw new Error('Unknown setup capabilities.');
|
|
81
|
-
if (value.hosting !== 'cloudflare'
|
|
76
|
+
if (value.hosting !== 'cloudflare')
|
|
82
77
|
throw new Error('Invalid hosting.');
|
|
83
78
|
validateRequirements(value.setup, value.products);
|
|
84
79
|
const selected = new Set(value.products);
|
|
85
|
-
resolveStandardProducts(selected, value.hosting
|
|
80
|
+
resolveStandardProducts(selected, value.hosting);
|
|
86
81
|
if (selected.size !== value.products.length)
|
|
87
82
|
throw new Error('Invalid or incomplete setup selection.');
|
|
88
83
|
if (value.name !== undefined && typeof value.name !== 'string')
|
package/dist/registry/add.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PROJECT_CONFIG_FILE, readProjectSection, writeProjectSection, hasProjectSection, } from '../project-config.js';
|
|
3
|
-
import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
|
|
4
|
-
import { scaffoldWebBackend } from '../scaffold/backend.js';
|
|
1
|
+
import { PROJECT_CONFIG_FILE, readProjectSection, writeProjectSection } from '../project-config.js';
|
|
5
2
|
import { configureDependencyPatches } from '../dependency-patches.js';
|
|
6
3
|
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
7
|
-
import {
|
|
4
|
+
import { assertWorkspaceRuntime } from '../scaffold/bootstrap.js';
|
|
8
5
|
import { registerApplication } from '../project-state.js';
|
|
9
|
-
import { registerVercelApplication } from '../vercel.js';
|
|
10
6
|
import { existsSync, lstatSync, readFileSync, realpathSync, rmSync } from 'node:fs';
|
|
11
7
|
import path from 'node:path';
|
|
12
8
|
import { isDeepStrictEqual } from 'node:util';
|
|
13
9
|
import { applyEdits, modify, parse } from 'jsonc-parser';
|
|
14
|
-
import {
|
|
10
|
+
import { installStackItem } from '../stack-registry.js';
|
|
15
11
|
import { inspectProject, validateSetupPlan } from '../readiness.js';
|
|
16
12
|
import { GENERATOR_VERSION } from '../version.js';
|
|
17
13
|
import { runStagedTransaction } from '../transaction.js';
|
|
18
14
|
import { inspectWorkspaceGraph } from '../workspace-graph.js';
|
|
19
15
|
import { execFile } from '../util.js';
|
|
20
|
-
import { supportsVoidRuntime, usesVoidSelection } from '../runtime-policy.js';
|
|
21
16
|
import { put } from '../scaffold/files.js';
|
|
22
17
|
import { writeStandardRoot } from '../scaffold/workspace.js';
|
|
23
|
-
import { configureVoidDelivery, refreshVoidEnvironment } from '../scaffold/void.js';
|
|
24
18
|
import { createRecipeContext } from './context.js';
|
|
25
|
-
import {
|
|
19
|
+
import { resolveStackRegistry, resolveStandardProducts } from './resolve.js';
|
|
26
20
|
import { sourceFiles, configurationFingerprints } from './receipt.js';
|
|
27
21
|
import { sourcePreview, validatePreviewPath, MAX_PREVIEW_TOTAL_BYTES, } from './preview.js';
|
|
28
22
|
/** Add recipes to an initialized workspace, refusing edits to customer-owned source. */
|
|
@@ -63,27 +57,11 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
63
57
|
const originalConfiguration = configurationFingerprints(root);
|
|
64
58
|
const selected = new Set(plan.products);
|
|
65
59
|
for (const id of request.items) {
|
|
66
|
-
if (!
|
|
60
|
+
if (!['stripe', 'revenuecat'].includes(id))
|
|
67
61
|
throw new Error(`Unknown stack product: ${id}.`);
|
|
68
62
|
selected.add(id);
|
|
69
63
|
}
|
|
70
|
-
|
|
71
|
-
if (!existingServerFeatures &&
|
|
72
|
-
request.items.some((id) => Boolean(getStackDefinition(id).runtime)))
|
|
73
|
-
selected.add('hono');
|
|
74
|
-
if (request.items.some((id) => ['stripe', 'revenuecat'].includes(id) && !plan.products.includes(id)))
|
|
75
|
-
resolveBillingProducts(selected);
|
|
76
|
-
if (['queues', 'basin', 'expo', 'images', 'analytics-engine'].some((id) => selected.has(id)) &&
|
|
77
|
-
hasProjectSection(root, 'cloudflare') &&
|
|
78
|
-
readProjectSection(root, 'cloudflare').deliveryEngine === 'void')
|
|
79
|
-
throw new Error('Expo web, Queues, Basin, Images and Analytics Engine require Wrangler delivery. They cannot be added to a Void project.');
|
|
80
|
-
resolveStandardProducts(selected, plan.hosting, false, false);
|
|
81
|
-
const voidSelected = usesVoidSelection([...selected], plan.hosting);
|
|
82
|
-
if (!request.dryRun &&
|
|
83
|
-
voidSelected &&
|
|
84
|
-
run === execFile &&
|
|
85
|
-
!supportsVoidRuntime(process.versions.node))
|
|
86
|
-
throw new Error('Cloudflare workspaces using Void require Node.js 24.21.0 or newer.');
|
|
64
|
+
resolveStandardProducts(selected, plan.hosting);
|
|
87
65
|
const options = {
|
|
88
66
|
root,
|
|
89
67
|
name: plan.name ?? path.basename(root),
|
|
@@ -94,13 +72,6 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
94
72
|
json: true,
|
|
95
73
|
initializeGit: false,
|
|
96
74
|
};
|
|
97
|
-
if (plan.products.includes('hono') &&
|
|
98
|
-
!existsSync(path.join(root, 'packages/contracts/package.json')) &&
|
|
99
|
-
(request.items.some((id) => ['vinext', 'next'].includes(id) && !plan.products.some((existing) => existing === id)) ||
|
|
100
|
-
(request.items.includes('better-auth') &&
|
|
101
|
-
!plan.products.includes('better-auth') &&
|
|
102
|
-
plan.products.some((id) => ['vinext', 'next'].includes(id)))))
|
|
103
|
-
throw new Error('This API predates shared contracts. Migrate its contracts and API endpoints explicitly before adding web/auth wiring.');
|
|
104
75
|
const registry = resolveStackRegistry(options);
|
|
105
76
|
const oldItems = new Map(plan.registry.items.map((item) => [item.name, item]));
|
|
106
77
|
const recipes = registry.items.filter((item) => item.installer === 'recipe' && !isDeepStrictEqual(oldItems.get(item.name), item));
|
|
@@ -121,22 +92,13 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
121
92
|
items: registry.items
|
|
122
93
|
.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item))
|
|
123
94
|
.map((item) => item.name),
|
|
124
|
-
bootstrapRequired:
|
|
125
|
-
!existsSync(path.join(root, 'apps/web/package.json')),
|
|
95
|
+
bootstrapRequired: false,
|
|
126
96
|
filesChecked: true,
|
|
127
97
|
targets: recipes.flatMap((item) => item.targets),
|
|
128
98
|
files: commitPaths,
|
|
129
99
|
conflicts,
|
|
130
100
|
...(request.preview ? { previews: [] } : {}),
|
|
131
101
|
};
|
|
132
|
-
// The upstream web generator requires network access and executes package scripts.
|
|
133
|
-
// A preview reports the resolved selection without invoking that generator.
|
|
134
|
-
if (request.dryRun && result.bootstrapRequired) {
|
|
135
|
-
result.filesChecked = false;
|
|
136
|
-
if (request.preview)
|
|
137
|
-
throw new Error('Source preview requires a new web bootstrap and cannot run offline. Use add --dry-run for the selection plan.');
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
102
|
await runStagedTransaction(root, {
|
|
141
103
|
dryRun: !!request.dryRun,
|
|
142
104
|
commitPaths,
|
|
@@ -146,27 +108,12 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
146
108
|
context.updating = true;
|
|
147
109
|
for (const item of registry.items)
|
|
148
110
|
Object.assign(context.bindings, item.bindings);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
bootstrapWorkspace(stage, options.name, run, true);
|
|
152
|
-
for (const item of recipes) {
|
|
153
|
-
if (item.name === 'expo' && plan.products.includes('expo')) {
|
|
154
|
-
scaffoldExpoRuntime(context);
|
|
155
|
-
}
|
|
156
|
-
else
|
|
157
|
-
await installStackItem(item, context);
|
|
158
|
-
}
|
|
159
|
-
// Connect a newly introduced backend without regenerating customer UI.
|
|
160
|
-
if (!plan.products.includes('hono') && selected.has('hono')) {
|
|
161
|
-
if (plan.products.includes('expo'))
|
|
162
|
-
scaffoldExpoRuntime(context);
|
|
163
|
-
if (plan.products.includes('next') || plan.products.includes('vinext'))
|
|
164
|
-
scaffoldWebBackend(context);
|
|
165
|
-
}
|
|
111
|
+
for (const item of recipes)
|
|
112
|
+
await installStackItem(item, context);
|
|
166
113
|
// Configuration items affect the existing runtime without regenerating its application source.
|
|
167
114
|
const configurationItems = registry.items.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item) && item.bindings);
|
|
168
115
|
if (configurationItems.length) {
|
|
169
|
-
const directory =
|
|
116
|
+
const directory = 'apps/api';
|
|
170
117
|
const file = `${directory}/${existsSync(path.join(stage, directory, 'anhedral.cloudflare.json')) ? 'anhedral.cloudflare.json' : 'wrangler.jsonc'}`;
|
|
171
118
|
let content = readFileSync(path.join(stage, file), 'utf8');
|
|
172
119
|
const config = parse(content);
|
|
@@ -180,14 +127,7 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
180
127
|
}
|
|
181
128
|
put(stage, file, content);
|
|
182
129
|
}
|
|
183
|
-
scaffoldCloudflareServiceContext(context);
|
|
184
130
|
writeStandardRoot(stage, options, registry, true);
|
|
185
|
-
if (voidSelected) {
|
|
186
|
-
configureVoidDelivery(stage);
|
|
187
|
-
refreshVoidEnvironment(stage);
|
|
188
|
-
}
|
|
189
|
-
if (options.products.includes('next') && options.hosting === 'vercel')
|
|
190
|
-
registerVercelApplication(stage);
|
|
191
131
|
if ([...sourceFiles(stage).keys()].some((file) => /^apps\/[^/]+\/(?:wrangler\.jsonc|anhedral\.cloudflare\.json)$/.test(file)))
|
|
192
132
|
registerApplication(stage, true);
|
|
193
133
|
if (!request.dryRun)
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
/** The foundation is generated locally from this exact CLI version. */
|
|
2
|
+
export declare const BOOTSTRAP_COMMAND: readonly ["anhedral", "init"];
|
|
3
|
+
export declare function bootstrapArguments(name: string, _cwd: string): string[];
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
export
|
|
4
|
-
'
|
|
5
|
-
'dlx',
|
|
6
|
-
SHADCN_PACKAGE,
|
|
7
|
-
'init',
|
|
8
|
-
'--monorepo',
|
|
9
|
-
'--template',
|
|
10
|
-
'next',
|
|
11
|
-
];
|
|
12
|
-
export function bootstrapArguments(name, cwd) {
|
|
13
|
-
return [...BOOTSTRAP_COMMAND.slice(1), '--defaults', '--name', name, '--cwd', cwd];
|
|
1
|
+
/** The foundation is generated locally from this exact CLI version. */
|
|
2
|
+
export const BOOTSTRAP_COMMAND = ['anhedral', 'init'];
|
|
3
|
+
export function bootstrapArguments(name, _cwd) {
|
|
4
|
+
return ['init', name];
|
|
14
5
|
}
|
|
@@ -3,16 +3,14 @@ import { addStackItems } from './add.js';
|
|
|
3
3
|
import { STACK_REGISTRY, STANDARD_PRODUCTS, getStackItem } from '../stack-registry.js';
|
|
4
4
|
import { printResult } from '../cli-output.js';
|
|
5
5
|
import { commandHelp } from './usage.js';
|
|
6
|
-
import { CliArgumentError, suggest } from '../cli-arguments.js';
|
|
6
|
+
import { CliArgumentError, suggest, commandArguments } from '../cli-arguments.js';
|
|
7
7
|
export async function runRegistry(args, json, output = { json }) {
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
8
|
+
const parsed = commandArguments('registry', args);
|
|
9
|
+
if (parsed.has('--help')) {
|
|
10
10
|
console.log(commandHelp('registry'));
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
throw new Error('Unknown registry option.');
|
|
15
|
-
const [action = 'list', name, ...extra] = positional;
|
|
13
|
+
const [action = 'list', name, ...extra] = parsed.positional;
|
|
16
14
|
if (action === 'capabilities' && !name && !extra.length) {
|
|
17
15
|
if (output.quiet && !json)
|
|
18
16
|
return;
|
|
@@ -69,12 +67,12 @@ export async function runAdd(args, output = {}) {
|
|
|
69
67
|
}
|
|
70
68
|
const items = positional;
|
|
71
69
|
if (!items.length)
|
|
72
|
-
throw new Error('Select
|
|
70
|
+
throw new Error('Select payments: anhedral add stripe revenuecat [--cwd <directory>].');
|
|
73
71
|
for (const item of items) {
|
|
74
|
-
if (
|
|
72
|
+
if (['stripe', 'revenuecat'].includes(item))
|
|
75
73
|
continue;
|
|
76
|
-
const correction = suggest(item,
|
|
77
|
-
throw new CliArgumentError(`Unknown stack part.${correction ? ` Did you mean ${correction}?` : ''}`, 'Select a project with --cwd <directory
|
|
74
|
+
const correction = suggest(item, ['stripe', 'revenuecat']);
|
|
75
|
+
throw new CliArgumentError(`Unknown stack part.${correction ? ` Did you mean ${correction}?` : ''}`, 'Select a project with --cwd <directory>; optional additions are stripe and revenuecat.');
|
|
78
76
|
}
|
|
79
77
|
printResult('add', await addStackItems(process.cwd(), {
|
|
80
78
|
items,
|
package/dist/registry/context.js
CHANGED
package/dist/registry/options.js
CHANGED
|
@@ -1,60 +1,30 @@
|
|
|
1
|
-
import { applyPreset } from './presets.js';
|
|
2
1
|
import { resolveStandardProducts } from './resolve.js';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import { packageNameFromText } from '../render.js';
|
|
5
|
-
import { STANDARD_PRODUCTS } from '../stack-registry.js';
|
|
6
4
|
function readGitFlag(token, previous) {
|
|
7
5
|
const value = token === '--git';
|
|
8
6
|
if (previous !== undefined && value !== previous)
|
|
9
7
|
throw new Error('Conflicting Git options.');
|
|
10
8
|
return value;
|
|
11
9
|
}
|
|
12
|
-
function readHostingFlag(value, previous, specified) {
|
|
13
|
-
if (value !== 'cloudflare' && value !== 'vercel')
|
|
14
|
-
throw new Error('hosting must be cloudflare or vercel.');
|
|
15
|
-
if (specified && previous !== value)
|
|
16
|
-
throw new Error('Conflicting hosting options.');
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
10
|
function parseStandardFlags(remaining) {
|
|
20
11
|
const products = new Set();
|
|
21
|
-
|
|
22
|
-
let hostingSpecified = false;
|
|
12
|
+
const hosting = 'cloudflare';
|
|
23
13
|
let gitSpecified;
|
|
24
|
-
|
|
25
|
-
for (let index = 0; index < remaining.length; index++) {
|
|
26
|
-
const token = remaining[index];
|
|
14
|
+
for (const token of remaining) {
|
|
27
15
|
if (['--skip-install', '--dry-run', '--json', '--verbose'].includes(token))
|
|
28
16
|
continue;
|
|
29
17
|
if (token === '--git' || token === '--no-git') {
|
|
30
18
|
gitSpecified = readGitFlag(token, gitSpecified);
|
|
31
19
|
continue;
|
|
32
20
|
}
|
|
33
|
-
if (token === '--
|
|
34
|
-
|
|
35
|
-
throw new Error('Specify --preset once.');
|
|
36
|
-
preset = token === '--preset' ? remaining[++index] : token.slice('--preset='.length);
|
|
37
|
-
if (!preset || preset.startsWith('-'))
|
|
38
|
-
throw new Error('Supply a value for --preset.');
|
|
21
|
+
if (token === '--stripe' || token === '--revenuecat') {
|
|
22
|
+
products.add(token.slice(2));
|
|
39
23
|
continue;
|
|
40
24
|
}
|
|
41
|
-
|
|
42
|
-
const value = token === '--hosting' ? remaining[++index] : token.slice('--hosting='.length);
|
|
43
|
-
hosting = readHostingFlag(value, hosting, hostingSpecified);
|
|
44
|
-
hostingSpecified = true;
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
const value = token.replace(/^--/, '');
|
|
48
|
-
if (!STANDARD_PRODUCTS.includes(value)) {
|
|
49
|
-
throw new Error(`Unknown standard product: ${token}. Select only required products.`);
|
|
50
|
-
}
|
|
51
|
-
products.add(value);
|
|
25
|
+
throw new Error(`Unknown init option: ${token}. The core stack is always included; optional additions are --stripe and --revenuecat.`);
|
|
52
26
|
}
|
|
53
|
-
|
|
54
|
-
applyPreset(preset, products);
|
|
55
|
-
if (!hostingSpecified && products.has('next'))
|
|
56
|
-
hosting = 'vercel';
|
|
57
|
-
return { products, hosting, hostingSpecified, gitSpecified };
|
|
27
|
+
return { products, hosting, gitSpecified };
|
|
58
28
|
}
|
|
59
29
|
export function parseStandardOptions(args) {
|
|
60
30
|
const remaining = [...args];
|
|
@@ -63,8 +33,8 @@ export function parseStandardOptions(args) {
|
|
|
63
33
|
if (!directory || directory.startsWith('-'))
|
|
64
34
|
throw new Error('Specify a valid initialization directory.');
|
|
65
35
|
const root = path.resolve(directory);
|
|
66
|
-
const { products, hosting,
|
|
67
|
-
resolveStandardProducts(products, hosting
|
|
36
|
+
const { products, hosting, gitSpecified } = parseStandardFlags(remaining);
|
|
37
|
+
resolveStandardProducts(products, hosting);
|
|
68
38
|
return {
|
|
69
39
|
root,
|
|
70
40
|
name: packageNameFromText(path.basename(root)),
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Hosting, StandardOptions, StandardProduct, StackRegistryItem } from './types.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function resolveStandardProducts(selected: Set<StandardProduct>, hosting: Hosting, hostingSpecified: boolean, initializing?: boolean): void;
|
|
2
|
+
export declare const CORE_PRODUCTS: readonly StandardProduct[];
|
|
3
|
+
/** Every initialization uses one foundation; only payment additions are optional. */
|
|
4
|
+
export declare function resolveStandardProducts(selected: Set<StandardProduct>, hosting: Hosting): void;
|
|
6
5
|
export interface ResolvedStackRegistry {
|
|
7
6
|
schemaVersion: number;
|
|
8
7
|
name: string;
|