Skip to content

Instantly share code, notes, and snippets.

@stipsan
Created August 2, 2022 09:01
Show Gist options
  • Save stipsan/4c7ad523f7ff48982815ba05c01d1a9c to your computer and use it in GitHub Desktop.
Save stipsan/4c7ad523f7ff48982815ba05c01d1a9c to your computer and use it in GitHub Desktop.
Query Sanity Studio version status from the Exchange
// Run these snippets from your DevTools console
const {default: createClient} = await import('https://unpkg.com/@sanity/client@esm/dist/sanityClient.browser.mjs')
const client = createClient({projectId: '81pocpw8', dataset: 'production'})
// Get all v3 ready plugins
await client.fetch(`*[studioVersion == 3 || defined(v3DistTag)].packageName`)
// Get v3 only, the listing never had a v2 version
await client.fetch(`*[studioVersion == 3 && studioV2Support == ""]`)
// Were v2 and v3 ready, but the v2 version is discontinued and it's now v3 only
await client.fetch(`*[studioVersion == 3 && studioV2Support == "discontinued"]{packageName, v2DistTag}`)
// Where v2 and v3 ready, but the v2 version lives under a new package name
await client.fetch(`*[studioVersion == 3 && studioV2Support == "continued"]{packageName, v2PackageName}`)
// v2 plugin, with a v3 ready test version available
await client.fetch(`*[studioVersion == 2 && defined(v3DistTag)]{packageName, v3DistTag, "v3InstallWith": "npm install " + packageName + "@" + v3DistTag}`)
// v2 only
await client.fetch(`*[studioVersion == 2 && !defined(v3DistTag)]`)
// Neither or both, the studioVersion isn't relevant, this applies to stuff like integrations that only talk to Content Lake
// A value of -1 means that "Studio version" were set to "N/A". This happens by default on new listings, and by opt-in on older listings
// Thus -1 effectively means someone decided that the listing isn't affected by the Studio version
await client.fetch(`*[studioVersion == -1]`)
// All listings where studioVersion is unspecified, but should be specified to be "N/A", "2" or "3", at some point
await client.fetch(`*[_type == "contribution.tool" && !defined(studioVersion)]`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment