Skip to content

Conversation

@fredrikekelund
Copy link
Contributor

Related issues

Proposed Changes

  • Added studio site set-domain command, which updates the appdata file and restarts the site if running.
  • Added studio site set-https command, which updates the appdata file and restarts the site if running.

Testing Instructions

  1. Run npm run cli:build
  2. Run node dist/cli/main.js site set-https true --path PATH_TO_SITE (where PATH_TO_SITE is the path to a Studio site WITH a custom domain)
  3. Ensure that it succeeds
  4. Run node dist/cli/main.js site start --path PATH_TO_SITE
  5. Run node dist/cli/main.js site set-https false --path PATH_TO_SITE
  6. Ensure that the site restarts successfully
  7. Run node dist/cli/main.js site set-domain example.com --path PATH_TO_SITE
  8. Ensure that the command returns an error about the domain name format
  9. Run node dist/cli/main.js site set-domain example.local --path PATH_TO_SITE
  10. Ensure that the site restarts successfully

Pre-merge Checklist

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

@fredrikekelund fredrikekelund requested review from a team and bcotrim November 28, 2025 12:08
@fredrikekelund fredrikekelund self-assigned this Nov 28, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

📊 Performance Test Results

Comparing 3f6193a vs trunk

site-editor

Metric trunk 3f6193a Diff Change
load 10228.00 ms 6131.00 ms -4097.00 ms 🟢 -40.1%

site-startup

Metric trunk 3f6193a Diff Change
siteCreation 14257.00 ms 14226.00 ms -31.00 ms 🟢 -0.2%
siteStartup 5986.00 ms 5935.00 ms -51.00 ms 🟢 -0.9%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

Base automatically changed from stu-951-studio-implement-the-studio-site-stop-command to trunk November 28, 2025 13:05
Copy link
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

Adding a custom domain for a running site isn't working for me, likely because await setupCustomDomain( site, logger ); is using the site from const site = await getSiteByFolder( sitePath, false ); that doesn't have a customDomain.

Cleaning up the logic to fetch the site (as I mentioned in the comments) should also fix this issue

Comment on lines 44 to 47
const site = appdata.sites.find( ( site ) => arePathsEqual( site.path, sitePath ) );
if ( ! site ) {
throw new LoggerError( __( 'The specified folder is not added to Studio.' ) );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need both getSiteByFolder and this validation, I understand we want to search the site in appdata to make the changes, so we could remove getSiteByFolder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call 👍

@@ -0,0 +1,247 @@
import { arePathsEqual } from 'common/lib/fs-utils';
import { SiteCommandLoggerAction as LoggerAction } from 'common/logger-actions';
Copy link
Contributor

Choose a reason for hiding this comment

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

lint shows warning 'LoggerAction' is defined but never used.

try {
await lockAppdata();
const appdata = await readAppdata();
const site = appdata.sites.find( ( site ) => arePathsEqual( site.path, sitePath ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as my comment on set-domain

@fredrikekelund
Copy link
Contributor Author

Adding a custom domain for a running site isn't working for me, likely because await setupCustomDomain( site, logger ); is using the site from const site = await getSiteByFolder( sitePath, false ); that doesn't have a customDomain.

Good catch 👍 I've updated the PR accordingly

Copy link
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

Minor issue I noticed:

  • When changing the domain of a site that already has a custom domain, we prompt for the admin password, twice.
    We could avoid this by doing the change in one step "replace domain" instead of remove first and add later.
    What do you think?

Code looks good and works as expected 👍

@fredrikekelund
Copy link
Contributor Author

When changing the domain of a site that already has a custom domain, we prompt for the admin password, twice

I agree, this is annoying. I created STU-1077 to fix this in a follow-up PR

@fredrikekelund fredrikekelund merged commit 6b374a6 into trunk Dec 2, 2025
8 of 9 checks passed
@fredrikekelund fredrikekelund deleted the f26d/cli-site-set-domain-https branch December 2, 2025 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants