From 662ad4a95e36a6eca88ada225f93e8be99d0f3c7 Mon Sep 17 00:00:00 2001 From: Javier Tinoco <213990346+javiert-okta@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:12:29 -0500 Subject: [PATCH 1/6] add script to update stars count on libraries json file --- scripts/updateStars.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/updateStars.js diff --git a/scripts/updateStars.js b/scripts/updateStars.js new file mode 100644 index 00000000..3b456edc --- /dev/null +++ b/scripts/updateStars.js @@ -0,0 +1,36 @@ +import fs from "fs" +import path from "path" + +const filePath = path.join(process.cwd(), "/scripts/example-repos.json") +const reposGroup = JSON.parse(fs.readFileSync(filePath, "utf-8")) + +async function getStars(repoUrl) { + const match = repoUrl.match(/github\.com\/([^/]+)\/([^/]+)(?:\/|$)/) + if(!match) throw new Error(`Invalid github repo URL: ${repoUrl}`) + const [, owner, repo] = match + const res = await fetch(`https://api.github.com/repos/${owner}/${repo}`, { + headers: { + Accept: "application/vnd.github+json" + } + }) + if(!res.ok) throw new Error(`${repoUrl} -> ${res.status} ${res.statusText}`) + const data = await res.json() + return data.stargazers_count ?? null +} + +(async () => { + const objectEntries = Object.values(reposGroup) + for(const group of objectEntries) { + for(const lib of group.libs) { + try { + const stars = await getStars(lib.repoUrl) + lib.stars = stars + console.log(`✅ ${lib.repoUrl} -> ${stars}`) + } catch(e) { + lib.stars = null + console.error(`❌ ${lib.repoUrl}: ${e.message}`) + } + } + } + fs.writeFileSync(filePath, JSON.stringify(reposGroup, null, 2) + "\n") +})() \ No newline at end of file From ec80a65a4b70565e4c49708c4d0aee65b5fcce18 Mon Sep 17 00:00:00 2001 From: Javier Tinoco <213990346+javiert-okta@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:13:33 -0500 Subject: [PATCH 2/6] add example file to test script --- scripts/example-repos.json | 158 +++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 scripts/example-repos.json diff --git a/scripts/example-repos.json b/scripts/example-repos.json new file mode 100644 index 00000000..8c244f47 --- /dev/null +++ b/scripts/example-repos.json @@ -0,0 +1,158 @@ +{ + "dot-net": { + "id": "dot-net", + "name": ".NET", + "uniqueClass": "net", + "image": "/img/1.svg", + "bgColor": "rgb(42, 168, 229)", + "libs": [ + { + "minimumVersion": null, + "support": { + "sign": true, + "verify": true, + "iss": true, + "sub": true, + "aud": true, + "exp": true, + "nbf": true, + "iat": true, + "jti": true, + "hs256": true, + "hs384": true, + "hs512": true, + "rs256": true, + "rs384": true, + "rs512": true, + "es256": true, + "es384": true, + "es512": true, + "ps256": true, + "ps384": true, + "ps512": true + }, + "authorUrl": "https://www.microsoft.com", + "authorName": "Microsoft", + "gitHubRepoPath": "AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet", + "repoUrl": "https://github.com/MSOpenTech/azure-activedirectory-identitymodel-extensions-for-dotnet", + "installCommandMarkdown": [ + "Install-Package", + "[System.IdentityModel.Tokens.Jwt](https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/)" + ], + "stars": 1115 + }, + { + "minimumVersion": null, + "support": { + "sign": true, + "verify": true, + "iss": true, + "sub": true, + "aud": true, + "exp": true, + "nbf": true, + "iat": true, + "jti": false, + "hs256": true, + "hs384": true, + "hs512": true, + "rs256": true, + "rs384": true, + "rs512": true, + "es256": true, + "es384": true, + "es512": true, + "ps256": false, + "ps384": false, + "ps512": false + }, + "authorUrl": "https://github.com/jwt-dotnet/jwt", + "authorName": "Alexander Batishchev", + "gitHubRepoPath": "jwt-dotnet/jwt", + "repoUrl": "https://github.com/jwt-dotnet/jwt", + "installCommandMarkdown": [ + "Install-Package", + "[JWT.NET](https://www.nuget.org/packages/JWT)" + ], + "stars": 2109 + } + ] + }, + "swift": { + "id": "swift", + "name": "Swift", + "uniqueClass": "swift", + "image": "/img/15.svg", + "bgColor": "rgb(234, 45, 46)", + "libs": [ + { + "minimumVersion": null, + "support": { + "sign": true, + "verify": true, + "iss": true, + "sub": false, + "aud": true, + "exp": true, + "nbf": true, + "iat": true, + "jti": false, + "hs256": true, + "hs384": true, + "hs512": true, + "rs256": false, + "rs384": false, + "rs512": false, + "es256": false, + "es384": false, + "es512": false, + "ps256": false, + "ps384": false, + "ps512": false + }, + "authorUrl": "https://github.com/kylef", + "authorName": "Kyle Fuller", + "gitHubRepoPath": "kylef/JSONWebToken.swift", + "repoUrl": "https://github.com/kylef/JSONWebToken.swift", + "installCommandMarkdown": [ + "pod 'JSONWebToken'" + ], + "stars": 751 + }, + { + "minimumVersion": null, + "support": { + "sign": true, + "verify": true, + "iss": true, + "sub": true, + "aud": true, + "exp": true, + "nbf": true, + "iat": true, + "jti": true, + "hs256": true, + "hs384": true, + "hs512": true, + "rs256": true, + "rs384": true, + "rs512": true, + "es256": true, + "es384": true, + "es512": true, + "ps256": false, + "ps384": false, + "ps512": false + }, + "authorUrl": "https://github.com/vapor", + "authorName": "Vapor", + "gitHubRepoPath": "vapor/jwt-kit", + "repoUrl": "https://github.com/vapor/jwt-kit", + "installCommandMarkdown": [ + ".package(url: \"https://github.com/vapor/jwt-kit.git\", from: \"4.0.0\")" + ], + "stars": 250 + } + ] + } +} From 21f0498988e14238e3b2925febe31bf2847e047c Mon Sep 17 00:00:00 2001 From: Javier Tinoco <213990346+javiert-okta@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:13:46 -0500 Subject: [PATCH 3/6] add action to update file (test) --- .github/workflows/update-libraries.yaml | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/update-libraries.yaml diff --git a/.github/workflows/update-libraries.yaml b/.github/workflows/update-libraries.yaml new file mode 100644 index 00000000..ce1303db --- /dev/null +++ b/.github/workflows/update-libraries.yaml @@ -0,0 +1,36 @@ +name: Update libraries stars count (test) +on: + push: + branches: [stars-ci-test] + workflow_dispatch: + + +jobs: + update-stars: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install dependencies + run: npm install node-fetch@2 + - name: Update stars in libraries-next.json + run: node scripts/updateStars.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Commit and push changes + run: | + git config --global user.name 'javier-okta' + git config --global user.email 'javiersebastian.tinocomachado@okta.com' + git add . + git commit -m "chore: update stars count [skip ci]" || echo "No changes to commit" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 791d2a4e645ca3fa6d7200a1e7a60417d7d59580 Mon Sep 17 00:00:00 2001 From: Javier Tinoco <213990346+javiert-okta@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:32:05 -0500 Subject: [PATCH 4/6] fix user name --- .github/workflows/update-libraries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-libraries.yaml b/.github/workflows/update-libraries.yaml index ce1303db..44bec59e 100644 --- a/.github/workflows/update-libraries.yaml +++ b/.github/workflows/update-libraries.yaml @@ -27,7 +27,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Commit and push changes run: | - git config --global user.name 'javier-okta' + git config --global user.name 'javiert-okta' git config --global user.email 'javiersebastian.tinocomachado@okta.com' git add . git commit -m "chore: update stars count [skip ci]" || echo "No changes to commit" From 5a1342710ce4e3e343644c6c1db5c9e354686c3f Mon Sep 17 00:00:00 2001 From: Javier Tinoco <213990346+javiert-okta@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:38:37 -0500 Subject: [PATCH 5/6] persist credentials --- .github/workflows/update-libraries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-libraries.yaml b/.github/workflows/update-libraries.yaml index 44bec59e..fa72e192 100644 --- a/.github/workflows/update-libraries.yaml +++ b/.github/workflows/update-libraries.yaml @@ -14,7 +14,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 with: - persist-credentials: false + persist-credentials: true - name: Setup Node.js uses: actions/setup-node@v4 with: From 434d09f86d0e2ee9a540363415b22a2fe06f23a8 Mon Sep 17 00:00:00 2001 From: javiert-okta Date: Thu, 14 Aug 2025 15:39:10 +0000 Subject: [PATCH 6/6] chore: update stars count [skip ci] --- package-lock.json | 43 ++++++++++++++++++++++++++++++++++++++ package.json | 1 + scripts/example-repos.json | 6 +++--- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f6f42523..76c36e9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "negotiator": "^1.0.0", "neverthrow": "^8.1.1", "next": "^14.2.25", + "node-fetch": "^2.7.0", "node-forge": "^1.3.1", "octokit": "^4.0.2", "prismjs": "^1.29.0", @@ -11377,6 +11378,26 @@ "tslib": "^2.0.3" } }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -13476,6 +13497,12 @@ "node": ">=8.0" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, "node_modules/trim-lines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", @@ -14601,6 +14628,22 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 3ba940b8..a62dbe55 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "negotiator": "^1.0.0", "neverthrow": "^8.1.1", "next": "^14.2.25", + "node-fetch": "^2.7.0", "node-forge": "^1.3.1", "octokit": "^4.0.2", "prismjs": "^1.29.0", diff --git a/scripts/example-repos.json b/scripts/example-repos.json index 8c244f47..1396e8ad 100644 --- a/scripts/example-repos.json +++ b/scripts/example-repos.json @@ -74,7 +74,7 @@ "Install-Package", "[JWT.NET](https://www.nuget.org/packages/JWT)" ], - "stars": 2109 + "stars": 2175 } ] }, @@ -117,7 +117,7 @@ "installCommandMarkdown": [ "pod 'JSONWebToken'" ], - "stars": 751 + "stars": 758 }, { "minimumVersion": null, @@ -151,7 +151,7 @@ "installCommandMarkdown": [ ".package(url: \"https://github.com/vapor/jwt-kit.git\", from: \"4.0.0\")" ], - "stars": 250 + "stars": 252 } ] }