feat(sdk): add custom domain support for staticwebsite - #1367
Conversation
🦋 Changeset detectedLatest commit: b6ddabd The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR adds first-class custom domain support to the Static Website service configuration and deployment flow, plus CLI commands to inspect custom-domain status and DNS targets.
Changes:
- Extend static website config/types with an optional
customDomainsarray. - Update
deployplanning/apply to diff desired vs existing custom domains and call Add/Remove RPCs, while only removing SDK-owned domains. - Add
tailor-sdk staticwebsite domain get|listcommands and document the new functionality.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/types/staticwebsite.generated.ts | Adds customDomains to the generated StaticWebsite type. |
| packages/sdk/src/parser/service/staticwebsite/schema.ts | Extends the Zod schema to accept customDomains. |
| packages/sdk/src/cli/shared/readonly-guard.test.ts | Marks new domain subcommands as read/local-safe. |
| packages/sdk/src/cli/commands/staticwebsite/index.ts | Registers the staticwebsite domain subcommand. |
| packages/sdk/src/cli/commands/staticwebsite/domain/status.ts | Adds status label mapping for custom domain statuses. |
| packages/sdk/src/cli/commands/staticwebsite/domain/list.ts | Implements staticwebsite domain list. |
| packages/sdk/src/cli/commands/staticwebsite/domain/index.ts | Adds the domain command group for staticwebsite. |
| packages/sdk/src/cli/commands/staticwebsite/domain/get.ts | Implements staticwebsite domain get. |
| packages/sdk/src/cli/commands/deploy/staticwebsite.ts | Plans/applies custom domain changes alongside static websites. |
| packages/sdk/src/cli/commands/deploy/staticwebsite.test.ts | Adds planning tests for custom domain diffing/ownership behavior. |
| packages/sdk/src/cli/commands/deploy/deploy.ts | Prints/summarizes the new custom domain changeset in plans. |
| packages/sdk/src/cli/commands/deploy/deploy.test.ts | Updates empty plan results to include the custom domain changeset. |
| packages/sdk/docs/services/staticwebsite.md | Documents customDomains and the new inspection command. |
| packages/sdk/docs/cli/staticwebsite.md | Adds docs for staticwebsite domain commands. |
| packages/sdk/docs/cli-reference.md | Adds custom domain commands to the CLI reference table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
bfd2fd8 to
545f74b
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
📖 Docs Consistency Check
⚠️ Inconsistencies Found
| File | Issue | Suggested Fix |
|---|---|---|
packages/sdk/docs/services/staticwebsite.md |
Missing documentation about SDK-managed vs console-managed domain behavior | Add a section explaining that only SDK-managed domains are removed during deployment, and console-added domains persist |
Details
1. Missing SDK-managed domain behavior documentation
Location: packages/sdk/docs/services/staticwebsite.md, line 65-75 (customDomains section)
Issue: The documentation does not explain the important distinction between SDK-managed and console-managed custom domains. According to the implementation (packages/sdk/src/cli/commands/deploy/staticwebsite.ts:299-329), the deploy logic:
- Only removes domains that are labeled as SDK-managed (tracked via labels with
sdk-name,sdk-version, andsdk-app-id) - Never removes domains added through the console UI
- Only performs removal when
customDomainsis explicitly specified in the config
Current documentation:
### customDomains
Associate custom domains with the static website:
```typescript
defineStaticWebSite("my-website", {
customDomains: ["app.example.com"],
});After deploying, use tailor-sdk staticwebsite domain get <domain> to check domain status and retrieve the CNAME targets required for DNS configuration.
**Suggested fix:** Add behavior documentation after the example:
```markdown
### customDomains
Associate custom domains with the static website:
```typescript
defineStaticWebSite("my-website", {
customDomains: ["app.example.com"],
});
After deploying, use tailor-sdk staticwebsite domain get <domain> to check domain status and retrieve the CNAME targets required for DNS configuration.
SDK-managed vs Console-managed Domains:
Custom domains can be added through the SDK (via customDomains config) or through the console UI. The SDK only manages domains it created:
- SDK-managed domains: Domains specified in
customDomainsare tracked by the SDK. If you remove a domain from the config, it will be deleted from the workspace on the nextdeploy. - Console-managed domains: Domains added through the console are never modified or removed by SDK deployments, even if
customDomainsis specified. - Omitting
customDomains: If you don't specifycustomDomainsin your config, all existing domains (both SDK-managed and console-managed) remain untouched during deployment.
This allows you to use both the SDK and console to manage domains on the same website without conflicts.
**Reference:** Implementation at `packages/sdk/src/cli/commands/deploy/staticwebsite.ts:299-329`, particularly the comment on line 322: "Only remove SDK-owned domains not in desired if customDomains is explicitly specified"
### Recommended Actions
1. Add the SDK-managed vs console-managed domain behavior section to `packages/sdk/docs/services/staticwebsite.md`
2. Consider adding a brief note in the deploy command documentation about this behavior if users are likely to be surprised by it
### What Was Checked
✅ **CLI command signatures** (`staticwebsite domain get`, `staticwebsite domain list`)
- Argument names, types, and descriptions match between implementation and documentation
- Options and their descriptions are consistent
✅ **CLI reference index** (`packages/sdk/docs/cli-reference.md`)
- New commands are listed with correct descriptions and links
✅ **Configuration API** (`customDomains` option)
- Type signature matches (`string[]` optional)
- Example code in documentation is valid
✅ **Generated types** (`packages/sdk/src/types/staticwebsite.generated.ts`)
- Generated type matches the schema definition
✅ **Service documentation structure**
- New `customDomains` section added with example
- Reference to CLI commands for checking domain status
⚠️ **Behavior documentation** (incomplete)
- Missing explanation of SDK-managed vs console-managed domain lifecycle
> Re-run this check by adding the `docs-check` label to the PR.
---
<!-- docs-consistency-check -->
Code Metrics Report (packages/sdk)
Details | | main (7249602) | #1367 (f0fa0a8) | +/- |
|--------------------|----------------|-----------------|-------|
- | Coverage | 66.0% | 66.0% | -0.1% |
| Files | 398 | 402 | +4 |
| Lines | 13769 | 13843 | +74 |
+ | Covered | 9095 | 9142 | +47 |
- | Code to Test Ratio | 1:0.4 | 1:0.4 | -0.1 |
| Code | 91692 | 92114 | +422 |
+ | Test | 39822 | 40001 | +179 |Code coverage of files in pull request scope (83.2% → 79.0%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
Summary
customDomainsoption todefineStaticWebSite()for associating custom domains with static websitesAddCustomDomain/RemoveCustomDomainRPCsdeploy. Only SDK-managed domains are tracked and can be removed...staticwebsite:{name}:custom_domain:{domain}) is a nested format not supported by the sharedresourceTrnhelper, so a localcustomDomainTrnfunction is used insteadstaticwebsite domain getandstaticwebsite domain listCLI commands for checking domain status and DNS CNAME targets