-
Notifications
You must be signed in to change notification settings - Fork 6
fix: disable Renovate updates for sync-generated examples #1843
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
Merged
+133
−37
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7cab723
fix: disable Renovate updates for sync-generated examples
yamcodes 393d2c9
fix: disable sync-generated example Renovate churn
yamcodes d48d38e
fix: derive Renovate example exclusions from metadata
yamcodes a572b7d
fix: satisfy autofix formatting
yamcodes 9a0c18c
docs: clarify Renovate example ownership
yamcodes 2479659
fix: always trailing-comma Renovate generated matchFileNames
cursoragent 7c7db49
fix: commit renovate.json in examples auto-sync
cursoragent ed4f5ce
fix: allow trailing commas in Renovate JSONC for Biome
cursoragent 8070d96
fix: omit trailing comma in generated renovate entries
yamcodes 4350775
fix: keep generated Renovate entries formatter-compatible
yamcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { readFileSync, writeFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { ROOT_DIR } from "./constants.js"; | ||
|
|
||
| const RENOVATE_CONFIG_PATH = join(ROOT_DIR, ".github", "renovate.json"); | ||
| const START_MARKER = "// BEGIN GENERATED SYNC EXAMPLES"; | ||
| const END_MARKER = "// END GENERATED SYNC EXAMPLES"; | ||
|
|
||
| /** | ||
| * Emit every generated `matchFileNames` entry with a trailing comma so the | ||
| * marker region stays self-contained JSONC whether or not hand-written entries | ||
| * follow the END marker before the closing `]`. | ||
| * | ||
| * @param {string[]} exampleNames | ||
| */ | ||
| export function generatedMatchFileNames(exampleNames) { | ||
| return [ | ||
| `\t\t\t\t${START_MARKER}`, | ||
| ...exampleNames.map((name) => `\t\t\t\t"examples/${name}/**",`), | ||
| `\t\t\t\t${END_MARKER}`, | ||
| ].join("\n"); | ||
| } | ||
|
|
||
| /** | ||
| * Keep Renovate's generated-example exclusion in sync with playground metadata. | ||
| */ | ||
| export function syncRenovateConfig(exampleNames, checkOnly = false) { | ||
| const content = readFileSync(RENOVATE_CONFIG_PATH, "utf8"); | ||
| const markerStart = content.indexOf(START_MARKER); | ||
| const start = content.lastIndexOf("\n", markerStart) + 1; | ||
| const end = content.indexOf(END_MARKER); | ||
|
|
||
| if (markerStart === -1 || end === -1 || end < start) { | ||
| throw new Error( | ||
| `Renovate config must contain ${START_MARKER} and ${END_MARKER}`, | ||
| ); | ||
| } | ||
|
|
||
| const generated = generatedMatchFileNames([...new Set(exampleNames)].sort()); | ||
| const current = content.slice(start, end + END_MARKER.length); | ||
| const updated = | ||
| content.slice(0, start) + | ||
| generated + | ||
| content.slice(end + END_MARKER.length); | ||
|
|
||
| if (checkOnly) { | ||
| return current !== generated; | ||
| } | ||
|
|
||
| if (current !== generated) { | ||
| writeFileSync(RENOVATE_CONFIG_PATH, updated); | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { generatedMatchFileNames } from "./renovate.js"; | ||
|
|
||
| describe("generatedMatchFileNames", () => { | ||
| it("always trailing-commas generated entries so the region is self-contained", () => { | ||
| const block = generatedMatchFileNames(["basic", "with-vite-react"]); | ||
| const entries = block | ||
| .split("\n") | ||
| .map((line) => line.trim()) | ||
| .filter((line) => line.startsWith('"examples/')); | ||
|
|
||
| expect(entries).toEqual([ | ||
| '"examples/basic/**",', | ||
| '"examples/with-vite-react/**",', | ||
| ]); | ||
| }); | ||
|
|
||
| it("trailing-commas a single generated entry", () => { | ||
| const block = generatedMatchFileNames(["basic"]); | ||
| expect(block).toContain('"examples/basic/**",'); | ||
| expect(block).not.toMatch(/"examples\/basic\/\*\*"\n/); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.