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

refactor(catalog): split to separate files, add tests #1467

Merged

Conversation

timofei-iatsenko
Copy link
Collaborator

packages/cli/src/api/catalog.ts was a big god module doing everything. I slowly split it to separate atomic functions covered with unit tests to make them more resusable and testable.

Key changes:

  1. Formatters now responsible for handling errors while reading / writing files. Means it enough to write format.write() or format.read() without additional boilerplate to handle ENOENT or EEXIST errors. Make usage cleaner. Corresponding tests added.
  2. All getCatalogs family methods extracted to separate file. Removed code duplication between them.
  3. mergeCatalog extracted, and separate test written
  4. extractFromFiles extracted, separate test not written, but it's covered from thru Catalog.makemethod
  5. types extracted from Catalog file to separate file.

@vercel
Copy link

vercel bot commented Feb 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 27, 2023 at 10:39AM (UTC)

@github-actions
Copy link

github-actions bot commented Feb 24, 2023

size-limit report 📦

Path Size
./packages/core/build/esm/index.js 1.72 KB (0%)
./packages/detect-locale/build/esm/index.js 812 B (0%)
./packages/react/build/esm/index.js 1.79 KB (0%)
./packages/remote-loader/build/esm/index.js 7.25 KB (0%)

@timofei-iatsenko timofei-iatsenko changed the title ref(catalog): split to separate files, add tests refactor(catalog): split to separate files, add tests Feb 24, 2023
@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Base: 74.04% // Head: 74.04% // No change to project coverage 👍

Coverage data is based on head (df28bce) compared to base (1f5bf69).
Patch coverage: 86.46% of modified lines in pull request are covered.

❗ Current head df28bce differs from pull request most recent head 50ac2a7. Consider uploading reports for the commit 50ac2a7 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #1467   +/-   ##
=======================================
  Coverage   74.04%   74.04%           
=======================================
  Files          75       78    +3     
  Lines        1961     1961           
  Branches      526      523    -3     
=======================================
  Hits         1452     1452           
+ Misses        386      385    -1     
- Partials      123      124    +1     
Impacted Files Coverage Δ
...s/cli/src/api/catalog/getTranslationsForCatalog.ts 96.42% <ø> (ø)
packages/cli/src/api/formats/index.ts 60.00% <ø> (ø)
packages/cli/src/api/formats/minimal.ts 17.64% <0.00%> (+1.85%) ⬆️
packages/cli/src/api/stats.ts 90.00% <ø> (ø)
packages/cli/src/lingui-compile.ts 34.17% <ø> (ø)
packages/cli/src/lingui-extract-template.ts 55.00% <ø> (ø)
packages/cli/src/lingui-extract.ts 18.82% <ø> (ø)
packages/cli/src/tests.ts 77.14% <ø> (-2.86%) ⬇️
packages/cli/src/api/formats/po-gettext.ts 74.03% <60.00%> (+1.48%) ⬆️
packages/cli/src/api/utils.ts 66.66% <76.92%> (+6.66%) ⬆️
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@timofei-iatsenko
Copy link
Collaborator Author

@Martin005 @andrii-bodnar any updates?

@timofei-iatsenko
Copy link
Collaborator Author

@Martin005

@andrii-bodnar andrii-bodnar merged commit e1fede8 into lingui:next Feb 28, 2023
@timofei-iatsenko timofei-iatsenko deleted the refactoring/split-catalog branch February 28, 2023 13:16
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