@sanity/cli-core 3.2.0 → 3.4.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.
@@ -1,5 +1,5 @@
1
1
  import { n as ProjectCliClientOptions, t as GlobalCliClientOptions } from "./apiClient-DXlF5ZV3.js";
2
- import { r as CliConfig } from "./cliConfig-DrUV6Wp6.js";
2
+ import { r as CliConfig } from "./cliConfig-DUt8uaF6.js";
3
3
  import { t as ProjectRootResult } from "./recursivelyResolveProjectRoot-BE54uEP6.js";
4
4
  import { t as CLITelemetryStore } from "./types-ZNH3prAd.js";
5
5
  import { t as Output } from "./types-CwJLTYDj.js";
@@ -1,5 +1,5 @@
1
- import { i as ConfigStore, o as TypeGenConfig, r as CliConfig } from "../cliConfig-DrUV6Wp6.js";
2
- import { a as getStudioWorkspaces, c as findProjectRoot, d as getCliConfigUncached, f as getCliToken, g as clearCliTokenCache, h as setCliUserConfig, i as isStudioConfig, l as getCliConfigSync, m as getUserConfig, n as tryFindStudioConfigPath, o as getStudioConfig, p as getCliUserConfig, r as findPathForFiles, s as findProjectRootSync, t as findStudioConfigPath, u as getCliConfig } from "../findStudioConfigPath-DeBa0pMT.js";
3
- import { n as isWorkbenchApp, r as parseWorkbenchCliConfig } from "../workbenchApp-CSYpReA-.js";
1
+ import { i as ConfigStore, o as TypeGenConfig, r as CliConfig } from "../cliConfig-DUt8uaF6.js";
2
+ import { _ as CliTokenInfo, a as getStudioWorkspaces, c as findProjectRoot, d as getCliConfigUncached, f as getCliToken, g as setCliUserConfig, h as getUserConfig, i as isStudioConfig, l as getCliConfigSync, m as getCliUserConfig, n as tryFindStudioConfigPath, o as getStudioConfig, p as getCliTokenInfo, r as findPathForFiles, s as findProjectRootSync, t as findStudioConfigPath, u as getCliConfig, v as clearCliTokenCache } from "../findStudioConfigPath-BV4DCesQ.js";
3
+ import { n as isWorkbenchApp, r as parseWorkbenchCliConfig } from "../workbenchApp-DVKwpTyU.js";
4
4
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
5
- export { type CliConfig, type ConfigStore, type TypeGenConfig, clearCliTokenCache, findPathForFiles, findProjectRoot, findProjectRootSync, findStudioConfigPath, getCliConfig, getCliConfigSync, getCliConfigUncached, getCliToken, getCliUserConfig, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getStudioConfig, getStudioWorkspaces, getUserConfig, getWorkspace, isStudioConfig, isWorkbenchApp, parseWorkbenchCliConfig, setCliUserConfig, tryFindStudioConfigPath };
5
+ export { type CliConfig, type CliTokenInfo, type ConfigStore, type TypeGenConfig, clearCliTokenCache, findPathForFiles, findProjectRoot, findProjectRootSync, findStudioConfigPath, getCliConfig, getCliConfigSync, getCliConfigUncached, getCliToken, getCliTokenInfo, getCliUserConfig, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getStudioConfig, getStudioWorkspaces, getUserConfig, getWorkspace, isStudioConfig, isWorkbenchApp, parseWorkbenchCliConfig, setCliUserConfig, tryFindStudioConfigPath };
@@ -1,5 +1,5 @@
1
1
  // Exports related to retrieving CLI, studio, app or workbench configuration or paths.
2
- export { clearCliTokenCache, getCliToken, getCliUserConfig, getUserConfig, setCliUserConfig } from '../config/cli/cliUserConfig.js';
2
+ export { clearCliTokenCache, getCliToken, getCliTokenInfo, getCliUserConfig, getUserConfig, setCliUserConfig } from '../config/cli/cliUserConfig.js';
3
3
  export { getCliConfig, getCliConfigUncached } from '../config/cli/getCliConfig.js';
4
4
  export { getCliConfigSync } from '../config/cli/getCliConfigSync.js';
5
5
  export { isWorkbenchApp, parseWorkbenchCliConfig } from '../config/cli/workbenchApp.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/config.ts"],"sourcesContent":["// Exports related to retrieving CLI, studio, app or workbench configuration or paths.\n\nexport {\n clearCliTokenCache,\n getCliToken,\n getCliUserConfig,\n getUserConfig,\n setCliUserConfig,\n} from '../config/cli/cliUserConfig.js'\nexport {getCliConfig, getCliConfigUncached} from '../config/cli/getCliConfig.js'\nexport {getCliConfigSync} from '../config/cli/getCliConfigSync.js'\nexport {\n type CliConfig,\n type ConfigStore,\n type TypeGenConfig,\n} from '../config/cli/types/cliConfig.js'\nexport {isWorkbenchApp, parseWorkbenchCliConfig} from '../config/cli/workbenchApp.js'\nexport {findProjectRoot} from '../config/findProjectRoot.js'\nexport {findProjectRootSync} from '../config/findProjectRootSync.js'\nexport {getStudioConfig} from '../config/studio/getStudioConfig.js'\nexport {getStudioWorkspaces} from '../config/studio/getStudioWorkspaces.js'\nexport {isStudioConfig} from '../config/studio/isStudioConfig.js'\nexport {findPathForFiles} from '../config/util/findConfigsPaths.js'\nexport {findStudioConfigPath, tryFindStudioConfigPath} from '../config/util/findStudioConfigPath.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\n"],"names":["clearCliTokenCache","getCliToken","getCliUserConfig","getUserConfig","setCliUserConfig","getCliConfig","getCliConfigUncached","getCliConfigSync","isWorkbenchApp","parseWorkbenchCliConfig","findProjectRoot","findProjectRootSync","getStudioConfig","getStudioWorkspaces","isStudioConfig","findPathForFiles","findStudioConfigPath","tryFindStudioConfigPath","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace"],"mappings":"AAAA,sFAAsF;AAEtF,SACEA,kBAAkB,EAClBC,WAAW,EACXC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,QACX,iCAAgC;AACvC,SAAQC,YAAY,EAAEC,oBAAoB,QAAO,gCAA+B;AAChF,SAAQC,gBAAgB,QAAO,oCAAmC;AAMlE,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,gCAA+B;AACrF,SAAQC,eAAe,QAAO,+BAA8B;AAC5D,SAAQC,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,eAAe,QAAO,sCAAqC;AACnE,SAAQC,mBAAmB,QAAO,0CAAyC;AAC3E,SAAQC,cAAc,QAAO,qCAAoC;AACjE,SAAQC,gBAAgB,QAAO,qCAAoC;AACnE,SAAQC,oBAAoB,EAAEC,uBAAuB,QAAO,yCAAwC;AACpG,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB"}
1
+ {"version":3,"sources":["../../src/_exports/config.ts"],"sourcesContent":["// Exports related to retrieving CLI, studio, app or workbench configuration or paths.\n\nexport {\n clearCliTokenCache,\n type CliTokenInfo,\n getCliToken,\n getCliTokenInfo,\n getCliUserConfig,\n getUserConfig,\n setCliUserConfig,\n} from '../config/cli/cliUserConfig.js'\nexport {getCliConfig, getCliConfigUncached} from '../config/cli/getCliConfig.js'\nexport {getCliConfigSync} from '../config/cli/getCliConfigSync.js'\nexport {\n type CliConfig,\n type ConfigStore,\n type TypeGenConfig,\n} from '../config/cli/types/cliConfig.js'\nexport {isWorkbenchApp, parseWorkbenchCliConfig} from '../config/cli/workbenchApp.js'\nexport {findProjectRoot} from '../config/findProjectRoot.js'\nexport {findProjectRootSync} from '../config/findProjectRootSync.js'\nexport {getStudioConfig} from '../config/studio/getStudioConfig.js'\nexport {getStudioWorkspaces} from '../config/studio/getStudioWorkspaces.js'\nexport {isStudioConfig} from '../config/studio/isStudioConfig.js'\nexport {findPathForFiles} from '../config/util/findConfigsPaths.js'\nexport {findStudioConfigPath, tryFindStudioConfigPath} from '../config/util/findStudioConfigPath.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\n"],"names":["clearCliTokenCache","getCliToken","getCliTokenInfo","getCliUserConfig","getUserConfig","setCliUserConfig","getCliConfig","getCliConfigUncached","getCliConfigSync","isWorkbenchApp","parseWorkbenchCliConfig","findProjectRoot","findProjectRootSync","getStudioConfig","getStudioWorkspaces","isStudioConfig","findPathForFiles","findStudioConfigPath","tryFindStudioConfigPath","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace"],"mappings":"AAAA,sFAAsF;AAEtF,SACEA,kBAAkB,EAElBC,WAAW,EACXC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,QACX,iCAAgC;AACvC,SAAQC,YAAY,EAAEC,oBAAoB,QAAO,gCAA+B;AAChF,SAAQC,gBAAgB,QAAO,oCAAmC;AAMlE,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,gCAA+B;AACrF,SAAQC,eAAe,QAAO,+BAA8B;AAC5D,SAAQC,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,eAAe,QAAO,sCAAqC;AACnE,SAAQC,mBAAmB,QAAO,0CAAyC;AAC3E,SAAQC,cAAc,QAAO,qCAAoC;AACjE,SAAQC,gBAAgB,QAAO,qCAAoC;AACnE,SAAQC,oBAAoB,EAAEC,uBAAuB,QAAO,yCAAwC;AACpG,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB"}
@@ -1,12 +1,12 @@
1
1
  import { i as getProjectCliClient, n as ProjectCliClientOptions, r as getGlobalCliClient, t as GlobalCliClientOptions } from "../apiClient-DXlF5ZV3.js";
2
- import { i as ConfigStore, n as AppVisibility, r as CliConfig, s as UserViteConfig, t as APP_VISIBILITIES } from "../cliConfig-DrUV6Wp6.js";
2
+ import { i as ConfigStore, n as AppVisibility, r as CliConfig, s as UserViteConfig, t as APP_VISIBILITIES } from "../cliConfig-DUt8uaF6.js";
3
3
  import { t as ProjectRootResult } from "../recursivelyResolveProjectRoot-BE54uEP6.js";
4
4
  import { n as ConsentInformation, r as TelemetryUserProperties, t as CLITelemetryStore } from "../types-ZNH3prAd.js";
5
5
  import { n as RequireProps, r as SanityOrgUser, t as Output } from "../types-CwJLTYDj.js";
6
6
  import { SanityCommand, SanityCommandInterface } from "../SanityCommand.js";
7
7
  import { t as mockBrowserEnvironment } from "../mockBrowserEnvironment-BjFQPb2W.js";
8
- import { a as getStudioWorkspaces, c as findProjectRoot, d as getCliConfigUncached, f as getCliToken, g as clearCliTokenCache, h as setCliUserConfig, i as isStudioConfig, l as getCliConfigSync, m as getUserConfig, n as tryFindStudioConfigPath, o as getStudioConfig, p as getCliUserConfig, r as findPathForFiles, s as findProjectRootSync, t as findStudioConfigPath, u as getCliConfig } from "../findStudioConfigPath-DeBa0pMT.js";
9
- import { n as isWorkbenchApp, t as ApplicationType } from "../workbenchApp-CSYpReA-.js";
8
+ import { _ as CliTokenInfo, a as getStudioWorkspaces, c as findProjectRoot, d as getCliConfigUncached, f as getCliToken, g as setCliUserConfig, h as getUserConfig, i as isStudioConfig, l as getCliConfigSync, m as getCliUserConfig, n as tryFindStudioConfigPath, o as getStudioConfig, p as getCliTokenInfo, r as findPathForFiles, s as findProjectRootSync, t as findStudioConfigPath, u as getCliConfig, v as clearCliTokenCache } from "../findStudioConfigPath-BV4DCesQ.js";
9
+ import { n as isWorkbenchApp, t as ApplicationType } from "../workbenchApp-DVKwpTyU.js";
10
10
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
11
11
  import { debug, subdebug } from "./debug.js";
12
12
  import { t as NonInteractiveError } from "../NonInteractiveError-CSLT5y93.js";
@@ -18,7 +18,7 @@ import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r
18
18
  import { a as getLocalPackageVersion, i as getLocalPackageDir, n as resolveLocalPackageFrom, r as resolveLocalPackagePath, t as resolveLocalPackage } from "../resolveLocalPackage-Dr-TNTyk.js";
19
19
  import { n as ReadPackageJsonOptions, r as readPackageJson, t as PackageJson } from "../readPackageJson-Cr_lbjVR.js";
20
20
  import { n as colorizeJson, t as getTimer } from "../timer-Dwu2TIgB.js";
21
- import { i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-Y-KwP413.js";
21
+ import { i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-D1LxkXeZ.js";
22
22
  import { WorkerOptions } from "node:worker_threads";
23
23
  interface PromisifyWorkerOptions extends WorkerOptions {
24
24
  /**
@@ -47,5 +47,5 @@ interface PromisifyWorkerOptions extends WorkerOptions {
47
47
  * @internal
48
48
  */
49
49
  declare function promisifyWorker<T = unknown>(filePath: URL, options?: PromisifyWorkerOptions): Promise<T>;
50
- export { APP_VISIBILITIES, type AppVisibility, type ApplicationType, type CLITelemetryStore, CLI_TELEMETRY_SYMBOL, type CliConfig, type ConfigStore, type ConsentInformation, type CoreAppManifest, type GlobalCliClientOptions, NonInteractiveError, NotFoundError, type Output, type PackageJson, type ProjectCliClientOptions, ProjectRootNotFoundError, type ProjectRootResult, type ReadPackageJsonOptions, type RequireProps, SanityCommand, type SanityCommandInterface, type SanityOrgUser, type StudioManifest, type TelemetryUserProperties, type UserViteConfig, clearCliTelemetry, clearCliTokenCache, colorizeJson, coreAppManifestSchema, createStudioWorker, debug, doImport, exitCodes, findPathForFiles, findProjectRoot, findProjectRootSync, findStudioConfigPath, getCliConfig, getCliConfigSync, getCliConfigUncached, getCliTelemetry, getCliToken, getCliUserConfig, getGlobalCliClient, getLocalPackageDir, getLocalPackageVersion, getProjectCliClient, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getStudioConfig, getStudioWorkspaces, getTelemetryBaseInfo, getTimer, getUserConfig, getWorkspace, importModule, isCi, isInteractive, isNotFoundError, isProjectRootNotFoundError, isStaging, isStudioConfig, isWorkbenchApp, mockBrowserEnvironment, noopLogger, normalizePath, promisifyWorker, readPackageJson, reportCliTraceError, resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath, safeStructuredClone, setCliTelemetry, setCliUserConfig, studioManifestSchema, studioWorkerTask, subdebug, tryFindStudioConfigPath, tsxWorkerTask };
50
+ export { APP_VISIBILITIES, type AppVisibility, type ApplicationType, type CLITelemetryStore, CLI_TELEMETRY_SYMBOL, type CliConfig, type CliTokenInfo, type ConfigStore, type ConsentInformation, type CoreAppManifest, type GlobalCliClientOptions, NonInteractiveError, NotFoundError, type Output, type PackageJson, type ProjectCliClientOptions, ProjectRootNotFoundError, type ProjectRootResult, type ReadPackageJsonOptions, type RequireProps, SanityCommand, type SanityCommandInterface, type SanityOrgUser, type StudioManifest, type TelemetryUserProperties, type UserViteConfig, clearCliTelemetry, clearCliTokenCache, colorizeJson, coreAppManifestSchema, createStudioWorker, debug, doImport, exitCodes, findPathForFiles, findProjectRoot, findProjectRootSync, findStudioConfigPath, getCliConfig, getCliConfigSync, getCliConfigUncached, getCliTelemetry, getCliToken, getCliTokenInfo, getCliUserConfig, getGlobalCliClient, getLocalPackageDir, getLocalPackageVersion, getProjectCliClient, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getStudioConfig, getStudioWorkspaces, getTelemetryBaseInfo, getTimer, getUserConfig, getWorkspace, importModule, isCi, isInteractive, isNotFoundError, isProjectRootNotFoundError, isStaging, isStudioConfig, isWorkbenchApp, mockBrowserEnvironment, noopLogger, normalizePath, promisifyWorker, readPackageJson, reportCliTraceError, resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath, safeStructuredClone, setCliTelemetry, setCliUserConfig, studioManifestSchema, studioWorkerTask, subdebug, tryFindStudioConfigPath, tsxWorkerTask };
51
51
  //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,7 @@
3
3
  // If you came here looking to add new exports, instead take a look through the `exports` in package.json and think about which of those groups your new export belongs to. You may want to consider adding a _new_ export if there is no clean conceptual fit.
4
4
  // This is all in the name of minimizing 'barrel' export files and keeping `import`s fast. See the following for context: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/
5
5
  export { getGlobalCliClient, getProjectCliClient } from '../apiClient.js';
6
- export { clearCliTokenCache, getCliToken, getCliUserConfig, getUserConfig, setCliUserConfig } from '../config/cli/cliUserConfig.js';
6
+ export { clearCliTokenCache, getCliToken, getCliTokenInfo, getCliUserConfig, getUserConfig, setCliUserConfig } from '../config/cli/cliUserConfig.js';
7
7
  export { getCliConfig, getCliConfigUncached } from '../config/cli/getCliConfig.js';
8
8
  export { getCliConfigSync } from '../config/cli/getCliConfigSync.js';
9
9
  export { APP_VISIBILITIES } from '../config/cli/types/cliConfig.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["// DO NOT ADD NEW EXPORTS TO THIS FILE!\n// These are left here for backwards compatibility.\n// If you came here looking to add new exports, instead take a look through the `exports` in package.json and think about which of those groups your new export belongs to. You may want to consider adding a _new_ export if there is no clean conceptual fit.\n// This is all in the name of minimizing 'barrel' export files and keeping `import`s fast. See the following for context: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/\nexport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from '../apiClient.js'\nexport {\n clearCliTokenCache,\n getCliToken,\n getCliUserConfig,\n getUserConfig,\n setCliUserConfig,\n} from '../config/cli/cliUserConfig.js'\nexport {getCliConfig, getCliConfigUncached} from '../config/cli/getCliConfig.js'\nexport {getCliConfigSync} from '../config/cli/getCliConfigSync.js'\nexport {\n APP_VISIBILITIES,\n type AppVisibility,\n type CliConfig,\n type ConfigStore,\n} from '../config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from '../config/cli/types/userViteConfig.js'\nexport {type ApplicationType, isWorkbenchApp} from '../config/cli/workbenchApp.js'\nexport {findProjectRoot} from '../config/findProjectRoot.js'\nexport {findProjectRootSync} from '../config/findProjectRootSync.js'\nexport {getStudioConfig} from '../config/studio/getStudioConfig.js'\nexport {getStudioWorkspaces} from '../config/studio/getStudioWorkspaces.js'\nexport {isStudioConfig} from '../config/studio/isStudioConfig.js'\nexport {findPathForFiles} from '../config/util/findConfigsPaths.js'\nexport {findStudioConfigPath, tryFindStudioConfigPath} from '../config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from '../config/util/recursivelyResolveProjectRoot.js'\nexport {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {isNotFoundError, NotFoundError} from '../errors/NotFoundError.js'\nexport {\n isProjectRootNotFoundError,\n ProjectRootNotFoundError,\n} from '../errors/ProjectRootNotFoundError.js'\nexport {exitCodes} from '../exitCodes.js'\nexport {createStudioWorker, studioWorkerTask} from '../loaders/studio/studioWorkerTask.js'\nexport {tsxWorkerTask} from '../loaders/tsx/tsxWorkerTask.js'\nexport {SanityCommand, type SanityCommandInterface} from '../SanityCommand.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n reportCliTraceError,\n setCliTelemetry,\n} from '../telemetry/getCliTelemetry.js'\nexport {getTelemetryBaseInfo} from '../telemetry/getTelemetryBaseInfo.js'\nexport {noopLogger} from '../telemetry/noopTelemetry.js'\nexport {\n type CLITelemetryStore,\n type ConsentInformation,\n type TelemetryUserProperties,\n} from '../telemetry/types.js'\nexport {type Output, type RequireProps, type SanityOrgUser} from '../types.js'\nexport {doImport} from '../util/doImport.js'\nexport {mockBrowserEnvironment} from '../util/environment/mockBrowserEnvironment.js'\nexport {getLocalPackageDir, getLocalPackageVersion} from '../util/getLocalPackageVersion.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {promisifyWorker} from '../util/promisifyWorker.js'\nexport {\n type PackageJson,\n readPackageJson,\n type ReadPackageJsonOptions,\n} from '../util/readPackageJson.js'\nexport {\n resolveLocalPackage,\n resolveLocalPackageFrom,\n resolveLocalPackagePath,\n} from '../util/resolveLocalPackage.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {getTimer} from '../ux/timer.js'\nexport {debug, subdebug} from './debug.js'\nexport {\n type CoreAppManifest,\n coreAppManifestSchema,\n type StudioManifest,\n studioManifestSchema,\n} from './schemas.js'\n"],"names":["getGlobalCliClient","getProjectCliClient","clearCliTokenCache","getCliToken","getCliUserConfig","getUserConfig","setCliUserConfig","getCliConfig","getCliConfigUncached","getCliConfigSync","APP_VISIBILITIES","isWorkbenchApp","findProjectRoot","findProjectRootSync","getStudioConfig","getStudioWorkspaces","isStudioConfig","findPathForFiles","findStudioConfigPath","tryFindStudioConfigPath","NonInteractiveError","isNotFoundError","NotFoundError","isProjectRootNotFoundError","ProjectRootNotFoundError","exitCodes","createStudioWorker","studioWorkerTask","tsxWorkerTask","SanityCommand","clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","reportCliTraceError","setCliTelemetry","getTelemetryBaseInfo","noopLogger","doImport","mockBrowserEnvironment","getLocalPackageDir","getLocalPackageVersion","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isStaging","normalizePath","promisifyWorker","readPackageJson","resolveLocalPackage","resolveLocalPackageFrom","resolveLocalPackagePath","safeStructuredClone","colorizeJson","getTimer","debug","subdebug","coreAppManifestSchema","studioManifestSchema"],"mappings":"AAAA,uCAAuC;AACvC,mDAAmD;AACnD,+PAA+P;AAC/P,2LAA2L;AAC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AAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAEEC,eAAe,QAEV,6BAA4B;AACnC,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,QAClB,iCAAgC;AACvC,SAAQC,mBAAmB,QAAO,iCAAgC;AAClE,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,KAAK,EAAEC,QAAQ,QAAO,aAAY;AAC1C,SAEEC,qBAAqB,EAErBC,oBAAoB,QACf,eAAc"}
1
+ {"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["// DO NOT ADD NEW EXPORTS TO THIS FILE!\n// These are left here for backwards compatibility.\n// If you came here looking to add new exports, instead take a look through the `exports` in package.json and think about which of those groups your new export belongs to. You may want to consider adding a _new_ export if there is no clean conceptual fit.\n// This is all in the name of minimizing 'barrel' export files and keeping `import`s fast. See the following for context: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/\nexport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from '../apiClient.js'\nexport {\n clearCliTokenCache,\n type CliTokenInfo,\n getCliToken,\n getCliTokenInfo,\n getCliUserConfig,\n getUserConfig,\n setCliUserConfig,\n} from '../config/cli/cliUserConfig.js'\nexport {getCliConfig, getCliConfigUncached} from '../config/cli/getCliConfig.js'\nexport {getCliConfigSync} from '../config/cli/getCliConfigSync.js'\nexport {\n APP_VISIBILITIES,\n type AppVisibility,\n type CliConfig,\n type ConfigStore,\n} from '../config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from '../config/cli/types/userViteConfig.js'\nexport {type ApplicationType, isWorkbenchApp} from '../config/cli/workbenchApp.js'\nexport {findProjectRoot} from '../config/findProjectRoot.js'\nexport {findProjectRootSync} from '../config/findProjectRootSync.js'\nexport {getStudioConfig} from '../config/studio/getStudioConfig.js'\nexport {getStudioWorkspaces} from '../config/studio/getStudioWorkspaces.js'\nexport {isStudioConfig} from '../config/studio/isStudioConfig.js'\nexport {findPathForFiles} from '../config/util/findConfigsPaths.js'\nexport {findStudioConfigPath, tryFindStudioConfigPath} from '../config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from '../config/util/recursivelyResolveProjectRoot.js'\nexport {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {isNotFoundError, NotFoundError} from '../errors/NotFoundError.js'\nexport {\n isProjectRootNotFoundError,\n ProjectRootNotFoundError,\n} from '../errors/ProjectRootNotFoundError.js'\nexport {exitCodes} from '../exitCodes.js'\nexport {createStudioWorker, studioWorkerTask} from '../loaders/studio/studioWorkerTask.js'\nexport {tsxWorkerTask} from '../loaders/tsx/tsxWorkerTask.js'\nexport {SanityCommand, type SanityCommandInterface} from '../SanityCommand.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n reportCliTraceError,\n setCliTelemetry,\n} from '../telemetry/getCliTelemetry.js'\nexport {getTelemetryBaseInfo} from '../telemetry/getTelemetryBaseInfo.js'\nexport {noopLogger} from '../telemetry/noopTelemetry.js'\nexport {\n type CLITelemetryStore,\n type ConsentInformation,\n type TelemetryUserProperties,\n} from '../telemetry/types.js'\nexport {type Output, type RequireProps, type SanityOrgUser} from '../types.js'\nexport {doImport} from '../util/doImport.js'\nexport {mockBrowserEnvironment} from '../util/environment/mockBrowserEnvironment.js'\nexport {getLocalPackageDir, getLocalPackageVersion} from '../util/getLocalPackageVersion.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {promisifyWorker} from '../util/promisifyWorker.js'\nexport {\n type PackageJson,\n readPackageJson,\n type ReadPackageJsonOptions,\n} from '../util/readPackageJson.js'\nexport {\n resolveLocalPackage,\n resolveLocalPackageFrom,\n resolveLocalPackagePath,\n} from '../util/resolveLocalPackage.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {getTimer} from '../ux/timer.js'\nexport {debug, subdebug} from './debug.js'\nexport {\n type CoreAppManifest,\n coreAppManifestSchema,\n type StudioManifest,\n studioManifestSchema,\n} from './schemas.js'\n"],"names":["getGlobalCliClient","getProjectCliClient","clearCliTokenCache","getCliToken","getCliTokenInfo","getCliUserConfig","getUserConfig","setCliUserConfig","getCliConfig","getCliConfigUncached","getCliConfigSync","APP_VISIBILITIES","isWorkbenchApp","findProjectRoot","findProjectRootSync","getStudioConfig","getStudioWorkspaces","isStudioConfig","findPathForFiles","findStudioConfigPath","tryFindStudioConfigPath","NonInteractiveError","isNotFoundError","NotFoundError","isProjectRootNotFoundError","ProjectRootNotFoundError","exitCodes","createStudioWorker","studioWorkerTask","tsxWorkerTask","SanityCommand","clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","reportCliTraceError","setCliTelemetry","getTelemetryBaseInfo","noopLogger","doImport","mockBrowserEnvironment","getLocalPackageDir","getLocalPackageVersion","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isStaging","normalizePath","promisifyWorker","readPackageJson","resolveLocalPackage","resolveLocalPackageFrom","resolveLocalPackagePath","safeStructuredClone","colorizeJson","getTimer","debug","subd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,QAAO,oCAAmC;AAC5F,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAEEC,eAAe,QAEV,6BAA4B;AACnC,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,QAClB,iCAAgC;AACvC,SAAQC,mBAAmB,QAAO,iCAAgC;AAClE,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,KAAK,EAAEC,QAAQ,QAAO,aAAY;AAC1C,SAEEC,qBAAqB,EAErBC,oBAAoB,QACf,eAAc"}
@@ -1,2 +1,2 @@
1
- import { a as cliConfigSchema, i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-Y-KwP413.js";
1
+ import { a as cliConfigSchema, i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-D1LxkXeZ.js";
2
2
  export { type CoreAppManifest, type StudioManifest, cliConfigSchema, coreAppManifestSchema, studioManifestSchema };
@@ -1,9 +1,9 @@
1
- import { a as ReactCompilerConfig, i as ConfigStore, o as TypeGenConfig, r as CliConfig, s as UserViteConfig } from "../cliConfig-DrUV6Wp6.js";
1
+ import { a as ReactCompilerConfig, i as ConfigStore, o as TypeGenConfig, r as CliConfig, s as UserViteConfig } from "../cliConfig-DUt8uaF6.js";
2
2
  import { t as ProjectRootResult } from "../recursivelyResolveProjectRoot-BE54uEP6.js";
3
3
  import { n as ConsentInformation, r as TelemetryUserProperties, t as CLITelemetryStore } from "../types-ZNH3prAd.js";
4
4
  import { n as RequireProps, r as SanityOrgUser, t as Output } from "../types-CwJLTYDj.js";
5
5
  import { SanityCommandInterface } from "../SanityCommand.js";
6
- import { t as ApplicationType } from "../workbenchApp-CSYpReA-.js";
6
+ import { t as ApplicationType } from "../workbenchApp-DVKwpTyU.js";
7
7
  import { n as ReadPackageJsonOptions, t as PackageJson } from "../readPackageJson-Cr_lbjVR.js";
8
- import { n as StudioManifest, t as CoreAppManifest } from "../schemas-Y-KwP413.js";
8
+ import { n as StudioManifest, t as CoreAppManifest } from "../schemas-D1LxkXeZ.js";
9
9
  export type { ApplicationType, CLITelemetryStore, CliConfig, ConfigStore, ConsentInformation, CoreAppManifest, Output, PackageJson, ProjectRootResult, ReactCompilerConfig, ReadPackageJsonOptions, RequireProps, SanityCommandInterface, SanityOrgUser, StudioManifest, TelemetryUserProperties, TypeGenConfig, UserViteConfig };
@@ -1,6 +1,14 @@
1
1
  import { a as getSanityDataDir, i as getSanityConfigDir, n as getSanityUrl, r as getSanityEnvVar, t as getWorkspace } from "../getWorkspace-CU32E6Uo.js";
2
2
  import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-CWB0MXmH.js";
3
3
  declare function getCoreAppUrl(organizationId: string, appId: string): string;
4
+ /**
5
+ * Checks if the given value is a record (javascript objectish)
6
+ *
7
+ * @param value - Value to check
8
+ * @returns True if the value is a record, false otherwise
9
+ * @internal
10
+ */
11
+ declare function isRecord(value: unknown): value is Record<string, unknown>;
4
12
  declare function isTrueish(value: string | undefined): boolean;
5
- export { doImport, getCoreAppUrl, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getWorkspace, importModule, isCi, isInteractive, isStaging, isTrueish, normalizePath, safeStructuredClone };
13
+ export { doImport, getCoreAppUrl, getSanityConfigDir, getSanityDataDir, getSanityEnvVar, getSanityUrl, getWorkspace, importModule, isCi, isInteractive, isRecord, isStaging, isTrueish, normalizePath, safeStructuredClone };
6
14
  //# sourceMappingURL=util.d.ts.map
@@ -9,6 +9,7 @@ export { getWorkspace } from '../util/getWorkspace.js';
9
9
  export { importModule } from '../util/importModule.js';
10
10
  export { isCi } from '../util/isCi.js';
11
11
  export { isInteractive } from '../util/isInteractive.js';
12
+ export { isRecord } from '../util/isRecord.js';
12
13
  export { isStaging } from '../util/isStaging.js';
13
14
  export { isTrueish } from '../util/isTrueish.js';
14
15
  export { normalizePath } from '../util/normalizePath.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/util.ts"],"sourcesContent":["// Pure in-memory and zero dep utilities\n//\nexport {doImport} from '../util/doImport.js'\nexport {getCoreAppUrl} from '../util/getCoreAppUrl.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {isTrueish} from '../util/isTrueish.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\n"],"names":["doImport","getCoreAppUrl","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isStaging","isTrueish","normalizePath","safeStructuredClone"],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,SAAQA,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,mBAAmB,QAAO,iCAAgC"}
1
+ {"version":3,"sources":["../../src/_exports/util.ts"],"sourcesContent":["// Pure in-memory and zero dep utilities\n//\nexport {doImport} from '../util/doImport.js'\nexport {getCoreAppUrl} from '../util/getCoreAppUrl.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isRecord} from '../util/isRecord.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {isTrueish} from '../util/isTrueish.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\n"],"names":["doImport","getCoreAppUrl","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isRecord","isStaging","isTrueish","normalizePath","safeStructuredClone"],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,SAAQA,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,gCAA+B;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,mBAAmB,QAAO,iCAAgC"}
@@ -5,6 +5,27 @@ import { ConfigEnv, InlineConfig } from "vite";
5
5
  * @public
6
6
  */
7
7
  type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig;
8
+ /**
9
+ * An optional peer dependency's options type, or `unknown` when the peer's
10
+ * typings did not resolve.
11
+ *
12
+ * `babel-plugin-react-compiler` and `oxc-transform-react` are optional peer
13
+ * dependencies, so the type-only imports above only resolve in projects that
14
+ * install them. When one is missing, TypeScript degrades its import to `any`
15
+ * (the unresolved-module error is suppressed inside declaration files under
16
+ * `skipLibCheck`), and intersecting `any` into a {@link ReactCompilerConfig}
17
+ * branch would collapse the whole union to `any` — silently disabling type
18
+ * checking of the `reactCompiler` option, including for the compiler that IS
19
+ * installed. Mapping a missing peer's options to `unknown` (the identity
20
+ * under intersection) instead reduces that branch to just its `transform`
21
+ * discriminator, keeping the other branch fully checked.
22
+ *
23
+ * `unknown extends T` is only true when `T` degraded to `any`/`unknown`;
24
+ * resolved options types pass through untouched. (`0 extends 1 & T` — the
25
+ * usual any-detector — does not work here: an unresolved import produces the
26
+ * checker's error type, which that intersection propagates.)
27
+ */
28
+ type OptionalPeerOptions<T> = unknown extends T ? unknown : T;
8
29
  /**
9
30
  * Configuration for React Compiler.
10
31
  *
@@ -18,11 +39,15 @@ type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig |
18
39
  * ({@link https://www.npmjs.com/package/oxc-transform-react | oxc-transform-react}
19
40
  * must be installed in your project)
20
41
  *
42
+ * Each branch's options are only type-checked when the corresponding package
43
+ * is installed; a missing package reduces its branch to just the `transform`
44
+ * discriminator.
45
+ *
21
46
  * @public
22
47
  */
23
- type ReactCompilerConfig = (PluginOptions & {
48
+ type ReactCompilerConfig = (OptionalPeerOptions<PluginOptions> & {
24
49
  transform?: 'babel';
25
- }) | (ReactCompilerOptions & {
50
+ }) | (OptionalPeerOptions<ReactCompilerOptions> & {
26
51
  transform: 'oxc';
27
52
  });
28
53
  interface TypeGenConfig {
@@ -194,4 +219,4 @@ interface ConfigStore {
194
219
  set: (key: string, value: unknown) => void;
195
220
  }
196
221
  export { ReactCompilerConfig as a, ConfigStore as i, AppVisibility as n, TypeGenConfig as o, CliConfig as r, UserViteConfig as s, APP_VISIBILITIES as t };
197
- //# sourceMappingURL=cliConfig-DrUV6Wp6.d.ts.map
222
+ //# sourceMappingURL=cliConfig-DUt8uaF6.d.ts.map
@@ -1,25 +1,25 @@
1
1
  /**
2
- * Module-level cache for the CLI auth token, shared between
3
- * `getCliToken` (reads/writes) and `setCliUserConfig` (invalidates).
2
+ * Module-level cache for the resolved CLI auth token, shared between
3
+ * `getCliTokenInfo` (reads/writes) and `setCliUserConfig` (invalidates).
4
4
  *
5
5
  * Extracted into its own module to avoid a circular dependency
6
6
  * between `cliUserConfig.ts` and `getCliToken.ts`.
7
- */ let cachedToken;
8
- export function getCachedToken() {
9
- return cachedToken;
7
+ */ let cachedTokenInfo;
8
+ export function getCachedTokenInfo() {
9
+ return cachedTokenInfo;
10
10
  }
11
- export function setCachedToken(token) {
12
- cachedToken = token;
11
+ export function setCachedTokenInfo(tokenInfo) {
12
+ cachedTokenInfo = tokenInfo;
13
13
  }
14
14
  /**
15
- * Clear the in-process token cache so the next `getCliToken()` call
15
+ * Clear the in-process token cache so the next token resolution
16
16
  * re-reads from disk or the environment.
17
17
  *
18
18
  * Called automatically by `setCliUserConfig('authToken', ...)`.
19
19
  *
20
20
  * @internal
21
21
  */ export function clearCliTokenCache() {
22
- cachedToken = undefined;
22
+ cachedTokenInfo = undefined;
23
23
  }
24
24
 
25
25
  //# sourceMappingURL=cliTokenCache.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/cliTokenCache.ts"],"sourcesContent":["/**\n * Module-level cache for the CLI auth token, shared between\n * `getCliToken` (reads/writes) and `setCliUserConfig` (invalidates).\n *\n * Extracted into its own module to avoid a circular dependency\n * between `cliUserConfig.ts` and `getCliToken.ts`.\n */\nlet cachedToken: string | undefined\n\nexport function getCachedToken(): string | undefined {\n return cachedToken\n}\n\nexport function setCachedToken(token: string | undefined): void {\n cachedToken = token\n}\n\n/**\n * Clear the in-process token cache so the next `getCliToken()` call\n * re-reads from disk or the environment.\n *\n * Called automatically by `setCliUserConfig('authToken', ...)`.\n *\n * @internal\n */\nexport function clearCliTokenCache(): void {\n cachedToken = undefined\n}\n"],"names":["cachedToken","getCachedToken","setCachedToken","token","clearCliTokenCache","undefined"],"mappings":"AAAA;;;;;;CAMC,GACD,IAAIA;AAEJ,OAAO,SAASC;IACd,OAAOD;AACT;AAEA,OAAO,SAASE,eAAeC,KAAyB;IACtDH,cAAcG;AAChB;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC;IACdJ,cAAcK;AAChB"}
1
+ {"version":3,"sources":["../../../src/config/cli/cliTokenCache.ts"],"sourcesContent":["/**\n * Module-level cache for the resolved CLI auth token, shared between\n * `getCliTokenInfo` (reads/writes) and `setCliUserConfig` (invalidates).\n *\n * Extracted into its own module to avoid a circular dependency\n * between `cliUserConfig.ts` and `getCliToken.ts`.\n */\nexport interface CliTokenInfo {\n source: string\n token: string\n}\n\nlet cachedTokenInfo: CliTokenInfo | undefined\n\nexport function getCachedTokenInfo(): CliTokenInfo | undefined {\n return cachedTokenInfo\n}\n\nexport function setCachedTokenInfo(tokenInfo: CliTokenInfo | undefined): void {\n cachedTokenInfo = tokenInfo\n}\n\n/**\n * Clear the in-process token cache so the next token resolution\n * re-reads from disk or the environment.\n *\n * Called automatically by `setCliUserConfig('authToken', ...)`.\n *\n * @internal\n */\nexport function clearCliTokenCache(): void {\n cachedTokenInfo = undefined\n}\n"],"names":["cachedTokenInfo","getCachedTokenInfo","setCachedTokenInfo","tokenInfo","clearCliTokenCache","undefined"],"mappings":"AAAA;;;;;;CAMC,GAMD,IAAIA;AAEJ,OAAO,SAASC;IACd,OAAOD;AACT;AAEA,OAAO,SAASE,mBAAmBC,SAAmC;IACpEH,kBAAkBG;AACpB;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC;IACdJ,kBAAkBK;AACpB"}
@@ -6,7 +6,7 @@ import { getCliExecutionContext } from '../../executionContext.js';
6
6
  import { getSanityConfigDir } from '../../util/getSanityConfigDir.js';
7
7
  import { readJsonFileSync } from '../../util/readJsonFileSync.js';
8
8
  import { writeJsonFileSync } from '../../util/writeJsonFileSync.js';
9
- import { clearCliTokenCache, getCachedToken, setCachedToken } from './cliTokenCache.js';
9
+ import { clearCliTokenCache, getCachedTokenInfo, setCachedTokenInfo } from './cliTokenCache.js';
10
10
  // Re-export so existing consumers don't break
11
11
  export { clearCliTokenCache } from './cliTokenCache.js';
12
12
  // Only used for testing
@@ -14,30 +14,50 @@ export const _internals = {
14
14
  getCliUserConfig
15
15
  };
16
16
  /**
17
- * Get the CLI authentication token from the environment or the config file
17
+ * Get the CLI authentication token selected for the current invocation.
18
18
  *
19
19
  * @returns A promise that resolves to a CLI token, or undefined if no token is found
20
20
  * @internal
21
21
  */ export async function getCliToken() {
22
+ return (await getCliTokenInfo())?.token;
23
+ }
24
+ /**
25
+ * Get the CLI authentication token and where it was resolved from.
26
+ *
27
+ * @returns A promise that resolves to the token and its source, or undefined if no token is found
28
+ * @internal
29
+ */ export async function getCliTokenInfo() {
22
30
  // A per-invocation execution context token (e.g. per-request from an MCP
23
31
  // server) takes precedence and must bypass the process-wide cache entirely:
24
32
  // reading the cache would leak another invocation's token, and writing it
25
33
  // would leak this one's.
26
34
  const context = getCliExecutionContext();
27
- if (context) return context.token;
28
- const cached = getCachedToken();
29
- if (cached !== undefined) {
30
- return cached;
35
+ if (context) {
36
+ return context.token === undefined ? undefined : {
37
+ source: 'CLI execution context',
38
+ token: context.token
39
+ };
40
+ }
41
+ const cachedTokenInfo = getCachedTokenInfo();
42
+ if (cachedTokenInfo !== undefined) {
43
+ return cachedTokenInfo;
31
44
  }
32
45
  const token = process.env.SANITY_AUTH_TOKEN;
33
46
  if (token) {
34
- const trimmed = token.trim();
35
- setCachedToken(trimmed);
36
- return trimmed;
47
+ const tokenInfo = {
48
+ source: 'SANITY_AUTH_TOKEN environment variable',
49
+ token: token.trim()
50
+ };
51
+ setCachedTokenInfo(tokenInfo);
52
+ return tokenInfo;
37
53
  }
38
54
  const configToken = _internals.getCliUserConfig('authToken');
39
- setCachedToken(configToken);
40
- return configToken;
55
+ const tokenInfo = configToken === undefined ? undefined : {
56
+ source: getCliUserConfigPath(),
57
+ token: configToken
58
+ };
59
+ setCachedTokenInfo(tokenInfo);
60
+ return tokenInfo;
41
61
  }
42
62
  const cliUserConfigSchema = {
43
63
  authToken: z.optional(z.string())
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/cliUserConfig.ts"],"sourcesContent":["import {mkdirSync} from 'node:fs'\nimport {dirname, join as joinPath} from 'node:path'\n\nimport {z} from 'zod/mini'\n\nimport {debug} from '../../_exports/debug.js'\nimport {getCliExecutionContext} from '../../executionContext.js'\nimport {getSanityConfigDir} from '../../util/getSanityConfigDir.js'\nimport {readJsonFileSync} from '../../util/readJsonFileSync.js'\nimport {writeJsonFileSync} from '../../util/writeJsonFileSync.js'\nimport {clearCliTokenCache, getCachedToken, setCachedToken} from './cliTokenCache.js'\nimport {type ConfigStore} from './types/cliConfig.js'\n\n// Re-export so existing consumers don't break\nexport {clearCliTokenCache} from './cliTokenCache.js'\n\n// Only used for testing\nexport const _internals = {\n getCliUserConfig,\n}\n\n/**\n * Get the CLI authentication token from the environment or the config file\n *\n * @returns A promise that resolves to a CLI token, or undefined if no token is found\n * @internal\n */\nexport async function getCliToken(): Promise<string | undefined> {\n // A per-invocation execution context token (e.g. per-request from an MCP\n // server) takes precedence and must bypass the process-wide cache entirely:\n // reading the cache would leak another invocation's token, and writing it\n // would leak this one's.\n const context = getCliExecutionContext()\n if (context) return context.token\n\n const cached = getCachedToken()\n if (cached !== undefined) {\n return cached\n }\n\n const token = process.env.SANITY_AUTH_TOKEN\n if (token) {\n const trimmed = token.trim()\n setCachedToken(trimmed)\n return trimmed\n }\n\n const configToken = _internals.getCliUserConfig('authToken')\n setCachedToken(configToken)\n return configToken\n}\nconst cliUserConfigSchema = {\n authToken: z.optional(z.string()),\n}\n\n/**\n * Set the config value for the given property.\n * Validates that the passed value adheres to the defined CLI config schema.\n *\n * @param prop - The property to set the value for\n * @param value - The value to set\n * @internal\n */\nexport function setCliUserConfig(prop: 'authToken', value: string | undefined): void {\n assertCanAccessHostUserConfig()\n const config = readConfig()\n const result = cliUserConfigSchema[prop].safeParse(value)\n if (!result.success) {\n const message = result.error.issues\n .map(({message, path}) => `[${path.join('.')}] ${message}`)\n .join('\\n')\n\n throw new Error(`Invalid value for config property \"${prop}\": ${message}`)\n }\n\n const configPath = getCliUserConfigPath()\n mkdirSync(dirname(configPath), {recursive: true})\n\n // When value is undefined, explicitly delete the key rather than relying\n // on JSON.stringify silently dropping undefined values.\n if (value === undefined) {\n const {[prop]: _, ...rest} = config\n writeJsonFileSync(configPath, rest, {pretty: true})\n } else {\n writeJsonFileSync(configPath, {...config, [prop]: value}, {pretty: true})\n }\n\n // Invalidate the in-process token cache so subsequent getCliToken() calls\n // pick up the new value from disk.\n clearCliTokenCache()\n}\n\n/**\n * Get the config value for the given property\n *\n * @param prop - The property to get the value for\n * @returns The value of the given property\n */\nexport function getCliUserConfig(prop: 'authToken'): string | undefined {\n assertCanAccessHostUserConfig()\n const config = readConfig()\n const result = cliUserConfigSchema[prop].safeParse(config[prop])\n if (!result.success) {\n debug('Ignoring invalid stored value for \"%s\", returning undefined', prop)\n return undefined\n }\n\n return result.data\n}\n\n/**\n * Get a key-value store backed by the CLI user configuration file\n * (`~/.config/sanity/config.json`).\n *\n * Each call to `get`, `set`, or `delete` performs a full synchronous\n * read-modify-write cycle. This is intentional: sync I/O prevents\n * intra-process race conditions that occurred with the previous async\n * (configstore-backed) implementation.\n *\n * Note: there is no file-level locking, so concurrent writes from\n * separate CLI processes could still conflict. In practice this is\n * unlikely since CLI config writes are rare and user-initiated.\n *\n * @returns A {@link ConfigStore} for the CLI config file\n * @public\n */\nexport function getUserConfig(): ConfigStore {\n assertCanAccessHostUserConfig()\n return {\n get(key: string): unknown {\n const config = readConfig()\n return config[key]\n },\n\n set(key: string, value: unknown): void {\n const config = readConfig()\n const configPath = getCliUserConfigPath()\n mkdirSync(dirname(configPath), {recursive: true})\n writeJsonFileSync(configPath, {...config, [key]: value}, {pretty: true})\n if (key === 'authToken') clearCliTokenCache()\n },\n\n // No mkdirSync needed: if readConfig() succeeded the directory already exists.\n delete(key: string): void {\n const config = readConfig()\n if (!(key in config)) return\n const {[key]: _, ...rest} = config\n writeJsonFileSync(getCliUserConfigPath(), rest, {pretty: true})\n if (key === 'authToken') clearCliTokenCache()\n },\n }\n}\n\nfunction assertCanAccessHostUserConfig(): void {\n if (getCliExecutionContext()) {\n throw new Error('Host CLI user configuration is unavailable during programmatic invocations')\n }\n}\n\n/**\n * Read the whole configuration from file system. If the file does not exist,\n * is corrupt, or otherwise unreadable, an empty object is returned. This is\n * intentional: the config only holds recoverable data (auth tokens, telemetry\n * consent) so silently resetting is preferable to blocking the user.\n *\n * @returns The whole CLI configuration.\n * @internal\n */\nfunction readConfig(): Record<string, unknown> {\n try {\n const config = readJsonFileSync(getCliUserConfigPath())\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new Error('Invalid config file - expected an object')\n }\n return config\n } catch (err: unknown) {\n debug('Failed to read CLI config file: %s', err instanceof Error ? err.message : `${err}`)\n return {}\n }\n}\n\n/**\n * Get the file system location for the CLI user configuration file.\n * Takes into account the active environment (staging vs production).\n * The file is located in the user's home directory under the `.config` directory.\n *\n * @returns The path to the CLI configuration file.\n * @internal\n */\nfunction getCliUserConfigPath() {\n return process.env.SANITY_CLI_CONFIG_PATH || joinPath(getSanityConfigDir(), 'config.json')\n}\n"],"names":["mkdirSync","dirname","join","joinPath","z","debug","getCliExecutionContext","getSanityConfigDir","readJsonFileSync","writeJsonFileSync","clearCliTokenCache","getCachedToken","setCachedToken","_internals","getCliUserConfig","getCliToken","context","token","cached","undefined","process","env","SANITY_AUTH_TOKEN","trimmed","trim","configToken","cliUserConfigSchema","authToken","optional","string","setCliUserConfig","prop","value","assertCanAccessHostUserConfig","config","readConfig","result","safeParse","success","message","error","issues","map","path","Error","configPath","getCliUserConfigPath","recursive","_","rest","pretty","data","getUserConfig","get","key","set","delete","Array","isArray","err","SANITY_CLI_CONFIG_PATH"],"mappings":"AAAA,SAAQA,SAAS,QAAO,UAAS;AACjC,SAAQC,OAAO,EAAEC,QAAQC,QAAQ,QAAO,YAAW;AAEnD,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,sBAAsB,QAAO,4BAA2B;AAChE,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,gBAAgB,QAAO,iCAAgC;AAC/D,SAAQC,iBAAiB,QAAO,kCAAiC;AACjE,SAAQC,kBAAkB,EAAEC,cAAc,EAAEC,cAAc,QAAO,qBAAoB;AAGrF,8CAA8C;AAC9C,SAAQF,kBAAkB,QAAO,qBAAoB;AAErD,wBAAwB;AACxB,OAAO,MAAMG,aAAa;IACxBC;AACF,EAAC;AAED;;;;;CAKC,GACD,OAAO,eAAeC;IACpB,yEAAyE;IACzE,4EAA4E;IAC5E,0EAA0E;IAC1E,yBAAyB;IACzB,MAAMC,UAAUV;IAChB,IAAIU,SAAS,OAAOA,QAAQC,KAAK;IAEjC,MAAMC,SAASP;IACf,IAAIO,WAAWC,WAAW;QACxB,OAAOD;IACT;IAEA,MAAMD,QAAQG,QAAQC,GAAG,CAACC,iBAAiB;IAC3C,IAAIL,OAAO;QACT,MAAMM,UAAUN,MAAMO,IAAI;QAC1BZ,eA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B,IAAIzD,SAASI,sBAAsB;AAC9E"}
1
+ {"version":3,"sources":["../../../src/config/cli/cliUserConfig.ts"],"sourcesContent":["import {mkdirSync} from 'node:fs'\nimport {dirname, join as joinPath} from 'node:path'\n\nimport {z} from 'zod/mini'\n\nimport {debug} from '../../_exports/debug.js'\nimport {getCliExecutionContext} from '../../executionContext.js'\nimport {getSanityConfigDir} from '../../util/getSanityConfigDir.js'\nimport {readJsonFileSync} from '../../util/readJsonFileSync.js'\nimport {writeJsonFileSync} from '../../util/writeJsonFileSync.js'\nimport {\n clearCliTokenCache,\n type CliTokenInfo,\n getCachedTokenInfo,\n setCachedTokenInfo,\n} from './cliTokenCache.js'\nimport {type ConfigStore} from './types/cliConfig.js'\n\n// Re-export so existing consumers don't break\nexport {clearCliTokenCache} from './cliTokenCache.js'\nexport {type CliTokenInfo} from './cliTokenCache.js'\n\n// Only used for testing\nexport const _internals = {\n getCliUserConfig,\n}\n\n/**\n * Get the CLI authentication token selected for the current invocation.\n *\n * @returns A promise that resolves to a CLI token, or undefined if no token is found\n * @internal\n */\nexport async function getCliToken(): Promise<string | undefined> {\n return (await getCliTokenInfo())?.token\n}\n\n/**\n * Get the CLI authentication token and where it was resolved from.\n *\n * @returns A promise that resolves to the token and its source, or undefined if no token is found\n * @internal\n */\nexport async function getCliTokenInfo(): Promise<CliTokenInfo | undefined> {\n // A per-invocation execution context token (e.g. per-request from an MCP\n // server) takes precedence and must bypass the process-wide cache entirely:\n // reading the cache would leak another invocation's token, and writing it\n // would leak this one's.\n const context = getCliExecutionContext()\n if (context) {\n return context.token === undefined\n ? undefined\n : {source: 'CLI execution context', token: context.token}\n }\n\n const cachedTokenInfo = getCachedTokenInfo()\n if (cachedTokenInfo !== undefined) {\n return cachedTokenInfo\n }\n\n const token = process.env.SANITY_AUTH_TOKEN\n if (token) {\n const tokenInfo = {\n source: 'SANITY_AUTH_TOKEN environment variable',\n token: token.trim(),\n }\n setCachedTokenInfo(tokenInfo)\n return tokenInfo\n }\n\n const configToken = _internals.getCliUserConfig('authToken')\n const tokenInfo =\n configToken === undefined ? undefined : {source: getCliUserConfigPath(), token: configToken}\n setCachedTokenInfo(tokenInfo)\n return tokenInfo\n}\nconst cliUserConfigSchema = {\n authToken: z.optional(z.string()),\n}\n\n/**\n * Set the config value for the given property.\n * Validates that the passed value adheres to the defined CLI config schema.\n *\n * @param prop - The property to set the value for\n * @param value - The value to set\n * @internal\n */\nexport function setCliUserConfig(prop: 'authToken', value: string | undefined): void {\n assertCanAccessHostUserConfig()\n const config = readConfig()\n const result = cliUserConfigSchema[prop].safeParse(value)\n if (!result.success) {\n const message = result.error.issues\n .map(({message, path}) => `[${path.join('.')}] ${message}`)\n .join('\\n')\n\n throw new Error(`Invalid value for config property \"${prop}\": ${message}`)\n }\n\n const configPath = getCliUserConfigPath()\n mkdirSync(dirname(configPath), {recursive: true})\n\n // When value is undefined, explicitly delete the key rather than relying\n // on JSON.stringify silently dropping undefined values.\n if (value === undefined) {\n const {[prop]: _, ...rest} = config\n writeJsonFileSync(configPath, rest, {pretty: true})\n } else {\n writeJsonFileSync(configPath, {...config, [prop]: value}, {pretty: true})\n }\n\n // Invalidate the in-process token cache so subsequent getCliToken() calls\n // pick up the new value from disk.\n clearCliTokenCache()\n}\n\n/**\n * Get the config value for the given property\n *\n * @param prop - The property to get the value for\n * @returns The value of the given property\n */\nexport function getCliUserConfig(prop: 'authToken'): string | undefined {\n assertCanAccessHostUserConfig()\n const config = readConfig()\n const result = cliUserConfigSchema[prop].safeParse(config[prop])\n if (!result.success) {\n debug('Ignoring invalid stored value for \"%s\", returning undefined', prop)\n return undefined\n }\n\n return result.data\n}\n\n/**\n * Get a key-value store backed by the CLI user configuration file\n * (`~/.config/sanity/config.json`).\n *\n * Each call to `get`, `set`, or `delete` performs a full synchronous\n * read-modify-write cycle. This is intentional: sync I/O prevents\n * intra-process race conditions that occurred with the previous async\n * (configstore-backed) implementation.\n *\n * Note: there is no file-level locking, so concurrent writes from\n * separate CLI processes could still conflict. In practice this is\n * unlikely since CLI config writes are rare and user-initiated.\n *\n * @returns A {@link ConfigStore} for the CLI config file\n * @public\n */\nexport function getUserConfig(): ConfigStore {\n assertCanAccessHostUserConfig()\n return {\n get(key: string): unknown {\n const config = readConfig()\n return config[key]\n },\n\n set(key: string, value: unknown): void {\n const config = readConfig()\n const configPath = getCliUserConfigPath()\n mkdirSync(dirname(configPath), {recursive: true})\n writeJsonFileSync(configPath, {...config, [key]: value}, {pretty: true})\n if (key === 'authToken') clearCliTokenCache()\n },\n\n // No mkdirSync needed: if readConfig() succeeded the directory already exists.\n delete(key: string): void {\n const config = readConfig()\n if (!(key in config)) return\n const {[key]: _, ...rest} = config\n writeJsonFileSync(getCliUserConfigPath(), rest, {pretty: true})\n if (key === 'authToken') clearCliTokenCache()\n },\n }\n}\n\nfunction assertCanAccessHostUserConfig(): void {\n if (getCliExecutionContext()) {\n throw new Error('Host CLI user configuration is unavailable during programmatic invocations')\n }\n}\n\n/**\n * Read the whole configuration from file system. If the file does not exist,\n * is corrupt, or otherwise unreadable, an empty object is returned. This is\n * intentional: the config only holds recoverable data (auth tokens, telemetry\n * consent) so silently resetting is preferable to blocking the user.\n *\n * @returns The whole CLI configuration.\n * @internal\n */\nfunction readConfig(): Record<string, unknown> {\n try {\n const config = readJsonFileSync(getCliUserConfigPath())\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new Error('Invalid config file - expected an object')\n }\n return config\n } catch (err: unknown) {\n debug('Failed to read CLI config file: %s', err instanceof Error ? err.message : `${err}`)\n return {}\n }\n}\n\n/**\n * Get the file system location for the CLI user configuration file.\n * Takes into account the active environment (staging vs production).\n * The file is located in the user's home directory under the `.config` directory.\n *\n * @returns The path to the CLI configuration file.\n * @internal\n */\nfunction getCliUserConfigPath() {\n return process.env.SANITY_CLI_CONFIG_PATH || joinPath(getSanityConfigDir(), 'config.json')\n}\n"],"names":["mkdirSync","dirname","join","joinPath","z","debug","getCliExecutionContext","getSanityConfigDir","readJsonFileSync","writeJsonFileSync","clearCliTokenCache","getCachedTokenInfo","setCachedTokenInfo","_internals","getCliUserConfig","getCliToken","getCliTokenInfo","token","context","undefined","source","cachedTokenInfo","process","env","SANITY_AUTH_TOKEN","tokenInfo","trim","configToken","getCliUserConfigPath","cliUserConfigSchema","authToken","optional","string","setCliUserConfig","prop","value","assertCanAccessHostUserConfig","config","readConfig","result","safeParse","success","message","error","issues","map","path","Error","configPath","recursive","_","rest","pretty","data","getUserConfig","get","key","set","delete","Array","isArray","err","SANITY_CLI_CONFIG_PATH"],"mappings":"AAAA,SAAQA,SAAS,QAAO,UAAS;AACjC,SAAQC,OAAO,EAAEC,QAAQC,QAAQ,QAAO,YAAW;AAEnD,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,sBAAsB,QAAO,4BAA2B;AAChE,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,gBAAgB,QAAO,iCAAgC;AAC/D,SAAQC,iBAAiB,QAAO,kCAAiC;AACjE,SACEC,kBAAkB,EAElBC,kBAAkB,EAClBC,kBAAkB,QACb,qBAAoB;AAG3B,8CAA8C;AAC9C,SAAQF,kBAAkB,QAAO,qBAAoB;AAGrD,wBAAwB;AACxB,OAAO,MAAMG,aAAa;IACxBC;AACF,EAAC;AAED;;;;;CAKC,GACD,OAAO,eAAeC;IACpB,OAAQ,CAAA,MAAMC,iBAAgB,GAAIC;AACpC;AAEA;;;;;CAKC,GACD,OAAO,eAAeD;IACpB,yEAAyE;IACzE,4EAA4E;IAC5E,0EAA0E;IAC1E,yBAAyB;IACzB,MAAME,UAAUZ;IAChB,IAAIY,SAAS;QACX,OAAOA,QAAQD,KAAK,KAAKE,YACrBA,YACA;YAACC,QAAQ;YAAyBH,OAAOC,QAAQD,KAAK;QAAA;IAC5D;IAEA,MAAMI,kBAAkBV;IACxB,IAAIU,oBAAoBF,WAAW;QACjC,OAAOE;IACT;IAEA,MAAMJ,QAAQK,QAAQ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,OAAOV;IACT,EAAE,OAAOwB,KAAc;QACrBxD,MAAM,sCAAsCwD,eAAed,QAAQc,IAAInB,OAAO,GAAG,GAAGmB,KAAK;QACzF,OAAO,CAAC;IACV;AACF;AAEA;;;;;;;CAOC,GACD,SAASjC;IACP,OAAON,QAAQC,GAAG,CAACuC,sBAAsB,IAAI3D,SAASI,sBAAsB;AAC9E"}
@@ -5,7 +5,7 @@ import { NotFoundError } from '../../errors/NotFoundError.js';
5
5
  import { importModule } from '../../util/importModule.js';
6
6
  import { findPathForFiles } from '../util/findConfigsPaths.js';
7
7
  import { cliConfigSchema } from './schemas.js';
8
- import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
8
+ import { isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig } from './workbenchApp.js';
9
9
  const cache = new Map();
10
10
  /**
11
11
  * Get the CLI config for a project, given the root path.
@@ -83,9 +83,10 @@ const cache = new Map();
83
83
  cause: err
84
84
  });
85
85
  }
86
- // Branch as early as possible: a branded `unstable_defineApp(...)` opts into
87
- // workbench behavior, so its `app` skips the legacy `app` schema entirely.
88
- if (isWorkbenchApp(cliConfig?.app)) {
86
+ // Branch as early as possible: a branded `defineApplication(...)` app or a
87
+ // branded `unstable_defineMediaLibrary(...)` config opts into workbench
88
+ // behavior, so its `app` skips the legacy `app` schema entirely.
89
+ if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {
89
90
  return parseWorkbenchCliConfig(cliConfig, dirname(configPath));
90
91
  }
91
92
  const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../_exports/debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AACzC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,uBA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AAIS,MAAM,+BAA+B;YAACQ,OAAOjB;QAAG;IAC5D;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAIX,eAAe0B,WAAWG,MAAM;QAClC,OAAO5B,wBAAwByB,WAAWhC,QAAQ6B;IACpD;IAEA,MAAM,EAACO,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGjC,gBAAgBkC,SAAS,CAACP;IACzD,IAAI,CAACM,SAAS;QACZrC,MAAM,CAAC,oBAAoB,EAAEoC,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAId,MAAM,CAAC,oBAAoB,EAAEW,MAAMG,OAAO,EAAE,EAAE;YAACN,OAAOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../_exports/debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `defineApplication(...)` app or a\n // branded `unstable_defineMediaLibrary(...)` config opts into workbench\n // behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","isWorkbenchConfig","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AACzC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAO,oBAAmB;AAE5F,MAAMC,QAAQ,IAAIC;AAElB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,aAAaC,QAAgB;IAC3C,MAAMC,SAASJ,MAAMK,GAAG,CAACF;IACzB,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,MAAME,UAAUC,qBAAqBJ,UAAUK,KAAK,CAAC,CAACC;QACpDT,MAAMU,MAAM,CAACP;QACb,MAAMM;IACR;IAEAT,MAAMW,GAAG,CAACR,UAAUG;IACpB,OAAOA;AACT;AAEA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,eAAeC,qBAAqBJ,QAAgB;IACzD,MAAMS,QAAQ,MAAMjB,iBAAiBQ,UAAU;QA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AOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
@@ -5,7 +5,7 @@ import { register } from 'tsx/esm/api';
5
5
  import { NotFoundError } from '../../errors/NotFoundError.js';
6
6
  import { tryGetDefaultExport } from '../../util/tryGetDefaultExport.js';
7
7
  import { cliConfigSchema } from './schemas.js';
8
- import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
8
+ import { isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig } from './workbenchApp.js';
9
9
  /**
10
10
  * Get the CLI config for a project synchronously, given the root path.
11
11
  *
@@ -40,9 +40,10 @@ import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
40
40
  } finally{
41
41
  unregister();
42
42
  }
43
- // Branch as early as possible: a branded `unstable_defineApp(...)` opts into
44
- // workbench behavior, so its `app` skips the legacy `app` schema entirely.
45
- if (isWorkbenchApp(cliConfig?.app)) {
43
+ // Branch as early as possible: a branded `defineApplication(...)` app or a
44
+ // branded `unstable_defineMediaLibrary(...)` config opts into workbench
45
+ // behavior, so its `app` skips the legacy `app` schema entirely.
46
+ if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {
46
47
  return parseWorkbenchCliConfig(cliConfig, rootPath);
47
48
  }
48
49
  const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/getCliConfigSync.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {createRequire} from 'node:module'\nimport {join} from 'node:path'\n\nimport {register} from 'tsx/esm/api'\n\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {tryGetDefaultExport} from '../../util/tryGetDefaultExport.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\n/**\n * Get the CLI config for a project synchronously, given the root path.\n *\n * This loads the CLI config in the main thread using tsx/register for TypeScript support.\n * Note: This is a synchronous operation and does not use worker threads like the async version.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfigSync(rootPath: string): CliConfig {\n const possiblePaths = ['sanity.cli.ts', 'sanity.cli.js'].map((file) => join(rootPath, file))\n const configPaths = possiblePaths.filter((path) => existsSync(path))\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`)\n }\n\n const configPath = configPaths[0]\n\n // Register tsx for TypeScript support\n const unregister = register()\n\n let cliConfig: CliConfig | undefined\n try {\n // Use createRequire for synchronous loading in ESM contexts\n // This works when tsx loader is active\n const require = createRequire(import.meta.url)\n const loaded = require(configPath)\n cliConfig = tryGetDefaultExport(loaded) as CliConfig | undefined\n } finally {\n unregister()\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, rootPath)\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`)\n }\n\n // There is a minor difference here because of the `vite` property and how the types\n // aren't as specific as our manually typed `CliConfig` type, thus the cast.\n return data as CliConfig\n}\n"],"names":["existsSync","createRequire","join","register","NotFoundError","tryGetDefaultExport","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","getCliConfigSync","rootPath","possiblePaths","map","file","configPaths","filter","path","length","Error","configPath","unregister","cliConfig","require","url","loaded","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,aAAa,QAAO,cAAa;AACzC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,aAAa,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["import {existsSync} from 'node:fs'\nimport {createRequire} from 'node:module'\nimport {join} from 'node:path'\n\nimport {register} from 'tsx/esm/api'\n\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {tryGetDefaultExport} from '../../util/tryGetDefaultExport.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, isWorkbenchConfig, parseWorkbenchCliConfig} from './workbenchApp.js'\n\n/**\n * Get the CLI config for a project synchronously, given the root path.\n *\n * This loads the CLI config in the main thread using tsx/register for TypeScript support.\n * Note: This is a synchronous operation and does not use worker threads like the async version.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfigSync(rootPath: string): CliConfig {\n const possiblePaths = ['sanity.cli.ts', 'sanity.cli.js'].map((file) => join(rootPath, file))\n const configPaths = possiblePaths.filter((path) => existsSync(path))\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`)\n }\n\n const configPath = configPaths[0]\n\n // Register tsx for TypeScript support\n const unregister = register()\n\n let cliConfig: CliConfig | undefined\n try {\n // Use createRequire for synchronous loading in ESM contexts\n // This works when tsx loader is active\n const require = createRequire(import.meta.url)\n const loaded = require(configPath)\n cliConfig = tryGetDefaultExport(loaded) as CliConfig | undefined\n } finally {\n unregister()\n }\n\n // Branch as early as possible: a branded `defineApplication(...)` app or a\n // branded `unstable_defineMediaLibrary(...)` config opts into workbench\n // behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, rootPath)\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`)\n }\n\n // There is a minor difference here because of the `vite` property and how the types\n // aren't as specific as our manually typed `CliConfig` type, thus the cast.\n return data as CliConfig\n}\n"],"names":["existsSync","createRequire","join","register","NotFoundError","tryGetDefaultExport","cliConfigSchema","isWorkbenchApp","isWorkbenchConfig","parseWorkbenchCliConfig","getCliConfigSync","rootPath","possiblePaths","map","file","configPaths","filter","path","length","Error","configPath","unregister","cliConfig","require","url","loaded","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,aAAa,QAAO,cAAa;AACzC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAO,oBAAmB;AAE5F;;;;;;;;;CASC,GACD,OAAO,SAASC,iBAAiBC,QAAgB;IAC/C,MAAMC,gBAAgB;QAAC;QAAiB;KAAgB,CAACC,GAAG,CAAC,CAACC,OAASZ,KAAKS,UAAUG;IACtF,MAAMC,cAAcH,cAAcI,MAAM,CAAC,CAACC,OAASjB,WAAWiB;IAE9D,IAAIF,YAAYG,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAId,cAAc,CAAC,uBAAuB,EAAEO,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAII,YAAYG,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEJ,YAAYb,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/E;IAEA,MAAMkB,aAAaL,WAAW,CAAC,EAAE;IAEjC,sCAAsC;IACtC,MAAMM,aAAalB;IAEnB,IAAImB;IACJ,IAAI;QACF,4DAA4D;QAC5D,uCAAuC;QACvC,MAAMC,UAAUtB,cAAc,YAAYuB,GAAG;QAC7C,MAAMC,SAASF,QAAQH;QACvBE,YAAYjB,oBAAoBoB;IAClC,SAAU;QACRJ;IACF;IAEA,2EAA2E;IAC3E,wEAAwE;IACxE,iEAAiE;IACjE,IAAId,eAAee,WAAWI,QAAQlB,kBAAkBc,WAAWI,MAAM;QACvE,OAAOjB,wBAAwBa,WAAWX;IAC5C;IAEA,MAAM,EAACgB,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGvB,gBAAgBwB,SAAS,CAACR;IACzD,IAAI,CAACO,SAAS;QACZ,MAAM,IAAIV,MAAM,CAAC,oBAAoB,EAAES,MAAMG,OAAO,EAAE;IACxD;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,OAAOJ;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as BabelReactCompilerOptions} from 'babel-plugin-react-compiler'\nimport {type ReactCompilerOptions as OxcReactCompilerOptions} from 'oxc-transform-react'\n\nimport {type UserViteConfig} from './userViteConfig'\n\n/**\n * Configuration for React Compiler.\n *\n * The `transform` field selects which React Compiler transform to run; the\n * remaining options are passed to the selected transform:\n *\n * - `'babel'` (default) - the Babel plugin\n * ({@link https://www.npmjs.com/package/babel-plugin-react-compiler | babel-plugin-react-compiler}\n * must be installed in your project)\n * - `'oxc'` (experimental) - the native Rust port\n * ({@link https://www.npmjs.com/package/oxc-transform-react | oxc-transform-react}\n * must be installed in your project)\n *\n * @public\n */\nexport type ReactCompilerConfig =\n | (BabelReactCompilerOptions & {transform?: 'babel'})\n | (OxcReactCompilerOptions & {transform: 'oxc'})\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /**\n * Configuration options for React Compiler. Pass `true` to enable it with\n * the default (babel) transform, or an object to configure it — see\n * {@link ReactCompilerConfig} for choosing between the babel and the\n * experimental oxc transform.\n */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAgCA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
1
+ {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as BabelReactCompilerOptions} from 'babel-plugin-react-compiler'\nimport {type ReactCompilerOptions as OxcReactCompilerOptions} from 'oxc-transform-react'\n\nimport {type UserViteConfig} from './userViteConfig'\n\n/**\n * An optional peer dependency's options type, or `unknown` when the peer's\n * typings did not resolve.\n *\n * `babel-plugin-react-compiler` and `oxc-transform-react` are optional peer\n * dependencies, so the type-only imports above only resolve in projects that\n * install them. When one is missing, TypeScript degrades its import to `any`\n * (the unresolved-module error is suppressed inside declaration files under\n * `skipLibCheck`), and intersecting `any` into a {@link ReactCompilerConfig}\n * branch would collapse the whole union to `any` — silently disabling type\n * checking of the `reactCompiler` option, including for the compiler that IS\n * installed. Mapping a missing peer's options to `unknown` (the identity\n * under intersection) instead reduces that branch to just its `transform`\n * discriminator, keeping the other branch fully checked.\n *\n * `unknown extends T` is only true when `T` degraded to `any`/`unknown`;\n * resolved options types pass through untouched. (`0 extends 1 & T` — the\n * usual any-detector — does not work here: an unresolved import produces the\n * checker's error type, which that intersection propagates.)\n */\ntype OptionalPeerOptions<T> = unknown extends T ? unknown : T\n\n/**\n * Configuration for React Compiler.\n *\n * The `transform` field selects which React Compiler transform to run; the\n * remaining options are passed to the selected transform:\n *\n * - `'babel'` (default) - the Babel plugin\n * ({@link https://www.npmjs.com/package/babel-plugin-react-compiler | babel-plugin-react-compiler}\n * must be installed in your project)\n * - `'oxc'` (experimental) - the native Rust port\n * ({@link https://www.npmjs.com/package/oxc-transform-react | oxc-transform-react}\n * must be installed in your project)\n *\n * Each branch's options are only type-checked when the corresponding package\n * is installed; a missing package reduces its branch to just the `transform`\n * discriminator.\n *\n * @public\n */\nexport type ReactCompilerConfig =\n | (OptionalPeerOptions<BabelReactCompilerOptions> & {transform?: 'babel'})\n | (OptionalPeerOptions<OxcReactCompilerOptions> & {transform: 'oxc'})\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /**\n * Configuration options for React Compiler. Pass `true` to enable it with\n * the default (babel) transform, or an object to configure it — see\n * {@link ReactCompilerConfig} for choosing between the babel and the\n * experimental oxc transform.\n */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AA0DA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
@@ -1,10 +1,12 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import { z } from 'zod/mini';
3
4
  import { cliConfigSchema } from './schemas.js';
4
5
  // Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that
5
6
  // import would cycle (it depends on cli-core) and pull workbench code into the
6
7
  // hot config-load path.
7
8
  const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
9
+ const WORKBENCH_CONFIG_BRAND = Symbol.for('sanity.workbench.defineConfig');
8
10
  /**
9
11
  * Boolean brand check — used for config-load routing, kept exported for
10
12
  * backward compatibility. For the typed narrowing (the app's declared fields),
@@ -12,6 +14,13 @@ const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
12
14
  */ export function isWorkbenchApp(app) {
13
15
  return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app;
14
16
  }
17
+ /**
18
+ * Boolean brand check for a branded `unstable_defineMediaLibrary(...)` config.
19
+ * A config is not an app — it lives in `cliConfig.app` but skips the legacy `app`
20
+ * schema and `applicationType` stamping, and resolves via `resolveWorkbenchConfig`.
21
+ */ export function isWorkbenchConfig(app) {
22
+ return typeof app === 'object' && app !== null && WORKBENCH_CONFIG_BRAND in app;
23
+ }
15
24
  const STUDIO_CONFIG_FILES = [
16
25
  'sanity.config.ts',
17
26
  'sanity.config.tsx',
@@ -21,23 +30,20 @@ const STUDIO_CONFIG_FILES = [
21
30
  'sanity.config.cjs'
22
31
  ];
23
32
  // Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`
24
- // schema — `unstable_defineApp` doesn't validate, so the loader is the first
33
+ // schema — `defineApplication` doesn't validate, so the loader is the first
25
34
  // place `applicationType` can be checked. Kept in sync by a test there.
26
35
  const APPLICATION_TYPES = [
27
36
  'coreApp',
28
37
  'studio',
29
38
  'canvas',
30
- 'dashboard',
31
- 'media-library'
39
+ 'dashboard'
32
40
  ];
33
- function isApplicationType(value) {
34
- return typeof value === 'string' && APPLICATION_TYPES.includes(value);
35
- }
41
+ const applicationTypeSchema = z.enum(APPLICATION_TYPES);
36
42
  /** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */ function detectApplicationType(projectDir) {
37
43
  return STUDIO_CONFIG_FILES.some((file)=>existsSync(join(projectDir, file))) ? 'studio' : 'coreApp';
38
44
  }
39
45
  /**
40
- * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The
46
+ * Parse a config whose `app` is a branded `defineApplication(...)` result. The
41
47
  * branded `app` bypasses the legacy `app` schema (which would strip its identity
42
48
  * fields and the brand); every other field is still validated.
43
49
  *
@@ -52,15 +58,22 @@ function isApplicationType(value) {
52
58
  cause: error
53
59
  });
54
60
  }
55
- const explicit = app.applicationType;
56
- if (explicit !== undefined && !isApplicationType(explicit)) {
57
- throw new Error(`Invalid \`applicationType\` "${explicit}" in \`unstable_defineApp\` — expected one of: ${APPLICATION_TYPES.join(', ')}`);
58
- }
59
- const applicationType = explicit ?? detectApplicationType(projectDir);
60
61
  // Clone via property descriptors, not spread — carries over the non-enumerable
61
62
  // brand and avoids mutating the caller's object.
62
63
  const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app));
63
- resolvedApp.applicationType = applicationType;
64
+ // A config is not an app: it carries no `applicationType` (it targets one by
65
+ // `appType`), so skip detection/stamping and pass its branded shape through.
66
+ if (isWorkbenchConfig(app)) {
67
+ return {
68
+ ...data,
69
+ app: resolvedApp
70
+ };
71
+ }
72
+ const explicit = app.applicationType;
73
+ if (explicit !== undefined && !applicationTypeSchema.safeParse(explicit).success) {
74
+ throw new Error(`Invalid \`applicationType\` "${explicit}" in \`defineApplication\` — expected one of: ${APPLICATION_TYPES.join(', ')}`);
75
+ }
76
+ resolvedApp.applicationType = explicit ?? detectApplicationType(projectDir);
64
77
  return {
65
78
  ...data,
66
79
  app: resolvedApp
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n// Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that\n// import would cycle (it depends on cli-core) and pull workbench code into the\n// hot config-load path.\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * Boolean brand check — used for config-load routing, kept exported for\n * backward compatibility. For the typed narrowing (the app's declared fields),\n * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.\n */\nexport function isWorkbenchApp(app: CliConfig['app']): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`\n// schema — `unstable_defineApp` doesn't validate, so the loader is the first\n// place `applicationType` can be checked. Kept in sync by a test there.\nconst APPLICATION_TYPES = ['coreApp', 'studio', 'canvas', 'dashboard', 'media-library'] as const\n\n/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */\nexport type ApplicationType = (typeof APPLICATION_TYPES)[number]\n\nfunction isApplicationType(value: unknown): value is ApplicationType {\n return typeof value === 'string' && (APPLICATION_TYPES as readonly string[]).includes(value)\n}\n\n/** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The\n * branded `app` bypasses the legacy `app` schema (which would strip its identity\n * fields and the brand); every other field is still validated.\n *\n * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere\n * downstream. The value lands on a clone, never the caller's object, so\n * re-parsing the same `app` for another directory can't inherit a stale guess.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !isApplicationType(explicit)) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`unstable_defineApp\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n const applicationType = explicit ?? detectApplicationType(projectDir)\n\n // Clone via property descriptors, not spread — carries over the non-enumerable\n // brand and avoids mutating the caller's object.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n resolvedApp.applicationType = applicationType\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","isWorkbenchApp","app","STUDIO_CONFIG_FILES","APPLICATION_TYPES","isApplicationType","value","includes","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","explicit","applicationType","undefined","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,eAAe,QAAO,eAAc;AAG5C,+EAA+E;AAC/E,+EAA+E;AAC/E,wBAAwB;AACxB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AAEvC;;;;CAIC,GACD,OAAO,SAASC,eAAeC,GAAqB;IAClD,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,uBAAuBI;AAC3E;AAEA,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,MAAMC,oBAAoB;IAAC;IAAW;IAAU;IAAU;IAAa;CAAgB;AAKvF,SAASC,kBAAkBC,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAY,AAACF,kBAAwCG,QAAQ,CAACD;AACxF;AAEA,wFAAwF,GACxF,SAASE,sBAAsBC,UAAkB;IAC/C,OAAON,oBAAoBO,IAAI,CAAC,CAACC,OAAShB,WAAWC,KAAKa,YAAYE,UAClE,WACA;AACN;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,wBAAwBC,SAAkB,EAAEJ,UAAkB;IAC5E,MAAM,EAACP,GAAG,EAAE,GAAGY,MAAK,GAAGD;IAGvB,MAAM,EAACE,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGpB,gBAAgBqB,SAAS,CAACJ;IACzD,IAAI,CAACG,SAAS;QACZ,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEH,MAAMI,OAAO,EAAE,EAAE;YAACC,OAAOL;QAAK;IACvE;IAEA,MAAMM,WAAWpB,IAAIqB,eAAe;IACpC,IAAID,aAAaE,aAAa,CAACnB,kBAAkBiB,WAAW;QAC1D,MAAM,IAAIH,MACR,CAAC,6BAA6B,EAAEG,SAAS,+CAA+C,EAAElB,kBAAkBR,IAAI,CAAC,OAAO;IAE5H;IACA,MAAM2B,kBAAkBD,YAAYd,sBAAsBC;IAE1D,+EAA+E;IAC/E,iDAAiD;IACjD,MAAMgB,cAAcC,OAAOC,gBAAgB,CAAC,CAAC,GAAGD,OAAOE,yBAAyB,CAAC1B;IAIjFuB,YAAYF,eAAe,GAAGA;IAE9B,OAAO;QAAC,GAAGR,IAAI;QAAEb,KAAKuB;IAAW;AACnC"}
1
+ {"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {z} from 'zod/mini'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n// Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that\n// import would cycle (it depends on cli-core) and pull workbench code into the\n// hot config-load path.\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\nconst WORKBENCH_CONFIG_BRAND = Symbol.for('sanity.workbench.defineConfig')\n\n/**\n * Boolean brand check — used for config-load routing, kept exported for\n * backward compatibility. For the typed narrowing (the app's declared fields),\n * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.\n */\nexport function isWorkbenchApp(app: unknown): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\n/**\n * Boolean brand check for a branded `unstable_defineMediaLibrary(...)` config.\n * A config is not an app — it lives in `cliConfig.app` but skips the legacy `app`\n * schema and `applicationType` stamping, and resolves via `resolveWorkbenchConfig`.\n */\nexport function isWorkbenchConfig(app: unknown): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_CONFIG_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`\n// schema — `defineApplication` doesn't validate, so the loader is the first\n// place `applicationType` can be checked. Kept in sync by a test there.\nconst APPLICATION_TYPES = ['coreApp', 'studio', 'canvas', 'dashboard'] as const\nconst applicationTypeSchema = z.enum(APPLICATION_TYPES)\n\n/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */\nexport type ApplicationType = z.infer<typeof applicationTypeSchema>\n\n/** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `defineApplication(...)` result. The\n * branded `app` bypasses the legacy `app` schema (which would strip its identity\n * fields and the brand); every other field is still validated.\n *\n * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere\n * downstream. The value lands on a clone, never the caller's object, so\n * re-parsing the same `app` for another directory can't inherit a stale guess.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n // Clone via property descriptors, not spread — carries over the non-enumerable\n // brand and avoids mutating the caller's object.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n\n // A config is not an app: it carries no `applicationType` (it targets one by\n // `appType`), so skip detection/stamping and pass its branded shape through.\n if (isWorkbenchConfig(app)) {\n return {...data, app: resolvedApp} as CliConfig\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !applicationTypeSchema.safeParse(explicit).success) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`defineApplication\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n resolvedApp.applicationType = explicit ?? detectApplicationType(projectDir)\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","z","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","WORKBENCH_CONFIG_BRAND","isWorkbenchApp","app","isWorkbenchConfig","STUDIO_CONFIG_FILES","APPLICATION_TYPES","applicationTypeSchema","enum","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors","explicit","applicationType","undefined"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,eAAe,QAAO,eAAc;AAG5C,+EAA+E;AAC/E,+EAA+E;AAC/E,wBAAwB;AACxB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AACvC,MAAMC,yBAAyBF,OAAOC,GAAG,CAAC;AAE1C;;;;CAIC,GACD,OAAO,SAASE,eAAeC,GAAY;IACzC,OAAO,OAAOA,QAAQ,YAAYA,QA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OAAO;IAE3H;IACA4B,YAAYK,eAAe,GAAGD,YAAYlB,sBAAsBC;IAEhE,OAAO;QAAC,GAAGM,IAAI;QAAEb,KAAKoB;IAAW;AACnC"}
@@ -1,9 +1,20 @@
1
- import { i as ConfigStore, r as CliConfig } from "./cliConfig-DrUV6Wp6.js";
1
+ import { i as ConfigStore, r as CliConfig } from "./cliConfig-DUt8uaF6.js";
2
2
  import { t as ProjectRootResult } from "./recursivelyResolveProjectRoot-BE54uEP6.js";
3
3
  import { z } from "zod/mini";
4
4
  import { Workspace } from "sanity";
5
5
  /**
6
- * Clear the in-process token cache so the next `getCliToken()` call
6
+ * Module-level cache for the resolved CLI auth token, shared between
7
+ * `getCliTokenInfo` (reads/writes) and `setCliUserConfig` (invalidates).
8
+ *
9
+ * Extracted into its own module to avoid a circular dependency
10
+ * between `cliUserConfig.ts` and `getCliToken.ts`.
11
+ */
12
+ interface CliTokenInfo {
13
+ source: string;
14
+ token: string;
15
+ }
16
+ /**
17
+ * Clear the in-process token cache so the next token resolution
7
18
  * re-reads from disk or the environment.
8
19
  *
9
20
  * Called automatically by `setCliUserConfig('authToken', ...)`.
@@ -12,12 +23,19 @@ import { Workspace } from "sanity";
12
23
  */
13
24
  declare function clearCliTokenCache(): void;
14
25
  /**
15
- * Get the CLI authentication token from the environment or the config file
26
+ * Get the CLI authentication token selected for the current invocation.
16
27
  *
17
28
  * @returns A promise that resolves to a CLI token, or undefined if no token is found
18
29
  * @internal
19
30
  */
20
31
  declare function getCliToken(): Promise<string | undefined>;
32
+ /**
33
+ * Get the CLI authentication token and where it was resolved from.
34
+ *
35
+ * @returns A promise that resolves to the token and its source, or undefined if no token is found
36
+ * @internal
37
+ */
38
+ declare function getCliTokenInfo(): Promise<CliTokenInfo | undefined>;
21
39
  /**
22
40
  * Set the config value for the given property.
23
41
  * Validates that the passed value adheres to the defined CLI config schema.
@@ -261,5 +279,5 @@ declare function findStudioConfigPath(basePath: string): Promise<string>;
261
279
  * @internal
262
280
  */
263
281
  declare function tryFindStudioConfigPath(basePath: string): Promise<string | undefined>;
264
- export { getStudioWorkspaces as a, findProjectRoot as c, getCliConfigUncached as d, getCliToken as f, clearCliTokenCache as g, setCliUserConfig as h, isStudioConfig as i, getCliConfigSync as l, getUserConfig as m, tryFindStudioConfigPath as n, getStudioConfig as o, getCliUserConfig as p, findPathForFiles as r, findProjectRootSync as s, findStudioConfigPath as t, getCliConfig as u };
265
- //# sourceMappingURL=findStudioConfigPath-DeBa0pMT.d.ts.map
282
+ export { CliTokenInfo as _, getStudioWorkspaces as a, findProjectRoot as c, getCliConfigUncached as d, getCliToken as f, setCliUserConfig as g, getUserConfig as h, isStudioConfig as i, getCliConfigSync as l, getCliUserConfig as m, tryFindStudioConfigPath as n, getStudioConfig as o, getCliTokenInfo as p, findPathForFiles as r, findProjectRootSync as s, findStudioConfigPath as t, getCliConfig as u, clearCliTokenCache as v };
283
+ //# sourceMappingURL=findStudioConfigPath-BV4DCesQ.d.ts.map
package/dist/manifest.js CHANGED
@@ -10,9 +10,15 @@ import { z } from 'zod/mini';
10
10
  * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the
11
11
  * CLI produces the payload in full.
12
12
  */ export const coreAppManifestSchema = z.object({
13
- group: z.optional(z.string()),
13
+ dock: z.optional(z.object({
14
+ group: z.optional(z.enum([
15
+ 'dock.system',
16
+ 'dock.applications',
17
+ 'dock.user'
18
+ ])),
19
+ order: z.optional(z.number())
20
+ })),
14
21
  icon: z.optional(z.string()),
15
- priority: z.optional(z.number()),
16
22
  slug: z.optional(z.string()),
17
23
  title: z.optional(z.string()),
18
24
  version: z.string()
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/manifest.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n/**\n * Studio/app manifest schemas. They live in cli-core because more than one\n * package validates manifests: the CLI extracts and writes them, and the\n * workbench dev-server registry stores and rebroadcasts them. Keeping the\n * contract here lets both validate against the same schema without depending on\n * each other.\n */\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the\n * CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n group: z.optional(z.string()),\n icon: z.optional(z.string()),\n priority: z.optional(z.number()),\n slug: z.optional(z.string()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\n/**\n * Studio application manifest (serialized `create-manifest.json`). Kept loose so\n * the CLI isn't coupled to the workbench's evolving client-side schema — the\n * workbench consumer is authoritative on the inner shape. See its\n * `ClientManifest` for the fields clients expect.\n */\nexport const studioManifestSchema = z.record(z.string(), z.unknown())\n\nexport type StudioManifest = z.infer<typeof studioManifestSchema>\n"],"names":["z","coreAppManifestSchema","object","group","optional","string","icon","priority","number","slug","title","version","studioManifestSchema","record","unknown"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBD,EAAEE,MAAM,CAAC;IAC5CC,OAAOH,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BC,MAAMN,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBE,UAAUP,EAAEI,QAAQ,CAACJ,EAAEQ,MAAM;IAC7BC,MAAMT,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBK,OAAOV,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BM,SAASX,EAAEK,MAAM;AACnB,GAAE;AAIF;;;;;CAKC,GACD,OAAO,MAAMO,uBAAuBZ,EAAEa,MAAM,CAACb,EAAEK,MAAM,IAAIL,EAAEc,OAAO,IAAG"}
1
+ {"version":3,"sources":["../src/manifest.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n/**\n * Studio/app manifest schemas. They live in cli-core because more than one\n * package validates manifests: the CLI extracts and writes them, and the\n * workbench dev-server registry stores and rebroadcasts them. Keeping the\n * contract here lets both validate against the same schema without depending on\n * each other.\n */\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the\n * CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n dock: z.optional(\n z.object({\n group: z.optional(z.enum(['dock.system', 'dock.applications', 'dock.user'])),\n order: z.optional(z.number()),\n }),\n ),\n icon: z.optional(z.string()),\n slug: z.optional(z.string()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\n/**\n * Studio application manifest (serialized `create-manifest.json`). Kept loose so\n * the CLI isn't coupled to the workbench's evolving client-side schema — the\n * workbench consumer is authoritative on the inner shape. See its\n * `ClientManifest` for the fields clients expect.\n */\nexport const studioManifestSchema = z.record(z.string(), z.unknown())\n\nexport type StudioManifest = z.infer<typeof studioManifestSchema>\n"],"names":["z","coreAppManifestSchema","object","dock","optional","group","enum","order","number","icon","string","slug","title","version","studioManifestSchema","record","unknown"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBD,EAAEE,MAAM,CAAC;IAC5CC,MAAMH,EAAEI,QAAQ,CACdJ,EAAEE,MAAM,CAAC;QACPG,OAAOL,EAAEI,QAAQ,CAACJ,EAAEM,IAAI,CAAC;YAAC;YAAe;YAAqB;SAAY;QAC1EC,OAAOP,EAAEI,QAAQ,CAACJ,EAAEQ,MAAM;IAC5B;IAEFC,MAAMT,EAAEI,QAAQ,CAACJ,EAAEU,MAAM;IACzBC,MAAMX,EAAEI,QAAQ,CAACJ,EAAEU,MAAM;IACzBE,OAAOZ,EAAEI,QAAQ,CAACJ,EAAEU,MAAM;IAC1BG,SAASb,EAAEU,MAAM;AACnB,GAAE;AAIF;;;;;CAKC,GACD,OAAO,MAAMI,uBAAuBd,EAAEe,MAAM,CAACf,EAAEU,MAAM,IAAIV,EAAEgB,OAAO,IAAG"}
@@ -1,4 +1,4 @@
1
- import { a as ReactCompilerConfig, o as TypeGenConfig, s as UserViteConfig } from "./cliConfig-DrUV6Wp6.js";
1
+ import { a as ReactCompilerConfig, o as TypeGenConfig, s as UserViteConfig } from "./cliConfig-DUt8uaF6.js";
2
2
  import { z } from "zod/mini";
3
3
  /**
4
4
  * @public
@@ -80,9 +80,15 @@ declare const cliConfigSchema: z.ZodMiniObject<{
80
80
  * CLI produces the payload in full.
81
81
  */
82
82
  declare const coreAppManifestSchema: z.ZodMiniObject<{
83
- group: z.ZodMiniOptional<z.ZodMiniString<string>>;
83
+ dock: z.ZodMiniOptional<z.ZodMiniObject<{
84
+ group: z.ZodMiniOptional<z.ZodMiniEnum<{
85
+ "dock.system": "dock.system";
86
+ "dock.applications": "dock.applications";
87
+ "dock.user": "dock.user";
88
+ }>>;
89
+ order: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
90
+ }, z.core.$strip>>;
84
91
  icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
85
- priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
86
92
  slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
87
93
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
88
94
  version: z.ZodMiniString<string>;
@@ -97,4 +103,4 @@ type CoreAppManifest = z.infer<typeof coreAppManifestSchema>;
97
103
  declare const studioManifestSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
98
104
  type StudioManifest = z.infer<typeof studioManifestSchema>;
99
105
  export { cliConfigSchema as a, studioManifestSchema as i, StudioManifest as n, coreAppManifestSchema as r, CoreAppManifest as t };
100
- //# sourceMappingURL=schemas-Y-KwP413.d.ts.map
106
+ //# sourceMappingURL=schemas-D1LxkXeZ.d.ts.map
@@ -1,15 +1,21 @@
1
- import { r as CliConfig } from "./cliConfig-DrUV6Wp6.js";
1
+ import { r as CliConfig } from "./cliConfig-DUt8uaF6.js";
2
+ import { z } from "zod/mini";
2
3
  /**
3
4
  * Boolean brand check — used for config-load routing, kept exported for
4
5
  * backward compatibility. For the typed narrowing (the app's declared fields),
5
6
  * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.
6
7
  */
7
- declare function isWorkbenchApp(app: CliConfig['app']): boolean;
8
- declare const APPLICATION_TYPES: readonly ["coreApp", "studio", "canvas", "dashboard", "media-library"];
8
+ declare function isWorkbenchApp(app: unknown): boolean;
9
+ declare const applicationTypeSchema: z.ZodMiniEnum<{
10
+ coreApp: "coreApp";
11
+ studio: "studio";
12
+ canvas: "canvas";
13
+ dashboard: "dashboard";
14
+ }>;
9
15
  /** The resolved kind of a workbench app — `studio` or one of the SDK app types. */
10
- type ApplicationType = (typeof APPLICATION_TYPES)[number];
16
+ type ApplicationType = z.infer<typeof applicationTypeSchema>;
11
17
  /**
12
- * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The
18
+ * Parse a config whose `app` is a branded `defineApplication(...)` result. The
13
19
  * branded `app` bypasses the legacy `app` schema (which would strip its identity
14
20
  * fields and the brand); every other field is still validated.
15
21
  *
@@ -19,4 +25,4 @@ type ApplicationType = (typeof APPLICATION_TYPES)[number];
19
25
  */
20
26
  declare function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig;
21
27
  export { isWorkbenchApp as n, parseWorkbenchCliConfig as r, ApplicationType as t };
22
- //# sourceMappingURL=workbenchApp-CSYpReA-.d.ts.map
28
+ //# sourceMappingURL=workbenchApp-DVKwpTyU.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",