feat: introduce reading resources in app template#255
feat: introduce reading resources in app template#255cngonzalez wants to merge 12 commits intomainfrom
Conversation
|
Claude finished @ryanbonial's task in 2m 35s —— View job Code Review
1. RC version pinning — blocker
2. Silent error swallowing for
try {
const cliConfig = await getCliConfig(cwd)
appResources = cliConfig.app?.resources
} catch (err) {
buildDebug('Failed to load CLI config for app resources: %s', err)
}If 3.
Both 4.
5.
|
Coverage Delta
Comparing 13 changed files against main @ Overall Coverage
|
|
@cngonzalez what's the status of this? Could this be converted to draft if not ready? |
The CLI now uses renderSanityApp from @sanity/sdk-react in the auto-generated app.js entry module, instead of relying on the user's App.tsx to contain a SanityApp context provider. Named resources (project/dataset pairs) are read from sanity.cli.ts and passed to renderSanityApp at build/dev time. Renames the CLI config property sources → resources (and AppSource → AppResource) to align with SDK v3 terminology. Also exports findAppConfigPath from @sanity/cli-core for use in the build pipeline. Made-with: Cursor
Adds static analysis to detect when a user's App.tsx still uses the legacy <SanityApp> component pattern from @sanity/sdk-react v2. If detected, the CLI emits a deprecation warning with migration instructions during build and dev. The output object is threaded through the build and dev server call chains (buildApp, buildStudio, buildStaticFiles, devServer, startAppDevServer, startStudioDevServer) so the warning uses the CLI's standard output.warn() mechanism rather than console.warn. Made-with: Cursor
App templates no longer wrap their root component with <SanityApp>. The CLI's generated entry module now handles this via renderSanityApp, so user code stays clean and framework-agnostic. Made-with: Cursor
7b4cda9 to
f304343
Compare
- Upgrade @sanity/sdk-react to ^3.0.0-rc.0 - Rename sources → resources in sanity.cli.ts - Remove stale SanityApp import from App.tsx - Set organizationId to match dev.test.ts expectation - Ignore test fixture files from knip Made-with: Cursor
f304343 to
d423392
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| // change these to 'latest' as in studioDependencies.ts once SDK v3 is released | ||
| '@sanity/sdk': '^2', | ||
| '@sanity/sdk-react': '^2', | ||
| // TODO: change these to 'latest' once SDK v3 is published |
There was a problem hiding this comment.
Don't merge this PR until SDK v3 is officially out and we change all of the 3.0.0-rc.0 references in this PR
Description
This PR adds support for configuring data sources in Sanity apps. It introduces a new
sourcesproperty in the CLI config that allows apps to specify project IDs and datasets they need to access. The runtime now automatically passes these sources to the app, eliminating the need for manual configuration in the App component.What to review
sourcesschema in the CLI configrenderSanityAppTesting
The changes have been tested with the basic-app example, which now uses a real organization ID and project/dataset configuration. The example app has been updated to use the latest SDK packages from PR #704.