@sanity/cli-core 2.6.0 → 2.7.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/apiClient.js +4 -7
- package/dist/apiClient.js.map +1 -1
- package/dist/executionContext.d.ts +12 -0
- package/dist/executionContext.js.map +1 -1
- package/dist/util/getSanityUrl.js +2 -1
- package/dist/util/getSanityUrl.js.map +1 -1
- package/dist/util/isStaging.js +3 -0
- package/dist/util/isStaging.js.map +1 -1
- package/package.json +2 -2
package/dist/apiClient.js
CHANGED
|
@@ -3,9 +3,8 @@ import { createClient, requester as defaultRequester, isHttpError } from '@sanit
|
|
|
3
3
|
import { getCliToken } from './config/cli/cliUserConfig.js';
|
|
4
4
|
import { generateHelpUrl } from './util/generateHelpUrl.js';
|
|
5
5
|
import { getSanityUrl } from './util/getSanityUrl.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
6
|
+
import { isStaging } from './util/isStaging.js';
|
|
7
|
+
const STAGING_API_HOST = 'https://api.sanity.work';
|
|
9
8
|
const CLI_REQUEST_TAG_PREFIX = 'sanity.cli';
|
|
10
9
|
/**
|
|
11
10
|
* Create a "global" (unscoped) Sanity API client.
|
|
@@ -17,8 +16,7 @@ const CLI_REQUEST_TAG_PREFIX = 'sanity.cli';
|
|
|
17
16
|
*/ export async function getGlobalCliClient({ requireUser, token: providedToken, unauthenticated, ...config }) {
|
|
18
17
|
const requester = defaultRequester.clone();
|
|
19
18
|
requester.use(authErrors());
|
|
20
|
-
const
|
|
21
|
-
const apiHost = apiHosts[sanityEnv];
|
|
19
|
+
const apiHost = isStaging() ? STAGING_API_HOST : undefined;
|
|
22
20
|
// Use the provided token if set, otherwise fall back to the stored CLI token (unless unauthenticated)
|
|
23
21
|
const token = providedToken || (unauthenticated ? undefined : await getCliToken());
|
|
24
22
|
// If the token is not set and requireUser is true, throw an error
|
|
@@ -49,8 +47,7 @@ const CLI_REQUEST_TAG_PREFIX = 'sanity.cli';
|
|
|
49
47
|
*/ export async function getProjectCliClient({ requireUser, token: providedToken, ...config }) {
|
|
50
48
|
const requester = defaultRequester.clone();
|
|
51
49
|
requester.use(authErrors(config.projectId));
|
|
52
|
-
const
|
|
53
|
-
const apiHost = apiHosts[sanityEnv];
|
|
50
|
+
const apiHost = isStaging() ? STAGING_API_HOST : undefined;
|
|
54
51
|
// Use the provided token if it is set, otherwise get the token from the config file
|
|
55
52
|
const token = providedToken || await getCliToken();
|
|
56
53
|
// If the token is not set and requireUser is true, throw an error
|
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'\n\nconst
|
|
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":"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"}
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
export declare interface CliExecutionContext {
|
|
24
|
+
/**
|
|
25
|
+
* Sanity deployment environment to use for this invocation.
|
|
26
|
+
* Overrides `SANITY_INTERNAL_ENV`.
|
|
27
|
+
*/
|
|
28
|
+
sanityEnv?: SanityEnvironment;
|
|
24
29
|
/**
|
|
25
30
|
* Sink for output the command would otherwise write to `process.stderr`.
|
|
26
31
|
* Called once per line, without a trailing newline.
|
|
@@ -60,4 +65,11 @@ export declare function runWithCliExecutionContext<T>(
|
|
|
60
65
|
fn: () => T,
|
|
61
66
|
): T;
|
|
62
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Sanity deployment environment used by a programmatic CLI invocation.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare type SanityEnvironment = "production" | "staging";
|
|
74
|
+
|
|
63
75
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/executionContext.ts"],"sourcesContent":["import {AsyncLocalStorage} from 'node:async_hooks'\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 * 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 * - `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;AAyDlD,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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Pure in-memory implementation. Widely exported.
|
|
2
|
+
import { isStaging } from './isStaging.js';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
* @returns The Sanity URL for the given path, using the correct domain based on the environment
|
|
5
6
|
*/ export function getSanityUrl(path = '/') {
|
|
6
|
-
const domain =
|
|
7
|
+
const domain = isStaging() ? 'https://www.sanity.work' : 'https://www.sanity.io';
|
|
7
8
|
return `${domain}${path.startsWith('/') ? path : `/${path}`}`;
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/getSanityUrl.ts"],"sourcesContent":["// Pure in-memory implementation. Widely exported.\n/**\n * @internal\n * @returns The Sanity URL for the given path, using the correct domain based on the environment\n */\nexport function getSanityUrl(path = '/') {\n const domain
|
|
1
|
+
{"version":3,"sources":["../../src/util/getSanityUrl.ts"],"sourcesContent":["// Pure in-memory implementation. Widely exported.\nimport {isStaging} from './isStaging.js'\n\n/**\n * @internal\n * @returns The Sanity URL for the given path, using the correct domain based on the environment\n */\nexport function getSanityUrl(path = '/') {\n const domain = isStaging() ? 'https://www.sanity.work' : 'https://www.sanity.io'\n return `${domain}${path.startsWith('/') ? path : `/${path}`}`\n}\n"],"names":["isStaging","getSanityUrl","path","domain","startsWith"],"mappings":"AAAA,kDAAkD;AAClD,SAAQA,SAAS,QAAO,iBAAgB;AAExC;;;CAGC,GACD,OAAO,SAASC,aAAaC,OAAO,GAAG;IACrC,MAAMC,SAASH,cAAc,4BAA4B;IACzD,OAAO,GAAGG,SAASD,KAAKE,UAAU,CAAC,OAAOF,OAAO,CAAC,CAAC,EAAEA,MAAM,EAAE;AAC/D"}
|
package/dist/util/isStaging.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { getCliExecutionContext } from '../executionContext.js';
|
|
1
2
|
/**
|
|
2
3
|
* Checks if the environment is staging.
|
|
3
4
|
*
|
|
4
5
|
* @returns True if the environment is staging, false otherwise
|
|
5
6
|
* @internal
|
|
6
7
|
*/ export function isStaging() {
|
|
8
|
+
const context = getCliExecutionContext();
|
|
9
|
+
if (context) return context.sanityEnv === 'staging';
|
|
7
10
|
return process.env.SANITY_INTERNAL_ENV === 'staging';
|
|
8
11
|
}
|
|
9
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/isStaging.ts"],"sourcesContent":["/**\n * Checks if the environment is staging.\n *\n * @returns True if the environment is staging, false otherwise\n * @internal\n */\nexport function isStaging(): boolean {\n return process.env.SANITY_INTERNAL_ENV === 'staging'\n}\n"],"names":["isStaging","process","env","SANITY_INTERNAL_ENV"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/util/isStaging.ts"],"sourcesContent":["import {getCliExecutionContext} from '../executionContext.js'\n\n/**\n * Checks if the environment is staging.\n *\n * @returns True if the environment is staging, false otherwise\n * @internal\n */\nexport function isStaging(): boolean {\n const context = getCliExecutionContext()\n\n if (context) return context.sanityEnv === 'staging'\n\n return process.env.SANITY_INTERNAL_ENV === 'staging'\n}\n"],"names":["getCliExecutionContext","isStaging","context","sanityEnv","process","env","SANITY_INTERNAL_ENV"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,yBAAwB;AAE7D;;;;;CAKC,GACD,OAAO,SAASC;IACd,MAAMC,UAAUF;IAEhB,IAAIE,SAAS,OAAOA,QAAQC,SAAS,KAAK;IAE1C,OAAOC,QAAQC,GAAG,CAACC,mBAAmB,KAAK;AAC7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
140
140
|
"eslint": "^10.7.0",
|
|
141
141
|
"publint": "^0.3.21",
|
|
142
|
-
"sanity": "^6.
|
|
142
|
+
"sanity": "^6.7.0",
|
|
143
143
|
"typescript": "^6.0.3",
|
|
144
144
|
"vitest": "^4.1.10",
|
|
145
145
|
"@repo/package.config": "0.0.1",
|