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 assets clean lookups #474

Merged
merged 3 commits into from
May 16, 2024
Merged

Fix assets clean lookups #474

merged 3 commits into from
May 16, 2024

Conversation

tomdracz
Copy link
Collaborator

@tomdracz tomdracz commented May 10, 2024

Summary

Fixes lookup for assets:clean tasks

The task was trying to group files but ended up lumping map and compressed files together that ended up with incorrect deletion.

Changes the regex grouping to group file by full .js.map.br for example rather than just .js to prevent incorrect deletion.

Think this will also address rails/webpacker#2913 issues like reported here

Pull Request checklist

  • Add/update test to cover these changes
  • Update documentation
  • Update CHANGELOG file

Summary by CodeRabbit

  • New Features
    • Improved file extension recognition to handle complex formats.
  • Bug Fixes
    • Adjusted handling of compressed and map files to ensure accurate file paths and modification times.
  • Chores
    • Fixed incorrect file removal in the assets:clean task.

Copy link

coderabbitai bot commented May 10, 2024

Walkthrough

The recent updates in the shakapacker library involve refining the regex for file extension extraction in commands.rb to handle multi-dot scenarios more accurately. Additionally, in command_spec.rb, adjustments were made to the timestamps and paths for various compressed and map files, standardizing the modification times across several JavaScript files.

Changes

File Path Change Summary
lib/shakapacker/commands.rb Improved regex for capturing file extensions.
spec/shakapacker/command_spec.rb Standardized timestamps for compressed and map files. Files ending in .br, .gz, and .map now have synchronized modification times.

🐇💻
A hop through code, a leap through time,
Regex now catches, every dot and line.
Compressed files, in their place,
Timely updates, in the digital space.
Cheers to changes, small and big,
Signed with a paw, not a fig! 🎉🥕


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (2)
lib/shakapacker/commands.rb (1)

64-64: Refine the regex to handle complex file extensions more accurately.

Consider adding a comment explaining the regex for future maintainability.

spec/shakapacker/command_spec.rb (1)

Line range hint 49-76: Enhance the test setup for handling compressed and map files.

Consider adding more explicit assertions to verify the correct handling of compressed and map files.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1a89919 and 23c0eb5.
Files selected for processing (2)
  • lib/shakapacker/commands.rb (1 hunks)
  • spec/shakapacker/command_spec.rb (2 hunks)

lib/shakapacker/commands.rb Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 23c0eb5 and e288981.
Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • lib/shakapacker/commands.rb (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • lib/shakapacker/commands.rb
Additional Context Used
LanguageTool (51)
CHANGELOG.md (51)

Near line 1: ‘prior to’ might be wordy. Consider a shorter alternative.
Context: * For the changelog of versions prior to v6, see the [5.x stable branch of rails...


Near line 4: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...grading to new spelling in version 7. * Please see the [v6 Upgrade Guide](./docs/v6_up...


Near line 4: ‘prior to’ might be wordy. Consider a shorter alternative.
Context: ...docs/v6_upgrade.md) to go from versions prior to v6. * [ShakaCode](https://www.shakacode...


Near line 45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...G-Rath. - Remove https option for webpack-dev-server...


Near line 47: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...G-Rath. - Remove verify_file_existance method [PR 446]...


Near line 64: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ad of errors when compilation is success but stderr is not empty. [PR 416](https://g...


Near line 67: You’ve repeated a verb. Did you mean to only write one of them?
Context: ...G-Rath](https://github.com/g-rath) ### Removed - Removes dependency on glob library. [PR 435](...


Near line 73: Possible missing article found.
Context: ...viously this could have been ignored in few code branches, especially when checking...


Near line 110: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...acker/pull/363). ## [v7.0.3] - July 7, 2023 ### Fixed - Fixed commands execution fo...


Near line 111: Possible typo: you repeated a word
Context: ...l/363). ## [v7.0.3] - July 7, 2023 ### Fixed - Fixed commands execution for projects with sp...


Near line 114: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...b.com/kukicola). ## [v7.0.2] - July 3, 2023 ### Fixed - Fixed creation of assets:pr...


Near line 115: Possible typo: you repeated a word
Context: ...icola). ## [v7.0.2] - July 3, 2023 ### Fixed - Fixed creation of assets:precompile if it is ...


Near line 118: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...com/ahangarha). ## [v7.0.1] - June 27, 2023 ### Fixed - Fixed the condition for sho...


Near line 119: Possible typo: you repeated a word
Context: ...arha). ## [v7.0.1] - June 27, 2023 ### Fixed - Fixed the condition for showing warning for s...


Near line 122: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...com/ahangarha). ## [v7.0.0] - June 23, 2023 ### Breaking changes - Removes defaults...


Near line 126: Possible missing comma found.
Context: ...ery file in the codebase was treated as TSX leading to potential issues. This has b...


Near line 126: Possible missing article found.
Context: ...s. This has been removed and returns to sensible default of the preset which is to figur...


Near line 126: Possible missing comma found.
Context: ... and returns to sensible default of the preset which is to figure out the file type fr...


Near line 126: Possible missing comma found.
Context: ...is change might affect generated output however so it is marked as breaking. - Export ...


Near line 150: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...dracz](https://github.com/tomdracz). Prior to this change, top level directory of sta...


Near line 150: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...com/tomdracz). Prior to this change, top level directory of static assets like images ...


Near line 150: Possible missing article found.
Context: ...and fonts was stripped. This meant that file in app/javascript/images/image.png wo...


Near line 152: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...tic/image.jpg")`. Going forward, the top level directory of static files will be retai...


Near line 152: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...rectory of static files will be retained so this will necessitate the update of fil...


Near line 159: Possible missing comma found.
Context: ...ery file in the codebase was treated as TSX leading to potential issues. This has b...


Near line 159: Possible missing article found.
Context: ...s. This has been removed and returns to sensible default of the preset which is to figur...


Near line 159: Possible missing comma found.
Context: ... and returns to sensible default of the preset which is to figure out the file type fr...


Near line 159: Possible missing comma found.
Context: ...is change might affect generated output however so it is marked as breaking. - Fixed R...


Near line 163: You’ve repeated a verb. Did you mean to only write one of them?
Context: ...arha](https://github.com/ahangarha) ### Removed - Remove redundant enhancement for precompile ta...


Near line 167: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...com/ahangarha). ## [v6.6.0] - March 7, 2023 ### Improved - Allow configuration of w...


Near line 171: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...alecslupu). ## [v6.5.6] - February 11, 2023 ### Fixed - Fixed failing to update `bi...


Near line 172: Possible typo: you repeated a word
Context: ...). ## [v6.5.6] - February 11, 2023 ### Fixed - Fixed failing to update bin/setup file due ...


Near line 190: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...m/tagliala). ## [v6.5.4] - November 4, 2022 ### Fixed - Fixed regression caused by ...


Near line 191: Possible typo: you repeated a word
Context: ...a). ## [v6.5.4] - November 4, 2022 ### Fixed - Fixed regression caused by 6.5.3. PR #192 int...


Near line 224: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ....com/pulkitkkr). ## [v6.5.0] - July 4, 2022 ### Added - `append_stylesheet_pack_tag...


Near line 231: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...ub.com/artemave) ## [v6.4.1] - June 5, 2022 ### Fixed - Restores automatic installa...


Near line 239: Unpaired symbol: ‘[’ seems to be missing
Context: ...ttps://github.com/tomdracz). ## [v6.4.0] - June 2, 2022 ### Fixed - Fixed [Issue...


Near line 239: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...b.com/tomdracz). ## [v6.4.0] - June 2, 2022 ### Fixed - Fixed [Issue 123: Rails 7.0...


Near line 240: Possible typo: you repeated a word
Context: ...dracz). ## [v6.4.0] - June 2, 2022 ### Fixed - Fixed [Issue 123: Rails 7.0.3 - Webpacker con...


Near line 244: ‘prior to’ might be wordy. Consider a shorter alternative.
Context: ...se nested entries. This was the default prior to v6.0. Because entries maybe generated, ...


Near line 249: If this is a question, use a question mark.
Context: ...tasks/yarn.rake) in your own application. ## [v6.3.0] - May 19, 2022 ### Improv...


Near line 266: The phrase “a variety of” may be wordy. To make your writing clearer, consider replacing it.
Context: ...e mode can affect how your code runs in a variety of ways, but in newer versions of Babel it...


Near line 270: You’ve repeated a verb. Did you mean to only write one of them?
Context: ... change probably won't affect you. ### Added - Adds webpacker_precompile setting to `webp...


Near line 277: The modal verb ‘will’ requires the verb’s base form.
Context: ...timestamp will be checked together will timestamps of all files and directories inside of ...


Near line 279: Possible missing comma found.
Context: ... in improved compiler checks performance but might be breaking for certain setups an...


Near line 284: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...com/tomdracz). ## [v6.2.1] - April 15, 2022 ### Fixed - Put back config.public_mani...


Near line 298: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...ple invocations of stylesheet_pack_tag (eg for a regular stylesheet & a print styl...


Near line 306: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...m/tomdracz). ## [v6.1.0] - February 4, 2022 ### Added - Support for SWC loader. [PR...


Near line 313: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: .../pull/2802). ## [v6.0.2] - January 25, 2022 ### Improved - Fix incorrect command na...


Near line 317: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...tricknotes). ## [v6.0.1] - January 24, 2022 ### Improved - PR #21 removed pnp-webpa...


Near line 350: Use a comma before ‘or’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...r environment.js, this must be removed or you will receive an error (`Item nodeMo...

@@ -10,6 +10,10 @@ _next_ branch is for v8 changes
## [Unreleased]
Changes since the last non-beta release.

### Fixed

- Fixes incorrect removal of files in the assets:clean task [PR 474](https://github.com/shakacode/shakapacker/pull/474) by [tomdracz](https://github.com/tomdracz).
Copy link

Choose a reason for hiding this comment

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

Ensure consistency in list item markers.

- - Fixes incorrect removal of files in the assets:clean task [PR 474](https://github.com/shakacode/shakapacker/pull/474) by [tomdracz](https://github.com/tomdracz).
+ * Fixes incorrect removal of files in the assets:clean task [PR 474](https://github.com/shakacode/shakapacker/pull/474) by [tomdracz](https://github.com/tomdracz).

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
- Fixes incorrect removal of files in the assets:clean task [PR 474](https://github.com/shakacode/shakapacker/pull/474) by [tomdracz](https://github.com/tomdracz).
* Fixes incorrect removal of files in the assets:clean task [PR 474](https://github.com/shakacode/shakapacker/pull/474) by [tomdracz](https://github.com/tomdracz).

@justin808 justin808 merged commit bc09740 into main May 16, 2024
35 checks passed
@justin808 justin808 deleted the fix-assets-clean branch May 16, 2024 03:32
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.

3 participants