-
Notifications
You must be signed in to change notification settings - Fork 471
Be more aware of the workspace during clean #7752
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if something doesn't make any sense.
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/win32-x64
commit: |
I think it might make sense to rethink the format command as well. Would it not be more consistent if we format either:
The |
Agreed, defaulting to all / keeping args similar to build/clean definitely makes sense! |
There still is more work to do here.
Running
I also think that if there is no link with package and repository rescript, For the time being if there is a workspace rescript.json, that "suffix" is primary. Post v12 we can explore the option to override suffix in child packages, but it is my understanding that it doesn't work that way today. I'm also in favour of renaming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances workspace awareness during the clean command by introducing a ProjectContext
enum that better categorizes project structures (single project, monorepo root, or monorepo package). The key improvement is that when cleaning from within a monorepo package, only files belonging to that specific package are removed rather than cleaning the entire workspace.
- Introduces a new
ProjectContext
enum to categorize project relationships and scope operations accordingly - Refactors the clean command to respect workspace boundaries and only clean relevant packages
- Removes the
--all
flag from the format command, making it the default behavior when no files are specified
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
rewatch/src/project_context.rs | Adds new ProjectContext enum and logic to determine workspace relationships |
rewatch/src/build/clean.rs | Updates clean operations to use ProjectContext for scoped cleaning |
rewatch/src/format.rs | Removes --all flag and uses ProjectContext for scoped formatting |
rewatch/src/cli.rs | Removes --all flag from format command CLI definition |
rewatch/src/build/packages.rs | Refactors dependency reading to use ProjectContext instead of workspace_root |
rewatch/src/build/build_types.rs | Updates BuildState to use ProjectContext and adds get_root_package method |
rewatch/src/helpers.rs | Adds is_local_package helper and updates get_rescript_legacy function |
rewatch/src/main.rs | Updates format command call to remove all parameter |
rewatch/src/lib.rs | Adds project_context module |
Multiple build files | Updates function signatures to use ProjectContext instead of separate workspace parameters |
This is an attempt to drive the conversation at #7707
In case of clean, we already do an upward traversal to find a root rescript json.
I'm adding some logic to check if the parent rescript json contains the current rescript json in "dependencies" (or "dev-dependencies").
If we did find a link, we would only remove the files from the current project and not everything.
Consider https://github.com/nojaf/rescript-kaplay/blob/main/packages/rescript-kaplay/rescript.json
We already find https://github.com/nojaf/rescript-kaplay/blob/d38649fcd409c174c39b31488f790e036f3b0a20/rescript.json#L8
If that name matches
root_package
(in the code, a bit confusing name) is"@nojaf/rescript-kaplay"
, so we only need to remove those files.Files from https://github.com/nojaf/rescript-kaplay/blob/main/packages/samples/rescript.json are unaffected.
If we were to clean from the repo root,
root_config
would be the well the root package and everything gets cleaned.