Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 3c68c3f

Browse files
authored
Package version & readme version (#25)
2 parents 8a10d9f + a790a3e commit 3c68c3f

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Rate limiting utility
2-
![version: 1.2.1](https://img.shields.io/badge/version-1.2.1-%233b82f6)
2+
[![npm](https://img.shields.io/npm/v/cldn-ratelimit)](https://www.npmjs.com/package/cldn-ratelimit)
3+
[![npm downloads](https://img.shields.io/npm/dt/cldn-ratelimit?label=downloads)](https://www.npmjs.com/package/cldn-ratelimit)
34
![test: passing](https://img.shields.io/badge/tests-passing-%2316a34a)
45
![coverage: 100%](https://img.shields.io/badge/coverage-100%25-%2316a34a)
56
![build: passing](https://img.shields.io/badge/build-passing-%2316a34a)
7+
[![CodeQL](https://github.com/cloudnode-pro/ratelimit/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/cloudnode-pro/ratelimit/actions/workflows/github-code-scanning/codeql)
68

79
A relatively simple utility for abstract rate limiting. This library uses memory storage (i.e. does not rely on external database or writing data on your file system). Rate limits are reset if the process is restarted.
810

README.template.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Rate limiting utility
2-
{{shield:version}}
2+
[![npm](https://img.shields.io/npm/v/cldn-ratelimit)](https://www.npmjs.com/package/cldn-ratelimit)
3+
[![npm downloads](https://img.shields.io/npm/dt/cldn-ratelimit?label=downloads)](https://www.npmjs.com/package/cldn-ratelimit)
34
{{shield:tests}}
45
{{shield:coverage}}
56
{{shield:build}}
7+
[![CodeQL](https://github.com/cloudnode-pro/ratelimit/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/cloudnode-pro/ratelimit/actions/workflows/github-code-scanning/codeql)
68

79
A relatively simple utility for abstract rate limiting. This library uses memory storage (i.e. does not rely on external database or writing data on your file system). Rate limits are reset if the process is restarted.
810

package-lock.json

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cldn-ratelimit",
3-
"version": "1.2.2",
3+
"version": "0.0.0-dev",
44
"description": "Simple ratelimiter for Node.js",
55
"main": "lib/RateLimit.js",
66
"type": "module",
@@ -32,7 +32,7 @@
3232
"homepage": "https://github.com/cloudnode-pro/ratelimit#readme",
3333
"devDependencies": {
3434
"c8": "^8.0.1",
35-
"mocha": "^10.0.0"
36-
},
37-
"dependencies": {}
35+
"mocha": "^10.0.0",
36+
"typescript": "^5.2.2"
37+
}
3838
}

scripts/generateReadme.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ import * as child_process from "child_process";
99
const TEMPLATE_FILE = "README.template.md";
1010
const OUTPUT_FILE = "README.md";
1111

12-
/**
13-
* Determine version from package.json
14-
*/
15-
const packageJson = JSON.parse(await fs.readFile("package.json", "utf8"));
16-
const version = packageJson.version;
17-
1812
/**
1913
* Run test and get coverage
2014
*
@@ -30,7 +24,7 @@ const version = packageJson.version;
3024
*
3125
* The coverage percentage is the average of all columns for "All files".
3226
*/
33-
const testsResult = await new Promise((resolve, reject) => {
27+
const testsResult = await new Promise((resolve) => {
3428
const child = child_process.spawn("npm", ["test"]);
3529
const data = [];
3630
child.stdout.on("data", (chunk) => data.push(chunk));
@@ -52,7 +46,7 @@ const coverageColors = ["16a34a", "ca8a04", "f97316", "ef4444", "b91c1c"];
5246
/**
5347
* Determine if the build passes by the exit code of `npm run build`
5448
*/
55-
const buildPass = await new Promise((resolve, reject) => {
49+
const buildPass = await new Promise((resolve) => {
5650
const child = child_process.spawn("npm", ["run", "build"]);
5751
child.on("exit", (code) => resolve(code === 0));
5852
});
@@ -63,7 +57,6 @@ const buildPass = await new Promise((resolve, reject) => {
6357
* {{variable_name}}
6458
*/
6559
const variables = {
66-
"shield:version": `![version: ${version}](https://img.shields.io/badge/version-${version}-%233b82f6)`,
6760
"shield:tests": `![test: ${testsResult.testsPass ? "passing" : "failing"}](https://img.shields.io/badge/tests-${testsResult.testsPass ? "passing" : "failing"}-${testsResult.testsPass ? "%2316a34a" : "%23ef4444"})`,
6861
"shield:coverage": `![coverage: ${testsResult.coverage}%](https://img.shields.io/badge/coverage-${testsResult.coverage}%25-%23${coverageColors.reverse()[Math.floor(testsResult.coverage * (coverageColors.length - 1) / 100)]})`,
6962
"shield:build": `![build: ${buildPass ? "passing" : "failing"}](https://img.shields.io/badge/build-${buildPass ? "passing" : "failing"}-${buildPass ? "%2316a34a" : "%23ef4444"})`,

0 commit comments

Comments
 (0)