@sanity/cli 8.38.1 → 8.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/deploy/deployApp.js +12 -1
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployRunner.js +9 -1
- package/dist/actions/deploy/deployRunner.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +12 -1
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/graphql/getSourceDeprecationWarning.js +20 -0
- package/dist/actions/graphql/getSourceDeprecationWarning.js.map +1 -0
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js +12 -6
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js.map +1 -1
- package/dist/actions/graphql/types.js.map +1 -1
- package/dist/actions/init/offerAspectPull.js +6 -8
- package/dist/actions/init/offerAspectPull.js.map +1 -1
- package/dist/commands/graphql/deploy.js +5 -0
- package/dist/commands/graphql/deploy.js.map +1 -1
- package/dist/commands/graphql/undeploy.js +5 -0
- package/dist/commands/graphql/undeploy.js.map +1 -1
- package/dist/commands/login.js +2 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/new.js +28 -29
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/projects/unclaimed.js +6 -5
- package/dist/commands/projects/unclaimed.js.map +1 -1
- package/dist/exports/index.d.ts +3 -0
- package/dist/generated/apiRoutes.js +6 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/services/mintProject.js +4 -0
- package/dist/services/mintProject.js.map +1 -1
- package/oclif.manifest.json +762 -762
- package/package.json +5 -5
- package/templates/shared/AGENTS.md +8 -1
|
@@ -7,7 +7,7 @@ import { nodeReadableFromWeb } from '@sanity/cli-core/request';
|
|
|
7
7
|
import { getCoreAppUrl } from '@sanity/cli-core/util';
|
|
8
8
|
import { confirm, spinner } from '@sanity/cli-core/ux';
|
|
9
9
|
import { resolveAppEntry } from '@sanity/workbench-cli/build';
|
|
10
|
-
import { createCoreApp, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, fetchOrganizationSummary, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
10
|
+
import { confirmDashboard2Replacement, createCoreApp, deployConfig, deployWorkbenchApp, fetchDeploySummaryDetails, fetchOrganizationSummary, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, resolveInstallationId, resolveWorkbenchConfig, selectWorkbenchAppId, summarizeConfig, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
11
11
|
import { c as createTar } from 'tar';
|
|
12
12
|
import { createDeployment, updateUserApplication } from '../../services/userApplications.js';
|
|
13
13
|
import { getAppId } from '../../util/appId.js';
|
|
@@ -131,6 +131,17 @@ export function deployApp(options) {
|
|
|
131
131
|
slug: workbench.slug,
|
|
132
132
|
title: appTitle
|
|
133
133
|
}))?.application;
|
|
134
|
+
if (targetAppId) {
|
|
135
|
+
await confirmDashboard2Replacement({
|
|
136
|
+
applicationId: targetAppId,
|
|
137
|
+
output,
|
|
138
|
+
warn: (message)=>reporter.report({
|
|
139
|
+
message,
|
|
140
|
+
status: 'warn'
|
|
141
|
+
}),
|
|
142
|
+
yes: flags.yes
|
|
143
|
+
});
|
|
144
|
+
}
|
|
134
145
|
} else if (deployApplication) {
|
|
135
146
|
;
|
|
136
147
|
({ application, created: appCreated } = await resolveAppApplication(options, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n type CoreAppManifest,\n extractCoreAppManifest,\n resolveTitleUpdate,\n} from '@sanity/cli-build/_internal/manifest'\nimport {type AppVisibility, exitCodes} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\nimport {getCoreAppUrl} from '@sanity/cli-core/util'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {resolveAppEntry} from '@sanity/workbench-cli/build'\nimport {\n createCoreApp,\n deployConfig,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n fetchOrganizationSummary,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n readAppIcon,\n resolveInstallationId,\n resolveWorkbenchConfig,\n selectWorkbenchAppId,\n summarizeConfig,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {c as createTar} from 'tar'\n\nimport {\n createDeployment,\n updateUserApplication,\n type UserApplication,\n type UserApplicationResolved,\n} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {runStep} from '../../util/checks.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED, NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {pluralize} from '../../util/pluralize.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {\n applyAspectSync,\n type AspectSyncPlan,\n planAspectSync,\n} from '../media/aspectSync/syncAspects.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createUserApplication} from './createUserApplication.js'\nimport {\n checkAppId,\n checkAppTarget,\n checkAutoUpdates,\n checkBuild,\n checkPackageVersion,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {findUserApplication} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst APP_PACKAGE = '@sanity/sdk-react'\n\nexport function deployApp(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runAppDeployment,\n type: 'coreApp',\n })\n}\n\n/** Validates the deploy, syncs the title from the manifest, and ships the build. */\nasync function runAppDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const workbench = getWorkbench(cliConfig)\n // A config (the Media Library) is not an app — it resolves through its own\n // brand and persists to the org's installation instead of hosting an application.\n const config = resolveWorkbenchConfig(cliConfig)\n const dryRun = !!flags['dry-run']\n\n const deployConfigOnly = !!config\n const deployApplication = !config && (!workbench || workbench.hasInterfaces)\n const hasAppView = resolveAppEntry(cliConfig.app) !== undefined\n\n const appTitle = workbench ? flags.title?.trim() || workbench.title : ''\n\n // A federated app with no entry, view or service would ship a remote with\n // nothing to load — reported first so it fails before any prompt or API call.\n if (workbench) {\n try {\n workbench.assertDeployable()\n } catch (err) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: getErrorMessage(err),\n solution: 'Declare at least one entry, view, or service in the app',\n status: 'fail',\n })\n }\n }\n\n // A config with no fields would overwrite the org's live config with an empty\n // snapshot, so block it here — same \"nothing to deploy\" gate an app gets.\n if (config?.appType === 'media-library' && config.fields.length === 0) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'Nothing to deploy: the media library config declares no fields.',\n solution: 'Add at least one field to the media library config',\n status: 'fail',\n })\n }\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n // An application ships the SDK runtime; a media-library config needs `sanity`.\n let version: string | null = null\n if (deployApplication) {\n version = await checkPackageVersion(reporter, {moduleName: APP_PACKAGE, workDir})\n } else if (deployConfigOnly) {\n version = await checkPackageVersion(reporter, {moduleName: 'sanity', workDir})\n }\n\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n checkAppId(reporter, {cliConfig})\n\n await checkBlueprintManaged(reporter, {kind: 'coreApp', projectRootDir: workDir})\n\n // 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 || config) && organizationId ? fetchOrganizationSummary(organizationId) : undefined\n const summaryDetails =\n organization && organizationId\n ? fetchDeploySummaryDetails(organizationId, organization)\n : undefined\n\n let application: UserApplicationResolved | null = null\n let appCreated = false\n let workbenchApp: object | undefined\n let targetAppId = appId\n if (flags.external) {\n reporter.report({\n message: EXTERNAL_APP_NOT_SUPPORTED,\n solution: 'Remove the --external flag — apps deploy to Sanity hosting',\n status: 'fail',\n })\n } else if (deployApplication && workbench) {\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'coreApp'})\n workbenchApp = (\n await checkAppTarget(reporter, {\n appId: targetAppId,\n hasAppView,\n hostSlug: (await organization)?.hostSlug,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n } else if (deployApplication) {\n ;({application, created: appCreated} = await resolveAppApplication(options, {dryRun, reporter}))\n }\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (deployApplication && workbench && !appId && !flags.external && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n\n // Create the app before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && deployApplication && workbench && organizationId && !applicationId) {\n const created = await createCoreApp({\n isSingleton: workbench.isSingleton,\n name: workbench.name,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildApp({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: flags.build\n ? undefined\n : 'Build skipped (--no-build) — validating existing output directory',\n successMessage: 'App built',\n })\n\n // A federated build has already read its manifest; anything else verifies the directory.\n const mfManifest =\n built?.mfManifest ??\n (await verifyOutputDir({\n isWorkbenchApp: workbench !== null || config !== null,\n reporter,\n sourceDir,\n }))\n\n // Workbench apps and configs ship a federation remote and don't read the\n // core-app manifest; only plain core-apps do. Manifests aren't strictly\n // essential, so a failure warns and continues.\n let manifest: CoreAppManifest | undefined\n if (!workbench && !config) {\n try {\n manifest = await extractCoreAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n reporter.report({\n message: `Error extracting app manifest: ${getErrorMessage(err)}`,\n status: 'warn',\n })\n }\n }\n\n // Resolve the installation in both modes so the report — dry-run and real —\n // shows whether the config is deployable; a missing one fails the deploy here.\n let installationId: string | undefined\n let configSummary: string | undefined\n const configAppType = config?.appType\n if (deployConfigOnly && organizationId && config && configAppType) {\n installationId = await resolveInstallationId({appType: configAppType, organizationId})\n configSummary = summarizeConfig(config)\n reporter.report(\n installationId\n ? {message: configSummary, status: 'pass'}\n : {\n exitCode: exitCodes.USAGE_ERROR,\n message: `No active \"${configAppType}\" installation for organization \"${organizationId}\"`,\n solution:\n 'Install the Media Library for the organization before deploying its config',\n status: 'fail',\n },\n )\n }\n\n // Plan the aspect-document sync in both modes, so the report — dry-run and\n // real — shows what the sync will write and, prominently, what it will\n // delete, before anything mutates. Gated on a resolved installation: when\n // that check failed, a real run already exited and a dry run has reported\n // the config as undeployable.\n let aspectSyncPlan: AspectSyncPlan | undefined\n // Gated on the `appType` discriminator, not the mere presence of a config:\n // `ConfigSchema` is a union built to grow, and a future config type must\n // not inherit the media-library aspect sync — and its deletions — by\n // default.\n if (config?.appType === 'media-library' && organizationId && installationId) {\n // runStep so an unexpected throw (network, API) becomes a fail check:\n // a real run exits, a dry run records it and keeps reporting.\n const planned = await runStep(reporter, {\n debug: deployDebug,\n formatError: (err) => `Planning the aspect-document sync failed: ${getErrorMessage(err)}`,\n name: 'aspect sync plan',\n work: () =>\n planAspectSync({\n fields: config.fields,\n mediaLibraryId: flags['media-library-id'],\n organizationId,\n workDir,\n }),\n })\n if (planned && 'failure' in planned) {\n reporter.report({\n exitCode: planned.failure.exitCode,\n message: planned.failure.message,\n solution: planned.failure.solution,\n status: 'fail',\n })\n } else if (planned) {\n aspectSyncPlan = planned.plan\n reportAspectSyncPlan(reporter, aspectSyncPlan)\n }\n }\n\n const interfaces = deployApplication && workbench ? reportInterfaces(reporter, workbench) : null\n\n // Applied after the app is live (see below) so a failed deploy never leaves\n // the org's installation config without its application.\n const deployApplicationConfig = async (): Promise<void> => {\n if (installationId && configAppType && organizationId) {\n await deployConfig({appType: configAppType, installationId, sourceDir})\n }\n }\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n type: 'coreApp',\n version,\n ...toWorkbenchPayload(workbench, {config: configSummary, interfaces, title: appTitle}),\n ...(configSummary ? {config: configSummary} : {}),\n ...(aspectSyncPlan\n ? {\n aspectSync: {\n deleteIds: aspectSyncPlan.staleIds,\n mediaLibraryId: aspectSyncPlan.mediaLibraryId,\n upsertIds: aspectSyncPlan.documents.map((document) => document._id),\n },\n }\n : {}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // Deleting stored definitions is the destructive part of a config deploy,\n // so an interactive run confirms it before anything mutates. Unattended\n // runs (--yes; forced in CI) proceed — the config is the source of truth\n // and the dry-run report lists the deletions.\n if (aspectSyncPlan && aspectSyncPlan.staleIds.length > 0 && !flags.yes) {\n const staleCount = aspectSyncPlan.staleIds.length\n const proceed = await confirm({\n default: false,\n message:\n `Delete ${staleCount} stored aspect ${pluralize('definition', staleCount)} with no ` +\n `matching config field (${aspectSyncPlan.staleIds.join(', ')})?`,\n })\n if (!proceed) {\n output.error('Deploy cancelled — the stored aspect definitions are unchanged.', {\n exit: exitCodes.USER_ABORT,\n })\n }\n }\n\n // A config-only singleton ships no application, only its config.\n if (!deployApplication) {\n await deployApplicationConfig()\n if (aspectSyncPlan) {\n await runAspectSync(aspectSyncPlan, output)\n }\n if (installationId && version && organizationId) {\n const {organizationName = null, userName = null} = (await summaryDetails) ?? {}\n output.log(\n formatDeploySummary({\n created: false,\n durationMs: Date.now() - startedAt,\n organizationId,\n organizationName,\n title: 'Media Library configuration',\n type: 'config',\n url: getWorkbenchUrl(organizationId, (await organization)?.hostSlug),\n userName,\n }),\n )\n return {\n application: null,\n deployedBy: userName,\n installationId,\n organizationName,\n payload,\n }\n }\n return\n }\n\n // A real deploy already exited on a version-resolution failure; this narrows the type.\n if (!version) return\n\n // The app was created (or resolved from `deployment.appId`) before the build,\n // so this only ships the deployment; plain coreApps use user-applications below.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: true,\n isAutoUpdating,\n mfManifest,\n // Once the deployment is live, a metadata-sync or later config failure\n // must not delete the app.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n workDir,\n })\n await deployApplicationConfig()\n const hostSlug = (await organization)?.hostSlug\n const url = hasAppView\n ? getApplicationUrl(\n {id: applicationId, organizationId, slug: workbench.slug, type: 'coreApp'},\n hostSlug,\n )\n : getWorkbenchUrl(organizationId, hostSlug)\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: 'coreApp',\n url,\n userName,\n }),\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 // A real deploy has already exited if anything failed; landing here without a\n // resolved application means the deploy target was never resolved.\n if (!application) return\n\n application = await syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility: cliConfig.app?.visibility,\n })\n await shipAppDeployment({application, isAutoUpdating, manifest, sourceDir, version})\n logAppDeployed({\n applicationId: application.id,\n cliConfig,\n created: appCreated,\n createRequested: flags.create,\n organizationId: application.organizationId,\n output,\n title: application.title,\n })\n return {\n action: appCreated ? 'create' : 'update',\n application,\n payload,\n url: getCoreAppUrl(application.organizationId, application.id),\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Reports the planned aspect-document sync: the upserts as a pass, stripped\n * non-serializable values as information, and — prominently, as a warning —\n * the stored definitions the sync will delete because no config field matches\n * them. Deploy is a mirror: the config owns the library's aspect namespace.\n */\nexport function reportAspectSyncPlan(reporter: DeployCheckReporter, plan: AspectSyncPlan): void {\n const upserts = plan.documents.length\n reporter.report({\n message: `Will sync ${upserts} aspect ${pluralize('definition', upserts)} to media library ${plan.mediaLibraryId}`,\n status: 'pass',\n })\n\n const strippedFields = Object.entries(plan.strippedByField)\n if (strippedFields.length > 0) {\n // Expected for fields with custom inputs, validation callbacks, or\n // initial-value resolvers: the live config keeps those capabilities, only\n // the stored mirror (read by Studio plugin mode and the dashboard) omits\n // them. Reported so the capability gap is explicit, but not a warning.\n const details = strippedFields\n .map(([name, paths]) => `${name} (${paths.join(', ')})`)\n .join('; ')\n reporter.report({\n message: `Stored definitions omit non-serializable values: ${details}`,\n status: 'pass',\n })\n }\n\n if (plan.staleIds.length > 0) {\n reporter.report({\n message: `Will delete ${plan.staleIds.length} stored aspect ${pluralize('definition', plan.staleIds.length)} with no matching config field: ${plan.staleIds.join(', ')}`,\n solution:\n 'Definitions only — aspects.<name> values on assets stay put and resurface if a matching ' +\n 'field is added back. To keep a definition, declare a matching field in sanity.cli.ts ' +\n '(generate one with `sanity media pull-aspects`)',\n status: 'warn',\n })\n }\n}\n\n/**\n * Applies the planned sync after the config itself deployed. A failure here\n * leaves the config live but the stored mirror stale, so the error says so\n * and points at the retry (deploys are idempotent).\n */\nasync function runAspectSync(\n plan: AspectSyncPlan,\n output: DeployAppOptions['output'],\n): Promise<void> {\n try {\n await applyAspectSync(plan)\n } catch (err) {\n throw new Error(\n `The config deployed, but syncing its aspect documents to media library ${plan.mediaLibraryId} failed: ${getErrorMessage(err)}\\nRun \\`sanity deploy\\` again to retry the sync.`,\n {cause: err},\n )\n }\n const deleted =\n plan.staleIds.length > 0\n ? ` (deleted ${plan.staleIds.length} stale ${pluralize('definition', plan.staleIds.length)})`\n : ''\n output.log(\n `Synced ${plan.documents.length} aspect ${pluralize('definition', plan.documents.length)} to media library ${plan.mediaLibraryId}${deleted}`,\n )\n}\n\n/**\n * Finds the application a real deploy targets, creating one when none is\n * configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveAppApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplicationResolved | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const organizationId = cliConfig.app?.organizationId ?? ''\n // Create name from --title or `app.title` config; blank falls back to the prompt\n const title = flags.title?.trim() || cliConfig.app?.title?.trim() || undefined\n\n if (dryRun) {\n await checkAppTarget(reporter, {\n appId: getAppId(cliConfig),\n create: flags.create,\n organizationId,\n title,\n })\n return {application: null, created: false}\n }\n\n let application = await findUserApplication({\n cliConfig,\n create: flags.create,\n organizationId,\n output,\n title,\n unattended: !!flags.yes,\n })\n deployDebug('User application found', application)\n\n if (!application) {\n deployDebug('No user application found. Creating a new one')\n application = await createUserApplication(organizationId, title, cliConfig.app?.visibility)\n deployDebug('User application created', application)\n return {application, created: true}\n }\n\n return {application, created: false}\n}\n\n/**\n * Syncs application metadata on redeploy when it has changed: the title from the\n * manifest and the dashboard visibility from config. Sends a single PATCH with\n * only the changed fields, and skips the request entirely when nothing changed.\n */\nexport async function syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility,\n}: {\n application: UserApplicationResolved\n manifest: CoreAppManifest | undefined\n output: DeployAppOptions['output']\n visibility: AppVisibility | undefined\n}): Promise<UserApplicationResolved> {\n const titleUpdate = resolveTitleUpdate(manifest, application)\n // Treat an unset server value as `default` so a config of `default` is a no-op.\n const visibilityChanged =\n visibility !== undefined && visibility !== (application.dashboardStatus ?? 'default')\n\n if (!titleUpdate && !visibilityChanged) return application\n\n if (titleUpdate) {\n deployDebug('Updating application title from manifest', titleUpdate)\n output.log(\n titleUpdate.from\n ? `Updating title from \"${titleUpdate.from}\" to \"${titleUpdate.to}\"`\n : `Setting application title to \"${titleUpdate.to}\"`,\n )\n }\n if (visibilityChanged) {\n output.log(`Setting dashboard visibility to \"${visibility}\"`)\n }\n\n const spin = spinner('Updating application').start()\n try {\n const updated = await updateUserApplication({\n applicationId: application.id,\n appType: 'coreApp',\n body: {\n ...(titleUpdate ? {title: titleUpdate.to} : {}),\n ...(visibilityChanged ? {dashboardStatus: visibility} : {}),\n },\n })\n spin.succeed()\n return updated\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application metadata', {message})\n output.logDiagnostic(`Warning: Error updating application metadata: ${message}`)\n return application\n }\n}\n\nasync function shipAppDeployment({\n application,\n isAutoUpdating,\n manifest,\n sourceDir,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n manifest: CoreAppManifest | undefined\n sourceDir: string\n version: string\n}): Promise<void> {\n const tarball = nodeReadableFromWeb(\n createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]),\n )\n\n const spin = spinner('Deploying...').start()\n try {\n await createDeployment({\n applicationId: application.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version,\n })\n } catch (error) {\n spin.clear()\n throw error\n }\n spin.succeed()\n}\n\nexport function logAppDeployed({\n applicationId,\n cliConfig,\n created,\n createRequested = false,\n organizationId,\n output,\n title,\n}: {\n applicationId: string\n cliConfig: DeployAppOptions['cliConfig']\n created: boolean\n createRequested?: boolean\n organizationId: string\n output: DeployAppOptions['output']\n title: string | null\n}): void {\n const url = getCoreAppUrl(organizationId, applicationId)\n const named = title ? ` — \"${title}\"` : ''\n output.log(`\\nSuccess! Application deployed to ${styleText('cyan', url)}${named}`)\n output.log(created ? 'Created a new application.' : 'Updated the existing application.')\n\n if (getAppId(cliConfig)) return\n\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n if (created) {\n output.log(\n styleText(\n 'yellow',\n createRequested\n ? '\\nSave `deployment.appId` and omit --create on later deploys to update this application.'\n : '\\nSave `deployment.appId` to update this application on later deploys.',\n ),\n )\n }\n output.log(\n styleText('bold', '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${applicationId}',\n}\\n`,\n)}`)\n}\n"],"names":["basename","dirname","styleText","extractCoreAppManifest","resolveTitleUpdate","exitCodes","getErrorMessage","nodeReadableFromWeb","getCoreAppUrl","confirm","spinner","resolveAppEntry","createCoreApp","deployConfig","deployWorkbenchApp","fetchDeploySummaryDetails","fetchOrganizationSummary","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","readAppIcon","resolveInstallationId","resolveWorkbenchConfig","selectWorkbenchAppId","summarizeConfig","toWorkbenchPayload","c","createTar","createDeployment","updateUserApplication","getAppId","runStep","EXTERNAL_APP_NOT_SUPPORTED","NO_ORGANIZATION_ID","pluralize","buildApp","applyAspectSync","planAspectSync","checkBlueprintManaged","createUserApplication","checkAppId","checkAppTarget","checkAutoUpdates","checkBuild","checkPackageVersion","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","findUserApplication","APP_PACKAGE","deployApp","options","listFiles","projectRoot","sourceDir","directory","run","runAppDeployment","type","reporter","cliConfig","flags","output","workDir","organizationId","app","appId","workbench","config","dryRun","deployConfigOnly","deployApplication","hasInterfaces","hasAppView","undefined","appTitle","title","trim","assertDeployable","err","report","exitCode","USAGE_ERROR","message","solution","status","appType","fields","length","isAutoUpdating","version","moduleName","kind","projectRootDir","organization","summaryDetails","application","appCreated","workbenchApp","targetAppId","external","hostSlug","isWorkbenchApp","slug","created","resolveAppApplication","build","appIcon","icon","startedAt","Date","now","applicationId","applicationCreated","rollbackApp","isSingleton","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","successMessage","mfManifest","manifest","installationId","configSummary","configAppType","aspectSyncPlan","planned","debug","formatError","work","mediaLibraryId","failure","plan","reportAspectSyncPlan","interfaces","deployApplicationConfig","payload","aspectSync","deleteIds","staleIds","upsertIds","documents","map","document","_id","yes","staleCount","proceed","default","join","error","exit","USER_ABORT","runAspectSync","organizationName","userName","log","durationMs","url","deployedBy","Error","isApp","onDeployed","showAppIdHint","action","syncApplicationMetadata","shipAppDeployment","logAppDeployed","createRequested","create","upserts","strippedFields","Object","entries","strippedByField","details","paths","cause","deleted","unattended","titleUpdate","visibilityChanged","dashboardStatus","from","to","spin","start","updated","body","succeed","fail","logDiagnostic","tarball","cwd","gzip","clear","named"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAEEC,sBAAsB,EACtBC,kBAAkB,QACb,uCAAsC;AAC7C,SAA4BC,SAAS,QAAO,mBAAkB;AAC9D,SA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EnK,UAAU,QAAQ,cAAc,KAAK,CAAC;IAC3D,IAAIyG,SAAS;QACX1C,OAAOoG,GAAG,CACRnK,UACE,UACA+K,kBACI,6FACA;IAGV;IACAhH,OAAOoG,GAAG,CACRnK,UAAU,QAAQ;IAEpB+D,OAAOoG,GAAG,CAAC,CAAC;AACd,EAAEnK,UACA,OACA,CAAC;;CAEF,CAAC,EACA;AACF,EAAEA,UACA;QAAC;QAAQ;KAAQ,EACjB,CAAC;UACO,EAAEiH,cAAc;GACvB,CAAC,GACD;AACH"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n type CoreAppManifest,\n extractCoreAppManifest,\n resolveTitleUpdate,\n} from '@sanity/cli-build/_internal/manifest'\nimport {type AppVisibility, exitCodes} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\nimport {getCoreAppUrl} from '@sanity/cli-core/util'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {resolveAppEntry} from '@sanity/workbench-cli/build'\nimport {\n confirmDashboard2Replacement,\n createCoreApp,\n deployConfig,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n fetchOrganizationSummary,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n readAppIcon,\n resolveInstallationId,\n resolveWorkbenchConfig,\n selectWorkbenchAppId,\n summarizeConfig,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {c as createTar} from 'tar'\n\nimport {\n createDeployment,\n updateUserApplication,\n type UserApplication,\n type UserApplicationResolved,\n} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {runStep} from '../../util/checks.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED, NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {pluralize} from '../../util/pluralize.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {\n applyAspectSync,\n type AspectSyncPlan,\n planAspectSync,\n} from '../media/aspectSync/syncAspects.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createUserApplication} from './createUserApplication.js'\nimport {\n checkAppId,\n checkAppTarget,\n checkAutoUpdates,\n checkBuild,\n checkPackageVersion,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {findUserApplication} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst APP_PACKAGE = '@sanity/sdk-react'\n\nexport function deployApp(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runAppDeployment,\n type: 'coreApp',\n })\n}\n\n/** Validates the deploy, syncs the title from the manifest, and ships the build. */\nasync function runAppDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const workbench = getWorkbench(cliConfig)\n // A config (the Media Library) is not an app — it resolves through its own\n // brand and persists to the org's installation instead of hosting an application.\n const config = resolveWorkbenchConfig(cliConfig)\n const dryRun = !!flags['dry-run']\n\n const deployConfigOnly = !!config\n const deployApplication = !config && (!workbench || workbench.hasInterfaces)\n const hasAppView = resolveAppEntry(cliConfig.app) !== undefined\n\n const appTitle = workbench ? flags.title?.trim() || workbench.title : ''\n\n // A federated app with no entry, view or service would ship a remote with\n // nothing to load — reported first so it fails before any prompt or API call.\n if (workbench) {\n try {\n workbench.assertDeployable()\n } catch (err) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: getErrorMessage(err),\n solution: 'Declare at least one entry, view, or service in the app',\n status: 'fail',\n })\n }\n }\n\n // A config with no fields would overwrite the org's live config with an empty\n // snapshot, so block it here — same \"nothing to deploy\" gate an app gets.\n if (config?.appType === 'media-library' && config.fields.length === 0) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'Nothing to deploy: the media library config declares no fields.',\n solution: 'Add at least one field to the media library config',\n status: 'fail',\n })\n }\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n // An application ships the SDK runtime; a media-library config needs `sanity`.\n let version: string | null = null\n if (deployApplication) {\n version = await checkPackageVersion(reporter, {moduleName: APP_PACKAGE, workDir})\n } else if (deployConfigOnly) {\n version = await checkPackageVersion(reporter, {moduleName: 'sanity', workDir})\n }\n\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n checkAppId(reporter, {cliConfig})\n\n await checkBlueprintManaged(reporter, {kind: 'coreApp', projectRootDir: workDir})\n\n // 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 || config) && organizationId ? fetchOrganizationSummary(organizationId) : undefined\n const summaryDetails =\n organization && organizationId\n ? fetchDeploySummaryDetails(organizationId, organization)\n : undefined\n\n let application: UserApplicationResolved | null = null\n let appCreated = false\n let workbenchApp: object | undefined\n let targetAppId = appId\n if (flags.external) {\n reporter.report({\n message: EXTERNAL_APP_NOT_SUPPORTED,\n solution: 'Remove the --external flag — apps deploy to Sanity hosting',\n status: 'fail',\n })\n } else if (deployApplication && workbench) {\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'coreApp'})\n workbenchApp = (\n await checkAppTarget(reporter, {\n appId: targetAppId,\n hasAppView,\n hostSlug: (await organization)?.hostSlug,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n\n if (targetAppId) {\n await confirmDashboard2Replacement({\n applicationId: targetAppId,\n output,\n warn: (message) => reporter.report({message, status: 'warn'}),\n yes: flags.yes,\n })\n }\n } else if (deployApplication) {\n ;({application, created: appCreated} = await resolveAppApplication(options, {dryRun, reporter}))\n }\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (deployApplication && workbench && !appId && !flags.external && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n\n // Create the app before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && deployApplication && workbench && organizationId && !applicationId) {\n const created = await createCoreApp({\n isSingleton: workbench.isSingleton,\n name: workbench.name,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildApp({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: flags.build\n ? undefined\n : 'Build skipped (--no-build) — validating existing output directory',\n successMessage: 'App built',\n })\n\n // A federated build has already read its manifest; anything else verifies the directory.\n const mfManifest =\n built?.mfManifest ??\n (await verifyOutputDir({\n isWorkbenchApp: workbench !== null || config !== null,\n reporter,\n sourceDir,\n }))\n\n // Workbench apps and configs ship a federation remote and don't read the\n // core-app manifest; only plain core-apps do. Manifests aren't strictly\n // essential, so a failure warns and continues.\n let manifest: CoreAppManifest | undefined\n if (!workbench && !config) {\n try {\n manifest = await extractCoreAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n reporter.report({\n message: `Error extracting app manifest: ${getErrorMessage(err)}`,\n status: 'warn',\n })\n }\n }\n\n // Resolve the installation in both modes so the report — dry-run and real —\n // shows whether the config is deployable; a missing one fails the deploy here.\n let installationId: string | undefined\n let configSummary: string | undefined\n const configAppType = config?.appType\n if (deployConfigOnly && organizationId && config && configAppType) {\n installationId = await resolveInstallationId({appType: configAppType, organizationId})\n configSummary = summarizeConfig(config)\n reporter.report(\n installationId\n ? {message: configSummary, status: 'pass'}\n : {\n exitCode: exitCodes.USAGE_ERROR,\n message: `No active \"${configAppType}\" installation for organization \"${organizationId}\"`,\n solution:\n 'Install the Media Library for the organization before deploying its config',\n status: 'fail',\n },\n )\n }\n\n // Plan the aspect-document sync in both modes, so the report — dry-run and\n // real — shows what the sync will write and, prominently, what it will\n // delete, before anything mutates. Gated on a resolved installation: when\n // that check failed, a real run already exited and a dry run has reported\n // the config as undeployable.\n let aspectSyncPlan: AspectSyncPlan | undefined\n // Gated on the `appType` discriminator, not the mere presence of a config:\n // `ConfigSchema` is a union built to grow, and a future config type must\n // not inherit the media-library aspect sync — and its deletions — by\n // default.\n if (config?.appType === 'media-library' && organizationId && installationId) {\n // runStep so an unexpected throw (network, API) becomes a fail check:\n // a real run exits, a dry run records it and keeps reporting.\n const planned = await runStep(reporter, {\n debug: deployDebug,\n formatError: (err) => `Planning the aspect-document sync failed: ${getErrorMessage(err)}`,\n name: 'aspect sync plan',\n work: () =>\n planAspectSync({\n fields: config.fields,\n mediaLibraryId: flags['media-library-id'],\n organizationId,\n workDir,\n }),\n })\n if (planned && 'failure' in planned) {\n reporter.report({\n exitCode: planned.failure.exitCode,\n message: planned.failure.message,\n solution: planned.failure.solution,\n status: 'fail',\n })\n } else if (planned) {\n aspectSyncPlan = planned.plan\n reportAspectSyncPlan(reporter, aspectSyncPlan)\n }\n }\n\n const interfaces = deployApplication && workbench ? reportInterfaces(reporter, workbench) : null\n\n // Applied after the app is live (see below) so a failed deploy never leaves\n // the org's installation config without its application.\n const deployApplicationConfig = async (): Promise<void> => {\n if (installationId && configAppType && organizationId) {\n await deployConfig({appType: configAppType, installationId, sourceDir})\n }\n }\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n type: 'coreApp',\n version,\n ...toWorkbenchPayload(workbench, {config: configSummary, interfaces, title: appTitle}),\n ...(configSummary ? {config: configSummary} : {}),\n ...(aspectSyncPlan\n ? {\n aspectSync: {\n deleteIds: aspectSyncPlan.staleIds,\n mediaLibraryId: aspectSyncPlan.mediaLibraryId,\n upsertIds: aspectSyncPlan.documents.map((document) => document._id),\n },\n }\n : {}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // Deleting stored definitions is the destructive part of a config deploy,\n // so an interactive run confirms it before anything mutates. Unattended\n // runs (--yes; forced in CI) proceed — the config is the source of truth\n // and the dry-run report lists the deletions.\n if (aspectSyncPlan && aspectSyncPlan.staleIds.length > 0 && !flags.yes) {\n const staleCount = aspectSyncPlan.staleIds.length\n const proceed = await confirm({\n default: false,\n message:\n `Delete ${staleCount} stored aspect ${pluralize('definition', staleCount)} with no ` +\n `matching config field (${aspectSyncPlan.staleIds.join(', ')})?`,\n })\n if (!proceed) {\n output.error('Deploy cancelled — the stored aspect definitions are unchanged.', {\n exit: exitCodes.USER_ABORT,\n })\n }\n }\n\n // A config-only singleton ships no application, only its config.\n if (!deployApplication) {\n await deployApplicationConfig()\n if (aspectSyncPlan) {\n await runAspectSync(aspectSyncPlan, output)\n }\n if (installationId && version && organizationId) {\n const {organizationName = null, userName = null} = (await summaryDetails) ?? {}\n output.log(\n formatDeploySummary({\n created: false,\n durationMs: Date.now() - startedAt,\n organizationId,\n organizationName,\n title: 'Media Library configuration',\n type: 'config',\n url: getWorkbenchUrl(organizationId, (await organization)?.hostSlug),\n userName,\n }),\n )\n return {\n application: null,\n deployedBy: userName,\n installationId,\n organizationName,\n payload,\n }\n }\n return\n }\n\n // A real deploy already exited on a version-resolution failure; this narrows the type.\n if (!version) return\n\n // The app was created (or resolved from `deployment.appId`) before the build,\n // so this only ships the deployment; plain coreApps use user-applications below.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: true,\n isAutoUpdating,\n mfManifest,\n // Once the deployment is live, a metadata-sync or later config failure\n // must not delete the app.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n workDir,\n })\n await deployApplicationConfig()\n const hostSlug = (await organization)?.hostSlug\n const url = hasAppView\n ? getApplicationUrl(\n {id: applicationId, organizationId, slug: workbench.slug, type: 'coreApp'},\n hostSlug,\n )\n : getWorkbenchUrl(organizationId, hostSlug)\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: 'coreApp',\n url,\n userName,\n }),\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 // A real deploy has already exited if anything failed; landing here without a\n // resolved application means the deploy target was never resolved.\n if (!application) return\n\n application = await syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility: cliConfig.app?.visibility,\n })\n await shipAppDeployment({application, isAutoUpdating, manifest, sourceDir, version})\n logAppDeployed({\n applicationId: application.id,\n cliConfig,\n created: appCreated,\n createRequested: flags.create,\n organizationId: application.organizationId,\n output,\n title: application.title,\n })\n return {\n action: appCreated ? 'create' : 'update',\n application,\n payload,\n url: getCoreAppUrl(application.organizationId, application.id),\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Reports the planned aspect-document sync: the upserts as a pass, stripped\n * non-serializable values as information, and — prominently, as a warning —\n * the stored definitions the sync will delete because no config field matches\n * them. Deploy is a mirror: the config owns the library's aspect namespace.\n */\nexport function reportAspectSyncPlan(reporter: DeployCheckReporter, plan: AspectSyncPlan): void {\n const upserts = plan.documents.length\n reporter.report({\n message: `Will sync ${upserts} aspect ${pluralize('definition', upserts)} to media library ${plan.mediaLibraryId}`,\n status: 'pass',\n })\n\n const strippedFields = Object.entries(plan.strippedByField)\n if (strippedFields.length > 0) {\n // Expected for fields with custom inputs, validation callbacks, or\n // initial-value resolvers: the live config keeps those capabilities, only\n // the stored mirror (read by Studio plugin mode and the dashboard) omits\n // them. Reported so the capability gap is explicit, but not a warning.\n const details = strippedFields\n .map(([name, paths]) => `${name} (${paths.join(', ')})`)\n .join('; ')\n reporter.report({\n message: `Stored definitions omit non-serializable values: ${details}`,\n status: 'pass',\n })\n }\n\n if (plan.staleIds.length > 0) {\n reporter.report({\n message: `Will delete ${plan.staleIds.length} stored aspect ${pluralize('definition', plan.staleIds.length)} with no matching config field: ${plan.staleIds.join(', ')}`,\n solution:\n 'Definitions only — aspects.<name> values on assets stay put and resurface if a matching ' +\n 'field is added back. To keep a definition, declare a matching field in sanity.cli.ts ' +\n '(generate one with `sanity media pull-aspects`)',\n status: 'warn',\n })\n }\n}\n\n/**\n * Applies the planned sync after the config itself deployed. A failure here\n * leaves the config live but the stored mirror stale, so the error says so\n * and points at the retry (deploys are idempotent).\n */\nasync function runAspectSync(\n plan: AspectSyncPlan,\n output: DeployAppOptions['output'],\n): Promise<void> {\n try {\n await applyAspectSync(plan)\n } catch (err) {\n throw new Error(\n `The config deployed, but syncing its aspect documents to media library ${plan.mediaLibraryId} failed: ${getErrorMessage(err)}\\nRun \\`sanity deploy\\` again to retry the sync.`,\n {cause: err},\n )\n }\n const deleted =\n plan.staleIds.length > 0\n ? ` (deleted ${plan.staleIds.length} stale ${pluralize('definition', plan.staleIds.length)})`\n : ''\n output.log(\n `Synced ${plan.documents.length} aspect ${pluralize('definition', plan.documents.length)} to media library ${plan.mediaLibraryId}${deleted}`,\n )\n}\n\n/**\n * Finds the application a real deploy targets, creating one when none is\n * configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveAppApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplicationResolved | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const organizationId = cliConfig.app?.organizationId ?? ''\n // Create name from --title or `app.title` config; blank falls back to the prompt\n const title = flags.title?.trim() || cliConfig.app?.title?.trim() || undefined\n\n if (dryRun) {\n await checkAppTarget(reporter, {\n appId: getAppId(cliConfig),\n create: flags.create,\n organizationId,\n title,\n })\n return {application: null, created: false}\n }\n\n let application = await findUserApplication({\n cliConfig,\n create: flags.create,\n organizationId,\n output,\n title,\n unattended: !!flags.yes,\n })\n deployDebug('User application found', application)\n\n if (!application) {\n deployDebug('No user application found. Creating a new one')\n application = await createUserApplication(organizationId, title, cliConfig.app?.visibility)\n deployDebug('User application created', application)\n return {application, created: true}\n }\n\n return {application, created: false}\n}\n\n/**\n * Syncs application metadata on redeploy when it has changed: the title from the\n * manifest and the dashboard visibility from config. Sends a single PATCH with\n * only the changed fields, and skips the request entirely when nothing changed.\n */\nexport async function syncApplicationMetadata({\n application,\n manifest,\n output,\n visibility,\n}: {\n application: UserApplicationResolved\n manifest: CoreAppManifest | undefined\n output: DeployAppOptions['output']\n visibility: AppVisibility | undefined\n}): Promise<UserApplicationResolved> {\n const titleUpdate = resolveTitleUpdate(manifest, application)\n // Treat an unset server value as `default` so a config of `default` is a no-op.\n const visibilityChanged =\n visibility !== undefined && visibility !== (application.dashboardStatus ?? 'default')\n\n if (!titleUpdate && !visibilityChanged) return application\n\n if (titleUpdate) {\n deployDebug('Updating application title from manifest', titleUpdate)\n output.log(\n titleUpdate.from\n ? `Updating title from \"${titleUpdate.from}\" to \"${titleUpdate.to}\"`\n : `Setting application title to \"${titleUpdate.to}\"`,\n )\n }\n if (visibilityChanged) {\n output.log(`Setting dashboard visibility to \"${visibility}\"`)\n }\n\n const spin = spinner('Updating application').start()\n try {\n const updated = await updateUserApplication({\n applicationId: application.id,\n appType: 'coreApp',\n body: {\n ...(titleUpdate ? {title: titleUpdate.to} : {}),\n ...(visibilityChanged ? {dashboardStatus: visibility} : {}),\n },\n })\n spin.succeed()\n return updated\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application metadata', {message})\n output.logDiagnostic(`Warning: Error updating application metadata: ${message}`)\n return application\n }\n}\n\nasync function shipAppDeployment({\n application,\n isAutoUpdating,\n manifest,\n sourceDir,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n manifest: CoreAppManifest | undefined\n sourceDir: string\n version: string\n}): Promise<void> {\n const tarball = nodeReadableFromWeb(\n createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]),\n )\n\n const spin = spinner('Deploying...').start()\n try {\n await createDeployment({\n applicationId: application.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version,\n })\n } catch (error) {\n spin.clear()\n throw error\n }\n spin.succeed()\n}\n\nexport function logAppDeployed({\n applicationId,\n cliConfig,\n created,\n createRequested = false,\n organizationId,\n output,\n title,\n}: {\n applicationId: string\n cliConfig: DeployAppOptions['cliConfig']\n created: boolean\n createRequested?: boolean\n organizationId: string\n output: DeployAppOptions['output']\n title: string | null\n}): void {\n const url = getCoreAppUrl(organizationId, applicationId)\n const named = title ? ` — \"${title}\"` : ''\n output.log(`\\nSuccess! Application deployed to ${styleText('cyan', url)}${named}`)\n output.log(created ? 'Created a new application.' : 'Updated the existing application.')\n\n if (getAppId(cliConfig)) return\n\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n if (created) {\n output.log(\n styleText(\n 'yellow',\n createRequested\n ? '\\nSave `deployment.appId` and omit --create on later deploys to update this application.'\n : '\\nSave `deployment.appId` to update this application on later deploys.',\n ),\n )\n }\n output.log(\n styleText('bold', '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${applicationId}',\n}\\n`,\n)}`)\n}\n"],"names":["basename","dirname","styleText","extractCoreAppManifest","resolveTitleUpdate","exitCodes","getErrorMessage","nodeReadableFromWeb","getCoreAppUrl","confirm","spinner","resolveAppEntry","confirmDashboard2Replacement","createCoreApp","deployConfig","deployWorkbenchApp","fetchDeploySummaryDetails","fetchOrganizationSummary","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","readAppIcon","resolveInstallationId","resolveWorkbenchConfig","selectWorkbenchAppId","summarizeConfig","toWorkbenchPayload","c","createTar","createDeployment","updateUserApplication","getAppId","runStep","EXTERNAL_APP_NOT_SUPPORTED","NO_ORGANIZATION_ID","pluralize","buildApp","applyAspectSync","planAspectSync","checkBlueprintManaged","createUserApplication","checkAppId","checkAppTarget","checkAutoUpdates","checkBuild","checkPackageVersion","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","findUserApplication","APP_PACKAGE","deployApp","options","listFiles","projectRoot","sourceDir","directory","run","runAppDeployment","type","reporter","cliConfig","flags","output","workDir","organizationId","app","appId","workbench","config","dryRun","deployConfigOnly","deployApplication","hasInterfaces","hasAppView","undefined","appTitle","title","trim","assertDeployable","err","report","exitCode","USAGE_ERROR","message","solution","status","appType","fields","length","isAutoUpdating","version","moduleName","kind","projectRootDir","organization","summaryDetails","application","appCreated","workbenchApp","targetAppId","external","hostSlug","isWorkbenchApp","slug","applicationId","warn","yes","created","resolveAppApplication","build","appIcon","icon","startedAt","Date","now","applicationCreated","rollbackApp","isSingleton","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","successMessage","mfManifest","manifest","installationId","configSummary","configAppType","aspectSyncPlan","planned","debug","formatError","work","mediaLibraryId","failure","plan","reportAspectSyncPlan","interfaces","deployApplicationConfig","payload","aspectSync","deleteIds","staleIds","upsertIds","documents","map","document","_id","staleCount","proceed","default","join","error","exit","USER_ABORT","runAspectSync","organizationName","userName","log","durationMs","url","deployedBy","Error","isApp","onDeployed","showAppIdHint","action","syncApplicationMetadata","shipAppDeployment","logAppDeployed","createRequested","create","upserts","strippedFields","Object","entries","strippedByField","details","paths","cause","deleted","unattended","titleUpdate","visibilityChanged","dashboardStatus","from","to","spin","start","updated","body","succeed","fail","logDiagnostic","tarball","cwd","gzip","clear","named"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAEEC,sBAAsB,EACtBC,kBAAkB,QACb,uCAAsC;AAC7C,SAA4BC,SAAS,QAAO,mBAAkB;AAC9D,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,mBAAmB,QAAO,2BAA0B;AAC5D,SAAQC,aAAa,QAAO,wBAAuB;AACnD,SAAQC,OAAO,EAAEC,OAAO,QAAO,sBAAqB;AACpD,SAAQC,eAAe,QAAO,8BAA6B;AAC3D,SACEC,4BAA4B,EAC5BC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,wBAAwB,EACxBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,WAAW,EACXC,qBAAqB,EACrBC,sBAAsB,EACtBC,oBAAoB,EACpBC,eAAe,EACfC,kBAAkB,QACb,+BAA8B;AACrC,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SACEC,gBAAgB,EAChBC,qBAAqB,QAGhB,qCAAoC;AAC3C,SA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ACvB,CAAC,GACD;AACH"}
|
|
@@ -32,10 +32,18 @@ import { getDeployErrorMessage } from './serviceUnavailable.js';
|
|
|
32
32
|
exitIfBlocked(plan, output);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
const
|
|
35
|
+
const failFast = createFailFastReporter(runOptions.output);
|
|
36
|
+
const warnings = [];
|
|
37
|
+
const result = await spec.run(runOptions, {
|
|
38
|
+
report (check) {
|
|
39
|
+
if (check.status === 'warn') warnings.push(check.message);
|
|
40
|
+
failFast.report(check);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
36
43
|
if (json && result) emitJson({
|
|
37
44
|
deployed: true,
|
|
38
45
|
reason: null,
|
|
46
|
+
warnings,
|
|
39
47
|
...result
|
|
40
48
|
});
|
|
41
49
|
} catch (error) {
|
|
@@ -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 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,
|
|
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 failFast = createFailFastReporter(runOptions.output)\n const warnings: string[] = []\n const result = await spec.run(runOptions, {\n report(check) {\n if (check.status === 'warn') warnings.push(check.message)\n failFast.report(check)\n },\n })\n\n if (json && result) emitJson({deployed: true, reason: null, warnings, ...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","failFast","warnings","result","run","report","check","status","push","message","deployed","reason","error","failure","normalizeFailure","type","application","undefined","exit","reporter","checks","results","files","target","find","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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,MAAMN,MAAMmB,KAAK,EAAEb,QAAQ;YAAGT,SAASG,MAAMH,OAAO;QAAA;IAC9D;IACA3B,YAAY,CAAC,gBAAgB,EAAEiC,SAAS,YAAY,gBAAgB,UAAU,EAAEH;IAChF,OAAO;QACLM,MAAMzC,UAAUqD,aAAa;QAC7BrB,SAAS,CAAC,gBAAgB,EAAEM,SAAS,YAAY,gBAAgB,SAAS,EAAE,EAAE7B,sBAAsB0B,QAAQ;IAC9G;AACF"}
|
|
@@ -4,7 +4,7 @@ import { formatSchemaValidation, SchemaExtractionError } from '@sanity/cli-build
|
|
|
4
4
|
import { exitCodes } from '@sanity/cli-core';
|
|
5
5
|
import { nodeReadableFromWeb } from '@sanity/cli-core/request';
|
|
6
6
|
import { spinner } from '@sanity/cli-core/ux';
|
|
7
|
-
import { createStudio, deployWorkbenchApp, fetchDeploySummaryDetails, fetchOrganizationSummary, formatDeploySummary, getApplicationUrl, getWorkbench, getWorkbenchUrl, readAppIcon, selectWorkbenchAppId, toWorkbenchPayload } from '@sanity/workbench-cli/deploy';
|
|
7
|
+
import { confirmDashboard2Replacement, 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';
|
|
@@ -98,6 +98,17 @@ export function deployStudio(options) {
|
|
|
98
98
|
appId: targetAppId,
|
|
99
99
|
url: flags.url
|
|
100
100
|
});
|
|
101
|
+
if (targetAppId) {
|
|
102
|
+
await confirmDashboard2Replacement({
|
|
103
|
+
applicationId: targetAppId,
|
|
104
|
+
output,
|
|
105
|
+
warn: (message)=>reporter.report({
|
|
106
|
+
message,
|
|
107
|
+
status: 'warn'
|
|
108
|
+
}),
|
|
109
|
+
yes: flags.yes
|
|
110
|
+
});
|
|
111
|
+
}
|
|
101
112
|
} else {
|
|
102
113
|
;
|
|
103
114
|
({ application, created: studioCreated } = await resolveStudioApplication(options, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname, relative} from 'node:path'\nimport {type Readable} from 'node:stream'\nimport {styleText} from 'node:util'\n\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {exitCodes} from '@sanity/cli-core'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\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: Readable | undefined\n if (!isExternal) {\n tarball = nodeReadableFromWeb(\n createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]),\n )\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","formatSchemaValidation","SchemaExtractionError","exitCodes","nodeReadableFromWeb","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","gzip","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;AAErD,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,mBAAmB,QAAO,2BAA0B;AAC5D,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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AAM,EACNV,SAAS,EAOV;IACC,MAAMmI,MAAM,GAAGhL,SAASiL,QAAQrB,GAAG,IAAI/G,cAAc,IAAI,CAAC,CAAC;IAC3D,2GAA2G;IAC3G,MAAMqI,UAAU;QAACpK,gBAAgBgD;QAAiBhD,gBAAgBgD,gBAAgByB;KAAU;IAC5FhC,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"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname, relative} from 'node:path'\nimport {type Readable} from 'node:stream'\nimport {styleText} from 'node:util'\n\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {exitCodes} from '@sanity/cli-core'\nimport {nodeReadableFromWeb} from '@sanity/cli-core/request'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {\n type BrettAccess,\n type BrettWorkspace,\n confirmDashboard2Replacement,\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\n if (targetAppId) {\n await confirmDashboard2Replacement({\n applicationId: targetAppId,\n output,\n warn: (message) => reporter.report({message, status: 'warn'}),\n yes: flags.yes,\n })\n }\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: Readable | undefined\n if (!isExternal) {\n tarball = nodeReadableFromWeb(\n createTar({cwd: dirname(sourceDir), gzip: true}, [basename(sourceDir)]),\n )\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","formatSchemaValidation","SchemaExtractionError","exitCodes","nodeReadableFromWeb","spinner","confirmDashboard2Replacement","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","applicationId","warn","yes","created","resolveStudioApplication","isExternallyHosted","build","exitCode","USAGE_ERROR","appIcon","icon","startedAt","Date","now","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","registered","urlType","configPath","path","outPath","schemaRequired","verbose","error","validation","length","exit","RUNTIME_ERROR","tarball","cwd","gzip","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;AAErD,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,mBAAmB,QAAO,2BAA0B;AAC5D,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAGEC,4BA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7B,IAAI,CAAC8B,OAAO,OAAO;IACnB;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { oneline } from 'oneline';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a warning naming the GraphQL APIs configured with the deprecated `source` option, or
|
|
4
|
+
* `undefined` when none use it.
|
|
5
|
+
*/ export function getSourceDeprecationWarning(apis = []) {
|
|
6
|
+
const names = apis.flatMap((api, index)=>api.source === undefined ? [] : [
|
|
7
|
+
api.id ? `"${api.id}"` : `at index ${index}`
|
|
8
|
+
]);
|
|
9
|
+
if (names.length === 0) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return oneline`
|
|
13
|
+
The \`source\` option for GraphQL APIs is deprecated and will be removed in a future major
|
|
14
|
+
version (used by GraphQL API ${names.join(', ')}). Studio v7 removes workspace sources:
|
|
15
|
+
configure each source as its own workspace in \`sanity.config.ts\`, then select it with
|
|
16
|
+
\`workspace\` in \`sanity.cli.ts\`.
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=getSourceDeprecationWarning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/graphql/getSourceDeprecationWarning.ts"],"sourcesContent":["import {oneline} from 'oneline'\n\nimport {type GraphQLAPIConfig} from './types.js'\n\n/**\n * Returns a warning naming the GraphQL APIs configured with the deprecated `source` option, or\n * `undefined` when none use it.\n */\nexport function getSourceDeprecationWarning(apis: GraphQLAPIConfig[] = []): string | undefined {\n const names = apis.flatMap((api, index) =>\n api.source === undefined ? [] : [api.id ? `\"${api.id}\"` : `at index ${index}`],\n )\n\n if (names.length === 0) {\n return undefined\n }\n\n return oneline`\n The \\`source\\` option for GraphQL APIs is deprecated and will be removed in a future major\n version (used by GraphQL API ${names.join(', ')}). Studio v7 removes workspace sources:\n configure each source as its own workspace in \\`sanity.config.ts\\`, then select it with\n \\`workspace\\` in \\`sanity.cli.ts\\`.\n `\n}\n"],"names":["oneline","getSourceDeprecationWarning","apis","names","flatMap","api","index","source","undefined","id","length","join"],"mappings":"AAAA,SAAQA,OAAO,QAAO,UAAS;AAI/B;;;CAGC,GACD,OAAO,SAASC,4BAA4BC,OAA2B,EAAE;IACvE,MAAMC,QAAQD,KAAKE,OAAO,CAAC,CAACC,KAAKC,QAC/BD,IAAIE,MAAM,KAAKC,YAAY,EAAE,GAAG;YAACH,IAAII,EAAE,GAAG,CAAC,CAAC,EAAEJ,IAAII,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,EAAEH,OAAO;SAAC;IAGhF,IAAIH,MAAMO,MAAM,KAAK,GAAG;QACtB,OAAOF;IACT;IAEA,OAAOR,OAAO,CAAC;;iCAEgB,EAAEG,MAAMQ,IAAI,CAAC,MAAM;;;EAGlD,CAAC;AACH"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { oneline } from 'oneline';
|
|
2
2
|
export function resolveGraphQLApis({ cliConfig, workspaces }) {
|
|
3
|
-
const numSources = workspaces.reduce((count, workspace)=>count + workspace.
|
|
3
|
+
const numSources = workspaces.reduce((count, workspace)=>count + getWorkspaceSources(workspace).length, 0);
|
|
4
4
|
const multiSource = numSources > 1;
|
|
5
5
|
const multiWorkspace = workspaces.length > 1;
|
|
6
6
|
const hasGraphQLConfig = Boolean(cliConfig?.graphql);
|
|
7
7
|
if (workspaces.length === 0) {
|
|
8
8
|
throw new Error('No studio configuration found');
|
|
9
9
|
}
|
|
10
|
-
if (numSources === 0) {
|
|
11
|
-
throw new Error('No sources (project ID / dataset) configured');
|
|
12
|
-
}
|
|
13
10
|
// We can only automatically configure if there is a single workspace + source in play
|
|
14
11
|
if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {
|
|
15
12
|
throw new Error(oneline`
|
|
@@ -20,7 +17,7 @@ export function resolveGraphQLApis({ cliConfig, workspaces }) {
|
|
|
20
17
|
}
|
|
21
18
|
// No config is defined, but we have a single workspace + source, so use that
|
|
22
19
|
if (!hasGraphQLConfig) {
|
|
23
|
-
const { dataset, projectId, schema } = workspaces[0]
|
|
20
|
+
const { dataset, projectId, schema } = workspaces[0];
|
|
24
21
|
return [
|
|
25
22
|
{
|
|
26
23
|
dataset,
|
|
@@ -129,7 +126,7 @@ function resolveGraphQLApiMetadataFromConfig(apiDefs, workspaces) {
|
|
|
129
126
|
}
|
|
130
127
|
function resolveGraphQLAPIsFromConfig(apiDefs, workspaces) {
|
|
131
128
|
return apiDefs.map((apiDef)=>{
|
|
132
|
-
const { source } = resolveWorkspaceAndSource(apiDef, workspaces,
|
|
129
|
+
const { source } = resolveWorkspaceAndSource(apiDef, workspaces, getWorkspaceSources);
|
|
133
130
|
return {
|
|
134
131
|
...apiDef,
|
|
135
132
|
dataset: source.dataset,
|
|
@@ -138,6 +135,15 @@ function resolveGraphQLAPIsFromConfig(apiDefs, workspaces) {
|
|
|
138
135
|
};
|
|
139
136
|
});
|
|
140
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* A workspace is its own single source, unless it comes from a Studio v6 config with more than
|
|
140
|
+
* one source in `unstable_sources`.
|
|
141
|
+
*/ function getWorkspaceSources(workspace) {
|
|
142
|
+
const sources = workspace.unstable_sources ?? [];
|
|
143
|
+
return sources.length > 1 ? sources : [
|
|
144
|
+
workspace
|
|
145
|
+
];
|
|
146
|
+
}
|
|
141
147
|
function validateCliConfig(config, configPath = 'sanity.cli.js') {
|
|
142
148
|
if (!Array.isArray(config)) {
|
|
143
149
|
throw new TypeError(`"graphql" key in "${configPath}" must be an array if defined`);
|