feat: add check sync | missing to lingui cli#2515
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2515 +/- ##
===========================================
+ Coverage 77.05% 88.83% +11.78%
===========================================
Files 84 125 +41
Lines 2157 3680 +1523
Branches 555 1088 +533
===========================================
+ Hits 1662 3269 +1607
+ Misses 382 369 -13
+ Partials 113 42 -71 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new lingui check CLI namespace to validate catalogs (missing translations and extract-sync drift) without producing compilation artifacts, while aligning missing-translation semantics with fallbackLocales and stabilizing PO serialization to make sync checks deterministic.
Changes:
- Introduces
lingui check sync(detects out-of-sync catalogs vsextractdry-run) andlingui check missing(fails on raw missing translations before fallbacks). - Updates strict-missing semantics across CLI compile, loader, and Vite plugin via
missingBehavior: "catalog". - Improves PO header normalization/order to preserve meaningful state and avoid noisy diffs; updates related fixtures/snapshots/tests.
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/ref/cli.md | Documents check commands and clarifies compile --strict semantics |
| packages/vite-plugin/test/vite-plugin.test.ts | Adds coverage for fail-on-missing with fallback locales |
| packages/vite-plugin/test/fail-on-missing-fallback/locale/en-US.po | Test fixture for fallback-missing scenario |
| packages/vite-plugin/test/fail-on-missing-fallback/locale/en-GB.po | Test fixture with a raw missing entry |
| packages/vite-plugin/test/fail-on-missing-fallback/lingui.config.js | Test config enabling fallbackLocales |
| packages/vite-plugin/test/fail-on-missing-fallback/entrypoint.js | Test entrypoint importing a PO file |
| packages/vite-plugin/src/index.ts | Uses missingBehavior: "catalog" for fail-on-missing checks |
| packages/loader/test/loader.test.ts | Adds coverage for fail-on-missing with fallback locales |
| packages/loader/test/fail-on-missing-fallback/locale/en-US.po | Loader test fixture for fallback-missing scenario |
| packages/loader/test/fail-on-missing-fallback/locale/en-GB.po | Loader test fixture with a raw missing entry |
| packages/loader/test/fail-on-missing-fallback/lingui.config.js | Loader test config enabling fallbackLocales |
| packages/loader/test/fail-on-missing-fallback/entrypoint.js | Loader test entrypoint importing a PO file |
| packages/loader/src/webpackLoader.ts | Uses missingBehavior: "catalog" for fail-on-missing checks |
| packages/format-po/src/po.ts | Stabilizes PO header normalization and deterministic header ordering |
| packages/format-po/src/po.test.ts | Adds tests for idempotent serialization and header preservation/merging |
| packages/cli/test/extractor-experimental/expected/index.page.pl.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental/expected/index.page.en.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental/expected/about.page.pl.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental/expected/about.page.en.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental-clean/expected/index.page.pl.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental-clean/expected/index.page.en.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental-clean/expected/about.page.pl.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extractor-experimental-clean/expected/about.page.en.po | Updates expected PO output (drops empty default headers) |
| packages/cli/test/extract-partial-consistency/expected/en.po | Updates expected PO output (drops empty default headers) |
| packages/cli/src/test/compile.test.ts | Adds strict missing test when fallbacks would resolve translation |
| packages/cli/src/test/checkTestUtils.ts | Shared helpers for check-command tests |
| packages/cli/src/test/check-sync.test.ts | Tests check sync behavior (dry-run extract parity) |
| packages/cli/src/test/check-registry.test.ts | Tests check registry resolution and option validation |
| packages/cli/src/test/check-missing.test.ts | Tests check missing semantics (raw missing, pseudo locale, filters) |
| packages/cli/src/test/check-cli.test.ts | Tests CLI program wiring for check |
| packages/cli/src/test/snapshots/compile.test.ts.snap | Updates snapshots for new strict/missing reporting/output |
| packages/cli/src/lingui.ts | Registers lingui check subcommand |
| packages/cli/src/lingui-compile.ts | Updates --strict help text/examples to match new semantics |
| packages/cli/src/lingui-check.ts | Implements lingui check CLI program runner and rendering |
| packages/cli/src/api/runBounded.ts | Adds bounded-concurrency helper for checks |
| packages/cli/src/api/resolveWorkersOptions.ts | Validates --workers input; preserves heuristic defaults |
| packages/cli/src/api/resolveWorkersOptions.test.ts | Adds test for rejecting non-numeric --workers |
| packages/cli/src/api/formats/formatterWrapper.ts | Adds serialize() to support dry-run comparisons; avoids writes when unchanged |
| packages/cli/src/api/formats/formatterWrapper.test.ts | Tests serialization without writing and write-if-changed behavior |
| packages/cli/src/api/findings.ts | Introduces shared finding shape for check results |
| packages/cli/src/api/compile/compileLocale.ts | Reuses shared missing-detection logic; improves verbose missing output formatting |
| packages/cli/src/api/check/types.ts | Defines check registry types, results, and findings |
| packages/cli/src/api/check/sync.ts | Implements sync check (extract dry-run vs existing files) |
| packages/cli/src/api/check/missing.ts | Implements missing check (raw missing before fallbacks) |
| packages/cli/src/api/check/index.ts | Implements check registry + option validation |
| packages/cli/src/api/catalog/translations.ts | Centralizes missing-detection + finding formatting for missing translations |
| packages/cli/src/api/catalog/getTranslationsForCatalog.ts | Adds missingBehavior option and raw-missing semantics |
| packages/cli/src/api/catalog/getTranslationsForCatalog.test.ts | Adds tests for raw-missing reporting with fallbacks enabled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…d formatter reads
Description
This PR adds a dedicated
lingui checkcommand for validating catalogs without writing output files.It is based on #2506 and should be merged after that PR.
It also closes #2195 by adding a CI-friendly way to check catalogs without running compilation.
Included in this PR:
lingui check missingto fail when translations are still missing afterfallbackLocalesare applied, matchinglingui compile --strictlingui check missing --mode catalogto fail on catalog-level missing translations beforefallbackLocalesare appliedlingui check syncto fail when catalogs are out of sync withlingui extractresolvedandcatalogmodesIn
packages/format-po/src/po.ts, PO serialization was updated to preserve meaningful existing header state, merge custom headers deterministically, and drop empty default gettext headers. This makes serialization more stable and avoids noisy diffs, which is important forcheck sync.Types of changes
Fixes #2195
Related to #2506
Checklist