@sanity/cli-core 3.15.1 → 3.17.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.
- package/dist/_exports/images.d.ts +13 -0
- package/dist/_exports/images.js +3 -0
- package/dist/_exports/images.js.map +1 -0
- package/dist/_exports/index.d.ts +2 -2
- package/dist/_exports/index.js +1 -0
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/package-manager.d.ts +2 -2
- package/dist/_exports/package-manager.js +1 -0
- package/dist/_exports/package-manager.js.map +1 -1
- package/dist/_exports/undeploy.d.ts +2 -1
- package/dist/_exports/undeploy.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +6 -9
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
- package/dist/{resolveLocalPackage-Dr-TNTyk.d.ts → resolveLocalPackage-a4ME8Uju.d.ts} +40 -2
- package/dist/util/doImport.js +2 -2
- package/dist/util/doImport.js.map +1 -1
- package/dist/util/environment/setupBrowserStubs.js +1 -1
- package/dist/util/environment/setupBrowserStubs.js.map +1 -1
- package/dist/util/loadStudioCliTooling.js +55 -0
- package/dist/util/loadStudioCliTooling.js.map +1 -0
- package/dist/util/readImageFile.js +50 -0
- package/dist/util/readImageFile.js.map +1 -0
- package/package.json +15 -12
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
interface ImageFile {
|
|
3
|
+
contentType: string;
|
|
4
|
+
image: Buffer;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Read an image file to upload, such as an organization's logo. Throws an error a user can act on
|
|
8
|
+
* when the file is missing, isn't a supported image type, or is over 5 MB.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare function readImageFile(filePath: string): Promise<ImageFile>;
|
|
12
|
+
export { type ImageFile, readImageFile };
|
|
13
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/images.ts"],"sourcesContent":["export {type ImageFile, readImageFile} from '../util/readImageFile.js'\n"],"names":["readImageFile"],"mappings":"AAAA,SAAwBA,aAAa,QAAO,2BAA0B"}
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { exitCodes } from "../exitCodes.js";
|
|
|
15
15
|
import { n as createStudioWorker, r as studioWorkerTask, t as tsxWorkerTask } from "../tsxWorkerTask-DQQSOYCZ.js";
|
|
16
16
|
import { a as getCliTelemetry, i as clearCliTelemetry, n as getTelemetryBaseInfo, o as reportCliTraceError, r as CLI_TELEMETRY_SYMBOL, s as setCliTelemetry, t as noopLogger } from "../noopTelemetry-BJRIvASI.js";
|
|
17
17
|
import { a as isCi, i as isInteractive, n as normalizePath, o as importModule, r as isStaging, s as doImport, t as safeStructuredClone } from "../safeStructuredClone-BixYyg4K.js";
|
|
18
|
-
import { a as
|
|
18
|
+
import { a as loadStudioCliTooling, i as StudioCliTooling, n as resolveLocalPackageFrom, o as getLocalPackageDir, r as resolveLocalPackagePath, s as getLocalPackageVersion, t as resolveLocalPackage } from "../resolveLocalPackage-a4ME8Uju.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
21
|
import { i as studioManifestSchema, n as StudioManifest, r as coreAppManifestSchema, t as CoreAppManifest } from "../schemas-Cgl_4hRt.js";
|
|
@@ -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 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 };
|
|
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 StudioCliTooling, 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, loadStudioCliTooling, mockBrowserEnvironment, noopLogger, normalizePath, promisifyWorker, readPackageJson, reportCliTraceError, resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath, safeStructuredClone, setCliTelemetry, setCliUserConfig, studioManifestSchema, studioWorkerTask, subdebug, tryFindStudioConfigPath, tsxWorkerTask };
|
|
51
51
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/_exports/index.js
CHANGED
|
@@ -36,6 +36,7 @@ export { importModule } from '../util/importModule.js';
|
|
|
36
36
|
export { isCi } from '../util/isCi.js';
|
|
37
37
|
export { isInteractive } from '../util/isInteractive.js';
|
|
38
38
|
export { isStaging } from '../util/isStaging.js';
|
|
39
|
+
export { loadStudioCliTooling } from '../util/loadStudioCliTooling.js';
|
|
39
40
|
export { normalizePath } from '../util/normalizePath.js';
|
|
40
41
|
export { promisifyWorker } from '../util/promisifyWorker.js';
|
|
41
42
|
export { readPackageJson } from '../util/readPackageJson.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 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","subdebug","coreAppManifestSchema","studioManifestSchema"],"mappings":"AAAA,uCAAuC;AACvC,mDAAmD;AACnD,+PAA+P;AAC/P,2LAA2L;AAC3L,SACEA,kBAAkB,EAClBC,mBAAmB,QAGd,kBAAiB;AACxB,SACEC,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;AAClE,SACEC,gBAAgB,QAIX,mCAAkC;AAEzC,SAA8BC,cAAc,QAAO,gCAA+B;AAClF,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;AAEpG,SAAQC,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,eAAe,EAAEC,aAAa,QAAO,6BAA4B;AACzE,SACEC,0BAA0B,EAC1BC,wBAAwB,QACnB,wCAAuC;AAC9C,SAAQC,SAAS,QAAO,kBAAiB;AACzC,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,wCAAuC;AAC1F,SAAQC,aAAa,QAAO,kCAAiC;AAC7D,SAAQC,aAAa,QAAoC,sBAAqB;AAC9E,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,mBAAmB,EACnBC,eAAe,QACV,kCAAiC;AACxC,SAAQC,oBAAoB,QAAO,uCAAsC;AACzE,SAAQC,UAAU,QAAO,gCAA+B;AAOxD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,sBAAsB,QAAO,gDAA+C;AACpF,SAAQC,kBAAkB,EAAEC,sBAAsB,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
|
+
{"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 {loadStudioCliTooling, type StudioCliTooling} from '../util/loadStudioCliTooling.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","loadStudioCliTooling","normalizePath","promisifyWorker","readPackageJson","resolveLocalPackage","resolveLocalPackageFrom","resolveLocalPackagePath","safeStructuredClone","colorizeJson","getTimer","debug","subdebug","coreAppManifestSchema","studioManifestSchema"],"mappings":"AAAA,uCAAuC;AACvC,mDAAmD;AACnD,+PAA+P;AAC/P,2LAA2L;AAC3L,SACEA,kBAAkB,EAClBC,mBAAmB,QAGd,kBAAiB;AACxB,SACEC,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;AAClE,SACEC,gBAAgB,QAIX,mCAAkC;AAEzC,SAA8BC,cAAc,QAAO,gCAA+B;AAClF,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;AAEpG,SAAQC,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,eAAe,EAAEC,aAAa,QAAO,6BAA4B;AACzE,SACEC,0BAA0B,EAC1BC,wBAAwB,QACnB,wCAAuC;AAC9C,SAAQC,SAAS,QAAO,kBAAiB;AACzC,SAAQC,kBAAkB,EAAEC,gBAAgB,QAAO,wCAAuC;AAC1F,SAAQC,aAAa,QAAO,kCAAiC;AAC7D,SAAQC,aAAa,QAAoC,sBAAqB;AAC9E,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,mBAAmB,EACnBC,eAAe,QACV,kCAAiC;AACxC,SAAQC,oBAAoB,QAAO,uCAAsC;AACzE,SAAQC,UAAU,QAAO,gCAA+B;AAOxD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,sBAAsB,QAAO,gDAA+C;AACpF,SAAQC,kBAAkB,EAAEC,sBAAsB,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,oBAAoB,QAA8B,kCAAiC;AAC3F,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,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as loadStudioCliTooling, i as StudioCliTooling, n as resolveLocalPackageFrom, o as getLocalPackageDir, r as resolveLocalPackagePath, s as getLocalPackageVersion, t as resolveLocalPackage } from "../resolveLocalPackage-a4ME8Uju.js";
|
|
2
2
|
import { n as ReadPackageJsonOptions, r as readPackageJson, t as PackageJson } from "../readPackageJson-Cr_lbjVR.js";
|
|
3
3
|
/**
|
|
4
4
|
* Runtime-detectable package managers (excludes 'manual' which is a UI-only choice).
|
|
@@ -26,5 +26,5 @@ declare function getBinCommand(options?: {
|
|
|
26
26
|
bin?: string;
|
|
27
27
|
userAgent?: string;
|
|
28
28
|
}): string;
|
|
29
|
-
export { type DetectedPackageManager, type PackageJson, type ReadPackageJsonOptions, getBinCommand, getLocalPackageDir, getLocalPackageVersion, getRunningPackageManager, getYarnMajorVersion, readPackageJson, resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath };
|
|
29
|
+
export { type DetectedPackageManager, type PackageJson, type ReadPackageJsonOptions, type StudioCliTooling, getBinCommand, getLocalPackageDir, getLocalPackageVersion, getRunningPackageManager, getYarnMajorVersion, loadStudioCliTooling, readPackageJson, resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath };
|
|
30
30
|
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getLocalPackageDir, getLocalPackageVersion } from '../util/getLocalPackageVersion.js';
|
|
2
|
+
export { loadStudioCliTooling } from '../util/loadStudioCliTooling.js';
|
|
2
3
|
export { getBinCommand, getRunningPackageManager, getYarnMajorVersion } from '../util/packageManager.js';
|
|
3
4
|
export { readPackageJson } from '../util/readPackageJson.js';
|
|
4
5
|
export { resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath } from '../util/resolveLocalPackage.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/package-manager.ts"],"sourcesContent":["export {getLocalPackageDir, getLocalPackageVersion} from '../util/getLocalPackageVersion.js'\nexport {\n type DetectedPackageManager,\n getBinCommand,\n getRunningPackageManager,\n getYarnMajorVersion,\n} from '../util/packageManager.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'\n"],"names":["getLocalPackageDir","getLocalPackageVersion","getBinCommand","getRunningPackageManager","getYarnMajorVersion","readPackageJson","resolveLocalPackage","resolveLocalPackageFrom","resolveLocalPackagePath"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,sBAAsB,QAAO,oCAAmC;AAC5F,SAEEC,aAAa,EACbC,wBAAwB,EACxBC,mBAAmB,QACd,4BAA2B;AAClC,SAEEC,eAAe,QAEV,6BAA4B;AACnC,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,QAClB,iCAAgC"}
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/package-manager.ts"],"sourcesContent":["export {getLocalPackageDir, getLocalPackageVersion} from '../util/getLocalPackageVersion.js'\nexport {loadStudioCliTooling, type StudioCliTooling} from '../util/loadStudioCliTooling.js'\nexport {\n type DetectedPackageManager,\n getBinCommand,\n getRunningPackageManager,\n getYarnMajorVersion,\n} from '../util/packageManager.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'\n"],"names":["getLocalPackageDir","getLocalPackageVersion","loadStudioCliTooling","getBinCommand","getRunningPackageManager","getYarnMajorVersion","readPackageJson","resolveLocalPackage","resolveLocalPackageFrom","resolveLocalPackagePath"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,sBAAsB,QAAO,oCAAmC;AAC5F,SAAQC,oBAAoB,QAA8B,kCAAiC;AAC3F,SAEEC,aAAa,EACbC,wBAAwB,EACxBC,mBAAmB,QACd,4BAA2B;AAClC,SAEEC,eAAe,QAEV,6BAA4B;AACnC,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,QAClB,iCAAgC"}
|
|
@@ -9,10 +9,11 @@ interface UndeployApplicationTarget extends UndeployTargetDetails {
|
|
|
9
9
|
deletes: 'application';
|
|
10
10
|
id: string;
|
|
11
11
|
}
|
|
12
|
-
/** An undeploy that deletes an installation's
|
|
12
|
+
/** An undeploy that deletes a deployed config, such as an installation's or the organization's Dashboard configuration. */
|
|
13
13
|
interface UndeployConfigTarget extends UndeployTargetDetails {
|
|
14
14
|
deletes: 'config';
|
|
15
15
|
id: null;
|
|
16
|
+
organizationId: string;
|
|
16
17
|
}
|
|
17
18
|
interface UndeployTargetDetails {
|
|
18
19
|
title: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["/**\n * What an undeploy deletes, resolved once and read by every report — the\n * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —\n * so the human and machine outputs can't drift.\n */\nexport type UndeployTarget = UndeployApplicationTarget | UndeployConfigTarget\n\n/** An undeploy that deletes the application, along with all its deployments. */\nexport interface UndeployApplicationTarget extends UndeployTargetDetails {\n deletes: 'application'\n id: string\n}\n\n/** An undeploy that deletes an installation's
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["/**\n * What an undeploy deletes, resolved once and read by every report — the\n * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —\n * so the human and machine outputs can't drift.\n */\nexport type UndeployTarget = UndeployApplicationTarget | UndeployConfigTarget\n\n/** An undeploy that deletes the application, along with all its deployments. */\nexport interface UndeployApplicationTarget extends UndeployTargetDetails {\n deletes: 'application'\n id: string\n}\n\n/** An undeploy that deletes a deployed config, such as an installation's or the organization's Dashboard configuration. */\nexport interface UndeployConfigTarget extends UndeployTargetDetails {\n deletes: 'config'\n id: null\n organizationId: string\n}\n\ninterface UndeployTargetDetails {\n title: string | null\n type: 'coreApp' | 'studio'\n url: string | null\n\n application?: object\n payload?: UndeployPayload\n /** Human-report lines only; never serialized. */\n summary?: string[]\n}\n\n/** Collected locally, so a dry run reports it too. */\nexport interface UndeployPayload {\n /** The configured `deployment.appId`; `null` when none is set. */\n appId: string | null\n type: 'coreApp' | 'studio'\n\n /** Media-library config summary. */\n config?: string\n services?: object[]\n views?: object[]\n}\n\nexport type UndeployTargetResolution<TTarget extends UndeployTarget = UndeployTarget> =\n | {message: string; solution?: string; type: 'none'}\n | {target: TTarget; type: 'found'}\n\n/**\n * The parts of an undeploy that differ per application backend. The shared\n * sequence — mode selection, target reporting, confirmation, error handling —\n * lives in the host CLI's runner; adapters only resolve and delete.\n */\nexport interface UndeployAdapter<TTarget extends UndeployTarget = UndeployTarget> {\n /** Resolves what an undeploy would delete; read-only. */\n resolveTarget(): Promise<UndeployTargetResolution<TTarget>>\n type: 'coreApp' | 'studio'\n /** Deletes the target — the only mutating step, never run on a dry run. */\n undeploy(target: TTarget): Promise<void>\n}\n"],"names":[],"mappings":"AAAA;;;;CAIC,GA2CD;;;;CAIC,GACD,WAMC"}
|
|
@@ -3,7 +3,7 @@ import { dirname } from 'node:path';
|
|
|
3
3
|
import { isMainThread } from 'node:worker_threads';
|
|
4
4
|
import { subdebug } from '../../_exports/debug.js';
|
|
5
5
|
import { doImport } from '../../util/doImport.js';
|
|
6
|
-
import {
|
|
6
|
+
import { loadStudioCliTooling } from '../../util/loadStudioCliTooling.js';
|
|
7
7
|
import { findStudioConfigPath } from '../util/findStudioConfigPath.js';
|
|
8
8
|
import { isStudioConfig } from './isStudioConfig.js';
|
|
9
9
|
const debug = subdebug('worker:getStudioWorkspaces');
|
|
@@ -34,10 +34,7 @@ const debug = subdebug('worker:getStudioWorkspaces');
|
|
|
34
34
|
}
|
|
35
35
|
const workDir = dirname(configPath);
|
|
36
36
|
debug('Work dir %s', workDir);
|
|
37
|
-
const
|
|
38
|
-
if (typeof resolveConfig !== 'function') {
|
|
39
|
-
throw new TypeError('Expected `resolveConfig` from `sanity` to be a function');
|
|
40
|
-
}
|
|
37
|
+
const tooling = await loadStudioCliTooling(workDir);
|
|
41
38
|
// We will also want to stub out some configuration - we don't need to resolve the
|
|
42
39
|
// users' logged in state, for instance - so let's disable the auth implementation.
|
|
43
40
|
const rawWorkspaces = Array.isArray(config) ? config : [
|
|
@@ -49,10 +46,10 @@ const debug = subdebug('worker:getStudioWorkspaces');
|
|
|
49
46
|
];
|
|
50
47
|
// Imported lazily: rxjs and `@sanity/client` are only needed here, but this
|
|
51
48
|
// module is reachable from the `@sanity/cli-core` barrel that every command loads.
|
|
52
|
-
const [{
|
|
53
|
-
// eslint-disable-next-line no-restricted-syntax -- package import, not a file path
|
|
49
|
+
const [{ of }, { getEmptyAuth }] = await Promise.all([
|
|
50
|
+
// eslint-disable-next-line eslint-js/no-restricted-syntax -- package import, not a file path
|
|
54
51
|
import('rxjs'),
|
|
55
|
-
// eslint-disable-next-line no-restricted-syntax -- static relative import, not a user file path
|
|
52
|
+
// eslint-disable-next-line eslint-js/no-restricted-syntax -- static relative import, not a user file path
|
|
56
53
|
import('../../util/getEmptyAuth.js')
|
|
57
54
|
]);
|
|
58
55
|
const emptyAuth = {
|
|
@@ -63,7 +60,7 @@ const debug = subdebug('worker:getStudioWorkspaces');
|
|
|
63
60
|
auth: emptyAuth
|
|
64
61
|
}));
|
|
65
62
|
debug('Unauthed workspaces %o', unauthedWorkspaces);
|
|
66
|
-
return
|
|
63
|
+
return tooling.resolveWorkspaces(unauthedWorkspaces);
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
//# sourceMappingURL=getStudioWorkspaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {loadStudioCliTooling} from '../../util/loadStudioCliTooling.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\nconst debug = subdebug('worker:getStudioWorkspaces')\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * NOTE: This function should only be called from a worker thread.\n *\n * @param configPath - The path to the studio config\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n if (isMainThread) {\n throw new Error('getStudioWorkspaces should only be called from a worker thread')\n }\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n debug('Finding studio config path %s', configPath)\n const mod = await doImport(configPath)\n // Named exports like `projectId` can make the module itself look like a config\n const config = 'default' in mod && isStudioConfig(mod.default) ? mod.default : mod\n\n debug('Imported config %o', config)\n if (!isStudioConfig(config)) {\n debug('Invalid studio config format in \"%s\"', configPath)\n throw new TypeError(`Invalid studio config format in \"${configPath}\"`)\n }\n\n const workDir = dirname(configPath)\n debug('Work dir %s', workDir)\n const tooling = await loadStudioCliTooling(workDir)\n\n // We will also want to stub out some configuration - we don't need to resolve the\n // users' logged in state, for instance - so let's disable the auth implementation.\n const rawWorkspaces = Array.isArray(config)\n ? config\n : [{...config, basePath: config.basePath || '/', name: config.name || 'default'}]\n\n // Imported lazily: rxjs and `@sanity/client` are only needed here, but this\n // module is reachable from the `@sanity/cli-core` barrel that every command loads.\n const [{of}, {getEmptyAuth}] = await Promise.all([\n // eslint-disable-next-line eslint-js/no-restricted-syntax -- package import, not a file path\n import('rxjs'),\n // eslint-disable-next-line eslint-js/no-restricted-syntax -- static relative import, not a user file path\n import('../../util/getEmptyAuth.js'),\n ])\n const emptyAuth = {state: of(getEmptyAuth())}\n\n const unauthedWorkspaces = rawWorkspaces.map((workspace) => ({\n ...workspace,\n auth: emptyAuth,\n }))\n\n debug('Unauthed workspaces %o', unauthedWorkspaces)\n\n return tooling.resolveWorkspaces(unauthedWorkspaces)\n}\n"],"names":["stat","dirname","isMainThread","subdebug","doImport","loadStudioCliTooling","findStudioConfigPath","isStudioConfig","debug","getStudioWorkspaces","configPath","Error","isDirectory","mod","config","default","TypeError","workDir","tooling","rawWorkspaces","Array","isArray","basePath","name","of","getEmptyAuth","Promise","all","emptyAuth","state","unauthedWorkspaces","map","workspace","auth","resolveWorkspaces"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,OAAO,QAAO,YAAW;AACjC,SAAQC,YAAY,QAAO,sBAAqB;AAIhD,SAAQC,QAAQ,QAAO,0BAAyB;AAChD,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,oBAAoB,QAAO,qCAAoC;AACvE,SAAQC,oBAAoB,QAAO,kCAAiC;AACpE,SAAQC,cAAc,QAAO,sBAAqB;AAElD,MAAMC,QAAQL,SAAS;AAEvB;;;;;;;;CAQC,GACD,OAAO,eAAeM,oBAAoBC,UAAkB;IAC1D,IAAIR,cAAc;QAChB,MAAM,IAAIS,MAAM;IAClB;IACA,MAAMC,cAAc,AAAC,CAAA,MAAMZ,KAAKU,WAAU,EAAGE,WAAW;IACxD,IAAIA,aAAa;QACfF,aAAa,MAAMJ,qBAAqBI;IAC1C;IACAF,MAAM,iCAAiCE;IACvC,MAAMG,MAAM,MAAMT,SAASM;IAC3B,+EAA+E;IAC/E,MAAMI,SAAS,aAAaD,OAAON,eAAeM,IAAIE,OAAO,IAAIF,IAAIE,OAAO,GAAGF;IAE/EL,MAAM,sBAAsBM;IAC5B,IAAI,CAACP,eAAeO,SAAS;QAC3BN,MAAM,wCAAwCE;QAC9C,MAAM,IAAIM,UAAU,CAAC,iCAAiC,EAAEN,WAAW,CAAC,CAAC;IACvE;IAEA,MAAMO,UAAUhB,QAAQS;IACxBF,MAAM,eAAeS;IACrB,MAAMC,UAAU,MAAMb,qBAAqBY;IAE3C,kFAAkF;IAClF,mFAAmF;IACnF,MAAME,gBAAgBC,MAAMC,OAAO,CAACP,UAChCA,SACA;QAAC;YAAC,GAAGA,MAAM;YAAEQ,UAAUR,OAAOQ,QAAQ,IAAI;YAAKC,MAAMT,OAAOS,IAAI,IAAI;QAAS;KAAE;IAEnF,4EAA4E;IAC5E,mFAAmF;IACnF,MAAM,CAAC,EAACC,EAAE,EAAC,EAAE,EAACC,YAAY,EAAC,CAAC,GAAG,MAAMC,QAAQC,GAAG,CAAC;QAC/C,6FAA6F;QAC7F,MAAM,CAAC;QACP,0GAA0G;QAC1G,MAAM,CAAC;KACR;IACD,MAAMC,YAAY;QAACC,OAAOL,GAAGC;IAAe;IAE5C,MAAMK,qBAAqBX,cAAcY,GAAG,CAAC,CAACC,YAAe,CAAA;YAC3D,GAAGA,SAAS;YACZC,MAAML;QACR,CAAA;IAEApB,MAAM,0BAA0BsB;IAEhC,OAAOZ,QAAQgB,iBAAiB,CAACJ;AACnC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SchemaValidationProblemGroup, StudioManifest, Workspace, createDefaultIcon, createSchema, generateStudioManifest, resolveConfig } from "sanity";
|
|
1
2
|
/**
|
|
2
3
|
* Get the version of a package installed locally.
|
|
3
4
|
*
|
|
@@ -18,6 +19,43 @@ declare function getLocalPackageVersion(moduleName: string, workDir: string): Pr
|
|
|
18
19
|
* @internal
|
|
19
20
|
*/
|
|
20
21
|
declare function getLocalPackageDir(moduleName: string, workDir: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* The operations the CLI needs from the studio to resolve workspaces, compile schemas and
|
|
24
|
+
* generate manifests.
|
|
25
|
+
*
|
|
26
|
+
* Studios provide these through `getStudioCliTooling()` from `sanity/cli`, so the CLI does not
|
|
27
|
+
* depend on where the underlying functions are exported from inside `sanity`. Studios that do
|
|
28
|
+
* not provide it yet are served by {@link loadStudioCliTooling}'s fallback to the root `sanity`
|
|
29
|
+
* exports.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
interface StudioCliTooling {
|
|
34
|
+
/** Compiles a schema definition. Replaces `createSchema()`. */
|
|
35
|
+
compileSchema: (definition: Parameters<typeof createSchema>[0]) => ReturnType<typeof createSchema>;
|
|
36
|
+
/** Creates the icon used for a workspace or tool that does not define one. */
|
|
37
|
+
createDefaultIcon: (title: string, subtitle: string) => ReturnType<typeof createDefaultIcon>;
|
|
38
|
+
/** Generates the studio manifest for resolved workspaces. */
|
|
39
|
+
generateStudioManifest: (options: Parameters<typeof generateStudioManifest>[0]) => Promise<StudioManifest>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the validation problem groups carried by a schema error thrown while resolving or
|
|
42
|
+
* compiling a schema, or `undefined` if `error` is not a schema error.
|
|
43
|
+
*/
|
|
44
|
+
getSchemaValidation: (error: unknown) => SchemaValidationProblemGroup[] | undefined;
|
|
45
|
+
/** Resolves workspace configs into workspaces. Replaces `resolveConfig()`. */
|
|
46
|
+
resolveWorkspaces: (workspaces: Parameters<typeof resolveConfig>[0]) => Promise<Workspace[]>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Loads the {@link StudioCliTooling} from the studio installed relative to `workDir`.
|
|
50
|
+
*
|
|
51
|
+
* Uses `getStudioCliTooling()` from `sanity/cli` when the studio provides it. Otherwise falls
|
|
52
|
+
* back to the functions exported from the root `sanity` entry, which is where studios that
|
|
53
|
+
* predate the entry export them.
|
|
54
|
+
*
|
|
55
|
+
* @param workDir - The working directory to resolve `sanity` from
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
declare function loadStudioCliTooling(workDir: string): Promise<StudioCliTooling>;
|
|
21
59
|
/**
|
|
22
60
|
* Resolves and imports a package from the local project's node_modules,
|
|
23
61
|
* relative to the given working directory. This avoids circular dependencies
|
|
@@ -74,5 +112,5 @@ declare function resolveLocalPackagePath(packageName: string, workDir: string):
|
|
|
74
112
|
* @internal
|
|
75
113
|
*/
|
|
76
114
|
declare function resolveLocalPackageFrom<T = unknown>(packageName: string, parentUrl: URL): Promise<T>;
|
|
77
|
-
export {
|
|
78
|
-
//# sourceMappingURL=resolveLocalPackage-
|
|
115
|
+
export { loadStudioCliTooling as a, StudioCliTooling as i, resolveLocalPackageFrom as n, getLocalPackageDir as o, resolveLocalPackagePath as r, getLocalPackageVersion as s, resolveLocalPackage as t };
|
|
116
|
+
//# sourceMappingURL=resolveLocalPackage-a4ME8Uju.d.ts.map
|
package/dist/util/doImport.js
CHANGED
|
@@ -9,8 +9,8 @@ import { pathToFileURL } from 'node:url';
|
|
|
9
9
|
// Absolute paths in windows are not valid URLs and are not supported by import().
|
|
10
10
|
// We need to convert the path to a file URL.
|
|
11
11
|
// See: https://github.com/nodejs/node/issues/31710
|
|
12
|
-
const url =
|
|
13
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
12
|
+
const url = source.startsWith('file://') ? source : pathToFileURL(source).href;
|
|
13
|
+
// eslint-disable-next-line eslint-js/no-restricted-syntax
|
|
14
14
|
return import(/* @vite-ignore */ url);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/doImport.ts"],"sourcesContent":["// Only file that should be using dynamic import\nimport {pathToFileURL} from 'node:url'\n\n/**\n * This function is a replacement for built in dynamic import\n * This handles the case for windows file paths especially for absolute paths.\n *\n * @param source - File path\n */\nexport function doImport(source: string) {\n // Absolute paths in windows are not valid URLs and are not supported by import().\n // We need to convert the path to a file URL.\n // See: https://github.com/nodejs/node/issues/31710\n const url =
|
|
1
|
+
{"version":3,"sources":["../../src/util/doImport.ts"],"sourcesContent":["// Only file that should be using dynamic import\nimport {pathToFileURL} from 'node:url'\n\n/**\n * This function is a replacement for built in dynamic import\n * This handles the case for windows file paths especially for absolute paths.\n *\n * @param source - File path\n */\nexport function doImport(source: string) {\n // Absolute paths in windows are not valid URLs and are not supported by import().\n // We need to convert the path to a file URL.\n // See: https://github.com/nodejs/node/issues/31710\n const url = source.startsWith('file://') ? source : pathToFileURL(source).href\n // eslint-disable-next-line eslint-js/no-restricted-syntax\n return import(\n /* @vite-ignore */\n url\n )\n}\n"],"names":["pathToFileURL","doImport","source","url","startsWith","href"],"mappings":"AAAA,gDAAgD;AAChD,SAAQA,aAAa,QAAO,WAAU;AAEtC;;;;;CAKC,GACD,OAAO,SAASC,SAASC,MAAc;IACrC,kFAAkF;IAClF,6CAA6C;IAC7C,mDAAmD;IACnD,MAAMC,MAAMD,OAAOE,UAAU,CAAC,aAAaF,SAASF,cAAcE,QAAQG,IAAI;IAC9E,0DAA0D;IAC1D,OAAO,MAAM,CACX,gBAAgB,GAChBF;AAEJ"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// even if Node provides them, so realm identity stays consistent.
|
|
19
19
|
// Imported lazily: `stubs.js` pulls in JSDOM (~600 modules), and this module
|
|
20
20
|
// is reachable from the `@sanity/cli-core` barrel that every command loads.
|
|
21
|
-
// eslint-disable-next-line no-restricted-syntax -- static relative import, not a user file path
|
|
21
|
+
// eslint-disable-next-line eslint-js/no-restricted-syntax -- static relative import, not a user file path
|
|
22
22
|
const { getBrowserStubs } = await import('./stubs.js');
|
|
23
23
|
const stubs = getBrowserStubs();
|
|
24
24
|
const mockedGlobalThis = globalThis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/environment/setupBrowserStubs.ts"],"sourcesContent":["/**\n * Sets up browser globals (window, document, etc.) in the global scope.\n *\n * This is used by both mockBrowserEnvironment (for child processes) and\n * studioWorkerLoader (for worker threads) to provide a browser-like environment.\n *\n * @returns A cleanup function that removes the injected globals\n * @internal\n */\nexport async function setupBrowserStubs(): Promise<() => void> {\n // Guard against double-registering\n if (globalThis.window && '__mockedBySanity' in globalThis.window) {\n return () => {\n /* intentional noop - already mocked */\n }\n }\n\n // Inject browser stubs into global scope. `getBrowserStubs()` has already\n // decided what to inject — including a small set of keys (e.g.\n // `localStorage`/`sessionStorage`/`Storage`) that we want to take from JSDOM\n // even if Node provides them, so realm identity stays consistent.\n // Imported lazily: `stubs.js` pulls in JSDOM (~600 modules), and this module\n // is reachable from the `@sanity/cli-core` barrel that every command loads.\n // eslint-disable-next-line no-restricted-syntax -- static relative import, not a user file path\n const {getBrowserStubs} = await import('./stubs.js')\n const stubs = getBrowserStubs()\n const mockedGlobalThis: Record<string, unknown> = globalThis\n const stubbedKeys: string[] = []\n const originalDescriptors = new Map<string, PropertyDescriptor>()\n\n for (const key of Object.keys(stubs)) {\n // Snapshot via descriptor to avoid triggering getters (e.g. Node 26's\n // `localStorage` getter logs an ExperimentalWarning on read).\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, key)\n if (descriptor) {\n originalDescriptors.set(key, descriptor)\n // Assignment would throw for getter-only accessors (e.g. Node 26's\n // `localStorage`/`sessionStorage`), so replace the property outright.\n Object.defineProperty(globalThis, key, {\n configurable: true,\n enumerable: descriptor.enumerable,\n value: stubs[key],\n writable: true,\n })\n } else {\n mockedGlobalThis[key] = stubs[key]\n }\n stubbedKeys.push(key)\n }\n\n // Add marker to window to detect double-mocking\n if (globalThis.window) {\n ;(globalThis.window as unknown as Record<string, unknown>).__mockedBySanity = true\n }\n\n // Return cleanup function\n return () => {\n // Remove marker before deleting window\n if (globalThis.window) {\n delete (globalThis.window as unknown as Record<string, unknown>).__mockedBySanity\n }\n\n for (const key of stubbedKeys) {\n const descriptor = originalDescriptors.get(key)\n if (descriptor) {\n Object.defineProperty(globalThis, key, descriptor)\n } else {\n delete mockedGlobalThis[key]\n }\n }\n }\n}\n"],"names":["setupBrowserStubs","globalThis","window","getBrowserStubs","stubs","mockedGlobalThis","stubbedKeys","originalDescriptors","Map","key","Object","keys","descriptor","getOwnPropertyDescriptor","set","defineProperty","configurable","enumerable","value","writable","push","__mockedBySanity","get"],"mappings":"AAAA;;;;;;;;CAQC,GACD,OAAO,eAAeA;IACpB,mCAAmC;IACnC,IAAIC,WAAWC,MAAM,IAAI,sBAAsBD,WAAWC,MAAM,EAAE;QAChE,OAAO;QACL,qCAAqC,GACvC;IACF;IAEA,0EAA0E;IAC1E,+DAA+D;IAC/D,6EAA6E;IAC7E,kEAAkE;IAClE,6EAA6E;IAC7E,4EAA4E;IAC5E,
|
|
1
|
+
{"version":3,"sources":["../../../src/util/environment/setupBrowserStubs.ts"],"sourcesContent":["/**\n * Sets up browser globals (window, document, etc.) in the global scope.\n *\n * This is used by both mockBrowserEnvironment (for child processes) and\n * studioWorkerLoader (for worker threads) to provide a browser-like environment.\n *\n * @returns A cleanup function that removes the injected globals\n * @internal\n */\nexport async function setupBrowserStubs(): Promise<() => void> {\n // Guard against double-registering\n if (globalThis.window && '__mockedBySanity' in globalThis.window) {\n return () => {\n /* intentional noop - already mocked */\n }\n }\n\n // Inject browser stubs into global scope. `getBrowserStubs()` has already\n // decided what to inject — including a small set of keys (e.g.\n // `localStorage`/`sessionStorage`/`Storage`) that we want to take from JSDOM\n // even if Node provides them, so realm identity stays consistent.\n // Imported lazily: `stubs.js` pulls in JSDOM (~600 modules), and this module\n // is reachable from the `@sanity/cli-core` barrel that every command loads.\n // eslint-disable-next-line eslint-js/no-restricted-syntax -- static relative import, not a user file path\n const {getBrowserStubs} = await import('./stubs.js')\n const stubs = getBrowserStubs()\n const mockedGlobalThis: Record<string, unknown> = globalThis\n const stubbedKeys: string[] = []\n const originalDescriptors = new Map<string, PropertyDescriptor>()\n\n for (const key of Object.keys(stubs)) {\n // Snapshot via descriptor to avoid triggering getters (e.g. Node 26's\n // `localStorage` getter logs an ExperimentalWarning on read).\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, key)\n if (descriptor) {\n originalDescriptors.set(key, descriptor)\n // Assignment would throw for getter-only accessors (e.g. Node 26's\n // `localStorage`/`sessionStorage`), so replace the property outright.\n Object.defineProperty(globalThis, key, {\n configurable: true,\n enumerable: descriptor.enumerable,\n value: stubs[key],\n writable: true,\n })\n } else {\n mockedGlobalThis[key] = stubs[key]\n }\n stubbedKeys.push(key)\n }\n\n // Add marker to window to detect double-mocking\n if (globalThis.window) {\n ;(globalThis.window as unknown as Record<string, unknown>).__mockedBySanity = true\n }\n\n // Return cleanup function\n return () => {\n // Remove marker before deleting window\n if (globalThis.window) {\n delete (globalThis.window as unknown as Record<string, unknown>).__mockedBySanity\n }\n\n for (const key of stubbedKeys) {\n const descriptor = originalDescriptors.get(key)\n if (descriptor) {\n Object.defineProperty(globalThis, key, descriptor)\n } else {\n delete mockedGlobalThis[key]\n }\n }\n }\n}\n"],"names":["setupBrowserStubs","globalThis","window","getBrowserStubs","stubs","mockedGlobalThis","stubbedKeys","originalDescriptors","Map","key","Object","keys","descriptor","getOwnPropertyDescriptor","set","defineProperty","configurable","enumerable","value","writable","push","__mockedBySanity","get"],"mappings":"AAAA;;;;;;;;CAQC,GACD,OAAO,eAAeA;IACpB,mCAAmC;IACnC,IAAIC,WAAWC,MAAM,IAAI,sBAAsBD,WAAWC,MAAM,EAAE;QAChE,OAAO;QACL,qCAAqC,GACvC;IACF;IAEA,0EAA0E;IAC1E,+DAA+D;IAC/D,6EAA6E;IAC7E,kEAAkE;IAClE,6EAA6E;IAC7E,4EAA4E;IAC5E,0GAA0G;IAC1G,MAAM,EAACC,eAAe,EAAC,GAAG,MAAM,MAAM,CAAC;IACvC,MAAMC,QAAQD;IACd,MAAME,mBAA4CJ;IAClD,MAAMK,cAAwB,EAAE;IAChC,MAAMC,sBAAsB,IAAIC;IAEhC,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAACP,OAAQ;QACpC,sEAAsE;QACtE,8DAA8D;QAC9D,MAAMQ,aAAaF,OAAOG,wBAAwB,CAACZ,YAAYQ;QAC/D,IAAIG,YAAY;YACdL,oBAAoBO,GAAG,CAACL,KAAKG;YAC7B,mEAAmE;YACnE,sEAAsE;YACtEF,OAAOK,cAAc,CAACd,YAAYQ,KAAK;gBACrCO,cAAc;gBACdC,YAAYL,WAAWK,UAAU;gBACjCC,OAAOd,KAAK,CAACK,IAAI;gBACjBU,UAAU;YACZ;QACF,OAAO;YACLd,gBAAgB,CAACI,IAAI,GAAGL,KAAK,CAACK,IAAI;QACpC;QACAH,YAAYc,IAAI,CAACX;IACnB;IAEA,gDAAgD;IAChD,IAAIR,WAAWC,MAAM,EAAE;;QACnBD,WAAWC,MAAM,CAAwCmB,gBAAgB,GAAG;IAChF;IAEA,0BAA0B;IAC1B,OAAO;QACL,uCAAuC;QACvC,IAAIpB,WAAWC,MAAM,EAAE;YACrB,OAAO,AAACD,WAAWC,MAAM,CAAwCmB,gBAAgB;QACnF;QAEA,KAAK,MAAMZ,OAAOH,YAAa;YAC7B,MAAMM,aAAaL,oBAAoBe,GAAG,CAACb;YAC3C,IAAIG,YAAY;gBACdF,OAAOK,cAAc,CAACd,YAAYQ,KAAKG;YACzC,OAAO;gBACL,OAAOP,gBAAgB,CAACI,IAAI;YAC9B;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { subdebug } from '../_exports/debug.js';
|
|
2
|
+
import { resolveLocalPackage } from './resolveLocalPackage.js';
|
|
3
|
+
const debug = subdebug('loadStudioCliTooling');
|
|
4
|
+
/**
|
|
5
|
+
* Loads the {@link StudioCliTooling} from the studio installed relative to `workDir`.
|
|
6
|
+
*
|
|
7
|
+
* Uses `getStudioCliTooling()` from `sanity/cli` when the studio provides it. Otherwise falls
|
|
8
|
+
* back to the functions exported from the root `sanity` entry, which is where studios that
|
|
9
|
+
* predate the entry export them.
|
|
10
|
+
*
|
|
11
|
+
* @param workDir - The working directory to resolve `sanity` from
|
|
12
|
+
* @internal
|
|
13
|
+
*/ export async function loadStudioCliTooling(workDir) {
|
|
14
|
+
const getStudioCliTooling = await resolveGetStudioCliTooling(workDir);
|
|
15
|
+
if (getStudioCliTooling) {
|
|
16
|
+
debug('Using getStudioCliTooling() from sanity/cli');
|
|
17
|
+
return getStudioCliTooling();
|
|
18
|
+
}
|
|
19
|
+
debug('sanity/cli has no getStudioCliTooling(), using exports from sanity');
|
|
20
|
+
return createToolingFromRootExports(workDir);
|
|
21
|
+
}
|
|
22
|
+
async function resolveGetStudioCliTooling(workDir) {
|
|
23
|
+
try {
|
|
24
|
+
const sanityCli = await resolveLocalPackage('sanity/cli', workDir);
|
|
25
|
+
return typeof sanityCli.getStudioCliTooling === 'function' ? sanityCli.getStudioCliTooling : undefined;
|
|
26
|
+
} catch (err) {
|
|
27
|
+
debug('Failed to load sanity/cli: %o', err);
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function createToolingFromRootExports(workDir) {
|
|
32
|
+
const sanity = await resolveLocalPackage('sanity', workDir);
|
|
33
|
+
return {
|
|
34
|
+
compileSchema: (definition)=>requireExport(sanity.createSchema, 'createSchema')(definition),
|
|
35
|
+
createDefaultIcon: (title, subtitle)=>requireExport(sanity.createDefaultIcon, 'createDefaultIcon')(title, subtitle),
|
|
36
|
+
generateStudioManifest: (options)=>requireExport(sanity.generateStudioManifest, 'generateStudioManifest')(options),
|
|
37
|
+
getSchemaValidation: (error)=>typeof sanity.SchemaError === 'function' && error instanceof sanity.SchemaError ? error.schema._validation : undefined,
|
|
38
|
+
resolveWorkspaces: async (workspaces)=>{
|
|
39
|
+
const resolve = requireExport(sanity.resolveConfig, 'resolveConfig');
|
|
40
|
+
// Imported lazily: rxjs is only needed here, but this module is reachable from the
|
|
41
|
+
// `@sanity/cli-core` barrel that every command loads.
|
|
42
|
+
// eslint-disable-next-line eslint-js/no-restricted-syntax -- package import, not a file path
|
|
43
|
+
const { firstValueFrom } = await import('rxjs');
|
|
44
|
+
return firstValueFrom(resolve(workspaces));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function requireExport(value, name) {
|
|
49
|
+
if (typeof value !== 'function') {
|
|
50
|
+
throw new TypeError(`Expected \`${name}\` from \`sanity\` to be a function`);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=loadStudioCliTooling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/loadStudioCliTooling.ts"],"sourcesContent":["import {\n type createDefaultIcon,\n type createSchema,\n type generateStudioManifest,\n type resolveConfig,\n type SchemaError,\n type SchemaValidationProblemGroup,\n type StudioManifest,\n type Workspace,\n} from 'sanity'\n\nimport {subdebug} from '../_exports/debug.js'\nimport {resolveLocalPackage} from './resolveLocalPackage.js'\n\nconst debug = subdebug('loadStudioCliTooling')\n\n/**\n * The operations the CLI needs from the studio to resolve workspaces, compile schemas and\n * generate manifests.\n *\n * Studios provide these through `getStudioCliTooling()` from `sanity/cli`, so the CLI does not\n * depend on where the underlying functions are exported from inside `sanity`. Studios that do\n * not provide it yet are served by {@link loadStudioCliTooling}'s fallback to the root `sanity`\n * exports.\n *\n * @internal\n */\nexport interface StudioCliTooling {\n /** Compiles a schema definition. Replaces `createSchema()`. */\n compileSchema: (definition: Parameters<typeof createSchema>[0]) => ReturnType<typeof createSchema>\n\n /** Creates the icon used for a workspace or tool that does not define one. */\n createDefaultIcon: (title: string, subtitle: string) => ReturnType<typeof createDefaultIcon>\n\n /** Generates the studio manifest for resolved workspaces. */\n generateStudioManifest: (\n options: Parameters<typeof generateStudioManifest>[0],\n ) => Promise<StudioManifest>\n\n /**\n * Returns the validation problem groups carried by a schema error thrown while resolving or\n * compiling a schema, or `undefined` if `error` is not a schema error.\n */\n getSchemaValidation: (error: unknown) => SchemaValidationProblemGroup[] | undefined\n\n /** Resolves workspace configs into workspaces. Replaces `resolveConfig()`. */\n resolveWorkspaces: (workspaces: Parameters<typeof resolveConfig>[0]) => Promise<Workspace[]>\n}\n\ninterface LegacySanityExports {\n createDefaultIcon?: StudioCliTooling['createDefaultIcon']\n createSchema?: StudioCliTooling['compileSchema']\n generateStudioManifest?: StudioCliTooling['generateStudioManifest']\n resolveConfig?: (\n workspaces: Parameters<typeof resolveConfig>[0],\n ) => ReturnType<typeof resolveConfig>\n SchemaError?: typeof SchemaError\n}\n\ninterface SanityCliExports {\n getStudioCliTooling?: () => Promise<StudioCliTooling> | StudioCliTooling\n}\n\n/**\n * Loads the {@link StudioCliTooling} from the studio installed relative to `workDir`.\n *\n * Uses `getStudioCliTooling()` from `sanity/cli` when the studio provides it. Otherwise falls\n * back to the functions exported from the root `sanity` entry, which is where studios that\n * predate the entry export them.\n *\n * @param workDir - The working directory to resolve `sanity` from\n * @internal\n */\nexport async function loadStudioCliTooling(workDir: string): Promise<StudioCliTooling> {\n const getStudioCliTooling = await resolveGetStudioCliTooling(workDir)\n if (getStudioCliTooling) {\n debug('Using getStudioCliTooling() from sanity/cli')\n return getStudioCliTooling()\n }\n\n debug('sanity/cli has no getStudioCliTooling(), using exports from sanity')\n return createToolingFromRootExports(workDir)\n}\n\nasync function resolveGetStudioCliTooling(\n workDir: string,\n): Promise<SanityCliExports['getStudioCliTooling']> {\n try {\n const sanityCli = await resolveLocalPackage<SanityCliExports>('sanity/cli', workDir)\n return typeof sanityCli.getStudioCliTooling === 'function'\n ? sanityCli.getStudioCliTooling\n : undefined\n } catch (err) {\n debug('Failed to load sanity/cli: %o', err)\n return undefined\n }\n}\n\nasync function createToolingFromRootExports(workDir: string): Promise<StudioCliTooling> {\n const sanity = await resolveLocalPackage<LegacySanityExports>('sanity', workDir)\n\n return {\n compileSchema: (definition) => requireExport(sanity.createSchema, 'createSchema')(definition),\n createDefaultIcon: (title, subtitle) =>\n requireExport(sanity.createDefaultIcon, 'createDefaultIcon')(title, subtitle),\n generateStudioManifest: (options) =>\n requireExport(sanity.generateStudioManifest, 'generateStudioManifest')(options),\n getSchemaValidation: (error) =>\n typeof sanity.SchemaError === 'function' && error instanceof sanity.SchemaError\n ? error.schema._validation\n : undefined,\n resolveWorkspaces: async (workspaces) => {\n const resolve = requireExport(sanity.resolveConfig, 'resolveConfig')\n // Imported lazily: rxjs is only needed here, but this module is reachable from the\n // `@sanity/cli-core` barrel that every command loads.\n // eslint-disable-next-line eslint-js/no-restricted-syntax -- package import, not a file path\n const {firstValueFrom} = await import('rxjs')\n return firstValueFrom(resolve(workspaces))\n },\n }\n}\n\nfunction requireExport<T>(value: T | undefined, name: string): T {\n if (typeof value !== 'function') {\n throw new TypeError(`Expected \\`${name}\\` from \\`sanity\\` to be a function`)\n }\n return value\n}\n"],"names":["subdebug","resolveLocalPackage","debug","loadStudioCliTooling","workDir","getStudioCliTooling","resolveGetStudioCliTooling","createToolingFromRootExports","sanityCli","undefined","err","sanity","compileSchema","definition","requireExport","createSchema","createDefaultIcon","title","subtitle","generateStudioManifest","options","getSchemaValidation","error","SchemaError","schema","_validation","resolveWorkspaces","workspaces","resolve","resolveConfig","firstValueFrom","value","name","TypeError"],"mappings":"AAWA,SAAQA,QAAQ,QAAO,uBAAsB;AAC7C,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,MAAMC,QAAQF,SAAS;AAiDvB;;;;;;;;;CASC,GACD,OAAO,eAAeG,qBAAqBC,OAAe;IACxD,MAAMC,sBAAsB,MAAMC,2BAA2BF;IAC7D,IAAIC,qBAAqB;QACvBH,MAAM;QACN,OAAOG;IACT;IAEAH,MAAM;IACN,OAAOK,6BAA6BH;AACtC;AAEA,eAAeE,2BACbF,OAAe;IAEf,IAAI;QACF,MAAMI,YAAY,MAAMP,oBAAsC,cAAcG;QAC5E,OAAO,OAAOI,UAAUH,mBAAmB,KAAK,aAC5CG,UAAUH,mBAAmB,GAC7BI;IACN,EAAE,OAAOC,KAAK;QACZR,MAAM,iCAAiCQ;QACvC,OAAOD;IACT;AACF;AAEA,eAAeF,6BAA6BH,OAAe;IACzD,MAAMO,SAAS,MAAMV,oBAAyC,UAAUG;IAExE,OAAO;QACLQ,eAAe,CAACC,aAAeC,cAAcH,OAAOI,YAAY,EAAE,gBAAgBF;QAClFG,mBAAmB,CAACC,OAAOC,WACzBJ,cAAcH,OAAOK,iBAAiB,EAAE,qBAAqBC,OAAOC;QACtEC,wBAAwB,CAACC,UACvBN,cAAcH,OAAOQ,sBAAsB,EAAE,0BAA0BC;QACzEC,qBAAqB,CAACC,QACpB,OAAOX,OAAOY,WAAW,KAAK,cAAcD,iBAAiBX,OAAOY,WAAW,GAC3ED,MAAME,MAAM,CAACC,WAAW,GACxBhB;QACNiB,mBAAmB,OAAOC;YACxB,MAAMC,UAAUd,cAAcH,OAAOkB,aAAa,EAAE;YACpD,mFAAmF;YACnF,sDAAsD;YACtD,6FAA6F;YAC7F,MAAM,EAACC,cAAc,EAAC,GAAG,MAAM,MAAM,CAAC;YACtC,OAAOA,eAAeF,QAAQD;QAChC;IACF;AACF;AAEA,SAASb,cAAiBiB,KAAoB,EAAEC,IAAY;IAC1D,IAAI,OAAOD,UAAU,YAAY;QAC/B,MAAM,IAAIE,UAAU,CAAC,WAAW,EAAED,KAAK,mCAAmC,CAAC;IAC7E;IACA,OAAOD;AACT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { extname } from 'node:path';
|
|
3
|
+
// The image formats Sanity accepts for uploaded images, such as organization logos. Uploads need
|
|
4
|
+
// an image Content-Type, and the CLI has no other source for one.
|
|
5
|
+
const IMAGE_CONTENT_TYPES = {
|
|
6
|
+
'.avif': 'image/avif',
|
|
7
|
+
'.bmp': 'image/bmp',
|
|
8
|
+
'.gif': 'image/gif',
|
|
9
|
+
'.heic': 'image/heic',
|
|
10
|
+
'.heif': 'image/heif',
|
|
11
|
+
'.jpeg': 'image/jpeg',
|
|
12
|
+
'.jpg': 'image/jpeg',
|
|
13
|
+
'.png': 'image/png',
|
|
14
|
+
'.svg': 'image/svg+xml',
|
|
15
|
+
'.tif': 'image/tiff',
|
|
16
|
+
'.tiff': 'image/tiff',
|
|
17
|
+
'.webp': 'image/webp'
|
|
18
|
+
};
|
|
19
|
+
// Matches the upload limit, so a large file fails here instead of after uploading it.
|
|
20
|
+
const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
21
|
+
/**
|
|
22
|
+
* Read an image file to upload, such as an organization's logo. Throws an error a user can act on
|
|
23
|
+
* when the file is missing, isn't a supported image type, or is over 5 MB.
|
|
24
|
+
* @public
|
|
25
|
+
*/ export async function readImageFile(filePath) {
|
|
26
|
+
const contentType = IMAGE_CONTENT_TYPES[extname(filePath).toLowerCase()];
|
|
27
|
+
if (!contentType) {
|
|
28
|
+
throw new Error(`"${filePath}" isn't a supported image type. Use a PNG, JPEG, GIF, WebP, SVG, BMP, TIFF, HEIF or AVIF file.`);
|
|
29
|
+
}
|
|
30
|
+
let stats;
|
|
31
|
+
try {
|
|
32
|
+
stats = await stat(filePath);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
35
|
+
throw new Error(`Couldn't find "${filePath}". Check the path and try again.`, {
|
|
36
|
+
cause: error
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
if (stats.size > MAX_IMAGE_BYTES) {
|
|
42
|
+
throw new Error(`"${filePath}" is larger than 5 MB, the upload limit. Use a smaller image.`);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
contentType,
|
|
46
|
+
image: await readFile(filePath)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=readImageFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/readImageFile.ts"],"sourcesContent":["import {type Stats} from 'node:fs'\nimport {readFile, stat} from 'node:fs/promises'\nimport {extname} from 'node:path'\n\n// The image formats Sanity accepts for uploaded images, such as organization logos. Uploads need\n// an image Content-Type, and the CLI has no other source for one.\nconst IMAGE_CONTENT_TYPES: Record<string, string> = {\n '.avif': 'image/avif',\n '.bmp': 'image/bmp',\n '.gif': 'image/gif',\n '.heic': 'image/heic',\n '.heif': 'image/heif',\n '.jpeg': 'image/jpeg',\n '.jpg': 'image/jpeg',\n '.png': 'image/png',\n '.svg': 'image/svg+xml',\n '.tif': 'image/tiff',\n '.tiff': 'image/tiff',\n '.webp': 'image/webp',\n}\n\n// Matches the upload limit, so a large file fails here instead of after uploading it.\nconst MAX_IMAGE_BYTES = 5 * 1024 * 1024\n\n/** @public */\nexport interface ImageFile {\n contentType: string\n image: Buffer\n}\n\n/**\n * Read an image file to upload, such as an organization's logo. Throws an error a user can act on\n * when the file is missing, isn't a supported image type, or is over 5 MB.\n * @public\n */\nexport async function readImageFile(filePath: string): Promise<ImageFile> {\n const contentType = IMAGE_CONTENT_TYPES[extname(filePath).toLowerCase()]\n if (!contentType) {\n throw new Error(\n `\"${filePath}\" isn't a supported image type. Use a PNG, JPEG, GIF, WebP, SVG, BMP, TIFF, HEIF or AVIF file.`,\n )\n }\n\n let stats: Stats\n try {\n stats = await stat(filePath)\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {\n throw new Error(`Couldn't find \"${filePath}\". Check the path and try again.`, {cause: error})\n }\n throw error\n }\n\n if (stats.size > MAX_IMAGE_BYTES) {\n throw new Error(`\"${filePath}\" is larger than 5 MB, the upload limit. Use a smaller image.`)\n }\n\n return {contentType, image: await readFile(filePath)}\n}\n"],"names":["readFile","stat","extname","IMAGE_CONTENT_TYPES","MAX_IMAGE_BYTES","readImageFile","filePath","contentType","toLowerCase","Error","stats","error","code","cause","size","image"],"mappings":"AACA,SAAQA,QAAQ,EAAEC,IAAI,QAAO,mBAAkB;AAC/C,SAAQC,OAAO,QAAO,YAAW;AAEjC,iGAAiG;AACjG,kEAAkE;AAClE,MAAMC,sBAA8C;IAClD,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,SAAS;AACX;AAEA,sFAAsF;AACtF,MAAMC,kBAAkB,IAAI,OAAO;AAQnC;;;;CAIC,GACD,OAAO,eAAeC,cAAcC,QAAgB;IAClD,MAAMC,cAAcJ,mBAAmB,CAACD,QAAQI,UAAUE,WAAW,GAAG;IACxE,IAAI,CAACD,aAAa;QAChB,MAAM,IAAIE,MACR,CAAC,CAAC,EAAEH,SAAS,8FAA8F,CAAC;IAEhH;IAEA,IAAII;IACJ,IAAI;QACFA,QAAQ,MAAMT,KAAKK;IACrB,EAAE,OAAOK,OAAO;QACd,IAAIA,iBAAiBF,SAAS,UAAUE,SAASA,MAAMC,IAAI,KAAK,UAAU;YACxE,MAAM,IAAIH,MAAM,CAAC,eAAe,EAAEH,SAAS,gCAAgC,CAAC,EAAE;gBAACO,OAAOF;YAAK;QAC7F;QACA,MAAMA;IACR;IAEA,IAAID,MAAMI,IAAI,GAAGV,iBAAiB;QAChC,MAAM,IAAIK,MAAM,CAAC,CAAC,EAAEH,SAAS,6DAA6D,CAAC;IAC7F;IAEA,OAAO;QAACC;QAAaQ,OAAO,MAAMf,SAASM;IAAS;AACtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
"source": "./src/_exports/errors.ts",
|
|
62
62
|
"default": "./dist/_exports/errors.js"
|
|
63
63
|
},
|
|
64
|
+
"./images": {
|
|
65
|
+
"source": "./src/_exports/images.ts",
|
|
66
|
+
"default": "./dist/_exports/images.js"
|
|
67
|
+
},
|
|
64
68
|
"./executionContext": {
|
|
65
69
|
"source": "./src/executionContext.ts",
|
|
66
70
|
"default": "./dist/executionContext.js"
|
|
@@ -119,10 +123,10 @@
|
|
|
119
123
|
"access": "public"
|
|
120
124
|
},
|
|
121
125
|
"dependencies": {
|
|
122
|
-
"@inquirer/core": "^12.
|
|
126
|
+
"@inquirer/core": "^12.1.1",
|
|
123
127
|
"@inquirer/prompts": "^8.7.5",
|
|
124
128
|
"@oclif/core": "^4.14.0",
|
|
125
|
-
"@sanity/client": "^8.
|
|
129
|
+
"@sanity/client": "^8.17.0",
|
|
126
130
|
"boxen": "^8.0.1",
|
|
127
131
|
"empathic": "^2.1.0",
|
|
128
132
|
"get-it": "^9.7.0",
|
|
@@ -135,15 +139,14 @@
|
|
|
135
139
|
"obug": "^3.0.0",
|
|
136
140
|
"ora": "^9.0.0",
|
|
137
141
|
"rxjs": "^7.8.2",
|
|
138
|
-
"vite": "^8.
|
|
142
|
+
"vite": "^8.4.0",
|
|
139
143
|
"wrap-ansi": "^9.0.2",
|
|
140
144
|
"zod": "^4.6.7"
|
|
141
145
|
},
|
|
142
146
|
"devDependencies": {
|
|
143
|
-
"@
|
|
147
|
+
"@repo/oxc-config": "0.0.0",
|
|
144
148
|
"@repo/package.config": "0.0.1",
|
|
145
149
|
"@repo/tsconfig": "3.70.0",
|
|
146
|
-
"@sanity/eslint-config-cli": "1.1.3",
|
|
147
150
|
"@sanity/pkg-utils": "^12.3.4",
|
|
148
151
|
"@sanity/telemetry": "^1.1.0",
|
|
149
152
|
"@swc/cli": "^0.8.2",
|
|
@@ -151,12 +154,12 @@
|
|
|
151
154
|
"@types/jsdom": "^28.0.3",
|
|
152
155
|
"@types/node": "^22.20.5",
|
|
153
156
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
154
|
-
"eslint": "^10.7.0",
|
|
155
157
|
"oxc-transform-react": "^0.158.0",
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
+
"oxlint": "^1.94.0",
|
|
159
|
+
"publint": "^0.3.25",
|
|
160
|
+
"sanity": "^6.25.0",
|
|
158
161
|
"typescript": "^6.0.3",
|
|
159
|
-
"vitest": "^5.1.
|
|
162
|
+
"vitest": "^5.1.1"
|
|
160
163
|
},
|
|
161
164
|
"peerDependencies": {
|
|
162
165
|
"babel-plugin-react-compiler": "*",
|
|
@@ -177,12 +180,12 @@
|
|
|
177
180
|
"build": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ src",
|
|
178
181
|
"build:types": "pkg-utils build --emitDeclarationOnly",
|
|
179
182
|
"check:types": "tsc --noEmit",
|
|
180
|
-
"lint": "eslint .",
|
|
181
183
|
"publint": "publint",
|
|
182
184
|
"test": "vitest run",
|
|
183
185
|
"posttest": "pnpm run lint",
|
|
184
186
|
"test:coverage": "vitest run --coverage",
|
|
185
187
|
"test:watch": "vitest",
|
|
186
|
-
"watch": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ --watch src"
|
|
188
|
+
"watch": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ --watch src",
|
|
189
|
+
"lint": "oxlint -c oxlint.config.ts"
|
|
187
190
|
}
|
|
188
191
|
}
|