@sanity/cli 8.32.1 → 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/deploy/deployApp.js +3 -3
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +2 -3
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/dev/devAction.js +2 -1
- package/dist/actions/dev/devAction.js.map +1 -1
- package/dist/actions/init/bootstrapLocalTemplate.js +18 -0
- package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -1
- 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/actions/preview/previewAction.js +2 -1
- package/dist/actions/preview/previewAction.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/organizations/create.js +2 -2
- package/dist/commands/organizations/create.js.map +1 -1
- package/dist/commands/organizations/update.js +2 -2
- package/dist/commands/organizations/update.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/generated/apiRoutes.js +2 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/services/organizations.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 +3173 -3151
- package/package.json +13 -11
- package/templates/app-quickstart/AGENTS.md +11 -0
- package/templates/app-sanity-ui/AGENTS.md +11 -0
- package/templates/shared/AGENTS.md +14 -0
- package/templates/shared/dashboard/app-quickstart/AGENTS.md +11 -0
- package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +11 -0
- package/dist/actions/organizations/readOrganizationLogo.js +0 -49
- package/dist/actions/organizations/readOrganizationLogo.js.map +0 -1
|
@@ -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,wBAAw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AM,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"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { basename, dirname } from 'node:path';
|
|
2
2
|
import { styleText } from 'node:util';
|
|
3
3
|
import { createGzip } from 'node:zlib';
|
|
4
|
-
import { extractCoreAppManifest,
|
|
4
|
+
import { extractCoreAppManifest, resolveTitleUpdate } from '@sanity/cli-build/_internal/manifest';
|
|
5
5
|
import { exitCodes } from '@sanity/cli-core';
|
|
6
6
|
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
7
7
|
import { getCoreAppUrl } from '@sanity/cli-core/util';
|
|
8
8
|
import { confirm, spinner } from '@sanity/cli-core/ux';
|
|
9
9
|
import { resolveAppEntry } from '@sanity/workbench-cli/build';
|
|
10
|
-
import { createCoreApp, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
10
|
+
import { createCoreApp, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
11
11
|
import { c as createTar } from 'tar';
|
|
12
12
|
import { createDeployment, updateUserApplication } from '../../services/userApplications.js';
|
|
13
13
|
import { getAppId } from '../../util/appId.js';
|
|
@@ -145,7 +145,7 @@ export function deployApp(options) {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
// Read up front so a bad icon path fails before we create or build.
|
|
148
|
-
const appIcon = !dryRun && workbench?.icon ? await
|
|
148
|
+
const appIcon = !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined;
|
|
149
149
|
const startedAt = Date.now();
|
|
150
150
|
const summaryDetails = workbench && organizationId && !flags.json ? fetchDeploySummaryDetails(organizationId) : undefined;
|
|
151
151
|
// Create the app before the build so the bundle carries its real id. A
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {\n type CoreAppManifest,\n extractCoreAppManifest,\n readIconFromPath,\n resolveTitleUpdate,\n} from '@sanity/cli-build/_internal/manifest'\nimport {type AppVisibility, exitCodes} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {getCoreAppUrl} from '@sanity/cli-core/util'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {resolveAppEntry} from '@sanity/workbench-cli/build'\nimport {\n createCoreApp,\n deployConfig,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n resolveInstallationId,\n resolveWorkbenchConfig,\n selectWorkbenchAppId,\n summarizeConfig,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {c as createTar} from 'tar'\n\nimport {\n createDeployment,\n updateUserApplication,\n type UserApplication,\n type UserApplicationResolved,\n} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {runStep} from '../../util/checks.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED, NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {pluralize} from '../../util/pluralize.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {\n applyAspectSync,\n type AspectSyncPlan,\n planAspectSync,\n} from '../media/aspectSync/syncAspects.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createUserApplication} from './createUserApplication.js'\nimport {\n checkAppId,\n checkAppTarget,\n checkAutoUpdates,\n checkBuild,\n checkPackageVersion,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {findUserApplication} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst APP_PACKAGE = '@sanity/sdk-react'\n\nexport function deployApp(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runAppDeployment,\n type: 'coreApp',\n })\n}\n\n/** Validates the deploy, syncs the title from the manifest, and ships the build. */\nasync function runAppDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const workbench = getWorkbench(cliConfig)\n // A config (the Media Library) is not an app — it resolves through its own\n // brand and persists to the org's installation instead of hosting an application.\n const config = resolveWorkbenchConfig(cliConfig)\n const dryRun = !!flags['dry-run']\n\n const deployConfigOnly = !!config\n const deployApplication = !config && (!workbench || workbench.hasInterfaces)\n const hasAppView = resolveAppEntry(cliConfig.app) !== undefined\n\n const appTitle = workbench\n ? flags.title?.trim() || cliConfig.app?.title?.trim() || workbench.slug\n : ''\n\n // A federated app with no entry, view or service would ship a remote with\n // nothing to load — reported first so it fails before any prompt or API call.\n if (workbench) {\n try {\n workbench.assertDeployable()\n } catch (err) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: getErrorMessage(err),\n solution: 'Declare at least one entry, view, or service in the app',\n status: 'fail',\n })\n }\n }\n\n // A config with no fields would overwrite the org's live config with an empty\n // snapshot, so block it here — same \"nothing to deploy\" gate an app gets.\n if (config && config.fields.length === 0) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'Nothing to deploy: the media library config declares no fields.',\n solution: 'Add at least one field to the media library config',\n status: 'fail',\n })\n }\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n // An application ships the SDK runtime; a media-library config stamps its\n // `sanity` version instead.\n let version: string | null = null\n if (deployApplication) {\n version = await checkPackageVersion(reporter, {moduleName: APP_PACKAGE, workDir})\n } else if (deployConfigOnly) {\n version = await checkPackageVersion(reporter, {moduleName: 'sanity', workDir})\n }\n\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n checkAppId(reporter, {cliConfig})\n\n await checkBlueprintManaged(reporter, {kind: 'coreApp', projectRootDir: workDir})\n\n let application: UserApplicationResolved | null = null\n let appCreated = false\n let workbenchApp: object | undefined\n let targetAppId = appId\n if (flags.external) {\n reporter.report({\n message: EXTERNAL_APP_NOT_SUPPORTED,\n solution: 'Remove the --external flag — apps deploy to Sanity hosting',\n status: 'fail',\n })\n } else if (deployApplication && workbench) {\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'coreApp'})\n workbenchApp = (\n await checkAppTarget(reporter, {\n appId: targetAppId,\n hasAppView,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n } else if (deployApplication) {\n ;({application, created: appCreated} = await resolveAppApplication(options, {dryRun, reporter}))\n }\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (deployApplication && workbench && !appId && !flags.external && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readIconFromPath(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n const summaryDetails =\n workbench && organizationId && !flags.json\n ? fetchDeploySummaryDetails(organizationId)\n : undefined\n\n // Create the app before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && deployApplication && workbench && organizationId && !applicationId) {\n const created = await createCoreApp({\n isSingleton: workbench.isSingleton,\n name: workbench.name,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildApp({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: flags.build\n ? undefined\n : 'Build skipped (--no-build) — validating existing output directory',\n successMessage: 'App built',\n })\n\n // A federated build has already read its manifest; anything else verifies the directory.\n const mfManifest =\n built?.mfManifest ??\n (await verifyOutputDir({\n isWorkbenchApp: workbench !== null || config !== null,\n reporter,\n sourceDir,\n }))\n\n // Workbench apps and configs ship a federation remote and don't read the\n // core-app manifest; only plain core-apps do. Manifests aren't strictly\n // essential, so a failure warns and continues.\n let manifest: CoreAppManifest | undefined\n if (!workbench && !config) {\n try {\n manifest = await extractCoreAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n reporter.report({\n message: `Error extracting app manifest: ${getErrorMessage(err)}`,\n status: 'warn',\n })\n }\n }\n\n // Resolve the installation in both modes so the report — dry-run and real —\n // shows whether the config is deployable; a missing one fails the deploy here.\n let installationId: string | undefined\n let configSummary: string | undefined\n const configAppType = config?.appType\n if (deployConfigOnly && organizationId && config && configAppType) {\n installationId = await resolveInstallationId({appType: configAppType, organizationId})\n configSummary = summarizeConfig(config)\n reporter.report(\n installationId\n ? {message: configSummary, status: 'pass'}\n : {\n exitCode: exitCodes.USAGE_ERROR,\n message: `No active \"${configAppType}\" installation for organization \"${organizationId}\"`,\n solution:\n 'Install the Media Library for the organization before deploying its config',\n status: 'fail',\n },\n )\n }\n\n // Plan the aspect-document sync in both modes, so the report — dry-run and\n // real — shows what the sync will write and, prominently, what it will\n // delete, before anything mutates. Gated on a resolved installation: when\n // that check failed, a real run already exited and a dry run has reported\n // the config as undeployable.\n let aspectSyncPlan: AspectSyncPlan | undefined\n // Gated on the `appType` discriminator, not the mere presence of a config:\n // `ConfigSchema` is a union built to grow, and a future config type must\n // not inherit the media-library aspect sync — and its deletions — by\n // default.\n if (configAppType === 'media-library' && organizationId && config && installationId) {\n // runStep so an unexpected throw (network, API) becomes a fail check:\n // a real run exits, a dry run records it and keeps reporting.\n const planned = await runStep(reporter, {\n debug: deployDebug,\n formatError: (err) => `Planning the aspect-document sync failed: ${getErrorMessage(err)}`,\n name: 'aspect sync plan',\n work: () =>\n planAspectSync({\n fields: config.fields,\n mediaLibraryId: flags['media-library-id'],\n organizationId,\n workDir,\n }),\n })\n if (planned && 'failure' in planned) {\n reporter.report({\n exitCode: planned.failure.exitCode,\n message: planned.failure.message,\n solution: planned.failure.solution,\n status: 'fail',\n })\n } else if (planned) {\n aspectSyncPlan = planned.plan\n reportAspectSyncPlan(reporter, aspectSyncPlan)\n }\n }\n\n const interfaces = deployApplication && workbench ? reportInterfaces(reporter, workbench) : null\n\n // Applied after the app is live (see below) so a failed deploy never leaves\n // the org's installation config without its application.\n const deployApplicationConfig = async (): Promise<void> => {\n if (installationId && version && configAppType && organizationId) {\n await deployConfig({\n appType: configAppType,\n installationId,\n organizationId,\n output,\n sourceDir,\n version,\n })\n }\n }\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n type: 'coreApp',\n version,\n ...toWorkbenchPayload(workbench, {config: configSummary, interfaces, title: appTitle}),\n ...(configSummary ? {config: configSummary} : {}),\n ...(aspectSyncPlan\n ? {\n aspectSync: {\n deleteIds: aspectSyncPlan.staleIds,\n mediaLibraryId: aspectSyncPlan.mediaLibraryId,\n upsertIds: aspectSyncPlan.documents.map((document) => document._id),\n },\n }\n : {}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // Deleting stored definitions is the destructive part of a config deploy,\n // so an interactive run confirms it before anything mutates. Unattended\n // runs (--yes; forced in CI) proceed — the config is the source of truth\n // and the dry-run report lists the deletions.\n if (aspectSyncPlan && aspectSyncPlan.staleIds.length > 0 && !flags.yes) {\n const staleCount = aspectSyncPlan.staleIds.length\n const proceed = await confirm({\n default: false,\n message:\n `Delete ${staleCount} stored aspect ${pluralize('definition', staleCount)} with no ` +\n `matching config field (${aspectSyncPlan.staleIds.join(', ')})?`,\n })\n if (!proceed) {\n output.error('Deploy cancelled — the stored aspect definitions are unchanged.', {\n exit: exitCodes.USER_ABORT,\n })\n }\n }\n\n // A config-only singleton ships no application, only its config.\n if (!deployApplication) {\n await deployApplicationConfig()\n if (aspectSyncPlan) {\n await runAspectSync(aspectSyncPlan, output)\n }\n if (installationId && version) {\n return {application: null, installationId, payload}\n }\n return\n }\n\n // A real deploy already exited on a version-resolution failure; this narrows the type.\n if (!version) return\n\n // The app was created (or resolved from `deployment.appId`) before the build,\n // so this only ships the deployment; plain coreApps use user-applications below.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: true,\n isAutoUpdating,\n mfManifest,\n // Once the deployment is live, a metadata-sync or later config failure\n // must not delete the app.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n })\n await deployApplicationConfig()\n const url = hasAppView\n ? getApplicationUrl({\n id: applicationId,\n organizationId,\n slug: workbench.slug,\n type: 'coreApp',\n })\n : getWorkbenchUrl(organizationId)\n const durationMs = Date.now() - startedAt\n output.log(\n formatDeploySummary({\n ...(await summaryDetails),\n applicationId,\n created: applicationCreated,\n durationMs,\n isApp: true,\n organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n url,\n }),\n )\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n payload,\n url,\n }\n }\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved application means the deploy target was never resolved.\n if (!application) return\n\n application = await syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility: cliConfig.app?.visibility,\n })\n await shipAppDeployment({application, isAutoUpdating, manifest, sourceDir, version})\n logAppDeployed({\n applicationId: application.id,\n cliConfig,\n created: appCreated,\n createRequested: flags.create,\n organizationId: application.organizationId,\n output,\n title: application.title,\n })\n return {\n action: appCreated ? 'create' : 'update',\n application,\n payload,\n url: getCoreAppUrl(application.organizationId, application.id),\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Reports the planned aspect-document sync: the upserts as a pass, stripped\n * non-serializable values as information, and — prominently, as a warning —\n * the stored definitions the sync will delete because no config field matches\n * them. Deploy is a mirror: the config owns the library's aspect namespace.\n */\nexport function reportAspectSyncPlan(reporter: DeployCheckReporter, plan: AspectSyncPlan): void {\n const upserts = plan.documents.length\n reporter.report({\n message: `Will sync ${upserts} aspect ${pluralize('definition', upserts)} to media library ${plan.mediaLibraryId}`,\n status: 'pass',\n })\n\n const strippedFields = Object.entries(plan.strippedByField)\n if (strippedFields.length > 0) {\n // Expected for fields with custom inputs, validation callbacks, or\n // initial-value resolvers: the live config keeps those capabilities, only\n // the stored mirror (read by Studio plugin mode and the dashboard) omits\n // them. Reported so the capability gap is explicit, but not a warning.\n const details = strippedFields\n .map(([name, paths]) => `${name} (${paths.join(', ')})`)\n .join('; ')\n reporter.report({\n message: `Stored definitions omit non-serializable values: ${details}`,\n status: 'pass',\n })\n }\n\n if (plan.staleIds.length > 0) {\n reporter.report({\n message: `Will delete ${plan.staleIds.length} stored aspect ${pluralize('definition', plan.staleIds.length)} with no matching config field: ${plan.staleIds.join(', ')}`,\n solution:\n 'Definitions only — aspects.<name> values on assets stay put and resurface if a matching ' +\n 'field is added back. To keep a definition, declare a matching field in sanity.cli.ts ' +\n '(generate one with `sanity media pull-aspects`)',\n status: 'warn',\n })\n }\n}\n\n/**\n * Applies the planned sync after the config itself deployed. A failure here\n * leaves the config live but the stored mirror stale, so the error says so\n * and points at the retry (deploys are idempotent).\n */\nasync function runAspectSync(\n plan: AspectSyncPlan,\n output: DeployAppOptions['output'],\n): Promise<void> {\n try {\n await applyAspectSync(plan)\n } catch (err) {\n throw new Error(\n `The config deployed, but syncing its aspect documents to media library ${plan.mediaLibraryId} failed: ${getErrorMessage(err)}\\nRun \\`sanity deploy\\` again to retry the sync.`,\n {cause: err},\n )\n }\n const deleted =\n plan.staleIds.length > 0\n ? ` (deleted ${plan.staleIds.length} stale ${pluralize('definition', plan.staleIds.length)})`\n : ''\n output.log(\n `Synced ${plan.documents.length} aspect ${pluralize('definition', plan.documents.length)} to media library ${plan.mediaLibraryId}${deleted}`,\n )\n}\n\n/**\n * Finds the application a real deploy targets, creating one when none is\n * configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveAppApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplicationResolved | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const organizationId = cliConfig.app?.organizationId ?? ''\n // Create name from --title or `app.title` config; blank falls back to the prompt\n const title = flags.title?.trim() || cliConfig.app?.title?.trim() || undefined\n\n if (dryRun) {\n await checkAppTarget(reporter, {\n appId: getAppId(cliConfig),\n create: flags.create,\n organizationId,\n title,\n })\n return {application: null, created: false}\n }\n\n let application = await findUserApplication({\n cliConfig,\n create: flags.create,\n organizationId,\n output,\n title,\n unattended: !!flags.yes,\n })\n deployDebug('User application found', application)\n\n if (!application) {\n deployDebug('No user application found. Creating a new one')\n application = await createUserApplication(organizationId, title, cliConfig.app?.visibility)\n deployDebug('User application created', application)\n return {application, created: true}\n }\n\n return {application, created: false}\n}\n\n/**\n * Syncs application metadata on redeploy when it has changed: the title from the\n * manifest and the dashboard visibility from config. Sends a single PATCH with\n * only the changed fields, and skips the request entirely when nothing changed.\n */\nexport async function syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility,\n}: {\n application: UserApplicationResolved\n manifest: CoreAppManifest | undefined\n output: DeployAppOptions['output']\n visibility: AppVisibility | undefined\n}): Promise<UserApplicationResolved> {\n const titleUpdate = resolveTitleUpdate(manifest, application)\n // Treat an unset server value as `default` so a config of `default` is a no-op.\n const visibilityChanged =\n visibility !== undefined && visibility !== (application.dashboardStatus ?? 'default')\n\n if (!titleUpdate && !visibilityChanged) return application\n\n if (titleUpdate) {\n deployDebug('Updating application title from manifest', titleUpdate)\n output.log(\n titleUpdate.from\n ? `Updating title from \"${titleUpdate.from}\" to \"${titleUpdate.to}\"`\n : `Setting application title to \"${titleUpdate.to}\"`,\n )\n }\n if (visibilityChanged) {\n output.log(`Setting dashboard visibility to \"${visibility}\"`)\n }\n\n const spin = spinner('Updating application').start()\n try {\n const updated = await updateUserApplication({\n applicationId: application.id,\n appType: 'coreApp',\n body: {\n ...(titleUpdate ? {title: titleUpdate.to} : {}),\n ...(visibilityChanged ? {dashboardStatus: visibility} : {}),\n },\n })\n spin.succeed()\n return updated\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application metadata', {message})\n output.logDiagnostic(`Warning: Error updating application metadata: ${message}`)\n return application\n }\n}\n\nasync function shipAppDeployment({\n application,\n isAutoUpdating,\n manifest,\n sourceDir,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n manifest: CoreAppManifest | undefined\n sourceDir: string\n version: string\n}): Promise<void> {\n const tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner('Deploying...').start()\n try {\n await createDeployment({\n applicationId: application.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version,\n })\n } catch (error) {\n spin.clear()\n throw error\n }\n spin.succeed()\n}\n\nexport function logAppDeployed({\n applicationId,\n cliConfig,\n created,\n createRequested = false,\n organizationId,\n output,\n title,\n}: {\n applicationId: string\n cliConfig: DeployAppOptions['cliConfig']\n created: boolean\n createRequested?: boolean\n organizationId: string\n output: DeployAppOptions['output']\n title: string | null\n}): void {\n const url = getCoreAppUrl(organizationId, applicationId)\n const named = title ? ` — \"${title}\"` : ''\n output.log(`\\nSuccess! Application deployed to ${styleText('cyan', url)}${named}`)\n output.log(created ? 'Created a new application.' : 'Updated the existing application.')\n\n if (getAppId(cliConfig)) return\n\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n if (created) {\n output.log(\n styleText(\n 'yellow',\n createRequested\n ? '\\nSave `deployment.appId` and omit --create on later deploys to update this application.'\n : '\\nSave `deployment.appId` to update this application on later deploys.',\n ),\n )\n }\n output.log(\n styleText('bold', '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${applicationId}',\n}\\n`,\n)}`)\n}\n"],"names":["basename","dirname","styleText","createGzip","extractCoreAppManifest","readIconFromPath","resolveTitleUpdate","exitCodes","getErrorMessage","getCoreAppUrl","confirm","spinner","resolveAppEntry","createCoreApp","deployConfig","deployWorkbenchApp","fetchDeploySummaryDetails","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","resolveInstallationId","resolveWorkbenchConfig","selectWorkbenchAppId","summarizeConfig","toWorkbenchPayload","c","createTar","createDeployment","updateUserApplication","getAppId","runStep","EXTERNAL_APP_NOT_SUPPORTED","NO_ORGANIZATION_ID","pluralize","buildApp","applyAspectSync","planAspectSync","checkBlueprintManaged","createUserApplication","checkAppId","checkAppTarget","checkAutoUpdates","checkBuild","checkPackageVersion","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","findUserApplication","APP_PACKAGE","deployApp","options","listFiles","projectRoot","sourceDir","directory","run","runAppDeployment","type","reporter","cliConfig","flags","output","workDir","organizationId","app","appId","workbench","config","dryRun","deployConfigOnly","deployApplication","hasInterfaces","hasAppView","undefined","appTitle","title","trim","slug","assertDeployable","err","report","exitCode","USAGE_ERROR","message","solution","status","fields","length","isAutoUpdating","version","moduleName","kind","projectRootDir","application","appCreated","workbenchApp","targetAppId","external","isWorkbenchApp","created","resolveAppApplication","build","appIcon","icon","startedAt","Date","now","summaryDetails","json","applicationId","applicationCreated","rollbackApp","isSingleton","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","successMessage","mfManifest","manifest","installationId","configSummary","configAppType","appType","aspectSyncPlan","planned","debug","formatError","work","mediaLibraryId","failure","plan","reportAspectSyncPlan","interfaces","deployApplicationConfig","payload","aspectSync","deleteIds","staleIds","upsertIds","documents","map","document","_id","yes","staleCount","proceed","default","join","error","exit","USER_ABORT","runAspectSync","Error","isApp","onDeployed","url","durationMs","log","showAppIdHint","action","syncApplicationMetadata","shipAppDeployment","logAppDeployed","createRequested","create","upserts","strippedFields","Object","entries","strippedByField","details","paths","cause","deleted","unattended","titleUpdate","visibilityChanged","dashboardStatus","from","to","spin","start","updated","body","succeed","fail","logDiagnostic","tarball","cwd","pipe","clear","named"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAEEC,sBAAsB,EACtBC,gBAAgB,EAChBC,kBAAkB,QACb,uCAAsC;AAC7C,SAA4BC,SAAS,QAAO,mBAAkB;AAC9D,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,aAAa,QAAO,wBAAuB;AACnD,SAAQC,OAAO,EAAEC,OAAO,QAAO,sBAAqB;AACpD,SAAQC,eAAe,QAAO,8BAA6B;AAC3D,SACEC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,qBAAqB,EACrBC,sBAAsB,EACtBC,oBAAoB,EACpBC,eAAe,EACfC,kBAAkB,QACb,+BAA8B;AACrC,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SACEC,gBAAgB,EAChBC,qBAAqB,QAGhB,qCAAoC;AAC3C,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,OAAO,QAAO,uBAAsB;AAC5C,SAAQC,0BAA0B,EAAEC,kBAAkB,QAAO,8BAA6B;AAC1F,SAAQC,SAAS,QAAO,0BAAyB;AACjD,SAAQC,QAAQ,QAAO,uBAAsB;AAC7C,SACEC,eAAe,EAEfC,cAAc,QACT,qCAAoC;AAC3C,SAAQC,qBAAqB,QAAO,wBAAuB;AAC3D,SAAQC,qBAAqB,QAAO,6BAA4B;AAChE,SACEC,UAAU,EACVC,cAAc,EACdC,gBAAgB,EAChBC,UAAU,EACVC,mBAAmB,EAEnBC,eAAe,QACV,oBAAmB;AAC1B,SAAQC,WAAW,QAAO,mBAAkB;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["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {\n type CoreAppManifest,\n extractCoreAppManifest,\n resolveTitleUpdate,\n} from '@sanity/cli-build/_internal/manifest'\nimport {type AppVisibility, exitCodes} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {getCoreAppUrl} from '@sanity/cli-core/util'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {resolveAppEntry} from '@sanity/workbench-cli/build'\nimport {\n createCoreApp,\n deployConfig,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n readAppIcon,\n resolveInstallationId,\n resolveWorkbenchConfig,\n selectWorkbenchAppId,\n summarizeConfig,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {c as createTar} from 'tar'\n\nimport {\n createDeployment,\n updateUserApplication,\n type UserApplication,\n type UserApplicationResolved,\n} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {runStep} from '../../util/checks.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED, NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {pluralize} from '../../util/pluralize.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {\n applyAspectSync,\n type AspectSyncPlan,\n planAspectSync,\n} from '../media/aspectSync/syncAspects.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createUserApplication} from './createUserApplication.js'\nimport {\n checkAppId,\n checkAppTarget,\n checkAutoUpdates,\n checkBuild,\n checkPackageVersion,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {findUserApplication} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst APP_PACKAGE = '@sanity/sdk-react'\n\nexport function deployApp(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runAppDeployment,\n type: 'coreApp',\n })\n}\n\n/** Validates the deploy, syncs the title from the manifest, and ships the build. */\nasync function runAppDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const workbench = getWorkbench(cliConfig)\n // A config (the Media Library) is not an app — it resolves through its own\n // brand and persists to the org's installation instead of hosting an application.\n const config = resolveWorkbenchConfig(cliConfig)\n const dryRun = !!flags['dry-run']\n\n const deployConfigOnly = !!config\n const deployApplication = !config && (!workbench || workbench.hasInterfaces)\n const hasAppView = resolveAppEntry(cliConfig.app) !== undefined\n\n const appTitle = workbench\n ? flags.title?.trim() || cliConfig.app?.title?.trim() || workbench.slug\n : ''\n\n // A federated app with no entry, view or service would ship a remote with\n // nothing to load — reported first so it fails before any prompt or API call.\n if (workbench) {\n try {\n workbench.assertDeployable()\n } catch (err) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: getErrorMessage(err),\n solution: 'Declare at least one entry, view, or service in the app',\n status: 'fail',\n })\n }\n }\n\n // A config with no fields would overwrite the org's live config with an empty\n // snapshot, so block it here — same \"nothing to deploy\" gate an app gets.\n if (config && config.fields.length === 0) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'Nothing to deploy: the media library config declares no fields.',\n solution: 'Add at least one field to the media library config',\n status: 'fail',\n })\n }\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n // An application ships the SDK runtime; a media-library config stamps its\n // `sanity` version instead.\n let version: string | null = null\n if (deployApplication) {\n version = await checkPackageVersion(reporter, {moduleName: APP_PACKAGE, workDir})\n } else if (deployConfigOnly) {\n version = await checkPackageVersion(reporter, {moduleName: 'sanity', workDir})\n }\n\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n checkAppId(reporter, {cliConfig})\n\n await checkBlueprintManaged(reporter, {kind: 'coreApp', projectRootDir: workDir})\n\n let application: UserApplicationResolved | null = null\n let appCreated = false\n let workbenchApp: object | undefined\n let targetAppId = appId\n if (flags.external) {\n reporter.report({\n message: EXTERNAL_APP_NOT_SUPPORTED,\n solution: 'Remove the --external flag — apps deploy to Sanity hosting',\n status: 'fail',\n })\n } else if (deployApplication && workbench) {\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'coreApp'})\n workbenchApp = (\n await checkAppTarget(reporter, {\n appId: targetAppId,\n hasAppView,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n } else if (deployApplication) {\n ;({application, created: appCreated} = await resolveAppApplication(options, {dryRun, reporter}))\n }\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (deployApplication && workbench && !appId && !flags.external && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n const summaryDetails =\n workbench && organizationId && !flags.json\n ? fetchDeploySummaryDetails(organizationId)\n : undefined\n\n // Create the app before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && deployApplication && workbench && organizationId && !applicationId) {\n const created = await createCoreApp({\n isSingleton: workbench.isSingleton,\n name: workbench.name,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildApp({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: flags.build\n ? undefined\n : 'Build skipped (--no-build) — validating existing output directory',\n successMessage: 'App built',\n })\n\n // A federated build has already read its manifest; anything else verifies the directory.\n const mfManifest =\n built?.mfManifest ??\n (await verifyOutputDir({\n isWorkbenchApp: workbench !== null || config !== null,\n reporter,\n sourceDir,\n }))\n\n // Workbench apps and configs ship a federation remote and don't read the\n // core-app manifest; only plain core-apps do. Manifests aren't strictly\n // essential, so a failure warns and continues.\n let manifest: CoreAppManifest | undefined\n if (!workbench && !config) {\n try {\n manifest = await extractCoreAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n reporter.report({\n message: `Error extracting app manifest: ${getErrorMessage(err)}`,\n status: 'warn',\n })\n }\n }\n\n // Resolve the installation in both modes so the report — dry-run and real —\n // shows whether the config is deployable; a missing one fails the deploy here.\n let installationId: string | undefined\n let configSummary: string | undefined\n const configAppType = config?.appType\n if (deployConfigOnly && organizationId && config && configAppType) {\n installationId = await resolveInstallationId({appType: configAppType, organizationId})\n configSummary = summarizeConfig(config)\n reporter.report(\n installationId\n ? {message: configSummary, status: 'pass'}\n : {\n exitCode: exitCodes.USAGE_ERROR,\n message: `No active \"${configAppType}\" installation for organization \"${organizationId}\"`,\n solution:\n 'Install the Media Library for the organization before deploying its config',\n status: 'fail',\n },\n )\n }\n\n // Plan the aspect-document sync in both modes, so the report — dry-run and\n // real — shows what the sync will write and, prominently, what it will\n // delete, before anything mutates. Gated on a resolved installation: when\n // that check failed, a real run already exited and a dry run has reported\n // the config as undeployable.\n let aspectSyncPlan: AspectSyncPlan | undefined\n // Gated on the `appType` discriminator, not the mere presence of a config:\n // `ConfigSchema` is a union built to grow, and a future config type must\n // not inherit the media-library aspect sync — and its deletions — by\n // default.\n if (configAppType === 'media-library' && organizationId && config && installationId) {\n // runStep so an unexpected throw (network, API) becomes a fail check:\n // a real run exits, a dry run records it and keeps reporting.\n const planned = await runStep(reporter, {\n debug: deployDebug,\n formatError: (err) => `Planning the aspect-document sync failed: ${getErrorMessage(err)}`,\n name: 'aspect sync plan',\n work: () =>\n planAspectSync({\n fields: config.fields,\n mediaLibraryId: flags['media-library-id'],\n organizationId,\n workDir,\n }),\n })\n if (planned && 'failure' in planned) {\n reporter.report({\n exitCode: planned.failure.exitCode,\n message: planned.failure.message,\n solution: planned.failure.solution,\n status: 'fail',\n })\n } else if (planned) {\n aspectSyncPlan = planned.plan\n reportAspectSyncPlan(reporter, aspectSyncPlan)\n }\n }\n\n const interfaces = deployApplication && workbench ? reportInterfaces(reporter, workbench) : null\n\n // Applied after the app is live (see below) so a failed deploy never leaves\n // the org's installation config without its application.\n const deployApplicationConfig = async (): Promise<void> => {\n if (installationId && version && configAppType && organizationId) {\n await deployConfig({\n appType: configAppType,\n installationId,\n organizationId,\n output,\n sourceDir,\n version,\n })\n }\n }\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n type: 'coreApp',\n version,\n ...toWorkbenchPayload(workbench, {config: configSummary, interfaces, title: appTitle}),\n ...(configSummary ? {config: configSummary} : {}),\n ...(aspectSyncPlan\n ? {\n aspectSync: {\n deleteIds: aspectSyncPlan.staleIds,\n mediaLibraryId: aspectSyncPlan.mediaLibraryId,\n upsertIds: aspectSyncPlan.documents.map((document) => document._id),\n },\n }\n : {}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // Deleting stored definitions is the destructive part of a config deploy,\n // so an interactive run confirms it before anything mutates. Unattended\n // runs (--yes; forced in CI) proceed — the config is the source of truth\n // and the dry-run report lists the deletions.\n if (aspectSyncPlan && aspectSyncPlan.staleIds.length > 0 && !flags.yes) {\n const staleCount = aspectSyncPlan.staleIds.length\n const proceed = await confirm({\n default: false,\n message:\n `Delete ${staleCount} stored aspect ${pluralize('definition', staleCount)} with no ` +\n `matching config field (${aspectSyncPlan.staleIds.join(', ')})?`,\n })\n if (!proceed) {\n output.error('Deploy cancelled — the stored aspect definitions are unchanged.', {\n exit: exitCodes.USER_ABORT,\n })\n }\n }\n\n // A config-only singleton ships no application, only its config.\n if (!deployApplication) {\n await deployApplicationConfig()\n if (aspectSyncPlan) {\n await runAspectSync(aspectSyncPlan, output)\n }\n if (installationId && version) {\n return {application: null, installationId, payload}\n }\n return\n }\n\n // A real deploy already exited on a version-resolution failure; this narrows the type.\n if (!version) return\n\n // The app was created (or resolved from `deployment.appId`) before the build,\n // so this only ships the deployment; plain coreApps use user-applications below.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: true,\n isAutoUpdating,\n mfManifest,\n // Once the deployment is live, a metadata-sync or later config failure\n // must not delete the app.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n })\n await deployApplicationConfig()\n const url = hasAppView\n ? getApplicationUrl({\n id: applicationId,\n organizationId,\n slug: workbench.slug,\n type: 'coreApp',\n })\n : getWorkbenchUrl(organizationId)\n const durationMs = Date.now() - startedAt\n output.log(\n formatDeploySummary({\n ...(await summaryDetails),\n applicationId,\n created: applicationCreated,\n durationMs,\n isApp: true,\n organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n url,\n }),\n )\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n payload,\n url,\n }\n }\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved application means the deploy target was never resolved.\n if (!application) return\n\n application = await syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility: cliConfig.app?.visibility,\n })\n await shipAppDeployment({application, isAutoUpdating, manifest, sourceDir, version})\n logAppDeployed({\n applicationId: application.id,\n cliConfig,\n created: appCreated,\n createRequested: flags.create,\n organizationId: application.organizationId,\n output,\n title: application.title,\n })\n return {\n action: appCreated ? 'create' : 'update',\n application,\n payload,\n url: getCoreAppUrl(application.organizationId, application.id),\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Reports the planned aspect-document sync: the upserts as a pass, stripped\n * non-serializable values as information, and — prominently, as a warning —\n * the stored definitions the sync will delete because no config field matches\n * them. Deploy is a mirror: the config owns the library's aspect namespace.\n */\nexport function reportAspectSyncPlan(reporter: DeployCheckReporter, plan: AspectSyncPlan): void {\n const upserts = plan.documents.length\n reporter.report({\n message: `Will sync ${upserts} aspect ${pluralize('definition', upserts)} to media library ${plan.mediaLibraryId}`,\n status: 'pass',\n })\n\n const strippedFields = Object.entries(plan.strippedByField)\n if (strippedFields.length > 0) {\n // Expected for fields with custom inputs, validation callbacks, or\n // initial-value resolvers: the live config keeps those capabilities, only\n // the stored mirror (read by Studio plugin mode and the dashboard) omits\n // them. Reported so the capability gap is explicit, but not a warning.\n const details = strippedFields\n .map(([name, paths]) => `${name} (${paths.join(', ')})`)\n .join('; ')\n reporter.report({\n message: `Stored definitions omit non-serializable values: ${details}`,\n status: 'pass',\n })\n }\n\n if (plan.staleIds.length > 0) {\n reporter.report({\n message: `Will delete ${plan.staleIds.length} stored aspect ${pluralize('definition', plan.staleIds.length)} with no matching config field: ${plan.staleIds.join(', ')}`,\n solution:\n 'Definitions only — aspects.<name> values on assets stay put and resurface if a matching ' +\n 'field is added back. To keep a definition, declare a matching field in sanity.cli.ts ' +\n '(generate one with `sanity media pull-aspects`)',\n status: 'warn',\n })\n }\n}\n\n/**\n * Applies the planned sync after the config itself deployed. A failure here\n * leaves the config live but the stored mirror stale, so the error says so\n * and points at the retry (deploys are idempotent).\n */\nasync function runAspectSync(\n plan: AspectSyncPlan,\n output: DeployAppOptions['output'],\n): Promise<void> {\n try {\n await applyAspectSync(plan)\n } catch (err) {\n throw new Error(\n `The config deployed, but syncing its aspect documents to media library ${plan.mediaLibraryId} failed: ${getErrorMessage(err)}\\nRun \\`sanity deploy\\` again to retry the sync.`,\n {cause: err},\n )\n }\n const deleted =\n plan.staleIds.length > 0\n ? ` (deleted ${plan.staleIds.length} stale ${pluralize('definition', plan.staleIds.length)})`\n : ''\n output.log(\n `Synced ${plan.documents.length} aspect ${pluralize('definition', plan.documents.length)} to media library ${plan.mediaLibraryId}${deleted}`,\n )\n}\n\n/**\n * Finds the application a real deploy targets, creating one when none is\n * configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveAppApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplicationResolved | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const organizationId = cliConfig.app?.organizationId ?? ''\n // Create name from --title or `app.title` config; blank falls back to the prompt\n const title = flags.title?.trim() || cliConfig.app?.title?.trim() || undefined\n\n if (dryRun) {\n await checkAppTarget(reporter, {\n appId: getAppId(cliConfig),\n create: flags.create,\n organizationId,\n title,\n })\n return {application: null, created: false}\n }\n\n let application = await findUserApplication({\n cliConfig,\n create: flags.create,\n organizationId,\n output,\n title,\n unattended: !!flags.yes,\n })\n deployDebug('User application found', application)\n\n if (!application) {\n deployDebug('No user application found. Creating a new one')\n application = await createUserApplication(organizationId, title, cliConfig.app?.visibility)\n deployDebug('User application created', application)\n return {application, created: true}\n }\n\n return {application, created: false}\n}\n\n/**\n * Syncs application metadata on redeploy when it has changed: the title from the\n * manifest and the dashboard visibility from config. Sends a single PATCH with\n * only the changed fields, and skips the request entirely when nothing changed.\n */\nexport async function syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility,\n}: {\n application: UserApplicationResolved\n manifest: CoreAppManifest | undefined\n output: DeployAppOptions['output']\n visibility: AppVisibility | undefined\n}): Promise<UserApplicationResolved> {\n const titleUpdate = resolveTitleUpdate(manifest, application)\n // Treat an unset server value as `default` so a config of `default` is a no-op.\n const visibilityChanged =\n visibility !== undefined && visibility !== (application.dashboardStatus ?? 'default')\n\n if (!titleUpdate && !visibilityChanged) return application\n\n if (titleUpdate) {\n deployDebug('Updating application title from manifest', titleUpdate)\n output.log(\n titleUpdate.from\n ? `Updating title from \"${titleUpdate.from}\" to \"${titleUpdate.to}\"`\n : `Setting application title to \"${titleUpdate.to}\"`,\n )\n }\n if (visibilityChanged) {\n output.log(`Setting dashboard visibility to \"${visibility}\"`)\n }\n\n const spin = spinner('Updating application').start()\n try {\n const updated = await updateUserApplication({\n applicationId: application.id,\n appType: 'coreApp',\n body: {\n ...(titleUpdate ? {title: titleUpdate.to} : {}),\n ...(visibilityChanged ? {dashboardStatus: visibility} : {}),\n },\n })\n spin.succeed()\n return updated\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application metadata', {message})\n output.logDiagnostic(`Warning: Error updating application metadata: ${message}`)\n return application\n }\n}\n\nasync function shipAppDeployment({\n application,\n isAutoUpdating,\n manifest,\n sourceDir,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n manifest: CoreAppManifest | undefined\n sourceDir: string\n version: string\n}): Promise<void> {\n const tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n\n const spin = spinner('Deploying...').start()\n try {\n await createDeployment({\n applicationId: application.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version,\n })\n } catch (error) {\n spin.clear()\n throw error\n }\n spin.succeed()\n}\n\nexport function logAppDeployed({\n applicationId,\n cliConfig,\n created,\n createRequested = false,\n organizationId,\n output,\n title,\n}: {\n applicationId: string\n cliConfig: DeployAppOptions['cliConfig']\n created: boolean\n createRequested?: boolean\n organizationId: string\n output: DeployAppOptions['output']\n title: string | null\n}): void {\n const url = getCoreAppUrl(organizationId, applicationId)\n const named = title ? ` — \"${title}\"` : ''\n output.log(`\\nSuccess! Application deployed to ${styleText('cyan', url)}${named}`)\n output.log(created ? 'Created a new application.' : 'Updated the existing application.')\n\n if (getAppId(cliConfig)) return\n\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n if (created) {\n output.log(\n styleText(\n 'yellow',\n createRequested\n ? '\\nSave `deployment.appId` and omit --create on later deploys to update this application.'\n : '\\nSave `deployment.appId` to update this application on later deploys.',\n ),\n )\n }\n output.log(\n styleText('bold', '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${applicationId}',\n}\\n`,\n)}`)\n}\n"],"names":["basename","dirname","styleText","createGzip","extractCoreAppManifest","resolveTitleUpdate","exitCodes","getErrorMessage","getCoreAppUrl","confirm","spinner","resolveAppEntry","createCoreApp","deployConfig","deployWorkbenchApp","fetchDeploySummaryDetails","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","readAppIcon","resolveInstallationId","resolveWorkbenchConfig","selectWorkbenchAppId","summarizeConfig","toWorkbenchPayload","c","createTar","createDeployment","updateUserApplication","getAppId","runStep","EXTERNAL_APP_NOT_SUPPORTED","NO_ORGANIZATION_ID","pluralize","buildApp","applyAspectSync","planAspectSync","checkBlueprintManaged","createUserApplication","checkAppId","checkAppTarget","checkAutoUpdates","checkBuild","checkPackageVersion","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","findUserApplication","APP_PACKAGE","deployApp","options","listFiles","projectRoot","sourceDir","directory","run","runAppDeployment","type","reporter","cliConfig","flags","output","workDir","organizationId","app","appId","workbench","config","dryRun","deployConfigOnly","deployApplication","hasInterfaces","hasAppView","undefined","appTitle","title","trim","slug","assertDeployable","err","report","exitCode","USAGE_ERROR","message","solution","status","fields","length","isAutoUpdating","version","moduleName","kind","projectRootDir","application","appCreated","workbenchApp","targetAppId","external","isWorkbenchApp","created","resolveAppApplication","build","appIcon","icon","startedAt","Date","now","summaryDetails","json","applicationId","applicationCreated","rollbackApp","isSingleton","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","successMessage","mfManifest","manifest","installationId","configSummary","configAppType","appType","aspectSyncPlan","planned","debug","formatError","work","mediaLibraryId","failure","plan","reportAspectSyncPlan","interfaces","deployApplicationConfig","payload","aspectSync","deleteIds","staleIds","upsertIds","documents","map","document","_id","yes","staleCount","proceed","default","join","error","exit","USER_ABORT","runAspectSync","Error","isApp","onDeployed","url","durationMs","log","showAppIdHint","action","syncApplicationMetadata","shipAppDeployment","logAppDeployed","createRequested","create","upserts","strippedFields","Object","entries","strippedByField","details","paths","cause","deleted","unattended","titleUpdate","visibilityChanged","dashboardStatus","from","to","spin","start","updated","body","succeed","fail","logDiagnostic","tarball","cwd","pipe","clear","named"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAEEC,sBAAsB,EACtBC,kBAAkB,QACb,uCAAsC;AAC7C,SAA4BC,SAAS,QAAO,mBAAkB;AAC9D,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,aAAa,QAAO,wBAAuB;AACnD,SAAQC,OAAO,EAAEC,OAAO,QAAO,sBAAqB;AACpD,SAAQC,eAAe,QAAO,8BAA6B;AAC3D,SACEC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,W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C,MAAMwF,QAAQ1H,QAAQ,CAAC,IAAI,EAAEA,MAAM,CAAC,CAAC,GAAG;IACxCd,OAAOsG,GAAG,CAAC,CAAC,mCAAmC,EAAEpK,UAAU,QAAQkK,OAAOoC,OAAO;IACjFxI,OAAOsG,GAAG,CAAChE,UAAU,+BAA+B;IAEpD,IAAIxE,SAASgC,YAAY;IAEzBE,OAAOsG,GAAG,CAAC,CAAC,OAAO,EAAEpK,UAAU,QAAQ,cAAc,KAAK,CAAC;IAC3D,IAAIoG,SAAS;QACXtC,OAAOsG,GAAG,CACRpK,UACE,UACA0K,kBACI,6FACA;IAGV;IACA5G,OAAOsG,GAAG,CACRpK,UAAU,QAAQ;IAEpB8D,OAAOsG,GAAG,CAAC,CAAC;AACd,EAAEpK,UACA,OACA,CAAC;;CAEF,CAAC,EACA;AACF,EAAEA,UACA;QAAC;QAAQ;KAAQ,EACjB,CAAC;UACO,EAAE8G,cAAc;GACvB,CAAC,GACD;AACH"}
|
|
@@ -2,10 +2,9 @@ import { basename, dirname, relative } from 'node:path';
|
|
|
2
2
|
import { styleText } from 'node:util';
|
|
3
3
|
import { createGzip } from 'node:zlib';
|
|
4
4
|
import { formatSchemaValidation, SchemaExtractionError } from '@sanity/cli-build/_internal/extract';
|
|
5
|
-
import { readIconFromPath } from '@sanity/cli-build/_internal/manifest';
|
|
6
5
|
import { exitCodes } from '@sanity/cli-core';
|
|
7
6
|
import { spinner } from '@sanity/cli-core/ux';
|
|
8
|
-
import { createStudio, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, selectWorkbenchAppId, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
7
|
+
import { createStudio, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, selectWorkbenchAppId, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
9
8
|
import { c as createTar } from 'tar';
|
|
10
9
|
import { createDeployment } from '../../services/userApplications.js';
|
|
11
10
|
import { getAppId } from '../../util/appId.js';
|
|
@@ -114,7 +113,7 @@ export function deployStudio(options) {
|
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
// Read up front so a bad icon path fails before we create or build.
|
|
117
|
-
const appIcon = !dryRun && workbench?.icon ? await
|
|
116
|
+
const appIcon = !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined;
|
|
118
117
|
const startedAt = Date.now();
|
|
119
118
|
const summaryDetails = workbench && organizationId && !flags.json ? fetchDeploySummaryDetails(organizationId) : undefined;
|
|
120
119
|
// Create the studio before the build so the bundle carries its real id. A
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname, relative} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip, type Gzip} from 'node:zlib'\n\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {readIconFromPath} from '@sanity/cli-build/_internal/manifest'\nimport {exitCodes} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {\n type BrettAccess,\n type BrettWorkspace,\n createStudio,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n selectWorkbenchAppId,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {type StudioManifest} from 'sanity'\nimport {c as createTar} from 'tar'\n\nimport {createDeployment, type UserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID, NO_PROJECT_ID} from '../../util/errorMessages.js'\nimport {buildStudio} from '../build/buildStudio.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createStudioUserApplication} from './createUserApplication.js'\nimport {\n checkAutoUpdates,\n checkBuild,\n checkExternalUrl,\n checkPackageVersion,\n checkStudioTarget,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {deployStudioSchemasAndManifests} from './deployStudioSchemasAndManifests.js'\nimport {findUserApplicationForStudio} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst STUDIO_PACKAGE = 'sanity'\n\nexport function deployStudio(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({flags, projectRoot, sourceDir}) =>\n flags.external ? Promise.resolve([]) : listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runStudioDeployment,\n type: 'studio',\n })\n}\n\n/** Validates the deploy, extracts and uploads the schema, and ships the build. */\nasync function runStudioDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const isExternal = !!flags.external\n const workbench = getWorkbench(cliConfig)\n const isWorkbenchApp = workbench !== null\n const projectId = cliConfig.api?.projectId\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const dryRun = !!flags['dry-run']\n // A legacy external studio only registers its URL; a federated one is built\n // and deployed like a hosted one, minus the upload.\n const isLegacyExternal = isExternal && !isWorkbenchApp\n\n const appTitle = workbench\n ? flags.title?.trim() || cliConfig.app?.title?.trim() || workbench.slug\n : ''\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n const version = await checkPackageVersion(reporter, {\n moduleName: STUDIO_PACKAGE,\n workDir,\n })\n\n reporter.report(\n projectId\n ? {message: `Project: ${projectId}`, status: 'pass'}\n : {\n message: NO_PROJECT_ID,\n solution: 'Add `api.projectId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n await checkBlueprintManaged(reporter, {kind: 'studio', projectRootDir: workDir})\n\n // Workbench studios deploy to Brett (which needs the org); plain studios\n // resolve/create on user-applications, unchanged.\n let application: UserApplication | null = null\n let studioCreated = false\n let workbenchApp: {externalUrl?: string} | undefined\n let externalUrl: string | undefined\n let targetAppId = appId\n if (workbench) {\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'studio'})\n workbenchApp = (\n await checkStudioTarget(reporter, {\n appId: targetAppId,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n if (isExternal) externalUrl = checkExternalUrl(reporter, {appId: targetAppId, url: flags.url})\n } else {\n ;({application, created: studioCreated} = await resolveStudioApplication(options, {\n dryRun,\n reporter,\n }))\n }\n // A redeploy follows how the application was registered, so --external is only needed once.\n const isExternallyHosted = isExternal || !!workbenchApp?.externalUrl\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (workbench && !appId && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readIconFromPath(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n const summaryDetails =\n workbench && organizationId && !flags.json\n ? fetchDeploySummaryDetails(organizationId)\n : undefined\n\n // Create the studio before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && workbench && organizationId && !applicationId) {\n const created = await createStudio({\n externalUrl,\n name: workbench.name,\n organizationId,\n projectId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildStudio({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: studioBuildSkipReason({build: flags.build, isLegacyExternal}),\n successMessage: 'Studio built',\n })\n\n let mfManifest = built?.mfManifest\n // A federated build has already read its manifest; anything else verifies the directory.\n if (mfManifest === undefined && !isLegacyExternal) {\n mfManifest = await verifyOutputDir({isWorkbenchApp, reporter, sourceDir})\n }\n\n const interfaces = workbench ? reportInterfaces(reporter, workbench) : null\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n ...(projectId ? {projectId} : {}),\n type: 'studio',\n version,\n ...toWorkbenchPayload(workbench, {interfaces, title: appTitle}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved version means the deploy target was never resolved.\n if (!version) return\n\n const studioManifest = await uploadStudioSchema(options, {\n applicationId: workbench ? applicationId : undefined,\n isExternal: isLegacyExternal,\n })\n // The studio was created (or resolved from `deployment.appId`) before the\n // build, so this only ships the deployment; plain studios use user-applications.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n access: toAccess(studioManifest),\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: false,\n isAutoUpdating,\n isExternal: isExternallyHosted,\n label: 'Deploying studio',\n mfManifest,\n // Once the deployment is live, a metadata-sync failure must not delete\n // the studio.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n workspaces: toWorkspaces(studioManifest),\n })\n const url = getApplicationUrl({\n id: applicationId,\n organizationId,\n slug: workbench.slug,\n type: 'studio',\n })\n const durationMs = Date.now() - startedAt\n output.log(\n formatDeploySummary({\n ...(await summaryDetails),\n applicationId,\n created: applicationCreated,\n durationMs,\n isApp: false,\n organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n url,\n }),\n )\n if (isExternallyHosted)\n logExternalHost({built: flags.build, organizationId, output, sourceDir})\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n payload,\n url,\n }\n }\n\n if (!application) return\n const location = await shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n })\n\n return {\n action: studioCreated ? 'create' : 'update',\n application,\n payload,\n url: location,\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Finds the application a real deploy targets, registering a studio host when\n * none is configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveStudioApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplication | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const isExternal = !!flags.external\n const appId = getAppId(cliConfig)\n // Sets the title on a newly registered studio; blank falls back to undefined\n const title = flags.title?.trim() || undefined\n\n if (dryRun) {\n await checkStudioTarget(reporter, {\n appId,\n isExternal,\n projectId: cliConfig.api?.projectId,\n studioHost: cliConfig.studioHost,\n title,\n urlFlag: flags.url,\n })\n return {application: null, created: false}\n }\n\n const projectId = cliConfig.api?.projectId ?? ''\n // `created` is true when a configured-but-unregistered host was just registered.\n const {application, created} = await findUserApplicationForStudio({\n appId,\n isExternal,\n output,\n projectId,\n studioHost: cliConfig.studioHost,\n title,\n unattended: !!flags.yes,\n urlFlag: flags.url,\n })\n\n if (!application) {\n if (isExternal) {\n output.log('Your project has not been registered with an external studio URL.')\n output.log('Please enter the full URL where your studio is hosted.')\n } else {\n output.log('Your project has not been assigned a studio hostname.')\n output.log('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.log('you will need one. Please enter the subdomain you want to use.')\n }\n\n const registered = await createStudioUserApplication({\n projectId,\n title,\n urlType: isExternal ? 'external' : 'internal',\n })\n deployDebug('Created user application', registered)\n return {application: registered, created: true}\n }\n\n deployDebug('Found user application', application)\n return {application, created}\n}\n\n/** Extracts the studio schema and manifest and uploads them to the schema store. */\nasync function uploadStudioSchema(\n options: DeployAppOptions,\n {applicationId, isExternal}: {applicationId?: string; isExternal: boolean},\n): Promise<StudioManifest | null> {\n const {flags, output, projectRoot, sourceDir} = options\n\n let studioManifest: StudioManifest | null = null\n try {\n studioManifest = await deployStudioSchemasAndManifests(\n {\n applicationId,\n configPath: projectRoot.path,\n isExternal,\n outPath: `${sourceDir}/static`,\n schemaRequired: flags['schema-required'],\n verbose: flags.verbose,\n workDir: projectRoot.directory,\n },\n output,\n )\n } catch (error) {\n deployDebug('Error deploying studio schemas and manifests', error)\n if (error instanceof SchemaExtractionError && error.validation?.length) {\n output.error(formatSchemaValidation(error.validation), {exit: exitCodes.RUNTIME_ERROR})\n }\n output.error(`Error deploying studio schemas and manifests: ${error}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!studioManifest) {\n output.error('Failed to generate studio manifest. Please check your schemas and manifests.', {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n return studioManifest\n}\n\nasync function shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n isExternal: boolean\n options: DeployAppOptions\n studioManifest: StudioManifest | null\n version: string\n}): Promise<string> {\n const {cliConfig, output, sourceDir} = options\n\n let tarball: Gzip | undefined\n if (!isExternal) {\n tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n }\n\n const spin = spinner(isExternal ? 'Registering studio' : 'Deploying to sanity.studio').start()\n let location: string\n try {\n ;({location} = await createDeployment({\n applicationId: application.id,\n isApp: false,\n isAutoUpdating,\n manifest: studioManifest,\n projectId: cliConfig.api?.projectId,\n tarball,\n version,\n }))\n } catch (error) {\n spin.fail()\n throw error\n }\n spin.succeed()\n\n const named = application.title ? ` — \"${application.title}\"` : ''\n output.log(\n isExternal\n ? `\\nSuccess! Studio registered${named}`\n : `\\nSuccess! Studio deployed to ${styleText('cyan', location)}${named}`,\n )\n\n if (getAppId(cliConfig)) return location\n\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${styleText('cyan', `appId: '${application.id}'`)},\n },\n //…\n})`\n output.log(`\\nAdd ${styleText('cyan', `appId: '${application.id}'`)}`)\n output.log(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting for application id on next deploy.`)\n output.log(`\\n${example}`)\n\n return location\n}\n\n/**\n * One `datasets` access entry per unique workspace dataset, with a `resourceId`\n * of `\"<projectId>.<dataset>\"`. Deduped, since workspaces can share a dataset.\n */\nfunction toAccess(manifest: StudioManifest | null): BrettAccess[] {\n const resourceIds = new Set(\n (manifest?.workspaces ?? []).map((w) => `${w.projectId}.${w.dataset}`),\n )\n return [...resourceIds].map(\n (resourceId) => ({resourceId, resourceType: 'dataset'}) satisfies BrettAccess,\n )\n}\n\nfunction toWorkspaces(manifest: StudioManifest | null): BrettWorkspace[] {\n return (manifest?.workspaces ?? []).map((workspace) => ({\n basePath: workspace.basePath,\n dataset: workspace.dataset,\n icon: workspace.icon,\n name: workspace.name,\n projectId: workspace.projectId,\n schemaDescriptorId: workspace.schemaDescriptorId,\n subtitle: workspace.subtitle,\n title: workspace.title,\n }))\n}\n\n/** Tells the customer what their host must do for the Dashboard to load the studio from it. */\nfunction logExternalHost({\n built,\n organizationId,\n output,\n sourceDir,\n}: {\n built: boolean\n organizationId: string\n output: DeployAppOptions['output']\n sourceDir: string\n}): void {\n const dir = `${relative(process.cwd(), sourceDir) || '.'}/`\n output.log(`\nThe Dashboard loads this studio from your host, which must:\n 1. Serve ${dir} unchanged at the root of its URL (/mf-manifest.json, /remoteEntry-*.js, /static/*)\n 2. Send Access-Control-Allow-Origin for ${getWorkbenchUrl(organizationId)}\n 3. Respond without cookies or a sign-in${built ? `\\n\\nThis deploy rebuilt ${dir}: copy it to your host before opening the studio in the Dashboard.` : ''}`)\n}\n\nfunction studioBuildSkipReason({\n build,\n isLegacyExternal,\n}: {\n build: boolean\n isLegacyExternal: boolean\n}) {\n if (isLegacyExternal) return 'Build skipped for externally hosted studios'\n if (!build) return 'Build skipped (--no-build) — validating existing output directory'\n return\n}\n"],"names":["basename","dirname","relative","styleText","createGzip","formatSchemaValidation","SchemaExtractionError","readIconFromPath","exitCodes","spinner","createStudio","deployWorkbenchApp","fetchDeploySummaryDetails","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","selectWorkbenchAppId","toWorkbenchPayload","c","createTar","createDeployment","getAppId","NO_ORGANIZATION_ID","NO_PROJECT_ID","buildStudio","checkBlueprintManaged","createStudioUserApplication","checkAutoUpdates","checkBuild","checkExternalUrl","checkPackageVersion","checkStudioTarget","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","deployStudioSchemasAndManifests","findUserApplicationForStudio","STUDIO_PACKAGE","deployStudio","options","listFiles","flags","projectRoot","sourceDir","external","Promise","resolve","directory","run","runStudioDeployment","type","reporter","cliConfig","output","workDir","isExternal","workbench","isWorkbenchApp","projectId","api","organizationId","app","appId","dryRun","isLegacyExternal","appTitle","title","trim","slug","isAutoUpdating","version","moduleName","report","message","status","solution","kind","projectRootDir","application","studioCreated","workbenchApp","externalUrl","targetAppId","url","created","resolveStudioApplication","isExternallyHosted","build","exitCode","USAGE_ERROR","appIcon","icon","undefined","startedAt","Date","now","summaryDetails","json","applicationId","applicationCreated","rollbackApp","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","studioBuildSkipReason","successMessage","mfManifest","interfaces","payload","studioManifest","uploadStudioSchema","Error","access","toAccess","isApp","label","onDeployed","workspaces","toWorkspaces","durationMs","log","showAppIdHint","logExternalHost","action","location","shipStudioDeployment","err","studioHost","urlFlag","unattended","yes","registered","urlType","configPath","path","outPath","schemaRequired","verbose","error","validation","length","exit","RUNTIME_ERROR","tarball","cwd","pipe","spin","start","manifest","fail","succeed","named","example","resourceIds","Set","map","w","dataset","resourceId","resourceType","workspace","basePath","schemaDescriptorId","subtitle","dir","process"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAO,YAAW;AACrD,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAkB,YAAW;AAE/C,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,gBAAgB,QAAO,uCAAsC;AACrE,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAGEC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,oBAAoB,EACpBC,kBAAkB,QACb,+BAA8B;AAErC,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAAQC,gBAAgB,QAA6B,qCAAoC;AACzF,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,kBAAkB,EAAEC,aAAa,QAAO,8BAA6B;AAC7E,SAAQC,WAAW,QAAO,0BAAyB;AACnD,SAAQC,qBAAqB,QAAO,wBAAuB;AAC3D,SAAQC,2BAA2B,QAAO,6BAA4B;AACtE,SACEC,gBAAgB,EAChBC,UAAU,EACVC,gBAAgB,EAChBC,mBAAmB,EACnBC,iBAAiB,EAEjBC,eAAe,QACV,oBAAmB;AAC1B,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,mBAAmB,EAAEC,gBAAgB,QAAO,sBAAqB;AACzE,SAA+CC,SAAS,QAAO,oBAAmB;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AAO,OAAO;IACnB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname, relative} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip, type Gzip} from 'node:zlib'\n\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {exitCodes} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {\n type BrettAccess,\n type BrettWorkspace,\n createStudio,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n readAppIcon,\n selectWorkbenchAppId,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {type StudioManifest} from 'sanity'\nimport {c as createTar} from 'tar'\n\nimport {createDeployment, type UserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID, NO_PROJECT_ID} from '../../util/errorMessages.js'\nimport {buildStudio} from '../build/buildStudio.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createStudioUserApplication} from './createUserApplication.js'\nimport {\n checkAutoUpdates,\n checkBuild,\n checkExternalUrl,\n checkPackageVersion,\n checkStudioTarget,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {deployStudioSchemasAndManifests} from './deployStudioSchemasAndManifests.js'\nimport {findUserApplicationForStudio} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst STUDIO_PACKAGE = 'sanity'\n\nexport function deployStudio(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({flags, projectRoot, sourceDir}) =>\n flags.external ? Promise.resolve([]) : listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runStudioDeployment,\n type: 'studio',\n })\n}\n\n/** Validates the deploy, extracts and uploads the schema, and ships the build. */\nasync function runStudioDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const isExternal = !!flags.external\n const workbench = getWorkbench(cliConfig)\n const isWorkbenchApp = workbench !== null\n const projectId = cliConfig.api?.projectId\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const dryRun = !!flags['dry-run']\n // A legacy external studio only registers its URL; a federated one is built\n // and deployed like a hosted one, minus the upload.\n const isLegacyExternal = isExternal && !isWorkbenchApp\n\n const appTitle = workbench\n ? flags.title?.trim() || cliConfig.app?.title?.trim() || workbench.slug\n : ''\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n const version = await checkPackageVersion(reporter, {\n moduleName: STUDIO_PACKAGE,\n workDir,\n })\n\n reporter.report(\n projectId\n ? {message: `Project: ${projectId}`, status: 'pass'}\n : {\n message: NO_PROJECT_ID,\n solution: 'Add `api.projectId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n await checkBlueprintManaged(reporter, {kind: 'studio', projectRootDir: workDir})\n\n // Workbench studios deploy to Brett (which needs the org); plain studios\n // resolve/create on user-applications, unchanged.\n let application: UserApplication | null = null\n let studioCreated = false\n let workbenchApp: {externalUrl?: string} | undefined\n let externalUrl: string | undefined\n let targetAppId = appId\n if (workbench) {\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'studio'})\n workbenchApp = (\n await checkStudioTarget(reporter, {\n appId: targetAppId,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n if (isExternal) externalUrl = checkExternalUrl(reporter, {appId: targetAppId, url: flags.url})\n } else {\n ;({application, created: studioCreated} = await resolveStudioApplication(options, {\n dryRun,\n reporter,\n }))\n }\n // A redeploy follows how the application was registered, so --external is only needed once.\n const isExternallyHosted = isExternal || !!workbenchApp?.externalUrl\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (workbench && !appId && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n const summaryDetails =\n workbench && organizationId && !flags.json\n ? fetchDeploySummaryDetails(organizationId)\n : undefined\n\n // Create the studio before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && workbench && organizationId && !applicationId) {\n const created = await createStudio({\n externalUrl,\n name: workbench.name,\n organizationId,\n projectId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildStudio({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: studioBuildSkipReason({build: flags.build, isLegacyExternal}),\n successMessage: 'Studio built',\n })\n\n let mfManifest = built?.mfManifest\n // A federated build has already read its manifest; anything else verifies the directory.\n if (mfManifest === undefined && !isLegacyExternal) {\n mfManifest = await verifyOutputDir({isWorkbenchApp, reporter, sourceDir})\n }\n\n const interfaces = workbench ? reportInterfaces(reporter, workbench) : null\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n ...(projectId ? {projectId} : {}),\n type: 'studio',\n version,\n ...toWorkbenchPayload(workbench, {interfaces, title: appTitle}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved version means the deploy target was never resolved.\n if (!version) return\n\n const studioManifest = await uploadStudioSchema(options, {\n applicationId: workbench ? applicationId : undefined,\n isExternal: isLegacyExternal,\n })\n // The studio was created (or resolved from `deployment.appId`) before the\n // build, so this only ships the deployment; plain studios use user-applications.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n access: toAccess(studioManifest),\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: false,\n isAutoUpdating,\n isExternal: isExternallyHosted,\n label: 'Deploying studio',\n mfManifest,\n // Once the deployment is live, a metadata-sync failure must not delete\n // the studio.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n workspaces: toWorkspaces(studioManifest),\n })\n const url = getApplicationUrl({\n id: applicationId,\n organizationId,\n slug: workbench.slug,\n type: 'studio',\n })\n const durationMs = Date.now() - startedAt\n output.log(\n formatDeploySummary({\n ...(await summaryDetails),\n applicationId,\n created: applicationCreated,\n durationMs,\n isApp: false,\n organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n url,\n }),\n )\n if (isExternallyHosted)\n logExternalHost({built: flags.build, organizationId, output, sourceDir})\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n payload,\n url,\n }\n }\n\n if (!application) return\n const location = await shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n })\n\n return {\n action: studioCreated ? 'create' : 'update',\n application,\n payload,\n url: location,\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Finds the application a real deploy targets, registering a studio host when\n * none is configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveStudioApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplication | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const isExternal = !!flags.external\n const appId = getAppId(cliConfig)\n // Sets the title on a newly registered studio; blank falls back to undefined\n const title = flags.title?.trim() || undefined\n\n if (dryRun) {\n await checkStudioTarget(reporter, {\n appId,\n isExternal,\n projectId: cliConfig.api?.projectId,\n studioHost: cliConfig.studioHost,\n title,\n urlFlag: flags.url,\n })\n return {application: null, created: false}\n }\n\n const projectId = cliConfig.api?.projectId ?? ''\n // `created` is true when a configured-but-unregistered host was just registered.\n const {application, created} = await findUserApplicationForStudio({\n appId,\n isExternal,\n output,\n projectId,\n studioHost: cliConfig.studioHost,\n title,\n unattended: !!flags.yes,\n urlFlag: flags.url,\n })\n\n if (!application) {\n if (isExternal) {\n output.log('Your project has not been registered with an external studio URL.')\n output.log('Please enter the full URL where your studio is hosted.')\n } else {\n output.log('Your project has not been assigned a studio hostname.')\n output.log('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.log('you will need one. Please enter the subdomain you want to use.')\n }\n\n const registered = await createStudioUserApplication({\n projectId,\n title,\n urlType: isExternal ? 'external' : 'internal',\n })\n deployDebug('Created user application', registered)\n return {application: registered, created: true}\n }\n\n deployDebug('Found user application', application)\n return {application, created}\n}\n\n/** Extracts the studio schema and manifest and uploads them to the schema store. */\nasync function uploadStudioSchema(\n options: DeployAppOptions,\n {applicationId, isExternal}: {applicationId?: string; isExternal: boolean},\n): Promise<StudioManifest | null> {\n const {flags, output, projectRoot, sourceDir} = options\n\n let studioManifest: StudioManifest | null = null\n try {\n studioManifest = await deployStudioSchemasAndManifests(\n {\n applicationId,\n configPath: projectRoot.path,\n isExternal,\n outPath: `${sourceDir}/static`,\n schemaRequired: flags['schema-required'],\n verbose: flags.verbose,\n workDir: projectRoot.directory,\n },\n output,\n )\n } catch (error) {\n deployDebug('Error deploying studio schemas and manifests', error)\n if (error instanceof SchemaExtractionError && error.validation?.length) {\n output.error(formatSchemaValidation(error.validation), {exit: exitCodes.RUNTIME_ERROR})\n }\n output.error(`Error deploying studio schemas and manifests: ${error}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!studioManifest) {\n output.error('Failed to generate studio manifest. Please check your schemas and manifests.', {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n return studioManifest\n}\n\nasync function shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n isExternal: boolean\n options: DeployAppOptions\n studioManifest: StudioManifest | null\n version: string\n}): Promise<string> {\n const {cliConfig, output, sourceDir} = options\n\n let tarball: Gzip | undefined\n if (!isExternal) {\n tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n }\n\n const spin = spinner(isExternal ? 'Registering studio' : 'Deploying to sanity.studio').start()\n let location: string\n try {\n ;({location} = await createDeployment({\n applicationId: application.id,\n isApp: false,\n isAutoUpdating,\n manifest: studioManifest,\n projectId: cliConfig.api?.projectId,\n tarball,\n version,\n }))\n } catch (error) {\n spin.fail()\n throw error\n }\n spin.succeed()\n\n const named = application.title ? ` — \"${application.title}\"` : ''\n output.log(\n isExternal\n ? `\\nSuccess! Studio registered${named}`\n : `\\nSuccess! Studio deployed to ${styleText('cyan', location)}${named}`,\n )\n\n if (getAppId(cliConfig)) return location\n\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${styleText('cyan', `appId: '${application.id}'`)},\n },\n //…\n})`\n output.log(`\\nAdd ${styleText('cyan', `appId: '${application.id}'`)}`)\n output.log(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting for application id on next deploy.`)\n output.log(`\\n${example}`)\n\n return location\n}\n\n/**\n * One `datasets` access entry per unique workspace dataset, with a `resourceId`\n * of `\"<projectId>.<dataset>\"`. Deduped, since workspaces can share a dataset.\n */\nfunction toAccess(manifest: StudioManifest | null): BrettAccess[] {\n const resourceIds = new Set(\n (manifest?.workspaces ?? []).map((w) => `${w.projectId}.${w.dataset}`),\n )\n return [...resourceIds].map(\n (resourceId) => ({resourceId, resourceType: 'dataset'}) satisfies BrettAccess,\n )\n}\n\nfunction toWorkspaces(manifest: StudioManifest | null): BrettWorkspace[] {\n return (manifest?.workspaces ?? []).map((workspace) => ({\n basePath: workspace.basePath,\n dataset: workspace.dataset,\n icon: workspace.icon,\n name: workspace.name,\n projectId: workspace.projectId,\n schemaDescriptorId: workspace.schemaDescriptorId,\n subtitle: workspace.subtitle,\n title: workspace.title,\n }))\n}\n\n/** Tells the customer what their host must do for the Dashboard to load the studio from it. */\nfunction logExternalHost({\n built,\n organizationId,\n output,\n sourceDir,\n}: {\n built: boolean\n organizationId: string\n output: DeployAppOptions['output']\n sourceDir: string\n}): void {\n const dir = `${relative(process.cwd(), sourceDir) || '.'}/`\n output.log(`\nThe Dashboard loads this studio from your host, which must:\n 1. Serve ${dir} unchanged at the root of its URL (/mf-manifest.json, /remoteEntry-*.js, /static/*)\n 2. Send Access-Control-Allow-Origin for ${getWorkbenchUrl(organizationId)}\n 3. Respond without cookies or a sign-in${built ? `\\n\\nThis deploy rebuilt ${dir}: copy it to your host before opening the studio in the Dashboard.` : ''}`)\n}\n\nfunction studioBuildSkipReason({\n build,\n isLegacyExternal,\n}: {\n build: boolean\n isLegacyExternal: boolean\n}) {\n if (isLegacyExternal) return 'Build skipped for externally hosted studios'\n if (!build) return 'Build skipped (--no-build) — validating existing output directory'\n return\n}\n"],"names":["basename","dirname","relative","styleText","createGzip","formatSchemaValidation","SchemaExtractionError","exitCodes","spinner","createStudio","deployWorkbenchApp","fetchDeploySummaryDetails","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","readAppIcon","selectWorkbenchAppId","toWorkbenchPayload","c","createTar","createDeployment","getAppId","NO_ORGANIZATION_ID","NO_PROJECT_ID","buildStudio","checkBlueprintManaged","createStudioUserApplication","checkAutoUpdates","checkBuild","checkExternalUrl","checkPackageVersion","checkStudioTarget","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","deployStudioSchemasAndManifests","findUserApplicationForStudio","STUDIO_PACKAGE","deployStudio","options","listFiles","flags","projectRoot","sourceDir","external","Promise","resolve","directory","run","runStudioDeployment","type","reporter","cliConfig","output","workDir","isExternal","workbench","isWorkbenchApp","projectId","api","organizationId","app","appId","dryRun","isLegacyExternal","appTitle","title","trim","slug","isAutoUpdating","version","moduleName","report","message","status","solution","kind","projectRootDir","application","studioCreated","workbenchApp","externalUrl","targetAppId","url","created","resolveStudioApplication","isExternallyHosted","build","exitCode","USAGE_ERROR","appIcon","icon","undefined","startedAt","Date","now","summaryDetails","json","applicationId","applicationCreated","rollbackApp","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","studioBuildSkipReason","successMessage","mfManifest","interfaces","payload","studioManifest","uploadStudioSchema","Error","access","toAccess","isApp","label","onDeployed","workspaces","toWorkspaces","durationMs","log","showAppIdHint","logExternalHost","action","location","shipStudioDeployment","err","studioHost","urlFlag","unattended","yes","registered","urlType","configPath","path","outPath","schemaRequired","verbose","error","validation","length","exit","RUNTIME_ERROR","tarball","cwd","pipe","spin","start","manifest","fail","succeed","named","example","resourceIds","Set","map","w","dataset","resourceId","resourceType","workspace","basePath","schemaDescriptorId","subtitle","dir","process"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAO,YAAW;AACrD,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAkB,YAAW;AAE/C,SAAQC,sBAAsB,EA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AAG,CAAC,CAACK,YAAe,CAAA;YACtDC,UAAUD,UAAUC,QAAQ;YAC5BJ,SAASG,UAAUH,OAAO;YAC1BxE,MAAM2E,UAAU3E,IAAI;YACpBU,MAAMiE,UAAUjE,IAAI;YACpB3C,WAAW4G,UAAU5G,SAAS;YAC9B8G,oBAAoBF,UAAUE,kBAAkB;YAChDC,UAAUH,UAAUG,QAAQ;YAC5BvG,OAAOoG,UAAUpG,KAAK;QACxB,CAAA;AACF;AAEA,6FAA6F,GAC7F,SAAS8D,gBAAgB,EACvBvB,KAAK,EACL7C,cAAc,EACdP,MAAM,EACNV,SAAS,EAMV;IACC,MAAM+H,MAAM,GAAG3K,SAAS4K,QAAQrB,GAAG,IAAI3G,cAAc,IAAI,CAAC,CAAC;IAC3DU,OAAOyE,GAAG,CAAC,CAAC;;WAEH,EAAE4C,IAAI;0CACyB,EAAE9J,gBAAgBgD,gBAAgB;yCACnC,EAAE6C,QAAQ,CAAC,wBAAwB,EAAEiE,IAAI,kEAAkE,CAAC,GAAG,IAAI;AAC5J;AAEA,SAAS5D,sBAAsB,EAC7BvB,KAAK,EACLvB,gBAAgB,EAIjB;IACC,IAAIA,kBAAkB,OAAO;IAC7B,IAAI,CAACuB,OAAO,OAAO;IACnB;AACF"}
|
|
@@ -56,7 +56,8 @@ function startWorkbench(options) {
|
|
|
56
56
|
output
|
|
57
57
|
}),
|
|
58
58
|
cliConfig,
|
|
59
|
-
extractManifest: isApp ? ({ workDir: wd })=>extractCoreAppManifest({
|
|
59
|
+
extractManifest: isApp ? ({ iconUrl, workDir: wd })=>extractCoreAppManifest({
|
|
60
|
+
iconUrl,
|
|
60
61
|
silent: true,
|
|
61
62
|
workDir: wd
|
|
62
63
|
}) : (params)=>extractStudioManifest({
|