@sanity/cli 8.36.0 → 8.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/dataset/blueprintDeletion.js +65 -0
- package/dist/actions/dataset/blueprintDeletion.js.map +1 -0
- package/dist/actions/deploy/deployApp.js +20 -7
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployChecks.js +2 -1
- package/dist/actions/deploy/deployChecks.js.map +1 -1
- package/dist/actions/deploy/deployDashboardConfig.js +11 -5
- package/dist/actions/deploy/deployDashboardConfig.js.map +1 -1
- package/dist/actions/deploy/deployRunner.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +24 -7
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/deploy/resolveDeployTarget.js +2 -2
- package/dist/actions/deploy/resolveDeployTarget.js.map +1 -1
- package/dist/actions/doctor/checks/cliInstallation.js +21 -6
- package/dist/actions/doctor/checks/cliInstallation.js.map +1 -1
- package/dist/actions/doctor/types.js.map +1 -1
- package/dist/actions/init/initAction.js +1 -0
- package/dist/actions/init/initAction.js.map +1 -1
- package/dist/actions/init/types.js.map +1 -1
- package/dist/actions/targets/resolveCommandTarget.js +133 -0
- package/dist/actions/targets/resolveCommandTarget.js.map +1 -0
- package/dist/actions/targets/resolveProjectForCommand.js +28 -0
- package/dist/actions/targets/resolveProjectForCommand.js.map +1 -0
- package/dist/actions/telemetry/resolveConsent.js +5 -5
- package/dist/actions/telemetry/resolveConsent.js.map +1 -1
- package/dist/actions/telemetry/setConsent.js +1 -1
- package/dist/actions/telemetry/setConsent.js.map +1 -1
- package/dist/actions/undeploy/runUndeploy.js +19 -3
- package/dist/actions/undeploy/runUndeploy.js.map +1 -1
- package/dist/commands/build.js +8 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/datasets/create.js +33 -20
- package/dist/commands/datasets/create.js.map +1 -1
- package/dist/commands/datasets/delete.js +19 -12
- package/dist/commands/datasets/delete.js.map +1 -1
- package/dist/commands/datasets/list.js +9 -12
- package/dist/commands/datasets/list.js.map +1 -1
- package/dist/commands/doctor.js +4 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/documents/query.js +26 -11
- package/dist/commands/documents/query.js.map +1 -1
- package/dist/commands/init.js +15 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/prompts/promptForProject.js +9 -3
- package/dist/prompts/promptForProject.js.map +1 -1
- package/dist/services/blueprints.js +24 -0
- package/dist/services/blueprints.js.map +1 -0
- package/dist/services/telemetry.js +3 -3
- package/dist/services/telemetry.js.map +1 -1
- package/dist/util/checkoutBlueprint.js +38 -0
- package/dist/util/checkoutBlueprint.js.map +1 -0
- package/dist/util/sharedFlags.js +10 -0
- package/dist/util/sharedFlags.js.map +1 -1
- package/oclif.manifest.json +419 -385
- package/package.json +5 -5
- package/dist/actions/telemetry/isTrueish.js +0 -10
- package/dist/actions/telemetry/isTrueish.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployDashboardConfig.ts"],"sourcesContent":["import {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type DashboardConfig} from '@sanity/workbench-cli'\nimport {\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getOrganizationDashboard,\n getWorkbenchUrl,\n summarizeConfig,\n uploadDashboardConfig,\n} from '@sanity/workbench-cli/deploy'\n\nimport {runStep} from '../../util/checks.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED} from '../../util/errorMessages.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {checkBuild, checkPackageVersion, verifyOutputDir} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles} from './deploymentPlan.js'\nimport {type DeployPayload, runDeploy} from './deployRunner.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport function deployDashboardConfig(\n options: DeployAppOptions & {config: DashboardConfig},\n): Promise<void> {\n const {organizationId} = options.config\n const summary = summarizeConfig(options.config)\n\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n async run({cliConfig, flags, output, projectRoot, sourceDir}, reporter) {\n const workDir = projectRoot.directory\n const startedAt = Date.now()\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployDashboardConfig.ts"],"sourcesContent":["import {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type DashboardConfig} from '@sanity/workbench-cli'\nimport {\n fetchDeploySummaryDetails,\n fetchOrganizationSummary,\n formatDeploySummary,\n getOrganizationDashboard,\n getWorkbenchUrl,\n summarizeConfig,\n uploadDashboardConfig,\n} from '@sanity/workbench-cli/deploy'\n\nimport {runStep} from '../../util/checks.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED} from '../../util/errorMessages.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {checkBuild, checkPackageVersion, verifyOutputDir} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles} from './deploymentPlan.js'\nimport {type DeployPayload, runDeploy} from './deployRunner.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport function deployDashboardConfig(\n options: DeployAppOptions & {config: DashboardConfig},\n): Promise<void> {\n const {organizationId} = options.config\n const summary = summarizeConfig(options.config)\n\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n async run({cliConfig, flags, output, projectRoot, sourceDir}, reporter) {\n const workDir = projectRoot.directory\n const startedAt = Date.now()\n // The Dashboard URL is built on the org's host slug (`--json` included).\n const organization = fetchOrganizationSummary(organizationId)\n const summaryDetails = fetchDeploySummaryDetails(organizationId, organization)\n const version = await checkPackageVersion(reporter, {moduleName: 'sanity', workDir})\n reporter.report({message: `Organization: ${organizationId}`, status: 'pass'})\n\n if (flags.external) {\n reporter.report({\n message: EXTERNAL_APP_NOT_SUPPORTED,\n solution:\n 'Remove the --external flag — dashboard configurations deploy to Sanity hosting',\n status: 'fail',\n })\n }\n\n const lookup = await runStep(reporter, {\n debug: deployDebug,\n formatError: (err) =>\n `Looking up the organization's Dashboard failed: ${getErrorMessage(err)}`,\n name: 'dashboard lookup',\n work: async () => ({dashboard: await getOrganizationDashboard(organizationId)}),\n })\n\n if (!lookup) return\n\n const {dashboard} = lookup\n const action = dashboard ? 'update' : 'create'\n const url = getWorkbenchUrl(organizationId, (await organization).hostSlug)\n reporter.report({\n message: dashboard\n ? 'Updates the dashboard configuration'\n : 'Creates the dashboard configuration',\n status: 'pass',\n target: {action, id: null, title: null, type: 'coreApp', url},\n })\n reporter.report({message: summary, status: 'pass'})\n\n const built = await checkBuild(reporter, {\n build: () =>\n buildApp({\n autoUpdatesEnabled: false,\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: 'Dashboard configuration built',\n })\n\n if (!built) {\n await verifyOutputDir({isWorkbenchApp: true, reporter, sourceDir})\n }\n\n const payload: DeployPayload = {\n appId: null,\n config: summary,\n isAutoUpdating: false,\n organizationId,\n type: 'coreApp',\n version,\n }\n\n if (flags['dry-run'] || !version) return {application: null, payload}\n\n await uploadDashboardConfig({dashboard, organizationId, sourceDir})\n const {organizationName, userName} = await summaryDetails\n output.log(\n formatDeploySummary({\n created: !dashboard,\n durationMs: Date.now() - startedAt,\n organizationId,\n organizationName,\n title: 'Dashboard configuration',\n type: 'config',\n url,\n userName,\n }),\n )\n\n return {action, application: null, deployedBy: userName, organizationName, payload, url}\n },\n type: 'coreApp',\n })\n}\n"],"names":["getErrorMessage","fetchDeploySummaryDetails","fetchOrganizationSummary","formatDeploySummary","getOrganizationDashboard","getWorkbenchUrl","summarizeConfig","uploadDashboardConfig","runStep","EXTERNAL_APP_NOT_SUPPORTED","buildApp","checkBuild","checkPackageVersion","verifyOutputDir","deployDebug","listDeploymentFiles","runDeploy","deployDashboardConfig","options","organizationId","config","summary","listFiles","projectRoot","sourceDir","directory","run","cliConfig","flags","output","reporter","workDir","startedAt","Date","now","organization","summaryDetails","version","moduleName","report","message","status","external","solution","lookup","debug","formatError","err","name","work","dashboard","action","url","hostSlug","target","id","title","type","built","build","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","undefined","successMessage","isWorkbenchApp","payload","appId","isAutoUpdating","application","organizationName","userName","log","created","durationMs","deployedBy"],"mappings":"AAAA,SAAQA,eAAe,QAAO,0BAAyB;AAEvD,SACEC,yBAAyB,EACzBC,wBAAwB,EACxBC,mBAAmB,EACnBC,wBAAwB,EACxBC,eAAe,EACfC,eAAe,EACfC,qBAAqB,QAChB,+BAA8B;AAErC,SAAQC,OAAO,QAAO,uBAAsB;AAC5C,SAAQC,0BAA0B,QAAO,8BAA6B;AACtE,SAAQC,QAAQ,QAAO,uBAAsB;AAC7C,SAAQC,UAAU,EAAEC,mBAAmB,EAAEC,eAAe,QAAO,oBAAmB;AAClF,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,mBAAmB,QAAO,sBAAqB;AACvD,SAA4BC,SAAS,QAAO,oBAAmB;AAG/D,OAAO,SAASC,sBACdC,OAAqD;IAErD,MAAM,EAACC,cAAc,EAAC,GAAGD,QAAQE,MAAM;IACvC,MAAMC,UAAUf,gBAAgBY,QAAQE,MAAM;IAE9C,OAAOJ,UAAUE,SAAS;QACxBI,WAAW,CAAC,EAACC,WAAW,EAAEC,SAAS,EAAC,GAAKT,oBAAoBS,WAAWD,YAAYE,SAAS;QAC7F,MAAMC,KAAI,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEN,WAAW,EAAEC,SAAS,EAAC,EAAEM,QAAQ;YACpE,MAAMC,UAAUR,YAAYE,SAAS;YACrC,MAAMO,YAAYC,KAAKC,GAAG;YAC1B,yEAAyE;YACzE,MAAMC,eAAejC,yBAAyBiB;YAC9C,MAAMiB,iBAAiBnC,0BAA0BkB,gBAAgBgB;YACjE,MAAME,U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gBACPhD,QAAQC;gBACRgD,gBAAgB;gBAChBlD;gBACAsC,MAAM;gBACNpB;YACF;YAEA,IAAIT,KAAK,CAAC,UAAU,IAAI,CAACS,SAAS,OAAO;gBAACiC,aAAa;gBAAMH;YAAO;YAEpE,MAAM5D,sBAAsB;gBAAC2C;gBAAW/B;gBAAgBK;YAAS;YACjE,MAAM,EAAC+C,gBAAgB,EAAEC,QAAQ,EAAC,GAAG,MAAMpC;YAC3CP,OAAO4C,GAAG,CACRtE,oBAAoB;gBAClBuE,SAAS,CAACxB;gBACVyB,YAAY1C,KAAKC,GAAG,KAAKF;gBACzBb;gBACAoD;gBACAf,OAAO;gBACPC,MAAM;gBACNL;gBACAoB;YACF;YAGF,OAAO;gBAACrB;gBAAQmB,aAAa;gBAAMM,YAAYJ;gBAAUD;gBAAkBJ;gBAASf;YAAG;QACzF;QACAK,MAAM;IACR;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployRunner.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output} from '@sanity/cli-core'\nimport {JsonOutputError} from '@sanity/cli-core/errors'\nimport {type WorkbenchDeployPayload} from '@sanity/workbench-cli/deploy'\n\nimport {createCollectingReporter, createFailFastReporter} from '../../util/checks.js'\nimport {toStderrOutput} from '../../util/toStderrOutput.js'\nimport {type DeployCheck, type DeployCheckReporter, type DeployTarget} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {\n type DeploymentFile,\n type DeploymentPlan,\n deploymentPlanToJson,\n isDeployable,\n renderDeploymentPlan,\n} from './deploymentPlan.js'\nimport {getDeployErrorMessage} from './serviceUnavailable.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport interface DeployResult {\n application: object | null\n payload: DeployPayload\n\n action?: DeployTarget['action']\n /** Resolved server-side, so it stays out of the local payload. */\n installationId?: string\n url?: string | null\n}\n\n/** Collected locally, so a dry run reports it too. */\nexport interface DeployPayload extends Partial<WorkbenchDeployPayload> {\n /** The configured `deployment.appId`; `null` when the deploy would mint one. */\n appId: string | null\n isAutoUpdating: boolean\n type: 'coreApp' | 'studio'\n version: string | null\n\n /**\n * The aspect-document sync a media-library config deploy will run: every\n * config field is upserted, stored definitions without a matching config\n * field are deleted (the config mirrors into the library). Collected during\n * planning, so a `--dry-run --json` consumer sees the deletions too.\n */\n aspectSync?: {\n deleteIds: string[]\n mediaLibraryId: string\n upsertIds: string[]\n }\n organizationId?: string\n projectId?: string\n}\n\n/**\n * The parts of a deploy that differ between core apps and studios. The shared\n * sequence — mode selection, error handling, the dry-run plan, `--json` — lives\n * in `runDeploy`.\n */\nexport interface DeploySpec {\n /** Files a real deploy would upload, listed only for the dry-run plan. */\n listFiles: (options: DeployAppOptions) => Promise<DeploymentFile[]>\n /** The step sequence; every step reports through `reporter`. */\n run: (options: DeployAppOptions, reporter: DeployCheckReporter) => Promise<DeployResult | void>\n type: 'coreApp' | 'studio'\n}\n\n/**\n * Runs a deploy in the mode the flags select: a real deploy fails fast and\n * mutates, `--dry-run` drives the same `run` sequence read-only and renders a\n * plan, and `--json` emits the same information as machine-readable JSON.\n */\nexport async function runDeploy(options: DeployAppOptions, spec: DeploySpec): Promise<void> {\n const {output} = options\n const json = !!options.flags.json\n const emitJson = (payload: unknown) => output.logJson(payload)\n let failurePayload: unknown\n\n // The JSON payload owns stdout, so the run's progress logs go to stderr; only\n // the final JSON.stringify writes to stdout.\n const runOptions = json ? {...options, output: toStderrOutput(output)} : options\n\n try {\n if (options.flags['dry-run']) {\n const plan = await collectPlan(runOptions, spec)\n if (json) {\n const payload = deploymentPlanToJson(plan)\n if (isDeployable(plan)) emitJson(payload)\n else failurePayload = payload\n } else renderDeploymentPlan(plan, output)\n exitIfBlocked(plan, output)\n return\n }\n\n const result = await spec.run(runOptions, createFailFastReporter(runOptions.output))\n if (json && result) emitJson({deployed: true, reason: null, ...result})\n } catch (error) {\n const failure = normalizeFailure(error, spec.type)\n // Preserve the blocked plan or the existing deployment failure envelope.\n if (json && !options.flags['dry-run']) {\n failurePayload = {\n application: null,\n deployed: false,\n error: {message: failure.message},\n payload: null,\n reason: failure.message,\n }\n }\n if (json && failurePayload !== undefined) {\n throw new JsonOutputError(failure.message, failurePayload, failure.exit)\n }\n output.error(failure.message, {exit: failure.exit})\n }\n}\n\n/** Runs the step sequence read-only and gathers the plan a dry run reports. */\nasync function collectPlan(options: DeployAppOptions, spec: DeploySpec): Promise<DeploymentPlan> {\n const reporter = createCollectingReporter<DeployCheck>()\n const result = await spec.run(options, reporter)\n const plan: DeploymentPlan = {\n checks: reporter.results,\n files: [],\n payload: result?.payload ?? null,\n target:\n reporter.results.find((check) => check.target && check.status !== 'fail')?.target ?? null,\n type: spec.type,\n }\n // A blocked deploy uploads nothing, so only enumerate files for a deployable plan.\n if (isDeployable(plan)) plan.files = await spec.listFiles(options)\n return plan\n}\n\n/** Exits like a real (fail-fast) deploy would, on the first failing check's exit code. */\nfunction exitIfBlocked(plan: DeploymentPlan, output: Output): void {\n if (isDeployable(plan)) return\n const failed = plan.checks.find((check) => check.status === 'fail')\n output.error('Deploy blocked by failing checks.', {exit: failed?.exitCode ?? 1})\n}\n\n/** The one failure diagnosis both the stderr message and the `--json` envelope read. */\nfunction normalizeFailure(\n error: unknown,\n type: 'coreApp' | 'studio',\n): {exit: number; message: string} {\n // Ctrl+C on an interactive prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n return {exit: exitCodes.RUNTIME_ERROR, message: 'Deployment cancelled by user'}\n }\n // A failed check already carries its own message and exit code\n if (error instanceof CLIError) {\n return {exit: error.oclif?.exit ?? 1, message: error.message}\n }\n deployDebug(`Error deploying ${type === 'coreApp' ? 'application' : 'studio'}`, error)\n return {\n exit: exitCodes.RUNTIME_ERROR,\n message: `Error deploying ${type === 'coreApp' ? 'application' : 'studio'}: ${getDeployErrorMessage(error)}`,\n }\n}\n"],"names":["CLIError","exitCodes","JsonOutputError","createCollectingReporter","createFailFastReporter","toStderrOutput","deployDebug","deploymentPlanToJson","isDeployable","renderDeploymentPlan","getDeployErrorMessage","runDeploy","options","spec","output","json","flags","emitJson","payload","logJson","failurePayload","runOptions","plan","collectPlan","exitIfBlocked","result","run","deployed","reason","error","failure","normalizeFailure","type","application","message","undefined","exit","reporter","checks","results","files","target","find","check","status","listFiles","failed","exitCode","Error","name","RUNTIME_ERROR","oclif"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,QAAoB,mBAAkB;AACvD,SAAQC,eAAe,QAAO,0BAAyB;AAGvD,SAAQC,wBAAwB,EAAEC,sBAAsB,QAAO,uBAAsB;AACrF,SAAQC,cAAc,QAAO,+BAA8B;AAE3D,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAGEC,oBAAoB,EACpBC,YAAY,EACZC,oBAAoB,QACf,sBAAqB;AAC5B,SAAQC,qBAAqB,QAAO,0BAAyB;
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployRunner.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output} from '@sanity/cli-core'\nimport {JsonOutputError} from '@sanity/cli-core/errors'\nimport {type WorkbenchDeployPayload} from '@sanity/workbench-cli/deploy'\n\nimport {createCollectingReporter, createFailFastReporter} from '../../util/checks.js'\nimport {toStderrOutput} from '../../util/toStderrOutput.js'\nimport {type DeployCheck, type DeployCheckReporter, type DeployTarget} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {\n type DeploymentFile,\n type DeploymentPlan,\n deploymentPlanToJson,\n isDeployable,\n renderDeploymentPlan,\n} from './deploymentPlan.js'\nimport {getDeployErrorMessage} from './serviceUnavailable.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport interface DeployResult {\n application: object | null\n payload: DeployPayload\n\n action?: DeployTarget['action']\n deployedBy?: string | null\n /** Resolved server-side, so it stays out of the local payload. */\n installationId?: string\n organizationName?: string | null\n url?: string | null\n}\n\n/** Collected locally, so a dry run reports it too. */\nexport interface DeployPayload extends Partial<WorkbenchDeployPayload> {\n /** The configured `deployment.appId`; `null` when the deploy would mint one. */\n appId: string | null\n isAutoUpdating: boolean\n type: 'coreApp' | 'studio'\n version: string | null\n\n /**\n * The aspect-document sync a media-library config deploy will run: every\n * config field is upserted, stored definitions without a matching config\n * field are deleted (the config mirrors into the library). Collected during\n * planning, so a `--dry-run --json` consumer sees the deletions too.\n */\n aspectSync?: {\n deleteIds: string[]\n mediaLibraryId: string\n upsertIds: string[]\n }\n organizationId?: string\n projectId?: string\n}\n\n/**\n * The parts of a deploy that differ between core apps and studios. The shared\n * sequence — mode selection, error handling, the dry-run plan, `--json` — lives\n * in `runDeploy`.\n */\nexport interface DeploySpec {\n /** Files a real deploy would upload, listed only for the dry-run plan. */\n listFiles: (options: DeployAppOptions) => Promise<DeploymentFile[]>\n /** The step sequence; every step reports through `reporter`. */\n run: (options: DeployAppOptions, reporter: DeployCheckReporter) => Promise<DeployResult | void>\n type: 'coreApp' | 'studio'\n}\n\n/**\n * Runs a deploy in the mode the flags select: a real deploy fails fast and\n * mutates, `--dry-run` drives the same `run` sequence read-only and renders a\n * plan, and `--json` emits the same information as machine-readable JSON.\n */\nexport async function runDeploy(options: DeployAppOptions, spec: DeploySpec): Promise<void> {\n const {output} = options\n const json = !!options.flags.json\n const emitJson = (payload: unknown) => output.logJson(payload)\n let failurePayload: unknown\n\n // The JSON payload owns stdout, so the run's progress logs go to stderr; only\n // the final JSON.stringify writes to stdout.\n const runOptions = json ? {...options, output: toStderrOutput(output)} : options\n\n try {\n if (options.flags['dry-run']) {\n const plan = await collectPlan(runOptions, spec)\n if (json) {\n const payload = deploymentPlanToJson(plan)\n if (isDeployable(plan)) emitJson(payload)\n else failurePayload = payload\n } else renderDeploymentPlan(plan, output)\n exitIfBlocked(plan, output)\n return\n }\n\n const result = await spec.run(runOptions, createFailFastReporter(runOptions.output))\n if (json && result) emitJson({deployed: true, reason: null, ...result})\n } catch (error) {\n const failure = normalizeFailure(error, spec.type)\n // Preserve the blocked plan or the existing deployment failure envelope.\n if (json && !options.flags['dry-run']) {\n failurePayload = {\n application: null,\n deployed: false,\n error: {message: failure.message},\n payload: null,\n reason: failure.message,\n }\n }\n if (json && failurePayload !== undefined) {\n throw new JsonOutputError(failure.message, failurePayload, failure.exit)\n }\n output.error(failure.message, {exit: failure.exit})\n }\n}\n\n/** Runs the step sequence read-only and gathers the plan a dry run reports. */\nasync function collectPlan(options: DeployAppOptions, spec: DeploySpec): Promise<DeploymentPlan> {\n const reporter = createCollectingReporter<DeployCheck>()\n const result = await spec.run(options, reporter)\n const plan: DeploymentPlan = {\n checks: reporter.results,\n files: [],\n payload: result?.payload ?? null,\n target:\n reporter.results.find((check) => check.target && check.status !== 'fail')?.target ?? null,\n type: spec.type,\n }\n // A blocked deploy uploads nothing, so only enumerate files for a deployable plan.\n if (isDeployable(plan)) plan.files = await spec.listFiles(options)\n return plan\n}\n\n/** Exits like a real (fail-fast) deploy would, on the first failing check's exit code. */\nfunction exitIfBlocked(plan: DeploymentPlan, output: Output): void {\n if (isDeployable(plan)) return\n const failed = plan.checks.find((check) => check.status === 'fail')\n output.error('Deploy blocked by failing checks.', {exit: failed?.exitCode ?? 1})\n}\n\n/** The one failure diagnosis both the stderr message and the `--json` envelope read. */\nfunction normalizeFailure(\n error: unknown,\n type: 'coreApp' | 'studio',\n): {exit: number; message: string} {\n // Ctrl+C on an interactive prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n return {exit: exitCodes.RUNTIME_ERROR, message: 'Deployment cancelled by user'}\n }\n // A failed check already carries its own message and exit code\n if (error instanceof CLIError) {\n return {exit: error.oclif?.exit ?? 1, message: error.message}\n }\n deployDebug(`Error deploying ${type === 'coreApp' ? 'application' : 'studio'}`, error)\n return {\n exit: exitCodes.RUNTIME_ERROR,\n message: `Error deploying ${type === 'coreApp' ? 'application' : 'studio'}: ${getDeployErrorMessage(error)}`,\n }\n}\n"],"names":["CLIError","exitCodes","JsonOutputError","createCollectingReporter","createFailFastReporter","toStderrOutput","deployDebug","deploymentPlanToJson","isDeployable","renderDeploymentPlan","getDeployErrorMessage","runDeploy","options","spec","output","json","flags","emitJson","payload","logJson","failurePayload","runOptions","plan","collectPlan","exitIfBlocked","result","run","deployed","reason","error","failure","normalizeFailure","type","application","message","undefined","exit","reporter","checks","results","files","target","find","check","status","listFiles","failed","exitCode","Error","name","RUNTIME_ERROR","oclif"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,QAAoB,mBAAkB;AACvD,SAAQC,eAAe,QAAO,0BAAyB;AAGvD,SAAQC,wBAAwB,EAAEC,sBAAsB,QAAO,uBAAsB;AACrF,SAAQC,cAAc,QAAO,+BAA8B;AAE3D,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAGEC,oBAAoB,EACpBC,YAAY,EACZC,oBAAoB,QACf,sBAAqB;AAC5B,SAAQC,qBAAqB,QAAO,0BAAyB;AAmD7D;;;;CAIC,GACD,OAAO,eAAeC,UAAUC,OAAyB,EAAEC,IAAgB;IACzE,MAAM,EAACC,MAAM,EAAC,GAAGF;IACjB,MAAMG,OAAO,CAAC,CAACH,QAAQI,KAAK,CAACD,IAAI;IACjC,MAAME,WAAW,CAACC,UAAqBJ,OAAOK,OAAO,CAACD;IACtD,IAAIE;IAEJ,8EAA8E;IAC9E,6CAA6C;IAC7C,MAAMC,aAAaN,OAAO;QAAC,GAAGH,OAAO;QAAEE,QAAQT,eAAeS;IAAO,IAAIF;IAEzE,IAAI;QACF,IAAIA,QAAQI,KAAK,CAAC,UAAU,EAAE;YAC5B,MAAMM,OAAO,MAAMC,YAAYF,YAAYR;YAC3C,IAAIE,MAAM;gBACR,MAAMG,UAAUX,qBAAqBe;gBACrC,IAAId,aAAac,OAAOL,SAASC;qBAC5BE,iBAAiBF;YACxB,OAAOT,qBAAqBa,MAAMR;YAClCU,cAAcF,MAAMR;YACpB;QACF;QAEA,MAAMW,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SAASxB,KAAKgB,MAAM,CAACI,IAAI,CAAC,CAACC,QAAUA,MAAMC,MAAM,KAAK;IAC5D9B,OAAOe,KAAK,CAAC,qCAAqC;QAACO,MAAMU,QAAQC,YAAY;IAAC;AAChF;AAEA,sFAAsF,GACtF,SAAShB,iBACPF,KAAc,EACdG,IAA0B;IAE1B,uDAAuD;IACvD,IAAIH,iBAAiBmB,SAASnB,MAAMoB,IAAI,KAAK,mBAAmB;QAC9D,OAAO;YAACb,MAAMnC,UAAUiD,aAAa;YAAEhB,SAAS;QAA8B;IAChF;IACA,+DAA+D;IAC/D,IAAIL,iBAAiB7B,UAAU;QAC7B,OAAO;YAACoC,MAAMP,MAAMsB,KAAK,EAAEf,QAAQ;YAAGF,SAASL,MAAMK,OAAO;QAAA;IAC9D;IACA5B,YAAY,CAAC,gBAAgB,EAAE0B,SAAS,YAAY,gBAAgB,UAAU,EAAEH;IAChF,OAAO;QACLO,MAAMnC,UAAUiD,aAAa;QAC7BhB,SAAS,CAAC,gBAAgB,EAAEF,SAAS,YAAY,gBAAgB,SAAS,EAAE,EAAEtB,sBAAsBmB,QAAQ;IAC9G;AACF"}
|
|
@@ -4,7 +4,7 @@ import { createGzip } from 'node:zlib';
|
|
|
4
4
|
import { formatSchemaValidation, SchemaExtractionError } from '@sanity/cli-build/_internal/extract';
|
|
5
5
|
import { exitCodes } from '@sanity/cli-core';
|
|
6
6
|
import { spinner } from '@sanity/cli-core/ux';
|
|
7
|
-
import { createStudio, deployWorkbenchApp, fetchDeploySummaryDetails, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, selectWorkbenchAppId, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
7
|
+
import { createStudio, deployWorkbenchApp, fetchDeploySummaryDetails, fetchOrganizationSummary, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, selectWorkbenchAppId, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
8
8
|
import { c as createTar } from 'tar';
|
|
9
9
|
import { createDeployment } from '../../services/userApplications.js';
|
|
10
10
|
import { getAppId } from '../../util/appId.js';
|
|
@@ -67,6 +67,10 @@ export function deployStudio(options) {
|
|
|
67
67
|
let workbenchApp;
|
|
68
68
|
let externalUrl;
|
|
69
69
|
let targetAppId = appId;
|
|
70
|
+
// Every Dashboard URL below is built on the org's host slug (`--json` included); the
|
|
71
|
+
// deployer lookup overlaps the build.
|
|
72
|
+
const organization = workbench && organizationId ? fetchOrganizationSummary(organizationId) : undefined;
|
|
73
|
+
const summaryDetails = organization && organizationId ? fetchDeploySummaryDetails(organizationId, organization) : undefined;
|
|
70
74
|
if (workbench) {
|
|
71
75
|
reporter.report(organizationId ? {
|
|
72
76
|
message: `Organization: ${organizationId}`,
|
|
@@ -84,6 +88,7 @@ export function deployStudio(options) {
|
|
|
84
88
|
});
|
|
85
89
|
workbenchApp = (await checkStudioTarget(reporter, {
|
|
86
90
|
appId: targetAppId,
|
|
91
|
+
hostSlug: (await organization)?.hostSlug,
|
|
87
92
|
isWorkbenchApp: true,
|
|
88
93
|
organizationId,
|
|
89
94
|
slug: workbench.slug,
|
|
@@ -115,7 +120,6 @@ export function deployStudio(options) {
|
|
|
115
120
|
// Read up front so a bad icon path fails before we create or build.
|
|
116
121
|
const appIcon = !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined;
|
|
117
122
|
const startedAt = Date.now();
|
|
118
|
-
const summaryDetails = workbench && organizationId && !flags.json ? fetchDeploySummaryDetails(organizationId) : undefined;
|
|
119
123
|
// Create the studio before the build so the bundle carries its real id. A
|
|
120
124
|
// redeploy already has it from `deployment.appId`; a dry run skips creation.
|
|
121
125
|
let applicationId = targetAppId;
|
|
@@ -221,26 +225,30 @@ export function deployStudio(options) {
|
|
|
221
225
|
workDir,
|
|
222
226
|
workspaces: toWorkspaces(studioManifest)
|
|
223
227
|
});
|
|
228
|
+
const hostSlug = (await organization)?.hostSlug;
|
|
224
229
|
const url = getApplicationUrl({
|
|
225
230
|
id: applicationId,
|
|
226
231
|
organizationId,
|
|
227
232
|
slug: workbench.slug,
|
|
228
233
|
type: 'studio'
|
|
229
|
-
});
|
|
234
|
+
}, hostSlug);
|
|
230
235
|
const durationMs = Date.now() - startedAt;
|
|
236
|
+
const { organizationName = null, userName = null } = await summaryDetails ?? {};
|
|
231
237
|
output.log(formatDeploySummary({
|
|
232
|
-
...await summaryDetails,
|
|
233
238
|
applicationId,
|
|
234
239
|
created: applicationCreated,
|
|
235
240
|
durationMs,
|
|
236
241
|
organizationId,
|
|
242
|
+
organizationName,
|
|
237
243
|
showAppIdHint: !appId,
|
|
238
244
|
title: appTitle,
|
|
239
245
|
type: 'studio',
|
|
240
|
-
url
|
|
246
|
+
url,
|
|
247
|
+
userName
|
|
241
248
|
}));
|
|
242
249
|
if (isExternallyHosted) logExternalHost({
|
|
243
250
|
built: flags.build,
|
|
251
|
+
hostSlug,
|
|
244
252
|
organizationId,
|
|
245
253
|
output,
|
|
246
254
|
sourceDir
|
|
@@ -248,6 +256,8 @@ export function deployStudio(options) {
|
|
|
248
256
|
return {
|
|
249
257
|
action: applicationCreated ? 'create' : 'update',
|
|
250
258
|
application: workbenchApp ?? null,
|
|
259
|
+
deployedBy: userName,
|
|
260
|
+
organizationName,
|
|
251
261
|
payload,
|
|
252
262
|
url
|
|
253
263
|
};
|
|
@@ -433,12 +443,19 @@ function toWorkspaces(manifest) {
|
|
|
433
443
|
title: workspace.title
|
|
434
444
|
}));
|
|
435
445
|
}
|
|
436
|
-
/** Tells the customer what their host must do for the Dashboard to load the studio from it. */ function logExternalHost({ built, organizationId, output, sourceDir }) {
|
|
446
|
+
/** Tells the customer what their host must do for the Dashboard to load the studio from it. */ function logExternalHost({ built, hostSlug, organizationId, output, sourceDir }) {
|
|
437
447
|
const dir = `${relative(process.cwd(), sourceDir) || '.'}/`;
|
|
448
|
+
// The Dashboard is served on both the org ID host and the slug host, so the studio's host must allow both.
|
|
449
|
+
const origins = [
|
|
450
|
+
getWorkbenchUrl(organizationId),
|
|
451
|
+
getWorkbenchUrl(organizationId, hostSlug)
|
|
452
|
+
];
|
|
438
453
|
output.log(`
|
|
439
454
|
The Dashboard loads this studio from your host, which must:
|
|
440
455
|
1. Serve ${dir} unchanged at the root of its URL (/mf-manifest.json, /remoteEntry-*.js, /static/*)
|
|
441
|
-
2. Send Access-Control-Allow-Origin for ${
|
|
456
|
+
2. Send Access-Control-Allow-Origin for ${[
|
|
457
|
+
...new Set(origins)
|
|
458
|
+
].join(' and ')}
|
|
442
459
|
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.` : ''}`);
|
|
443
460
|
}
|
|
444
461
|
function studioBuildSkipReason({ build, isLegacyExternal }) {
|
|
@@ -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 {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 ? flags.title?.trim() || workbench.title : ''\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 | null} | 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 workDir,\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 organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n type: 'studio',\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","isAutoUpdating","version","moduleName","report","message","status","solution","kind","projectRootDir","application","studioCreated","workbenchApp","externalUrl","targetAppId","slug","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,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAGEC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,WAAW,EACXC,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;AAClF,SAAQ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+
{"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 fetchOrganizationSummary,\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 ? flags.title?.trim() || workbench.title : ''\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 | null} | undefined\n let externalUrl: string | undefined\n let targetAppId = appId\n // Every Dashboard URL below is built on the org's host slug (`--json` included); the\n // deployer lookup overlaps the build.\n const organization =\n workbench && organizationId ? fetchOrganizationSummary(organizationId) : undefined\n const summaryDetails =\n organization && organizationId\n ? fetchDeploySummaryDetails(organizationId, organization)\n : undefined\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 hostSlug: (await organization)?.hostSlug,\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\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 workDir,\n workspaces: toWorkspaces(studioManifest),\n })\n const hostSlug = (await organization)?.hostSlug\n const url = getApplicationUrl(\n {id: applicationId, organizationId, slug: workbench.slug, type: 'studio'},\n hostSlug,\n )\n const durationMs = Date.now() - startedAt\n const {organizationName = null, userName = null} = (await summaryDetails) ?? {}\n output.log(\n formatDeploySummary({\n applicationId,\n created: applicationCreated,\n durationMs,\n organizationId,\n organizationName,\n showAppIdHint: !appId,\n title: appTitle,\n type: 'studio',\n url,\n userName,\n }),\n )\n if (isExternallyHosted)\n logExternalHost({\n built: flags.build,\n hostSlug,\n organizationId,\n output,\n sourceDir,\n })\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n deployedBy: userName,\n organizationName,\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 hostSlug,\n organizationId,\n output,\n sourceDir,\n}: {\n built: boolean\n hostSlug?: string | null\n organizationId: string\n output: DeployAppOptions['output']\n sourceDir: string\n}): void {\n const dir = `${relative(process.cwd(), sourceDir) || '.'}/`\n // The Dashboard is served on both the org ID host and the slug host, so the studio's host must allow both.\n const origins = [getWorkbenchUrl(organizationId), getWorkbenchUrl(organizationId, hostSlug)]\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 ${[...new Set(origins)].join(' and ')}\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","fetchOrganizationSummary","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","isAutoUpdating","version","moduleName","report","message","status","solution","kind","projectRootDir","application","studioCreated","workbenchApp","externalUrl","targetAppId","organization","undefined","summaryDetails","hostSlug","slug","url","created","resolveStudioApplication","isExternallyHosted","build","exitCode","USAGE_ERROR","appIcon","icon","startedAt","Date","now","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","organizationName","userName","log","showAppIdHint","logExternalHost","action","deployedBy","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","origins","join"],"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,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAGEC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,wBAAwB,EACxBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,WAAW,EACXC,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;AAClF,SAAQC,+BAA+B,QAAO,uCAAsC;AACpF,SAAQC,4BAA4B,QAAO,2BAA0B;AAGrE,MAAMC,iB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OAAO4E,GAAG,CAAC,CAAC;;WAEH,EAAE6C,IAAI;0CACyB,EAAE;WAAI,IAAIV,IAAIY;KAAS,CAACC,IAAI,CAAC,SAAS;yCACvC,EAAEvE,QAAQ,CAAC,wBAAwB,EAAEoE,IAAI,kEAAkE,CAAC,GAAG,IAAI;AAC5J;AAEA,SAAS/D,sBAAsB,EAC7BpB,KAAK,EACL3B,gBAAgB,EAIjB;IACC,IAAIA,kBAAkB,OAAO;IAC7B,IAAI,CAAC2B,OAAO,OAAO;IACnB;AACF"}
|
|
@@ -149,8 +149,8 @@ import { normalizeUrl, validateUrl } from './urlUtils.js';
|
|
|
149
149
|
* can name its id instead of a create that would fail.
|
|
150
150
|
*
|
|
151
151
|
* @internal
|
|
152
|
-
*/ export async function resolveWorkbenchApp({ appId, hasAppView = true, organizationId, slug }) {
|
|
153
|
-
const getUrl = (application)=>hasAppView ? getApplicationUrl(application) : getWorkbenchUrl(application.organizationId);
|
|
152
|
+
*/ export async function resolveWorkbenchApp({ appId, hasAppView = true, hostSlug, organizationId, slug }) {
|
|
153
|
+
const getUrl = (application)=>hasAppView ? getApplicationUrl(application, hostSlug) : getWorkbenchUrl(application.organizationId, hostSlug);
|
|
154
154
|
if (appId) return resolveAppById(appId, getUrl);
|
|
155
155
|
if (organizationId && slug) {
|
|
156
156
|
const existing = (await listApplications(organizationId)).find((app)=>app.slug === slug);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/resolveDeployTarget.ts"],"sourcesContent":["import {\n type Application,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '@sanity/workbench-cli/deploy'\n\nimport {\n getUserApplication,\n getUserApplications,\n type UserApplication,\n type UserApplicationResolved,\n} from '../../services/userApplications.js'\nimport {APP_ID_NOT_FOUND_IN_ORGANIZATION} from '../../util/errorMessages.js'\nimport {normalizeUrl, validateUrl} from './urlUtils.js'\n\n/** The application fields a deploy-target verdict carries for reporting. */\nexport interface DeployTargetApp {\n id: string\n title: string | null\n type: 'coreApp' | 'studio'\n\n appHost?: string\n url?: string\n}\n\n/** A coreApp verdict also carries the organization, for the dashboard URL. */\ninterface DeployTargetCoreApp extends DeployTargetApp {\n organizationId: string\n}\n\n/**\n * The read-only outcome of resolving where a deploy would go.\n *\n * - `found` — the deploy targets this existing application\n * - `would-create` — nothing registered yet; a deploy would create it without prompting\n * - `needs-input` — config doesn't determine a target; a deploy would prompt\n * (`existing` lists the applications a prompt would offer)\n * - `invalid` — the configured target can never resolve (bad host, unknown appId)\n * - `blocked` — resolution requires config that's missing (projectId/organizationId)\n *\n * Transport errors (network, permissions) throw — they're not verdicts.\n *\n * The user-applications resolvers carry the full {@link UserApplication} (the\n * real deploy needs it); the workbench resolvers and the report only need\n * {@link DeployTargetApp}, so `App` defaults to that widened shape.\n */\ntype CommonDeployTargetResolution<App = DeployTargetApp> =\n | {application: App; type: 'found'}\n | {existing: App[]; type: 'needs-input'}\n | {message: string; reason: 'app-not-found' | 'invalid-host'; type: 'invalid'}\n | {message: string; type: 'blocked'}\n\nexport type StudioDeployTargetResolution<App = DeployTargetApp> =\n | CommonDeployTargetResolution<App>\n | {appHost: string; existing: App; type: 'slug-taken'}\n | {appHost: string; type: 'would-create'}\n\nexport type AppDeployTargetResolution<App = DeployTargetCoreApp> =\n | CommonDeployTargetResolution<App>\n | {appHost: string; existing: App; type: 'slug-taken'}\n | {appHost?: string; type: 'would-create'}\n\n/**\n * Owns the studio deploy-target rules: the --url flag over studioHost config,\n * appId over appHost precedence, external URL normalization and validation.\n * Both the real deploy and the dry run consume these verdicts.\n *\n * @internal\n */\nexport async function resolveStudioDeployTarget(options: {\n appId: string | undefined\n isExternal: boolean\n projectId: string | undefined\n studioHost: string | undefined\n urlFlag: string | undefined\n}): Promise<StudioDeployTargetResolution<UserApplication>> {\n const {appId, isExternal, projectId, studioHost, urlFlag} = options\n\n // appId wins over host config (and undeploy resolves it the same way): a\n // configured appId deploys even when studioHost is stale or invalid, so it's\n // resolved before any host validation.\n if (appId) {\n if (!projectId) {\n return {message: 'api.projectId is missing', type: 'blocked'}\n }\n const application = await getUserApplication({appId, isSdkApp: false, projectId})\n if (application) {\n return {application, type: 'found'}\n }\n return {\n message: `Cannot find app with app ID ${appId}`,\n reason: 'app-not-found',\n type: 'invalid',\n }\n }\n\n const {error: hostError, host: resolvedHost} = resolveAppHost({\n isExternal,\n studioHost,\n url: urlFlag,\n })\n if (hostError) {\n return {message: hostError, reason: 'invalid-host', type: 'invalid'}\n }\n\n // A host from config hasn't passed through the --url validation yet\n let appHost = resolvedHost\n if (appHost && isExternal) {\n appHost = normalizeUrl(appHost)\n const validation = validateUrl(appHost)\n if (validation !== true) {\n return {message: validation, reason: 'invalid-host', type: 'invalid'}\n }\n }\n\n if (appHost) {\n if (!projectId) {\n return {message: 'api.projectId is missing', type: 'blocked'}\n }\n const application = await getUserApplication({appHost, isSdkApp: false, projectId})\n if (application) {\n return {application, type: 'found'}\n }\n return {appHost, type: 'would-create'}\n }\n\n // Neither appId nor host configured — a deploy would prompt.\n // Without a project there is nothing to list; a deploy would still prompt.\n const existing = projectId ? await listStudioApplications(projectId, isExternal) : []\n return {existing, type: 'needs-input'}\n}\n\n/**\n * Owns the app deploy-target rules: appId lookup, falling back to listing the\n * organization's applications. Both the real deploy and the dry run consume\n * these verdicts.\n *\n * @internal\n */\nexport async function resolveAppDeployTarget(options: {\n appId: string | undefined\n create?: boolean\n organizationId: string | undefined\n}): Promise<AppDeployTargetResolution<UserApplicationResolved>> {\n const {appId, create, organizationId} = options\n\n if (appId) {\n const application = await getUserApplication({appId, isSdkApp: true})\n if (application) {\n return {application, type: 'found'}\n }\n return {\n message: `Cannot find app with app ID ${appId}`,\n reason: 'app-not-found',\n type: 'invalid',\n }\n }\n\n if (!organizationId) {\n return {message: 'app.organizationId is missing', type: 'blocked'}\n }\n\n if (create) {\n return {type: 'would-create'}\n }\n\n const existing = await getUserApplications({appType: 'coreApp', organizationId})\n if (existing?.length) {\n return {existing, type: 'needs-input'}\n }\n\n return {type: 'would-create'}\n}\n\n/**\n * The dry-run counterpart to a workbench app's create-on-deploy: without an\n * `appId`, an org already holding the slug resolves to that app, so the report\n * can name its id instead of a create that would fail.\n *\n * @internal\n */\nexport async function resolveWorkbenchApp({\n appId,\n hasAppView = true,\n organizationId,\n slug,\n}: {\n appId: string | undefined\n hasAppView?: boolean\n organizationId?: string\n slug?: string\n}): Promise<AppDeployTargetResolution> {\n const getUrl = (application: Application) =>\n hasAppView ? getApplicationUrl(application) : getWorkbenchUrl(application.organizationId)\n\n if (appId) return resolveAppById(appId, getUrl)\n\n if (organizationId && slug) {\n const existing = (await listApplications(organizationId)).find((app) => app.slug === slug)\n if (existing) {\n return {\n appHost: slug,\n existing: {...existing, url: getUrl(existing)},\n type: 'slug-taken',\n }\n }\n }\n\n return {appHost: slug, type: 'would-create'}\n}\n\n/**\n * {@link resolveWorkbenchApp} narrowed for a studio, whose slug is always configured.\n *\n * @internal\n */\nexport async function resolveWorkbenchStudio(options: {\n appId: string | undefined\n organizationId?: string\n slug: string\n}): Promise<StudioDeployTargetResolution> {\n const resolution = await resolveWorkbenchApp(options)\n return resolution.type === 'would-create'\n ? {appHost: options.slug, type: 'would-create'}\n : resolution\n}\n\nasync function resolveAppById(\n appId: string,\n getUrl: (application: Application) => string,\n): Promise<CommonDeployTargetResolution<DeployTargetCoreApp>> {\n const application = await getApplication(appId)\n return application\n ? {\n application: {...application, url: getUrl(application)},\n type: 'found',\n }\n : {message: APP_ID_NOT_FOUND_IN_ORGANIZATION, reason: 'app-not-found', type: 'invalid'}\n}\n\nasync function listStudioApplications(\n projectId: string,\n isExternal: boolean,\n): Promise<UserApplication[]> {\n const urlType = isExternal ? 'external' : 'internal'\n const applications = await getUserApplications({appType: 'studio', projectId})\n // External deploys should only see external studios and vice versa\n return applications?.filter((application) => application.urlType === urlType) ?? []\n}\n\nfunction resolveAppHost({\n isExternal,\n studioHost,\n url,\n}: {\n isExternal: boolean\n studioHost: string | undefined\n url: string | undefined\n}): {error?: string; host?: string} {\n if (!url) {\n return {host: studioHost}\n }\n\n if (isExternal) {\n const normalized = normalizeUrl(url)\n const validation = validateUrl(normalized)\n if (validation !== true) {\n return {error: validation}\n }\n return {host: normalized}\n }\n\n // For internal deploys, strip protocol prefix and .sanity.studio suffix if present\n const hostname = url.replace(/^https?:\\/\\//i, '').replace(/\\.sanity\\.studio\\/?$/i, '')\n\n // If the result still looks like a URL (contains dots), the user likely meant --external\n if (hostname.includes('.')) {\n return {\n error: `\"${hostname}\" does not look like a sanity.studio hostname. Did you mean to use --external?`,\n }\n }\n\n // Validate hostname characters (alphanumeric and hyphens only)\n if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/i.test(hostname)) {\n return {\n error: `Invalid studio hostname \"${hostname}\". Hostnames can only contain letters, numbers, and hyphens.`,\n }\n }\n\n return {host: hostname}\n}\n"],"names":["getApplication","getApplicationUrl","getWorkbenchUrl","listApplications","getUserApplication","getUserApplications","APP_ID_NOT_FOUND_IN_ORGANIZATION","normalizeUrl","validateUrl","resolveStudioDeployTarget","options","appId","isExternal","projectId","studioHost","urlFlag","message","type","application","isSdkApp","reason","error","hostError","host","resolvedHost","resolveAppHost","url","appHost","validation","existing","listStudioApplications","resolveAppDeployTarget","create","organizationId","appType","length","resolveWorkbenchApp","hasAppView","slug","getUrl","resolveAppById","find","app","resolveWorkbenchStudio","resolution","urlType","applications","filter","normalized","hostname","replace","includes","test"],"mappings":"AAAA,SAEEA,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,+BAA8B;AAErC,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,qCAAoC;AAC3C,SAAQC,gCAAgC,QAAO,8BAA6B;AAC5E,SAAQC,YAAY,EAAEC,WAAW,QAAO,gBAAe;AAiDvD;;;;;;CAMC,GACD,OAAO,eAAeC,0BAA0BC,OAM/C;IACC,MAAM,EAACC,KAAK,EAAEC,UAAU,EAAEC,SAAS,EAAEC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AW;QACtD,OAAO;YACL5B,OAAO,CAAC,yBAAyB,EAAE4B,SAAS,4DAA4D,CAAC;QAC3G;IACF;IAEA,OAAO;QAAC1B,MAAM0B;IAAQ;AACxB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/resolveDeployTarget.ts"],"sourcesContent":["import {\n type Application,\n getApplication,\n getApplicationUrl,\n getWorkbenchUrl,\n listApplications,\n} from '@sanity/workbench-cli/deploy'\n\nimport {\n getUserApplication,\n getUserApplications,\n type UserApplication,\n type UserApplicationResolved,\n} from '../../services/userApplications.js'\nimport {APP_ID_NOT_FOUND_IN_ORGANIZATION} from '../../util/errorMessages.js'\nimport {normalizeUrl, validateUrl} from './urlUtils.js'\n\n/** The application fields a deploy-target verdict carries for reporting. */\nexport interface DeployTargetApp {\n id: string\n title: string | null\n type: 'coreApp' | 'studio'\n\n appHost?: string\n url?: string\n}\n\n/** A coreApp verdict also carries the organization, for the dashboard URL. */\ninterface DeployTargetCoreApp extends DeployTargetApp {\n organizationId: string\n}\n\n/**\n * The read-only outcome of resolving where a deploy would go.\n *\n * - `found` — the deploy targets this existing application\n * - `would-create` — nothing registered yet; a deploy would create it without prompting\n * - `needs-input` — config doesn't determine a target; a deploy would prompt\n * (`existing` lists the applications a prompt would offer)\n * - `invalid` — the configured target can never resolve (bad host, unknown appId)\n * - `blocked` — resolution requires config that's missing (projectId/organizationId)\n *\n * Transport errors (network, permissions) throw — they're not verdicts.\n *\n * The user-applications resolvers carry the full {@link UserApplication} (the\n * real deploy needs it); the workbench resolvers and the report only need\n * {@link DeployTargetApp}, so `App` defaults to that widened shape.\n */\ntype CommonDeployTargetResolution<App = DeployTargetApp> =\n | {application: App; type: 'found'}\n | {existing: App[]; type: 'needs-input'}\n | {message: string; reason: 'app-not-found' | 'invalid-host'; type: 'invalid'}\n | {message: string; type: 'blocked'}\n\nexport type StudioDeployTargetResolution<App = DeployTargetApp> =\n | CommonDeployTargetResolution<App>\n | {appHost: string; existing: App; type: 'slug-taken'}\n | {appHost: string; type: 'would-create'}\n\nexport type AppDeployTargetResolution<App = DeployTargetCoreApp> =\n | CommonDeployTargetResolution<App>\n | {appHost: string; existing: App; type: 'slug-taken'}\n | {appHost?: string; type: 'would-create'}\n\n/**\n * Owns the studio deploy-target rules: the --url flag over studioHost config,\n * appId over appHost precedence, external URL normalization and validation.\n * Both the real deploy and the dry run consume these verdicts.\n *\n * @internal\n */\nexport async function resolveStudioDeployTarget(options: {\n appId: string | undefined\n isExternal: boolean\n projectId: string | undefined\n studioHost: string | undefined\n urlFlag: string | undefined\n}): Promise<StudioDeployTargetResolution<UserApplication>> {\n const {appId, isExternal, projectId, studioHost, urlFlag} = options\n\n // appId wins over host config (and undeploy resolves it the same way): a\n // configured appId deploys even when studioHost is stale or invalid, so it's\n // resolved before any host validation.\n if (appId) {\n if (!projectId) {\n return {message: 'api.projectId is missing', type: 'blocked'}\n }\n const application = await getUserApplication({appId, isSdkApp: false, projectId})\n if (application) {\n return {application, type: 'found'}\n }\n return {\n message: `Cannot find app with app ID ${appId}`,\n reason: 'app-not-found',\n type: 'invalid',\n }\n }\n\n const {error: hostError, host: resolvedHost} = resolveAppHost({\n isExternal,\n studioHost,\n url: urlFlag,\n })\n if (hostError) {\n return {message: hostError, reason: 'invalid-host', type: 'invalid'}\n }\n\n // A host from config hasn't passed through the --url validation yet\n let appHost = resolvedHost\n if (appHost && isExternal) {\n appHost = normalizeUrl(appHost)\n const validation = validateUrl(appHost)\n if (validation !== true) {\n return {message: validation, reason: 'invalid-host', type: 'invalid'}\n }\n }\n\n if (appHost) {\n if (!projectId) {\n return {message: 'api.projectId is missing', type: 'blocked'}\n }\n const application = await getUserApplication({appHost, isSdkApp: false, projectId})\n if (application) {\n return {application, type: 'found'}\n }\n return {appHost, type: 'would-create'}\n }\n\n // Neither appId nor host configured — a deploy would prompt.\n // Without a project there is nothing to list; a deploy would still prompt.\n const existing = projectId ? await listStudioApplications(projectId, isExternal) : []\n return {existing, type: 'needs-input'}\n}\n\n/**\n * Owns the app deploy-target rules: appId lookup, falling back to listing the\n * organization's applications. Both the real deploy and the dry run consume\n * these verdicts.\n *\n * @internal\n */\nexport async function resolveAppDeployTarget(options: {\n appId: string | undefined\n create?: boolean\n organizationId: string | undefined\n}): Promise<AppDeployTargetResolution<UserApplicationResolved>> {\n const {appId, create, organizationId} = options\n\n if (appId) {\n const application = await getUserApplication({appId, isSdkApp: true})\n if (application) {\n return {application, type: 'found'}\n }\n return {\n message: `Cannot find app with app ID ${appId}`,\n reason: 'app-not-found',\n type: 'invalid',\n }\n }\n\n if (!organizationId) {\n return {message: 'app.organizationId is missing', type: 'blocked'}\n }\n\n if (create) {\n return {type: 'would-create'}\n }\n\n const existing = await getUserApplications({appType: 'coreApp', organizationId})\n if (existing?.length) {\n return {existing, type: 'needs-input'}\n }\n\n return {type: 'would-create'}\n}\n\n/**\n * The dry-run counterpart to a workbench app's create-on-deploy: without an\n * `appId`, an org already holding the slug resolves to that app, so the report\n * can name its id instead of a create that would fail.\n *\n * @internal\n */\nexport async function resolveWorkbenchApp({\n appId,\n hasAppView = true,\n hostSlug,\n organizationId,\n slug,\n}: {\n appId: string | undefined\n hasAppView?: boolean\n hostSlug?: string | null\n organizationId?: string\n slug?: string\n}): Promise<AppDeployTargetResolution> {\n const getUrl = (application: Application) =>\n hasAppView\n ? getApplicationUrl(application, hostSlug)\n : getWorkbenchUrl(application.organizationId, hostSlug)\n\n if (appId) return resolveAppById(appId, getUrl)\n\n if (organizationId && slug) {\n const existing = (await listApplications(organizationId)).find((app) => app.slug === slug)\n if (existing) {\n return {\n appHost: slug,\n existing: {...existing, url: getUrl(existing)},\n type: 'slug-taken',\n }\n }\n }\n\n return {appHost: slug, type: 'would-create'}\n}\n\n/**\n * {@link resolveWorkbenchApp} narrowed for a studio, whose slug is always configured.\n *\n * @internal\n */\nexport async function resolveWorkbenchStudio(options: {\n appId: string | undefined\n hostSlug?: string | null\n organizationId?: string\n slug: string\n}): Promise<StudioDeployTargetResolution> {\n const resolution = await resolveWorkbenchApp(options)\n return resolution.type === 'would-create'\n ? {appHost: options.slug, type: 'would-create'}\n : resolution\n}\n\nasync function resolveAppById(\n appId: string,\n getUrl: (application: Application) => string,\n): Promise<CommonDeployTargetResolution<DeployTargetCoreApp>> {\n const application = await getApplication(appId)\n return application\n ? {\n application: {...application, url: getUrl(application)},\n type: 'found',\n }\n : {message: APP_ID_NOT_FOUND_IN_ORGANIZATION, reason: 'app-not-found', type: 'invalid'}\n}\n\nasync function listStudioApplications(\n projectId: string,\n isExternal: boolean,\n): Promise<UserApplication[]> {\n const urlType = isExternal ? 'external' : 'internal'\n const applications = await getUserApplications({appType: 'studio', projectId})\n // External deploys should only see external studios and vice versa\n return applications?.filter((application) => application.urlType === urlType) ?? []\n}\n\nfunction resolveAppHost({\n isExternal,\n studioHost,\n url,\n}: {\n isExternal: boolean\n studioHost: string | undefined\n url: string | undefined\n}): {error?: string; host?: string} {\n if (!url) {\n return {host: studioHost}\n }\n\n if (isExternal) {\n const normalized = normalizeUrl(url)\n const validation = validateUrl(normalized)\n if (validation !== true) {\n return {error: validation}\n }\n return {host: normalized}\n }\n\n // For internal deploys, strip protocol prefix and .sanity.studio suffix if present\n const hostname = url.replace(/^https?:\\/\\//i, '').replace(/\\.sanity\\.studio\\/?$/i, '')\n\n // If the result still looks like a URL (contains dots), the user likely meant --external\n if (hostname.includes('.')) {\n return {\n error: `\"${hostname}\" does not look like a sanity.studio hostname. Did you mean to use --external?`,\n }\n }\n\n // Validate hostname characters (alphanumeric and hyphens only)\n if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/i.test(hostname)) {\n return {\n error: `Invalid studio hostname \"${hostname}\". Hostnames can only contain letters, numbers, and hyphens.`,\n }\n }\n\n return {host: hostname}\n}\n"],"names":["getApplication","getApplicationUrl","getWorkbenchUrl","listApplications","getUserApplication","getUserApplications","APP_ID_NOT_FOUND_IN_ORGANIZATION","normalizeUrl","validateUrl","resolveStudioDeployTarget","options","appId","isExternal","projectId","studioHost","urlFlag","message","type","application","isSdkApp","reason","error","hostError","host","resolvedHost","resolveAppHost","url","appHost","validation","existing","listStudioApplications","resolveAppDeployTarget","create","organizationId","appType","length","resolveWorkbenchApp","hasAppView","hostSlug","slug","getUrl","resolveAppById","find","app","resolveWorkbenchStudio","resolution","urlType","applications","filter","normalized","hostname","replace","includes","test"],"mappings":"AAAA,SAEEA,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,gBAAgB,QACX,+BAA8B;AAErC,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,qCAAoC;AAC3C,SAAQC,gCAAgC,QAAO,8BAA6B;AAC5E,SAAQC,YAAY,EAAEC,WAAW,QAAO,gBAAe;AAiDvD;;;;;;CAMC,GACD,OAAO,eAAeC,0BAA0BC,OAM/C;IACC,MAAM,EAACC,KAAK,EAAEC,UAAU,EAAEC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAC,GAAGL;IAE5D,yEAAyE;IACzE,6EAA6E;IAC7E,uCAAuC;IACvC,IAAIC,OAAO;QACT,IAAI,CAACE,WAAW;YACd,OAAO;gBAACG,SAAS;gBAA4BC,MAAM;YAAS;QAC9D;QACA,MAAMC,cAAc,MAAMd,mBAAmB;YAACO;YAAOQ,UAAU;YAAON;QAAS;QAC/E,IAAIK,aAAa;YACf,OAAO;gBAACA;gBAAaD,MAAM;YAAO;QACpC;QACA,OAAO;YACLD,SAAS,CAAC,4BAA4B,EAAEL,OAAO;YAC/CS,QAAQ;YACRH,MAAM;QACR;IACF;IAEA,MAAM,EAACI,OAAOC,SAAS,EAAEC,MAAMC,YAAY,EAAC,GAAGC,eAAe;QAC5Db;QACAE;QACAY,KAAKX;IACP;IACA,IAAIO,WAAW;QACb,OAAO;YAACN,SAASM;YAAWF,QAAQ;YAAgBH,MAAM;QAAS;IACrE;IAEA,oEAAoE;IACpE,IAAIU,UAAUH;IACd,IAAIG,WAAWf,YAAY;QACzBe,UAAUpB,aAAaoB;QACvB,MAAMC,aAAapB,Y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AASrB,eAAe,EACtBb,UAAU,EACVE,UAAU,EACVY,GAAG,EAKJ;IACC,IAAI,CAACA,KAAK;QACR,OAAO;YAACH,MAAMT;QAAU;IAC1B;IAEA,IAAIF,YAAY;QACd,MAAMqC,aAAa1C,aAAamB;QAChC,MAAME,aAAapB,YAAYyC;QAC/B,IAAIrB,eAAe,MAAM;YACvB,OAAO;gBAACP,OAAOO;YAAU;QAC3B;QACA,OAAO;YAACL,MAAM0B;QAAU;IAC1B;IAEA,mFAAmF;IACnF,MAAMC,WAAWxB,IAAIyB,OAAO,CAAC,iBAAiB,IAAIA,OAAO,CAAC,yBAAyB;IAEnF,yFAAyF;IACzF,IAAID,SAASE,QAAQ,CAAC,MAAM;QAC1B,OAAO;YACL/B,OAAO,CAAC,CAAC,EAAE6B,SAAS,8EAA8E,CAAC;QACrG;IACF;IAEA,+DAA+D;IAC/D,IAAI,CAAC,mCAAmCG,IAAI,CAACH,WAAW;QACtD,OAAO;YACL7B,OAAO,CAAC,yBAAyB,EAAE6B,SAAS,4DAA4D,CAAC;QAC3G;IACF;IAEA,OAAO;QAAC3B,MAAM2B;IAAQ;AACxB"}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { BLUEPRINT_FILE_NAMES } from '@sanity/blueprints/resolve';
|
|
1
4
|
import { detectCliInstallation } from '../../../util/packageManager/installationInfo/detectCliInstallation.js';
|
|
5
|
+
const SANITY_CONFIG_FILE_NAMES = [
|
|
6
|
+
'sanity.config.ts',
|
|
7
|
+
'sanity.config.tsx',
|
|
8
|
+
'sanity.config.js',
|
|
9
|
+
'sanity.config.jsx',
|
|
10
|
+
'sanity.cli.ts',
|
|
11
|
+
'sanity.cli.js'
|
|
12
|
+
];
|
|
2
13
|
export const cliInstallationCheck = {
|
|
3
14
|
name: 'cli',
|
|
4
|
-
title: 'CLI
|
|
15
|
+
title: 'CLI installation',
|
|
5
16
|
async run (context) {
|
|
6
17
|
const info = await detectCliInstallation({
|
|
7
18
|
cwd: context.cwd
|
|
8
19
|
});
|
|
9
20
|
const messages = [];
|
|
10
|
-
|
|
21
|
+
const configFileNames = context.withBlueprints ? [
|
|
22
|
+
...SANITY_CONFIG_FILE_NAMES,
|
|
23
|
+
...BLUEPRINT_FILE_NAMES
|
|
24
|
+
] : SANITY_CONFIG_FILE_NAMES;
|
|
11
25
|
const sanityPkg = info.packages.sanity;
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
26
|
+
const isSanityProject = sanityPkg?.declared || sanityPkg?.installed || configFileNames.some((fileName)=>existsSync(join(context.cwd, fileName)));
|
|
27
|
+
if (!isSanityProject) {
|
|
28
|
+
const configExamples = context.withBlueprints ? 'sanity.config.ts, sanity.cli.ts, or sanity.blueprint.ts' : 'sanity.config.ts or sanity.cli.ts';
|
|
14
29
|
messages.push({
|
|
15
|
-
text:
|
|
30
|
+
text: `No Sanity configuration found in this directory (${configExamples}). Run this command from your project root for full diagnostics.`,
|
|
16
31
|
type: 'info'
|
|
17
32
|
});
|
|
18
33
|
return {
|
|
@@ -25,7 +40,7 @@ export const cliInstallationCheck = {
|
|
|
25
40
|
// Everything is fine — brief success
|
|
26
41
|
const version = sanityPkg?.installed?.version;
|
|
27
42
|
messages.push({
|
|
28
|
-
text: version ? `sanity@${version}
|
|
43
|
+
text: version ? `sanity@${version}: no issues found` : 'No issues found',
|
|
29
44
|
type: 'success'
|
|
30
45
|
});
|
|
31
46
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/doctor/checks/cliInstallation.ts"],"sourcesContent":["import {detectCliInstallation} from '../../../util/packageManager/installationInfo/detectCliInstallation.js'\nimport {\n type CheckMessage,\n type CheckResult,\n type DoctorCheck,\n type DoctorContext,\n} from '../types.js'\n\nexport const cliInstallationCheck: DoctorCheck = {\n name: 'cli',\n title: 'CLI
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/doctor/checks/cliInstallation.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {BLUEPRINT_FILE_NAMES} from '@sanity/blueprints/resolve'\n\nimport {detectCliInstallation} from '../../../util/packageManager/installationInfo/detectCliInstallation.js'\nimport {\n type CheckMessage,\n type CheckResult,\n type DoctorCheck,\n type DoctorContext,\n} from '../types.js'\n\nconst SANITY_CONFIG_FILE_NAMES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.cli.ts',\n 'sanity.cli.js',\n]\n\nexport const cliInstallationCheck: DoctorCheck = {\n name: 'cli',\n title: 'CLI installation',\n\n async run(context: DoctorContext): Promise<CheckResult> {\n const info = await detectCliInstallation({cwd: context.cwd})\n const messages: CheckMessage[] = []\n\n const configFileNames = context.withBlueprints\n ? [...SANITY_CONFIG_FILE_NAMES, ...BLUEPRINT_FILE_NAMES]\n : SANITY_CONFIG_FILE_NAMES\n const sanityPkg = info.packages.sanity\n const isSanityProject =\n sanityPkg?.declared ||\n sanityPkg?.installed ||\n configFileNames.some((fileName) => existsSync(join(context.cwd, fileName)))\n\n if (!isSanityProject) {\n const configExamples = context.withBlueprints\n ? 'sanity.config.ts, sanity.cli.ts, or sanity.blueprint.ts'\n : 'sanity.config.ts or sanity.cli.ts'\n messages.push({\n text: `No Sanity configuration found in this directory (${configExamples}). Run this command from your project root for full diagnostics.`,\n type: 'info',\n })\n return {messages, status: 'passed'}\n }\n\n // Map issues to messages\n if (info.issues.length === 0) {\n // Everything is fine — brief success\n const version = sanityPkg?.installed?.version\n messages.push({\n text: version ? `sanity@${version}: no issues found` : 'No issues found',\n type: 'success',\n })\n } else {\n // Add each issue as a self-contained message\n for (const issue of info.issues) {\n const suggestions: string[] = []\n if (issue.suggestion) {\n suggestions.push(issue.suggestion)\n }\n\n messages.push({\n suggestions: suggestions.length > 0 ? suggestions : undefined,\n text: issue.message,\n type:\n issue.severity === 'error'\n ? 'error'\n : issue.severity === 'warning'\n ? 'warning'\n : 'info',\n })\n }\n }\n\n // Determine overall status\n const hasErrors = info.issues.some((i) => i.severity === 'error')\n const hasWarnings = info.issues.some((i) => i.severity === 'warning')\n const status = hasErrors ? 'error' : hasWarnings ? 'warning' : 'passed'\n\n return {messages, status}\n },\n}\n"],"names":["existsSync","join","BLUEPRINT_FILE_NAMES","detectCliInstallation","SANITY_CONFIG_FILE_NAMES","cliInstallationCheck","name","title","run","context","info","cwd","messages","configFileNames","withBlueprints","sanityPkg","packages","sanity","isSanityProject","declared","installed","some","fileName","configExamples","push","text","type","status","issues","length","version","issue","suggestions","suggestion","undefined","message","severity","hasErrors","i","hasWarnings"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,oBAAoB,QAAO,6BAA4B;AAE/D,SAAQC,qBAAqB,QAAO,yEAAwE;AAQ5G,MAAMC,2BAA2B;IAC/B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,OAAO,MAAMC,uBAAoC;IAC/CC,MAAM;IACNC,OAAO;IAEP,MAAMC,KAAIC,OAAsB;QAC9B,MAAMC,OAAO,MAAMP,sBAAsB;YAACQ,KAAKF,QAAQE,GAAG;QAAA;QAC1D,MAAMC,WAA2B,EAAE;QAEnC,MAAMC,kBAAkBJ,QAAQK,cAAc,GAC1C;eAAIV;eAA6BF;SAAqB,GACtDE;QACJ,MAAMW,YAAYL,KAAKM,QAAQ,CAACC,MAAM;QACtC,MAAMC,kBACJH,WAAWI,YACXJ,WAAWK,aACXP,gBAAgBQ,IAAI,CAAC,CAACC,WAAatB,WAAWC,KAAKQ,QAAQE,GAAG,EAAEW;QAElE,IAAI,CAACJ,iBAAiB;YACpB,MAAMK,iBAAiBd,QAAQK,cAAc,GACzC,4DACA;YACJF,SAASY,IAAI,CAAC;gBACZC,MAAM,CAAC,iDAAiD,EAAEF,eAAe,gEAAgE,CAAC;gBAC1IG,MAAM;YACR;YACA,OAAO;gBAACd;gBAAUe,QAAQ;YAAQ;QACpC;QAEA,yBAAyB;QACzB,IAAIjB,KAAKkB,MAAM,CAACC,MAAM,KAAK,GAAG;YAC5B,qCAAqC;YACrC,MAAMC,UAAUf,WAAWK,WAAWU;YACtClB,SAASY,IAAI,CAAC;gBACZC,MAAMK,UAAU,CAAC,OAAO,EAAEA,QAAQ,iBAAiB,CAAC,GAAG;gBACvDJ,MAAM;YACR;QACF,OAAO;YACL,6CAA6C;YAC7C,KAAK,MAAMK,SAASrB,KAAKkB,MAAM,CAAE;gBAC/B,MAAMI,cAAwB,EAAE;gBAChC,IAAID,MAAME,UAAU,EAAE;oBACpBD,YAAYR,IAAI,CAACO,MAAME,UAAU;gBACnC;gBAEArB,SAASY,IAAI,CAAC;oBACZQ,aAAaA,YAAYH,MAAM,GAAG,IAAIG,cAAcE;oBACpDT,MAAMM,MAAMI,OAAO;oBACnBT,MACEK,MAAMK,QAAQ,KAAK,UACf,UACAL,MAAMK,QAAQ,KAAK,YACjB,YACA;gBACV;YACF;QACF;QAEA,2BAA2B;QAC3B,MAAMC,YAAY3B,KAAKkB,MAAM,CAACP,IAAI,CAAC,CAACiB,IAAMA,EAAEF,QAAQ,KAAK;QACzD,MAAMG,cAAc7B,KAAKkB,MAAM,CAACP,IAAI,CAAC,CAACiB,IAAMA,EAAEF,QAAQ,KAAK;QAC3D,MAAMT,SAASU,YAAY,UAAUE,cAAc,YAAY;QAE/D,OAAO;YAAC3B;YAAUe;QAAM;IAC1B;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/doctor/types.ts"],"sourcesContent":["export interface DoctorCheck {\n name: string\n run(context: DoctorContext): Promise<CheckResult>\n title: string\n}\n\nexport type CheckResultStatus = 'error' | 'passed' | 'warning'\n\nexport type MessageType = 'error' | 'info' | 'success' | 'warning'\n\ntype SummaryTypes = 'errors' | 'passed' | 'warnings'\n\nexport interface DoctorContext {\n cwd: string\n}\n\nexport interface CheckResult {\n messages: CheckMessage[]\n status: CheckResultStatus\n}\n\nexport interface CheckMessage {\n text: string\n type: MessageType\n\n suggestions?: string[]\n}\n\nexport interface DoctorResults {\n checks: CheckResultWithMeta[]\n summary: Record<SummaryTypes, number>\n}\n\nexport interface CheckResultWithMeta extends CheckResult {\n name: string\n title: string\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/doctor/types.ts"],"sourcesContent":["export interface DoctorCheck {\n name: string\n run(context: DoctorContext): Promise<CheckResult>\n title: string\n}\n\nexport type CheckResultStatus = 'error' | 'passed' | 'warning'\n\nexport type MessageType = 'error' | 'info' | 'success' | 'warning'\n\ntype SummaryTypes = 'errors' | 'passed' | 'warnings'\n\nexport interface DoctorContext {\n cwd: string\n\n withBlueprints?: boolean\n}\n\nexport interface CheckResult {\n messages: CheckMessage[]\n status: CheckResultStatus\n}\n\nexport interface CheckMessage {\n text: string\n type: MessageType\n\n suggestions?: string[]\n}\n\nexport interface DoctorResults {\n checks: CheckResultWithMeta[]\n summary: Record<SummaryTypes, number>\n}\n\nexport interface CheckResultWithMeta extends CheckResult {\n name: string\n title: string\n}\n"],"names":[],"mappings":"AAmCA,WAGC"}
|
|
@@ -116,6 +116,7 @@ export async function initAction(options, context) {
|
|
|
116
116
|
}
|
|
117
117
|
const envFilename = typeof options.env === 'string' ? options.env : envFilenameDefault;
|
|
118
118
|
const { user } = await ensureAuthenticated(options, output, trace);
|
|
119
|
+
await context.onAuthenticated?.();
|
|
119
120
|
if (!isAppTemplate) {
|
|
120
121
|
output.log(`${logSymbols.success} Fetching existing projects`);
|
|
121
122
|
output.log('');
|