openedx / openedx-atlas

An Open edX CLI tool for moving translation files from openedx-translations
GNU Affero General Public License v3.0
3 stars 7 forks source link

feat: accept multiple directories with destination for each #13

Closed OmarIthawi closed 1 year ago

OmarIthawi commented 1 year ago

Description

Remove the --directory argument in favor of the positional arguments DIRECTORY ... to allow multiple directories to be specified in a single step. This is useful for pulling a huge batch of XBlocks into edX Platform or components in MFEs in a single checkout operation.

Breaking Changes and Developer Experience

One of the primary goals of the project is to avoid breaking changes. However, this pull request breaks compatibility with current (if any) usage of atlas due to the change from --directory argument to DIRECTORY... positional argument.

The main driver behind this change is to allow breaking the command into multiple lines, in which the --directory argument wouldn't support:

$ atlas pull translations/frontend-app-learning/:learning-mfe \
            translations/frontend-component-header/src/i18n/messages:frontend-component-header

Testing

Argument description

DIRECTORY... represents one or more directory map pair separated by a colon (:) e.g. FROM_DIR:TO_DIR:

Design

In order for this to work, an extensive "matrix" of git sparse-checkout rules are added to filter for each DIRECTORY and --filter:

# Include directories that matches the language pattern e.g. `/ar/`
git sparse-checkout add "$directory_from/**/${one_filter}/**"
# Include files that matches the language pattern e.g. `ar.*`
git sparse-checkout add "$directory_from/**/${one_filter}.*"

For example, two directories and three languages would result into 12 rules.

 1. translations/frontend-app-learning/src/i18n/messages/**/fr_CA/**
 2. translations/frontend-app-learning/src/i18n/messages/**/fr_CA.*
 3. translations/frontend-app-learning/src/i18n/messages/**/ar/**
 4. translations/frontend-app-learning/src/i18n/messages/**/ar.*
 5. translations/frontend-app-learning/src/i18n/messages/**/es_419/**
 6. translations/frontend-app-learning/src/i18n/messages/**/es_419.*
 7. translations/frontend-component-footer/src/i18n/messages/**/fr_CA/**
 8. translations/frontend-component-footer/src/i18n/messages/**/fr_CA.*
 9. translations/frontend-component-footer/src/i18n/messages/**/ar/**
10. translations/frontend-component-footer/src/i18n/messages/**/ar.*
11. translations/frontend-component-footer/src/i18n/messages/**/es_419/**
12. translations/frontend-component-footer/src/i18n/messages/**/es_419.*

Example call

$ cd frontend-app-learning/src/i18n/messages
$ atlas pull --filter=fr_CA,ar,es_419 \
            translations/frontend-app-learning/src/i18n/messages:frontend-app-learning \
            translations/frontend-component-header/src/i18n/messages:frontend-component-header

Will result in the following tree:

├── frontend-app-learning
│   ├── ar.json
│   ├── es_419.json
│   └── fr_CA.json
└── frontend-component-header
    ├── ar.json
    ├── es_419.json
    └── fr_CA.json

References

This pull request is part of the FC-0012 project which is sparked by the Translation Infrastructure update OEP-58.

Check the links above for full information about the overall project.

Internalization is being rearchitected in Open edX Python, XBlock, Micro-frontend, and other projects. There are a number of immediately visible changes:

openedx-webhooks commented 1 year ago

Thanks for the pull request, @OmarIthawi! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

openedx-webhooks commented 1 year ago

@OmarIthawi 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.