@sanity/cli 8.33.0 → 8.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/codemods/dashboardViewsV1.ts +226 -0
- package/dist/actions/codemods/dashboard.js +8 -117
- package/dist/actions/codemods/dashboard.js.map +1 -1
- package/dist/actions/codemods/dashboardViewsV1.js +82 -0
- package/dist/actions/codemods/dashboardViewsV1.js.map +1 -0
- package/dist/actions/codemods/index.js +2 -0
- package/dist/actions/codemods/index.js.map +1 -1
- package/dist/actions/codemods/upgradeRequiredPackages.js +121 -0
- package/dist/actions/codemods/upgradeRequiredPackages.js.map +1 -0
- package/dist/actions/mcp/detectAvailableEditors.js +2 -2
- package/dist/actions/mcp/detectAvailableEditors.js.map +1 -1
- package/dist/actions/mcp/editorConfigs.js +25 -2
- package/dist/actions/mcp/editorConfigs.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/mcp/configure.js +1 -1
- package/dist/commands/mcp/configure.js.map +1 -1
- package/dist/commands/projects/create.js +54 -5
- package/dist/commands/projects/create.js.map +1 -1
- package/dist/commands/skills/install.js +1 -1
- package/dist/commands/skills/install.js.map +1 -1
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +2 -1
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
- package/dist/services/projects.js +18 -0
- package/dist/services/projects.js.map +1 -1
- package/dist/util/telemetry/sanitizeTelemetryEvent.js +2 -2
- package/dist/util/telemetry/sanitizeTelemetryEvent.js.map +1 -1
- package/oclif.manifest.json +3180 -3158
- package/package.json +5 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getLocalPackageVersion } from '@sanity/cli-core';
|
|
4
|
+
import { getYarnMajorVersion, readPackageJson } from '@sanity/cli-core/package-manager';
|
|
5
|
+
import { confirm } from '@sanity/cli-core/ux';
|
|
6
|
+
import { execa } from 'execa';
|
|
7
|
+
import { lt } from 'semver';
|
|
8
|
+
import yaml from 'yaml';
|
|
9
|
+
import { detectWorkspace } from '../../util/packageManager/installationInfo/detectWorkspace.js';
|
|
10
|
+
import { getPackageManagerChoice, getPartialEnvWithNpmPath } from '../../util/packageManager/packageManagerChoice.js';
|
|
11
|
+
async function findOutdated(packages, workDir) {
|
|
12
|
+
const installed = await Promise.all(packages.map(({ name })=>getLocalPackageVersion(name, workDir)));
|
|
13
|
+
return packages.flatMap((pkg, index)=>{
|
|
14
|
+
const version = installed[index];
|
|
15
|
+
return version && lt(version, pkg.min) ? [
|
|
16
|
+
{
|
|
17
|
+
...pkg,
|
|
18
|
+
version
|
|
19
|
+
}
|
|
20
|
+
] : [];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// corepack's `packageManager: "yarn@4.9.1"` names the major even without a .yarnrc.yml
|
|
24
|
+
function declaredYarnMajor(field) {
|
|
25
|
+
const match = typeof field === 'string' ? /^yarn@(\d+)/.exec(field) : null;
|
|
26
|
+
return match ? Number.parseInt(match[1], 10) : undefined;
|
|
27
|
+
}
|
|
28
|
+
function listOutdated(packages) {
|
|
29
|
+
return packages.map(({ min, name, neededBy, version })=>` - ${name} ${version} (${neededBy} ${min} or later)`).join('\n');
|
|
30
|
+
}
|
|
31
|
+
export async function upgradeRequiredPackages(required, { dry, output, workDir }) {
|
|
32
|
+
const outdated = await findOutdated(required, workDir);
|
|
33
|
+
if (outdated.length > 0) {
|
|
34
|
+
output.warn(`\`sanity dev\` and \`sanity deploy\` will fail until you upgrade:\n${listOutdated(outdated)}`);
|
|
35
|
+
const { chosen: packageManager } = await getPackageManagerChoice(workDir, {
|
|
36
|
+
interactive: false
|
|
37
|
+
});
|
|
38
|
+
const { root, yarnBerry } = await detectWorkspace(workDir);
|
|
39
|
+
const [{ dependencies, devDependencies }, rootManifest] = await Promise.all([
|
|
40
|
+
readPackageJson(path.join(workDir, 'package.json'), {
|
|
41
|
+
skipSchemaValidation: true
|
|
42
|
+
}),
|
|
43
|
+
readFile(path.join(root, 'package.json'), 'utf8').then(JSON.parse, ()=>null)
|
|
44
|
+
]);
|
|
45
|
+
let pnpmOverrides = [];
|
|
46
|
+
if (packageManager === 'pnpm') {
|
|
47
|
+
const workspacePath = path.join(root, 'pnpm-workspace.yaml');
|
|
48
|
+
const workspaceConfig = await readFile(workspacePath, 'utf8').then(yaml.parse, ()=>null);
|
|
49
|
+
pnpmOverrides = Object.keys({
|
|
50
|
+
...rootManifest?.pnpm?.overrides,
|
|
51
|
+
...workspaceConfig?.overrides
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// bun's upgrade leaves a catalog untouched, yarn's swaps `catalog:` for a plain range, and
|
|
55
|
+
// pnpm's does the same when `overrides` pins the package
|
|
56
|
+
const isUnupgradableCatalog = (name)=>(dependencies?.[name] ?? devDependencies?.[name] ?? '').startsWith('catalog:') && (packageManager === 'bun' || packageManager === 'yarn' || pnpmOverrides.some((key)=>key === name || key.startsWith(`${name}@`)));
|
|
57
|
+
const catalogued = outdated.filter(({ name })=>isUnupgradableCatalog(name));
|
|
58
|
+
const upgradable = outdated.filter(({ name })=>!isUnupgradableCatalog(name));
|
|
59
|
+
if (catalogued.length > 0) {
|
|
60
|
+
const targets = catalogued.map(({ min, name })=>`${name} to ^${min} or later`).join(', ');
|
|
61
|
+
const install = `then run \`${packageManager} install\``;
|
|
62
|
+
output.log(packageManager === 'pnpm' ? `pnpm can't upgrade catalog packages that \`overrides\` pin, so update them yourself: set ${targets} in the catalog and in \`overrides\`, ${install}.` : `${packageManager} can't upgrade catalog packages, so update them yourself: set ${targets} in the catalog in ${packageManager === 'bun' ? 'the root package.json' : '.yarnrc.yml'}, ${install}.`);
|
|
63
|
+
}
|
|
64
|
+
if (upgradable.length > 0) {
|
|
65
|
+
const names = upgradable.map(({ name })=>name);
|
|
66
|
+
const latest = names.map((name)=>`${name}@latest`);
|
|
67
|
+
// Berry dropped `yarn upgrade`, and the user agent only names yarn when the CLI itself was
|
|
68
|
+
// run through yarn, so take the project's own signals first
|
|
69
|
+
const isYarnBerry = yarnBerry || (declaredYarnMajor(rootManifest?.packageManager) ?? getYarnMajorVersion() ?? 1) >= 2;
|
|
70
|
+
// pnpm keeps `catalog:` and bumps the catalog entry only with `update --latest`
|
|
71
|
+
const command = {
|
|
72
|
+
bun: [
|
|
73
|
+
'bun',
|
|
74
|
+
'update',
|
|
75
|
+
...latest
|
|
76
|
+
],
|
|
77
|
+
manual: undefined,
|
|
78
|
+
npm: [
|
|
79
|
+
'npm',
|
|
80
|
+
'install',
|
|
81
|
+
'--legacy-peer-deps',
|
|
82
|
+
...latest
|
|
83
|
+
],
|
|
84
|
+
pnpm: [
|
|
85
|
+
'pnpm',
|
|
86
|
+
'update',
|
|
87
|
+
...names,
|
|
88
|
+
'--latest'
|
|
89
|
+
],
|
|
90
|
+
yarn: [
|
|
91
|
+
'yarn',
|
|
92
|
+
isYarnBerry ? 'up' : 'upgrade',
|
|
93
|
+
...latest
|
|
94
|
+
]
|
|
95
|
+
}[packageManager];
|
|
96
|
+
if (!command) {
|
|
97
|
+
output.log(`Upgrade ${names.join(', ')} to the latest version with your package manager.`);
|
|
98
|
+
} else if (dry || !await confirm({
|
|
99
|
+
default: true,
|
|
100
|
+
message: `Upgrade ${names.join(', ')} to the latest version now?`
|
|
101
|
+
})) {
|
|
102
|
+
output.log(`Run \`${command.join(' ')}\` to upgrade.`);
|
|
103
|
+
} else {
|
|
104
|
+
output.log(`Running \`${command.join(' ')}\``);
|
|
105
|
+
// The version check below reports a failed upgrade, so the exit code isn't needed
|
|
106
|
+
await execa(command[0], command.slice(1), {
|
|
107
|
+
cwd: workDir,
|
|
108
|
+
env: getPartialEnvWithNpmPath(workDir),
|
|
109
|
+
reject: false,
|
|
110
|
+
stdio: 'inherit'
|
|
111
|
+
});
|
|
112
|
+
const stillOutdated = await findOutdated(upgradable, workDir);
|
|
113
|
+
if (stillOutdated.length > 0) {
|
|
114
|
+
output.warn(`These are still too old after the upgrade. Upgrade them before you run \`sanity dev\` or \`sanity deploy\`:\n${listOutdated(stillOutdated)}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=upgradeRequiredPackages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/codemods/upgradeRequiredPackages.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {getLocalPackageVersion, type Output} from '@sanity/cli-core'\nimport {getYarnMajorVersion, readPackageJson} from '@sanity/cli-core/package-manager'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {execa} from 'execa'\nimport {lt} from 'semver'\nimport yaml from 'yaml'\n\nimport {detectWorkspace} from '../../util/packageManager/installationInfo/detectWorkspace.js'\nimport {\n getPackageManagerChoice,\n getPartialEnvWithNpmPath,\n} from '../../util/packageManager/packageManagerChoice.js'\n\ninterface RequiredPackage {\n min: string\n name: string\n neededBy: string\n}\n\nasync function findOutdated(packages: RequiredPackage[], workDir: string) {\n const installed = await Promise.all(\n packages.map(({name}) => getLocalPackageVersion(name, workDir)),\n )\n return packages.flatMap((pkg, index) => {\n const version = installed[index]\n return version && lt(version, pkg.min) ? [{...pkg, version}] : []\n })\n}\n\n// corepack's `packageManager: \"yarn@4.9.1\"` names the major even without a .yarnrc.yml\nfunction declaredYarnMajor(field: unknown) {\n const match = typeof field === 'string' ? /^yarn@(\\d+)/.exec(field) : null\n return match ? Number.parseInt(match[1], 10) : undefined\n}\n\nfunction listOutdated(packages: Awaited<ReturnType<typeof findOutdated>>) {\n return packages\n .map(({min, name, neededBy, version}) => ` - ${name} ${version} (${neededBy} ${min} or later)`)\n .join('\\n')\n}\n\nexport async function upgradeRequiredPackages(\n required: RequiredPackage[],\n {dry, output, workDir}: {dry: boolean; output: Output; workDir: string},\n): Promise<void> {\n const outdated = await findOutdated(required, workDir)\n if (outdated.length > 0) {\n output.warn(\n `\\`sanity dev\\` and \\`sanity deploy\\` will fail until you upgrade:\\n${listOutdated(outdated)}`,\n )\n\n const {chosen: packageManager} = await getPackageManagerChoice(workDir, {interactive: false})\n const {root, yarnBerry} = await detectWorkspace(workDir)\n const [{dependencies, devDependencies}, rootManifest] = await Promise.all([\n readPackageJson(path.join(workDir, 'package.json'), {skipSchemaValidation: true}),\n readFile(path.join(root, 'package.json'), 'utf8').then(JSON.parse, () => null),\n ])\n let pnpmOverrides: string[] = []\n if (packageManager === 'pnpm') {\n const workspacePath = path.join(root, 'pnpm-workspace.yaml')\n const workspaceConfig = await readFile(workspacePath, 'utf8').then(yaml.parse, () => null)\n pnpmOverrides = Object.keys({\n ...rootManifest?.pnpm?.overrides,\n ...workspaceConfig?.overrides,\n })\n }\n\n // bun's upgrade leaves a catalog untouched, yarn's swaps `catalog:` for a plain range, and\n // pnpm's does the same when `overrides` pins the package\n const isUnupgradableCatalog = (name: string) =>\n (dependencies?.[name] ?? devDependencies?.[name] ?? '').startsWith('catalog:') &&\n (packageManager === 'bun' ||\n packageManager === 'yarn' ||\n pnpmOverrides.some((key) => key === name || key.startsWith(`${name}@`)))\n const catalogued = outdated.filter(({name}) => isUnupgradableCatalog(name))\n const upgradable = outdated.filter(({name}) => !isUnupgradableCatalog(name))\n\n if (catalogued.length > 0) {\n const targets = catalogued.map(({min, name}) => `${name} to ^${min} or later`).join(', ')\n const install = `then run \\`${packageManager} install\\``\n output.log(\n packageManager === 'pnpm'\n ? `pnpm can't upgrade catalog packages that \\`overrides\\` pin, so update them yourself: set ${targets} in the catalog and in \\`overrides\\`, ${install}.`\n : `${packageManager} can't upgrade catalog packages, so update them yourself: set ${targets} in the catalog in ${packageManager === 'bun' ? 'the root package.json' : '.yarnrc.yml'}, ${install}.`,\n )\n }\n\n if (upgradable.length > 0) {\n const names = upgradable.map(({name}) => name)\n const latest = names.map((name) => `${name}@latest`)\n // Berry dropped `yarn upgrade`, and the user agent only names yarn when the CLI itself was\n // run through yarn, so take the project's own signals first\n const isYarnBerry =\n yarnBerry ||\n (declaredYarnMajor(rootManifest?.packageManager) ?? getYarnMajorVersion() ?? 1) >= 2\n // pnpm keeps `catalog:` and bumps the catalog entry only with `update --latest`\n const command = {\n bun: ['bun', 'update', ...latest],\n manual: undefined,\n npm: ['npm', 'install', '--legacy-peer-deps', ...latest],\n pnpm: ['pnpm', 'update', ...names, '--latest'],\n yarn: ['yarn', isYarnBerry ? 'up' : 'upgrade', ...latest],\n }[packageManager]\n\n if (!command) {\n output.log(`Upgrade ${names.join(', ')} to the latest version with your package manager.`)\n } else if (\n dry ||\n !(await confirm({\n default: true,\n message: `Upgrade ${names.join(', ')} to the latest version now?`,\n }))\n ) {\n output.log(`Run \\`${command.join(' ')}\\` to upgrade.`)\n } else {\n output.log(`Running \\`${command.join(' ')}\\``)\n // The version check below reports a failed upgrade, so the exit code isn't needed\n await execa(command[0], command.slice(1), {\n cwd: workDir,\n env: getPartialEnvWithNpmPath(workDir),\n reject: false,\n stdio: 'inherit',\n })\n const stillOutdated = await findOutdated(upgradable, workDir)\n if (stillOutdated.length > 0) {\n output.warn(\n `These are still too old after the upgrade. Upgrade them before you run \\`sanity dev\\` or \\`sanity deploy\\`:\\n${listOutdated(stillOutdated)}`,\n )\n }\n }\n }\n }\n}\n"],"names":["readFile","path","getLocalPackageVersion","getYarnMajorVersion","readPackageJson","confirm","execa","lt","yaml","detectWorkspace","getPackageManagerChoice","getPartialEnvWithNpmPath","findOutdated","packages","workDir","installed","Promise","all","map","name","flatMap","pkg","index","version","min","declaredYarnMajor","field","match","exec","Number","parseInt","undefined","listOutdated","neededBy","join","upgradeRequiredPackages","required","dry","output","outdated","length","warn","chosen","packageManager","interactive","root","yarnBerry","dependencies","devDependencies","rootManifest","skipSchemaValidation","then","JSON","parse","pnpmOverrides","workspacePath","workspaceConfig","Object","keys","pnpm","overrides","isUnupgradableCatalog","startsWith","some","key","catalogued","filter","upgradable","targets","install","log","names","latest","isYarnBerry","command","bun","manual","npm","yarn","default","message","slice","cwd","env","reject","stdio","stillOutdated"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,OAAOC,UAAU,YAAW;AAE5B,SAAQC,sBAAsB,QAAoB,mBAAkB;AACpE,SAAQC,mBAAmB,EAAEC,eAAe,QAAO,mCAAkC;AACrF,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,KAAK,QAAO,QAAO;AAC3B,SAAQC,EAAE,QAAO,SAAQ;AACzB,OAAOC,UAAU,OAAM;AAEvB,SAAQC,eAAe,QAAO,gEAA+D;AAC7F,SACEC,uBAAuB,EACvBC,wBAAwB,QACnB,oDAAmD;AAQ1D,eAAeC,aAAaC,QAA2B,EAAEC,OAAe;IACtE,MAAMC,YAAY,MAAMC,QAAQC,GAAG,CACjCJ,SAASK,GAAG,CAAC,CAAC,EAACC,IAAI,EAAC,GAAKjB,uBAAuBiB,MAAML;IAExD,OAAOD,SAASO,OAAO,CAAC,CAACC,KAAKC;QAC5B,MAAMC,UAAUR,SAAS,CAACO,MAAM;QAChC,OAAOC,WAAWhB,GAAGgB,SAASF,IAAIG,GAAG,IAAI;YAAC;gBAAC,GAAGH,GAAG;gBAAEE;YAAO;SAAE,GAAG,EAAE;IACnE;AACF;AAEA,uFAAuF;AACvF,SAASE,kBAAkBC,KAAc;IACvC,MAAMC,QAAQ,OAAOD,UAAU,WAAW,cAAcE,IAAI,CAACF,SAAS;IACtE,OAAOC,QAAQE,OAAOC,QAAQ,CAACH,KAAK,CAAC,EAAE,EAAE,MAAMI;AACjD;AAEA,SAASC,aAAanB,QAAkD;IACtE,OAAOA,SACJK,GAAG,CAAC,CAAC,EAACM,GAAG,EAAEL,IAAI,EAAEc,QAAQ,EAAEV,OAAO,EAAC,GAAK,CAAC,IAAI,EAAEJ,KAAK,CAAC,EAAEI,QAAQ,EAAE,EAAEU,SAAS,C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AO;oBAAW;uBAAyBL;iBAAO;gBACxDb,MAAM;oBAAC;oBAAQ;uBAAaY;oBAAO;iBAAW;gBAC9CO,MAAM;oBAAC;oBAAQL,cAAc,OAAO;uBAAcD;iBAAO;YAC3D,CAAC,CAAC7B,eAAe;YAEjB,IAAI,CAAC+B,SAAS;gBACZpC,OAAOgC,GAAG,CAAC,CAAC,QAAQ,EAAEC,MAAMrC,IAAI,CAAC,MAAM,iDAAiD,CAAC;YAC3F,OAAO,IACLG,OACA,CAAE,MAAMhC,QAAQ;gBACd0E,SAAS;gBACTC,SAAS,CAAC,QAAQ,EAAET,MAAMrC,IAAI,CAAC,MAAM,2BAA2B,CAAC;YACnE,IACA;gBACAI,OAAOgC,GAAG,CAAC,CAAC,MAAM,EAAEI,QAAQxC,IAAI,CAAC,KAAK,cAAc,CAAC;YACvD,OAAO;gBACLI,OAAOgC,GAAG,CAAC,CAAC,UAAU,EAAEI,QAAQxC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7C,kFAAkF;gBAClF,MAAM5B,MAAMoE,OAAO,CAAC,EAAE,EAAEA,QAAQO,KAAK,CAAC,IAAI;oBACxCC,KAAKpE;oBACLqE,KAAKxE,yBAAyBG;oBAC9BsE,QAAQ;oBACRC,OAAO;gBACT;gBACA,MAAMC,gBAAgB,MAAM1E,aAAauD,YAAYrD;gBACrD,IAAIwE,cAAc9C,MAAM,GAAG,GAAG;oBAC5BF,OAAOG,IAAI,CACT,CAAC,6GAA6G,EAAET,aAAasD,gBAAgB;gBAEjJ;YACF;QACF;IACF;AACF"}
|
|
@@ -87,8 +87,8 @@ const debug = subdebug('mcp:detectAvailableEditors');
|
|
|
87
87
|
*/ export async function detectAvailableEditors(env) {
|
|
88
88
|
const ctx = env ?? createDetectionEnv();
|
|
89
89
|
// Detect all editors in parallel to avoid stacking timeouts —
|
|
90
|
-
// CLI-based editors (Claude Code, Codex CLI, OpenCode) each have a
|
|
91
|
-
// 5s execa timeout, so sequential detection can add ~
|
|
90
|
+
// CLI-based editors (Claude Code, Codex CLI, OpenCode, Pi) each have a
|
|
91
|
+
// 5s execa timeout, so sequential detection can add ~20s on machines
|
|
92
92
|
// where none are installed.
|
|
93
93
|
const results = await Promise.all(Object.entries(EDITOR_CONFIGS).map(async ([name, config])=>{
|
|
94
94
|
const configPath = await config.detect(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/mcp/detectAvailableEditors.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport fs from 'node:fs/promises'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {type ParseError, parse as parseJsonc} from 'jsonc-parser'\nimport {parse as parseToml} from 'smol-toml'\n\nimport {\n createDetectionEnv,\n type DetectionEnv,\n EDITOR_CONFIGS,\n type EditorName,\n hasLegacyToken,\n} from './editorConfigs.js'\nimport {type Editor} from './types.js'\n\nconst debug = subdebug('mcp:detectAvailableEditors')\n\ninterface MCPConfig {\n [key: string]: Record<string, unknown> | undefined\n}\n\n/**\n * Safely parse config file content\n * Returns parsed config or null if unparseable\n */\nfunction parseConfig(content: string, format: 'jsonc' | 'toml'): MCPConfig | null {\n const trimmed = content.trim()\n if (trimmed === '') {\n return {} // Empty file - safe to write, treat as empty config\n }\n\n if (format === 'toml') {\n try {\n const parsed = parseToml(content)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null\n }\n\n return parsed as MCPConfig\n } catch {\n return null\n }\n }\n\n const errors: ParseError[] = []\n const parsed = parseJsonc(content, errors, {allowTrailingComma: true})\n\n if (errors.length > 0 || typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null // Parse failed\n }\n\n return parsed as MCPConfig\n}\n\n/**\n * Check if an editor's config is usable and whether Sanity MCP is already configured.\n * Returns null only if config exists but can't be parsed (to avoid data loss).\n */\nasync function checkEditorConfig(name: EditorName, configPath: string): Promise<Editor | null> {\n const {configKey, format} = EDITOR_CONFIGS[name]\n\n // Config file doesn't exist - can create it\n if (!existsSync(configPath)) {\n return {configPath, configured: false, name}\n }\n\n // Config exists - try to parse it\n try {\n const content = await fs.readFile(configPath, 'utf8')\n const config = parseConfig(content, format)\n\n if (config === null) {\n debug('Skipping %s: could not parse %s', name, configPath)\n return null // Can't parse - skip this editor\n }\n\n // Check if Sanity MCP is already configured, and whether it still holds a token\n const sanityConfig = config[configKey]?.Sanity\n const configured = Boolean(sanityConfig)\n if (\n typeof sanityConfig === 'object' &&\n sanityConfig !== null &&\n hasLegacyToken(sanityConfig as Record<string, unknown>)\n ) {\n return {configPath, configured, hasLegacyToken: true, name}\n }\n\n return {configPath, configured, name}\n } catch (err) {\n debug('Skipping %s: could not read %s: %s', name, configPath, err)\n return null\n }\n}\n\n/**\n * Detect which editors are installed and have parseable configs.\n * Editors with unparseable configs are skipped to avoid data loss.\n *\n * Accepts an optional `DetectionEnv` for testability. When omitted,\n * uses the real process/OS environment.\n */\nexport async function detectAvailableEditors(env?: DetectionEnv): Promise<Editor[]> {\n const ctx = env ?? createDetectionEnv()\n\n // Detect all editors in parallel to avoid stacking timeouts —\n // CLI-based editors (Claude Code, Codex CLI, OpenCode) each have a\n // 5s execa timeout, so sequential detection can add ~
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/mcp/detectAvailableEditors.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport fs from 'node:fs/promises'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {type ParseError, parse as parseJsonc} from 'jsonc-parser'\nimport {parse as parseToml} from 'smol-toml'\n\nimport {\n createDetectionEnv,\n type DetectionEnv,\n EDITOR_CONFIGS,\n type EditorName,\n hasLegacyToken,\n} from './editorConfigs.js'\nimport {type Editor} from './types.js'\n\nconst debug = subdebug('mcp:detectAvailableEditors')\n\ninterface MCPConfig {\n [key: string]: Record<string, unknown> | undefined\n}\n\n/**\n * Safely parse config file content\n * Returns parsed config or null if unparseable\n */\nfunction parseConfig(content: string, format: 'jsonc' | 'toml'): MCPConfig | null {\n const trimmed = content.trim()\n if (trimmed === '') {\n return {} // Empty file - safe to write, treat as empty config\n }\n\n if (format === 'toml') {\n try {\n const parsed = parseToml(content)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null\n }\n\n return parsed as MCPConfig\n } catch {\n return null\n }\n }\n\n const errors: ParseError[] = []\n const parsed = parseJsonc(content, errors, {allowTrailingComma: true})\n\n if (errors.length > 0 || typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null // Parse failed\n }\n\n return parsed as MCPConfig\n}\n\n/**\n * Check if an editor's config is usable and whether Sanity MCP is already configured.\n * Returns null only if config exists but can't be parsed (to avoid data loss).\n */\nasync function checkEditorConfig(name: EditorName, configPath: string): Promise<Editor | null> {\n const {configKey, format} = EDITOR_CONFIGS[name]\n\n // Config file doesn't exist - can create it\n if (!existsSync(configPath)) {\n return {configPath, configured: false, name}\n }\n\n // Config exists - try to parse it\n try {\n const content = await fs.readFile(configPath, 'utf8')\n const config = parseConfig(content, format)\n\n if (config === null) {\n debug('Skipping %s: could not parse %s', name, configPath)\n return null // Can't parse - skip this editor\n }\n\n // Check if Sanity MCP is already configured, and whether it still holds a token\n const sanityConfig = config[configKey]?.Sanity\n const configured = Boolean(sanityConfig)\n if (\n typeof sanityConfig === 'object' &&\n sanityConfig !== null &&\n hasLegacyToken(sanityConfig as Record<string, unknown>)\n ) {\n return {configPath, configured, hasLegacyToken: true, name}\n }\n\n return {configPath, configured, name}\n } catch (err) {\n debug('Skipping %s: could not read %s: %s', name, configPath, err)\n return null\n }\n}\n\n/**\n * Detect which editors are installed and have parseable configs.\n * Editors with unparseable configs are skipped to avoid data loss.\n *\n * Accepts an optional `DetectionEnv` for testability. When omitted,\n * uses the real process/OS environment.\n */\nexport async function detectAvailableEditors(env?: DetectionEnv): Promise<Editor[]> {\n const ctx = env ?? createDetectionEnv()\n\n // Detect all editors in parallel to avoid stacking timeouts —\n // CLI-based editors (Claude Code, Codex CLI, OpenCode, Pi) each have a\n // 5s execa timeout, so sequential detection can add ~20s on machines\n // where none are installed.\n const results = await Promise.all(\n Object.entries(EDITOR_CONFIGS).map(async ([name, config]) => {\n const configPath = await config.detect(ctx)\n if (!configPath) return null\n return checkEditorConfig(name as EditorName, configPath)\n }),\n )\n\n return results.filter((editor): editor is Editor => editor !== null)\n}\n"],"names":["existsSync","fs","subdebug","parse","parseJsonc","parseToml","createDetectionEnv","EDITOR_CONFIGS","hasLegacyToken","debug","parseConfig","content","format","trimmed","trim","parsed","Array","isArray","errors","allowTrailingComma","length","checkEditorConfig","name","configPath","configKey","configured","readFile","config","sanityConfig","Sanity","Boolean","err","detectAvailableEditors","env","ctx","results","Promise","all","Object","entries","map","detect","filter","editor"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,QAAQ,mBAAkB;AAEjC,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAyBC,SAASC,UAAU,QAAO,eAAc;AACjE,SAAQD,SAASE,SAAS,QAAO,YAAW;AAE5C,SACEC,kBAAkB,EAElBC,cAAc,EAEdC,cAAc,QACT,qBAAoB;AAG3B,MAAMC,QAAQP,SAAS;AAMvB;;;CAGC,GACD,SAASQ,YAAYC,OAAe,EAAEC,MAAwB;IAC5D,MAAMC,UAAUF,QAAQG,IAAI;IAC5B,IAAID,YAAY,IAAI;QAClB,OAAO,CAAC,EAAE,oDAAoD;;IAChE;IAEA,IAAID,WAAW,QAAQ;QACrB,IAAI;YACF,MAAMG,SAASV,UAAUM;YACzB,IAAI,OAAOI,WAAW,YAAYA,WAAW,QAAQC,MAAMC,OAAO,CAACF,SAAS;gBAC1E,OAAO;YACT;YAEA,OAAOA;QACT,EAAE,OAAM;YACN,OAAO;QACT;IACF;IAEA,MAAMG,SAAuB,EAAE;IAC/B,MAAMH,SAASX,WAAWO,SAASO,QAAQ;QAACC,oBAAoB;IAAI;IAEpE,IAAID,OAAOE,MAAM,GAAG,KAAK,OAAOL,WAAW,YAAYA,WAAW,QAAQC,MAAMC,OAAO,CAACF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OY,QAAQO,MAAM,CAAC,CAACC,SAA6BA,WAAW;AACjE"}
|
|
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { execa } from 'execa';
|
|
5
|
+
import { gte as semverGte, valid as semverValid } from 'semver';
|
|
5
6
|
import { MCP_SERVER_URL } from '../../services/mcp.js';
|
|
6
7
|
/** Create the real detection environment backed by process/OS globals. */ export function createDetectionEnv() {
|
|
7
8
|
return {
|
|
@@ -9,7 +10,7 @@ import { MCP_SERVER_URL } from '../../services/mcp.js';
|
|
|
9
10
|
execCommand: (cmd, args)=>execa(cmd, args, {
|
|
10
11
|
stdio: 'pipe',
|
|
11
12
|
timeout: 5000
|
|
12
|
-
}).then(()=>
|
|
13
|
+
}).then((res)=>res.stdout),
|
|
13
14
|
existsSync,
|
|
14
15
|
homedir: os.homedir(),
|
|
15
16
|
platform: process.platform
|
|
@@ -95,6 +96,20 @@ async function detectOpenCode(ctx) {
|
|
|
95
96
|
return null;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
async function detectPi(ctx) {
|
|
100
|
+
try {
|
|
101
|
+
const stdout = await ctx.execCommand('pi', [
|
|
102
|
+
'--version'
|
|
103
|
+
]);
|
|
104
|
+
const version = semverValid(stdout.trim());
|
|
105
|
+
// Built-in MCP support was introduced in Pi v1
|
|
106
|
+
if (!version || !semverGte(version, '1.0.0')) return null;
|
|
107
|
+
const piDir = ctx.env.PI_CODING_AGENT_DIR || path.join(ctx.homedir, '.pi/agent');
|
|
108
|
+
return path.join(piDir, 'mcp.json');
|
|
109
|
+
} catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
98
113
|
async function detectVSCode(ctx) {
|
|
99
114
|
const configDir = getVSCodeUserDir(ctx);
|
|
100
115
|
return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null;
|
|
@@ -279,6 +294,13 @@ function buildZedServerConfig() {
|
|
|
279
294
|
detect: detectOpenCode,
|
|
280
295
|
skillsCliAgent: 'opencode'
|
|
281
296
|
},
|
|
297
|
+
// Doc: https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/mcp.md
|
|
298
|
+
// Path: $PI_CODING_AGENT_DIR || ~/.pi/agent/mcp.json Key: mcpServers
|
|
299
|
+
Pi: {
|
|
300
|
+
...EDITOR_DEFAULTS,
|
|
301
|
+
detect: detectPi,
|
|
302
|
+
skillsCliAgent: 'pi'
|
|
303
|
+
},
|
|
282
304
|
// Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
|
|
283
305
|
// Path: <VS Code User dir>/mcp.json Key: servers
|
|
284
306
|
// VS Code uses GitHub Copilot for AI features; skills are installed via the
|
|
@@ -326,7 +348,8 @@ export function getSkillsCliAgent(editorName) {
|
|
|
326
348
|
cursor: 'Cursor',
|
|
327
349
|
'gemini-cli': 'Gemini CLI',
|
|
328
350
|
'github-copilot': 'GitHub Copilot',
|
|
329
|
-
opencode: 'OpenCode'
|
|
351
|
+
opencode: 'OpenCode',
|
|
352
|
+
pi: 'Pi'
|
|
330
353
|
};
|
|
331
354
|
export function isUniversalSkillsCliAgentByEditorName(editorName) {
|
|
332
355
|
return EDITOR_CONFIGS[editorName]?.skillsDir === UNIVERSAL_SKILLS_DIR;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/mcp/editorConfigs.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport {execa} from 'execa'\n\nimport {MCP_SERVER_URL} from '../../services/mcp.js'\n\n/**\n * Environment abstraction for editor detection.\n *\n * Detect functions receive this instead of using module-level imports, making\n * each function independently testable without global mocks.\n */\nexport interface DetectionEnv {\n env: Record<string, string | undefined>\n /** Run a CLI command to check if a tool is installed. Rejects on failure. */\n execCommand: (cmd: string, args: string[]) => Promise<void>\n existsSync: (p: string) => boolean\n homedir: string\n platform: NodeJS.Platform\n}\n\n/** Create the real detection environment backed by process/OS globals. */\nexport function createDetectionEnv(): DetectionEnv {\n return {\n env: process.env,\n execCommand: (cmd, args) => execa(cmd, args, {stdio: 'pipe', timeout: 5000}).then(() => {}),\n existsSync,\n homedir: os.homedir(),\n platform: process.platform,\n }\n}\n\ninterface EditorConfig {\n /**\n * Builds the Sanity server config. It never contains credentials: every\n * supported editor signs in to the MCP server itself, using OAuth.\n */\n buildServerConfig: () => Record<string, unknown>\n configKey: string\n /** Returns the config file path if editor is detected, null otherwise */\n detect: (env: DetectionEnv) => Promise<string | null>\n format: 'jsonc' | 'toml'\n\n /**\n * Corresponding `--agent` value for the `skills` CLI (https://github.com/vercel-labs/skills).\n * Omit when the editor has no skills CLI equivalent.\n */\n skillsCliAgent?: string\n /**\n * The directory to install skills to.\n */\n skillsDir?: string\n}\n\n/** The Sanity MCP server uses OAuth, so a config only needs to point at it */\nconst defaultHttpConfig = () => ({\n type: 'http',\n url: MCP_SERVER_URL,\n})\n\n// -- Detect functions --\n\nasync function detectClaudeCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('claude', ['--version'])\n return path.join(ctx.homedir, '.claude.json')\n } catch {\n return null\n }\n}\n\nasync function detectAntigravity(ctx: DetectionEnv): Promise<string | null> {\n // Shared by the Antigravity app and CLI. The older `~/.gemini/antigravity`\n // location is no longer read.\n const configDir = path.join(ctx.homedir, '.gemini/config')\n return ctx.existsSync(configDir) ? path.join(configDir, 'mcp_config.json') : null\n}\n\nexport function getVSCodeUserDir(\n ctx: DetectionEnv,\n variant: 'insiders' | 'stable' = 'stable',\n): string | null {\n switch (ctx.platform) {\n case 'darwin': {\n return path.join(\n ctx.homedir,\n variant === 'insiders'\n ? 'Library/Application Support/Code - Insiders/User'\n : 'Library/Application Support/Code/User',\n )\n }\n case 'win32': {\n if (!ctx.env.APPDATA) return null\n return path.join(\n ctx.env.APPDATA,\n variant === 'insiders' ? 'Code - Insiders/User' : 'Code/User',\n )\n }\n default: {\n return path.join(\n ctx.homedir,\n variant === 'insiders' ? '.config/Code - Insiders/User' : '.config/Code/User',\n )\n }\n }\n}\n\nasync function detectCline(ctx: DetectionEnv): Promise<string | null> {\n // Shared by the Cline VS Code extension (4.1+) and Cline CLI. The extension's\n // older `globalStorage/saoudrizwan.claude-dev` file is no longer read.\n const clineHome = ctx.env.CLINE_DIR || path.join(ctx.homedir, '.cline')\n if (!ctx.existsSync(clineHome)) return null\n return path.join(clineHome, 'data/settings/cline_mcp_settings.json')\n}\n\nasync function detectCodexCli(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('codex', ['--version'])\n const codexHome = ctx.env.CODEX_HOME || path.join(ctx.homedir, '.codex')\n return path.join(codexHome, 'config.toml')\n } catch {\n return null\n }\n}\n\nasync function detectCursor(ctx: DetectionEnv): Promise<string | null> {\n const cursorDir = path.join(ctx.homedir, '.cursor')\n return ctx.existsSync(cursorDir) ? path.join(cursorDir, 'mcp.json') : null\n}\n\nasync function detectGeminiCli(ctx: DetectionEnv): Promise<string | null> {\n // Antigravity stores its config under ~/.gemini/antigravity, so checking\n // only the parent ~/.gemini directory causes false Gemini CLI detection.\n const settingsPath = path.join(ctx.homedir, '.gemini/settings.json')\n return ctx.existsSync(settingsPath) ? settingsPath : null\n}\n\nasync function detectGitHubCopilotCli(ctx: DetectionEnv): Promise<string | null> {\n const copilotDir =\n ctx.platform === 'linux' && ctx.env.XDG_CONFIG_HOME\n ? path.join(ctx.env.XDG_CONFIG_HOME, 'copilot')\n : path.join(ctx.homedir, '.copilot')\n return ctx.existsSync(copilotDir) ? path.join(copilotDir, 'mcp-config.json') : null\n}\n\nasync function detectOpenCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('opencode', ['--version'])\n return path.join(ctx.homedir, '.config/opencode/opencode.json')\n } catch {\n return null\n }\n}\n\nasync function detectVSCode(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx)\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectVSCodeInsiders(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx, 'insiders')\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectZed(ctx: DetectionEnv): Promise<string | null> {\n let configDir: string | null = null\n switch (ctx.platform) {\n case 'win32': {\n if (ctx.env.APPDATA) {\n configDir = path.join(ctx.env.APPDATA, 'Zed')\n }\n break\n }\n default: {\n configDir = path.join(ctx.homedir, '.config/zed')\n }\n }\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'settings.json') : null\n}\n\nasync function detectMCPorter(ctx: DetectionEnv): Promise<string | null> {\n const mcporterDir = path.join(ctx.homedir, '.mcporter')\n if (!ctx.existsSync(mcporterDir)) return null\n\n const jsonPath = path.join(mcporterDir, 'mcporter.json')\n const jsoncPath = path.join(mcporterDir, 'mcporter.jsonc')\n if (ctx.existsSync(jsonPath)) return jsonPath\n if (ctx.existsSync(jsoncPath)) return jsoncPath\n return jsonPath\n}\n\n// -- Legacy token detection --\n\n/**\n * Whether a Sanity server config holds a token in `headers` (or `http_headers`\n * for Codex CLI). Older CLI versions saved a login token there as\n * `Authorization: Bearer <token>`, and users may have added an API token the\n * same way. The two can't be told apart, so both are treated alike.\n */\nexport function hasLegacyToken(serverConfig: Record<string, unknown>): boolean {\n return [serverConfig.headers, serverConfig.http_headers].some(\n (headers) =>\n typeof headers === 'object' &&\n headers !== null &&\n typeof (headers as Record<string, unknown>).Authorization === 'string',\n )\n}\n\n// -- Defaults & build server config functions --\n\nexport const UNIVERSAL_SKILLS_DIR = '.agents/skills'\n/** Most editors share these values — entries only need to declare `detect` + any overrides. */\nconst EDITOR_DEFAULTS = {\n buildServerConfig: defaultHttpConfig,\n configKey: 'mcpServers',\n format: 'jsonc' as const,\n skillsDir: UNIVERSAL_SKILLS_DIR,\n}\n\nfunction buildAntigravityServerConfig(): Record<string, unknown> {\n return {serverUrl: MCP_SERVER_URL}\n}\n\nfunction buildClineServerConfig(): Record<string, unknown> {\n return {\n disabled: false,\n type: 'streamableHttp',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildGeminiCliServerConfig(): Record<string, unknown> {\n // Without `oauth.enabled`, Gemini CLI waits for the user to run `/mcp auth`\n return {\n oauth: {enabled: true},\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildGitHubCopilotCliServerConfig(): Record<string, unknown> {\n return {\n tools: ['*'],\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildMCPorterServerConfig(): Record<string, unknown> {\n return {\n auth: 'oauth',\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildOpenCodeServerConfig(): Record<string, unknown> {\n return {\n type: 'remote',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildZedServerConfig(): Record<string, unknown> {\n return {\n enabled: true,\n url: MCP_SERVER_URL,\n }\n}\n\n/**\n * Centralized editor configuration including detection logic.\n * To add a new editor: add an entry here — EditorName type is derived automatically.\n *\n * Each entry includes a doc URL pointing to the source of truth for its\n * config path and format. When updating a path, verify against the linked\n * documentation first.\n */\nexport const EDITOR_CONFIGS = {\n // Doc: https://antigravity.google/docs/mcp\n // Path: ~/.gemini/config/mcp_config.json Key: mcpServers\n Antigravity: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildAntigravityServerConfig,\n detect: detectAntigravity,\n skillsCliAgent: 'antigravity',\n },\n // Doc: https://docs.anthropic.com/en/docs/claude-code/mcp\n // Path: ~/.claude.json Key: mcpServers\n 'Claude Code': {\n ...EDITOR_DEFAULTS,\n detect: detectClaudeCode,\n skillsCliAgent: 'claude-code',\n skillsDir: '.claude/skills',\n },\n // Doc: https://github.com/cline/cline — VS Code extension and CLI share one file\n // Path: $CLINE_DIR || ~/.cline/data/settings/cline_mcp_settings.json\n Cline: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildClineServerConfig,\n detect: detectCline,\n skillsCliAgent: 'cline',\n },\n // Doc: https://platform.openai.com/docs/guides/tools-remote-mcp#codex-cli\n // Path: $CODEX_HOME || ~/.codex/config.toml Key: mcp_servers Format: TOML\n 'Codex CLI': {\n ...EDITOR_DEFAULTS,\n configKey: 'mcp_servers',\n detect: detectCodexCli,\n format: 'toml' as const,\n skillsCliAgent: 'codex',\n },\n // Doc: https://docs.cursor.com/context/model-context-protocol\n // Path: ~/.cursor/mcp.json Key: mcpServers\n Cursor: {\n ...EDITOR_DEFAULTS,\n detect: detectCursor,\n skillsCliAgent: 'cursor',\n },\n // Doc: https://googlegemini.wiki/gemini-cli/mcp-servers\n // Path: ~/.gemini/settings.json Key: mcpServers\n 'Gemini CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGeminiCliServerConfig,\n detect: detectGeminiCli,\n skillsCliAgent: 'gemini-cli',\n },\n // Doc: https://docs.github.com/en/copilot/customizing-copilot/extending-copilot-coding-agent-with-mcp\n // Path: ~/.copilot/mcp-config.json (or $XDG_CONFIG_HOME/copilot on Linux) Key: mcpServers\n 'GitHub Copilot CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGitHubCopilotCliServerConfig,\n detect: detectGitHubCopilotCli,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://github.com/nicobailon/mcporter\n // Path: ~/.mcporter/mcporter.{json,jsonc} Key: mcpServers\n MCPorter: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildMCPorterServerConfig,\n detect: detectMCPorter,\n },\n // Doc: https://opencode.ai/docs/config\n // Path: ~/.config/opencode/opencode.json Key: mcp\n OpenCode: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildOpenCodeServerConfig,\n configKey: 'mcp',\n detect: detectOpenCode,\n skillsCliAgent: 'opencode',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code User dir>/mcp.json Key: servers\n // VS Code uses GitHub Copilot for AI features; skills are installed via the\n // `github-copilot` agent (see https://code.visualstudio.com/docs/copilot/customization/agent-skills).\n 'VS Code': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCode,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code Insiders User dir>/mcp.json Key: servers\n 'VS Code Insiders': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCodeInsiders,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://zed.dev/docs/assistant/model-context-protocol\n // Path: ~/.config/zed/settings.json (or $APPDATA/Zed on Windows) Key: context_servers\n // Zed doesn't support agent skills - https://github.com/zed-industries/zed/issues/49057\n Zed: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildZedServerConfig,\n configKey: 'context_servers',\n detect: detectZed,\n },\n} satisfies Record<string, EditorConfig>\n\n/** Derived from EDITOR_CONFIGS keys - add a new editor there and this updates automatically */\nexport type EditorName = keyof typeof EDITOR_CONFIGS\n\nexport function getSkillsCliAgent(editorName: EditorName): string | undefined {\n if (editorName in EDITOR_CONFIGS) {\n const config = EDITOR_CONFIGS[editorName]\n return 'skillsCliAgent' in config ? config.skillsCliAgent : undefined\n }\n}\n\n/**\n * Skills-CLI agent ID → display name. Mirrors `displayName` from\n * `~/git/skills/src/agents.ts` for the subset of agents we install for. Used\n * to match `skills list --json` output (which keys by display name) against\n * our editors.\n */\nconst SKILLS_CLI_AGENT_DISPLAY_NAMES: Record<string, string> = {\n antigravity: 'Antigravity',\n 'claude-code': 'Claude Code',\n cline: 'Cline',\n codex: 'Codex',\n cursor: 'Cursor',\n 'gemini-cli': 'Gemini CLI',\n 'github-copilot': 'GitHub Copilot',\n opencode: 'OpenCode',\n}\n\nexport function isUniversalSkillsCliAgentByEditorName(editorName: EditorName): boolean {\n return EDITOR_CONFIGS[editorName]?.skillsDir === UNIVERSAL_SKILLS_DIR\n}\n\n/** Display name used by the skills CLI for the given editor, if it has a mapping. */\nexport function getSkillsCliAgentDisplayName(editorName: EditorName): string | undefined {\n const agent = getSkillsCliAgent(editorName)\n return agent ? SKILLS_CLI_AGENT_DISPLAY_NAMES[agent] : undefined\n}\n\n/** Display name for a skills-CLI agent ID (e.g. `'cursor'` → `'Cursor'`). */\nexport function getSkillsCliAgentDisplayNameById(agentId: string): string | undefined {\n return SKILLS_CLI_AGENT_DISPLAY_NAMES[agentId]\n}\n\n/**\n * The relative, home-anchored directory the `skills` CLI installs into for a\n * given agent ID (e.g. `'cursor'` → `'.agents/skills'`, `'claude-code'` →\n * `'.claude/skills'`). Derived from `EDITOR_CONFIGS` so it stays a single\n * source of truth.\n */\nexport function getSkillsCliAgentSkillsDir(agentName: string): string | undefined {\n for (const name of Object.keys(EDITOR_CONFIGS) as EditorName[]) {\n const config = EDITOR_CONFIGS[name]\n const agent = getSkillsCliAgent(name)\n if (agent === agentName) {\n return config.skillsDir\n }\n }\n return undefined\n}\n"],"names":["existsSync","os","path","execa","MCP_SERVER_URL","createDetectionEnv","env","process","execCommand","cmd","args","stdio","timeout","then","homedir","platform","defaultHttpConfig","type","url","detectClaudeCode","ctx","join","detectAntigravity","configDir","getVSCodeUserDir","variant","APPDATA","detectCline","clineHome","CLINE_DIR","detectCodexCli","codexHome","CODEX_HOME","detectCursor","cursorDir","detectGeminiCli","settingsPath","detectGitHubCopilotCli","copilotDir","XDG_CONFIG_HOME","detectOpenCode","detectVSCode","detectVSCodeInsiders","detectZed","detectMCPorter","mcporterDir","jsonPath","jsoncPath","hasLegacyToken","serverConfig","headers","http_headers","some","Authorization","UNIVERSAL_SKILLS_DIR","EDITOR_DEFAULTS","buildServerConfig","configKey","format","skillsDir","buildAntigravityServerConfig","serverUrl","buildClineServerConfig","disabled","buildGeminiCliServerConfig","oauth","enabled","buildGitHubCopilotCliServerConfig","tools","buildMCPorterServerConfig","auth","buildOpenCodeServerConfig","buildZedServerConfig","EDITOR_CONFIGS","Antigravity","detect","skillsCliAgent","Cline","Cursor","MCPorter","OpenCode","Zed","getSkillsCliAgent","editorName","config","undefined","SKILLS_CLI_AGENT_DISPLAY_NAMES","antigravity","cline","codex","cursor","opencode","isUniversalSkillsCliAgentByEditorName","getSkillsCliAgentDisplayName","agent","getSkillsCliAgentDisplayNameById","agentId","getSkillsCliAgentSkillsDir","agentName","name","Object","keys"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAAQC,KAAK,QAAO,QAAO;AAE3B,SAAQC,cAAc,QAAO,wBAAuB;AAiBpD,wEAAwE,GACxE,OAAO,SAASC;IACd,OAAO;QACLC,KAAKC,QAAQD,GAAG;QAChBE,aAAa,CAACC,KAAKC,OAASP,MAAMM,KAAKC,MAAM;gBAACC,OAAO;gBAAQC,SAAS;YAAI,GAAGC,IAAI,CAAC,KAAO;QACzFb;QACAc,SAASb,GAAGa,OAAO;QACnBC,UAAUR,QAAQQ,QAAQ;IAC5B;AACF;AAwBA,4EAA4E,GAC5E,MAAMC,oBAAoB,IAAO,CAAA;QAC/BC,MAAM;QACNC,KAAKd;IACP,CAAA;AAEA,yBAAyB;AAEzB,eAAee,iBAAiBC,GAAiB;IAC/C,IAAI;QACF,MAAMA,IAAIZ,WAAW,CAAC,UAAU;YAAC;SAAY;QAC7C,OAAON,KAAKmB,IAAI,CAACD,IAAIN,OAAO,EAAE;IAChC,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,eAAeQ,kBAAkBF,GAAiB;IAChD,2EAA2E;IAC3E,8BAA8B;IAC9B,MAAMG,YAAYrB,KAAKmB,IAAI,CAACD,IAAIN,OAAO,EAAE;IACzC,OAAOM,IAAIpB,UAAU,CAACuB,aAAarB,KAAKmB,IAAI,CAACE,WAAW,qBAAqB;AAC/E;AAEA,OAAO,SAASC,iBACdJ,GAAiB,EACjBK,UAAiC,QAAQ;IAEzC,OAAQL,IAAIL,QAAQ;QAClB,KAAK;YAAU;gBACb,OAAOb,KAA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Ae;QAClBE,WAAW;QACXkB,QAAQjC;QACRkC,gBAAgB;IAClB;IACA,6DAA6D;IAC7D,uFAAuF;IACvF,wFAAwF;IACxFK,KAAK;QACH,GAAG1B,eAAe;QAClBC,mBAAmBgB;QACnBf,WAAW;QACXkB,QAAQhC;IACV;AACF,EAAwC;AAKxC,OAAO,SAASuC,kBAAkBC,UAAsB;IACtD,IAAIA,cAAcV,gBAAgB;QAChC,MAAMW,SAASX,cAAc,CAACU,WAAW;QACzC,OAAO,oBAAoBC,SAASA,OAAOR,cAAc,GAAGS;IAC9D;AACF;AAEA;;;;;CAKC,GACD,MAAMC,iCAAyD;IAC7DC,aAAa;IACb,eAAe;IACfC,OAAO;IACPC,OAAO;IACPC,QAAQ;IACR,cAAc;IACd,kBAAkB;IAClBC,UAAU;AACZ;AAEA,OAAO,SAASC,sCAAsCT,UAAsB;IAC1E,OAAOV,cAAc,CAACU,WAAW,EAAExB,cAAcL;AACnD;AAEA,mFAAmF,GACnF,OAAO,SAASuC,6BAA6BV,UAAsB;IACjE,MAAMW,QAAQZ,kBAAkBC;IAChC,OAAOW,QAAQR,8BAA8B,CAACQ,MAAM,GAAGT;AACzD;AAEA,2EAA2E,GAC3E,OAAO,SAASU,iCAAiCC,OAAe;IAC9D,OAAOV,8BAA8B,CAACU,QAAQ;AAChD;AAEA;;;;;CAKC,GACD,OAAO,SAASC,2BAA2BC,SAAiB;IAC1D,KAAK,MAAMC,QAAQC,OAAOC,IAAI,CAAC5B,gBAAiC;QAC9D,MAAMW,SAASX,cAAc,CAAC0B,KAAK;QACnC,MAAML,QAAQZ,kBAAkBiB;QAChC,IAAIL,UAAUI,WAAW;YACvB,OAAOd,OAAOzB,SAAS;QACzB;IACF;IACA,OAAO0B;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/mcp/editorConfigs.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport {execa} from 'execa'\nimport {gte as semverGte, valid as semverValid} from 'semver'\n\nimport {MCP_SERVER_URL} from '../../services/mcp.js'\n\n/**\n * Environment abstraction for editor detection.\n *\n * Detect functions receive this instead of using module-level imports, making\n * each function independently testable without global mocks.\n */\nexport interface DetectionEnv {\n env: Record<string, string | undefined>\n /** Run a CLI command and return its stdout. Rejects on failure. */\n execCommand: (cmd: string, args: string[]) => Promise<string>\n existsSync: (p: string) => boolean\n homedir: string\n platform: NodeJS.Platform\n}\n\n/** Create the real detection environment backed by process/OS globals. */\nexport function createDetectionEnv(): DetectionEnv {\n return {\n env: process.env,\n execCommand: (cmd, args) =>\n execa(cmd, args, {stdio: 'pipe', timeout: 5000}).then((res) => res.stdout),\n existsSync,\n homedir: os.homedir(),\n platform: process.platform,\n }\n}\n\ninterface EditorConfig {\n /**\n * Builds the Sanity server config. It never contains credentials: every\n * supported editor signs in to the MCP server itself, using OAuth.\n */\n buildServerConfig: () => Record<string, unknown>\n configKey: string\n /** Returns the config file path if editor is detected, null otherwise */\n detect: (env: DetectionEnv) => Promise<string | null>\n format: 'jsonc' | 'toml'\n\n /**\n * Corresponding `--agent` value for the `skills` CLI (https://github.com/vercel-labs/skills).\n * Omit when the editor has no skills CLI equivalent.\n */\n skillsCliAgent?: string\n /**\n * The directory to install skills to.\n */\n skillsDir?: string\n}\n\n/** The Sanity MCP server uses OAuth, so a config only needs to point at it */\nconst defaultHttpConfig = () => ({\n type: 'http',\n url: MCP_SERVER_URL,\n})\n\n// -- Detect functions --\n\nasync function detectClaudeCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('claude', ['--version'])\n return path.join(ctx.homedir, '.claude.json')\n } catch {\n return null\n }\n}\n\nasync function detectAntigravity(ctx: DetectionEnv): Promise<string | null> {\n // Shared by the Antigravity app and CLI. The older `~/.gemini/antigravity`\n // location is no longer read.\n const configDir = path.join(ctx.homedir, '.gemini/config')\n return ctx.existsSync(configDir) ? path.join(configDir, 'mcp_config.json') : null\n}\n\nexport function getVSCodeUserDir(\n ctx: DetectionEnv,\n variant: 'insiders' | 'stable' = 'stable',\n): string | null {\n switch (ctx.platform) {\n case 'darwin': {\n return path.join(\n ctx.homedir,\n variant === 'insiders'\n ? 'Library/Application Support/Code - Insiders/User'\n : 'Library/Application Support/Code/User',\n )\n }\n case 'win32': {\n if (!ctx.env.APPDATA) return null\n return path.join(\n ctx.env.APPDATA,\n variant === 'insiders' ? 'Code - Insiders/User' : 'Code/User',\n )\n }\n default: {\n return path.join(\n ctx.homedir,\n variant === 'insiders' ? '.config/Code - Insiders/User' : '.config/Code/User',\n )\n }\n }\n}\n\nasync function detectCline(ctx: DetectionEnv): Promise<string | null> {\n // Shared by the Cline VS Code extension (4.1+) and Cline CLI. The extension's\n // older `globalStorage/saoudrizwan.claude-dev` file is no longer read.\n const clineHome = ctx.env.CLINE_DIR || path.join(ctx.homedir, '.cline')\n if (!ctx.existsSync(clineHome)) return null\n return path.join(clineHome, 'data/settings/cline_mcp_settings.json')\n}\n\nasync function detectCodexCli(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('codex', ['--version'])\n const codexHome = ctx.env.CODEX_HOME || path.join(ctx.homedir, '.codex')\n return path.join(codexHome, 'config.toml')\n } catch {\n return null\n }\n}\n\nasync function detectCursor(ctx: DetectionEnv): Promise<string | null> {\n const cursorDir = path.join(ctx.homedir, '.cursor')\n return ctx.existsSync(cursorDir) ? path.join(cursorDir, 'mcp.json') : null\n}\n\nasync function detectGeminiCli(ctx: DetectionEnv): Promise<string | null> {\n // Antigravity stores its config under ~/.gemini/antigravity, so checking\n // only the parent ~/.gemini directory causes false Gemini CLI detection.\n const settingsPath = path.join(ctx.homedir, '.gemini/settings.json')\n return ctx.existsSync(settingsPath) ? settingsPath : null\n}\n\nasync function detectGitHubCopilotCli(ctx: DetectionEnv): Promise<string | null> {\n const copilotDir =\n ctx.platform === 'linux' && ctx.env.XDG_CONFIG_HOME\n ? path.join(ctx.env.XDG_CONFIG_HOME, 'copilot')\n : path.join(ctx.homedir, '.copilot')\n return ctx.existsSync(copilotDir) ? path.join(copilotDir, 'mcp-config.json') : null\n}\n\nasync function detectOpenCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('opencode', ['--version'])\n return path.join(ctx.homedir, '.config/opencode/opencode.json')\n } catch {\n return null\n }\n}\n\nasync function detectPi(ctx: DetectionEnv): Promise<string | null> {\n try {\n const stdout = await ctx.execCommand('pi', ['--version'])\n const version = semverValid(stdout.trim())\n // Built-in MCP support was introduced in Pi v1\n if (!version || !semverGte(version, '1.0.0')) return null\n const piDir = ctx.env.PI_CODING_AGENT_DIR || path.join(ctx.homedir, '.pi/agent')\n return path.join(piDir, 'mcp.json')\n } catch {\n return null\n }\n}\n\nasync function detectVSCode(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx)\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectVSCodeInsiders(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx, 'insiders')\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectZed(ctx: DetectionEnv): Promise<string | null> {\n let configDir: string | null = null\n switch (ctx.platform) {\n case 'win32': {\n if (ctx.env.APPDATA) {\n configDir = path.join(ctx.env.APPDATA, 'Zed')\n }\n break\n }\n default: {\n configDir = path.join(ctx.homedir, '.config/zed')\n }\n }\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'settings.json') : null\n}\n\nasync function detectMCPorter(ctx: DetectionEnv): Promise<string | null> {\n const mcporterDir = path.join(ctx.homedir, '.mcporter')\n if (!ctx.existsSync(mcporterDir)) return null\n\n const jsonPath = path.join(mcporterDir, 'mcporter.json')\n const jsoncPath = path.join(mcporterDir, 'mcporter.jsonc')\n if (ctx.existsSync(jsonPath)) return jsonPath\n if (ctx.existsSync(jsoncPath)) return jsoncPath\n return jsonPath\n}\n\n// -- Legacy token detection --\n\n/**\n * Whether a Sanity server config holds a token in `headers` (or `http_headers`\n * for Codex CLI). Older CLI versions saved a login token there as\n * `Authorization: Bearer <token>`, and users may have added an API token the\n * same way. The two can't be told apart, so both are treated alike.\n */\nexport function hasLegacyToken(serverConfig: Record<string, unknown>): boolean {\n return [serverConfig.headers, serverConfig.http_headers].some(\n (headers) =>\n typeof headers === 'object' &&\n headers !== null &&\n typeof (headers as Record<string, unknown>).Authorization === 'string',\n )\n}\n\n// -- Defaults & build server config functions --\n\nexport const UNIVERSAL_SKILLS_DIR = '.agents/skills'\n/** Most editors share these values — entries only need to declare `detect` + any overrides. */\nconst EDITOR_DEFAULTS = {\n buildServerConfig: defaultHttpConfig,\n configKey: 'mcpServers',\n format: 'jsonc' as const,\n skillsDir: UNIVERSAL_SKILLS_DIR,\n}\n\nfunction buildAntigravityServerConfig(): Record<string, unknown> {\n return {serverUrl: MCP_SERVER_URL}\n}\n\nfunction buildClineServerConfig(): Record<string, unknown> {\n return {\n disabled: false,\n type: 'streamableHttp',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildGeminiCliServerConfig(): Record<string, unknown> {\n // Without `oauth.enabled`, Gemini CLI waits for the user to run `/mcp auth`\n return {\n oauth: {enabled: true},\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildGitHubCopilotCliServerConfig(): Record<string, unknown> {\n return {\n tools: ['*'],\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildMCPorterServerConfig(): Record<string, unknown> {\n return {\n auth: 'oauth',\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildOpenCodeServerConfig(): Record<string, unknown> {\n return {\n type: 'remote',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildZedServerConfig(): Record<string, unknown> {\n return {\n enabled: true,\n url: MCP_SERVER_URL,\n }\n}\n\n/**\n * Centralized editor configuration including detection logic.\n * To add a new editor: add an entry here — EditorName type is derived automatically.\n *\n * Each entry includes a doc URL pointing to the source of truth for its\n * config path and format. When updating a path, verify against the linked\n * documentation first.\n */\nexport const EDITOR_CONFIGS = {\n // Doc: https://antigravity.google/docs/mcp\n // Path: ~/.gemini/config/mcp_config.json Key: mcpServers\n Antigravity: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildAntigravityServerConfig,\n detect: detectAntigravity,\n skillsCliAgent: 'antigravity',\n },\n // Doc: https://docs.anthropic.com/en/docs/claude-code/mcp\n // Path: ~/.claude.json Key: mcpServers\n 'Claude Code': {\n ...EDITOR_DEFAULTS,\n detect: detectClaudeCode,\n skillsCliAgent: 'claude-code',\n skillsDir: '.claude/skills',\n },\n // Doc: https://github.com/cline/cline — VS Code extension and CLI share one file\n // Path: $CLINE_DIR || ~/.cline/data/settings/cline_mcp_settings.json\n Cline: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildClineServerConfig,\n detect: detectCline,\n skillsCliAgent: 'cline',\n },\n // Doc: https://platform.openai.com/docs/guides/tools-remote-mcp#codex-cli\n // Path: $CODEX_HOME || ~/.codex/config.toml Key: mcp_servers Format: TOML\n 'Codex CLI': {\n ...EDITOR_DEFAULTS,\n configKey: 'mcp_servers',\n detect: detectCodexCli,\n format: 'toml' as const,\n skillsCliAgent: 'codex',\n },\n // Doc: https://docs.cursor.com/context/model-context-protocol\n // Path: ~/.cursor/mcp.json Key: mcpServers\n Cursor: {\n ...EDITOR_DEFAULTS,\n detect: detectCursor,\n skillsCliAgent: 'cursor',\n },\n // Doc: https://googlegemini.wiki/gemini-cli/mcp-servers\n // Path: ~/.gemini/settings.json Key: mcpServers\n 'Gemini CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGeminiCliServerConfig,\n detect: detectGeminiCli,\n skillsCliAgent: 'gemini-cli',\n },\n // Doc: https://docs.github.com/en/copilot/customizing-copilot/extending-copilot-coding-agent-with-mcp\n // Path: ~/.copilot/mcp-config.json (or $XDG_CONFIG_HOME/copilot on Linux) Key: mcpServers\n 'GitHub Copilot CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGitHubCopilotCliServerConfig,\n detect: detectGitHubCopilotCli,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://github.com/nicobailon/mcporter\n // Path: ~/.mcporter/mcporter.{json,jsonc} Key: mcpServers\n MCPorter: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildMCPorterServerConfig,\n detect: detectMCPorter,\n },\n // Doc: https://opencode.ai/docs/config\n // Path: ~/.config/opencode/opencode.json Key: mcp\n OpenCode: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildOpenCodeServerConfig,\n configKey: 'mcp',\n detect: detectOpenCode,\n skillsCliAgent: 'opencode',\n },\n // Doc: https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/mcp.md\n // Path: $PI_CODING_AGENT_DIR || ~/.pi/agent/mcp.json Key: mcpServers\n Pi: {\n ...EDITOR_DEFAULTS,\n detect: detectPi,\n skillsCliAgent: 'pi',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code User dir>/mcp.json Key: servers\n // VS Code uses GitHub Copilot for AI features; skills are installed via the\n // `github-copilot` agent (see https://code.visualstudio.com/docs/copilot/customization/agent-skills).\n 'VS Code': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCode,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code Insiders User dir>/mcp.json Key: servers\n 'VS Code Insiders': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCodeInsiders,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://zed.dev/docs/assistant/model-context-protocol\n // Path: ~/.config/zed/settings.json (or $APPDATA/Zed on Windows) Key: context_servers\n // Zed doesn't support agent skills - https://github.com/zed-industries/zed/issues/49057\n Zed: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildZedServerConfig,\n configKey: 'context_servers',\n detect: detectZed,\n },\n} satisfies Record<string, EditorConfig>\n\n/** Derived from EDITOR_CONFIGS keys - add a new editor there and this updates automatically */\nexport type EditorName = keyof typeof EDITOR_CONFIGS\n\nexport function getSkillsCliAgent(editorName: EditorName): string | undefined {\n if (editorName in EDITOR_CONFIGS) {\n const config = EDITOR_CONFIGS[editorName]\n return 'skillsCliAgent' in config ? config.skillsCliAgent : undefined\n }\n}\n\n/**\n * Skills-CLI agent ID → display name. Mirrors `displayName` from\n * `~/git/skills/src/agents.ts` for the subset of agents we install for. Used\n * to match `skills list --json` output (which keys by display name) against\n * our editors.\n */\nconst SKILLS_CLI_AGENT_DISPLAY_NAMES: Record<string, string> = {\n antigravity: 'Antigravity',\n 'claude-code': 'Claude Code',\n cline: 'Cline',\n codex: 'Codex',\n cursor: 'Cursor',\n 'gemini-cli': 'Gemini CLI',\n 'github-copilot': 'GitHub Copilot',\n opencode: 'OpenCode',\n pi: 'Pi',\n}\n\nexport function isUniversalSkillsCliAgentByEditorName(editorName: EditorName): boolean {\n return EDITOR_CONFIGS[editorName]?.skillsDir === UNIVERSAL_SKILLS_DIR\n}\n\n/** Display name used by the skills CLI for the given editor, if it has a mapping. */\nexport function getSkillsCliAgentDisplayName(editorName: EditorName): string | undefined {\n const agent = getSkillsCliAgent(editorName)\n return agent ? SKILLS_CLI_AGENT_DISPLAY_NAMES[agent] : undefined\n}\n\n/** Display name for a skills-CLI agent ID (e.g. `'cursor'` → `'Cursor'`). */\nexport function getSkillsCliAgentDisplayNameById(agentId: string): string | undefined {\n return SKILLS_CLI_AGENT_DISPLAY_NAMES[agentId]\n}\n\n/**\n * The relative, home-anchored directory the `skills` CLI installs into for a\n * given agent ID (e.g. `'cursor'` → `'.agents/skills'`, `'claude-code'` →\n * `'.claude/skills'`). Derived from `EDITOR_CONFIGS` so it stays a single\n * source of truth.\n */\nexport function getSkillsCliAgentSkillsDir(agentName: string): string | undefined {\n for (const name of Object.keys(EDITOR_CONFIGS) as EditorName[]) {\n const config = EDITOR_CONFIGS[name]\n const agent = getSkillsCliAgent(name)\n if (agent === agentName) {\n return config.skillsDir\n }\n }\n return undefined\n}\n"],"names":["existsSync","os","path","execa","gte","semverGte","valid","semverValid","MCP_SERVER_URL","createDetectionEnv","env","process","execCommand","cmd","args","stdio","timeout","then","res","stdout","homedir","platform","defaultHttpConfig","type","url","detectClaudeCode","ctx","join","detectAntigravity","configDir","getVSCodeUserDir","variant","APPDATA","detectCline","clineHome","CLINE_DIR","detectCodexCli","codexHome","CODEX_HOME","detectCursor","cursorDir","detectGeminiCli","settingsPath","detectGitHubCopilotCli","copilotDir","XDG_CONFIG_HOME","detectOpenCode","detectPi","version","trim","piDir","PI_CODING_AGENT_DIR","detectVSCode","detectVSCodeInsiders","detectZed","detectMCPorter","mcporterDir","jsonPath","jsoncPath","hasLegacyToken","serverConfig","headers","http_headers","some","Authorization","UNIVERSAL_SKILLS_DIR","EDITOR_DEFAULTS","buildServerConfig","configKey","format","skillsDir","buildAntigravityServerConfig","serverUrl","buildClineServerConfig","disabled","buildGeminiCliServerConfig","oauth","enabled","buildGitHubCopilotCliServerConfig","tools","buildMCPorterServerConfig","auth","buildOpenCodeServerConfig","buildZedServerConfig","EDITOR_CONFIGS","Antigravity","detect","skillsCliAgent","Cline","Cursor","MCPorter","OpenCode","Pi","Zed","getSkillsCliAgent","editorName","config","undefined","SKILLS_CLI_AGENT_DISPLAY_NAMES","antigravity","cline","codex","cursor","opencode","pi","isUniversalSkillsCliAgentByEditorName","getSkillsCliAgentDisplayName","agent","getSkillsCliAgentDisplayNameById","agentId","getSkillsCliAgentSkillsDir","agentName","name","Object","keys"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAAQC,KAAK,QAAO,QAAO;AAC3B,SAAQC,OAAOC,SAAS,EAAEC,SAASC,WAAW,QAAO,SAAQ;AAE7D,SAAQC,cAAc,QAAO,wBAAuB;AAiBpD,wEAAwE,GACxE,OAAO,SAASC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,SAAS;QACzB;IACF;IACA,OAAO2B;AACT"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -41,7 +41,7 @@ export class DevCommand extends SanityCommand {
|
|
|
41
41
|
const cliConfig = await this.getCliConfig();
|
|
42
42
|
const isApp = determineIsApp(cliConfig);
|
|
43
43
|
if (shouldWarnDashboardFlagIgnored(cliConfig, flags['load-in-dashboard'])) {
|
|
44
|
-
this.output.warn('
|
|
44
|
+
this.output.warn('Apps using `defineApplication` always run in the local Dashboard. Remove the --load-in-dashboard flag from your command.');
|
|
45
45
|
}
|
|
46
46
|
// load-in-dashboard is defaulted to true for apps.
|
|
47
47
|
if (isApp && flags['load-in-dashboard'] === undefined) {
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/dev.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {type CliConfig, exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {devAction} from '../actions/dev/devAction.js'\nimport {devDebug} from '../actions/dev/devDebug.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\n/**\n * Workbench apps never load in the Sanity dashboard, so `--load-in-dashboard`\n * has no effect for them. The flag is defaulted later in `run`, so an\n * `undefined` value here still means the user never passed it.\n */\nexport function shouldWarnDashboardFlagIgnored(\n cliConfig: CliConfig | undefined,\n loadInDashboard: boolean | undefined,\n): boolean {\n return isWorkbenchApp(cliConfig?.app) && loadInDashboard !== undefined\n}\n\nexport class DevCommand extends SanityCommand<typeof DevCommand> {\n static override description = 'Start a local development server with live reloading'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %> --host=0.0.0.0',\n '<%= config.bin %> <%= command.id %> --port=1942',\n '<%= config.bin %> <%= command.id %> --load-in-dashboard',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Automatically update Sanity Studio dependencies',\n }),\n host: Flags.string({\n description: 'Local network interface to listen on (default: localhost)',\n }),\n 'load-in-dashboard': Flags.boolean({\n allowNo: true,\n description: 'Load the app/studio in the Sanity dashboard',\n }),\n port: Flags.string({\n description: 'TCP port to start server on (default: 3333)',\n }),\n }\n\n public async run(): Promise<{close?: () => Promise<void>}> {\n const {flags} = await this.parse(DevCommand)\n\n const workDir = (await this.getProjectRoot()).directory\n const cliConfig = await this.getCliConfig()\n const isApp = determineIsApp(cliConfig)\n\n if (shouldWarnDashboardFlagIgnored(cliConfig, flags['load-in-dashboard'])) {\n this.output.warn('
|
|
1
|
+
{"version":3,"sources":["../../src/commands/dev.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {type CliConfig, exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {devAction} from '../actions/dev/devAction.js'\nimport {devDebug} from '../actions/dev/devDebug.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\n/**\n * Workbench apps never load in the Sanity dashboard, so `--load-in-dashboard`\n * has no effect for them. The flag is defaulted later in `run`, so an\n * `undefined` value here still means the user never passed it.\n */\nexport function shouldWarnDashboardFlagIgnored(\n cliConfig: CliConfig | undefined,\n loadInDashboard: boolean | undefined,\n): boolean {\n return isWorkbenchApp(cliConfig?.app) && loadInDashboard !== undefined\n}\n\nexport class DevCommand extends SanityCommand<typeof DevCommand> {\n static override description = 'Start a local development server with live reloading'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %> --host=0.0.0.0',\n '<%= config.bin %> <%= command.id %> --port=1942',\n '<%= config.bin %> <%= command.id %> --load-in-dashboard',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Automatically update Sanity Studio dependencies',\n }),\n host: Flags.string({\n description: 'Local network interface to listen on (default: localhost)',\n }),\n 'load-in-dashboard': Flags.boolean({\n allowNo: true,\n description: 'Load the app/studio in the Sanity dashboard',\n }),\n port: Flags.string({\n description: 'TCP port to start server on (default: 3333)',\n }),\n }\n\n public async run(): Promise<{close?: () => Promise<void>}> {\n const {flags} = await this.parse(DevCommand)\n\n const workDir = (await this.getProjectRoot()).directory\n const cliConfig = await this.getCliConfig()\n const isApp = determineIsApp(cliConfig)\n\n if (shouldWarnDashboardFlagIgnored(cliConfig, flags['load-in-dashboard'])) {\n this.output.warn(\n 'Apps using `defineApplication` always run in the local Dashboard. Remove the --load-in-dashboard flag from your command.',\n )\n }\n\n // load-in-dashboard is defaulted to true for apps.\n if (isApp && flags['load-in-dashboard'] === undefined) {\n flags['load-in-dashboard'] = true\n } else if (flags['load-in-dashboard'] === undefined) {\n // For non-apps, load-in-dashboard is defaulted to false.\n flags['load-in-dashboard'] = false\n }\n\n try {\n const result = await devAction({\n cliConfig,\n flags,\n isApp,\n output: this.output,\n workDir,\n })\n return result\n } catch (error) {\n devDebug(`Failed to start dev server`, error)\n this.output.error(\n styleText(['red', 'bgBlack'], `Failed to start dev server: ${error.message}`),\n {\n exit: exitCodes.RUNTIME_ERROR,\n },\n )\n }\n }\n}\n"],"names":["styleText","Flags","exitCodes","SanityCommand","isWorkbenchApp","devAction","devDebug","determineIsApp","shouldWarnDashboardFlagIgnored","cliConfig","loadInDashboard","app","undefined","DevCommand","description","examples","flags","boolean","allowNo","host","string","port","run","parse","workDir","getProjectRoot","directory","getCliConfig","isApp","output","warn","result","error","message","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAwBC,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzE,SAAQC,cAAc,QAAO,wBAAuB;AAEpD,SAAQC,SAAS,QAAO,8BAA6B;AACrD,SAAQC,QAAQ,QAAO,6BAA4B;AACnD,SAAQC,cAAc,QAAO,4BAA2B;AAExD;;;;CAIC,GACD,OAAO,SAASC,+BACdC,SAAgC,EAChCC,eAAoC;IAEpC,OAAON,eAAeK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AE,CAAC,4BAA4B,EAAEgC,MAAMC,OAAO,EAAE,GAC5E;gBACEC,MAAMhC,UAAUiC,aAAa;YAC/B;QAEJ;IACF;AACF"}
|
|
@@ -3,7 +3,7 @@ import { getErrorMessage, toError } from '@sanity/cli-core/errors';
|
|
|
3
3
|
import { setupMCP } from '../../actions/mcp/setupMCP.js';
|
|
4
4
|
import { MCPConfigureTrace } from '../../telemetry/mcp.telemetry.js';
|
|
5
5
|
export class ConfigureMcpCommand extends SanityCommand {
|
|
6
|
-
static description = 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)';
|
|
6
|
+
static description = 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, Pi, VS Code, VS Code Insiders, Zed)';
|
|
7
7
|
static examples = [
|
|
8
8
|
{
|
|
9
9
|
command: '<%= config.bin %> <%= command.id %>',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {getErrorMessage, toError} from '@sanity/cli-core/errors'\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 (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)'\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 const mcpResult = await setupMCP({\n explicit: true,\n mode: this.resolveIsInteractive() ? 'prompt' : 'auto',\n output: this.output,\n skillsMode: 'skip',\n })\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: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["exitCodes","SanityCommand","getErrorMessage","toError","setupMCP","MCPConfigureTrace","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","mcpResult","explicit","mode","resolveIsInteractive","output","skillsMode","log","configuredEditors","detectedEditors","error","complete","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,eAAe,EAAEC,OAAO,QAAO,0BAAyB;AAEhE,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,iBAAiB,QAAO,mCAAkC;AAElE,OAAO,MAAMC,4BAA4BL;IACvC,OAAgBM,cACd,
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {getErrorMessage, toError} from '@sanity/cli-core/errors'\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 (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, Pi, VS Code, VS Code Insiders, Zed)'\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 const mcpResult = await setupMCP({\n explicit: true,\n mode: this.resolveIsInteractive() ? 'prompt' : 'auto',\n output: this.output,\n skillsMode: 'skip',\n })\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: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["exitCodes","SanityCommand","getErrorMessage","toError","setupMCP","MCPConfigureTrace","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","mcpResult","explicit","mode","resolveIsInteractive","output","skillsMode","log","configuredEditors","detectedEditors","error","complete","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,eAAe,EAAEC,OAAO,QAAO,0BAAyB;AAEhE,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,iBAAiB,QAAO,mCAAkC;AAElE,OAAO,MAAMC,4BAA4BL;IACvC,OAAgBM,cACd,0LAAyL;IAC3L,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;QAEX,IAAI;YACF,MAAMC,YAAY,MAAMV,SAAS;gBAC/BW,UAAU;gBACVC,MAAM,IAAI,CAACC,oBAAoB,KAAK,WAAW;gBAC/CC,QAAQ,IAAI,CAACA,MAAM;gBACnBC,YAAY;YACd;YAEAR,MAAMS,GAAG,CAAC;gBACRC,mBAAmBP,UAAUO,iBAAiB;gBAC9CC,iBAAiBR,UAAUQ,eAAe;YAC5C;YAEA,IAAIR,UAAUS,KAAK,EAAE;gBACnBZ,MAAMY,KAAK,CAACT,UAAUS,KAAK;YAC7B,OAAO;gBACLZ,MAAMa,QAAQ;YAChB;QACF,EAAE,OAAOD,OAAO;YACdZ,MAAMY,KAAK,CAACpB,QAAQoB;YACpB,IAAI,CAACA,KAAK,CAACrB,gBAAgBqB,QAAQ;gBAACE,MAAMzB,UAAU0B,aAAa;YAAA;QACnE;IACF;AACF"}
|
|
@@ -2,6 +2,8 @@ import { Args, Flags } from '@oclif/core';
|
|
|
2
2
|
import { CLIError } from '@oclif/core/errors';
|
|
3
3
|
import { exitCodes } from '@sanity/cli-core';
|
|
4
4
|
import { subdebug } from '@sanity/cli-core/debug';
|
|
5
|
+
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
6
|
+
import { readImageFile } from '@sanity/cli-core/images';
|
|
5
7
|
import { SanityCommand } from '@sanity/cli-core/SanityCommand';
|
|
6
8
|
import { confirm, spinner } from '@sanity/cli-core/ux';
|
|
7
9
|
import { createDataset } from '../../actions/dataset/create.js';
|
|
@@ -13,8 +15,9 @@ import { promptForDefaultConfig } from '../../prompts/promptForDefaultConfig.js'
|
|
|
13
15
|
import { promptForProjectName } from '../../prompts/promptForProjectName.js';
|
|
14
16
|
import { listDatasets } from '../../services/datasets.js';
|
|
15
17
|
import { getProjectFeatures } from '../../services/getProjectFeatures.js';
|
|
16
|
-
import { createProject } from '../../services/projects.js';
|
|
18
|
+
import { createProject, setProjectLogo } from '../../services/projects.js';
|
|
17
19
|
import { getCliUser } from '../../services/user.js';
|
|
20
|
+
import { defineCommandTelemetry } from '../../util/telemetry/commandTelemetry.js';
|
|
18
21
|
const debug = subdebug('projects:create');
|
|
19
22
|
export class CreateProjectCommand extends SanityCommand {
|
|
20
23
|
static args = {
|
|
@@ -42,6 +45,10 @@ export class CreateProjectCommand extends SanityCommand {
|
|
|
42
45
|
command: '<%= config.bin %> <%= command.id %> "My Project" --dataset=staging --dataset-visibility=private',
|
|
43
46
|
description: 'Create a project with a private dataset named "staging"'
|
|
44
47
|
},
|
|
48
|
+
{
|
|
49
|
+
command: '<%= config.bin %> <%= command.id %> "My Project" --logo ./logo.png',
|
|
50
|
+
description: 'Create a project with a logo'
|
|
51
|
+
},
|
|
45
52
|
{
|
|
46
53
|
command: '<%= config.bin %> <%= command.id %> "CI Project" --yes --json',
|
|
47
54
|
description: 'Create a project non-interactively with JSON output'
|
|
@@ -67,6 +74,10 @@ export class CreateProjectCommand extends SanityCommand {
|
|
|
67
74
|
'public'
|
|
68
75
|
]
|
|
69
76
|
}),
|
|
77
|
+
logo: Flags.string({
|
|
78
|
+
description: 'Image file to use as the logo: PNG, JPEG, GIF, WebP, SVG, BMP, TIFF, HEIF or AVIF, at most 5 MB',
|
|
79
|
+
helpValue: '<path>'
|
|
80
|
+
}),
|
|
70
81
|
organization: Flags.string({
|
|
71
82
|
description: 'Organization to create the project in',
|
|
72
83
|
helpValue: '<slug|id>'
|
|
@@ -80,10 +91,30 @@ export class CreateProjectCommand extends SanityCommand {
|
|
|
80
91
|
static hiddenAliases = [
|
|
81
92
|
'project:create'
|
|
82
93
|
];
|
|
94
|
+
static telemetry = defineCommandTelemetry(this.flags, {
|
|
95
|
+
redact: [
|
|
96
|
+
'logo'
|
|
97
|
+
]
|
|
98
|
+
});
|
|
83
99
|
async run() {
|
|
84
100
|
const { args, flags } = await this.parse(CreateProjectCommand);
|
|
85
101
|
const { projectName } = args;
|
|
86
|
-
const { dataset, 'dataset-visibility': datasetVisibility, organization, yes } = flags;
|
|
102
|
+
const { dataset, 'dataset-visibility': datasetVisibility, logo: logoPath, organization, yes } = flags;
|
|
103
|
+
// Read the logo before creating anything, so a bad file doesn't leave a project without it.
|
|
104
|
+
let logo;
|
|
105
|
+
if (logoPath === '') {
|
|
106
|
+
return this.output.error('--logo needs the path to an image file. To create the project without a logo, leave out --logo.', {
|
|
107
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
108
|
+
});
|
|
109
|
+
} else if (logoPath !== undefined) {
|
|
110
|
+
try {
|
|
111
|
+
logo = await readImageFile(logoPath);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
return this.output.error(getErrorMessage(error), {
|
|
114
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
87
118
|
const user = await getCliUser();
|
|
88
119
|
const finalProjectName = projectName || (yes || this.isUnattended() ? 'My Sanity Project' : await promptForProjectName());
|
|
89
120
|
debug('Creating project with options: %O', {
|
|
@@ -125,12 +156,24 @@ export class CreateProjectCommand extends SanityCommand {
|
|
|
125
156
|
exit: exitCodes.RUNTIME_ERROR
|
|
126
157
|
});
|
|
127
158
|
}
|
|
159
|
+
let logoUrl;
|
|
160
|
+
if (logo) {
|
|
161
|
+
const logoSpin = spinner('Setting logo').start();
|
|
162
|
+
try {
|
|
163
|
+
logoUrl = (await setProjectLogo(newProject.projectId, logo)).logoUrl;
|
|
164
|
+
logoSpin.succeed();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
logoSpin.fail();
|
|
167
|
+
debug(`Error setting project logo: ${error}`);
|
|
168
|
+
this.output.logDiagnostic(`Warning: Project created but its logo wasn't set: ${getErrorMessage(error)}\nTo set it, go to ${getManageUrl(newProject.projectId)}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
128
171
|
let newDataset;
|
|
129
172
|
// If dataset name specified, or in attended mode (to prompt for dataset name), create a dataset.
|
|
130
173
|
if (dataset || !this.isUnattended()) {
|
|
131
174
|
newDataset = await this.handleDatasetCreation(newProject.projectId, dataset, datasetVisibility);
|
|
132
175
|
}
|
|
133
|
-
this.printProjectCreationSuccess(chosenOrganization, newProject, newDataset);
|
|
176
|
+
this.printProjectCreationSuccess(chosenOrganization, newProject, newDataset, logoUrl);
|
|
134
177
|
}
|
|
135
178
|
async handleDatasetCreation(projectId, datasetFromFlag, datasetVisibility) {
|
|
136
179
|
try {
|
|
@@ -168,9 +211,12 @@ export class CreateProjectCommand extends SanityCommand {
|
|
|
168
211
|
return;
|
|
169
212
|
}
|
|
170
213
|
}
|
|
171
|
-
async printProjectCreationSuccess(organization, project, dataset) {
|
|
214
|
+
async printProjectCreationSuccess(organization, project, dataset, logoUrl) {
|
|
172
215
|
if (this.flags.json) {
|
|
173
|
-
this.logJson(
|
|
216
|
+
this.logJson(logoUrl ? {
|
|
217
|
+
...project,
|
|
218
|
+
logoUrl
|
|
219
|
+
} : project);
|
|
174
220
|
return;
|
|
175
221
|
}
|
|
176
222
|
this.output.log(`Project created successfully!`);
|
|
@@ -180,6 +226,9 @@ export class CreateProjectCommand extends SanityCommand {
|
|
|
180
226
|
if (dataset) {
|
|
181
227
|
this.output.log(`Dataset: ${dataset.datasetName} (${dataset.aclMode})`);
|
|
182
228
|
}
|
|
229
|
+
if (logoUrl) {
|
|
230
|
+
this.output.log(`Logo: ${logoUrl}`);
|
|
231
|
+
}
|
|
183
232
|
this.output.log(``);
|
|
184
233
|
this.output.log(`Manage your project: ${getManageUrl(project.projectId)}`);
|
|
185
234
|
}
|