@sanity/cli-core 2.8.1 → 3.1.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 +7 -6
- package/dist/NonInteractiveError-CSLT5y93.d.ts +13 -0
- package/dist/ProjectRootNotFoundError-RgthN9uy.d.ts +47 -0
- package/dist/SanityCommand.d.ts +26 -355
- package/dist/SanityCommand.js +5 -0
- package/dist/SanityCommand.js.map +1 -1
- package/dist/_exports/browser.d.ts +2 -21
- package/dist/_exports/config.d.ts +5 -661
- package/dist/_exports/debug.d.ts +4 -8
- package/dist/_exports/debug.js +3 -3
- package/dist/_exports/debug.js.map +1 -1
- package/dist/_exports/errors.d.ts +12 -77
- package/dist/_exports/index.d.ts +34 -1674
- package/dist/_exports/package-manager.d.ts +14 -207
- package/dist/_exports/request.d.ts +52 -69
- package/dist/_exports/request.js +5 -4
- package/dist/_exports/request.js.map +1 -1
- package/dist/_exports/schemas.d.ts +2 -235
- package/dist/_exports/tasks.d.ts +2 -120
- package/dist/_exports/telemetry.d.ts +2 -156
- package/dist/_exports/types.d.ts +9 -475
- package/dist/_exports/undeploy.d.ts +45 -62
- package/dist/_exports/undeploy.js +1 -3
- package/dist/_exports/undeploy.js.map +1 -1
- package/dist/_exports/util.d.ts +6 -137
- package/dist/_exports/ux.d.ts +31 -102
- package/dist/apiClient-DXlF5ZV3.d.ts +65 -0
- package/dist/apiClient.d.ts +2 -79
- package/dist/apiClient.js +69 -47
- package/dist/apiClient.js.map +1 -1
- package/dist/cliConfig-CbW8neMv.d.ts +171 -0
- package/dist/errors/enrichAuthError.js +48 -0
- package/dist/errors/enrichAuthError.js.map +1 -0
- package/dist/errors/getErrorMessage.js +3 -1
- package/dist/errors/getErrorMessage.js.map +1 -1
- package/dist/executionContext.d.ts +21 -20
- package/dist/executionContext.js.map +1 -1
- package/dist/exitCodes.d.ts +3 -3
- package/dist/findStudioConfigPath-DcKlHhyW.d.ts +265 -0
- package/dist/getWorkspace-CU32E6Uo.d.ts +54 -0
- package/dist/mockBrowserEnvironment-BjFQPb2W.d.ts +19 -0
- package/dist/noopTelemetry-BJRIvASI.d.ts +64 -0
- package/dist/readPackageJson-Cr_lbjVR.d.ts +67 -0
- package/dist/recursivelyResolveProjectRoot-BE54uEP6.d.ts +18 -0
- package/dist/request/createRequester.js +39 -50
- package/dist/request/createRequester.js.map +1 -1
- package/dist/request/nodeReadableFromWeb.js +64 -0
- package/dist/request/nodeReadableFromWeb.js.map +1 -0
- package/dist/resolveLocalPackage-Dr-TNTyk.d.ts +78 -0
- package/dist/safeStructuredClone-CWB0MXmH.d.ts +58 -0
- package/dist/schemas-DRCVXpyW.d.ts +140 -0
- package/dist/timer-Dwu2TIgB.d.ts +14 -0
- package/dist/tsxWorkerTask-CxG3fWbU.d.ts +97 -0
- package/dist/types-CwJLTYDj.d.ts +23 -0
- package/dist/types-ZNH3prAd.d.ts +91 -0
- package/dist/ux/spinner.js +70 -9
- package/dist/ux/spinner.js.map +1 -1
- package/dist/workbenchApp-Dhtbsuhn.d.ts +22 -0
- package/package.json +7 -8
- package/dist/request/createIsolatedRequester.js +0 -75
- package/dist/request/createIsolatedRequester.js.map +0 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { PluginOptions } from "babel-plugin-react-compiler";
|
|
2
|
+
import { ConfigEnv, InlineConfig } from "vite";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig;
|
|
7
|
+
interface TypeGenConfig {
|
|
8
|
+
formatGeneratedCode: boolean;
|
|
9
|
+
generates: string;
|
|
10
|
+
overloadClientMethods: boolean;
|
|
11
|
+
path: string | string[];
|
|
12
|
+
schema: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dashboard visibility an application can declare. Mirrors Brett's canonical
|
|
16
|
+
* `VISIBILITIES` — the source of truth lives in the application service.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
declare const APP_VISIBILITIES: readonly ["default", "unlisted", "disabled"];
|
|
20
|
+
/** @public */
|
|
21
|
+
type AppVisibility = (typeof APP_VISIBILITIES)[number];
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
interface CliConfig {
|
|
26
|
+
/** The project ID and dataset the Sanity CLI should use to run its commands */
|
|
27
|
+
api?: {
|
|
28
|
+
dataset?: string;
|
|
29
|
+
projectId?: string;
|
|
30
|
+
};
|
|
31
|
+
/** Configuration for custom Sanity apps built with the App SDK */
|
|
32
|
+
app?: {
|
|
33
|
+
/** The entrypoint for your custom app. By default, `src/App.tsx` */
|
|
34
|
+
entry?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Path to an icon file relative to project root.
|
|
37
|
+
* The file must be an SVG.
|
|
38
|
+
*/
|
|
39
|
+
icon?: string;
|
|
40
|
+
/** @deprecated Use deployment.appId */
|
|
41
|
+
id?: string;
|
|
42
|
+
/** The ID for the Sanity organization that manages this application */
|
|
43
|
+
organizationId?: string;
|
|
44
|
+
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
45
|
+
title?: string;
|
|
46
|
+
/** Dashboard visibility of the application. Defaults to `default`. */
|
|
47
|
+
visibility?: AppVisibility;
|
|
48
|
+
};
|
|
49
|
+
/** @deprecated Use deployment.autoUpdates */
|
|
50
|
+
autoUpdates?: boolean;
|
|
51
|
+
/** Options for custom app and Studio deployments */
|
|
52
|
+
deployment?: {
|
|
53
|
+
/**
|
|
54
|
+
* The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.
|
|
55
|
+
* Get your app ID by either:
|
|
56
|
+
* 1. Checking the output of `sanity deploy`, or
|
|
57
|
+
* 2. Checking your project’s Studio tab at https://sanity.io/manage
|
|
58
|
+
*
|
|
59
|
+
* @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.
|
|
60
|
+
* {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}
|
|
61
|
+
*/
|
|
62
|
+
appId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Enable automatic updates for your Studio or custom app’s Sanity dependencies.
|
|
65
|
+
* {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}
|
|
66
|
+
*/
|
|
67
|
+
autoUpdates?: boolean;
|
|
68
|
+
};
|
|
69
|
+
/** Define the GraphQL APIs that the CLI can deploy and interact with */
|
|
70
|
+
graphql?: Array<{
|
|
71
|
+
filterSuffix?: string;
|
|
72
|
+
generation?: 'gen1' | 'gen2' | 'gen3';
|
|
73
|
+
id?: string;
|
|
74
|
+
nonNullDocumentFields?: boolean;
|
|
75
|
+
playground?: boolean;
|
|
76
|
+
source?: string;
|
|
77
|
+
tag?: string;
|
|
78
|
+
workspace?: string;
|
|
79
|
+
}>;
|
|
80
|
+
/** Configuration for the Media Library */
|
|
81
|
+
mediaLibrary?: {
|
|
82
|
+
/** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */
|
|
83
|
+
aspectsPath?: string;
|
|
84
|
+
};
|
|
85
|
+
/** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */
|
|
86
|
+
project?: {
|
|
87
|
+
basePath?: string;
|
|
88
|
+
};
|
|
89
|
+
/** Configuration options for React Compiler */
|
|
90
|
+
reactCompiler?: boolean | PluginOptions;
|
|
91
|
+
/** Wraps the Studio in \<React.StrictMode\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE="true"|"false". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */
|
|
92
|
+
reactStrictMode?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Configuration for schema extraction (`sanity schema extract`)
|
|
95
|
+
*/
|
|
96
|
+
schemaExtraction?: {
|
|
97
|
+
/**
|
|
98
|
+
* Enable schema extraction as part of sanity dev and sanity build
|
|
99
|
+
*/
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* When true, schema fields marked as required will be non-optional in the output.
|
|
103
|
+
* Defaults to `false`
|
|
104
|
+
*/
|
|
105
|
+
enforceRequiredFields?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Output path for the extracted schema file.
|
|
108
|
+
* Defaults to `schema.json` in the working directory.
|
|
109
|
+
*/
|
|
110
|
+
path?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Additional glob patterns to watch for schema changes in watch mode.
|
|
113
|
+
* These extend the default patterns:
|
|
114
|
+
* - `sanity.config.{js,jsx,ts,tsx,mjs}`
|
|
115
|
+
* - `schema*\/**\/*.{js,jsx,ts,tsx,mjs}`
|
|
116
|
+
*/
|
|
117
|
+
watchPatterns?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* The name of the workspace to generate a schema for. Required if your Sanity project has more than one
|
|
120
|
+
* workspace.
|
|
121
|
+
*/
|
|
122
|
+
workspace?: string;
|
|
123
|
+
};
|
|
124
|
+
/** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */
|
|
125
|
+
server?: {
|
|
126
|
+
hostname?: string;
|
|
127
|
+
port?: number;
|
|
128
|
+
};
|
|
129
|
+
/** @deprecated Use deployment.appId */
|
|
130
|
+
studioHost?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Configuration for Sanity typegen
|
|
133
|
+
*/
|
|
134
|
+
typegen?: Partial<TypeGenConfig> & {
|
|
135
|
+
/**
|
|
136
|
+
* Enable typegen as part of sanity dev and sanity build.
|
|
137
|
+
* When enabled, types are generated on startup and when files change.
|
|
138
|
+
* Defaults to `false`
|
|
139
|
+
*/
|
|
140
|
+
enabled?: boolean;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled
|
|
144
|
+
* files during development, which can speed up startup and reloads for large projects.
|
|
145
|
+
* Defaults to `false`.
|
|
146
|
+
*
|
|
147
|
+
* Unstable: may change or be removed without notice while the underlying Vite
|
|
148
|
+
* feature (`experimental.bundledDev`) is experimental.
|
|
149
|
+
* {@link https://vite.dev/guide/rolldown#full-bundle-mode}
|
|
150
|
+
*/
|
|
151
|
+
unstable_bundledDev?: boolean;
|
|
152
|
+
/** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */
|
|
153
|
+
vite?: UserViteConfig;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A raw key-value store for CLI user configuration.
|
|
157
|
+
* Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on
|
|
158
|
+
* arbitrary keys without schema validation.
|
|
159
|
+
*
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
interface ConfigStore {
|
|
163
|
+
/** Remove a key from the config file. */
|
|
164
|
+
delete: (key: string) => void;
|
|
165
|
+
/** Read a value by key. Returns `undefined` if the key does not exist. */
|
|
166
|
+
get: (key: string) => unknown;
|
|
167
|
+
/** Write a value by key, merging it into the existing config. */
|
|
168
|
+
set: (key: string, value: unknown) => void;
|
|
169
|
+
}
|
|
170
|
+
export { TypeGenConfig as a, ConfigStore as i, AppVisibility as n, UserViteConfig as o, CliConfig as r, APP_VISIBILITIES as t };
|
|
171
|
+
//# sourceMappingURL=cliConfig-CbW8neMv.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import { isHttpError } from '@sanity/client';
|
|
3
|
+
import { generateHelpUrl } from '../util/generateHelpUrl.js';
|
|
4
|
+
import { getSanityUrl } from '../util/getSanityUrl.js';
|
|
5
|
+
const enrichedErrors = new WeakSet();
|
|
6
|
+
/**
|
|
7
|
+
* Append login/membership guidance to 401 API errors.
|
|
8
|
+
*
|
|
9
|
+
* Replaces the `onError` requester middleware used with client v7. The client
|
|
10
|
+
* request handler applies the hint after errors have been normalized. Mutates
|
|
11
|
+
* the error message (matching the old middleware behavior) and is idempotent.
|
|
12
|
+
*
|
|
13
|
+
* @param err - The error to enrich
|
|
14
|
+
* @returns The same error, with an enriched message when it is a 401
|
|
15
|
+
* @internal
|
|
16
|
+
*/ export function enrichAuthError(err) {
|
|
17
|
+
if (typeof err !== 'object' || err === null || enrichedErrors.has(err)) return err;
|
|
18
|
+
if (!isHttpError(err) || err.statusCode !== 401) return err;
|
|
19
|
+
enrichedErrors.add(err);
|
|
20
|
+
const projectId = projectIdFromUrl(err.response.url);
|
|
21
|
+
if (projectId && isProjectUserNotFoundError(err.response.body)) {
|
|
22
|
+
err.message = `${err.message}. Add this account as a project member: ${getSanityUrl(`/manage/project/${encodeURIComponent(projectId)}/members`)}.`;
|
|
23
|
+
return err;
|
|
24
|
+
}
|
|
25
|
+
err.message = `${err.message}. You may need to login again with ${styleText('cyan', 'sanity login')}.\nFor more information, see ${generateHelpUrl('cli-errors')}.`;
|
|
26
|
+
return err;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Derive the project ID from a project-hostname API URL
|
|
30
|
+
* (`<projectId>.api.sanity.io` or `.work`). Global-host requests return
|
|
31
|
+
* `undefined`, mirroring the old middleware which only knew the project ID
|
|
32
|
+
* for project-scoped clients.
|
|
33
|
+
*/ function projectIdFromUrl(url) {
|
|
34
|
+
if (typeof url !== 'string') return undefined;
|
|
35
|
+
try {
|
|
36
|
+
const host = new URL(url).hostname;
|
|
37
|
+
return /^([a-z0-9-]+)\.api\.sanity\.(?:io|work)$/.exec(host)?.[1];
|
|
38
|
+
} catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isProjectUserNotFoundError(body) {
|
|
43
|
+
if (typeof body !== 'object' || body === null || !('error' in body)) return false;
|
|
44
|
+
const { error } = body;
|
|
45
|
+
return typeof error === 'object' && error !== null && 'type' in error && error.type === 'projectUserNotFoundError';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=enrichAuthError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors/enrichAuthError.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {isHttpError} from '@sanity/client'\n\nimport {generateHelpUrl} from '../util/generateHelpUrl.js'\nimport {getSanityUrl} from '../util/getSanityUrl.js'\n\nconst enrichedErrors = new WeakSet<object>()\n\n/**\n * Append login/membership guidance to 401 API errors.\n *\n * Replaces the `onError` requester middleware used with client v7. The client\n * request handler applies the hint after errors have been normalized. Mutates\n * the error message (matching the old middleware behavior) and is idempotent.\n *\n * @param err - The error to enrich\n * @returns The same error, with an enriched message when it is a 401\n * @internal\n */\nexport function enrichAuthError<T>(err: T): T {\n if (typeof err !== 'object' || err === null || enrichedErrors.has(err)) return err\n if (!isHttpError(err) || err.statusCode !== 401) return err\n enrichedErrors.add(err)\n\n const projectId = projectIdFromUrl(err.response.url)\n if (projectId && isProjectUserNotFoundError(err.response.body)) {\n err.message = `${err.message}. Add this account as a project member: ${getSanityUrl(`/manage/project/${encodeURIComponent(projectId)}/members`)}.`\n return err\n }\n\n err.message = `${err.message}. You may need to login again with ${styleText('cyan', 'sanity login')}.\\nFor more information, see ${generateHelpUrl('cli-errors')}.`\n return err\n}\n\n/**\n * Derive the project ID from a project-hostname API URL\n * (`<projectId>.api.sanity.io` or `.work`). Global-host requests return\n * `undefined`, mirroring the old middleware which only knew the project ID\n * for project-scoped clients.\n */\nfunction projectIdFromUrl(url: unknown): string | undefined {\n if (typeof url !== 'string') return undefined\n try {\n const host = new URL(url).hostname\n return /^([a-z0-9-]+)\\.api\\.sanity\\.(?:io|work)$/.exec(host)?.[1]\n } catch {\n return undefined\n }\n}\n\nfunction isProjectUserNotFoundError(\n body: unknown,\n): body is {error: {type: 'projectUserNotFoundError'}} {\n if (typeof body !== 'object' || body === null || !('error' in body)) return false\n\n const {error} = body\n return (\n typeof error === 'object' &&\n error !== null &&\n 'type' in error &&\n error.type === 'projectUserNotFoundError'\n )\n}\n"],"names":["styleText","isHttpError","generateHelpUrl","getSanityUrl","enrichedErrors","WeakSet","enrichAuthError","err","has","statusCode","add","projectId","projectIdFromUrl","response","url","isProjectUserNotFoundError","body","message","encodeURIComponent","undefined","host","URL","hostname","exec","error","type"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,WAAW,QAAO,iBAAgB;AAE1C,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AAEpD,MAAMC,iBAAiB,IAAIC;AAE3B;;;;;;;;;;CAUC,GACD,OAAO,SAASC,gBAAmBC,GAAM;IACvC,IAAI,OAAOA,QAAQ,YAAYA,QAAQ,QAAQH,eAAeI,GAAG,CAACD,MAAM,OAAOA;IAC/E,IAAI,CAACN,YAAYM,QAAQA,IAAIE,UAAU,KAAK,KAAK,OAAOF;IACxDH,eAAeM,GAAG,CAACH;IAEnB,MAAMI,YAAYC,iBAAiBL,IAAIM,QAAQ,CAACC,GAAG;IACnD,IAAIH,aAAaI,2BAA2BR,IAAIM,QAAQ,CAACG,IAAI,GAAG;QAC9DT,IAAIU,OAAO,GAAG,GAAGV,IAAIU,OAAO,CAAC,wCAAwC,EAAEd,aAAa,CAAC,gBAAgB,EAAEe,mBAAmBP,WAAW,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClJ,OAAOJ;IACT;IAEAA,IAAIU,OAAO,GAAG,GAAGV,IAAIU,OAAO,CAAC,mCAAmC,EAAEjB,UAAU,QAAQ,gBAAgB,6BAA6B,EAAEE,gBAAgB,cAAc,CAAC,CAAC;IACnK,OAAOK;AACT;AAEA;;;;;CAKC,GACD,SAASK,iBAAiBE,GAAY;IACpC,IAAI,OAAOA,QAAQ,UAAU,OAAOK;IACpC,IAAI;QACF,MAAMC,OAAO,IAAIC,IAAIP,KAAKQ,QAAQ;QAClC,OAAO,2CAA2CC,IAAI,CAACH,OAAO,CAAC,EAAE;IACnE,EAAE,OAAM;QACN,OAAOD;IACT;AACF;AAEA,SAASJ,2BACPC,IAAa;IAEb,IAAI,OAAOA,SAAS,YAAYA,SAAS,QAAQ,CAAE,CAAA,WAAWA,IAAG,GAAI,OAAO;IAE5E,MAAM,EAACQ,KAAK,EAAC,GAAGR;IAChB,OACE,OAAOQ,UAAU,YACjBA,UAAU,QACV,UAAUA,SACVA,MAAMC,IAAI,KAAK;AAEnB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isHttpError } from '@sanity/client';
|
|
2
|
+
import { enrichAuthError } from './enrichAuthError.js';
|
|
2
3
|
/**
|
|
3
4
|
* Coerce an unknown thrown value into an Error instance.
|
|
4
5
|
*
|
|
@@ -16,8 +17,9 @@ import { isHttpError } from '@sanity/client';
|
|
|
16
17
|
* @internal
|
|
17
18
|
*/ export function getErrorMessage(err) {
|
|
18
19
|
if (isHttpError(err)) {
|
|
20
|
+
enrichAuthError(err);
|
|
19
21
|
const body = err.response.body;
|
|
20
|
-
if (typeof body === 'object' && body !== null && 'message' in body && typeof body.message === 'string') {
|
|
22
|
+
if (typeof body === 'object' && body !== null && 'message' in body && typeof body.message === 'string' && err.statusCode !== 401) {
|
|
21
23
|
return body.message;
|
|
22
24
|
}
|
|
23
25
|
return err.message || 'HTTP error';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\n/**\n * Coerce an unknown thrown value into an Error instance.\n *\n * @param value - The thrown value\n * @returns An Error instance (the original if already an Error, otherwise a new one)\n * @internal\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string'\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","toError","value","Error","String","getErrorMessage","err","body","response","message"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C;;;;;;CAMC,GACD,OAAO,SAASC,QAAQC,KAAc;IACpC,OAAOA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF;AAC3D;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBC,GAAY;IAC1C,
|
|
1
|
+
{"version":3,"sources":["../../src/errors/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\nimport {enrichAuthError} from './enrichAuthError.js'\n\n/**\n * Coerce an unknown thrown value into an Error instance.\n *\n * @param value - The thrown value\n * @returns An Error instance (the original if already an Error, otherwise a new one)\n * @internal\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n enrichAuthError(err)\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string' &&\n err.statusCode !== 401\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","enrichAuthError","toError","value","Error","String","getErrorMessage","err","body","response","message","statusCode"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C,SAAQC,eAAe,QAAO,uBAAsB;AAEpD;;;;;;CAMC,GACD,OAAO,SAASC,QAAQC,KAAc;IACpC,OAAOA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF;AAC3D;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBC,GAAY;IAC1C,IAAIP,YAAYO,MAAM;QACpBN,gBAAgBM;QAChB,MAAMC,OAAOD,IAAIE,QAAQ,CAACD,IAAI;QAC9B,IACE,OAAOA,SAAS,YAChBA,SAAS,QACT,aAAaA,QACb,OAAOA,KAAKE,OAAO,KAAK,YACxBH,IAAII,UAAU,KAAK,KACnB;YACA,OAAOH,KAAKE,OAAO;QACrB;QACA,OAAOH,IAAIG,OAAO,IAAI;IACxB;IACA,OAAOH,eAAeH,QAAQG,IAAIG,OAAO,GAAG;AAC9C"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { FetchFunction } from "get-it";
|
|
2
|
+
/**
|
|
3
|
+
* Sanity deployment environment used by a programmatic CLI invocation.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
type SanityEnvironment = 'production' | 'staging';
|
|
1
8
|
/**
|
|
2
9
|
* Explicit, per-invocation execution context for running CLI commands
|
|
3
10
|
* programmatically (e.g. from an MCP server or another embedding host).
|
|
@@ -23,7 +30,14 @@
|
|
|
23
30
|
*
|
|
24
31
|
* @public
|
|
25
32
|
*/
|
|
26
|
-
|
|
33
|
+
interface CliExecutionContext {
|
|
34
|
+
/**
|
|
35
|
+
* Fetch implementation for API requests made during this invocation.
|
|
36
|
+
* Overrides the CLI's default transport (get-it's undici-backed Node
|
|
37
|
+
* fetch). The execution context's transport hygiene — such as stripping
|
|
38
|
+
* the embedding process's lineage header — is applied on top of it.
|
|
39
|
+
*/
|
|
40
|
+
fetch?: FetchFunction;
|
|
27
41
|
/**
|
|
28
42
|
* Sanity deployment environment to use for this invocation.
|
|
29
43
|
* Overrides `SANITY_INTERNAL_ENV`.
|
|
@@ -45,16 +59,6 @@ export declare interface CliExecutionContext {
|
|
|
45
59
|
*/
|
|
46
60
|
token?: string;
|
|
47
61
|
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get the active execution context, if any. Returns `undefined` when running
|
|
51
|
-
* as the regular CLI (process-global behavior applies).
|
|
52
|
-
*
|
|
53
|
-
* @public
|
|
54
|
-
*/
|
|
55
|
-
export declare function getCliExecutionContext():
|
|
56
|
-
CliExecutionContext | undefined;
|
|
57
|
-
|
|
58
62
|
/**
|
|
59
63
|
* Run `fn` with the given execution context active. The context is visible
|
|
60
64
|
* (via {@link getCliExecutionContext}) to all code in the async call graph of
|
|
@@ -63,16 +67,13 @@ export declare function getCliExecutionContext():
|
|
|
63
67
|
*
|
|
64
68
|
* @public
|
|
65
69
|
*/
|
|
66
|
-
|
|
67
|
-
context: CliExecutionContext,
|
|
68
|
-
fn: () => T,
|
|
69
|
-
): T;
|
|
70
|
-
|
|
70
|
+
declare function runWithCliExecutionContext<T>(context: CliExecutionContext, fn: () => T): T;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Get the active execution context, if any. Returns `undefined` when running
|
|
73
|
+
* as the regular CLI (process-global behavior applies).
|
|
73
74
|
*
|
|
74
75
|
* @public
|
|
75
76
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
declare function getCliExecutionContext(): CliExecutionContext | undefined;
|
|
78
|
+
export { CliExecutionContext, SanityEnvironment, getCliExecutionContext, runWithCliExecutionContext };
|
|
79
|
+
//# sourceMappingURL=executionContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/executionContext.ts"],"sourcesContent":["import {AsyncLocalStorage} from 'node:async_hooks'\n\n/**\n * Sanity deployment environment used by a programmatic CLI invocation.\n *\n * @public\n */\nexport type SanityEnvironment = 'production' | 'staging'\n\n/**\n * Explicit, per-invocation execution context for running CLI commands\n * programmatically (e.g. from an MCP server or another embedding host).\n *\n * When a context is active, it overrides the process-global defaults the CLI\n * normally relies on:\n *\n * - `token` takes precedence over `SANITY_AUTH_TOKEN` and the stored CLI\n * config token, and never touches the process-wide token cache\n * - the embedding process's `X_SANITY_LINEAGE` is never propagated to API\n * requests\n * - `stdout`/`stderr` receive the output that commands would otherwise write\n * to the process streams\n * - debug logging is disabled, even when the embedding process enables it\n * - interactivity checks report non-interactive, so commands fail fast with\n * actionable errors instead of prompting\n * - project root resolution from the filesystem is disabled: commands never\n * read (or execute) `sanity.config.ts`/`sanity.cli.ts` files found near the\n * host process's cwd, so project context must come from explicit flags\n * (e.g. `--project-id`)\n *\n * The CLI binary never enters a context, so its behavior is unchanged.\n *\n * @public\n */\nexport interface CliExecutionContext {\n /**\n * Sanity deployment environment to use for this invocation.\n * Overrides `SANITY_INTERNAL_ENV`.\n */\n sanityEnv?: SanityEnvironment\n\n /**\n * Sink for output the command would otherwise write to `process.stderr`.\n * Called once per line, without a trailing newline.\n */\n stderr?: (line: string) => void\n\n /**\n * Sink for output the command would otherwise write to `process.stdout`.\n * Called once per line, without a trailing newline.\n */\n stdout?: (line: string) => void\n\n /**\n * Auth token to use for API clients created during this invocation.\n * Overrides `SANITY_AUTH_TOKEN` and the stored CLI config token.\n */\n token?: string\n}\n\n// Anchored on globalThis (same pattern as CLI_TELEMETRY_SYMBOL) so that the\n// context survives dual module instances: an embedding host may import this\n// module from source (e.g. via vitest or a bundler) while oclif loads command\n// classes from dist, and both must observe the same AsyncLocalStorage.\nconst STORAGE_SYMBOL = Symbol.for('sanity.cli.executionContext')\n\nconst globalStorage = globalThis as {\n [STORAGE_SYMBOL]?: AsyncLocalStorage<CliExecutionContext>\n}\n\nconst storage = (globalStorage[STORAGE_SYMBOL] ??= new AsyncLocalStorage<CliExecutionContext>())\n\n/**\n * Run `fn` with the given execution context active. The context is visible\n * (via {@link getCliExecutionContext}) to all code in the async call graph of\n * `fn`, and invisible to everything else — concurrent invocations with\n * different contexts are fully isolated.\n *\n * @public\n */\nexport function runWithCliExecutionContext<T>(context: CliExecutionContext, fn: () => T): T {\n return storage.run(context, fn)\n}\n\n/**\n * Get the active execution context, if any. Returns `undefined` when running\n * as the regular CLI (process-global behavior applies).\n *\n * @public\n */\nexport function getCliExecutionContext(): CliExecutionContext | undefined {\n return storage.getStore()\n}\n"],"names":["AsyncLocalStorage","STORAGE_SYMBOL","Symbol","for","globalStorage","globalThis","storage","runWithCliExecutionContext","context","fn","run","getCliExecutionContext","getStore"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,mBAAkB;
|
|
1
|
+
{"version":3,"sources":["../src/executionContext.ts"],"sourcesContent":["import {AsyncLocalStorage} from 'node:async_hooks'\n\nimport {type FetchFunction} from 'get-it'\n\n/**\n * Sanity deployment environment used by a programmatic CLI invocation.\n *\n * @public\n */\nexport type SanityEnvironment = 'production' | 'staging'\n\n/**\n * Explicit, per-invocation execution context for running CLI commands\n * programmatically (e.g. from an MCP server or another embedding host).\n *\n * When a context is active, it overrides the process-global defaults the CLI\n * normally relies on:\n *\n * - `token` takes precedence over `SANITY_AUTH_TOKEN` and the stored CLI\n * config token, and never touches the process-wide token cache\n * - the embedding process's `X_SANITY_LINEAGE` is never propagated to API\n * requests\n * - `stdout`/`stderr` receive the output that commands would otherwise write\n * to the process streams\n * - debug logging is disabled, even when the embedding process enables it\n * - interactivity checks report non-interactive, so commands fail fast with\n * actionable errors instead of prompting\n * - project root resolution from the filesystem is disabled: commands never\n * read (or execute) `sanity.config.ts`/`sanity.cli.ts` files found near the\n * host process's cwd, so project context must come from explicit flags\n * (e.g. `--project-id`)\n *\n * The CLI binary never enters a context, so its behavior is unchanged.\n *\n * @public\n */\nexport interface CliExecutionContext {\n /**\n * Fetch implementation for API requests made during this invocation.\n * Overrides the CLI's default transport (get-it's undici-backed Node\n * fetch). The execution context's transport hygiene — such as stripping\n * the embedding process's lineage header — is applied on top of it.\n */\n fetch?: FetchFunction\n\n /**\n * Sanity deployment environment to use for this invocation.\n * Overrides `SANITY_INTERNAL_ENV`.\n */\n sanityEnv?: SanityEnvironment\n\n /**\n * Sink for output the command would otherwise write to `process.stderr`.\n * Called once per line, without a trailing newline.\n */\n stderr?: (line: string) => void\n\n /**\n * Sink for output the command would otherwise write to `process.stdout`.\n * Called once per line, without a trailing newline.\n */\n stdout?: (line: string) => void\n\n /**\n * Auth token to use for API clients created during this invocation.\n * Overrides `SANITY_AUTH_TOKEN` and the stored CLI config token.\n */\n token?: string\n}\n\n// Anchored on globalThis (same pattern as CLI_TELEMETRY_SYMBOL) so that the\n// context survives dual module instances: an embedding host may import this\n// module from source (e.g. via vitest or a bundler) while oclif loads command\n// classes from dist, and both must observe the same AsyncLocalStorage.\nconst STORAGE_SYMBOL = Symbol.for('sanity.cli.executionContext')\n\nconst globalStorage = globalThis as {\n [STORAGE_SYMBOL]?: AsyncLocalStorage<CliExecutionContext>\n}\n\nconst storage = (globalStorage[STORAGE_SYMBOL] ??= new AsyncLocalStorage<CliExecutionContext>())\n\n/**\n * Run `fn` with the given execution context active. The context is visible\n * (via {@link getCliExecutionContext}) to all code in the async call graph of\n * `fn`, and invisible to everything else — concurrent invocations with\n * different contexts are fully isolated.\n *\n * @public\n */\nexport function runWithCliExecutionContext<T>(context: CliExecutionContext, fn: () => T): T {\n return storage.run(context, fn)\n}\n\n/**\n * Get the active execution context, if any. Returns `undefined` when running\n * as the regular CLI (process-global behavior applies).\n *\n * @public\n */\nexport function getCliExecutionContext(): CliExecutionContext | undefined {\n return storage.getStore()\n}\n"],"names":["AsyncLocalStorage","STORAGE_SYMBOL","Symbol","for","globalStorage","globalThis","storage","runWithCliExecutionContext","context","fn","run","getCliExecutionContext","getStore"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,mBAAkB;AAsElD,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,uEAAuE;AACvE,MAAMC,iBAAiBC,OAAOC,GAAG,CAAC;AAElC,MAAMC,gBAAgBC;AAItB,MAAMC,UAAWF,aAAa,CAACH,eAAe,KAAK,IAAID;AAEvD;;;;;;;CAOC,GACD,OAAO,SAASO,2BAA8BC,OAA4B,EAAEC,EAAW;IACrF,OAAOH,QAAQI,GAAG,CAACF,SAASC;AAC9B;AAEA;;;;;CAKC,GACD,OAAO,SAASE;IACd,OAAOL,QAAQM,QAAQ;AACzB"}
|
package/dist/exitCodes.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @see CLAUDE.md "Exit Code Convention" for usage guidance and examples.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
declare const exitCodes: {
|
|
11
11
|
/** Something went wrong that is not the user's fault (API errors, network, missing config, etc.). */
|
|
12
12
|
readonly RUNTIME_ERROR: 1;
|
|
13
13
|
/** The user interrupted via Ctrl+C (128 + SIGINT). Handled by SanityCommand.catch(). */
|
|
@@ -19,5 +19,5 @@ export declare const exitCodes: {
|
|
|
19
19
|
/** The user declined a confirmation or chose not to proceed. */
|
|
20
20
|
readonly USER_ABORT: 3;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
export { exitCodes };
|
|
23
|
+
//# sourceMappingURL=exitCodes.d.ts.map
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { i as ConfigStore, r as CliConfig } from "./cliConfig-CbW8neMv.js";
|
|
2
|
+
import { t as ProjectRootResult } from "./recursivelyResolveProjectRoot-BE54uEP6.js";
|
|
3
|
+
import { z } from "zod/mini";
|
|
4
|
+
import { Workspace } from "sanity";
|
|
5
|
+
/**
|
|
6
|
+
* Clear the in-process token cache so the next `getCliToken()` call
|
|
7
|
+
* re-reads from disk or the environment.
|
|
8
|
+
*
|
|
9
|
+
* Called automatically by `setCliUserConfig('authToken', ...)`.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
declare function clearCliTokenCache(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get the CLI authentication token from the environment or the config file
|
|
16
|
+
*
|
|
17
|
+
* @returns A promise that resolves to a CLI token, or undefined if no token is found
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare function getCliToken(): Promise<string | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Set the config value for the given property.
|
|
23
|
+
* Validates that the passed value adheres to the defined CLI config schema.
|
|
24
|
+
*
|
|
25
|
+
* @param prop - The property to set the value for
|
|
26
|
+
* @param value - The value to set
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
declare function setCliUserConfig(prop: 'authToken', value: string | undefined): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the config value for the given property
|
|
32
|
+
*
|
|
33
|
+
* @param prop - The property to get the value for
|
|
34
|
+
* @returns The value of the given property
|
|
35
|
+
*/
|
|
36
|
+
declare function getCliUserConfig(prop: 'authToken'): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get a key-value store backed by the CLI user configuration file
|
|
39
|
+
* (`~/.config/sanity/config.json`).
|
|
40
|
+
*
|
|
41
|
+
* Each call to `get`, `set`, or `delete` performs a full synchronous
|
|
42
|
+
* read-modify-write cycle. This is intentional: sync I/O prevents
|
|
43
|
+
* intra-process race conditions that occurred with the previous async
|
|
44
|
+
* (configstore-backed) implementation.
|
|
45
|
+
*
|
|
46
|
+
* Note: there is no file-level locking, so concurrent writes from
|
|
47
|
+
* separate CLI processes could still conflict. In practice this is
|
|
48
|
+
* unlikely since CLI config writes are rare and user-initiated.
|
|
49
|
+
*
|
|
50
|
+
* @returns A {@link ConfigStore} for the CLI config file
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
declare function getUserConfig(): ConfigStore;
|
|
54
|
+
/**
|
|
55
|
+
* Get the CLI config for a project, given the root path.
|
|
56
|
+
*
|
|
57
|
+
* Results are cached in-memory keyed by rootPath for the lifetime of the
|
|
58
|
+
* process. Since the CLI always runs from a single project root, the config
|
|
59
|
+
* won't change during a command's execution, so caching avoids redundant
|
|
60
|
+
* filesystem reads and jiti imports from the prerun hook, SanityCommand
|
|
61
|
+
* helpers, and action files.
|
|
62
|
+
*
|
|
63
|
+
* If loading fails the cached promise is evicted so the next call retries.
|
|
64
|
+
*
|
|
65
|
+
* Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`
|
|
66
|
+
* (e.g. a dev-server watcher) should use {@link getCliConfigUncached}
|
|
67
|
+
* instead — it bypasses both this in-memory cache and Node's module cache.
|
|
68
|
+
*
|
|
69
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
70
|
+
* @returns The CLI config
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
declare function getCliConfig(rootPath: string): Promise<CliConfig>;
|
|
74
|
+
/**
|
|
75
|
+
* Read the CLI config for a project from disk, bypassing both the
|
|
76
|
+
* `getCliConfig` in-memory cache and Node's module cache. Each call locates
|
|
77
|
+
* `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,
|
|
78
|
+
* re-imports, and re-validates.
|
|
79
|
+
*
|
|
80
|
+
* Use this when the config file is expected to change during the process's
|
|
81
|
+
* lifetime — typically a dev-server watcher that needs the new values picked
|
|
82
|
+
* up after each save. One-shot CLI invocations should prefer
|
|
83
|
+
* {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action
|
|
84
|
+
* files share a single load.
|
|
85
|
+
*
|
|
86
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
87
|
+
* @returns The freshly loaded CLI config
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
declare function getCliConfigUncached(rootPath: string): Promise<CliConfig>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the CLI config for a project synchronously, given the root path.
|
|
93
|
+
*
|
|
94
|
+
* This loads the CLI config in the main thread using tsx/register for TypeScript support.
|
|
95
|
+
* Note: This is a synchronous operation and does not use worker threads like the async version.
|
|
96
|
+
*
|
|
97
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
98
|
+
* @returns The CLI config
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
declare function getCliConfigSync(rootPath: string): CliConfig;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve project root directory and type.
|
|
104
|
+
*
|
|
105
|
+
* Project root is:
|
|
106
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
107
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
108
|
+
*
|
|
109
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
110
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
declare function findProjectRoot(cwd: string): Promise<ProjectRootResult>;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve project root directory and type synchronously.
|
|
117
|
+
*
|
|
118
|
+
* Project root is:
|
|
119
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
120
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
121
|
+
*
|
|
122
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
123
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
124
|
+
*
|
|
125
|
+
* @param cwd - Current working directory to start searching from
|
|
126
|
+
* @returns Project root result
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
declare function findProjectRootSync(cwd: string): ProjectRootResult;
|
|
130
|
+
declare const rawConfigSchema: z.ZodMiniUnion<readonly [z.ZodMiniArray<z.ZodMiniObject<{
|
|
131
|
+
basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
132
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
133
|
+
plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
134
|
+
schema: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
135
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
136
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
137
|
+
}, z.core.$loose>>;
|
|
138
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
139
|
+
unstable_sources: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
140
|
+
dataset: z.ZodMiniString<string>;
|
|
141
|
+
projectId: z.ZodMiniString<string>;
|
|
142
|
+
schema: z.ZodMiniObject<{
|
|
143
|
+
_original: z.ZodMiniObject<{
|
|
144
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
145
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
146
|
+
}, z.core.$loose>;
|
|
147
|
+
}, z.core.$loose>;
|
|
148
|
+
}, z.core.$loose>>>;
|
|
149
|
+
dataset: z.ZodMiniString<string>;
|
|
150
|
+
projectId: z.ZodMiniString<string>;
|
|
151
|
+
}, z.core.$loose>>, z.ZodMiniObject<{
|
|
152
|
+
basePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
153
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
154
|
+
plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
155
|
+
schema: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
156
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
157
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
158
|
+
}, z.core.$loose>>;
|
|
159
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
160
|
+
unstable_sources: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
161
|
+
dataset: z.ZodMiniString<string>;
|
|
162
|
+
projectId: z.ZodMiniString<string>;
|
|
163
|
+
schema: z.ZodMiniObject<{
|
|
164
|
+
_original: z.ZodMiniObject<{
|
|
165
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
166
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
167
|
+
}, z.core.$loose>;
|
|
168
|
+
}, z.core.$loose>;
|
|
169
|
+
}, z.core.$loose>>>;
|
|
170
|
+
dataset: z.ZodMiniString<string>;
|
|
171
|
+
projectId: z.ZodMiniString<string>;
|
|
172
|
+
}, z.core.$loose>]>;
|
|
173
|
+
declare const resolvedConfigSchema: z.ZodMiniArray<z.ZodMiniObject<{
|
|
174
|
+
basePath: z.ZodMiniString<string>;
|
|
175
|
+
name: z.ZodMiniString<string>;
|
|
176
|
+
plugins: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
177
|
+
title: z.ZodMiniString<string>;
|
|
178
|
+
unstable_sources: z.ZodMiniArray<z.ZodMiniObject<{
|
|
179
|
+
dataset: z.ZodMiniString<string>;
|
|
180
|
+
projectId: z.ZodMiniString<string>;
|
|
181
|
+
schema: z.ZodMiniObject<{
|
|
182
|
+
_original: z.ZodMiniObject<{
|
|
183
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
184
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
185
|
+
}, z.core.$loose>;
|
|
186
|
+
}, z.core.$loose>;
|
|
187
|
+
}, z.core.$loose>>;
|
|
188
|
+
dataset: z.ZodMiniString<string>;
|
|
189
|
+
projectId: z.ZodMiniString<string>;
|
|
190
|
+
schema: z.ZodMiniObject<{
|
|
191
|
+
_original: z.ZodMiniObject<{
|
|
192
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
193
|
+
types: z.ZodMiniArray<z.ZodMiniObject<{}, z.core.$loose>>;
|
|
194
|
+
}, z.core.$loose>;
|
|
195
|
+
}, z.core.$loose>;
|
|
196
|
+
}, z.core.$loose>>;
|
|
197
|
+
type RawStudioConfig = z.infer<typeof rawConfigSchema>;
|
|
198
|
+
type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>;
|
|
199
|
+
/**
|
|
200
|
+
* Get the studio config for a project, given the root path.
|
|
201
|
+
*
|
|
202
|
+
* @param rootPath - The root path for the project
|
|
203
|
+
* @returns The studio config (some properties may be missing)
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
declare function getStudioConfig(rootPath: string, options: {
|
|
207
|
+
resolvePlugins: true;
|
|
208
|
+
}): Promise<ResolvedStudioConfig>;
|
|
209
|
+
declare function getStudioConfig(rootPath: string, options: {
|
|
210
|
+
resolvePlugins: false;
|
|
211
|
+
}): Promise<RawStudioConfig>;
|
|
212
|
+
/**
|
|
213
|
+
* Resolves the workspaces from the studio config.
|
|
214
|
+
*
|
|
215
|
+
* NOTE: This function should only be called from a worker thread.
|
|
216
|
+
*
|
|
217
|
+
* @param configPath - The path to the studio config
|
|
218
|
+
* @returns The workspaces
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
declare function getStudioWorkspaces(configPath: string): Promise<Workspace[]>;
|
|
222
|
+
/**
|
|
223
|
+
* Checks if the given value conforms to a minimum studio config shape.
|
|
224
|
+
*
|
|
225
|
+
* @param value - The value to check
|
|
226
|
+
* @returns Whether the value is a studio config
|
|
227
|
+
* @internal
|
|
228
|
+
*/
|
|
229
|
+
declare function isStudioConfig(value: unknown): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
interface PathResult {
|
|
234
|
+
exists: boolean;
|
|
235
|
+
path: string;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Finds the path for a given set of files.
|
|
239
|
+
*
|
|
240
|
+
* @param basePath - The base path to search for files.
|
|
241
|
+
* @param files - The files to search for.
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
declare function findPathForFiles(basePath: string, files: string[]): Promise<PathResult[]>;
|
|
245
|
+
/**
|
|
246
|
+
* Resolves to a string containing the found config path, otherwise throws an error.
|
|
247
|
+
* Also throws if Sanity v2 studio root is found.
|
|
248
|
+
*
|
|
249
|
+
* @param basePath - The base path to start searching from
|
|
250
|
+
* @returns A promise that resolves to a string containing the found config path
|
|
251
|
+
* @throws On multiple config files found, if v2 studio root found, or no config found
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
254
|
+
declare function findStudioConfigPath(basePath: string): Promise<string>;
|
|
255
|
+
/**
|
|
256
|
+
* Tries to find the studio config path, returning `undefined` if not found.
|
|
257
|
+
*
|
|
258
|
+
* @param basePath - The base path to start searching from
|
|
259
|
+
* @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
|
|
260
|
+
* @throws On errors other than config not found
|
|
261
|
+
* @internal
|
|
262
|
+
*/
|
|
263
|
+
declare function tryFindStudioConfigPath(basePath: string): Promise<string | undefined>;
|
|
264
|
+
export { getStudioWorkspaces as a, findProjectRoot as c, getCliConfigUncached as d, getCliToken as f, clearCliTokenCache as g, setCliUserConfig as h, isStudioConfig as i, getCliConfigSync as l, getUserConfig as m, tryFindStudioConfigPath as n, getStudioConfig as o, getCliUserConfig as p, findPathForFiles as r, findProjectRootSync as s, findStudioConfigPath as t, getCliConfig as u };
|
|
265
|
+
//# sourceMappingURL=findStudioConfigPath-DcKlHhyW.d.ts.map
|