anhedral 0.11.2 → 0.13.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 +171 -18
- package/dist/bin.js +48 -493
- package/dist/capabilities.d.ts +3 -3
- package/dist/capability-contract.js +16 -1
- package/dist/cli-arguments.d.ts +8 -0
- package/dist/cli-arguments.js +32 -0
- package/dist/cli-commands.d.ts +3 -0
- package/dist/cli-commands.js +114 -0
- package/dist/cli-delivery.d.ts +3 -0
- package/dist/cli-delivery.js +172 -0
- package/dist/cli-output.js +231 -205
- package/dist/command-schema.js +8 -2
- package/dist/command.js +9 -11
- package/dist/delivery-evidence.d.ts +62 -0
- package/dist/delivery-evidence.js +186 -0
- package/dist/delivery.d.ts +3 -40
- package/dist/delivery.js +7 -182
- package/dist/dependencies.d.ts +7 -1
- package/dist/dependencies.js +15 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mobile-delivery.d.ts +21 -44
- package/dist/mobile-delivery.js +127 -80
- package/dist/platforms/mobile.d.ts +1 -1
- package/dist/platforms/mobile.js +44 -3
- package/dist/project-state.js +4 -1
- package/dist/provider-auth.js +9 -3
- package/dist/providers/adapters.js +9 -3
- package/dist/providers/runtime.js +11 -0
- package/dist/readiness.js +4 -2
- package/dist/registry/add.js +40 -7
- package/dist/registry/options.js +12 -0
- package/dist/registry/presets.d.ts +4 -0
- package/dist/registry/presets.js +41 -0
- package/dist/registry/resolve.d.ts +3 -1
- package/dist/registry/resolve.js +40 -14
- package/dist/registry/types.d.ts +1 -0
- package/dist/registry/usage.js +1 -1
- package/dist/runtime-policy.js +4 -1
- package/dist/scaffold/api.js +10 -2
- package/dist/scaffold/auth.d.ts +1 -1
- package/dist/scaffold/auth.js +22 -6
- package/dist/scaffold/backend.d.ts +6 -0
- package/dist/scaffold/backend.js +224 -0
- package/dist/scaffold/billing-config.d.ts +1 -0
- package/dist/scaffold/billing-config.js +73 -0
- package/dist/scaffold/billing-contracts.d.ts +2 -0
- package/dist/scaffold/billing-contracts.js +48 -0
- package/dist/scaffold/billing-providers.d.ts +1 -0
- package/dist/scaffold/billing-providers.js +249 -0
- package/dist/scaffold/billing-schema.d.ts +1 -0
- package/dist/scaffold/billing-schema.js +34 -0
- package/dist/scaffold/billing-security.d.ts +1 -0
- package/dist/scaffold/billing-security.js +46 -0
- package/dist/scaffold/billing-server.d.ts +1 -0
- package/dist/scaffold/billing-server.js +139 -0
- package/dist/scaffold/billing-store.d.ts +1 -0
- package/dist/scaffold/billing-store.js +72 -0
- package/dist/scaffold/billing.d.ts +2 -0
- package/dist/scaffold/billing.js +216 -0
- package/dist/scaffold/cloudflare-services.d.ts +8 -0
- package/dist/scaffold/cloudflare-services.js +198 -0
- package/dist/scaffold/compose.js +2 -0
- package/dist/scaffold/database.js +19 -2
- package/dist/scaffold/documentation.js +11 -6
- package/dist/scaffold/expo-auth.d.ts +3 -0
- package/dist/scaffold/expo-auth.js +192 -0
- package/dist/scaffold/expo-billing.d.ts +3 -0
- package/dist/scaffold/expo-billing.js +292 -0
- package/dist/scaffold/expo-runtime.d.ts +3 -0
- package/dist/scaffold/expo-runtime.js +134 -0
- package/dist/scaffold/integrations.d.ts +2 -1
- package/dist/scaffold/integrations.js +7 -2
- package/dist/scaffold/stream.d.ts +2 -0
- package/dist/scaffold/stream.js +114 -0
- package/dist/scaffold/void.js +13 -5
- package/dist/scaffold/web.js +2 -0
- package/dist/scaffold/workspace.js +6 -1
- package/dist/service-readers.js +1 -1
- package/dist/services-command.js +8 -6
- package/dist/ship.d.ts +15 -15
- package/dist/ship.js +3 -1
- package/dist/stack-registry.d.ts +13 -2
- package/dist/stack-registry.js +152 -16
- package/dist/transaction-lock.d.ts +15 -0
- package/dist/transaction-lock.js +227 -0
- package/dist/transaction.js +2 -208
- package/dist/vercel-project.d.ts +101 -0
- package/dist/vercel-project.js +305 -0
- package/dist/vercel.d.ts +3 -36
- package/dist/vercel.js +3 -300
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +122 -0
- package/docs/software-factory.md +402 -7
- package/docs/stack-standard.md +226 -49
- package/docs/verification.md +557 -0
- package/package.json +7 -7
- package/docs/cli-design.md +0 -67
- package/docs/plugin-ui.md +0 -102
- package/docs/provider-configuration.md +0 -116
- package/docs/void-verification.md +0 -185
package/dist/mobile-delivery.js
CHANGED
|
@@ -68,7 +68,7 @@ export async function buildMobileApplication(root, options, run = defaultRunner)
|
|
|
68
68
|
await executeMobileBuild(root, { ...options, dryRun: true }, run);
|
|
69
69
|
return withLifecycleOperation(root, 'mobile', run, (session) => session.phase('mobile-build', () => executeMobileBuild(root, options, run)));
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
function mobileConfiguration(root, options) {
|
|
72
72
|
root = realpathSync(root);
|
|
73
73
|
if (!['ios', 'android'].includes(options.platform) ||
|
|
74
74
|
!/^[a-z][a-z0-9-]{0,63}$/.test(options.profile))
|
|
@@ -110,15 +110,9 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
110
110
|
'--json',
|
|
111
111
|
'--no-wait',
|
|
112
112
|
];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
profile: options.profile,
|
|
117
|
-
command: ['pnpm', ...args],
|
|
118
|
-
mutation: false,
|
|
119
|
-
storeSubmission: false,
|
|
120
|
-
integrations: planProviderProvisioning(root),
|
|
121
|
-
};
|
|
113
|
+
return { root, options, directory, profile, selectedEnvironment, args };
|
|
114
|
+
}
|
|
115
|
+
function readMobileApplication(directory) {
|
|
122
116
|
const app = JSON.parse(readBoundedFile(path.join(directory, 'app.json'), MAX_PROJECT_JSON_BYTES).toString('utf8')).expo;
|
|
123
117
|
if (['app.config.js', 'app.config.ts'].some((file) => existsSync(path.join(directory, file))))
|
|
124
118
|
throw new Error('Automatic EAS setup requires a static app.json with explicit owner and slug.');
|
|
@@ -127,57 +121,46 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
127
121
|
typeof app.slug !== 'string' ||
|
|
128
122
|
!/^[a-zA-Z0-9_-]+$/.test(app.slug))
|
|
129
123
|
throw new Error('Set the intended Expo owner and slug in app.json before shipping.');
|
|
124
|
+
return app;
|
|
125
|
+
}
|
|
126
|
+
function mobileEnvironment() {
|
|
130
127
|
const environment = { ...process.env, CI: '1', NO_COLOR: '1' };
|
|
131
128
|
// Expo keeps its own login credential; server/provider keys never reach native builds.
|
|
132
129
|
for (const key of [...Object.values(CREDENTIALS), ...RUNTIME_KEYS])
|
|
133
130
|
if (!key.startsWith('EXPO_PUBLIC_'))
|
|
134
131
|
delete environment[key];
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
return environment;
|
|
133
|
+
}
|
|
134
|
+
async function mobileSource(root, environment, run) {
|
|
135
|
+
if (realpathSync((await run('git', ['rev-parse', '--show-toplevel'], root, environment)).trim()) !==
|
|
136
|
+
root ||
|
|
137
|
+
(await run('git', ['status', '--porcelain'], root, environment)).trim())
|
|
138
|
+
throw new Error('Mobile delivery requires a clean application Git repository.');
|
|
139
|
+
const commit = (await run('git', ['rev-parse', 'HEAD'], root, environment)).trim();
|
|
140
|
+
if (!/^[a-f0-9]{40,64}$/.test(commit))
|
|
141
|
+
throw new Error('Invalid mobile source commit.');
|
|
142
|
+
return commit;
|
|
143
|
+
}
|
|
144
|
+
const easCli = ['dlx', `eas-cli@${EAS_CLI_VERSION}`];
|
|
145
|
+
async function linkMobileProject({ configuration: { directory }, app, environment, run, }) {
|
|
146
|
+
const cli = easCli;
|
|
147
|
+
await run('pnpm', [...cli, 'project:init', '--non-interactive', '--force'], directory, environment);
|
|
148
|
+
const linked = JSON.parse(readBoundedFile(path.join(directory, 'app.json'), MAX_PROJECT_JSON_BYTES).toString('utf8')).expo;
|
|
149
|
+
if (linked?.owner !== app.owner ||
|
|
150
|
+
linked.slug !== app.slug ||
|
|
151
|
+
typeof linked.extra?.eas?.projectId !== 'string' ||
|
|
152
|
+
!/^[a-f0-9-]{36}$/i.test(linked.extra.eas.projectId))
|
|
153
|
+
throw new Error('EAS did not confirm a project link for the selected owner and slug. Inspect the account before retrying.');
|
|
154
|
+
return {
|
|
155
|
+
state: 'configuration-required',
|
|
156
|
+
deployed: false,
|
|
157
|
+
storeSubmission: false,
|
|
158
|
+
nextAction: 'Review and commit the EAS project link written to app.json, then run ship again.',
|
|
143
159
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if ((await source()) !== initialCommit)
|
|
149
|
-
throw new Error('Source changed during mobile checks.');
|
|
150
|
-
const configured = await provisionSelectedProviders(root, false, run);
|
|
151
|
-
if (!configured.ready)
|
|
152
|
-
return {
|
|
153
|
-
state: 'provider-configuration-required',
|
|
154
|
-
deployed: false,
|
|
155
|
-
integrations: configured,
|
|
156
|
-
storeSubmission: false,
|
|
157
|
-
};
|
|
158
|
-
const runtime = configuredRuntime(root);
|
|
159
|
-
const commit = await source();
|
|
160
|
-
if (commit !== initialCommit)
|
|
161
|
-
throw new Error('Source changed during provider configuration.');
|
|
162
|
-
const cli = ['dlx', `eas-cli@${EAS_CLI_VERSION}`];
|
|
163
|
-
if (!app.extra?.eas?.projectId) {
|
|
164
|
-
await run('pnpm', [...cli, 'project:init', '--non-interactive', '--force'], directory, environment);
|
|
165
|
-
const linked = JSON.parse(readBoundedFile(path.join(directory, 'app.json'), MAX_PROJECT_JSON_BYTES).toString('utf8')).expo;
|
|
166
|
-
if (linked?.owner !== app.owner ||
|
|
167
|
-
linked.slug !== app.slug ||
|
|
168
|
-
typeof linked.extra?.eas?.projectId !== 'string' ||
|
|
169
|
-
!/^[a-f0-9-]{36}$/i.test(linked.extra.eas.projectId))
|
|
170
|
-
throw new Error('EAS did not confirm a project link for the selected owner and slug. Inspect the account before retrying.');
|
|
171
|
-
return {
|
|
172
|
-
state: 'configuration-required',
|
|
173
|
-
deployed: false,
|
|
174
|
-
storeSubmission: false,
|
|
175
|
-
nextAction: 'Review and commit the EAS project link written to app.json, then run ship again.',
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const projectId = app.extra.eas.projectId;
|
|
179
|
-
if (typeof projectId !== 'string' || !/^[a-f0-9-]{36}$/i.test(projectId))
|
|
180
|
-
throw new Error('Invalid EAS project ID.');
|
|
160
|
+
}
|
|
161
|
+
async function verifyMobileProject(session, projectId) {
|
|
162
|
+
const { configuration: { directory }, app, environment, run, } = session;
|
|
163
|
+
const cli = easCli;
|
|
181
164
|
const remote = await run('pnpm', [...cli, 'project:info'], directory, environment);
|
|
182
165
|
const remoteName = remote
|
|
183
166
|
.split(/\r?\n/)
|
|
@@ -191,7 +174,10 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
191
174
|
.split(/\s+/)[1];
|
|
192
175
|
if (remoteId !== projectId || remoteName !== `@${app.owner}/${app.slug}`)
|
|
193
176
|
throw new Error('EAS project identity differs from the selected owner and project.');
|
|
194
|
-
|
|
177
|
+
}
|
|
178
|
+
async function configureMobileEnvironment(session, values) {
|
|
179
|
+
const { configuration: { directory, selectedEnvironment }, environment, run, } = session;
|
|
180
|
+
const cli = easCli;
|
|
195
181
|
if (values && Object.keys(values).length) {
|
|
196
182
|
const file = path.join(tmpdir(), `anhedral-expo-${randomUUID()}.env`);
|
|
197
183
|
try {
|
|
@@ -204,6 +190,12 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
204
190
|
rmSync(file, { force: true });
|
|
205
191
|
}
|
|
206
192
|
}
|
|
193
|
+
}
|
|
194
|
+
async function requestMobileBuild(session, selection) {
|
|
195
|
+
const { configuration: { root, options, directory, args }, environment, run, } = session;
|
|
196
|
+
const { commit, projectId, values } = selection;
|
|
197
|
+
const cli = easCli;
|
|
198
|
+
const source = () => mobileSource(root, environment, run);
|
|
207
199
|
let builds;
|
|
208
200
|
let expectedBuildId;
|
|
209
201
|
const pendingFile = path.join(root, '.anhedral/mobile-build.pending.json');
|
|
@@ -236,25 +228,48 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
236
228
|
catch {
|
|
237
229
|
throw new Error('EAS build did not return verified completion; inspect the selected Expo project before retrying.');
|
|
238
230
|
}
|
|
231
|
+
return { builds, expectedBuildId, pendingFile };
|
|
232
|
+
}
|
|
233
|
+
function validateMobileBuild(session, selection, builds, expectedBuildId) {
|
|
234
|
+
const { configuration: { options, profile, selectedEnvironment }, app, } = session;
|
|
235
|
+
const { commit, projectId } = selection;
|
|
239
236
|
if (!Array.isArray(builds) || builds.length !== 1)
|
|
240
237
|
throw new Error('EAS returned an unexpected build selection.');
|
|
241
238
|
const build = builds[0];
|
|
242
|
-
const downloadUrl = artifactUrl(build?.artifacts?.applicationArchiveUrl ?? build?.artifacts?.buildUrl);
|
|
243
239
|
if (typeof build?.id !== 'string' || !/^[a-zA-Z0-9-]{1,255}$/.test(build.id))
|
|
244
240
|
throw new Error('EAS did not return a valid build ID.');
|
|
245
241
|
if (build.project?.id !== projectId ||
|
|
246
242
|
build.project?.ownerAccount?.name !== app.owner ||
|
|
247
243
|
build.project?.slug !== app.slug)
|
|
248
244
|
throw new Error('EAS build belongs to a different project.');
|
|
245
|
+
validateBuildProfile(build, options, profile, selectedEnvironment);
|
|
246
|
+
if (build.gitCommitHash !== commit)
|
|
247
|
+
throw new Error('EAS build source differs from the selected source commit.');
|
|
248
|
+
if (expectedBuildId && build.id !== expectedBuildId)
|
|
249
|
+
throw new Error('EAS returned a different build than the recorded selection.');
|
|
250
|
+
return build;
|
|
251
|
+
}
|
|
252
|
+
function validateBuildProfile(build, options, profile, selectedEnvironment) {
|
|
249
253
|
if (build.platform !== options.platform.toUpperCase() ||
|
|
250
254
|
build.buildProfile !== options.profile ||
|
|
251
255
|
(build.environment !== undefined && build.environment !== selectedEnvironment) ||
|
|
252
256
|
(options.platform === 'ios' && build.isForIosSimulator !== (profile.ios?.simulator === true)))
|
|
253
257
|
throw new Error('EAS build platform, profile or environment differs from the selected configuration.');
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
+
}
|
|
259
|
+
function mobileArtifact(options, profile) {
|
|
260
|
+
if (options.platform === 'ios')
|
|
261
|
+
return profile.ios?.simulator === true ? 'ios-simulator' : 'ipa';
|
|
262
|
+
return profile.android?.buildType === 'apk' ||
|
|
263
|
+
profile.distribution === 'internal' ||
|
|
264
|
+
profile.developmentClient === true
|
|
265
|
+
? 'apk'
|
|
266
|
+
: 'aab';
|
|
267
|
+
}
|
|
268
|
+
async function recordMobileBuild(session, selection, build, pendingFile) {
|
|
269
|
+
const { configuration: { root, options, profile }, app, environment, run, } = session;
|
|
270
|
+
const { commit, projectId } = selection;
|
|
271
|
+
const source = () => mobileSource(root, environment, run);
|
|
272
|
+
const downloadUrl = artifactUrl(build.artifacts?.applicationArchiveUrl ?? build.artifacts?.buildUrl);
|
|
258
273
|
atomicJson(pendingFile, {
|
|
259
274
|
schemaVersion: 1,
|
|
260
275
|
status: 'queued',
|
|
@@ -265,7 +280,7 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
265
280
|
buildId: build.id,
|
|
266
281
|
});
|
|
267
282
|
const buildPage = `https://expo.dev/accounts/${app.owner}/projects/${app.slug}/builds/${build.id}`;
|
|
268
|
-
if (['NEW', 'IN_QUEUE', 'IN_PROGRESS', 'PENDING_CANCEL'].includes(build.status))
|
|
283
|
+
if (['NEW', 'IN_QUEUE', 'IN_PROGRESS', 'PENDING_CANCEL'].includes(build.status ?? ''))
|
|
269
284
|
return {
|
|
270
285
|
schemaVersion: 1,
|
|
271
286
|
state: 'building',
|
|
@@ -281,21 +296,14 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
281
296
|
throw new Error('EAS has not confirmed a completed downloadable build. Inspect the recorded build before retrying.');
|
|
282
297
|
if ((await source()) !== commit)
|
|
283
298
|
throw new Error('Source changed during mobile build; do not treat this artifact as the current release.');
|
|
284
|
-
const owner = build.project?.ownerAccount?.name;
|
|
285
|
-
const slug = build.project?.slug;
|
|
286
|
-
const buildPageUrl = typeof owner === 'string' &&
|
|
287
|
-
/^[a-zA-Z0-9_-]+$/.test(owner) &&
|
|
288
|
-
typeof slug === 'string' &&
|
|
289
|
-
/^[a-zA-Z0-9_-]+$/.test(slug)
|
|
290
|
-
? `https://expo.dev/accounts/${owner}/projects/${slug}/builds/${build.id}`
|
|
291
|
-
: undefined;
|
|
292
299
|
const result = {
|
|
293
300
|
schemaVersion: 1,
|
|
294
301
|
projectId,
|
|
295
302
|
owner: app.owner,
|
|
296
303
|
slug: app.slug,
|
|
297
304
|
recordedAt: new Date().toISOString(),
|
|
298
|
-
|
|
305
|
+
// Identity validation already matched the provider owner/slug to the local app.
|
|
306
|
+
buildPageUrl: buildPage,
|
|
299
307
|
commit,
|
|
300
308
|
platform: options.platform,
|
|
301
309
|
profile: options.profile,
|
|
@@ -303,17 +311,56 @@ async function executeMobileBuild(root, options, run = defaultRunner) {
|
|
|
303
311
|
downloadUrl,
|
|
304
312
|
state: 'built',
|
|
305
313
|
storeSubmission: false,
|
|
306
|
-
artifact: options
|
|
307
|
-
? profile.ios?.simulator === true
|
|
308
|
-
? 'ios-simulator'
|
|
309
|
-
: 'ipa'
|
|
310
|
-
: profile.android?.buildType === 'apk' ||
|
|
311
|
-
profile.distribution === 'internal' ||
|
|
312
|
-
profile.developmentClient === true
|
|
313
|
-
? 'apk'
|
|
314
|
-
: 'aab',
|
|
314
|
+
artifact: mobileArtifact(options, profile),
|
|
315
315
|
};
|
|
316
316
|
atomicJson(path.join(root, '.anhedral/mobile-build.json'), result);
|
|
317
317
|
rmSync(pendingFile, { force: true });
|
|
318
318
|
return result;
|
|
319
319
|
}
|
|
320
|
+
async function executeMobileBuild(root, options, run) {
|
|
321
|
+
const configuration = mobileConfiguration(root, options);
|
|
322
|
+
root = configuration.root;
|
|
323
|
+
if (options.dryRun)
|
|
324
|
+
return {
|
|
325
|
+
platform: options.platform,
|
|
326
|
+
profile: options.profile,
|
|
327
|
+
command: ['pnpm', ...configuration.args],
|
|
328
|
+
mutation: false,
|
|
329
|
+
storeSubmission: false,
|
|
330
|
+
integrations: planProviderProvisioning(root),
|
|
331
|
+
};
|
|
332
|
+
const app = readMobileApplication(configuration.directory);
|
|
333
|
+
const environment = mobileEnvironment();
|
|
334
|
+
const session = { configuration, app, environment, run };
|
|
335
|
+
const source = () => mobileSource(root, environment, run);
|
|
336
|
+
const initialCommit = await source();
|
|
337
|
+
// Unknown submissions must stop before checks, provisioning or remote configuration.
|
|
338
|
+
pendingBuild(root, initialCommit, options, app.extra?.eas?.projectId);
|
|
339
|
+
await run('pnpm', ['run', 'check'], root, environment);
|
|
340
|
+
if ((await source()) !== initialCommit)
|
|
341
|
+
throw new Error('Source changed during mobile checks.');
|
|
342
|
+
const configured = await provisionSelectedProviders(root, false, run);
|
|
343
|
+
if (!configured.ready)
|
|
344
|
+
return {
|
|
345
|
+
state: 'provider-configuration-required',
|
|
346
|
+
deployed: false,
|
|
347
|
+
integrations: configured,
|
|
348
|
+
storeSubmission: false,
|
|
349
|
+
};
|
|
350
|
+
const runtime = configuredRuntime(root);
|
|
351
|
+
const commit = await source();
|
|
352
|
+
if (commit !== initialCommit)
|
|
353
|
+
throw new Error('Source changed during provider configuration.');
|
|
354
|
+
if (!app.extra?.eas?.projectId)
|
|
355
|
+
return linkMobileProject(session);
|
|
356
|
+
const projectId = app.extra.eas.projectId;
|
|
357
|
+
if (typeof projectId !== 'string' || !/^[a-f0-9-]{36}$/i.test(projectId))
|
|
358
|
+
throw new Error('Invalid EAS project ID.');
|
|
359
|
+
await verifyMobileProject(session, projectId);
|
|
360
|
+
const values = runtimeTargets(root, runtime)['apps/mobile/.env.local'];
|
|
361
|
+
await configureMobileEnvironment(session, values);
|
|
362
|
+
const selection = { commit, projectId, values };
|
|
363
|
+
const { builds, expectedBuildId, pendingFile } = await requestMobileBuild(session, selection);
|
|
364
|
+
const build = validateMobileBuild(session, selection, builds, expectedBuildId);
|
|
365
|
+
return recordMobileBuild(session, selection, build, pendingFile);
|
|
366
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
export declare function scaffoldExpo(
|
|
2
|
+
export declare function scaffoldExpo(context: RecipeContext): Promise<void>;
|
package/dist/platforms/mobile.js
CHANGED
|
@@ -4,6 +4,7 @@ import { writeReactLintConfig } from './lint.js';
|
|
|
4
4
|
import { appendGitignore, writeFile } from '../util.js';
|
|
5
5
|
import { childPackageName, jsString } from '../render.js';
|
|
6
6
|
import { MOBILE_APP_DEPENDENCIES, MOBILE_NATIVEWIND_DEPENDENCIES, EAS_CLI_VERSION, } from '../dependencies.js';
|
|
7
|
+
import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
|
|
7
8
|
function writeReactNativeReusablesConfig(dir) {
|
|
8
9
|
writeFile(path.join(dir, 'components.json'), JSON.stringify({
|
|
9
10
|
$schema: 'https://ui.shadcn.com/schema.json',
|
|
@@ -88,7 +89,8 @@ function expoScheme(projectName) {
|
|
|
88
89
|
const candidate = normalized || 'app';
|
|
89
90
|
return /^[a-z]/.test(candidate) ? candidate : `app-${candidate}`;
|
|
90
91
|
}
|
|
91
|
-
export async function scaffoldExpo(
|
|
92
|
+
export async function scaffoldExpo(context) {
|
|
93
|
+
const { root, options } = context;
|
|
92
94
|
const dir = path.join(root, 'apps/mobile');
|
|
93
95
|
const projectName = options.name;
|
|
94
96
|
const displayName = options.name;
|
|
@@ -132,6 +134,7 @@ export async function scaffoldExpo({ root, options }) {
|
|
|
132
134
|
slug: projectName.replace(/^@[^/]+\//, ''),
|
|
133
135
|
version: '1.0.0',
|
|
134
136
|
orientation: 'portrait',
|
|
137
|
+
userInterfaceStyle: 'automatic',
|
|
135
138
|
scheme: expoScheme(projectName),
|
|
136
139
|
web: { bundler: 'metro', output: 'static' },
|
|
137
140
|
plugins: ['expo-router', 'expo-status-bar'],
|
|
@@ -152,9 +155,11 @@ export async function scaffoldExpo({ root, options }) {
|
|
|
152
155
|
'expo-env.d.ts',
|
|
153
156
|
'nativewind-env.d.ts',
|
|
154
157
|
],
|
|
158
|
+
exclude: ['node_modules', 'worker', '.output', 'worker-configuration.d.ts'],
|
|
155
159
|
}, null, 2) + '\n');
|
|
156
160
|
writeReactNativeReusablesConfig(dir);
|
|
157
161
|
writeFile(path.join(dir, 'app/_layout.tsx'), `import '@/global.css';
|
|
162
|
+
import '@/lib/development-client';
|
|
158
163
|
|
|
159
164
|
import { PortalHost } from '@rn-primitives/portal';
|
|
160
165
|
import { Stack } from 'expo-router';
|
|
@@ -163,17 +168,43 @@ export default function RootLayout() {
|
|
|
163
168
|
return <><Stack /><PortalHost /></>;
|
|
164
169
|
}
|
|
165
170
|
`);
|
|
166
|
-
writeFile(path.join(dir, '
|
|
171
|
+
writeFile(path.join(dir, 'lib/development-client.ts'), 'export {};\n');
|
|
172
|
+
writeFile(path.join(dir, 'lib/development-client.native.ts'), "import 'expo-dev-client';\n");
|
|
173
|
+
writeFile(path.join(dir, 'app/index.tsx'), `${context.has('hono') ? "import { useEffect, useState } from 'react';\nimport { api } from '@/lib/api-client';\n" : ''}import { StatusBar } from 'expo-status-bar';
|
|
167
174
|
import { Linking, ScrollView, StyleSheet, Text, View } from 'react-native';
|
|
168
175
|
import { Button } from '@/components/ui/button';
|
|
169
176
|
|
|
170
177
|
export default function HomeScreen() {
|
|
178
|
+
${context.has('hono')
|
|
179
|
+
? `const [connection, setConnection] = useState('Connecting to the API…');
|
|
180
|
+
const [pending, setPending] = useState(true);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
let active = true;
|
|
183
|
+
void api.health().then(
|
|
184
|
+
() => { if (active) setConnection('API connected'); },
|
|
185
|
+
() => { if (active) setConnection('Unable to reach the API. Check the server and device API origin.'); },
|
|
186
|
+
).finally(() => { if (active) setPending(false); });
|
|
187
|
+
return () => { active = false; };
|
|
188
|
+
}, []);
|
|
189
|
+
async function checkConnection() {
|
|
190
|
+
setPending(true);
|
|
191
|
+
setConnection('Connecting to the API…');
|
|
192
|
+
try { await api.health(); setConnection('API connected'); }
|
|
193
|
+
catch { setConnection('Unable to reach the API. Check the server and device API origin.'); }
|
|
194
|
+
finally { setPending(false); }
|
|
195
|
+
}
|
|
196
|
+
`
|
|
197
|
+
: ''}
|
|
171
198
|
return (
|
|
172
199
|
<ScrollView style={styles.screen} contentInsetAdjustmentBehavior="automatic" contentContainerStyle={styles.container}>
|
|
173
200
|
<StatusBar style="auto" />
|
|
174
201
|
<View style={styles.content}>
|
|
175
202
|
<Text accessibilityRole="header" style={styles.title}>{${nameLiteral}}</Text>
|
|
176
203
|
<Text selectable style={styles.subtitle}>Expo application scaffold generated by Anhedral.</Text>
|
|
204
|
+
${context.has('hono')
|
|
205
|
+
? `<Text accessibilityLiveRegion="polite">{connection}</Text>
|
|
206
|
+
<Button disabled={pending} onPress={() => void checkConnection()}>{pending ? 'Connecting…' : 'Check API connection'}</Button>`
|
|
207
|
+
: ''}
|
|
177
208
|
<Button onPress={() => void Linking.openURL('https://docs.expo.dev')}>Learn more</Button>
|
|
178
209
|
</View>
|
|
179
210
|
</ScrollView>
|
|
@@ -202,5 +233,15 @@ const styles = StyleSheet.create({
|
|
|
202
233
|
production: { environment: 'production', autoIncrement: true },
|
|
203
234
|
},
|
|
204
235
|
}, null, 2) + '\n');
|
|
205
|
-
|
|
236
|
+
scaffoldExpoRuntime(context);
|
|
237
|
+
appendGitignore(dir, [
|
|
238
|
+
'.env',
|
|
239
|
+
'.env.*',
|
|
240
|
+
'!.env.example',
|
|
241
|
+
'.expo',
|
|
242
|
+
'.wrangler',
|
|
243
|
+
'.output',
|
|
244
|
+
'dist',
|
|
245
|
+
'node_modules',
|
|
246
|
+
]);
|
|
206
247
|
}
|
package/dist/project-state.js
CHANGED
|
@@ -137,7 +137,10 @@ export function registerApplication(root, extendTargets = false) {
|
|
|
137
137
|
throw new Error('Invalid Worker name.');
|
|
138
138
|
return { id: entry.name, directory: `apps/${entry.name}`, workerName };
|
|
139
139
|
})
|
|
140
|
-
.sort((a, b) =>
|
|
140
|
+
.sort((a, b) => {
|
|
141
|
+
const rank = (id) => (id === 'web' ? 2 : id === 'mobile' ? 1 : 0);
|
|
142
|
+
return rank(a.id) - rank(b.id) || a.id.localeCompare(b.id);
|
|
143
|
+
});
|
|
141
144
|
const selectedEngine = targets.length &&
|
|
142
145
|
targets.every((target) => existsSync(path.join(root, target.directory, 'void.config.ts')))
|
|
143
146
|
? 'void'
|
package/dist/provider-auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EAS_CLI_VERSION, STACK_DEPENDENCIES } from './dependencies.js';
|
|
1
|
+
import { EAS_CLI_VERSION, STACK_DEPENDENCIES, VERCEL_CLI_VERSION } from './dependencies.js';
|
|
2
2
|
import { realpathSync } from 'node:fs';
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
4
|
import { readProjectSection } from './project-config.js';
|
|
@@ -12,6 +12,12 @@ export const PROVIDER_AUTH = [
|
|
|
12
12
|
{
|
|
13
13
|
id: 'cloudflare',
|
|
14
14
|
products: [
|
|
15
|
+
'expo',
|
|
16
|
+
'analytics-engine',
|
|
17
|
+
'images',
|
|
18
|
+
'realtimekit',
|
|
19
|
+
'video',
|
|
20
|
+
'stream',
|
|
15
21
|
'vinext',
|
|
16
22
|
'hono',
|
|
17
23
|
'd1',
|
|
@@ -31,8 +37,8 @@ export const PROVIDER_AUTH = [
|
|
|
31
37
|
{
|
|
32
38
|
id: 'vercel',
|
|
33
39
|
products: [],
|
|
34
|
-
login: ['pnpm', 'dlx',
|
|
35
|
-
identity: ['pnpm', 'dlx',
|
|
40
|
+
login: ['pnpm', 'dlx', `vercel@${VERCEL_CLI_VERSION}`, 'login'],
|
|
41
|
+
identity: ['pnpm', 'dlx', `vercel@${VERCEL_CLI_VERSION}`, 'whoami'],
|
|
36
42
|
setup: 'Connect the intended Vercel team and project before shipping.',
|
|
37
43
|
},
|
|
38
44
|
...INTEGRATION_PROVIDERS.map((id) => {
|
|
@@ -117,7 +117,10 @@ async function stripe(context) {
|
|
|
117
117
|
if (!prefix.test(key))
|
|
118
118
|
throw new Error('Stripe key does not match the selected test/live mode.');
|
|
119
119
|
const resources = { account: resourceId(account.id) };
|
|
120
|
-
const runtime = {
|
|
120
|
+
const runtime = {
|
|
121
|
+
STRIPE_SECRET_KEY: key,
|
|
122
|
+
BILLING_ENVIRONMENT: config.mode === 'live' ? 'production' : 'sandbox',
|
|
123
|
+
};
|
|
121
124
|
if (setting(config, 'webhookUrl')) {
|
|
122
125
|
const webhook = await create(context, 'webhook', '/v1/webhook_endpoints', {
|
|
123
126
|
url: config.webhookUrl,
|
|
@@ -217,7 +220,7 @@ async function revenuecat(context) {
|
|
|
217
220
|
const project = object(await api(`/v2/projects/${id}`));
|
|
218
221
|
same(project.id, id, 'RevenueCat project');
|
|
219
222
|
const resources = { project: id };
|
|
220
|
-
const runtime = {};
|
|
223
|
+
const runtime = { REVENUECAT_PROJECT_ID: id };
|
|
221
224
|
if (setting(config, 'webAppId') || setting(config, 'stripeAccountId')) {
|
|
222
225
|
let appId = setting(config, 'webAppId');
|
|
223
226
|
if (!appId)
|
|
@@ -256,8 +259,11 @@ async function revenuecat(context) {
|
|
|
256
259
|
resources[`${platform}App`] = appId;
|
|
257
260
|
runtime[`EXPO_PUBLIC_REVENUECAT_${platform.toUpperCase()}_API_KEY`] = text(keys[0].key);
|
|
258
261
|
}
|
|
262
|
+
const appIds = ['iosApp', 'androidApp', 'webApp'].flatMap((name) => resources[name] ? [resources[name]] : []);
|
|
263
|
+
if (appIds.length)
|
|
264
|
+
runtime.REVENUECAT_APP_IDS_JSON = JSON.stringify(appIds);
|
|
259
265
|
return result(resources, runtime, [
|
|
260
|
-
'Configure store credentials or the Stripe connection, products and offerings and verify purchases before enabling billing. SDK keys alone do not activate subscriptions.',
|
|
266
|
+
'Configure the dedicated server RevenueCat v1 API key and authenticated webhook integration separately from the v2 management credential. Configure store credentials or the Stripe connection, products and offerings and verify purchases before enabling billing. SDK keys alone do not activate subscriptions.',
|
|
261
267
|
]);
|
|
262
268
|
}
|
|
263
269
|
export const PROVIDER_ADAPTERS = {
|
|
@@ -25,10 +25,21 @@ export const RUNTIME_KEYS = [
|
|
|
25
25
|
'RESEND_API_KEY',
|
|
26
26
|
'STRIPE_SECRET_KEY',
|
|
27
27
|
'STRIPE_WEBHOOK_SECRET',
|
|
28
|
+
'BILLING_ORIGIN',
|
|
29
|
+
'BILLING_ENVIRONMENT',
|
|
30
|
+
'BILLING_PLANS_JSON',
|
|
31
|
+
'BILLING_ENTITLEMENTS_JSON',
|
|
32
|
+
'BILLING_PREMIUM_ENTITLEMENT',
|
|
33
|
+
'REVENUECAT_SECRET_KEY',
|
|
34
|
+
'REVENUECAT_WEBHOOK_AUTHORIZATION',
|
|
35
|
+
'REVENUECAT_WEBHOOK_SIGNING_SECRET',
|
|
36
|
+
'REVENUECAT_APP_IDS_JSON',
|
|
37
|
+
'REVENUECAT_PROJECT_ID',
|
|
28
38
|
'SENTRY_DSN',
|
|
29
39
|
'POSTHOG_API_KEY',
|
|
30
40
|
'POSTHOG_HOST',
|
|
31
41
|
'OPENAI_API_KEY',
|
|
42
|
+
'EXPO_PUBLIC_API_URL',
|
|
32
43
|
'EXPO_PUBLIC_REVENUECAT_IOS_API_KEY',
|
|
33
44
|
'EXPO_PUBLIC_REVENUECAT_ANDROID_API_KEY',
|
|
34
45
|
];
|
package/dist/readiness.js
CHANGED
|
@@ -46,7 +46,9 @@ export function inspectProject(root) {
|
|
|
46
46
|
record('selection', standard.schemaVersion === 1 &&
|
|
47
47
|
JSON.stringify(standard.products) === JSON.stringify(plan.products) &&
|
|
48
48
|
standard.hosting ===
|
|
49
|
-
(plan.products.includes('next') ||
|
|
49
|
+
(plan.products.includes('next') ||
|
|
50
|
+
plan.products.includes('vinext') ||
|
|
51
|
+
plan.products.includes('expo')
|
|
50
52
|
? plan.hosting
|
|
51
53
|
: null), 'Setup plan matches project selection');
|
|
52
54
|
}
|
|
@@ -80,7 +82,7 @@ export function validateSetupPlan(plan) {
|
|
|
80
82
|
throw new Error('Invalid hosting.');
|
|
81
83
|
validateRequirements(value.setup, value.products);
|
|
82
84
|
const selected = new Set(value.products);
|
|
83
|
-
resolveStandardProducts(selected, value.hosting, false);
|
|
85
|
+
resolveStandardProducts(selected, value.hosting, false, false);
|
|
84
86
|
if (selected.size !== value.products.length)
|
|
85
87
|
throw new Error('Invalid or incomplete setup selection.');
|
|
86
88
|
if (value.name !== undefined && typeof value.name !== 'string')
|
package/dist/registry/add.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { scaffoldCloudflareServiceContext } from '../scaffold/cloudflare-services.js';
|
|
1
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';
|
|
2
5
|
import { configureDependencyPatches } from '../dependency-patches.js';
|
|
3
6
|
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
4
7
|
import { bootstrapWorkspace, assertWorkspaceRuntime } from '../scaffold/bootstrap.js';
|
|
@@ -8,7 +11,7 @@ import { existsSync, lstatSync, readFileSync, realpathSync, rmSync } from 'node:
|
|
|
8
11
|
import path from 'node:path';
|
|
9
12
|
import { isDeepStrictEqual } from 'node:util';
|
|
10
13
|
import { applyEdits, modify, parse } from 'jsonc-parser';
|
|
11
|
-
import { STANDARD_PRODUCTS, installStackItem } from '../stack-registry.js';
|
|
14
|
+
import { STANDARD_PRODUCTS, getStackDefinition, installStackItem } from '../stack-registry.js';
|
|
12
15
|
import { inspectProject, validateSetupPlan } from '../readiness.js';
|
|
13
16
|
import { GENERATOR_VERSION } from '../version.js';
|
|
14
17
|
import { runStagedTransaction } from '../transaction.js';
|
|
@@ -19,7 +22,7 @@ import { put } from '../scaffold/files.js';
|
|
|
19
22
|
import { writeStandardRoot } from '../scaffold/workspace.js';
|
|
20
23
|
import { configureVoidDelivery, refreshVoidEnvironment } from '../scaffold/void.js';
|
|
21
24
|
import { createRecipeContext } from './context.js';
|
|
22
|
-
import { resolveStackRegistry, resolveStandardProducts } from './resolve.js';
|
|
25
|
+
import { resolveBillingProducts, resolveStackRegistry, resolveStandardProducts, } from './resolve.js';
|
|
23
26
|
import { sourceFiles, configurationFingerprints } from './receipt.js';
|
|
24
27
|
import { sourcePreview, validatePreviewPath, MAX_PREVIEW_TOTAL_BYTES, } from './preview.js';
|
|
25
28
|
/** Add recipes to an initialized workspace, refusing edits to customer-owned source. */
|
|
@@ -41,6 +44,9 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
41
44
|
if (!request.items.length)
|
|
42
45
|
throw new Error('Select at least one registry item.');
|
|
43
46
|
const plan = readProjectSection(root, 'setup');
|
|
47
|
+
if (Array.isArray(plan?.registry?.items) &&
|
|
48
|
+
plan.registry.items.some((item) => item.name === 'stripe' && item.package))
|
|
49
|
+
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
50
|
validateSetupPlan(plan);
|
|
45
51
|
if (plan.cliVersion !== GENERATOR_VERSION)
|
|
46
52
|
throw new Error('Use the project CLI version before adding recipes.');
|
|
@@ -61,11 +67,17 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
61
67
|
throw new Error(`Unknown stack product: ${id}.`);
|
|
62
68
|
selected.add(id);
|
|
63
69
|
}
|
|
64
|
-
|
|
70
|
+
const existingServerFeatures = plan.products.some((id) => Boolean(getStackDefinition(id).runtime));
|
|
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)) &&
|
|
65
77
|
hasProjectSection(root, 'cloudflare') &&
|
|
66
78
|
readProjectSection(root, 'cloudflare').deliveryEngine === 'void')
|
|
67
|
-
throw new Error('Queues
|
|
68
|
-
resolveStandardProducts(selected, plan.hosting, false);
|
|
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);
|
|
69
81
|
const voidSelected = usesVoidSelection([...selected], plan.hosting);
|
|
70
82
|
if (!request.dryRun &&
|
|
71
83
|
voidSelected &&
|
|
@@ -82,6 +94,13 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
82
94
|
json: true,
|
|
83
95
|
initializeGit: false,
|
|
84
96
|
};
|
|
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.');
|
|
85
104
|
const registry = resolveStackRegistry(options);
|
|
86
105
|
const oldItems = new Map(plan.registry.items.map((item) => [item.name, item]));
|
|
87
106
|
const recipes = registry.items.filter((item) => item.installer === 'recipe' && !isDeepStrictEqual(oldItems.get(item.name), item));
|
|
@@ -124,13 +143,26 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
124
143
|
seedPaths: [...before.keys(), PROJECT_CONFIG_FILE],
|
|
125
144
|
build: async (stage) => {
|
|
126
145
|
const context = createRecipeContext(stage, options);
|
|
146
|
+
context.updating = true;
|
|
127
147
|
for (const item of registry.items)
|
|
128
148
|
Object.assign(context.bindings, item.bindings);
|
|
129
149
|
if (recipes.some((item) => ['vinext', 'next'].includes(item.name)) &&
|
|
130
150
|
!existsSync(path.join(stage, 'apps/web/package.json')))
|
|
131
151
|
bootstrapWorkspace(stage, options.name, run, true);
|
|
132
|
-
for (const item of recipes)
|
|
133
|
-
|
|
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
|
+
}
|
|
134
166
|
// Configuration items affect the existing runtime without regenerating its application source.
|
|
135
167
|
const configurationItems = registry.items.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item) && item.bindings);
|
|
136
168
|
if (configurationItems.length) {
|
|
@@ -148,6 +180,7 @@ export async function addStackItems(root, request, run = execFile) {
|
|
|
148
180
|
}
|
|
149
181
|
put(stage, file, content);
|
|
150
182
|
}
|
|
183
|
+
scaffoldCloudflareServiceContext(context);
|
|
151
184
|
writeStandardRoot(stage, options, registry, true);
|
|
152
185
|
if (voidSelected) {
|
|
153
186
|
configureVoidDelivery(stage);
|