@sanity/cli 7.4.2 → 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.
- package/dist/actions/build/buildApp.js +7 -183
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +6 -213
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/build/shouldAutoUpdate.js +100 -22
- package/dist/actions/build/shouldAutoUpdate.js.map +1 -1
- package/dist/actions/deploy/{createStudioUserApplication.js → createUserApplication.js} +56 -5
- package/dist/actions/deploy/createUserApplication.js.map +1 -0
- package/dist/actions/deploy/deployApp.js +232 -185
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployChecks.js +263 -0
- package/dist/actions/deploy/deployChecks.js.map +1 -0
- package/dist/actions/deploy/deployRunner.js +57 -0
- package/dist/actions/deploy/deployRunner.js.map +1 -0
- package/dist/actions/deploy/deployStudio.js +189 -198
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/deploy/deploymentPlan.js +89 -0
- package/dist/actions/deploy/deploymentPlan.js.map +1 -0
- package/dist/actions/deploy/findUserApplication.js +209 -0
- package/dist/actions/deploy/findUserApplication.js.map +1 -0
- package/dist/actions/deploy/resolveDeployTarget.js +185 -0
- package/dist/actions/deploy/resolveDeployTarget.js.map +1 -0
- package/dist/actions/dev/devAction.js +1 -1
- package/dist/actions/dev/devAction.js.map +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js +18 -6
- package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
- package/dist/actions/dev/servers/startAppDevServer.js +1 -1
- package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
- package/dist/actions/dev/servers/startStudioDevServer.js +2 -1
- package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
- package/dist/actions/manifest/extractCoreAppManifest.js +14 -0
- package/dist/actions/manifest/extractCoreAppManifest.js.map +1 -1
- package/dist/actions/mcp/editorConfigs.js +11 -5
- package/dist/actions/mcp/editorConfigs.js.map +1 -1
- package/dist/commands/deploy.js +27 -11
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.js +2 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.js +2 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/exports/index.d.ts +9 -0
- package/dist/exports/index.js +1 -8
- package/dist/exports/index.js.map +1 -1
- package/dist/server/devServer.js +27 -3
- package/dist/server/devServer.js.map +1 -1
- package/dist/util/appId.js +13 -5
- package/dist/util/appId.js.map +1 -1
- package/dist/util/compareDependencyVersions.js.map +1 -1
- package/dist/util/determineIsApp.js +1 -1
- package/dist/util/determineIsApp.js.map +1 -1
- package/dist/util/errorMessages.js +2 -0
- package/dist/util/errorMessages.js.map +1 -1
- package/oclif.manifest.json +14 -1
- package/package.json +8 -8
- package/templates/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +56 -0
- package/templates/app-quickstart/AGENTS.md +40 -0
- package/templates/app-quickstart/README.md +22 -0
- package/templates/app-quickstart/src/ExampleComponent.css +6 -0
- package/templates/app-quickstart/src/ExampleComponent.tsx +30 -9
- package/templates/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +60 -0
- package/templates/app-sanity-ui/AGENTS.md +44 -0
- package/templates/app-sanity-ui/README.md +23 -0
- package/templates/app-sanity-ui/src/ExampleComponent.tsx +8 -5
- package/dist/actions/build/handlePrereleaseVersions.js +0 -44
- package/dist/actions/build/handlePrereleaseVersions.js.map +0 -1
- package/dist/actions/deploy/createStudioUserApplication.js.map +0 -1
- package/dist/actions/deploy/createUserApplicationForApp.js +0 -56
- package/dist/actions/deploy/createUserApplicationForApp.js.map +0 -1
- package/dist/actions/deploy/findUserApplicationForApp.js +0 -111
- package/dist/actions/deploy/findUserApplicationForApp.js.map +0 -1
- package/dist/actions/deploy/findUserApplicationForStudio.js +0 -172
- package/dist/actions/deploy/findUserApplicationForStudio.js.map +0 -1
- package/dist/actions/deploy/viewDeployment.js +0 -32
- package/dist/actions/deploy/viewDeployment.js.map +0 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { exitCodes, getLocalPackageVersion } from '@sanity/cli-core';
|
|
2
|
+
import { spinner } from '@sanity/cli-core/ux';
|
|
3
|
+
import { checkBuiltOutput } from '@sanity/workbench-cli/deploy';
|
|
4
|
+
import { resolveAppIdIssue } from '../../util/appId.js';
|
|
5
|
+
import { APP_ID_NOT_FOUND_IN_ORGANIZATION } from '../../util/errorMessages.js';
|
|
6
|
+
import { getErrorMessage } from '../../util/getErrorMessage.js';
|
|
7
|
+
import { getAutoUpdateIssueMessage, getAutoUpdateMigrationHint, resolveAutoUpdates } from '../build/shouldAutoUpdate.js';
|
|
8
|
+
import { checkDir } from './checkDir.js';
|
|
9
|
+
import { deployDebug } from './deployDebug.js';
|
|
10
|
+
import { resolveAppDeployTarget, resolveStudioDeployTarget } from './resolveDeployTarget.js';
|
|
11
|
+
export function createFailFastReporter(output) {
|
|
12
|
+
return {
|
|
13
|
+
report (check) {
|
|
14
|
+
// Fixes surface in both modes: appended after the message here, and in the
|
|
15
|
+
// dry-run report, so the problem and its fix never drift apart.
|
|
16
|
+
const text = check.solution ? `${check.message}: ${check.solution}` : check.message;
|
|
17
|
+
if (check.status === 'fail') {
|
|
18
|
+
output.error(text, {
|
|
19
|
+
exit: check.exitCode ?? 1
|
|
20
|
+
});
|
|
21
|
+
} else if (check.status === 'warn') {
|
|
22
|
+
output.warn(text);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function createCollectingReporter() {
|
|
28
|
+
const results = [];
|
|
29
|
+
return {
|
|
30
|
+
report (check) {
|
|
31
|
+
results.push(check);
|
|
32
|
+
},
|
|
33
|
+
results
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Runs a fallible step and turns a throw into a `fail` check. In a real deploy
|
|
38
|
+
* that fail exits (aborting the run); in a dry run it's recorded and `null`
|
|
39
|
+
* comes back so the caller can skip the rest of the step. `name` labels the
|
|
40
|
+
* step in debug logs.
|
|
41
|
+
*/ export async function runStep(reporter, name, work, formatError = getErrorMessage, solution) {
|
|
42
|
+
try {
|
|
43
|
+
return await work();
|
|
44
|
+
} catch (err) {
|
|
45
|
+
deployDebug(`${name} step failed`, err);
|
|
46
|
+
reporter.report({
|
|
47
|
+
message: formatError(err),
|
|
48
|
+
solution,
|
|
49
|
+
status: 'fail'
|
|
50
|
+
});
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function checkPackageVersion(reporter, { moduleName, workDir }) {
|
|
55
|
+
const version = await getLocalPackageVersion(moduleName, workDir);
|
|
56
|
+
reporter.report(version ? {
|
|
57
|
+
message: `Using ${moduleName} ${version}`,
|
|
58
|
+
status: 'pass'
|
|
59
|
+
} : {
|
|
60
|
+
message: `Failed to find installed ${moduleName} version`,
|
|
61
|
+
solution: `Install ${moduleName} in this project`,
|
|
62
|
+
status: 'fail'
|
|
63
|
+
});
|
|
64
|
+
return version;
|
|
65
|
+
}
|
|
66
|
+
export function checkAutoUpdates(reporter, { cliConfig, flags }) {
|
|
67
|
+
const { enabled, issue } = resolveAutoUpdates({
|
|
68
|
+
cliConfig,
|
|
69
|
+
flags
|
|
70
|
+
});
|
|
71
|
+
if (issue) {
|
|
72
|
+
reporter.report({
|
|
73
|
+
message: getAutoUpdateIssueMessage(issue),
|
|
74
|
+
// A config conflict makes a real deploy refuse to run; deprecations only warn
|
|
75
|
+
status: issue.type === 'conflicting-config' ? 'fail' : 'warn'
|
|
76
|
+
});
|
|
77
|
+
// The deprecated top-level config also gets the styled migration edit, the
|
|
78
|
+
// same second warning the build/dev path prints through shouldAutoUpdate.
|
|
79
|
+
if (issue.type === 'deprecated-config') {
|
|
80
|
+
reporter.report({
|
|
81
|
+
message: getAutoUpdateMigrationHint(cliConfig.autoUpdates),
|
|
82
|
+
status: 'warn'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return enabled;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The dry-run form of the `app.id` config check a real deploy runs in
|
|
90
|
+
* `findUserApplication`: a conflict fails (both `app.id` and `deployment.appId`
|
|
91
|
+
* set), the deprecated config alone warns.
|
|
92
|
+
*/ export function checkAppId(reporter, { cliConfig }) {
|
|
93
|
+
const issue = resolveAppIdIssue(cliConfig);
|
|
94
|
+
if (issue === 'conflicting-config') {
|
|
95
|
+
reporter.report({
|
|
96
|
+
message: 'Both `app.id` (deprecated) and `deployment.appId` are set',
|
|
97
|
+
solution: 'Remove `app.id` from sanity.cli.ts',
|
|
98
|
+
status: 'fail'
|
|
99
|
+
});
|
|
100
|
+
} else if (issue === 'deprecated-config') {
|
|
101
|
+
reporter.report({
|
|
102
|
+
message: 'The `app.id` config is deprecated',
|
|
103
|
+
solution: 'Move it to `deployment.appId` in sanity.cli.ts',
|
|
104
|
+
status: 'warn'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export async function checkBuild(reporter, { build, skipReason, successMessage }) {
|
|
109
|
+
if (skipReason) {
|
|
110
|
+
reporter.report({
|
|
111
|
+
message: skipReason,
|
|
112
|
+
status: 'skip'
|
|
113
|
+
});
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await runStep(reporter, 'build', async ()=>{
|
|
117
|
+
await build();
|
|
118
|
+
reporter.report({
|
|
119
|
+
message: successMessage,
|
|
120
|
+
status: 'pass'
|
|
121
|
+
});
|
|
122
|
+
}, (err)=>`Build failed: ${getErrorMessage(err)}`, 'Fix the build error above, then retry');
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The deploy directory must exist and hold the right build output: a federation
|
|
126
|
+
* remote for a workbench app, an `index.html` SPA otherwise.
|
|
127
|
+
*/ export async function verifyOutputDir({ isWorkbenchApp, reporter, sourceDir }) {
|
|
128
|
+
const spin = spinner('Verifying local content...').start();
|
|
129
|
+
const verifyBuild = isWorkbenchApp ? checkBuiltOutput : checkDir;
|
|
130
|
+
try {
|
|
131
|
+
await verifyBuild(sourceDir);
|
|
132
|
+
spin.succeed();
|
|
133
|
+
} catch (err) {
|
|
134
|
+
spin.fail();
|
|
135
|
+
deployDebug('Error checking directory', err);
|
|
136
|
+
reporter.report({
|
|
137
|
+
message: getErrorMessage(err),
|
|
138
|
+
solution: 'Run the build first, or check the output directory',
|
|
139
|
+
status: 'fail'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The single diagnosis for each app deploy-target verdict, shared by the
|
|
145
|
+
* dry-run report and the real deploy's unattended error paths so message,
|
|
146
|
+
* fix, and exit code can't drift between the two.
|
|
147
|
+
*/ export function describeAppTarget(resolution, { title } = {}) {
|
|
148
|
+
switch(resolution.type){
|
|
149
|
+
case 'blocked':
|
|
150
|
+
{
|
|
151
|
+
return {
|
|
152
|
+
message: `Deploy target not resolved — ${resolution.message}`,
|
|
153
|
+
status: 'skip'
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
case 'found':
|
|
157
|
+
{
|
|
158
|
+
const { application } = resolution;
|
|
159
|
+
return {
|
|
160
|
+
message: `Deploys to existing application "${application.title ?? application.appHost}"`,
|
|
161
|
+
status: 'pass'
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
case 'invalid':
|
|
165
|
+
{
|
|
166
|
+
return {
|
|
167
|
+
message: APP_ID_NOT_FOUND_IN_ORGANIZATION,
|
|
168
|
+
solution: 'Check `deployment.appId` matches an app in your organization',
|
|
169
|
+
status: 'fail'
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
case 'needs-input':
|
|
173
|
+
{
|
|
174
|
+
return {
|
|
175
|
+
exitCode: exitCodes.USAGE_ERROR,
|
|
176
|
+
message: `No \`deployment.appId\` configured (${resolution.existing.length} existing ${resolution.existing.length === 1 ? 'application' : 'applications'} to choose from)`,
|
|
177
|
+
solution: 'Add `deployment.appId` to sanity.cli.ts',
|
|
178
|
+
status: 'fail'
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// Without --title, creating an app needs a prompt no unattended run can answer
|
|
182
|
+
case 'would-create':
|
|
183
|
+
{
|
|
184
|
+
if (title) {
|
|
185
|
+
return {
|
|
186
|
+
message: `Would create a new application "${title}"`,
|
|
187
|
+
status: 'pass'
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
exitCode: exitCodes.USAGE_ERROR,
|
|
192
|
+
message: 'No application to deploy to — creating one needs a title',
|
|
193
|
+
solution: 'Pass `--title "<name>"` or set `app.title` in sanity.cli.ts to create one, or set `deployment.appId` to deploy to an existing app',
|
|
194
|
+
status: 'fail'
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export function describeAppTargetError(err, organizationId) {
|
|
200
|
+
return err?.statusCode === 403 ? `You don’t have permission to view applications for the configured organization ID ("${organizationId}"). Verify the organization ID, or ask your organization’s admin for access.` : `Failed to resolve deploy target: ${getErrorMessage(err)}`;
|
|
201
|
+
}
|
|
202
|
+
export async function checkAppTarget(reporter, { appId, organizationId, title }) {
|
|
203
|
+
await runStep(reporter, 'target', async ()=>reporter.report(describeAppTarget(await resolveAppDeployTarget({
|
|
204
|
+
appId,
|
|
205
|
+
organizationId
|
|
206
|
+
}), {
|
|
207
|
+
title
|
|
208
|
+
})), (err)=>describeAppTargetError(err, organizationId));
|
|
209
|
+
}
|
|
210
|
+
/** Same contract as {@link describeAppTarget}, for the studio verdicts. */ export function describeStudioTarget(resolution, { isExternal, title }) {
|
|
211
|
+
const studioUrl = (host)=>isExternal ? host : `https://${host}.sanity.studio`;
|
|
212
|
+
switch(resolution.type){
|
|
213
|
+
case 'blocked':
|
|
214
|
+
{
|
|
215
|
+
return {
|
|
216
|
+
message: `Deploy target not resolved — ${resolution.message}`,
|
|
217
|
+
status: 'skip'
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
case 'found':
|
|
221
|
+
{
|
|
222
|
+
return {
|
|
223
|
+
message: `Deploys to existing studio ${studioUrl(resolution.application.appHost)}`,
|
|
224
|
+
status: 'pass'
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
case 'invalid':
|
|
228
|
+
{
|
|
229
|
+
return {
|
|
230
|
+
// A bad host is a usage error; other invalid targets exit 1
|
|
231
|
+
exitCode: resolution.reason === 'invalid-host' ? exitCodes.USAGE_ERROR : 1,
|
|
232
|
+
message: resolution.message,
|
|
233
|
+
solution: 'Check `studioHost` and `deployment.appId` in sanity.cli.ts',
|
|
234
|
+
status: 'fail'
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
case 'needs-input':
|
|
238
|
+
{
|
|
239
|
+
return {
|
|
240
|
+
exitCode: exitCodes.USAGE_ERROR,
|
|
241
|
+
message: isExternal ? 'No external studio URL configured' : 'No studio hostname configured',
|
|
242
|
+
solution: isExternal ? 'Set `studioHost` in sanity.cli.ts, or pass the full URL with --url' : 'Set `studioHost` in sanity.cli.ts, or pass a hostname with --url',
|
|
243
|
+
status: 'fail'
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
case 'would-create':
|
|
247
|
+
{
|
|
248
|
+
const titled = title ? ` titled "${title}"` : '';
|
|
249
|
+
return {
|
|
250
|
+
message: isExternal ? `Would register external studio at ${resolution.appHost}${titled}` : `Would create studio hostname ${studioUrl(resolution.appHost)}${titled} (name availability is checked on deploy)`,
|
|
251
|
+
status: 'pass'
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
export async function checkStudioTarget(reporter, options) {
|
|
257
|
+
await runStep(reporter, 'target', async ()=>reporter.report(describeStudioTarget(await resolveStudioDeployTarget(options), {
|
|
258
|
+
isExternal: options.isExternal,
|
|
259
|
+
title: options.title
|
|
260
|
+
})), (err)=>`Failed to resolve deploy target: ${getErrorMessage(err)}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//# sourceMappingURL=deployChecks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployChecks.ts"],"sourcesContent":["import {type CliConfig, exitCodes, getLocalPackageVersion, type Output} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {checkBuiltOutput} from '@sanity/workbench-cli/deploy'\n\nimport {resolveAppIdIssue} from '../../util/appId.js'\nimport {APP_ID_NOT_FOUND_IN_ORGANIZATION} from '../../util/errorMessages.js'\nimport {getErrorMessage} from '../../util/getErrorMessage.js'\nimport {\n getAutoUpdateIssueMessage,\n getAutoUpdateMigrationHint,\n resolveAutoUpdates,\n} from '../build/shouldAutoUpdate.js'\nimport {checkDir} from './checkDir.js'\nimport {deployDebug} from './deployDebug.js'\nimport {\n type AppDeployTargetResolution,\n resolveAppDeployTarget,\n resolveStudioDeployTarget,\n type StudioDeployTargetResolution,\n} from './resolveDeployTarget.js'\nimport {type DeployFlags} from './types.js'\n\ntype DeployCheckStatus = 'fail' | 'pass' | 'skip' | 'warn'\n\nexport interface DeployCheck {\n message: string\n status: DeployCheckStatus\n\n /** Exit code a real deploy uses when this check fails; defaults to 1 */\n exitCode?: number\n /** Actionable fix, shown under a failing or warning check */\n solution?: string\n}\n\n/**\n * Where deploy steps send their check outcomes — and the only place the deploy\n * mode lives. A real deploy fails fast: a `fail` prints and exits immediately,\n * which aborts the sequence. A dry run collects every outcome and never exits.\n * Steps just call `report`; they never know which mode is running.\n */\nexport interface CheckReporter {\n report(check: DeployCheck): void\n}\n\nexport function createFailFastReporter(output: Output): CheckReporter {\n return {\n report(check) {\n // Fixes surface in both modes: appended after the message here, and in the\n // dry-run report, so the problem and its fix never drift apart.\n const text = check.solution ? `${check.message}: ${check.solution}` : check.message\n if (check.status === 'fail') {\n output.error(text, {exit: check.exitCode ?? 1})\n } else if (check.status === 'warn') {\n output.warn(text)\n }\n },\n }\n}\n\nexport function createCollectingReporter(): CheckReporter & {results: DeployCheck[]} {\n const results: DeployCheck[] = []\n return {\n report(check) {\n results.push(check)\n },\n results,\n }\n}\n\n/**\n * Runs a fallible step and turns a throw into a `fail` check. In a real deploy\n * that fail exits (aborting the run); in a dry run it's recorded and `null`\n * comes back so the caller can skip the rest of the step. `name` labels the\n * step in debug logs.\n */\nexport async function runStep<T>(\n reporter: CheckReporter,\n name: string,\n work: () => Promise<T>,\n formatError: (err: unknown) => string = getErrorMessage,\n solution?: string,\n): Promise<T | null> {\n try {\n return await work()\n } catch (err) {\n deployDebug(`${name} step failed`, err)\n reporter.report({message: formatError(err), solution, status: 'fail'})\n return null\n }\n}\n\nexport async function checkPackageVersion(\n reporter: CheckReporter,\n {moduleName, workDir}: {moduleName: string; workDir: string},\n): Promise<string | null> {\n const version = await getLocalPackageVersion(moduleName, workDir)\n reporter.report(\n version\n ? {message: `Using ${moduleName} ${version}`, status: 'pass'}\n : {\n message: `Failed to find installed ${moduleName} version`,\n solution: `Install ${moduleName} in this project`,\n status: 'fail',\n },\n )\n return version\n}\n\nexport function checkAutoUpdates(\n reporter: CheckReporter,\n {cliConfig, flags}: {cliConfig: CliConfig; flags: DeployFlags},\n): boolean {\n const {enabled, issue} = resolveAutoUpdates({cliConfig, flags})\n\n if (issue) {\n reporter.report({\n message: getAutoUpdateIssueMessage(issue),\n // A config conflict makes a real deploy refuse to run; deprecations only warn\n status: issue.type === 'conflicting-config' ? 'fail' : 'warn',\n })\n\n // The deprecated top-level config also gets the styled migration edit, the\n // same second warning the build/dev path prints through shouldAutoUpdate.\n if (issue.type === 'deprecated-config') {\n reporter.report({\n message: getAutoUpdateMigrationHint(cliConfig.autoUpdates),\n status: 'warn',\n })\n }\n }\n\n return enabled\n}\n\n/**\n * The dry-run form of the `app.id` config check a real deploy runs in\n * `findUserApplication`: a conflict fails (both `app.id` and `deployment.appId`\n * set), the deprecated config alone warns.\n */\nexport function checkAppId(reporter: CheckReporter, {cliConfig}: {cliConfig: CliConfig}): void {\n const issue = resolveAppIdIssue(cliConfig)\n if (issue === 'conflicting-config') {\n reporter.report({\n message: 'Both `app.id` (deprecated) and `deployment.appId` are set',\n solution: 'Remove `app.id` from sanity.cli.ts',\n status: 'fail',\n })\n } else if (issue === 'deprecated-config') {\n reporter.report({\n message: 'The `app.id` config is deprecated',\n solution: 'Move it to `deployment.appId` in sanity.cli.ts',\n status: 'warn',\n })\n }\n}\n\nexport async function checkBuild(\n reporter: CheckReporter,\n {\n build,\n skipReason,\n successMessage,\n }: {build: () => Promise<void>; skipReason: string | undefined; successMessage: string},\n): Promise<void> {\n if (skipReason) {\n reporter.report({message: skipReason, status: 'skip'})\n return\n }\n\n await runStep(\n reporter,\n 'build',\n async () => {\n await build()\n reporter.report({message: successMessage, status: 'pass'})\n },\n (err) => `Build failed: ${getErrorMessage(err)}`,\n 'Fix the build error above, then retry',\n )\n}\n\n/**\n * The deploy directory must exist and hold the right build output: a federation\n * remote for a workbench app, an `index.html` SPA otherwise.\n */\nexport async function verifyOutputDir({\n isWorkbenchApp,\n reporter,\n sourceDir,\n}: {\n isWorkbenchApp: boolean\n reporter: CheckReporter\n sourceDir: string\n}): Promise<void> {\n const spin = spinner('Verifying local content...').start()\n const verifyBuild = isWorkbenchApp ? checkBuiltOutput : checkDir\n try {\n await verifyBuild(sourceDir)\n spin.succeed()\n } catch (err) {\n spin.fail()\n deployDebug('Error checking directory', err)\n reporter.report({\n message: getErrorMessage(err),\n solution: 'Run the build first, or check the output directory',\n status: 'fail',\n })\n }\n}\n\n/**\n * The single diagnosis for each app deploy-target verdict, shared by the\n * dry-run report and the real deploy's unattended error paths so message,\n * fix, and exit code can't drift between the two.\n */\nexport function describeAppTarget(\n resolution: AppDeployTargetResolution,\n {title}: {title?: string} = {},\n): DeployCheck {\n switch (resolution.type) {\n case 'blocked': {\n return {message: `Deploy target not resolved — ${resolution.message}`, status: 'skip'}\n }\n case 'found': {\n const {application} = resolution\n return {\n message: `Deploys to existing application \"${application.title ?? application.appHost}\"`,\n status: 'pass',\n }\n }\n case 'invalid': {\n return {\n message: APP_ID_NOT_FOUND_IN_ORGANIZATION,\n solution: 'Check `deployment.appId` matches an app in your organization',\n status: 'fail',\n }\n }\n case 'needs-input': {\n return {\n exitCode: exitCodes.USAGE_ERROR,\n message: `No \\`deployment.appId\\` configured (${resolution.existing.length} existing ${resolution.existing.length === 1 ? 'application' : 'applications'} to choose from)`,\n solution: 'Add `deployment.appId` to sanity.cli.ts',\n status: 'fail',\n }\n }\n // Without --title, creating an app needs a prompt no unattended run can answer\n case 'would-create': {\n if (title) {\n return {message: `Would create a new application \"${title}\"`, status: 'pass'}\n }\n return {\n exitCode: exitCodes.USAGE_ERROR,\n message: 'No application to deploy to — creating one needs a title',\n solution:\n 'Pass `--title \"<name>\"` or set `app.title` in sanity.cli.ts to create one, or set `deployment.appId` to deploy to an existing app',\n status: 'fail',\n }\n }\n }\n}\n\nexport function describeAppTargetError(err: unknown, organizationId: string | undefined): string {\n return (err as {statusCode?: number})?.statusCode === 403\n ? `You don’t have permission to view applications for the configured organization ID (\"${organizationId}\"). Verify the organization ID, or ask your organization’s admin for access.`\n : `Failed to resolve deploy target: ${getErrorMessage(err)}`\n}\n\nexport async function checkAppTarget(\n reporter: CheckReporter,\n {\n appId,\n organizationId,\n title,\n }: {appId: string | undefined; organizationId: string | undefined; title?: string},\n): Promise<void> {\n await runStep(\n reporter,\n 'target',\n async () =>\n reporter.report(\n describeAppTarget(await resolveAppDeployTarget({appId, organizationId}), {title}),\n ),\n (err) => describeAppTargetError(err, organizationId),\n )\n}\n\n/** Same contract as {@link describeAppTarget}, for the studio verdicts. */\nexport function describeStudioTarget(\n resolution: StudioDeployTargetResolution,\n {isExternal, title}: {isExternal: boolean; title?: string},\n): DeployCheck {\n const studioUrl = (host: string) => (isExternal ? host : `https://${host}.sanity.studio`)\n\n switch (resolution.type) {\n case 'blocked': {\n return {message: `Deploy target not resolved — ${resolution.message}`, status: 'skip'}\n }\n case 'found': {\n return {\n message: `Deploys to existing studio ${studioUrl(resolution.application.appHost)}`,\n status: 'pass',\n }\n }\n case 'invalid': {\n return {\n // A bad host is a usage error; other invalid targets exit 1\n exitCode: resolution.reason === 'invalid-host' ? exitCodes.USAGE_ERROR : 1,\n message: resolution.message,\n solution: 'Check `studioHost` and `deployment.appId` in sanity.cli.ts',\n status: 'fail',\n }\n }\n case 'needs-input': {\n return {\n exitCode: exitCodes.USAGE_ERROR,\n message: isExternal ? 'No external studio URL configured' : 'No studio hostname configured',\n solution: isExternal\n ? 'Set `studioHost` in sanity.cli.ts, or pass the full URL with --url'\n : 'Set `studioHost` in sanity.cli.ts, or pass a hostname with --url',\n status: 'fail',\n }\n }\n case 'would-create': {\n const titled = title ? ` titled \"${title}\"` : ''\n return {\n message: isExternal\n ? `Would register external studio at ${resolution.appHost}${titled}`\n : `Would create studio hostname ${studioUrl(resolution.appHost)}${titled} (name availability is checked on deploy)`,\n status: 'pass',\n }\n }\n }\n}\n\nexport async function checkStudioTarget(\n reporter: CheckReporter,\n options: {\n appId: string | undefined\n isExternal: boolean\n projectId: string | undefined\n studioHost: string | undefined\n title: string | undefined\n urlFlag: string | undefined\n },\n): Promise<void> {\n await runStep(\n reporter,\n 'target',\n async () =>\n reporter.report(\n describeStudioTarget(await resolveStudioDeployTarget(options), {\n isExternal: options.isExternal,\n title: options.title,\n }),\n ),\n (err) => `Failed to resolve deploy target: ${getErrorMessage(err)}`,\n )\n}\n"],"names":["exitCodes","getLocalPackageVersion","spinner","checkBuiltOutput","resolveAppIdIssue","APP_ID_NOT_FOUND_IN_ORGANIZATION","getErrorMessage","getAutoUpdateIssueMessage","getAutoUpdateMigrationHint","resolveAutoUpdates","checkDir","deployDebug","resolveAppDeployTarget","resolveStudioDeployTarget","createFailFastReporter","output","report","check","text","solution","message","status","error","exit","exitCode","warn","createCollectingReporter","results","push","runStep","reporter","name","work","formatError","err","checkPackageVersion","moduleName","workDir","version","checkAutoUpdates","cliConfig","flags","enabled","issue","type","autoUpdates","checkAppId","checkBuild","build","skipReason","successMessage","verifyOutputDir","isWorkbenchApp","sourceDir","spin","start","verifyBuild","succeed","fail","describeAppTarget","resolution","title","application","appHost","USAGE_ERROR","existing","length","describeAppTargetError","organizationId","statusCode","checkAppTarget","appId","describeStudioTarget","isExternal","studioUrl","host","reason","titled","checkStudioTarget","options"],"mappings":"AAAA,SAAwBA,SAAS,EAAEC,sBAAsB,QAAoB,mBAAkB;AAC/F,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,gBAAgB,QAAO,+BAA8B;AAE7D,SAAQC,iBAAiB,QAAO,sBAAqB;AACrD,SAAQC,gCAAgC,QAAO,8BAA6B;AAC5E,SAAQC,eAAe,QAAO,gCAA+B;AAC7D,SACEC,yBAAyB,EACzBC,0BAA0B,EAC1BC,kBAAkB,QACb,+BAA8B;AACrC,SAAQC,QAAQ,QAAO,gBAAe;AACtC,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAEEC,sBAAsB,EACtBC,yBAAyB,QAEpB,2BAA0B;AAyBjC,OAAO,SAASC,uBAAuBC,MAAc;IACnD,OAAO;QACLC,QAAOC,KAAK;YACV,2EAA2E;YAC3E,gEAAgE;YAChE,MAAMC,OAAOD,MAAME,QAAQ,GAAG,GAAGF,MAAMG,OAAO,CAAC,EAAE,EAAEH,MAAME,QAAQ,EAAE,GAAGF,MAAMG,OAAO;YACnF,IAAIH,MAAMI,MAAM,KAAK,QAAQ;gBAC3BN,OAAOO,KAAK,CAACJ,MAAM;oBAACK,MAAMN,MAAMO,QAAQ,IAAI;gBAAC;YAC/C,OAAO,IAAIP,MAAMI,MAAM,KAAK,QAAQ;gBAClCN,OAAOU,IAAI,CAACP;YACd;QACF;IACF;AACF;AAEA,OAAO,SAASQ;IACd,MAAMC,UAAyB,EAAE;IACjC,OAAO;QACLX,QAAOC,KAAK;YACVU,QAAQC,IAAI,CAACX;QACf;QACAU;IACF;AACF;AAEA;;;;;CAKC,GACD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,OAAOkB,QAAQlB,KAAK;QACtB,KAEJ,CAAC3B,MAAQ,CAAC,iCAAiC,EAAE5B,gBAAgB4B,MAAM;AAEvE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import { createCollectingReporter, createFailFastReporter } from './deployChecks.js';
|
|
3
|
+
import { deployDebug } from './deployDebug.js';
|
|
4
|
+
import { renderDeploymentPlan } from './deploymentPlan.js';
|
|
5
|
+
/**
|
|
6
|
+
* Runs a deploy in the mode the flags select. A real deploy fails fast and
|
|
7
|
+
* mutates; `--dry-run` drives the same `run` sequence read-only and renders a
|
|
8
|
+
* plan. The mode lives only in the reporter, so the two can't drift.
|
|
9
|
+
*/ export async function runDeploy(options, spec) {
|
|
10
|
+
const { output } = options;
|
|
11
|
+
if (options.flags['dry-run']) {
|
|
12
|
+
const reporter = createCollectingReporter();
|
|
13
|
+
await spec.run(options, reporter);
|
|
14
|
+
const failed = reporter.results.find((check)=>check.status === 'fail');
|
|
15
|
+
const plan = {
|
|
16
|
+
checks: reporter.results,
|
|
17
|
+
// A blocked deploy uploads nothing, so only enumerate files for a deployable plan.
|
|
18
|
+
files: failed ? [] : await spec.listFiles(options),
|
|
19
|
+
type: spec.type
|
|
20
|
+
};
|
|
21
|
+
renderDeploymentPlan(plan, output);
|
|
22
|
+
// Exit like a real (fail-fast) deploy would on the first failing check, so a
|
|
23
|
+
// script gating on the exit code sees the same status.
|
|
24
|
+
if (failed) output.error('Deploy blocked by failing checks.', {
|
|
25
|
+
exit: failed.exitCode ?? 1
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await spec.run(options, createFailFastReporter(output));
|
|
31
|
+
} catch (error) {
|
|
32
|
+
normalizeDeployError(error, output, spec.type);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function normalizeDeployError(error, output, type) {
|
|
36
|
+
const noun = type === 'coreApp' ? 'application' : 'studio';
|
|
37
|
+
// Ctrl+C on an interactive prompt isn't a real failure
|
|
38
|
+
if (error instanceof Error && error.name === 'ExitPromptError') {
|
|
39
|
+
output.error('Deployment cancelled by user', {
|
|
40
|
+
exit: 1
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// A failed check already carries its own exit code; keep it
|
|
45
|
+
if (error instanceof CLIError) {
|
|
46
|
+
output.error(error.message, {
|
|
47
|
+
exit: error.oclif?.exit ?? 1
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
deployDebug(`Error deploying ${noun}`, error);
|
|
52
|
+
output.error(`Error deploying ${noun}: ${error}`, {
|
|
53
|
+
exit: 1
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=deployRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployRunner.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\nimport {type Output} from '@sanity/cli-core'\n\nimport {\n type CheckReporter,\n createCollectingReporter,\n createFailFastReporter,\n} from './deployChecks.js'\nimport {deployDebug} from './deployDebug.js'\nimport {type DeploymentFile, type DeploymentPlan, renderDeploymentPlan} from './deploymentPlan.js'\nimport {type DeployAppOptions} from './types.js'\n\n/**\n * The parts of a deploy that differ between core apps and studios. The shared\n * sequence — mode selection, error handling, the dry-run plan — lives in `runDeploy`.\n */\nexport interface DeploySpec {\n /** Files a real deploy would upload, listed only for the dry-run plan. */\n listFiles: (options: DeployAppOptions) => Promise<DeploymentFile[]>\n /** The step sequence; every step reports through `reporter`. */\n run: (options: DeployAppOptions, reporter: CheckReporter) => Promise<void>\n type: 'coreApp' | 'studio'\n}\n\n/**\n * Runs a deploy in the mode the flags select. A real deploy fails fast and\n * mutates; `--dry-run` drives the same `run` sequence read-only and renders a\n * plan. The mode lives only in the reporter, so the two can't drift.\n */\nexport async function runDeploy(options: DeployAppOptions, spec: DeploySpec): Promise<void> {\n const {output} = options\n\n if (options.flags['dry-run']) {\n const reporter = createCollectingReporter()\n await spec.run(options, reporter)\n const failed = reporter.results.find((check) => check.status === 'fail')\n const plan: DeploymentPlan = {\n checks: reporter.results,\n // A blocked deploy uploads nothing, so only enumerate files for a deployable plan.\n files: failed ? [] : await spec.listFiles(options),\n type: spec.type,\n }\n renderDeploymentPlan(plan, output)\n // Exit like a real (fail-fast) deploy would on the first failing check, so a\n // script gating on the exit code sees the same status.\n if (failed) output.error('Deploy blocked by failing checks.', {exit: failed.exitCode ?? 1})\n return\n }\n\n try {\n await spec.run(options, createFailFastReporter(output))\n } catch (error) {\n normalizeDeployError(error, output, spec.type)\n }\n}\n\nfunction normalizeDeployError(error: unknown, output: Output, type: 'coreApp' | 'studio'): void {\n const noun = type === 'coreApp' ? 'application' : 'studio'\n\n // Ctrl+C on an interactive prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n output.error('Deployment cancelled by user', {exit: 1})\n return\n }\n // A failed check already carries its own exit code; keep it\n if (error instanceof CLIError) {\n output.error(error.message, {exit: error.oclif?.exit ?? 1})\n return\n }\n deployDebug(`Error deploying ${noun}`, error)\n output.error(`Error deploying ${noun}: ${error}`, {exit: 1})\n}\n"],"names":["CLIError","createCollectingReporter","createFailFastReporter","deployDebug","renderDeploymentPlan","runDeploy","options","spec","output","flags","reporter","run","failed","results","find","check","status","plan","checks","files","listFiles","type","error","exit","exitCode","normalizeDeployError","noun","Error","name","message","oclif"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAG3C,SAEEC,wBAAwB,EACxBC,sBAAsB,QACjB,oBAAmB;AAC1B,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAkDC,oBAAoB,QAAO,sBAAqB;AAelG;;;;CAIC,GACD,OAAO,eAAeC,UAAUC,OAAyB,EAAEC,IAAgB;IACzE,MAAM,EAACC,MAAM,EAAC,GAAGF;IAEjB,IAAIA,QAAQG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