Commit c14c70c
fix(cli): make
`os i18n extract --check` printed a "Regenerate and commit" command assembled at
the print site from four things that happened to be in scope: the config
argument, the emitted locales minus the default one, `--fill` and `--out`. Every
other flag the operator passed was not in the expression, so it was not in the
advice. Driven on the reported invocation against a stack whose
`i18n.defaultLocale` is `zh-CN`:
$ os i18n extract objectstack.config.ts --locales=zh-CN --no-metadata-forms
--no-objects-only --filter=kpi_ --out=OUT --check
missing: ../../../../../tmp/os-i18n-repro-jNrZ/zh-CN.objects.generated.ts
Translation bundles have drifted from the schema. Regenerate and commit:
os i18n extract objectstack.config.ts --locales= --fill=empty --out=OUT
Three defects, each measured before the repair:
* `--locales=` came out EMPTY. The echo drops the default locale on the
grounds that `--locales` always re-adds it, and here the only locale asked
for WAS the default one. The `Skeleton summary` two lines up names `zh-CN`,
so one code path had the locale and the other did not.
* `--no-metadata-forms`, `--no-objects-only` and `--filter=kpi_` were never
candidates for the line. Running what it printed wrote 775 keys across two
files where the operator's own command writes 2 across one — including a
`metadata-forms` companion they had explicitly switched off.
* `missing:` printed a `../../../../../…` walk out of the cwd for a directory
the operator had just typed in full.
The second one is what it costs. A failing `--check` is self-healable in one
step; following the printed advice emitted a different key set, so the next
`--check` failed AGAIN — on `out of date:` rather than `missing:` — and printed
the same wrong command. Both halves driven end to end.
The hint is now a DELETION, never an assembly: this run's own argv (`this.argv`,
verified to hold the arguments as typed with the command id stripped) with the
`--check` token removed, shell-quoted so it survives a copy, and `--` honoured
so a positional `--check` is left alone. Nothing enumerates flags, so a flag
added to this command later is echoed without anyone remembering this print
site — which is the property the assembled expression could not have. When
`--check` is not in the argv the command cannot point at what it removed and
prints "re-run the same command without `--check`" instead, the degraded line
the report asked for; today's flag surface has no other way to set `--check`
(no `env`, no default, no `allowNo`), so that branch is defence rather than a
reachable path, and it is what keeps an approximation from ever becoming the
fallback.
Diagnostic paths are printed absolute once the cwd cannot reach them downwards,
and keep the short relative form otherwise. That covers `Wrote` as well as
`missing:` / `out of date:`: it is the same `path.relative(process.cwd(), file)`
expression, in the same function, with the same symptom — the repro's write leg
printed `Wrote ../../../../../tmp/os-i18n-repro-jNrZ/…` — and repairing the
`--check` half alone would have left the two lines disagreeing. All nine of this
repo's extract configs write in-tree and their output is unchanged.
The pin drives the real CLI. Its central case asserts the WHOLE token list
rather than probing for `--filter` and `--no-objects-only` by name, because a
name-probing pin inherits exactly the blind spot being closed: it would be green
for the next flag added. Its second case is the loop itself — the printed line
is executed VERBATIM through `sh -c`, with an `os` shim on `PATH` in front of
the source entry point, and the original `--check` must then pass. No
approximate command can satisfy that one, and quoting is exercised for real by a
case whose `--filter` value carries a `|`.
Fixes #14895
Claude-Session: https://claude.ai/code/session_01D47qPfEWVPmhguWgBZCi5N
Co-authored-by: Claude <noreply@anthropic.com>i18n extract --check's regenerate hint the invocation it was given (#16470)1 parent ce8caba commit c14c70c
3 files changed
Lines changed: 415 additions & 8 deletions
File tree
- .changeset
- packages/cli
- src/commands/i18n
- test
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
34 | 135 | | |
35 | 136 | | |
36 | 137 | | |
| |||
471 | 572 | | |
472 | 573 | | |
473 | 574 | | |
474 | | - | |
475 | | - | |
476 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
477 | 578 | | |
478 | 579 | | |
479 | 580 | | |
480 | 581 | | |
481 | 582 | | |
482 | 583 | | |
483 | | - | |
484 | | - | |
| 584 | + | |
| 585 | + | |
485 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
486 | 593 | | |
487 | 594 | | |
488 | | - | |
489 | | - | |
| 595 | + | |
490 | 596 | | |
491 | 597 | | |
492 | 598 | | |
| |||
496 | 602 | | |
497 | 603 | | |
498 | 604 | | |
499 | | - | |
| 605 | + | |
500 | 606 | | |
501 | 607 | | |
502 | 608 | | |
| |||
0 commit comments