anhedral 0.10.1 → 0.11.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.
Files changed (89) hide show
  1. package/README.md +77 -38
  2. package/assets/{anhedral-cli-init-technical.svg → anhedral-stack-technical.svg} +6 -6
  3. package/assets/{anhedral-cli-init.svg → anhedral-stack.svg} +7 -7
  4. package/dist/bin.js +271 -154
  5. package/dist/capabilities.d.ts +3 -3
  6. package/dist/capability-contract.d.ts +47 -0
  7. package/dist/capability-contract.js +136 -0
  8. package/dist/cli-arguments.d.ts +16 -0
  9. package/dist/cli-arguments.js +115 -0
  10. package/dist/cli-output.d.ts +8 -0
  11. package/dist/cli-output.js +211 -0
  12. package/dist/cloudflare.d.ts +7 -2
  13. package/dist/cloudflare.js +166 -36
  14. package/dist/command-schema.d.ts +21 -0
  15. package/dist/command-schema.js +374 -0
  16. package/dist/delivery.d.ts +2 -2
  17. package/dist/delivery.js +21 -4
  18. package/dist/index.d.ts +23 -1
  19. package/dist/index.js +15 -1
  20. package/dist/inspector-model.d.ts +115 -0
  21. package/dist/inspector-model.js +1 -0
  22. package/dist/lifecycle-model.d.ts +15 -0
  23. package/dist/lifecycle-model.js +20 -0
  24. package/dist/lifecycle.d.ts +12 -0
  25. package/dist/lifecycle.js +92 -0
  26. package/dist/mobile-delivery.d.ts +100 -0
  27. package/dist/mobile-delivery.js +319 -0
  28. package/dist/platforms/mobile.js +8 -5
  29. package/dist/project-inspector.d.ts +4 -0
  30. package/dist/project-inspector.js +646 -0
  31. package/dist/project-state.d.ts +17 -0
  32. package/dist/project-state.js +239 -11
  33. package/dist/provider-auth.d.ts +41 -0
  34. package/dist/provider-auth.js +210 -0
  35. package/dist/providers/adapters.d.ts +17 -0
  36. package/dist/providers/adapters.js +269 -0
  37. package/dist/providers/api.d.ts +28 -0
  38. package/dist/providers/api.js +252 -0
  39. package/dist/providers/config.d.ts +15 -0
  40. package/dist/providers/config.js +184 -0
  41. package/dist/providers/definitions.d.ts +318 -0
  42. package/dist/providers/definitions.js +127 -0
  43. package/dist/providers/provision.d.ts +24 -0
  44. package/dist/providers/provision.js +76 -0
  45. package/dist/providers/receipts.d.ts +20 -0
  46. package/dist/providers/receipts.js +66 -0
  47. package/dist/providers/recovery-verification.d.ts +7 -0
  48. package/dist/providers/recovery-verification.js +112 -0
  49. package/dist/providers/recovery.d.ts +30 -0
  50. package/dist/providers/recovery.js +34 -0
  51. package/dist/providers/runtime.d.ts +10 -0
  52. package/dist/providers/runtime.js +231 -0
  53. package/dist/providers/schema.d.ts +28 -0
  54. package/dist/providers/schema.js +49 -0
  55. package/dist/providers/state.d.ts +56 -0
  56. package/dist/providers/state.js +329 -0
  57. package/dist/provision.d.ts +1 -1
  58. package/dist/provision.js +61 -3
  59. package/dist/registry/add.d.ts +6 -0
  60. package/dist/registry/add.js +29 -1
  61. package/dist/registry/commands.d.ts +3 -2
  62. package/dist/registry/commands.js +53 -14
  63. package/dist/registry/options.js +3 -2
  64. package/dist/registry/preview.d.ts +11 -0
  65. package/dist/registry/preview.js +91 -0
  66. package/dist/registry/usage.d.ts +10 -0
  67. package/dist/registry/usage.js +22 -37
  68. package/dist/scaffold/auth.js +3 -19
  69. package/dist/scaffold/workspace.js +11 -0
  70. package/dist/ship.d.ts +320 -0
  71. package/dist/ship.js +211 -0
  72. package/dist/stack-registry.d.ts +2 -2
  73. package/dist/stack-registry.js +7 -1
  74. package/dist/standard.d.ts +2 -1
  75. package/dist/standard.js +11 -11
  76. package/dist/vercel.d.ts +3 -3
  77. package/dist/vercel.js +27 -1
  78. package/dist/version.d.ts +1 -1
  79. package/dist/version.js +1 -1
  80. package/docs/application-stack-standard.md +51 -80
  81. package/docs/cli-design.md +67 -0
  82. package/docs/delivery-workflow.md +29 -15
  83. package/docs/plugin-ui.md +61 -0
  84. package/docs/provider-configuration.md +117 -0
  85. package/package.json +16 -12
  86. package/dist/managed-hosting.d.ts +0 -49
  87. package/dist/managed-hosting.js +0 -373
  88. package/docs/managed-hosting-architecture.md +0 -87
  89. package/docs/sponsorships.md +0 -25
package/dist/ship.d.ts ADDED
@@ -0,0 +1,320 @@
1
+ import { type DeliveryRunner } from './project-state.js';
2
+ import { planProvisioning, provisionApplication } from './provision.js';
3
+ import type { CloudflareRequest } from './cloudflare.js';
4
+ import { planProviderProvisioning, provisionSelectedProviders } from './providers/provision.js';
5
+ export declare function shipCloudflareApplication(root: string, dryRun?: boolean, run?: DeliveryRunner, request?: CloudflareRequest, send?: typeof fetch, providerEnvironment?: NodeJS.ProcessEnv): Promise<{
6
+ projectId: string;
7
+ release: import("./delivery.js").Release;
8
+ managementFile: string;
9
+ productVerification: string;
10
+ management: string;
11
+ } | ({
12
+ project: import("./project-state.js").ApplicationProject;
13
+ checks: string[][];
14
+ deployments: {
15
+ target: string;
16
+ directory: string;
17
+ command: string[];
18
+ }[];
19
+ resourcesProvisioned: boolean;
20
+ audience: "unconfigured" | "public" | "private";
21
+ } & {
22
+ provisioning: ReturnType<typeof planProvisioning>;
23
+ mutation: false;
24
+ integrations: ReturnType<typeof planProviderProvisioning>;
25
+ }) | {
26
+ state: "configuration-required";
27
+ resources: Awaited<ReturnType<typeof provisionApplication>>;
28
+ deployed: false;
29
+ nextAction: string;
30
+ } | {
31
+ state: "provider-configuration-required";
32
+ deployed: false;
33
+ integrations: Awaited<ReturnType<typeof provisionSelectedProviders>>;
34
+ }>;
35
+ export declare function shipSelectedVercelApplication(root: string, dryRun?: boolean, run?: DeliveryRunner, send?: typeof fetch, providerEnvironment?: NodeJS.ProcessEnv): Promise<{
36
+ projectId: string;
37
+ release: import("./vercel.js").WebRelease;
38
+ productVerification: string;
39
+ } | {
40
+ integrations: {
41
+ schemaVersion: number;
42
+ providers: {
43
+ provider: keyof import("./index.js").ProviderSettingsById;
44
+ settings: import("./providers/definitions.js").NeonSettings | import("./providers/definitions.js").ClerkSettings | import("./providers/definitions.js").ResendSettings | import("./providers/definitions.js").StripeSettings | import("./providers/definitions.js").RevenueCatSettings | import("./providers/definitions.js").SentrySettings | import("./providers/definitions.js").PostHogSettings | import("./providers/definitions.js").OpenAISettings;
45
+ credential: string;
46
+ missing: string[];
47
+ }[];
48
+ configured: boolean;
49
+ mutation: boolean;
50
+ };
51
+ mutation: boolean;
52
+ project: import("./vercel.js").WebProject;
53
+ checks: string[];
54
+ deployment: string[];
55
+ cloudflareServices: string;
56
+ state?: undefined;
57
+ deployed?: undefined;
58
+ } | {
59
+ state: string;
60
+ deployed: boolean;
61
+ integrations: {
62
+ schemaVersion: number;
63
+ results: {
64
+ provider: string;
65
+ resources: Record<string, string>;
66
+ ready: boolean;
67
+ nextActions: string[];
68
+ }[];
69
+ ready: boolean;
70
+ configuredFiles: string[];
71
+ mutation: boolean;
72
+ };
73
+ }>;
74
+ /** Each mixed target keeps its own release receipt; this is not a provider transaction. */
75
+ export declare function shipSelectedStack(root: string, dryRun?: boolean, run?: DeliveryRunner, request?: CloudflareRequest, send?: typeof fetch, providerEnvironment?: NodeJS.ProcessEnv): Promise<{
76
+ projectId: string;
77
+ release: import("./delivery.js").Release;
78
+ managementFile: string;
79
+ productVerification: string;
80
+ management: string;
81
+ } | {
82
+ projectId: string;
83
+ release: import("./vercel.js").WebRelease;
84
+ productVerification: string;
85
+ } | ({
86
+ project: import("./project-state.js").ApplicationProject;
87
+ checks: string[][];
88
+ deployments: {
89
+ target: string;
90
+ directory: string;
91
+ command: string[];
92
+ }[];
93
+ resourcesProvisioned: boolean;
94
+ audience: "unconfigured" | "public" | "private";
95
+ } & {
96
+ provisioning: ReturnType<typeof planProvisioning>;
97
+ mutation: false;
98
+ integrations: ReturnType<typeof planProviderProvisioning>;
99
+ }) | {
100
+ state: "configuration-required";
101
+ resources: Awaited<ReturnType<typeof provisionApplication>>;
102
+ deployed: false;
103
+ nextAction: string;
104
+ } | {
105
+ integrations: {
106
+ schemaVersion: number;
107
+ providers: {
108
+ provider: keyof import("./index.js").ProviderSettingsById;
109
+ settings: import("./providers/definitions.js").NeonSettings | import("./providers/definitions.js").ClerkSettings | import("./providers/definitions.js").ResendSettings | import("./providers/definitions.js").StripeSettings | import("./providers/definitions.js").RevenueCatSettings | import("./providers/definitions.js").SentrySettings | import("./providers/definitions.js").PostHogSettings | import("./providers/definitions.js").OpenAISettings;
110
+ credential: string;
111
+ missing: string[];
112
+ }[];
113
+ configured: boolean;
114
+ mutation: boolean;
115
+ };
116
+ mutation: boolean;
117
+ project: import("./vercel.js").WebProject;
118
+ checks: string[];
119
+ deployment: string[];
120
+ cloudflareServices: string;
121
+ state?: undefined;
122
+ deployed?: undefined;
123
+ } | {
124
+ state: string;
125
+ deployed: boolean;
126
+ integrations: {
127
+ schemaVersion: number;
128
+ results: {
129
+ provider: string;
130
+ resources: Record<string, string>;
131
+ ready: boolean;
132
+ nextActions: string[];
133
+ }[];
134
+ ready: boolean;
135
+ configuredFiles: string[];
136
+ mutation: boolean;
137
+ };
138
+ } | ({
139
+ state: "configuration-required" | "provider-configuration-required";
140
+ deployed: boolean;
141
+ targets: {
142
+ provider: string;
143
+ result: {
144
+ state: "configuration-required";
145
+ resources: Awaited<ReturnType<typeof provisionApplication>>;
146
+ deployed: false;
147
+ nextAction: string;
148
+ } | {
149
+ state: "provider-configuration-required";
150
+ deployed: false;
151
+ integrations: Awaited<ReturnType<typeof provisionSelectedProviders>>;
152
+ };
153
+ }[];
154
+ nextAction: string;
155
+ productVerification?: undefined;
156
+ } & {
157
+ operation: import("./lifecycle-model.js").LifecycleOperation;
158
+ }) | ({
159
+ nextAction?: string | undefined;
160
+ state: string;
161
+ deployed: boolean;
162
+ targets: ({
163
+ provider: string;
164
+ result: {
165
+ projectId: string;
166
+ release: import("./delivery.js").Release;
167
+ managementFile: string;
168
+ productVerification: string;
169
+ management: string;
170
+ } | ({
171
+ project: import("./project-state.js").ApplicationProject;
172
+ checks: string[][];
173
+ deployments: {
174
+ target: string;
175
+ directory: string;
176
+ command: string[];
177
+ }[];
178
+ resourcesProvisioned: boolean;
179
+ audience: "unconfigured" | "public" | "private";
180
+ } & {
181
+ provisioning: ReturnType<typeof planProvisioning>;
182
+ mutation: false;
183
+ integrations: ReturnType<typeof planProviderProvisioning>;
184
+ }) | {
185
+ state: "configuration-required";
186
+ resources: Awaited<ReturnType<typeof provisionApplication>>;
187
+ deployed: false;
188
+ nextAction: string;
189
+ } | {
190
+ state: "provider-configuration-required";
191
+ deployed: false;
192
+ integrations: Awaited<ReturnType<typeof provisionSelectedProviders>>;
193
+ };
194
+ } | {
195
+ provider: string;
196
+ result: {
197
+ projectId: string;
198
+ release: import("./vercel.js").WebRelease;
199
+ productVerification: string;
200
+ } | {
201
+ integrations: {
202
+ schemaVersion: number;
203
+ providers: {
204
+ provider: keyof import("./index.js").ProviderSettingsById;
205
+ settings: import("./providers/definitions.js").NeonSettings | import("./providers/definitions.js").ClerkSettings | import("./providers/definitions.js").ResendSettings | import("./providers/definitions.js").StripeSettings | import("./providers/definitions.js").RevenueCatSettings | import("./providers/definitions.js").SentrySettings | import("./providers/definitions.js").PostHogSettings | import("./providers/definitions.js").OpenAISettings;
206
+ credential: string;
207
+ missing: string[];
208
+ }[];
209
+ configured: boolean;
210
+ mutation: boolean;
211
+ };
212
+ mutation: boolean;
213
+ project: import("./vercel.js").WebProject;
214
+ checks: string[];
215
+ deployment: string[];
216
+ cloudflareServices: string;
217
+ state?: undefined;
218
+ deployed?: undefined;
219
+ } | {
220
+ state: string;
221
+ deployed: boolean;
222
+ integrations: {
223
+ schemaVersion: number;
224
+ results: {
225
+ provider: string;
226
+ resources: Record<string, string>;
227
+ ready: boolean;
228
+ nextActions: string[];
229
+ }[];
230
+ ready: boolean;
231
+ configuredFiles: string[];
232
+ mutation: boolean;
233
+ };
234
+ };
235
+ })[];
236
+ productVerification: string;
237
+ } & {
238
+ operation: import("./lifecycle-model.js").LifecycleOperation;
239
+ }) | ({
240
+ state: string;
241
+ deployed: boolean;
242
+ targets: ({
243
+ provider: string;
244
+ result: {
245
+ projectId: string;
246
+ release: import("./delivery.js").Release;
247
+ managementFile: string;
248
+ productVerification: string;
249
+ management: string;
250
+ } | ({
251
+ project: import("./project-state.js").ApplicationProject;
252
+ checks: string[][];
253
+ deployments: {
254
+ target: string;
255
+ directory: string;
256
+ command: string[];
257
+ }[];
258
+ resourcesProvisioned: boolean;
259
+ audience: "unconfigured" | "public" | "private";
260
+ } & {
261
+ provisioning: ReturnType<typeof planProvisioning>;
262
+ mutation: false;
263
+ integrations: ReturnType<typeof planProviderProvisioning>;
264
+ }) | {
265
+ state: "configuration-required";
266
+ resources: Awaited<ReturnType<typeof provisionApplication>>;
267
+ deployed: false;
268
+ nextAction: string;
269
+ } | {
270
+ state: "provider-configuration-required";
271
+ deployed: false;
272
+ integrations: Awaited<ReturnType<typeof provisionSelectedProviders>>;
273
+ };
274
+ state?: undefined;
275
+ } | {
276
+ provider: string;
277
+ state: string;
278
+ result?: undefined;
279
+ })[];
280
+ productVerification: string;
281
+ nextAction: string;
282
+ } & {
283
+ operation: import("./lifecycle-model.js").LifecycleOperation;
284
+ }) | {
285
+ mutation: boolean;
286
+ dependencies: {
287
+ target: string;
288
+ after: string[];
289
+ }[];
290
+ targets: ({
291
+ project: import("./project-state.js").ApplicationProject;
292
+ checks: string[][];
293
+ deployments: {
294
+ target: string;
295
+ directory: string;
296
+ command: string[];
297
+ }[];
298
+ resourcesProvisioned: boolean;
299
+ audience: "unconfigured" | "public" | "private";
300
+ provider: string;
301
+ } | {
302
+ project: import("./vercel.js").WebProject;
303
+ checks: string[];
304
+ deployment: string[];
305
+ cloudflareServices: string;
306
+ mutation: boolean;
307
+ provider: string;
308
+ })[];
309
+ integrations: {
310
+ schemaVersion: number;
311
+ providers: {
312
+ provider: keyof import("./index.js").ProviderSettingsById;
313
+ settings: import("./providers/definitions.js").NeonSettings | import("./providers/definitions.js").ClerkSettings | import("./providers/definitions.js").ResendSettings | import("./providers/definitions.js").StripeSettings | import("./providers/definitions.js").RevenueCatSettings | import("./providers/definitions.js").SentrySettings | import("./providers/definitions.js").PostHogSettings | import("./providers/definitions.js").OpenAISettings;
314
+ credential: string;
315
+ missing: string[];
316
+ }[];
317
+ configured: boolean;
318
+ mutation: boolean;
319
+ };
320
+ }>;
package/dist/ship.js ADDED
@@ -0,0 +1,211 @@
1
+ import { existsSync, realpathSync, writeFileSync, rmSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { tmpdir } from 'node:os';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { defaultRunner } from './project-state.js';
6
+ import { withLifecycleOperation } from './lifecycle.js';
7
+ import { planDelivery, shipApplication } from './delivery.js';
8
+ import { planProvisioning, provisionApplication } from './provision.js';
9
+ import { planProviderProvisioning, provisionSelectedProviders } from './providers/provision.js';
10
+ import { applicationRuntime, configuredRuntime, runtimeTargets, RUNTIME_KEYS, } from './providers/runtime.js';
11
+ import { CREDENTIALS } from './providers/api.js';
12
+ import { readApplication } from './project-state.js';
13
+ import { planVercelDelivery, configureVercelEnvironment, shipVercelApplication } from './vercel.js';
14
+ /** Provisioning can change tracked binding IDs; never silently commit that change. */
15
+ async function executeCloudflareApplication(root, dryRun = false, run = defaultRunner, request, send = fetch, providerEnvironment = process.env, session) {
16
+ root = realpathSync(root);
17
+ const deployment = planDelivery(root, true);
18
+ const provisioning = planProvisioning(root);
19
+ const integrations = planProviderProvisioning(root);
20
+ if (dryRun)
21
+ return { ...deployment, provisioning, integrations, mutation: false };
22
+ if (deployment.project.audience === 'unconfigured' || !deployment.project.accountId)
23
+ throw new Error('Connect the intended account and audience before shipping.');
24
+ const environment = runtimeEnvironment(providerEnvironment);
25
+ const providerRun = (command, args, cwd, env) => run(command, args, cwd, runtimeEnvironment(env));
26
+ if (realpathSync((await run('git', ['rev-parse', '--show-toplevel'], root, environment)).trim()) !==
27
+ root ||
28
+ (await run('git', ['status', '--porcelain'], root, environment)).trim())
29
+ throw new Error('Shipping requires a clean application repository before provisioning.');
30
+ const commit = (await run('git', ['rev-parse', 'HEAD'], root, environment)).trim();
31
+ const application = await phase(session, 'application-runtime', () => applicationRuntime(root, providerRun));
32
+ await phase(session, 'checks', () => run('pnpm', ['run', 'check'], root, environment));
33
+ if ((await run('git', ['status', '--porcelain'], root, environment)).trim() ||
34
+ (await run('git', ['rev-parse', 'HEAD'], root, environment)).trim() !== commit)
35
+ throw new Error('Source changed during checks; provisioning was not started.');
36
+ const configured = await phase(session, 'integrations', () => provisionSelectedProviders(root, false, providerRun, send, providerEnvironment));
37
+ if (!configured.ready)
38
+ return { state: 'provider-configuration-required', deployed: false, integrations: configured };
39
+ if ((await run('git', ['status', '--porcelain'], root, environment)).trim() ||
40
+ (await run('git', ['rev-parse', 'HEAD'], root, environment)).trim() !== commit)
41
+ throw new Error('Source changed during provider configuration; provisioning was stopped.');
42
+ const resources = await phase(session, 'resources', () => provisionApplication(root, false, providerRun, request));
43
+ if ((await run('git', ['status', '--porcelain'], root, environment)).trim()) {
44
+ return {
45
+ state: 'configuration-required',
46
+ resources,
47
+ deployed: false,
48
+ nextAction: 'Review and commit the resolved resource bindings, then run anhedral ship again. No source commit or deployment was performed automatically.',
49
+ };
50
+ }
51
+ if ((await run('git', ['rev-parse', 'HEAD'], root, environment)).trim() !== commit)
52
+ throw new Error('Source changed during provider configuration; deployment was not started.');
53
+ const runtime = configuredRuntime(root);
54
+ const environments = mergeRuntimeTargets(runtimeTargets(root, runtime), application);
55
+ const buildRunner = async (command, args, cwd, env) => {
56
+ const values = environments[`${path.relative(root, cwd).split(path.sep).join('/')}/.dev.vars`];
57
+ const environment = runtimeEnvironment(env, values);
58
+ if (command !== 'pnpm' ||
59
+ args.join(' ') !== 'run deploy' ||
60
+ !values ||
61
+ !Object.keys(values).length)
62
+ return run(command, args, cwd, environment);
63
+ const file = path.join(tmpdir(), `anhedral-secrets-${randomUUID()}.json`);
64
+ try {
65
+ writeFileSync(file, JSON.stringify(values), { mode: 0o600, flag: 'wx' });
66
+ return await run(command, [...args, '--secrets-file', file], cwd, environment);
67
+ }
68
+ finally {
69
+ rmSync(file, { force: true });
70
+ }
71
+ };
72
+ return phase(session, 'deployment', () => shipApplication(root, buildRunner, request));
73
+ }
74
+ async function executeVercelApplication(root, dryRun = false, run = defaultRunner, send = fetch, providerEnvironment = process.env, session) {
75
+ const deployment = planVercelDelivery(root);
76
+ const integrations = planProviderProvisioning(root);
77
+ if (dryRun)
78
+ return { ...deployment, integrations, mutation: false };
79
+ if (!deployment.project.projectId ||
80
+ !deployment.project.teamId ||
81
+ deployment.project.audience === 'unconfigured')
82
+ throw new Error('Connect the intended Vercel account, plan and audience before shipping.');
83
+ const env = runtimeEnvironment(providerEnvironment);
84
+ const providerRun = (command, args, cwd, env) => run(command, args, cwd, runtimeEnvironment(env));
85
+ if (realpathSync((await run('git', ['rev-parse', '--show-toplevel'], root, env)).trim()) !==
86
+ realpathSync(root) ||
87
+ (await run('git', ['status', '--porcelain'], root, env)).trim())
88
+ throw new Error('Shipping requires a clean application repository before provisioning.');
89
+ const commit = (await run('git', ['rev-parse', 'HEAD'], root, env)).trim();
90
+ const application = await phase(session, 'application-runtime', () => applicationRuntime(root, providerRun));
91
+ await phase(session, 'checks', () => run('pnpm', ['run', 'check'], root, env));
92
+ if ((await run('git', ['status', '--porcelain'], root, env)).trim() ||
93
+ (await run('git', ['rev-parse', 'HEAD'], root, env)).trim() !== commit)
94
+ throw new Error('Source changed during checks; provisioning was not started.');
95
+ const configured = await phase(session, 'integrations', () => provisionSelectedProviders(root, false, providerRun, send, providerEnvironment));
96
+ if (!configured.ready)
97
+ return { state: 'provider-configuration-required', deployed: false, integrations: configured };
98
+ const runtime = configuredRuntime(root);
99
+ if ((await run('git', ['status', '--porcelain'], root, env)).trim() ||
100
+ (await run('git', ['rev-parse', 'HEAD'], root, env)).trim() !== commit)
101
+ throw new Error('Source changed during provider configuration; deployment was not started.');
102
+ const environments = mergeRuntimeTargets(runtimeTargets(root, runtime), application);
103
+ const values = environments['apps/web/.env.local'] ?? {};
104
+ await phase(session, 'runtime', () => configureVercelEnvironment(root, values, providerRun));
105
+ const buildRunner = (command, args, cwd, env) => run(command, args, cwd, runtimeEnvironment(env, values));
106
+ return phase(session, 'deployment', () => shipVercelApplication(root, buildRunner));
107
+ }
108
+ function phase(session, name, action) {
109
+ return session ? session.phase(name, action) : action();
110
+ }
111
+ export async function shipCloudflareApplication(root, dryRun = false, run = defaultRunner, request, send = fetch, providerEnvironment = process.env) {
112
+ if (dryRun)
113
+ return executeCloudflareApplication(root, true, run, request, send, providerEnvironment);
114
+ return withLifecycleOperation(root, 'cloudflare', run, (session) => executeCloudflareApplication(root, false, run, request, send, providerEnvironment, session));
115
+ }
116
+ export async function shipSelectedVercelApplication(root, dryRun = false, run = defaultRunner, send = fetch, providerEnvironment = process.env) {
117
+ if (dryRun)
118
+ return executeVercelApplication(root, true, run, send, providerEnvironment);
119
+ return withLifecycleOperation(root, 'vercel', run, (session) => executeVercelApplication(root, false, run, send, providerEnvironment, session));
120
+ }
121
+ function runtimeEnvironment(base, values = {}) {
122
+ const environment = { ...base, CI: '1', NO_COLOR: '1' };
123
+ for (const name of Object.values(CREDENTIALS))
124
+ delete environment[name];
125
+ for (const name of RUNTIME_KEYS)
126
+ if (!name.startsWith('NEXT_PUBLIC_') && !name.startsWith('EXPO_PUBLIC_'))
127
+ delete environment[name];
128
+ return { ...environment, ...values };
129
+ }
130
+ function mergeRuntimeTargets(providers, application) {
131
+ const targets = { ...providers };
132
+ for (const [file, values] of Object.entries(application))
133
+ targets[file] = { ...targets[file], ...values };
134
+ return targets;
135
+ }
136
+ /** Each mixed target keeps its own release receipt; this is not a provider transaction. */
137
+ export async function shipSelectedStack(root, dryRun = false, run = defaultRunner, request, send = fetch, providerEnvironment = process.env) {
138
+ root = realpathSync(root);
139
+ const mixed = existsSync(path.join(root, 'anhedral.web.json')) &&
140
+ existsSync(path.join(root, 'anhedral.project.json')) &&
141
+ readApplication(root).targets.length > 0;
142
+ if (!mixed)
143
+ return existsSync(path.join(root, 'anhedral.web.json'))
144
+ ? shipSelectedVercelApplication(root, dryRun, run, send, providerEnvironment)
145
+ : shipCloudflareApplication(root, dryRun, run, request, send, providerEnvironment);
146
+ const cloudflare = planDelivery(root, true);
147
+ const vercel = planVercelDelivery(root);
148
+ if (dryRun)
149
+ return {
150
+ mutation: false,
151
+ dependencies: [
152
+ { target: 'cloudflare', after: [] },
153
+ { target: 'vercel', after: ['cloudflare'] },
154
+ ],
155
+ targets: [
156
+ { provider: 'cloudflare', ...cloudflare },
157
+ { provider: 'vercel', ...vercel },
158
+ ],
159
+ integrations: planProviderProvisioning(root),
160
+ };
161
+ if (!cloudflare.project.accountId ||
162
+ cloudflare.project.audience === 'unconfigured' ||
163
+ !vercel.project.projectId ||
164
+ !vercel.project.teamId ||
165
+ vercel.project.audience === 'unconfigured')
166
+ throw new Error('Connect both intended hosting accounts and audiences before mixed delivery.');
167
+ return withLifecycleOperation(root, 'mixed', run, async (session) => {
168
+ const scoped = (prefix) => ({
169
+ phase: (name, action) => session.phase(`${prefix}-${name}`, action),
170
+ });
171
+ const services = await executeCloudflareApplication(root, false, run, request, send, providerEnvironment, scoped('cloudflare'));
172
+ if ('state' in services &&
173
+ ['configuration-required', 'provider-configuration-required'].includes(services.state))
174
+ return {
175
+ state: services.state,
176
+ deployed: false,
177
+ targets: [{ provider: 'cloudflare', result: services }],
178
+ nextAction: 'Resolve Cloudflare setup and review source changes, then repeat ship. Vercel was not deployed.',
179
+ };
180
+ try {
181
+ const web = await executeVercelApplication(root, false, run, send, providerEnvironment, scoped('vercel'));
182
+ const blocked = 'state' in web && web.state === 'provider-configuration-required';
183
+ return {
184
+ state: blocked ? 'partial' : 'deployed',
185
+ deployed: !blocked,
186
+ targets: [
187
+ { provider: 'cloudflare', result: services },
188
+ { provider: 'vercel', result: web },
189
+ ],
190
+ productVerification: 'required',
191
+ ...(blocked
192
+ ? {
193
+ nextAction: 'Cloudflare completed. Resolve Vercel prerequisites and repeat ship; no resource or data rollback was attempted.',
194
+ }
195
+ : {}),
196
+ };
197
+ }
198
+ catch {
199
+ return {
200
+ state: 'partial',
201
+ deployed: false,
202
+ targets: [
203
+ { provider: 'cloudflare', result: services },
204
+ { provider: 'vercel', state: 'failed' },
205
+ ],
206
+ productVerification: 'required',
207
+ nextAction: 'Cloudflare completed; Vercel stopped. Inspect hosting status and the failed operation phase, then repeat the deployment plan. No resource or data rollback was attempted.',
208
+ };
209
+ }
210
+ });
211
+ }
@@ -30,7 +30,7 @@ declare const PRODUCT_ITEMS: {
30
30
  styling: ItemDefinition;
31
31
  };
32
32
  export type StandardProduct = keyof typeof PRODUCT_ITEMS;
33
- export declare const STANDARD_PRODUCTS: readonly ("realtime" | "electron" | "wxt" | "expo" | "vinext" | "next" | "workflows" | "styling" | "hono" | "neon" | "d1" | "local-data" | "clerk" | "better-auth" | "r2" | "kv" | "queues" | "cron" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "basin" | "posthog")[];
33
+ export declare const STANDARD_PRODUCTS: readonly ("realtime" | "d1" | "r2" | "kv" | "queues" | "workflows" | "electron" | "wxt" | "expo" | "vinext" | "next" | "styling" | "hono" | "neon" | "local-data" | "clerk" | "better-auth" | "cron" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "basin" | "posthog")[];
34
34
  declare const DEFINITIONS: {
35
35
  vinext: ItemDefinition;
36
36
  next: ItemDefinition;
@@ -67,7 +67,7 @@ declare const DEFINITIONS: {
67
67
  export type StackItemId = keyof typeof DEFINITIONS;
68
68
  export declare function getStackDefinition(name: string): ItemDefinition;
69
69
  export declare function getStackItem(name: string): StackRegistryItem;
70
- export declare const STACK_ITEMS: Record<"realtime" | "electron" | "eslint" | "typescript" | "wxt" | "expo" | "vinext" | "next" | "workflows" | "ui" | "workspace" | "styling" | "hono" | "neon" | "d1" | "local-data" | "clerk" | "better-auth" | "r2" | "kv" | "queues" | "cron" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "basin" | "posthog", StackRegistryItem>;
70
+ export declare const STACK_ITEMS: Record<"realtime" | "d1" | "r2" | "kv" | "queues" | "workflows" | "electron" | "eslint" | "typescript" | "wxt" | "expo" | "vinext" | "next" | "ui" | "workspace" | "styling" | "hono" | "neon" | "local-data" | "clerk" | "better-auth" | "cron" | "openai" | "ai-sdk" | "workers-ai" | "resend" | "stripe" | "revenuecat" | "sentry" | "basin" | "posthog", StackRegistryItem>;
71
71
  export declare const STACK_REGISTRY: {
72
72
  schemaVersion: number;
73
73
  name: string;
@@ -137,7 +137,12 @@ export interface LocalDataStore {
137
137
  registryDependencies: ['workspace', 'typescript', 'eslint'],
138
138
  setup: requirements('Managed identity', ['Clerk integration or dashboard'], ['Client-owned Clerk project access'], ['Clerk publishable key; server secret key; webhook secret when used'], ['Identity project, allowed URLs, SDK setup and protected routes'], ['Sign-in/out, session expiry, resource authorization and selected native client flows']),
139
139
  install: scaffoldClerk,
140
- environment: ['NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY', 'CLERK_PUBLISHABLE_KEY', 'CLERK_SECRET_KEY'],
140
+ environment: [
141
+ 'NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY',
142
+ 'EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY',
143
+ 'CLERK_PUBLISHABLE_KEY',
144
+ 'CLERK_SECRET_KEY',
145
+ ],
141
146
  resolveEnvironment: ({ has }) => [
142
147
  'CLERK_SECRET_KEY',
143
148
  ...(has('vinext') || has('next') ? ['NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY'] : []),
@@ -289,6 +294,7 @@ export interface LocalDataStore {
289
294
  registryDependencies: ['stripe'],
290
295
  setup: requirements('Cross-store subscription entitlements alongside Stripe', ['RevenueCat integration or API', 'Selected mobile store tooling'], ['RevenueCat project; App Store/Play Store product access'], ['Platform public SDK keys; server API/webhook credentials as required'], ['Integration guidance only; install platform SDKs and configure offerings/store products'], ['Sandbox purchase/restore, verified webhooks and entitlement reconciliation']),
291
296
  install: scaffoldRevenueCat,
297
+ environment: ['EXPO_PUBLIC_REVENUECAT_IOS_API_KEY', 'EXPO_PUBLIC_REVENUECAT_ANDROID_API_KEY'],
292
298
  },
293
299
  sentry: {
294
300
  type: 'package',
@@ -1,7 +1,8 @@
1
1
  import { parseStandardOptions } from './registry/options.js';
2
2
  import { STANDARD_USAGE } from './registry/usage.js';
3
3
  import type { StandardOptions, StandardRunner } from './registry/types.js';
4
+ import { type OutputOptions } from './cli-output.js';
4
5
  export { parseStandardOptions, STANDARD_USAGE };
5
6
  export { STANDARD_PRODUCTS } from './stack-registry.js';
6
7
  export type { StandardOptions, StandardProduct, StandardRunner } from './registry/types.js';
7
- export declare function scaffoldStandardProject(options: StandardOptions, run?: StandardRunner): Promise<void>;
8
+ export declare function scaffoldStandardProject(options: StandardOptions, run?: StandardRunner, output?: OutputOptions): Promise<void>;
package/dist/standard.js CHANGED
@@ -12,12 +12,14 @@ import { bootstrapWorkspace, assertBootstrapPlatform, assertWorkspaceRuntime, }
12
12
  import { composeStack } from './scaffold/compose.js';
13
13
  import { parseStandardOptions } from './registry/options.js';
14
14
  import { STANDARD_USAGE } from './registry/usage.js';
15
+ import { printProgress, printResult } from './cli-output.js';
15
16
  export { parseStandardOptions, STANDARD_USAGE };
16
17
  export { STANDARD_PRODUCTS } from './stack-registry.js';
17
- export async function scaffoldStandardProject(options, run = execFile) {
18
+ export async function scaffoldStandardProject(options, run = execFile, output = {}) {
18
19
  const plan = createSetupPlan(options);
20
+ const display = { ...output, json: options.json };
19
21
  if (options.dryRun) {
20
- console.log(options.json ? JSON.stringify(plan, null, 2) : JSON.stringify(plan));
22
+ printResult('init', plan, { ...output, json: options.json });
21
23
  return;
22
24
  }
23
25
  assertBootstrapPlatform(run);
@@ -47,12 +49,15 @@ export async function scaffoldStandardProject(options, run = execFile) {
47
49
  throw new Error('Destination changed before generation.');
48
50
  },
49
51
  build: async (stageRoot) => {
52
+ printProgress('Creating the shadcn/Turborepo workspace…', display);
50
53
  bootstrapWorkspace(stageRoot, options.name, run);
54
+ printProgress('Composing the selected stack…', display);
51
55
  await composeStack(stageRoot, options, plan.registry);
52
56
  if (options.products.includes('next') && options.hosting === 'vercel')
53
57
  registerVercelApplication(stageRoot);
54
58
  if (readdirSync(path.join(stageRoot, 'apps')).some((app) => existsSync(path.join(stageRoot, 'apps', app, 'wrangler.jsonc'))))
55
59
  registerApplication(stageRoot);
60
+ printProgress('Resolving pinned dependencies…', display);
56
61
  run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], stageRoot);
57
62
  if (configureSecurityBackports(stageRoot))
58
63
  run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile'], stageRoot);
@@ -68,18 +73,13 @@ export async function scaffoldStandardProject(options, run = execFile) {
68
73
  if (checkout.status !== 0 || realpathSync(checkout.stdout.trim()) !== realpathSync(root))
69
74
  run('git', ['init'], root);
70
75
  }
71
- if (!options.skipInstall)
76
+ if (!options.skipInstall) {
77
+ printProgress('Installing workspace dependencies…', display);
72
78
  run('pnpm', ['install', '--frozen-lockfile'], root);
79
+ }
73
80
  },
74
81
  });
75
- console.log(options.json
76
- ? JSON.stringify({ ...plan, generated: true })
77
- : `Created ${root}. Next: cd ${JSON.stringify(root)}, then pnpm dev. Implement the product flows, configure selected resources using README.md and anhedral.setup.json, and run pnpm check. Record stack decisions in docs/architecture.md and exercised acceptance criteria in docs/verification.md.`);
78
- if (!options.json) {
79
- console.log('\nHelp keep Anhedral Init free and open source.');
80
- console.log('Sponsor ongoing development, maintenance, and documentation.');
81
- console.log('Become a sponsor: https://github.com/anhedral/anhedral-init/blob/main/docs/sponsorships.md');
82
- }
82
+ printResult('init', { ...plan, generated: true }, { ...output, json: options.json });
83
83
  }
84
84
  finally {
85
85
  if (created && existsSync(root) && readdirSync(root).length === 0)