Skip to content

fix: execute cli commands from project root #20

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

Merged
merged 21 commits into from
Mar 17, 2025
Merged

Conversation

andrew-fenton
Copy link
Contributor

@andrew-fenton andrew-fenton commented Mar 2, 2025

Previously, CLI commands would execute relative to the user's current directory. Now, CLI commands execute from the project root directory regardless of the user's current directory.

Functionality added:

  • Function to find project root
  • Block users from executing CLI commands before running setup
  • Block users from executing setup more than once (unless diff_state folder is deleted).

The main files where relevant changes occurred are:

  • i18nilize/src/internationalize/command_line.py
  • i18nilize/src/internationalize/package_init_utils.py
  • i18nilize/src/internationalize/project_root_utils.py

The rest of the changes were to adapt components and tests to use the dynamically set project root variable instead of hardcoded values.

Note: my IDE formats files when saving so the diff shows a lot of unrelated changes to formatting, my bad 😅

@andrew-fenton andrew-fenton requested a review from Copilot March 2, 2025 04:27
Copy link

@Copilot 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.

PR Overview

This PR ensures that CLI commands execute from the project’s root directory rather than the user’s current directory. Key changes include:

  • Adding project root detection functions and integrating them into the CLI initialization.
  • Updating project setup and translation state management via the diff_state directory.
  • Refactoring installation and synchronization processes across multiple modules.

Reviewed Changes

File Description
i18nilize/src/internationalize/project_root_utils.py Added functions to locate and return the project root directory.
core/Pipfile Introduced dependency specifications and Python version definition.
i18nilize/src/internationalize/package_init_utils.py Added functions to initialize and validate the package setup.
setup.py Updated custom install command and project root detection logic.
i18nilize/src/internationalize/globals.py Updated global config values and endpoint definitions.
i18nilize/src/internationalize/diffing_processor.py Refactored DiffingProcessor for diff state management and file syncing.
i18nilize/src/internationalize/sync_processor.py Updated pull and push translation logic with consistent path usage.
i18nilize/src/internationalize/command_line.py Updated CLI command parsing and initialization to use the project root.

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

i18nilize/src/internationalize/diffing_processor.py:68

  • Prefer using 'is None' instead of '== None' for comparisons with None.
if hash_dict == None:

i18nilize/src/internationalize/diffing_processor.py:191

  • Avoid using 'type' as a parameter name because it shadows the built-in function 'type'. Consider renaming it to something like 'template_type'.
def __initialize_changed_template(self, type):

i18nilize/src/internationalize/diffing_processor.py:90

  • The word 'occured' is misspelled; please change it to 'occurred'.
print(f"An exception occured: {e}")

@andrew-fenton andrew-fenton marked this pull request as ready for review March 8, 2025 03:17
@andrew-fenton andrew-fenton merged commit 57c30f1 into main Mar 17, 2025
1 check passed
@andrew-fenton andrew-fenton deleted the set_package_root branch March 17, 2025 14:18
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