feat(deploy): add --url flag and unattended mode support#760
feat(deploy): add --url flag and unattended mode support#760
Conversation
Add --url flag to `sanity deploy` that works for both external and internal studios. For external deploys it passes the full URL directly. For internal deploys it strips the .sanity.studio suffix if present. The flag takes precedence over the studioHost config value. When --yes (unattended mode) is used without --url or studioHost, the command now errors with a helpful message instead of hanging on an interactive prompt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @rexxars's task in 3m 3s —— View job Code Review
1. Dead code causes the 3.3% coverage dropIn if (validation !== true) {
output.error(validation, {exit: 1})
return undefined // never reached
}
// ... and two more like thisThese are there purely to satisfy TypeScript's control flow, but Istanbul counts them as uncovered branches. That's where the 3.3% drop comes from. You could suppress this with a type assertion or by extracting a helper typed as 2. Double URL normalization for external
|
Strip https:// prefix from --url for internal deploys so that `--url https://my-studio.sanity.studio` correctly resolves to `my-studio` instead of `https://my-studio`. Also fix the unattended error path in findUserApplicationForStudio to return null instead of undefined for consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Say "A studio found" instead of "Multiple studios found" when only one studio exists in the unattended error path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… URLs Validate that the resolved hostname for internal deploys only contains valid characters (letters, numbers, hyphens). If the result still looks like a URL (contains dots after stripping protocol and .sanity.studio), suggest using --external instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move unattended error messaging to a single place in deployStudio.ts. Previously, findUserApplicationForStudio emitted its own error when apps existed but couldn't be selected, then the caller emitted a second error since userApplication was null and flags.yes was true. Now findUserApplicationForStudio just returns null in unattended mode and lets the caller handle the error consistently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coverage Delta
Comparing 3 changed files against main @ Overall Coverage
|
Tighten the hostname regex to disallow trailing hyphens, which are invalid per DNS rules and would fail at the API with a confusing error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
binoy14
left a comment
There was a problem hiding this comment.
This is using cliConfig.studioHost which is deprecated would it be more confusing from the CLI usage perspective?
There was a problem hiding this comment.
The error tests should test for exit code?
|
|
||
| expect(error).toBeInstanceOf(Error) | ||
| expect(error?.message).toContain('Invalid studio hostname') | ||
| expect(error?.message).toContain('letters, numbers, and hyphens') |
There was a problem hiding this comment.
should test for error code?
| }) | ||
|
|
||
| expect(error).toBeInstanceOf(Error) | ||
| expect(error?.message).toContain('Invalid studio hostname') |
There was a problem hiding this comment.
shoudl test for exit code?
|
|
||
| expect(error).toBeInstanceOf(Error) | ||
| expect(error?.message).toContain('Cannot prompt for studio hostname in unattended mode') | ||
| expect(error?.message).toContain('Use --url to specify the studio hostname') |
There was a problem hiding this comment.
should test for exit code?
|
|
||
| expect(error).toBeInstanceOf(Error) | ||
| expect(error?.message).toContain('Cannot prompt for studio hostname in unattended mode') | ||
| expect(error?.message).toContain('Use --url to specify the studio hostname') |
There was a problem hiding this comment.
should test for exit code?
Summary
--urlflag tosanity deploythat works for both external and internal studio deploys. For external deploys, it passes the full URL. For internal deploys, it strips the.sanity.studiosuffix if present, so users can pass eithermy-studioormy-studio.sanity.studio.--urlflag takes precedence over thestudioHostconfig value, making it useful as a CLI override.--yes(unattended mode) is used without--urlorstudioHostconfig, the command now errors with a helpful message (pointing to--url) instead of hanging on an interactive prompt.select()prompt when multiple studios exist, and theinput()prompt when no studio is configured.Test plan
🤖 Generated with Claude Code