@sanity/cli-core 2.7.1 → 2.8.1
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/SanityCommand.d.ts +0 -4
- package/dist/_exports/config.d.ts +0 -4
- package/dist/_exports/debug.js +8 -0
- package/dist/_exports/debug.js.map +1 -1
- package/dist/_exports/index.d.ts +0 -4
- package/dist/_exports/types.d.ts +0 -4
- package/dist/_exports/ux.d.ts +40 -0
- package/dist/_exports/ux.js +1 -0
- package/dist/_exports/ux.js.map +1 -1
- package/dist/apiClient.js +6 -2
- package/dist/apiClient.js.map +1 -1
- package/dist/config/cli/types/cliConfig.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/flowOutput.js +128 -0
- package/dist/ux/flowOutput.js.map +1 -0
- package/package.json +3 -2
package/dist/SanityCommand.d.ts
CHANGED
|
@@ -34,8 +34,6 @@ declare interface CliConfig {
|
|
|
34
34
|
app?: {
|
|
35
35
|
/** The entrypoint for your custom app. By default, `src/App.tsx` */
|
|
36
36
|
entry?: string;
|
|
37
|
-
/** Dock group the app renders in. Defaults to `dock.applications`. */
|
|
38
|
-
group?: "dock.applications" | "dock.system" | "dock.user";
|
|
39
37
|
/**
|
|
40
38
|
* Path to an icon file relative to project root.
|
|
41
39
|
* The file must be an SVG.
|
|
@@ -45,8 +43,6 @@ declare interface CliConfig {
|
|
|
45
43
|
id?: string;
|
|
46
44
|
/** The ID for the Sanity organization that manages this application */
|
|
47
45
|
organizationId?: string;
|
|
48
|
-
/** Sort position within the dock group, ascending. Defaults to `100`. */
|
|
49
|
-
priority?: number;
|
|
50
46
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
51
47
|
title?: string;
|
|
52
48
|
/** Dashboard visibility of the application. Defaults to `default`. */
|
|
@@ -37,8 +37,6 @@ export declare interface CliConfig {
|
|
|
37
37
|
app?: {
|
|
38
38
|
/** The entrypoint for your custom app. By default, `src/App.tsx` */
|
|
39
39
|
entry?: string;
|
|
40
|
-
/** Dock group the app renders in. Defaults to `dock.applications`. */
|
|
41
|
-
group?: "dock.applications" | "dock.system" | "dock.user";
|
|
42
40
|
/**
|
|
43
41
|
* Path to an icon file relative to project root.
|
|
44
42
|
* The file must be an SVG.
|
|
@@ -48,8 +46,6 @@ export declare interface CliConfig {
|
|
|
48
46
|
id?: string;
|
|
49
47
|
/** The ID for the Sanity organization that manages this application */
|
|
50
48
|
organizationId?: string;
|
|
51
|
-
/** Sort position within the dock group, ascending. Defaults to `100`. */
|
|
52
|
-
priority?: number;
|
|
53
49
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
54
50
|
title?: string;
|
|
55
51
|
/** Dashboard visibility of the application. Defaults to `default`. */
|
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"}
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -80,8 +80,6 @@ export declare interface CliConfig {
|
|
|
80
80
|
app?: {
|
|
81
81
|
/** The entrypoint for your custom app. By default, `src/App.tsx` */
|
|
82
82
|
entry?: string;
|
|
83
|
-
/** Dock group the app renders in. Defaults to `dock.applications`. */
|
|
84
|
-
group?: "dock.applications" | "dock.system" | "dock.user";
|
|
85
83
|
/**
|
|
86
84
|
* Path to an icon file relative to project root.
|
|
87
85
|
* The file must be an SVG.
|
|
@@ -91,8 +89,6 @@ export declare interface CliConfig {
|
|
|
91
89
|
id?: string;
|
|
92
90
|
/** The ID for the Sanity organization that manages this application */
|
|
93
91
|
organizationId?: string;
|
|
94
|
-
/** Sort position within the dock group, ascending. Defaults to `100`. */
|
|
95
|
-
priority?: number;
|
|
96
92
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
97
93
|
title?: string;
|
|
98
94
|
/** Dashboard visibility of the application. Defaults to `default`. */
|
package/dist/_exports/types.d.ts
CHANGED
|
@@ -38,8 +38,6 @@ export declare interface CliConfig {
|
|
|
38
38
|
app?: {
|
|
39
39
|
/** The entrypoint for your custom app. By default, `src/App.tsx` */
|
|
40
40
|
entry?: string;
|
|
41
|
-
/** Dock group the app renders in. Defaults to `dock.applications`. */
|
|
42
|
-
group?: "dock.applications" | "dock.system" | "dock.user";
|
|
43
41
|
/**
|
|
44
42
|
* Path to an icon file relative to project root.
|
|
45
43
|
* The file must be an SVG.
|
|
@@ -49,8 +47,6 @@ export declare interface CliConfig {
|
|
|
49
47
|
id?: string;
|
|
50
48
|
/** The ID for the Sanity organization that manages this application */
|
|
51
49
|
organizationId?: string;
|
|
52
|
-
/** Sort position within the dock group, ascending. Defaults to `100`. */
|
|
53
|
-
priority?: number;
|
|
54
50
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
55
51
|
title?: string;
|
|
56
52
|
/** Dashboard visibility of the application. Defaults to `default`. */
|
package/dist/_exports/ux.d.ts
CHANGED
|
@@ -24,12 +24,50 @@ export declare function colorizeJson(input: unknown): string;
|
|
|
24
24
|
|
|
25
25
|
export declare const confirm: typeof inquirer.confirm;
|
|
26
26
|
|
|
27
|
+
/** Create a {@link Flow} that writes rail lines through `log`. */
|
|
28
|
+
export declare function createFlow(log: LogFn): Flow;
|
|
29
|
+
|
|
27
30
|
export { CustomBorderStyle };
|
|
28
31
|
|
|
29
32
|
export declare const editor: typeof inquirer.editor;
|
|
30
33
|
|
|
31
34
|
export declare const expand: typeof inquirer.expand;
|
|
32
35
|
|
|
36
|
+
export declare interface Flow {
|
|
37
|
+
/** A copyable command belonging to the preceding action. */
|
|
38
|
+
command(command: string): void;
|
|
39
|
+
/** `│` — a blank rail line separating steps. */
|
|
40
|
+
gap(): void;
|
|
41
|
+
/** `◆` — an outcome the user should act on or remember. */
|
|
42
|
+
highlight(text: string): void;
|
|
43
|
+
/** `┌` — opening line of the story. */
|
|
44
|
+
intro(text: string): void;
|
|
45
|
+
/** `│ <text>` — a continuation line belonging to the previous step. */
|
|
46
|
+
line(text: string): void;
|
|
47
|
+
/** A copy-safe URL. Long URLs are never hard-wrapped. */
|
|
48
|
+
link(
|
|
49
|
+
url: string,
|
|
50
|
+
options?: {
|
|
51
|
+
label?: string;
|
|
52
|
+
outro?: boolean;
|
|
53
|
+
},
|
|
54
|
+
): void;
|
|
55
|
+
/** `●` — a step happening behind the scenes, or a tip. */
|
|
56
|
+
note(text: string): void;
|
|
57
|
+
/** `└` — closing line of the story. */
|
|
58
|
+
outro(text: string): void;
|
|
59
|
+
/** `◇` — a completed step or produced value. */
|
|
60
|
+
result(text: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* An in-flight step. Resolve it with `succeed(text)` (persists as a `◇` line) or `fail(text)`;
|
|
63
|
+
* renders on stderr so machine-readable stdout is never corrupted.
|
|
64
|
+
*/
|
|
65
|
+
spin(text: string): {
|
|
66
|
+
fail(text: string): void;
|
|
67
|
+
succeed(text: string): void;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
33
71
|
/**
|
|
34
72
|
* Starts a terminal timer
|
|
35
73
|
*
|
|
@@ -39,6 +77,8 @@ export declare function getTimer(): TimeMeasurer;
|
|
|
39
77
|
|
|
40
78
|
export declare const input: typeof inquirer.input;
|
|
41
79
|
|
|
80
|
+
declare type LogFn = (message?: string) => void;
|
|
81
|
+
|
|
42
82
|
export { logSymbols };
|
|
43
83
|
|
|
44
84
|
/**
|
package/dist/_exports/ux.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { NonInteractiveError } from '../errors/NonInteractiveError.js';
|
|
2
2
|
export { boxen } from '../ux/boxen.js';
|
|
3
3
|
export { colorizeJson } from '../ux/colorizeJson.js';
|
|
4
|
+
export { createFlow } from '../ux/flowOutput.js';
|
|
4
5
|
export { logSymbols } from '../ux/logSymbols.js';
|
|
5
6
|
export { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select, Separator } from '../ux/prompts.js';
|
|
6
7
|
export { spinner, spinnerPromise } from '../ux/spinner.js';
|
package/dist/_exports/ux.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {\n boxen,\n type BoxenOptions,\n type Boxes,\n type CustomBorderStyle,\n type Spacing,\n} from '../ux/boxen.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {logSymbols} from '../ux/logSymbols.js'\nexport {\n checkbox,\n confirm,\n editor,\n expand,\n input,\n number,\n password,\n rawlist,\n search,\n select,\n Separator,\n} from '../ux/prompts.js'\nexport {\n spinner,\n type Spinner,\n type SpinnerInstance,\n type SpinnerOptions,\n spinnerPromise,\n type SpinnerPromiseOptions,\n} from '../ux/spinner.js'\nexport {getTimer} from '../ux/timer.js'\n"],"names":["NonInteractiveError","boxen","colorizeJson","logSymbols","checkbox","confirm","editor","expand","input","number","password","rawlist","search","select","Separator","spinner","spinnerPromise","getTimer"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SACEC,KAAK,QAKA,iBAAgB;AACvB,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SACEC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,QACJ,mBAAkB;AACzB,SACEC,OAAO,EAIPC,cAAc,QAET,mBAAkB;AACzB,SAAQC,QAAQ,QAAO,iBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {\n boxen,\n type BoxenOptions,\n type Boxes,\n type CustomBorderStyle,\n type Spacing,\n} from '../ux/boxen.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {createFlow, type Flow} from '../ux/flowOutput.js'\nexport {logSymbols} from '../ux/logSymbols.js'\nexport {\n checkbox,\n confirm,\n editor,\n expand,\n input,\n number,\n password,\n rawlist,\n search,\n select,\n Separator,\n} from '../ux/prompts.js'\nexport {\n spinner,\n type Spinner,\n type SpinnerInstance,\n type SpinnerOptions,\n spinnerPromise,\n type SpinnerPromiseOptions,\n} from '../ux/spinner.js'\nexport {getTimer} from '../ux/timer.js'\n"],"names":["NonInteractiveError","boxen","colorizeJson","createFlow","logSymbols","checkbox","confirm","editor","expand","input","number","password","rawlist","search","select","Separator","spinner","spinnerPromise","getTimer"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SACEC,KAAK,QAKA,iBAAgB;AACvB,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,UAAU,QAAkB,sBAAqB;AACzD,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SACEC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,QACJ,mBAAkB;AACzB,SACEC,OAAO,EAIPC,cAAc,QAET,mBAAkB;AACzB,SAAQC,QAAQ,QAAO,iBAAgB"}
|
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":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** 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. */\n aspectsPath?: string\n }\n\n /** 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. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** 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. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAYA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import wrapAnsi from 'wrap-ansi';
|
|
3
|
+
import { isInteractive } from '../util/isInteractive.js';
|
|
4
|
+
import { spinner } from './spinner.js';
|
|
5
|
+
const SPINNER_FRAMES = [
|
|
6
|
+
'◐ ',
|
|
7
|
+
'◓ ',
|
|
8
|
+
'◑ ',
|
|
9
|
+
'◒ '
|
|
10
|
+
];
|
|
11
|
+
const RAIL_PREFIX_WIDTH = 3;
|
|
12
|
+
const MAX_RENDERED_LINE_WIDTH = 79;
|
|
13
|
+
function rail(glyph) {
|
|
14
|
+
return styleText('gray', glyph);
|
|
15
|
+
}
|
|
16
|
+
function wrapText(text) {
|
|
17
|
+
const terminalWidth = process.stdout.isTTY && Number.isFinite(process.stdout.columns) && process.stdout.columns > 0 ? process.stdout.columns : MAX_RENDERED_LINE_WIDTH + 1;
|
|
18
|
+
const renderedWidth = Math.min(terminalWidth - 1, MAX_RENDERED_LINE_WIDTH);
|
|
19
|
+
const width = Math.max(renderedWidth - RAIL_PREFIX_WIDTH, 1);
|
|
20
|
+
return wrapAnsi(text, width, {
|
|
21
|
+
hard: false,
|
|
22
|
+
wordWrap: true
|
|
23
|
+
}).split('\n');
|
|
24
|
+
}
|
|
25
|
+
function writeRailed(log, glyph, text) {
|
|
26
|
+
for (const [index, line] of wrapText(text).entries()){
|
|
27
|
+
const marker = index === 0 && glyph === '◆' ? styleText('green', glyph) : rail(index === 0 ? glyph : '│');
|
|
28
|
+
log(`${marker} ${line}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function writeStderr(message = '') {
|
|
32
|
+
process.stderr.write(`${message}\n`);
|
|
33
|
+
}
|
|
34
|
+
function isTerminalControl(character) {
|
|
35
|
+
const codePoint = character.codePointAt(0);
|
|
36
|
+
return codePoint !== undefined && (codePoint <= 0x1f || codePoint >= 0x7f && codePoint <= 0x9f);
|
|
37
|
+
}
|
|
38
|
+
function isSafeTerminalLink(url) {
|
|
39
|
+
if ([
|
|
40
|
+
...url
|
|
41
|
+
].some((character)=>isTerminalControl(character))) return false;
|
|
42
|
+
try {
|
|
43
|
+
const protocol = new URL(url).protocol;
|
|
44
|
+
return protocol === 'http:' || protocol === 'https:';
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function encodeTerminalControls(value) {
|
|
50
|
+
return [
|
|
51
|
+
...value
|
|
52
|
+
].map((character)=>isTerminalControl(character) ? encodeURIComponent(character) : character).join('');
|
|
53
|
+
}
|
|
54
|
+
function terminalLink(url) {
|
|
55
|
+
const sanitizedUrl = encodeTerminalControls(url);
|
|
56
|
+
if (!process.stdout.isTTY || sanitizedUrl !== url || !isSafeTerminalLink(url)) {
|
|
57
|
+
return sanitizedUrl;
|
|
58
|
+
}
|
|
59
|
+
return `\u001B]8;;${url}\u0007${styleText([
|
|
60
|
+
'cyan',
|
|
61
|
+
'underline'
|
|
62
|
+
], url)}\u001B]8;;\u0007`;
|
|
63
|
+
}
|
|
64
|
+
/** Create a {@link Flow} that writes rail lines through `log`. */ export function createFlow(log) {
|
|
65
|
+
return {
|
|
66
|
+
command (command) {
|
|
67
|
+
log(`${rail('│')} ${styleText('cyan', encodeTerminalControls(command))}`);
|
|
68
|
+
},
|
|
69
|
+
gap () {
|
|
70
|
+
log(rail('│'));
|
|
71
|
+
},
|
|
72
|
+
highlight (text) {
|
|
73
|
+
writeRailed(log, '◆', text);
|
|
74
|
+
},
|
|
75
|
+
intro (text) {
|
|
76
|
+
writeRailed(log, '┌', text);
|
|
77
|
+
},
|
|
78
|
+
line (text) {
|
|
79
|
+
writeRailed(log, '│', text);
|
|
80
|
+
},
|
|
81
|
+
link (url, options = {}) {
|
|
82
|
+
const label = options.label ? `${options.label} ` : '';
|
|
83
|
+
log(`${rail(options.outro ? '└' : '│')} ${label}${terminalLink(url)}`);
|
|
84
|
+
},
|
|
85
|
+
note (text) {
|
|
86
|
+
writeRailed(log, '●', text);
|
|
87
|
+
},
|
|
88
|
+
outro (text) {
|
|
89
|
+
writeRailed(log, '└', text);
|
|
90
|
+
},
|
|
91
|
+
result (text) {
|
|
92
|
+
writeRailed(log, '◇', text);
|
|
93
|
+
},
|
|
94
|
+
spin (text) {
|
|
95
|
+
const sanitizedText = encodeTerminalControls(text);
|
|
96
|
+
if (!isInteractive() || !process.stderr.isTTY || !process.stderr.columns) {
|
|
97
|
+
writeRailed(writeStderr, '●', sanitizedText);
|
|
98
|
+
return {
|
|
99
|
+
fail: (failText)=>writeStderr(`${styleText('red', '✖')} ${encodeTerminalControls(failText)}`),
|
|
100
|
+
succeed: (successText)=>writeStderr(`${rail('◇')} ${encodeTerminalControls(successText)}`)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const spin = spinner({
|
|
104
|
+
spinner: {
|
|
105
|
+
frames: SPINNER_FRAMES,
|
|
106
|
+
interval: 120
|
|
107
|
+
},
|
|
108
|
+
text: sanitizedText
|
|
109
|
+
}).start();
|
|
110
|
+
return {
|
|
111
|
+
fail (failText) {
|
|
112
|
+
spin.stopAndPersist({
|
|
113
|
+
symbol: `${styleText('red', '✖')} `,
|
|
114
|
+
text: encodeTerminalControls(failText)
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
succeed (successText) {
|
|
118
|
+
spin.stopAndPersist({
|
|
119
|
+
symbol: `${rail('◇')} `,
|
|
120
|
+
text: encodeTerminalControls(successText)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=flowOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ux/flowOutput.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport wrapAnsi from 'wrap-ansi'\n\nimport {isInteractive} from '../util/isInteractive.js'\nimport {spinner, type SpinnerInstance} from './spinner.js'\n\ntype LogFn = (message?: string) => void\n\nconst SPINNER_FRAMES = ['◐ ', '◓ ', '◑ ', '◒ ']\nconst RAIL_PREFIX_WIDTH = 3\nconst MAX_RENDERED_LINE_WIDTH = 79\n\nfunction rail(glyph: string): string {\n return styleText('gray', glyph)\n}\n\nfunction wrapText(text: string): string[] {\n const terminalWidth =\n process.stdout.isTTY && Number.isFinite(process.stdout.columns) && process.stdout.columns > 0\n ? process.stdout.columns\n : MAX_RENDERED_LINE_WIDTH + 1\n const renderedWidth = Math.min(terminalWidth - 1, MAX_RENDERED_LINE_WIDTH)\n const width = Math.max(renderedWidth - RAIL_PREFIX_WIDTH, 1)\n return wrapAnsi(text, width, {hard: false, wordWrap: true}).split('\\n')\n}\n\nfunction writeRailed(log: LogFn, glyph: string, text: string): void {\n for (const [index, line] of wrapText(text).entries()) {\n const marker =\n index === 0 && glyph === '◆' ? styleText('green', glyph) : rail(index === 0 ? glyph : '│')\n log(`${marker} ${line}`)\n }\n}\n\nfunction writeStderr(message = ''): void {\n process.stderr.write(`${message}\\n`)\n}\n\nfunction isTerminalControl(character: string): boolean {\n const codePoint = character.codePointAt(0)\n return codePoint !== undefined && (codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f))\n}\n\nfunction isSafeTerminalLink(url: string): boolean {\n if ([...url].some((character) => isTerminalControl(character))) return false\n try {\n const protocol = new URL(url).protocol\n return protocol === 'http:' || protocol === 'https:'\n } catch {\n return false\n }\n}\n\nfunction encodeTerminalControls(value: string): string {\n return [...value]\n .map((character) => (isTerminalControl(character) ? encodeURIComponent(character) : character))\n .join('')\n}\n\nfunction terminalLink(url: string): string {\n const sanitizedUrl = encodeTerminalControls(url)\n if (!process.stdout.isTTY || sanitizedUrl !== url || !isSafeTerminalLink(url)) {\n return sanitizedUrl\n }\n return `\\u001B]8;;${url}\\u0007${styleText(['cyan', 'underline'], url)}\\u001B]8;;\\u0007`\n}\n\nexport interface Flow {\n /** A copyable command belonging to the preceding action. */\n command(command: string): void\n /** `│` — a blank rail line separating steps. */\n gap(): void\n /** `◆` — an outcome the user should act on or remember. */\n highlight(text: string): void\n /** `┌` — opening line of the story. */\n intro(text: string): void\n /** `│ <text>` — a continuation line belonging to the previous step. */\n line(text: string): void\n /** A copy-safe URL. Long URLs are never hard-wrapped. */\n link(url: string, options?: {label?: string; outro?: boolean}): void\n /** `●` — a step happening behind the scenes, or a tip. */\n note(text: string): void\n /** `└` — closing line of the story. */\n outro(text: string): void\n /** `◇` — a completed step or produced value. */\n result(text: string): void\n /**\n * An in-flight step. Resolve it with `succeed(text)` (persists as a `◇` line) or `fail(text)`;\n * renders on stderr so machine-readable stdout is never corrupted.\n */\n spin(text: string): {fail(text: string): void; succeed(text: string): void}\n}\n\n/** Create a {@link Flow} that writes rail lines through `log`. */\nexport function createFlow(log: LogFn): Flow {\n return {\n command(command: string) {\n log(`${rail('│')} ${styleText('cyan', encodeTerminalControls(command))}`)\n },\n gap() {\n log(rail('│'))\n },\n highlight(text: string) {\n writeRailed(log, '◆', text)\n },\n intro(text: string) {\n writeRailed(log, '┌', text)\n },\n line(text: string) {\n writeRailed(log, '│', text)\n },\n link(url: string, options = {}) {\n const label = options.label ? `${options.label} ` : ''\n log(`${rail(options.outro ? '└' : '│')} ${label}${terminalLink(url)}`)\n },\n note(text: string) {\n writeRailed(log, '●', text)\n },\n outro(text: string) {\n writeRailed(log, '└', text)\n },\n result(text: string) {\n writeRailed(log, '◇', text)\n },\n spin(text: string) {\n const sanitizedText = encodeTerminalControls(text)\n if (!isInteractive() || !process.stderr.isTTY || !process.stderr.columns) {\n writeRailed(writeStderr, '●', sanitizedText)\n return {\n fail: (failText: string) =>\n writeStderr(`${styleText('red', '✖')} ${encodeTerminalControls(failText)}`),\n succeed: (successText: string) =>\n writeStderr(`${rail('◇')} ${encodeTerminalControls(successText)}`),\n }\n }\n\n const spin: SpinnerInstance = spinner({\n spinner: {frames: SPINNER_FRAMES, interval: 120},\n text: sanitizedText,\n }).start()\n return {\n fail(failText: string) {\n spin.stopAndPersist({\n symbol: `${styleText('red', '✖')} `,\n text: encodeTerminalControls(failText),\n })\n },\n succeed(successText: string) {\n spin.stopAndPersist({symbol: `${rail('◇')} `, text: encodeTerminalControls(successText)})\n },\n }\n },\n }\n}\n"],"names":["styleText","wrapAnsi","isInteractive","spinner","SPINNER_FRAMES","RAIL_PREFIX_WIDTH","MAX_RENDERED_LINE_WIDTH","rail","glyph","wrapText","text","terminalWidth","process","stdout","isTTY","Number","isFinite","columns","renderedWidth","Math","min","width","max","hard","wordWrap","split","writeRailed","log","index","line","entries","marker","writeStderr","message","stderr","write","isTerminalControl","character","codePoint","codePointAt","undefined","isSafeTerminalLink","url","some","protocol","URL","encodeTerminalControls","value","map","encodeURIComponent","join","terminalLink","sanitizedUrl","createFlow","command","gap","highlight","intro","link","options","label","outro","note","result","spin","sanitizedText","fail","failText","succeed","successText","frames","interval","start","stopAndPersist","symbol"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -123,8 +123,9 @@
|
|
|
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
|
+
"wrap-ansi": "^9.0.2",
|
|
128
129
|
"zod": "^4.4.3"
|
|
129
130
|
},
|
|
130
131
|
"devDependencies": {
|