fix(cli): make 'lingo.dev lockfile' additively populate missing sections#2093
fix(cli): make 'lingo.dev lockfile' additively populate missing sections#2093cherkanovart wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe PR implements additive merge behavior for ChangesLockfile Additive Merge Behavior
🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Builds on #2091. PR #2091 patched the
--frozenfalse-positive only for the narrow case where a no-oplingo.dev runprecedes--frozen. This PR closes the remaining cases by changinglingo.dev lockfilefrom a bail-out into the actual recovery command, and by updating--frozenerrors to point users at it.Failure scenarios this closes (that #2091 left open)
**recursive glob → newpathPattern→ no lock section.i18n.json.--target-locale(execute.ts gatessaveChecksumson!flags.targetLocale?.length).i18n.lockwithchecksums: {}(or any section that exists but is empty).All four funnel through the same throw at
frozen.ts:127–131becauseloadChecksumsreturns{}for a missing section and every key insrccompares unequal toundefined.Behavior change:
lingo.dev lockfileWithout
--force:getBuckets(i18nConfig).bucketConfig.pathPattern, checkMD5(pathPattern)against the lock'schecksumsmap.--frozenrelies on).registerSourceData(full-section write).--forceretains the previous full-rebuild semantics.Per-path stdout:
added,skipped (already populated),replaced (--force), plus a summary line.A new public method
hasSourceData(pathPattern: string): booleanwas added tocreateLockfileHelper()to expose the section-presence check cleanly.registerPartialSourceDatais deliberately not used — its_.mergewould overwrite individual checksums in a non-empty section and re-introduce the masking risk (a source value flip"Sasha"→"Petr"would silently get re-baselined). The whole point of this design is that any non-empty section is load-bearing and only--forcemay touch it.Error-message update:
frozen.tsAll four throws (lines 129/147/157/167) now read:
The existing
Details: …suffixes are unchanged.Why not auto-heal inside
--frozen?I considered self-healing inside
frozen.ts(initialize missing sections automatically). Rejected because:--frozenfrom "strict no-drift validation" to "validate, but auto-fill missing entries" — out of line withnpm ci,yarn --immutable,cargo --locked,bundler --frozen.The explicit "run a command, commit the lock" flow has no analogous failure mode and matches user expectations for a lockfile-based tool.
Test plan
src/cli/utils/lockfile.test.ts— 4hasSourceDatatests (absent lock, absent section, empty section, populated section).src/cli/cmd/lockfile.spec.ts— 5 integration scenarios:checksums: {}) → section created.--frozenstill throws the divergence signal).--forceregression guard: existing section fully rebuilt.**recursive glob: 2 files run, add 3rd, run again — only the 3rd section is added; first two byte-identical.pnpm testinpackages/cli/: Test Files 55 passed (55) | Tests 886 passed (886).Follow-ups (intentionally not in this PR)
delta.ts:104–112andlockfile.ts:72–78rewrite the lock during a read whendeduplicateLockfileYamlfinds duplicates — so--frozenisn't actually read-only today. Worth a separate PR to skip the rewrite from--frozen, and to harden the YAML round-trip (parseDocument → toJSON → new Document → toString) against translation keys that look like YAML specials (yes/no, ISO dates, numbers).lingo.dev run --frozen --healto inline the merge step before validation. Hold until there's user demand; the two-command flow is the default we want.Summary by CodeRabbit
Release Notes
New Features
--forcestill rebuilds entirely.Bug Fixes
--frozenvalidation failures with wildcard path patterns and empty sections.--frozenerror messages to guide users to the recovery command.Tests