@sanity/cli 6.1.3 → 6.1.5

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.
@@ -1,6 +1,10 @@
1
- import { SanityCommand } from '@sanity/cli-core';
1
+ import { SanityCommand, subdebug } from '@sanity/cli-core';
2
+ import { ensureAuthenticated } from '../../actions/auth/ensureAuthenticated.js';
2
3
  import { setupMCP } from '../../actions/mcp/setupMCP.js';
4
+ import { LoginError } from '../../errors/LoginError.js';
3
5
  import { MCPConfigureTrace } from '../../telemetry/mcp.telemetry.js';
6
+ import { getErrorMessage, toError } from '../../util/getErrorMessage.js';
7
+ const debug = subdebug('mcp:configure');
4
8
  export class ConfigureMcpCommand extends SanityCommand {
5
9
  static description = 'Configure Sanity MCP server for AI editors (Claude Code, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, VS Code)';
6
10
  static examples = [
@@ -12,17 +16,41 @@ export class ConfigureMcpCommand extends SanityCommand {
12
16
  async run() {
13
17
  const trace = this.telemetry.trace(MCPConfigureTrace);
14
18
  trace.start();
15
- const mcpResult = await setupMCP({
16
- explicit: true
17
- });
18
- trace.log({
19
- configuredEditors: mcpResult.configuredEditors,
20
- detectedEditors: mcpResult.detectedEditors
21
- });
22
- if (mcpResult.error) {
23
- trace.error(mcpResult.error);
24
- } else {
25
- trace.complete();
19
+ try {
20
+ await ensureAuthenticated({
21
+ output: this.output,
22
+ telemetry: this.telemetry
23
+ });
24
+ } catch (error) {
25
+ debug('Authentication check failed: %O', error);
26
+ trace.error(toError(error));
27
+ if (error instanceof LoginError) {
28
+ this.error(`Failed to verify authentication credentials: ${error.message}. Try running \`sanity login\`.`, {
29
+ exit: 1
30
+ });
31
+ }
32
+ this.error(`Failed to check authentication: ${getErrorMessage(error)}`, {
33
+ exit: 1
34
+ });
35
+ }
36
+ try {
37
+ const mcpResult = await setupMCP({
38
+ explicit: true
39
+ });
40
+ trace.log({
41
+ configuredEditors: mcpResult.configuredEditors,
42
+ detectedEditors: mcpResult.detectedEditors
43
+ });
44
+ if (mcpResult.error) {
45
+ trace.error(mcpResult.error);
46
+ } else {
47
+ trace.complete();
48
+ }
49
+ } catch (error) {
50
+ trace.error(toError(error));
51
+ this.error(getErrorMessage(error), {
52
+ exit: 1
53
+ });
26
54
  }
27
55
  }
28
56
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {SanityCommand} from '@sanity/cli-core'\n\nimport {setupMCP} from '../../actions/mcp/setupMCP.js'\nimport {MCPConfigureTrace} from '../../telemetry/mcp.telemetry.js'\n\nexport class ConfigureMcpCommand extends SanityCommand<typeof ConfigureMcpCommand> {\n static override description =\n 'Configure Sanity MCP server for AI editors (Claude Code, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, VS Code)'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Configure Sanity MCP server for detected AI editors',\n },\n ]\n\n public async run(): Promise<void> {\n const trace = this.telemetry.trace(MCPConfigureTrace)\n trace.start()\n const mcpResult = await setupMCP({explicit: true})\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n })\n\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n } else {\n trace.complete()\n }\n }\n}\n"],"names":["SanityCommand","setupMCP","MCPConfigureTrace","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","mcpResult","explicit","log","configuredEditors","detectedEditors","error","complete"],"mappings":"AAAA,SAAQA,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,iBAAiB,QAAO,mCAAkC;AAElE,OAAO,MAAMC,4BAA4BH;IACvC,OAAgBI,cACd,uHAAsH;IAExH,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAqB;QAChC,MAAMC,QAAQ,IAAI,CAACC,SAAS,CAACD,KAAK,CAACN;QACnCM,MAAME,KAAK;QACX,MAAMC,YAAY,MAAMV,SAAS;YAACW,UAAU;QAAI;QAEhDJ,MAAMK,GAAG,CAAC;YACRC,mBAAmBH,UAAUG,iBAAiB;YAC9CC,iBAAiBJ,UAAUI,eAAe;QAC5C;QAEA,IAAIJ,UAAUK,KAAK,EAAE;YACnBR,MAAMQ,KAAK,CAACL,UAAUK,KAAK;QAC7B,OAAO;YACLR,MAAMS,QAAQ;QAChB;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {ensureAuthenticated} from '../../actions/auth/ensureAuthenticated.js'\nimport {setupMCP} from '../../actions/mcp/setupMCP.js'\nimport {LoginError} from '../../errors/LoginError.js'\nimport {MCPConfigureTrace} from '../../telemetry/mcp.telemetry.js'\nimport {getErrorMessage, toError} from '../../util/getErrorMessage.js'\n\nconst debug = subdebug('mcp:configure')\n\nexport class ConfigureMcpCommand extends SanityCommand<typeof ConfigureMcpCommand> {\n static override description =\n 'Configure Sanity MCP server for AI editors (Claude Code, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, VS Code)'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Configure Sanity MCP server for detected AI editors',\n },\n ]\n\n public async run(): Promise<void> {\n const trace = this.telemetry.trace(MCPConfigureTrace)\n trace.start()\n\n try {\n await ensureAuthenticated({output: this.output, telemetry: this.telemetry})\n } catch (error) {\n debug('Authentication check failed: %O', error)\n trace.error(toError(error))\n\n if (error instanceof LoginError) {\n this.error(\n `Failed to verify authentication credentials: ${error.message}. Try running \\`sanity login\\`.`,\n {exit: 1},\n )\n }\n\n this.error(`Failed to check authentication: ${getErrorMessage(error)}`, {exit: 1})\n }\n\n try {\n const mcpResult = await setupMCP({explicit: true})\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n })\n\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n } else {\n trace.complete()\n }\n } catch (error) {\n trace.error(toError(error))\n this.error(getErrorMessage(error), {exit: 1})\n }\n }\n}\n"],"names":["SanityCommand","subdebug","ensureAuthenticated","setupMCP","LoginError","MCPConfigureTrace","getErrorMessage","toError","debug","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","output","error","message","exit","mcpResult","explicit","log","configuredEditors","detectedEditors","complete"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAExD,SAAQC,mBAAmB,QAAO,4CAA2C;AAC7E,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,UAAU,QAAO,6BAA4B;AACrD,SAAQC,iBAAiB,QAAO,mCAAkC;AAClE,SAAQC,eAAe,EAAEC,OAAO,QAAO,gCAA+B;AAEtE,MAAMC,QAAQP,SAAS;AAEvB,OAAO,MAAMQ,4BAA4BT;IACvC,OAAgBU,cACd,uHAAsH;IAExH,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAqB;QAChC,MAAMC,QAAQ,IAAI,CAACC,SAAS,CAACD,KAAK,CAACT;QACnCS,MAAME,KAAK;QAEX,IAAI;YACF,MAAMd,oBAAoB;gBAACe,QAAQ,IAAI,CAACA,MAAM;gBAAEF,WAAW,IAAI,CAACA,SAAS;YAAA;QAC3E,EAAE,OAAOG,OAAO;YACdV,MAAM,mCAAmCU;YACzCJ,MAAMI,KAAK,CAACX,QAAQW;YAEpB,IAAIA,iBAAiBd,YAAY;gBAC/B,IAAI,CAACc,KAAK,CACR,CAAC,6CAA6C,EAAEA,MAAMC,OAAO,CAAC,+BAA+B,CAAC,EAC9F;oBAACC,MAAM;gBAAC;YAEZ;YAEA,IAAI,CAACF,KAAK,CAAC,CAAC,gCAAgC,EAAEZ,gBAAgBY,QAAQ,EAAE;gBAACE,MAAM;YAAC;QAClF;QAEA,IAAI;YACF,MAAMC,YAAY,MAAMlB,SAAS;gBAACmB,UAAU;YAAI;YAEhDR,MAAMS,GAAG,CAAC;gBACRC,mBAAmBH,UAAUG,iBAAiB;gBAC9CC,iBAAiBJ,UAAUI,eAAe;YAC5C;YAEA,IAAIJ,UAAUH,KAAK,EAAE;gBACnBJ,MAAMI,KAAK,CAACG,UAAUH,KAAK;YAC7B,OAAO;gBACLJ,MAAMY,QAAQ;YAChB;QACF,EAAE,OAAOR,OAAO;YACdJ,MAAMI,KAAK,CAACX,QAAQW;YACpB,IAAI,CAACA,KAAK,CAACZ,gBAAgBY,QAAQ;gBAACE,MAAM;YAAC;QAC7C;IACF;AACF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Thrown when interactive login fails or is cancelled.
3
+ * Callers can use this to distinguish login failures (suggest `sanity login`)
4
+ * from transient network/server errors (don't suggest login).
5
+ *
6
+ * @internal
7
+ */ export class LoginError extends Error {
8
+ name = 'LoginError';
9
+ }
10
+
11
+ //# sourceMappingURL=LoginError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/errors/LoginError.ts"],"sourcesContent":["/**\n * Thrown when interactive login fails or is cancelled.\n * Callers can use this to distinguish login failures (suggest `sanity login`)\n * from transient network/server errors (don't suggest login).\n *\n * @internal\n */\nexport class LoginError extends Error {\n override name = 'LoginError'\n}\n"],"names":["LoginError","Error","name"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,mBAAmBC;IACrBC,OAAO,aAAY;AAC9B"}
@@ -1,4 +1,13 @@
1
1
  import { isHttpError } from '@sanity/client';
2
+ /**
3
+ * Coerce an unknown thrown value into an Error instance.
4
+ *
5
+ * @param value - The thrown value
6
+ * @returns An Error instance (the original if already an Error, otherwise a new one)
7
+ * @internal
8
+ */ export function toError(value) {
9
+ return value instanceof Error ? value : new Error(String(value));
10
+ }
2
11
  /**
3
12
  * Get the error message from an error object
4
13
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string'\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","getErrorMessage","err","body","response","message","Error"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C;;;;;;CAMC,GACD,OAAO,SAASC,gBAAgBC,GAAY;IAC1C,IAAIF,YAAYE,MAAM;QACpB,MAAMC,OAAOD,IAAIE,QAAQ,CAACD,IAAI;QAC9B,IACE,OAAOA,SAAS,YAChBA,SAAS,QACT,aAAaA,QACb,OAAOA,KAAKE,OAAO,KAAK,UACxB;YACA,OAAOF,KAAKE,OAAO;QACrB;QACA,OAAOH,IAAIG,OAAO,IAAI;IACxB;IACA,OAAOH,eAAeI,QAAQJ,IAAIG,OAAO,GAAG;AAC9C"}
1
+ {"version":3,"sources":["../../src/util/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\n/**\n * Coerce an unknown thrown value into an Error instance.\n *\n * @param value - The thrown value\n * @returns An Error instance (the original if already an Error, otherwise a new one)\n * @internal\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string'\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","toError","value","Error","String","getErrorMessage","err","body","response","message"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C;;;;;;CAMC,GACD,OAAO,SAASC,QAAQC,KAAc;IACpC,OAAOA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF;AAC3D;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBC,GAAY;IAC1C,IAAIN,YAAYM,MAAM;QACpB,MAAMC,OAAOD,IAAIE,QAAQ,CAACD,IAAI;QAC9B,IACE,OAAOA,SAAS,YAChBA,SAAS,QACT,aAAaA,QACb,OAAOA,KAAKE,OAAO,KAAK,UACxB;YACA,OAAOF,KAAKE,OAAO;QACrB;QACA,OAAOH,IAAIG,OAAO,IAAI;IACxB;IACA,OAAOH,eAAeH,QAAQG,IAAIG,OAAO,GAAG;AAC9C"}
@@ -4943,5 +4943,5 @@
4943
4943
  ]
4944
4944
  }
4945
4945
  },
4946
- "version": "6.1.3"
4946
+ "version": "6.1.5"
4947
4947
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "6.1.3",
3
+ "version": "6.1.5",
4
4
  "description": "Sanity CLI tool for managing Sanity projects and organizations",
5
5
  "keywords": [
6
6
  "cli",
@@ -51,11 +51,11 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@oclif/core": "^4.8.3",
54
+ "@oclif/core": "^4.8.4",
55
55
  "@oclif/plugin-help": "^6.2.37",
56
56
  "@oclif/plugin-not-found": "^3.2.74",
57
57
  "@sanity/client": "^7.17.0",
58
- "@sanity/codegen": "^6.0.0",
58
+ "@sanity/codegen": "^6.0.1",
59
59
  "@sanity/descriptors": "^1.3.0",
60
60
  "@sanity/export": "^6.1.0",
61
61
  "@sanity/generate-help-url": "^4.0.0",
@@ -118,11 +118,11 @@
118
118
  "which": "^6.0.1",
119
119
  "yaml": "^2.8.2",
120
120
  "zod": "^4.3.6",
121
- "@sanity/cli-core": "1.1.1"
121
+ "@sanity/cli-core": "1.1.2"
122
122
  },
123
123
  "devDependencies": {
124
124
  "@eslint/compat": "^2.0.3",
125
- "@sanity/pkg-utils": "^10.4.8",
125
+ "@sanity/pkg-utils": "^10.4.9",
126
126
  "@swc/cli": "^0.8.0",
127
127
  "@swc/core": "^1.15.18",
128
128
  "@types/debug": "^4.1.12",
@@ -142,7 +142,7 @@
142
142
  "babel-plugin-react-compiler": "^1.0.0",
143
143
  "eslint": "^9.39.4",
144
144
  "nock": "^14.0.11",
145
- "oclif": "^4.22.85",
145
+ "oclif": "^4.22.87",
146
146
  "publint": "^0.3.18",
147
147
  "rimraf": "^6.0.1",
148
148
  "sanity": "^5.15.0",
@@ -151,8 +151,8 @@
151
151
  "vitest": "^4.0.18",
152
152
  "@repo/package.config": "0.0.1",
153
153
  "@repo/tsconfig": "3.70.0",
154
- "@sanity/cli-test": "0.2.3",
155
- "@sanity/eslint-config-cli": "1.0.0"
154
+ "@sanity/eslint-config-cli": "1.0.0",
155
+ "@sanity/cli-test": "0.2.4"
156
156
  },
157
157
  "engines": {
158
158
  "node": ">=20.19.1 <22 || >=22.12"