@sanity/cli-core 2.1.3 → 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.
- package/README.md +224 -1
- package/dist/SanityCommand.d.ts +454 -0
- package/dist/SanityCommand.js +5 -4
- package/dist/SanityCommand.js.map +1 -1
- package/dist/_exports/browser.d.ts +21 -0
- package/dist/_exports/browser.js +5 -0
- package/dist/_exports/browser.js.map +1 -0
- package/dist/_exports/config.d.ts +653 -0
- package/dist/_exports/config.js +18 -0
- package/dist/_exports/config.js.map +1 -0
- package/dist/_exports/debug.d.ts +20 -0
- package/dist/_exports/debug.js.map +1 -0
- package/dist/_exports/errors.d.ts +67 -0
- package/dist/_exports/errors.js +5 -0
- package/dist/_exports/errors.js.map +1 -0
- package/dist/_exports/index.d.ts +30 -33
- package/dist/_exports/index.js +42 -39
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/package-manager.d.ts +191 -0
- package/dist/_exports/package-manager.js +3 -0
- package/dist/_exports/package-manager.js.map +1 -1
- package/dist/_exports/schemas.d.ts +227 -0
- package/dist/_exports/schemas.js +4 -0
- package/dist/_exports/schemas.js.map +1 -0
- package/dist/_exports/tasks.d.ts +120 -0
- package/dist/_exports/tasks.js +4 -0
- package/dist/_exports/tasks.js.map +1 -0
- package/dist/_exports/telemetry.d.ts +156 -0
- package/dist/_exports/telemetry.js +7 -0
- package/dist/_exports/telemetry.js.map +1 -0
- package/dist/_exports/types.d.ts +444 -0
- package/dist/_exports/types.js +3 -0
- package/dist/_exports/types.js.map +1 -0
- package/dist/_exports/util.d.ts +132 -0
- package/dist/_exports/util.js +16 -0
- package/dist/_exports/util.js.map +1 -0
- package/dist/_exports/ux.d.ts +15 -0
- package/dist/_exports/ux.js +6 -4
- package/dist/_exports/ux.js.map +1 -1
- package/dist/apiClient.d.ts +79 -0
- package/dist/{services/apiClient.js → apiClient.js} +2 -2
- package/dist/{services/apiClient.js.map → apiClient.js.map} +1 -1
- package/dist/config/cli/cliTokenCache.js.map +1 -0
- package/dist/{services → config/cli}/cliUserConfig.js +31 -6
- package/dist/config/cli/cliUserConfig.js.map +1 -0
- package/dist/config/cli/getCliConfig.js +1 -1
- package/dist/config/cli/getCliConfig.js.map +1 -1
- package/dist/config/cli/schemas.js +1 -0
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/cli/workbenchApp.js +19 -38
- package/dist/config/cli/workbenchApp.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +1 -1
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
- package/dist/config/studio/readStudioConfig.worker.js +1 -1
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
- package/dist/exitCodes.d.ts +23 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js +2 -2
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
- package/dist/telemetry/getCliTelemetry.js +3 -2
- package/dist/telemetry/getCliTelemetry.js.map +1 -1
- package/dist/telemetry/getTelemetryBaseInfo.js +1 -1
- package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -1
- package/dist/util/environment/mockBrowserEnvironment.js +3 -2
- package/dist/util/environment/mockBrowserEnvironment.js.map +1 -1
- package/dist/util/environment/setupBrowserStubs.js +1 -1
- package/dist/util/environment/setupBrowserStubs.js.map +1 -1
- package/dist/util/getSanityConfigDir.js +1 -0
- package/dist/util/getSanityConfigDir.js.map +1 -1
- package/dist/util/getSanityEnvVar.js +1 -0
- package/dist/util/getSanityEnvVar.js.map +1 -1
- package/dist/util/getSanityUrl.js +1 -0
- package/dist/util/getSanityUrl.js.map +1 -1
- package/dist/util/getWorkspace.js +1 -0
- package/dist/util/getWorkspace.js.map +1 -1
- package/dist/util/importModule.js +1 -1
- package/dist/util/importModule.js.map +1 -1
- package/dist/util/promisifyWorker.js +1 -1
- package/dist/util/promisifyWorker.js.map +1 -1
- package/package.json +56 -8
- package/dist/debug.js.map +0 -1
- package/dist/services/cliTokenCache.js.map +0 -1
- package/dist/services/cliUserConfig.js.map +0 -1
- package/dist/services/getCliToken.js +0 -26
- package/dist/services/getCliToken.js.map +0 -1
- /package/dist/{debug.js → _exports/debug.js} +0 -0
- /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"}
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -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 "
|
|
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<
|
|
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<
|
|
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
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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
|
/**
|
package/dist/_exports/index.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
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
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
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
|
|
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,
|
|
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"}
|