@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.
Files changed (46) hide show
  1. package/dist/actions/build/buildApp.js +1 -4
  2. package/dist/actions/build/buildApp.js.map +1 -1
  3. package/dist/actions/build/buildStudio.js +1 -0
  4. package/dist/actions/build/buildStudio.js.map +1 -1
  5. package/dist/actions/deploy/deployApp.js +17 -9
  6. package/dist/actions/deploy/deployApp.js.map +1 -1
  7. package/dist/actions/deploy/deployDashboardConfig.js +118 -0
  8. package/dist/actions/deploy/deployDashboardConfig.js.map +1 -0
  9. package/dist/actions/deploy/deployStudio.js +3 -2
  10. package/dist/actions/deploy/deployStudio.js.map +1 -1
  11. package/dist/actions/dev/servers/getDevServerConfig.js +2 -5
  12. package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
  13. package/dist/actions/graphql/extractGraphQLAPIs.js +13 -6
  14. package/dist/actions/graphql/extractGraphQLAPIs.js.map +1 -1
  15. package/dist/actions/graphql/extractGraphQLAPIs.worker.js +2 -1
  16. package/dist/actions/graphql/extractGraphQLAPIs.worker.js.map +1 -1
  17. package/dist/actions/init/initAction.js +30 -3
  18. package/dist/actions/init/initAction.js.map +1 -1
  19. package/dist/actions/init/initBlueprint.js +66 -0
  20. package/dist/actions/init/initBlueprint.js.map +1 -0
  21. package/dist/actions/init/types.js +2 -1
  22. package/dist/actions/init/types.js.map +1 -1
  23. package/dist/actions/preview/previewAction.js +2 -2
  24. package/dist/actions/preview/previewAction.js.map +1 -1
  25. package/dist/actions/undeploy/runUndeploy.js +16 -4
  26. package/dist/actions/undeploy/runUndeploy.js.map +1 -1
  27. package/dist/actions/undeploy/undeployPlan.js +2 -2
  28. package/dist/actions/undeploy/undeployPlan.js.map +1 -1
  29. package/dist/commands/deploy.js +15 -3
  30. package/dist/commands/deploy.js.map +1 -1
  31. package/dist/commands/init.js +10 -0
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/media/prune-aspect-data.js +1 -1
  34. package/dist/commands/media/prune-aspect-data.js.map +1 -1
  35. package/dist/commands/media/pull-aspects.js +1 -1
  36. package/dist/commands/media/pull-aspects.js.map +1 -1
  37. package/dist/exports/index.d.ts +2 -2
  38. package/dist/exports/index.js +1 -1
  39. package/dist/exports/index.js.map +1 -1
  40. package/dist/exports/runtime.d.ts +2 -2
  41. package/dist/exports/runtime.js +1 -1
  42. package/dist/exports/runtime.js.map +1 -1
  43. package/dist/generated/apiRoutes.js +52 -0
  44. package/dist/generated/apiRoutes.js.map +1 -1
  45. package/oclif.manifest.json +3019 -3006
  46. package/package.json +16 -15
@@ -0,0 +1,66 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { DEFAULT_BLUEPRINTS_API_VERSION } from '@sanity/blueprints/resolve';
3
+ import { getGlobalCliClient } from '@sanity/cli-core/apiClient';
4
+ import { initializeBlueprintWorkspace, JSON_BLUEPRINT_CONTENT } from '@sanity/cli-setup';
5
+ export async function initBlueprint({ datasetName, output, outputPath, projectId }) {
6
+ const { blueprintPath, config, configPath } = await initializeBlueprintWorkspace({
7
+ blueprintExtension: 'json',
8
+ jsonContent: {
9
+ ...JSON_BLUEPRINT_CONTENT,
10
+ $schema: 'https://schemas.sanity.io/blueprints/v2024-10-01/blueprint.schema.json',
11
+ values: {
12
+ dataset: datasetName
13
+ }
14
+ },
15
+ outputPath,
16
+ resolveConfig: async (manifestPath)=>{
17
+ const stackName = `init-${projectId}-${randomUUID().slice(0, 8)}`;
18
+ try {
19
+ const client = await getGlobalCliClient({
20
+ apiVersion: process.env.SANITY_BLUEPRINTS_API_VERSION ?? DEFAULT_BLUEPRINTS_API_VERSION,
21
+ maxRetries: 0,
22
+ requireUser: true
23
+ });
24
+ const stack = await client.request({
25
+ body: {
26
+ document: {
27
+ resources: []
28
+ },
29
+ name: stackName,
30
+ scopeId: projectId,
31
+ scopeType: 'project',
32
+ useProjectBasedId: false
33
+ },
34
+ headers: {
35
+ 'x-sanity-scope-id': projectId,
36
+ 'x-sanity-scope-type': 'project'
37
+ },
38
+ method: 'POST',
39
+ url: '/blueprints/stacks'
40
+ });
41
+ if (!stack.id) throw new Error('The API returned no Stack ID.');
42
+ return {
43
+ projectId,
44
+ stackId: stack.id
45
+ };
46
+ } catch (error) {
47
+ throw new Error(`Saved ${manifestPath}. Could not create Stack "${stackName}". ${error instanceof Error ? error.message : String(error)}\n` + `From ${outputPath}, run \`npx @sanity/cli blueprints init --project-id ${projectId}\` to connect the Blueprint to a Stack.`, {
48
+ cause: error
49
+ });
50
+ }
51
+ }
52
+ });
53
+ const { stackId } = config;
54
+ output.log(`Created ${blueprintPath}`);
55
+ output.log(`Connected the Blueprint to Stack ${stackId} in project ${projectId}.`);
56
+ output.log(`From ${outputPath}, run \`npx @sanity/cli blueprints plan\` to review changes.`);
57
+ return {
58
+ blueprintPath,
59
+ configPath,
60
+ dataset: datasetName,
61
+ projectId,
62
+ stackId
63
+ };
64
+ }
65
+
66
+ //# sourceMappingURL=initBlueprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/actions/init/initBlueprint.ts"],"sourcesContent":["import {randomUUID} from 'node:crypto'\n\nimport {DEFAULT_BLUEPRINTS_API_VERSION} from '@sanity/blueprints/resolve'\nimport {type Output} from '@sanity/cli-core'\nimport {getGlobalCliClient} from '@sanity/cli-core/apiClient'\nimport {initializeBlueprintWorkspace, JSON_BLUEPRINT_CONTENT} from '@sanity/cli-setup'\n\nexport async function initBlueprint({\n datasetName,\n output,\n outputPath,\n projectId,\n}: {\n datasetName: string\n output: Pick<Output, 'log'>\n outputPath: string\n projectId: string\n}) {\n const {blueprintPath, config, configPath} = await initializeBlueprintWorkspace({\n blueprintExtension: 'json',\n jsonContent: {\n ...JSON_BLUEPRINT_CONTENT,\n $schema: 'https://schemas.sanity.io/blueprints/v2024-10-01/blueprint.schema.json',\n values: {dataset: datasetName},\n },\n outputPath,\n resolveConfig: async (manifestPath) => {\n const stackName = `init-${projectId}-${randomUUID().slice(0, 8)}`\n try {\n const client = await getGlobalCliClient({\n apiVersion: process.env.SANITY_BLUEPRINTS_API_VERSION ?? DEFAULT_BLUEPRINTS_API_VERSION,\n maxRetries: 0,\n requireUser: true,\n })\n const stack = await client.request<{id: string}>({\n body: {\n document: {resources: []},\n name: stackName,\n scopeId: projectId,\n scopeType: 'project',\n useProjectBasedId: false,\n },\n headers: {'x-sanity-scope-id': projectId, 'x-sanity-scope-type': 'project'},\n method: 'POST',\n url: '/blueprints/stacks',\n })\n if (!stack.id) throw new Error('The API returned no Stack ID.')\n return {projectId, stackId: stack.id}\n } catch (error) {\n throw new Error(\n `Saved ${manifestPath}. Could not create Stack \"${stackName}\". ${error instanceof Error ? error.message : String(error)}\\n` +\n `From ${outputPath}, run \\`npx @sanity/cli blueprints init --project-id ${projectId}\\` to connect the Blueprint to a Stack.`,\n {cause: error},\n )\n }\n },\n })\n const {stackId} = config\n\n output.log(`Created ${blueprintPath}`)\n output.log(`Connected the Blueprint to Stack ${stackId} in project ${projectId}.`)\n output.log(`From ${outputPath}, run \\`npx @sanity/cli blueprints plan\\` to review changes.`)\n return {blueprintPath, configPath, dataset: datasetName, projectId, stackId}\n}\n"],"names":["randomUUID","DEFAULT_BLUEPRINTS_API_VERSION","getGlobalCliClient","initializeBlueprintWorkspace","JSON_BLUEPRINT_CONTENT","initBlueprint","datasetName","output","outputPath","projectId","blueprintPath","config","configPath","blueprintExtension","jsonContent","$schema","values","dataset","resolveConfig","manifestPath","stackName","slice","client","apiVersion","process","env","SANITY_BLUEPRINTS_API_VERSION","maxRetries","requireUser","stack","request","body","document","resources","name","scopeId","scopeType","useProjectBasedId","headers","method","url","id","Error","stackId","error","message","String","cause","log"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAa;AAEtC,SAAQC,8BAA8B,QAAO,6BAA4B;AAEzE,SAAQC,kBAAkB,QAAO,6BAA4B;AAC7D,SAAQC,4BAA4B,EAAEC,sBAAsB,QAAO,oBAAmB;AA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,GAAG,CAAC,CAAC,QAAQ,EAAEtC,eAAe;IACrCH,OAAOyC,GAAG,CAAC,CAAC,iCAAiC,EAAEL,QAAQ,YAAY,EAAElC,UAAU,CAAC,CAAC;IACjFF,OAAOyC,GAAG,CAAC,CAAC,KAAK,EAAExC,WAAW,4DAA4D,CAAC;IAC3F,OAAO;QAACE;QAAeE;QAAYK,SAASX;QAAaG;QAAWkC;IAAO;AAC7E"}
@@ -45,7 +45,8 @@ export function flagsToInitOptions(flags, isUnattended, args, mcpMode, skillsMod
45
45
  templateToken: flags['template-token'],
46
46
  typescript: flags.typescript,
47
47
  unattended: isUnattended,
48
- visibility: narrowVisibility(flags.visibility)
48
+ visibility: narrowVisibility(flags.visibility),
49
+ withBlueprints: flags['with-blueprints']
49
50
  };
50
51
  }
51
52
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/types.ts"],"sourcesContent":["import {type CLITelemetryStore, type Output} from '@sanity/cli-core'\nimport {type Framework} from '@vercel/frameworks'\n\nimport {type GenerateConfigOptions} from './createStudioConfig.js'\n\nexport type VersionedFramework = Framework & {\n detectedVersion?: string\n}\n\nexport interface ProjectTemplate {\n configTemplate?: ((variables: GenerateConfigOptions['variables']) => string) | string\n datasetUrl?: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n entry?: string\n importPrompt?: string\n scripts?: Record<string, string>\n type?: 'commonjs' | 'module'\n typescriptOnly?: boolean\n}\n\nexport interface InitOptions {\n autoUpdates: boolean\n bare: boolean\n datasetDefault: boolean\n fromCreate: boolean\n install: boolean\n mcpMode: 'auto' | 'prompt' | 'skip'\n skillsMode: 'auto' | 'prompt' | 'skip'\n unattended: boolean\n\n argType?: string\n coupon?: string\n dashboard?: boolean\n dataset?: string\n env?: string\n git?: boolean | string\n importDataset?: boolean\n nextjsAddConfigFiles?: boolean\n nextjsAppendEnv?: boolean\n nextjsEmbedStudio?: boolean\n organization?: string\n outputPath?: string\n overwriteFiles?: boolean\n packageManager?: 'npm' | 'pnpm' | 'yarn'\n project?: string\n projectName?: string\n projectPlan?: string\n provider?: string\n reconfigure?: boolean\n template?: string\n templateToken?: string\n typescript?: boolean\n visibility?: 'private' | 'public'\n}\n\nexport interface InitContext {\n output: Output\n telemetry: CLITelemetryStore\n workDir: string\n}\n\ninterface InitCommandFlags {\n 'auto-updates': boolean\n bare: boolean\n 'dataset-default': boolean\n 'from-create': boolean\n install: boolean\n mcp: boolean\n 'no-git': boolean\n skills: boolean\n\n coupon?: string\n 'create-project'?: string\n dashboard?: boolean\n dataset?: string\n env?: string\n git?: string\n 'import-dataset'?: boolean\n 'nextjs-add-config-files'?: boolean\n 'nextjs-append-env'?: boolean\n 'nextjs-embed-studio'?: boolean\n organization?: string\n 'output-path'?: string\n 'overwrite-files'?: boolean\n 'package-manager'?: string\n project?: string\n 'project-name'?: string\n 'project-plan'?: string\n provider?: string\n reconfigure?: boolean\n template?: string\n 'template-token'?: string\n typescript?: boolean\n visibility?: string\n}\n\ninterface InitCommandArgs {\n type?: string\n}\n\nconst VALID_PACKAGE_MANAGERS = new Set<string>(['npm', 'pnpm', 'yarn'])\nfunction narrowPackageManager(value: string | undefined): InitOptions['packageManager'] {\n return value !== undefined && VALID_PACKAGE_MANAGERS.has(value)\n ? (value as InitOptions['packageManager'])\n : undefined\n}\n\nconst VALID_VISIBILITIES = new Set<string>(['private', 'public'])\nfunction narrowVisibility(value: string | undefined): InitOptions['visibility'] {\n return value !== undefined && VALID_VISIBILITIES.has(value)\n ? (value as InitOptions['visibility'])\n : undefined\n}\n\nexport function flagsToInitOptions(\n flags: InitCommandFlags,\n isUnattended: boolean,\n args: InitCommandArgs | undefined,\n mcpMode: InitOptions['mcpMode'],\n skillsMode: InitOptions['skillsMode'],\n): InitOptions {\n return {\n argType: args?.type,\n autoUpdates: flags['auto-updates'],\n bare: flags.bare,\n coupon: flags.coupon,\n dashboard: flags.dashboard,\n dataset: flags.dataset,\n datasetDefault: flags['dataset-default'],\n env: flags.env,\n fromCreate: flags['from-create'],\n git: flags['no-git'] ? false : flags.git,\n importDataset: flags['import-dataset'],\n install: flags.install,\n mcpMode,\n nextjsAddConfigFiles: flags['nextjs-add-config-files'],\n nextjsAppendEnv: flags['nextjs-append-env'],\n nextjsEmbedStudio: flags['nextjs-embed-studio'],\n organization: flags.organization,\n outputPath: flags['output-path'],\n overwriteFiles: flags['overwrite-files'],\n packageManager: narrowPackageManager(flags['package-manager']),\n project: flags.project,\n projectName: flags['project-name'] ?? flags['create-project'],\n projectPlan: flags['project-plan'],\n provider: flags.provider,\n reconfigure: flags.reconfigure,\n skillsMode,\n template: flags.template,\n templateToken: flags['template-token'],\n typescript: flags.typescript,\n unattended: isUnattended,\n visibility: narrowVisibility(flags.visibility),\n }\n}\n"],"names":["VALID_PACKAGE_MANAGERS","Set","narrowPackageManager","value","undefined","has","VALID_VISIBILITIES","narrowVisibility","flagsToInitOptions","flags","isUnattended","args","mcpMode","skillsMode","argType","type","autoUpdates","bare","coupon","dashboard","dataset","datasetDefault","env","fromCreate","git","importDataset","install","nextjsAddConfigFiles","nextjsAppendEnv","nextjsEmbedStudio","organization","outputPath","overwriteFiles","packageManager","project","projectName","projectPlan","provider","reconfigure","template","templateToken","typescript","unattended","visibility"],"mappings":"AAqGA,MAAMA,yBAAyB,IAAIC,IAAY;IAAC;IAAO;IAAQ;CAAO;AACtE,SAASC,qBAAqBC,KAAyB;IACrD,OAAOA,UAAUC,aAAaJ,uBAAuBK,GAAG,CAACF,SACpDA,QACDC;AACN;AAEA,MAAME,qBAAqB,IAAIL,IAAY;IAAC;IAAW;CAAS;AAChE,SAASM,iBAAiBJ,KAAyB;IACjD,OAAOA,UAAUC,aAAaE,mBAAmBD,GAAG,CAACF,SAChDA,QACDC;AACN;AAEA,OAAO,SAASI,mBACdC,KAAuB,EACvBC,YAAqB,EACrBC,IAAiC,EACjCC,OAA+B,EAC/BC,UAAqC;IAErC,OAAO;QACLC,SAASH,MAAMI;QACfC,aAAaP,KAAK,CAAC,eAAe;QAClCQ,MAAMR,MAAMQ,IAAI;QAChBC,QAAQT,MAAMS,MAAM;QACpBC,WAAWV,MAAMU,SAAS;QAC1BC,SAASX,MAAMW,OAAO;QACtBC,gBAAgBZ,KAAK,CAAC,kBAAkB;QACxCa,KAAKb,MAAMa,GAAG;QACdC,YAAYd,KAAK,CAAC,cAAc;QAChCe,KAAKf,KAAK,CAAC,SAAS,GAAG,QAAQA,MAAMe,GAAG;QACxCC,eAAehB,KAAK,CAAC,iBAAiB;QACtCiB,SAASjB,MAAMiB,OAAO;QACtBd;QACAe,sBAAsBlB,KAAK,CAAC,0BAA0B;QACtDmB,iBAAiBnB,KAAK,CAAC,oBAAoB;QAC3CoB,mBAAmBpB,KAAK,CAAC,sBAAsB;QAC/CqB,cAAcrB,MAAMqB,YAAY;QAChCC,YAAYtB,KAAK,CAAC,cAAc;QAChCuB,gBAAgBvB,KAAK,CAAC,kBAAkB;QACxCwB,gBAAgB/B,qBAAqBO,KAAK,CAAC,kBAAkB;QAC7DyB,SAASzB,MAAMyB,OAAO;QACtBC,aAAa1B,KAAK,CAAC,eAAe,IAAIA,KAAK,CAAC,iBAAiB;QAC7D2B,aAAa3B,KAAK,CAAC,eAAe;QAClC4B,UAAU5B,MAAM4B,QAAQ;QACxBC,aAAa7B,MAAM6B,WAAW;QAC9BzB;QACA0B,UAAU9B,MAAM8B,QAAQ;QACxBC,eAAe/B,KAAK,CAAC,iBAAiB;QACtCgC,YAAYhC,MAAMgC,UAAU;QAC5BC,YAAYhC;QACZiC,YAAYpC,iBAAiBE,MAAMkC,UAAU;IAC/C;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/init/types.ts"],"sourcesContent":["import {type CLITelemetryStore, type Output} from '@sanity/cli-core'\nimport {type Framework} from '@vercel/frameworks'\n\nimport {type GenerateConfigOptions} from './createStudioConfig.js'\n\nexport type VersionedFramework = Framework & {\n detectedVersion?: string\n}\n\nexport interface ProjectTemplate {\n configTemplate?: ((variables: GenerateConfigOptions['variables']) => string) | string\n datasetUrl?: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n entry?: string\n importPrompt?: string\n scripts?: Record<string, string>\n type?: 'commonjs' | 'module'\n typescriptOnly?: boolean\n}\n\nexport interface InitOptions {\n autoUpdates: boolean\n bare: boolean\n datasetDefault: boolean\n fromCreate: boolean\n install: boolean\n mcpMode: 'auto' | 'prompt' | 'skip'\n skillsMode: 'auto' | 'prompt' | 'skip'\n unattended: boolean\n\n argType?: string\n coupon?: string\n dashboard?: boolean\n dataset?: string\n env?: string\n git?: boolean | string\n importDataset?: boolean\n nextjsAddConfigFiles?: boolean\n nextjsAppendEnv?: boolean\n nextjsEmbedStudio?: boolean\n organization?: string\n outputPath?: string\n overwriteFiles?: boolean\n packageManager?: 'npm' | 'pnpm' | 'yarn'\n project?: string\n projectName?: string\n projectPlan?: string\n provider?: string\n reconfigure?: boolean\n template?: string\n templateToken?: string\n typescript?: boolean\n visibility?: 'private' | 'public'\n withBlueprints?: boolean\n}\n\nexport interface InitContext {\n output: Output\n telemetry: CLITelemetryStore\n workDir: string\n}\n\ninterface InitCommandFlags {\n 'auto-updates': boolean\n bare: boolean\n 'dataset-default': boolean\n 'from-create': boolean\n install: boolean\n mcp: boolean\n 'no-git': boolean\n skills: boolean\n\n coupon?: string\n 'create-project'?: string\n dashboard?: boolean\n dataset?: string\n env?: string\n git?: string\n 'import-dataset'?: boolean\n 'nextjs-add-config-files'?: boolean\n 'nextjs-append-env'?: boolean\n 'nextjs-embed-studio'?: boolean\n organization?: string\n 'output-path'?: string\n 'overwrite-files'?: boolean\n 'package-manager'?: string\n project?: string\n 'project-name'?: string\n 'project-plan'?: string\n provider?: string\n reconfigure?: boolean\n template?: string\n 'template-token'?: string\n typescript?: boolean\n visibility?: string\n 'with-blueprints'?: boolean\n}\n\ninterface InitCommandArgs {\n type?: string\n}\n\nconst VALID_PACKAGE_MANAGERS = new Set<string>(['npm', 'pnpm', 'yarn'])\nfunction narrowPackageManager(value: string | undefined): InitOptions['packageManager'] {\n return value !== undefined && VALID_PACKAGE_MANAGERS.has(value)\n ? (value as InitOptions['packageManager'])\n : undefined\n}\n\nconst VALID_VISIBILITIES = new Set<string>(['private', 'public'])\nfunction narrowVisibility(value: string | undefined): InitOptions['visibility'] {\n return value !== undefined && VALID_VISIBILITIES.has(value)\n ? (value as InitOptions['visibility'])\n : undefined\n}\n\nexport function flagsToInitOptions(\n flags: InitCommandFlags,\n isUnattended: boolean,\n args: InitCommandArgs | undefined,\n mcpMode: InitOptions['mcpMode'],\n skillsMode: InitOptions['skillsMode'],\n): InitOptions {\n return {\n argType: args?.type,\n autoUpdates: flags['auto-updates'],\n bare: flags.bare,\n coupon: flags.coupon,\n dashboard: flags.dashboard,\n dataset: flags.dataset,\n datasetDefault: flags['dataset-default'],\n env: flags.env,\n fromCreate: flags['from-create'],\n git: flags['no-git'] ? false : flags.git,\n importDataset: flags['import-dataset'],\n install: flags.install,\n mcpMode,\n nextjsAddConfigFiles: flags['nextjs-add-config-files'],\n nextjsAppendEnv: flags['nextjs-append-env'],\n nextjsEmbedStudio: flags['nextjs-embed-studio'],\n organization: flags.organization,\n outputPath: flags['output-path'],\n overwriteFiles: flags['overwrite-files'],\n packageManager: narrowPackageManager(flags['package-manager']),\n project: flags.project,\n projectName: flags['project-name'] ?? flags['create-project'],\n projectPlan: flags['project-plan'],\n provider: flags.provider,\n reconfigure: flags.reconfigure,\n skillsMode,\n template: flags.template,\n templateToken: flags['template-token'],\n typescript: flags.typescript,\n unattended: isUnattended,\n visibility: narrowVisibility(flags.visibility),\n withBlueprints: flags['with-blueprints'],\n }\n}\n"],"names":["VALID_PACKAGE_MANAGERS","Set","narrowPackageManager","value","undefined","has","VALID_VISIBILITIES","narrowVisibility","flagsToInitOptions","flags","isUnattended","args","mcpMode","skillsMode","argType","type","autoUpdates","bare","coupon","dashboard","dataset","datasetDefault","env","fromCreate","git","importDataset","install","nextjsAddConfigFiles","nextjsAppendEnv","nextjsEmbedStudio","organization","outputPath","overwriteFiles","packageManager","project","projectName","projectPlan","provider","reconfigure","template","templateToken","typescript","unattended","visibility","withBlueprints"],"mappings":"AAuGA,MAAMA,yBAAyB,IAAIC,IAAY;IAAC;IAAO;IAAQ;CAAO;AACtE,SAASC,qBAAqBC,KAAyB;IACrD,OAAOA,UAAUC,aAAaJ,uBAAuBK,GAAG,CAACF,SACpDA,QACDC;AACN;AAEA,MAAME,qBAAqB,IAAIL,IAAY;IAAC;IAAW;CAAS;AAChE,SAASM,iBAAiBJ,KAAyB;IACjD,OAAOA,UAAUC,aAAaE,mBAAmBD,GAAG,CAACF,SAChDA,QACDC;AACN;AAEA,OAAO,SAASI,mBACdC,KAAuB,EACvBC,YAAqB,EACrBC,IAAiC,EACjCC,OAA+B,EAC/BC,UAAqC;IAErC,OAAO;QACLC,SAASH,MAAMI;QACfC,aAAaP,KAAK,CAAC,eAAe;QAClCQ,MAAMR,MAAMQ,IAAI;QAChBC,QAAQT,MAAMS,MAAM;QACpBC,WAAWV,MAAMU,SAAS;QAC1BC,SAASX,MAAMW,OAAO;QACtBC,gBAAgBZ,KAAK,CAAC,kBAAkB;QACxCa,KAAKb,MAAMa,GAAG;QACdC,YAAYd,KAAK,CAAC,cAAc;QAChCe,KAAKf,KAAK,CAAC,SAAS,GAAG,QAAQA,MAAMe,GAAG;QACxCC,eAAehB,KAAK,CAAC,iBAAiB;QACtCiB,SAASjB,MAAMiB,OAAO;QACtBd;QACAe,sBAAsBlB,KAAK,CAAC,0BAA0B;QACtDmB,iBAAiBnB,KAAK,CAAC,oBAAoB;QAC3CoB,mBAAmBpB,KAAK,CAAC,sBAAsB;QAC/CqB,cAAcrB,MAAMqB,YAAY;QAChCC,YAAYtB,KAAK,CAAC,cAAc;QAChCuB,gBAAgBvB,KAAK,CAAC,kBAAkB;QACxCwB,gBAAgB/B,qBAAqBO,KAAK,CAAC,kBAAkB;QAC7DyB,SAASzB,MAAMyB,OAAO;QACtBC,aAAa1B,KAAK,CAAC,eAAe,IAAIA,KAAK,CAAC,iBAAiB;QAC7D2B,aAAa3B,KAAK,CAAC,eAAe;QAClC4B,UAAU5B,MAAM4B,QAAQ;QACxBC,aAAa7B,MAAM6B,WAAW;QAC9BzB;QACA0B,UAAU9B,MAAM8B,QAAQ;QACxBC,eAAe/B,KAAK,CAAC,iBAAiB;QACtCgC,YAAYhC,MAAMgC,UAAU;QAC5BC,YAAYhC;QACZiC,YAAYpC,iBAAiBE,MAAMkC,UAAU;QAC7CC,gBAAgBnC,KAAK,CAAC,kBAAkB;IAC1C;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { SANITY_CACHE_DIR } from '@sanity/cli-build/_internal/build';
2
2
  import { extractCoreAppManifest } from '@sanity/cli-build/_internal/manifest';
3
- import { isWorkbenchApp } from '@sanity/workbench-cli';
3
+ import { isWorkbenchApp, isWorkbenchConfig } from '@sanity/workbench-cli';
4
4
  import { gracefulServerDeath } from '../../server/gracefulServerDeath.js';
5
5
  import { startPreviewServer } from '../../server/previewServer.js';
6
6
  import { checkForDeprecatedAppId } from '../../util/appId.js';
@@ -16,7 +16,7 @@ export async function previewAction(options) {
16
16
  rootDir: outDir,
17
17
  workDir
18
18
  });
19
- if (isWorkbenchApp(cliConfig?.app)) {
19
+ if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {
20
20
  const isApp = determineIsApp(cliConfig);
21
21
  // Lazy so a non-workbench `sanity start` never loads the package. `doImport`
22
22
  // is path-based and doesn't apply to a bare specifier.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/preview/previewAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {type CliConfig, type Output} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {type PreviewServer, startPreviewServer} from '../../server/previewServer.js'\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {getPreviewServerConfig} from './getPreviewServerConfig.js'\nimport {type PreviewFlags} from './types.js'\n\ninterface PreviewActionOptions {\n cliConfig: CliConfig\n flags: PreviewFlags\n outDir: string\n output: Output\n workDir: string\n}\n\nexport async function previewAction(\n options: PreviewActionOptions,\n): Promise<PreviewServer | {close: () => Promise<void>}> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n const config = getPreviewServerConfig({cliConfig, flags, rootDir: outDir, workDir})\n\n if (isWorkbenchApp(cliConfig?.app)) {\n const isApp = determineIsApp(cliConfig)\n // Lazy so a non-workbench `sanity start` never loads the package. `doImport`\n // is path-based and doesn't apply to a bare specifier.\n // eslint-disable-next-line eslint-js/no-restricted-syntax\n const {startWorkbenchPreview} = await import('@sanity/workbench-cli/preview')\n return startWorkbenchPreview({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({iconUrl, workDir: wd}) => extractCoreAppManifest({iconUrl, workDir: wd})\n : (params) => extractStudioManifest(params),\n httpHost: config.httpHost,\n httpPort: config.httpPort,\n isApp,\n outDir,\n output,\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n workDir,\n })\n }\n\n try {\n const server = await startPreviewServer(config)\n return server\n } catch (err) {\n throw gracefulServerDeath('preview', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","gracefulServerDeath","startPreviewServer","checkForDeprecatedAppId","determineIsApp","resolveReactStrictMode","extractStudioManifest","getPreviewServerConfig","previewAction","options","cliConfig","flags","outDir","output","workDir","config","rootDir","app","isApp","startWorkbenchPreview","cacheDir","extractManifest","iconUrl","wd","params","httpHost","httpPort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,MAAM5B,oBAAoB,WAAWc,OAAOU,QAAQ,EAAEV,OAAOW,QAAQ,EAAEG;IACzE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/preview/previewAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {type CliConfig, type Output} from '@sanity/cli-core'\nimport {isWorkbenchApp, isWorkbenchConfig} from '@sanity/workbench-cli'\n\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {type PreviewServer, startPreviewServer} from '../../server/previewServer.js'\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {getPreviewServerConfig} from './getPreviewServerConfig.js'\nimport {type PreviewFlags} from './types.js'\n\ninterface PreviewActionOptions {\n cliConfig: CliConfig\n flags: PreviewFlags\n outDir: string\n output: Output\n workDir: string\n}\n\nexport async function previewAction(\n options: PreviewActionOptions,\n): Promise<PreviewServer | {close: () => Promise<void>}> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n const config = getPreviewServerConfig({cliConfig, flags, rootDir: outDir, workDir})\n\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n const isApp = determineIsApp(cliConfig)\n // Lazy so a non-workbench `sanity start` never loads the package. `doImport`\n // is path-based and doesn't apply to a bare specifier.\n // eslint-disable-next-line eslint-js/no-restricted-syntax\n const {startWorkbenchPreview} = await import('@sanity/workbench-cli/preview')\n return startWorkbenchPreview({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({iconUrl, workDir: wd}) => extractCoreAppManifest({iconUrl, workDir: wd})\n : (params) => extractStudioManifest(params),\n httpHost: config.httpHost,\n httpPort: config.httpPort,\n isApp,\n outDir,\n output,\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n workDir,\n })\n }\n\n try {\n const server = await startPreviewServer(config)\n return server\n } catch (err) {\n throw gracefulServerDeath('preview', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","isWorkbenchConfig","gracefulServerDeath","startPreviewServer","checkForDeprecatedAppId","determineIsApp","resolveReactStrictMode","extractStudioManifest","getPreviewServerConfig","previewAction","options","cliConfig","flags","outDir","output","workDir","config","rootDir","app","isApp","startWorkbenchPreview","cacheDir","extractManifest","iconUrl","wd","params","httpHost","httpPort","reactStrictMode","server","err"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,sBAAsB,QAAO,uCAAsC;AAE3E,SAAQC,cAAc,EAAEC,iBAAiB,QAAO,wBAAuB;AAEvE,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAA4BC,kBAAkB,QAAO,gCAA+B;AACpF,SAAQC,uBAAuB,QAAO,sBAAqB;AAC3D,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,sBAAsB,QAAO,8BAA6B;AAWlE,OAAO,eAAeC,cACpBC,OAA6B;IAE7B,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGL;IAEpD,MAAMM,SAASR,uBAAuB;QAACG;QAAWC;QAAOK,SAASJ;QAAQE;IAAO;IAEjF,IAAIf,eAAeW,WAAWO,QAAQjB,kBAAkBU,WAAWO,MAAM;QACvE,MAAMC,QAAQd,eAAeM;QAC7B,6EAA6E;QAC7E,uDAAuD;QACvD,0DAA0D;QAC1D,MAAM,EAACS,qBAAqB,EAAC,GAAG,MAAM,MAAM,CAAC;QAC7C,OAAOA,sBAAsB;YAC3BC,UAAU,GAAGvB,iBAAiB,KAAK,CAAC;YACpCM,yBAAyB,IAAMA,wBAAwB;oBAACO;oBAAWG;gBAAM;YACzEH;YACAW,iBAAiBH,QACb,CAAC,EAACI,OAAO,EAAER,SAASS,EAAE,EAAC,GAAKzB,uBAAuB;oBAACwB;oBAASR,SAASS;gBAAE,KACxE,CAACC,SAAWlB,sBAAsBkB;YACtCC,UAAUV,OAAOU,QAAQ;YACzBC,UAAUX,OAAOW,QAAQ;YACzBR;YACAN;YACAC;YACAc,iBAAiBtB,uBAAuBK,cAAc;YACtDI;QACF;IACF;IAEA,IAAI;QACF,MAAMc,SAAS,MAAM1B,mBAAmBa;QACxC,OAAOa;IACT,EAAE,OAAOC,KAAK;QACZ,MAAM5B,oBAAoB,WAAWc,OAAOU,QAAQ,EAAEV,OAAOW,QAAQ,EAAEG;IACzE;AACF"}
@@ -3,6 +3,8 @@ import { CLIError } from '@oclif/core/errors';
3
3
  import { exitCodes, subdebug } from '@sanity/cli-core';
4
4
  import { getErrorMessage, JsonOutputError } from '@sanity/cli-core/errors';
5
5
  import { confirm, spinner } from '@sanity/cli-core/ux';
6
+ import { fetchDeploySummaryDetails, getWorkbenchUrl } from '@sanity/workbench-cli/deploy';
7
+ import { formatUndeploySummary } from '@sanity/workbench-cli/undeploy';
6
8
  import { createCollectingReporter, createFailFastReporter } from '../../util/checks.js';
7
9
  import { toStderrOutput } from '../../util/toStderrOutput.js';
8
10
  import { describeUndeployTarget, renderUndeployPlan, undeployLabel, undeployPlanToJson } from './undeployPlan.js';
@@ -71,6 +73,7 @@ const undeployDebug = subdebug('undeploy');
71
73
  }
72
74
  /** The real run: resolve the target, confirm, delete, report. */ async function undeployApp(options, adapter) {
73
75
  const { flags, output } = options;
76
+ const startedAt = Date.now();
74
77
  const resolution = await resolveTarget(adapter, createFailFastReporter(output));
75
78
  // A resolve failure never lands here: the fail-fast reporter already exited.
76
79
  if (!resolution) return undefined;
@@ -86,6 +89,7 @@ const undeployDebug = subdebug('undeploy');
86
89
  };
87
90
  }
88
91
  const { target } = resolution;
92
+ const summaryDetails = target.deletes === 'config' && !flags.json ? fetchDeploySummaryDetails(target.organizationId) : undefined;
89
93
  if (!flags.yes && options.isUnattended) {
90
94
  throw new CLIError('Undeploy requires confirmation. Pass --yes to continue.', {
91
95
  exit: exitCodes.USAGE_ERROR
@@ -115,7 +119,10 @@ const undeployDebug = subdebug('undeploy');
115
119
  });
116
120
  }
117
121
  spin.succeed();
118
- printUndeployed(target, output);
122
+ printUndeployed(target, output, {
123
+ ...await summaryDetails,
124
+ durationMs: Date.now() - startedAt
125
+ });
119
126
  return {
120
127
  application: target.application ?? null,
121
128
  deletes: target.deletes,
@@ -148,7 +155,7 @@ const undeployDebug = subdebug('undeploy');
148
155
  }
149
156
  function confirmUndeployMessage(target) {
150
157
  if (target.deletes === 'config') {
151
- return `This will delete the deployed config for ${styleText('yellow', target.title ?? 'this app')}.
158
+ return `This will delete the ${styleText('yellow', target.title ?? 'deployed config')}.
152
159
  Are you ${styleText('red', 'sure')} you want to undeploy?`;
153
160
  }
154
161
  if (target.type === 'coreApp') {
@@ -164,9 +171,14 @@ Are you ${styleText('red', 'sure')} you want to undeploy?`;
164
171
  return `This will undeploy ${styleText('yellow', target.url ?? target.id)} and make it unavailable for your users.
165
172
  Are you ${styleText('red', 'sure')} you want to undeploy?`;
166
173
  }
167
- function printUndeployed(target, output) {
174
+ function printUndeployed(target, output, summary) {
168
175
  if (target.deletes === 'config') {
169
- output.log(`\n${styleText('bold', 'Config deleted.')}`);
176
+ output.log(formatUndeploySummary({
177
+ ...summary,
178
+ organizationId: target.organizationId,
179
+ title: target.title ?? 'Deployed config',
180
+ url: target.url ?? getWorkbenchUrl(target.organizationId)
181
+ }));
170
182
  return;
171
183
  }
172
184
  if (target.type === 'coreApp') {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/undeploy/runUndeploy.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage, JsonOutputError} from '@sanity/cli-core/errors'\nimport {\n type UndeployAdapter,\n type UndeployTarget,\n type UndeployTargetResolution,\n} from '@sanity/cli-core/undeploy'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\n\nimport {type UndeployCommand} from '../../commands/undeploy.js'\nimport {\n type CheckReporter,\n createCollectingReporter,\n createFailFastReporter,\n} from '../../util/checks.js'\nimport {toStderrOutput} from '../../util/toStderrOutput.js'\nimport {\n describeUndeployTarget,\n renderUndeployPlan,\n undeployLabel,\n type UndeployPlan,\n undeployPlanToJson,\n} from './undeployPlan.js'\n\nconst undeployDebug = subdebug('undeploy')\n\ntype UndeployFlags = UndeployCommand['flags']\n\nexport interface UndeployOptions {\n flags: UndeployFlags\n isUnattended: boolean\n output: Output\n}\n\n/** What a real undeploy produced — the payload `--json` reports. */\ntype UndeployResult =\n | {application: null; payload: null; reason: string; undeployed: false}\n | {\n application: object | null\n deletes: UndeployTarget['deletes']\n payload: UndeployTarget['payload']\n reason: null\n undeployed: true\n url: string | null\n }\n\n/**\n * Runs an undeploy in the mode the flags select: a real undeploy fails fast,\n * confirms, and deletes; `--dry-run` drives the same target resolution\n * read-only and renders a plan instead. `--json` emits the same information as\n * machine-readable JSON.\n */\nexport async function runUndeploy(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<void> {\n const {flags, output} = options\n const json = !!flags.json\n const emitJson = (payload: unknown) => output.logJson(payload)\n let failurePayload: unknown\n\n // The JSON payload owns stdout, so the run's progress logs go to stderr; only\n // the final JSON.stringify writes to stdout.\n const runOptions = json ? {...options, output: toStderrOutput(output)} : options\n\n try {\n if (flags['dry-run']) {\n const reporter = createCollectingReporter()\n const resolution = await resolveTarget(adapter, reporter)\n const plan: UndeployPlan = {\n checks: reporter.results,\n reason: resolution?.type === 'none' ? resolution.message : null,\n target: resolution?.type === 'found' ? resolution.target : null,\n type: adapter.type,\n }\n if (json) {\n const payload = undeployPlanToJson(plan)\n if (plan.checks.some((check) => check.status === 'fail')) failurePayload = payload\n else emitJson(payload)\n } else renderUndeployPlan(plan, output)\n // A blocked plan exits like a real (fail-fast) undeploy would.\n const failed = plan.checks.find((check) => check.status === 'fail')\n if (failed) output.error('Undeploy blocked by failing checks.', {exit: failed.exitCode ?? 1})\n return\n }\n\n const result = await undeployApp(runOptions, adapter)\n if (json && result) emitJson(result)\n } catch (error) {\n const failure = normalizeFailure(error, adapter.type)\n // Preserve the blocked plan or the existing undeployment failure envelope.\n if (json && !flags['dry-run']) {\n failurePayload = {\n application: null,\n error: {message: failure.message},\n payload: null,\n reason: failure.message,\n undeployed: false,\n }\n }\n if (json && failurePayload !== undefined) {\n throw new JsonOutputError(failure.message, failurePayload, failure.exit)\n }\n output.error(failure.message, {exit: failure.exit})\n }\n}\n\n/** The real run: resolve the target, confirm, delete, report. */\nasync function undeployApp(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<UndeployResult | undefined> {\n const {flags, output} = options\n\n const resolution = await resolveTarget(adapter, createFailFastReporter(output))\n // A resolve failure never lands here: the fail-fast reporter already exited.\n if (!resolution) return undefined\n if (resolution.type === 'none') {\n output.log(`${resolution.message}.`)\n if (resolution.solution) output.log(`${resolution.solution}.`)\n output.log('Nothing to undeploy.')\n return {application: null, payload: null, reason: resolution.message, undeployed: false}\n }\n\n const {target} = resolution\n if (!flags.yes && options.isUnattended) {\n throw new CLIError('Undeploy requires confirmation. Pass --yes to continue.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n if (!flags.yes) {\n const shouldUndeploy = await confirm({\n default: false,\n message: confirmUndeployMessage(target),\n })\n if (!shouldUndeploy) {\n throw new CLIError('Undeploy cancelled', {exit: exitCodes.USER_ABORT})\n }\n }\n\n const label = undeployLabel(target, adapter.type)\n const spin = spinner(`Undeploying ${label}`).start()\n try {\n await adapter.undeploy(target)\n } catch (error) {\n spin.fail()\n undeployDebug(`Error undeploying ${label}`, error)\n // Labeled here, where the target is known — `normalizeFailure` only sees the adapter type.\n throw new CLIError(`Error undeploying ${label}: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n spin.succeed()\n\n printUndeployed(target, output)\n return {\n application: target.application ?? null,\n deletes: target.deletes,\n payload: target.payload,\n reason: null,\n undeployed: true,\n url: target.url,\n }\n}\n\n/**\n * Resolves the undeploy target and reports the verdict as a check, shared by\n * both modes so a real run and a dry run can't diverge.\n */\nasync function resolveTarget(\n adapter: UndeployAdapter,\n reporter: CheckReporter,\n): Promise<UndeployTargetResolution | null> {\n const spin = spinner('Checking application info').start()\n\n let resolution: UndeployTargetResolution\n try {\n resolution = await adapter.resolveTarget()\n } catch (error) {\n spin.fail()\n undeployDebug('Failed to resolve undeploy target', error)\n reporter.report({\n message: `Failed to resolve undeploy target: ${getErrorMessage(error)}`,\n status: 'fail',\n })\n return null\n }\n\n spin[resolution.type === 'found' ? 'succeed' : 'fail']()\n reporter.report(describeUndeployTarget(resolution))\n return resolution\n}\n\nfunction confirmUndeployMessage(target: UndeployTarget): string {\n if (target.deletes === 'config') {\n return `This will delete the deployed config for ${styleText(\n 'yellow',\n target.title ?? 'this app',\n )}.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n if (target.type === 'coreApp') {\n return `This will undeploy the following application:\n\n Title: ${styleText('yellow', target.title || '(untitled application)')}\n ID: ${styleText('yellow', target.id)}\n\nThe application will no longer be available for any of your users if you proceed.\n\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n return `This will undeploy ${styleText('yellow', target.url ?? target.id)} and make it unavailable for your users.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n}\n\nfunction printUndeployed(target: UndeployTarget, output: Output): void {\n if (target.deletes === 'config') {\n output.log(`\\n${styleText('bold', 'Config deleted.')}`)\n return\n }\n\n if (target.type === 'coreApp') {\n output.log(\n `\\n${styleText('bold', '⏱️ Application undeploy scheduled.')} It might be a few minutes until ${\n target.title ? styleText('italic', `'${target.title}'`) : 'your application'\n } is unavailable.`,\n )\n output.log(\n `\\n${styleText('bold', 'Remember to remove `deployment.appId` from your application configuration')} to avoid errors when redeploying.`,\n )\n return\n }\n\n output.log(\n `\\nStudio undeploy scheduled. It might be a few minutes until ${target.url ?? 'your studio'} is unavailable.`,\n )\n}\n\n/** The one failure diagnosis both the stderr message and the `--json` envelope read. */\nfunction normalizeFailure(\n error: unknown,\n type: UndeployAdapter['type'],\n): {exit: number; message: string} {\n // Ctrl+C on the confirmation prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n return {exit: exitCodes.USER_ABORT, message: 'Undeploy cancelled'}\n }\n // A failed check already carries its own message and exit code\n if (error instanceof CLIError) {\n return {exit: error.oclif?.exit ?? 1, message: error.message}\n }\n const label = type === 'coreApp' ? 'application' : 'studio'\n undeployDebug(`Error undeploying ${label}`, error)\n return {\n exit: exitCodes.RUNTIME_ERROR,\n message: `Error undeploying ${label}: ${getErrorMessage(error)}`,\n }\n}\n"],"names":["styleText","CLIError","exitCodes","subdebug","getErrorMessage","JsonOutputError","confirm","spinner","createCollectingReporter","createFailFastReporter","toStderrOutput","describeUndeployTarget","renderUndeployPlan","undeployLabel","undeployPlanToJson","undeployDebug","runUndeploy","options","adapter","flags","output","json","emitJson","payload","logJson","failurePayload","runOptions","reporter","resolution","resolveTarget","plan","checks","results","reason","type","message","target","some","check","status","failed","find","error","exit","exitCode","result","undeployApp","failure","normalizeFailure","application","undeployed","undefined","log","solution","yes","isUnattended","USAGE_ERROR","shouldUndeploy","default","confirmUndeployMessage","USER_ABORT","label","spin","start","undeploy","fail","RUNTIME_ERROR","succeed","printUndeployed","deletes","url","report","title","id","Error","name","oclif"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,EAAeC,QAAQ,QAAO,mBAAkB;AACjE,SAAQC,e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BAC3D,gBAAgB,CAAC;QAEpBpD,OAAOgC,GAAG,CACR,CAAC,EAAE,EAAEpD,UAAU,QAAQ,6EAA6E,kCAAkC,CAAC;QAEzI;IACF;IAEAoB,OAAOgC,GAAG,CACR,CAAC,6DAA6D,EAAEhB,OAAOkC,GAAG,IAAI,cAAc,gBAAgB,CAAC;AAEjH;AAEA,sFAAsF,GACtF,SAAStB,iBACPN,KAAc,EACdR,IAA6B;IAE7B,yDAAyD;IACzD,IAAIQ,iBAAiBgC,SAAShC,MAAMiC,IAAI,KAAK,mBAAmB;QAC9D,OAAO;YAAChC,MAAMzC,UAAU0D,UAAU;YAAEzB,SAAS;QAAoB;IACnE;IACA,+DAA+D;IAC/D,IAAIO,iBAAiBzC,UAAU;QAC7B,OAAO;YAAC0C,MAAMD,MAAMkC,KAAK,EAAEjC,QAAQ;YAAGR,SAASO,MAAMP,OAAO;QAAA;IAC9D;IACA,MAAM0B,QAAQ3B,SAAS,YAAY,gBAAgB;IACnDnB,cAAc,CAAC,kBAAkB,EAAE8C,OAAO,EAAEnB;IAC5C,OAAO;QACLC,MAAMzC,UAAUgE,aAAa;QAC7B/B,SAAS,CAAC,kBAAkB,EAAE0B,MAAM,EAAE,EAAEzD,gBAAgBsC,QAAQ;IAClE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/undeploy/runUndeploy.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage, JsonOutputError} from '@sanity/cli-core/errors'\nimport {\n type UndeployAdapter,\n type UndeployTarget,\n type UndeployTargetResolution,\n} from '@sanity/cli-core/undeploy'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {fetchDeploySummaryDetails, getWorkbenchUrl} from '@sanity/workbench-cli/deploy'\nimport {formatUndeploySummary} from '@sanity/workbench-cli/undeploy'\n\nimport {type UndeployCommand} from '../../commands/undeploy.js'\nimport {\n type CheckReporter,\n createCollectingReporter,\n createFailFastReporter,\n} from '../../util/checks.js'\nimport {toStderrOutput} from '../../util/toStderrOutput.js'\nimport {\n describeUndeployTarget,\n renderUndeployPlan,\n undeployLabel,\n type UndeployPlan,\n undeployPlanToJson,\n} from './undeployPlan.js'\n\nconst undeployDebug = subdebug('undeploy')\n\ntype UndeployFlags = UndeployCommand['flags']\n\nexport interface UndeployOptions {\n flags: UndeployFlags\n isUnattended: boolean\n output: Output\n}\n\n/** What a real undeploy produced — the payload `--json` reports. */\ntype UndeployResult =\n | {application: null; payload: null; reason: string; undeployed: false}\n | {\n application: object | null\n deletes: UndeployTarget['deletes']\n payload: UndeployTarget['payload']\n reason: null\n undeployed: true\n url: string | null\n }\n\n/**\n * Runs an undeploy in the mode the flags select: a real undeploy fails fast,\n * confirms, and deletes; `--dry-run` drives the same target resolution\n * read-only and renders a plan instead. `--json` emits the same information as\n * machine-readable JSON.\n */\nexport async function runUndeploy(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<void> {\n const {flags, output} = options\n const json = !!flags.json\n const emitJson = (payload: unknown) => output.logJson(payload)\n let failurePayload: unknown\n\n // The JSON payload owns stdout, so the run's progress logs go to stderr; only\n // the final JSON.stringify writes to stdout.\n const runOptions = json ? {...options, output: toStderrOutput(output)} : options\n\n try {\n if (flags['dry-run']) {\n const reporter = createCollectingReporter()\n const resolution = await resolveTarget(adapter, reporter)\n const plan: UndeployPlan = {\n checks: reporter.results,\n reason: resolution?.type === 'none' ? resolution.message : null,\n target: resolution?.type === 'found' ? resolution.target : null,\n type: adapter.type,\n }\n if (json) {\n const payload = undeployPlanToJson(plan)\n if (plan.checks.some((check) => check.status === 'fail')) failurePayload = payload\n else emitJson(payload)\n } else renderUndeployPlan(plan, output)\n // A blocked plan exits like a real (fail-fast) undeploy would.\n const failed = plan.checks.find((check) => check.status === 'fail')\n if (failed) output.error('Undeploy blocked by failing checks.', {exit: failed.exitCode ?? 1})\n return\n }\n\n const result = await undeployApp(runOptions, adapter)\n if (json && result) emitJson(result)\n } catch (error) {\n const failure = normalizeFailure(error, adapter.type)\n // Preserve the blocked plan or the existing undeployment failure envelope.\n if (json && !flags['dry-run']) {\n failurePayload = {\n application: null,\n error: {message: failure.message},\n payload: null,\n reason: failure.message,\n undeployed: false,\n }\n }\n if (json && failurePayload !== undefined) {\n throw new JsonOutputError(failure.message, failurePayload, failure.exit)\n }\n output.error(failure.message, {exit: failure.exit})\n }\n}\n\n/** The real run: resolve the target, confirm, delete, report. */\nasync function undeployApp(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<UndeployResult | undefined> {\n const {flags, output} = options\n const startedAt = Date.now()\n\n const resolution = await resolveTarget(adapter, createFailFastReporter(output))\n // A resolve failure never lands here: the fail-fast reporter already exited.\n if (!resolution) return undefined\n if (resolution.type === 'none') {\n output.log(`${resolution.message}.`)\n if (resolution.solution) output.log(`${resolution.solution}.`)\n output.log('Nothing to undeploy.')\n return {application: null, payload: null, reason: resolution.message, undeployed: false}\n }\n\n const {target} = resolution\n const summaryDetails =\n target.deletes === 'config' && !flags.json\n ? fetchDeploySummaryDetails(target.organizationId)\n : undefined\n\n if (!flags.yes && options.isUnattended) {\n throw new CLIError('Undeploy requires confirmation. Pass --yes to continue.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n if (!flags.yes) {\n const shouldUndeploy = await confirm({\n default: false,\n message: confirmUndeployMessage(target),\n })\n if (!shouldUndeploy) {\n throw new CLIError('Undeploy cancelled', {exit: exitCodes.USER_ABORT})\n }\n }\n\n const label = undeployLabel(target, adapter.type)\n const spin = spinner(`Undeploying ${label}`).start()\n try {\n await adapter.undeploy(target)\n } catch (error) {\n spin.fail()\n undeployDebug(`Error undeploying ${label}`, error)\n // Labeled here, where the target is known — `normalizeFailure` only sees the adapter type.\n throw new CLIError(`Error undeploying ${label}: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n spin.succeed()\n\n printUndeployed(target, output, {\n ...(await summaryDetails),\n durationMs: Date.now() - startedAt,\n })\n return {\n application: target.application ?? null,\n deletes: target.deletes,\n payload: target.payload,\n reason: null,\n undeployed: true,\n url: target.url,\n }\n}\n\n/**\n * Resolves the undeploy target and reports the verdict as a check, shared by\n * both modes so a real run and a dry run can't diverge.\n */\nasync function resolveTarget(\n adapter: UndeployAdapter,\n reporter: CheckReporter,\n): Promise<UndeployTargetResolution | null> {\n const spin = spinner('Checking application info').start()\n\n let resolution: UndeployTargetResolution\n try {\n resolution = await adapter.resolveTarget()\n } catch (error) {\n spin.fail()\n undeployDebug('Failed to resolve undeploy target', error)\n reporter.report({\n message: `Failed to resolve undeploy target: ${getErrorMessage(error)}`,\n status: 'fail',\n })\n return null\n }\n\n spin[resolution.type === 'found' ? 'succeed' : 'fail']()\n reporter.report(describeUndeployTarget(resolution))\n return resolution\n}\n\nfunction confirmUndeployMessage(target: UndeployTarget): string {\n if (target.deletes === 'config') {\n return `This will delete the ${styleText('yellow', target.title ?? 'deployed config')}.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n if (target.type === 'coreApp') {\n return `This will undeploy the following application:\n\n Title: ${styleText('yellow', target.title || '(untitled application)')}\n ID: ${styleText('yellow', target.id)}\n\nThe application will no longer be available for any of your users if you proceed.\n\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n return `This will undeploy ${styleText('yellow', target.url ?? target.id)} and make it unavailable for your users.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n}\n\nfunction printUndeployed(\n target: UndeployTarget,\n output: Output,\n summary: {durationMs: number; organizationName?: string | null},\n): void {\n if (target.deletes === 'config') {\n output.log(\n formatUndeploySummary({\n ...summary,\n organizationId: target.organizationId,\n title: target.title ?? 'Deployed config',\n url: target.url ?? getWorkbenchUrl(target.organizationId),\n }),\n )\n return\n }\n\n if (target.type === 'coreApp') {\n output.log(\n `\\n${styleText('bold', '⏱️ Application undeploy scheduled.')} It might be a few minutes until ${\n target.title ? styleText('italic', `'${target.title}'`) : 'your application'\n } is unavailable.`,\n )\n output.log(\n `\\n${styleText('bold', 'Remember to remove `deployment.appId` from your application configuration')} to avoid errors when redeploying.`,\n )\n return\n }\n\n output.log(\n `\\nStudio undeploy scheduled. It might be a few minutes until ${target.url ?? 'your studio'} is unavailable.`,\n )\n}\n\n/** The one failure diagnosis both the stderr message and the `--json` envelope read. */\nfunction normalizeFailure(\n error: unknown,\n type: UndeployAdapter['type'],\n): {exit: number; message: string} {\n // Ctrl+C on the confirmation prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n return {exit: exitCodes.USER_ABORT, message: 'Undeploy cancelled'}\n }\n // A failed check already carries its own message and exit code\n if (error instanceof CLIError) {\n return {exit: error.oclif?.exit ?? 1, message: error.message}\n }\n const label = type === 'coreApp' ? 'application' : 'studio'\n undeployDebug(`Error undeploying ${label}`, error)\n return {\n exit: exitCodes.RUNTIME_ERROR,\n message: `Error undeploying ${label}: ${getErrorMessage(error)}`,\n }\n}\n"],"names":["styleText","CLIError","exitCodes","subdebug","getErrorMessage","JsonOutputError","confirm","spinner","fetchDeploySummaryDetails","getWorkbenchUrl","formatUndeploySummary","createCollectingReporter","createFailFastReporter","toStderrOutput","describeUndeployTarget","renderUndeployPlan","undeployLabel","undeployPlanToJson","undeployDebug","runUndeploy","options","adapter","flags","output","json","emitJson","payload","logJson","failurePayload","runOptions","reporter","resolution","resolveTarget","plan","checks","results","reason","type","message","target","some","check","status","failed","find","error","exit","exitCode","result","undeployApp","failure","normalizeFailure","application","undeployed","undefined","startedAt","Date","now","log","solution","summaryDetails","deletes","organizationId","yes","isUnattended","USAGE_ERROR","shouldUndeploy","default","confirmUndeployMessage","USER_ABORT","label","spin","start","undeploy","fail","RUNTIME_ERROR","succeed","printUndeployed","durationMs","url","report","title","id","summary","Error","name","oclif"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,EAAeC,QAAQ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E,EAAElE,gBAAgByC,QAAQ;IAClE;AACF"}
@@ -5,7 +5,7 @@ export function canUndeploy(plan) {
5
5
  }
6
6
  /** What an undeploy deletes, phrased for the human output. */ export function undeployLabel(target, type) {
7
7
  if (target?.deletes === 'config') {
8
- return `installation config${target.title ? ` for "${target.title}"` : ''}`;
8
+ return target.title ?? 'deployed config';
9
9
  }
10
10
  return type === 'coreApp' ? 'application' : 'studio';
11
11
  }
@@ -46,7 +46,7 @@ export function canUndeploy(plan) {
46
46
  const { target } = resolution;
47
47
  if (target.deletes === 'config') {
48
48
  return {
49
- message: target.title ? `Undeploys the installation config for "${target.title}"` : 'Undeploys the installation config',
49
+ message: `Undeploys the ${target.title ?? 'deployed config'}`,
50
50
  status: 'pass'
51
51
  };
52
52
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/undeploy/undeployPlan.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\nimport {type UndeployTarget, type UndeployTargetResolution} from '@sanity/cli-core/undeploy'\n\nimport {type Check, checkStatusIcon, renderIssues} from '../../util/checks.js'\n\n/** What a `--dry-run` undeploy would do: the real undeploy sequence with the deletion gated off. */\nexport interface UndeployPlan {\n checks: Check[]\n /** Why there is nothing to undeploy; `null` when a target resolved. */\n reason: string | null\n /** What would be deleted; `null` when there is nothing to undeploy. */\n target: UndeployTarget | null\n type: 'coreApp' | 'studio'\n}\n\nexport function canUndeploy(plan: UndeployPlan): boolean {\n return plan.target !== null && plan.checks.every((check) => check.status !== 'fail')\n}\n\n/** What an undeploy deletes, phrased for the human output. */\nexport function undeployLabel(target: UndeployTarget | null, type: 'coreApp' | 'studio'): string {\n if (target?.deletes === 'config') {\n return `installation config${target.title ? ` for \"${target.title}\"` : ''}`\n }\n return type === 'coreApp' ? 'application' : 'studio'\n}\n\n/**\n * A machine-readable projection of the plan: blocking problems mapped to their\n * fix, warnings as messages. Derived from the same checks and target the human\n * report renders, so the two can't drift.\n */\nexport function undeployPlanToJson(plan: UndeployPlan): UndeployPlanJson {\n const errors: Record<string, string | null> = {}\n const warnings: string[] = []\n for (const check of plan.checks) {\n if (check.status === 'fail') errors[check.message] = check.solution ?? null\n else if (check.status === 'warn') warnings.push(check.message)\n }\n\n return {\n // Only a successful undeploy reports the backend's record.\n application: null,\n canUndeploy: canUndeploy(plan),\n deletes: plan.target?.deletes ?? null,\n errors,\n payload: plan.target?.payload ?? null,\n reason: plan.reason ?? plan.checks.find((check) => check.status === 'fail')?.message ?? null,\n url: plan.target?.url ?? null,\n warnings,\n }\n}\n\ninterface UndeployPlanJson {\n application: null\n canUndeploy: boolean\n deletes: UndeployTarget['deletes'] | null\n errors: Record<string, string | null>\n payload: UndeployTarget['payload'] | null\n reason: string | null\n url: string | null\n warnings: string[]\n}\n\n/**\n * The single diagnosis for each undeploy-target verdict, shared by the dry-run\n * report and the real run so message and fix can't drift between the two.\n */\nexport function describeUndeployTarget(resolution: UndeployTargetResolution): Check {\n if (resolution.type === 'none') {\n return {message: resolution.message, solution: resolution.solution, status: 'skip'}\n }\n\n const {target} = resolution\n if (target.deletes === 'config') {\n return {\n message: target.title\n ? `Undeploys the installation config for \"${target.title}\"`\n : 'Undeploys the installation config',\n status: 'pass',\n }\n }\n if (target.type === 'studio') {\n return {message: `Undeploys studio ${target.url ?? target.id}`, status: 'pass'}\n }\n const name = target.title ? `\"${target.title}\" (${target.id})` : target.id\n return {message: `Undeploys application ${name}`, status: 'pass'}\n}\n\nexport function renderUndeployPlan(plan: UndeployPlan, output: Output): void {\n const problems = plan.checks.filter((check) => check.status === 'fail')\n const warnings = plan.checks.filter((check) => check.status === 'warn')\n\n output.log('\\nDry run — no changes made.\\n')\n\n // Only pass/skip here; problems and warnings render below with their fixes.\n // A passing target check already says what gets undeployed, so an\n // undeployable plan needs no extra verdict line.\n for (const check of plan.checks) {\n if (check.status === 'pass' || check.status === 'skip') {\n const fix = check.solution ? `: ${check.solution}` : ''\n output.log(` ${checkStatusIcon(check.status)} ${check.message}${fix}`)\n }\n }\n\n if (plan.target) renderTarget(plan.target, output)\n\n if (!canUndeploy(plan)) {\n if (problems.length > 0) {\n const label = undeployLabel(plan.target, plan.type)\n output.log(\n styleText(\n 'red',\n `\\n${checkStatusIcon('fail')} ${label[0].toUpperCase()}${label.slice(1)} can not be undeployed.`,\n ),\n )\n } else {\n output.log('\\nNothing to undeploy.')\n }\n }\n\n renderIssues(output, 'Problems to fix:', problems)\n renderIssues(output, 'Warnings:', warnings)\n}\n\nfunction renderTarget(target: UndeployTarget, output: Output): void {\n const rows: [string, string | null][] = [\n ['Title', target.title],\n ['ID', target.id],\n ['URL', target.url],\n ]\n\n output.log('')\n for (const [key, value] of rows) {\n if (value) output.log(` ${key.padEnd(8)} ${styleText('yellow', value)}`)\n }\n\n // Adapter-authored lines about what gets deleted (interfaces, config snapshots, …)\n for (const entry of target.summary ?? []) {\n for (const line of entry.split('\\n')) output.log(` ${line}`)\n }\n}\n"],"names":["styleText","checkStatusIcon","renderIssues","canUndeploy","plan","target","checks","every","check","status","undeployLabel","type","deletes","title","undeployPlanToJson","errors","warnings","message","solution","push","application","payload","reason","find","url","describeUndeployTarget","resolution","id","name","renderUndeployPlan","output","problems","filter","log","fix","renderTarget","length","label","toUpperCase","slice","rows","key","value","padEnd","entry","summary","line","split"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAKnC,SAAoBC,eAAe,EAAEC,YAAY,QAAO,uBAAsB;AAY9E,OAAO,SAASC,YAAYC,IAAkB;IAC5C,OAAOA,KAAKC,MAAM,KAAK,QAAQD,KAAKE,MAAM,CAACC,KAAK,CAAC,CAACC,QAAUA,MAAMC,MAAM,KAAK;AAC/E;AAEA,4DAA4D,GAC5D,OAAO,SAASC,cAAcL,MAA6B,EAAEM,IAA0B;IACrF,IAAIN,QAAQO,YAAY,UAAU;QAChC,OAAO,CAAC,mBAAmB,EAAEP,OAAOQ,KAAK,GAAG,CAAC,MAAM,EAAER,OAAOQ,KAAK,CAAC,CAAC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AAK,CAAC,GAAG,uBAAuB,CAAC;QAGtG,OAAO;YACLT,OAAOG,GAAG,CAAC;QACb;IACF;IAEA/B,aAAa4B,QAAQ,oBAAoBC;IACzC7B,aAAa4B,QAAQ,aAAad;AACpC;AAEA,SAASmB,aAAa9B,MAAsB,EAAEyB,MAAc;IAC1D,MAAMU,OAAkC;QACtC;YAAC;YAASnC,OAAOQ,KAAK;SAAC;QACvB;YAAC;YAAMR,OAAOsB,EAAE;SAAC;QACjB;YAAC;YAAOtB,OAAOmB,GAAG;SAAC;KACpB;IAEDM,OAAOG,GAAG,CAAC;IACX,KAAK,MAAM,CAACQ,KAAKC,MAAM,IAAIF,KAAM;QAC/B,IAAIE,OAAOZ,OAAOG,GAAG,CAAC,CAAC,IAAI,EAAEQ,IAAIE,MAAM,CAAC,GAAG,CAAC,EAAE3C,UAAU,UAAU0C,QAAQ;IAC5E;IAEA,mFAAmF;IACnF,KAAK,MAAME,SAASvC,OAAOwC,OAAO,IAAI,EAAE,CAAE;QACxC,KAAK,MAAMC,QAAQF,MAAMG,KAAK,CAAC,MAAOjB,OAAOG,GAAG,CAAC,CAAC,IAAI,EAAEa,MAAM;IAChE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/undeploy/undeployPlan.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\nimport {type UndeployTarget, type UndeployTargetResolution} from '@sanity/cli-core/undeploy'\n\nimport {type Check, checkStatusIcon, renderIssues} from '../../util/checks.js'\n\n/** What a `--dry-run` undeploy would do: the real undeploy sequence with the deletion gated off. */\nexport interface UndeployPlan {\n checks: Check[]\n /** Why there is nothing to undeploy; `null` when a target resolved. */\n reason: string | null\n /** What would be deleted; `null` when there is nothing to undeploy. */\n target: UndeployTarget | null\n type: 'coreApp' | 'studio'\n}\n\nexport function canUndeploy(plan: UndeployPlan): boolean {\n return plan.target !== null && plan.checks.every((check) => check.status !== 'fail')\n}\n\n/** What an undeploy deletes, phrased for the human output. */\nexport function undeployLabel(target: UndeployTarget | null, type: 'coreApp' | 'studio'): string {\n if (target?.deletes === 'config') {\n return target.title ?? 'deployed config'\n }\n return type === 'coreApp' ? 'application' : 'studio'\n}\n\n/**\n * A machine-readable projection of the plan: blocking problems mapped to their\n * fix, warnings as messages. Derived from the same checks and target the human\n * report renders, so the two can't drift.\n */\nexport function undeployPlanToJson(plan: UndeployPlan): UndeployPlanJson {\n const errors: Record<string, string | null> = {}\n const warnings: string[] = []\n for (const check of plan.checks) {\n if (check.status === 'fail') errors[check.message] = check.solution ?? null\n else if (check.status === 'warn') warnings.push(check.message)\n }\n\n return {\n // Only a successful undeploy reports the backend's record.\n application: null,\n canUndeploy: canUndeploy(plan),\n deletes: plan.target?.deletes ?? null,\n errors,\n payload: plan.target?.payload ?? null,\n reason: plan.reason ?? plan.checks.find((check) => check.status === 'fail')?.message ?? null,\n url: plan.target?.url ?? null,\n warnings,\n }\n}\n\ninterface UndeployPlanJson {\n application: null\n canUndeploy: boolean\n deletes: UndeployTarget['deletes'] | null\n errors: Record<string, string | null>\n payload: UndeployTarget['payload'] | null\n reason: string | null\n url: string | null\n warnings: string[]\n}\n\n/**\n * The single diagnosis for each undeploy-target verdict, shared by the dry-run\n * report and the real run so message and fix can't drift between the two.\n */\nexport function describeUndeployTarget(resolution: UndeployTargetResolution): Check {\n if (resolution.type === 'none') {\n return {message: resolution.message, solution: resolution.solution, status: 'skip'}\n }\n\n const {target} = resolution\n if (target.deletes === 'config') {\n return {\n message: `Undeploys the ${target.title ?? 'deployed config'}`,\n status: 'pass',\n }\n }\n if (target.type === 'studio') {\n return {message: `Undeploys studio ${target.url ?? target.id}`, status: 'pass'}\n }\n const name = target.title ? `\"${target.title}\" (${target.id})` : target.id\n return {message: `Undeploys application ${name}`, status: 'pass'}\n}\n\nexport function renderUndeployPlan(plan: UndeployPlan, output: Output): void {\n const problems = plan.checks.filter((check) => check.status === 'fail')\n const warnings = plan.checks.filter((check) => check.status === 'warn')\n\n output.log('\\nDry run — no changes made.\\n')\n\n // Only pass/skip here; problems and warnings render below with their fixes.\n // A passing target check already says what gets undeployed, so an\n // undeployable plan needs no extra verdict line.\n for (const check of plan.checks) {\n if (check.status === 'pass' || check.status === 'skip') {\n const fix = check.solution ? `: ${check.solution}` : ''\n output.log(` ${checkStatusIcon(check.status)} ${check.message}${fix}`)\n }\n }\n\n if (plan.target) renderTarget(plan.target, output)\n\n if (!canUndeploy(plan)) {\n if (problems.length > 0) {\n const label = undeployLabel(plan.target, plan.type)\n output.log(\n styleText(\n 'red',\n `\\n${checkStatusIcon('fail')} ${label[0].toUpperCase()}${label.slice(1)} can not be undeployed.`,\n ),\n )\n } else {\n output.log('\\nNothing to undeploy.')\n }\n }\n\n renderIssues(output, 'Problems to fix:', problems)\n renderIssues(output, 'Warnings:', warnings)\n}\n\nfunction renderTarget(target: UndeployTarget, output: Output): void {\n const rows: [string, string | null][] = [\n ['Title', target.title],\n ['ID', target.id],\n ['URL', target.url],\n ]\n\n output.log('')\n for (const [key, value] of rows) {\n if (value) output.log(` ${key.padEnd(8)} ${styleText('yellow', value)}`)\n }\n\n // Adapter-authored lines about what gets deleted (interfaces, config snapshots, …)\n for (const entry of target.summary ?? []) {\n for (const line of entry.split('\\n')) output.log(` ${line}`)\n }\n}\n"],"names":["styleText","checkStatusIcon","renderIssues","canUndeploy","plan","target","checks","every","check","status","undeployLabel","type","deletes","title","undeployPlanToJson","errors","warnings","message","solution","push","application","payload","reason","find","url","describeUndeployTarget","resolution","id","name","renderUndeployPlan","output","problems","filter","log","fix","renderTarget","length","label","toUpperCase","slice","rows","key","value","padEnd","entry","summary","line","split"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAKnC,SAAoBC,eAAe,EAAEC,YAAY,QAAO,uBAAsB;AAY9E,OAAO,SAASC,YAAYC,IAAkB;IAC5C,OAAOA,KAAKC,MAAM,KAAK,QAAQD,KAAKE,MAAM,CAACC,KAAK,CAAC,CAACC,QAAUA,MAAMC,MAAM,KAAK;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AAE,EAAEC,gBAAgB,QAAQ,CAAC,EAAEoC,KAAK,CAAC,EAAE,CAACC,WAAW,KAAKD,MAAME,KAAK,CAAC,GAAG,uBAAuB,CAAC;QAGtG,OAAO;YACLT,OAAOG,GAAG,CAAC;QACb;IACF;IAEA/B,aAAa4B,QAAQ,oBAAoBC;IACzC7B,aAAa4B,QAAQ,aAAad;AACpC;AAEA,SAASmB,aAAa9B,MAAsB,EAAEyB,MAAc;IAC1D,MAAMU,OAAkC;QACtC;YAAC;YAASnC,OAAOQ,KAAK;SAAC;QACvB;YAAC;YAAMR,OAAOsB,EAAE;SAAC;QACjB;YAAC;YAAOtB,OAAOmB,GAAG;SAAC;KACpB;IAEDM,OAAOG,GAAG,CAAC;IACX,KAAK,MAAM,CAACQ,KAAKC,MAAM,IAAIF,KAAM;QAC/B,IAAIE,OAAOZ,OAAOG,GAAG,CAAC,CAAC,IAAI,EAAEQ,IAAIE,MAAM,CAAC,GAAG,CAAC,EAAE3C,UAAU,UAAU0C,QAAQ;IAC5E;IAEA,mFAAmF;IACnF,KAAK,MAAME,SAASvC,OAAOwC,OAAO,IAAI,EAAE,CAAE;QACxC,KAAK,MAAMC,QAAQF,MAAMG,KAAK,CAAC,MAAOjB,OAAOG,GAAG,CAAC,CAAC,IAAI,EAAEa,MAAM;IAChE;AACF"}
@@ -4,6 +4,7 @@ import { exitCodes, SanityCommand } from '@sanity/cli-core';
4
4
  import { confirm } from '@sanity/cli-core/ux';
5
5
  import { getWorkbench, resolveWorkbenchConfig } from '@sanity/workbench-cli/deploy';
6
6
  import { deployApp } from '../actions/deploy/deployApp.js';
7
+ import { deployDashboardConfig } from '../actions/deploy/deployDashboardConfig.js';
7
8
  import { deployDebug } from '../actions/deploy/deployDebug.js';
8
9
  import { deployStudio } from '../actions/deploy/deployStudio.js';
9
10
  import { getAppId } from '../util/appId.js';
@@ -133,11 +134,12 @@ export class DeployCommand extends SanityCommand {
133
134
  const cliConfig = await this.getCliConfig();
134
135
  const projectRoot = await this.getProjectRoot();
135
136
  const isApp = determineIsApp(cliConfig);
137
+ const config = resolveWorkbenchConfig(cliConfig);
136
138
  // `--media-library-id` only steers the aspect-document sync of a Media
137
139
  // Library config deploy (see deployApp); studio and app deploys never read
138
140
  // it. Warned rather than silently dropped (same courtesy init gives
139
141
  // --dashboard on the media template).
140
- if (flags['media-library-id'] && !resolveWorkbenchConfig(cliConfig)) {
142
+ if (flags['media-library-id'] && config?.appType !== 'media-library') {
141
143
  this.output.warn('--media-library-id is ignored — it only applies when deploying a Media Library config');
142
144
  }
143
145
  if (flags.create) {
@@ -147,7 +149,7 @@ export class DeployCommand extends SanityCommand {
147
149
  if (getAppId(cliConfig)) {
148
150
  return this.output.error('--create cannot be used with a configured app ID. Omit --create to deploy to that app, or remove deployment.appId and app.id to create a new one.');
149
151
  }
150
- if (getWorkbench(cliConfig) || resolveWorkbenchConfig(cliConfig)) {
152
+ if (getWorkbench(cliConfig) || config) {
151
153
  return this.output.error('--create is not supported for this app configuration. Omit --create and run sanity deploy.');
152
154
  }
153
155
  }
@@ -179,7 +181,17 @@ export class DeployCommand extends SanityCommand {
179
181
  ...flags,
180
182
  yes: true
181
183
  } : flags;
182
- if (isApp) {
184
+ if (config?.appType === 'dashboard') {
185
+ deployDebug('Deploying dashboard configuration');
186
+ await deployDashboardConfig({
187
+ cliConfig,
188
+ config,
189
+ flags: deployFlags,
190
+ output: this.output,
191
+ projectRoot,
192
+ sourceDir
193
+ });
194
+ } else if (isApp) {
183
195
  deployDebug('Deploying app');
184
196
  await deployApp({
185
197
  cliConfig,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/deploy.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {Args, Flags} from '@oclif/core'\nimport {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {getWorkbench, resolveWorkbenchConfig} from '@sanity/workbench-cli/deploy'\n\nimport {deployApp} from '../actions/deploy/deployApp.js'\nimport {deployDebug} from '../actions/deploy/deployDebug.js'\nimport {deployStudio} from '../actions/deploy/deployStudio.js'\nimport {getAppId} from '../util/appId.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\nimport {dirIsEmptyOrNonExistent} from '../util/dirIsEmptyOrNonExistent.js'\nimport {defineCommandTelemetry} from '../util/telemetry/commandTelemetry.js'\n\nexport class DeployCommand extends SanityCommand<typeof DeployCommand> {\n static override args = {\n sourceDir: Args.directory({\n description: 'Source directory',\n }),\n }\n\n static override description = 'Builds and deploys Sanity Studio or application to Sanity hosting'\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Build and deploy the studio to Sanity hosting',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n description: 'Deploys non-minified build with source maps',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --schema-required',\n description:\n 'Fail fast on schema store fails - for when other services rely on the stored schema',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --external',\n description: 'Register an externally hosted studio (studioHost contains full URL)',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --external --url https://apps.example.com',\n description: 'Register an externally hosted studio, served from the provided origin',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --create --title \"My App\" --yes --json',\n description:\n 'Create and deploy an App SDK app without prompts. Save application.id as deployment.appId, then omit --create on later deploys',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --create --title \"My App\" --dry-run --json',\n description: 'Preview a new App SDK deployment without creating or uploading anything',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --url my-studio --yes',\n description: 'Deploy a studio without prompts using its hostname',\n },\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n deprecated: true,\n description: 'Automatically update the studio to the latest version',\n }),\n build: Flags.boolean({\n allowNo: true,\n default: true,\n description:\n 'Build the studio before deploying (use --no-build to deploy existing `dist/` output)',\n }),\n create: Flags.boolean({\n description: 'Create a new App SDK app, even if the organization has other apps',\n exclusive: ['external', 'url'],\n }),\n 'dry-run': Flags.boolean({\n default: false,\n description: 'Report what would be deployed without uploading or creating anything',\n }),\n external: Flags.boolean({\n default: false,\n description: 'Register an externally hosted studio',\n exclusive: ['source-maps', 'minify'],\n }),\n json: Flags.boolean({\n char: 'j',\n default: false,\n description: 'Output the result as JSON',\n }),\n 'media-library-id': Flags.string({\n description:\n 'For a Media Library config deploy: the media library to sync the aspect definitions to. Defaults to the single active library of the configured organization; required when the organization has several',\n // Part of the beta config-app flow, like the hidden media commands it\n // pairs with. A help-listed flag is hard to take back — unhide at GA.\n hidden: true,\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Minify built JavaScript (use --no-minify to skip for faster builds)',\n }),\n 'schema-required': Flags.boolean({\n default: false,\n description: 'Fail if schema deployment fails',\n }),\n 'source-maps': Flags.boolean({\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n title: Flags.string({\n description:\n 'Title for a newly created application or studio. For apps, use --create to select creation when the organization already has apps',\n }),\n url: Flags.string({\n description:\n 'Studio URL for deployment. For external deploys, the full URL. For hosted studios, the hostname (e.g. \"my-studio\" or \"my-studio.sanity.studio\")',\n }),\n verbose: Flags.boolean({\n default: false,\n description: 'Enable verbose logging',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n static telemetry = defineCommandTelemetry(this.flags, {redact: ['title', 'url']})\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(DeployCommand)\n\n const cliConfig = await this.getCliConfig()\n const projectRoot = await this.getProjectRoot()\n\n const isApp = determineIsApp(cliConfig)\n\n // `--media-library-id` only steers the aspect-document sync of a Media\n // Library config deploy (see deployApp); studio and app deploys never read\n // it. Warned rather than silently dropped (same courtesy init gives\n // --dashboard on the media template).\n if (flags['media-library-id'] && !resolveWorkbenchConfig(cliConfig)) {\n this.output.warn(\n '--media-library-id is ignored — it only applies when deploying a Media Library config',\n )\n }\n\n if (flags.create) {\n if (!isApp) {\n return this.output.error(\n '--create is only supported for App SDK apps. For a studio, use --url <hostname>.',\n )\n }\n if (getAppId(cliConfig)) {\n return this.output.error(\n '--create cannot be used with a configured app ID. Omit --create to deploy to that app, or remove deployment.appId and app.id to create a new one.',\n )\n }\n if (getWorkbench(cliConfig) || resolveWorkbenchConfig(cliConfig)) {\n return this.output.error(\n '--create is not supported for this app configuration. Omit --create and run sanity deploy.',\n )\n }\n }\n\n const defaultOutputDir = path.resolve(path.join(projectRoot.directory, 'dist'))\n const sourceDir = path.resolve(process.cwd(), this.args.sourceDir || defaultOutputDir)\n\n // Skip the directory check if the studio is externally hosted\n if (this.args.sourceDir && this.args.sourceDir !== 'dist' && !flags.external) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n if (!this.isUnattended() && !flags['dry-run']) {\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await confirm({\n default: false,\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n }))\n\n if (!shouldProceed) {\n this.output.error('Cancelled.', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n // Keep --json's stdout clean for the payload\n if (!flags.json) this.output.log(`Building to ${relativeOutput}\\n`)\n }\n\n // Force yes downstream: build/app resolution otherwise prompts for prerelease/version choices\n const deployFlags = this.isUnattended() || flags['dry-run'] ? {...flags, yes: true} : flags\n\n if (isApp) {\n deployDebug('Deploying app')\n await deployApp({\n cliConfig,\n flags: deployFlags,\n output: this.output,\n projectRoot,\n sourceDir,\n })\n } else {\n deployDebug('Deploying studio')\n await deployStudio({\n cliConfig,\n flags: deployFlags,\n output: this.output,\n projectRoot,\n sourceDir,\n })\n }\n }\n}\n"],"names":["path","Args","Flags","exitCodes","SanityCommand","confirm","getWorkbench","resolveWorkbenchConfig","deployApp","deployDebug","deployStudio","getAppId","determineIsApp","dirIsEmptyOrNonExistent","defineCommandTelemetry","DeployCommand","args","sourceDir","directory","description","enableJsonFlag","examples","command","flags","boolean","allowNo","deprecated","build","default","create","exclusive","external","json","char","string","hidden","minify","title","url","verbose","yes","telemetry","redact","run","parse","cliConfig","getCliConfig","projectRoot","getProjectRoot","isApp","output","warn","error","defaultOutputDir","resolve","join","process","cwd","relativeOutput","relative","isUnattended","isEmpty","shouldProceed","message","exit","RUNTIME_ERROR","log","deployFlags"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,YAAY,EAAEC,sBAAsB,QAAO,+BAA8B;AAEjF,SAAQC,SAAS,QAAO,iCAAgC;AACxD,SAAQC,WAAW,QAAO,mCAAkC;AAC5D,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,cAAc,QAAO,4BAA2B;AACxD,SAAQC,uBAAuB,QAAO,qCAAoC;AAC1E,SAAQC,sBAAsB,QAAO,wCAAuC;AAE5E,OAAO,MAAMC,sBAAsBX;IACjC,OAAgBY,OAAO;QACrBC,WAAWhB,KAAKiB,SAAS,CAAC;YACxBC,aAAa;QACf;IACF,EAAC;IAED,OAAgBA,cAAc,oEAAmE;IAEjG,OAAgBC,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aACE;QACJ;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aACE;QACJ;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;KACD,CAAA;I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BAC9C,MAAM6C,gBACJD,WACC,MAAMxD,QAAQ;oBACbuB,SAAS;oBACTmC,SAAS,CAAC,CAAC,EAAEL,eAAe,uCAAuC,CAAC;gBACtE;gBAEF,IAAI,CAACI,eAAe;oBAClB,IAAI,CAACZ,MAAM,CAACE,KAAK,CAAC,cAAc;wBAACY,MAAM7D,UAAU8D,aAAa;oBAAA;gBAChE;YACF;YAEA,6CAA6C;YAC7C,IAAI,CAAC1C,MAAMS,IAAI,EAAE,IAAI,CAACkB,MAAM,CAACgB,GAAG,CAAC,CAAC,YAAY,EAAER,eAAe,EAAE,CAAC;QACpE;QAEA,8FAA8F;QAC9F,MAAMS,cAAc,IAAI,CAACP,YAAY,MAAMrC,KAAK,CAAC,UAAU,GAAG;YAAC,GAAGA,KAAK;YAAEiB,KAAK;QAAI,IAAIjB;QAEtF,IAAI0B,OAAO;YACTxC,YAAY;YACZ,MAAMD,UAAU;gBACdqC;gBACAtB,OAAO4C;gBACPjB,QAAQ,IAAI,CAACA,MAAM;gBACnBH;gBACA9B;YACF;QACF,OAAO;YACLR,YAAY;YACZ,MAAMC,aAAa;gBACjBmC;gBACAtB,OAAO4C;gBACPjB,QAAQ,IAAI,CAACA,MAAM;gBACnBH;gBACA9B;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/commands/deploy.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {Args, Flags} from '@oclif/core'\nimport {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\nimport {getWorkbench, resolveWorkbenchConfig} from '@sanity/workbench-cli/deploy'\n\nimport {deployApp} from '../actions/deploy/deployApp.js'\nimport {deployDashboardConfig} from '../actions/deploy/deployDashboardConfig.js'\nimport {deployDebug} from '../actions/deploy/deployDebug.js'\nimport {deployStudio} from '../actions/deploy/deployStudio.js'\nimport {getAppId} from '../util/appId.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\nimport {dirIsEmptyOrNonExistent} from '../util/dirIsEmptyOrNonExistent.js'\nimport {defineCommandTelemetry} from '../util/telemetry/commandTelemetry.js'\n\nexport class DeployCommand extends SanityCommand<typeof DeployCommand> {\n static override args = {\n sourceDir: Args.directory({\n description: 'Source directory',\n }),\n }\n\n static override description = 'Builds and deploys Sanity Studio or application to Sanity hosting'\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Build and deploy the studio to Sanity hosting',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n description: 'Deploys non-minified build with source maps',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --schema-required',\n description:\n 'Fail fast on schema store fails - for when other services rely on the stored schema',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --external',\n description: 'Register an externally hosted studio (studioHost contains full URL)',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --external --url https://apps.example.com',\n description: 'Register an externally hosted studio, served from the provided origin',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --create --title \"My App\" --yes --json',\n description:\n 'Create and deploy an App SDK app without prompts. Save application.id as deployment.appId, then omit --create on later deploys',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --create --title \"My App\" --dry-run --json',\n description: 'Preview a new App SDK deployment without creating or uploading anything',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --url my-studio --yes',\n description: 'Deploy a studio without prompts using its hostname',\n },\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n deprecated: true,\n description: 'Automatically update the studio to the latest version',\n }),\n build: Flags.boolean({\n allowNo: true,\n default: true,\n description:\n 'Build the studio before deploying (use --no-build to deploy existing `dist/` output)',\n }),\n create: Flags.boolean({\n description: 'Create a new App SDK app, even if the organization has other apps',\n exclusive: ['external', 'url'],\n }),\n 'dry-run': Flags.boolean({\n default: false,\n description: 'Report what would be deployed without uploading or creating anything',\n }),\n external: Flags.boolean({\n default: false,\n description: 'Register an externally hosted studio',\n exclusive: ['source-maps', 'minify'],\n }),\n json: Flags.boolean({\n char: 'j',\n default: false,\n description: 'Output the result as JSON',\n }),\n 'media-library-id': Flags.string({\n description:\n 'For a Media Library config deploy: the media library to sync the aspect definitions to. Defaults to the single active library of the configured organization; required when the organization has several',\n // Part of the beta config-app flow, like the hidden media commands it\n // pairs with. A help-listed flag is hard to take back — unhide at GA.\n hidden: true,\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Minify built JavaScript (use --no-minify to skip for faster builds)',\n }),\n 'schema-required': Flags.boolean({\n default: false,\n description: 'Fail if schema deployment fails',\n }),\n 'source-maps': Flags.boolean({\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n title: Flags.string({\n description:\n 'Title for a newly created application or studio. For apps, use --create to select creation when the organization already has apps',\n }),\n url: Flags.string({\n description:\n 'Studio URL for deployment. For external deploys, the full URL. For hosted studios, the hostname (e.g. \"my-studio\" or \"my-studio.sanity.studio\")',\n }),\n verbose: Flags.boolean({\n default: false,\n description: 'Enable verbose logging',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n static telemetry = defineCommandTelemetry(this.flags, {redact: ['title', 'url']})\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(DeployCommand)\n\n const cliConfig = await this.getCliConfig()\n const projectRoot = await this.getProjectRoot()\n\n const isApp = determineIsApp(cliConfig)\n const config = resolveWorkbenchConfig(cliConfig)\n\n // `--media-library-id` only steers the aspect-document sync of a Media\n // Library config deploy (see deployApp); studio and app deploys never read\n // it. Warned rather than silently dropped (same courtesy init gives\n // --dashboard on the media template).\n if (flags['media-library-id'] && config?.appType !== 'media-library') {\n this.output.warn(\n '--media-library-id is ignored — it only applies when deploying a Media Library config',\n )\n }\n\n if (flags.create) {\n if (!isApp) {\n return this.output.error(\n '--create is only supported for App SDK apps. For a studio, use --url <hostname>.',\n )\n }\n if (getAppId(cliConfig)) {\n return this.output.error(\n '--create cannot be used with a configured app ID. Omit --create to deploy to that app, or remove deployment.appId and app.id to create a new one.',\n )\n }\n if (getWorkbench(cliConfig) || config) {\n return this.output.error(\n '--create is not supported for this app configuration. Omit --create and run sanity deploy.',\n )\n }\n }\n\n const defaultOutputDir = path.resolve(path.join(projectRoot.directory, 'dist'))\n const sourceDir = path.resolve(process.cwd(), this.args.sourceDir || defaultOutputDir)\n\n // Skip the directory check if the studio is externally hosted\n if (this.args.sourceDir && this.args.sourceDir !== 'dist' && !flags.external) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n if (!this.isUnattended() && !flags['dry-run']) {\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await confirm({\n default: false,\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n }))\n\n if (!shouldProceed) {\n this.output.error('Cancelled.', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n // Keep --json's stdout clean for the payload\n if (!flags.json) this.output.log(`Building to ${relativeOutput}\\n`)\n }\n\n // Force yes downstream: build/app resolution otherwise prompts for prerelease/version choices\n const deployFlags = this.isUnattended() || flags['dry-run'] ? {...flags, yes: true} : flags\n\n if (config?.appType === 'dashboard') {\n deployDebug('Deploying dashboard configuration')\n await deployDashboardConfig({\n cliConfig,\n config,\n flags: deployFlags,\n output: this.output,\n projectRoot,\n sourceDir,\n })\n } else if (isApp) {\n deployDebug('Deploying app')\n await deployApp({\n cliConfig,\n flags: deployFlags,\n output: this.output,\n projectRoot,\n sourceDir,\n })\n } else {\n deployDebug('Deploying studio')\n await deployStudio({\n cliConfig,\n flags: deployFlags,\n output: this.output,\n projectRoot,\n sourceDir,\n })\n }\n }\n}\n"],"names":["path","Args","Flags","exitCodes","SanityCommand","confirm","getWorkbench","resolveWorkbenchConfig","deployApp","deployDashboardConfig","deployDebug","deployStudio","getAppId","determineIsApp","dirIsEmptyOrNonExistent","defineCommandTelemetry","DeployCommand","args","sourceDir","directory","description","enableJsonFlag","examples","command","flags","boolean","allowNo","deprecated","build","default","create","exclusive","external","json","char","string","hidden","minify","title","url","verbose","yes","telemetry","redact","run","parse","cliConfig","getCliConfig","projectRoot","getProjectRoot","isApp","config","appType","output","warn","error","defaultOutputDir","resolve","join","process","cwd","relativeOutput","relative","isUnattended","isEmpty","shouldProceed","message","exit","RUNTIME_ERROR","log","deployFlags"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,YAAY,EAAEC,sBAAsB,QAAO,+BAA8B;AAEjF,SAAQC,SAAS,QAAO,iCAAgC;AACxD,SAAQC,qBAAqB,QAAO,6CAA4C;AAChF,SAAQC,WAAW,QAAO,mCAAkC;AAC5D,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,cAAc,QAAO,4BAA2B;AACxD,SAAQC,uBAAuB,QAAO,qCAAoC;AAC1E,SAAQC,sBAAsB,QAAO,wCAAuC;AAE5E,OAAO,MAAMC,sBAAsBZ;IACjC,OAAgBa,OAAO;QACrBC,WAAWjB,KAAKkB,SAAS,CAAC;YACxBC,aAAa;QACf;IACF,EAAC;IAED,OAAgBA,cAAc,oEAAmE;IAEjG,OAAgBC,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aACE;QACJ;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aACE;QACJ;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS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C,UAAU,EAAE;gBAC7C,MAAMwC,UAAU,MAAMlD,wBAAwBI;gBAC9C,MAAM+C,gBACJD,WACC,MAAM3D,QAAQ;oBACbwB,SAAS;oBACTqC,SAAS,CAAC,CAAC,EAAEL,eAAe,uCAAuC,CAAC;gBACtE;gBAEF,IAAI,CAACI,eAAe;oBAClB,IAAI,CAACZ,MAAM,CAACE,KAAK,CAAC,cAAc;wBAACY,MAAMhE,UAAUiE,aAAa;oBAAA;gBAChE;YACF;YAEA,6CAA6C;YAC7C,IAAI,CAAC5C,MAAMS,IAAI,EAAE,IAAI,CAACoB,MAAM,CAACgB,GAAG,CAAC,CAAC,YAAY,EAAER,eAAe,EAAE,CAAC;QACpE;QAEA,8FAA8F;QAC9F,MAAMS,cAAc,IAAI,CAACP,YAAY,MAAMvC,KAAK,CAAC,UAAU,GAAG;YAAC,GAAGA,KAAK;YAAEiB,KAAK;QAAI,IAAIjB;QAEtF,IAAI2B,QAAQC,YAAY,aAAa;YACnC1C,YAAY;YACZ,MAAMD,sBAAsB;gBAC1BqC;gBACAK;gBACA3B,OAAO8C;gBACPjB,QAAQ,IAAI,CAACA,MAAM;gBACnBL;gBACA9B;YACF;QACF,OAAO,IAAIgC,OAAO;YAChBxC,YAAY;YACZ,MAAMF,UAAU;gBACdsC;gBACAtB,OAAO8C;gBACPjB,QAAQ,IAAI,CAACA,MAAM;gBACnBL;gBACA9B;YACF;QACF,OAAO;YACLR,YAAY;YACZ,MAAMC,aAAa;gBACjBmC;gBACAtB,OAAO8C;gBACPjB,QAAQ,IAAI,CAACA,MAAM;gBACnBL;gBACA9B;YACF;QACF;IACF;AACF"}
@@ -249,6 +249,16 @@ export class InitCommand extends SanityCommand {
249
249
  'private'
250
250
  ]
251
251
  }),
252
+ 'with-blueprints': Flags.boolean({
253
+ description: 'Set up a Blueprint workspace',
254
+ exclusive: [
255
+ 'bare',
256
+ 'dashboard',
257
+ 'env',
258
+ 'template'
259
+ ],
260
+ hidden: true
261
+ }),
252
262
  yes: Flags.boolean({
253
263
  char: 'y',
254
264
  default: false,