Skip to content

Commit 0389ae6

Browse files
committed
Update README badges to reflect new build tool version and enhance README update script
1 parent cab3af3 commit 0389ae6

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Version](https://img.shields.io/npm/v/@eslint-react/eslint-plugin?style=flat&colorA=111111&colorB=000000)](https://npmjs.com/package/@eslint-react/eslint-plugin)
66
[![Downloads](https://img.shields.io/npm/dt/@eslint-react/eslint-plugin.svg?style=flat&colorA=222222&colorB=000000)](https://npmjs.com/package/@eslint-react/eslint-plugin)
77
[![License](https://img.shields.io/npm/l/@eslint-react/eslint-plugin?style=flat&colorA=333333&colorB=000000)](https://npmjs.com/package/@eslint-react/eslint-plugin)
8-
[![Build with](https://img.shields.io/badge/built_with-tsdown@0.16.5-000000?style=flat)](https://tsdown.dev)
8+
[![Build with](https://img.shields.io/badge/built_with-tsdown@0.17.0-beta.5)](https://tsdown.dev)
99

1010
4-7x faster composable ESLint rules for React and friends.
1111

packages/plugins/eslint-plugin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Version](https://img.shields.io/npm/v/@eslint-react/eslint-plugin?style=flat&colorA=111111&colorB=000000)](https://npmjs.com/package/@eslint-react/eslint-plugin)
66
[![Downloads](https://img.shields.io/npm/dt/@eslint-react/eslint-plugin.svg?style=flat&colorA=222222&colorB=000000)](https://npmjs.com/package/@eslint-react/eslint-plugin)
77
[![License](https://img.shields.io/npm/l/@eslint-react/eslint-plugin?style=flat&colorA=333333&colorB=000000)](https://npmjs.com/package/@eslint-react/eslint-plugin)
8-
[![Build with](https://img.shields.io/badge/built_with-tsdown@0.16.5-000000?style=flat)](https://tsdown.dev)
8+
[![Build with](https://img.shields.io/badge/built_with-tsdown@0.17.0-beta.5)](https://tsdown.dev)
99

1010
4-7x faster composable ESLint rules for React and friends.
1111

scripts/update-readme.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as Command from "@effect/platform/Command";
44
import * as CommandExecutor from "@effect/platform/CommandExecutor";
55
import * as FileSystem from "@effect/platform/FileSystem";
66
import * as Effect from "effect/Effect";
7+
import * as Str from "effect/String";
8+
import { P, match } from "ts-pattern";
79

810
const getCurrentBranch = Command.make("git", "branch", "--show-current");
911

@@ -13,21 +15,24 @@ const program = Effect.gen(function*() {
1315
const branch = yield* ce.string(getCurrentBranch);
1416
const source = "README.md";
1517
const destination = "packages/plugins/eslint-plugin/README.md";
16-
// Ensure the destination directory exists
17-
yield* fs.makeDirectory("packages/plugins/eslint-plugin", { recursive: true });
18-
18+
const buildToolVersion = match(JSON.parse(yield* fs.readFileString("package.json", "utf8")))
19+
.with({ devDependencies: { tsdown: P.select(P.string) } }, Str.replace("^", ""))
20+
.otherwise(() => "latest");
1921
const readmeContent = yield* fs.readFileString(source, "utf8");
20-
22+
// dprint-ignore
23+
const readmeContentNew = readmeContent.replace(/built_with-tsdown@.*?\)/g, `built_with-tsdown@${buildToolVersion})`);
2124
// Convert relative links to absolute links
22-
const updatedContent = readmeContent.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, text, url) => {
25+
const readmeContentAbs = readmeContentNew.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, text, url) => {
2326
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("#")) {
2427
return match; // Leave absolute links unchanged
2528
}
2629
const absoluteUrl = `${`https://github.com/Rel1cx/eslint-react/tree/${branch.trim()}`}/${url.replace(/^\.\//, "")}`;
2730
return `[${text}](${absoluteUrl})`;
2831
});
29-
30-
yield* fs.writeFileString(destination, updatedContent);
32+
// Ensure the destination directory exists
33+
yield* fs.makeDirectory("packages/plugins/eslint-plugin", { recursive: true });
34+
yield* fs.writeFileString(source, readmeContentNew);
35+
yield* fs.writeFileString(destination, readmeContentAbs);
3136
yield* Effect.log(`Updated ${destination} from ${source}`);
3237
});
3338

0 commit comments

Comments
 (0)