@sanity/cli 8.28.0 → 8.28.1

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 CHANGED
@@ -1274,8 +1274,8 @@ List documents
1274
1274
 
1275
1275
  ```
1276
1276
  USAGE
1277
- $ sanity context documents list KNOWLEDGEBASEID [--json] [--source <value>] [--state active|missing|deleted] [--ids
1278
- <value>]
1277
+ $ sanity context documents list KNOWLEDGEBASEID [--json] [--limit <value>] [--source <value>] [--state
1278
+ active|missing|deleted] [--ids <value>]
1279
1279
 
1280
1280
  ARGUMENTS
1281
1281
  KNOWLEDGEBASEID The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted.
@@ -1283,6 +1283,7 @@ ARGUMENTS
1283
1283
  FLAGS
1284
1284
  --ids=<value> Comma-separated IDs of the documents to return, up to 200, in any state. Use it to look up the
1285
1285
  documents entry citations point at.
1286
+ --limit=<value> The maximum number of items to return.
1286
1287
  --source=<value> Return only the documents of this source.
1287
1288
  --state=<option> Return only documents in this state. Without it, `deleted` documents are left out.
1288
1289
  <options: active|missing|deleted>
@@ -1808,11 +1809,12 @@ List knowledge bases
1808
1809
 
1809
1810
  ```
1810
1811
  USAGE
1811
- $ sanity context list [--json] [--include-drafts] [--organization <id>]
1812
+ $ sanity context list [--json] [--limit <value>] [--include-drafts] [--organization <id>]
1812
1813
 
1813
1814
  FLAGS
1814
1815
  --[no-]include-drafts Set to `true` to also list the organization's drafts, which have `state` set to `draft`. Drafts
1815
1816
  count toward the plan's knowledge base limit, and `createdBy` says who started each one.
1817
+ --limit=<value> The maximum number of items to return.
1816
1818
 
1817
1819
  GLOBAL FLAGS
1818
1820
  --json Format output as json.
@@ -1944,42 +1946,18 @@ Get an MCP endpoint's initial context
1944
1946
 
1945
1947
  ```
1946
1948
  USAGE
1947
- $ sanity context mcp initial-context MCPENDPOINT [--json] [--instructions <value>] [--perspective <value>] [--embeddings
1948
- <value>] [--groq-filter <value>] [--mode knowledge_base|groq] [--knowledge-bases <value>] [--link-resolver <value>]
1949
- [--workspace <value>] [--heading_offset <value>] [--organization <id>]
1949
+ $ sanity context mcp initial-context MCPENDPOINT [--json] [--link-resolver <value>] [--heading_offset <value>] [--organization
1950
+ <id>]
1950
1951
 
1951
1952
  ARGUMENTS
1952
1953
  MCPENDPOINT The MCP endpoint's name, set when the endpoint was created.
1953
1954
 
1954
1955
  FLAGS
1955
- --embeddings=<value> Set to `true` or `false` to turn semantic search on or off. Omit it to use the dataset
1956
- source setting. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP
1957
- endpoint instead.
1958
- --groq-filter=<value> A GROQ filter that narrows the endpoint's configured content filter for this request.
1959
- Documents must match both. Deprecated: refused from API version `v2026-11-03`. Configure it
1960
- on the MCP endpoint instead.
1961
- --heading_offset=<value> How many levels to shift markdown headings down, from `0` to `6`. Defaults to `1`, so `#`
1962
- becomes `##`.
1963
- --instructions=<value> Agent instructions that replace the endpoint's configured instructions for this request.
1964
- Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint
1965
- instead.
1966
- --knowledge-bases=<value> Comma-separated knowledge base public IDs (`kb...`) that replace the endpoint's knowledge
1967
- base sources for this request. Deprecated: refused from API version `v2026-11-03`.
1968
- Configure it on the MCP endpoint instead.
1969
- --link-resolver=<value> A JSON array that adds `_url` fields to query results. Each item has `types` (document
1970
- types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to
1971
- `slug.current`. Invalid JSON is ignored.
1972
- --mode=<option> Serves only one side of the endpoint for this request: `knowledge_base` serves its
1973
- knowledge bases and `groq` serves its dataset. Omit it to serve every source the endpoint
1974
- has. A request whose chosen side the endpoint doesn't have is refused. Deprecated: refused
1975
- from API version `v2026-11-03`. Configure it on the MCP endpoint instead.
1976
- <options: knowledge_base|groq>
1977
- --perspective=<value> The perspective for GROQ queries: `published` (default), `previewDrafts`, `raw`, or a
1978
- release. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP
1979
- endpoint instead.
1980
- --workspace=<value> The studio workspace to use. Replaces the dataset source's workspace for this request.
1981
- Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint
1982
- instead.
1956
+ --heading_offset=<value> How many levels to shift markdown headings down, from `0` to `6`. Defaults to `1`, so `#`
1957
+ becomes `##`.
1958
+ --link-resolver=<value> A JSON array that adds `_url` fields to query results. Each item has `types` (document
1959
+ types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to
1960
+ `slug.current`. Invalid JSON is ignored.
1983
1961
 
1984
1962
  GLOBAL FLAGS
1985
1963
  --json Format output as json.
@@ -2183,8 +2161,8 @@ FLAGS
2183
2161
  --max-depth=<value> How many levels deep the crawl goes from the root URL. Only for type web.
2184
2162
  --page-limit=<value> The maximum number of pages to crawl. The crawl can stop sooner when the knowledge
2185
2163
  base reaches its source limit. Only for type web.
2186
- --query=<value> A GROQ query that selects the documents, with an optional projection. It can match up
2187
- to 5,000 documents. Each sync runs it again. Only for type sanity-dataset.
2164
+ --query=<value> A GROQ query that selects the documents, with an optional projection. Each sync runs
2165
+ it again. Only for type sanity-dataset.
2188
2166
  --sanity-dataset-id=<value> The dataset to read documents from. Only for type sanity-dataset.
2189
2167
  --sanity-project-id=<value> The ID of the Sanity project to read documents from. You need full read access to the
2190
2168
  dataset and, on its project, the Administrator or Developer role or a custom role that
@@ -2379,11 +2357,14 @@ List sources
2379
2357
 
2380
2358
  ```
2381
2359
  USAGE
2382
- $ sanity context sources list KNOWLEDGEBASEID [--json]
2360
+ $ sanity context sources list KNOWLEDGEBASEID [--json] [--limit <value>]
2383
2361
 
2384
2362
  ARGUMENTS
2385
2363
  KNOWLEDGEBASEID The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted.
2386
2364
 
2365
+ FLAGS
2366
+ --limit=<value> The maximum number of items to return.
2367
+
2387
2368
  GLOBAL FLAGS
2388
2369
  --json Format output as json.
2389
2370
 
@@ -2550,12 +2531,15 @@ List a source's syncs
2550
2531
 
2551
2532
  ```
2552
2533
  USAGE
2553
- $ sanity context sources syncs list KNOWLEDGEBASEID SOURCEID [--json]
2534
+ $ sanity context sources syncs list KNOWLEDGEBASEID SOURCEID [--json] [--limit <value>]
2554
2535
 
2555
2536
  ARGUMENTS
2556
2537
  KNOWLEDGEBASEID The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted.
2557
2538
  SOURCEID The source's ID.
2558
2539
 
2540
+ FLAGS
2541
+ --limit=<value> The maximum number of items to return.
2542
+
2559
2543
  GLOBAL FLAGS
2560
2544
  --json Format output as json.
2561
2545
 
@@ -1,5 +1,5 @@
1
1
  import { styleText } from 'node:util';
2
- import { checkRequiredDependencies, checkStudioDependencyVersions, compareDependencyVersions } from '@sanity/cli-build/_internal/build';
2
+ import { checkRequiredDependencies, checkStudioDependencyVersions, compareDependencyVersions, getUnavailableVersionsWarning } from '@sanity/cli-build/_internal/build';
3
3
  import { exitCodes, getLocalPackageVersion, isInteractive } from '@sanity/cli-core';
4
4
  import { confirm, logSymbols, spinner } from '@sanity/cli-core/ux';
5
5
  import { isWorkbenchApp } from '@sanity/workbench-cli';
@@ -62,6 +62,9 @@ export async function startStudioDevServer(options) {
62
62
  } catch (err) {
63
63
  output.warn(`Failed to compare local versions against auto-updating versions: ${err}`);
64
64
  }
65
+ if (result?.unavailable?.length) {
66
+ output.warn(getUnavailableVersionsWarning(result.unavailable));
67
+ }
65
68
  if (result?.unresolvedPrerelease.length) {
66
69
  for (const mod of result.unresolvedPrerelease){
67
70
  output.warn(`Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/dev/servers/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n checkRequiredDependencies,\n checkStudioDependencyVersions,\n compareDependencyVersions,\n} from '@sanity/cli-build/_internal/build'\nimport {exitCodes, getLocalPackageVersion, isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../../server/devServer.js'\nimport {gracefulServerDeath} from '../../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../../services/projects.js'\nimport {getAppId} from '../../../util/appId.js'\nimport {getPackageManagerChoice} from '../../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../../util/packageManager/upgradePackages.js'\nimport {hasLocalUnclaimedProject} from '../../../util/unclaimedProjects.js'\nimport {checkDependenciesEventListenerFactory} from '../../build/eventListenerFactory.js'\nimport {shouldAutoUpdate} from '../../build/shouldAutoUpdate.js'\nimport {devDebug} from '../devDebug.js'\nimport {type DevActionOptions, type StartDevServerResult} from '../types.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<StartDevServerResult> {\n const {announceUrl = true, cliConfig, flags, httpPort, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n // Workbench apps don't load through the dashboard, so the flag has no\n // meaning for them and is ignored.\n const loadInDashboard = flags['load-in-dashboard'] && !isWorkbenchApp(cliConfig?.app)\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies({\n ...options,\n ...checkDependenciesEventListenerFactory(output),\n })\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, httpPort, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = withUnclaimedSignInHash(\n `http://${httpHost || 'localhost'}:${port}${config.basePath}`,\n projectId,\n )\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)}` +\n (announceUrl ? ` and running at ${styleText('cyan', url)}` : ''),\n )\n }\n\n return {close, server, started: true}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n\nfunction withUnclaimedSignInHash(url: string, projectId: string | undefined): string {\n const token = process.env.SANITY_AUTH_TOKEN\n if (!token || !projectId || !hasLocalUnclaimedProject(projectId)) return url\n return `${url}#token=${encodeURIComponent(token)}`\n}\n"],"names":["styleText","checkRequiredDependencies","checkStudioDependencyVersions","compareDependencyVersions","exitCodes","getLocalPackageVersion","isInteractive","confirm","logSymbols","spinner","isWorkbenchApp","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","getPackageManagerChoice","upgradePackages","hasLocalUnclaimedProject","checkDependenciesEventListenerFactory","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","announceUrl","cliConfig","flags","httpPort","output","workDir","projectId","api","organizationId","loadInDashboard","app","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unresolvedPrerelease","length","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","RUNTIME_ERROR","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","startupDuration","url","withUnclaimedSignInHash","basePath","appType","viteVersion","Math","ceil","started","token","process","env","SANITY_AUTH_TOKEN","encodeURIComponent"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,yBAAyB,EACzBC,6BAA6B,EAC7BC,yBAAyB,QACpB,oCAAmC;AAC1C,SAAQC,SAAS,EAAEC,sBAAsB,EAAEC,aAAa,QAAO,mBAAkB;AACjF,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAChE,SAAQC,cAAc,QAAO,wBAAuB;AACpD,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,mBAAmB,QAAO,yCAAwC;AAC1E,SAAQC,cAAc,QAAO,gCAA+B;AAC5D,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,uBAAuB,QAAO,uDAAsD;AAC5F,SAAQC,eAAe,QAAO,kDAAiD;AAC/E,SAAQC,wBAAwB,QAAO,qCAAoC;AAC3E,SAAQC,qCAAqC,QAAO,sCAAqC;AACzF,SAAQC,gBAAgB,QAAO,kCAAiC;AAChE,SAAQC,QAAQ,QAAO,iBAAgB;AAEvC,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,SAAQC,kBAAkB,QAAO,0BAAyB;AAE1D,OAAO,eAAeC,qBACpBC,OAAyB;IAEzB,MAAM,EAACC,cAAc,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGN;IAC1E,MAAMO,YAAYL,WAAWM,KAAKD;IAClC,IAAIE;IAEJ,sEAAsE;IACtE,mC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AAS;QAAI;IACtC,EAAE,OAAO9C,KAAK;QACZ3B,SAAS,oCAAoC2B;QAC7C,MAAMnC,oBAAoB,OAAOwD,OAAOe,QAAQ,EAAEf,OAAOxC,QAAQ,EAAEmB;IACrE;AACF;AAEA,SAASwC,wBAAwBD,GAAW,EAAEvD,SAA6B;IACzE,MAAM+D,QAAQC,QAAQC,GAAG,CAACC,iBAAiB;IAC3C,IAAI,CAACH,SAAS,CAAC/D,aAAa,CAACd,yBAAyBc,YAAY,OAAOuD;IACzE,OAAO,GAAGA,IAAI,OAAO,EAAEY,mBAAmBJ,QAAQ;AACpD"}
1
+ {"version":3,"sources":["../../../../src/actions/dev/servers/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n checkRequiredDependencies,\n checkStudioDependencyVersions,\n compareDependencyVersions,\n getUnavailableVersionsWarning,\n} from '@sanity/cli-build/_internal/build'\nimport {exitCodes, getLocalPackageVersion, isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../../server/devServer.js'\nimport {gracefulServerDeath} from '../../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../../services/projects.js'\nimport {getAppId} from '../../../util/appId.js'\nimport {getPackageManagerChoice} from '../../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../../util/packageManager/upgradePackages.js'\nimport {hasLocalUnclaimedProject} from '../../../util/unclaimedProjects.js'\nimport {checkDependenciesEventListenerFactory} from '../../build/eventListenerFactory.js'\nimport {shouldAutoUpdate} from '../../build/shouldAutoUpdate.js'\nimport {devDebug} from '../devDebug.js'\nimport {type DevActionOptions, type StartDevServerResult} from '../types.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<StartDevServerResult> {\n const {announceUrl = true, cliConfig, flags, httpPort, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n // Workbench apps don't load through the dashboard, so the flag has no\n // meaning for them and is ignored.\n const loadInDashboard = flags['load-in-dashboard'] && !isWorkbenchApp(cliConfig?.app)\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies({\n ...options,\n ...checkDependenciesEventListenerFactory(output),\n })\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unavailable?.length) {\n output.warn(getUnavailableVersionsWarning(result.unavailable))\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, httpPort, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = withUnclaimedSignInHash(\n `http://${httpHost || 'localhost'}:${port}${config.basePath}`,\n projectId,\n )\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)}` +\n (announceUrl ? ` and running at ${styleText('cyan', url)}` : ''),\n )\n }\n\n return {close, server, started: true}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n\nfunction withUnclaimedSignInHash(url: string, projectId: string | undefined): string {\n const token = process.env.SANITY_AUTH_TOKEN\n if (!token || !projectId || !hasLocalUnclaimedProject(projectId)) return url\n return `${url}#token=${encodeURIComponent(token)}`\n}\n"],"names":["styleText","checkRequiredDependencies","checkStudioDependencyVersions","compareDependencyVersions","getUnavailableVersionsWarning","exitCodes","getLocalPackageVersion","isInteractive","confirm","logSymbols","spinner","isWorkbenchApp","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","getPackageManagerChoice","upgradePackages","hasLocalUnclaimedProject","checkDependenciesEventListenerFactory","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","announceUrl","cliConfig","flags","httpPort","output","workDir","projectId","api","organizationId","loadInDashboard","app","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unavailable","length","unresolvedPrerelease","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","RUNTIME_ERROR","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","startupDuration","url","withUnclaimedSignInHash","basePath","appType","viteVersion","Math","ceil","started","token","process","env","SANITY_AUTH_TOKEN","encodeURIComponent"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,yBAAyB,EACzBC,6BAA6B,EAC7BC,yBAAyB,EACzBC,6BAA6B,QACxB,oCAAmC;AAC1C,SAAQC,SAAS,EAAEC,sBAAsB,EAAEC,aAAa,QAAO,mBAAkB;AACjF,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAChE,SAAQC,cAAc,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