Skip to content

CLI: Only ask for admin permissions once when changing domain#2315

Merged
sejas merged 2 commits intodev/studio-cli-i2from
stu-1077-studio-only-ask-for-admin-permissions-once-when-changing
Dec 30, 2025
Merged

CLI: Only ask for admin permissions once when changing domain#2315
sejas merged 2 commits intodev/studio-cli-i2from
stu-1077-studio-only-ask-for-admin-permissions-once-when-changing

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Dec 24, 2025

Related issues

Proposed Changes

  • Add updateDomainInHosts() function to cli/lib/hosts-file.ts that handles removing the old domain and adding the new domain in a single hosts file write operation (single admin privilege request)
  • Add skipHostsUpdate option to setupCustomDomain() in cli/lib/site-utils.ts to avoid duplicate hosts file updates
  • Refactor cli/commands/site/set-domain.ts to use the new combined operation

Testing Instructions

  1. Create a site with no custom domain
  2. Run studio site set-domain test.local --path <site-path>
    • Verify you're only prompted for admin password once
    • Verify the domain is added to /etc/hosts
  3. Run studio site set-domain test2.local --path <site-path> to change the domain
    • Verify you're only prompted for admin password once (previously this asked twice)
    • Verify test.local is removed and test2.local is added to /etc/hosts
  4. Run unit tests: npm test -- cli/commands/site/tests/set-domain.test.ts

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this Dec 24, 2025
@bcotrim bcotrim changed the base branch from trunk to dev/studio-cli-i2 December 24, 2025 17:01
@bcotrim bcotrim requested review from a team and fredrikekelund December 24, 2025 17:03
Copy link
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and works as expected 👍

Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm the password dialog appears only once, and the custom domain is correctly updated in /etc/hosts. The old domain is correctly removed and replaced by the new one.

Image

@sejas sejas merged commit 9a0d42f into dev/studio-cli-i2 Dec 30, 2025
4 of 7 checks passed
@sejas sejas deleted the stu-1077-studio-only-ask-for-admin-permissions-once-when-changing branch December 30, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants