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

fix: javascript workspace bugs #1309

Merged
merged 6 commits into from
Aug 13, 2024
Merged

fix: javascript workspace bugs #1309

merged 6 commits into from
Aug 13, 2024

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented Aug 9, 2024

Use the [dist] section package dist.tomls, and add errors for cases where a metadata.dist exists but is being ignored.

Also handles npm package scopes better.

Also handles url equality checks better.

fixes #1308
fixes #1307

And add errors for cases where a metadata.dist exists but is being ignored.
@Gankra
Copy link
Contributor Author

Gankra commented Aug 9, 2024

currently missing: a checked in test that stresses this (did some local edits to axolotlsay-hybrid to smoke test, but we need a real test before landing)

/// Path to a dist.toml overriding this package's contents
///
/// NOTE: this WILL be the same path as the manifest_path for a pure dist.toml
/// package. Don't assume these are disjoint!
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason people might assume they are disjoint beyond that they are 2 diff vars? and if so what's the consequence? besides... being wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code like init which loads up some state, edits it, and then writes it back could go sideways if it's too clever about batching edits / caching state, but forgets that these "two" files are the same one.

This is not a problem with the current impl.

Copy link
Member

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

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

lgtm modulo a few questions- mostly want to avoid forcing a migration with this release

@@ -465,6 +465,18 @@ pub enum DistError {
/// Error messsage details
message: String,
},

/// Something has metadata.dist but shouldn't
#[error("The metadata.dist entry in this Cargo.toml isn't being used:\n{manifest_path}")]
Copy link
Member

Choose a reason for hiding this comment

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

love this

@@ -846,6 +846,22 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> {
) -> DistResult<Self> {
let root_workspace_idx = workspaces.root_workspace_idx();
let root_workspace = workspaces.workspace(root_workspace_idx);

// Complain if someone still has [workspace.metadata.dist] in a dist-workspace.toml scenario
if let Some(dist_manifest_path) = root_workspace.dist_manifest_path.as_deref() {
Copy link
Member

Choose a reason for hiding this comment

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

are we turning this on now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code only runs if someone has migrated to dist-workspace.toml, so this is basically just erroring on "it looks like you started a migration but I see some gunk you missed".

@Gankra Gankra changed the title fix: use the [dist] section in package dist.tomls fix: javascript workspace bugs Aug 9, 2024
fn merge_package_with_raw_generic(
package: &mut PackageInfo,
generic: Package,
generic_path: Utf8PathBuf,
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarifying what generic_path here is in a comment might be nice

/// Path to the dist.toml or dist-workspace.toml for the workspace
///
/// If this is ever set, then this will be the same as manifest_path.
pub dist_manifest_path: Option<Utf8PathBuf>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it true that this is the same as manifest_path for a package.json/Cargo.toml workspace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "if this is ever set" clause is doing heavy lifting here. Basically this option is morally a boolean saying manifest_path might be a dist(-workspace).toml, but I decided to make it an option to make code that deals with the pacakge version of dist_manifest_path uniform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or i guess to put it another way -- if this is ever set, it's shared/generic workspace.

@Gankra Gankra merged commit c8ae68c into main Aug 13, 2024
16 checks passed
@Gankra Gankra deleted the use-package-dist branch August 13, 2024 19:47
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.

dist.toml's [dist] section is never read for packages Make repository-url-sameness check more robust
3 participants