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

Add --immutable arg #164

Merged
merged 5 commits into from
Jan 10, 2025
Merged

Add --immutable arg #164

merged 5 commits into from
Jan 10, 2025

Conversation

chrisdothtml
Copy link
Contributor

@chrisdothtml chrisdothtml commented Jan 9, 2025

Adds a new --immutable arg to the install command so that it has parity with how yarn behaves with --immutable with regard to generated files.

Currently, in "immutable" cases (i.e. when running jz ci), jazelle skips the file generation altogether (.bazelignore and BUILD.bazel files).

This PR changes it so that when --immutable is passed (either explicitly via jz install --immutable or implicitly via jz ci), it will run the file generation, but fail if any files need to be created/changed. In the failure case it emits an error message listing the files that would have changed.

This is what it looks like to a user when it fails:
Screenshot 2025-01-10 at 11 24 41 AM

@@ -104,7 +104,7 @@ const sortCallArgItems /*: SortCallArgItems */ = (code, caller, argName) => {
.filter(Boolean)
.sort()
.join(',');
return `[${sorted},${dedent}]`.replace(/,]/, ']');
return `[${sorted},${dedent}]`.replace(/,]/, ']').replace(/\[,/, '[');
Copy link
Contributor Author

@chrisdothtml chrisdothtml Jan 10, 2025

Choose a reason for hiding this comment

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

There was a bug in this util that was generating a dangling comma in the deps list for BUILD.bazel files which looked like this:

web_library(
    name = "library",
    deps = [,
        
    ],
    srcs = glob(["**"], exclude = ["dist/**"]),
)

This was necessary to fix the testBatchTestGroup test (its behavior changed after my update because it internally calls an immutable install, which was failing due to changed generated files)

@chrisdothtml chrisdothtml marked this pull request as ready for review January 10, 2025 19:57
@chrisdothtml chrisdothtml requested a review from lhorie January 10, 2025 20:01
@chrisdothtml chrisdothtml merged commit 3ddd5e7 into main Jan 10, 2025
5 checks passed
@chrisdothtml chrisdothtml deleted the immutable-arg branch January 10, 2025 23:13
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.

2 participants