Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Related to #1547: use dioxus-cli within a workspace (wildcard-members, real package names) #1642

Conversation

RGafiyatullin
Copy link
Contributor

@RGafiyatullin RGafiyatullin commented Nov 15, 2023

(Related to #1547)

Although the dx CLI allows to specify a package name to chose from workspace members, it does not support workspace members specified as glob-wildcards. Neither it respects the effective package name, specified in the crate's Cargo.toml.

This PR addresses that issue:

  • upon dx build ..., if the --bin CLI-argument is provided, treat the current dir as a workspace;
  • search through the workspace's members: resolve each of them with glob;
  • assume that any workspace member has a Cargo.toml in it (cargo does it, so it's okay);
  • read said manifest, and check the package name in it;
  • if found — there we have our sought package.

Although the `dx` CLI allows to specify a package name to chose from workspace members,
it does not support workspace members specified as glob-wildcards.
Neither it respects the effective package name, specified in the crate's `Cargo.toml`.

This PR addresses that issue:
- upon `dx build ...`, if the `--bin` CLI-argument is provided, treat the current dir as a workspace;
- search through the workspace's `members`: resolve each of them with `glob`;
- assume that any workspace member has a `Cargo.toml` in it (cargo does it, so it's okay);
- read said manifest, and check the package name in it;
- if found — there we have our sought package.
@RGafiyatullin RGafiyatullin changed the title Related to #1547: use dioxus-cli within a workspace Related to #1547: use dioxus-cli within a workspace (wildcard-members, real package names) Nov 15, 2023
@ealmloff
Copy link
Member

ealmloff commented Nov 15, 2023

It seems like this handles workspace names much better!

I'm curious what your use case is for glob patterns for the bin field?

I realize this PR doesn't introduce this error, but as a note, we don't actually need to assume that the current directory is the root of the package. We can use cargo-metadata to get the members of the workspace associated with the current path (even if we are in a different workspace member) https://docs.rs/cargo_metadata/latest/cargo_metadata/struct.Metadata.html#method.workspace_packages

@RGafiyatullin
Copy link
Contributor Author

@ealmloff , I agree: invoking cargo-metadata should simplify the things.

I'm curious what your use case is for glob patterns for the bin field?

I do not use wildcards for the bin field, I use them to specify member-crates of a workspace.
E.g.

members = [
  "crates/lib/*",
  "crates/app/*"
]

@ealmloff
Copy link
Member

Interesting, I didn't know that the workspace field had glob support!

@ealmloff ealmloff added enhancement New feature or request cli Related to the dioxus-cli program labels Nov 15, 2023
@RGafiyatullin
Copy link
Contributor Author

I had a look at how the rest of the CLI works: a lot of it could use moving to cargo-metadata...

Copy link
Member

@ealmloff ealmloff left a comment

Choose a reason for hiding this comment

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

This looks much better, thank you!

@ealmloff ealmloff merged commit 0986890 into DioxusLabs:master Nov 15, 2023
10 checks passed
@RGafiyatullin RGafiyatullin deleted the issues-1547-workspace-support--members-as-wildcards-and-with-proper-package-name branch November 15, 2023 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the dioxus-cli program enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants