@sanity/cli-core 2.8.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/debug.js +8 -0
- package/dist/_exports/debug.js.map +1 -1
- package/dist/_exports/undeploy.d.ts +15 -19
- package/dist/_exports/undeploy.js +1 -3
- package/dist/_exports/undeploy.js.map +1 -1
- package/dist/apiClient.js +6 -2
- package/dist/apiClient.js.map +1 -1
- package/dist/executionContext.d.ts +3 -0
- package/dist/executionContext.js.map +1 -1
- package/dist/request/createIsolatedRequester.js +75 -0
- package/dist/request/createIsolatedRequester.js.map +1 -0
- package/dist/request/createRequester.js +3 -1
- package/dist/request/createRequester.js.map +1 -1
- package/dist/ux/spinner.js +70 -9
- package/dist/ux/spinner.js.map +1 -1
- package/package.json +4 -4
package/dist/_exports/debug.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import debugIt from 'debug';
|
|
2
|
+
import { getCliExecutionContext } from '../executionContext.js';
|
|
2
3
|
/**
|
|
3
4
|
* `debug` instance for the CLI
|
|
4
5
|
*
|
|
5
6
|
* @internal
|
|
6
7
|
*/ export const debug = debugIt('sanity:cli');
|
|
8
|
+
const defaultLog = debugIt.log;
|
|
9
|
+
debug.log = (...args)=>{
|
|
10
|
+
// DEBUG belongs to the embedding process, not to an individual invocation.
|
|
11
|
+
// Suppress it inside the execution context so it cannot bypass output sinks or expose request details to unrelated host logs.
|
|
12
|
+
if (getCliExecutionContext()) return;
|
|
13
|
+
defaultLog(...args);
|
|
14
|
+
};
|
|
7
15
|
/**
|
|
8
16
|
* Get a `debug` instance which extends the CLI debug instance with the given namespace,
|
|
9
17
|
* eg namespace would be `sanity:cli:<providedNamespace>`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/debug.ts"],"sourcesContent":["import debugIt from 'debug'\n\n/**\n * `debug` instance for the CLI\n *\n * @internal\n */\nexport const debug = debugIt('sanity:cli')\n\n/**\n * Get a `debug` instance which extends the CLI debug instance with the given namespace,\n * eg namespace would be `sanity:cli:<providedNamespace>`\n *\n * @param namespace - The namespace to extend the CLI debug instance with\n * @returns The extended `debug` instance\n */\nexport const subdebug = (namespace: string) => debug.extend(namespace)\n"],"names":["debugIt","debug","subdebug","namespace","extend"],"mappings":"AAAA,OAAOA,aAAa,QAAO;AAE3B;;;;CAIC,GACD,OAAO,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/debug.ts"],"sourcesContent":["import debugIt from 'debug'\n\nimport {getCliExecutionContext} from '../executionContext.js'\n\n/**\n * `debug` instance for the CLI\n *\n * @internal\n */\nexport const debug = debugIt('sanity:cli')\n\nconst defaultLog: (...args: unknown[]) => void = debugIt.log\ndebug.log = (...args: unknown[]) => {\n // DEBUG belongs to the embedding process, not to an individual invocation.\n // Suppress it inside the execution context so it cannot bypass output sinks or expose request details to unrelated host logs.\n if (getCliExecutionContext()) return\n defaultLog(...args)\n}\n\n/**\n * Get a `debug` instance which extends the CLI debug instance with the given namespace,\n * eg namespace would be `sanity:cli:<providedNamespace>`\n *\n * @param namespace - The namespace to extend the CLI debug instance with\n * @returns The extended `debug` instance\n */\nexport const subdebug = (namespace: string) => debug.extend(namespace)\n"],"names":["debugIt","getCliExecutionContext","debug","defaultLog","log","args","subdebug","namespace","extend"],"mappings":"AAAA,OAAOA,aAAa,QAAO;AAE3B,SAAQC,sBAAsB,QAAO,yBAAwB;AAE7D;;;;CAIC,GACD,OAAO,MAAMC,QAAQF,QAAQ,cAAa;AAE1C,MAAMG,aAA2CH,QAAQI,GAAG;AAC5DF,MAAME,GAAG,GAAG,CAAC,GAAGC;IACd,2EAA2E;IAC3E,8HAA8H;IAC9H,IAAIJ,0BAA0B;IAC9BE,cAAcE;AAChB;AAEA;;;;;;CAMC,GACD,OAAO,MAAMC,WAAW,CAACC,YAAsBL,MAAMM,MAAM,CAACD,WAAU"}
|
|
@@ -25,36 +25,32 @@ export declare interface UndeployConfigTarget extends UndeployTargetDetails {
|
|
|
25
25
|
id: null;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** Collected locally, so a dry run reports it too. */
|
|
29
|
+
export declare interface UndeployPayload {
|
|
30
|
+
/** The configured `deployment.appId`; `null` when none is set. */
|
|
31
|
+
appId: string | null;
|
|
32
|
+
type: "coreApp" | "studio";
|
|
33
|
+
/** Media-library config summary. */
|
|
34
|
+
config?: string;
|
|
35
|
+
services?: object[];
|
|
36
|
+
views?: object[];
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
/**
|
|
29
40
|
* What an undeploy deletes, resolved once and read by every report — the
|
|
30
41
|
* dry-run plan, the `--json` payloads, and the real run's confirmation prompt —
|
|
31
|
-
* so the human and machine outputs can't drift.
|
|
32
|
-
* variants with backend-specific fields; they serialize into `--json` as-is,
|
|
33
|
-
* except the report-only `summary`.
|
|
42
|
+
* so the human and machine outputs can't drift.
|
|
34
43
|
*/
|
|
35
44
|
export declare type UndeployTarget =
|
|
36
45
|
UndeployApplicationTarget | UndeployConfigTarget;
|
|
37
46
|
|
|
38
47
|
declare interface UndeployTargetDetails {
|
|
39
|
-
/** Details of the deployment currently being served; `null` when none is live. */
|
|
40
|
-
activeDeployment: {
|
|
41
|
-
deployedAt: string;
|
|
42
|
-
deployedBy: string;
|
|
43
|
-
} | null;
|
|
44
|
-
/** Hostname the application is served from; freed for anyone to claim after undeploy. */
|
|
45
|
-
appHost: string | null;
|
|
46
|
-
createdAt: string | null;
|
|
47
|
-
organizationId: string | null;
|
|
48
|
-
projectId: string | null;
|
|
49
48
|
title: string | null;
|
|
50
49
|
type: "coreApp" | "studio";
|
|
51
|
-
/** Where the deployed studio/app is currently reachable. */
|
|
52
50
|
url: string | null;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* the adapter puts on its target, so the report can't drift from the payload.
|
|
57
|
-
*/
|
|
51
|
+
application?: object;
|
|
52
|
+
payload?: UndeployPayload;
|
|
53
|
+
/** Human-report lines only; never serialized. */
|
|
58
54
|
summary?: string[];
|
|
59
55
|
}
|
|
60
56
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What an undeploy deletes, resolved once and read by every report — the
|
|
3
3
|
* dry-run plan, the `--json` payloads, and the real run's confirmation prompt —
|
|
4
|
-
* so the human and machine outputs can't drift.
|
|
5
|
-
* variants with backend-specific fields; they serialize into `--json` as-is,
|
|
6
|
-
* except the report-only `summary`.
|
|
4
|
+
* so the human and machine outputs can't drift.
|
|
7
5
|
*/ /**
|
|
8
6
|
* The parts of an undeploy that differ per application backend. The shared
|
|
9
7
|
* sequence — mode selection, target reporting, confirmation, error handling —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["/**\n * What an undeploy deletes, resolved once and read by every report — the\n * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —\n * so the human and machine outputs can't drift
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/undeploy.ts"],"sourcesContent":["/**\n * What an undeploy deletes, resolved once and read by every report — the\n * dry-run plan, the `--json` payloads, and the real run's confirmation prompt —\n * so the human and machine outputs can't drift.\n */\nexport type UndeployTarget = UndeployApplicationTarget | UndeployConfigTarget\n\n/** An undeploy that deletes the application, along with all its deployments. */\nexport interface UndeployApplicationTarget extends UndeployTargetDetails {\n deletes: 'application'\n id: string\n}\n\n/** An undeploy that deletes an installation's deployed config; the installation stays installed. */\nexport interface UndeployConfigTarget extends UndeployTargetDetails {\n deletes: 'config'\n id: null\n}\n\ninterface UndeployTargetDetails {\n title: string | null\n type: 'coreApp' | 'studio'\n url: string | null\n\n application?: object\n payload?: UndeployPayload\n /** Human-report lines only; never serialized. */\n summary?: string[]\n}\n\n/** Collected locally, so a dry run reports it too. */\nexport interface UndeployPayload {\n /** The configured `deployment.appId`; `null` when none is set. */\n appId: string | null\n type: 'coreApp' | 'studio'\n\n /** Media-library config summary. */\n config?: string\n services?: object[]\n views?: object[]\n}\n\nexport type UndeployTargetResolution<TTarget extends UndeployTarget = UndeployTarget> =\n | {message: string; solution?: string; type: 'none'}\n | {target: TTarget; type: 'found'}\n\n/**\n * The parts of an undeploy that differ per application backend. The shared\n * sequence — mode selection, target reporting, confirmation, error handling —\n * lives in the host CLI's runner; adapters only resolve and delete.\n */\nexport interface UndeployAdapter<TTarget extends UndeployTarget = UndeployTarget> {\n /** Resolves what an undeploy would delete; read-only. */\n resolveTarget(): Promise<UndeployTargetResolution<TTarget>>\n type: 'coreApp' | 'studio'\n /** Deletes the target — the only mutating step, never run on a dry run. */\n undeploy(target: TTarget): Promise<void>\n}\n"],"names":[],"mappings":"AAAA;;;;CAIC,GA0CD;;;;CAIC,GACD,WAMC"}
|
package/dist/apiClient.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
import { createClient, requester as defaultRequester, isHttpError } from '@sanity/client';
|
|
3
3
|
import { getCliToken } from './config/cli/cliUserConfig.js';
|
|
4
|
+
import { getCliExecutionContext } from './executionContext.js';
|
|
5
|
+
import { createIsolatedRequester } from './request/createIsolatedRequester.js';
|
|
4
6
|
import { generateHelpUrl } from './util/generateHelpUrl.js';
|
|
5
7
|
import { getSanityUrl } from './util/getSanityUrl.js';
|
|
6
8
|
import { isStaging } from './util/isStaging.js';
|
|
@@ -14,7 +16,8 @@ const CLI_REQUEST_TAG_PREFIX = 'sanity.cli';
|
|
|
14
16
|
* @param options - The options to use for the client.
|
|
15
17
|
* @returns Promise that resolves to a configured Sanity API client.
|
|
16
18
|
*/ export async function getGlobalCliClient({ requireUser, token: providedToken, unauthenticated, ...config }) {
|
|
17
|
-
const
|
|
19
|
+
const context = getCliExecutionContext();
|
|
20
|
+
const requester = context ? createIsolatedRequester() : defaultRequester.clone();
|
|
18
21
|
requester.use(authErrors());
|
|
19
22
|
const apiHost = isStaging() ? STAGING_API_HOST : undefined;
|
|
20
23
|
// Use the provided token if set, otherwise fall back to the stored CLI token (unless unauthenticated)
|
|
@@ -45,7 +48,8 @@ const CLI_REQUEST_TAG_PREFIX = 'sanity.cli';
|
|
|
45
48
|
* @param options - The options to use for the client.
|
|
46
49
|
* @returns Promise that resolves to a configured Sanity API client.
|
|
47
50
|
*/ export async function getProjectCliClient({ requireUser, token: providedToken, ...config }) {
|
|
48
|
-
const
|
|
51
|
+
const context = getCliExecutionContext();
|
|
52
|
+
const requester = context ? createIsolatedRequester() : defaultRequester.clone();
|
|
49
53
|
requester.use(authErrors(config.projectId));
|
|
50
54
|
const apiHost = isStaging() ? STAGING_API_HOST : undefined;
|
|
51
55
|
// Use the provided token if it is set, otherwise get the token from the config file
|
package/dist/apiClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/apiClient.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n type ClientConfig,\n type ClientError,\n createClient,\n requester as defaultRequester,\n isHttpError,\n type SanityClient,\n type ServerError,\n} from '@sanity/client'\n\nimport {getCliToken} from './config/cli/cliUserConfig.js'\nimport {generateHelpUrl} from './util/generateHelpUrl.js'\nimport {getSanityUrl} from './util/getSanityUrl.js'\nimport {isStaging} from './util/isStaging.js'\n\nconst STAGING_API_HOST = 'https://api.sanity.work'\n\nconst CLI_REQUEST_TAG_PREFIX = 'sanity.cli'\n\n/**\n * @public\n */\nexport interface GlobalCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n\n /**\n * Whether to skip reading the stored CLI token. When `true`, the client will\n * have no token unless one is explicitly provided.\n * Default: `false`.\n */\n unauthenticated?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getGlobalCliClient({\n requireUser,\n token: providedToken,\n unauthenticated,\n ...config\n}: GlobalCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const apiHost = isStaging() ? STAGING_API_HOST : undefined\n\n // Use the provided token if set, otherwise fall back to the stored CLI token (unless unauthenticated)\n const token = providedToken || (unauthenticated ? undefined : await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: false,\n ...config,\n })\n}\n\n/**\n * @public\n */\nexport interface ProjectCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * The project ID to use for this client.\n */\n projectId: string\n\n /**\n * The dataset to use for this client.\n */\n dataset?: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"project\" (scoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getProjectCliClient({\n requireUser,\n token: providedToken,\n ...config\n}: ProjectCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors(config.projectId))\n\n const apiHost = isStaging() ? STAGING_API_HOST : undefined\n\n // Use the provided token if it is set, otherwise get the token from the config file\n const token = providedToken || (await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: true,\n ...config,\n })\n}\n\n/**\n * `get-it` middleware that checks for 401 authentication errors and extends the error with more\n * helpful guidance on what to do next.\n *\n * @returns get-it middleware with `onError` handler\n * @internal\n */\nfunction authErrors(projectId?: string) {\n return {\n onError: (err: Error | null) => {\n if (!err || !isReqResError(err)) {\n return err\n }\n\n const statusCode = isHttpError(err) && err.statusCode\n if (statusCode === 401) {\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 }\n\n return err\n },\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\nfunction isReqResError(err: Error): err is ClientError | ServerError {\n return Object.prototype.hasOwnProperty.call(err, 'response')\n}\n"],"names":["styleText","createClient","requester","defaultRequester","isHttpError","getCliToken","generateHelpUrl","getSanityUrl","isStaging","STAGING_API_HOST","CLI_REQUEST_TAG_PREFIX","getGlobalCliClient","requireUser","token","providedToken","unauthenticated","config","clone","use","authErrors","apiHost","undefined","Error","ignoreBrowserTokenWarning","requestTagPrefix","useCdn","useProjectHostname","getProjectCliClient","projectId","onError","err","isReqResError","statusCode","isProjectUserNotFoundError","response","body","message","encodeURIComponent","error","type","Object","prototype","hasOwnProperty","call"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAGEC,YAAY,EACZC,aAAaC,gBAAgB,EAC7BC,WAAW,QAGN,iBAAgB;AAEvB,SAAQC,WAAW,QAAO,gCAA+B;AACzD,SAAQC,eAAe,QAAO,4BAA2B;AACzD,SAAQC,YAAY,QAAO,yBAAwB;AACnD,SAAQC,SAAS,QAAO,sBAAqB;AAE7C,MAAMC,mBAAmB;AAEzB,MAAMC,yBAAyB;AA0B/B;;;;;;;CAOC,GACD,OAAO,eAAeC,mBAAmB,EACvCC,WAAW,EACXC,OAAOC,aAAa,EACpBC,eAAe,EACf,GAAGC,QACoB;IACvB,
|
|
1
|
+
{"version":3,"sources":["../src/apiClient.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n type ClientConfig,\n type ClientError,\n createClient,\n requester as defaultRequester,\n isHttpError,\n type SanityClient,\n type ServerError,\n} from '@sanity/client'\n\nimport {getCliToken} from './config/cli/cliUserConfig.js'\nimport {getCliExecutionContext} from './executionContext.js'\nimport {createIsolatedRequester} from './request/createIsolatedRequester.js'\nimport {generateHelpUrl} from './util/generateHelpUrl.js'\nimport {getSanityUrl} from './util/getSanityUrl.js'\nimport {isStaging} from './util/isStaging.js'\n\nconst STAGING_API_HOST = 'https://api.sanity.work'\n\nconst CLI_REQUEST_TAG_PREFIX = 'sanity.cli'\n\n/**\n * @public\n */\nexport interface GlobalCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n\n /**\n * Whether to skip reading the stored CLI token. When `true`, the client will\n * have no token unless one is explicitly provided.\n * Default: `false`.\n */\n unauthenticated?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getGlobalCliClient({\n requireUser,\n token: providedToken,\n unauthenticated,\n ...config\n}: GlobalCliClientOptions): Promise<SanityClient> {\n const context = getCliExecutionContext()\n const requester = context ? createIsolatedRequester() : defaultRequester.clone()\n requester.use(authErrors())\n\n const apiHost = isStaging() ? STAGING_API_HOST : undefined\n\n // Use the provided token if set, otherwise fall back to the stored CLI token (unless unauthenticated)\n const token = providedToken || (unauthenticated ? undefined : await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: false,\n ...config,\n })\n}\n\n/**\n * @public\n */\nexport interface ProjectCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * The project ID to use for this client.\n */\n projectId: string\n\n /**\n * The dataset to use for this client.\n */\n dataset?: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"project\" (scoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getProjectCliClient({\n requireUser,\n token: providedToken,\n ...config\n}: ProjectCliClientOptions): Promise<SanityClient> {\n const context = getCliExecutionContext()\n const requester = context ? createIsolatedRequester() : defaultRequester.clone()\n requester.use(authErrors(config.projectId))\n\n const apiHost = isStaging() ? STAGING_API_HOST : undefined\n\n // Use the provided token if it is set, otherwise get the token from the config file\n const token = providedToken || (await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: true,\n ...config,\n })\n}\n\n/**\n * `get-it` middleware that checks for 401 authentication errors and extends the error with more\n * helpful guidance on what to do next.\n *\n * @returns get-it middleware with `onError` handler\n * @internal\n */\nfunction authErrors(projectId?: string) {\n return {\n onError: (err: Error | null) => {\n if (!err || !isReqResError(err)) {\n return err\n }\n\n const statusCode = isHttpError(err) && err.statusCode\n if (statusCode === 401) {\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 }\n\n return err\n },\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\nfunction isReqResError(err: Error): err is ClientError | ServerError {\n return Object.prototype.hasOwnProperty.call(err, 'response')\n}\n"],"names":["styleText","createClient","requester","defaultRequester","isHttpError","getCliToken","getCliExecutionContext","createIsolatedRequester","generateHelpUrl","getSanityUrl","isStaging","STAGING_API_HOST","CLI_REQUEST_TAG_PREFIX","getGlobalCliClient","requireUser","token","providedToken","unauthenticated","config","context","clone","use","authErrors","apiHost","undefined","Error","ignoreBrowserTokenWarning","requestTagPrefix","useCdn","useProjectHostname","getProjectCliClient","projectId","onError","err","isReqResError","statusCode","isProjectUserNotFoundError","response","body","message","encodeURIComponent","error","type","Object","prototype","hasOwnProperty","call"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAGEC,YAAY,EACZC,aAAaC,gBAAgB,EAC7BC,WAAW,QAGN,iBAAgB;AAEvB,SAAQC,WAAW,QAAO,gCAA+B;AACzD,SAAQC,sBAAsB,QAAO,wBAAuB;AAC5D,SAAQC,uBAAuB,QAAO,uCAAsC;AAC5E,SAAQC,eAAe,QAAO,4BAA2B;AACzD,SAAQC,YAAY,QAAO,yBAAwB;AACnD,SAAQC,SAAS,QAAO,sBAAqB;AAE7C,MAAMC,mBAAmB;AAEzB,MAAMC,yBAAyB;AA0B/B;;;;;;;CAOC,GACD,OAAO,eAAeC,mBAAmB,EACvCC,WAAW,EACXC,OAAOC,aAAa,EACpBC,eAAe,EACf,GAAGC,QACoB;IACvB,MAAMC,UAAUb;IAChB,MAAMJ,YAAYiB,UAAUZ,4BAA4BJ,iBAAiBiB,KAAK;IAC9ElB,UAAUmB,GAAG,CAACC;IAEd,MAAMC,UAAUb,cAAcC,mBAAmBa;IAEjD,sGAAsG;IACtG,MAAMT,QAAQC,iBAAkBC,CAAAA,kBAAkBO,YAAY,MAAMnB,aAAY;IAEhF,kEAAkE;IAClE,IAAI,CAACU,SAASD,aAAa;QACzB,MAAM,IAAIW,MAAM;IAClB;IAEA,OAAOxB,aAAa;QAClB,GAAIsB,UAAU;YAACA;QAAO,IAAI,CAAC,CAAC;QAC5B,8EAA8E;QAC9EG,2BAA2B;QAC3BxB;QACAyB,kBAAkBf;QAClBG;QACAa,QAAQ;QACRC,oBAAoB;QACpB,GAAGX,MAAM;IACX;AACF;AA6BA;;;;;;;CAOC,GACD,OAAO,eAAeY,oBAAoB,EACxChB,WAAW,EACXC,OAAOC,aAAa,EACpB,GAAGE,QACqB;IACxB,MAAMC,UAAUb;IAChB,MAAMJ,YAAYiB,UAAUZ,4BAA4BJ,iBAAiBiB,KAAK;IAC9ElB,UAAUmB,GAAG,CAACC,WAAWJ,OAAOa,SAAS;IAEzC,MAAMR,UAAUb,cAAcC,mBAAmBa;IAEjD,oFAAoF;IACpF,MAAMT,QAAQC,iBAAkB,MAAMX;IAEtC,kEAAkE;IAClE,IAAI,CAACU,SAASD,aAAa;QACzB,MAAM,IAAIW,MAAM;IAClB;IAEA,OAAOxB,aAAa;QAClB,GAAIsB,UAAU;YAACA;QAAO,IAAI,CAAC,CAAC;QAC5B,8EAA8E;QAC9EG,2BAA2B;QAC3BxB;QACAyB,kBAAkBf;QAClBG;QACAa,QAAQ;QACRC,oBAAoB;QACpB,GAAGX,MAAM;IACX;AACF;AAEA;;;;;;CAMC,GACD,SAASI,WAAWS,SAAkB;IACpC,OAAO;QACLC,SAAS,CAACC;YACR,IAAI,CAACA,OAAO,CAACC,cAAcD,MAAM;gBAC/B,OAAOA;YACT;YAEA,MAAME,aAAa/B,YAAY6B,QAAQA,IAAIE,UAAU;YACrD,IAAIA,eAAe,KAAK;gBACtB,IAAIJ,aAAaK,2BAA2BH,IAAII,QAAQ,CAACC,IAAI,GAAG;oBAC9DL,IAAIM,OAAO,GAAG,GAAGN,IAAIM,OAAO,CAAC,wCAAwC,EAAE9B,aAAa,CAAC,gBAAgB,EAAE+B,mBAAmBT,WAAW,QAAQ,CAAC,EAAE,CAAC,CAAC;oBAClJ,OAAOE;gBACT;gBAEAA,IAAIM,OAAO,GAAG,GAAGN,IAAIM,OAAO,CAAC,mCAAmC,EAAEvC,UAAU,QAAQ,gBAAgB,6BAA6B,EAAEQ,gBAAgB,cAAc,CAAC,CAAC;YACrK;YAEA,OAAOyB;QACT;IACF;AACF;AAEA,SAASG,2BACPE,IAAa;IAEb,IAAI,OAAOA,SAAS,YAAYA,SAAS,QAAQ,CAAE,CAAA,WAAWA,IAAG,GAAI,OAAO;IAE5E,MAAM,EAACG,KAAK,EAAC,GAAGH;IAChB,OACE,OAAOG,UAAU,YACjBA,UAAU,QACV,UAAUA,SACVA,MAAMC,IAAI,KAAK;AAEnB;AAEA,SAASR,cAAcD,GAAU;IAC/B,OAAOU,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACb,KAAK;AACnD"}
|
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* - `token` takes precedence over `SANITY_AUTH_TOKEN` and the stored CLI
|
|
9
9
|
* config token, and never touches the process-wide token cache
|
|
10
|
+
* - the embedding process's `X_SANITY_LINEAGE` is never propagated to API
|
|
11
|
+
* requests
|
|
10
12
|
* - `stdout`/`stderr` receive the output that commands would otherwise write
|
|
11
13
|
* to the process streams
|
|
14
|
+
* - debug logging is disabled, even when the embedding process enables it
|
|
12
15
|
* - interactivity checks report non-interactive, so commands fail fast with
|
|
13
16
|
* actionable errors instead of prompting
|
|
14
17
|
* - project root resolution from the filesystem is disabled: commands never
|
|
@@ -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 * - `stdout`/`stderr` receive the output that commands would otherwise write\n * to the process streams\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\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;AA4DlD,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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { ClientError, isHttpError, ServerError } from '@sanity/client';
|
|
3
|
+
import { getIt } from 'get-it';
|
|
4
|
+
import { agent, headers, jsonRequest, jsonResponse, observable, progress, retry } from 'get-it/middleware';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
7
|
+
const clientPackage = requireFromHere('@sanity/client/package.json');
|
|
8
|
+
const clientVersion = typeof clientPackage === 'object' && clientPackage !== null && 'version' in clientPackage && typeof clientPackage.version === 'string' ? clientPackage.version : 'unknown';
|
|
9
|
+
/**
|
|
10
|
+
* Create the requester used by Sanity clients inside a CLI execution context.
|
|
11
|
+
*
|
|
12
|
+
* This mirrors the Node requester from `@sanity/client`, except that it has no
|
|
13
|
+
* debug or lineage middleware. The client requester's defaults cannot be
|
|
14
|
+
* safely reused here because they read `DEBUG` and `X_SANITY_LINEAGE` from the
|
|
15
|
+
* embedding process.
|
|
16
|
+
*/ export function createIsolatedRequester() {
|
|
17
|
+
return getIt([
|
|
18
|
+
retry({
|
|
19
|
+
shouldRetry
|
|
20
|
+
}),
|
|
21
|
+
headers({
|
|
22
|
+
'User-Agent': `@sanity/client ${clientVersion}`
|
|
23
|
+
}),
|
|
24
|
+
removeLineage(),
|
|
25
|
+
agent({
|
|
26
|
+
keepAlive: true,
|
|
27
|
+
maxSockets: 30,
|
|
28
|
+
maxTotalSockets: 256
|
|
29
|
+
}),
|
|
30
|
+
jsonRequest(),
|
|
31
|
+
jsonResponse(),
|
|
32
|
+
progress(),
|
|
33
|
+
httpErrors,
|
|
34
|
+
observable({
|
|
35
|
+
implementation: Observable
|
|
36
|
+
})
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
function removeLineage() {
|
|
40
|
+
return {
|
|
41
|
+
processOptions (options) {
|
|
42
|
+
const requestHeaders = {
|
|
43
|
+
...options.headers
|
|
44
|
+
};
|
|
45
|
+
for (const name of Object.keys(requestHeaders)){
|
|
46
|
+
if (name.toLowerCase() === 'x-sanity-lineage') delete requestHeaders[name];
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
...options,
|
|
50
|
+
headers: requestHeaders
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const httpErrors = {
|
|
56
|
+
onResponse (response, context) {
|
|
57
|
+
if (response.statusCode >= 500) throw new ServerError(response);
|
|
58
|
+
if (response.statusCode >= 400) throw new ClientError(response, context);
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function shouldRetry(error, attempt, options) {
|
|
63
|
+
if (options.maxRetries === 0) return false;
|
|
64
|
+
const isSafe = options.method === 'GET' || options.method === 'HEAD';
|
|
65
|
+
const uri = 'uri' in options && typeof options.uri === 'string' ? options.uri : options.url;
|
|
66
|
+
const isQuery = uri.startsWith('/data/query');
|
|
67
|
+
const isRetriableResponse = isHttpError(error) && [
|
|
68
|
+
429,
|
|
69
|
+
502,
|
|
70
|
+
503
|
|
71
|
+
].includes(error.response.statusCode);
|
|
72
|
+
return (isSafe || isQuery) && isRetriableResponse ? true : retry.shouldRetry(error, attempt, options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=createIsolatedRequester.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/request/createIsolatedRequester.ts"],"sourcesContent":["import {createRequire} from 'node:module'\n\nimport {ClientError, isHttpError, ServerError} from '@sanity/client'\nimport {getIt, type HttpContext, type Middleware, type Requester, type RequestOptions} from 'get-it'\nimport {\n agent,\n headers,\n jsonRequest,\n jsonResponse,\n observable,\n progress,\n retry,\n} from 'get-it/middleware'\nimport {Observable} from 'rxjs'\n\nconst requireFromHere = createRequire(import.meta.url)\nconst clientPackage: unknown = requireFromHere('@sanity/client/package.json')\nconst clientVersion =\n typeof clientPackage === 'object' &&\n clientPackage !== null &&\n 'version' in clientPackage &&\n typeof clientPackage.version === 'string'\n ? clientPackage.version\n : 'unknown'\n\n/**\n * Create the requester used by Sanity clients inside a CLI execution context.\n *\n * This mirrors the Node requester from `@sanity/client`, except that it has no\n * debug or lineage middleware. The client requester's defaults cannot be\n * safely reused here because they read `DEBUG` and `X_SANITY_LINEAGE` from the\n * embedding process.\n */\nexport function createIsolatedRequester(): Requester {\n return getIt([\n retry({shouldRetry}),\n headers({'User-Agent': `@sanity/client ${clientVersion}`}),\n removeLineage(),\n agent({keepAlive: true, maxSockets: 30, maxTotalSockets: 256}),\n jsonRequest(),\n jsonResponse(),\n progress(),\n httpErrors,\n observable({implementation: Observable}),\n ])\n}\n\nfunction removeLineage(): Middleware {\n return {\n processOptions(options: RequestOptions) {\n const requestHeaders = {...options.headers}\n for (const name of Object.keys(requestHeaders)) {\n if (name.toLowerCase() === 'x-sanity-lineage') delete requestHeaders[name]\n }\n return {...options, headers: requestHeaders}\n },\n }\n}\n\nconst httpErrors: Middleware = {\n onResponse(response, context: HttpContext) {\n if (response.statusCode >= 500) throw new ServerError(response)\n if (response.statusCode >= 400) throw new ClientError(response, context)\n return response\n },\n}\n\nfunction shouldRetry(error: unknown, attempt: number, options: RequestOptions): boolean {\n if (options.maxRetries === 0) return false\n\n const isSafe = options.method === 'GET' || options.method === 'HEAD'\n const uri = 'uri' in options && typeof options.uri === 'string' ? options.uri : options.url\n const isQuery = uri.startsWith('/data/query')\n const isRetriableResponse =\n isHttpError(error) && [429, 502, 503].includes(error.response.statusCode)\n\n return (isSafe || isQuery) && isRetriableResponse\n ? true\n : retry.shouldRetry(error, attempt, options)\n}\n"],"names":["createRequire","ClientError","isHttpError","ServerError","getIt","agent","headers","jsonRequest","jsonResponse","observable","progress","retry","Observable","requireFromHere","url","clientPackage","clientVersion","version","createIsolatedRequester","shouldRetry","removeLineage","keepAlive","maxSockets","maxTotalSockets","httpErrors","implementation","processOptions","options","requestHeaders","name","Object","keys","toLowerCase","onResponse","response","context","statusCode","error","attempt","maxRetries","isSafe","method","uri","isQuery","startsWith","isRetriableResponse","includes"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AAEzC,SAAQC,WAAW,EAAEC,WAAW,EAAEC,WAAW,QAAO,iBAAgB;AACpE,SAAQC,KAAK,QAA+E,SAAQ;AACpG,SACEC,KAAK,EACLC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,QAAQ,EACRC,KAAK,QACA,oBAAmB;AAC1B,SAAQC,UAAU,QAAO,OAAM;AAE/B,MAAMC,kBAAkBb,cAAc,YAAYc,GAAG;AACrD,MAAMC,gBAAyBF,gBAAgB;AAC/C,MAAMG,gBACJ,OAAOD,kBAAkB,YACzBA,kBAAkB,QAClB,aAAaA,iBACb,OAAOA,cAAcE,OAAO,KAAK,WAC7BF,cAAcE,OAAO,GACrB;AAEN;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,OAAOd,MAAM;QACXO,MAAM;YAACQ;QAAW;QAClBb,QAAQ;YAAC,cAAc,CAAC,eAAe,EAAEU,eAAe;QAAA;QACxDI;QACAf,MAAM;YAACgB,WAAW;YAAMC,YAAY;YAAIC,iBAAiB;QAAG;QAC5DhB;QACAC;QACAE;QACAc;QACAf,WAAW;YAACgB,gBAAgBb;QAAU;KACvC;AACH;AAEA,SAASQ;IACP,OAAO;QACLM,gBAAeC,OAAuB;YACpC,MAAMC,iBAAiB;gBAAC,GAAGD,QAAQrB,OAAO;YAAA;YAC1C,KAAK,MAAMuB,QAAQC,OAAOC,IAAI,CAACH,gBAAiB;gBAC9C,IAAIC,KAAKG,WAAW,OAAO,oBAAoB,OAAOJ,cAAc,CAACC,KAAK;YAC5E;YACA,OAAO;gBAAC,GAAGF,OAAO;gBAAErB,SAASsB;YAAc;QAC7C;IACF;AACF;AAEA,MAAMJ,aAAyB;IAC7BS,YAAWC,QAAQ,EAAEC,OAAoB;QACvC,IAAID,SAASE,UAAU,IAAI,KAAK,MAAM,IAAIjC,YAAY+B;QACtD,IAAIA,SAASE,UAAU,IAAI,KAAK,MAAM,IAAInC,YAAYiC,UAAUC;QAChE,OAAOD;IACT;AACF;AAEA,SAASf,YAAYkB,KAAc,EAAEC,OAAe,EAAEX,OAAuB;IAC3E,IAAIA,QAAQY,UAAU,KAAK,GAAG,OAAO;IAErC,MAAMC,SAASb,QAAQc,MAAM,KAAK,SAASd,QAAQc,MAAM,KAAK;IAC9D,MAAMC,MAAM,SAASf,WAAW,OAAOA,QAAQe,GAAG,KAAK,WAAWf,QAAQe,GAAG,GAAGf,QAAQb,GAAG;IAC3F,MAAM6B,UAAUD,IAAIE,UAAU,CAAC;IAC/B,MAAMC,sBACJ3C,YAAYmC,UAAU;QAAC;QAAK;QAAK;KAAI,CAACS,QAAQ,CAACT,MAAMH,QAAQ,CAACE,UAAU;IAE1E,OAAO,AAACI,CAAAA,UAAUG,OAAM,KAAME,sBAC1B,OACAlC,MAAMQ,WAAW,CAACkB,OAAOC,SAASX;AACxC"}
|
|
@@ -2,6 +2,7 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { up as packageUp } from 'empathic/package';
|
|
3
3
|
import { getIt } from 'get-it';
|
|
4
4
|
import { debug, headers, httpErrors, promise } from 'get-it/middleware';
|
|
5
|
+
import { getCliExecutionContext } from '../executionContext.js';
|
|
5
6
|
let cachedPkg;
|
|
6
7
|
/**
|
|
7
8
|
* Creates a `get-it` requester with a standard set of middleware.
|
|
@@ -37,7 +38,8 @@ let cachedPkg;
|
|
|
37
38
|
middleware.push(headers(allHeaders));
|
|
38
39
|
}
|
|
39
40
|
// 3. debug
|
|
40
|
-
|
|
41
|
+
// A programmatic invocation must not inherit the embedding process's DEBUG setting or write request/response bodies outside its output sinks.
|
|
42
|
+
if (!getCliExecutionContext() && opts?.debug !== false) {
|
|
41
43
|
const debugDefaults = {
|
|
42
44
|
namespace: 'sanity:cli',
|
|
43
45
|
verbose: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/request/createRequester.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\n\nimport {up as packageUp} from 'empathic/package'\nimport {getIt, type Requester} from 'get-it'\nimport {debug, headers, httpErrors, promise} from 'get-it/middleware'\n\nlet cachedPkg: {name: string; version: string} | undefined\n\n/**\n * Options for configuring individual middleware in {@link createRequester}.\n *\n * Each key corresponds to a middleware. Omitting a key uses the default,\n * `false` disables it, and an object merges with the defaults.\n *\n * @public\n */\nexport type MiddlewareOptions = {\n debug?: false | {namespace?: string; verbose?: boolean}\n headers?: false | Record<string, string>\n httpErrors?: false\n promise?: false | {onlyBody?: boolean}\n}\n\n/**\n * Creates a `get-it` requester with a standard set of middleware.\n *\n * Default middleware (in order):\n * 1. `httpErrors()` — throw on HTTP error status codes\n * 2. `headers({'User-Agent': '@sanity/cli-core@<version>'})` — identify CLI requests\n * 3. `debug({verbose: true, namespace: 'sanity:cli'})` — debug logging\n * 4. `promise({onlyBody: true})` — return body directly (must be last)\n *\n * @param options - Optional configuration to disable or customize middleware\n * @returns A configured `get-it` requester\n * @public\n */\nexport function createRequester(options?: {middleware?: MiddlewareOptions}): Requester {\n const opts = options?.middleware\n\n const middleware = []\n\n // 1. httpErrors\n if (opts?.httpErrors !== false) {\n middleware.push(httpErrors())\n }\n\n // 2. headers\n if (opts?.headers !== false) {\n const customHeaders = typeof opts?.headers === 'object' ? opts.headers : {}\n const allHeaders = customHeaders['User-Agent']\n ? {...customHeaders}\n : {\n get ['User-Agent']() {\n const pkg = getPackageInfo()\n return `${pkg.name}@${pkg.version}`\n },\n ...customHeaders,\n }\n middleware.push(headers(allHeaders))\n }\n\n // 3. debug\n if (opts?.debug !== false) {\n const debugDefaults = {namespace: 'sanity:cli', verbose: true}\n const customDebug = typeof opts?.debug === 'object' ? opts.debug : {}\n middleware.push(debug({...debugDefaults, ...customDebug}))\n }\n\n // 4. promise (must be last)\n if (opts?.promise !== false) {\n const promiseDefaults = {onlyBody: true}\n const customPromise = typeof opts?.promise === 'object' ? opts.promise : {}\n middleware.push(promise({...promiseDefaults, ...customPromise}))\n }\n\n return getIt(middleware)\n}\n\n/**\n * Reads the nearest `package.json` to determine the name and version of the `@sanity/cli-core` package.\n *\n * @returns The name and version of the package\n * @internal\n */\nfunction getPackageInfo(): {name: string; version: string} {\n if (cachedPkg) return cachedPkg\n\n const pkgPath = packageUp({cwd: import.meta.dirname})\n if (!pkgPath) {\n throw new Error('Unable to resolve @sanity/cli-core package root')\n }\n\n const packageJson = JSON.parse(readFileSync(pkgPath, 'utf8'))\n cachedPkg = {\n name: packageJson.name ?? '@sanity/cli-core',\n version: packageJson.version ?? '0.0.0',\n }\n return cachedPkg\n}\n"],"names":["readFileSync","up","packageUp","getIt","debug","headers","httpErrors","promise","cachedPkg","createRequester","options","opts","middleware","push","customHeaders","allHeaders","pkg","getPackageInfo","name","version","debugDefaults","namespace","verbose","customDebug","promiseDefaults","onlyBody","customPromise","pkgPath","cwd","dirname","Error","packageJson","JSON","parse"],"mappings":"AAAA,SAAQA,YAAY,QAAO,UAAS;AAEpC,SAAQC,MAAMC,SAAS,QAAO,mBAAkB;AAChD,SAAQC,KAAK,QAAuB,SAAQ;AAC5C,SAAQC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,oBAAmB;AAErE,IAAIC;AAiBJ;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,gBAAgBC,OAA0C;IACxE,MAAMC,OAAOD,SAASE;IAEtB,MAAMA,aAAa,EAAE;IAErB,gBAAgB;IAChB,IAAID,
|
|
1
|
+
{"version":3,"sources":["../../src/request/createRequester.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\n\nimport {up as packageUp} from 'empathic/package'\nimport {getIt, type Requester} from 'get-it'\nimport {debug, headers, httpErrors, promise} from 'get-it/middleware'\n\nimport {getCliExecutionContext} from '../executionContext.js'\n\nlet cachedPkg: {name: string; version: string} | undefined\n\n/**\n * Options for configuring individual middleware in {@link createRequester}.\n *\n * Each key corresponds to a middleware. Omitting a key uses the default,\n * `false` disables it, and an object merges with the defaults.\n *\n * @public\n */\nexport type MiddlewareOptions = {\n debug?: false | {namespace?: string; verbose?: boolean}\n headers?: false | Record<string, string>\n httpErrors?: false\n promise?: false | {onlyBody?: boolean}\n}\n\n/**\n * Creates a `get-it` requester with a standard set of middleware.\n *\n * Default middleware (in order):\n * 1. `httpErrors()` — throw on HTTP error status codes\n * 2. `headers({'User-Agent': '@sanity/cli-core@<version>'})` — identify CLI requests\n * 3. `debug({verbose: true, namespace: 'sanity:cli'})` — debug logging\n * 4. `promise({onlyBody: true})` — return body directly (must be last)\n *\n * @param options - Optional configuration to disable or customize middleware\n * @returns A configured `get-it` requester\n * @public\n */\nexport function createRequester(options?: {middleware?: MiddlewareOptions}): Requester {\n const opts = options?.middleware\n\n const middleware = []\n\n // 1. httpErrors\n if (opts?.httpErrors !== false) {\n middleware.push(httpErrors())\n }\n\n // 2. headers\n if (opts?.headers !== false) {\n const customHeaders = typeof opts?.headers === 'object' ? opts.headers : {}\n const allHeaders = customHeaders['User-Agent']\n ? {...customHeaders}\n : {\n get ['User-Agent']() {\n const pkg = getPackageInfo()\n return `${pkg.name}@${pkg.version}`\n },\n ...customHeaders,\n }\n middleware.push(headers(allHeaders))\n }\n\n // 3. debug\n // A programmatic invocation must not inherit the embedding process's DEBUG setting or write request/response bodies outside its output sinks.\n if (!getCliExecutionContext() && opts?.debug !== false) {\n const debugDefaults = {namespace: 'sanity:cli', verbose: true}\n const customDebug = typeof opts?.debug === 'object' ? opts.debug : {}\n middleware.push(debug({...debugDefaults, ...customDebug}))\n }\n\n // 4. promise (must be last)\n if (opts?.promise !== false) {\n const promiseDefaults = {onlyBody: true}\n const customPromise = typeof opts?.promise === 'object' ? opts.promise : {}\n middleware.push(promise({...promiseDefaults, ...customPromise}))\n }\n\n return getIt(middleware)\n}\n\n/**\n * Reads the nearest `package.json` to determine the name and version of the `@sanity/cli-core` package.\n *\n * @returns The name and version of the package\n * @internal\n */\nfunction getPackageInfo(): {name: string; version: string} {\n if (cachedPkg) return cachedPkg\n\n const pkgPath = packageUp({cwd: import.meta.dirname})\n if (!pkgPath) {\n throw new Error('Unable to resolve @sanity/cli-core package root')\n }\n\n const packageJson = JSON.parse(readFileSync(pkgPath, 'utf8'))\n cachedPkg = {\n name: packageJson.name ?? '@sanity/cli-core',\n version: packageJson.version ?? '0.0.0',\n }\n return cachedPkg\n}\n"],"names":["readFileSync","up","packageUp","getIt","debug","headers","httpErrors","promise","getCliExecutionContext","cachedPkg","createRequester","options","opts","middleware","push","customHeaders","allHeaders","pkg","getPackageInfo","name","version","debugDefaults","namespace","verbose","customDebug","promiseDefaults","onlyBody","customPromise","pkgPath","cwd","dirname","Error","packageJson","JSON","parse"],"mappings":"AAAA,SAAQA,YAAY,QAAO,UAAS;AAEpC,SAAQC,MAAMC,SAAS,QAAO,mBAAkB;AAChD,SAAQC,KAAK,QAAuB,SAAQ;AAC5C,SAAQC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,oBAAmB;AAErE,SAAQC,sBAAsB,QAAO,yBAAwB;AAE7D,IAAIC;AAiBJ;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,gBAAgBC,OAA0C;IACxE,MAAMC,OAAOD,SAASE;IAEtB,MAAMA,aAAa,EAAE;IAErB,gBAAgB;IAChB,IAAID,MAAMN,eAAe,OAAO;QAC9BO,WAAWC,IAAI,CAACR;IAClB;IAEA,aAAa;IACb,IAAIM,MAAMP,YAAY,OAAO;QAC3B,MAAMU,gBAAgB,OAAOH,MAAMP,YAAY,WAAWO,KAAKP,OAAO,GAAG,CAAC;QAC1E,MAAMW,aAAaD,aAAa,CAAC,aAAa,GAC1C;YAAC,GAAGA,aAAa;QAAA,IACjB;YACE,IAAI,CAAC,aAAa,IAAG;gBACnB,MAAME,MAAMC;gBACZ,OAAO,GAAGD,IAAIE,IAAI,CAAC,CAAC,EAAEF,IAAIG,OAAO,EAAE;YACrC;YACA,GAAGL,aAAa;QAClB;QACJF,WAAWC,IAAI,CAACT,QAAQW;IAC1B;IAEA,WAAW;IACX,8IAA8I;IAC9I,IAAI,CAACR,4BAA4BI,MAAMR,UAAU,OAAO;QACtD,MAAMiB,gBAAgB;YAACC,WAAW;YAAcC,SAAS;QAAI;QAC7D,MAAMC,cAAc,OAAOZ,MAAMR,UAAU,WAAWQ,KAAKR,KAAK,GAAG,CAAC;QACpES,WAAWC,IAAI,CAACV,MAAM;YAAC,GAAGiB,aAAa;YAAE,GAAGG,WAAW;QAAA;IACzD;IAEA,4BAA4B;IAC5B,IAAIZ,MAAML,YAAY,OAAO;QAC3B,MAAMkB,kBAAkB;YAACC,UAAU;QAAI;QACvC,MAAMC,gBAAgB,OAAOf,MAAML,YAAY,WAAWK,KAAKL,OAAO,GAAG,CAAC;QAC1EM,WAAWC,IAAI,CAACP,QAAQ;YAAC,GAAGkB,eAAe;YAAE,GAAGE,aAAa;QAAA;IAC/D;IAEA,OAAOxB,MAAMU;AACf;AAEA;;;;;CAKC,GACD,SAASK;IACP,IAAIT,WAAW,OAAOA;IAEtB,MAAMmB,UAAU1B,UAAU;QAAC2B,KAAK,YAAYC,OAAO;IAAA;IACnD,IAAI,CAACF,SAAS;QACZ,MAAM,IAAIG,MAAM;IAClB;IAEA,MAAMC,cAAcC,KAAKC,KAAK,CAAClC,aAAa4B,SAAS;IACrDnB,YAAY;QACVU,MAAMa,YAAYb,IAAI,IAAI;QAC1BC,SAASY,YAAYZ,OAAO,IAAI;IAClC;IACA,OAAOX;AACT"}
|
package/dist/ux/spinner.js
CHANGED
|
@@ -1,21 +1,82 @@
|
|
|
1
1
|
import ora, { oraPromise } from 'ora';
|
|
2
2
|
import { getCliExecutionContext } from '../executionContext.js';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Uncolored counterparts of the `log-symbols` glyphs a real spinner persists
|
|
5
|
+
* with. Lines forwarded to an execution context are handed to the embedding
|
|
6
|
+
* host verbatim, so they should not carry ANSI codes the host has to strip.
|
|
7
|
+
*/ const persistSymbols = {
|
|
8
|
+
error: '✖',
|
|
9
|
+
info: 'ℹ',
|
|
10
|
+
success: '✔',
|
|
11
|
+
warning: '⚠'
|
|
12
|
+
};
|
|
13
|
+
function resolveAffix(value1) {
|
|
14
|
+
const resolved = typeof value1 === 'function' ? value1() : value1;
|
|
15
|
+
return typeof resolved === 'string' ? resolved : '';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Stand-in for a real spinner, used when a CLI execution context is active.
|
|
19
|
+
*
|
|
20
|
+
* Frame animation and transient text updates have nowhere useful to go, so they
|
|
21
|
+
* are dropped. The lines a spinner *persists* (`succeed`, `fail`, `warn`,
|
|
22
|
+
* `info`, `stopAndPersist`) are the command's actual output rather than
|
|
23
|
+
* progress, so they are forwarded to the context's sink instead of being
|
|
24
|
+
* swallowed. Ora writes to `process.stderr` by default, so the `stderr` sink is
|
|
25
|
+
* preferred, falling back to `stdout`.
|
|
26
|
+
*/ function silentSpinner(options) {
|
|
27
|
+
const resolved = typeof options === 'string' ? {
|
|
28
|
+
text: options
|
|
29
|
+
} : options ?? {};
|
|
30
|
+
const context = getCliExecutionContext();
|
|
31
|
+
const emit = resolved.isSilent ? undefined : context?.stderr ?? context?.stdout;
|
|
32
|
+
const prefixText = resolveAffix(resolved.prefixText);
|
|
33
|
+
const suffixText = resolveAffix(resolved.suffixText);
|
|
34
|
+
const state = {
|
|
35
|
+
text: resolved.text ?? ''
|
|
36
|
+
};
|
|
37
|
+
const persist = (symbol, text)=>{
|
|
38
|
+
if (!emit) return;
|
|
39
|
+
// Mirrors ora's own line layout, minus the trailing whitespace it leaves
|
|
40
|
+
// behind when only one of the symbol and the text is present.
|
|
41
|
+
const body = text ?? state.text;
|
|
42
|
+
const line = (prefixText ? `${prefixText} ` : '') + symbol + (symbol && body ? ` ${body}` : body) + (suffixText ? ` ${suffixText}` : '');
|
|
43
|
+
if (line.trim() !== '') emit(line);
|
|
44
|
+
};
|
|
4
45
|
const instance = {
|
|
5
46
|
clear: ()=>instance,
|
|
6
|
-
fail: ()=>
|
|
47
|
+
fail: (text)=>{
|
|
48
|
+
persist(persistSymbols.error, text);
|
|
49
|
+
return instance;
|
|
50
|
+
},
|
|
7
51
|
frame: ()=>'',
|
|
8
|
-
info: ()=>
|
|
52
|
+
info: (text)=>{
|
|
53
|
+
persist(persistSymbols.info, text);
|
|
54
|
+
return instance;
|
|
55
|
+
},
|
|
9
56
|
isSpinning: false,
|
|
10
|
-
prefixText
|
|
57
|
+
prefixText,
|
|
11
58
|
render: ()=>instance,
|
|
12
59
|
start: ()=>instance,
|
|
13
60
|
stop: ()=>instance,
|
|
14
|
-
stopAndPersist: ()=>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
61
|
+
stopAndPersist: (persistOptions = {})=>{
|
|
62
|
+
persist(persistOptions.symbol ?? '', persistOptions.text);
|
|
63
|
+
return instance;
|
|
64
|
+
},
|
|
65
|
+
succeed: (text)=>{
|
|
66
|
+
persist(persistSymbols.success, text);
|
|
67
|
+
return instance;
|
|
68
|
+
},
|
|
69
|
+
suffixText,
|
|
70
|
+
get text () {
|
|
71
|
+
return state.text;
|
|
72
|
+
},
|
|
73
|
+
set text (value){
|
|
74
|
+
state.text = value;
|
|
75
|
+
},
|
|
76
|
+
warn: (text)=>{
|
|
77
|
+
persist(persistSymbols.warning, text);
|
|
78
|
+
return instance;
|
|
79
|
+
}
|
|
19
80
|
};
|
|
20
81
|
return instance;
|
|
21
82
|
}
|
package/dist/ux/spinner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ux/spinner.ts"],"sourcesContent":["import ora, {\n type Options,\n type Ora,\n oraPromise,\n type Spinner as OraSpinner,\n type PromiseOptions,\n} from 'ora'\n\nimport {getCliExecutionContext} from '../executionContext.js'\n\nfunction silentSpinner(options?: Options | string): Ora {\n const
|
|
1
|
+
{"version":3,"sources":["../../src/ux/spinner.ts"],"sourcesContent":["import ora, {\n type Options,\n type Ora,\n oraPromise,\n type Spinner as OraSpinner,\n type PersistOptions,\n type PromiseOptions,\n} from 'ora'\n\nimport {getCliExecutionContext} from '../executionContext.js'\n\n/**\n * Uncolored counterparts of the `log-symbols` glyphs a real spinner persists\n * with. Lines forwarded to an execution context are handed to the embedding\n * host verbatim, so they should not carry ANSI codes the host has to strip.\n */\nconst persistSymbols = {\n error: '✖',\n info: 'ℹ',\n success: '✔',\n warning: '⚠',\n}\n\nfunction resolveAffix(value: Options['prefixText'] | Options['suffixText']): string {\n const resolved = typeof value === 'function' ? value() : value\n return typeof resolved === 'string' ? resolved : ''\n}\n\n/**\n * Stand-in for a real spinner, used when a CLI execution context is active.\n *\n * Frame animation and transient text updates have nowhere useful to go, so they\n * are dropped. The lines a spinner *persists* (`succeed`, `fail`, `warn`,\n * `info`, `stopAndPersist`) are the command's actual output rather than\n * progress, so they are forwarded to the context's sink instead of being\n * swallowed. Ora writes to `process.stderr` by default, so the `stderr` sink is\n * preferred, falling back to `stdout`.\n */\nfunction silentSpinner(options?: Options | string): Ora {\n const resolved = typeof options === 'string' ? {text: options} : (options ?? {})\n const context = getCliExecutionContext()\n const emit = resolved.isSilent ? undefined : (context?.stderr ?? context?.stdout)\n\n const prefixText = resolveAffix(resolved.prefixText)\n const suffixText = resolveAffix(resolved.suffixText)\n const state = {text: resolved.text ?? ''}\n\n const persist = (symbol: string, text?: string): void => {\n if (!emit) return\n\n // Mirrors ora's own line layout, minus the trailing whitespace it leaves\n // behind when only one of the symbol and the text is present.\n const body = text ?? state.text\n const line =\n (prefixText ? `${prefixText} ` : '') +\n symbol +\n (symbol && body ? ` ${body}` : body) +\n (suffixText ? ` ${suffixText}` : '')\n\n if (line.trim() !== '') emit(line)\n }\n\n const instance = {\n clear: () => instance,\n fail: (text?: string) => {\n persist(persistSymbols.error, text)\n return instance\n },\n frame: () => '',\n info: (text?: string) => {\n persist(persistSymbols.info, text)\n return instance\n },\n isSpinning: false,\n prefixText,\n render: () => instance,\n start: () => instance,\n stop: () => instance,\n stopAndPersist: (persistOptions: PersistOptions = {}) => {\n persist(persistOptions.symbol ?? '', persistOptions.text)\n return instance\n },\n succeed: (text?: string) => {\n persist(persistSymbols.success, text)\n return instance\n },\n suffixText,\n get text(): string {\n return state.text\n },\n set text(value: string) {\n state.text = value\n },\n warn: (text?: string) => {\n persist(persistSymbols.warning, text)\n return instance\n },\n }\n return instance as unknown as Ora\n}\n\nexport function spinner(options?: Options | string): Ora {\n return getCliExecutionContext() ? silentSpinner(options) : ora(options)\n}\n\nexport function spinnerPromise<T>(\n action: ((instance: Ora) => PromiseLike<T>) | PromiseLike<T>,\n options?: PromiseOptions<T> | string,\n): Promise<T> {\n if (!getCliExecutionContext()) return oraPromise(action, options)\n return Promise.resolve(typeof action === 'function' ? action(silentSpinner(options)) : action)\n}\n\nexport type Spinner = OraSpinner\nexport type SpinnerInstance = Ora\nexport type SpinnerOptions = Options\nexport type SpinnerPromiseOptions<T> = PromiseOptions<T>\n"],"names":["ora","oraPromise","getCliExecutionContext","persistSymbols","error","info","success","warning","resolveAffix","value","resolved","silentSpinner","options","text","context","emit","isSilent","undefined","stderr","stdout","prefixText","suffixText","state","persist","symbol","body","line","trim","instance","clear","fail","frame","isSpinning","render","start","stop","stopAndPersist","persistOptions","succeed","warn","spinner","spinnerPromise","action","Promise","resolve"],"mappings":"AAAA,OAAOA,OAGLC,UAAU,QAIL,MAAK;AAEZ,SAAQC,sBAAsB,QAAO,yBAAwB;AAE7D;;;;CAIC,GACD,MAAMC,iBAAiB;IACrBC,OAAO;IACPC,MAAM;IACNC,SAAS;IACTC,SAAS;AACX;AAEA,SAASC,aAAaC,MAAoD;IACxE,MAAMC,WAAW,OAAOD,WAAU,aAAaA,WAAUA;IACzD,OAAO,OAAOC,aAAa,WAAWA,WAAW;AACnD;AAEA;;;;;;;;;CASC,GACD,SAASC,cAAcC,OAA0B;IAC/C,MAAMF,WAAW,OAAOE,YAAY,WAAW;QAACC,MAAMD;IAAO,IAAKA,WAAW,CAAC;IAC9E,MAAME,UAAUZ;IAChB,MAAMa,OAAOL,SAASM,QAAQ,GAAGC,YAAaH,SAASI,UAAUJ,SAASK;IAE1E,MAAMC,aAAaZ,aAAaE,SAASU,UAAU;IACnD,MAAMC,aAAab,aAAaE,SAASW,UAAU;IACnD,MAAMC,QAAQ;QAACT,MAAMH,SAASG,IAAI,IAAI;IAAE;IAExC,MAAMU,UAAU,CAACC,QAAgBX;QAC/B,IAAI,CAACE,MAAM;QAEX,yEAAyE;QACzE,8DAA8D;QAC9D,MAAMU,OAAOZ,QAAQS,MAAMT,IAAI;QAC/B,MAAMa,OACJ,AAACN,CAAAA,aAAa,GAAGA,WAAW,CAAC,CAAC,GAAG,EAAC,IAClCI,SACCA,CAAAA,UAAUC,OAAO,CAAC,CAAC,EAAEA,MAAM,GAAGA,IAAG,IACjCJ,CAAAA,aAAa,CAAC,CAAC,EAAEA,YAAY,GAAG,EAAC;QAEpC,IAAIK,KAAKC,IAAI,OAAO,IAAIZ,KAAKW;IAC/B;IAEA,MAAME,WAAW;QACfC,OAAO,IAAMD;QACbE,MAAM,CAACjB;YACLU,QAAQpB,eAAeC,KAAK,EAAES;YAC9B,OAAOe;QACT;QACAG,OAAO,IAAM;QACb1B,MAAM,CAACQ;YACLU,QAAQpB,eAAeE,IAAI,EAAEQ;YAC7B,OAAOe;QACT;QACAI,YAAY;QACZZ;QACAa,QAAQ,IAAML;QACdM,OAAO,IAAMN;QACbO,MAAM,IAAMP;QACZQ,gBAAgB,CAACC,iBAAiC,CAAC,CAAC;YAClDd,QAAQc,eAAeb,MAAM,IAAI,IAAIa,eAAexB,IAAI;YACxD,OAAOe;QACT;QACAU,SAAS,CAACzB;YACRU,QAAQpB,eAAeG,OAAO,EAAEO;YAChC,OAAOe;QACT;QACAP;QACA,IAAIR,QAAe;YACjB,OAAOS,MAAMT,IAAI;QACnB;QACA,IAAIA,MAAKJ,MAAe;YACtBa,MAAMT,IAAI,GAAGJ;QACf;QACA8B,MAAM,CAAC1B;YACLU,QAAQpB,eAAeI,OAAO,EAAEM;YAChC,OAAOe;QACT;IACF;IACA,OAAOA;AACT;AAEA,OAAO,SAASY,QAAQ5B,OAA0B;IAChD,OAAOV,2BAA2BS,cAAcC,WAAWZ,IAAIY;AACjE;AAEA,OAAO,SAAS6B,eACdC,MAA4D,EAC5D9B,OAAoC;IAEpC,IAAI,CAACV,0BAA0B,OAAOD,WAAWyC,QAAQ9B;IACzD,OAAO+B,QAAQC,OAAO,CAAC,OAAOF,WAAW,aAAaA,OAAO/B,cAAcC,YAAY8B;AACzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"ora": "^9.0.0",
|
|
124
124
|
"rxjs": "^7.8.2",
|
|
125
125
|
"tsx": "^4.23.1",
|
|
126
|
-
"vite": "^8.
|
|
126
|
+
"vite": "^8.2.0",
|
|
127
127
|
"vite-node": "^6.0.0",
|
|
128
128
|
"wrap-ansi": "^9.0.2",
|
|
129
129
|
"zod": "^4.4.3"
|
|
@@ -144,8 +144,8 @@
|
|
|
144
144
|
"typescript": "^6.0.3",
|
|
145
145
|
"vitest": "^4.1.10",
|
|
146
146
|
"@repo/package.config": "0.0.1",
|
|
147
|
-
"@
|
|
148
|
-
"@
|
|
147
|
+
"@sanity/eslint-config-cli": "1.1.3",
|
|
148
|
+
"@repo/tsconfig": "3.70.0"
|
|
149
149
|
},
|
|
150
150
|
"peerDependencies": {
|
|
151
151
|
"babel-plugin-react-compiler": "*"
|