@sanity/cli 7.5.0 β†’ 7.6.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 (63) hide show
  1. package/dist/actions/build/buildApp.js +7 -183
  2. package/dist/actions/build/buildApp.js.map +1 -1
  3. package/dist/actions/build/buildStudio.js +6 -213
  4. package/dist/actions/build/buildStudio.js.map +1 -1
  5. package/dist/actions/build/shouldAutoUpdate.js +100 -22
  6. package/dist/actions/build/shouldAutoUpdate.js.map +1 -1
  7. package/dist/actions/deploy/{createStudioUserApplication.js β†’ createUserApplication.js} +56 -5
  8. package/dist/actions/deploy/createUserApplication.js.map +1 -0
  9. package/dist/actions/deploy/deployApp.js +232 -185
  10. package/dist/actions/deploy/deployApp.js.map +1 -1
  11. package/dist/actions/deploy/deployChecks.js +263 -0
  12. package/dist/actions/deploy/deployChecks.js.map +1 -0
  13. package/dist/actions/deploy/deployRunner.js +57 -0
  14. package/dist/actions/deploy/deployRunner.js.map +1 -0
  15. package/dist/actions/deploy/deployStudio.js +189 -198
  16. package/dist/actions/deploy/deployStudio.js.map +1 -1
  17. package/dist/actions/deploy/deploymentPlan.js +89 -0
  18. package/dist/actions/deploy/deploymentPlan.js.map +1 -0
  19. package/dist/actions/deploy/findUserApplication.js +209 -0
  20. package/dist/actions/deploy/findUserApplication.js.map +1 -0
  21. package/dist/actions/deploy/resolveDeployTarget.js +185 -0
  22. package/dist/actions/deploy/resolveDeployTarget.js.map +1 -0
  23. package/dist/actions/dev/devAction.js +1 -1
  24. package/dist/actions/dev/devAction.js.map +1 -1
  25. package/dist/actions/dev/servers/getDevServerConfig.js +18 -6
  26. package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
  27. package/dist/actions/dev/servers/startAppDevServer.js +1 -1
  28. package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
  29. package/dist/actions/dev/servers/startStudioDevServer.js +2 -1
  30. package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
  31. package/dist/actions/manifest/extractCoreAppManifest.js +14 -0
  32. package/dist/actions/manifest/extractCoreAppManifest.js.map +1 -1
  33. package/dist/commands/deploy.js +27 -11
  34. package/dist/commands/deploy.js.map +1 -1
  35. package/dist/commands/dev.js +2 -1
  36. package/dist/commands/dev.js.map +1 -1
  37. package/dist/commands/init.js +2 -1
  38. package/dist/commands/init.js.map +1 -1
  39. package/dist/exports/index.d.ts +9 -0
  40. package/dist/exports/index.js +1 -8
  41. package/dist/exports/index.js.map +1 -1
  42. package/dist/server/devServer.js +27 -3
  43. package/dist/server/devServer.js.map +1 -1
  44. package/dist/util/appId.js +13 -5
  45. package/dist/util/appId.js.map +1 -1
  46. package/dist/util/compareDependencyVersions.js.map +1 -1
  47. package/dist/util/determineIsApp.js +1 -1
  48. package/dist/util/determineIsApp.js.map +1 -1
  49. package/dist/util/errorMessages.js +2 -0
  50. package/dist/util/errorMessages.js.map +1 -1
  51. package/oclif.manifest.json +14 -1
  52. package/package.json +8 -8
  53. package/dist/actions/build/handlePrereleaseVersions.js +0 -44
  54. package/dist/actions/build/handlePrereleaseVersions.js.map +0 -1
  55. package/dist/actions/deploy/createStudioUserApplication.js.map +0 -1
  56. package/dist/actions/deploy/createUserApplicationForApp.js +0 -56
  57. package/dist/actions/deploy/createUserApplicationForApp.js.map +0 -1
  58. package/dist/actions/deploy/findUserApplicationForApp.js +0 -111
  59. package/dist/actions/deploy/findUserApplicationForApp.js.map +0 -1
  60. package/dist/actions/deploy/findUserApplicationForStudio.js +0 -172
  61. package/dist/actions/deploy/findUserApplicationForStudio.js.map +0 -1
  62. package/dist/actions/deploy/viewDeployment.js +0 -32
  63. package/dist/actions/deploy/viewDeployment.js.map +0 -1
@@ -1,86 +1,97 @@
1
1
  import { basename, dirname } from 'node:path';
2
2
  import { styleText } from 'node:util';
3
3
  import { createGzip } from 'node:zlib';
4
- import { CLIError } from '@oclif/core/errors';
5
- import { exitCodes, getLocalPackageVersion } from '@sanity/cli-core';
4
+ import { exitCodes } from '@sanity/cli-core';
6
5
  import { spinner } from '@sanity/cli-core/ux';
7
- import { getWorkbench } from '@sanity/workbench-cli/deploy';
6
+ import { deployInstallationConfig, getWorkbench, resolveInstallationId, summarizeInstallationConfig } from '@sanity/workbench-cli/deploy';
8
7
  import { pack } from 'tar-fs';
9
8
  import { createDeployment, updateUserApplication } from '../../services/userApplications.js';
10
9
  import { getAppId } from '../../util/appId.js';
11
- import { NO_ORGANIZATION_ID } from '../../util/errorMessages.js';
10
+ import { EXTERNAL_APP_NOT_SUPPORTED, NO_ORGANIZATION_ID } from '../../util/errorMessages.js';
12
11
  import { getErrorMessage } from '../../util/getErrorMessage.js';
13
12
  import { buildApp } from '../build/buildApp.js';
14
- import { shouldAutoUpdate } from '../build/shouldAutoUpdate.js';
15
- import { extractCoreAppManifest } from '../manifest/extractCoreAppManifest.js';
16
- import { checkDir } from './checkDir.js';
17
- import { createUserApplicationForApp } from './createUserApplicationForApp.js';
13
+ import { extractCoreAppManifest, resolveTitleUpdate } from '../manifest/extractCoreAppManifest.js';
14
+ import { createUserApplication } from './createUserApplication.js';
15
+ import { checkAppId, checkAppTarget, checkAutoUpdates, checkBuild, checkPackageVersion, verifyOutputDir } from './deployChecks.js';
18
16
  import { deployDebug } from './deployDebug.js';
19
- import { findUserApplicationForApp } from './findUserApplicationForApp.js';
20
- import { buildViewDeploymentPayload } from './viewDeployment.js';
21
- /**
22
- * Deploy a Sanity application.
23
- *
24
- * @internal
25
- */ export async function deployApp(options) {
26
- const { cliConfig, flags, output, projectRoot, sourceDir } = options;
27
- const workbench = getWorkbench(cliConfig);
28
- const workDir = projectRoot.directory;
29
- const organizationId = cliConfig.app?.organizationId;
30
- const appId = getAppId(cliConfig);
31
- const isAutoUpdating = shouldAutoUpdate({
32
- cliConfig,
33
- flags,
34
- output
17
+ import { listDeploymentFiles } from './deploymentPlan.js';
18
+ import { runDeploy } from './deployRunner.js';
19
+ import { findUserApplication } from './findUserApplication.js';
20
+ export function deployApp(options) {
21
+ return runDeploy(options, {
22
+ listFiles: ({ projectRoot, sourceDir })=>listDeploymentFiles(sourceDir, projectRoot.directory),
23
+ run: runAppDeployment,
24
+ type: 'coreApp'
35
25
  });
36
- const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir);
37
- if (!installedSdkVersion) {
38
- output.error(`Failed to find installed @sanity/sdk-react version`, {
39
- exit: 1
40
- });
41
- return;
42
- }
43
- if (!organizationId) {
44
- output.error(NO_ORGANIZATION_ID, {
45
- exit: 1
46
- });
47
- return;
48
- }
49
- if (flags.external) {
50
- output.error('Deploying an app to an external host is not supported.', {
51
- exit: 1
52
- });
53
- }
54
- // Fail before any prompts or API calls when the app declares nothing to
55
- // expose.
26
+ }
27
+ /** Validates the deploy, syncs the title from the manifest, and ships the build. */ async function runAppDeployment(options, reporter) {
28
+ const { cliConfig, flags, output, sourceDir } = options;
29
+ const workDir = options.projectRoot.directory;
30
+ const organizationId = cliConfig.app?.organizationId;
31
+ const workbench = getWorkbench(cliConfig);
32
+ const dryRun = !!flags['dry-run'];
33
+ // A singleton (the Media Library) persists its config instead of hosting an
34
+ // application; anything with interfaces still ships one.
35
+ const deploySingletonInstallationConfig = workbench?.deploySingletonInstallationConfig ?? false;
36
+ const deployApplication = !workbench || workbench.hasInterfaces;
37
+ // A federated app with no entry, view or service would ship a remote with
38
+ // nothing to load β€” reported first so it fails before any prompt or API call.
56
39
  if (workbench) {
57
40
  try {
58
41
  workbench.assertDeployable();
59
42
  } catch (err) {
60
- output.error(getErrorMessage(err), {
61
- exit: exitCodes.USAGE_ERROR
43
+ reporter.report({
44
+ exitCode: exitCodes.USAGE_ERROR,
45
+ message: getErrorMessage(err),
46
+ solution: 'Declare at least one entry, view, or service in the app',
47
+ status: 'fail'
62
48
  });
63
- return;
64
49
  }
65
50
  }
66
- let spin = spinner('Verifying local content...');
67
- try {
68
- let userApplication = await findUserApplicationForApp({
69
- cliConfig,
70
- organizationId,
71
- output
51
+ const isAutoUpdating = checkAutoUpdates(reporter, {
52
+ cliConfig,
53
+ flags
54
+ });
55
+ // An application ships the SDK runtime; a media-library config stamps its
56
+ // `sanity` version instead.
57
+ let version = null;
58
+ if (deployApplication) {
59
+ version = await checkPackageVersion(reporter, {
60
+ moduleName: '@sanity/sdk-react',
61
+ workDir
72
62
  });
73
- deployDebug(`User application found`, userApplication);
74
- if (!userApplication) {
75
- deployDebug(`No user application found. Creating a new one`);
76
- userApplication = await createUserApplicationForApp(organizationId);
77
- deployDebug(`User application created`, userApplication);
78
- }
79
- // Always build the project, unless --no-build is passed
80
- const shouldBuild = flags.build;
81
- if (shouldBuild) {
82
- deployDebug(`Building app`);
83
- await buildApp({
63
+ } else if (deploySingletonInstallationConfig) {
64
+ version = await checkPackageVersion(reporter, {
65
+ moduleName: 'sanity',
66
+ workDir
67
+ });
68
+ }
69
+ reporter.report(organizationId ? {
70
+ message: `Organization: ${organizationId}`,
71
+ status: 'pass'
72
+ } : {
73
+ message: NO_ORGANIZATION_ID,
74
+ solution: 'Add `app.organizationId` to sanity.cli.ts',
75
+ status: 'fail'
76
+ });
77
+ checkAppId(reporter, {
78
+ cliConfig
79
+ });
80
+ let application = null;
81
+ if (flags.external) {
82
+ reporter.report({
83
+ message: EXTERNAL_APP_NOT_SUPPORTED,
84
+ solution: 'Remove the --external flag β€” apps deploy to Sanity hosting',
85
+ status: 'fail'
86
+ });
87
+ } else if (deployApplication) {
88
+ application = await resolveAppApplication(options, {
89
+ dryRun,
90
+ reporter
91
+ });
92
+ }
93
+ await checkBuild(reporter, {
94
+ build: ()=>buildApp({
84
95
  autoUpdatesEnabled: isAutoUpdating,
85
96
  calledFromDeploy: true,
86
97
  cliConfig,
@@ -88,139 +99,175 @@ import { buildViewDeploymentPayload } from './viewDeployment.js';
88
99
  outDir: sourceDir,
89
100
  output,
90
101
  workDir
91
- });
92
- }
93
- // Ensure that the directory exists, is a directory and seems to have valid content
94
- spin = spin.start();
95
- try {
96
- await (workbench ? workbench.checkBuiltOutput(sourceDir) : checkDir(sourceDir));
97
- spin.succeed();
98
- } catch (err) {
99
- spin.fail();
100
- deployDebug('Error checking directory', err);
101
- output.error(getErrorMessage(err), {
102
- exit: 1
103
- });
104
- return;
105
- }
106
- // Create a tarball of the given directory
107
- const parentDir = dirname(sourceDir);
108
- const base = basename(sourceDir);
109
- const tarball = pack(parentDir, {
110
- entries: [
111
- base
112
- ]
113
- }).pipe(createGzip());
114
- let manifest;
115
- try {
116
- manifest = await extractCoreAppManifest({
117
- workDir
118
- });
119
- } catch (err) {
120
- deployDebug('Error extracting app manifest', err);
121
- const message = getErrorMessage(err);
122
- // manifests aren't strictly essential, so continue deploy
123
- output.warn(`Error extracting app manifest: ${message}`);
124
- }
125
- // Sync app title from manifest when it has changed (Brett user-applications)
126
- if (manifest?.title !== undefined && manifest.title !== userApplication.title) {
127
- deployDebug('Updating application title from manifest', {
128
- from: userApplication.title,
129
- to: manifest.title
130
- });
131
- const existing = userApplication.title;
132
- output.log(existing ? `Updating title from "${existing}" to "${manifest.title}"` : `Setting application title to "${manifest.title}"`);
133
- spin = spinner(`Updating application title`).start();
134
- try {
135
- userApplication = await updateUserApplication({
136
- applicationId: userApplication.id,
137
- appType: 'coreApp',
138
- body: {
139
- title: manifest.title
140
- }
141
- });
142
- spin.succeed();
143
- } catch (err) {
144
- spin.fail();
145
- const message = getErrorMessage(err);
146
- deployDebug('Error updating application title', {
147
- message
148
- });
149
- output.warn(`Error updating application title: ${message}`);
150
- }
151
- }
152
- // Register the app's declared views with the application service. That
153
- // service doesn't exist yet, so validate the payload and log it (no store);
154
- // a malformed view declaration fails the deploy before we ship the bundle.
155
- // `views` lives on the branded `unstable_defineApp` result, not the legacy
156
- // `app` config object.
157
- const declaredViews = workbench?.views ?? [];
158
- if (declaredViews.length > 0) {
159
- try {
160
- const payload = buildViewDeploymentPayload({
161
- applicationId: userApplication.id,
162
- views: declaredViews
163
- });
164
- output.log(`Validated ${payload.views.length} view(s) for the application service (not yet persisted):`);
165
- output.log(JSON.stringify(payload, null, 2));
166
- deployDebug('View deployment payload', payload);
167
- } catch (err) {
168
- const message = getErrorMessage(err);
169
- output.error(`Invalid view declaration: ${message}`, {
170
- exit: 1
171
- });
172
- return;
102
+ }),
103
+ skipReason: flags.build ? undefined : 'Build skipped (--no-build) β€” validating existing output directory',
104
+ successMessage: 'App built'
105
+ });
106
+ await verifyOutputDir({
107
+ isWorkbenchApp: workbench !== null,
108
+ reporter,
109
+ sourceDir
110
+ });
111
+ // Manifests aren't strictly essential, so a failure warns and continues
112
+ let manifest;
113
+ try {
114
+ manifest = await extractCoreAppManifest({
115
+ workDir
116
+ });
117
+ } catch (err) {
118
+ deployDebug('Error extracting app manifest', err);
119
+ reporter.report({
120
+ message: `Error extracting app manifest: ${getErrorMessage(err)}`,
121
+ status: 'warn'
122
+ });
123
+ }
124
+ // Resolve the installation in both modes so the report β€” dry-run and real β€”
125
+ // shows whether the config is deployable; a missing one fails the deploy here.
126
+ let installationId;
127
+ const configAppType = workbench?.installationConfig?.appType;
128
+ if (deploySingletonInstallationConfig && organizationId && workbench?.installationConfig && configAppType) {
129
+ installationId = await resolveInstallationId({
130
+ appType: configAppType,
131
+ organizationId
132
+ });
133
+ reporter.report(installationId ? {
134
+ message: summarizeInstallationConfig(workbench.installationConfig),
135
+ status: 'pass'
136
+ } : {
137
+ exitCode: exitCodes.USAGE_ERROR,
138
+ message: `No active "${configAppType}" installation for organization "${organizationId}"`,
139
+ solution: 'Install the Media Library for the organization before deploying its config',
140
+ status: 'fail'
141
+ });
142
+ }
143
+ // Dry run stops here β€” everything below mutates.
144
+ if (dryRun) return;
145
+ if (installationId && version && configAppType) {
146
+ await deployInstallationConfig({
147
+ appType: configAppType,
148
+ installationId,
149
+ output,
150
+ sourceDir,
151
+ version
152
+ });
153
+ }
154
+ // A config-only singleton has no application to ship.
155
+ if (!deployApplication) return;
156
+ // A real deploy has already exited if anything failed; landing here without a
157
+ // resolved application or version means the deploy target was never resolved.
158
+ if (!application || !version) return;
159
+ application = await syncApplicationTitle({
160
+ application,
161
+ manifest,
162
+ output
163
+ });
164
+ await shipAppDeployment({
165
+ application,
166
+ isAutoUpdating,
167
+ manifest,
168
+ sourceDir,
169
+ version
170
+ });
171
+ logAppDeployed({
172
+ application,
173
+ cliConfig,
174
+ output
175
+ });
176
+ }
177
+ /**
178
+ * Finds the application a real deploy targets, creating one when none is
179
+ * configured. A dry run resolves and reports the target read-only instead.
180
+ */ async function resolveAppApplication(options, { dryRun, reporter }) {
181
+ const { cliConfig, flags, output } = options;
182
+ const organizationId = cliConfig.app?.organizationId ?? '';
183
+ // Create name from --title or `app.title` config; blank falls back to the prompt
184
+ const title = flags.title?.trim() || cliConfig.app?.title?.trim() || undefined;
185
+ if (dryRun) {
186
+ await checkAppTarget(reporter, {
187
+ appId: getAppId(cliConfig),
188
+ organizationId,
189
+ title
190
+ });
191
+ return null;
192
+ }
193
+ let application = await findUserApplication({
194
+ cliConfig,
195
+ organizationId,
196
+ output,
197
+ title,
198
+ unattended: !!flags.yes
199
+ });
200
+ deployDebug('User application found', application);
201
+ if (!application) {
202
+ deployDebug('No user application found. Creating a new one');
203
+ application = await createUserApplication(organizationId, title);
204
+ deployDebug('User application created', application);
205
+ }
206
+ return application;
207
+ }
208
+ /** Syncs the application title from the manifest when it has changed. */ async function syncApplicationTitle({ application, manifest, output }) {
209
+ const titleUpdate = resolveTitleUpdate(manifest, application);
210
+ if (!titleUpdate) return application;
211
+ deployDebug('Updating application title from manifest', titleUpdate);
212
+ output.log(titleUpdate.from ? `Updating title from "${titleUpdate.from}" to "${titleUpdate.to}"` : `Setting application title to "${titleUpdate.to}"`);
213
+ const spin = spinner('Updating application title').start();
214
+ try {
215
+ const updated = await updateUserApplication({
216
+ applicationId: application.id,
217
+ appType: 'coreApp',
218
+ body: {
219
+ title: titleUpdate.to
173
220
  }
174
- }
175
- spin = spinner('Deploying...').start();
221
+ });
222
+ spin.succeed();
223
+ return updated;
224
+ } catch (err) {
225
+ spin.fail();
226
+ const message = getErrorMessage(err);
227
+ deployDebug('Error updating application title', {
228
+ message
229
+ });
230
+ output.warn(`Error updating application title: ${message}`);
231
+ return application;
232
+ }
233
+ }
234
+ async function shipAppDeployment({ application, isAutoUpdating, manifest, sourceDir, version }) {
235
+ const tarball = pack(dirname(sourceDir), {
236
+ entries: [
237
+ basename(sourceDir)
238
+ ]
239
+ }).pipe(createGzip());
240
+ const spin = spinner('Deploying...').start();
241
+ try {
176
242
  await createDeployment({
177
- applicationId: userApplication.id,
243
+ applicationId: application.id,
178
244
  isApp: true,
179
245
  isAutoUpdating,
180
246
  manifest,
181
247
  tarball,
182
- version: installedSdkVersion
248
+ version
183
249
  });
184
- spin.succeed();
185
- // And let the user know we're done
186
- output.log(`\nπŸš€ ${styleText('bold', 'Success!')} Application deployed`);
187
- if (!appId) {
188
- output.log(`\n════ ${styleText('bold', 'Next step:')} ════`);
189
- output.log(styleText('bold', '\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'));
190
- output.log(`
250
+ } catch (error) {
251
+ spin.clear();
252
+ throw error;
253
+ }
254
+ spin.succeed();
255
+ }
256
+ function logAppDeployed({ application, cliConfig, output }) {
257
+ output.log(`\nπŸš€ ${styleText('bold', 'Success!')} Application deployed`);
258
+ if (getAppId(cliConfig)) return;
259
+ output.log(`\n════ ${styleText('bold', 'Next step:')} ════`);
260
+ output.log(styleText('bold', '\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'));
261
+ output.log(`
191
262
  ${styleText('dim', `app: {
192
263
  // your application config here…
193
264
  }`)},
194
265
  ${styleText([
195
- 'bold',
196
- 'green'
197
- ], `deployment: {
198
- appId: '${userApplication.id}',
266
+ 'bold',
267
+ 'green'
268
+ ], `deployment: {
269
+ appId: '${application.id}',
199
270
  }\n`)}`);
200
- }
201
- } catch (error) {
202
- spin.clear();
203
- // Don't throw generic error if user cancels
204
- if (error.name === 'ExitPromptError') {
205
- output.error('Deployment cancelled by user', {
206
- exit: 1
207
- });
208
- return;
209
- }
210
- // If the error is a CLIError, we can just output the message & error options (if any), while ensuring we exit
211
- if (error instanceof CLIError) {
212
- const { message, ...errorOptions } = error;
213
- output.error(message, {
214
- ...errorOptions,
215
- exit: 1
216
- });
217
- return;
218
- }
219
- deployDebug('Error deploying application', error);
220
- output.error(`Error deploying application: ${error}`, {
221
- exit: 1
222
- });
223
- }
224
271
  }
225
272
 
226
273
  //# sourceMappingURL=deployApp.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, getLocalPackageVersion} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {getWorkbench} from '@sanity/workbench-cli/deploy'\nimport {pack} from 'tar-fs'\n\nimport {createDeployment, updateUserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {shouldAutoUpdate} from '../build/shouldAutoUpdate.js'\nimport {extractCoreAppManifest} from '../manifest/extractCoreAppManifest.js'\nimport {type CoreAppManifest} from '../manifest/types.js'\nimport {checkDir} from './checkDir.js'\nimport {createUserApplicationForApp} from './createUserApplicationForApp.js'\nimport {deployDebug} from './deployDebug.js'\nimport {findUserApplicationForApp} from './findUserApplicationForApp.js'\nimport {type DeployAppOptions} from './types.js'\nimport {buildViewDeploymentPayload} from './viewDeployment.js'\n\n/**\n * Deploy a Sanity application.\n *\n * @internal\n */\nexport async function deployApp(options: DeployAppOptions) {\n const {cliConfig, flags, output, projectRoot, sourceDir} = options\n const workbench = getWorkbench(cliConfig)\n\n const workDir = projectRoot.directory\n\n const organizationId = cliConfig.app?.organizationId\n const appId = getAppId(cliConfig)\n const isAutoUpdating = shouldAutoUpdate({cliConfig, flags, output})\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n if (!organizationId) {\n output.error(NO_ORGANIZATION_ID, {exit: 1})\n return\n }\n\n if (flags.external) {\n output.error('Deploying an app to an external host is not supported.', {exit: 1})\n }\n\n // Fail before any prompts or API calls when the app declares nothing to\n // expose.\n if (workbench) {\n try {\n workbench.assertDeployable()\n } catch (err) {\n output.error(getErrorMessage(err), {exit: exitCodes.USAGE_ERROR})\n return\n }\n }\n\n let spin = spinner('Verifying local content...')\n\n try {\n let userApplication = await findUserApplicationForApp({\n cliConfig,\n organizationId,\n output,\n })\n\n deployDebug(`User application found`, userApplication)\n\n if (!userApplication) {\n deployDebug(`No user application found. Creating a new one`)\n\n userApplication = await createUserApplicationForApp(organizationId)\n deployDebug(`User application created`, userApplication)\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n deployDebug(`Building app`)\n await buildApp({\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n })\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spin = spin.start()\n try {\n await (workbench ? workbench.checkBuiltOutput(sourceDir) : checkDir(sourceDir))\n spin.succeed()\n } catch (err) {\n spin.fail()\n deployDebug('Error checking directory', err)\n output.error(getErrorMessage(err), {exit: 1})\n return\n }\n\n // Create a tarball of the given directory\n const parentDir = dirname(sourceDir)\n const base = basename(sourceDir)\n const tarball = pack(parentDir, {entries: [base]}).pipe(createGzip())\n let manifest: CoreAppManifest | undefined\n try {\n manifest = await extractCoreAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n const message = getErrorMessage(err)\n // manifests aren't strictly essential, so continue deploy\n output.warn(`Error extracting app manifest: ${message}`)\n }\n\n // Sync app title from manifest when it has changed (Brett user-applications)\n if (manifest?.title !== undefined && manifest.title !== userApplication.title) {\n deployDebug('Updating application title from manifest', {\n from: userApplication.title,\n to: manifest.title,\n })\n const existing = userApplication.title\n output.log(\n existing\n ? `Updating title from \"${existing}\" to \"${manifest.title}\"`\n : `Setting application title to \"${manifest.title}\"`,\n )\n spin = spinner(`Updating application title`).start()\n try {\n userApplication = await updateUserApplication({\n applicationId: userApplication.id,\n appType: 'coreApp',\n body: {title: manifest.title},\n })\n spin.succeed()\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application title', {message})\n output.warn(`Error updating application title: ${message}`)\n }\n }\n\n // Register the app's declared views with the application service. That\n // service doesn't exist yet, so validate the payload and log it (no store);\n // a malformed view declaration fails the deploy before we ship the bundle.\n // `views` lives on the branded `unstable_defineApp` result, not the legacy\n // `app` config object.\n const declaredViews = workbench?.views ?? []\n if (declaredViews.length > 0) {\n try {\n const payload = buildViewDeploymentPayload({\n applicationId: userApplication.id,\n views: declaredViews,\n })\n output.log(\n `Validated ${payload.views.length} view(s) for the application service (not yet persisted):`,\n )\n output.log(JSON.stringify(payload, null, 2))\n deployDebug('View deployment payload', payload)\n } catch (err) {\n const message = getErrorMessage(err)\n output.error(`Invalid view declaration: ${message}`, {exit: 1})\n return\n }\n }\n\n spin = spinner('Deploying...').start()\n await createDeployment({\n applicationId: userApplication.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version: installedSdkVersion,\n })\n\n spin.succeed()\n\n // And let the user know we're done\n output.log(`\\nπŸš€ ${styleText('bold', 'Success!')} Application deployed`)\n\n if (!appId) {\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n output.log(\n styleText(\n 'bold',\n '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:',\n ),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${userApplication.id}',\n}\\n`,\n)}`)\n }\n } catch (error) {\n spin.clear()\n // Don't throw generic error if user cancels\n if (error.name === 'ExitPromptError') {\n output.error('Deployment cancelled by user', {exit: 1})\n return\n }\n // If the error is a CLIError, we can just output the message & error options (if any), while ensuring we exit\n if (error instanceof CLIError) {\n const {message, ...errorOptions} = error\n output.error(message, {...errorOptions, exit: 1})\n return\n }\n\n deployDebug('Error deploying application', error)\n output.error(`Error deploying application: ${error}`, {exit: 1})\n }\n}\n"],"names":["basename","dirname","styleText","createGzip","CLIError","exitCodes","getLocalPackageVersion","spinner","getWorkbench","pack","createDeployment","updateUserApplication","getAppId","NO_ORGANIZATION_ID","getErrorMessage","buildApp","shouldAutoUpdate","extractCoreAppManifest","checkDir","createUserApplicationForApp","deployDebug","findUserApplicationForApp","buildViewDeploymentPayload","deployApp","options","cliConfig","flags","output","projectRoot","sourceDir","workbench","workDir","directory","organizationId","app","appId","isAutoUpdating","installedSdkVersion","error","exit","external","assertDeployable","err","USAGE_ERROR","spin","userApplication","shouldBuild","build","autoUpdatesEnabled","calledFromDeploy","outDir","start","checkBuiltOutput","succeed","fail","parentDir","base","tarball","entries","pipe","manifest","message","warn","title","undefined","from","to","existing","log","applicationId","id","appType","body","declaredViews","views","length","payload","JSON","stringify","isApp","version","clear","name","errorOptions"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,EAAEC,sBAAsB,QAAO,mBAAkB;AAClE,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,YAAY,QAAO,+BAA8B;AACzD,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SAAQC,gBAAgB,EAAEC,qBAAqB,QAAO,qCAAoC;AAC1F,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,kBAAkB,QAAO,8BAA6B;AAC9D,SAAQC,eAAe,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AAOW,KAAK,CAAC,CAAC,0BAA0B,EAAEuB,SAAS,EAAE;oBAACtB,MAAM;gBAAC;gBAC7D;YACF;QACF;QAEAK,OAAOrC,QAAQ,gBAAgB4C,KAAK;QACpC,MAAMzC,iBAAiB;YACrB2D,eAAexB,gBAAgByB,EAAE;YACjCS,OAAO;YACP3C;YACAwB;YACAH;YACAuB,SAAS3C;QACX;QAEAO,KAAKS,OAAO;QAEZ,mCAAmC;QACnC1B,OAAOyC,GAAG,CAAC,CAAC,KAAK,EAAElE,UAAU,QAAQ,YAAY,qBAAqB,CAAC;QAEvE,IAAI,CAACiC,OAAO;YACVR,OAAOyC,GAAG,CAAC,CAAC,OAAO,EAAElE,UAAU,QAAQ,cAAc,KAAK,CAAC;YAC3DyB,OAAOyC,GAAG,CACRlE,UACE,QACA;YAGJyB,OAAOyC,GAAG,CAAC,CAAC;AAClB,EAAElE,UACA,OACA,CAAC;;CAEF,CAAC,EACA;AACF,EAAEA,UACA;gBAAC;gBAAQ;aAAQ,EACjB,CAAC;UACO,EAAE2C,gBAAgByB,EAAE,CAAC;GAC5B,CAAC,GACD;QACC;IACF,EAAE,OAAOhC,OAAO;QACdM,KAAKqC,KAAK;QACV,4CAA4C;QAC5C,IAAI3C,MAAM4C,IAAI,KAAK,mBAAmB;YACpCvD,OAAOW,KAAK,CAAC,gCAAgC;gBAACC,MAAM;YAAC;YACrD;QACF;QACA,8GAA8G;QAC9G,IAAID,iBAAiBlC,UAAU;YAC7B,MAAM,EAACyD,OAAO,EAAE,GAAGsB,cAAa,GAAG7C;YACnCX,OAAOW,KAAK,CAACuB,SAAS;gBAAC,GAAGsB,YAAY;gBAAE5C,MAAM;YAAC;YAC/C;QACF;QAEAnB,YAAY,+BAA+BkB;QAC3CX,OAAOW,KAAK,CAAC,CAAC,6BAA6B,EAAEA,OAAO,EAAE;YAACC,MAAM;QAAC;IAChE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/deploy/deployApp.ts"],"sourcesContent":["import {basename, dirname} from 'node:path'\nimport {styleText} from 'node:util'\nimport {createGzip} from 'node:zlib'\n\nimport {exitCodes} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {\n deployInstallationConfig,\n getWorkbench,\n resolveInstallationId,\n summarizeInstallationConfig,\n} from '@sanity/workbench-cli/deploy'\nimport {pack} from 'tar-fs'\n\nimport {\n createDeployment,\n updateUserApplication,\n type UserApplication,\n} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {EXTERNAL_APP_NOT_SUPPORTED, NO_ORGANIZATION_ID} from '../../util/errorMessages.js'\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {buildApp} from '../build/buildApp.js'\nimport {extractCoreAppManifest, resolveTitleUpdate} from '../manifest/extractCoreAppManifest.js'\nimport {type CoreAppManifest} from '../manifest/types.js'\nimport {createUserApplication} from './createUserApplication.js'\nimport {\n checkAppId,\n checkAppTarget,\n checkAutoUpdates,\n checkBuild,\n checkPackageVersion,\n type CheckReporter,\n verifyOutputDir,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {listDeploymentFiles} from './deploymentPlan.js'\nimport {runDeploy} from './deployRunner.js'\nimport {findUserApplication} from './findUserApplication.js'\nimport {type DeployAppOptions} from './types.js'\n\nexport function deployApp(options: DeployAppOptions): Promise<void> {\n return runDeploy(options, {\n listFiles: ({projectRoot, sourceDir}) => listDeploymentFiles(sourceDir, projectRoot.directory),\n run: runAppDeployment,\n type: 'coreApp',\n })\n}\n\n/** Validates the deploy, syncs the title from the manifest, and ships the build. */\nasync function runAppDeployment(options: DeployAppOptions, reporter: CheckReporter): Promise<void> {\n const {cliConfig, flags, output, sourceDir} = options\n const workDir = options.projectRoot.directory\n const organizationId = cliConfig.app?.organizationId\n const workbench = getWorkbench(cliConfig)\n const dryRun = !!flags['dry-run']\n\n // A singleton (the Media Library) persists its config instead of hosting an\n // application; anything with interfaces still ships one.\n const deploySingletonInstallationConfig = workbench?.deploySingletonInstallationConfig ?? false\n const deployApplication = !workbench || workbench.hasInterfaces\n\n // A federated app with no entry, view or service would ship a remote with\n // nothing to load β€” reported first so it fails before any prompt or API call.\n if (workbench) {\n try {\n workbench.assertDeployable()\n } catch (err) {\n reporter.report({\n exitCode: exitCodes.USAGE_ERROR,\n message: getErrorMessage(err),\n solution: 'Declare at least one entry, view, or service in the app',\n status: 'fail',\n })\n }\n }\n\n const isAutoUpdating = checkAutoUpdates(reporter, {cliConfig, flags})\n\n // An application ships the SDK runtime; a media-library config stamps its\n // `sanity` version instead.\n let version: string | null = null\n if (deployApplication) {\n version = await checkPackageVersion(reporter, {moduleName: '@sanity/sdk-react', workDir})\n } else if (deploySingletonInstallationConfig) {\n version = await checkPackageVersion(reporter, {moduleName: 'sanity', workDir})\n }\n\n reporter.report(\n organizationId\n ? {message: `Organization: ${organizationId}`, status: 'pass'}\n : {\n message: NO_ORGANIZATION_ID,\n solution: 'Add `app.organizationId` to sanity.cli.ts',\n status: 'fail',\n },\n )\n\n checkAppId(reporter, {cliConfig})\n\n let application: UserApplication | null = null\n if (flags.external) {\n reporter.report({\n message: EXTERNAL_APP_NOT_SUPPORTED,\n solution: 'Remove the --external flag β€” apps deploy to Sanity hosting',\n status: 'fail',\n })\n } else if (deployApplication) {\n application = await resolveAppApplication(options, {dryRun, reporter})\n }\n\n await checkBuild(reporter, {\n build: () =>\n buildApp({\n autoUpdatesEnabled: isAutoUpdating,\n calledFromDeploy: true,\n cliConfig,\n flags,\n outDir: sourceDir,\n output,\n workDir,\n }),\n skipReason: flags.build\n ? undefined\n : 'Build skipped (--no-build) β€” validating existing output directory',\n successMessage: 'App built',\n })\n\n await verifyOutputDir({isWorkbenchApp: workbench !== null, reporter, sourceDir})\n\n // Manifests aren't strictly essential, so a failure warns and continues\n let manifest: CoreAppManifest | undefined\n try {\n manifest = await extractCoreAppManifest({workDir})\n } catch (err) {\n deployDebug('Error extracting app manifest', err)\n reporter.report({\n message: `Error extracting app manifest: ${getErrorMessage(err)}`,\n status: 'warn',\n })\n }\n\n // Resolve the installation in both modes so the report β€” dry-run and real β€”\n // shows whether the config is deployable; a missing one fails the deploy here.\n let installationId: string | undefined\n const configAppType = workbench?.installationConfig?.appType\n if (\n deploySingletonInstallationConfig &&\n organizationId &&\n workbench?.installationConfig &&\n configAppType\n ) {\n installationId = await resolveInstallationId({appType: configAppType, organizationId})\n reporter.report(\n installationId\n ? {message: summarizeInstallationConfig(workbench.installationConfig), status: 'pass'}\n : {\n exitCode: exitCodes.USAGE_ERROR,\n message: `No active \"${configAppType}\" installation for organization \"${organizationId}\"`,\n solution: 'Install the Media Library for the organization before deploying its config',\n status: 'fail',\n },\n )\n }\n\n // Dry run stops here β€” everything below mutates.\n if (dryRun) return\n\n if (installationId && version && configAppType) {\n await deployInstallationConfig({\n appType: configAppType,\n installationId,\n output,\n sourceDir,\n version,\n })\n }\n\n // A config-only singleton has no application to ship.\n if (!deployApplication) return\n\n // A real deploy has already exited if anything failed; landing here without a\n // resolved application or version means the deploy target was never resolved.\n if (!application || !version) return\n\n application = await syncApplicationTitle({application, manifest, output})\n\n await shipAppDeployment({application, isAutoUpdating, manifest, sourceDir, version})\n\n logAppDeployed({application, cliConfig, output})\n}\n\n/**\n * Finds the application a real deploy targets, creating one when none is\n * configured. A dry run resolves and reports the target read-only instead.\n */\nasync function resolveAppApplication(\n options: DeployAppOptions,\n {dryRun, reporter}: {dryRun: boolean; reporter: CheckReporter},\n): Promise<UserApplication | null> {\n const {cliConfig, flags, output} = options\n const organizationId = cliConfig.app?.organizationId ?? ''\n // Create name from --title or `app.title` config; blank falls back to the prompt\n const title = flags.title?.trim() || cliConfig.app?.title?.trim() || undefined\n\n if (dryRun) {\n await checkAppTarget(reporter, {appId: getAppId(cliConfig), organizationId, title})\n return null\n }\n\n let application = await findUserApplication({\n cliConfig,\n organizationId,\n output,\n title,\n unattended: !!flags.yes,\n })\n deployDebug('User application found', application)\n\n if (!application) {\n deployDebug('No user application found. Creating a new one')\n application = await createUserApplication(organizationId, title)\n deployDebug('User application created', application)\n }\n\n return application\n}\n\n/** Syncs the application title from the manifest when it has changed. */\nasync function syncApplicationTitle({\n application,\n manifest,\n output,\n}: {\n application: UserApplication\n manifest: CoreAppManifest | undefined\n output: DeployAppOptions['output']\n}): Promise<UserApplication> {\n const titleUpdate = resolveTitleUpdate(manifest, application)\n if (!titleUpdate) return application\n\n deployDebug('Updating application title from manifest', titleUpdate)\n output.log(\n titleUpdate.from\n ? `Updating title from \"${titleUpdate.from}\" to \"${titleUpdate.to}\"`\n : `Setting application title to \"${titleUpdate.to}\"`,\n )\n const spin = spinner('Updating application title').start()\n try {\n const updated = await updateUserApplication({\n applicationId: application.id,\n appType: 'coreApp',\n body: {title: titleUpdate.to},\n })\n spin.succeed()\n return updated\n } catch (err) {\n spin.fail()\n const message = getErrorMessage(err)\n deployDebug('Error updating application title', {message})\n output.warn(`Error updating application title: ${message}`)\n return application\n }\n}\n\nasync function shipAppDeployment({\n application,\n isAutoUpdating,\n manifest,\n sourceDir,\n version,\n}: {\n application: UserApplication\n isAutoUpdating: boolean\n manifest: CoreAppManifest | undefined\n sourceDir: string\n version: string\n}): Promise<void> {\n const tarball = pack(dirname(sourceDir), {entries: [basename(sourceDir)]}).pipe(createGzip())\n\n const spin = spinner('Deploying...').start()\n try {\n await createDeployment({\n applicationId: application.id,\n isApp: true,\n isAutoUpdating,\n manifest,\n tarball,\n version,\n })\n } catch (error) {\n spin.clear()\n throw error\n }\n spin.succeed()\n}\n\nfunction logAppDeployed({\n application,\n cliConfig,\n output,\n}: {\n application: UserApplication\n cliConfig: DeployAppOptions['cliConfig']\n output: DeployAppOptions['output']\n}): void {\n output.log(`\\nπŸš€ ${styleText('bold', 'Success!')} Application deployed`)\n\n if (getAppId(cliConfig)) return\n\n output.log(`\\n════ ${styleText('bold', 'Next step:')} ════`)\n output.log(\n styleText('bold', '\\nAdd the deployment.appId to your sanity.cli.js or sanity.cli.ts file:'),\n )\n output.log(`\n${styleText(\n 'dim',\n `app: {\n // your application config here…\n}`,\n)},\n${styleText(\n ['bold', 'green'],\n `deployment: {\n appId: '${application.id}',\n}\\n`,\n)}`)\n}\n"],"names":["basename","dirname","styleText","createGzip","exitCodes","spinner","deployInstallationConfig","getWorkbench","resolveInstallationId","summarizeInstallationConfig","pack","createDeployment","updateUserApplication","getAppId","EXTERNAL_APP_NOT_SUPPORTED","NO_ORGANIZATION_ID","getErrorMessage","buildApp","extractCoreAppManifest","resolveTitleUpdate","createUserApplication","checkAppId","checkAppTarget","checkAutoUpdates","checkBuild","checkPackageVersion","verifyOutputDir","deployDebug","listDeploymentFiles","runDeploy","findUserApplication","deployApp","options","listFiles","projectRoot","sourceDir","directory","run","runAppDeployment","type","reporter","cliConfig","flags","output","workDir","organizationId","app","workbench","dryRun","deploySingletonInstallationConfig","deployApplication","hasInterfaces","assertDeployable","err","report","exitCode","USAGE_ERROR","message","solution","status","isAutoUpdating","version","moduleName","application","external","resolveAppApplication","build","autoUpdatesEnabled","calledFromDeploy","outDir","skipReason","undefined","successMessage","isWorkbenchApp","manifest","installationId","configAppType","installationConfig","appType","syncApplicationTitle","shipAppDeployment","logAppDeployed","title","trim","appId","unattended","yes","titleUpdate","log","from","to","spin","start","updated","applicationId","id","body","succeed","fail","warn","tarball","entries","pipe","isApp","error","clear"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAC3C,SAAQC,SAAS,QAAO,YAAW;AACnC,SAAQC,UAAU,QAAO,YAAW;AAEpC,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SACEC,wBAAwB,EACxBC,YAAY,EACZC,qBAAqB,EACrBC,2BAA2B,QACtB,+BAA8B;AACrC,SAAQC,IAAI,QAAO,SAAQ;AAE3B,SACEC,gBAAgB,EAChBC,qBAAqB,QAEhB,qCAAoC;AAC3C,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,0BAA0B,EAAEC,kBAAkB,QAAO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