@sanity/cli-core 2.1.2 → 2.2.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.
Files changed (87) hide show
  1. package/README.md +224 -1
  2. package/dist/SanityCommand.d.ts +454 -0
  3. package/dist/SanityCommand.js +5 -4
  4. package/dist/SanityCommand.js.map +1 -1
  5. package/dist/_exports/browser.d.ts +21 -0
  6. package/dist/_exports/browser.js +5 -0
  7. package/dist/_exports/browser.js.map +1 -0
  8. package/dist/_exports/config.d.ts +653 -0
  9. package/dist/_exports/config.js +18 -0
  10. package/dist/_exports/config.js.map +1 -0
  11. package/dist/_exports/debug.d.ts +20 -0
  12. package/dist/_exports/debug.js.map +1 -0
  13. package/dist/_exports/errors.d.ts +67 -0
  14. package/dist/_exports/errors.js +5 -0
  15. package/dist/_exports/errors.js.map +1 -0
  16. package/dist/_exports/index.d.ts +30 -33
  17. package/dist/_exports/index.js +42 -39
  18. package/dist/_exports/index.js.map +1 -1
  19. package/dist/_exports/package-manager.d.ts +191 -0
  20. package/dist/_exports/package-manager.js +3 -0
  21. package/dist/_exports/package-manager.js.map +1 -1
  22. package/dist/_exports/schemas.d.ts +227 -0
  23. package/dist/_exports/schemas.js +4 -0
  24. package/dist/_exports/schemas.js.map +1 -0
  25. package/dist/_exports/tasks.d.ts +120 -0
  26. package/dist/_exports/tasks.js +4 -0
  27. package/dist/_exports/tasks.js.map +1 -0
  28. package/dist/_exports/telemetry.d.ts +156 -0
  29. package/dist/_exports/telemetry.js +7 -0
  30. package/dist/_exports/telemetry.js.map +1 -0
  31. package/dist/_exports/types.d.ts +444 -0
  32. package/dist/_exports/types.js +3 -0
  33. package/dist/_exports/types.js.map +1 -0
  34. package/dist/_exports/util.d.ts +132 -0
  35. package/dist/_exports/util.js +16 -0
  36. package/dist/_exports/util.js.map +1 -0
  37. package/dist/_exports/ux.d.ts +15 -0
  38. package/dist/_exports/ux.js +6 -4
  39. package/dist/_exports/ux.js.map +1 -1
  40. package/dist/apiClient.d.ts +79 -0
  41. package/dist/{services/apiClient.js → apiClient.js} +2 -2
  42. package/dist/{services/apiClient.js.map → apiClient.js.map} +1 -1
  43. package/dist/config/cli/cliTokenCache.js.map +1 -0
  44. package/dist/{services → config/cli}/cliUserConfig.js +31 -6
  45. package/dist/config/cli/cliUserConfig.js.map +1 -0
  46. package/dist/config/cli/getCliConfig.js +1 -1
  47. package/dist/config/cli/getCliConfig.js.map +1 -1
  48. package/dist/config/cli/schemas.js +1 -0
  49. package/dist/config/cli/schemas.js.map +1 -1
  50. package/dist/config/cli/types/cliConfig.js.map +1 -1
  51. package/dist/config/cli/workbenchApp.js +19 -38
  52. package/dist/config/cli/workbenchApp.js.map +1 -1
  53. package/dist/config/studio/getStudioWorkspaces.js +1 -1
  54. package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
  55. package/dist/config/studio/readStudioConfig.worker.js +1 -1
  56. package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
  57. package/dist/exitCodes.d.ts +23 -0
  58. package/dist/loaders/studio/studioWorkerLoader.worker.js +2 -2
  59. package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
  60. package/dist/telemetry/getCliTelemetry.js +3 -2
  61. package/dist/telemetry/getCliTelemetry.js.map +1 -1
  62. package/dist/telemetry/getTelemetryBaseInfo.js +1 -1
  63. package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -1
  64. package/dist/util/environment/mockBrowserEnvironment.js +3 -2
  65. package/dist/util/environment/mockBrowserEnvironment.js.map +1 -1
  66. package/dist/util/environment/setupBrowserStubs.js +1 -1
  67. package/dist/util/environment/setupBrowserStubs.js.map +1 -1
  68. package/dist/util/getSanityConfigDir.js +1 -0
  69. package/dist/util/getSanityConfigDir.js.map +1 -1
  70. package/dist/util/getSanityEnvVar.js +1 -0
  71. package/dist/util/getSanityEnvVar.js.map +1 -1
  72. package/dist/util/getSanityUrl.js +1 -0
  73. package/dist/util/getSanityUrl.js.map +1 -1
  74. package/dist/util/getWorkspace.js +1 -0
  75. package/dist/util/getWorkspace.js.map +1 -1
  76. package/dist/util/importModule.js +1 -1
  77. package/dist/util/importModule.js.map +1 -1
  78. package/dist/util/promisifyWorker.js +1 -1
  79. package/dist/util/promisifyWorker.js.map +1 -1
  80. package/package.json +57 -9
  81. package/dist/debug.js.map +0 -1
  82. package/dist/services/cliTokenCache.js.map +0 -1
  83. package/dist/services/cliUserConfig.js.map +0 -1
  84. package/dist/services/getCliToken.js +0 -26
  85. package/dist/services/getCliToken.js.map +0 -1
  86. /package/dist/{debug.js → _exports/debug.js} +0 -0
  87. /package/dist/{services → config/cli}/cliTokenCache.js +0 -0
@@ -0,0 +1,67 @@
1
+ import { CLIError } from "@oclif/core/errors";
2
+
3
+ /**
4
+ * Returns whether or not the given error is a `NotFoundError`
5
+ *
6
+ * @param err - The error to check
7
+ * @returns `true` if the error is a `NotFoundError`, `false` otherwise
8
+ * @internal
9
+ */
10
+ export declare function isNotFoundError(err: unknown): err is NotFoundError;
11
+
12
+ /**
13
+ * Returns whether or not the given error is a `ProjectRootNotFoundError`
14
+ *
15
+ * @param err - The error to check
16
+ * @returns `true` if the error is a `ProjectRootNotFoundError`, `false` otherwise
17
+ * @internal
18
+ */
19
+ export declare function isProjectRootNotFoundError(
20
+ err: unknown,
21
+ ): err is ProjectRootNotFoundError;
22
+
23
+ /**
24
+ * Error thrown when a prompt is attempted in a non-interactive environment
25
+ * (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error
26
+ * to provide appropriate fallback behavior.
27
+ *
28
+ * Extends `CLIError` to suppress stack traces in user-facing output.
29
+ */
30
+ export declare class NonInteractiveError extends CLIError {
31
+ constructor(promptName: string);
32
+ }
33
+
34
+ /**
35
+ * Error thrown when a file or directory is not found
36
+ *
37
+ * `code` is always `ENOENT` to mirror Node.js behavior when a file is not found
38
+ *
39
+ * @internal
40
+ */
41
+ export declare class NotFoundError extends Error {
42
+ code: string;
43
+ path?: string;
44
+ constructor(message: string, path?: string);
45
+ }
46
+
47
+ /**
48
+ * Error thrown when a project root directory cannot be found.
49
+ *
50
+ * This occurs when the CLI is run outside a Sanity project directory
51
+ * (one containing `sanity.config.(ts|js)` or `sanity.cli.(ts|js)`).
52
+ *
53
+ * Extends `CLIError` to suppress stack traces in user-facing output.
54
+ *
55
+ * @internal
56
+ */
57
+ export declare class ProjectRootNotFoundError extends CLIError {
58
+ constructor(
59
+ message: string,
60
+ options?: {
61
+ cause?: Error;
62
+ suggestions?: string[];
63
+ },
64
+ );
65
+ }
66
+
67
+ export {};
@@ -0,0 +1,5 @@
1
+ export { NonInteractiveError } from '../errors/NonInteractiveError.js';
2
+ export { isNotFoundError, NotFoundError } from '../errors/NotFoundError.js';
3
+ export { isProjectRootNotFoundError, ProjectRootNotFoundError } from '../errors/ProjectRootNotFoundError.js';
4
+
5
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/_exports/errors.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {isNotFoundError, NotFoundError} from '../errors/NotFoundError.js'\nexport {\n isProjectRootNotFoundError,\n ProjectRootNotFoundError,\n} from '../errors/ProjectRootNotFoundError.js'\n"],"names":["NonInteractiveError","isNotFoundError","NotFoundError","isProjectRootNotFoundError","ProjectRootNotFoundError"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,eAAe,EAAEC,aAAa,QAAO,6BAA4B;AACzE,SACEC,0BAA0B,EAC1BC,wBAAwB,QACnB,wCAAuC"}
@@ -7,8 +7,8 @@ import debugIt from "debug";
7
7
  import { InlineConfig } from "vite";
8
8
  import { Interfaces } from "@oclif/core";
9
9
  import { PluginOptions } from "babel-plugin-react-compiler";
10
- import { SanityClient } from "sanity";
11
- import { SanityClient as SanityClient_2 } from "@sanity/client";
10
+ import { SanityClient } from "@sanity/client";
11
+ import { SanityClient as SanityClient_2 } from "sanity";
12
12
  import { URL as URL_2 } from "node:url";
13
13
  import { Worker as Worker_2 } from "node:worker_threads";
14
14
  import { WorkerOptions as WorkerOptions_2 } from "node:worker_threads";
@@ -175,6 +175,16 @@ export declare interface CliConfig {
175
175
  */
176
176
  enabled?: boolean;
177
177
  };
178
+ /**
179
+ * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled
180
+ * files during development, which can speed up startup and reloads for large projects.
181
+ * Defaults to `false`.
182
+ *
183
+ * Unstable: may change or be removed without notice while the underlying Vite
184
+ * feature (`experimental.bundledDev`) is experimental.
185
+ * {@link https://vite.dev/guide/rolldown#full-bundle-mode}
186
+ */
187
+ unstable_bundledDev?: boolean;
178
188
  /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */
179
189
  vite?: UserViteConfig;
180
190
  }
@@ -488,7 +498,6 @@ export declare function getCliToken(): Promise<string | undefined>;
488
498
  *
489
499
  * @param prop - The property to get the value for
490
500
  * @returns The value of the given property
491
- * @internal
492
501
  */
493
502
  export declare function getCliUserConfig(prop: "authToken"): string | undefined;
494
503
 
@@ -505,7 +514,7 @@ export declare function getGlobalCliClient({
505
514
  token: providedToken,
506
515
  unauthenticated,
507
516
  ...config
508
- }: GlobalCliClientOptions): Promise<SanityClient_2>;
517
+ }: GlobalCliClientOptions): Promise<SanityClient>;
509
518
 
510
519
  /**
511
520
  * Resolve the filesystem directory of a locally installed package using Node
@@ -547,7 +556,7 @@ export declare function getProjectCliClient({
547
556
  requireUser,
548
557
  token: providedToken,
549
558
  ...config
550
- }: ProjectCliClientOptions): Promise<SanityClient_2>;
559
+ }: ProjectCliClientOptions): Promise<SanityClient>;
551
560
 
552
561
  /**
553
562
  * Returns the base Sanity configuration directory for the current user.
@@ -775,31 +784,11 @@ export declare function isStaging(): boolean;
775
784
  export declare function isStudioConfig(value: unknown): boolean;
776
785
 
777
786
  /**
778
- * Whether `app` is a branded `unstable_defineApp(...)` result — the sole
779
- * workbench opt-in. Narrows to the shared `app` config plus the workbench-only
780
- * fields a branded result carries: its `name`, the resolved `applicationType`
781
- * (settled by `parseWorkbenchCliConfig` on load, so callers read it instead of
782
- * re-deriving studio-vs-app), dock panel `views`, and background worker
783
- * `services`. The `type` literals match the `DefineAppInput` schema so
784
- * `views`/`services` stay assignable to `DefineAppInput['views' | 'services']`
785
- * downstream.
787
+ * Boolean brand check — used for config-load routing, kept exported for
788
+ * backward compatibility. For the typed narrowing (the app's declared fields),
789
+ * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.
786
790
  */
787
- export declare function isWorkbenchApp(
788
- app: CliConfig["app"],
789
- ): app is NonNullable<CliConfig["app"]> & {
790
- applicationType?: ApplicationType;
791
- name: string;
792
- services?: {
793
- name: string;
794
- src: string;
795
- type: "worker";
796
- }[];
797
- views?: {
798
- name: string;
799
- src: string;
800
- type: "panel";
801
- }[];
802
- };
791
+ export declare function isWorkbenchApp(app: CliConfig["app"]): boolean;
803
792
 
804
793
  /**
805
794
  * Mocks a browser-like environment for processes in the main thread by:
@@ -1151,7 +1140,14 @@ export declare interface ReadPackageJsonOptions {
1151
1140
  skipSchemaValidation?: boolean;
1152
1141
  }
1153
1142
 
1154
- declare type RequireProps<T, K extends keyof T> = Omit<T, K> &
1143
+ /**
1144
+ * Reports an error to the CLI command trace. Called from SanityCommand.catch()
1145
+ * for real command errors (not user aborts).
1146
+ * @internal
1147
+ */
1148
+ export declare function reportCliTraceError(error: Error): void;
1149
+
1150
+ export declare type RequireProps<T, K extends keyof T> = Omit<T, K> &
1155
1151
  Required<Pick<T, K>>;
1156
1152
 
1157
1153
  declare const resolvedConfigSchema: z.ZodMiniArray<
@@ -1296,7 +1292,7 @@ export declare abstract class SanityCommand<T extends typeof Command>
1296
1292
  */
1297
1293
  protected getGlobalApiClient: (
1298
1294
  args: GlobalCliClientOptions,
1299
- ) => Promise<SanityClient>;
1295
+ ) => Promise<SanityClient_2>;
1300
1296
  /**
1301
1297
  * Get the project API client.
1302
1298
  *
@@ -1307,7 +1303,7 @@ export declare abstract class SanityCommand<T extends typeof Command>
1307
1303
  */
1308
1304
  protected getProjectApiClient: (
1309
1305
  args: ProjectCliClientOptions,
1310
- ) => Promise<SanityClient>;
1306
+ ) => Promise<SanityClient_2>;
1311
1307
  /**
1312
1308
  * Helper for outputting to the console.
1313
1309
  *
@@ -1373,7 +1369,8 @@ export declare abstract class SanityCommand<T extends typeof Command>
1373
1369
  *
1374
1370
  * Most commands should take an explicit `--yes` flag to enable unattended mode, but
1375
1371
  * some commands may also be run in unattended mode if `process.stdin` is not a TTY
1376
- * (eg when running in a CI environment).
1372
+ * (eg when running in a CI environment), or when `--json` asks for machine-readable
1373
+ * output (a caller parsing JSON can't answer a prompt).
1377
1374
  */
1378
1375
  isUnattended(): boolean;
1379
1376
  /**
@@ -1,45 +1,48 @@
1
- export * from '../config/cli/getCliConfig.js';
2
- export * from '../config/cli/getCliConfigSync.js';
1
+ // DO NOT ADD NEW EXPORTS TO THIS FILE!
2
+ // These are left here for backwards compatibility.
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
+ // 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
+ export { getGlobalCliClient, getProjectCliClient } from '../apiClient.js';
6
+ export { clearCliTokenCache, getCliToken, getCliUserConfig, getUserConfig, setCliUserConfig } from '../config/cli/cliUserConfig.js';
7
+ export { getCliConfig, getCliConfigUncached } from '../config/cli/getCliConfig.js';
8
+ export { getCliConfigSync } from '../config/cli/getCliConfigSync.js';
3
9
  export { isWorkbenchApp } from '../config/cli/workbenchApp.js';
4
- export * from '../config/findProjectRoot.js';
5
- export * from '../config/findProjectRootSync.js';
6
- export * from '../config/studio/getStudioConfig.js';
7
- export * from '../config/studio/getStudioWorkspaces.js';
8
- export * from '../config/studio/isStudioConfig.js';
9
- export * from '../config/util/findConfigsPaths.js';
10
- export * from '../config/util/findStudioConfigPath.js';
11
- export * from '../debug.js';
12
- export * from '../errors/NonInteractiveError.js';
13
- export * from '../errors/NotFoundError.js';
14
- export * from '../errors/ProjectRootNotFoundError.js';
15
- export * from '../exitCodes.js';
16
- export * from '../loaders/studio/studioWorkerTask.js';
17
- export * from '../loaders/tsx/tsxWorkerTask.js';
18
- export * from '../manifest.js';
19
- export * from '../SanityCommand.js';
20
- export * from '../services/apiClient.js';
21
- export * from '../services/cliUserConfig.js';
22
- export * from '../services/getCliToken.js';
23
- export { clearCliTelemetry, CLI_TELEMETRY_SYMBOL, getCliTelemetry, setCliTelemetry } from '../telemetry/getCliTelemetry.js';
10
+ export { findProjectRoot } from '../config/findProjectRoot.js';
11
+ export { findProjectRootSync } from '../config/findProjectRootSync.js';
12
+ export { getStudioConfig } from '../config/studio/getStudioConfig.js';
13
+ export { getStudioWorkspaces } from '../config/studio/getStudioWorkspaces.js';
14
+ export { isStudioConfig } from '../config/studio/isStudioConfig.js';
15
+ export { findPathForFiles } from '../config/util/findConfigsPaths.js';
16
+ export { findStudioConfigPath, tryFindStudioConfigPath } from '../config/util/findStudioConfigPath.js';
17
+ export { NonInteractiveError } from '../errors/NonInteractiveError.js';
18
+ export { isNotFoundError, NotFoundError } from '../errors/NotFoundError.js';
19
+ export { isProjectRootNotFoundError, ProjectRootNotFoundError } from '../errors/ProjectRootNotFoundError.js';
20
+ export { exitCodes } from '../exitCodes.js';
21
+ export { createStudioWorker, studioWorkerTask } from '../loaders/studio/studioWorkerTask.js';
22
+ export { tsxWorkerTask } from '../loaders/tsx/tsxWorkerTask.js';
23
+ export { SanityCommand } from '../SanityCommand.js';
24
+ export { clearCliTelemetry, CLI_TELEMETRY_SYMBOL, getCliTelemetry, reportCliTraceError, setCliTelemetry } from '../telemetry/getCliTelemetry.js';
24
25
  export { getTelemetryBaseInfo } from '../telemetry/getTelemetryBaseInfo.js';
25
26
  export { noopLogger } from '../telemetry/noopTelemetry.js';
26
27
  export { doImport } from '../util/doImport.js';
27
- export * from '../util/environment/mockBrowserEnvironment.js';
28
- export * from '../util/getLocalPackageVersion.js';
29
- export * from '../util/getSanityConfigDir.js';
30
- export * from '../util/getSanityEnvVar.js';
31
- export * from '../util/getSanityUrl.js';
32
- export * from '../util/getWorkspace.js';
33
- export * from '../util/importModule.js';
34
- export * from '../util/isCi.js';
35
- export * from '../util/isInteractive.js';
36
- export * from '../util/isStaging.js';
37
- export * from '../util/normalizePath.js';
38
- export * from '../util/promisifyWorker.js';
39
- export * from '../util/readPackageJson.js';
40
- export * from '../util/resolveLocalPackage.js';
41
- export * from '../util/safeStructuredClone.js';
42
- export * from '../ux/colorizeJson.js';
43
- export * from '../ux/timer.js';
28
+ export { mockBrowserEnvironment } from '../util/environment/mockBrowserEnvironment.js';
29
+ export { getLocalPackageDir, getLocalPackageVersion } from '../util/getLocalPackageVersion.js';
30
+ export { getSanityConfigDir, getSanityDataDir } from '../util/getSanityConfigDir.js';
31
+ export { getSanityEnvVar } from '../util/getSanityEnvVar.js';
32
+ export { getSanityUrl } from '../util/getSanityUrl.js';
33
+ export { getWorkspace } from '../util/getWorkspace.js';
34
+ export { importModule } from '../util/importModule.js';
35
+ export { isCi } from '../util/isCi.js';
36
+ export { isInteractive } from '../util/isInteractive.js';
37
+ export { isStaging } from '../util/isStaging.js';
38
+ export { normalizePath } from '../util/normalizePath.js';
39
+ export { promisifyWorker } from '../util/promisifyWorker.js';
40
+ export { readPackageJson } from '../util/readPackageJson.js';
41
+ export { resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath } from '../util/resolveLocalPackage.js';
42
+ export { safeStructuredClone } from '../util/safeStructuredClone.js';
43
+ export { colorizeJson } from '../ux/colorizeJson.js';
44
+ export { getTimer } from '../ux/timer.js';
45
+ export { debug, subdebug } from './debug.js';
46
+ export { coreAppManifestSchema, studioManifestSchema } from './schemas.js';
44
47
 
45
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["export * from '../config/cli/getCliConfig.js'\nexport * from '../config/cli/getCliConfigSync.js'\nexport {type CliConfig} 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 * from '../config/findProjectRoot.js'\nexport * from '../config/findProjectRootSync.js'\nexport * from '../config/studio/getStudioConfig.js'\nexport * from '../config/studio/getStudioWorkspaces.js'\nexport * from '../config/studio/isStudioConfig.js'\nexport * from '../config/util/findConfigsPaths.js'\nexport * from '../config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from '../config/util/recursivelyResolveProjectRoot.js'\nexport * from '../debug.js'\nexport * from '../errors/NonInteractiveError.js'\nexport * from '../errors/NotFoundError.js'\nexport * from '../errors/ProjectRootNotFoundError.js'\nexport * from '../exitCodes.js'\nexport * from '../loaders/studio/studioWorkerTask.js'\nexport * from '../loaders/tsx/tsxWorkerTask.js'\nexport * from '../manifest.js'\nexport * from '../SanityCommand.js'\nexport * from '../services/apiClient.js'\nexport * from '../services/cliUserConfig.js'\nexport * from '../services/getCliToken.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\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 SanityOrgUser} from '../types.js'\nexport {doImport} from '../util/doImport.js'\nexport * from '../util/environment/mockBrowserEnvironment.js'\nexport * from '../util/getLocalPackageVersion.js'\nexport * from '../util/getSanityConfigDir.js'\nexport * from '../util/getSanityEnvVar.js'\nexport * from '../util/getSanityUrl.js'\nexport * from '../util/getWorkspace.js'\nexport * from '../util/importModule.js'\nexport * from '../util/isCi.js'\nexport * from '../util/isInteractive.js'\nexport * from '../util/isStaging.js'\nexport * from '../util/normalizePath.js'\nexport * from '../util/promisifyWorker.js'\nexport * from '../util/readPackageJson.js'\nexport * from '../util/resolveLocalPackage.js'\nexport * from '../util/safeStructuredClone.js'\nexport * from '../ux/colorizeJson.js'\nexport * from '../ux/timer.js'\n"],"names":["isWorkbenchApp","clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","setCliTelemetry","getTelemetryBaseInfo","noopLogger","doImport"],"mappings":"AAAA,cAAc,gCAA+B;AAC7C,cAAc,oCAAmC;AAGjD,SAA8BA,cAAc,QAAO,gCAA+B;AAClF,cAAc,+BAA8B;AAC5C,cAAc,mCAAkC;AAChD,cAAc,sCAAqC;AACnD,cAAc,0CAAyC;AACvD,cAAc,qCAAoC;AAClD,cAAc,qCAAoC;AAClD,cAAc,yCAAwC;AAEtD,cAAc,cAAa;AAC3B,cAAc,mCAAkC;AAChD,cAAc,6BAA4B;AAC1C,cAAc,wCAAuC;AACrD,cAAc,kBAAiB;AAC/B,cAAc,wCAAuC;AACrD,cAAc,kCAAiC;AAC/C,cAAc,iBAAgB;AAC9B,cAAc,sBAAqB;AACnC,cAAc,2BAA0B;AACxC,cAAc,+BAA8B;AAC5C,cAAc,6BAA4B;AAC1C,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,eAAe,QACV,kCAAiC;AACxC,SAAQC,oBAAoB,QAAO,uCAAsC;AACzE,SAAQC,UAAU,QAAO,gCAA+B;AAOxD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,cAAc,gDAA+C;AAC7D,cAAc,oCAAmC;AACjD,cAAc,gCAA+B;AAC7C,cAAc,6BAA4B;AAC1C,cAAc,0BAAyB;AACvC,cAAc,0BAAyB;AACvC,cAAc,0BAAyB;AACvC,cAAc,kBAAiB;AAC/B,cAAc,2BAA0B;AACxC,cAAc,uBAAsB;AACpC,cAAc,2BAA0B;AACxC,cAAc,6BAA4B;AAC1C,cAAc,6BAA4B;AAC1C,cAAc,iCAAgC;AAC9C,cAAc,iCAAgC;AAC9C,cAAc,wBAAuB;AACrC,cAAc,iBAAgB"}
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 ConfigStore,\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 {type CliConfig} 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","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,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,QACX,iCAAgC;AACvC,SAAQC,YAAY,EAAEC,oBAAoB,QAAO,gCAA+B;AAChF,SAAQC,gBAAgB,QAAO,oCAAmC;AAGlE,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,3 +1,5 @@
1
+ import { z } from "zod/mini";
2
+
1
3
  /**
2
4
  * Runtime-detectable package managers (excludes 'manual' which is a UI-only choice).
3
5
  */
@@ -14,6 +16,34 @@ export declare function getBinCommand(options?: {
14
16
  userAgent?: string;
15
17
  }): string;
16
18
 
19
+ /**
20
+ * Resolve the filesystem directory of a locally installed package using Node
21
+ * module resolution. Works correctly with hoisted packages in monorepos/workspaces,
22
+ * pnpm symlinks, and other non-standard node_modules layouts.
23
+ *
24
+ * @param moduleName - The name of the package in npm.
25
+ * @param workDir - The working directory to resolve the module from. (aka project root)
26
+ * @returns The absolute path to the package directory.
27
+ * @internal
28
+ */
29
+ export declare function getLocalPackageDir(
30
+ moduleName: string,
31
+ workDir: string,
32
+ ): string;
33
+
34
+ /**
35
+ * Get the version of a package installed locally.
36
+ *
37
+ * @param moduleName - The name of the package in npm.
38
+ * @param workDir - The working directory to resolve the module from. (aka project root)
39
+ * @returns The version of the package installed locally.
40
+ * @internal
41
+ */
42
+ export declare function getLocalPackageVersion(
43
+ moduleName: string,
44
+ workDir: string,
45
+ ): Promise<string | null>;
46
+
17
47
  /**
18
48
  * Convenience wrapper that reads `process.env.npm_config_user_agent` and returns
19
49
  * the detected package manager.
@@ -30,4 +60,165 @@ export declare function getRunningPackageManager():
30
60
  */
31
61
  export declare function getYarnMajorVersion(ua?: string): number | undefined;
32
62
 
63
+ /**
64
+ * Comprehensive representation of a package.json file.
65
+ * Consolidates all properties from previous type definitions.
66
+ *
67
+ * @public
68
+ */
69
+ export declare type PackageJson = z.infer<typeof packageJsonSchema>;
70
+
71
+ /**
72
+ * Comprehensive package.json schema including all common properties.
73
+ * Feel free to add properties to this,
74
+ * 🟠ℹ️ BUT ENSURE OPTIONAL STUFF IS ACTUALLY OPTIONAL ℹ️🟠
75
+ * 🟠ℹ️ SINCE THIS IS USED IN A NUMBER OF LOCATIONS WHERE ℹ️🟠
76
+ * 🟠ℹ️ WE CANNOT ENFORCE/GUARANTEE ANY PARTICULAR PROPS ℹ️🟠
77
+ */
78
+ declare const packageJsonSchema: z.ZodMiniObject<
79
+ {
80
+ name: z.ZodMiniString<string>;
81
+ version: z.ZodMiniString<string>;
82
+ dependencies: z.ZodMiniOptional<
83
+ z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
84
+ >;
85
+ devDependencies: z.ZodMiniOptional<
86
+ z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
87
+ >;
88
+ peerDependencies: z.ZodMiniOptional<
89
+ z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
90
+ >;
91
+ exports: z.ZodMiniOptional<
92
+ z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>
93
+ >;
94
+ main: z.ZodMiniOptional<z.ZodMiniString<string>>;
95
+ types: z.ZodMiniOptional<z.ZodMiniString<string>>;
96
+ author: z.ZodMiniOptional<z.ZodMiniString<string>>;
97
+ description: z.ZodMiniOptional<z.ZodMiniString<string>>;
98
+ engines: z.ZodMiniOptional<
99
+ z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
100
+ >;
101
+ license: z.ZodMiniOptional<z.ZodMiniString<string>>;
102
+ private: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
103
+ repository: z.ZodMiniOptional<
104
+ z.ZodMiniObject<
105
+ {
106
+ type: z.ZodMiniString<string>;
107
+ url: z.ZodMiniString<string>;
108
+ },
109
+ z.core.$strip
110
+ >
111
+ >;
112
+ scripts: z.ZodMiniOptional<
113
+ z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>
114
+ >;
115
+ type: z.ZodMiniOptional<
116
+ z.ZodMiniEnum<{
117
+ module: "module";
118
+ commonjs: "commonjs";
119
+ }>
120
+ >;
121
+ },
122
+ z.core.$loose
123
+ >;
124
+
125
+ /**
126
+ * Read the `package.json` file at the given path
127
+ *
128
+ * @param filePath - Path to package.json to read
129
+ * @param options - Options object for controlling read behavior
130
+ * @returns The parsed package.json
131
+ * @public
132
+ */
133
+ export declare function readPackageJson(
134
+ filePath: string | URL,
135
+ options?: ReadPackageJsonOptions,
136
+ ): Promise<PackageJson>;
137
+
138
+ /**
139
+ * Options for reading package.json files
140
+ *
141
+ * @public
142
+ */
143
+ export declare interface ReadPackageJsonOptions {
144
+ /**
145
+ * Default values to merge with the parsed package.json.
146
+ * Parsed values take precedence over defaults.
147
+ */
148
+ defaults?: Partial<PackageJson>;
149
+ /**
150
+ * Skip Zod schema validation. When true, the file is parsed but not validated.
151
+ * Defaults to false.
152
+ */
153
+ skipSchemaValidation?: boolean;
154
+ }
155
+
156
+ /**
157
+ * Resolves and imports a package from the local project's node_modules,
158
+ * relative to the given working directory. This avoids circular dependencies
159
+ * and ensures the correct version of the package is used.
160
+ *
161
+ * @param packageName - The name of the package to resolve (e.g., 'sanity')
162
+ * @param workDir - The working directory to resolve the package from
163
+ * @returns The imported module
164
+ * @throws If the package cannot be resolved or imported
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * const {createSchema} = await resolveLocalPackage('sanity', workDir)
169
+ * ```
170
+ *
171
+ * @internal
172
+ */
173
+ export declare function resolveLocalPackage<T = unknown>(
174
+ packageName: string,
175
+ workDir: string,
176
+ ): Promise<T>;
177
+
178
+ /**
179
+ * Resolves and imports a package relative to another resolved module URL.
180
+ * Useful for resolving transitive dependencies that may not be directly
181
+ * accessible from the project root (e.g., in pnpm strict mode).
182
+ *
183
+ * @param packageName - The name of the package to resolve
184
+ * @param parentUrl - The URL of the parent module to resolve from
185
+ * @returns The imported module
186
+ * @throws If the package cannot be resolved or imported
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const sanityUrl = resolveLocalPackagePath('sanity', workDir)
191
+ * const ui = await resolveLocalPackageFrom<typeof import('@sanity/ui')>('@sanity/ui', sanityUrl)
192
+ * ```
193
+ *
194
+ * @internal
195
+ */
196
+ export declare function resolveLocalPackageFrom<T = unknown>(
197
+ packageName: string,
198
+ parentUrl: URL,
199
+ ): Promise<T>;
200
+
201
+ /**
202
+ * Resolves the URL of a package from the local project's node_modules,
203
+ * relative to the given working directory, without importing it.
204
+ *
205
+ * @param packageName - The name of the package to resolve (e.g., 'sanity')
206
+ * @param workDir - The working directory to resolve the package from
207
+ * @returns The resolved URL of the package entry point
208
+ * @throws If the package cannot be resolved
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * // Resolve a transitive dependency via its parent package:
213
+ * const sanityUrl = resolveLocalPackagePath('sanity', workDir)
214
+ * const uiUrl = resolveLocalPackagePathFrom('@sanity/ui', sanityUrl)
215
+ * ```
216
+ *
217
+ * @internal
218
+ */
219
+ export declare function resolveLocalPackagePath(
220
+ packageName: string,
221
+ workDir: string,
222
+ ): URL;
223
+
33
224
  export {};
@@ -1,3 +1,6 @@
1
+ export { getLocalPackageDir, getLocalPackageVersion } from '../util/getLocalPackageVersion.js';
1
2
  export { getBinCommand, getRunningPackageManager, getYarnMajorVersion } from '../util/packageManager.js';
3
+ export { readPackageJson } from '../util/readPackageJson.js';
4
+ export { resolveLocalPackage, resolveLocalPackageFrom, resolveLocalPackagePath } from '../util/resolveLocalPackage.js';
2
5
 
3
6
  //# sourceMappingURL=package-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/package-manager.ts"],"sourcesContent":["export {\n type DetectedPackageManager,\n getBinCommand,\n getRunningPackageManager,\n getYarnMajorVersion,\n} from '../util/packageManager.js'\n"],"names":["getBinCommand","getRunningPackageManager","getYarnMajorVersion"],"mappings":"AAAA,SAEEA,aAAa,EACbC,wBAAwB,EACxBC,mBAAmB,QACd,4BAA2B"}
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"}