anhedral 0.15.0 → 0.17.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 +82 -34
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/UPSTREAM.json +0 -11
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -66
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +39 -322
- package/dist/dependencies.d.ts +29 -9
- package/dist/dependencies.js +57 -64
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- package/dist/platforms/web.d.ts +1 -1
- package/dist/platforms/web.js +27 -75
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -82
- package/dist/registry/options.js +1 -5
- package/dist/registry/resolve.d.ts +1 -1
- package/dist/registry/resolve.js +4 -10
- package/dist/registry/usage.js +3 -9
- package/dist/scaffold/backend.js +0 -3
- package/dist/scaffold/database.js +2 -1
- package/dist/scaffold/documentation.js +56 -25
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/workspace.js +21 -22
- package/dist/stack-registry.d.ts +2 -10
- package/dist/stack-registry.js +12 -98
- package/dist/standard.js +1 -11
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +12 -23
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +47 -0
- package/docs/software-factory.md +35 -50
- package/docs/stack-standard.md +19 -70
- package/docs/ui.md +33 -0
- package/docs/verification.md +6 -876
- package/package.json +21 -16
- package/assets/ui/native/button.tsx +0 -85
- package/assets/ui/native/card.tsx +0 -33
- package/assets/ui/native/dialog.tsx +0 -75
- package/assets/ui/native/input.tsx +0 -27
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -129
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -112
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -157
- package/dist/delivery.d.ts +0 -82
- package/dist/delivery.js +0 -489
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -12
- package/dist/integration-service-readers.js +0 -92
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -370
- package/dist/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -156
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -671
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -47
- package/dist/project-state.js +0 -480
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -180
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -85
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -103
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -136
- package/dist/providers/definitions.d.ts +0 -115
- package/dist/providers/definitions.js +0 -42
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -56
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -52
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -234
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -283
- package/dist/provision.d.ts +0 -47
- package/dist/provision.js +0 -208
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -117
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -210
- package/dist/registry/bootstrap.d.ts +0 -3
- package/dist/registry/bootstrap.js +0 -5
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -83
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -2
- package/dist/scaffold/auth.js +0 -76
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -208
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -203
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -257
- package/dist/scaffold/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -43
- package/dist/scaffold/integrations.d.ts +0 -2
- package/dist/scaffold/integrations.js +0 -11
- package/dist/scaffold/managed-email.d.ts +0 -3
- package/dist/scaffold/managed-email.js +0 -47
- package/dist/scaffold/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -69
- package/dist/scaffold/password-reset.d.ts +0 -1
- package/dist/scaffold/password-reset.js +0 -99
- package/dist/scaffold/private-files.d.ts +0 -2
- package/dist/scaffold/private-files.js +0 -78
- package/dist/scaffold/web-billing.d.ts +0 -2
- package/dist/scaffold/web-billing.js +0 -48
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -71
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -48
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -216
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -96
- package/dist/ship.d.ts +0 -35
- package/dist/ship.js +0 -107
package/dist/r2-service-data.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { createHash, createHmac } from 'node:crypto';
|
|
2
|
-
const hash = (value) => createHash('sha256').update(value).digest('hex');
|
|
3
|
-
const hmac = (key, value) => createHmac('sha256', key).update(value).digest();
|
|
4
|
-
const encode = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (char) => '%' + char.charCodeAt(0).toString(16).toUpperCase());
|
|
5
|
-
function xmlValue(value) {
|
|
6
|
-
return value.replace(/&(?:amp|lt|gt|quot|apos);/g, (entity) => ({ '&': '&', '<': '<', '>': '>', '"': '"', ''': "'" })[entity]);
|
|
7
|
-
}
|
|
8
|
-
export async function browseR2Objects(service, cursor, env = process.env, send = fetch) {
|
|
9
|
-
if (service.kind !== 'r2' ||
|
|
10
|
-
!/^[a-f0-9]{32}$/.test(service.accountId) ||
|
|
11
|
-
!service.name ||
|
|
12
|
-
!/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/.test(service.name) ||
|
|
13
|
-
(cursor !== undefined && (cursor.length > 4096 || /[\x00-\x1f\x7f]/.test(cursor))))
|
|
14
|
-
throw new Error('Choose a supported R2 bucket and cursor.');
|
|
15
|
-
const key = env[`ANHEDRAL_R2_ACCESS_KEY_ID_${service.accountId.toUpperCase()}`] ??
|
|
16
|
-
env.ANHEDRAL_R2_ACCESS_KEY_ID;
|
|
17
|
-
const secret = env[`ANHEDRAL_R2_SECRET_ACCESS_KEY_${service.accountId.toUpperCase()}`] ??
|
|
18
|
-
env.ANHEDRAL_R2_SECRET_ACCESS_KEY;
|
|
19
|
-
if (!key ||
|
|
20
|
-
!secret ||
|
|
21
|
-
!/^[a-zA-Z0-9_-]{8,128}$/.test(key) ||
|
|
22
|
-
!/^[\x21-\x7e]{8,256}$/.test(secret))
|
|
23
|
-
throw new Error('Provide scoped read-only R2 S3 credentials for metadata browsing.');
|
|
24
|
-
const host = `${service.accountId}.r2.cloudflarestorage.com`;
|
|
25
|
-
const pathname = `/${service.name}`;
|
|
26
|
-
const params = {
|
|
27
|
-
'list-type': '2',
|
|
28
|
-
'max-keys': '25',
|
|
29
|
-
...(cursor ? { 'continuation-token': cursor } : {}),
|
|
30
|
-
};
|
|
31
|
-
const query = Object.entries(params)
|
|
32
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
33
|
-
.map(([name, value]) => `${encode(name)}=${encode(value)}`)
|
|
34
|
-
.join('&');
|
|
35
|
-
const timestamp = new Date().toISOString().replace(/[-:]/g, '').slice(0, 15) + 'Z';
|
|
36
|
-
const date = timestamp.slice(0, 8);
|
|
37
|
-
const payloadHash = hash('');
|
|
38
|
-
const headers = `host:${host}\nx-amz-content-sha256:${payloadHash}\nx-amz-date:${timestamp}\n`;
|
|
39
|
-
const signed = 'host;x-amz-content-sha256;x-amz-date';
|
|
40
|
-
const scope = `${date}/auto/s3/aws4_request`;
|
|
41
|
-
const canonical = `GET\n${pathname}\n${query}\n${headers}\n${signed}\n${payloadHash}`;
|
|
42
|
-
const signingKey = hmac(hmac(hmac(hmac('AWS4' + secret, date), 'auto'), 's3'), 'aws4_request');
|
|
43
|
-
const signature = createHmac('sha256', signingKey)
|
|
44
|
-
.update(`AWS4-HMAC-SHA256\n${timestamp}\n${scope}\n${hash(canonical)}`)
|
|
45
|
-
.digest('hex');
|
|
46
|
-
const controller = new AbortController();
|
|
47
|
-
const timer = setTimeout(() => controller.abort(), 10000);
|
|
48
|
-
try {
|
|
49
|
-
const response = await send(`https://${host}${pathname}?${query}`, {
|
|
50
|
-
method: 'GET',
|
|
51
|
-
redirect: 'error',
|
|
52
|
-
signal: controller.signal,
|
|
53
|
-
headers: {
|
|
54
|
-
Authorization: `AWS4-HMAC-SHA256 Credential=${key}/${scope}, SignedHeaders=${signed}, Signature=${signature}`,
|
|
55
|
-
'x-amz-date': timestamp,
|
|
56
|
-
'x-amz-content-sha256': payloadHash,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
if (!response.ok) {
|
|
60
|
-
void response.body?.cancel();
|
|
61
|
-
throw new Error('R2 metadata read requires scoped access and provider availability.');
|
|
62
|
-
}
|
|
63
|
-
const reader = response.body?.getReader();
|
|
64
|
-
if (!reader)
|
|
65
|
-
throw new Error('Empty R2 metadata response.');
|
|
66
|
-
const abort = () => {
|
|
67
|
-
void reader.cancel();
|
|
68
|
-
};
|
|
69
|
-
controller.signal.addEventListener('abort', abort, { once: true });
|
|
70
|
-
const chunks = [];
|
|
71
|
-
let bytes = 0;
|
|
72
|
-
try {
|
|
73
|
-
for (;;) {
|
|
74
|
-
const chunk = await reader.read();
|
|
75
|
-
if (chunk.done)
|
|
76
|
-
break;
|
|
77
|
-
bytes += chunk.value.length;
|
|
78
|
-
if (bytes > 2 * 1024 * 1024 || controller.signal.aborted)
|
|
79
|
-
throw new Error('R2 metadata exceeded its limits.');
|
|
80
|
-
chunks.push(chunk.value);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
void reader.cancel().catch(() => undefined);
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
controller.signal.removeEventListener('abort', abort);
|
|
89
|
-
reader.releaseLock();
|
|
90
|
-
}
|
|
91
|
-
if (controller.signal.aborted)
|
|
92
|
-
throw new Error('R2 metadata request timed out.');
|
|
93
|
-
const xml = Buffer.concat(chunks).toString('utf8');
|
|
94
|
-
if (/<!DOCTYPE|<!ENTITY/i.test(xml) ||
|
|
95
|
-
!/<ListBucketResult(?:\s[^>]*)?>/.test(xml) ||
|
|
96
|
-
!xml.includes('</ListBucketResult>') ||
|
|
97
|
-
!/<IsTruncated>(?:true|false)<\/IsTruncated>/.test(xml) ||
|
|
98
|
-
xmlValue(xml.match(/<Name>([^<]*)<\/Name>/)?.[1] ?? '') !== service.name)
|
|
99
|
-
throw new Error('R2 metadata does not match the selected bucket.');
|
|
100
|
-
const contents = [...xml.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)];
|
|
101
|
-
if (contents.length > 25)
|
|
102
|
-
throw new Error('R2 metadata page exceeded its limit.');
|
|
103
|
-
const rows = contents.map((entry) => {
|
|
104
|
-
const value = entry[1];
|
|
105
|
-
const key = xmlValue(value.match(/<Key>([^<]*)<\/Key>/)?.[1] ?? '');
|
|
106
|
-
const size = Number(value.match(/<Size>(\d+)<\/Size>/)?.[1]);
|
|
107
|
-
const modified = value.match(/<LastModified>([^<]*)<\/LastModified>/)?.[1];
|
|
108
|
-
if (!key ||
|
|
109
|
-
!Number.isSafeInteger(size) ||
|
|
110
|
-
size < 0 ||
|
|
111
|
-
!modified ||
|
|
112
|
-
!Number.isFinite(Date.parse(modified)))
|
|
113
|
-
throw new Error('Unsupported object metadata.');
|
|
114
|
-
return [key.slice(0, 1000), size, modified];
|
|
115
|
-
});
|
|
116
|
-
const nextCursor = xmlValue(xml.match(/<NextContinuationToken>([^<]*)<\/NextContinuationToken>/)?.[1] ?? '');
|
|
117
|
-
const hasMore = xml.includes('<IsTruncated>true</IsTruncated>');
|
|
118
|
-
if (hasMore && (!nextCursor || nextCursor.length > 4096))
|
|
119
|
-
throw new Error('R2 cursor is unavailable.');
|
|
120
|
-
return {
|
|
121
|
-
fetchedAt: new Date().toISOString(),
|
|
122
|
-
columns: ['Object key', 'Size (bytes)', 'Last modified'],
|
|
123
|
-
rows,
|
|
124
|
-
offset: 0,
|
|
125
|
-
hasMore,
|
|
126
|
-
masked: false,
|
|
127
|
-
...(hasMore ? { nextCursor } : {}),
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
throw new Error('R2 metadata could not be read. Check selected bucket, read-only S3 credentials, permissions, and response limits.');
|
|
132
|
-
}
|
|
133
|
-
finally {
|
|
134
|
-
clearTimeout(timer);
|
|
135
|
-
}
|
|
136
|
-
}
|
package/dist/readiness.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ResolvedStackRegistry } from './registry/resolve.js';
|
|
2
|
-
import { type StandardProduct } from './stack-registry.js';
|
|
3
|
-
export declare function inspectProject(root: string): {
|
|
4
|
-
schemaVersion: number;
|
|
5
|
-
root: string;
|
|
6
|
-
checks: {
|
|
7
|
-
id: string;
|
|
8
|
-
ok: boolean;
|
|
9
|
-
detail: string;
|
|
10
|
-
}[];
|
|
11
|
-
localReady: boolean;
|
|
12
|
-
providerVerification: string;
|
|
13
|
-
productionReady: boolean;
|
|
14
|
-
};
|
|
15
|
-
export declare function validateSetupPlan(plan: unknown): asserts plan is {
|
|
16
|
-
schemaVersion: 1;
|
|
17
|
-
cliVersion: string;
|
|
18
|
-
registryVersion: 1;
|
|
19
|
-
products: StandardProduct[];
|
|
20
|
-
hosting: 'cloudflare';
|
|
21
|
-
name?: string;
|
|
22
|
-
registry: ResolvedStackRegistry;
|
|
23
|
-
};
|
package/dist/readiness.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { readProjectSection } from './project-config.js';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
5
|
-
import { inspectWorkspaceGraph } from './workspace-graph.js';
|
|
6
|
-
import { resolveStackRegistry, resolveStandardProducts } from './registry/resolve.js';
|
|
7
|
-
import { CAPABILITY_REGISTRY } from './capabilities.js';
|
|
8
|
-
import { STANDARD_PRODUCTS } from './stack-registry.js';
|
|
9
|
-
export function inspectProject(root) {
|
|
10
|
-
const checks = [];
|
|
11
|
-
const record = (id, ok, detail) => checks.push({ id, ok, detail });
|
|
12
|
-
record('workspace', existsSync(path.join(root, 'pnpm-workspace.yaml')), 'pnpm workspace manifest');
|
|
13
|
-
record('lockfile', existsSync(path.join(root, 'pnpm-lock.yaml')), 'Committed dependency resolution required');
|
|
14
|
-
try {
|
|
15
|
-
const plan = readProjectSection(root, 'setup');
|
|
16
|
-
const recordedVersion = plan?.cliVersion;
|
|
17
|
-
const current = recordedVersion === CAPABILITY_REGISTRY.cliVersion;
|
|
18
|
-
record('cli-version', current, `Project configuration must be generated by anhedral@${CAPABILITY_REGISTRY.cliVersion}.`);
|
|
19
|
-
validateSetupPlan(plan);
|
|
20
|
-
const standard = readProjectSection(root, 'standard');
|
|
21
|
-
record('setup-plan', true, `Requirements recorded by CLI ${plan.cliVersion}`);
|
|
22
|
-
try {
|
|
23
|
-
const installed = readProjectSection(root, 'registry');
|
|
24
|
-
const { status, workspaces: _workspaces, files: _files, configuration: _configuration, resourcesProvisioned, ...snapshot } = installed;
|
|
25
|
-
if (status !== 'scaffolded' ||
|
|
26
|
-
resourcesProvisioned !== false ||
|
|
27
|
-
!isDeepStrictEqual(snapshot, plan.registry))
|
|
28
|
-
throw new Error('Registry provenance differs from the setup plan.');
|
|
29
|
-
for (const item of plan.registry.items)
|
|
30
|
-
for (const target of item.targets) {
|
|
31
|
-
if (!existsSync(path.join(root, target)))
|
|
32
|
-
throw new Error(`Registry target missing: ${item.name}.`);
|
|
33
|
-
}
|
|
34
|
-
record('stack-registry', true, 'Registry provenance and resolved targets match the setup plan');
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
record('stack-registry', false, 'Missing registry provenance or targets; inspect before regenerating');
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const workspaces = inspectWorkspaceGraph(root);
|
|
41
|
-
record('workspace-graph', workspaces.length > 0, 'Workspace names and dependencies resolve without cycles');
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
record('workspace-graph', false, 'Invalid workspace manifests, references or dependency cycles');
|
|
45
|
-
}
|
|
46
|
-
record('selection', standard.schemaVersion === 1 &&
|
|
47
|
-
JSON.stringify(standard.products) === JSON.stringify(plan.products) &&
|
|
48
|
-
standard.hosting === plan.hosting, 'Setup plan matches project selection');
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
record('setup-plan', false, 'Missing, invalid or unsupported setup plan; inspect the project before changing it');
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
schemaVersion: 1,
|
|
55
|
-
root,
|
|
56
|
-
checks,
|
|
57
|
-
localReady: checks.every((check) => check.ok),
|
|
58
|
-
providerVerification: 'unverified',
|
|
59
|
-
productionReady: false,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export function validateSetupPlan(plan) {
|
|
63
|
-
if (!plan || typeof plan !== 'object')
|
|
64
|
-
throw new Error('Invalid setup plan.');
|
|
65
|
-
const value = plan;
|
|
66
|
-
if (value.schemaVersion !== 1 ||
|
|
67
|
-
value.registryVersion !== 1 ||
|
|
68
|
-
typeof value.cliVersion !== 'string')
|
|
69
|
-
throw new Error('Unsupported setup plan version.');
|
|
70
|
-
if (value.cliVersion !== CAPABILITY_REGISTRY.cliVersion)
|
|
71
|
-
throw new Error(`Project configuration must be generated by anhedral@${CAPABILITY_REGISTRY.cliVersion}.`);
|
|
72
|
-
if (!Array.isArray(value.products) ||
|
|
73
|
-
!value.products.length ||
|
|
74
|
-
!value.products.every((id) => STANDARD_PRODUCTS.includes(id)))
|
|
75
|
-
throw new Error('Unknown setup capabilities.');
|
|
76
|
-
if (value.hosting !== 'cloudflare')
|
|
77
|
-
throw new Error('Invalid hosting.');
|
|
78
|
-
validateRequirements(value.setup, value.products);
|
|
79
|
-
const selected = new Set(value.products);
|
|
80
|
-
resolveStandardProducts(selected, value.hosting);
|
|
81
|
-
if (selected.size !== value.products.length)
|
|
82
|
-
throw new Error('Invalid or incomplete setup selection.');
|
|
83
|
-
if (value.name !== undefined && typeof value.name !== 'string')
|
|
84
|
-
throw new Error('Invalid setup project name.');
|
|
85
|
-
if (!isDeepStrictEqual(value.registry, resolveStackRegistry({
|
|
86
|
-
products: value.products,
|
|
87
|
-
hosting: value.hosting,
|
|
88
|
-
name: value.name,
|
|
89
|
-
})))
|
|
90
|
-
throw new Error('Invalid or inconsistent stack registry.');
|
|
91
|
-
}
|
|
92
|
-
function validateRequirements(setup, products) {
|
|
93
|
-
if (!setup || typeof setup !== 'object')
|
|
94
|
-
throw new Error('Missing setup requirements.');
|
|
95
|
-
const value = setup;
|
|
96
|
-
if (value.resourcesProvisioned !== false ||
|
|
97
|
-
!Array.isArray(value.capabilities) ||
|
|
98
|
-
value.capabilities.length !== products.length)
|
|
99
|
-
throw new Error('Invalid capability requirements.');
|
|
100
|
-
const ids = value.capabilities.map((item) => validateCapability(item));
|
|
101
|
-
if (new Set(ids).size !== products.length || !products.every((id) => ids.includes(id)))
|
|
102
|
-
throw new Error('Capability selection mismatch.');
|
|
103
|
-
}
|
|
104
|
-
function validateCapability(item) {
|
|
105
|
-
if (!item || typeof item !== 'object')
|
|
106
|
-
throw new Error('Invalid capability.');
|
|
107
|
-
const value = item;
|
|
108
|
-
if (typeof value.id !== 'string' ||
|
|
109
|
-
typeof value.purpose !== 'string' ||
|
|
110
|
-
!['planned', 'starter'].includes(String(value.status)))
|
|
111
|
-
throw new Error('Invalid capability metadata.');
|
|
112
|
-
for (const key of ['tools', 'access', 'credentials', 'resources', 'verify']) {
|
|
113
|
-
if (!Array.isArray(value[key]) || !value[key].every((entry) => typeof entry === 'string'))
|
|
114
|
-
throw new Error('Invalid requirement fields.');
|
|
115
|
-
}
|
|
116
|
-
return value.id;
|
|
117
|
-
}
|
package/dist/registry/add.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { StandardRunner } from './types.js';
|
|
2
|
-
import { type SourcePreview } from './preview.js';
|
|
3
|
-
export interface AddRequest {
|
|
4
|
-
items: string[];
|
|
5
|
-
dryRun?: boolean;
|
|
6
|
-
skipInstall?: boolean;
|
|
7
|
-
preview?: {
|
|
8
|
-
mode: 'diff' | 'view';
|
|
9
|
-
path?: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
/** Add recipes to an initialized workspace, refusing edits to customer-owned source. */
|
|
13
|
-
export declare function addStackItems(root: string, request: AddRequest, run?: StandardRunner): Promise<{
|
|
14
|
-
previews?: SourcePreview[] | undefined;
|
|
15
|
-
schemaVersion: number;
|
|
16
|
-
root: string;
|
|
17
|
-
dryRun: boolean;
|
|
18
|
-
items: string[];
|
|
19
|
-
bootstrapRequired: boolean;
|
|
20
|
-
filesChecked: boolean;
|
|
21
|
-
targets: string[];
|
|
22
|
-
files: string[];
|
|
23
|
-
conflicts: string[];
|
|
24
|
-
}>;
|
package/dist/registry/add.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { PROJECT_CONFIG_FILE, readProjectSection, writeProjectSection } from '../project-config.js';
|
|
2
|
-
import { configureDependencyPatches } from '../dependency-patches.js';
|
|
3
|
-
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
4
|
-
import { assertWorkspaceRuntime } from '../scaffold/bootstrap.js';
|
|
5
|
-
import { registerApplication } from '../project-state.js';
|
|
6
|
-
import { existsSync, lstatSync, readFileSync, realpathSync, rmSync } from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
9
|
-
import { applyEdits, modify, parse } from 'jsonc-parser';
|
|
10
|
-
import { installStackItem } from '../stack-registry.js';
|
|
11
|
-
import { inspectProject, validateSetupPlan } from '../readiness.js';
|
|
12
|
-
import { GENERATOR_VERSION } from '../version.js';
|
|
13
|
-
import { runStagedTransaction } from '../transaction.js';
|
|
14
|
-
import { inspectWorkspaceGraph } from '../workspace-graph.js';
|
|
15
|
-
import { execFile } from '../util.js';
|
|
16
|
-
import { put } from '../scaffold/files.js';
|
|
17
|
-
import { writeStandardRoot } from '../scaffold/workspace.js';
|
|
18
|
-
import { createRecipeContext } from './context.js';
|
|
19
|
-
import { resolveStackRegistry, resolveStandardProducts } from './resolve.js';
|
|
20
|
-
import { sourceFiles, configurationFingerprints } from './receipt.js';
|
|
21
|
-
import { sourcePreview, validatePreviewPath, MAX_PREVIEW_TOTAL_BYTES, } from './preview.js';
|
|
22
|
-
/** Add recipes to an initialized workspace, refusing edits to customer-owned source. */
|
|
23
|
-
export async function addStackItems(root, request, run = execFile) {
|
|
24
|
-
for (const key of Object.keys(request))
|
|
25
|
-
if (!['items', 'dryRun', 'skipInstall', 'preview'].includes(key))
|
|
26
|
-
throw new Error(`Unknown add option: ${key}. Only bundled registry items are supported.`);
|
|
27
|
-
if (request.preview) {
|
|
28
|
-
if (!request.dryRun ||
|
|
29
|
-
!['diff', 'view'].includes(request.preview.mode) ||
|
|
30
|
-
Object.keys(request.preview).some((key) => !['mode', 'path'].includes(key)))
|
|
31
|
-
throw new Error('Source previews require dry-run and one mode: diff or view.');
|
|
32
|
-
if (request.preview.path !== undefined)
|
|
33
|
-
validatePreviewPath(request.preview.path);
|
|
34
|
-
}
|
|
35
|
-
if (!request.dryRun)
|
|
36
|
-
assertWorkspaceRuntime(run);
|
|
37
|
-
root = realpathSync(root);
|
|
38
|
-
if (!request.items.length)
|
|
39
|
-
throw new Error('Select at least one registry item.');
|
|
40
|
-
const plan = readProjectSection(root, 'setup');
|
|
41
|
-
if (Array.isArray(plan?.registry?.items) &&
|
|
42
|
-
plan.registry.items.some((item) => item.name === 'stripe' && item.package))
|
|
43
|
-
throw new Error('This project uses the legacy billing SDK recipe. Use its pinned CLI or perform a reviewed billing migration before adding capabilities.');
|
|
44
|
-
validateSetupPlan(plan);
|
|
45
|
-
if (plan.cliVersion !== GENERATOR_VERSION)
|
|
46
|
-
throw new Error('Use the project CLI version before adding recipes.');
|
|
47
|
-
if (!inspectProject(root).localReady)
|
|
48
|
-
throw new Error('Run doctor and resolve project provenance or workspace errors before add.');
|
|
49
|
-
const receipt = readProjectSection(root, 'registry');
|
|
50
|
-
if (!receipt.files || typeof receipt.files !== 'object' || Array.isArray(receipt.files))
|
|
51
|
-
throw new Error('Add requires current scaffold fingerprints.');
|
|
52
|
-
const baseline = receipt.files;
|
|
53
|
-
if (!receipt.configuration ||
|
|
54
|
-
typeof receipt.configuration !== 'object' ||
|
|
55
|
-
Array.isArray(receipt.configuration))
|
|
56
|
-
throw new Error('Add requires current configuration fingerprints.');
|
|
57
|
-
const originalConfiguration = configurationFingerprints(root);
|
|
58
|
-
const selected = new Set(plan.products);
|
|
59
|
-
for (const id of request.items) {
|
|
60
|
-
if (!['stripe', 'revenuecat'].includes(id))
|
|
61
|
-
throw new Error(`Unknown stack product: ${id}.`);
|
|
62
|
-
selected.add(id);
|
|
63
|
-
}
|
|
64
|
-
resolveStandardProducts(selected, plan.hosting);
|
|
65
|
-
const options = {
|
|
66
|
-
root,
|
|
67
|
-
name: plan.name ?? path.basename(root),
|
|
68
|
-
products: [...selected].sort(),
|
|
69
|
-
hosting: plan.hosting,
|
|
70
|
-
skipInstall: !!request.skipInstall,
|
|
71
|
-
dryRun: false,
|
|
72
|
-
json: true,
|
|
73
|
-
initializeGit: false,
|
|
74
|
-
};
|
|
75
|
-
const registry = resolveStackRegistry(options);
|
|
76
|
-
const oldItems = new Map(plan.registry.items.map((item) => [item.name, item]));
|
|
77
|
-
const recipes = registry.items.filter((item) => item.installer === 'recipe' && !isDeepStrictEqual(oldItems.get(item.name), item));
|
|
78
|
-
// Relocating auth, database or service ownership requires a migration, not an additive scaffold.
|
|
79
|
-
for (const item of registry.items) {
|
|
80
|
-
const before = oldItems.get(item.name);
|
|
81
|
-
if (before && before.targets.some((target) => !item.targets.includes(target)))
|
|
82
|
-
throw new Error(`Adding this selection relocates ${item.name}; additions must preserve existing runtime ownership.`);
|
|
83
|
-
}
|
|
84
|
-
const before = sourceFiles(root);
|
|
85
|
-
const receiptText = readBoundedFile(path.join(root, PROJECT_CONFIG_FILE), MAX_PROJECT_JSON_BYTES).toString('utf8');
|
|
86
|
-
const commitPaths = [];
|
|
87
|
-
const conflicts = [];
|
|
88
|
-
const result = {
|
|
89
|
-
schemaVersion: 1,
|
|
90
|
-
root,
|
|
91
|
-
dryRun: !!request.dryRun,
|
|
92
|
-
items: registry.items
|
|
93
|
-
.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item))
|
|
94
|
-
.map((item) => item.name),
|
|
95
|
-
bootstrapRequired: false,
|
|
96
|
-
filesChecked: true,
|
|
97
|
-
targets: recipes.flatMap((item) => item.targets),
|
|
98
|
-
files: commitPaths,
|
|
99
|
-
conflicts,
|
|
100
|
-
...(request.preview ? { previews: [] } : {}),
|
|
101
|
-
};
|
|
102
|
-
await runStagedTransaction(root, {
|
|
103
|
-
dryRun: !!request.dryRun,
|
|
104
|
-
commitPaths,
|
|
105
|
-
seedPaths: [...before.keys(), PROJECT_CONFIG_FILE],
|
|
106
|
-
build: async (stage) => {
|
|
107
|
-
const context = createRecipeContext(stage, options);
|
|
108
|
-
context.updating = true;
|
|
109
|
-
for (const item of registry.items)
|
|
110
|
-
Object.assign(context.bindings, item.bindings);
|
|
111
|
-
for (const item of recipes)
|
|
112
|
-
await installStackItem(item, context);
|
|
113
|
-
// Configuration items affect the existing runtime without regenerating its application source.
|
|
114
|
-
const configurationItems = registry.items.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item) && item.bindings);
|
|
115
|
-
if (configurationItems.length) {
|
|
116
|
-
const directory = 'apps/api';
|
|
117
|
-
const file = `${directory}/${existsSync(path.join(stage, directory, 'anhedral.cloudflare.json')) ? 'anhedral.cloudflare.json' : 'wrangler.jsonc'}`;
|
|
118
|
-
let content = readFileSync(path.join(stage, file), 'utf8');
|
|
119
|
-
const config = parse(content);
|
|
120
|
-
for (const item of configurationItems)
|
|
121
|
-
for (const [key, value] of Object.entries(item.bindings)) {
|
|
122
|
-
if (config[key] !== undefined && !isDeepStrictEqual(config[key], value))
|
|
123
|
-
throw new Error(`Existing ${key} configuration conflicts with ${item.name}; configure it explicitly.`);
|
|
124
|
-
content = applyEdits(content, modify(content, [key], value, {
|
|
125
|
-
formattingOptions: { insertSpaces: true, tabSize: 2 },
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
put(stage, file, content);
|
|
129
|
-
}
|
|
130
|
-
writeStandardRoot(stage, options, registry, true);
|
|
131
|
-
if ([...sourceFiles(stage).keys()].some((file) => /^apps\/[^/]+\/(?:wrangler\.jsonc|anhedral\.cloudflare\.json)$/.test(file)))
|
|
132
|
-
registerApplication(stage, true);
|
|
133
|
-
if (!request.dryRun)
|
|
134
|
-
run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile', '--ignore-scripts'], stage);
|
|
135
|
-
if (!request.dryRun && configureDependencyPatches(stage))
|
|
136
|
-
run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile', '--ignore-scripts'], stage);
|
|
137
|
-
const after = sourceFiles(stage);
|
|
138
|
-
const files = { ...baseline };
|
|
139
|
-
for (const [file, hash] of after) {
|
|
140
|
-
if (before.get(file) === hash)
|
|
141
|
-
continue;
|
|
142
|
-
if (before.has(file) && baseline[file] !== before.get(file))
|
|
143
|
-
conflicts.push(file);
|
|
144
|
-
commitPaths.push(file);
|
|
145
|
-
files[file] = hash;
|
|
146
|
-
}
|
|
147
|
-
const configuration = configurationFingerprints(stage);
|
|
148
|
-
for (const [section, hash] of Object.entries(originalConfiguration)) {
|
|
149
|
-
// Hosting registration preserves existing user fields while adding new targets.
|
|
150
|
-
if (section !== 'cloudflare' &&
|
|
151
|
-
hash !== receipt.configuration[section] &&
|
|
152
|
-
configuration[section] !== hash)
|
|
153
|
-
conflicts.push(`${PROJECT_CONFIG_FILE} (${section})`);
|
|
154
|
-
}
|
|
155
|
-
// Never delete preexisting source as a side effect of an addition.
|
|
156
|
-
for (const file of before.keys())
|
|
157
|
-
if (!after.has(file))
|
|
158
|
-
conflicts.push(file);
|
|
159
|
-
if (conflicts.length && !request.dryRun)
|
|
160
|
-
throw new Error(`Addition conflicts with edited or untracked source: ${conflicts.join(', ')}. No files were installed.`);
|
|
161
|
-
writeProjectSection(stage, 'registry', {
|
|
162
|
-
...registry,
|
|
163
|
-
status: 'scaffolded',
|
|
164
|
-
resourcesProvisioned: false,
|
|
165
|
-
workspaces: inspectWorkspaceGraph(stage),
|
|
166
|
-
files,
|
|
167
|
-
configuration,
|
|
168
|
-
});
|
|
169
|
-
commitPaths.push(PROJECT_CONFIG_FILE);
|
|
170
|
-
if (request.preview && result.previews) {
|
|
171
|
-
const preview = request.preview;
|
|
172
|
-
const selected = [...commitPaths]
|
|
173
|
-
.filter((file) => !preview.path || preview.path === file)
|
|
174
|
-
.sort();
|
|
175
|
-
if (preview.path && !selected.length)
|
|
176
|
-
throw new Error('Requested path is not a changed generated source file.');
|
|
177
|
-
let total = 0;
|
|
178
|
-
for (const file of selected) {
|
|
179
|
-
const content = sourcePreview(root, stage, file, preview.mode);
|
|
180
|
-
total += Buffer.byteLength(JSON.stringify(content));
|
|
181
|
-
if (total > MAX_PREVIEW_TOTAL_BYTES)
|
|
182
|
-
throw new Error('Source preview exceeds 1 MiB. Select a single file with --diff <path> or --view <path>.');
|
|
183
|
-
result.previews.push(content);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
// Detect concurrent changes even to source that this addition would otherwise preserve.
|
|
187
|
-
if (!isDeepStrictEqual(sourceFiles(root), before) ||
|
|
188
|
-
readBoundedFile(path.join(root, PROJECT_CONFIG_FILE), MAX_PROJECT_JSON_BYTES).toString('utf8') !== receiptText)
|
|
189
|
-
throw new Error('Workspace changed during addition; retry after reviewing source.');
|
|
190
|
-
},
|
|
191
|
-
afterCommit: () => {
|
|
192
|
-
if (request.skipInstall)
|
|
193
|
-
return;
|
|
194
|
-
const lockPath = path.join(root, 'pnpm-lock.yaml');
|
|
195
|
-
const lock = readBoundedFile(lockPath, 16 * 1024 * 1024);
|
|
196
|
-
const modules = path.join(root, 'node_modules');
|
|
197
|
-
const metadata = lstatSync(modules, { throwIfNoEntry: false });
|
|
198
|
-
if (metadata && (!metadata.isDirectory() || metadata.isSymbolicLink()))
|
|
199
|
-
throw new Error('Dependency installation requires a real project node_modules directory.');
|
|
200
|
-
// pnpm 10 can retain skipped optional packages after a new recipe makes
|
|
201
|
-
// them required. Rebuild generated links from the reviewed lock while
|
|
202
|
-
// retaining the separate content-addressed package store.
|
|
203
|
-
rmSync(modules, { recursive: true, force: true });
|
|
204
|
-
run('pnpm', ['install', '--frozen-lockfile'], root);
|
|
205
|
-
if (!readBoundedFile(lockPath, 16 * 1024 * 1024).equals(lock))
|
|
206
|
-
throw new Error('Frozen dependency installation changed the reviewed lockfile; review it before continuing.');
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
return result;
|
|
210
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { CAPABILITY_CONTRACT, formatCapabilityContract } from '../capability-contract.js';
|
|
2
|
-
import { addStackItems } from './add.js';
|
|
3
|
-
import { STACK_REGISTRY, STANDARD_PRODUCTS, getStackItem } from '../stack-registry.js';
|
|
4
|
-
import { printResult } from '../cli-output.js';
|
|
5
|
-
import { commandHelp } from './usage.js';
|
|
6
|
-
import { CliArgumentError, suggest, commandArguments } from '../cli-arguments.js';
|
|
7
|
-
export async function runRegistry(args, json, output = { json }) {
|
|
8
|
-
const parsed = commandArguments('registry', args);
|
|
9
|
-
if (parsed.has('--help')) {
|
|
10
|
-
console.log(commandHelp('registry'));
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const [action = 'list', name, ...extra] = parsed.positional;
|
|
14
|
-
if (action === 'capabilities' && !name && !extra.length) {
|
|
15
|
-
if (output.quiet && !json)
|
|
16
|
-
return;
|
|
17
|
-
console.log(json ? JSON.stringify(CAPABILITY_CONTRACT, null, 2) : formatCapabilityContract());
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (action === 'list' && !name && !extra.length) {
|
|
21
|
-
if (output.quiet && !json)
|
|
22
|
-
return;
|
|
23
|
-
console.log(json
|
|
24
|
-
? JSON.stringify(STACK_REGISTRY, null, 2)
|
|
25
|
-
: STACK_REGISTRY.items
|
|
26
|
-
.map((item) => `${item.name} (${item.type}) — ${item.description}`)
|
|
27
|
-
.join('\n'));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (action === 'view' && name && !extra.length) {
|
|
31
|
-
if (!STACK_REGISTRY.items.some((item) => item.name === name)) {
|
|
32
|
-
const correction = suggest(name, STACK_REGISTRY.items.map((item) => item.name));
|
|
33
|
-
throw new CliArgumentError(`Unknown bundled registry item.${correction ? ` Did you mean ${correction}?` : ''}`, 'Run anhedral registry list.');
|
|
34
|
-
}
|
|
35
|
-
printResult('registry', getStackItem(name), { ...output, json });
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
throw new Error('Use registry list, registry view <item>, or registry capabilities.');
|
|
39
|
-
}
|
|
40
|
-
export async function runAdd(args, output = {}) {
|
|
41
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
42
|
-
console.log(commandHelp('add'));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const positional = [];
|
|
46
|
-
let preview;
|
|
47
|
-
for (let index = 0; index < args.length; index++) {
|
|
48
|
-
const arg = args[index];
|
|
49
|
-
if (arg === '--diff' || arg === '--view') {
|
|
50
|
-
if (preview)
|
|
51
|
-
throw new Error('Select one source preview: --diff or --view.');
|
|
52
|
-
preview = { mode: arg === '--diff' ? 'diff' : 'view' };
|
|
53
|
-
const next = args[index + 1];
|
|
54
|
-
if (next &&
|
|
55
|
-
!next.startsWith('-') &&
|
|
56
|
-
!STANDARD_PRODUCTS.includes(next)) {
|
|
57
|
-
preview.path = next;
|
|
58
|
-
index++;
|
|
59
|
-
}
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (['--dry-run', '--skip-install', '--json'].includes(arg))
|
|
63
|
-
continue;
|
|
64
|
-
if (arg.startsWith('-'))
|
|
65
|
-
throw new Error(`Unknown add option: ${arg}.`);
|
|
66
|
-
positional.push(arg);
|
|
67
|
-
}
|
|
68
|
-
const items = positional;
|
|
69
|
-
if (!items.length)
|
|
70
|
-
throw new Error('Select payments: anhedral add stripe revenuecat [--cwd <directory>].');
|
|
71
|
-
for (const item of items) {
|
|
72
|
-
if (['stripe', 'revenuecat'].includes(item))
|
|
73
|
-
continue;
|
|
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.');
|
|
76
|
-
}
|
|
77
|
-
printResult('add', await addStackItems(process.cwd(), {
|
|
78
|
-
items,
|
|
79
|
-
dryRun: args.includes('--dry-run') || Boolean(preview),
|
|
80
|
-
skipInstall: args.includes('--skip-install'),
|
|
81
|
-
...(preview ? { preview } : {}),
|
|
82
|
-
}), { ...output, json: args.includes('--json') });
|
|
83
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const MAX_PREVIEW_TOTAL_BYTES: number;
|
|
2
|
-
export interface SourcePreview {
|
|
3
|
-
path: string;
|
|
4
|
-
content?: string;
|
|
5
|
-
diff?: string;
|
|
6
|
-
unavailable?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function validatePreviewPath(file: string): void;
|
|
9
|
-
/** A single contextual hunk is linear in file size and remains an applicable unified patch. */
|
|
10
|
-
export declare function sourceDiff(file: string, before: string | undefined, after: string): string;
|
|
11
|
-
export declare function sourcePreview(root: string, stage: string, file: string, mode: 'diff' | 'view'): SourcePreview;
|