Pin the prettier toolchain and reformat on upgrade
Prettier's output depends on its version. When prettier-plugin-tailwindcss
went from 0.8.0 to 0.8.1 it started sorting class names differently, which
made all 27 Svelte files in hamer/website count as unformatted - without any
change to package.json, because lockFileMaintenance only touches the lock
file. Nobody noticed until a lint gate was added weeks later.
Two things now guard against that:
rangeStrategy: pin writes the exact version into package.json, so lock
file maintenance can no longer move it unseen and
every bump shows up in the diff
postUpgradeTasks runs `npx prettier --write .` after the upgrade and
commits the result into the same PR
The group is deliberately not automerged. If the bot lacks the command
allowlist the reformatting is skipped silently, and an unattended merge would
reintroduce exactly the drift this is meant to prevent.
postUpgradeTasks only runs when the commands are allowed in the bot itself
via RENOVATE_ALLOWED_COMMANDS. That is a self-hosted setting and is ignored
in repository config; the README documents the value to set.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ghd74zZHdKuvt9pv7Z7Hk
Signed-off-by: Peter Siegmund <peter.siegmund@entwicklung.eq-3.de>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e0fa116ae6
commit
1b8251e324
@@ -25,6 +25,7 @@ In jedem überwachten Repo genügt eine `renovate.json` mit:
|
||||
- CI actions
|
||||
- Lockfile-Maintenance
|
||||
- **Nur gruppiert, kein Automerge:** Svelte-/Frontend-Toolchain, Spring/Kotlin. Diese PRs schaut man sich an.
|
||||
- **Prettier-Toolchain:** `prettier` und `prettier-plugin-*` gruppiert, exakt gepinnt (`rangeStrategy: pin`) und mit automatischer Neuformatierung im selben PR. Siehe unten.
|
||||
- **Major-Updates:** kein PR ohne Freigabe per Checkbox im Dependency Dashboard.
|
||||
|
||||
## Abweichen pro Repo
|
||||
@@ -41,3 +42,20 @@ Alles hinter dem `extends` überschreibt das Preset für dieses eine Repo:
|
||||
## Voraussetzung für Automerge
|
||||
|
||||
Der Renovate-User braucht Merge-Rechte, und die CI-Jobs müssen in der Branch Protection des Ziel-Branches als *required status checks* eingetragen sein. Ohne required checks würde Giteas Auto-Merge sofort mergen, ohne auf CI zu warten.
|
||||
|
||||
## Voraussetzung für die Prettier-Neuformatierung
|
||||
|
||||
Prettiers Ausgabe hängt an der Version. Ein Sprung von `prettier-plugin-tailwindcss` 0.8.0 auf 0.8.1 sortiert Klassen anders und lässt jede Svelte-Datei als unformatiert gelten — ohne dass sich `package.json` ändert, weil `lockFileMaintenance` nur das Lockfile anfasst. Genau das ist im Repo `hamer/website` passiert: 27 Dateien wichen ab, gemerkt hat es niemand, weil dort kein Lint-Gate lief.
|
||||
|
||||
Dagegen wirken zwei Dinge im Preset:
|
||||
|
||||
- `rangeStrategy: "pin"` schreibt die exakte Version in die `package.json`. Damit kann Lockfile-Maintenance sie nicht mehr unbemerkt verschieben, und jeder Sprung ist im Diff sichtbar.
|
||||
- `postUpgradeTasks` lässt Renovate nach dem Upgrade `npx prettier --write .` laufen und die Änderung in denselben PR committen.
|
||||
|
||||
**`postUpgradeTasks` läuft nur, wenn die Kommandos im Bot freigegeben sind.** Das ist eine Self-Hosted-Einstellung und wird in der Repo-Konfiguration ignoriert. Beim Container-Betrieb gehört sie in die Umgebung des Renovate-Containers:
|
||||
|
||||
```yaml
|
||||
- RENOVATE_ALLOWED_COMMANDS=["^npm ci --ignore-scripts$","^npx prettier --write \\.$"]
|
||||
```
|
||||
|
||||
Die Einträge sind reguläre Ausdrücke, gegen die das jeweilige Kommando geprüft wird. Fehlt die Variable, führt Renovate die Kommandos still nicht aus — der PR kommt dann ohne Neuformatierung, und das Lint-Gate im Ziel-Repo schlägt an. Das ist der gewollte Rückfall: lieber ein roter PR als eine unbemerkte Drift.
|
||||
|
||||
@@ -64,6 +64,19 @@
|
||||
],
|
||||
"groupName": "spring + kotlin"
|
||||
},
|
||||
{
|
||||
"description": "Prettier und seine Plugins zusammen und exakt gepinnt. Die Formatierung haengt an der Version: ein Sprung im Lockfile aendert die Ausgabe, ohne dass package.json es zeigt, und das Repo driftet unbemerkt ab. postUpgradeTasks formatiert im selben PR nach.",
|
||||
"matchManagers": ["npm"],
|
||||
"matchPackageNames": ["prettier", "prettier-plugin-**"],
|
||||
"groupName": "prettier toolchain",
|
||||
"rangeStrategy": "pin",
|
||||
"automerge": false,
|
||||
"postUpgradeTasks": {
|
||||
"commands": ["npm ci --ignore-scripts", "npx prettier --write ."],
|
||||
"fileFilters": ["**/*"],
|
||||
"executionMode": "branch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Major-Updates nur nach Freigabe im Dependency Dashboard",
|
||||
"matchUpdateTypes": ["major"],
|
||||
|
||||
Reference in New Issue
Block a user