@sanity/cli 8.34.0 → 8.36.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/build/buildApp.js +1 -4
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +1 -0
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +17 -9
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployDashboardConfig.js +118 -0
- package/dist/actions/deploy/deployDashboardConfig.js.map +1 -0
- package/dist/actions/deploy/deployStudio.js +3 -2
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js +2 -5
- package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
- package/dist/actions/graphql/extractGraphQLAPIs.js +13 -6
- package/dist/actions/graphql/extractGraphQLAPIs.js.map +1 -1
- package/dist/actions/graphql/extractGraphQLAPIs.worker.js +2 -1
- package/dist/actions/graphql/extractGraphQLAPIs.worker.js.map +1 -1
- package/dist/actions/init/initAction.js +30 -3
- package/dist/actions/init/initAction.js.map +1 -1
- package/dist/actions/init/initBlueprint.js +66 -0
- package/dist/actions/init/initBlueprint.js.map +1 -0
- package/dist/actions/init/types.js +2 -1
- package/dist/actions/init/types.js.map +1 -1
- package/dist/actions/preview/previewAction.js +2 -2
- package/dist/actions/preview/previewAction.js.map +1 -1
- package/dist/actions/undeploy/runUndeploy.js +16 -4
- package/dist/actions/undeploy/runUndeploy.js.map +1 -1
- package/dist/actions/undeploy/undeployPlan.js +2 -2
- package/dist/actions/undeploy/undeployPlan.js.map +1 -1
- package/dist/commands/deploy.js +15 -3
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.js +10 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/media/prune-aspect-data.js +1 -1
- package/dist/commands/media/prune-aspect-data.js.map +1 -1
- package/dist/commands/media/pull-aspects.js +1 -1
- package/dist/commands/media/pull-aspects.js.map +1 -1
- package/dist/exports/index.d.ts +2 -2
- package/dist/exports/index.js +1 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/runtime.d.ts +2 -2
- package/dist/exports/runtime.js +1 -1
- package/dist/exports/runtime.js.map +1 -1
- package/dist/generated/apiRoutes.js +52 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/oclif.manifest.json +3019 -3006
- package/package.json +16 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname, relative} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip, type Gzip} from 'node:zlib'\n\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {exitCodes} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {\n type BrettAccess,\n type BrettWorkspace,\n createStudio,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n readAppIcon,\n selectWorkbenchAppId,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {type StudioManifest} from 'sanity'\nimport {c as createTar} from 'tar'\n\nimport {createDeployment, type UserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID, NO_PROJECT_ID} from '../../util/errorMessages.js'\nimport {buildStudio} from '../build/buildStudio.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createStudioUserApplication} from './createUserApplication.js'\nimport {\n checkAutoUpdates,\n checkBuild,\n checkExternalUrl,\n checkPackageVersion,\n checkStudioTarget,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {deployStudioSchemasAndManifests} from './deployStudioSchemasAndManifests.js'\nimport {findUserApplicationForStudio} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst STUDIO_PACKAGE = 'sanity'\n\nexport function deployStudio(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({flags, projectRoot, sourceDir}) =>\n flags.external ? Promise.resolve([]) : listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runStudioDeployment,\n type: 'studio',\n })\n}\n\n/** Validates the deploy, extracts and uploads the schema, and ships the build. */\nasync function runStudioDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const isExternal = !!flags.external\n const workbench = getWorkbench(cliConfig)\n const isWorkbenchApp = workbench !== null\n const projectId = cliConfig.api?.projectId\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const dryRun = !!flags['dry-run']\n // A legacy external studio only registers its URL; a federated one is built\n // and deployed like a hosted one, minus the upload.\n const isLegacyExternal = isExternal && !isWorkbenchApp\n\n const appTitle = workbench\n ? flags.title?.trim() || cliConfig.app?.title?.trim() || workbench.slug\n : ''\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n const version = await checkPackageVersion(reporter, {\n moduleName: STUDIO_PACKAGE,\n workDir,\n })\n\n reporter.report(\n projectId\n ? {message: `Project: ${projectId}`, status: 'pass'}\n : {\n message: NO_PROJECT_ID,\n solution: 'Add `api.projectId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n await checkBlueprintManaged(reporter, {kind: 'studio', projectRootDir: workDir})\n\n // Workbench studios deploy to Brett (which needs the org); plain studios\n // resolve/create on user-applications, unchanged.\n let application: UserApplication | null = null\n let studioCreated = false\n let workbenchApp: {externalUrl?: string} | undefined\n let externalUrl: string | undefined\n let targetAppId = appId\n if (workbench) {\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'studio'})\n workbenchApp = (\n await checkStudioTarget(reporter, {\n appId: targetAppId,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n if (isExternal) externalUrl = checkExternalUrl(reporter, {appId: targetAppId, url: flags.url})\n } else {\n ;({application, created: studioCreated} = await resolveStudioApplication(options, {\n dryRun,\n reporter,\n }))\n }\n // A redeploy follows how the application was registered, so --external is only needed once.\n const isExternallyHosted = isExternal || !!workbenchApp?.externalUrl\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (workbench && !appId && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n const summaryDetails =\n workbench && organizationId && !flags.json\n ? fetchDeploySummaryDetails(organizationId)\n : undefined\n\n // Create the studio before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && workbench && organizationId && !applicationId) {\n const created = await createStudio({\n externalUrl,\n name: workbench.name,\n organizationId,\n projectId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildStudio({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: studioBuildSkipReason({build: flags.build, isLegacyExternal}),\n successMessage: 'Studio built',\n })\n\n let mfManifest = built?.mfManifest\n // A federated build has already read its manifest; anything else verifies the directory.\n if (mfManifest === undefined && !isLegacyExternal) {\n mfManifest = await verifyOutputDir({isWorkbenchApp, reporter, sourceDir})\n }\n\n const interfaces = workbench ? reportInterfaces(reporter, workbench) : null\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n ...(projectId ? {projectId} : {}),\n type: 'studio',\n version,\n ...toWorkbenchPayload(workbench, {interfaces, title: appTitle}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved version means the deploy target was never resolved.\n if (!version) return\n\n const studioManifest = await uploadStudioSchema(options, {\n applicationId: workbench ? applicationId : undefined,\n isExternal: isLegacyExternal,\n })\n // The studio was created (or resolved from `deployment.appId`) before the\n // build, so this only ships the deployment; plain studios use user-applications.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n access: toAccess(studioManifest),\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: false,\n isAutoUpdating,\n isExternal: isExternallyHosted,\n label: 'Deploying studio',\n mfManifest,\n // Once the deployment is live, a metadata-sync failure must not delete\n // the studio.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n workspaces: toWorkspaces(studioManifest),\n })\n const url = getApplicationUrl({\n id: applicationId,\n organizationId,\n slug: workbench.slug,\n type: 'studio',\n })\n const durationMs = Date.now() - startedAt\n output.log(\n formatDeploySummary({\n ...(await summaryDetails),\n applicationId,\n created: applicationCreated,\n durationMs,\n isApp: false,\n organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n url,\n }),\n )\n if (isExternallyHosted)\n logExternalHost({built: flags.build, organizationId, output, sourceDir})\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n payload,\n url,\n }\n }\n\n if (!application) return\n const location = await shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n })\n\n return {\n action: studioCreated ? 'create' : 'update',\n application,\n payload,\n url: location,\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Finds the application a real deploy targets, registering a studio host when\n * none is configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveStudioApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplication | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const isExternal = !!flags.external\n const appId = getAppId(cliConfig)\n // Sets the title on a newly registered studio; blank falls back to undefined\n const title = flags.title?.trim() || undefined\n\n if (dryRun) {\n await checkStudioTarget(reporter, {\n appId,\n isExternal,\n projectId: cliConfig.api?.projectId,\n studioHost: cliConfig.studioHost,\n title,\n urlFlag: flags.url,\n })\n return {application: null, created: false}\n }\n\n const projectId = cliConfig.api?.projectId ?? ''\n // `created` is true when a configured-but-unregistered host was just registered.\n const {application, created} = await findUserApplicationForStudio({\n appId,\n isExternal,\n output,\n projectId,\n studioHost: cliConfig.studioHost,\n title,\n unattended: !!flags.yes,\n urlFlag: flags.url,\n })\n\n if (!application) {\n if (isExternal) {\n output.log('Your project has not been registered with an external studio URL.')\n output.log('Please enter the full URL where your studio is hosted.')\n } else {\n output.log('Your project has not been assigned a studio hostname.')\n output.log('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.log('you will need one. Please enter the subdomain you want to use.')\n }\n\n const registered = await createStudioUserApplication({\n projectId,\n title,\n urlType: isExternal ? 'external' : 'internal',\n })\n deployDebug('Created user application', registered)\n return {application: registered, created: true}\n }\n\n deployDebug('Found user application', application)\n return {application, created}\n}\n\n/** Extracts the studio schema and manifest and uploads them to the schema store. */\nasync function uploadStudioSchema(\n options: DeployAppOptions,\n {applicationId, isExternal}: {applicationId?: string; isExternal: boolean},\n): Promise<StudioManifest | null> {\n const {flags, output, projectRoot, sourceDir} = options\n\n let studioManifest: StudioManifest | null = null\n try {\n studioManifest = await deployStudioSchemasAndManifests(\n {\n applicationId,\n configPath: projectRoot.path,\n isExternal,\n outPath: `${sourceDir}/static`,\n schemaRequired: flags['schema-required'],\n verbose: flags.verbose,\n workDir: projectRoot.directory,\n },\n output,\n )\n } catch (error) {\n deployDebug('Error deploying studio schemas and manifests', error)\n if (error instanceof SchemaExtractionError && error.validation?.length) {\n output.error(formatSchemaValidation(error.validation), {exit: exitCodes.RUNTIME_ERROR})\n }\n output.error(`Error deploying studio schemas and manifests: ${error}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!studioManifest) {\n output.error('Failed to generate studio manifest. Please check your schemas and manifests.', {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n return studioManifest\n}\n\nasync function shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n isExternal: boolean\n options: DeployAppOptions\n studioManifest: StudioManifest | null\n version: string\n}): Promise<string> {\n const {cliConfig, output, sourceDir} = options\n\n let tarball: Gzip | undefined\n if (!isExternal) {\n tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n }\n\n const spin = spinner(isExternal ? 'Registering studio' : 'Deploying to sanity.studio').start()\n let location: string\n try {\n ;({location} = await createDeployment({\n applicationId: application.id,\n isApp: false,\n isAutoUpdating,\n manifest: studioManifest,\n projectId: cliConfig.api?.projectId,\n tarball,\n version,\n }))\n } catch (error) {\n spin.fail()\n throw error\n }\n spin.succeed()\n\n const named = application.title ? ` — \"${application.title}\"` : ''\n output.log(\n isExternal\n ? `\\nSuccess! Studio registered${named}`\n : `\\nSuccess! Studio deployed to ${styleText('cyan', location)}${named}`,\n )\n\n if (getAppId(cliConfig)) return location\n\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${styleText('cyan', `appId: '${application.id}'`)},\n },\n //…\n})`\n output.log(`\\nAdd ${styleText('cyan', `appId: '${application.id}'`)}`)\n output.log(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting for application id on next deploy.`)\n output.log(`\\n${example}`)\n\n return location\n}\n\n/**\n * One `datasets` access entry per unique workspace dataset, with a `resourceId`\n * of `\"<projectId>.<dataset>\"`. Deduped, since workspaces can share a dataset.\n */\nfunction toAccess(manifest: StudioManifest | null): BrettAccess[] {\n const resourceIds = new Set(\n (manifest?.workspaces ?? []).map((w) => `${w.projectId}.${w.dataset}`),\n )\n return [...resourceIds].map(\n (resourceId) => ({resourceId, resourceType: 'dataset'}) satisfies BrettAccess,\n )\n}\n\nfunction toWorkspaces(manifest: StudioManifest | null): BrettWorkspace[] {\n return (manifest?.workspaces ?? []).map((workspace) => ({\n basePath: workspace.basePath,\n dataset: workspace.dataset,\n icon: workspace.icon,\n name: workspace.name,\n projectId: workspace.projectId,\n schemaDescriptorId: workspace.schemaDescriptorId,\n subtitle: workspace.subtitle,\n title: workspace.title,\n }))\n}\n\n/** Tells the customer what their host must do for the Dashboard to load the studio from it. */\nfunction logExternalHost({\n built,\n organizationId,\n output,\n sourceDir,\n}: {\n built: boolean\n organizationId: string\n output: DeployAppOptions['output']\n sourceDir: string\n}): void {\n const dir = `${relative(process.cwd(), sourceDir) || '.'}/`\n output.log(`\nThe Dashboard loads this studio from your host, which must:\n 1. Serve ${dir} unchanged at the root of its URL (/mf-manifest.json, /remoteEntry-*.js, /static/*)\n 2. Send Access-Control-Allow-Origin for ${getWorkbenchUrl(organizationId)}\n 3. Respond without cookies or a sign-in${built ? `\\n\\nThis deploy rebuilt ${dir}: copy it to your host before opening the studio in the Dashboard.` : ''}`)\n}\n\nfunction studioBuildSkipReason({\n build,\n isLegacyExternal,\n}: {\n build: boolean\n isLegacyExternal: boolean\n}) {\n if (isLegacyExternal) return 'Build skipped for externally hosted studios'\n if (!build) return 'Build skipped (--no-build) — validating existing output directory'\n return\n}\n"],"names":["basename","dirname","relative","styleText","createGzip","formatSchemaValidation","SchemaExtractionError","exitCodes","spinner","createStudio","deployWorkbenchApp","fetchDeploySummaryDetails","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","readAppIcon","selectWorkbenchAppId","toWorkbenchPayload","c","createTar","createDeployment","getAppId","NO_ORGANIZATION_ID","NO_PROJECT_ID","buildStudio","checkBlueprintManaged","createStudioUserApplication","checkAutoUpdates","checkBuild","checkExternalUrl","checkPackageVersion","checkStudioTarget","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","deployStudioSchemasAndManifests","findUserApplicationForStudio","STUDIO_PACKAGE","deployStudio","options","listFiles","flags","projectRoot","sourceDir","external","Promise","resolve","directory","run","runStudioDeployment","type","reporter","cliConfig","output","workDir","isExternal","workbench","isWorkbenchApp","projectId","api","organizationId","app","appId","dryRun","isLegacyExternal","appTitle","title","trim","slug","isAutoUpdating","version","moduleName","report","message","status","solution","kind","projectRootDir","application","studioCreated","workbenchApp","externalUrl","targetAppId","url","created","resolveStudioApplication","isExternallyHosted","build","exitCode","USAGE_ERROR","appIcon","icon","undefined","startedAt","Date","now","summaryDetails","json","applicationId","applicationCreated","rollbackApp","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","studioBuildSkipReason","successMessage","mfManifest","interfaces","payload","studioManifest","uploadStudioSchema","Error","access","toAccess","isApp","label","onDeployed","workspaces","toWorkspaces","durationMs","log","showAppIdHint","logExternalHost","action","location","shipStudioDeployment","err","studioHost","urlFlag","unattended","yes","registered","urlType","configPath","path","outPath","schemaRequired","verbose","error","validation","length","exit","RUNTIME_ERROR","tarball","cwd","pipe","spin","start","manifest","fail","succeed","named","example","resourceIds","Set","map","w","dataset","resourceId","resourceType","workspace","basePath","schemaDescriptorId","subtitle","dir","process"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAO,YAAW;AACrD,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAkB,YAAW;AAE/C,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAGEC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,WAAW,EACXC,oBAAoB,EACpBC,kBAAkB,QACb,+BAA8B;AAErC,SAAQC,KAAKC,SAAS,QAAO,MAAK;AAElC,SAAQC,gBAAgB,QAA6B,qCAAoC;AACzF,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,kBAAkB,EAAEC,aAAa,QAAO,8BAA6B;AAC7E,SAAQC,WAAW,QAAO,0BAAyB;AACnD,SAAQC,qBAAqB,QAAO,wBAAuB;AAC3D,SAAQC,2BAA2B,QAAO,6BAA4B;AACtE,SACEC,gBAAgB,EAChBC,UAAU,EACVC,gBAAgB,EAChBC,mBAAmB,EACnBC,iBAAiB,EAEjBC,eAAe,QACV,oBAAmB;AAC1B,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,mBAAmB,EAAEC,gBAAgB,QAAO,sBAAqB;AACzE,SAA+CC,SAAS,QAAO,oBAAmB;AAClF,SAAQC,+BAA+B,QAAO,uCAAsC;AACpF,SAAQC,4BAA4B,QAAO,2BAA0B;AAGrE,MAAMC,iBAAiB;AAEvB,OAAO,SAASC,aAAaC,OAAyB;IACpD,OAAOL,UAAUK,SAAS;QACxBC,WAAW,CAAC,EAACC,KAAK,EAAEC,WAAW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AG,CAAC,CAACC,IAAM,GAAGA,EAAExG,SAAS,CAAC,CAAC,EAAEwG,EAAEC,OAAO,EAAE;IAEvE,OAAO;WAAIJ;KAAY,CAACE,GAAG,CACzB,CAACG,aAAgB,CAAA;YAACA;YAAYC,cAAc;QAAS,CAAA;AAEzD;AAEA,SAASzC,aAAa8B,QAA+B;IACnD,OAAO,AAACA,CAAAA,UAAU/B,cAAc,EAAE,AAAD,EAAGsC,GAAG,CAAC,CAACK,YAAe,CAAA;YACtDC,UAAUD,UAAUC,QAAQ;YAC5BJ,SAASG,UAAUH,OAAO;YAC1BxE,MAAM2E,UAAU3E,IAAI;YACpBU,MAAMiE,UAAUjE,IAAI;YACpB3C,WAAW4G,UAAU5G,SAAS;YAC9B8G,oBAAoBF,UAAUE,kBAAkB;YAChDC,UAAUH,UAAUG,QAAQ;YAC5BvG,OAAOoG,UAAUpG,KAAK;QACxB,CAAA;AACF;AAEA,6FAA6F,GAC7F,SAAS8D,gBAAgB,EACvBvB,KAAK,EACL7C,cAAc,EACdP,MAAM,EACNV,SAAS,EAMV;IACC,MAAM+H,MAAM,GAAG3K,SAAS4K,QAAQrB,GAAG,IAAI3G,cAAc,IAAI,CAAC,CAAC;IAC3DU,OAAOyE,GAAG,CAAC,CAAC;;WAEH,EAAE4C,IAAI;0CACyB,EAAE9J,gBAAgBgD,gBAAgB;yCACnC,EAAE6C,QAAQ,CAAC,wBAAwB,EAAEiE,IAAI,kEAAkE,CAAC,GAAG,IAAI;AAC5J;AAEA,SAAS5D,sBAAsB,EAC7BvB,KAAK,EACLvB,gBAAgB,EAIjB;IACC,IAAIA,kBAAkB,OAAO;IAC7B,IAAI,CAACuB,OAAO,OAAO;IACnB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployStudio.ts"],"sourcesContent":["import {basename, dirname, relative} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip, type Gzip} from 'node:zlib'\n\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {exitCodes} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {\n type BrettAccess,\n type BrettWorkspace,\n createStudio,\n deployWorkbenchApp,\n fetchDeploySummaryDetails,\n formatDeploySummary,\n getApplicationUrl,\n getWorkbench,\n getWorkbenchUrl,\n readAppIcon,\n selectWorkbenchAppId,\n toWorkbenchPayload,\n} from '@sanity/workbench-cli/deploy'\nimport {type StudioManifest} from 'sanity'\nimport {c as createTar} from 'tar'\n\nimport {createDeployment, type UserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID, NO_PROJECT_ID} from '../../util/errorMessages.js'\nimport {buildStudio} from '../build/buildStudio.js'\nimport {checkBlueprintManaged} from './blueprintManaged.js'\nimport {createStudioUserApplication} from './createUserApplication.js'\nimport {\n checkAutoUpdates,\n checkBuild,\n checkExternalUrl,\n checkPackageVersion,\n checkStudioTarget,\n type DeployCheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles, reportInterfaces} from './deploymentPlan.js'\nimport {type DeployPayload, type DeployResult, runDeploy} from './deployRunner.js'\nimport {deployStudioSchemasAndManifests} from './deployStudioSchemasAndManifests.js'\nimport {findUserApplicationForStudio} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nconst STUDIO_PACKAGE = 'sanity'\n\nexport function deployStudio(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({flags, projectRoot, sourceDir}) =>\n flags.external ? Promise.resolve([]) : listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runStudioDeployment,\n type: 'studio',\n })\n}\n\n/** Validates the deploy, extracts and uploads the schema, and ships the build. */\nasync function runStudioDeployment(\n options: DeployAppOptions,\n reporter: DeployCheckReporter,\n): Promise<DeployResult | void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const isExternal = !!flags.external\n const workbench = getWorkbench(cliConfig)\n const isWorkbenchApp = workbench !== null\n const projectId = cliConfig.api?.projectId\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const dryRun = !!flags['dry-run']\n // A legacy external studio only registers its URL; a federated one is built\n // and deployed like a hosted one, minus the upload.\n const isLegacyExternal = isExternal && !isWorkbenchApp\n\n const appTitle = workbench ? flags.title?.trim() || workbench.title : ''\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n const version = await checkPackageVersion(reporter, {\n moduleName: STUDIO_PACKAGE,\n workDir,\n })\n\n reporter.report(\n projectId\n ? {message: `Project: ${projectId}`, status: 'pass'}\n : {\n message: NO_PROJECT_ID,\n solution: 'Add `api.projectId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n await checkBlueprintManaged(reporter, {kind: 'studio', projectRootDir: workDir})\n\n // Workbench studios deploy to Brett (which needs the org); plain studios\n // resolve/create on user-applications, unchanged.\n let application: UserApplication | null = null\n let studioCreated = false\n let workbenchApp: {externalUrl?: string | null} | undefined\n let externalUrl: string | undefined\n let targetAppId = appId\n if (workbench) {\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n targetAppId = await selectWorkbenchAppId({appId, flags, organizationId, type: 'studio'})\n workbenchApp = (\n await checkStudioTarget(reporter, {\n appId: targetAppId,\n isWorkbenchApp: true,\n organizationId,\n slug: workbench.slug,\n title: appTitle,\n })\n )?.application\n if (isExternal) externalUrl = checkExternalUrl(reporter, {appId: targetAppId, url: flags.url})\n } else {\n ;({application, created: studioCreated} = await resolveStudioApplication(options, {\n dryRun,\n reporter,\n }))\n }\n // A redeploy follows how the application was registered, so --external is only needed once.\n const isExternallyHosted = isExternal || !!workbenchApp?.externalUrl\n\n // A first deploy mints the app id and the build inlines it; --no-build would\n // ship an existing bundle carrying a different id, so it can't be a first deploy.\n if (workbench && !appId && !flags.build) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: 'A first deploy cannot skip the build (--no-build)',\n solution: 'Drop --no-build so the new application id is inlined into the build',\n status: 'fail',\n })\n }\n\n // Read up front so a bad icon path fails before we create or build.\n const appIcon =\n !dryRun && workbench?.icon ? await readAppIcon(workDir, workbench.icon) : undefined\n\n const startedAt = Date.now()\n const summaryDetails =\n workbench && organizationId && !flags.json\n ? fetchDeploySummaryDetails(organizationId)\n : undefined\n\n // Create the studio before the build so the bundle carries its real id. A\n // redeploy already has it from `deployment.appId`; a dry run skips creation.\n let applicationId = targetAppId\n let applicationCreated = false\n let rollbackApp: (() => Promise<void>) | undefined\n if (!dryRun && workbench && organizationId && !applicationId) {\n const created = await createStudio({\n externalUrl,\n name: workbench.name,\n organizationId,\n projectId,\n slug: workbench.slug,\n title: appTitle,\n visibility: workbench.visibility,\n })\n workbenchApp = created.application\n applicationId = created.application.id\n rollbackApp = created.rollback\n applicationCreated = true\n }\n\n // A record created above is stranded at its slug (and blocks retries) if any\n // step before it fully deploys fails, so undo the creation on failure.\n try {\n const built = await checkBuild(reporter, {\n build: () =>\n buildStudio({\n applicationId: workbench ? applicationId : undefined,\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: studioBuildSkipReason({build: flags.build, isLegacyExternal}),\n successMessage: 'Studio built',\n })\n\n let mfManifest = built?.mfManifest\n // A federated build has already read its manifest; anything else verifies the directory.\n if (mfManifest === undefined && !isLegacyExternal) {\n mfManifest = await verifyOutputDir({isWorkbenchApp, reporter, sourceDir})\n }\n\n const interfaces = workbench ? reportInterfaces(reporter, workbench) : null\n\n const payload: DeployPayload = {\n appId: appId ?? null,\n isAutoUpdating,\n ...(organizationId ? {organizationId} : {}),\n ...(projectId ? {projectId} : {}),\n type: 'studio',\n version,\n ...toWorkbenchPayload(workbench, {interfaces, title: appTitle}),\n }\n\n // Dry run stops here — everything below mutates.\n if (dryRun) return {application: null, payload}\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved version means the deploy target was never resolved.\n if (!version) return\n\n const studioManifest = await uploadStudioSchema(options, {\n applicationId: workbench ? applicationId : undefined,\n isExternal: isLegacyExternal,\n })\n // The studio was created (or resolved from `deployment.appId`) before the\n // build, so this only ships the deployment; plain studios use user-applications.\n if (workbench && organizationId && applicationId) {\n if (!mfManifest) throw new Error('The federated build produced no manifest.')\n await deployWorkbenchApp({\n access: toAccess(studioManifest),\n app: cliConfig.app,\n applicationId,\n icon: appIcon,\n isApp: false,\n isAutoUpdating,\n isExternal: isExternallyHosted,\n label: 'Deploying studio',\n mfManifest,\n // Once the deployment is live, a metadata-sync failure must not delete\n // the studio.\n onDeployed: () => {\n rollbackApp = undefined\n },\n slug: workbench.slug,\n sourceDir,\n title: appTitle,\n version,\n visibility: workbench.visibility,\n workDir,\n workspaces: toWorkspaces(studioManifest),\n })\n const url = getApplicationUrl({\n id: applicationId,\n organizationId,\n slug: workbench.slug,\n type: 'studio',\n })\n const durationMs = Date.now() - startedAt\n output.log(\n formatDeploySummary({\n ...(await summaryDetails),\n applicationId,\n created: applicationCreated,\n durationMs,\n organizationId,\n showAppIdHint: !appId,\n title: appTitle,\n type: 'studio',\n url,\n }),\n )\n if (isExternallyHosted)\n logExternalHost({built: flags.build, organizationId, output, sourceDir})\n return {\n action: applicationCreated ? 'create' : 'update',\n application: workbenchApp ?? null,\n payload,\n url,\n }\n }\n\n if (!application) return\n const location = await shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n })\n\n return {\n action: studioCreated ? 'create' : 'update',\n application,\n payload,\n url: location,\n }\n } catch (err) {\n await rollbackApp?.()\n throw err\n }\n}\n\n/**\n * Finds the application a real deploy targets, registering a studio host when\n * none is configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveStudioApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: DeployCheckReporter},\n): Promise<{application: UserApplication | null; created: boolean}> {\n const {cliConfig, flags, output} = options\n const isExternal = !!flags.external\n const appId = getAppId(cliConfig)\n // Sets the title on a newly registered studio; blank falls back to undefined\n const title = flags.title?.trim() || undefined\n\n if (dryRun) {\n await checkStudioTarget(reporter, {\n appId,\n isExternal,\n projectId: cliConfig.api?.projectId,\n studioHost: cliConfig.studioHost,\n title,\n urlFlag: flags.url,\n })\n return {application: null, created: false}\n }\n\n const projectId = cliConfig.api?.projectId ?? ''\n // `created` is true when a configured-but-unregistered host was just registered.\n const {application, created} = await findUserApplicationForStudio({\n appId,\n isExternal,\n output,\n projectId,\n studioHost: cliConfig.studioHost,\n title,\n unattended: !!flags.yes,\n urlFlag: flags.url,\n })\n\n if (!application) {\n if (isExternal) {\n output.log('Your project has not been registered with an external studio URL.')\n output.log('Please enter the full URL where your studio is hosted.')\n } else {\n output.log('Your project has not been assigned a studio hostname.')\n output.log('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.log('you will need one. Please enter the subdomain you want to use.')\n }\n\n const registered = await createStudioUserApplication({\n projectId,\n title,\n urlType: isExternal ? 'external' : 'internal',\n })\n deployDebug('Created user application', registered)\n return {application: registered, created: true}\n }\n\n deployDebug('Found user application', application)\n return {application, created}\n}\n\n/** Extracts the studio schema and manifest and uploads them to the schema store. */\nasync function uploadStudioSchema(\n options: DeployAppOptions,\n {applicationId, isExternal}: {applicationId?: string; isExternal: boolean},\n): Promise<StudioManifest | null> {\n const {flags, output, projectRoot, sourceDir} = options\n\n let studioManifest: StudioManifest | null = null\n try {\n studioManifest = await deployStudioSchemasAndManifests(\n {\n applicationId,\n configPath: projectRoot.path,\n isExternal,\n outPath: `${sourceDir}/static`,\n schemaRequired: flags['schema-required'],\n verbose: flags.verbose,\n workDir: projectRoot.directory,\n },\n output,\n )\n } catch (error) {\n deployDebug('Error deploying studio schemas and manifests', error)\n if (error instanceof SchemaExtractionError && error.validation?.length) {\n output.error(formatSchemaValidation(error.validation), {exit: exitCodes.RUNTIME_ERROR})\n }\n output.error(`Error deploying studio schemas and manifests: ${error}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!studioManifest) {\n output.error('Failed to generate studio manifest. Please check your schemas and manifests.', {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n return studioManifest\n}\n\nasync function shipStudioDeployment({\n application,\n isAutoUpdating,\n isExternal,\n options,\n studioManifest,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n isExternal: boolean\n options: DeployAppOptions\n studioManifest: StudioManifest | null\n version: string\n}): Promise<string> {\n const {cliConfig, output, sourceDir} = options\n\n let tarball: Gzip | undefined\n if (!isExternal) {\n tarball = createTar({cwd: dirname(sourceDir)}, [basename(sourceDir)]).pipe(createGzip())\n }\n\n const spin = spinner(isExternal ? 'Registering studio' : 'Deploying to sanity.studio').start()\n let location: string\n try {\n ;({location} = await createDeployment({\n applicationId: application.id,\n isApp: false,\n isAutoUpdating,\n manifest: studioManifest,\n projectId: cliConfig.api?.projectId,\n tarball,\n version,\n }))\n } catch (error) {\n spin.fail()\n throw error\n }\n spin.succeed()\n\n const named = application.title ? ` — \"${application.title}\"` : ''\n output.log(\n isExternal\n ? `\\nSuccess! Studio registered${named}`\n : `\\nSuccess! Studio deployed to ${styleText('cyan', location)}${named}`,\n )\n\n if (getAppId(cliConfig)) return location\n\n const example = `Example:\nexport default defineCliConfig({\n //…\n deployment: {\n ${styleText('cyan', `appId: '${application.id}'`)},\n },\n //…\n})`\n output.log(`\\nAdd ${styleText('cyan', `appId: '${application.id}'`)}`)\n output.log(`to the \\`deployment\\` section in sanity.cli.js or sanity.cli.ts`)\n output.log(`to avoid prompting for application id on next deploy.`)\n output.log(`\\n${example}`)\n\n return location\n}\n\n/**\n * One `datasets` access entry per unique workspace dataset, with a `resourceId`\n * of `\"<projectId>.<dataset>\"`. Deduped, since workspaces can share a dataset.\n */\nfunction toAccess(manifest: StudioManifest | null): BrettAccess[] {\n const resourceIds = new Set(\n (manifest?.workspaces ?? []).map((w) => `${w.projectId}.${w.dataset}`),\n )\n return [...resourceIds].map(\n (resourceId) => ({resourceId, resourceType: 'dataset'}) satisfies BrettAccess,\n )\n}\n\nfunction toWorkspaces(manifest: StudioManifest | null): BrettWorkspace[] {\n return (manifest?.workspaces ?? []).map((workspace) => ({\n basePath: workspace.basePath,\n dataset: workspace.dataset,\n icon: workspace.icon,\n name: workspace.name,\n projectId: workspace.projectId,\n schemaDescriptorId: workspace.schemaDescriptorId,\n subtitle: workspace.subtitle,\n title: workspace.title,\n }))\n}\n\n/** Tells the customer what their host must do for the Dashboard to load the studio from it. */\nfunction logExternalHost({\n built,\n organizationId,\n output,\n sourceDir,\n}: {\n built: boolean\n organizationId: string\n output: DeployAppOptions['output']\n sourceDir: string\n}): void {\n const dir = `${relative(process.cwd(), sourceDir) || '.'}/`\n output.log(`\nThe Dashboard loads this studio from your host, which must:\n 1. Serve ${dir} unchanged at the root of its URL (/mf-manifest.json, /remoteEntry-*.js, /static/*)\n 2. Send Access-Control-Allow-Origin for ${getWorkbenchUrl(organizationId)}\n 3. Respond without cookies or a sign-in${built ? `\\n\\nThis deploy rebuilt ${dir}: copy it to your host before opening the studio in the Dashboard.` : ''}`)\n}\n\nfunction studioBuildSkipReason({\n build,\n isLegacyExternal,\n}: {\n build: boolean\n isLegacyExternal: boolean\n}) {\n if (isLegacyExternal) return 'Build skipped for externally hosted studios'\n if (!build) return 'Build skipped (--no-build) — validating existing output directory'\n return\n}\n"],"names":["basename","dirname","relative","styleText","createGzip","formatSchemaValidation","SchemaExtractionError","exitCodes","spinner","createStudio","deployWorkbenchApp","fetchDeploySummaryDetails","formatDeploySummary","getApplicationUrl","getWorkbench","getWorkbenchUrl","readAppIcon","selectWorkbenchAppId","toWorkbenchPayload","c","createTar","createDeployment","getAppId","NO_ORGANIZATION_ID","NO_PROJECT_ID","buildStudio","checkBlueprintManaged","createStudioUserApplication","checkAutoUpdates","checkBuild","checkExternalUrl","checkPackageVersion","checkStudioTarget","verifyOutputDir","deployDebug","listDeploymentFiles","reportInterfaces","runDeploy","deployStudioSchemasAndManifests","findUserApplicationForStudio","STUDIO_PACKAGE","deployStudio","options","listFiles","flags","projectRoot","sourceDir","external","Promise","resolve","directory","run","runStudioDeployment","type","reporter","cliConfig","output","workDir","isExternal","workbench","isWorkbenchApp","projectId","api","organizationId","app","appId","dryRun","isLegacyExternal","appTitle","title","trim","isAutoUpdating","version","moduleName","report","message","status","solution","kind","projectRootDir","application","studioCreated","workbenchApp","externalUrl","targetAppId","slug","url","created","resolveStudioApplication","isExternallyHosted","build","exitCode","USAGE_ERROR","appIcon","icon","undefined","startedAt","Date","now","summaryDetails","json","applicationId","applicationCreated","rollbackApp","name","visibility","id","rollback","built","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","studioBuildSkipReason","successMessage","mfManifest","interfaces","payload","studioManifest","uploadStudioSchema","Error","access","toAccess","isApp","label","onDeployed","workspaces","toWorkspaces","durationMs","log","showAppIdHint","logExternalHost","action","location","shipStudioDeployment","err","studioHost","urlFlag","unattended","yes","registered","urlType","configPath","path","outPath","schemaRequired","verbose","error","validation","length","exit","RUNTIME_ERROR","tarball","cwd","pipe","spin","start","manifest","fail","succeed","named","example","resourceIds","Set","map","w","dataset","resourceId","resourceType","workspace","basePath","schemaDescriptorId","subtitle","dir","process"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAO,YAAW;AACrD,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAkB,YAAW;AAE/C,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAGEC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,mBAAmB,EACnBC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,WA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,QAAQ;YAC5BvG,OAAOoG,UAAUpG,KAAK;QACxB,CAAA;AACF;AAEA,6FAA6F,GAC7F,SAAS8D,gBAAgB,EACvBvB,KAAK,EACL7C,cAAc,EACdP,MAAM,EACNV,SAAS,EAMV;IACC,MAAM+H,MAAM,GAAG3K,SAAS4K,QAAQrB,GAAG,IAAI3G,cAAc,IAAI,CAAC,CAAC;IAC3DU,OAAOyE,GAAG,CAAC,CAAC;;WAEH,EAAE4C,IAAI;0CACyB,EAAE9J,gBAAgBgD,gBAAgB;yCACnC,EAAE6C,QAAQ,CAAC,wBAAwB,EAAEiE,IAAI,kEAAkE,CAAC,GAAG,IAAI;AAC5J;AAEA,SAAS5D,sBAAsB,EAC7BvB,KAAK,EACLvB,gBAAgB,EAIjB;IACC,IAAIA,kBAAkB,OAAO;IAC7B,IAAI,CAACuB,OAAO,OAAO;IACnB;AACF"}
|
|
@@ -21,7 +21,7 @@ export function getDevServerConfig({ cliConfig, flags, httpPort, output, workDir
|
|
|
21
21
|
const reactStrictMode = resolveReactStrictMode(cliConfig);
|
|
22
22
|
// `views`/`webWorkers` are declared via `defineApplication`, so read them off
|
|
23
23
|
// the branded app result rather than the legacy `app` config type. A config is
|
|
24
|
-
// not an app — it resolves separately and expands
|
|
24
|
+
// not an app — it resolves separately and expands into its config module.
|
|
25
25
|
const app = cliConfig?.app;
|
|
26
26
|
const workbenchConfig = resolveWorkbenchConfig(cliConfig);
|
|
27
27
|
const envBasePath = getSanityEnvVar('BASEPATH', isApp ?? false);
|
|
@@ -45,10 +45,7 @@ export function getDevServerConfig({ cliConfig, flags, httpPort, output, workDir
|
|
|
45
45
|
views: app.views,
|
|
46
46
|
webWorkers: app.webWorkers
|
|
47
47
|
} : workbenchConfig ? {
|
|
48
|
-
config:
|
|
49
|
-
appType: workbenchConfig.appType,
|
|
50
|
-
fields: workbenchConfig.fields
|
|
51
|
-
}
|
|
48
|
+
config: workbenchConfig
|
|
52
49
|
} : undefined,
|
|
53
50
|
// `devAction` passes an explicit port when a running workbench claimed the
|
|
54
51
|
// configured one; otherwise the shared resolution stands.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/dev/servers/getDevServerConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, getSanityEnvVar, type Output} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {resolveAppEntry, resolveWorkbenchConfig} from '@sanity/workbench-cli/build'\n\nimport {type DevServerOptions} from '../../../server/devServer.js'\nimport {determineIsApp} from '../../../util/determineIsApp.js'\nimport {getSharedServerConfig} from '../../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../../util/resolveReactStrictMode.js'\nimport {type DevFlags} from '../types.js'\n\nexport function getDevServerConfig({\n cliConfig,\n flags,\n httpPort,\n output,\n workDir,\n}: {\n cliConfig?: CliConfig\n flags: DevFlags\n httpPort?: number\n output: Output\n workDir: string\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = spinner('Checking configuration files...')\n\n const baseConfig = getSharedServerConfig({\n cliConfig,\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n })\n\n configSpinner.succeed()\n\n const isApp = cliConfig ? determineIsApp(cliConfig) : false\n const reactStrictMode = resolveReactStrictMode(cliConfig)\n // `views`/`webWorkers` are declared via `defineApplication`, so read them off\n // the branded app result rather than the legacy `app` config type. A config is\n // not an app — it resolves separately and expands
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/dev/servers/getDevServerConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, getSanityEnvVar, type Output} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {resolveAppEntry, resolveWorkbenchConfig} from '@sanity/workbench-cli/build'\n\nimport {type DevServerOptions} from '../../../server/devServer.js'\nimport {determineIsApp} from '../../../util/determineIsApp.js'\nimport {getSharedServerConfig} from '../../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../../util/resolveReactStrictMode.js'\nimport {type DevFlags} from '../types.js'\n\nexport function getDevServerConfig({\n cliConfig,\n flags,\n httpPort,\n output,\n workDir,\n}: {\n cliConfig?: CliConfig\n flags: DevFlags\n httpPort?: number\n output: Output\n workDir: string\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = spinner('Checking configuration files...')\n\n const baseConfig = getSharedServerConfig({\n cliConfig,\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n })\n\n configSpinner.succeed()\n\n const isApp = cliConfig ? determineIsApp(cliConfig) : false\n const reactStrictMode = resolveReactStrictMode(cliConfig)\n // `views`/`webWorkers` are declared via `defineApplication`, so read them off\n // the branded app result rather than the legacy `app` config type. A config is\n // not an app — it resolves separately and expands into its config module.\n const app = cliConfig?.app\n const workbenchConfig = resolveWorkbenchConfig(cliConfig)\n\n const envBasePath = getSanityEnvVar('BASEPATH', isApp ?? false)\n if (envBasePath && cliConfig?.project?.basePath) {\n output.warn(\n `Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n // Unstable opt-in to Vite's experimental bundled dev mode, via\n // `unstable_bundledDev` in sanity.cli.ts. Defaults to off.\n const bundledDev = cliConfig?.unstable_bundledDev ?? false\n if (bundledDev) {\n output.log(`${logSymbols.info} Running dev server with experimental Vite bundled dev mode`)\n }\n\n return {\n ...baseConfig,\n bundledDev,\n documentComponent: cliConfig?.unstable_documentComponent,\n // The app's navigable entry. A branded app that omits `entry` has no app\n // view: the runtime/federation skip the `./App` render path entirely.\n entry: resolveAppEntry(app),\n exposes: isWorkbenchApp(app)\n ? {views: app.views, webWorkers: app.webWorkers}\n : workbenchConfig\n ? {config: workbenchConfig}\n : undefined,\n // `devAction` passes an explicit port when a running workbench claimed the\n // configured one; otherwise the shared resolution stands.\n httpPort: httpPort ?? baseConfig.httpPort,\n isWorkbenchApp: isWorkbenchApp(app) || !!workbenchConfig,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n reactStrictMode,\n staticPath: path.join(workDir, 'static'),\n typegen: cliConfig?.typegen,\n workbenchAppId: isWorkbenchApp(app) ? app.slug : undefined,\n }\n}\n"],"names":["path","getSanityEnvVar","logSymbols","spinner","isWorkbenchApp","resolveAppEntry","resolveWorkbenchConfig","determineIsApp","getSharedServerConfig","resolveReactStrictMode","getDevServerConfig","cliConfig","flags","httpPort","output","workDir","configSpinner","baseConfig","host","port","succeed","isApp","reactStrictMode","app","workbenchConfig","envBasePath","project","basePath","warn","bundledDev","unstable_bundledDev","log","info","documentComponent","unstable_documentComponent","entry","exposes","views","webWorkers","config","undefined","reactCompiler","staticPath","join","typegen","workbenchAppId","slug"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAwBC,eAAe,QAAoB,mBAAkB;AAC7E,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AACvD,SAAQC,cAAc,QAAO,wBAAuB;AACpD,SAAQC,eAAe,EAAEC,sBAAsB,QAAO,8BAA6B;AAGnF,SAAQC,cAAc,QAAO,kCAAiC;AAC9D,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,sBAAsB,QAAO,0CAAyC;AAG9E,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,KAAK,EACLC,QAAQ,EACRC,MAAM,EACNC,OAAO,EAOR;IACC,MAAMC,gBAAgBb,QAAQ;IAE9B,MAAMc,aAAaT,sBAAsB;QACvCG;QACAC,OAAO;YACLM,MAAMN,MAAMM,IAAI;YAChBC,MAAMP,MAAMO,IAAI;QAClB;QACAJ;IACF;IAEAC,cAAcI,OAAO;IAErB,MAAMC,QAAQV,YAAYJ,eAAeI,aAAa;IACtD,MAAMW,kBAAkBb,uBAAuBE;IAC/C,8EAA8E;IAC9E,+EAA+E;IAC/E,0EAA0E;IAC1E,MAAMY,MAAMZ,WAAWY;IACvB,MAAMC,kBAAkBlB,uBAAuBK;IAE/C,MAAMc,cAAcxB,gBAAgB,YAAYoB,SAAS;IACzD,IAAII,eAAed,WAAWe,SAASC,UAAU;QAC/Cb,OAAOc,IAAI,CACT,CAAC,iCAAiC,EAAEjB,UAAUe,OAAO,CAACC,QAAQ,CAAC,wCAAwC,EAAEF,YAAY,CAAC,CAAC;IAE3H;IAEA,+DAA+D;IAC/D,2DAA2D;IAC3D,MAAMI,aAAalB,WAAWmB,uBAAuB;IACrD,IAAID,YAAY;QACdf,OAAOiB,GAAG,CAAC,GAAG7B,WAAW8B,IAAI,CAAC,2DAA2D,CAAC;IAC5F;IAEA,OAAO;QACL,GAAGf,UAAU;QACbY;QACAI,mBAAmBtB,WAAWuB;QAC9B,yEAAyE;QACzE,sEAAsE;QACtEC,OAAO9B,gBAAgBkB;QACvBa,SAAShC,eAAemB,OACpB;YAACc,OAAOd,IAAIc,KAAK;YAAEC,YAAYf,IAAIe,UAAU;QAAA,IAC7Cd,kBACE;YAACe,QAAQf;QAAe,IACxBgB;QACN,2EAA2E;QAC3E,0DAA0D;QAC1D3B,UAAUA,YAAYI,WAAWJ,QAAQ;QACzCT,gBAAgBA,eAAemB,QAAQ,CAAC,CAACC;QACzCiB,eAAe9B,aAAa,mBAAmBA,YAAYA,UAAU8B,aAAa,GAAGD;QACrFlB;QACAoB,YAAY1C,KAAK2C,IAAI,CAAC5B,SAAS;QAC/B6B,SAASjC,WAAWiC;QACpBC,gBAAgBzC,eAAemB,OAAOA,IAAIuB,IAAI,GAAGN;IACnD;AACF"}
|
|
@@ -71,15 +71,16 @@ export async function extractGraphQLAPIsWorker(port, data, deps) {
|
|
|
71
71
|
cliConfig,
|
|
72
72
|
workspaces
|
|
73
73
|
});
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const [{ compileSchema }, { RELEASE_DOCUMENT_TYPE: releaseDocumentType }] = await Promise.all([
|
|
75
|
+
deps.loadStudioCliTooling(workDir),
|
|
76
|
+
deps.resolveLocalPackage('sanity', workDir)
|
|
77
|
+
]);
|
|
76
78
|
// Build default schema to identify built-in types that should be filtered out
|
|
77
|
-
const defaultSchema =
|
|
79
|
+
const defaultSchema = compileSchema({
|
|
78
80
|
name: 'default',
|
|
79
81
|
types: []
|
|
80
82
|
});
|
|
81
83
|
const defaultTypes = defaultSchema.getTypeNames();
|
|
82
|
-
const isCustomType = (type)=>!defaultTypes.includes(type.name);
|
|
83
84
|
// For each API: create compiled schema, extract GraphQL spec, catch SchemaError
|
|
84
85
|
const results = [];
|
|
85
86
|
for (const api of resolvedApis){
|
|
@@ -94,9 +95,15 @@ export async function extractGraphQLAPIsWorker(port, data, deps) {
|
|
|
94
95
|
tag: api.tag
|
|
95
96
|
};
|
|
96
97
|
try {
|
|
97
|
-
const
|
|
98
|
+
const excludedTypes = new Set(defaultTypes);
|
|
99
|
+
if (releaseDocumentType && api.schemaTypes.some((type)=>type.name === releaseDocumentType)) {
|
|
100
|
+
// Studio's release records and their metadata are managed by Content Releases.
|
|
101
|
+
excludedTypes.add(releaseDocumentType);
|
|
102
|
+
excludedTypes.add('sanity.releaseMetadata');
|
|
103
|
+
}
|
|
104
|
+
const schema = compileSchema({
|
|
98
105
|
name: 'default',
|
|
99
|
-
types: api.schemaTypes.filter((type)
|
|
106
|
+
types: api.schemaTypes.filter((type)=>!excludedTypes.has(type.name))
|
|
100
107
|
});
|
|
101
108
|
const extracted = extractFromSanitySchema(schema, {
|
|
102
109
|
nonNullDocumentFields: nonNullDocumentFieldsFlag === undefined ? api.nonNullDocumentFields : nonNullDocumentFieldsFlag,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/graphql/extractGraphQLAPIs.ts"],"sourcesContent":["import {isMainThread, type MessagePort} from 'node:worker_threads'\n\nimport {findStudioConfigPath, getCliConfig} from '@sanity/cli-core/config'\nimport {subdebug} from '@sanity/cli-core/debug'\nimport {studioWorkerTask} from '@sanity/cli-core/tasks'\nimport {type CliConfig} from '@sanity/cli-core/types'\n\nimport {isSchemaError} from '../../util/isSchemaError.js'\nimport {extractFromSanitySchema} from './extractFromSanitySchema.js'\nimport {resolveGraphQLApis, type Workspace} from './resolveGraphQLApisFromWorkspaces.js'\nimport {SchemaError} from './SchemaError.js'\nimport {\n type ExtractedGraphQLAPI,\n type GraphQLAPIConfig,\n type GraphQLWorkerResult,\n type SchemaDefinitionish,\n} from './types.js'\n\n// ---------------------------------------------------------------------------\n// Main-thread orchestrator\n// ---------------------------------------------------------------------------\n\nexport async function extractGraphQLAPIs(\n workDir: string,\n options: {nonNullDocumentFieldsFlag?: boolean; withUnionCache?: boolean},\n): Promise<ExtractedGraphQLAPI[]> {\n if (!isMainThread) {\n throw new Error('extractGraphQLAPIs() must be called from the main thread')\n }\n\n const [cliConfig, configPath] = await Promise.all([\n getCliConfig(workDir),\n findStudioConfigPath(workDir),\n ])\n\n const result = await studioWorkerTask<GraphQLWorkerResult>(\n new URL('extractGraphQLAPIs.worker.js', import.meta.url),\n {\n name: 'extractGraphQLAPIs',\n studioRootPath: workDir,\n workerData: {\n cliConfig: extractGraphQLConfig(cliConfig),\n configPath,\n nonNullDocumentFieldsFlag: options.nonNullDocumentFieldsFlag,\n withUnionCache: options.withUnionCache,\n workDir,\n },\n },\n )\n\n if (result.configErrors?.length) {\n throw new SchemaError(result.configErrors)\n }\n\n return result.apis\n}\n\nfunction extractGraphQLConfig(config: CliConfig) {\n return {\n graphql: config.graphql,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Worker logic (runs inside the worker thread)\n// ---------------------------------------------------------------------------\n\nexport interface ExtractWorkerData {\n configPath: string\n workDir: string\n\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n nonNullDocumentFieldsFlag?: boolean\n withUnionCache?: boolean\n}\n\nexport interface ExtractWorkerDeps {\n getStudioWorkspaces: (configPath: string) => Promise<unknown[]>\n resolveLocalPackage: <T>(name: string, workDir: string) => Promise<T>\n}\n\nconst debug = subdebug('graphql:extractGraphQLAPIs:worker')\n\nexport async function extractGraphQLAPIsWorker(\n port: MessagePort,\n data: ExtractWorkerData,\n deps: ExtractWorkerDeps,\n): Promise<void> {\n const {cliConfig, configPath, nonNullDocumentFieldsFlag, withUnionCache, workDir} = data\n\n // Load workspaces — this loads sanity.config.ts through Vite, caching `sanity` in the process\n let workspaces: Workspace[]\n try {\n workspaces = (await deps.getStudioWorkspaces(configPath)) as Workspace[]\n } catch (err) {\n if (isSchemaError(err)) {\n const validation = err.schema._validation ?? []\n const configErrors = validation\n .map((g) => ({...g, problems: g.problems.filter((p) => p.severity === 'error')}))\n .filter((g) => g.problems.length > 0)\n\n // Only treat error-severity problems as schema errors. If the validation\n // only contains warnings, re-throw the original error so it isn't silently\n // swallowed — warnings alone should not block deployment.\n if (configErrors.length === 0) {\n throw err\n }\n\n port.postMessage({apis: [], configErrors} satisfies GraphQLWorkerResult)\n return\n }\n throw err\n }\n\n // Resolve which GraphQL APIs to deploy from workspace + CLI config\n const resolvedApis = resolveGraphQLApis({cliConfig, workspaces})\n\n // Get createSchema from sanity (0ms — already cached by ViteNodeRunner)\n const {createSchema} = await deps.resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n\n // Build default schema to identify built-in types that should be filtered out\n const defaultSchema = createSchema({name: 'default', types: []})\n const defaultTypes = defaultSchema.getTypeNames()\n const isCustomType = (type: SchemaDefinitionish) => !defaultTypes.includes(type.name)\n\n // For each API: create compiled schema, extract GraphQL spec, catch SchemaError\n const results: ExtractedGraphQLAPI[] = []\n\n for (const api of resolvedApis) {\n const apiBase: Omit<ExtractedGraphQLAPI, 'extracted' | 'extractionError' | 'schemaErrors'> = {\n dataset: api.dataset,\n filterSuffix: api.filterSuffix,\n generation: api.generation,\n id: api.id,\n nonNullDocumentFields: api.nonNullDocumentFields,\n playground: api.playground,\n projectId: api.projectId,\n tag: api.tag,\n }\n\n try {\n const schema = createSchema({\n name: 'default',\n types: api.schemaTypes.filter((type) => isCustomType(type)),\n })\n\n const extracted = extractFromSanitySchema(schema, {\n nonNullDocumentFields:\n nonNullDocumentFieldsFlag === undefined\n ? api.nonNullDocumentFields\n : nonNullDocumentFieldsFlag,\n withUnionCache,\n })\n\n results.push({...apiBase, extracted})\n } catch (err) {\n if (err instanceof SchemaError) {\n results.push({...apiBase, schemaErrors: err.problemGroups})\n } else if (isSchemaError(err)) {\n // Sanity's internal schema error from createSchema() — different class from our\n // SchemaError, but carries structured validation data on err.schema._validation.\n // This is low-probability since getStudioWorkspaces() above already validated,\n // but createSchema() on filtered types could still surface issues.\n const validation = err.schema._validation ?? []\n const errorGroups = validation\n .map((g) => ({...g, problems: g.problems.filter((p) => p.severity === 'error')}))\n .filter((g) => g.problems.length > 0)\n if (errorGroups.length > 0) {\n results.push({...apiBase, schemaErrors: errorGroups})\n } else {\n // Warning-only or empty _validation — fall through to generic error with the\n // message, matching the global path which re-throws warning-only errors.\n results.push({\n ...apiBase,\n extractionError: err instanceof Error ? err.message : String(err),\n })\n }\n } else {\n debug(\n 'Schema extraction failed for %s/%s: %O',\n apiBase.dataset,\n apiBase.tag ?? 'default',\n err,\n )\n results.push({\n ...apiBase,\n extractionError: err instanceof Error ? err.message : String(err),\n })\n }\n }\n }\n\n port.postMessage({apis: results} satisfies GraphQLWorkerResult)\n}\n"],"names":["isMainThread","findStudioConfigPath","getCliConfig","subdebug","studioWorkerTask","isSchemaError","extractFromSanitySchema","resolveGraphQLApis","SchemaError","extractGraphQLAPIs","workDir","options","Error","cliConfig","configPath","Promise","all","result","URL","url","name","studioRootPath","workerData","extractGraphQLConfig","nonNullDocumentFieldsFlag","withUnionCache","configErrors","length","apis","config","graphql","debug","extractGraphQLAPIsWorker","port","data","deps","workspaces","getStudioWorkspaces","err","validation","schema","_validation","map","g","problems","filter","p","severity","postMessage","resolvedApis","createSchema","resolveLocalPackage","defaultSchema","types","defaultTypes","getTypeNames","isCustomType","type","includes","results","api","apiBase","dataset","filterSuffix","generation","id","nonNullDocumentFields","playground","projectId","tag","schemaTypes","extracted","undefined","push","schemaErrors","problemGroups","errorGroups","extractionError","message","String"],"mappings":"AAAA,SAAQA,YAAY,QAAyB,sBAAqB;AAElE,SAAQC,oBAAoB,EAAEC,YAAY,QAAO,0BAAyB;AAC1E,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,gBAAgB,QAAO,yBAAwB;AAGvD,SAAQC,aAAa,QAAO,8BAA6B;AACzD,SAAQC,uBAAuB,QAAO,+BAA8B;AACpE,SAAQC,kBAAkB,QAAuB,wCAAuC;AACxF,SAAQC,WAAW,QAAO,mBAAkB;AAQ5C,8EAA8E;AAC9E,2BAA2B;AAC3B,8EAA8E;AAE9E,OAAO,eAAeC,mBACpBC,OAAe,EACfC,OAAwE;IAExE,IAAI,CAACX,cAAc;QACjB,MAAM,IAAIY,MAAM;IAClB;IAEA,MAAM,CAACC,WAAWC,WAAW,GAAG,MAAMC,QAAQC,GAAG,CAAC;QAChDd,aAAaQ;QACbT,qBAAqBS;KACtB;IAED,MAAMO,SAAS,MAAMb,iBACnB,IAAIc,IAAI,gCAAgC,YAAYC,GAAG,GACvD;QACEC,MAAM;QACNC,gBAAgBX;QAChBY,YAAY;YACVT,WAAWU,qBAAqBV;YAChCC;YACAU,2BAA2Bb,QAAQa,yBAAyB;YAC5DC,gBAAgBd,QAAQc,cAAc;YACtCf;QACF;IACF;IAGF,IAAIO,OAAOS,YAAY,EAAEC,QAAQ;QAC/B,MAAM,IAAInB,YAAYS,OAAOS,YAAY;IAC3C;IAEA,OAAOT,OAAOW,IAAI;AACpB;AAEA,SAASL,qBAAqBM,MAAiB;IAC7C,OAAO;QACLC,SAASD,OAAOC,OAAO;IACzB;AACF;AAoBA,MAAMC,QAAQ5B,SAAS;AAEvB,OAAO,eAAe6B,yBACpBC,IAAiB,EACjBC,IAAuB,EACvBC,IAAuB;IAEvB,MAAM,EAACtB,SAAS,EAAEC,UAAU,EAAEU,yBAAyB,EAAEC,cAAc,EAAEf,OAAO,EAAC,GAAGwB;IAEpF,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AAO;gBACLP,MACE,0CACA8B,QAAQC,OAAO,EACfD,QAAQQ,GAAG,IAAI,WACf/B;gBAEFqB,QAAQc,IAAI,CAAC;oBACX,GAAGZ,OAAO;oBACVgB,iBAAiBvC,eAAe1B,QAAQ0B,IAAIwC,OAAO,GAAGC,OAAOzC;gBAC/D;YACF;QACF;IACF;IAEAL,KAAKe,WAAW,CAAC;QAACpB,MAAM+B;IAAO;AACjC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/graphql/extractGraphQLAPIs.ts"],"sourcesContent":["import {isMainThread, type MessagePort} from 'node:worker_threads'\n\nimport {findStudioConfigPath, getCliConfig} from '@sanity/cli-core/config'\nimport {subdebug} from '@sanity/cli-core/debug'\nimport {type StudioCliTooling} from '@sanity/cli-core/package-manager'\nimport {studioWorkerTask} from '@sanity/cli-core/tasks'\nimport {type CliConfig} from '@sanity/cli-core/types'\n\nimport {isSchemaError} from '../../util/isSchemaError.js'\nimport {extractFromSanitySchema} from './extractFromSanitySchema.js'\nimport {resolveGraphQLApis, type Workspace} from './resolveGraphQLApisFromWorkspaces.js'\nimport {SchemaError} from './SchemaError.js'\nimport {type ExtractedGraphQLAPI, type GraphQLAPIConfig, type GraphQLWorkerResult} from './types.js'\n\n// ---------------------------------------------------------------------------\n// Main-thread orchestrator\n// ---------------------------------------------------------------------------\n\nexport async function extractGraphQLAPIs(\n workDir: string,\n options: {nonNullDocumentFieldsFlag?: boolean; withUnionCache?: boolean},\n): Promise<ExtractedGraphQLAPI[]> {\n if (!isMainThread) {\n throw new Error('extractGraphQLAPIs() must be called from the main thread')\n }\n\n const [cliConfig, configPath] = await Promise.all([\n getCliConfig(workDir),\n findStudioConfigPath(workDir),\n ])\n\n const result = await studioWorkerTask<GraphQLWorkerResult>(\n new URL('extractGraphQLAPIs.worker.js', import.meta.url),\n {\n name: 'extractGraphQLAPIs',\n studioRootPath: workDir,\n workerData: {\n cliConfig: extractGraphQLConfig(cliConfig),\n configPath,\n nonNullDocumentFieldsFlag: options.nonNullDocumentFieldsFlag,\n withUnionCache: options.withUnionCache,\n workDir,\n },\n },\n )\n\n if (result.configErrors?.length) {\n throw new SchemaError(result.configErrors)\n }\n\n return result.apis\n}\n\nfunction extractGraphQLConfig(config: CliConfig) {\n return {\n graphql: config.graphql,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Worker logic (runs inside the worker thread)\n// ---------------------------------------------------------------------------\n\nexport interface ExtractWorkerData {\n configPath: string\n workDir: string\n\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n nonNullDocumentFieldsFlag?: boolean\n withUnionCache?: boolean\n}\n\nexport interface ExtractWorkerDeps {\n getStudioWorkspaces: (configPath: string) => Promise<unknown[]>\n loadStudioCliTooling: (workDir: string) => Promise<Pick<StudioCliTooling, 'compileSchema'>>\n resolveLocalPackage: <T>(name: string, workDir: string) => Promise<T>\n}\n\nconst debug = subdebug('graphql:extractGraphQLAPIs:worker')\n\nexport async function extractGraphQLAPIsWorker(\n port: MessagePort,\n data: ExtractWorkerData,\n deps: ExtractWorkerDeps,\n): Promise<void> {\n const {cliConfig, configPath, nonNullDocumentFieldsFlag, withUnionCache, workDir} = data\n\n // Load workspaces — this loads sanity.config.ts through Vite, caching `sanity` in the process\n let workspaces: Workspace[]\n try {\n workspaces = (await deps.getStudioWorkspaces(configPath)) as Workspace[]\n } catch (err) {\n if (isSchemaError(err)) {\n const validation = err.schema._validation ?? []\n const configErrors = validation\n .map((g) => ({...g, problems: g.problems.filter((p) => p.severity === 'error')}))\n .filter((g) => g.problems.length > 0)\n\n // Only treat error-severity problems as schema errors. If the validation\n // only contains warnings, re-throw the original error so it isn't silently\n // swallowed — warnings alone should not block deployment.\n if (configErrors.length === 0) {\n throw err\n }\n\n port.postMessage({apis: [], configErrors} satisfies GraphQLWorkerResult)\n return\n }\n throw err\n }\n\n // Resolve which GraphQL APIs to deploy from workspace + CLI config\n const resolvedApis = resolveGraphQLApis({cliConfig, workspaces})\n\n const [{compileSchema}, {RELEASE_DOCUMENT_TYPE: releaseDocumentType}] = await Promise.all([\n deps.loadStudioCliTooling(workDir),\n deps.resolveLocalPackage<{RELEASE_DOCUMENT_TYPE?: string}>('sanity', workDir),\n ])\n\n // Build default schema to identify built-in types that should be filtered out\n const defaultSchema = compileSchema({name: 'default', types: []})\n const defaultTypes = defaultSchema.getTypeNames()\n\n // For each API: create compiled schema, extract GraphQL spec, catch SchemaError\n const results: ExtractedGraphQLAPI[] = []\n\n for (const api of resolvedApis) {\n const apiBase: Omit<ExtractedGraphQLAPI, 'extracted' | 'extractionError' | 'schemaErrors'> = {\n dataset: api.dataset,\n filterSuffix: api.filterSuffix,\n generation: api.generation,\n id: api.id,\n nonNullDocumentFields: api.nonNullDocumentFields,\n playground: api.playground,\n projectId: api.projectId,\n tag: api.tag,\n }\n\n try {\n const excludedTypes = new Set(defaultTypes)\n if (\n releaseDocumentType &&\n api.schemaTypes.some((type) => type.name === releaseDocumentType)\n ) {\n // Studio's release records and their metadata are managed by Content Releases.\n excludedTypes.add(releaseDocumentType)\n excludedTypes.add('sanity.releaseMetadata')\n }\n\n const schema = compileSchema({\n name: 'default',\n types: api.schemaTypes.filter((type) => !excludedTypes.has(type.name)),\n })\n\n const extracted = extractFromSanitySchema(schema, {\n nonNullDocumentFields:\n nonNullDocumentFieldsFlag === undefined\n ? api.nonNullDocumentFields\n : nonNullDocumentFieldsFlag,\n withUnionCache,\n })\n\n results.push({...apiBase, extracted})\n } catch (err) {\n if (err instanceof SchemaError) {\n results.push({...apiBase, schemaErrors: err.problemGroups})\n } else if (isSchemaError(err)) {\n // Sanity's internal schema error from createSchema() — different class from our\n // SchemaError, but carries structured validation data on err.schema._validation.\n // This is low-probability since getStudioWorkspaces() above already validated,\n // but createSchema() on filtered types could still surface issues.\n const validation = err.schema._validation ?? []\n const errorGroups = validation\n .map((g) => ({...g, problems: g.problems.filter((p) => p.severity === 'error')}))\n .filter((g) => g.problems.length > 0)\n if (errorGroups.length > 0) {\n results.push({...apiBase, schemaErrors: errorGroups})\n } else {\n // Warning-only or empty _validation — fall through to generic error with the\n // message, matching the global path which re-throws warning-only errors.\n results.push({\n ...apiBase,\n extractionError: err instanceof Error ? err.message : String(err),\n })\n }\n } else {\n debug(\n 'Schema extraction failed for %s/%s: %O',\n apiBase.dataset,\n apiBase.tag ?? 'default',\n err,\n )\n results.push({\n ...apiBase,\n extractionError: err instanceof Error ? err.message : String(err),\n })\n }\n }\n }\n\n port.postMessage({apis: results} satisfies GraphQLWorkerResult)\n}\n"],"names":["isMainThread","findStudioConfigPath","getCliConfig","subdebug","studioWorkerTask","isSchemaError","extractFromSanitySchema","resolveGraphQLApis","SchemaError","extractGraphQLAPIs","workDir","options","Error","cliConfig","configPath","Promise","all","result","URL","url","name","studioRootPath","workerData","extractGraphQLConfig","nonNullDocumentFieldsFlag","withUnionCache","configErrors","length","apis","config","graphql","debug","extractGraphQLAPIsWorker","port","data","deps","workspaces","getStudioWorkspaces","err","validation","schema","_validation","map","g","problems","filter","p","severity","postMessage","resolvedApis","compileSchema","RELEASE_DOCUMENT_TYPE","releaseDocumentType","loadStudioCliTooling","resolveLocalPackage","defaultSchema","types","defaultTypes","getTypeNames","results","api","apiBase","dataset","filterSuffix","generation","id","nonNullDocumentFields","playground","projectId","tag","excludedTypes","Set","schemaTypes","some","type","add","has","extracted","undefined","push","schemaErrors","problemGroups","errorGroups","extractionError","message","String"],"mappings":"AAAA,SAAQA,YAAY,QAAyB,sBAAqB;AAElE,SAAQC,oBAAoB,EAAEC,YAAY,QAAO,0BAAyB;AAC1E,SAAQC,QAAQ,QAAO,yBAAwB;AAE/C,SAAQC,gBAAgB,QAAO,yBAAwB;AAGvD,SAAQC,aAAa,QAAO,8BAA6B;AACzD,SAAQC,uBAAuB,QAAO,+BAA8B;AACpE,SAAQC,kBAAkB,QAAuB,wCAAuC;AACxF,SAAQC,WAAW,QAAO,mBAAkB;AAG5C,8EAA8E;AAC9E,2BAA2B;AAC3B,8EAA8E;AAE9E,OAAO,eAAeC,mBACpBC,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1B,QAAQ0B,IAAI8C,OAAO,GAAGC,OAAO/C;gBAC/D;YACF;QACF;IACF;IAEAL,KAAKe,WAAW,CAAC;QAACpB,MAAM+B;IAAO;AACjC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
2
|
-
import { getStudioWorkspaces, resolveLocalPackage } from '@sanity/cli-core';
|
|
2
|
+
import { getStudioWorkspaces, loadStudioCliTooling, resolveLocalPackage } from '@sanity/cli-core';
|
|
3
3
|
import { extractGraphQLAPIsWorker } from './extractGraphQLAPIs.js';
|
|
4
4
|
if (isMainThread || !parentPort) {
|
|
5
5
|
throw new Error('This module must be run as a worker thread');
|
|
6
6
|
}
|
|
7
7
|
await extractGraphQLAPIsWorker(parentPort, workerData, {
|
|
8
8
|
getStudioWorkspaces,
|
|
9
|
+
loadStudioCliTooling,
|
|
9
10
|
resolveLocalPackage
|
|
10
11
|
});
|
|
11
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/graphql/extractGraphQLAPIs.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, resolveLocalPackage} from '@sanity/cli-core'\n\nimport {extractGraphQLAPIsWorker, type ExtractWorkerData} from './extractGraphQLAPIs.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('This module must be run as a worker thread')\n}\n\nawait extractGraphQLAPIsWorker(parentPort, workerData as ExtractWorkerData, {\n getStudioWorkspaces,\n resolveLocalPackage,\n})\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","resolveLocalPackage","extractGraphQLAPIsWorker","Error"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,mBAAmB,QAAO,mBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/graphql/extractGraphQLAPIs.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, loadStudioCliTooling, resolveLocalPackage} from '@sanity/cli-core'\n\nimport {extractGraphQLAPIsWorker, type ExtractWorkerData} from './extractGraphQLAPIs.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('This module must be run as a worker thread')\n}\n\nawait extractGraphQLAPIsWorker(parentPort, workerData as ExtractWorkerData, {\n getStudioWorkspaces,\n loadStudioCliTooling,\n resolveLocalPackage,\n})\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","loadStudioCliTooling","resolveLocalPackage","extractGraphQLAPIsWorker","Error"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,oBAAoB,EAAEC,mBAAmB,QAAO,mBAAkB;AAE/F,SAAQC,wBAAwB,QAA+B,0BAAyB;AAExF,IAAIN,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIM,MAAM;AAClB;AAEA,MAAMD,yBAAyBL,YAAYC,YAAiC;IAC1EC;IACAC;IACAC;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
import { exitCodes, subdebug } from '@sanity/cli-core';
|
|
3
3
|
import { logSymbols, spinner } from '@sanity/cli-core/ux';
|
|
4
|
+
import { checkBlueprintDestination } from '@sanity/cli-setup';
|
|
4
5
|
import { frameworks } from '@vercel/frameworks';
|
|
5
6
|
import deburr from 'lodash-es/deburr.js';
|
|
6
7
|
import { promptForConfigFiles } from '../../prompts/init/nextjs.js';
|
|
@@ -21,6 +22,7 @@ import { determineAppTemplate } from './determineAppTemplate.js';
|
|
|
21
22
|
import { determineMediaLibraryTemplate } from './determineMediaLibraryTemplate.js';
|
|
22
23
|
import { createOrAppendEnvVars } from './env/createOrAppendEnvVars.js';
|
|
23
24
|
import { initApp } from './initApp.js';
|
|
25
|
+
import { initBlueprint } from './initBlueprint.js';
|
|
24
26
|
import { InitError } from './initError.js';
|
|
25
27
|
import { flagOrDefault, shouldPrompt, writeStagingEnvIfNeeded } from './initHelpers.js';
|
|
26
28
|
import { initNextJs } from './initNextJs.js';
|
|
@@ -60,6 +62,10 @@ export async function initAction(options, context) {
|
|
|
60
62
|
rootPath: workDir
|
|
61
63
|
});
|
|
62
64
|
const isNextJs = detectedFramework?.slug === 'nextjs';
|
|
65
|
+
const isBlueprint = options.withBlueprints === true;
|
|
66
|
+
if (isBlueprint && (options.outputPath || options.unattended)) {
|
|
67
|
+
checkBlueprintDestination(options.outputPath || workDir);
|
|
68
|
+
}
|
|
63
69
|
let remoteTemplateInfo;
|
|
64
70
|
if (options.template && checkIsRemoteTemplate(options.template)) {
|
|
65
71
|
remoteTemplateInfo = await getGitHubRepoInfo(options.template, options.templateToken);
|
|
@@ -83,7 +89,7 @@ export async function initAction(options, context) {
|
|
|
83
89
|
checkFlagsInUnattendedMode(options, {
|
|
84
90
|
isAppTemplate,
|
|
85
91
|
isMediaLibraryTemplate,
|
|
86
|
-
isNextJs
|
|
92
|
+
useCurrentPath: isNextJs || isBlueprint
|
|
87
93
|
});
|
|
88
94
|
}
|
|
89
95
|
trace.start();
|
|
@@ -100,6 +106,9 @@ export async function initAction(options, context) {
|
|
|
100
106
|
},
|
|
101
107
|
step: 'start'
|
|
102
108
|
});
|
|
109
|
+
if (isBlueprint) {
|
|
110
|
+
output.log('Setting up a Blueprint');
|
|
111
|
+
}
|
|
103
112
|
const planId = await getPlan(options, output, trace);
|
|
104
113
|
let envFilenameDefault = '.env';
|
|
105
114
|
if (detectedFramework && detectedFramework.slug === 'nextjs') {
|
|
@@ -154,6 +163,24 @@ export async function initAction(options, context) {
|
|
|
154
163
|
trace.complete();
|
|
155
164
|
return;
|
|
156
165
|
}
|
|
166
|
+
if (isBlueprint) {
|
|
167
|
+
const outputPath = await getProjectOutputPath({
|
|
168
|
+
initFramework: false,
|
|
169
|
+
outputPath: options.outputPath,
|
|
170
|
+
sluggedName: projectId,
|
|
171
|
+
unattended: options.unattended,
|
|
172
|
+
useEnv: false,
|
|
173
|
+
workDir
|
|
174
|
+
});
|
|
175
|
+
const result = await initBlueprint({
|
|
176
|
+
datasetName,
|
|
177
|
+
output,
|
|
178
|
+
outputPath,
|
|
179
|
+
projectId
|
|
180
|
+
});
|
|
181
|
+
trace.complete();
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
157
184
|
// Detect editors once, then share the result with MCP and skills setup so
|
|
158
185
|
// we don't pay the detection cost (filesystem probes + CLI execa calls) twice.
|
|
159
186
|
const detectedEditors = options.mcpMode === 'skip' && options.skillsMode === 'skip' ? [] : await detectAvailableEditors();
|
|
@@ -301,7 +328,7 @@ export async function initAction(options, context) {
|
|
|
301
328
|
}));
|
|
302
329
|
trace.complete();
|
|
303
330
|
}
|
|
304
|
-
function checkFlagsInUnattendedMode(options, { isAppTemplate, isMediaLibraryTemplate,
|
|
331
|
+
function checkFlagsInUnattendedMode(options, { isAppTemplate, isMediaLibraryTemplate, useCurrentPath }) {
|
|
305
332
|
debug('Unattended mode, validating required options');
|
|
306
333
|
const errors = [];
|
|
307
334
|
if (isAppTemplate) {
|
|
@@ -318,7 +345,7 @@ function checkFlagsInUnattendedMode(options, { isAppTemplate, isMediaLibraryTemp
|
|
|
318
345
|
errors.push('Project or organization is required for app templates in unattended mode. ' + 'Pass `--project <id>` or `--organization <id>`. To create a project, pass ' + '`--project-name <name>` with `--organization <id>`.');
|
|
319
346
|
}
|
|
320
347
|
} else {
|
|
321
|
-
if (!
|
|
348
|
+
if (!useCurrentPath && !options.bare && !options.outputPath) {
|
|
322
349
|
errors.push('Output path is required in unattended mode. Pass it with `--output-path <path>`.');
|
|
323
350
|
}
|
|
324
351
|
if (!options.project && !options.projectName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/init/initAction.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n exitCodes,\n type SanityOrgUser,\n subdebug,\n type TelemetryUserProperties,\n} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {type TelemetryTrace} from '@sanity/telemetry'\nimport {type Framework, frameworks} from '@vercel/frameworks'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {promptForConfigFiles} from '../../prompts/init/nextjs.js'\nimport {getCliUser} from '../../services/user.js'\nimport {CLIInitStepCompleted, type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {detectFrameworkRecord} from '../../util/detectFramework.js'\nimport {formatCliErrorMessages} from '../../util/formatCliErrorMessages.js'\nimport {getProjectDefaults} from '../../util/getProjectDefaults.js'\nimport {validateSession} from '../auth/ensureAuthenticated.js'\nimport {getProviderName, getUserDisplayName} from '../auth/getProviderName.js'\nimport {login} from '../auth/login/login.js'\nimport {LOGIN_REQUIRED_MESSAGE} from '../auth/login/loginInstructions.js'\nimport {detectAvailableEditors} from '../mcp/detectAvailableEditors.js'\nimport {setupMCP} from '../mcp/setupMCP.js'\nimport {setupSkills} from '../skills/setupSkills.js'\nimport {checkNextJsReactCompatibility} from './checkNextJsReactCompatibility.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {determineMediaLibraryTemplate} from './determineMediaLibraryTemplate.js'\nimport {createOrAppendEnvVars} from './env/createOrAppendEnvVars.js'\nimport {initApp} from './initApp.js'\nimport {InitError} from './initError.js'\nimport {flagOrDefault, shouldPrompt, writeStagingEnvIfNeeded} from './initHelpers.js'\nimport {initNextJs} from './initNextJs.js'\nimport {initStudio} from './initStudio.js'\nimport {getPlan} from './plan/getPlan.js'\nimport {createProjectFromName} from './project/createProjectFromName.js'\nimport {getProjectDetails} from './project/getProjectDetails.js'\nimport {getProjectOutputPath} from './project/getProjectOutputPath.js'\nimport {checkIsRemoteTemplate, getGitHubRepoInfo, type RepoInfo} from './remoteTemplate.js'\nimport {type InitContext, type InitOptions} from './types.js'\n\nconst debug = subdebug('init')\n\nexport async function initAction(options: InitOptions, context: InitContext): Promise<void> {\n const {output, workDir} = context\n\n if (options.argType) {\n throw new InitError(\n options.argType === 'plugin'\n ? 'Initializing plugins through the CLI is no longer supported'\n : `Unknown init type \"${options.argType}\"`,\n 1,\n )\n }\n\n const trace = context.telemetry.trace(CLIInitStepCompleted)\n\n if (options.reconfigure) {\n throw new InitError('--reconfigure is deprecated - manual configuration is now required', 1)\n }\n\n // Media Library config templates ride the app init flow end to end:\n // organization-only project details, app unattended-flag rules, `initApp`.\n // Template-shape differences are handled downstream (bootstrapLocalTemplate\n // and initApp check `determineMediaLibraryTemplate` themselves).\n const isMediaLibraryTemplate = options.template\n ? determineMediaLibraryTemplate(options.template)\n : false\n\n // That template ignores project flags outright (getProjectDetails warns), so\n // the pair is not the move-a-project contradiction this guard is about.\n if (options.project && options.organization && !isMediaLibraryTemplate) {\n throw new InitError(\n 'You have specified both a project and an organization. To move a project to an organization please visit https://www.sanity.io/manage',\n 1,\n )\n }\n\n const defaultConfig = options.datasetDefault\n let showDefaultConfigPrompt = !defaultConfig\n if (options.dataset || options.visibility || options.datasetDefault || options.unattended) {\n showDefaultConfigPrompt = false\n }\n\n const detectedFramework = await detectFrameworkRecord({\n frameworkList: frameworks as readonly Framework[],\n rootPath: workDir,\n })\n const isNextJs = detectedFramework?.slug === 'nextjs'\n\n let remoteTemplateInfo: RepoInfo | undefined\n if (options.template && checkIsRemoteTemplate(options.template)) {\n remoteTemplateInfo = await getGitHubRepoInfo(options.template, options.templateToken)\n }\n\n // Warned before any setup so the user can cancel. Remote templates ship their\n // own `sanity.cli.*`, so there is nothing to swap.\n if (options.dashboard && remoteTemplateInfo) {\n output.warn('--dashboard is ignored for remote templates')\n }\n\n if (detectedFramework && detectedFramework.slug !== 'sanity' && remoteTemplateInfo) {\n throw new InitError(\n `A remote template cannot be used with a detected framework. Detected: ${detectedFramework.name}`,\n 1,\n )\n }\n\n const isAppTemplate = options.template\n ? determineAppTemplate(options.template) || isMediaLibraryTemplate\n : false\n\n // A config app persists to the org's installation, not to a dashboard\n // workbench, so `createMediaLibraryCliConfig` has no slot for --dashboard.\n // Warned rather than silently dropped (same courtesy as remote templates).\n if (options.dashboard && isMediaLibraryTemplate) {\n output.warn('--dashboard is ignored for the media-library-config template')\n }\n\n if (options.unattended) {\n checkFlagsInUnattendedMode(options, {isAppTemplate, isMediaLibraryTemplate, isNextJs})\n }\n\n trace.start()\n trace.log({\n flags: {\n bare: options.bare,\n coupon: Boolean(options.coupon),\n defaultConfig,\n env: Boolean(options.env),\n git: typeof options.git === 'string',\n plan: options.projectPlan,\n reconfigure: options.reconfigure,\n unattended: options.unattended,\n },\n step: 'start',\n })\n\n const planId = await getPlan(options, output, trace)\n\n let envFilenameDefault = '.env'\n if (detectedFramework && detectedFramework.slug === 'nextjs') {\n envFilenameDefault = '.env.local'\n }\n const envFilename = typeof options.env === 'string' ? options.env : envFilenameDefault\n\n const {user} = await ensureAuthenticated(options, output, trace)\n if (!isAppTemplate) {\n output.log(`${logSymbols.success} Fetching existing projects`)\n output.log('')\n }\n\n let newProject: string | undefined\n // A media-library config records only the organization; creating a project\n // from --project-name here would be a throwaway side effect.\n if (options.projectName && isMediaLibraryTemplate) {\n output.warn(\n '--project-name is ignored for the media-library-config template — it only records the organization.',\n )\n }\n if (options.projectName && !isMediaLibraryTemplate) {\n newProject = await createProjectFromName({\n coupon: options.coupon,\n createProjectName: options.projectName,\n dataset: options.dataset,\n organization: options.organization,\n planId,\n user,\n visibility: options.visibility,\n })\n }\n\n const {datasetName, displayName, isFirstProject, organizationId, projectId} =\n await getProjectDetails({\n coupon: options.coupon,\n dataset: options.dataset,\n datasetDefault: options.datasetDefault,\n isAppTemplate,\n isMediaLibraryTemplate,\n newProject,\n organization: options.organization,\n output,\n planId,\n project: options.project,\n showDefaultConfigPrompt,\n trace,\n unattended: options.unattended,\n user,\n visibility: options.visibility,\n })\n\n if (options.bare) {\n output.log(`${logSymbols.success} Below are your project details`)\n output.log('')\n output.log(`Project ID: ${styleText('cyan', projectId)}`)\n output.log(`Dataset: ${styleText('cyan', datasetName)}`)\n output.log(\n `\\nYou can find your project on Sanity Manage — https://www.sanity.io/manage/project/${projectId}\\n`,\n )\n trace.complete()\n return\n }\n\n // Detect editors once, then share the result with MCP and skills setup so\n // we don't pay the detection cost (filesystem probes + CLI execa calls) twice.\n const detectedEditors =\n options.mcpMode === 'skip' && options.skillsMode === 'skip'\n ? []\n : await detectAvailableEditors()\n\n const mcpResult = await setupMCP({\n editors: detectedEditors,\n mode: options.mcpMode,\n output,\n skillsMode: options.skillsMode,\n })\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n skipped: mcpResult.skipped,\n step: 'mcpSetup',\n })\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n }\n const mcpConfigured = mcpResult.configuredEditors\n\n async function installSkills(): Promise<void> {\n if (mcpResult.skillsToInstall.length === 0) return\n try {\n const skillsResult = await setupSkills({\n agents: mcpResult.skillsToInstall,\n output,\n })\n trace.log({\n installedAgents: skillsResult.installedAgents,\n skipped: skillsResult.skipped,\n step: 'skillsSetup',\n })\n if (skillsResult.error) {\n trace.error(skillsResult.error)\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n debug('Unexpected error from setupSkills %O', err)\n output.warn(`Could not install Sanity agent skills: ${err.message}`)\n trace.error(err)\n }\n }\n\n // Install skills right after the MCP/skills prompt so the progress + result\n // surface in sequence, rather than trailing the studio \"Success!\" output.\n await installSkills()\n\n const {alreadyConfiguredEditors} = mcpResult\n if (alreadyConfiguredEditors.length > 0) {\n const label =\n alreadyConfiguredEditors.length === 1\n ? `${alreadyConfiguredEditors[0]} already configured for Sanity MCP`\n : `${alreadyConfiguredEditors.length} editors already configured for Sanity MCP`\n spinner(label).start().succeed()\n }\n\n let initNext = flagOrDefault(options.nextjsAddConfigFiles, false)\n if (isNextJs && shouldPrompt(options.unattended, options.nextjsAddConfigFiles)) {\n initNext = await promptForConfigFiles()\n }\n\n trace.log({\n detectedFramework: detectedFramework?.name,\n selectedOption: initNext ? 'yes' : 'no',\n step: 'useDetectedFramework',\n })\n\n // The media-library config template skips project selection, so\n // `displayName` is empty and the slug would be too — which would default the\n // output-path prompt to the (usually non-empty) cwd, a default\n // `validateEmptyPath` then refuses. Fall back to the template's own name.\n const sluggedName =\n deburr(displayName.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '') || (isMediaLibraryTemplate ? 'media-library-config' : '')\n\n const initFramework = initNext\n\n const defaults = await getProjectDefaults({isPlugin: false, workDir})\n\n const outputPath = await getProjectOutputPath({\n initFramework,\n outputPath: options.outputPath,\n sluggedName,\n unattended: options.unattended,\n useEnv: Boolean(options.env),\n workDir,\n })\n\n if (isNextJs) {\n await checkNextJsReactCompatibility({\n detectedFramework,\n output,\n outputPath,\n })\n }\n\n if (initNext) {\n if (options.dashboard) {\n output.warn('--dashboard is ignored for Next.js projects')\n }\n await initNextJs({\n datasetName,\n detectedFramework,\n envFilename,\n mcpConfigured,\n options,\n output,\n projectId,\n trace,\n workDir,\n })\n trace.complete()\n return\n }\n\n if (options.env) {\n await createOrAppendEnvVars({\n envVars: {\n DATASET: datasetName,\n PROJECT_ID: projectId,\n },\n filename: envFilename,\n framework: detectedFramework,\n log: false,\n output,\n outputPath,\n })\n await writeStagingEnvIfNeeded(output, outputPath)\n trace.complete()\n return\n }\n\n // The Dashboard is opt-in (no prompt): `--dashboard` swaps the scaffolded\n // `sanity.cli.*` over to `defineApplication` — the branded app is the sole\n // Dashboard opt-in.\n const workbench = flagOrDefault(options.dashboard, false)\n\n const sharedParams = {\n defaults,\n mcpConfigured,\n options,\n organizationId,\n output,\n outputPath,\n remoteTemplateInfo,\n sluggedName,\n trace,\n workbench,\n workDir,\n }\n\n await (isAppTemplate\n ? initApp({...sharedParams, datasetName, projectId})\n : initStudio({\n ...sharedParams,\n datasetName,\n displayName,\n isFirstProject,\n projectId,\n }))\n\n trace.complete()\n}\n\nfunction checkFlagsInUnattendedMode(\n options: InitOptions,\n {\n isAppTemplate,\n isMediaLibraryTemplate,\n isNextJs,\n }: {isAppTemplate: boolean; isMediaLibraryTemplate: boolean; isNextJs: boolean},\n): void {\n debug('Unattended mode, validating required options')\n\n const errors: string[] = []\n\n if (isAppTemplate) {\n if (!options.outputPath) {\n errors.push(\n 'Output path is required in unattended mode. Pass it with `--output-path <path>`.',\n )\n }\n\n // The media-library config is organization-only, so project flags can't\n // stand in for --organization the way they can for other app templates.\n if (isMediaLibraryTemplate && !options.organization) {\n errors.push(\n 'Organization is required for the media-library-config template in unattended mode. ' +\n 'Pass it with `--organization <id>`.',\n )\n } else if (options.projectName && !options.organization) {\n errors.push(\n 'Organization is required when creating a project in unattended mode. Pass it with `--organization <id>`.',\n )\n } else if (!options.project && !options.organization) {\n errors.push(\n 'Project or organization is required for app templates in unattended mode. ' +\n 'Pass `--project <id>` or `--organization <id>`. To create a project, pass ' +\n '`--project-name <name>` with `--organization <id>`.',\n )\n }\n } else {\n if (!isNextJs && !options.bare && !options.outputPath) {\n errors.push(\n 'Output path is required in unattended mode. Pass it with `--output-path <path>`.',\n )\n }\n\n if (!options.project && !options.projectName) {\n errors.push(\n 'Project is required in unattended mode. Pass it with `--project <id>` or `--project-name <name>`.',\n )\n }\n\n if (!options.project && !options.organization) {\n errors.push(\n 'Organization is required when creating a project in unattended mode. Pass it with `--organization <id>`.',\n )\n }\n }\n\n if (errors.length > 0) {\n throw new InitError(formatCliErrorMessages(errors), exitCodes.USAGE_ERROR)\n }\n}\n\nasync function ensureAuthenticated(\n options: InitOptions,\n output: InitContext['output'],\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>,\n): Promise<{user: SanityOrgUser}> {\n const user = await validateSession()\n\n if (user) {\n trace.log({alreadyLoggedIn: true, step: 'login'})\n output.log(\n `${logSymbols.success} You are logged in as ${getUserDisplayName(user)} using ${getProviderName(user.provider)}`,\n )\n return {user}\n }\n\n if (options.unattended) {\n throw new InitError(LOGIN_REQUIRED_MESSAGE, exitCodes.RUNTIME_ERROR)\n }\n\n trace.log({step: 'login'})\n output.warn(LOGIN_REQUIRED_MESSAGE)\n\n try {\n await login({\n output,\n telemetry: trace.newContext('login'),\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new InitError(`Login failed: ${message}`, 1)\n }\n\n const loggedInUser = await getCliUser()\n\n output.log(\n `${logSymbols.success} You are logged in as ${getUserDisplayName(loggedInUser)} using ${getProviderName(loggedInUser.provider)}`,\n )\n return {user: loggedInUser}\n}\n"],"names":["styleText","exitCodes","subdebug","logSymbols","spinner","frameworks","deburr","promptForConfigFiles","getCliUser","CLIInitStepCompleted","detectFrameworkRecord","formatCliErrorMessages","getProjectDefaults","validateSession","getProviderName","getUserDisplayName","login","LOGIN_REQUIRED_MESSAGE","detectAvailableEditors","setupMCP","setupSkills","checkNextJsReactCompatibility","determineAppTemplate","determineMediaLibraryTemplate","createOrAppendEnvVars","initApp","InitError","flagOrDefault","shouldPrompt","writeStagingEnvIfNeeded","initNextJs","initStudio","getPlan","createProjectFromName","getProjectDetails","getProjectOutputPath","checkIsRemoteTemplate","getGitHubRepoInfo","debug","initAction","options","context","output","workDir","argType","trace","telemetry","reconfigure","isMediaLibraryTemplate","template","project","organization","defaultConfig","datasetDefault","showDefaultConfigPrompt","dataset","visibility","unattended","detectedFramework","frameworkList","rootPath","isNextJs","slug","remoteTemplateInfo","templateToken","dashboard","warn","name","isAppTemplate","checkFlagsInUnattendedMode","start","log","flags","bare","coupon","Boolean","env","git","plan","projectPlan","step","planId","envFilenameDefault","envFilename","user","ensureAuthenticated","success","newProject","projectName","createProjectName","datasetName","displayName","isFirstProject","organizationId","projectId","complete","detectedEditors","mcpMode","skillsMode","mcpResult","editors","mode","configuredEditors","skipped","error","mcpConfigured","installSkills","skillsToInstall","length","skillsResult","agents","installedAgents","err","Error","String","message","alreadyConfiguredEditors","label","succeed","initNext","nextjsAddConfigFiles","selectedOption","sluggedName","toLowerCase","replaceAll","initFramework","defaults","isPlugin","outputPath","useEnv","envVars","DATASET","PROJECT_ID","filename","framework","workbench","sharedParams","errors","push","USAGE_ERROR","alreadyLoggedIn","provider","RUNTIME_ERROR","newContext","loggedInUser"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,SAAS,EAETC,QAAQ,QAEH,mBAAkB;AACzB,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAEvD,SAAwBC,UAAU,QAAO,qBAAoB;AAC7D,OAAOC,YAAY,sBAAqB;AAExC,SAAQC,oBAAoB,QAAO,+BAA8B;AACjE,SAAQC,UAAU,QAAO,yBAAwB;AACjD,SAAQC,oBAAoB,QAA4B,oCAAmC;AAC3F,SAAQC,qBAAqB,QAAO,gCAA+B;AACnE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,eAAe,QAAO,iCAAgC;AAC9D,SAAQC,eAAe,EAAEC,kBAAkB,QAAO,6BAA4B;AAC9E,SAAQC,KAAK,QAAO,yBAAwB;AAC5C,SAAQC,sBAAsB,QAAO,qCAAoC;AACzE,SAAQC,sBAAsB,QAAO,mCAAkC;AACvE,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,WAAW,QAAO,2BAA0B;AACpD,SAAQC,6BAA6B,QAAO,qCAAoC;AAChF,SAAQC,oBAAoB,QAAO,4BAA2B;AAC9D,SAAQC,6BAA6B,QAAO,qCAAoC;AAChF,SAAQC,qBAAqB,QAAO,iCAAgC;AACpE,SAAQC,OAAO,QAAO,eAAc;AACpC,SAAQC,SAAS,QAAO,iBAAgB;AACxC,SAAQC,aAAa,EAAEC,YAAY,EAAEC,uBAAuB,QAAO,mBAAkB;AACrF,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SAAQC,OAAO,QAAO,oBAAmB;AACzC,SAAQC,qBAAqB,QAAO,qCAAoC;AACxE,SAAQC,iBAA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AaH,QAAQ,GAAG;IAElI,OAAO;QAACzD,MAAM4D;IAAY;AAC5B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/init/initAction.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n exitCodes,\n type SanityOrgUser,\n subdebug,\n type TelemetryUserProperties,\n} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {checkBlueprintDestination} from '@sanity/cli-setup'\nimport {type TelemetryTrace} from '@sanity/telemetry'\nimport {type Framework, frameworks} from '@vercel/frameworks'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {promptForConfigFiles} from '../../prompts/init/nextjs.js'\nimport {getCliUser} from '../../services/user.js'\nimport {CLIInitStepCompleted, type InitStepResult} from '../../telemetry/init.telemetry.js'\nimport {detectFrameworkRecord} from '../../util/detectFramework.js'\nimport {formatCliErrorMessages} from '../../util/formatCliErrorMessages.js'\nimport {getProjectDefaults} from '../../util/getProjectDefaults.js'\nimport {validateSession} from '../auth/ensureAuthenticated.js'\nimport {getProviderName, getUserDisplayName} from '../auth/getProviderName.js'\nimport {login} from '../auth/login/login.js'\nimport {LOGIN_REQUIRED_MESSAGE} from '../auth/login/loginInstructions.js'\nimport {detectAvailableEditors} from '../mcp/detectAvailableEditors.js'\nimport {setupMCP} from '../mcp/setupMCP.js'\nimport {setupSkills} from '../skills/setupSkills.js'\nimport {checkNextJsReactCompatibility} from './checkNextJsReactCompatibility.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {determineMediaLibraryTemplate} from './determineMediaLibraryTemplate.js'\nimport {createOrAppendEnvVars} from './env/createOrAppendEnvVars.js'\nimport {initApp} from './initApp.js'\nimport {initBlueprint} from './initBlueprint.js'\nimport {InitError} from './initError.js'\nimport {flagOrDefault, shouldPrompt, writeStagingEnvIfNeeded} from './initHelpers.js'\nimport {initNextJs} from './initNextJs.js'\nimport {initStudio} from './initStudio.js'\nimport {getPlan} from './plan/getPlan.js'\nimport {createProjectFromName} from './project/createProjectFromName.js'\nimport {getProjectDetails} from './project/getProjectDetails.js'\nimport {getProjectOutputPath} from './project/getProjectOutputPath.js'\nimport {checkIsRemoteTemplate, getGitHubRepoInfo, type RepoInfo} from './remoteTemplate.js'\nimport {type InitContext, type InitOptions} from './types.js'\n\nconst debug = subdebug('init')\n\nexport async function initAction(options: InitOptions, context: InitContext) {\n const {output, workDir} = context\n\n if (options.argType) {\n throw new InitError(\n options.argType === 'plugin'\n ? 'Initializing plugins through the CLI is no longer supported'\n : `Unknown init type \"${options.argType}\"`,\n 1,\n )\n }\n\n const trace = context.telemetry.trace(CLIInitStepCompleted)\n\n if (options.reconfigure) {\n throw new InitError('--reconfigure is deprecated - manual configuration is now required', 1)\n }\n\n // Media Library config templates ride the app init flow end to end:\n // organization-only project details, app unattended-flag rules, `initApp`.\n // Template-shape differences are handled downstream (bootstrapLocalTemplate\n // and initApp check `determineMediaLibraryTemplate` themselves).\n const isMediaLibraryTemplate = options.template\n ? determineMediaLibraryTemplate(options.template)\n : false\n\n // That template ignores project flags outright (getProjectDetails warns), so\n // the pair is not the move-a-project contradiction this guard is about.\n if (options.project && options.organization && !isMediaLibraryTemplate) {\n throw new InitError(\n 'You have specified both a project and an organization. To move a project to an organization please visit https://www.sanity.io/manage',\n 1,\n )\n }\n\n const defaultConfig = options.datasetDefault\n let showDefaultConfigPrompt = !defaultConfig\n if (options.dataset || options.visibility || options.datasetDefault || options.unattended) {\n showDefaultConfigPrompt = false\n }\n\n const detectedFramework = await detectFrameworkRecord({\n frameworkList: frameworks as readonly Framework[],\n rootPath: workDir,\n })\n const isNextJs = detectedFramework?.slug === 'nextjs'\n const isBlueprint = options.withBlueprints === true\n if (isBlueprint && (options.outputPath || options.unattended)) {\n checkBlueprintDestination(options.outputPath || workDir)\n }\n\n let remoteTemplateInfo: RepoInfo | undefined\n if (options.template && checkIsRemoteTemplate(options.template)) {\n remoteTemplateInfo = await getGitHubRepoInfo(options.template, options.templateToken)\n }\n\n // Warned before any setup so the user can cancel. Remote templates ship their\n // own `sanity.cli.*`, so there is nothing to swap.\n if (options.dashboard && remoteTemplateInfo) {\n output.warn('--dashboard is ignored for remote templates')\n }\n\n if (detectedFramework && detectedFramework.slug !== 'sanity' && remoteTemplateInfo) {\n throw new InitError(\n `A remote template cannot be used with a detected framework. Detected: ${detectedFramework.name}`,\n 1,\n )\n }\n\n const isAppTemplate = options.template\n ? determineAppTemplate(options.template) || isMediaLibraryTemplate\n : false\n\n // A config app persists to the org's installation, not to a dashboard\n // workbench, so `createMediaLibraryCliConfig` has no slot for --dashboard.\n // Warned rather than silently dropped (same courtesy as remote templates).\n if (options.dashboard && isMediaLibraryTemplate) {\n output.warn('--dashboard is ignored for the media-library-config template')\n }\n\n if (options.unattended) {\n checkFlagsInUnattendedMode(options, {\n isAppTemplate,\n isMediaLibraryTemplate,\n useCurrentPath: isNextJs || isBlueprint,\n })\n }\n\n trace.start()\n trace.log({\n flags: {\n bare: options.bare,\n coupon: Boolean(options.coupon),\n defaultConfig,\n env: Boolean(options.env),\n git: typeof options.git === 'string',\n plan: options.projectPlan,\n reconfigure: options.reconfigure,\n unattended: options.unattended,\n },\n step: 'start',\n })\n\n if (isBlueprint) {\n output.log('Setting up a Blueprint')\n }\n\n const planId = await getPlan(options, output, trace)\n\n let envFilenameDefault = '.env'\n if (detectedFramework && detectedFramework.slug === 'nextjs') {\n envFilenameDefault = '.env.local'\n }\n const envFilename = typeof options.env === 'string' ? options.env : envFilenameDefault\n\n const {user} = await ensureAuthenticated(options, output, trace)\n if (!isAppTemplate) {\n output.log(`${logSymbols.success} Fetching existing projects`)\n output.log('')\n }\n\n let newProject: string | undefined\n // A media-library config records only the organization; creating a project\n // from --project-name here would be a throwaway side effect.\n if (options.projectName && isMediaLibraryTemplate) {\n output.warn(\n '--project-name is ignored for the media-library-config template — it only records the organization.',\n )\n }\n if (options.projectName && !isMediaLibraryTemplate) {\n newProject = await createProjectFromName({\n coupon: options.coupon,\n createProjectName: options.projectName,\n dataset: options.dataset,\n organization: options.organization,\n planId,\n user,\n visibility: options.visibility,\n })\n }\n\n const {datasetName, displayName, isFirstProject, organizationId, projectId} =\n await getProjectDetails({\n coupon: options.coupon,\n dataset: options.dataset,\n datasetDefault: options.datasetDefault,\n isAppTemplate,\n isMediaLibraryTemplate,\n newProject,\n organization: options.organization,\n output,\n planId,\n project: options.project,\n showDefaultConfigPrompt,\n trace,\n unattended: options.unattended,\n user,\n visibility: options.visibility,\n })\n\n if (options.bare) {\n output.log(`${logSymbols.success} Below are your project details`)\n output.log('')\n output.log(`Project ID: ${styleText('cyan', projectId)}`)\n output.log(`Dataset: ${styleText('cyan', datasetName)}`)\n output.log(\n `\\nYou can find your project on Sanity Manage — https://www.sanity.io/manage/project/${projectId}\\n`,\n )\n trace.complete()\n return\n }\n\n if (isBlueprint) {\n const outputPath = await getProjectOutputPath({\n initFramework: false,\n outputPath: options.outputPath,\n sluggedName: projectId,\n unattended: options.unattended,\n useEnv: false,\n workDir,\n })\n const result = await initBlueprint({datasetName, output, outputPath, projectId})\n trace.complete()\n return result\n }\n\n // Detect editors once, then share the result with MCP and skills setup so\n // we don't pay the detection cost (filesystem probes + CLI execa calls) twice.\n const detectedEditors =\n options.mcpMode === 'skip' && options.skillsMode === 'skip'\n ? []\n : await detectAvailableEditors()\n\n const mcpResult = await setupMCP({\n editors: detectedEditors,\n mode: options.mcpMode,\n output,\n skillsMode: options.skillsMode,\n })\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n skipped: mcpResult.skipped,\n step: 'mcpSetup',\n })\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n }\n const mcpConfigured = mcpResult.configuredEditors\n\n async function installSkills(): Promise<void> {\n if (mcpResult.skillsToInstall.length === 0) return\n try {\n const skillsResult = await setupSkills({\n agents: mcpResult.skillsToInstall,\n output,\n })\n trace.log({\n installedAgents: skillsResult.installedAgents,\n skipped: skillsResult.skipped,\n step: 'skillsSetup',\n })\n if (skillsResult.error) {\n trace.error(skillsResult.error)\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n debug('Unexpected error from setupSkills %O', err)\n output.warn(`Could not install Sanity agent skills: ${err.message}`)\n trace.error(err)\n }\n }\n\n // Install skills right after the MCP/skills prompt so the progress + result\n // surface in sequence, rather than trailing the studio \"Success!\" output.\n await installSkills()\n\n const {alreadyConfiguredEditors} = mcpResult\n if (alreadyConfiguredEditors.length > 0) {\n const label =\n alreadyConfiguredEditors.length === 1\n ? `${alreadyConfiguredEditors[0]} already configured for Sanity MCP`\n : `${alreadyConfiguredEditors.length} editors already configured for Sanity MCP`\n spinner(label).start().succeed()\n }\n\n let initNext = flagOrDefault(options.nextjsAddConfigFiles, false)\n if (isNextJs && shouldPrompt(options.unattended, options.nextjsAddConfigFiles)) {\n initNext = await promptForConfigFiles()\n }\n\n trace.log({\n detectedFramework: detectedFramework?.name,\n selectedOption: initNext ? 'yes' : 'no',\n step: 'useDetectedFramework',\n })\n\n // The media-library config template skips project selection, so\n // `displayName` is empty and the slug would be too — which would default the\n // output-path prompt to the (usually non-empty) cwd, a default\n // `validateEmptyPath` then refuses. Fall back to the template's own name.\n const sluggedName =\n deburr(displayName.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '') || (isMediaLibraryTemplate ? 'media-library-config' : '')\n\n const initFramework = initNext\n\n const defaults = await getProjectDefaults({isPlugin: false, workDir})\n\n const outputPath = await getProjectOutputPath({\n initFramework,\n outputPath: options.outputPath,\n sluggedName,\n unattended: options.unattended,\n useEnv: Boolean(options.env),\n workDir,\n })\n\n if (isNextJs) {\n await checkNextJsReactCompatibility({\n detectedFramework,\n output,\n outputPath,\n })\n }\n\n if (initNext) {\n if (options.dashboard) {\n output.warn('--dashboard is ignored for Next.js projects')\n }\n await initNextJs({\n datasetName,\n detectedFramework,\n envFilename,\n mcpConfigured,\n options,\n output,\n projectId,\n trace,\n workDir,\n })\n trace.complete()\n return\n }\n\n if (options.env) {\n await createOrAppendEnvVars({\n envVars: {\n DATASET: datasetName,\n PROJECT_ID: projectId,\n },\n filename: envFilename,\n framework: detectedFramework,\n log: false,\n output,\n outputPath,\n })\n await writeStagingEnvIfNeeded(output, outputPath)\n trace.complete()\n return\n }\n\n // The Dashboard is opt-in (no prompt): `--dashboard` swaps the scaffolded\n // `sanity.cli.*` over to `defineApplication` — the branded app is the sole\n // Dashboard opt-in.\n const workbench = flagOrDefault(options.dashboard, false)\n\n const sharedParams = {\n defaults,\n mcpConfigured,\n options,\n organizationId,\n output,\n outputPath,\n remoteTemplateInfo,\n sluggedName,\n trace,\n workbench,\n workDir,\n }\n\n await (isAppTemplate\n ? initApp({...sharedParams, datasetName, projectId})\n : initStudio({\n ...sharedParams,\n datasetName,\n displayName,\n isFirstProject,\n projectId,\n }))\n\n trace.complete()\n}\n\nfunction checkFlagsInUnattendedMode(\n options: InitOptions,\n {\n isAppTemplate,\n isMediaLibraryTemplate,\n useCurrentPath,\n }: {isAppTemplate: boolean; isMediaLibraryTemplate: boolean; useCurrentPath: boolean},\n): void {\n debug('Unattended mode, validating required options')\n\n const errors: string[] = []\n\n if (isAppTemplate) {\n if (!options.outputPath) {\n errors.push(\n 'Output path is required in unattended mode. Pass it with `--output-path <path>`.',\n )\n }\n\n // The media-library config is organization-only, so project flags can't\n // stand in for --organization the way they can for other app templates.\n if (isMediaLibraryTemplate && !options.organization) {\n errors.push(\n 'Organization is required for the media-library-config template in unattended mode. ' +\n 'Pass it with `--organization <id>`.',\n )\n } else if (options.projectName && !options.organization) {\n errors.push(\n 'Organization is required when creating a project in unattended mode. Pass it with `--organization <id>`.',\n )\n } else if (!options.project && !options.organization) {\n errors.push(\n 'Project or organization is required for app templates in unattended mode. ' +\n 'Pass `--project <id>` or `--organization <id>`. To create a project, pass ' +\n '`--project-name <name>` with `--organization <id>`.',\n )\n }\n } else {\n if (!useCurrentPath && !options.bare && !options.outputPath) {\n errors.push(\n 'Output path is required in unattended mode. Pass it with `--output-path <path>`.',\n )\n }\n\n if (!options.project && !options.projectName) {\n errors.push(\n 'Project is required in unattended mode. Pass it with `--project <id>` or `--project-name <name>`.',\n )\n }\n\n if (!options.project && !options.organization) {\n errors.push(\n 'Organization is required when creating a project in unattended mode. Pass it with `--organization <id>`.',\n )\n }\n }\n\n if (errors.length > 0) {\n throw new InitError(formatCliErrorMessages(errors), exitCodes.USAGE_ERROR)\n }\n}\n\nasync function ensureAuthenticated(\n options: InitOptions,\n output: InitContext['output'],\n trace: TelemetryTrace<TelemetryUserProperties, InitStepResult>,\n): Promise<{user: SanityOrgUser}> {\n const user = await validateSession()\n\n if (user) {\n trace.log({alreadyLoggedIn: true, step: 'login'})\n output.log(\n `${logSymbols.success} You are logged in as ${getUserDisplayName(user)} using ${getProviderName(user.provider)}`,\n )\n return {user}\n }\n\n if (options.unattended) {\n throw new InitError(LOGIN_REQUIRED_MESSAGE, exitCodes.RUNTIME_ERROR)\n }\n\n trace.log({step: 'login'})\n output.warn(LOGIN_REQUIRED_MESSAGE)\n\n try {\n await login({\n output,\n telemetry: trace.newContext('login'),\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new InitError(`Login failed: ${message}`, 1)\n }\n\n const loggedInUser = await getCliUser()\n\n output.log(\n `${logSymbols.success} You are logged in as ${getUserDisplayName(loggedInUser)} using ${getProviderName(loggedInUser.provider)}`,\n )\n return {user: loggedInUser}\n}\n"],"names":["styleText","exitCodes","subdebug","logSymbols","spinner","checkBlueprintDestination","frameworks","deburr","promptForConfigFiles","getCliUser","CLIInitStepCompleted","detectFrameworkRecord","formatCliErrorMessages","getProjectDefaults","validateSession","getProviderName","getUserDisplayName","login","LOGIN_REQUIRED_MESSAGE","detectAvailableEditors","setupMCP","setupSkills","checkNextJsReactCompatibility","determineAppTemplate","determineMediaLibraryTemplate","createOrAppendEnvVars","initApp","initBlueprint","InitError","flagOrDefault","shouldPrompt","writeStagingEnvIfNeeded","initNextJs","initStudio","getPlan","createProjectFromName","getProjectDetails","getProjectOutputPath","checkIsRemoteTemplate","getGitHubRepoInfo","debug","initAction","options","context","output","workDir","argType","trace","telemetry","reconfigure","isMediaLibraryTemplate","template","project","organization","defaultConfig","datasetDefault","showDefaultConfigPrompt","dataset","visibility","unattended","detectedFramework","frameworkList","rootPath","isNextJs","slug","isBlueprint","withBlueprints","outputPath","remoteTemplateInfo","templateToken","dashboard","warn","name","isAppTemplate","checkFlagsInUnattendedMode","useCurrentPath","start","log","flags","bare","coupon","Boolean","env","git","plan","projectPlan","step","planId","envFilenameDefault","envFilename","user","ensureAuthenticated","success","newProject","projectName","createProjectName","datasetName","displayName","isFirstProject","organizationId","projectId","complete","initFramework","sluggedName","useEnv","result","detectedEditors","mcpMode","skillsMode","mcpResult","editors","mode","configuredEditors","skipped","error","mcpConfigured","installSkills","skillsToInstall","length","skillsResult","agents","installedAgents","err","Error","String","message","alreadyConfiguredEditors","label","succeed","initNext","nextjsAddConfigFiles","selectedOption","toLowerCase","replaceAll","defaults","isPlugin","envVars","DATASET","PROJECT_ID","filename","framework","workbench","sharedParams","errors","push","USAGE_ERROR","alreadyLoggedIn","provider","RUNTIME_ERROR","newContext","loggedInUser"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,SAAS,EAETC,QAAQ,QAEH,mBAAkB;AACzB,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AACvD,SAAQC,yBAAyB,QAAO,oBAAmB;AAE3D,SAAwBC,UAAU,QAAO,qBAAoB;AAC7D,OAAOC,YAAY,sBAAqB;AAExC,SAAQC,oBAAoB,QAAO,+BAA8B;AACjE,SAAQC,UAAU,QAAO,yBAAwB;AACjD,SAAQC,oBAAoB,QAA4B,oCAAmC;AAC3F,SAAQC,qBAAqB,QAAO,gCAA+B;AACnE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,eAAe,QAAO,iCAAgC;AAC9D,SAAQC,e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