Skip to content

Conversation

brandonpayton
Copy link
Member

Motivation for the change, related issues

It is impossible (or at least awkward) to test the Playground CLI --auto-mount option locally using the npx nx unbuilt-jspi playground-cli family of commands. The reason is that --auto-mount tries to auto mount the current working directory, but those commands must be executed with the Playground source directory.

For this case, it would be useful to be able to pass a path to the --auto-mount option.

In addition, it is more powerful and flexible for to regular users to be able to pass an explicit --auto-mount=path.

Implementation details

This PR:

  • Changes the type of the --auto-mount option to a string.
  • Updates the --auto-mount yargs description.
  • Updates runCLI() to default auto-mount to the current working directory if --auto-mount is specific but no path is provided.
  • Adds tests passing an explicit path to auto-mount.

Testing Instructions (or ideally a Blueprint)

  • CI

type: 'boolean',
default: false,
describe: `Automatically mount the specified directory. If no path is provided, mount the current working directory. You can mount a WordPress directory, a plugin directory, a theme directory, a wp-content directory, or any directory containing PHP and HTML files.`,
type: 'string',
Copy link
Member

Choose a reason for hiding this comment

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

The auto in the name now seems to kind of lose its semantics:

  • The --auto-mount variant without the path looks fine because it "automatically mounts the CWD".
  • The --auto-mount=path makes me wonder what the difference is from --mount=path. In other words, what's the "auto" for, and why do we need that in addition to --mount=path.

Copy link
Member

@JanJakes JanJakes Aug 20, 2025

Choose a reason for hiding this comment

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

Or maybe the "auto" means that it automatically resolves the mount target? Sorry, I don't know the semantics of these arguments.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the meaning of auto is to resemble what wp-now does, i.e. if it's a plugin directory, mount it in wp-content/plugins, if it's a theme, in wp-content/themes etc.

Copy link
Member

@JanJakes JanJakes left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@akirk
Copy link
Member

akirk commented Aug 22, 2025

I wonder, given @JanJakes point, whether we could also achieve the same using a environment variable and thus not modifying the semantics? For example:

AUTOMOUNT_DIR=~/abc npx nx unbuilt-jspi playground-cli --auto-mount

@JanJakes
Copy link
Member

@akirk Now that I understand the difference between --auto-mount and --mount, I like how this PR approaches this:

  • --auto-mount: The behavior remains the same.
  • --auto-mount=dir: We can specify the directory (a different "auto-mount root").

Do you see any advantages to using AUTOMOUNT_DIR, or is it more like it feels semantically better? I like that in this PR, the auto mount configuration is in a single place and handled by a single flag.

@akirk
Copy link
Member

akirk commented Aug 22, 2025

My concern is that we're too complex in options but I guess this is already the case before this modification. Now that I think more about it, this solution makes a lot of sense if you wanted to automount multiple directories.

Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

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

I'm ok with this change!

@brandonpayton
Copy link
Member Author

@akirk and @JanJakes thanks for all your feedback.

Now that I think more about it, this solution makes a lot of sense if you wanted to automount multiple directories.

We don't currently support auto-mounting multiple directories, but depending on which directories folks want to auto-mount, we could consider implementing that in the future.

@brandonpayton brandonpayton merged commit dd57ceb into trunk Aug 22, 2025
26 checks passed
@brandonpayton brandonpayton deleted the support-auto-mount-path-arg branch August 22, 2025 16:57
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