Repository navigation
feat(cms): detect Sanity sites and suggest their project - #87
Merged
flowtricks merged 2 commits intoNov 17, 2026
Merged
Conversation
"Log in with Sanity" suggested a project only when a .env file named it (*SANITY_PROJECT_ID). Many sites write the id in code instead: a site with an embedded Studio typically has projectId in astro.config.mjs and in studio/sanity.config.ts or studio/sanity.cli.ts, so nothing was preselected. The suggestion now also reads a projectId string literal from astro.config.*, sanity.config.* and sanity.cli.*, at the root and in studio/, without running them. It reuses sanitySource.ts, so comments and ids built at run time (process.env…) do not count. The .env id comes first, and only a project the person belongs to is suggested, so a stale id is passed over. The dataset still comes from .env. Files, file size and ids are bounded.
Stacki never noticed that a site uses Sanity: CMS connections looked the same as for a site without it. When package.json lists @sanity/astro or sanity and no Sanity connection exists, CMS connections now says "This site uses Sanity. Connect it to edit its content in Stacki." The line goes away once connected. Studio shows it too, with no server change. hasDependency moves unchanged from features/props/loopCatalog.ts to src/lib/packageManifest.ts, because features may not import each other along this edge; its tests move with it. The new file is added to Studio's shared source list. Non-English lines are marked for review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacki didn't notice when a site uses Sanity: CMS connections looked like a site without any CMS, and after "Log in with Sanity" nothing was preselected when the project id lives in code (
astro.config.mjs,studio/sanity.cli.ts) rather than in.env.1. The login suggests the project from config files (a1a3edb)
.envnames the project, the suggestion also reads aprojectId: '…'string literal fromastro.config.*,sanity.config.*andsanity.cli.*, at the root and instudio/.sanitySource.ts, so commented-out ids and ids built at run time (process.env…) don't count..envid still comes first, and only a project the person belongs to is suggested. The dataset still comes from.env.2. CMS connections says when a site uses Sanity (a9e9f9f)
package.jsonlists@sanity/astroorsanityand there's no Sanity connection yet, one line shows above the buttons: "This site uses Sanity. Connect it to edit its content in Stacki."hasDependencywithout breaking the feature import rule, it moves unchanged fromloopCatalog.tstosrc/lib/packageManifest.ts, with its tests.Full gate: 1154/1154. Tested in the app on an Astro + Sanity site: the hint shows without a connection and goes away after login, and the project and dataset are preselected. Non-English lines are marked
// review.Note: this touches
sanityLogin.tsnear the same lines as #86, so whichever merges second may need a small rebase.