Skip to content

Conversation

@kartik0905
Copy link

This PR introduces the initial scaffolding and implementation for the new lingo fix command, as tracked in issue #1156. This command is designed to automatically find and fix common issues in lingo files.

This initial PR is intentionally scoped small and includes:

The core fix command scaffolding within the CLI.

A global --dry-run option, which allows users to see what changes would be made without modifying any files.

The first fixer implementation: a fixer to automatically remove UTF-8 BOM characters from files.

To Test:

  • Pull down the branch and build the CLI.
  • Create a test file that is saved with a UTF-8 BOM (many code editors like VS Code or Notepad++ have an option to save a file as "UTF-8 with BOM").
  • Test the "dry run" mode: lingo fix ./path/to/your/file.json --dry-run
  • Then to test the files changes and all i have run this command: cd packages/cli/demo/json and node ../../bin/cli.mjs fix --dry-run

Screenshot
Screenshot 2025-10-29 at 9 54 07 PM

What We Have Done in the Code (The Implementation):

  1. Added a New Command: You have registered a new top-level command called lingo fix in your command-line application (CLI).
  2. Built the "Scaffolding": You've created the basic code structure for this command. This means you've set up the argument parsing and the main function that will run one or more "fixers" on the user's files.
  3. Created a --dry-run Option: You have added a specific flag (or "option") called --dry-run. Your code will have if statements that check if this flag is present. If it is, the code will skip the part that saves changes to the disk.
  4. Wrote the First Fixer (BOM Fixer): You've written the first piece of active logic. This is a function that:
  • Reads the bytes of a file.
  • Checks if the first few bytes match the specific signature of a UTF-8 BOM (Byte Order Mark).
  • If they do, it returns the rest of the file's content, effectively stripping the BOM from the beginning.

What Changes It Shall Do (The Behavior):
This is what will happen when a user runs your new command:

  1. When a user runs lingo fix ... --dry-run:
  • Your code will scan the specified files.
  • It will find files that have a BOM.
  • It will NOT change or save any files.
  • It will only print a report to the console, saying something like, "BOM found in file.json. (dry-run)."
  1. When a user runs lingo fix ... (without --dry-run):
  • Your code will scan the specified files.
  • If a file has a BOM: Your code will read it, remove the BOM, and then overwrite the original file with the new, clean content. It will then report that the file was "fixed."
  • If a file does NOT have a BOM: Your code will check it, find no issues, and do nothing to that file before moving on to the next one.

Implements issue lingodotdev#1156 by adding the scaffolding for the 'fix' command.

This first PR includes the --dry-run option and a fixer for removing BOM characters.

Subsequent PRs will add more fixers.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@sumitsaurabh927
Copy link
Contributor

@maxprilutskiy can you have a look here please?

@kartik0905
Copy link
Author

@maxprilutskiy Hey now i think this PR is upto date and ready to be merged as this resolve a good issue have a look at it please...Thanks...

@sumitsaurabh927
Copy link
Contributor

@kartik0905 please resolve the merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants